@gmb/bitmark-parser 6.11.1 → 7.0.0
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.
- package/README.md +222 -54
- package/dist/browser/bitmark-parser.min.js +4 -4
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/cjs/index.cjs +547 -325
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +342 -68
- package/dist/browser/esm/index.d.ts +342 -68
- package/dist/browser/esm/index.js +546 -324
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/esm/worker-entry.js +497 -242
- package/dist/browser/esm/worker-entry.js.map +1 -1
- package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
- package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
- package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
- package/dist/index.cjs +51 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +342 -68
- package/dist/index.d.ts +342 -68
- package/dist/index.js +50 -87
- package/dist/index.js.map +1 -1
- package/dist/legacy.cjs +8 -30
- package/dist/legacy.cjs.map +1 -1
- package/dist/legacy.d.cts +0 -2
- package/dist/legacy.d.ts +0 -2
- package/dist/legacy.js +8 -30
- package/dist/legacy.js.map +1 -1
- package/dist/worker-entry.cjs +1 -5
- package/dist/worker-entry.cjs.map +1 -1
- package/package.json +6 -6
- package/schema/bitmark.schema.json +496 -139
- package/wasm/bitmark_wasm.d.ts +27 -23
- package/wasm/bitmark_wasm.js +198 -112
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +2 -2
- package/wasm/package.json +1 -1
- package/wasm-bitmark-json/bitmark_json_wasm.d.ts +18 -12
- package/wasm-bitmark-json/bitmark_json_wasm.js +170 -72
- package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
- package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +1 -1
- package/wasm-bitmark-json/package.json +1 -1
- package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +27 -23
- package/wasm-browser-full/bitmark_browser_full_wasm.js +198 -112
- package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
- package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +2 -2
- package/wasm-browser-full/package.json +1 -1
package/dist/legacy.d.cts
CHANGED
|
@@ -290,8 +290,6 @@ declare class BitmarkParserGenerator {
|
|
|
290
290
|
protected checkBrowserFileWrite(outputFile: string | undefined): void;
|
|
291
291
|
/** Return `data`, or write it to `outputFile` (returning void), as bpg does. */
|
|
292
292
|
protected deliver(data: string, outputFile?: string, fileOptions?: FileOptions): string | void;
|
|
293
|
-
/** The core reports failures as `error:`-prefixed strings; bpg throws. */
|
|
294
|
-
protected throwOnError(out: string): void;
|
|
295
293
|
}
|
|
296
294
|
/**
|
|
297
295
|
* Direct bitmark text parser (bpg-compatible `bitmarkTextParse`):
|
package/dist/legacy.d.ts
CHANGED
|
@@ -290,8 +290,6 @@ declare class BitmarkParserGenerator {
|
|
|
290
290
|
protected checkBrowserFileWrite(outputFile: string | undefined): void;
|
|
291
291
|
/** Return `data`, or write it to `outputFile` (returning void), as bpg does. */
|
|
292
292
|
protected deliver(data: string, outputFile?: string, fileOptions?: FileOptions): string | void;
|
|
293
|
-
/** The core reports failures as `error:`-prefixed strings; bpg throws. */
|
|
294
|
-
protected throwOnError(out: string): void;
|
|
295
293
|
}
|
|
296
294
|
/**
|
|
297
295
|
* Direct bitmark text parser (bpg-compatible `bitmarkTextParse`):
|
package/dist/legacy.js
CHANGED
|
@@ -45,7 +45,7 @@ function initLegacyNode(provider) {
|
|
|
45
45
|
// src/generated/package_info.ts
|
|
46
46
|
var PACKAGE_INFO = {
|
|
47
47
|
"name": "@gmb/bitmark-parser",
|
|
48
|
-
"version": "
|
|
48
|
+
"version": "7.0.0",
|
|
49
49
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
50
50
|
"license": "ISC",
|
|
51
51
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -249,10 +249,7 @@ var Builder = class {
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
this.parseStringTexts(bit);
|
|
252
|
-
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false);
|
|
253
|
-
if (out.startsWith("error:")) {
|
|
254
|
-
throw new Error(out.slice("error:".length).trim());
|
|
255
|
-
}
|
|
252
|
+
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false, "", "");
|
|
256
253
|
const entries = JSON.parse(out);
|
|
257
254
|
const built = entries[0]?.bit ?? bit;
|
|
258
255
|
for (const [key, value] of Object.entries(bit)) {
|
|
@@ -389,8 +386,7 @@ var BitmarkParserGenerator = class {
|
|
|
389
386
|
const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
|
|
390
387
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
391
388
|
const includeUnknown = !jsonOptions.excludeUnknownProperties;
|
|
392
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false);
|
|
393
|
-
this.throwOnError(out);
|
|
389
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false, "", "");
|
|
394
390
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
395
391
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
396
392
|
}
|
|
@@ -424,7 +420,6 @@ var BitmarkParserGenerator = class {
|
|
|
424
420
|
);
|
|
425
421
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
426
422
|
const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
|
|
427
|
-
this.throwOnError(out);
|
|
428
423
|
if (isBitmark) return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
429
424
|
if (opts.outputFile) return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
430
425
|
if (pretty || jsonOptions.stringify) return out;
|
|
@@ -441,7 +436,6 @@ var BitmarkParserGenerator = class {
|
|
|
441
436
|
const { pretty, indent } = prettyIndent(opts.prettify);
|
|
442
437
|
const coreFormat = format === "pojo" ? "json" : format;
|
|
443
438
|
const out = wasm2.info(type, coreFormat, opts.bit ?? "", pretty, indent, false, false, true, "");
|
|
444
|
-
this.throwOnError(out);
|
|
445
439
|
if (format === "pojo") return JSON.parse(out);
|
|
446
440
|
return out;
|
|
447
441
|
}
|
|
@@ -473,8 +467,7 @@ var BitmarkParserGenerator = class {
|
|
|
473
467
|
const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
|
|
474
468
|
if (!isHtmlInput) {
|
|
475
469
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
476
|
-
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false);
|
|
477
|
-
this.throwOnError(out2);
|
|
470
|
+
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false, "", "");
|
|
478
471
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
479
472
|
}
|
|
480
473
|
const bitType = opts.tableFormat === "table" ? "table" : "table-extended";
|
|
@@ -483,13 +476,11 @@ var BitmarkParserGenerator = class {
|
|
|
483
476
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
484
477
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
485
478
|
if (outputFormat === "html") {
|
|
486
|
-
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false);
|
|
487
|
-
this.throwOnError(out2);
|
|
479
|
+
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false, "", "");
|
|
488
480
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
489
481
|
}
|
|
490
482
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
491
|
-
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false);
|
|
492
|
-
this.throwOnError(out);
|
|
483
|
+
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false, "", "");
|
|
493
484
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
494
485
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
495
486
|
}
|
|
@@ -513,8 +504,7 @@ var BitmarkParserGenerator = class {
|
|
|
513
504
|
const opts = Object.assign({}, options);
|
|
514
505
|
const wasm2 = getLegacyWasm();
|
|
515
506
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
516
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false);
|
|
517
|
-
this.throwOnError(out);
|
|
507
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false, "", "");
|
|
518
508
|
return makePseudoAst(JSON.parse(out));
|
|
519
509
|
}
|
|
520
510
|
/**
|
|
@@ -566,11 +556,9 @@ var BitmarkParserGenerator = class {
|
|
|
566
556
|
}
|
|
567
557
|
if (ast !== void 0) {
|
|
568
558
|
const out2 = isBitmarkText ? wasm2.convert_text(JSON.stringify(ast), "astToText", "bitmark++", textLocation) : wasm2.convert_text(JSON.stringify(ast), "astToPlainText", "plainText", textLocation);
|
|
569
|
-
this.throwOnError(out2);
|
|
570
559
|
return this.deliver(out2, opts.outputFile, opts.fileOptions);
|
|
571
560
|
}
|
|
572
561
|
const out = wasm2.convert_text(inStr, "textToAst", isBitmarkText ? "bitmark++" : "plainText", "body");
|
|
573
|
-
this.throwOnError(out);
|
|
574
562
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
575
563
|
const outStr = pretty ? wasm2.prettify(out, indent) : out;
|
|
576
564
|
if (opts.outputFile) return this.deliver(outStr, opts.outputFile, opts.fileOptions);
|
|
@@ -588,7 +576,6 @@ var BitmarkParserGenerator = class {
|
|
|
588
576
|
"bitmark++",
|
|
589
577
|
"body"
|
|
590
578
|
);
|
|
591
|
-
this.throwOnError(out);
|
|
592
579
|
return out;
|
|
593
580
|
}
|
|
594
581
|
/**
|
|
@@ -603,7 +590,6 @@ var BitmarkParserGenerator = class {
|
|
|
603
590
|
if (inputFormat === "bitmarkText") {
|
|
604
591
|
const ast = wasm2.convert_text(String(input), "textToAst", "bitmark++", "body");
|
|
605
592
|
const out2 = wasm2.convert_text(ast, "astToPlainText", "bitmark++", "body");
|
|
606
|
-
this.throwOnError(out2);
|
|
607
593
|
return out2;
|
|
608
594
|
}
|
|
609
595
|
if (typeof input === "string" && this.parseTextAstString(input) === void 0 && !wasm2.is_bitmark(input)) {
|
|
@@ -620,8 +606,7 @@ var BitmarkParserGenerator = class {
|
|
|
620
606
|
}
|
|
621
607
|
}
|
|
622
608
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
623
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false);
|
|
624
|
-
this.throwOnError(out);
|
|
609
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false, "", "");
|
|
625
610
|
return out;
|
|
626
611
|
}
|
|
627
612
|
/** If `s` parses as a TextAst JSON array, return it. */
|
|
@@ -725,12 +710,6 @@ var BitmarkParserGenerator = class {
|
|
|
725
710
|
encoding: fileOptions?.encoding ?? "utf8"
|
|
726
711
|
});
|
|
727
712
|
}
|
|
728
|
-
/** The core reports failures as `error:`-prefixed strings; bpg throws. */
|
|
729
|
-
throwOnError(out) {
|
|
730
|
-
if (out.startsWith("error:")) {
|
|
731
|
-
throw new Error(out.slice("error:".length).trim());
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
713
|
};
|
|
735
714
|
function extractHtmlTables(html) {
|
|
736
715
|
const tables = [];
|
|
@@ -767,7 +746,6 @@ function extractHtmlTables(html) {
|
|
|
767
746
|
}
|
|
768
747
|
function bitmarkTextParse(text) {
|
|
769
748
|
const out = getLegacyWasm().convert_text(text, "textToAst", "bitmark++", "body");
|
|
770
|
-
if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
|
|
771
749
|
return JSON.parse(out);
|
|
772
750
|
}
|
|
773
751
|
|