Bundle language tools with CodeMirror package
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { rmSync, writeFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
const wasmDir = resolve(import.meta.dirname, '../../../packages/decodal-codemirror/wasm');
|
||||
|
||||
rmSync(resolve(wasmDir, 'README.md'), { force: true });
|
||||
rmSync(resolve(wasmDir, 'package.json'), { force: true });
|
||||
|
||||
writeFileSync(
|
||||
resolve(wasmDir, '.gitignore'),
|
||||
'# wasm-pack output is committed as part of decodal-codemirror.\n',
|
||||
);
|
||||
@@ -1,76 +0,0 @@
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
const packageDir = resolve(import.meta.dirname, '../../../packages/decodal-language-tools');
|
||||
|
||||
writeFileSync(
|
||||
resolve(packageDir, '.gitignore'),
|
||||
'# wasm-pack output is committed for the browser language tools package.\n',
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
resolve(packageDir, 'README.md'),
|
||||
`# decodal-language-tools
|
||||
|
||||
Source-level language tooling for Decodal.
|
||||
|
||||
This package is generated from the Rust crate in \`crates/decodal-language-tools\` with \`wasm-pack\`.
|
||||
It currently exposes a comment-preserving formatter that is shared by the official playground and future editor/LSP tooling.
|
||||
|
||||
Use \`decodal-codemirror\` separately when you need CodeMirror 6 language support.
|
||||
Use \`decodal-wasm\` separately when you need to evaluate Decodal in a browser.
|
||||
|
||||
## Install
|
||||
|
||||
\`\`\`sh
|
||||
npm install decodal-language-tools
|
||||
\`\`\`
|
||||
|
||||
JSR:
|
||||
|
||||
\`\`\`sh
|
||||
deno add jsr:@hare/decodal-language-tools
|
||||
\`\`\`
|
||||
|
||||
## Usage
|
||||
|
||||
\`\`\`js
|
||||
import init, { formatSource } from 'decodal-language-tools';
|
||||
|
||||
await init();
|
||||
|
||||
const result = JSON.parse(formatSource('Server={# host\\nhost=String default "localhost";};'));
|
||||
|
||||
if (result.ok) {
|
||||
console.log(result.source);
|
||||
} else {
|
||||
console.error(result.error);
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
The exported functions return JSON strings so callers can handle diagnostics without depending on Rust data structures.
|
||||
`,
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
resolve(packageDir, 'jsr.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: '@hare/decodal-language-tools',
|
||||
version: '0.1.2',
|
||||
license: 'MIT',
|
||||
exports: './decodal_language_tools.js',
|
||||
publish: {
|
||||
include: [
|
||||
'README.md',
|
||||
'decodal_language_tools.js',
|
||||
'decodal_language_tools.d.ts',
|
||||
'decodal_language_tools_bg.wasm',
|
||||
'package.json',
|
||||
],
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + '\n',
|
||||
);
|
||||
Reference in New Issue
Block a user