@gmb/bitmark-parser-generator 3.38.0 → 4.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.
@@ -2175,6 +2175,7 @@ interface ResourceWrapperJson {
2175
2175
  type: ResourceTypeType;
2176
2176
  __typeAlias: ResourceTypeType;
2177
2177
  __configKey: ConfigKeyType;
2178
+ __invalid?: boolean;
2178
2179
  }
2179
2180
  interface ImageResourceWrapperJson extends ResourceWrapperJson {
2180
2181
  type: 'image';
@@ -7521,7 +7522,7 @@ declare class BitmarkParserGenerator {
7521
7522
  /**
7522
7523
  * Generate the new configuration for the bitmark parser.
7523
7524
  */
7524
- generateConfig(options?: GenerateConfigOptions): Promise<unknown>;
7525
+ generateConfig(options?: GenerateConfigOptions): void;
7525
7526
  /**
7526
7527
  * Convert bitmark from bitmark to JSON, or JSON to bitmark.
7527
7528
  *
@@ -7544,11 +7545,11 @@ declare class BitmarkParserGenerator {
7544
7545
  * @param input - bitmark or JSON or AST as a string, JSON or AST as plain JS object, or path to a file containing
7545
7546
  * bitmark, JSON, or AST.
7546
7547
  * @param options - the conversion options
7547
- * @returns Promise that resolves to string if converting to bitmark, a plain JS object if converting to JSON, or
7548
+ * @returns A string if converting to bitmark, a plain JS object if converting to JSON, or
7548
7549
  * void if writing to a file
7549
7550
  * @throws Error if any error occurs
7550
7551
  */
7551
- convert(input: string | fs.PathLike | unknown, options?: ConvertOptions): Promise<string | unknown | void>;
7552
+ convert(input: string | fs.PathLike | unknown, options?: ConvertOptions): string | unknown | void;
7552
7553
  /**
7553
7554
  * Upgrade bitmark or JSON, upgrading to the latest supported syntax, removing unrecognised data in the process.
7554
7555
  *
@@ -7574,7 +7575,7 @@ declare class BitmarkParserGenerator {
7574
7575
  * void if writing to a file
7575
7576
  * @throws Error if any error occurs
7576
7577
  */
7577
- upgrade(input: string | fs.PathLike | unknown, options?: UpgradeOptions): Promise<string | unknown | void>;
7578
+ upgrade(input: string | fs.PathLike | unknown, options?: UpgradeOptions): string | unknown | void;
7578
7579
  /**
7579
7580
  * Create a bitmark AST (Abstract Syntax Tree) from bitmark or JSON or AST
7580
7581
  *
@@ -7609,7 +7610,7 @@ declare class BitmarkParserGenerator {
7609
7610
  * void if writing to a file
7610
7611
  * @throws Error if any error occurs
7611
7612
  */
7612
- convertText(input: string | fs.PathLike | unknown, options?: ConvertTextOptions): Promise<string | unknown | void>;
7613
+ convertText(input: string | fs.PathLike | unknown, options?: ConvertTextOptions): string | unknown | void;
7613
7614
  /**
7614
7615
  * Breakscape bitmark text.
7615
7616
  *
@@ -7733,12 +7734,20 @@ interface BitmarkFileGeneratorOptions extends BitmarkGeneratorOptions {
7733
7734
  * The options for file output.
7734
7735
  */
7735
7736
  fileOptions?: FileOptions;
7737
+ /**
7738
+ * If true, the file will be generated asynchronously - generateSync() will throw an error.
7739
+ * If false, the file will be generated synchronously.
7740
+ *
7741
+ * Defaults to false.
7742
+ */
7743
+ async?: boolean;
7736
7744
  }
7737
7745
  /**
7738
7746
  * Generate bitmark markup from a bitmark AST as a file
7739
7747
  */
7740
7748
  declare class BitmarkFileGenerator implements Generator<BitmarkAst> {
7741
7749
  private generator;
7750
+ private async;
7742
7751
  /**
7743
7752
  * Generate bitmark markup from a bitmark AST as a file
7744
7753
  *
@@ -7757,7 +7766,7 @@ declare class BitmarkFileGenerator implements Generator<BitmarkAst> {
7757
7766
  *
7758
7767
  * @param ast bitmark AST
7759
7768
  */
7760
- generateSync(_ast: BitmarkAst): string;
7769
+ generateSync(_ast: BitmarkAst): void;
7761
7770
  }
7762
7771
 
7763
7772
  /**
@@ -7768,14 +7777,21 @@ interface JsonFileGeneratorOptions extends JsonGeneratorOptions {
7768
7777
  * The options for file output.
7769
7778
  */
7770
7779
  fileOptions?: FileOptions;
7780
+ /**
7781
+ * If true, the file will be generated asynchronously - generateSync() will throw an error.
7782
+ * If false, the file will be generated synchronously.
7783
+ *
7784
+ * Defaults to false.
7785
+ */
7786
+ async?: boolean;
7771
7787
  }
