@gmb/bitmark-parser-generator 4.0.1 → 4.1.1
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/dist/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/browser/cjs/index.cjs +30 -25
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +14 -14
- package/dist/browser/esm/index.d.ts +14 -14
- package/dist/browser/esm/index.js +30 -25
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/index.cjs +50 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +50 -39
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@gmb/bitmark-parser-generator [
|
|
6
|
+
<title>@gmb/bitmark-parser-generator [6 Aug 2025 at 04:59]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dx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YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<body>
|
|
32
32
|
<div id="app"></div>
|
|
33
33
|
<script>
|
|
34
|
-
window.chartData = [{"label":"bitmark-parser-generator.min.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"bitmark-parser-generator.min.js","isAsset":true,"statSize":1135852,"parsedSize":492807,"gzipSize":96133,"groups":[{"label":"dist/browser/cjs","path":"./dist/browser/cjs","statSize":1128872,"groups":[{"id":922,"label":"index.cjs","path":"./dist/browser/cjs/index.cjs","statSize":1128872,"parsedSize":492703,"gzipSize":96133}],"parsedSize":492703,"gzipSize":96133},{"label":"node_modules/@ncoderz/superenum/dist/esm","path":"./node_modules/@ncoderz/superenum/dist/esm","statSize":6980,"groups":[{"id":718,"label":"superenum.js","path":"./node_modules/@ncoderz/superenum/dist/esm/superenum.js","statSize":6980}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"main":true}}];
|
|
35
35
|
window.entrypoints = ["main"];
|
|
36
36
|
window.defaultSizes = "stat";
|
|
37
37
|
</script>
|
|
@@ -8925,7 +8925,7 @@ var instance2 = new Config();
|
|
|
8925
8925
|
// src/generated/package_info.ts
|
|
8926
8926
|
var PACKAGE_INFO = {
|
|
8927
8927
|
"name": "@gmb/bitmark-parser-generator",
|
|
8928
|
-
"version": "4.
|
|
8928
|
+
"version": "4.1.1",
|
|
8929
8929
|
"author": "Get More Brain Ltd",
|
|
8930
8930
|
"license": "ISC",
|
|
8931
8931
|
"description": "A bitmark parser and generator using Peggy.js"
|
|
@@ -20628,7 +20628,7 @@ var NodeValidator = class {
|
|
|
20628
20628
|
}
|
|
20629
20629
|
validateResource(resource) {
|
|
20630
20630
|
if (!resource) return void 0;
|
|
20631
|
-
|
|
20631
|
+
const ret = resource;
|
|
20632
20632
|
let valid = false;
|
|
20633
20633
|
switch (resource.type) {
|
|
20634
20634
|
case ResourceType.image:
|
|
@@ -20690,12 +20690,7 @@ var NodeValidator = class {
|
|
|
20690
20690
|
}
|
|
20691
20691
|
if (!valid) {
|
|
20692
20692
|
if (resource.type) {
|
|
20693
|
-
|
|
20694
|
-
type: resource.type,
|
|
20695
|
-
__typeAlias: resource.type,
|
|
20696
|
-
__configKey: resource.__configKey,
|
|
20697
|
-
__invalid: true
|
|
20698
|
-
};
|
|
20693
|
+
resource.__invalid = true;
|
|
20699
20694
|
}
|
|
20700
20695
|
}
|
|
20701
20696
|
return ret;
|
|
@@ -28332,7 +28327,6 @@ var ContentDepth = (0, import_superenum30.superenum)({
|
|
|
28332
28327
|
});
|
|
28333
28328
|
|
|
28334
28329
|
// src/parser/bitmark/peg/BitmarkPegParserHelper.ts
|
|
28335
|
-
var ENABLE_DEBUG = true;
|
|
28336
28330
|
var DEBUG_TRACE_RAW_BIT = true;
|
|
28337
28331
|
var DEBUG_TRACE_TEXT_FORMAT = false;
|
|
28338
28332
|
var DEBUG_TRACE_RESOURCE_TYPE = false;
|
|
@@ -28349,7 +28343,6 @@ var DEBUG_TRACE_CARD_LINE_OR_DIVIDER = false;
|
|
|
28349
28343
|
var DEBUG_TRACE_CARD_CONTENT = false;
|
|
28350
28344
|
var DEBUG_TRACE_CARD_TAGS = false;
|
|
28351
28345
|
var DEBUG_TRACE_CARD_PARSED = true;
|
|
28352
|
-
var DEBUG = ENABLE_DEBUG && process.env.BPG_ENV === "development";
|
|
28353
28346
|
var BitmarkPegParserHelper = class {
|
|
28354
28347
|
constructor(options) {
|
|
28355
28348
|
__publicField(this, "cardIndex", 0);
|
|
@@ -31221,7 +31214,6 @@ function buildResources(context, resourceTypeAttachment, resources) {
|
|
|
31221
31214
|
const countsMax = resourcesConfig.getCountsMax();
|
|
31222
31215
|
if (resources) {
|
|
31223
31216
|
for (const r of resources.reverse()) {
|
|
31224
|
-
if (r.__invalid) continue;
|
|
31225
31217
|
const configKey = r.__configKey;
|
|
31226
31218
|
let countMin = countsMin.get(configKey) ?? 0;
|
|
31227
31219
|
let countMax = countsMax.get(configKey) ?? 0;
|
|
@@ -31236,6 +31228,9 @@ function buildResources(context, resourceTypeAttachment, resources) {
|
|
|
31236
31228
|
}
|
|
31237
31229
|
countsMin.set(configKey, countMin);
|
|
31238
31230
|
countsMax.set(configKey, countMax);
|
|
31231
|
+
if (r.__invalid) {
|
|
31232
|
+
context.addWarning(`Resource type [&${r.type}] is not valid`);
|
|
31233
|
+
}
|
|
31239
31234
|
}
|
|
31240
31235
|
}
|
|
31241
31236
|
if (!resourceAttachmentAllowed && resourceTypeAttachment) {
|
|
@@ -31541,7 +31536,6 @@ function buildSelect(context, tagsConfig, selectContent) {
|
|
|
31541
31536
|
}
|
|
31542
31537
|
|
|
31543
31538
|
// src/parser/bitmark/peg/BitmarkPegParserProcessor.ts
|
|
31544
|
-
var ENABLE_DEBUG2 = true;
|
|
31545
31539
|
var DEBUG_BIT_RAW = true;
|
|
31546
31540
|
var DEBUG_BIT_CONTENT_RAW = false;
|
|
31547
31541
|
var DEBUG_BIT_CONTENT = true;
|
|
@@ -31553,7 +31547,6 @@ var DEBUG_CHAIN_TAGS = true;
|
|
|
31553
31547
|
var DEBUG_CARD_SET_CONTENT = true;
|
|
31554
31548
|
var DEBUG_CARD_SET = true;
|
|
31555
31549
|
var DEBUG_CARD_TAGS = true;
|
|
31556
|
-
var DEBUG2 = ENABLE_DEBUG2 && process.env.BPG_ENV === "development";
|
|
31557
31550
|
var builder2 = new Builder();
|
|
31558
31551
|
var BitmarkPegParserProcessor = class {
|
|
31559
31552
|
constructor(options) {
|
|
@@ -35226,12 +35219,13 @@ var BitmarkParserGenerator = class {
|
|
|
35226
35219
|
const outputAst = outputFormat === Output.ast;
|
|
35227
35220
|
const bitmarkParserType = BitmarkParserType.peggy;
|
|
35228
35221
|
let inStr = input;
|
|
35222
|
+
const inputIsString = typeof input === "string";
|
|
35229
35223
|
if (env.isBrowser && opts.outputFile) {
|
|
35230
35224
|
throw new Error("Cannot write to file in browser environment");
|
|
35231
35225
|
}
|
|
35232
35226
|
if (!opts.inputFormat || opts.inputFormat === Input.file) {
|
|
35233
35227
|
if (env.isNode) {
|
|
35234
|
-
if (fs.existsSync(inStr)) {
|
|
35228
|
+
if (inputIsString && fs.existsSync(inStr)) {
|
|
35235
35229
|
inStr = fs.readFileSync(inStr, {
|
|
35236
35230
|
encoding: "utf8"
|
|
35237
35231
|
});
|
|
@@ -35244,7 +35238,7 @@ var BitmarkParserGenerator = class {
|
|
|
35244
35238
|
ast = this.jsonParser.toAst(inStr);
|
|
35245
35239
|
}
|
|
35246
35240
|
const isJson = !!ast?.bits;
|
|
35247
|
-
const isBitmark = !isJson && !isAst;
|
|
35241
|
+
const isBitmark = inputIsString && !isJson && !isAst;
|
|
35248
35242
|
const bitmarkToBitmark = (bitmarkStr) => {
|
|
35249
35243
|
bitmarkToAst(bitmarkStr);
|
|
35250
35244
|
astToBitmark(res);
|
|
@@ -35323,7 +35317,7 @@ var BitmarkParserGenerator = class {
|
|
|
35323
35317
|
} else {
|
|
35324
35318
|
astToBitmark(ast);
|
|
35325
35319
|
}
|
|
35326
|
-
} else {
|
|
35320
|
+
} else if (isJson) {
|
|
35327
35321
|
ast = ast;
|
|
35328
35322
|
if (outputJson) {
|
|
35329
35323
|
jsonToJson(ast);
|
|
@@ -35332,6 +35326,8 @@ var BitmarkParserGenerator = class {
|
|
|
35332
35326
|
} else {
|
|
35333
35327
|
jsonToBitmark(ast);
|
|
35334
35328
|
}
|
|
35329
|
+
} else {
|
|
35330
|
+
res = "";
|
|
35335
35331
|
}
|
|
35336
35332
|
return res;
|
|
35337
35333
|
}
|
|
@@ -35366,12 +35362,13 @@ var BitmarkParserGenerator = class {
|
|
|
35366
35362
|
const jsonOptions = Object.assign({}, opts.jsonOptions);
|
|
35367
35363
|
const bitmarkParserType = opts.bitmarkParserType;
|
|
35368
35364
|
let inStr = input;
|
|
35365
|
+
const inputIsString = typeof input === "string";
|
|
35369
35366
|
if (env.isBrowser && opts.outputFile) {
|
|
35370
35367
|
throw new Error("Cannot write to file in browser environment");
|
|
35371
35368
|
}
|
|
35372
35369
|
if (!opts.inputFormat || opts.inputFormat === Input.file) {
|
|
35373
35370
|
if (env.isNode) {
|
|
35374
|
-
if (fs.existsSync(inStr)) {
|
|
35371
|
+
if (inputIsString && fs.existsSync(inStr)) {
|
|
35375
35372
|
inStr = fs.readFileSync(inStr, {
|
|
35376
35373
|
encoding: "utf8"
|
|
35377
35374
|
});
|
|
@@ -35380,7 +35377,7 @@ var BitmarkParserGenerator = class {
|
|
|
35380
35377
|
}
|
|
35381
35378
|
let ast = this.jsonParser.toAst(inStr);
|
|
35382
35379
|
const isJson = !!ast?.bits;
|
|
35383
|
-
const isBitmark = !isJson;
|
|
35380
|
+
const isBitmark = inputIsString && !isJson;
|
|
35384
35381
|
const bitmarkToBitmark = (bitmarkStr) => {
|
|
35385
35382
|
const astJson = this.bitmarkParser.toAst(bitmarkStr, {
|
|
35386
35383
|
parserType: bitmarkParserType
|
|
@@ -35405,9 +35402,11 @@ var BitmarkParserGenerator = class {
|
|
|
35405
35402
|
};
|
|
35406
35403
|
if (isBitmark) {
|
|
35407
35404
|
bitmarkToBitmark(inStr);
|
|
35408
|
-
} else {
|
|
35405
|
+
} else if (isJson) {
|
|
35409
35406
|
ast = ast;
|
|
35410
35407
|
jsonToJson(ast);
|
|
35408
|
+
} else {
|
|
35409
|
+
return;
|
|
35411
35410
|
}
|
|
35412
35411
|
return res;
|
|
35413
35412
|
}
|
|
@@ -35424,10 +35423,11 @@ var BitmarkParserGenerator = class {
|
|
|
35424
35423
|
createAst(input, options) {
|
|
35425
35424
|
let res;
|
|
35426
35425
|
let inStr = input;
|
|
35426
|
+
const inputIsString = typeof input === "string";
|
|
35427
35427
|
const opts = Object.assign({}, options);
|
|
35428
35428
|
if (!opts.inputFormat || opts.inputFormat === Input.file) {
|
|
35429
35429
|
if (env.isNode) {
|
|
35430
|
-
if (fs.existsSync(inStr)) {
|
|
35430
|
+
if (inputIsString && fs.existsSync(inStr)) {
|
|
35431
35431
|
inStr = fs.readFileSync(inStr, {
|
|
35432
35432
|
encoding: "utf8"
|
|
35433
35433
|
});
|
|
@@ -35440,11 +35440,13 @@ var BitmarkParserGenerator = class {
|
|
|
35440
35440
|
ast = this.jsonParser.toAst(inStr);
|
|
35441
35441
|
}
|
|
35442
35442
|
const isJson = !!ast?.bits;
|
|
35443
|
-
const isBitmark = !isJson && !isAst;
|
|
35443
|
+
const isBitmark = inputIsString && !isJson && !isAst;
|
|
35444
35444
|
if (isBitmark) {
|
|
35445
35445
|
res = this.bitmarkParser.toAst(inStr);
|
|
35446
|
-
} else {
|
|
35446
|
+
} else if (isJson) {
|
|
35447
35447
|
res = ast;
|
|
35448
|
+
} else {
|
|
35449
|
+
res = {};
|
|
35448
35450
|
}
|
|
35449
35451
|
return res;
|
|
35450
35452
|
}
|
|
@@ -35480,12 +35482,13 @@ var BitmarkParserGenerator = class {
|
|
|
35480
35482
|
const textFormat = TextFormat.fromValue(opts.textFormat) ?? TextFormat.bitmarkText;
|
|
35481
35483
|
const textLocation = opts.textLocation ?? TextLocation.body;
|
|
35482
35484
|
let inStr = input;
|
|
35485
|
+
const inputIsString = typeof input === "string";
|
|
35483
35486
|
if (env.isBrowser && opts.outputFile) {
|
|
35484
35487
|
throw new Error("Cannot write to file in browser environment");
|
|
35485
35488
|
}
|
|
35486
35489
|
if (!opts.inputFormat || opts.inputFormat === Input.file) {
|
|
35487
35490
|
if (env.isNode) {
|
|
35488
|
-
if (fs.existsSync(inStr)) {
|
|
35491
|
+
if (inputIsString && fs.existsSync(inStr)) {
|
|
35489
35492
|
inStr = fs.readFileSync(inStr, {
|
|
35490
35493
|
encoding: "utf8"
|
|
35491
35494
|
});
|
|
@@ -35547,12 +35550,13 @@ var BitmarkParserGenerator = class {
|
|
|
35547
35550
|
const textFormat = TextFormat.fromValue(opts.textFormat) ?? TextFormat.bitmarkText;
|
|
35548
35551
|
const textLocation = opts.textLocation ?? TextLocation.body;
|
|
35549
35552
|
let inStr = input;
|
|
35553
|
+
const inputIsString = typeof input === "string";
|
|
35550
35554
|
if (env.isBrowser && opts.outputFile) {
|
|
35551
35555
|
throw new Error("Cannot write to file in browser environment");
|
|
35552
35556
|
}
|
|
35553
35557
|
if (!opts.inputFormat || opts.inputFormat === Input.file) {
|
|
35554
35558
|
if (env.isNode) {
|
|
35555
|
-
if (fs.existsSync(inStr)) {
|
|
35559
|
+
if (inputIsString && fs.existsSync(inStr)) {
|
|
35556
35560
|
inStr = fs.readFileSync(inStr, {
|
|
35557
35561
|
encoding: "utf8"
|
|
35558
35562
|
});
|
|
@@ -35599,12 +35603,13 @@ var BitmarkParserGenerator = class {
|
|
|
35599
35603
|
const textFormat = TextFormat.fromValue(opts.textFormat) ?? TextFormat.bitmarkText;
|
|
35600
35604
|
const textLocation = opts.textLocation ?? TextLocation.body;
|
|
35601
35605
|
let inStr = input;
|
|
35606
|
+
const inputIsString = typeof input === "string";
|
|
35602
35607
|
if (env.isBrowser && opts.outputFile) {
|
|
35603
35608
|
throw new Error("Cannot write to file in browser environment");
|
|
35604
35609
|
}
|
|
35605
35610
|
if (!opts.inputFormat || opts.inputFormat === Input.file) {
|
|
35606
35611
|
if (env.isNode) {
|
|
35607
|
-
if (fs.existsSync(inStr)) {
|
|
35612
|
+
if (inputIsString && fs.existsSync(inStr)) {
|
|
35608
35613
|
inStr = fs.readFileSync(inStr, {
|
|
35609
35614
|
encoding: "utf8"
|
|
35610
35615
|
});
|