@platforma-sdk/tengo-builder 2.3.14 → 2.4.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.
@@ -8,30 +8,29 @@ const namePattern = '[_a-zA-Z][_a-zA-Z0-9]*';
8
8
  const functionCallRE = (moduleName, fnName) => {
9
9
  return new RegExp(`\\b${moduleName}\\.(?<fnCall>(?<fnName>`
10
10
  + fnName
11
- + `)\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))`);
11
+ + `)\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))`, 'g');
12
12
  };
13
- const newGetTemplateIdRE = (moduleName) => {
14
- return functionCallRE(moduleName, 'getTemplateId');
15
- };
16
- const newGetSoftwareInfoRE = (moduleName) => {
17
- return functionCallRE(moduleName, 'getSoftwareInfo');
18
- };
19
- const newImportTemplateRE = (moduleName) => {
20
- return functionCallRE(moduleName, 'importTemplate');
21
- };
22
- const newImportSoftwareRE = (moduleName) => {
23
- return functionCallRE(moduleName, 'importSoftware');
24
- };
25
- const newImportAssetRE = (moduleName) => {
26
- return functionCallRE(moduleName, 'importAsset');
13
+ const functionCallLikeRE = (moduleName, fnName) => {
14
+ return new RegExp(`\\b${moduleName}\\.(?<fnName>`
15
+ + fnName
16
+ + `)\\s*\\(`, 'g');
27
17
  };
18
+ const newGetTemplateIdRE = (moduleName) => functionCallRE(moduleName, 'getTemplateId');
19
+ const newGetSoftwareInfoRE = (moduleName) => functionCallRE(moduleName, 'getSoftwareInfo');
20
+ const newImportTemplateRE = (moduleName) => functionCallRE(moduleName, 'importTemplate');
21
+ const newImportTemplateDetector = (moduleName) => functionCallLikeRE(moduleName, 'importTemplate');
22
+ const newImportSoftwareRE = (moduleName) => functionCallRE(moduleName, 'importSoftware');
23
+ const newImportSoftwareDetector = (moduleName) => functionCallLikeRE(moduleName, 'importSoftware');
24
+ const newImportAssetRE = (moduleName) => functionCallRE(moduleName, 'importAsset');
25
+ const newImportAssetDetector = (moduleName) => functionCallLikeRE(moduleName, 'importAsset');
28
26
  const emptyLineRE = /^\s*$/;
29
27
  const compilerOptionRE = /^\/\/tengo:[\w]/;
30
28
  const wrongCompilerOptionRE = /^\s*\/\/\s*tengo:\s*./;
31
- const inlineCommentRE = /\/\*.*?\*\//g; // .*? = non-greedy search
32
29
  const singlelineCommentRE = /^\s*(\/\/)/;
30
+ const singlelineTerminatedCommentRE = /^\s*\/\*.*\*\/\s*$/; // matches '^/* ... */$' comment lines as a special case of singleline comments.
33
31
  const multilineCommentStartRE = /^\s*\/\*/;
34
32
  const multilineCommentEndRE = /\*\//;
33
+ const multilineStatementRE = /[.,]\s*$/; // it is hard to consistently treat (\n"a"\n) multiline statements, we forbid them for now.
35
34
  // import could only be an assignment in a statement,
36
35
  // other ways could break a compilation.
37
36
  const importRE = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/;
@@ -114,16 +113,18 @@ function parseSourceData(logger, src, fullSourceName, globalizeImports) {
114
113
  let parserContext = {
115
114
  isInCommentBlock: false,
116
115
  canDetectOptions: true,
117
- tplDepREs: new Map(),
116
+ artifactImportREs: new Map(),
117
+ importLikeREs: new Map(),
118
+ multilineStatement: '',
118
119
  lineNo: 0,
119
120
  };
120
121
  for (const line of lines) {
121
122
  parserContext.lineNo++;
122
123
  try {
123
- const { line: processedLine, context: newContext, artifact, option } = parseSingleSourceLine(logger, line, parserContext, fullSourceName.pkg, globalizeImports);
124
+ const { line: processedLine, context: newContext, artifacts, option } = parseSingleSourceLine(logger, line, parserContext, fullSourceName.pkg, globalizeImports);
124
125
  processedLines.push(processedLine);
125
126
  parserContext = newContext;
126
- if (artifact) {
127
+ for (const artifact of artifacts ?? []) {
127
128
  dependencySet.add(artifact);
128
129
  }
129
130
  if (option) {
@@ -142,112 +143,175 @@ function parseSourceData(logger, src, fullSourceName, globalizeImports) {
142
143
  };
143
144
  }
144
145
  function parseSingleSourceLine(logger, line, context, localPackageName, globalizeImports) {
145
- // preprocess line and remove inline comments
146
- line = line.replaceAll(inlineCommentRE, '');
147
146
  if (context.isInCommentBlock) {
148
147
  if (multilineCommentEndRE.exec(line)) {
149
148
  context.isInCommentBlock = false;
150
149
  }
151
- return { line: '', context, artifact: undefined, option: undefined };
150
+ return { line: '', context, artifacts: [], option: undefined };
152
151
  }
153
152
  if (compilerOptionRE.exec(line)) {
154
153
  if (!context.canDetectOptions) {
155
154
  logger.error(`[line ${context.lineNo}]: compiler option '//tengo:' was detected, but it cannot be applied as compiler options can be set only at the file header, before any code line'`);
156
155
  throw new Error('tengo compiler options (\'//tengo:\' comments) can be set only in file header');
157
156
  }
158
- return { line, context, artifact: undefined, option: parseComplierOption(line) };
157
+ return { line, context, artifacts: [], option: parseComplierOption(line) };
159
158
  }
160
159
  if (wrongCompilerOptionRE.exec(line) && context.canDetectOptions) {
161
160
  logger.warn(`[line ${context.lineNo}]: text simillar to compiler option ('//tengo:...') was detected, but it has wrong format. Leave it as is, if you did not mean to use a line as compiler option. Or format it to '//tengo:<option>' otherwise (no spaces between '//' and 'tengo', no spaces between ':' and option name)`);
162
- return { line, context, artifact: undefined, option: undefined };
161
+ return { line, context, artifacts: [], option: undefined };
163
162
  }
164
- if (singlelineCommentRE.test(line)) {
165
- return { line: '', context, artifact: undefined, option: undefined };
163
+ if (singlelineCommentRE.test(line) || singlelineTerminatedCommentRE.test(line)) {
164
+ return { line: '', context, artifacts: [], option: undefined };
166
165
  }
167
- if (multilineCommentStartRE.exec(line)) {
166
+ const canBeInlinedComment = line.includes('*/');
167
+ if (multilineCommentStartRE.exec(line) && !canBeInlinedComment) {
168
168
  context.isInCommentBlock = true;
169
- return { line: '', context, artifact: undefined, option: undefined };
169
+ return { line: '', context, artifacts: [], option: undefined };
170
170
  }
171
- if (line.includes('/*')) {
172
- throw new Error('malformed multiline comment');
171
+ const statement = context.multilineStatement + line.trim();
172
+ const mayContainAComment = line.includes('//') || line.includes('/*');
173
+ if (multilineStatementRE.test(line) && !mayContainAComment) {
174
+ // We accumulate multiline statements into single line before analyzing them.
175
+ // This dramatically simplifies parsing logic: things like
176
+ //
177
+ // assets.
178
+ // importSoftware("a:b");
179
+ //
180
+ // become simple 'assets.importSoftware("a:b");' for parser checks.
181
+ //
182
+ // For safety reasons, we never consider anything that 'may look like a comment'
183
+ // as a part of multiline statement to prevent joining things like
184
+ //
185
+ // someFnCall() // looks like multiline statement because of dot in the end of a comment.
186
+ //
187
+ // This problem also appears in multiline string literals, but I hope this will not
188
+ // cause problems in real life.
189
+ // We still try to process each line to globalize imports in case of complex constructions, when
190
+ // statements are stacked one into another:
191
+ // a.
192
+ // use(assets.importSoftware(":soft1")).
193
+ // use(assets.importSoftware(":soft2")).
194
+ // run()
195
+ // It is multiline, and it still requires import globalization mid-way, not just for the last line of statement
196
+ const result = processAssetImport(line, statement, context, localPackageName);
197
+ context.multilineStatement += result.line.trim(); // accumulate the line after imports globalization.
198
+ return result;
173
199
  }
174
- if (emptyLineRE.exec(line)) {
175
- return { line, context, artifact: undefined, option: undefined };
200
+ context.multilineStatement = ''; // reset accumulated multiline statement parts once we reach statement end.
201
+ if (emptyLineRE.exec(statement)) {
202
+ return { line, context, artifacts: [], option: undefined };
176
203
  }
177
204
  // options could be only at the top of the file.
178
205
  context.canDetectOptions = false;
179
- const importInstruction = importRE.exec(line);
180
- if (importInstruction) {
181
- const iInfo = parseImport(line);
182
- // If we have plapi, ll or assets, then try to parse
183
- // getTemplateId, getSoftwareInfo, getSoftware and getAsset calls.
184
- if (iInfo.module === 'plapi') {
185
- if (!context.tplDepREs.has(iInfo.module)) {
186
- context.tplDepREs.set(iInfo.module, [
187
- ['template', newGetTemplateIdRE(iInfo.alias)],
188
- ['software', newGetSoftwareInfoRE(iInfo.alias)],
189
- ]);
190
- }
191
- return { line, context, artifact: undefined, option: undefined };
192
- }
193
- if (iInfo.module === '@milaboratory/tengo-sdk:ll'
194
- || iInfo.module === '@platforma-sdk/workflow-tengo:ll'
195
- || ((localPackageName === '@milaboratory/tengo-sdk'
196
- || localPackageName === '@platforma-sdk/workflow-tengo')
197
- && iInfo.module === ':ll')) {
198
- if (!context.tplDepREs.has(iInfo.module)) {
199
- context.tplDepREs.set(iInfo.module, [
200
- ['template', newImportTemplateRE(iInfo.alias)],
201
- ['software', newImportSoftwareRE(iInfo.alias)],
202
- ]);
203
- }
204
- }
205
- if (iInfo.module === '@milaboratory/tengo-sdk:assets'
206
- || iInfo.module === '@platforma-sdk/workflow-tengo:assets'
207
- || ((localPackageName === '@milaboratory/tengo-sdk'
208
- || localPackageName === '@platforma-sdk/workflow-tengo')
209
- && iInfo.module === ':assets')) {
210
- if (!context.tplDepREs.has(iInfo.module)) {
211
- context.tplDepREs.set(iInfo.module, [
212
- ['template', newImportTemplateRE(iInfo.alias)],
213
- ['software', newImportSoftwareRE(iInfo.alias)],
214
- ['asset', newImportAssetRE(iInfo.alias)],
215
- ]);
216
- }
206
+ return processAssetImport(line, statement, context, localPackageName);
207
+ }
208
+ function processModuleImport(importInstruction, originalLine, statement, context, localPackageName, globalizeImports) {
209
+ const iInfo = parseImport(statement);
210
+ // If we have plapi, ll or assets, then try to parse
211
+ // getTemplateId, getSoftwareInfo, getSoftware and getAsset calls.
212
+ if (iInfo.module === 'plapi') {
213
+ if (!context.artifactImportREs.has(iInfo.module)) {
214
+ context.artifactImportREs.set(iInfo.module, [
215
+ ['template', newGetTemplateIdRE(iInfo.alias)],
216
+ ['software', newGetSoftwareInfoRE(iInfo.alias)],
217
+ ]);
217
218
  }
218
- const artifact = parseArtifactName(iInfo.module, 'library', localPackageName);
219
- if (!artifact) {
220
- // not a Platforma Tengo library import
221
- return { line, context, artifact: undefined, option: undefined };
219
+ return { line: originalLine, context, artifacts: [], option: undefined };
220
+ }
221
+ if (iInfo.module === '@milaboratory/tengo-sdk:ll'
222
+ || iInfo.module === '@platforma-sdk/workflow-tengo:ll'
223
+ || ((localPackageName === '@milaboratory/tengo-sdk'
224
+ || localPackageName === '@platforma-sdk/workflow-tengo')
225
+ && iInfo.module === ':ll')) {
226
+ if (!context.artifactImportREs.has(iInfo.module)) {
227
+ context.artifactImportREs.set(iInfo.module, [
228
+ ['template', newImportTemplateRE(iInfo.alias)],
229
+ ['software', newImportSoftwareRE(iInfo.alias)],
230
+ ]);
222
231
  }
223
- {
224
- line = line.replace(importInstruction[0], ` := import("${artifact.pkg}:${artifact.id}")`);
232
+ }
233
+ if (iInfo.module === '@milaboratory/tengo-sdk:assets'
234
+ || iInfo.module === '@platforma-sdk/workflow-tengo:assets'
235
+ || ((localPackageName === '@milaboratory/tengo-sdk'
236
+ || localPackageName === '@platforma-sdk/workflow-tengo')
237
+ && iInfo.module === ':assets')) {
238
+ if (!context.artifactImportREs.has(iInfo.module)) {
239
+ context.artifactImportREs.set(iInfo.module, [
240
+ ['template', newImportTemplateRE(iInfo.alias)],
241
+ ['software', newImportSoftwareRE(iInfo.alias)],
242
+ ['asset', newImportAssetRE(iInfo.alias)],
243
+ ]);
244
+ context.importLikeREs.set(iInfo.module, [
245
+ ['template', newImportTemplateDetector(iInfo.alias)],
246
+ ['software', newImportSoftwareDetector(iInfo.alias)],
247
+ ['asset', newImportAssetDetector(iInfo.alias)],
248
+ ]);
225
249
  }
226
- return { line, context, artifact, option: undefined };
227
250
  }
228
- if (context.tplDepREs.size > 0) {
229
- for (const [_, artifactRE] of context.tplDepREs) {
251
+ const artifact = parseArtifactName(iInfo.module, 'library', localPackageName);
252
+ if (!artifact) {
253
+ // not a Platforma Tengo library import
254
+ return { line: originalLine, context, artifacts: [], option: undefined };
255
+ }
256
+ {
257
+ originalLine = originalLine.replace(importInstruction[0], ` := import("${artifact.pkg}:${artifact.id}")`);
258
+ }
259
+ return { line: originalLine, context, artifacts: [artifact], option: undefined };
260
+ }
261
+ function processAssetImport(originalLine, statement, context, localPackageName, globalizeImports) {
262
+ if (emptyLineRE.exec(statement)) {
263
+ return { line: originalLine, context, artifacts: [], option: undefined };
264
+ }
265
+ // options could be only at the top of the file.
266
+ context.canDetectOptions = false;
267
+ const importInstruction = importRE.exec(statement);
268
+ if (importInstruction) {
269
+ return processModuleImport(importInstruction, originalLine, statement, context, localPackageName);
270
+ }
271
+ if (context.artifactImportREs.size > 0) {
272
+ for (const [_, artifactRE] of context.artifactImportREs) {
230
273
  for (const [artifactType, re] of artifactRE) {
231
- const match = re.exec(line);
232
- if (!match || !match.groups) {
274
+ // Find all matches in the statement
275
+ const matches = Array.from(statement.matchAll(re));
276
+ if (matches.length === 0) {
233
277
  continue;
234
278
  }
235
- const { fnCall, templateName, fnName } = match.groups;
236
- if (!fnCall || !templateName || !fnName) {
237
- throw Error(`failed to parse template import statement`);
279
+ const artifacts = [];
280
+ for (let i = matches.length - 1; i >= 0; i--) {
281
+ const match = matches[i];
282
+ if (!match || !match.groups) {
283
+ continue;
284
+ }
285
+ const { fnCall, templateName, fnName } = match.groups;
286
+ if (!fnCall || !templateName || !fnName) {
287
+ throw Error(`failed to parse template import statement`);
288
+ }
289
+ const artifact = parseArtifactName(templateName, artifactType, localPackageName);
290
+ if (!artifact) {
291
+ throw Error(`failed to parse artifact name in ${fnName} import statement`);
292
+ }
293
+ artifacts.push(artifact);
294
+ {
295
+ // Replace all occurrences of this fnCall in originalLine
296
+ originalLine = originalLine.replaceAll(fnCall, `${fnName}("${artifact.pkg}:${artifact.id}")`);
297
+ }
238
298
  }
239
- const artifact = parseArtifactName(templateName, artifactType, localPackageName);
240
- if (!artifact) {
241
- throw Error(`failed to parse artifact name in ${fnName} import statement`);
242
- }
243
- {
244
- line = line.replace(fnCall, `${fnName}("${artifact.pkg}:${artifact.id}")`);
299
+ return { line: originalLine, context, artifacts, option: undefined };
300
+ }
301
+ }
302
+ }
303
+ if (context.importLikeREs.size > 0) {
304
+ for (const [_, artifactRE] of context.importLikeREs) {
305
+ for (const [artifactType, re] of artifactRE) {
306
+ const match = re.exec(statement);
307
+ if (!match || !match.groups) {
308
+ continue;
245
309
  }
246
- return { line, context, artifact, option: undefined };
310
+ throw Error(`incorrect '${artifactType}' import statement: use string literal as ID (variables are not allowed) in the same line with brackets (i.e. 'importSoftware("sw:main")').`);
247
311
  }
248
312
  }
249
313
  }
250
- return { line, context, artifact: undefined, option: undefined };
314
+ return { line: originalLine, context, artifacts: [], option: undefined };
251
315
  }
252
316
  function parseImport(line) {
253
317
  const match = importNameRE.exec(line);
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sources":["../../src/compiler/source.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport {\n type TypedArtifactName,\n type FullArtifactName,\n type ArtifactType,\n type CompileMode,\n type CompilerOption,\n fullNameToString,\n} from './package';\nimport type { ArtifactMap } from './artifactset';\nimport { createArtifactNameSet } from './artifactset';\nimport { createHash } from 'node:crypto';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\n\n// matches any valid name in tengo. Don't forget to use '\\b' when needed to limit the boundaries!\nconst namePattern = '[_a-zA-Z][_a-zA-Z0-9]*';\n\nconst functionCallRE = (moduleName: string, fnName: string) => {\n return new RegExp(\n `\\\\b${moduleName}\\\\.(?<fnCall>(?<fnName>`\n + fnName\n + `)\\\\s*\\\\(\\\\s*\"(?<templateName>[^\"]+)\"\\\\s*\\\\))`,\n );\n};\n\nexport const newGetTemplateIdRE = (moduleName: string) => {\n return functionCallRE(moduleName, 'getTemplateId');\n};\nexport const newGetSoftwareInfoRE = (moduleName: string) => {\n return functionCallRE(moduleName, 'getSoftwareInfo');\n};\n\nconst newImportTemplateRE = (moduleName: string) => {\n return functionCallRE(moduleName, 'importTemplate');\n};\nconst newImportSoftwareRE = (moduleName: string) => {\n return functionCallRE(moduleName, 'importSoftware');\n};\nconst newImportAssetRE = (moduleName: string) => {\n return functionCallRE(moduleName, 'importAsset');\n};\n\nconst emptyLineRE = /^\\s*$/;\nconst compilerOptionRE = /^\\/\\/tengo:[\\w]/;\nconst wrongCompilerOptionRE = /^\\s*\\/\\/\\s*tengo:\\s*./;\nconst inlineCommentRE = /\\/\\*.*?\\*\\//g; // .*? = non-greedy search\nconst singlelineCommentRE = /^\\s*(\\/\\/)/;\nconst multilineCommentStartRE = /^\\s*\\/\\*/;\nconst multilineCommentEndRE = /\\*\\//;\n\n// import could only be an assignment in a statement,\n// other ways could break a compilation.\nconst importRE = /\\s*:=\\s*import\\s*\\(\\s*\"(?<moduleName>[^\"]+)\"\\s*\\)/;\nconst importNameRE = new RegExp(\n `\\\\b(?<importName>${namePattern}(\\\\.${namePattern})*)${importRE.source}`,\n);\nconst dependencyRE = /(?<pkgName>[^\"]+)?:(?<depID>[^\"]+)/; // use it to parse <moduleName> from importPattern or <templateName> from getTemplateID\n\n/**\n * Parse compiler option string representation\n * Compiler option line is a comment starting with '//tengo:', say\n * //tengo:hash_override tralala\n *\n * The common compiler option syntax is:\n * //tengo:<option name> [<option arg1> [<option arg 2> [...]]]\n */\nconst parseComplierOption = (opt: string): CompilerOption => {\n const parts = opt.split(' ');\n const namePart = parts[0].split(':');\n if (namePart.length != 2) {\n throw new Error(\n 'compiler option format is wrong: expect to have option name after \\'tengo:\\' prefix, like \\'tengo:MyOption\\'',\n );\n }\n const optName = namePart[1];\n\n return {\n name: optName,\n args: parts.slice(1),\n };\n};\n\nexport class ArtifactSource {\n constructor(\n /** The mode this artifact was built (dev or dist) */\n public readonly compileMode: CompileMode,\n /** Full artifact id, including package version */\n public readonly fullName: FullArtifactName,\n /** Hash of the source code */\n public readonly sourceHash: string,\n /** Normalized source code */\n public readonly src: string,\n /** Path to source file where artifact came from */\n public readonly srcName: string,\n /** List of dependencies */\n public readonly dependencies: TypedArtifactName[],\n /** Additional compiler options detected in source code */\n public readonly compilerOptions: CompilerOption[],\n ) {}\n}\n\nexport function parseSourceFile(\n logger: MiLogger,\n mode: CompileMode,\n srcFile: string,\n fullSourceName: FullArtifactName,\n normalize: boolean,\n): ArtifactSource {\n const src = readFileSync(srcFile).toString();\n const { deps, normalized, opts } = parseSourceData(logger, src, fullSourceName, normalize);\n\n return new ArtifactSource(\n mode,\n fullSourceName,\n getSha256(normalized),\n normalized,\n srcFile,\n deps.array,\n opts,\n );\n}\n\nexport function parseSource(\n logger: MiLogger,\n mode: CompileMode,\n src: string,\n fullSourceName: FullArtifactName,\n normalize: boolean,\n): ArtifactSource {\n const { deps, normalized, opts } = parseSourceData(logger, src, fullSourceName, normalize);\n\n return new ArtifactSource(mode, fullSourceName, getSha256(normalized), normalized, '', deps.array, opts);\n}\n\n/**\n * Reads src\n * returns normalized source code,\n * gets dependencies from imports,\n * maps imports to global names if globalizeImports is true,\n * and collects compiler options like hashOverride.\n */\nfunction parseSourceData(\n logger: MiLogger,\n src: string,\n fullSourceName: FullArtifactName,\n globalizeImports: boolean,\n): {\n normalized: string;\n deps: ArtifactMap<TypedArtifactName>;\n opts: CompilerOption[];\n } {\n const dependencySet = createArtifactNameSet();\n const optionList: CompilerOption[] = [];\n\n // iterating over lines\n const lines = src.split('\\n');\n\n // processedLines keep all the original lines from <src>.\n // If <globalizeImport>==true, the parser modifies 'import' and 'getTemplateId' lines\n // with Platforma Tengo lib and template usages, resolving local names (\":<item>\") to\n // global (\"@milaboratory/pkg:<item>\")\n const processedLines: string[] = [];\n let parserContext: sourceParserContext = {\n isInCommentBlock: false,\n canDetectOptions: true,\n tplDepREs: new Map<string, [ArtifactType, RegExp][]>(),\n lineNo: 0,\n };\n\n for (const line of lines) {\n parserContext.lineNo++;\n\n try {\n const { line: processedLine, context: newContext, artifact, option } = parseSingleSourceLine(\n logger,\n line,\n parserContext,\n fullSourceName.pkg,\n globalizeImports,\n );\n processedLines.push(processedLine);\n parserContext = newContext;\n\n if (artifact) {\n dependencySet.add(artifact);\n }\n if (option) {\n optionList.push(option);\n }\n } catch (error: unknown) {\n const err = error as Error;\n throw new Error(`[line ${parserContext.lineNo} in ${fullNameToString(fullSourceName)}]: ${err.message}\\n\\t${line}`, { cause: err });\n }\n }\n\n return {\n normalized: processedLines.join('\\n'),\n deps: dependencySet,\n opts: optionList,\n };\n}\n\ninterface sourceParserContext {\n isInCommentBlock: boolean;\n canDetectOptions: boolean;\n tplDepREs: Map<string, [ArtifactType, RegExp][]>;\n lineNo: number;\n}\n\nexport function parseSingleSourceLine(\n logger: MiLogger,\n line: string,\n context: sourceParserContext,\n localPackageName: string,\n globalizeImports?: boolean,\n): {\n line: string;\n context: sourceParserContext;\n artifact: TypedArtifactName | undefined;\n option: CompilerOption | undefined;\n } {\n // preprocess line and remove inline comments\n line = line.replaceAll(inlineCommentRE, '');\n\n if (context.isInCommentBlock) {\n if (multilineCommentEndRE.exec(line)) {\n context.isInCommentBlock = false;\n }\n return { line: '', context, artifact: undefined, option: undefined };\n }\n\n if (compilerOptionRE.exec(line)) {\n if (!context.canDetectOptions) {\n logger.error(\n `[line ${context.lineNo}]: compiler option '//tengo:' was detected, but it cannot be applied as compiler options can be set only at the file header, before any code line'`,\n );\n throw new Error('tengo compiler options (\\'//tengo:\\' comments) can be set only in file header');\n }\n return { line, context, artifact: undefined, option: parseComplierOption(line) };\n }\n\n if (wrongCompilerOptionRE.exec(line) && context.canDetectOptions) {\n logger.warn(\n `[line ${context.lineNo}]: text simillar to compiler option ('//tengo:...') was detected, but it has wrong format. Leave it as is, if you did not mean to use a line as compiler option. Or format it to '//tengo:<option>' otherwise (no spaces between '//' and 'tengo', no spaces between ':' and option name)`,\n );\n return { line, context, artifact: undefined, option: undefined };\n }\n\n if (singlelineCommentRE.test(line)) {\n return { line: '', context, artifact: undefined, option: undefined };\n }\n\n if (multilineCommentStartRE.exec(line)) {\n context.isInCommentBlock = true;\n return { line: '', context, artifact: undefined, option: undefined };\n }\n\n if (line.includes('/*')) {\n throw new Error('malformed multiline comment');\n }\n\n if (emptyLineRE.exec(line)) {\n return { line, context, artifact: undefined, option: undefined };\n }\n\n // options could be only at the top of the file.\n context.canDetectOptions = false;\n\n const importInstruction = importRE.exec(line);\n\n if (importInstruction) {\n const iInfo = parseImport(line);\n\n // If we have plapi, ll or assets, then try to parse\n // getTemplateId, getSoftwareInfo, getSoftware and getAsset calls.\n\n if (iInfo.module === 'plapi') {\n if (!context.tplDepREs.has(iInfo.module)) {\n context.tplDepREs.set(iInfo.module, [\n ['template', newGetTemplateIdRE(iInfo.alias)],\n ['software', newGetSoftwareInfoRE(iInfo.alias)],\n ]);\n }\n return { line, context, artifact: undefined, option: undefined };\n }\n\n if (\n iInfo.module === '@milaboratory/tengo-sdk:ll'\n || iInfo.module === '@platforma-sdk/workflow-tengo:ll'\n || ((localPackageName === '@milaboratory/tengo-sdk'\n || localPackageName === '@platforma-sdk/workflow-tengo')\n && iInfo.module === ':ll')\n ) {\n if (!context.tplDepREs.has(iInfo.module)) {\n context.tplDepREs.set(iInfo.module, [\n ['template', newImportTemplateRE(iInfo.alias)],\n ['software', newImportSoftwareRE(iInfo.alias)],\n ]);\n }\n }\n\n if (\n iInfo.module === '@milaboratory/tengo-sdk:assets'\n || iInfo.module === '@platforma-sdk/workflow-tengo:assets'\n || ((localPackageName === '@milaboratory/tengo-sdk'\n || localPackageName === '@platforma-sdk/workflow-tengo')\n && iInfo.module === ':assets')\n ) {\n if (!context.tplDepREs.has(iInfo.module)) {\n context.tplDepREs.set(iInfo.module, [\n ['template', newImportTemplateRE(iInfo.alias)],\n ['software', newImportSoftwareRE(iInfo.alias)],\n ['asset', newImportAssetRE(iInfo.alias)],\n ]);\n }\n }\n\n const artifact = parseArtifactName(iInfo.module, 'library', localPackageName);\n if (!artifact) {\n // not a Platforma Tengo library import\n return { line, context, artifact: undefined, option: undefined };\n }\n\n if (globalizeImports) {\n line = line.replace(importInstruction[0], ` := import(\"${artifact.pkg}:${artifact.id}\")`);\n }\n\n return { line, context, artifact, option: undefined };\n }\n\n if (context.tplDepREs.size > 0) {\n for (const [_, artifactRE] of context.tplDepREs) {\n for (const [artifactType, re] of artifactRE) {\n const match = re.exec(line);\n if (!match || !match.groups) {\n continue;\n }\n\n const { fnCall, templateName, fnName } = match.groups;\n\n if (!fnCall || !templateName || !fnName) {\n throw Error(`failed to parse template import statement`);\n }\n\n const artifact = parseArtifactName(templateName, artifactType, localPackageName);\n if (!artifact) {\n throw Error(`failed to parse artifact name in ${fnName} import statement`);\n }\n\n if (globalizeImports) {\n line = line.replace(fnCall, `${fnName}(\"${artifact.pkg}:${artifact.id}\")`);\n }\n\n return { line, context, artifact, option: undefined };\n }\n }\n }\n\n return { line, context, artifact: undefined, option: undefined };\n}\n\ninterface ImportInfo {\n module: string; // the module name without wrapping quotes: import(\"<module>\")\n alias: string; // the name of variable that keeps imported module: <alias> := import(\"<module>\")\n}\n\nfunction parseImport(line: string): ImportInfo {\n const match = importNameRE.exec(line);\n\n if (!match || !match.groups) {\n throw Error(`failed to parse 'import' statement`);\n }\n\n const { importName, moduleName } = match.groups;\n if (!importName || !moduleName) {\n throw Error(`failed to parse 'import' statement`);\n }\n\n return {\n module: moduleName, // the module name without wrapping quotes: import(\"<module>\")\n alias: importName, // the name of variable that keeps imported module: <alias> := import(\"<module>\")\n };\n}\n\nfunction parseArtifactName(\n moduleName: string,\n aType: ArtifactType,\n localPackageName: string,\n): TypedArtifactName | undefined {\n const depInfo = dependencyRE.exec(moduleName);\n if (!depInfo) {\n return;\n }\n\n if (!depInfo.groups) {\n throw Error(\n `failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'`,\n );\n }\n\n const { pkgName, depID } = depInfo.groups;\n if (!depID) {\n throw Error(\n `failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'`,\n );\n }\n\n return { type: aType, pkg: pkgName ?? localPackageName, id: depID };\n}\n\nexport function getSha256(source: string): string {\n return createHash('sha256').update(source).digest('hex');\n}\n"],"names":[],"mappings":";;;;;AAcA;AACA,MAAM,WAAW,GAAG,wBAAwB;AAE5C,MAAM,cAAc,GAAG,CAAC,UAAkB,EAAE,MAAc,KAAI;AAC5D,IAAA,OAAO,IAAI,MAAM,CACf,CAAA,GAAA,EAAM,UAAU,CAAA,uBAAA;UACd;AACA,UAAA,CAAA,4CAAA,CAA8C,CACjD;AACH,CAAC;AAEM,MAAM,kBAAkB,GAAG,CAAC,UAAkB,KAAI;AACvD,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AAE;AACV,QAAA,MAAM,KAAK,CACT,CAAA,4HAAA,CAA8H,CAC/H;IACH;AAEA,IAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,IAAI,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE;AACrE;AAEM,SAAU,SAAS,CAAC,MAAc,EAAA;AACtC,IAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAC1D;;;;"}
1
+ {"version":3,"file":"source.js","sources":["../../src/compiler/source.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport {\n type TypedArtifactName,\n type FullArtifactName,\n type ArtifactType,\n type CompileMode,\n type CompilerOption,\n fullNameToString,\n} from './package';\nimport type { ArtifactMap } from './artifactset';\nimport { createArtifactNameSet } from './artifactset';\nimport { createHash } from 'node:crypto';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\n\n// matches any valid name in tengo. Don't forget to use '\\b' when needed to limit the boundaries!\nconst namePattern = '[_a-zA-Z][_a-zA-Z0-9]*';\n\nconst functionCallRE = (moduleName: string, fnName: string) => {\n return new RegExp(\n `\\\\b${moduleName}\\\\.(?<fnCall>(?<fnName>`\n + fnName\n + `)\\\\s*\\\\(\\\\s*\"(?<templateName>[^\"]+)\"\\\\s*\\\\))`,\n 'g',\n );\n};\n\nconst functionCallLikeRE = (moduleName: string, fnName: string) => {\n return new RegExp(\n `\\\\b${moduleName}\\\\.(?<fnName>`\n + fnName\n + `)\\\\s*\\\\(`,\n 'g',\n );\n};\n\nexport const newGetTemplateIdRE = (moduleName: string) => functionCallRE(moduleName, 'getTemplateId');\nexport const newGetSoftwareInfoRE = (moduleName: string) => functionCallRE(moduleName, 'getSoftwareInfo');\n\nconst newImportTemplateRE = (moduleName: string) => functionCallRE(moduleName, 'importTemplate');\nconst newImportTemplateDetector = (moduleName: string) => functionCallLikeRE(moduleName, 'importTemplate');\nconst newImportSoftwareRE = (moduleName: string) => functionCallRE(moduleName, 'importSoftware');\nconst newImportSoftwareDetector = (moduleName: string) => functionCallLikeRE(moduleName, 'importSoftware');\nconst newImportAssetRE = (moduleName: string) => functionCallRE(moduleName, 'importAsset');\nconst newImportAssetDetector = (moduleName: string) => functionCallLikeRE(moduleName, 'importAsset');\n\nconst emptyLineRE = /^\\s*$/;\nconst compilerOptionRE = /^\\/\\/tengo:[\\w]/;\nconst wrongCompilerOptionRE = /^\\s*\\/\\/\\s*tengo:\\s*./;\nconst singlelineCommentRE = /^\\s*(\\/\\/)/;\nconst singlelineTerminatedCommentRE = /^\\s*\\/\\*.*\\*\\/\\s*$/; // matches '^/* ... */$' comment lines as a special case of singleline comments.\nconst multilineCommentStartRE = /^\\s*\\/\\*/;\nconst multilineCommentEndRE = /\\*\\//;\nconst multilineStatementRE = /[.,]\\s*$/; // it is hard to consistently treat (\\n\"a\"\\n) multiline statements, we forbid them for now.\n\n// import could only be an assignment in a statement,\n// other ways could break a compilation.\nconst importRE = /\\s*:=\\s*import\\s*\\(\\s*\"(?<moduleName>[^\"]+)\"\\s*\\)/;\nconst importNameRE = new RegExp(\n `\\\\b(?<importName>${namePattern}(\\\\.${namePattern})*)${importRE.source}`,\n);\nconst dependencyRE = /(?<pkgName>[^\"]+)?:(?<depID>[^\"]+)/; // use it to parse <moduleName> from importPattern or <templateName> from getTemplateID\n\n/**\n * Parse compiler option string representation\n * Compiler option line is a comment starting with '//tengo:', say\n * //tengo:hash_override tralala\n *\n * The common compiler option syntax is:\n * //tengo:<option name> [<option arg1> [<option arg 2> [...]]]\n */\nconst parseComplierOption = (opt: string): CompilerOption => {\n const parts = opt.split(' ');\n const namePart = parts[0].split(':');\n if (namePart.length != 2) {\n throw new Error(\n 'compiler option format is wrong: expect to have option name after \\'tengo:\\' prefix, like \\'tengo:MyOption\\'',\n );\n }\n const optName = namePart[1];\n\n return {\n name: optName,\n args: parts.slice(1),\n };\n};\n\nexport class ArtifactSource {\n constructor(\n /** The mode this artifact was built (dev or dist) */\n public readonly compileMode: CompileMode,\n /** Full artifact id, including package version */\n public readonly fullName: FullArtifactName,\n /** Hash of the source code */\n public readonly sourceHash: string,\n /** Normalized source code */\n public readonly src: string,\n /** Path to source file where artifact came from */\n public readonly srcName: string,\n /** List of dependencies */\n public readonly dependencies: TypedArtifactName[],\n /** Additional compiler options detected in source code */\n public readonly compilerOptions: CompilerOption[],\n ) {}\n}\n\nexport function parseSourceFile(\n logger: MiLogger,\n mode: CompileMode,\n srcFile: string,\n fullSourceName: FullArtifactName,\n normalize: boolean,\n): ArtifactSource {\n const src = readFileSync(srcFile).toString();\n const { deps, normalized, opts } = parseSourceData(logger, src, fullSourceName, normalize);\n\n return new ArtifactSource(\n mode,\n fullSourceName,\n getSha256(normalized),\n normalized,\n srcFile,\n deps.array,\n opts,\n );\n}\n\nexport function parseSource(\n logger: MiLogger,\n mode: CompileMode,\n src: string,\n fullSourceName: FullArtifactName,\n normalize: boolean,\n): ArtifactSource {\n const { deps, normalized, opts } = parseSourceData(logger, src, fullSourceName, normalize);\n\n return new ArtifactSource(mode, fullSourceName, getSha256(normalized), normalized, '', deps.array, opts);\n}\n\n/**\n * Reads src\n * returns normalized source code,\n * gets dependencies from imports,\n * maps imports to global names if globalizeImports is true,\n * and collects compiler options like hashOverride.\n */\nfunction parseSourceData(\n logger: MiLogger,\n src: string,\n fullSourceName: FullArtifactName,\n globalizeImports: boolean,\n): {\n normalized: string;\n deps: ArtifactMap<TypedArtifactName>;\n opts: CompilerOption[];\n } {\n const dependencySet = createArtifactNameSet();\n const optionList: CompilerOption[] = [];\n\n // iterating over lines\n const lines = src.split('\\n');\n\n // processedLines keep all the original lines from <src>.\n // If <globalizeImport>==true, the parser modifies 'import' and 'getTemplateId' lines\n // with Platforma Tengo lib and template usages, resolving local names (\":<item>\") to\n // global (\"@milaboratory/pkg:<item>\")\n const processedLines: string[] = [];\n let parserContext: sourceParserContext = {\n isInCommentBlock: false,\n canDetectOptions: true,\n artifactImportREs: new Map<string, [ArtifactType, RegExp][]>(),\n importLikeREs: new Map<string, [ArtifactType, RegExp][]>(),\n multilineStatement: '',\n lineNo: 0,\n };\n\n for (const line of lines) {\n parserContext.lineNo++;\n\n try {\n const { line: processedLine, context: newContext, artifacts, option } = parseSingleSourceLine(\n logger,\n line,\n parserContext,\n fullSourceName.pkg,\n globalizeImports,\n );\n processedLines.push(processedLine);\n parserContext = newContext;\n\n for (const artifact of artifacts ?? []) {\n dependencySet.add(artifact);\n }\n if (option) {\n optionList.push(option);\n }\n } catch (error: unknown) {\n const err = error as Error;\n throw new Error(`[line ${parserContext.lineNo} in ${fullNameToString(fullSourceName)}]: ${err.message}\\n\\t${line}`, { cause: err });\n }\n }\n\n return {\n normalized: processedLines.join('\\n'),\n deps: dependencySet,\n opts: optionList,\n };\n}\n\nexport type sourceParserContext = {\n isInCommentBlock: boolean;\n canDetectOptions: boolean;\n artifactImportREs: Map<string, [ArtifactType, RegExp][]>;\n importLikeREs: Map<string, [ArtifactType, RegExp][]>;\n multilineStatement: string;\n lineNo: number;\n};\n\nexport type lineProcessingResult = {\n line: string;\n context: sourceParserContext;\n artifacts: TypedArtifactName[];\n option: CompilerOption | undefined;\n};\n\nexport function parseSingleSourceLine(\n logger: MiLogger,\n line: string,\n context: sourceParserContext,\n localPackageName: string,\n globalizeImports?: boolean,\n): lineProcessingResult {\n if (context.isInCommentBlock) {\n if (multilineCommentEndRE.exec(line)) {\n context.isInCommentBlock = false;\n }\n return { line: '', context, artifacts: [], option: undefined };\n }\n\n if (compilerOptionRE.exec(line)) {\n if (!context.canDetectOptions) {\n logger.error(\n `[line ${context.lineNo}]: compiler option '//tengo:' was detected, but it cannot be applied as compiler options can be set only at the file header, before any code line'`,\n );\n throw new Error('tengo compiler options (\\'//tengo:\\' comments) can be set only in file header');\n }\n return { line, context, artifacts: [], option: parseComplierOption(line) };\n }\n\n if (wrongCompilerOptionRE.exec(line) && context.canDetectOptions) {\n logger.warn(\n `[line ${context.lineNo}]: text simillar to compiler option ('//tengo:...') was detected, but it has wrong format. Leave it as is, if you did not mean to use a line as compiler option. Or format it to '//tengo:<option>' otherwise (no spaces between '//' and 'tengo', no spaces between ':' and option name)`,\n );\n return { line, context, artifacts: [], option: undefined };\n }\n\n if (singlelineCommentRE.test(line) || singlelineTerminatedCommentRE.test(line)) {\n return { line: '', context, artifacts: [], option: undefined };\n }\n\n const canBeInlinedComment = line.includes('*/');\n if (multilineCommentStartRE.exec(line) && !canBeInlinedComment) {\n context.isInCommentBlock = true;\n return { line: '', context, artifacts: [], option: undefined };\n }\n\n const statement = context.multilineStatement + line.trim();\n\n const mayContainAComment = line.includes('//') || line.includes('/*');\n if (multilineStatementRE.test(line) && !mayContainAComment) {\n // We accumulate multiline statements into single line before analyzing them.\n // This dramatically simplifies parsing logic: things like\n //\n // assets.\n // importSoftware(\"a:b\");\n //\n // become simple 'assets.importSoftware(\"a:b\");' for parser checks.\n //\n // For safety reasons, we never consider anything that 'may look like a comment'\n // as a part of multiline statement to prevent joining things like\n //\n // someFnCall() // looks like multiline statement because of dot in the end of a comment.\n //\n // This problem also appears in multiline string literals, but I hope this will not\n // cause problems in real life.\n\n // We still try to process each line to globalize imports in case of complex constructions, when\n // statements are stacked one into another:\n // a.\n // use(assets.importSoftware(\":soft1\")).\n // use(assets.importSoftware(\":soft2\")).\n // run()\n // It is multiline, and it still requires import globalization mid-way, not just for the last line of statement\n const result = processAssetImport(line, statement, context, localPackageName, globalizeImports);\n context.multilineStatement += result.line.trim(); // accumulate the line after imports globalization.\n return result;\n }\n\n context.multilineStatement = ''; // reset accumulated multiline statement parts once we reach statement end.\n\n if (emptyLineRE.exec(statement)) {\n return { line, context, artifacts: [], option: undefined };\n }\n\n // options could be only at the top of the file.\n context.canDetectOptions = false;\n\n return processAssetImport(line, statement, context, localPackageName, globalizeImports);\n}\n\nfunction processModuleImport(\n importInstruction: RegExpExecArray,\n originalLine: string,\n statement: string,\n context: sourceParserContext,\n localPackageName: string,\n globalizeImports?: boolean,\n): lineProcessingResult {\n const iInfo = parseImport(statement);\n\n // If we have plapi, ll or assets, then try to parse\n // getTemplateId, getSoftwareInfo, getSoftware and getAsset calls.\n\n if (iInfo.module === 'plapi') {\n if (!context.artifactImportREs.has(iInfo.module)) {\n context.artifactImportREs.set(iInfo.module, [\n ['template', newGetTemplateIdRE(iInfo.alias)],\n ['software', newGetSoftwareInfoRE(iInfo.alias)],\n ]);\n }\n return { line: originalLine, context, artifacts: [], option: undefined };\n }\n\n if (\n iInfo.module === '@milaboratory/tengo-sdk:ll'\n || iInfo.module === '@platforma-sdk/workflow-tengo:ll'\n || ((localPackageName === '@milaboratory/tengo-sdk'\n || localPackageName === '@platforma-sdk/workflow-tengo')\n && iInfo.module === ':ll')\n ) {\n if (!context.artifactImportREs.has(iInfo.module)) {\n context.artifactImportREs.set(iInfo.module, [\n ['template', newImportTemplateRE(iInfo.alias)],\n ['software', newImportSoftwareRE(iInfo.alias)],\n ]);\n }\n }\n\n if (\n iInfo.module === '@milaboratory/tengo-sdk:assets'\n || iInfo.module === '@platforma-sdk/workflow-tengo:assets'\n || ((localPackageName === '@milaboratory/tengo-sdk'\n || localPackageName === '@platforma-sdk/workflow-tengo')\n && iInfo.module === ':assets')\n ) {\n if (!context.artifactImportREs.has(iInfo.module)) {\n context.artifactImportREs.set(iInfo.module, [\n ['template', newImportTemplateRE(iInfo.alias)],\n ['software', newImportSoftwareRE(iInfo.alias)],\n ['asset', newImportAssetRE(iInfo.alias)],\n ]);\n context.importLikeREs.set(iInfo.module, [\n ['template', newImportTemplateDetector(iInfo.alias)],\n ['software', newImportSoftwareDetector(iInfo.alias)],\n ['asset', newImportAssetDetector(iInfo.alias)],\n ]);\n }\n }\n\n const artifact = parseArtifactName(iInfo.module, 'library', localPackageName);\n if (!artifact) {\n // not a Platforma Tengo library import\n return { line: originalLine, context, artifacts: [], option: undefined };\n }\n\n if (globalizeImports) {\n originalLine = originalLine.replace(importInstruction[0], ` := import(\"${artifact.pkg}:${artifact.id}\")`);\n }\n\n return { line: originalLine, context, artifacts: [artifact], option: undefined };\n}\n\nfunction processAssetImport(\n originalLine: string,\n statement: string,\n context: sourceParserContext,\n localPackageName: string,\n globalizeImports?: boolean,\n): lineProcessingResult {\n if (emptyLineRE.exec(statement)) {\n return { line: originalLine, context, artifacts: [], option: undefined };\n }\n\n // options could be only at the top of the file.\n context.canDetectOptions = false;\n\n const importInstruction = importRE.exec(statement);\n\n if (importInstruction) {\n return processModuleImport(importInstruction, originalLine, statement, context, localPackageName, globalizeImports);\n }\n\n if (context.artifactImportREs.size > 0) {\n for (const [_, artifactRE] of context.artifactImportREs) {\n for (const [artifactType, re] of artifactRE) {\n // Find all matches in the statement\n const matches = Array.from(statement.matchAll(re));\n if (matches.length === 0) {\n continue;\n }\n\n const artifacts: TypedArtifactName[] = [];\n for (let i = matches.length - 1; i >= 0; i--) {\n const match = matches[i];\n if (!match || !match.groups) {\n continue;\n }\n\n const { fnCall, templateName, fnName } = match.groups;\n\n if (!fnCall || !templateName || !fnName) {\n throw Error(`failed to parse template import statement`);\n }\n\n const artifact = parseArtifactName(templateName, artifactType, localPackageName);\n if (!artifact) {\n throw Error(`failed to parse artifact name in ${fnName} import statement`);\n }\n artifacts.push(artifact);\n\n if (globalizeImports) {\n // Replace all occurrences of this fnCall in originalLine\n originalLine = originalLine.replaceAll(fnCall, `${fnName}(\"${artifact.pkg}:${artifact.id}\")`);\n }\n }\n\n return { line: originalLine, context, artifacts, option: undefined };\n }\n }\n }\n\n if (context.importLikeREs.size > 0) {\n for (const [_, artifactRE] of context.importLikeREs) {\n for (const [artifactType, re] of artifactRE) {\n const match = re.exec(statement);\n if (!match || !match.groups) {\n continue;\n }\n\n throw Error(`incorrect '${artifactType}' import statement: use string literal as ID (variables are not allowed) in the same line with brackets (i.e. 'importSoftware(\"sw:main\")').`);\n }\n }\n }\n\n return { line: originalLine, context, artifacts: [], option: undefined };\n}\n\ninterface ImportInfo {\n module: string; // the module name without wrapping quotes: import(\"<module>\")\n alias: string; // the name of variable that keeps imported module: <alias> := import(\"<module>\")\n}\n\nfunction parseImport(line: string): ImportInfo {\n const match = importNameRE.exec(line);\n\n if (!match || !match.groups) {\n throw Error(`failed to parse 'import' statement`);\n }\n\n const { importName, moduleName } = match.groups;\n if (!importName || !moduleName) {\n throw Error(`failed to parse 'import' statement`);\n }\n\n return {\n module: moduleName, // the module name without wrapping quotes: import(\"<module>\")\n alias: importName, // the name of variable that keeps imported module: <alias> := import(\"<module>\")\n };\n}\n\nfunction parseArtifactName(\n moduleName: string,\n aType: ArtifactType,\n localPackageName: string,\n): TypedArtifactName | undefined {\n const depInfo = dependencyRE.exec(moduleName);\n if (!depInfo) {\n return;\n }\n\n if (!depInfo.groups) {\n throw Error(\n `failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'`,\n );\n }\n\n const { pkgName, depID } = depInfo.groups;\n if (!depID) {\n throw Error(\n `failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'`,\n );\n }\n\n return { type: aType, pkg: pkgName ?? localPackageName, id: depID };\n}\n\nexport function getSha256(source: string): string {\n return createHash('sha256').update(source).digest('hex');\n}\n"],"names":[],"mappings":";;;;;AAcA;AACA,MAAM,WAAW,GAAG,wBAAwB;AAE5C,MAAM,cAAc,GAAG,CAAC,UAAkB,EAAE,MAAc,KAAI;AAC5D,IAAA,OAAO,IAAI,MAAM,CACf,CAAA,GAAA,EAAM,UAAU,CAAA,uBAAA;UACd;UACA,CAAA,4CAAA,CAA8C,EAChD,GAAG,CACJ;AACH,CAAC;AAED,MAAM,kBAAkB,GAAG,CAAC,UAAkB,EAAE,MAAc,KAAI;AAChE,IAAA,OAAO,IAAI,MAAM,CACf,CAAA,GAAA,EAAM,UAAU,CAAA,aAAA;UACd;UACA,CAAA,QAAA,CAAU,EACZ,GAAG,CACJ;AACH,CAAC;AAEM,MAAM,kBAAkB,GAAG,CAAC,UAAkB,KAAK,cAAc,CAAC,UAAU,EAAE,eAAe;AAC7F,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MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,MAAM;IACzC,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,MAAM,KAAK,CACT,CAAA,4HAAA,CAA8H,CAC/H;IACH;AAEA,IAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,IAAI,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE;AACrE;AAEM,SAAU,SAAS,CAAC,MAAc,EAAA;AACtC,IAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAC1D;;;;"}
@@ -4,10 +4,11 @@ export interface TestArtifactSource {
4
4
  src: string;
5
5
  }
6
6
  export declare const testLocalLib1Name: FullArtifactName;
7
- export declare const testLocalLib1Src = "\notherLib := import(\"package1:other-lib-2\" )\nplapiCustomName := import(\"plapi\" )\n\nnotplapiCustomName.getTemplateId( \"some other:parameter\")\n\nplapiCustomName.getTemplateIdAnother(\"sss:kkk\" )\nplapiCustomName.getSoftwareInfo(\":software-1\")\n\nexport {\n \"some\": \"value\",\n \"template2\": plapiCustomName.getTemplateId(\":local-template-2\" ),\n \"template3\": plapiCustomName.getTemplateId ( \"package1:template-3\")\n}\n";
8
- export declare const testLocalLib1SrcNormalized = "\notherLib := import(\"package1:other-lib-2\")\nplapiCustomName := import(\"plapi\" )\n\nnotplapiCustomName.getTemplateId( \"some other:parameter\")\n\nplapiCustomName.getTemplateIdAnother(\"sss:kkk\" )\nplapiCustomName.getSoftwareInfo(\"current-package:software-1\")\n\nexport {\n \"some\": \"value\",\n \"template2\": plapiCustomName.getTemplateId(\"current-package:local-template-2\"),\n \"template3\": plapiCustomName.getTemplateId(\"package1:template-3\")\n}\n";
7
+ export declare const testLocalLib1Src = "\notherLib := import(\"package1:other-lib-2\" )\nplapiCustomName := import(\"plapi\" )\n\nnotplapiCustomName.getTemplateId( \"some other:parameter\")\n\n/* inline comment */ plapiCustomName.getTemplateIdAnother(\"sss:kkk\" )\nplapiCustomName.getSoftwareInfo(\":software-1\") /* inline comment */\n\nsomeCall(\"comment-like string literal/*\")\n\nexport {\n \"some\": \"value\",\n \"template2\": plapiCustomName.getTemplateId(\":local-template-2\" ),\n \"template3\": plapiCustomName.getTemplateId ( \"package1:template-3\")\n}\n";
8
+ export declare const testLocalLib1SrcNormalized = "\notherLib := import(\"package1:other-lib-2\")\nplapiCustomName := import(\"plapi\" )\n\nnotplapiCustomName.getTemplateId( \"some other:parameter\")\n\n/* inline comment */ plapiCustomName.getTemplateIdAnother(\"sss:kkk\" )\nplapiCustomName.getSoftwareInfo(\"current-package:software-1\") /* inline comment */\n\nsomeCall(\"comment-like string literal/*\")\n\nexport {\n \"some\": \"value\",\n \"template2\": plapiCustomName.getTemplateId(\"current-package:local-template-2\"),\n \"template3\": plapiCustomName.getTemplateId(\"package1:template-3\")\n}\n";
9
9
  export declare const testLocalLib2Name: FullArtifactName;
10
10
  export declare const testLocalLib2Src = "\notherLib := import(\"package1:someid\")\nll := import(\"@platforma-sdk/workflow-tengo:assets\")\n\n/* multiline comments should be ignored\n a := import(\":non-existent-library\")\n */\n\ntplID := ll.importTemplate(\"package2:template-1\")\nsoftwareID := ll.importSoftware(\"package2:software-1\")\nassetID := ll.importAsset(\"package2:asset-1\")\n\nexport {\n \"some\": \"value\",\n \"template1\": ll.importTemplate(\"current-package:local-template-2\"),\n \"template2\": tplID,\n}\n";
11
+ export declare const testLocalLib2SrcNormalized = "\notherLib := import(\"package1:someid\")\nll := import(\"@platforma-sdk/workflow-tengo:assets\")\n\n\n\n\n\ntplID := ll.importTemplate(\"package2:template-1\")\nsoftwareID := ll.importSoftware(\"package2:software-1\")\nassetID := ll.importAsset(\"package2:asset-1\")\n\nexport {\n \"some\": \"value\",\n \"template1\": ll.importTemplate(\"current-package:local-template-2\"),\n \"template2\": tplID,\n}\n";
11
12
  export declare const testLocalLib3Name: FullArtifactName;
12
13
  export declare const testLocalLib3Src = "\nexport {\n \"some\": \"value\"\n}\n";
13
14
  export declare const testLocalTpl1Name: FullArtifactName;
@@ -41,4 +42,6 @@ export declare const testPackage1Tpl3: TestArtifactSource;
41
42
  export declare const testPackage1: TestArtifactSource[];
42
43
  export declare const testPackage2: TestArtifactSource[];
43
44
  export declare const testPackage2BrokenHash: TestArtifactSource[];
45
+ export declare const testTrickyCasesSrc = "\nassets := import(\"@platforma-sdk/workflow-tengo:assets\")\nexec := import(\"@platforma-sdk/workflow-tengo:exec\")\n\nrun := exec.builder().\n processWorkdir(\"p\", assets.importTemplate(\":test.wd_processor_1\"), {}).\n processWorkdir(\"q\", assets.\n importTemplate(\":test.wd_processor_2\"),\n {}).\n run()\n";
46
+ export declare const testTrickyCasesNormalized = "\nassets := import(\"@platforma-sdk/workflow-tengo:assets\")\nexec := import(\"@platforma-sdk/workflow-tengo:exec\")\n\nrun := exec.builder().\n processWorkdir(\"p\", assets.importTemplate(\"stub-pkg:test.wd_processor_1\"), {}).\n processWorkdir(\"q\", assets.\n importTemplate(\"stub-pkg:test.wd_processor_2\"),\n {}).\n run()\n";
44
47
  //# sourceMappingURL=test.artifacts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.artifacts.d.ts","sourceRoot":"","sources":["../../src/compiler/test.artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AA4BD,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AACF,eAAO,MAAM,gBAAgB,qcAc5B,CAAC;AACF,eAAO,MAAM,0BAA0B,+dActC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AACF,eAAO,MAAM,gBAAgB,qfAiB5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,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a,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sBAAgD,CAAC;AAE9E,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,8CAI/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AACF,eAAO,MAAM,oBAAoB,wEAEhC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,gBAKpC,CAAC;AACF,eAAO,MAAM,qBAAqB,qEAEjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,kJAM/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,gDAE/B,CAAC;AAEF,eAAO,MAAM,8BAA8B,yOAC+L,CAAC;AAE3O,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,kBAAkB,EAI5C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,kBAAkB,EAAmC,CAAC;AAEjF,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,EAMtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,uUAU9B,CAAC;AAEF,eAAO,MAAM,yBAAyB,uVAUrC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/tengo-builder",
3
- "version": "2.3.14",
3
+ "version": "2.4.0",
4
4
  "description": "Pl Tengo Template Builder",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,11 +28,11 @@
28
28
  "typescript": "~5.6.3",
29
29
  "vitest": "^4.0.7",
30
30
  "@types/node": "~24.5.2",
31
- "@milaboratories/eslint-config": "1.0.5",
32
- "@milaboratories/ts-builder": "1.0.5",
33
- "@milaboratories/build-configs": "1.0.8",
31
+ "@milaboratories/build-configs": "1.0.9",
32
+ "@milaboratories/ts-builder": "1.0.6",
34
33
  "@milaboratories/ts-configs": "1.0.6",
35
- "@milaboratories/oclif-index": "1.1.1"
34
+ "@milaboratories/oclif-index": "1.1.1",
35
+ "@milaboratories/eslint-config": "1.0.5"
36
36
  },
37
37
  "oclif": {
38
38
  "bin": "pl-tengo",