yini-parser 1.1.0-beta → 1.3.0-beta

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +50 -2
  2. package/README.md +2 -2
  3. package/dist/YINI.d.ts +155 -27
  4. package/dist/YINI.js +145 -174
  5. package/dist/YINI.js.map +1 -0
  6. package/dist/config/env.js +1 -0
  7. package/dist/config/env.js.map +1 -0
  8. package/dist/core/{ASTBuilder.d.ts → astBuilder.d.ts} +4 -4
  9. package/dist/core/{ASTBuilder.js → astBuilder.js} +82 -69
  10. package/dist/core/astBuilder.js.map +1 -0
  11. package/dist/core/{ErrorDataHandler.d.ts → errorDataHandler.d.ts} +16 -10
  12. package/dist/core/{ErrorDataHandler.js → errorDataHandler.js} +115 -109
  13. package/dist/core/errorDataHandler.js.map +1 -0
  14. package/dist/core/internalTypes.d.ts +127 -0
  15. package/dist/core/{types.js → internalTypes.js} +6 -0
  16. package/dist/core/internalTypes.js.map +1 -0
  17. package/dist/core/objectBuilder.d.ts +2 -2
  18. package/dist/core/objectBuilder.js +1 -0
  19. package/dist/core/objectBuilder.js.map +1 -0
  20. package/dist/core/options/defaultParserOptions.d.ts +17 -0
  21. package/dist/core/options/defaultParserOptions.js +46 -0
  22. package/dist/core/options/defaultParserOptions.js.map +1 -0
  23. package/dist/core/options/failLevel.d.ts +3 -0
  24. package/dist/core/options/failLevel.js +27 -0
  25. package/dist/core/options/failLevel.js.map +1 -0
  26. package/dist/core/options/optionsFunctions.d.ts +8 -0
  27. package/dist/core/options/optionsFunctions.js +62 -0
  28. package/dist/core/options/optionsFunctions.js.map +1 -0
  29. package/dist/core/parsingRules/modeFromRulesMatcher.d.ts +8 -0
  30. package/dist/core/parsingRules/modeFromRulesMatcher.js +114 -0
  31. package/dist/core/parsingRules/modeFromRulesMatcher.js.map +1 -0
  32. package/dist/core/parsingRules/rulesConstAndGuards.d.ts +7 -0
  33. package/dist/core/parsingRules/rulesConstAndGuards.js +35 -0
  34. package/dist/core/parsingRules/rulesConstAndGuards.js.map +1 -0
  35. package/dist/core/pipeline/errorListeners.d.ts +18 -0
  36. package/dist/core/pipeline/errorListeners.js +107 -0
  37. package/dist/core/pipeline/errorListeners.js.map +1 -0
  38. package/dist/core/pipeline/pipeline.d.ts +18 -0
  39. package/dist/core/pipeline/pipeline.js +244 -0
  40. package/dist/core/pipeline/pipeline.js.map +1 -0
  41. package/dist/core/resultMetadataBuilder.d.ts +19 -0
  42. package/dist/core/resultMetadataBuilder.js +187 -0
  43. package/dist/core/resultMetadataBuilder.js.map +1 -0
  44. package/dist/core/runtime.d.ts +21 -0
  45. package/dist/core/runtime.js +201 -0
  46. package/dist/core/runtime.js.map +1 -0
  47. package/dist/dev/main.d.ts +1 -0
  48. package/dist/dev/main.js +305 -0
  49. package/dist/dev/main.js.map +1 -0
  50. package/dist/grammar/{YiniLexer.js → generated/YiniLexer.js} +2 -1
  51. package/dist/grammar/generated/YiniLexer.js.map +1 -0
  52. package/dist/grammar/{YiniParser.js → generated/YiniParser.js} +2 -1
  53. package/dist/grammar/generated/YiniParser.js.map +1 -0
  54. package/dist/grammar/{YiniParserVisitor.js → generated/YiniParserVisitor.js} +2 -1
  55. package/dist/grammar/generated/YiniParserVisitor.js.map +1 -0
  56. package/dist/index.d.ts +40 -1
  57. package/dist/index.js +60 -359
  58. package/dist/index.js.map +1 -0
  59. package/dist/parsers/extractHeaderParts.d.ts +2 -2
  60. package/dist/parsers/extractHeaderParts.js +2 -1
  61. package/dist/parsers/extractHeaderParts.js.map +1 -0
  62. package/dist/parsers/extractSignificantYiniLine.js +2 -1
  63. package/dist/parsers/extractSignificantYiniLine.js.map +1 -0
  64. package/dist/parsers/parseBoolean.js +1 -0
  65. package/dist/parsers/parseBoolean.js.map +1 -0
  66. package/dist/parsers/parseNull.js +1 -0
  67. package/dist/parsers/parseNull.js.map +1 -0
  68. package/dist/parsers/parseNumber.js +1 -0
  69. package/dist/parsers/parseNumber.js.map +1 -0
  70. package/dist/parsers/parseSectionHeader.d.ts +3 -3
  71. package/dist/parsers/parseSectionHeader.js +2 -1
  72. package/dist/parsers/parseSectionHeader.js.map +1 -0
  73. package/dist/parsers/parseString.js +3 -3
  74. package/dist/parsers/parseString.js.map +1 -0
  75. package/dist/types/index.d.ts +219 -0
  76. package/dist/types/index.js +4 -0
  77. package/dist/types/index.js.map +1 -0
  78. package/dist/utils/number.js +1 -0
  79. package/dist/utils/number.js.map +1 -0
  80. package/dist/utils/object.d.ts +12 -0
  81. package/dist/utils/object.js +41 -1
  82. package/dist/utils/object.js.map +1 -0
  83. package/dist/utils/pathAndFileName.js +1 -0
  84. package/dist/utils/pathAndFileName.js.map +1 -0
  85. package/dist/utils/print.d.ts +2 -2
  86. package/dist/utils/print.js +11 -6
  87. package/dist/utils/print.js.map +1 -0
  88. package/dist/utils/string.d.ts +5 -0
  89. package/dist/utils/string.js +10 -1
  90. package/dist/utils/string.js.map +1 -0
  91. package/dist/utils/system.js +1 -0
  92. package/dist/utils/system.js.map +1 -0
  93. package/dist/{yiniHelpers.d.ts → utils/yiniHelpers.d.ts} +1 -1
  94. package/dist/{yiniHelpers.js → utils/yiniHelpers.js} +3 -2
  95. package/dist/utils/yiniHelpers.js.map +1 -0
  96. package/examples/basic-output.js +12 -12
  97. package/package.json +11 -6
  98. package/dist/core/types.d.ts +0 -249
  99. package/dist/parseEntry.d.ts +0 -3
  100. package/dist/parseEntry.js +0 -456
  101. /package/dist/grammar/{YiniLexer.d.ts → generated/YiniLexer.d.ts} +0 -0
  102. /package/dist/grammar/{YiniParser.d.ts → generated/YiniParser.d.ts} +0 -0
  103. /package/dist/grammar/{YiniParserVisitor.d.ts → generated/YiniParserVisitor.d.ts} +0 -0
