@gmb/bitmark-parser-generator 3.38.0 → 4.0.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.
@@ -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.1",
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) {
@@ -26633,6 +26637,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
26633
26637
  this.resetState();
26634
26638
  this.writer.openSync();
26635
26639
  this.walkAndWrite(ast);
26640
+ this.write(JSON.stringify(this.json, null, this.jsonPrettifySpace));
26636
26641
  this.writer.closeSync();
26637
26642
  }
26638
26643
  resetState() {
@@ -31171,7 +31176,8 @@ function buildResources(context, resourceTypeAttachment, resources) {
31171
31176
  const countsMax = resourcesConfig.getCountsMax();
31172
31177
  if (resources) {
31173
31178
  for (const r of resources.reverse()) {
31174
- const configKey = resourceTypeToConfigKey(r.__typeAlias);
31179
+ if (r.__invalid) continue;
31180
+ const configKey = r.__configKey;
31175
31181
  let countMin = countsMin.get(configKey) ?? 0;
31176
31182
  let countMax = countsMax.get(configKey) ?? 0;
31177
31183
  countMin = Math.max(0, countMin - 1);
@@ -31192,7 +31198,7 @@ function buildResources(context, resourceTypeAttachment, resources) {
31192
31198
  context.addWarning(warningMsg);
31193
31199
  } else if (filteredResources.length === 0 && resourceTypeAttachment) {
31194
31200
  context.addWarning(
31195
- `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such a resource is present`
31201
+ `Resource type [&${resourceTypeAttachment}] is specified in the bit header, but no such resource is present`
31196
31202
  );
31197
31203
  }
31198
31204
  if (excessResources.length > 0) {
@@ -35134,11 +35140,10 @@ var BitmarkParserGenerator = class {
35134
35140
  /**
35135
35141
  * Generate the new configuration for the bitmark parser.
35136
35142
  */
35137
- async generateConfig(options) {
35143
+ generateConfig(options) {
35138
35144
  const opts = Object.assign({}, options);
35139
35145
  const builder3 = new ConfigBuilder();
35140
- await builder3.build(opts);
35141
- return void 0;
35146
+ builder3.build(opts);
35142
35147
  }
35143
35148
  /**
35144
35149
  * Convert bitmark from bitmark to JSON, or JSON to bitmark.
@@ -35162,11 +35167,11 @@ var BitmarkParserGenerator = class {
35162
35167
  * @param input - bitmark or JSON or AST as a string, JSON or AST as plain JS object, or path to a file containing
35163
35168
  * bitmark, JSON, or AST.
35164
35169
  * @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
35170
+ * @returns A string if converting to bitmark, a plain JS object if converting to JSON, or
35166
35171
  * void if writing to a file
35167
35172
  * @throws Error if any error occurs
35168
35173
  */
35169
- async convert(input, options) {
35174
+ convert(input, options) {
35170
35175
  let res;
35171
35176
  const opts = Object.assign({}, options);
35172
35177
  const jsonOptions = Object.assign({}, opts.jsonOptions);
@@ -35195,92 +35200,92 @@ var BitmarkParserGenerator = class {
35195
35200
  }
35196
35201
  const isJson = !!ast?.bits;
35197
35202
  const isBitmark = !isJson && !isAst;
35198
- const bitmarkToBitmark = async (bitmarkStr) => {
35199
- await bitmarkToAst(bitmarkStr);
35200
- await astToBitmark(res);
35203
+ const bitmarkToBitmark = (bitmarkStr) => {
35204
+ bitmarkToAst(bitmarkStr);
35205
+ astToBitmark(res);
35201
35206
  };
35202
- const bitmarkToAst = async (bitmarkStr) => {
35207
+ const bitmarkToAst = (bitmarkStr) => {
35203
35208
  res = this.bitmarkParser.toAst(bitmarkStr, {
35204
35209
  parserType: bitmarkParserType
35205
35210
  });
35206
35211
  };
35207
- const bitmarkToJson = async (bitmarkStr) => {
35212
+ const bitmarkToJson = (bitmarkStr) => {
35208
35213
  if (bitmarkParserType === BitmarkParserType.peggy) {
35209
35214
  ast = this.bitmarkParser.toAst(bitmarkStr, {
35210
35215
  parserType: bitmarkParserType
35211
35216
  });
35212
35217
  if (opts.outputFile) {
35213
35218
  const generator = new JsonFileGenerator(opts.outputFile, opts);
35214
- await generator.generate(ast);
35219
+ generator.generateSync(ast);
35215
35220
  } else {
35216
35221
  const generator = new JsonObjectGenerator(opts);
35217
- const json = await generator.generate(ast);
35222
+ const json = generator.generateSync(ast);
35218
35223
  res = this.jsonStringifyPrettify(json, jsonOptions);
35219
35224
  }
35220
35225
  }
35221
35226
  };
35222
- const astToBitmark = async (astJson) => {
35227
+ const astToBitmark = (astJson) => {
35223
35228
  if (opts.outputFile) {
35224
35229
  const generator = new BitmarkFileGenerator(opts.outputFile, opts);
35225
- await generator.generate(astJson);
35230
+ generator.generateSync(astJson);
35226
35231
  } else {
35227
35232
  const generator = new BitmarkStringGenerator(opts);
35228
- res = await generator.generate(astJson);
35233
+ res = generator.generateSync(astJson);
35229
35234
  }
35230
35235
  };
35231
- const astToAst = async (astJson) => {
35236
+ const astToAst = (astJson) => {
35232
35237
  res = this.jsonStringifyPrettify(astJson, jsonOptions);
35233
35238
  };
35234
- const astToJson = async (astJson) => {
35239
+ const astToJson = (astJson) => {
35235
35240
  if (opts.outputFile) {
35236
35241
  const generator = new JsonFileGenerator(opts.outputFile, opts);
35237
- await generator.generate(astJson);
35242
+ generator.generateSync(astJson);
35238
35243
  } else {
35239
35244
  const generator = new JsonObjectGenerator(opts);
35240
- const json = await generator.generate(astJson);
35245
+ const json = generator.generateSync(astJson);
35241
35246
  res = this.jsonStringifyPrettify(json, jsonOptions);
35242
35247
  }
35243
35248
  };
35244
- const jsonToBitmark = async (astJson) => {
35249
+ const jsonToBitmark = (astJson) => {
35245
35250
  if (opts.outputFile) {
35246
35251
  const generator = new BitmarkFileGenerator(opts.outputFile, opts);
35247
- await generator.generate(astJson);
35252
+ generator.generateSync(astJson);
35248
35253
  } else {
35249
35254
  const generator = new BitmarkStringGenerator(opts);
35250
- res = await generator.generate(astJson);
35255
+ res = generator.generateSync(astJson);
35251
35256
  }
35252
35257
  };
35253
- const jsonToAst = async (astJson) => {
35258
+ const jsonToAst = (astJson) => {
35254
35259
  res = this.jsonStringifyPrettify(astJson, jsonOptions);
35255
35260
  };
35256
- const jsonToJson = async (astJson) => {
35257
- await astToJson(astJson);
35261
+ const jsonToJson = (astJson) => {
35262
+ astToJson(astJson);
35258
35263
  };
35259
35264
  if (isBitmark) {
35260
35265
  if (outputBitmark) {
35261
- await bitmarkToBitmark(inStr);
35266
+ bitmarkToBitmark(inStr);
35262
35267
  } else if (outputAst) {
35263
- await bitmarkToAst(inStr);
35268
+ bitmarkToAst(inStr);
35264
35269
  } else {
35265
- await bitmarkToJson(inStr);
35270
+ bitmarkToJson(inStr);
35266
35271
  }
35267
35272
  } else if (isAst) {
35268
35273
  ast = ast;
35269
35274
  if (outputAst) {
35270
- await astToAst(ast);
35275
+ astToAst(ast);
35271
35276
  } else if (outputJson) {
35272
- await astToJson(ast);
35277
+ astToJson(ast);
35273
35278
  } else {
35274
- await astToBitmark(ast);
35279
+ astToBitmark(ast);
35275
35280
  }
35276
35281
  } else {
35277
35282
  ast = ast;
35278
35283
  if (outputJson) {
35279
- await jsonToJson(ast);
35284
+ jsonToJson(ast);
35280
35285
  } else if (outputAst) {
35281
- await jsonToAst(ast);
35286
+ jsonToAst(ast);
35282
35287
  } else {
35283
- await jsonToBitmark(ast);
35288
+ jsonToBitmark(ast);
35284
35289
  }
35285
35290
  }
35286
35291
  return res;
@@ -35310,7 +35315,7 @@ var BitmarkParserGenerator = class {
35310
35315
  * void if writing to a file
35311
35316
  * @throws Error if any error occurs
35312
35317
  */
35313
- async upgrade(input, options) {
35318
+ upgrade(input, options) {
35314
35319
  let res;
35315
35320
  const opts = Object.assign({}, options);
35316
35321
  const jsonOptions = Object.assign({}, opts.jsonOptions);
@@ -35331,33 +35336,33 @@ var BitmarkParserGenerator = class {
35331
35336
  let ast = this.jsonParser.toAst(inStr);
35332
35337
  const isJson = !!ast?.bits;
35333
35338
  const isBitmark = !isJson;
35334
- const bitmarkToBitmark = async (bitmarkStr) => {
35339
+ const bitmarkToBitmark = (bitmarkStr) => {
35335
35340
  const astJson = this.bitmarkParser.toAst(bitmarkStr, {
35336
35341
  parserType: bitmarkParserType
35337
35342
  });
35338
35343
  if (opts.outputFile) {
35339
35344
  const generator = new BitmarkFileGenerator(opts.outputFile, opts);
35340
- await generator.generate(astJson);
35345
+ generator.generateSync(astJson);
35341
35346
  } else {
35342
35347
  const generator = new BitmarkStringGenerator(opts);
35343
- res = await generator.generate(astJson);
35348
+ res = generator.generateSync(astJson);
35344
35349
  }
35345
35350
  };
35346
- const jsonToJson = async (astJson) => {
35351
+ const jsonToJson = (astJson) => {
35347
35352
  if (opts.outputFile) {
35348
35353
  const generator = new JsonFileGenerator(opts.outputFile, opts);
35349
- await generator.generate(astJson);
35354
+ generator.generateSync(astJson);
35350
35355
  } else {
35351
35356
  const generator = new JsonObjectGenerator(opts);
35352
- const json = await generator.generate(astJson);
35357
+ const json = generator.generateSync(astJson);
35353
35358
  res = this.jsonStringifyPrettify(json, jsonOptions);
35354
35359
  }
35355
35360
  };
35356
35361
  if (isBitmark) {
35357
- await bitmarkToBitmark(inStr);
35362
+ bitmarkToBitmark(inStr);
35358
35363
  } else {
35359
35364
  ast = ast;
35360
- await jsonToJson(ast);
35365
+ jsonToJson(ast);
35361
35366
  }
35362
35367
  return res;
35363
35368
  }
@@ -35421,7 +35426,7 @@ var BitmarkParserGenerator = class {
35421
35426
  * void if writing to a file
35422
35427
  * @throws Error if any error occurs
35423
35428
  */
35424
- async convertText(input, options) {
35429
+ convertText(input, options) {
35425
35430
  let res;
35426
35431
  let preRes;
35427
35432
  const opts = Object.assign({}, options);
@@ -35450,7 +35455,7 @@ var BitmarkParserGenerator = class {
35450
35455
  location: TextLocation.body
35451
35456
  });
35452
35457
  } else {
35453
- preRes = await this.textGenerator.generate(ast, textFormat, textLocation);
35458
+ preRes = this.textGenerator.generateSync(ast, textFormat, textLocation);
35454
35459
  }
35455
35460
  if (opts.outputFile) {
35456
35461
  const output = opts.outputFile.toString();