7772
7788
  /**
7773
7789
  * Generate bitmark JSON from a bitmark AST as a file
7774
7790
  *
7775
- * TODO: NOT IMPLEMENTED!
7776
7791
  */
7777
7792
  declare class JsonFileGenerator implements Generator<BitmarkAst> {
7778
7793
  private generator;
7794
+ private async;
7779
7795
  /**
7780
7796
  * Generate bitmark JSON from a bitmark AST as a file
7781
7797
  *
@@ -7796,7 +7812,7 @@ declare class JsonFileGenerator implements Generator<BitmarkAst> {
7796
7812
  *
7797
7813
  * @param ast bitmark AST
7798
7814
  */
7799
- generateSync(_ast: BitmarkAst): string;
7815
+ generateSync(_ast: BitmarkAst): void;
7800
7816
  }
7801
7817
 
7802
7818
  export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AstWalkCallbacks, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type Bit, type BitJson, BitType, type BitTypeType, type BitWrapperJson, type BitmarkAst, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type Body, type BodyBitJson, type BodyBitsJson, type BodyPart, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, type BreakscapeOptions, type BreakscapedString, Builder, type CardBit, type CardNode, CardSetVersion, type CardSetVersionType, type ChoiceJson, type ConvertOptions, type ConvertTextOptions, type CreateAstOptions, type DefinitionListItemJson, type DocumentDownloadResourceJson, type DocumentDownloadResourceWrapperJson, type DocumentEmbedResourceJson, type DocumentEmbedResourceWrapperJson, type DocumentLinkResourceJson, type DocumentLinkResourceWrapperJson, type DocumentResourceJson, type DocumentResourceWrapperJson, type Example, type ExampleJson, type ExtraProperties, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type Footer, type GapJson, type Generator, type HeadingJson, type HighlightJson, type HighlightTextJson, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageSourceJson, InfoFormat, type InfoFormatType, type InfoOptions, InfoType, type InfoTypeType, type IngredientJson, Input, type InputType, JsonFileGenerator, JsonGenerator, type JsonOptions, JsonParser, JsonStringGenerator, type ListItemJson, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type Node, type NodeInfo, NodeType, type NodeTypeType, Output, type OutputType, type PairJson, type ParserJson, type PersonJson, type UpgradeOptions as PrettifyOptions, type PronunciationTableCellJson, type PronunciationTableJson, type Property, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceWrapperJson, type ResponseJson, type SelectJson, type SelectOptionJson, type ServingsJson, type StatementJson, type StillImageFilmEmbedResourceJson, type StillImageFilmEmbedResourceWrapperJson, type StillImageFilmLinkResourceJson, type StillImageFilmLinkResourceWrapperJson, type StillImageFilmResourceJson, type StillImageFilmResourceWrapperJson, StreamWriter, StringWriter, type TableJson, type TechnicalTermJson, type JsonText as Text, type TextAndIconJson, type TextAst, type TextJsonOptions, type UnbreakscapeOptions, type UpgradeOptions, type VideoEmbedResourceJson, type VideoEmbedResourceWrapperJson, type VideoLinkResourceJson, type VideoLinkResourceWrapperJson, type VideoResourceJson, type VideoResourceWrapperJson, type WebsiteLinkResourceJson, type WebsiteLinkResourceWrapperJson, type Writer, parse as bitmarkTextParse };
