@tabnas/abnf 0.4.20 → 0.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":";AAAA,2EAA2E;;QAylDzE,SAAS;AAxkDX,MAAM,WAAW,GAAqB,MAAM,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDX;IACC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ts","../src/bin/tabnas-abnf-cli.ts"],"packageJsons":["../node_modules/@tabnas/bnf/package.json","../node_modules/@tabnas/parser/package.json","../node_modules/@types/node/package.json","../node_modules/undici-types/package.json","../package.json"],"missingPackageJsons":["../node_modules/@tabnas/bnf/dist/package.json","../node_modules/@tabnas/parser/dist/package.json","../node_modules/@types/assert/package.json","../node_modules/@types/assert/strict/package.json","../node_modules/@types/async_hooks/package.json","../node_modules/@types/buffer/package.json","../node_modules/@types/child_process/package.json","../node_modules/@types/cluster/package.json","../node_modules/@types/console/package.json","../node_modules/@types/constants/package.json","../node_modules/@types/crypto/package.json","../node_modules/@types/dgram/package.json","../node_modules/@types/diagnostics_channel/package.json","../node_modules/@types/dns/package.json","../node_modules/@types/dns/promises/package.json","../node_modules/@types/domain/package.json","../node_modules/@types/events/package.json","../node_modules/@types/fs/package.json","../node_modules/@types/fs/promises/package.json","../node_modules/@types/http/package.json","../node_modules/@types/http2/package.json","../node_modules/@types/https/package.json","../node_modules/@types/inspector/package.json","../node_modules/@types/inspector/promises/package.json","../node_modules/@types/module/package.json","../node_modules/@types/net/package.json","../node_modules/@types/node/assert/package.json","../node_modules/@types/node/dns/package.json","../node_modules/@types/node/fs/package.json","../node_modules/@types/node/inspector/package.json","../node_modules/@types/node/path/package.json","../node_modules/@types/node/readline/package.json","../node_modules/@types/node/stream/package.json","../node_modules/@types/node/test/package.json","../node_modules/@types/node/timers/package.json","../node_modules/@types/node/util/package.json","../node_modules/@types/node/web-globals/package.json","../node_modules/@types/node/zlib/package.json","../node_modules/@types/os/package.json","../node_modules/@types/path/package.json","../node_modules/@types/path/posix/package.json","../node_modules/@types/path/win32/package.json","../node_modules/@types/perf_hooks/package.json","../node_modules/@types/process/package.json","../node_modules/@types/punycode/package.json","../node_modules/@types/querystring/package.json","../node_modules/@types/readline/package.json","../node_modules/@types/readline/promises/package.json","../node_modules/@types/repl/package.json","../node_modules/@types/stream/consumers/package.json","../node_modules/@types/stream/iter/package.json","../node_modules/@types/stream/package.json","../node_modules/@types/stream/promises/package.json","../node_modules/@types/stream/web/package.json","../node_modules/@types/string_decoder/package.json","../node_modules/@types/timers/package.json","../node_modules/@types/timers/promises/package.json","../node_modules/@types/tls/package.json","../node_modules/@types/trace_events/package.json","../node_modules/@types/tty/package.json","../node_modules/@types/url/package.json","../node_modules/@types/util/package.json","../node_modules/@types/util/types/package.json","../node_modules/@types/v8/package.json","../node_modules/@types/vm/package.json","../node_modules/@types/wasi/package.json","../node_modules/@types/worker_threads/package.json","../node_modules/@types/zlib/package.json","../node_modules/assert/package.json","../node_modules/assert/strict/package.json","../node_modules/async_hooks/package.json","../node_modules/buffer/package.json","../node_modules/child_process/package.json","../node_modules/cluster/package.json","../node_modules/console/package.json","../node_modules/constants/package.json","../node_modules/crypto/package.json","../node_modules/dgram/package.json","../node_modules/diagnostics_channel/package.json","../node_modules/dns/package.json","../node_modules/dns/promises/package.json","../node_modules/domain/package.json","../node_modules/events/package.json","../node_modules/fs/package.json","../node_modules/fs/promises/package.json","../node_modules/http/package.json","../node_modules/http2/package.json","../node_modules/https/package.json","../node_modules/inspector/package.json","../node_modules/inspector/promises/package.json","../node_modules/module/package.json","../node_modules/net/package.json","../node_modules/os/package.json","../node_modules/path/package.json","../node_modules/path/posix/package.json","../node_modules/path/win32/package.json","../node_modules/perf_hooks/package.json","../node_modules/process/package.json","../node_modules/punycode/package.json","../node_modules/querystring/package.json","../node_modules/readline/package.json","../node_modules/readline/promises/package.json","../node_modules/repl/package.json","../node_modules/stream/consumers/package.json","../node_modules/stream/iter/package.json","../node_modules/stream/package.json","../node_modules/stream/promises/package.json","../node_modules/stream/web/package.json","../node_modules/string_decoder/package.json","../node_modules/timers/package.json","../node_modules/timers/promises/package.json","../node_modules/tls/package.json","../node_modules/trace_events/package.json","../node_modules/tty/package.json","../node_modules/url/package.json","../node_modules/util/package.json","../node_modules/util/types/package.json","../node_modules/v8/package.json","../node_modules/vm/package.json","../node_modules/wasi/package.json","../node_modules/worker_threads/package.json","../node_modules/zlib/package.json"]}
1
+ {"version":"7.0.2","root":["../src/abnf.ts","../src/compile.ts","../src/converter.ts","../src/translate.ts","../src/bin/tabnas-abnf-cli.ts"],"packageJsons":["../node_modules/@tabnas/bnf/package.json","../node_modules/@tabnas/parser/package.json","../node_modules/@types/node/package.json","../node_modules/undici-types/package.json","../package.json"],"missingPackageJsons":["../node_modules/@tabnas/bnf/dist/package.json","../node_modules/@tabnas/parser/dist/package.json","../node_modules/@types/assert/package.json","../node_modules/@types/assert/strict/package.json","../node_modules/@types/async_hooks/package.json","../node_modules/@types/buffer/package.json","../node_modules/@types/child_process/package.json","../node_modules/@types/cluster/package.json","../node_modules/@types/console/package.json","../node_modules/@types/constants/package.json","../node_modules/@types/crypto/package.json","../node_modules/@types/dgram/package.json","../node_modules/@types/diagnostics_channel/package.json","../node_modules/@types/dns/package.json","../node_modules/@types/dns/promises/package.json","../node_modules/@types/domain/package.json","../node_modules/@types/events/package.json","../node_modules/@types/fs/package.json","../node_modules/@types/fs/promises/package.json","../node_modules/@types/http/package.json","../node_modules/@types/http2/package.json","../node_modules/@types/https/package.json","../node_modules/@types/inspector/package.json","../node_modules/@types/inspector/promises/package.json","../node_modules/@types/module/package.json","../node_modules/@types/net/package.json","../node_modules/@types/node/assert/package.json","../node_modules/@types/node/dns/package.json","../node_modules/@types/node/fs/package.json","../node_modules/@types/node/inspector/package.json","../node_modules/@types/node/path/package.json","../node_modules/@types/node/readline/package.json","../node_modules/@types/node/stream/package.json","../node_modules/@types/node/test/package.json","../node_modules/@types/node/timers/package.json","../node_modules/@types/node/util/package.json","../node_modules/@types/node/web-globals/package.json","../node_modules/@types/node/zlib/package.json","../node_modules/@types/os/package.json","../node_modules/@types/path/package.json","../node_modules/@types/path/posix/package.json","../node_modules/@types/path/win32/package.json","../node_modules/@types/perf_hooks/package.json","../node_modules/@types/process/package.json","../node_modules/@types/punycode/package.json","../node_modules/@types/querystring/package.json","../node_modules/@types/readline/package.json","../node_modules/@types/readline/promises/package.json","../node_modules/@types/repl/package.json","../node_modules/@types/stream/consumers/package.json","../node_modules/@types/stream/iter/package.json","../node_modules/@types/stream/package.json","../node_modules/@types/stream/promises/package.json","../node_modules/@types/stream/web/package.json","../node_modules/@types/string_decoder/package.json","../node_modules/@types/timers/package.json","../node_modules/@types/timers/promises/package.json","../node_modules/@types/tls/package.json","../node_modules/@types/trace_events/package.json","../node_modules/@types/tty/package.json","../node_modules/@types/url/package.json","../node_modules/@types/util/package.json","../node_modules/@types/util/types/package.json","../node_modules/@types/v8/package.json","../node_modules/@types/vm/package.json","../node_modules/@types/wasi/package.json","../node_modules/@types/worker_threads/package.json","../node_modules/@types/zlib/package.json","../node_modules/assert/package.json","../node_modules/assert/strict/package.json","../node_modules/async_hooks/package.json","../node_modules/buffer/package.json","../node_modules/child_process/package.json","../node_modules/cluster/package.json","../node_modules/console/package.json","../node_modules/constants/package.json","../node_modules/crypto/package.json","../node_modules/dgram/package.json","../node_modules/diagnostics_channel/package.json","../node_modules/dns/package.json","../node_modules/dns/promises/package.json","../node_modules/domain/package.json","../node_modules/events/package.json","../node_modules/fs/package.json","../node_modules/fs/promises/package.json","../node_modules/http/package.json","../node_modules/http2/package.json","../node_modules/https/package.json","../node_modules/inspector/package.json","../node_modules/inspector/promises/package.json","../node_modules/module/package.json","../node_modules/net/package.json","../node_modules/os/package.json","../node_modules/path/package.json","../node_modules/path/posix/package.json","../node_modules/path/win32/package.json","../node_modules/perf_hooks/package.json","../node_modules/process/package.json","../node_modules/punycode/package.json","../node_modules/querystring/package.json","../node_modules/readline/package.json","../node_modules/readline/promises/package.json","../node_modules/repl/package.json","../node_modules/stream/consumers/package.json","../node_modules/stream/iter/package.json","../node_modules/stream/package.json","../node_modules/stream/promises/package.json","../node_modules/stream/web/package.json","../node_modules/string_decoder/package.json","../node_modules/timers/package.json","../node_modules/timers/promises/package.json","../node_modules/tls/package.json","../node_modules/trace_events/package.json","../node_modules/tty/package.json","../node_modules/url/package.json","../node_modules/util/package.json","../node_modules/util/types/package.json","../node_modules/v8/package.json","../node_modules/vm/package.json","../node_modules/wasi/package.json","../node_modules/worker_threads/package.json","../node_modules/zlib/package.json"]}
@@ -0,0 +1,124 @@
1
+ /* Copyright (c) 2026 Richard Rodger and other contributors, MIT License */
2
+
3
+ // Generate the TypeScript translation interface and the packaged Go and
4
+ // Rust copies from the repository's one manifest and alchemy sources.
5
+ // Node's standard library only: `npm run embed` runs it, and so does the
6
+ // build.
7
+
8
+ const fs = require('node:fs')
9
+ const path = require('node:path')
10
+
11
+ const root = path.resolve(__dirname, '..')
12
+ const manifestPath = path.join(root, 'tabnas.plugin.json')
13
+
14
+ // A published package is `ts/` alone: it carries this script, which its
15
+ // build runs, and the `src/translate.ts` it generated, but not the files
16
+ // above `ts/` it reads. Rebuilding an unpacked package keeps the
17
+ // generated file as it was published.
18
+ if (!fs.existsSync(manifestPath)) {
19
+ console.log(`embed-translate: no ${manifestPath}, so src/translate.ts is kept as published`)
20
+ process.exit(0)
21
+ }
22
+
23
+ const manifestText = fs.readFileSync(manifestPath, 'utf8')
24
+ const manifest = JSON.parse(manifestText)
25
+ const spec = manifest.translate
26
+
27
+ if (null == spec) {
28
+ throw new Error('tabnas.plugin.json has no translate object')
29
+ }
30
+
31
+ const languageId = manifest.languageId
32
+ if ('string' !== typeof languageId || '' === languageId) {
33
+ throw new Error('tabnas.plugin.json has no languageId')
34
+ }
35
+
36
+ // One part the manifest names: an alchemy file, embedded with its entry
37
+ // point `<languageId>-<part>`, or a render alchemy carries (`json`,
38
+ // `csv`), named and not embedded.
39
+ function part (kind) {
40
+ const value = spec[kind]
41
+ if (null == value) return undefined
42
+ if ('string' !== typeof value || '' === value) {
43
+ throw new Error(`translate.${kind} is not a non-empty string`)
44
+ }
45
+
46
+ if (!value.endsWith('.alc')) {
47
+ return { entry: value }
48
+ }
49
+
50
+ const sourcePath = path.join(root, value)
51
+ const source = fs.readFileSync(sourcePath, 'utf8')
52
+ return { entry: `${languageId}-${kind}`, source, file: path.basename(value) }
53
+ }
54
+
55
+ const lift = part('lift')
56
+ const embed = part('embed')
57
+ const render = part('render')
58
+
59
+ function tsPart (value) {
60
+ if (null == value) return undefined
61
+ const fields = [`entry: ${JSON.stringify(value.entry)}`]
62
+ if (null != value.source) fields.push(`source: ${tsString(value.source)}`)
63
+ return `Object.freeze({ ${fields.join(', ')} })`
64
+ }
65
+
66
+ // A template literal holding the text exactly: its backslashes, backticks
67
+ // and `${` escaped.
68
+ function tsString (value) {
69
+ return '`' + value
70
+ .replaceAll('\\', '\\\\')
71
+ .replaceAll('`', '\\`')
72
+ .replaceAll('${', '\\${') + '`'
73
+ }
74
+
75
+ const fields = [`manifest: ${tsString(manifestText)}`]
76
+ if (lift) fields.push(`lift: ${tsPart(lift)}`)
77
+ if (embed) fields.push(`embed: ${tsPart(embed)}`)
78
+ if (render) fields.push(`render: ${tsPart(render)}`)
79
+
80
+ const generated = `/* Copyright (c) 2026 Richard Rodger and other contributors, MIT License */
81
+
82
+ // Generated by ../embed-translate.js. Edit tabnas.plugin.json or alchemy/*,
83
+ // then run npm run embed.
84
+
85
+ type TranslationPart = Readonly<{
86
+ entry: string
87
+ source?: string
88
+ }>
89
+
90
+ type TranslationParts = Readonly<{
91
+ manifest: string
92
+ lift?: TranslationPart
93
+ embed?: TranslationPart
94
+ render?: TranslationPart
95
+ }>
96
+
97
+ const TRANSLATION: TranslationParts = Object.freeze({
98
+ ${fields.join(',\n ')}
99
+ })
100
+
101
+ function translate (): TranslationParts | undefined {
102
+ return TRANSLATION
103
+ }
104
+
105
+ export {
106
+ translate,
107
+ }
108
+
109
+ export type {
110
+ TranslationPart,
111
+ TranslationParts,
112
+ }
113
+ `
114
+
115
+ fs.writeFileSync(path.join(__dirname, 'src', 'translate.ts'), generated)
116
+
117
+ for (const runtime of ['go', 'rs']) {
118
+ const target = path.join(root, runtime, 'translate')
119
+ fs.mkdirSync(target, { recursive: true })
120
+ fs.writeFileSync(path.join(target, 'manifest.json'), manifestText)
121
+ for (const value of [lift, embed, render]) {
122
+ if (value?.source) fs.writeFileSync(path.join(target, value.file), value.source)
123
+ }
124
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabnas/abnf",
3
- "version": "0.4.20",
3
+ "version": "0.4.21",
4
4
  "main": "dist/abnf.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/abnf.d.ts",
@@ -25,7 +25,8 @@
25
25
  "test-unit": "node --enable-source-maps --test --test-skip-pattern='^conformance' test/**/*.test.js",
26
26
  "test-conformance": "node --enable-source-maps --test test/conformance.test.js",
27
27
  "watch": "tsc --build src -w",
28
- "build": "tsc --build src",
28
+ "embed": "node embed-translate.js",
29
+ "build": "node embed-translate.js && tsc --build src",
29
30
  "clean": "rm -rf node_modules dist dist-test yarn.lock package-lock.json",
30
31
  "reset": "npm run clean && npm i && npm run build && npm test",
31
32
  "repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: ts/v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag ts/v$REPO_VERSION && git push origin ts/v$REPO_VERSION;",
@@ -41,6 +42,7 @@
41
42
  "dist",
42
43
  "src",
43
44
  "bin",
45
+ "embed-translate.js",
44
46
  "README.md",
45
47
  "LICENSE"
46
48
  ],
package/src/abnf.ts CHANGED
@@ -85,8 +85,11 @@ export {
85
85
 
86
86
  export type { AbnfConvertOptions, AbnfCompileOptions, ActionsMap }
87
87
 
88
+ export { translate } from './translate'
89
+ export type { TranslationPart, TranslationParts } from './translate'
90
+
88
91
 
89
92
  // VERSION is this package's version. It MUST equal package.json "version":
90
93
  // the release orchestrator rewrites both, and the version test fails the
91
94
  // build if they drift. Mirrors `const VERSION` in go/abnf.go.
92
- const VERSION = '0.4.20'
95
+ const VERSION = '0.4.21'