Toolverse
All skills

implementing-jsc-classes-zig

by oven-sh

Creates JavaScript classes using Bun's Zig bindings generator (.classes.ts). Use when implementing new JS APIs in Zig with JSC integration.

Installation

Pick a client and clone the repository into its skills directory.

Installation

Quick info

Author
oven-sh
Category
Frontend
Views
6

About this skill

Creates JavaScript classes using Bun's Zig bindings generator (.classes.ts). Use when implementing new JS APIs in Zig with JSC integration.

How to use

  1. Utwórz plik .classes.ts w swoim projekcie Bun, w którym zdefiniujesz strukturę klasy JavaScript. Użyj funkcji define() z opcjami takimi jak name (nazwa klasy), constructor (czy ma publiczny konstruktor), proto (właściwości i metody), finalize (czy wymaga czyszczenia zasobów) i cache (czy cachować wartości właściwości).

  2. W pliku .zig zaimplementuj strukturę odpowiadającą zdefiniowanej klasie. Dodaj pole js wskazujące na wygenerowany kod JSC.Codegen, oraz funkcje toJS, fromJS i fromJSDirect do konwersji między Zig a JavaScript.

  3. Zaimplementuj funkcję constructor w Zig, która przyjmuje globalObject i callFrame, inicjalizuje strukturę i zwraca instancję. Ta funkcja będzie wywoływana gdy użytkownik tworzy nową instancję klasy w JavaScript.

  4. Dla każdej metody zdefiniowanej w proto dodaj odpowiadającą jej funkcję w strukturze Zig. Każda metoda powinna przyjmować this (instancję), globalObject i callFrame, a zwracać JSC.JSValue lub bun.JSError.

  5. Dla właściwości z opcją getter zaimplementuj funkcję getPropertyName w Zig, która zwraca JSC.JSValue. Jeśli ustawiłeś cache: true, wartość będzie automatycznie cachowana przez WriteBarrier.

  6. Generator automatycznie tworzy kod C++/Zig łączący definicję .classes.ts z implementacją Zig — nie musisz ręcznie pisać kodu integracyjnego. Skompiluj projekt, a Twoja klasa będzie dostępna w JavaScript z pełnym wsparciem dla konstruktora, metod i getterów.

Related skills

markitdown

by K-Dense-AI

Convert various file formats (PDF, Office documents, images, audio, web content, structured data) to Markdown optimized for LLM processing. Use when converting documents to markdown, extracting text from PDFs/Office files, transcribing audio, performing OCR on images, extracting

Frontend
75173

keyword-research

by openclaw

Discovers high-value keywords with search intent analysis, difficulty assessment, and content opportunity mapping. Essential for starting any SEO or GEO content strategy.

Frontend
24138

landing-page-guide-v2

by bear2u

Create distinctive, high-converting landing pages that combine proven conversion elements with exceptional design quality. Build beautiful, memorable landing pages using Next.js 14+ and ShadCN UI that avoid generic AI aesthetics while following the 11 essential elements

Frontend
3486

browser-automation

by browserbase

Automate web browser interactions using natural language via CLI commands. Use when the user asks to browse websites, navigate web pages, extract data from websites, take screenshots, fill forms, click buttons, or interact with web applications. Triggers include \

Frontend
21175

interactive-dashboard-builder

by anthropics

Build self-contained interactive HTML dashboards with Chart.js, dropdown filters, and professional styling. Use when creating dashboards, building interactive reports, or generating shareable HTML files with charts and filters that work without a server.

Frontend
2298

react

by lobehub

React component development guide. Use when working with React components (.tsx files), creating UI, using @lobehub/ui components, implementing routing, or building frontend features. Triggers on React component creation, modification, layout implementation, or navigation tasks.

Frontend
2058