package/dist/YINI.js CHANGED
@@ -1,50 +1,20 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const perf_hooks_1 = require("perf_hooks");
8
3
  const env_1 = require("./config/env");
9
- const ErrorDataHandler_1 = require("./core/ErrorDataHandler");
10
- const parseEntry_1 = require("./parseEntry");
11
- const pathAndFileName_1 = require("./utils/pathAndFileName");
4
+ const errorDataHandler_1 = require("./core/errorDataHandler");
5
+ const optionsFunctions_1 = require("./core/options/optionsFunctions");
6
+ const runtime_1 = require("./core/runtime");
12
7
  const print_1 = require("./utils/print");
13
- const string_1 = require("./utils/string");
14
8
  const DEFAULT_TAB_SIZE = 4; // De facto "modern default" (even though traditionally/historically it's 8).
15
- let _runtimeInfo = {
16
- sourceType: 'Inline',
17
- fileName: undefined,
18
- fileByteSize: null,
19
- lineCount: null,
20
- timeIoMs: null,
21
- preferredBailSensitivity: null,
22
- sha256: null,
23
- };
24
- // Type guard: did the caller use the options-object form?
25
- const isOptionsObjectForm = (v) => {
26
- return (v != null &&
27
- typeof v === 'object' &&
28
- // Note: If one wants, this can be relax to "typeof v === 'object'"
29
- // but this keeps accidental booleans/strings out.
30
- ('strictMode' in v ||
31
- 'failLevel' in v ||
32
- 'includeMetaData' in v ||
33
- 'includeDiagnostics' in v ||
34
- 'includeTiming' in v ||
35
- 'preserveUndefinedInMeta' in v ||
36
- 'requireDocTerminator' in v));
37
- };
38
- // Initial default values.
39
- const DEFAULT_OPTS = {
40
- strictMode: false,
41
- failLevel: 'auto',
42
- includeMetaData: false,
43
- includeDiagnostics: false,
44
- includeTiming: false,
45
- preserveUndefinedInMeta: false,
46
- requireDocTerminator: false,
47
- };
9
+ // let _runtimeInfo: IRuntimeInfo = {
10
+ // sourceType: 'Inline',
11
+ // fileName: undefined,
12
+ // fileByteSize: null,
13
+ // lineCount: null,
14
+ // timeIoMs: null,
15
+ // preferredBailSensitivity: null,
16
+ // sha256: null,
17
+ // }
48
18
  /**
49
19
  * This class is the public API, which exposes only parse(..) and
50
20
  * parseFile(..), rest of the implementation details are hidden.
@@ -63,7 +33,8 @@ class YINI {
63
33
  */