@@ -2175,6 +2175,7 @@ interface ResourceWrapperJson {
2175
2175
  type: ResourceTypeType;
2176
2176
  __typeAlias: ResourceTypeType;
2177
2177
  __configKey: ConfigKeyType;
2178
+ __invalid?: boolean;
2178
2179
  }
2179
2180
  interface ImageResourceWrapperJson extends ResourceWrapperJson {
2180
2181
  type: 'image';
@@ -7521,7 +7522,7 @@ declare class BitmarkParserGenerator {
7521
7522
  /**
7522
7523
  * Generate the new configuration for the bitmark parser.
7523
7524
  */
7524
- generateConfig(options?: GenerateConfigOptions): Promise<unknown>;
7525
+ generateConfig(options?: GenerateConfigOptions): void;
7525
7526
  /**
7526
7527
  * Convert bitmark from bitmark to JSON, or JSON to bitmark.
7527
7528
  *
@@ -7544,11 +7545,11 @@ declare class BitmarkParserGenerator {
7544
7545
  * @param input - bitmark or JSON or AST as a string, JSON or AST as plain JS object, or path to a file containing
7545
7546
  * bitmark, JSON, or AST.
7546
7547
  * @param options - the conversion options
7547
- * @returns Promise that resolves to string if converting to bitmark, a plain JS object if converting to JSON, or
7548
+ * @returns A string if converting to bitmark, a plain JS object if converting to JSON, or
7548
7549
  * void if writing to a file
7549
7550
  * @throws Error if any error occurs
7550
7551
  */
7551
- convert(input: string | fs.PathLike | unknown, options?: ConvertOptions): Promise<string | unknown | void>;
7552
+ convert(input: string | fs.PathLike | unknown, options?: ConvertOptions): string | unknown | void;
7552
7553
  /**
7553
7554
  * Upgrade bitmark or JSON, upgrading to the latest supported syntax, removing unrecognised data in the process.
7554
7555
  *
@@ -7574,7 +7575,7 @@ declare class BitmarkParserGenerator {
7574
7575
  * void if writing to a file
7575
7576
  * @throws Error if any error occurs
7576
7577
  */
7577
- upgrade(input: string | fs.PathLike | unknown, options?: UpgradeOptions): Promise<string | unknown | void>;
7578
+ upgrade(input: string | fs.PathLike | unknown, options?: UpgradeOptions): string | unknown | void;
7578
7579
  /**
7579
7580
  * Create a bitmark AST (Abstract Syntax Tree) from bitmark or JSON or AST
7580
7581
  *
@@ -7609,7 +7610,7 @@ declare class BitmarkParserGenerator {
7609
7610
  * void if writing to a file
7610
7611
  * @throws Error if any error occurs
7611
7612
  */
7612
- convertText(input: string | fs.PathLike | unknown, options?: ConvertTextOptions): Promise<string | unknown | void>;
7613
+ convertText(input: string | fs.PathLike | unknown, options?: ConvertTextOptions): string | unknown | void;
7613
7614
  /**
7614
7615
  * Breakscape bitmark text.
7615
7616
  *
@@ -7733,12 +7734,20 @@ interface BitmarkFileGeneratorOptions extends BitmarkGeneratorOptions {
7733
7734
  * The options for file output.
7734
7735
  */
7735
7736
  fileOptions?: FileOptions;
7737
+ /**
7738
+ * If true, the file will be generated asynchronously - generateSync() will throw an error.
7739
+ * If false, the file will be generated synchronously.
7740
+ *
7741
+ * Defaults to false.
7742
+ */
7743
+ async?: boolean;
7736
7744
  }
7737
7745
  /**
7738
7746
  * Generate bitmark markup from a bitmark AST as a file
7739
7747
  */
7740
7748
  declare class BitmarkFileGenerator implements Generator<BitmarkAst> {
7741
7749
  private generator;
7750
+ private async;
7742
7751
  /**
7743
7752
  * Generate bitmark markup from a bitmark AST as a file
7744
7753
  *
@@ -7757,7 +7766,7 @@ declare class BitmarkFileGenerator implements Generator<BitmarkAst> {
7757
7766
  *
7758
7767
  * @param ast bitmark AST
7759
7768
  */
7760
- generateSync(_ast: BitmarkAst): string;
7769
+ generateSync(_ast: BitmarkAst): void;
7761
7770
  }
7762
7771
 
7763
7772
  /**
@@ -7768,14 +7777,21 @@ interface JsonFileGeneratorOptions extends JsonGeneratorOptions {
7768
7777
  * The options for file output.
7769
7778
  */
7770
7779
  fileOptions?: FileOptions;
7780
+ /**
7781
+ * If true, the file will be generated asynchronously - generateSync() will throw an error.
7782
+ * If false, the file will be generated synchronously.
7783
+ *
7784
+ * Defaults to false.
7785
+ */
7786
+ async?: boolean;
7771
7787
  }
