@microtronics/studio-cli 0.61.0 → 0.63.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.
- package/CHANGELOG.md +15 -3
- package/README.md +17 -0
- package/dist/main.js +54 -57
- package/dist/studio-cli.d.ts +1 -0
- package/out/api.js +137 -149
- package/out/studio-cli.d.ts +5297 -0
- package/package.json +4 -4
- package/out/DeviceProfiles.js +0 -436
- package/out/FS.js +0 -43
- package/out/crc.js +0 -93
- package/out/dde/coreDefinitions.js +0 -541
- package/out/dde/dde.js +0 -618
- package/out/dde/dynamic-dde.schema.json +0 -1061
- package/out/dde/fileGenerators/api.js +0 -688
- package/out/dde/fileGenerators/dlo.js +0 -1014
- package/out/dde/fileGenerators/dloLocalData.js +0 -387
- package/out/dde/fileGenerators/xml.js +0 -180
- package/out/dde/yamlDdePreCompiler.js +0 -889
- package/out/defaultFiles.js +0 -114
- package/out/dependencies.js +0 -578
- package/out/dfiles/dfiles.js +0 -205
- package/out/diagnostics.js +0 -10
- package/out/dlo/CustomWasmFS.js +0 -258
- package/out/dlo/compiler.js +0 -231
- package/out/dlo/dlo.js +0 -33
- package/out/dlo/dlocc.js +0 -3799
- package/out/dlo/fileSequencer.js +0 -40
- package/out/dlo/preCompiler.js +0 -442
- package/out/dotenv.js +0 -28
- package/out/globals.js +0 -402
- package/out/helper.js +0 -145
- package/out/log.js +0 -60
- package/out/manifest.js +0 -492
- package/out/myDatanetClient.js +0 -291
- package/out/package/apm.js +0 -294
- package/out/package/library.js +0 -165
- package/out/package/package.js +0 -518
- package/out/registryAPI.js +0 -326
- package/out/scriptRunner.js +0 -107
- package/out/typings/registry.js +0 -7
package/out/globals.js
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Globals = void 0;
|
|
27
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
28
|
-
const dependencies_1 = require("./dependencies");
|
|
29
|
-
const manifest_1 = require("./manifest");
|
|
30
|
-
const defaultFiles_1 = require("./defaultFiles");
|
|
31
|
-
const ini = __importStar(require("ini"));
|
|
32
|
-
const helper_1 = require("./helper");
|
|
33
|
-
var convertBlobToString = helper_1.Helper.convertBlobToString;
|
|
34
|
-
const DLO_PATH = defaultFiles_1.DefaultFiles.filePaths.dlo.path;
|
|
35
|
-
var Globals;
|
|
36
|
-
(function (Globals) {
|
|
37
|
-
/**
|
|
38
|
-
* Supported ENV for the studio environment
|
|
39
|
-
*/
|
|
40
|
-
let ENV;
|
|
41
|
-
(function (ENV) {
|
|
42
|
-
ENV["lucky"] = "lucky";
|
|
43
|
-
ENV["wynni"] = "wynni";
|
|
44
|
-
ENV["production"] = "production";
|
|
45
|
-
})(ENV = Globals.ENV || (Globals.ENV = {}));
|
|
46
|
-
/**
|
|
47
|
-
* Read all ini files from the project directory and its dependencies.
|
|
48
|
-
*
|
|
49
|
-
* Merge order (lowest → highest priority):
|
|
50
|
-
* Library dlo/<name>.ini & defaults.ini (from each installed dependency)
|
|
51
|
-
* Project dlo/<name>.ini (library projects only)
|
|
52
|
-
* Project dlo/main.ini (or manifest dlo.iniFile override)
|
|
53
|
-
* Project defaults.ini (library) or app.ini (app/addon/analytics)
|
|
54
|
-
*
|
|
55
|
-
* @param cwd - project root URI
|
|
56
|
-
* @param fs - filesystem abstraction
|
|
57
|
-
* @param logger
|
|
58
|
-
*/
|
|
59
|
-
async function read(cwd, fs, logger) {
|
|
60
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
61
|
-
const allDependencies = await dependencies_1.Dependencies.getAll(manifest);
|
|
62
|
-
const allDefines = {};
|
|
63
|
-
const sections = {};
|
|
64
|
-
const definesWithSource = {};
|
|
65
|
-
// Library dlo/<name>.ini and default.ini files
|
|
66
|
-
for (const dependencyId in allDependencies) {
|
|
67
|
-
const depPath = dependencies_1.Dependencies.dependencyToPath(cwd, dependencyId);
|
|
68
|
-
const name = dependencies_1.Dependencies.dependencyIdToName(dependencyId);
|
|
69
|
-
const libIniPath = vscode_uri_1.Utils.joinPath(depPath, DLO_PATH, `${name}.ini`);
|
|
70
|
-
await mergeIniFile(fs, libIniPath, allDefines, sections, definesWithSource, name);
|
|
71
|
-
// defaults.ini files
|
|
72
|
-
const libDefaultsPath = vscode_uri_1.Utils.joinPath(depPath, defaultFiles_1.DefaultFiles.filePaths.defaultsIni);
|
|
73
|
-
await mergeIniFile(fs, libDefaultsPath, allDefines, sections, definesWithSource, name);
|
|
74
|
-
}
|
|
75
|
-
// Load the library project's specific ini file (deprecated location)
|
|
76
|
-
if (manifest_1.Manifest.isLibrary(manifest)) {
|
|
77
|
-
const libIni = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dlo.path, `${manifest.name}.ini`);
|
|
78
|
-
if (logger && (await fs.stat(libIni))) {
|
|
79
|
-
logger.warn(`dlo/${manifest.name}.ini is deprecated. Please migrate your defines to defaults.ini in the project root.`);
|
|
80
|
-
}
|
|
81
|
-
await mergeIniFile(fs, libIni, allDefines, sections, definesWithSource, manifest.name);
|
|
82
|
-
}
|
|
83
|
-
// Load the project's main.ini and overwrite existing defines (deprecated location)
|
|
84
|
-
const mainIniRelPath = manifest.dlo?.iniFile || defaultFiles_1.DefaultFiles.filePaths.dlo.mainINI;
|
|
85
|
-
const mainIni = vscode_uri_1.Utils.joinPath(cwd, mainIniRelPath);
|
|
86
|
-
if (logger && (await fs.stat(mainIni))) {
|
|
87
|
-
logger.warn(`${mainIniRelPath} is deprecated. Please migrate your defines to app.ini in the project root.`);
|
|
88
|
-
}
|
|
89
|
-
const mainIniLabel = iniFileLabel(mainIniRelPath);
|
|
90
|
-
await mergeIniFile(fs, mainIni, allDefines, sections, definesWithSource, mainIniLabel);
|
|
91
|
-
// Project root: defaults.ini (library) or app.ini (app/addon/analytics)
|
|
92
|
-
if (manifest_1.Manifest.isLibrary(manifest)) {
|
|
93
|
-
const defaultsIni = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.defaultsIni);
|
|
94
|
-
await mergeIniFile(fs, defaultsIni, allDefines, sections, definesWithSource, 'defaults');
|
|
95
|
-
}
|
|
96
|
-
// Snapshot defaults-only state before app.ini merge (for library dual-defines)
|
|
97
|
-
const defaultsOnly = snapshotDefaultsOnly(manifest, allDefines, sections, definesWithSource);
|
|
98
|
-
// app.ini is always loaded (provides local dev overrides for libraries, main config for apps)
|
|
99
|
-
const appIni = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.appIni);
|
|
100
|
-
await mergeIniFile(fs, appIni, allDefines, sections, definesWithSource, 'app');
|
|
101
|
-
return { flat: allDefines, sections, definesWithSource, defaultsOnly };
|
|
102
|
-
}
|
|
103
|
-
Globals.read = read;
|
|
104
|
-
/**
|
|
105
|
-
* Generate a dist/defines.ts file from the resolved config.
|
|
106
|
-
* The generated file creates/extends globalThis.STUDIO_DEFINES.
|
|
107
|
-
*
|
|
108
|
-
* @param cwd - project root URI
|
|
109
|
-
* @param fs - filesystem abstraction
|
|
110
|
-
* @param resolvedConfig - the resolved config from Globals.read()
|
|
111
|
-
*/
|
|
112
|
-
async function exportDefinesTs(cwd, fs, resolvedConfig, outputPath) {
|
|
113
|
-
const entries = Object.entries(resolvedConfig.flat);
|
|
114
|
-
// Build the StudioDefines interface members
|
|
115
|
-
const interfaceLines = [];
|
|
116
|
-
for (const [key, value] of entries) {
|
|
117
|
-
const entry = resolvedConfig.definesWithSource[key];
|
|
118
|
-
if (entry?.comment) {
|
|
119
|
-
const jsDoc = formatJsDoc(entry.comment);
|
|
120
|
-
for (const docLine of jsDoc.split('\n')) {
|
|
121
|
-
interfaceLines.push(`\t\t${docLine}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const tsType = isNumericValue(value) ? 'number' : 'string';
|
|
125
|
-
interfaceLines.push(`\t\t${key}: ${tsType};`);
|
|
126
|
-
}
|
|
127
|
-
const lines = [
|
|
128
|
-
'// Auto-generated by @microtronics/studio-cli \u2014 DO NOT EDIT',
|
|
129
|
-
'declare global {',
|
|
130
|
-
'\tinterface StudioDefines {',
|
|
131
|
-
...interfaceLines,
|
|
132
|
-
'\t}',
|
|
133
|
-
'\tvar STUDIO_DEFINES: StudioDefines;',
|
|
134
|
-
'}',
|
|
135
|
-
'',
|
|
136
|
-
'globalThis.STUDIO_DEFINES ??= {} as StudioDefines;',
|
|
137
|
-
''
|
|
138
|
-
];
|
|
139
|
-
for (const [key, value] of entries) {
|
|
140
|
-
const entry = resolvedConfig.definesWithSource[key];
|
|
141
|
-
if (entry?.comment) {
|
|
142
|
-
lines.push(formatJsDoc(entry.comment));
|
|
143
|
-
}
|
|
144
|
-
if (isNumericValue(value)) {
|
|
145
|
-
lines.push(`globalThis.STUDIO_DEFINES['${key}'] = ${Number(value)};`);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
const escapedValue = value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
149
|
-
lines.push(`globalThis.STUDIO_DEFINES['${key}'] = '${escapedValue}';`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
lines.push('');
|
|
153
|
-
lines.push('export {};');
|
|
154
|
-
lines.push('');
|
|
155
|
-
const definesPath = vscode_uri_1.Utils.joinPath(cwd, outputPath ?? defaultFiles_1.DefaultFiles.filePaths.dist.definesTs);
|
|
156
|
-
await fs.writeFile(definesPath, lines.join('\n'));
|
|
157
|
-
}
|
|
158
|
-
Globals.exportDefinesTs = exportDefinesTs;
|
|
159
|
-
/**
|
|
160
|
-
* Replace {{KEY}} template tokens in a string with their resolved values.
|
|
161
|
-
*
|
|
162
|
-
* @param content - the content string with {{KEY}} tokens
|
|
163
|
-
* @param defines - the flat defines map
|
|
164
|
-
* @returns the substituted string and list of unresolved keys
|
|
165
|
-
*/
|
|
166
|
-
function replaceDefineTemplates(content, defines) {
|
|
167
|
-
const unresolvedKeys = [];
|
|
168
|
-
const result = content.replace(/\{\{([^}]+)\}\}/g, (_match, key) => {
|
|
169
|
-
const trimmedKey = key.trim();
|
|
170
|
-
if (Object.hasOwn(defines, trimmedKey)) {
|
|
171
|
-
return defines[trimmedKey];
|
|
172
|
-
}
|
|
173
|
-
unresolvedKeys.push(trimmedKey);
|
|
174
|
-
return _match;
|
|
175
|
-
});
|
|
176
|
-
return { result, unresolvedKeys };
|
|
177
|
-
}
|
|
178
|
-
Globals.replaceDefineTemplates = replaceDefineTemplates;
|
|
179
|
-
})(Globals || (exports.Globals = Globals = {}));
|
|
180
|
-
/**
|
|
181
|
-
* For library projects, snapshot the current defines state (before app.ini merge)
|
|
182
|
-
* so the published library only contains defaults.ini values.
|
|
183
|
-
* Returns undefined for non-library projects.
|
|
184
|
-
*/
|
|
185
|
-
function snapshotDefaultsOnly(manifest, allDefines, sections, definesWithSource) {
|
|
186
|
-
if (!manifest_1.Manifest.isLibrary(manifest)) {
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
flat: { ...allDefines },
|
|
191
|
-
sections: structuredClone(sections),
|
|
192
|
-
definesWithSource: { ...definesWithSource }
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Classify a trimmed ini-file line into one of the known kinds.
|
|
197
|
-
* Moves boolean-operator branching out of the main loop to reduce cognitive complexity.
|
|
198
|
-
*/
|
|
199
|
-
function classifyIniLine(trimmed) {
|
|
200
|
-
if (trimmed === '') {
|
|
201
|
-
return { kind: 'empty' };
|
|
202
|
-
}
|
|
203
|
-
if (trimmed.startsWith('#') || trimmed.startsWith(';')) {
|
|
204
|
-
return { kind: 'comment', text: trimmed.replace(/^[#;]\s?/, '') };
|
|
205
|
-
}
|
|
206
|
-
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
207
|
-
return { kind: 'section', name: trimmed.slice(1, -1) };
|
|
208
|
-
}
|
|
209
|
-
const eqIndex = trimmed.indexOf('=');
|
|
210
|
-
if (eqIndex > 0) {
|
|
211
|
-
return { kind: 'keyValue', key: trimmed.slice(0, eqIndex).trim() };
|
|
212
|
-
}
|
|
213
|
-
return { kind: 'other' };
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Extract comment-to-key associations from raw ini text.
|
|
217
|
-
* Comments are lines starting with `#` or `;`. Consecutive comment lines
|
|
218
|
-
* are joined with `\n`. An empty line between a comment block and a key
|
|
219
|
-
* breaks the association. Section headers (`[Name]`) do NOT break a pending
|
|
220
|
-
* comment — the comment carries over to the first key inside the section.
|
|
221
|
-
*
|
|
222
|
-
* Returns a map of flattened key → comment text (with `#`/`;` prefix stripped).
|
|
223
|
-
*/
|
|
224
|
-
function extractComments(rawText) {
|
|
225
|
-
const result = {};
|
|
226
|
-
const lines = rawText.split(/\r?\n/);
|
|
227
|
-
let pendingCommentLines = [];
|
|
228
|
-
let currentSection = null;
|
|
229
|
-
for (const line of lines) {
|
|
230
|
-
const classified = classifyIniLine(line.trim());
|
|
231
|
-
if (classified.kind === 'empty' || classified.kind === 'other') {
|
|
232
|
-
pendingCommentLines = [];
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (classified.kind === 'comment') {
|
|
236
|
-
pendingCommentLines.push(classified.text);
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (classified.kind === 'section') {
|
|
240
|
-
currentSection = classified.name;
|
|
241
|
-
// Don't reset pendingCommentLines — comment carries to first key
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
// keyValue
|
|
245
|
-
const flatKey = currentSection ? `${currentSection}_${classified.key}` : classified.key;
|
|
246
|
-
if (pendingCommentLines.length > 0) {
|
|
247
|
-
result[flatKey] = pendingCommentLines.join('\n');
|
|
248
|
-
}
|
|
249
|
-
pendingCommentLines = [];
|
|
250
|
-
}
|
|
251
|
-
return result;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Format a comment string as a JSDoc block.
|
|
255
|
-
* Single-line: \/** comment*\/
|
|
256
|
-
* Multi-line: \/**\n * line1\n * line2\n *\/
|
|
257
|
-
*/
|
|
258
|
-
function formatJsDoc(comment) {
|
|
259
|
-
const commentLines = comment.split('\n');
|
|
260
|
-
if (commentLines.length === 1) {
|
|
261
|
-
return `/** ${commentLines[0]} */`;
|
|
262
|
-
}
|
|
263
|
-
const body = commentLines.map(l => ` * ${l}`).join('\n');
|
|
264
|
-
return `/**\n${body}\n */`;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Check whether a string value represents a valid number.
|
|
268
|
-
* Empty strings are NOT considered numeric.
|
|
269
|
-
*/
|
|
270
|
-
function isNumericValue(value) {
|
|
271
|
-
return value !== '' && !isNaN(Number(value));
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Derive a human-readable source label from an ini file path.
|
|
275
|
-
* Strips the directory prefix and `.ini` extension.
|
|
276
|
-
* E.g. `dlo/main.ini` → `main`, `app.ini` → `app`.
|
|
277
|
-
*/
|
|
278
|
-
function iniFileLabel(relPath) {
|
|
279
|
-
const filename = relPath.split('/').pop() || relPath;
|
|
280
|
-
return filename.replace(/\.ini$/i, '');
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Merge an incoming comment with an existing one.
|
|
284
|
-
*
|
|
285
|
-
* - Both present → join existing (already prefixed) and new (prefixed) with `\n`
|
|
286
|
-
* - Only existing → keep it
|
|
287
|
-
* - Only new → use it (prefixed)
|
|
288
|
-
* - Neither → undefined
|
|
289
|
-
*/
|
|
290
|
-
function mergeComment(existingComment, newRawComment, sourceLabel) {
|
|
291
|
-
const prefixedNew = newRawComment ? `${sourceLabel}: ${newRawComment}` : undefined;
|
|
292
|
-
if (existingComment && prefixedNew) {
|
|
293
|
-
return `${existingComment}\n${prefixedNew}`;
|
|
294
|
-
}
|
|
295
|
-
return prefixedNew || existingComment;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Create a DefineEntry, attaching a comment from the comment map if available.
|
|
299
|
-
* The comment is prefixed with the source label for provenance tracking.
|
|
300
|
-
*/
|
|
301
|
-
function createDefineEntry(stringValue, fileUri, lines, key, sectionName, commentMap, sourceLabel) {
|
|
302
|
-
const flatKey = sectionName ? `${sectionName}_${key}` : key;
|
|
303
|
-
const entry = {
|
|
304
|
-
value: stringValue,
|
|
305
|
-
sourceUri: fileUri,
|
|
306
|
-
sourceLine: findLineNumber(lines, key, sectionName)
|
|
307
|
-
};
|
|
308
|
-
if (commentMap[flatKey]) {
|
|
309
|
-
entry.comment = `${sourceLabel}: ${commentMap[flatKey]}`;
|
|
310
|
-
}
|
|
311
|
-
return entry;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Merge all keys from a parsed ini section into the accumulators.
|
|
315
|
-
*/
|
|
316
|
-
function mergeSectionEntries(sectionName, sectionData, allDefines, sections, definesWithSource, fileUri, lines, commentMap, sourceLabel) {
|
|
317
|
-
if (!sections[sectionName]) {
|
|
318
|
-
sections[sectionName] = {};
|
|
319
|
-
}
|
|
320
|
-
for (const [key, sectionValue] of Object.entries(sectionData)) {
|
|
321
|
-
const flatKey = `${sectionName}_${key}`;
|
|
322
|
-
const rawComment = commentMap[flatKey];
|
|
323
|
-
const stringValue = `${sectionValue}`;
|
|
324
|
-
allDefines[flatKey] = stringValue;
|
|
325
|
-
sections[sectionName][key] = stringValue;
|
|
326
|
-
const newEntry = createDefineEntry(stringValue, fileUri, lines, key, sectionName, commentMap, sourceLabel);
|
|
327
|
-
newEntry.comment = mergeComment(definesWithSource[flatKey]?.comment, rawComment, sourceLabel);
|
|
328
|
-
definesWithSource[flatKey] = newEntry;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Read and merge a single ini file into the accumulated defines, sections, and source tracking.
|
|
333
|
-
* Supports sections: keys under [SectionName] are flattened as SectionName_keyname.
|
|
334
|
-
*
|
|
335
|
-
* @param fs - filesystem abstraction
|
|
336
|
-
* @param filePath - URI to the ini file
|
|
337
|
-
* @param allDefines - accumulated flat defines (mutated)
|
|
338
|
-
* @param sections - accumulated sectioned config (mutated)
|
|
339
|
-
* @param definesWithSource - accumulated source tracking (mutated)
|
|
340
|
-
*/
|
|
341
|
-
async function mergeIniFile(fs, filePath, allDefines, sections, definesWithSource, sourceLabel) {
|
|
342
|
-
// early return if the file doesn't exist
|
|
343
|
-
if (!(await fs.stat(filePath))) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const iniContent = await fs.readFile(filePath);
|
|
347
|
-
const rawText = convertBlobToString(iniContent);
|
|
348
|
-
const parsed = ini.parse(rawText);
|
|
349
|
-
const fileUri = filePath.toString();
|
|
350
|
-
const lines = rawText.split(/\r?\n/);
|
|
351
|
-
const commentMap = extractComments(rawText);
|
|
352
|
-
for (const [sectionOrKey, value] of Object.entries(parsed)) {
|
|
353
|
-
if (typeof value === 'object' && value !== null) {
|
|
354
|
-
mergeSectionEntries(sectionOrKey, value, allDefines, sections, definesWithSource, fileUri, lines, commentMap, sourceLabel);
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
const rawComment = commentMap[sectionOrKey];
|
|
358
|
-
const stringValue = `${value}`;
|
|
359
|
-
allDefines[sectionOrKey] = stringValue;
|
|
360
|
-
const newEntry = createDefineEntry(stringValue, fileUri, lines, sectionOrKey, null, commentMap, sourceLabel);
|
|
361
|
-
newEntry.comment = mergeComment(definesWithSource[sectionOrKey]?.comment, rawComment, sourceLabel);
|
|
362
|
-
definesWithSource[sectionOrKey] = newEntry;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Find the line number (0-based) of a key within an ini file's text lines.
|
|
368
|
-
* If a sectionName is provided, only searches within that section.
|
|
369
|
-
*
|
|
370
|
-
* @param lines - the file split by newlines
|
|
371
|
-
* @param key - the ini key to find
|
|
372
|
-
* @param sectionName - the section to search within, or null for top-level
|
|
373
|
-
* @returns 0-based line number, or 0 if not found
|
|
374
|
-
*/
|
|
375
|
-
function findLineNumber(lines, key, sectionName) {
|
|
376
|
-
let inTargetSection = sectionName === null;
|
|
377
|
-
const sectionHeader = sectionName ? `[${sectionName}]` : null;
|
|
378
|
-
const keyPattern = new RegExp(`^\\s*${escapeRegex(key)}\\s*=`);
|
|
379
|
-
for (let i = 0; i < lines.length; i++) {
|
|
380
|
-
const trimmed = lines[i].trim();
|
|
381
|
-
if (sectionHeader && trimmed === sectionHeader) {
|
|
382
|
-
inTargetSection = true;
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
if (inTargetSection && trimmed.startsWith('[') && trimmed.endsWith(']') && sectionName !== null) {
|
|
386
|
-
// Entered a different section
|
|
387
|
-
inTargetSection = false;
|
|
388
|
-
continue;
|
|
389
|
-
}
|
|
390
|
-
if (inTargetSection && keyPattern.test(lines[i])) {
|
|
391
|
-
return i;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return 0;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Escape a string for use in a RegExp
|
|
398
|
-
*/
|
|
399
|
-
function escapeRegex(str) {
|
|
400
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
401
|
-
}
|
|
402
|
-
//# sourceMappingURL=globals.js.map
|
package/out/helper.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Helper = void 0;
|
|
4
|
-
const crc_1 = require("./crc");
|
|
5
|
-
var Helper;
|
|
6
|
-
(function (Helper) {
|
|
7
|
-
/**
|
|
8
|
-
* Convert yaml range to an valid vscode line information
|
|
9
|
-
* @param lineCounter
|
|
10
|
-
* @param fieldRange
|
|
11
|
-
*/
|
|
12
|
-
function yamlRangeToLineInformation(lineCounter, fieldRange) {
|
|
13
|
-
const [offset, offsetLength] = fieldRange;
|
|
14
|
-
const { line, col } = lineCounter.linePos(offset);
|
|
15
|
-
return {
|
|
16
|
-
line: Number(line) - 1,
|
|
17
|
-
startCharacter: col - 1,
|
|
18
|
-
endCharacter: col + (offsetLength - offset)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
Helper.yamlRangeToLineInformation = yamlRangeToLineInformation;
|
|
22
|
-
const textEncoder = new TextEncoder();
|
|
23
|
-
/**
|
|
24
|
-
* Generates based on the name of the library a CRC16 Modbus hash
|
|
25
|
-
* @param libraryName
|
|
26
|
-
*/
|
|
27
|
-
function generateHashForLibraryName(libraryName) {
|
|
28
|
-
return (0, crc_1.crc32_ethernet)(textEncoder.encode(libraryName)).toString(16);
|
|
29
|
-
}
|
|
30
|
-
Helper.generateHashForLibraryName = generateHashForLibraryName;
|
|
31
|
-
function generateHashForFilePath(filePath) {
|
|
32
|
-
return (0, crc_1.crc32_ethernet)(textEncoder.encode(filePath)).toString(16);
|
|
33
|
-
}
|
|
34
|
-
Helper.generateHashForFilePath = generateHashForFilePath;
|
|
35
|
-
/**
|
|
36
|
-
* Generate CRC32 for any binary blob
|
|
37
|
-
* @param content
|
|
38
|
-
*/
|
|
39
|
-
function generateCRC32ForFileContent(content) {
|
|
40
|
-
return (0, crc_1.crc32_ethernet)(content).toString(16).toUpperCase().padStart(8, '0');
|
|
41
|
-
}
|
|
42
|
-
Helper.generateCRC32ForFileContent = generateCRC32ForFileContent;
|
|
43
|
-
function convertBlobToString(blob) {
|
|
44
|
-
try {
|
|
45
|
-
let binaryData = null;
|
|
46
|
-
// if vscode runs in desktop mode, the blob is a serialized buffer
|
|
47
|
-
if (blob?.type === 'Buffer') {
|
|
48
|
-
binaryData = Uint8Array.from(blob.data);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
binaryData = blob;
|
|
52
|
-
}
|
|
53
|
-
return new TextDecoder('utf8').decode(binaryData);
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
return '';
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
Helper.convertBlobToString = convertBlobToString;
|
|
60
|
-
function normalizeLF(stringToNormalize = '') {
|
|
61
|
-
return stringToNormalize.replace(/\r\n|\n\r|\r/g, '\n');
|
|
62
|
-
}
|
|
63
|
-
Helper.normalizeLF = normalizeLF;
|
|
64
|
-
function convertBlobToStringArray(blob) {
|
|
65
|
-
try {
|
|
66
|
-
const textData = convertBlobToString(blob);
|
|
67
|
-
return normalizeLF(textData).split('\n');
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
Helper.convertBlobToStringArray = convertBlobToStringArray;
|
|
74
|
-
/**
|
|
75
|
-
* Check if the given value is numeric
|
|
76
|
-
* @param v
|
|
77
|
-
*/
|
|
78
|
-
Helper.isNumeric = (v) => {
|
|
79
|
-
return !Array.isArray(v) && v - parseFloat(v) + 1 >= 0;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Convert an uint8Array to a base64 string
|
|
83
|
-
* @param bytes
|
|
84
|
-
*/
|
|
85
|
-
function bufferToBase64(bytes) {
|
|
86
|
-
let binary = '';
|
|
87
|
-
const len = bytes.byteLength;
|
|
88
|
-
for (let i = 0; i < len; i++) {
|
|
89
|
-
binary += String.fromCharCode(bytes[i]);
|
|
90
|
-
}
|
|
91
|
-
return btoa(binary);
|
|
92
|
-
}
|
|
93
|
-
Helper.bufferToBase64 = bufferToBase64;
|
|
94
|
-
/**
|
|
95
|
-
* Parse and resolve any {index} or {index+X} within the given value
|
|
96
|
-
* @param valueToPatch
|
|
97
|
-
* @param arrayIndex
|
|
98
|
-
*/
|
|
99
|
-
function patchValueWithArrayInfo(valueToPatch, arrayIndex) {
|
|
100
|
-
// look for these phrases in attribute strings: "<a>i+<b>", "<a>o+<b>", "<a>n+<b>" (or "<a>i", "<a>o", "<a>n")
|
|
101
|
-
const valueNTHS = `${valueToPatch}`.match(/\{\d*(index)(\+\d*)?}/g);
|
|
102
|
-
if (valueNTHS) {
|
|
103
|
-
let patchedValue = valueToPatch;
|
|
104
|
-
valueNTHS.forEach((nth) => {
|
|
105
|
-
// normalize & parse "(xn+y)" string
|
|
106
|
-
const normalizedNTH = nth.replace(/\+0$/, '');
|
|
107
|
-
const scope = normalizedNTH.match(/index/)?.[0];
|
|
108
|
-
if (scope) {
|
|
109
|
-
const stepOffset = normalizedNTH.slice(1, -1).split(scope)[1];
|
|
110
|
-
const offset = parseInt(stepOffset) || 0;
|
|
111
|
-
// reassign the patched value
|
|
112
|
-
patchedValue = patchedValue.replace(nth, `${arrayIndex + offset}`);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return patchedValue;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return valueToPatch;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
Helper.patchValueWithArrayInfo = patchValueWithArrayInfo;
|
|
122
|
-
const _deferrals = {}; // <token>:{ handler:func, tmr:timeoutHandle }
|
|
123
|
-
/**
|
|
124
|
-
* Defer a given named task
|
|
125
|
-
* @param token
|
|
126
|
-
* @param timeout Milliseconds
|
|
127
|
-
* @param callback Callback
|
|
128
|
-
*/
|
|
129
|
-
function defer(token, timeout, callback) {
|
|
130
|
-
const d = _deferrals[token];
|
|
131
|
-
if (d) {
|
|
132
|
-
clearTimeout(d.timer);
|
|
133
|
-
}
|
|
134
|
-
_deferrals[token] = {
|
|
135
|
-
// @ts-ignore
|
|
136
|
-
timer: setTimeout(() => {
|
|
137
|
-
delete _deferrals[token];
|
|
138
|
-
callback();
|
|
139
|
-
}, timeout),
|
|
140
|
-
handler: callback
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
Helper.defer = defer;
|
|
144
|
-
})(Helper || (exports.Helper = Helper = {}));
|
|
145
|
-
//# sourceMappingURL=helper.js.map
|
package/out/log.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Log = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
var Log;
|
|
9
|
-
(function (Log) {
|
|
10
|
-
let LogMessageType;
|
|
11
|
-
(function (LogMessageType) {
|
|
12
|
-
LogMessageType[LogMessageType["log"] = 0] = "log";
|
|
13
|
-
LogMessageType[LogMessageType["done"] = 1] = "done";
|
|
14
|
-
LogMessageType[LogMessageType["info"] = 2] = "info";
|
|
15
|
-
LogMessageType[LogMessageType["warning"] = 3] = "warning";
|
|
16
|
-
LogMessageType[LogMessageType["error"] = 4] = "error";
|
|
17
|
-
})(LogMessageType = Log.LogMessageType || (Log.LogMessageType = {}));
|
|
18
|
-
Log.LOG_PREFIX = {
|
|
19
|
-
[LogMessageType.done]: chalk_1.default.bgGreen.black(' DONE '),
|
|
20
|
-
[LogMessageType.log]: '',
|
|
21
|
-
[LogMessageType.info]: chalk_1.default.bgBlueBright.black(' INFO '),
|
|
22
|
-
[LogMessageType.warning]: chalk_1.default.bgYellow.black(' WARNING '),
|
|
23
|
-
[LogMessageType.error]: chalk_1.default.bgRed.black(' ERROR ')
|
|
24
|
-
};
|
|
25
|
-
class Logger {
|
|
26
|
-
_logHandler;
|
|
27
|
-
_silent = false;
|
|
28
|
-
constructor(logOutput = console) {
|
|
29
|
-
this._logHandler = logOutput;
|
|
30
|
-
}
|
|
31
|
-
_log(type, msg, ...args) {
|
|
32
|
-
// only log errors if silent is set
|
|
33
|
-
if (this._silent && type !== LogMessageType.error) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
args = [Log.LOG_PREFIX[type], msg, ...args];
|
|
37
|
-
this._logHandler.log(...args);
|
|
38
|
-
}
|
|
39
|
-
set silent(value) {
|
|
40
|
-
this._silent = value;
|
|
41
|
-
}
|
|
42
|
-
log(msg, ...args) {
|
|
43
|
-
this._log(LogMessageType.log, msg, ...args);
|
|
44
|
-
}
|
|
45
|
-
error(msg, ...args) {
|
|
46
|
-
this._log(LogMessageType.error, msg, ...args);
|
|
47
|
-
}
|
|
48
|
-
info(msg, ...args) {
|
|
49
|
-
this._log(LogMessageType.info, msg, ...args);
|
|
50
|
-
}
|
|
51
|
-
warn(msg, ...args) {
|
|
52
|
-
this._log(LogMessageType.warning, msg, ...args);
|
|
53
|
-
}
|
|
54
|
-
done(msg, ...args) {
|
|
55
|
-
this._log(LogMessageType.done, msg, ...args);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
Log.Logger = Logger;
|
|
59
|
-
})(Log || (exports.Log = Log = {}));
|
|
60
|
-
//# sourceMappingURL=log.js.map
|