64
34
  static setTabSize(spaces) {
65
35
  if (spaces < 1 || spaces > 32) {
66
- new ErrorDataHandler_1.ErrorDataHandler('None/Ignore').pushOrBail(null, 'Fatal-Error', `Invalid tab size ${spaces} is out of range.`, 'Tab size must be between 1 and 32 spaces.');
36
+ new errorDataHandler_1.ErrorDataHandler('None/Ignore').pushOrBail(null, 'Fatal-Error', `Invalid tab size ${spaces} is out of range.`, 'Tab size must be between 1 and 32 spaces.');
37
+ throw new RangeError(`Tab size ${spaces} is out of range (1–32).`);
67
38
  }
68
39
  this.g_tabSize = spaces;
69
40
  }
@@ -71,76 +42,67 @@ class YINI {
71
42
  // Implementation method (not declared with arrow function) for both method overload signatures.
72
43
  // NOTE: Must be method declaration with NO =, arrow functions not (currently) supported for this type of method overloading.
73
44
  static parse(yiniContent, arg2, // strictMode | options
74
- failLevel = DEFAULT_OPTS.failLevel, includeMetaData = DEFAULT_OPTS.includeMetaData) {
75
- var _a, _b, _c, _d, _e, _f, _g, _h;
45
+ failLevel = 'auto', includeMetadata = false) {
76
46
  (0, print_1.debugPrint)('-> Entered static parse(..) in class YINI\n');
77
- // Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
78
- if (isOptionsObjectForm(arg2) &&
79
- (failLevel !== 'auto' || includeMetaData !== false)) {
80
- throw new TypeError('Invalid call: when providing an options object, do not also pass positional parameters.');
81
- }
82
- // Normalize to a fully-required options object.
83
- let userOpts;
84
- // Required, makes all properties in T required, no undefined.
85
- // const userOpts: Required<IAllUserOptions> = isOptionsObjectForm(arg2)
86
- if (isOptionsObjectForm(arg2)) {
87
- // Options-object Form.
88
- /* parse = (
89
- yiniContent: string,
90
- options: IAllUserOptions,
91
- )
92
- */
93
- userOpts = Object.assign(Object.assign({}, DEFAULT_OPTS), { strictMode: (_a = arg2.strictMode) !== null && _a !== void 0 ? _a : DEFAULT_OPTS.strictMode, failLevel: (_b = arg2.failLevel) !== null && _b !== void 0 ? _b : DEFAULT_OPTS.failLevel, includeMetaData: (_c = arg2.includeMetaData) !== null && _c !== void 0 ? _c : DEFAULT_OPTS.includeMetaData, includeDiagnostics: (_d = arg2.includeDiagnostics) !== null && _d !== void 0 ? _d : DEFAULT_OPTS.includeDiagnostics, includeTiming: (_e = arg2.includeTiming) !== null && _e !== void 0 ? _e : DEFAULT_OPTS.includeTiming, preserveUndefinedInMeta: (_f = arg2.preserveUndefinedInMeta) !== null && _f !== void 0 ? _f : DEFAULT_OPTS.preserveUndefinedInMeta, requireDocTerminator: (_g = arg2.requireDocTerminator) !== null && _g !== void 0 ? _g : DEFAULT_OPTS.requireDocTerminator });
94
- }
95
- else {
96
- // Positional form.
97
- /* parse = (
98
- yiniContent: string,
99
- strictMode?: boolean,
100
- failLevel?: TPreferredFailLevel,
101
- includeMetaData?: boolean,
102
- )
103
- */
104
- userOpts = Object.assign(Object.assign({}, DEFAULT_OPTS), { strictMode: (_h = arg2) !== null && _h !== void 0 ? _h : DEFAULT_OPTS.strictMode, failLevel,
105
- includeMetaData });
106
- }
107
- if (userOpts.includeMetaData && _runtimeInfo.sourceType === 'Inline') {
108
- const lineCount = yiniContent.split(/\r?\n/).length; // Counts the lines.
109
- const sha256 = (0, string_1.computeSha256)(yiniContent); // NOTE: Compute BEFORE any possible tampering of content.
110
- _runtimeInfo.lineCount = lineCount;
111
- _runtimeInfo.preferredBailSensitivity = userOpts.failLevel;
112
- _runtimeInfo.sha256 = sha256;
113
- }
114
- // NOTE: Important: Do not trim or mutate the yiniContent here, due
115
- // to it will mess up the line numbers in error reporting.
116
- if (!yiniContent) {
117
- throw new Error('Syntax-Error: Unexpected blank YINI input');
118
- }
119
- if (!yiniContent.endsWith('\n')) {
120
- yiniContent += '\n';
121
- }
122
- let level = 0;
123
- if (userOpts.failLevel === 'auto') {
124
- if (!userOpts.strictMode)
125
- level = 0;
126
- if (userOpts.strictMode)
127
- level = 1;
128
- }
129
- else {
130
- level = userOpts.failLevel;
131
- }
132
- const coreOpts = {
133
- isStrict: userOpts.strictMode,
134
- bailSensitivity: level,
135
- isIncludeMeta: userOpts.includeMetaData,
136
- isWithDiagnostics: (0, env_1.isDev)() || (0, env_1.isDebug)() || userOpts.includeDiagnostics,
137
- isWithTiming: (0, env_1.isDev)() || (0, env_1.isDebug)() || userOpts.includeTiming,
138
- isKeepUndefinedInMeta: (0, env_1.isDebug)() || userOpts.preserveUndefinedInMeta,
139
- isRequireDocTerminator: userOpts.requireDocTerminator,
140
- };
47
+ // // Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
48
+ // if (
49
+ // isOptionsObjectForm(arg2) &&
50
+ // (failLevel !== 'auto' || includeMetadata !== false)
51
+ // ) {
52
+ // throw new TypeError(
53
+ // 'Invalid call: when providing an options object, do not also pass positional parameters.',
54
+ // )
55
+ // }
56
+ // const mode: TParserMode = inferModeFromArgs(arg2)
57
+ // const defaultOptions = getDefaultOptions(mode)
58
+ // // Normalize to a fully-required options object.
59
+ // let userOpts: Required<ParseOptions>
60
+ // // Required, makes all properties in T required, no undefined.
61
+ // if (isOptionsObjectForm(arg2)) {
62
+ // userOpts = {
63
+ // ...defaultOptions, // Sets the default options.
64
+ // ...arg2,
65
+ // }
66
+ // } else {
67
+ // // Positional form.
68
+ // userOpts = {
69
+ // ...defaultOptions, // Sets the default options.
70
+ // strictMode:
71
+ // (arg2 as boolean | undefined) ?? defaultOptions.strictMode,
72
+ // failLevel,
73
+ // includeMetadata,
74
+ // }
75
+ // }
76
+ // if (userOpts.includeMetadata && _runtimeInfo.sourceType === 'Inline') {
77
+ // const lineCount = yiniContent.split(/\r?\n/).length // Counts the lines.
78
+ // const sha256 = computeSha256(yiniContent) // NOTE: Compute BEFORE any possible tampering of content.
79
+ // _runtimeInfo.lineCount = lineCount
80
+ // _runtimeInfo.preferredBailSensitivity = userOpts.failLevel
81
+ // _runtimeInfo.sha256 = sha256
82
+ // }
83
+ // // NOTE: Important: Do not trim or mutate the yiniContent here, due
84
+ // // to it will mess up the line numbers in error reporting.
85
+ // if (!yiniContent) {
86
+ // throw new Error('Syntax-Error: Unexpected blank YINI input')
87
+ // }
88
+ // if (!yiniContent.endsWith('\n')) {
89
+ // yiniContent += '\n'
90
+ // }
91
+ // let level: TBailSensitivityLevel = mapFailLevelToBail(
92
+ // userOpts.strictMode,
93
+ // userOpts.failLevel,
94
+ // )
95
+ ////////////////
96
+ // const coreOpts: IParseCoreOptions = toCoreOptions(userOpts,level)
141
97
  (0, print_1.debugPrint)();
142
- (0, print_1.debugPrint)('==== Call parse ==========================');
143
- const result = (0, parseEntry_1._parseMain)(yiniContent, coreOpts, _runtimeInfo);
98
+ (0, print_1.debugPrint)('==== Call doParse(..) in runtime ==========================');
99
+ // const result = _parseMain(yiniContent, coreOpts, _runtimeInfo)
100
+ const runtime = new runtime_1.YiniRuntime('Inline');
101
+ const result = (0, optionsFunctions_1.isOptionsObjectForm)(arg2)
102
+ ? runtime.doParse(yiniContent, arg2) // Overload #2: (content, options)
103
+ : runtime.doParse(
104
+ // Overload #1: (content, strict?, failLevel?, includeMeta?)
105
+ yiniContent, arg2, failLevel, includeMetadata);
144
106
  (0, print_1.debugPrint)('==== End call parse ==========================\n');
145
107
  if ((0, env_1.isDev)()) {
146
108
  console.log();
@@ -155,73 +117,82 @@ class YINI {
155
117
  // Implementation method (not declared with arrow function) for both method overload signatures.
156
118
  // NOTE: Must be method declaration with NO =, arrow functions not (currently) supported for this type of method overloading.
157
119
  static parseFile(filePath, arg2, // strictMode | options
158
- failLevel = DEFAULT_OPTS.failLevel, includeMetaData = DEFAULT_OPTS.includeMetaData) {
159
- var _a, _b, _c, _d, _e, _f, _g, _h;
120
+ failLevel = 'auto', includeMetadata = false) {
160
121
  (0, print_1.debugPrint)('-> Entered static parseFile(..) in class YINI\n');
161
122
  (0, print_1.debugPrint)('Current directory = ' + process.cwd());
162
- // Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
163
- if (isOptionsObjectForm(arg2) &&
164
- (failLevel !== 'auto' || includeMetaData !== false)) {
165
- throw new TypeError('Invalid call: when providing an options object, do not also pass positional parameters.');
166
- }
167
- // Normalize to a fully-required options object.
168
- let userOpts;
169
- // Required, makes all properties in T required, no undefined.
170
- // const userOpts: Required<IAllUserOptions> = isOptionsObjectForm(arg2)
171
- if (isOptionsObjectForm(arg2)) {
172
- // Options-object Form.
173
- /* parse = (
174
- yiniContent: string,
175
- options: IAllUserOptions,
176
- )
177
- */
178
- userOpts = Object.assign(Object.assign({}, DEFAULT_OPTS), { strictMode: (_a = arg2.strictMode) !== null && _a !== void 0 ? _a : DEFAULT_OPTS.strictMode, failLevel: (_b = arg2.failLevel) !== null && _b !== void 0 ? _b : DEFAULT_OPTS.failLevel, includeMetaData: (_c = arg2.includeMetaData) !== null && _c !== void 0 ? _c : DEFAULT_OPTS.includeMetaData, includeDiagnostics: (_d = arg2.includeDiagnostics) !== null && _d !== void 0 ? _d : DEFAULT_OPTS.includeDiagnostics, includeTiming: (_e = arg2.includeTiming) !== null && _e !== void 0 ? _e : DEFAULT_OPTS.includeTiming, preserveUndefinedInMeta: (_f = arg2.preserveUndefinedInMeta) !== null && _f !== void 0 ? _f : DEFAULT_OPTS.preserveUndefinedInMeta, requireDocTerminator: (_g = arg2.requireDocTerminator) !== null && _g !== void 0 ? _g : DEFAULT_OPTS.requireDocTerminator });
179
- }
180
- else {
181
- // Positional form.
182
- /* parse = (
183
- yiniContent: string,
184
- strictMode?: boolean,
185
- failLevel?: TPreferredFailLevel,
186
- includeMetaData?: boolean,
187
- )
188
- */
189
- userOpts = Object.assign(Object.assign({}, DEFAULT_OPTS), { strictMode: (_h = arg2) !== null && _h !== void 0 ? _h : DEFAULT_OPTS.strictMode, failLevel,
190
- includeMetaData });
191
- }
192
- if ((0, pathAndFileName_1.getFileNameExtension)(filePath).toLowerCase() !== '.yini') {
193
- console.error('Invalid file extension for YINI file:');
194
- console.error(`"${filePath}"`);
195
- console.log('File does not have a valid ".yini" extension (case-insensitive).');
196
- throw new Error('Error: Unexpected file extension for YINI file');
197
- }
198
- // ---- Phase 0: I/O ----
199
- const timeStartMs = perf_hooks_1.performance.now();
200
- // let content = fs.readFileSync(filePath, 'utf8')
201
- const rawBuffer = fs_1.default.readFileSync(filePath); // Raw buffer for size.
202
- const fileByteSize = rawBuffer.byteLength; // Byte size in UTF-8.
203
- let content = rawBuffer.toString('utf8');
204
- const timeEndMs = perf_hooks_1.performance.now();
205
- _runtimeInfo.sourceType = 'File';
206
- _runtimeInfo.fileName = filePath;
207
- if (userOpts.includeMetaData) {
208
- _runtimeInfo.lineCount = content.split(/\r?\n/).length; // Counts the lines.
209
- _runtimeInfo.fileByteSize = fileByteSize;
210
- _runtimeInfo.timeIoMs = +(timeEndMs - timeStartMs);
211
- _runtimeInfo.preferredBailSensitivity = userOpts.failLevel;
212
- _runtimeInfo.sha256 = (0, string_1.computeSha256)(content); // NOTE: Compute BEFORE any possible tampering of content.
213
- }
214
- let hasNoNewlineAtEOF = false;
215
- if (!content.endsWith('\n')) {
216
- content += '\n';
217
- hasNoNewlineAtEOF = true;
218
- }
219
- const result = this.parse(content, userOpts.strictMode, userOpts.failLevel, userOpts.includeMetaData);
220
- if (hasNoNewlineAtEOF) {
221
- console.warn(`No newline at end of file, it's recommended to end a file with a newline. File:\n"${filePath}"`);
222
- }
123
+ // // Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
124
+ // if (
125
+ // isOptionsObjectForm(arg2) &&
126
+ // (failLevel !== 'auto' || includeMetadata !== false)
127
+ // ) {
128
+ // throw new TypeError(
129
+ // 'Invalid call: when providing an options object, do not also pass positional parameters.',
130
+ // )
131
+ // }
132
+ // const mode: TParserMode = inferModeFromArgs(arg2)
133
+ // const defaultOptions = getDefaultOptions(mode)
134
+ // // Normalize to a fully-required options object.
135
+ // let userOpts: Required<ParseOptions>
136
+ // // Required, makes all properties in T required, no undefined.
137
+ // if (isOptionsObjectForm(arg2)) {
138
+ // // Options-object Form.
139
+ // userOpts = {
140
+ // ...defaultOptions, // Sets the default options.
141
+ // ...arg2,
142
+ // }
143
+ // } else {
144
+ // // Positional form.
145
+ // userOpts = {
146
+ // ...defaultOptions, // Sets the default options.
147
+ // strictMode:
148
+ // (arg2 as boolean | undefined) ?? defaultOptions.strictMode,
149
+ // failLevel,
150
+ // includeMetadata,
151
+ // }
152
+ // }
153
+ // if (getFileNameExtension(filePath).toLowerCase() !== '.yini') {
154
+ // console.error('Invalid file extension for YINI file:')
155
+ // console.error(`"${filePath}"`)
156
+ // console.log(
157
+ // 'File does not have a valid ".yini" extension (case-insensitive).',
158
+ // )
159
+ // throw new Error('Error: Unexpected file extension for YINI file')
160
+ // }
161
+ // // ---- Phase 0: I/O ----
162
+ // const timeStartMs = performance.now()
163
+ // // let content = fs.readFileSync(filePath, 'utf8')
164
+ // const rawBuffer = fs.readFileSync(filePath) // Raw buffer for size.
165
+ // const fileByteSize = rawBuffer.byteLength // Byte size in UTF-8.
166
+ // let content = rawBuffer.toString('utf8')
167
+ // const timeEndMs = performance.now()
168
+ // _runtimeInfo.sourceType = 'File'
169
+ // _runtimeInfo.fileName = filePath
170
+ // if (userOpts.includeMetadata) {
171
+ // _runtimeInfo.lineCount = content.split(/\r?\n/).length // Counts the lines.
172
+ // _runtimeInfo.fileByteSize = fileByteSize
173
+ // _runtimeInfo.timeIoMs = +(timeEndMs - timeStartMs).toFixed(3)
174
+ // _runtimeInfo.preferredBailSensitivity = userOpts.failLevel
175
+ // _runtimeInfo.sha256 = computeSha256(content) // NOTE: Compute BEFORE any possible tampering of content.
176
+ // }
177
+ // let hasNoNewlineAtEOF = false
178
+ // if (!content.endsWith('\n')) {
179
+ // content += '\n'
180
+ // hasNoNewlineAtEOF = true
181
+ // }
182
+ (0, print_1.debugPrint)();
183
+ (0, print_1.debugPrint)('==== Call doParseFile(..) in runtime ==========================');
184
+ // const result = _parseMain(yiniContent, coreOpts, _runtimeInfo)
185
+ const runtime = new runtime_1.YiniRuntime('File');
186
+ const result = (0, optionsFunctions_1.isOptionsObjectForm)(arg2)
187
+ ? runtime.doParseFile(filePath, arg2) // Overload #2: (content, options)
188
+ : runtime.doParseFile(
189
+ // Overload #1: (content, strict?, failLevel?, includeMeta?)
190
+ filePath, arg2, failLevel, includeMetadata);
191
+ (0, print_1.debugPrint)('==== End call parse ==========================\n');
223
192
  return result;
224
193
  }
225
194
  }
195
+ // @todo In future move/change this to not be a global and suffer from possible race conditions, possibly move this into YiniRuntime class.
226
196
  YINI.g_tabSize = DEFAULT_TAB_SIZE; // Global tab size used in error messages.
227
197
  exports.default = YINI;
198
+ //# sourceMappingURL=YINI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YINI.js","sourceRoot":"","sources":["../src/YINI.ts"],"names":[],"mappings":";;AAAA,sCAA6C;AAC7C,8DAA0D;AAC1D,sEAAqE;AACrE,4CAA4C;AAO5C,yCAAiE;AAEjE,MAAM,gBAAgB,GAAG,CAAC,CAAA,CAAC,6EAA6E;AAExG,qCAAqC;AACrC,4BAA4B;AAC5B,2BAA2B;AAC3B,0BAA0B;AAC1B,uBAAuB;AACvB,sBAAsB;AACtB,sCAAsC;AACtC,oBAAoB;AACpB,IAAI;AAEJ;;;;GAIG;AACH,MAAqB,IAAI;IAIrB;;OAEG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,CAAC,SAAS,CAAA;IACzB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU,CAAC,MAAc;QACnC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,EAAE,CAAC;YAC5B,IAAI,mCAAgB,CAAC,aAAa,CAAC,CAAC,UAAU,CAC1C,IAAI,EACJ,aAAa,EACb,oBAAoB,MAAM,mBAAmB,EAC7C,2CAA2C,CAC9C,CAAA;YACD,MAAM,IAAI,UAAU,CAAC,YAAY,MAAM,0BAA0B,CAAC,CAAA;QACtE,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAA;IAC3B,CAAC;IA6GD,yEAAyE;IACzE,gGAAgG;IAChG,6HA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AC5B,wCAAwC;QAExC,qDAAqD;QACrD,sEAAsE;QACtE,mEAAmE;QAEnE,2CAA2C;QAC3C,sCAAsC;QAEtC,mCAAmC;QACnC,mCAAmC;QAEnC,kCAAkC;QAClC,kFAAkF;QAClF,+CAA+C;QAC/C,oEAAoE;QACpE,iEAAiE;QACjE,8GAA8G;QAC9G,IAAI;QAEJ,gCAAgC;QAChC,iCAAiC;QACjC,sBAAsB;QACtB,+BAA+B;QAC/B,IAAI;QAEJ,IAAA,kBAAU,GAAE,CAAA;QACZ,IAAA,kBAAU,EACN,iEAAiE,CACpE,CAAA;QACD,iEAAiE;QACjE,MAAM,OAAO,GAAG,IAAI,qBAAW,CAAC,MAAM,CAAC,CAAA;QAEvC,MAAM,MAAM,GAAG,IAAA,sCAAmB,EAAC,IAAI,CAAC;YACpC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,kCAAkC;YACxE,CAAC,CAAC,OAAO,CAAC,WAAW;YACf,4DAA4D;YAC5D,QAAQ,EACR,IAA2B,EAC3B,SAAS,EACT,eAAe,CAClB,CAAA;QAEP,IAAA,kBAAU,EAAC,kDAAkD,CAAC,CAAA;QAC9D,OAAO,MAAM,CAAA;IACjB,CAAC;;AA3bD,2IAA2I;AAC5H,cAAS,GAAG,gBAAgB,CAAA,CAAC,0CAA0C;kBAFrE,IAAI"}
@@ -60,3 +60,4 @@ const isDebug = () => {
60
60
  return false;
61
61
  };
62
62
  exports.isDebug = isDebug;
63
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":";;;AAeA,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,YAAY,CAAa,CAAA;AAqE9D,oCAAY;AApErB,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,YAAY,CAAY,CAAA;AA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G,GAAW,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACzC,IACI,GAAG,CAAC,WAAW,EAAE,KAAK,WAAW;YACjC,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc,EACtC,CAAC;YACC,OAAO,IAAI,CAAA;QACf,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAA;AAChB,CAAC,CAAA;AAjBY,QAAA,OAAO,WAiBnB"}
@@ -1,7 +1,7 @@
1
- import { AnnotationContext, AssignmentContext, Bad_memberContext, Bad_meta_textContext, Boolean_literalContext, Colon_list_declContext, DirectiveContext, ElementsContext, EolContext, List_literalContext, MemberContext, Meta_stmtContext, Null_literalContext, Number_literalContext, Object_literalContext, Object_memberContext, Object_membersContext, PrologContext, StmtContext, String_concatContext, String_literalContext, Terminal_stmtContext, ValueContext, YiniContext } from '../grammar/YiniParser.js';
2
- import YiniParserVisitor from '../grammar/YiniParserVisitor';
3
- import { ErrorDataHandler } from './ErrorDataHandler';
4
- import { IParseCoreOptions, IYiniAST, TSourceType } from './types';
1
+ import { AnnotationContext, AssignmentContext, Bad_memberContext, Bad_meta_textContext, Boolean_literalContext, Colon_list_declContext, DirectiveContext, ElementsContext, EolContext, List_literalContext, MemberContext, Meta_stmtContext, Null_literalContext, Number_literalContext, Object_literalContext, Object_memberContext, Object_membersContext, PrologContext, StmtContext, String_concatContext, String_literalContext, Terminal_stmtContext, ValueContext, YiniContext } from '../grammar/generated/YiniParser.js';
2
+ import YiniParserVisitor from '../grammar/generated/YiniParserVisitor';
3
+ import { ErrorDataHandler } from './errorDataHandler';
4
+ import { IParseCoreOptions, IYiniAST, TSourceType } from './internalTypes';
5
5
  /** Parse SECTION_HEAD token text → {level, name}.
6
6
  * Supports repeated markers (^^^^) and shorthand (^7) (Spec 5.2–5.3.1). :contentReference[oaicite:5]{index=5}:contentReference[oaicite:6]{index=6}
7
7
  */