Skip to content

Latest commit

 

History

History
86 lines (60 loc) · 2.66 KB

File metadata and controls

86 lines (60 loc) · 2.66 KB

AGENTS Guidelines for This Repository

This repository contains a sample code and a starter template to illustrate interoperability between C++/WebAssembly and TypeScript. It is structured as a monorepo.

Do

  • Implement heavy computations and business logic in an appropriate C++ library or create new
  • For interfacing with TS code declare emscripten bindings in a corresponding .embind.cpp file
  • Minimize data exchange between C++ WebAssembly and TS

Don't

  • Do not hard code colors

Commands

npm run tsc:sample --noEmit path/to/file.tsx
npm run format:sample --write path/to/file.tsx
npm run lint:sample --fix path/to/file.tsx
npm run build:native
npm run dev
  • tests
npm run test
  • full build when explicitly requested
npm run build

Code style

  • TypeScript strict mode
  • Use functional patterns where possible

Safety and permissions

Allowed without prompt:

  • read files, list files
  • single file prettier and eslint
  • tsc, build, test

Ask first:

  • package installs
  • git push
  • deleting files, chmod
  • running full build or end to end suites

Project Structure

native: C++/CMake sources and wasm build scripts (Emscripten)
native/libs/NlpLib: A C++ library with NLP and text processing classes.
packages: TypeScript client and server node applications and tests
packages/sample: Example TypeScript application which consumes WebAssembly
packages/tests: Tests of functionality of the WebAssembly from typescript

native

  • Primary Responsibility: Root of C++/CMake libraries and wasm build scripts (Emscripten)
  • Interaction Pattern: The native code is compiled into WebAssembly using Emscripten. The resulting .wasm file is then used by the TypeScript consumer via a generated WebassemblyTemplate.js. New libraries can be added to libs folder and add_subdirectory to the root CMakeLists.txt.
  • Dependencies: Catch2 for native unit tests
  • Output: A .wasm file that can be consumed by the TypeScript consumer.

packages/sample

  • Primary Responsibility: Example TypeScript consumer
  • Interaction Pattern: The TypeScript consumer loads the .wasm file generated by the native code and uses it to perform operations.
  • Dependencies: The native code must be compiled into WebAssembly using Emscripten.
  • Output: A TypeScript application that uses the WebAssembly module.

packages/tests

  • Primary Responsibility: Tests of WebAssembly classes from a TS client
  • Interaction Pattern: The tests are used to test the native code from the TypeScript consumer.
  • Dependencies: The native code must be compiled into WebAssembly using Emscripten.
  • Output: Test results and CI reports.