7772
7788
  /**
7773
7789
  * Generate bitmark JSON from a bitmark AST as a file
7774
7790
  *
7775
- * TODO: NOT IMPLEMENTED!
7776
7791
  */
7777
7792
  declare class JsonFileGenerator implements Generator<BitmarkAst> {
7778
7793
  private generator;
7794
+ private async;
7779
7795
  /**
7780
7796
  * Generate bitmark JSON from a bitmark AST as a file
7781
7797
  *
@@ -7796,7 +7812,7 @@ declare class JsonFileGenerator implements Generator<BitmarkAst> {
7796
7812
  *
7797
7813
  * @param ast bitmark AST
7798
7814
  */
7799
- generateSync(_ast: BitmarkAst): string;
7815
+ generateSync(_ast: BitmarkAst): void;
7800
7816
  }
7801
7817
 
7802
7818
  export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AstWalkCallbacks, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type Bit, type BitJson, BitType, type BitTypeType, type BitWrapperJson, type BitmarkAst, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type Body, type BodyBitJson, type BodyBitsJson, type BodyPart, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, type BreakscapeOptions, type BreakscapedString, Builder, type CardBit, type CardNode, CardSetVersion, type CardSetVersionType, type ChoiceJson, type ConvertOptions, type ConvertTextOptions, type CreateAstOptions, type DefinitionListItemJson, type DocumentDownloadResourceJson, type DocumentDownloadResourceWrapperJson, type DocumentEmbedResourceJson, type DocumentEmbedResourceWrapperJson, type DocumentLinkResourceJson, type DocumentLinkResourceWrapperJson, type DocumentResourceJson, type DocumentResourceWrapperJson, type Example, type ExampleJson, type ExtraProperties, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type Footer, type GapJson, type Generator, type HeadingJson, type HighlightJson, type HighlightTextJson, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageSourceJson, InfoFormat, type InfoFormatType, type InfoOptions, InfoType, type InfoTypeType, type IngredientJson, Input, type InputType, JsonFileGenerator, JsonGenerator, type JsonOptions, JsonParser, JsonStringGenerator, type ListItemJson, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type Node, type NodeInfo, NodeType, type NodeTypeType, Output, type OutputType, type PairJson, type ParserJson, type PersonJson, type UpgradeOptions as PrettifyOptions, type PronunciationTableCellJson, type PronunciationTableJson, type Property, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceWrapperJson, type ResponseJson, type SelectJson, type SelectOptionJson, type ServingsJson, type StatementJson, type StillImageFilmEmbedResourceJson, type StillImageFilmEmbedResourceWrapperJson, type StillImageFilmLinkResourceJson, type StillImageFilmLinkResourceWrapperJson, type StillImageFilmResourceJson, type StillImageFilmResourceWrapperJson, StreamWriter, StringWriter, type TableJson, type TechnicalTermJson, type JsonText as Text, type TextAndIconJson, type TextAst, type TextJsonOptions, type UnbreakscapeOptions, type UpgradeOptions, type VideoEmbedResourceJson, type VideoEmbedResourceWrapperJson, type VideoLinkResourceJson, type VideoLinkResourceWrapperJson, type VideoResourceJson, type VideoResourceWrapperJson, type WebsiteLinkResourceJson, type WebsiteLinkResourceWrapperJson, type Writer, parse as bitmarkTextParse };
