@platforma-sdk/tengo-builder 2.3.14 → 2.4.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.
- package/dist/compiler/source.cjs +156 -92
- package/dist/compiler/source.cjs.map +1 -1
- package/dist/compiler/source.d.ts +8 -6
- package/dist/compiler/source.d.ts.map +1 -1
- package/dist/compiler/source.js +156 -92
- package/dist/compiler/source.js.map +1 -1
- package/dist/compiler/test.artifacts.d.ts +5 -2
- package/dist/compiler/test.artifacts.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/compiler/source.test.ts +209 -50
- package/src/compiler/source.ts +203 -108
- package/src/compiler/test.artifacts.ts +50 -4
package/dist/compiler/source.cjs
CHANGED
|
@@ -10,30 +10,29 @@ const namePattern = '[_a-zA-Z][_a-zA-Z0-9]*';
|
|
|
10
10
|
const functionCallRE = (moduleName, fnName) => {
|
|
11
11
|
return new RegExp(`\\b${moduleName}\\.(?<fnCall>(?<fnName>`
|
|
12
12
|
+ fnName
|
|
13
|
-
+ `)\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))
|
|
13
|
+
+ `)\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))`, 'g');
|
|
14
14
|
};
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return functionCallRE(moduleName, 'getSoftwareInfo');
|
|
20
|
-
};
|
|
21
|
-
const newImportTemplateRE = (moduleName) => {
|
|
22
|
-
return functionCallRE(moduleName, 'importTemplate');
|
|
23
|
-
};
|
|
24
|
-
const newImportSoftwareRE = (moduleName) => {
|
|
25
|
-
return functionCallRE(moduleName, 'importSoftware');
|
|
26
|
-
};
|
|
27
|
-
const newImportAssetRE = (moduleName) => {
|
|
28
|
-
return functionCallRE(moduleName, 'importAsset');
|
|
15
|
+
const functionCallLikeRE = (moduleName, fnName) => {
|
|
16
|
+
return new RegExp(`\\b${moduleName}\\.(?<fnName>`
|
|
17
|
+
+ fnName
|
|
18
|
+
+ `)\\s*\\(`, 'g');
|
|
29
19
|
};
|
|
20
|
+
const newGetTemplateIdRE = (moduleName) => functionCallRE(moduleName, 'getTemplateId');
|
|
21
|
+
const newGetSoftwareInfoRE = (moduleName) => functionCallRE(moduleName, 'getSoftwareInfo');
|
|
22
|
+
const newImportTemplateRE = (moduleName) => functionCallRE(moduleName, 'importTemplate');
|
|
23
|
+
const newImportTemplateDetector = (moduleName) => functionCallLikeRE(moduleName, 'importTemplate');
|
|
24
|
+
const newImportSoftwareRE = (moduleName) => functionCallRE(moduleName, 'importSoftware');
|
|
25
|
+
const newImportSoftwareDetector = (moduleName) => functionCallLikeRE(moduleName, 'importSoftware');
|
|
26
|
+
const newImportAssetRE = (moduleName) => functionCallRE(moduleName, 'importAsset');
|
|
27
|
+
const newImportAssetDetector = (moduleName) => functionCallLikeRE(moduleName, 'importAsset');
|
|
30
28
|
const emptyLineRE = /^\s*$/;
|
|
31
29
|
const compilerOptionRE = /^\/\/tengo:[\w]/;
|
|
32
30
|
const wrongCompilerOptionRE = /^\s*\/\/\s*tengo:\s*./;
|
|
33
|
-
const inlineCommentRE = /\/\*.*?\*\//g; // .*? = non-greedy search
|
|
34
31
|
const singlelineCommentRE = /^\s*(\/\/)/;
|
|
32
|
+
const singlelineTerminatedCommentRE = /^\s*\/\*.*\*\/\s*$/; // matches '^/* ... */$' comment lines as a special case of singleline comments.
|
|
35
33
|
const multilineCommentStartRE = /^\s*\/\*/;
|
|
36
34
|
const multilineCommentEndRE = /\*\//;
|
|
35
|
+
const multilineStatementRE = /[.,]\s*$/; // it is hard to consistently treat (\n"a"\n) multiline statements, we forbid them for now.
|
|
37
36
|
// import could only be an assignment in a statement,
|
|
38
37
|
// other ways could break a compilation.
|
|
39
38
|
const importRE = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/;
|
|
@@ -116,16 +115,18 @@ function parseSourceData(logger, src, fullSourceName, globalizeImports) {
|
|
|
116
115
|
let parserContext = {
|
|
117
116
|
isInCommentBlock: false,
|
|
118
117
|
canDetectOptions: true,
|
|
119
|
-
|
|
118
|
+
artifactImportREs: new Map(),
|
|
119
|
+
importLikeREs: new Map(),
|
|
120
|
+
multilineStatement: '',
|
|
120
121
|
lineNo: 0,
|
|
121
122
|
};
|
|
122
123
|
for (const line of lines) {
|
|
123
124
|
parserContext.lineNo++;
|
|
124
125
|
try {
|
|
125
|
-
const { line: processedLine, context: newContext,
|
|
126
|
+
const { line: processedLine, context: newContext, artifacts, option } = parseSingleSourceLine(logger, line, parserContext, fullSourceName.pkg, globalizeImports);
|
|
126
127
|
processedLines.push(processedLine);
|
|
127
128
|
parserContext = newContext;
|
|
128
|
-
|
|
129
|
+
for (const artifact of artifacts ?? []) {
|
|
129
130
|
dependencySet.add(artifact);
|
|
130
131
|
}
|
|
131
132
|
if (option) {
|
|
@@ -144,112 +145,175 @@ function parseSourceData(logger, src, fullSourceName, globalizeImports) {
|
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
function parseSingleSourceLine(logger, line, context, localPackageName, globalizeImports) {
|
|
147
|
-
// preprocess line and remove inline comments
|
|
148
|
-
line = line.replaceAll(inlineCommentRE, '');
|
|
149
148
|
if (context.isInCommentBlock) {
|
|
150
149
|
if (multilineCommentEndRE.exec(line)) {
|
|
151
150
|
context.isInCommentBlock = false;
|
|
152
151
|
}
|
|
153
|
-
return { line: '', context,
|
|
152
|
+
return { line: '', context, artifacts: [], option: undefined };
|
|
154
153
|
}
|
|
155
154
|
if (compilerOptionRE.exec(line)) {
|
|
156
155
|
if (!context.canDetectOptions) {
|
|
157
156
|
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'`);
|
|
158
157
|
throw new Error('tengo compiler options (\'//tengo:\' comments) can be set only in file header');
|
|
159
158
|
}
|
|
160
|
-
return { line, context,
|
|
159
|
+
return { line, context, artifacts: [], option: parseComplierOption(line) };
|
|
161
160
|
}
|
|
162
161
|
if (wrongCompilerOptionRE.exec(line) && context.canDetectOptions) {
|
|
163
162
|
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)`);
|
|
164
|
-
return { line, context,
|
|
163
|
+
return { line, context, artifacts: [], option: undefined };
|
|
165
164
|
}
|
|
166
|
-
if (singlelineCommentRE.test(line)) {
|
|
167
|
-
return { line: '', context,
|
|
165
|
+
if (singlelineCommentRE.test(line) || singlelineTerminatedCommentRE.test(line)) {
|
|
166
|
+
return { line: '', context, artifacts: [], option: undefined };
|
|
168
167
|
}
|
|
169
|
-
|
|
168
|
+
const canBeInlinedComment = line.includes('*/');
|
|
169
|
+
if (multilineCommentStartRE.exec(line) && !canBeInlinedComment) {
|
|
170
170
|
context.isInCommentBlock = true;
|
|
171
|
-
return { line: '', context,
|
|
171
|
+
return { line: '', context, artifacts: [], option: undefined };
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
const statement = context.multilineStatement + line.trim();
|
|
174
|
+
const mayContainAComment = line.includes('//') || line.includes('/*');
|
|
175
|
+
if (multilineStatementRE.test(line) && !mayContainAComment) {
|
|
176
|
+
// We accumulate multiline statements into single line before analyzing them.
|
|
177
|
+
// This dramatically simplifies parsing logic: things like
|
|
178
|
+
//
|
|
179
|
+
// assets.
|
|
180
|
+
// importSoftware("a:b");
|
|
181
|
+
//
|
|
182
|
+
// become simple 'assets.importSoftware("a:b");' for parser checks.
|
|
183
|
+
//
|
|
184
|
+
// For safety reasons, we never consider anything that 'may look like a comment'
|
|
185
|
+
// as a part of multiline statement to prevent joining things like
|
|
186
|
+
//
|
|
187
|
+
// someFnCall() // looks like multiline statement because of dot in the end of a comment.
|
|
188
|
+
//
|
|
189
|
+
// This problem also appears in multiline string literals, but I hope this will not
|
|
190
|
+
// cause problems in real life.
|
|
191
|
+
// We still try to process each line to globalize imports in case of complex constructions, when
|
|
192
|
+
// statements are stacked one into another:
|
|
193
|
+
// a.
|
|
194
|
+
// use(assets.importSoftware(":soft1")).
|
|
195
|
+
// use(assets.importSoftware(":soft2")).
|
|
196
|
+
// run()
|
|
197
|
+
// It is multiline, and it still requires import globalization mid-way, not just for the last line of statement
|
|
198
|
+
const result = processAssetImport(line, statement, context, localPackageName);
|
|
199
|
+
context.multilineStatement += result.line.trim(); // accumulate the line after imports globalization.
|
|
200
|
+
return result;
|
|
175
201
|
}
|
|
176
|
-
|
|
177
|
-
|
|
202
|
+
context.multilineStatement = ''; // reset accumulated multiline statement parts once we reach statement end.
|
|
203
|
+
if (emptyLineRE.exec(statement)) {
|
|
204
|
+
return { line, context, artifacts: [], option: undefined };
|
|
178
205
|
}
|
|
179
206
|
// options could be only at the top of the file.
|
|
180
207
|
context.canDetectOptions = false;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
]
|
|
192
|
-
|
|
193
|
-
return { line, context, artifact: undefined, option: undefined };
|
|
194
|
-
}
|
|
195
|
-
if (iInfo.module === '@milaboratory/tengo-sdk:ll'
|
|
196
|
-
|| iInfo.module === '@platforma-sdk/workflow-tengo:ll'
|
|
197
|
-
|| ((localPackageName === '@milaboratory/tengo-sdk'
|
|
198
|
-
|| localPackageName === '@platforma-sdk/workflow-tengo')
|
|
199
|
-
&& iInfo.module === ':ll')) {
|
|
200
|
-
if (!context.tplDepREs.has(iInfo.module)) {
|
|
201
|
-
context.tplDepREs.set(iInfo.module, [
|
|
202
|
-
['template', newImportTemplateRE(iInfo.alias)],
|
|
203
|
-
['software', newImportSoftwareRE(iInfo.alias)],
|
|
204
|
-
]);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (iInfo.module === '@milaboratory/tengo-sdk:assets'
|
|
208
|
-
|| iInfo.module === '@platforma-sdk/workflow-tengo:assets'
|
|
209
|
-
|| ((localPackageName === '@milaboratory/tengo-sdk'
|
|
210
|
-
|| localPackageName === '@platforma-sdk/workflow-tengo')
|
|
211
|
-
&& iInfo.module === ':assets')) {
|
|
212
|
-
if (!context.tplDepREs.has(iInfo.module)) {
|
|
213
|
-
context.tplDepREs.set(iInfo.module, [
|
|
214
|
-
['template', newImportTemplateRE(iInfo.alias)],
|
|
215
|
-
['software', newImportSoftwareRE(iInfo.alias)],
|
|
216
|
-
['asset', newImportAssetRE(iInfo.alias)],
|
|
217
|
-
]);
|
|
218
|
-
}
|
|
208
|
+
return processAssetImport(line, statement, context, localPackageName);
|
|
209
|
+
}
|
|
210
|
+
function processModuleImport(importInstruction, originalLine, statement, context, localPackageName, globalizeImports) {
|
|
211
|
+
const iInfo = parseImport(statement);
|
|
212
|
+
// If we have plapi, ll or assets, then try to parse
|
|
213
|
+
// getTemplateId, getSoftwareInfo, getSoftware and getAsset calls.
|
|
214
|
+
if (iInfo.module === 'plapi') {
|
|
215
|
+
if (!context.artifactImportREs.has(iInfo.module)) {
|
|
216
|
+
context.artifactImportREs.set(iInfo.module, [
|
|
217
|
+
['template', newGetTemplateIdRE(iInfo.alias)],
|
|
218
|
+
['software', newGetSoftwareInfoRE(iInfo.alias)],
|
|
219
|
+
]);
|
|
219
220
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
return { line: originalLine, context, artifacts: [], option: undefined };
|
|
222
|
+
}
|
|
223
|
+
if (iInfo.module === '@milaboratory/tengo-sdk:ll'
|
|
224
|
+
|| iInfo.module === '@platforma-sdk/workflow-tengo:ll'
|
|
225
|
+
|| ((localPackageName === '@milaboratory/tengo-sdk'
|
|
226
|
+
|| localPackageName === '@platforma-sdk/workflow-tengo')
|
|
227
|
+
&& iInfo.module === ':ll')) {
|
|
228
|
+
if (!context.artifactImportREs.has(iInfo.module)) {
|
|
229
|
+
context.artifactImportREs.set(iInfo.module, [
|
|
230
|
+
['template', newImportTemplateRE(iInfo.alias)],
|
|
231
|
+
['software', newImportSoftwareRE(iInfo.alias)],
|
|
232
|
+
]);
|
|
224
233
|
}
|
|
225
|
-
|
|
226
|
-
|
|
234
|
+
}
|
|
235
|
+
if (iInfo.module === '@milaboratory/tengo-sdk:assets'
|
|
236
|
+
|| iInfo.module === '@platforma-sdk/workflow-tengo:assets'
|
|
237
|
+
|| ((localPackageName === '@milaboratory/tengo-sdk'
|
|
238
|
+
|| localPackageName === '@platforma-sdk/workflow-tengo')
|
|
239
|
+
&& iInfo.module === ':assets')) {
|
|
240
|
+
if (!context.artifactImportREs.has(iInfo.module)) {
|
|
241
|
+
context.artifactImportREs.set(iInfo.module, [
|
|
242
|
+
['template', newImportTemplateRE(iInfo.alias)],
|
|
243
|
+
['software', newImportSoftwareRE(iInfo.alias)],
|
|
244
|
+
['asset', newImportAssetRE(iInfo.alias)],
|
|
245
|
+
]);
|
|
246
|
+
context.importLikeREs.set(iInfo.module, [
|
|
247
|
+
['template', newImportTemplateDetector(iInfo.alias)],
|
|
248
|
+
['software', newImportSoftwareDetector(iInfo.alias)],
|
|
249
|
+
['asset', newImportAssetDetector(iInfo.alias)],
|
|
250
|
+
]);
|
|
227
251
|
}
|
|
228
|
-
return { line, context, artifact, option: undefined };
|
|
229
252
|
}
|
|
230
|
-
|
|
231
|
-
|
|
253
|
+
const artifact = parseArtifactName(iInfo.module, 'library', localPackageName);
|
|
254
|
+
if (!artifact) {
|
|
255
|
+
// not a Platforma Tengo library import
|
|
256
|
+
return { line: originalLine, context, artifacts: [], option: undefined };
|
|
257
|
+
}
|
|
258
|
+
{
|
|
259
|
+
originalLine = originalLine.replace(importInstruction[0], ` := import("${artifact.pkg}:${artifact.id}")`);
|
|
260
|
+
}
|
|
261
|
+
return { line: originalLine, context, artifacts: [artifact], option: undefined };
|
|
262
|
+
}
|
|
263
|
+
function processAssetImport(originalLine, statement, context, localPackageName, globalizeImports) {
|
|
264
|
+
if (emptyLineRE.exec(statement)) {
|
|
265
|
+
return { line: originalLine, context, artifacts: [], option: undefined };
|
|
266
|
+
}
|
|
267
|
+
// options could be only at the top of the file.
|
|
268
|
+
context.canDetectOptions = false;
|
|
269
|
+
const importInstruction = importRE.exec(statement);
|
|
270
|
+
if (importInstruction) {
|
|
271
|
+
return processModuleImport(importInstruction, originalLine, statement, context, localPackageName);
|
|
272
|
+
}
|
|
273
|
+
if (context.artifactImportREs.size > 0) {
|
|
274
|
+
for (const [_, artifactRE] of context.artifactImportREs) {
|
|
232
275
|
for (const [artifactType, re] of artifactRE) {
|
|
233
|
-
|
|
234
|
-
|
|
276
|
+
// Find all matches in the statement
|
|
277
|
+
const matches = Array.from(statement.matchAll(re));
|
|
278
|
+
if (matches.length === 0) {
|
|
235
279
|
continue;
|
|
236
280
|
}
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
281
|
+
const artifacts = [];
|
|
282
|
+
for (let i = matches.length - 1; i >= 0; i--) {
|
|
283
|
+
const match = matches[i];
|
|
284
|
+
if (!match || !match.groups) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const { fnCall, templateName, fnName } = match.groups;
|
|
288
|
+
if (!fnCall || !templateName || !fnName) {
|
|
289
|
+
throw Error(`failed to parse template import statement`);
|
|
290
|
+
}
|
|
291
|
+
const artifact = parseArtifactName(templateName, artifactType, localPackageName);
|
|
292
|
+
if (!artifact) {
|
|
293
|
+
throw Error(`failed to parse artifact name in ${fnName} import statement`);
|
|
294
|
+
}
|
|
295
|
+
artifacts.push(artifact);
|
|
296
|
+
{
|
|
297
|
+
// Replace all occurrences of this fnCall in originalLine
|
|
298
|
+
originalLine = originalLine.replaceAll(fnCall, `${fnName}("${artifact.pkg}:${artifact.id}")`);
|
|
299
|
+
}
|
|
240
300
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
301
|
+
return { line: originalLine, context, artifacts, option: undefined };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (context.importLikeREs.size > 0) {
|
|
306
|
+
for (const [_, artifactRE] of context.importLikeREs) {
|
|
307
|
+
for (const [artifactType, re] of artifactRE) {
|
|
308
|
+
const match = re.exec(statement);
|
|
309
|
+
if (!match || !match.groups) {
|
|
310
|
+
continue;
|
|
247
311
|
}
|
|
248
|
-
|
|
312
|
+
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")').`);
|
|
249
313
|
}
|
|
250
314
|
}
|
|
251
315
|
}
|
|
252
|
-
return { line, context,
|
|
316
|
+
return { line: originalLine, context, artifacts: [], option: undefined };
|
|
253
317
|
}
|
|
254
318
|
function parseImport(line) {
|
|
255
319
|
const match = importNameRE.exec(line);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.cjs","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":["readFileSync","createArtifactNameSet","fullNameToString","createHash"],"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,IAAA,OAAO,cAAc,CAAC,UAAU,EAAE,eAAe,CAAC;AACpD;AACO,MAAM,oBAAoB,GAAG,CAAC,UAAkB,KAAI;AACzD,IAAA,OAAO,cAAc,CAAC,UAAU,EAAE,iBAAiB,CAAC;AACtD;AAEA,MAAM,mBAAmB,GAAG,CAAC,UAAkB,KAAI;AACjD,IAAA,OAAO,cAAc,CAAC,UAAU,EAAE,gBAAgB,CAAC;AACrD,CAAC;AACD,MAAM,mBAAmB,GAAG,CAAC,UAAkB,KAAI;AACjD,IAAA,OAAO,cAAc,CAAC,UAAU,EAAE,gBAAgB,CAAC;AACrD,CAAC;AACD,MAAM,gBAAgB,GAAG,CAAC,UAAkB,KAAI;AAC9C,IAAA,OAAO,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC;AAClD,CAAC;AAED,MAAM,WAAW,GAAG,OAAO;AAC3B,MAAM,gBAAgB,GAAG,iBAAiB;AAC1C,MAAM,qBAAqB,GAAG,uBAAuB;AACrD,MAAM,eAAe,GAAG,cAAc,CAAC;AACvC,MAAM,mBAAmB,GAAG,YAAY;AACxC,MAAM,uBAAuB,GAAG,UAAU;AAC1C,MAAM,qBAAqB,GAAG,MAAM;AAEpC;AACA;AACA,MAAM,QAAQ,GAAG,mDAAmD;AACpE,MAAM,YAAY,GAAG,IAAI,MAAM,CAC7B,CAAA,iB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ClB,KAAK,EAAE,UAAU;KAClB;AACH;AAEA,SAAS,iBAAiB,CACxB,UAAkB,EAClB,KAAmB,EACnB,gBAAwB,EAAA;IAExB,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE;QACZ;IACF;AAEA,IAAA,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AACnB,QAAA,MAAM,KAAK,CACT,CAAA,4HAAA,CAA8H,CAC/H;IACH;IAEA,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,OAAOC,sBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAC1D;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"source.cjs","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":["readFileSync","createArtifactNameSet","fullNameToString","createHash"],"mappings":";;;;;;;AAcA;AACA,MAAM,WAAW,GAAG,wBAAwB;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AAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE;AAC9B,QAAA,MAAM,KAAK,CAAC,CAAA,kCAAA,CAAoC,CAAC;IACnD;IAEA,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,UAAU;KAClB;AACH;AAEA,SAAS,iBAAiB,CACxB,UAAkB,EAClB,KAAmB,EACnB,gBAAwB,EAAA;IAExB,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE;QACZ;IACF;AAEA,IAAA,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AACnB,QAAA,MAAM,KAAK,CACT,CAAA,4HAAA,CAA8H,CAC/H;IACH;IAEA,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,OAAOC,sBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAC1D;;;;;;;;;"}
|
|
@@ -35,18 +35,20 @@ export declare class ArtifactSource {
|
|
|
35
35
|
}
|
|
36
36
|
export declare function parseSourceFile(logger: MiLogger, mode: CompileMode, srcFile: string, fullSourceName: FullArtifactName, normalize: boolean): ArtifactSource;
|
|
37
37
|
export declare function parseSource(logger: MiLogger, mode: CompileMode, src: string, fullSourceName: FullArtifactName, normalize: boolean): ArtifactSource;
|
|
38
|
-
|
|
38
|
+
export type sourceParserContext = {
|
|
39
39
|
isInCommentBlock: boolean;
|
|
40
40
|
canDetectOptions: boolean;
|
|
41
|
-
|
|
41
|
+
artifactImportREs: Map<string, [ArtifactType, RegExp][]>;
|
|
42
|
+
importLikeREs: Map<string, [ArtifactType, RegExp][]>;
|
|
43
|
+
multilineStatement: string;
|
|
42
44
|
lineNo: number;
|
|
43
|
-
}
|
|
44
|
-
export
|
|
45
|
+
};
|
|
46
|
+
export type lineProcessingResult = {
|
|
45
47
|
line: string;
|
|
46
48
|
context: sourceParserContext;
|
|
47
|
-
|
|
49
|
+
artifacts: TypedArtifactName[];
|
|
48
50
|
option: CompilerOption | undefined;
|
|
49
51
|
};
|
|
52
|
+
export declare function parseSingleSourceLine(logger: MiLogger, line: string, context: sourceParserContext, localPackageName: string, globalizeImports?: boolean): lineProcessingResult;
|
|
50
53
|
export declare function getSha256(source: string): string;
|
|
51
|
-
export {};
|
|
52
54
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/compiler/source.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/compiler/source.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAuB3D,eAAO,MAAM,kBAAkB,eAAgB,MAAM,WAAgD,CAAC;AACtG,eAAO,MAAM,oBAAoB,eAAgB,MAAM,WAAkD,CAAC;AAkD1G,qBAAa,cAAc;IAEvB,qDAAqD;aACrC,WA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