@gmb/bitmark-parser-generator 4.0.2 → 4.1.2

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.
@@ -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 [30 Jul 2025 at 08:01]</title>
6
+ <title>@gmb/bitmark-parser-generator [6 Aug 2025 at 05:03]</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+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9Ib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nRuLabN4CGNRkAE23na2+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":1135319,"parsedSize":492579,"gzipSize":96068,"groups":[{"label":"dist/browser/cjs","path":"./dist/browser/cjs","statSize":1128339,"groups":[{"id":922,"label":"index.cjs","path":"./dist/browser/cjs/index.cjs","statSize":1128339,"parsedSize":492475,"gzipSize":96068}],"parsedSize":492475,"gzipSize":96068},{"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}}];
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.0.2",
8928
+ "version": "4.1.2",
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
- let ret = resource;
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
- ret = {
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;
@@ -31219,7 +31214,6 @@ function buildResources(context, resourceTypeAttachment, resources) {
31219
31214
  const countsMax = resourcesConfig.getCountsMax();
31220
31215
  if (resources) {
31221
31216
  for (const r of resources.reverse()) {
31222
- if (r.__invalid) continue;
31223
31217
  const configKey = r.__configKey;
31224
31218
  let countMin = countsMin.get(configKey) ?? 0;
31225
31219
  let countMax = countsMax.get(configKey) ?? 0;
@@ -31234,6 +31228,9 @@ function buildResources(context, resourceTypeAttachment, resources) {
31234
31228
  }
31235
31229
  countsMin.set(configKey, countMin);
31236
31230
  countsMax.set(configKey, countMax);
31231
+ if (r.__invalid) {
31232
+ context.addWarning(`Resource type [&${r.type}] is not valid`);
31233
+ }
31237
31234
  }
31238
31235
  }
31239
31236
  if (!resourceAttachmentAllowed && resourceTypeAttachment) {
@@ -35222,12 +35219,13 @@ var BitmarkParserGenerator = class {
35222
35219
  const outputAst = outputFormat === Output.ast;
35223
35220
  const bitmarkParserType = BitmarkParserType.peggy;
35224
35221
  let inStr = input;
35222
+ const inputIsString = typeof input === "string";
35225
35223
  if (env.isBrowser && opts.outputFile) {
35226
35224
  throw new Error("Cannot write to file in browser environment");
35227
35225
  }
35228
35226
  if (!opts.inputFormat || opts.inputFormat === Input.file) {
35229
35227
  if (env.isNode) {
35230
- if (fs.existsSync(inStr)) {
35228
+ if (inputIsString && fs.existsSync(inStr)) {
35231
35229
  inStr = fs.readFileSync(inStr, {
35232
35230
  encoding: "utf8"
35233
35231
  });
@@ -35240,7 +35238,7 @@ var BitmarkParserGenerator = class {
35240
35238
  ast = this.jsonParser.toAst(inStr);
35241
35239
  }
35242
35240
  const isJson = !!ast?.bits;
35243
- const isBitmark = !isJson && !isAst;
35241
+ const isBitmark = inputIsString && !isJson && !isAst;
35244
35242
  const bitmarkToBitmark = (bitmarkStr) => {
35245
35243
  bitmarkToAst(bitmarkStr);
35246
35244
  astToBitmark(res);
@@ -35319,7 +35317,7 @@ var BitmarkParserGenerator = class {
35319
35317
  } else {
35320
35318
  astToBitmark(ast);
35321
35319
  }
35322
- } else {
35320
+ } else if (isJson) {
35323
35321
  ast = ast;
35324
35322
  if (outputJson) {
35325
35323
  jsonToJson(ast);
@@ -35328,6 +35326,8 @@ var BitmarkParserGenerator = class {
35328
35326
  } else {
35329
35327
  jsonToBitmark(ast);
35330
35328
  }
35329
+ } else {
35330
+ res = "";
35331
35331
  }
35332
35332
  return res;
35333
35333
  }
@@ -35362,12 +35362,13 @@ var BitmarkParserGenerator = class {
35362
35362
  const jsonOptions = Object.assign({}, opts.jsonOptions);
35363
35363
  const bitmarkParserType = opts.bitmarkParserType;
35364
35364
  let inStr = input;
35365
+ const inputIsString = typeof input === "string";
35365
35366
  if (env.isBrowser && opts.outputFile) {
35366
35367
  throw new Error("Cannot write to file in browser environment");
35367
35368
  }
35368
35369
  if (!opts.inputFormat || opts.inputFormat === Input.file) {
35369
35370
  if (env.isNode) {
35370
- if (fs.existsSync(inStr)) {
35371
+ if (inputIsString && fs.existsSync(inStr)) {
35371
35372
  inStr = fs.readFileSync(inStr, {
35372
35373
  encoding: "utf8"
35373
35374
  });
@@ -35376,7 +35377,7 @@ var BitmarkParserGenerator = class {
35376
35377
  }
35377
35378
  let ast = this.jsonParser.toAst(inStr);
35378
35379
  const isJson = !!ast?.bits;
35379
- const isBitmark = !isJson;
35380
+ const isBitmark = inputIsString && !isJson;
35380
35381
  const bitmarkToBitmark = (bitmarkStr) => {
35381
35382
  const astJson = this.bitmarkParser.toAst(bitmarkStr, {
35382
35383
  parserType: bitmarkParserType
@@ -35401,9 +35402,11 @@ var BitmarkParserGenerator = class {
35401
35402
  };
35402
35403
  if (isBitmark) {
35403
35404
  bitmarkToBitmark(inStr);
35404
- } else {
35405
+ } else if (isJson) {
35405
35406
  ast = ast;
35406
35407
  jsonToJson(ast);
35408
+ } else {
35409
+ return;
35407
35410
  }
35408
35411
  return res;
35409
35412
  }
@@ -35420,10 +35423,11 @@ var BitmarkParserGenerator = class {
35420
35423
  createAst(input, options) {
35421
35424
  let res;
35422
35425
  let inStr = input;
35426
+ const inputIsString = typeof input === "string";
35423
35427
  const opts = Object.assign({}, options);
35424
35428
  if (!opts.inputFormat || opts.inputFormat === Input.file) {
35425
35429
  if (env.isNode) {
35426
- if (fs.existsSync(inStr)) {
35430
+ if (inputIsString && fs.existsSync(inStr)) {
35427
35431
  inStr = fs.readFileSync(inStr, {
35428
35432
  encoding: "utf8"
35429
35433
  });
@@ -35436,11 +35440,13 @@ var BitmarkParserGenerator = class {
35436
35440
  ast = this.jsonParser.toAst(inStr);
35437
35441
  }
35438
35442
  const isJson = !!ast?.bits;
35439
- const isBitmark = !isJson && !isAst;
35443
+ const isBitmark = inputIsString && !isJson && !isAst;
35440
35444
  if (isBitmark) {
35441
35445
  res = this.bitmarkParser.toAst(inStr);
35442
- } else {
35446
+ } else if (isJson) {
35443
35447
  res = ast;
35448
+ } else {
35449
+ res = {};
35444
35450
  }
35445
35451
  return res;
35446
35452
  }
@@ -35476,12 +35482,13 @@ var BitmarkParserGenerator = class {
35476
35482
  const textFormat = TextFormat.fromValue(opts.textFormat) ?? TextFormat.bitmarkText;
35477
35483
  const textLocation = opts.textLocation ?? TextLocation.body;
35478
35484
  let inStr = input;
35485
+ const inputIsString = typeof input === "string";
35479
35486
  if (env.isBrowser && opts.outputFile) {
35480
35487
  throw new Error("Cannot write to file in browser environment");
35481
35488
  }
35482
35489
  if (!opts.inputFormat || opts.inputFormat === Input.file) {
35483
35490
  if (env.isNode) {
35484
- if (fs.existsSync(inStr)) {
35491
+ if (inputIsString && fs.existsSync(inStr)) {
35485
35492
  inStr = fs.readFileSync(inStr, {
35486
35493
  encoding: "utf8"
35487
35494
  });
@@ -35543,12 +35550,13 @@ var BitmarkParserGenerator = class {
35543
35550
  const textFormat = TextFormat.fromValue(opts.textFormat) ?? TextFormat.bitmarkText;
35544
35551
  const textLocation = opts.textLocation ?? TextLocation.body;
35545
35552
  let inStr = input;
35553
+ const inputIsString = typeof input === "string";
35546
35554
  if (env.isBrowser && opts.outputFile) {
35547
35555
  throw new Error("Cannot write to file in browser environment");
35548
35556
  }
35549
35557
  if (!opts.inputFormat || opts.inputFormat === Input.file) {
35550
35558
  if (env.isNode) {
35551
- if (fs.existsSync(inStr)) {
35559
+ if (inputIsString && fs.existsSync(inStr)) {
35552
35560
  inStr = fs.readFileSync(inStr, {
35553
35561
  encoding: "utf8"
35554
35562
  });
@@ -35595,12 +35603,13 @@ var BitmarkParserGenerator = class {
35595
35603
  const textFormat = TextFormat.fromValue(opts.textFormat) ?? TextFormat.bitmarkText;
35596
35604
  const textLocation = opts.textLocation ?? TextLocation.body;
35597
35605
  let inStr = input;
35606
+ const inputIsString = typeof input === "string";
35598
35607
  if (env.isBrowser && opts.outputFile) {
35599
35608
  throw new Error("Cannot write to file in browser environment");
35600
35609
  }
35601
35610
  if (!opts.inputFormat || opts.inputFormat === Input.file) {
35602
35611
  if (env.isNode) {
35603
- if (fs.existsSync(inStr)) {
35612
+ if (inputIsString && fs.existsSync(inStr)) {
35604
35613
  inStr = fs.readFileSync(inStr, {
35605
35614
  encoding: "utf8"
35606
35615
  });