Improve JSR package metadata

This commit is contained in:
2026-07-10 04:19:00 +09:00
parent 8eac5c5cb4
commit fc1f3e0b25
10 changed files with 213 additions and 19 deletions
+2 -5
View File
@@ -26,11 +26,8 @@ import init, { evaluateProject } from 'decodal-wasm';
await init();
const result = evaluateProject(JSON.stringify({
entry: 'main.dcdl',
files: {
'main.dcdl': 'Server = { port = Int default 8080; };',
},
const result = evaluateProject('main.dcdl', JSON.stringify({
'main.dcdl': 'Server = { port = Int default 8080; };',
}));
console.log(JSON.parse(result));
+3 -2
View File
@@ -1,11 +1,12 @@
{
"name": "@hare/decodal-wasm",
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"exports": "./decodal_wasm.js",
"exports": "./mod.ts",
"publish": {
"include": [
"README.md",
"mod.ts",
"decodal_wasm.js",
"decodal_wasm.d.ts",
"decodal_wasm_bg.wasm",
+66
View File
@@ -0,0 +1,66 @@
/**
* Browser and JavaScript runtime bindings for the Decodal evaluator.
*
* This module wraps the wasm-bindgen output generated from the Rust
* `decodal-wasm` crate and exposes stable, documented entrypoints for JSR
* users. The exported evaluator functions return JSON strings.
*
* @module
*/
import initWasm, {
evaluate as evaluateImpl,
evaluateProject as evaluateProjectImpl,
initSync as initSyncImpl,
} from './decodal_wasm.js';
/** Input accepted by the wasm-bindgen initializer. */
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
/** Initialized Decodal WebAssembly exports. */
export interface InitOutput {
/** Linear memory exported by the WebAssembly module. */
readonly memory: WebAssembly.Memory;
readonly evaluate: (source: number, len: number) => [number, number, number, number];
readonly evaluateProject: (entry: number, entryLen: number, files: number, filesLen: number) => [number, number, number, number];
}
/**
* Initialize the Decodal WebAssembly runtime asynchronously.
*
* @param moduleOrPath - Optional WebAssembly module, bytes, response, URL, or request.
* @returns The initialized WebAssembly exports.
*/
export default async function initDecodalRuntime(moduleOrPath?: InitInput): Promise<InitOutput> {
return await initWasm(moduleOrPath) as InitOutput;
}
/**
* Initialize the Decodal WebAssembly runtime synchronously.
*
* @param module - Compiled module, bytes, or wasm-bindgen sync initialization input.
* @returns The initialized WebAssembly exports.
*/
export function initSync(module: WebAssembly.Module | BufferSource): InitOutput {
return initSyncImpl(module) as InitOutput;
}
/**
* Evaluate and materialize a single Decodal source string.
*
* @param source - Decodal source text.
* @returns A JSON string containing either `{ ok: true, output }` or `{ ok: false, error }`.
*/
export function evaluate(source: string): string {
return evaluateImpl(source);
}
/**
* Evaluate and materialize a virtual multi-file Decodal project.
*
* @param entry - Entry point file path to materialize.
* @param filesJson - JSON object mapping virtual file paths to source strings.
* @returns A JSON string containing either `{ ok: true, output }` or `{ ok: false, error }`.
*/
export function evaluateProject(entry: string, filesJson: string): string {
return evaluateProjectImpl(entry, filesJson);
}
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "decodal-wasm",
"type": "module",
"description": "WebAssembly wrapper for evaluating Decodal in browser playgrounds.",
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT OR Apache-2.0",
"repository": {
"type": "git",