@@ -1463,12 +1463,12 @@ var StringUtils = class {
1463
1463
  subLength = width;
1464
1464
  rangeStartNext = rangeStart + width;
1465
1465
  }
1466
- subString = str.substr(rangeStart, subLength);
1466
+ subString = str.slice(rangeStart, rangeStart + subLength);
1467
1467
  rangeStart = rangeStartNext;
1468
1468
  result.push(subString.trim());
1469
1469
  }
1470
1470
  if (rangeStart < len) {
1471
- subString = str.substr(rangeStart);
1471
+ subString = str.slice(rangeStart);
1472
1472
  result.push(subString);
1473
1473
  }
1474
1474
  return result;
@@ -1480,6 +1480,7 @@ var StringUtils = class {
1480
1480
  * @returns the camelCase version of the string
1481
1481
  */
1482
1482
  kebabToCamel(str) {
1483
+ if (!str) return str;
1483
1484
  return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
1484
1485
  }
1485
1486
  };
@@ -8879,7 +8880,7 @@ var instance2 = new Config();
8879
8880
  // src/generated/package_info.ts
8880
8881
  var PACKAGE_INFO = {
8881
8882
  "name": "@gmb/bitmark-parser-generator",
8882
- "version": "3.38.0",
8883
+ "version": "4.0.0",
8883
8884
  "author": "Get More Brain Ltd",
8884
8885
  "license": "ISC",
8885
8886
  "description": "A bitmark parser and generator using Peggy.js"
@@ -20645,8 +20646,10 @@ var NodeValidator = class {
20645
20646
  if (!valid) {
20646
20647
  if (resource.type) {
20647
20648
  ret = {
20648
- type: resource.type
20649
- // __typeAlias: resource.type,
20649
+ type: resource.type,
20650
+ __typeAlias: resource.type,
20651
+ __configKey: resource.__configKey,
20652
+ __invalid: true
20650
20653
  };
20651
20654
  }
20652
20655
  }
@@ -24339,13 +24342,14 @@ var StringWriter = class {
24339
24342
  }
24340
24343
  writeLine(value) {
24341
24344
  if (!this._buffer) return this;
24345
+ let line;
24342
24346
  if (value != null) {
24343
- this._buffer.push(value + this.endOfLineString);
24344
- this.lastWrite = value + this.endOfLineString;
24347
+ line = value + this.endOfLineString;
24345
24348
  } else {
24346
- this._buffer.push(this.endOfLineString);
24347
- this.lastWrite = this.endOfLineString;
24349
+ line = this.endOfLineString;
24348
24350
  }
24351
+ this._buffer.push(line);
24352
+ this.lastWrite = line;
24349
24353
  return this;
24350
24354
  }
24351
24355
  writeLines(values, delimiter) {
@@ -31171,7 +31175,8 @@ function buildResources(context, resourceTypeAttachment, resources) {
31171
31175
  const countsMax = resourcesConfig.getCountsMax();
31172
31176
  if (resources) {
31173
31177
  for (const r of resources.reverse()) {
31174
- const configKey = resourceTypeToConfigKey(r.__typeAlias);
31178
+ if (r.__invalid) continue;
31179
+ const configKey = r.__configKey;
31175
31180
  let countMin = countsMin.get(configKey) ?? 0;
31176
31181
  let countMax = countsMax.get(configKey) ?? 0;
31177
31182
  countMin = Math.max(0, countMin - 1);
@@ -31192,7 +31197,7 @@ function buildResources(context, resourceTypeAttachment, resources) {
31192
31197
  context.addWarning(warningMsg);
31193
31198
  } else if (filteredResources.length === 0 && resourceTypeAttachment) {
31194
31199
  context.addWarning(
31195
- `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such a resource is present`
31200
+ `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such resource is present`
31196
31201
  );
31197
31202
  }
31198
31203
  if (excessResources.length > 0) {
@@ -35134,11 +35139,10 @@ var BitmarkParserGenerator = class {
35134
35139
  /**
35135
35140
  * Generate the new configuration for the bitmark parser.
35136
35141
  */
35137
- async generateConfig(options) {
35142
+ generateConfig(options) {
35138
35143
  const opts = Object.assign({}, options);
35139
35144
  const builder3 = new ConfigBuilder();
35140
- await builder3.build(opts);
35141
- return void 0;
35145
+ builder3.build(opts);
35142
35146
  }
35143
35147
  /**
35144
35148
  * Convert bitmark from bitmark to JSON, or JSON to bitmark.
@@ -35162,11 +35166,11 @@ var BitmarkParserGenerator = class {
35162
35166
  * @param input - bitmark or JSON or AST as a string, JSON or AST as plain JS object, or path to a file containing
35163
35167
  * bitmark, JSON, or AST.
35164
35168
  * @param options - the conversion options
35165
- * @returns Promise that resolves to string if converting to bitmark, a plain JS object if converting to JSON, or
35169
+ * @returns A string if converting to bitmark, a plain JS object if converting to JSON, or
35166
35170
  * void if writing to a file
35167
35171
  * @throws Error if any error occurs
35168
35172
  */
35169
- async convert(input, options) {
35173
+ convert(input, options) {
35170
35174
  let res;
35171
35175
  const opts = Object.assign({}, options);
35172
35176
  const jsonOptions = Object.assign({}, opts.jsonOptions);
@@ -35195,92 +35199,92 @@ var BitmarkParserGenerator = class {
35195
35199
  }
35196
35200
  const isJson = !!ast?.bits;
35197
35201
  const isBitmark = !isJson && !isAst;
35198
- const bitmarkToBitmark = async (bitmarkStr) => {
35199
- await bitmarkToAst(bitmarkStr);
35200
- await astToBitmark(res);
35202
+ const bitmarkToBitmark = (bitmarkStr) => {
35203
+ bitmarkToAst(bitmarkStr);
35204
+ astToBitmark(res);
35201
35205
  };
35202
- const bitmarkToAst = async (bitmarkStr) => {
35206
+ const bitmarkToAst = (bitmarkStr) => {
35203
35207
  res = this.bitmarkParser.toAst(bitmarkStr, {
35204
35208
  parserType: bitmarkParserType
35205
35209
  });
35206
35210
  };
35207
- const bitmarkToJson = async (bitmarkStr) => {
35211
+ const bitmarkToJson = (bitmarkStr) => {
35208
35212
  if (bitmarkParserType === BitmarkParserType.peggy) {
35209
35213
  ast = this.bitmarkParser.toAst(bitmarkStr, {
35210
35214
  parserType: bitmarkParserType
35211
35215
  });
35212
35216
  if (opts.outputFile) {
35213
35217
  const generator = new JsonFileGenerator(opts.outputFile, opts);
35214
- await generator.generate(ast);
35218
+ generator.generateSync(ast);
35215
35219
  } else {
35216
35220
  const generator = new JsonObjectGenerator(opts);
35217
- const json = await generator.generate(ast);
35221
+ const json = generator.generateSync(ast);
35218
35222
  res = this.jsonStringifyPrettify(json, jsonOptions);
35219
35223
  }
35220
35224
  }
35221
35225
  };
35222
- const astToBitmark = async (astJson) => {
35226
+ const astToBitmark = (astJson) => {
35223
35227
  if (opts.outputFile) {
35224
35228
  const generator = new BitmarkFileGenerator(opts.outputFile, opts);
35225
- await generator.generate(astJson);
35229
+ generator.generateSync(astJson);
35226
35230
  } else {
35227
35231
  const generator = new BitmarkStringGenerator(opts);
35228
- res = await generator.generate(astJson);
35232
+ res = generator.generateSync(astJson);
35229
35233
  }
35230
35234
  };
35231
- const astToAst = async (astJson) => {
35235
+ const astToAst = (astJson) => {
35232
35236
  res = this.jsonStringifyPrettify(astJson, jsonOptions);
35233
35237
  };
35234
- const astToJson = async (astJson) => {
35238
+ const astToJson = (astJson) => {
35235
35239
  if (opts.outputFile) {
35236
35240
  const generator = new JsonFileGenerator(opts.outputFile, opts);
35237
- await generator.generate(astJson);
35241
+ generator.generateSync(astJson);
35238
35242
  } else {
35239
35243
  const generator = new JsonObjectGenerator(opts);
35240
- const json = await generator.generate(astJson);
35244
+ const json = generator.generateSync(astJson);
35241
35245
  res = this.jsonStringifyPrettify(json, jsonOptions);
35242
35246
  }
35243
35247
  };
35244
- const jsonToBitmark = async (astJson) => {
35248
+ const jsonToBitmark = (astJson) => {
35245
35249
  if (opts.outputFile) {
35246
35250
  const generator = new BitmarkFileGenerator(opts.outputFile, opts);
35247
- await generator.generate(astJson);
35251
+ generator.generateSync(astJson);
35248
35252
  } else {
35249
35253
  const generator = new BitmarkStringGenerator(opts);
35250
- res = await generator.generate(astJson);
35254
+ res = generator.generateSync(astJson);
35251
35255
  }
35252
35256
  };
35253
- const jsonToAst = async (astJson) => {
35257
+ const jsonToAst = (astJson) => {
35254
35258
  res = this.jsonStringifyPrettify(astJson, jsonOptions);
35255
35259
  };
35256
- const jsonToJson = async (astJson) => {
35257
- await astToJson(astJson);
35260
+ const jsonToJson = (astJson) => {
35261
+ astToJson(astJson);
35258
35262
  };
35259
35263
  if (isBitmark) {
35260
35264
  if (outputBitmark) {
35261
- await bitmarkToBitmark(inStr);
35265
+ bitmarkToBitmark(inStr);
35262
35266
  } else if (outputAst) {
35263
- await bitmarkToAst(inStr);
35267
+ bitmarkToAst(inStr);
35264
35268
  } else {
35265
- await bitmarkToJson(inStr);
35269
+ bitmarkToJson(inStr);
35266
35270
  }
35267
35271
  } else if (isAst) {
35268
35272
  ast = ast;
35269
35273
  if (outputAst) {
35270
- await astToAst(ast);
35274
+ astToAst(ast);
35271
35275
  } else if (outputJson) {
35272
- await astToJson(ast);
35276
+ astToJson(ast);
35273
35277
  } else {
35274
- await astToBitmark(ast);
35278
+ astToBitmark(ast);
35275
35279
  }
35276
35280
  } else {
35277
35281
  ast = ast;
35278
35282
  if (outputJson) {
35279
- await jsonToJson(ast);
35283
+ jsonToJson(ast);
35280
35284
  } else if (outputAst) {
35281
- await jsonToAst(ast);
35285
+ jsonToAst(ast);
35282
35286
  } else {
35283
- await jsonToBitmark(ast);
35287
+ jsonToBitmark(ast);
35284
35288
  }
35285
35289
  }
35286
35290
  return res;
@@ -35310,7 +35314,7 @@ var BitmarkParserGenerator = class {
35310
35314
  * void if writing to a file
35311
35315
  * @throws Error if any error occurs
35312
35316
  */
35313
- async upgrade(input, options) {
35317
+ upgrade(input, options) {
35314
35318
  let res;
35315
35319
  const opts = Object.assign({}, options);
35316
35320
  const jsonOptions = Object.assign({}, opts.jsonOptions);
@@ -35331,33 +35335,33 @@ var BitmarkParserGenerator = class {
35331
35335
  let ast = this.jsonParser.toAst(inStr);
35332
35336
  const isJson = !!ast?.bits;
35333
35337
  const isBitmark = !isJson;
35334
- const bitmarkToBitmark = async (bitmarkStr) => {
35338
+ const bitmarkToBitmark = (bitmarkStr) => {
35335
35339
  const astJson = this.bitmarkParser.toAst(bitmarkStr, {
35336
35340
  parserType: bitmarkParserType
35337
35341
  });
35338
35342
  if (opts.outputFile) {
35339
35343
  const generator = new BitmarkFileGenerator(opts.outputFile, opts);
35340
- await generator.generate(astJson);
35344
+ generator.generateSync(astJson);
35341
35345
  } else {
35342
35346
  const generator = new BitmarkStringGenerator(opts);
35343
- res = await generator.generate(astJson);
35347
+ res = generator.generateSync(astJson);
35344
35348
  }
35345
35349
  };
35346
- const jsonToJson = async (astJson) => {
35350
+ const jsonToJson = (astJson) => {
35347
35351
  if (opts.outputFile) {
35348
35352
  const generator = new JsonFileGenerator(opts.outputFile, opts);
35349
- await generator.generate(astJson);
35353
+ generator.generateSync(astJson);
35350
35354
  } else {
35351
35355
  const generator = new JsonObjectGenerator(opts);
35352
- const json = await generator.generate(astJson);
35356
+ const json = generator.generateSync(astJson);
35353
35357
  res = this.jsonStringifyPrettify(json, jsonOptions);
35354
35358
  }
35355
35359
  };
35356
35360
  if (isBitmark) {
35357
- await bitmarkToBitmark(inStr);
35361
+ bitmarkToBitmark(inStr);
35358
35362
  } else {
35359
35363
  ast = ast;
35360
- await jsonToJson(ast);
35364
+ jsonToJson(ast);
35361
35365
  }
35362
35366
  return res;
35363
35367
  }
@@ -35421,7 +35425,7 @@ var BitmarkParserGenerator = class {
35421
35425
  * void if writing to a file
35422
35426
  * @throws Error if any error occurs
35423
35427
  */
35424
- async convertText(input, options) {
35428
+ convertText(input, options) {
35425
35429
  let res;
35426
35430
  let preRes;
35427
35431
  const opts = Object.assign({}, options);
@@ -35450,7 +35454,7 @@ var BitmarkParserGenerator = class {
35450
35454
  location: TextLocation.body
35451
35455
  });
35452
35456
  } else {
35453
- preRes = await this.textGenerator.generate(ast, textFormat, textLocation);
35457
+ preRes = this.textGenerator.generateSync(ast, textFormat, textLocation);
35454
35458
  }
35455
35459
  if (opts.outputFile) {
35456
35460
  const output = opts.outputFile.toString();