@microtronics/studio-cli 0.61.0 → 0.62.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 +9 -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/dfiles/dfiles.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DFILES = void 0;
|
|
4
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
5
|
-
const dependencies_1 = require("../dependencies");
|
|
6
|
-
const helper_1 = require("../helper");
|
|
7
|
-
const yaml_1 = require("yaml");
|
|
8
|
-
const apm_1 = require("../package/apm");
|
|
9
|
-
const defaultFiles_1 = require("../defaultFiles");
|
|
10
|
-
var convertBlobToString = helper_1.Helper.convertBlobToString;
|
|
11
|
-
var yamlRangeToLineInformation = helper_1.Helper.yamlRangeToLineInformation;
|
|
12
|
-
var DFILES;
|
|
13
|
-
(function (DFILES) {
|
|
14
|
-
let Type;
|
|
15
|
-
(function (Type) {
|
|
16
|
-
Type["static"] = "static";
|
|
17
|
-
Type["dynamic"] = "dynamic";
|
|
18
|
-
})(Type = DFILES.Type || (DFILES.Type = {}));
|
|
19
|
-
let SyncLogic;
|
|
20
|
-
(function (SyncLogic) {
|
|
21
|
-
SyncLogic["crcStamp"] = "crc_stamp";
|
|
22
|
-
SyncLogic["stampOnly"] = "stamp_only";
|
|
23
|
-
SyncLogic["onlyDown"] = "only_down";
|
|
24
|
-
SyncLogic["onlyUp"] = "only_up";
|
|
25
|
-
})(SyncLogic = DFILES.SyncLogic || (DFILES.SyncLogic = {}));
|
|
26
|
-
let Force;
|
|
27
|
-
(function (Force) {
|
|
28
|
-
Force["down"] = "down";
|
|
29
|
-
Force["up"] = "up";
|
|
30
|
-
Force["off"] = "off";
|
|
31
|
-
})(Force = DFILES.Force || (DFILES.Force = {}));
|
|
32
|
-
async function process(cwd, fs, logger) {
|
|
33
|
-
const { properties, diagnostics, libraryFiles } = await parseDfile(cwd, fs);
|
|
34
|
-
const distDir = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesPath);
|
|
35
|
-
// clear dist directory beforehand
|
|
36
|
-
if (await fs.stat(distDir)) {
|
|
37
|
-
await fs.rm(distDir);
|
|
38
|
-
}
|
|
39
|
-
// copy all files to dist directory
|
|
40
|
-
// copy all files to the dist directory
|
|
41
|
-
for (const [dfileName, dfileInfo] of Object.entries(properties)) {
|
|
42
|
-
await copyDfilesToDist(cwd, fs, dfileName, dfileInfo, libraryFiles);
|
|
43
|
-
}
|
|
44
|
-
// do not write the properties file if there aren't any dfiles
|
|
45
|
-
if (!Object.keys(properties).length) {
|
|
46
|
-
return diagnostics;
|
|
47
|
-
}
|
|
48
|
-
logger.done(`${Object.keys(properties).length} dfiles processed.`);
|
|
49
|
-
await fs.writeFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesProperties), JSON.stringify(properties, null, '\t'));
|
|
50
|
-
return diagnostics;
|
|
51
|
-
}
|
|
52
|
-
DFILES.process = process;
|
|
53
|
-
/**
|
|
54
|
-
* Parses DFILES from the specified directory and aggregates properties, diagnostics, and library files.
|
|
55
|
-
*
|
|
56
|
-
* @param {URI} cwd - The current working directory URI.
|
|
57
|
-
* @param {LocalFS} fs - The local file system instance used for file operations.
|
|
58
|
-
* @return {Promise<{properties: PropertyList, diagnostics: Diagnostics.File[], libraryFiles: any[]}>}
|
|
59
|
-
* Resolves to an object containing the aggregated properties, diagnostics, and library files information.
|
|
60
|
-
*/
|
|
61
|
-
async function parseDfile(cwd, fs) {
|
|
62
|
-
const allDiagnostics = [];
|
|
63
|
-
const allProperties = {};
|
|
64
|
-
const libraryFiles = await dependencies_1.Dependencies.getApmPartDependencies(cwd, fs, apm_1.APM.Part.dfiles);
|
|
65
|
-
for (const library of libraryFiles) {
|
|
66
|
-
const { properties, diagnostics } = await parseYamlFile(fs, library.path, library.name);
|
|
67
|
-
Object.assign(allProperties, properties);
|
|
68
|
-
allDiagnostics.push(...diagnostics);
|
|
69
|
-
}
|
|
70
|
-
const { properties, diagnostics } = await parseYamlFile(fs, vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dfiles.mainDFILES), null);
|
|
71
|
-
Object.assign(allProperties, properties);
|
|
72
|
-
allDiagnostics.push(...diagnostics);
|
|
73
|
-
return {
|
|
74
|
-
properties: allProperties,
|
|
75
|
-
diagnostics: allDiagnostics,
|
|
76
|
-
libraryFiles: libraryFiles
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
DFILES.parseDfile = parseDfile;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @param fs
|
|
83
|
-
* @param fileUri
|
|
84
|
-
* @param libraryName
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
88
|
-
async function parseYamlFile(fs, fileUri, libraryName) {
|
|
89
|
-
const compilerDiagnostics = [];
|
|
90
|
-
const dfileProperties = {};
|
|
91
|
-
if (!(await fs.stat(fileUri))) {
|
|
92
|
-
return {
|
|
93
|
-
properties: dfileProperties,
|
|
94
|
-
diagnostics: compilerDiagnostics
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const fileBlob = await fs.readFile(fileUri);
|
|
98
|
-
const yamlString = convertBlobToString(fileBlob);
|
|
99
|
-
const lineCounter = new yaml_1.LineCounter();
|
|
100
|
-
const yamlDoc = (0, yaml_1.parseDocument)(yamlString, { lineCounter });
|
|
101
|
-
const fileNodes = yamlDoc.contents || new yaml_1.YAMLMap();
|
|
102
|
-
for (const fileNode of fileNodes.items) {
|
|
103
|
-
const fileName = fileNode.key.value;
|
|
104
|
-
const fileValues = fileNode.value;
|
|
105
|
-
const yamlFileNameRange = yamlRangeToLineInformation(lineCounter, fileNode.key.range);
|
|
106
|
-
const hasSyncMode = fileValues.value !== null ? fileNode.value.has('syncMode') : false;
|
|
107
|
-
const syncMode = hasSyncMode
|
|
108
|
-
? fileNode.value.get('syncMode')
|
|
109
|
-
: SyncLogic.crcStamp;
|
|
110
|
-
if (hasSyncMode) {
|
|
111
|
-
const values = Object.values(DFILES.SyncLogic);
|
|
112
|
-
if (!values.includes(syncMode)) {
|
|
113
|
-
const syncModeItem = fileNode.value.items.find(item => {
|
|
114
|
-
return item.key.value === 'syncMode';
|
|
115
|
-
});
|
|
116
|
-
const yamlSyncModeRange = yamlRangeToLineInformation(lineCounter, syncModeItem.key.range);
|
|
117
|
-
compilerDiagnostics.push({
|
|
118
|
-
file: fileUri,
|
|
119
|
-
code: '',
|
|
120
|
-
message: `Property syncMode does not match any of "${values.join(', ')}"`,
|
|
121
|
-
line: yamlSyncModeRange.line,
|
|
122
|
-
startCharacter: yamlSyncModeRange.startCharacter,
|
|
123
|
-
endCharacter: yamlSyncModeRange.endCharacter,
|
|
124
|
-
level: 'error'
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
compilerDiagnostics.push({
|
|
130
|
-
file: fileUri,
|
|
131
|
-
code: '',
|
|
132
|
-
message: `Property "syncMode" missing`,
|
|
133
|
-
line: yamlFileNameRange.line,
|
|
134
|
-
startCharacter: yamlFileNameRange.startCharacter,
|
|
135
|
-
endCharacter: yamlFileNameRange.endCharacter,
|
|
136
|
-
level: 'error'
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (!fileName.match(/^[a-z0-9._-]*$/)) {
|
|
140
|
-
compilerDiagnostics.push({
|
|
141
|
-
file: fileUri,
|
|
142
|
-
code: '',
|
|
143
|
-
message: 'Filename does not match pattern "a-z0-9._-"',
|
|
144
|
-
line: yamlFileNameRange.line,
|
|
145
|
-
startCharacter: yamlFileNameRange.startCharacter,
|
|
146
|
-
endCharacter: yamlFileNameRange.endCharacter,
|
|
147
|
-
level: 'error'
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
const dfilePath = vscode_uri_1.Utils.joinPath(vscode_uri_1.Utils.dirname(fileUri), fileName);
|
|
151
|
-
const exists = await getFileStat(fs, dfilePath);
|
|
152
|
-
if (!exists) {
|
|
153
|
-
const yamlRange = yamlRangeToLineInformation(lineCounter, fileNode.key.range);
|
|
154
|
-
compilerDiagnostics.push({
|
|
155
|
-
file: fileUri,
|
|
156
|
-
code: '',
|
|
157
|
-
message: `Could not find file "${fileName}"`,
|
|
158
|
-
line: yamlRange.line,
|
|
159
|
-
startCharacter: yamlRange.startCharacter,
|
|
160
|
-
endCharacter: yamlRange.endCharacter,
|
|
161
|
-
level: 'error'
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
dfileProperties[fileName] = {
|
|
166
|
-
crc: exists.crc,
|
|
167
|
-
force: Force.off,
|
|
168
|
-
readable: false,
|
|
169
|
-
size: exists.size,
|
|
170
|
-
stamp: exists.stamp,
|
|
171
|
-
sync_logic: syncMode,
|
|
172
|
-
type: Type.static,
|
|
173
|
-
library: libraryName
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
properties: dfileProperties,
|
|
179
|
-
diagnostics: compilerDiagnostics
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
DFILES.parseYamlFile = parseYamlFile;
|
|
183
|
-
})(DFILES || (exports.DFILES = DFILES = {}));
|
|
184
|
-
async function getFileStat(fs, filePath) {
|
|
185
|
-
const stat = await fs.stat(filePath);
|
|
186
|
-
if (!stat) {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
const blob = await fs.readFile(filePath);
|
|
190
|
-
return {
|
|
191
|
-
size: stat.size,
|
|
192
|
-
stamp: Math.trunc(stat.ctime),
|
|
193
|
-
crc: helper_1.Helper.generateCRC32ForFileContent(blob)
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
async function copyDfilesToDist(cwd, fs, fileName, property, libraryFiles) {
|
|
197
|
-
const isLibrary = property.library !== null;
|
|
198
|
-
const sourcePath = isLibrary
|
|
199
|
-
? vscode_uri_1.Utils.dirname(libraryFiles.find(lib => lib.name === property.library).path)
|
|
200
|
-
: vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dfiles.path);
|
|
201
|
-
const destinationDir = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesPath, fileName);
|
|
202
|
-
const sourceDir = vscode_uri_1.Utils.joinPath(sourcePath, fileName);
|
|
203
|
-
await fs.copy(sourceDir, destinationDir);
|
|
204
|
-
}
|
|
205
|
-
//# sourceMappingURL=dfiles.js.map
|
package/out/diagnostics.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Diagnostics = void 0;
|
|
4
|
-
var Diagnostics;
|
|
5
|
-
(function (Diagnostics) {
|
|
6
|
-
Diagnostics.CODE = {
|
|
7
|
-
ddeFieldLength: 'field_name_length'
|
|
8
|
-
};
|
|
9
|
-
})(Diagnostics || (exports.Diagnostics = Diagnostics = {}));
|
|
10
|
-
//# sourceMappingURL=diagnostics.js.map
|
package/out/dlo/CustomWasmFS.js
DELETED
|
@@ -1,258 +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.CUSTOM_WASM_FS = exports.precompilerDiagnostics = void 0;
|
|
27
|
-
exports.uriToMemFsPath = uriToMemFsPath;
|
|
28
|
-
exports.relativeMemFsPath = relativeMemFsPath;
|
|
29
|
-
const nodeFs = __importStar(require("fs"));
|
|
30
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
31
|
-
const preCompiler_1 = require("./preCompiler");
|
|
32
|
-
const helper_1 = require("../helper");
|
|
33
|
-
var convertBlobToStringArray = helper_1.Helper.convertBlobToStringArray;
|
|
34
|
-
const iconv = __importStar(require("iconv-lite"));
|
|
35
|
-
const S_IFDIR = 0o040000; // Directory flag
|
|
36
|
-
const DEFAULT_DIR_MODE = 0o777; // rwxrwxrwx
|
|
37
|
-
const MODE_DIR = S_IFDIR | DEFAULT_DIR_MODE;
|
|
38
|
-
const S_IFREG = 0o100000; // Regular file flag
|
|
39
|
-
const DEFAULT_FILE_MODE = 0o666; // rw-rw-rw-
|
|
40
|
-
const MODE_FILE = S_IFREG | DEFAULT_FILE_MODE;
|
|
41
|
-
const preCompiler = new preCompiler_1.DloPreCompiler();
|
|
42
|
-
const modifiedFileCache = {};
|
|
43
|
-
exports.precompilerDiagnostics = [];
|
|
44
|
-
const CUSTOM_WASM_FS = (FS, cwd, manifest, logger) => {
|
|
45
|
-
// clear all cached artifacts during FS setup ( this is needed when loaded in vscode context )
|
|
46
|
-
exports.precompilerDiagnostics.length = 0;
|
|
47
|
-
Object.keys(modifiedFileCache).forEach(key => delete modifiedFileCache[key]);
|
|
48
|
-
const nodeOps = {
|
|
49
|
-
getattr(node) {
|
|
50
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(node.mount.opts.root), FS.getPath(node));
|
|
51
|
-
const fsPath = path.fsPath;
|
|
52
|
-
if (!nodeFs.existsSync(fsPath)) {
|
|
53
|
-
throw new FS.ErrnoError(44 /* ENOENT */);
|
|
54
|
-
}
|
|
55
|
-
const modifiedFileContent = getUpdateModifiedFileCache(cwd, logger, manifest, path);
|
|
56
|
-
const stat = nodeFs.statSync(fsPath);
|
|
57
|
-
const size = modifiedFileContent?.length || stat.size;
|
|
58
|
-
return {
|
|
59
|
-
mode: stat.isDirectory() ? MODE_DIR : MODE_FILE,
|
|
60
|
-
size: size,
|
|
61
|
-
atime: stat.atime,
|
|
62
|
-
mtime: stat.mtime,
|
|
63
|
-
ctime: stat.ctime
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
setattr(node, attr) {
|
|
67
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(node.mount.opts.root), FS.getPath(node)).fsPath;
|
|
68
|
-
if (!nodeFs.existsSync(path)) {
|
|
69
|
-
throw new FS.ErrnoError(44 /* ENOENT */);
|
|
70
|
-
}
|
|
71
|
-
// Change file size (truncate/grow)
|
|
72
|
-
if (typeof attr.size === 'number') {
|
|
73
|
-
nodeFs.truncateSync(path, attr.size);
|
|
74
|
-
}
|
|
75
|
-
// Change file mode (permissions)
|
|
76
|
-
if (typeof attr.mode === 'number') {
|
|
77
|
-
nodeFs.chmodSync(path, attr.mode);
|
|
78
|
-
}
|
|
79
|
-
// Change access/modification time
|
|
80
|
-
if (attr.atime || attr.mtime) {
|
|
81
|
-
const stat = nodeFs.statSync(path);
|
|
82
|
-
nodeFs.utimesSync(path, attr.atime ?? stat.atime, attr.mtime ?? stat.mtime);
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
lookup(parent, name) {
|
|
86
|
-
const currPath = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(parent.mount.opts.root), FS.getPath(parent), name);
|
|
87
|
-
const path = currPath.fsPath;
|
|
88
|
-
if (!nodeFs.existsSync(path)) {
|
|
89
|
-
throw new FS.ErrnoError(44 /* ENOENT */);
|
|
90
|
-
}
|
|
91
|
-
const stat = nodeFs.statSync(path);
|
|
92
|
-
const node = FS.createNode(parent, name, stat.isDirectory() ? MODE_DIR : MODE_FILE, 0);
|
|
93
|
-
node.node_ops = parent.node_ops;
|
|
94
|
-
node.stream_ops = parent.stream_ops;
|
|
95
|
-
return node;
|
|
96
|
-
},
|
|
97
|
-
readdir(node) {
|
|
98
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(node.mount.opts.root), FS.getPath(node)).fsPath;
|
|
99
|
-
return ['.', '..', ...nodeFs.readdirSync(path)];
|
|
100
|
-
},
|
|
101
|
-
mknod(parent, name, mode, dev) {
|
|
102
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(parent.mount.opts.root), FS.getPath(parent), name).fsPath;
|
|
103
|
-
nodeFs.writeFileSync(path, '');
|
|
104
|
-
const node = FS.createNode(parent, name, mode, dev);
|
|
105
|
-
node.node_ops = parent.node_ops;
|
|
106
|
-
node.stream_ops = parent.stream_ops;
|
|
107
|
-
return node;
|
|
108
|
-
},
|
|
109
|
-
unlink(parent, name) {
|
|
110
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(parent.mount.opts.root), FS.getPath(parent), name).fsPath;
|
|
111
|
-
nodeFs.unlinkSync(path);
|
|
112
|
-
},
|
|
113
|
-
mkdir(parent, name, mode) {
|
|
114
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(parent.mount.opts.root), FS.getPath(parent), name).fsPath;
|
|
115
|
-
nodeFs.mkdirSync(path, { mode });
|
|
116
|
-
const node = FS.createNode(parent, name, mode | MODE_DIR, 0);
|
|
117
|
-
node.node_ops = parent.node_ops;
|
|
118
|
-
node.stream_ops = parent.stream_ops;
|
|
119
|
-
return node;
|
|
120
|
-
},
|
|
121
|
-
rmdir(parent, name) {
|
|
122
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(parent.mount.opts.root), FS.getPath(parent), name).fsPath;
|
|
123
|
-
nodeFs.rmdirSync(path);
|
|
124
|
-
},
|
|
125
|
-
rename(oldParent, newParent, newName) {
|
|
126
|
-
const oldPath = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(oldParent.mount.opts.root), FS.getPath(oldParent)).fsPath;
|
|
127
|
-
const newPath = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(newParent.mount.opts.root), FS.getPath(newParent), newName).fsPath;
|
|
128
|
-
nodeFs.renameSync(oldPath, newPath);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
const streamOps = {
|
|
132
|
-
open(stream) {
|
|
133
|
-
const path = vscode_uri_1.Utils.joinPath(vscode_uri_1.URI.parse(stream.node.mount.opts.root), FS.getPath(stream.node));
|
|
134
|
-
stream.modifiedContent = getUpdateModifiedFileCache(cwd, logger, manifest, path);
|
|
135
|
-
if (!stream.modifiedContent) {
|
|
136
|
-
stream.nfd = nodeFs.openSync(path.fsPath, flagsToMode(stream.flags));
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
close(stream) {
|
|
140
|
-
if (stream.nfd) {
|
|
141
|
-
nodeFs.closeSync(stream.nfd);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
read(stream, buffer, offset, length, position) {
|
|
145
|
-
// allow reading none precompiled files
|
|
146
|
-
if (!stream.modifiedContent) {
|
|
147
|
-
return nodeFs.readSync(stream.nfd, buffer, offset, length, position);
|
|
148
|
-
}
|
|
149
|
-
const fileContent = stream.modifiedContent;
|
|
150
|
-
if (position >= fileContent.length) {
|
|
151
|
-
return 0;
|
|
152
|
-
} // EOF handling properly
|
|
153
|
-
const bytesAvailable = fileContent.length - position;
|
|
154
|
-
const bytesToRead = Math.min(length, bytesAvailable);
|
|
155
|
-
copyToBuffer(fileContent, buffer, offset, position, position + bytesToRead);
|
|
156
|
-
// fileContent.copy(buffer, offset, position, position + bytesToRead);
|
|
157
|
-
return bytesToRead;
|
|
158
|
-
},
|
|
159
|
-
write(stream, buffer, offset, length, position) {
|
|
160
|
-
return nodeFs.writeSync(stream.nfd, buffer, offset, length, position);
|
|
161
|
-
},
|
|
162
|
-
flagsToMode: flagsToMode,
|
|
163
|
-
llseek(stream, offset, whence) {
|
|
164
|
-
let position = offset;
|
|
165
|
-
if (whence === 1) {
|
|
166
|
-
position += stream.position;
|
|
167
|
-
}
|
|
168
|
-
else if (whence === 2) {
|
|
169
|
-
const stat = nodeFs.fstatSync(stream.nfd);
|
|
170
|
-
position += stat.size;
|
|
171
|
-
}
|
|
172
|
-
if (position < 0) {
|
|
173
|
-
throw new FS.ErrnoError(28);
|
|
174
|
-
} // EINVAL
|
|
175
|
-
stream.position = position;
|
|
176
|
-
return position;
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
return {
|
|
180
|
-
mount( /*mount: any*/) {
|
|
181
|
-
const memfsRoot = uriToMemFsPath(cwd);
|
|
182
|
-
const root = FS.createNode(null, memfsRoot, S_IFDIR | DEFAULT_DIR_MODE, 0);
|
|
183
|
-
root.node_ops = nodeOps;
|
|
184
|
-
root.stream_ops = streamOps;
|
|
185
|
-
return root;
|
|
186
|
-
},
|
|
187
|
-
node_ops: nodeOps,
|
|
188
|
-
stream_ops: streamOps
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
exports.CUSTOM_WASM_FS = CUSTOM_WASM_FS;
|
|
192
|
-
function flagsToMode(flags) {
|
|
193
|
-
const accmode = flags & 2097155;
|
|
194
|
-
if (accmode === 0)
|
|
195
|
-
return 'r';
|
|
196
|
-
if (accmode === 1)
|
|
197
|
-
return 'r+';
|
|
198
|
-
if (accmode === 65)
|
|
199
|
-
return 'w';
|
|
200
|
-
if (accmode === 577)
|
|
201
|
-
return 'w+';
|
|
202
|
-
if (accmode === 1089)
|
|
203
|
-
return 'a';
|
|
204
|
-
if (accmode === 1217)
|
|
205
|
-
return 'a+';
|
|
206
|
-
throw new Error(`Unknown file open flags: ${flags}`);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Copies a segment of data from the source buffer to the target buffer, starting at specified offsets.
|
|
210
|
-
* Somehow within the vscode context the target buffer is an Int8Array.
|
|
211
|
-
*
|
|
212
|
-
* @param {Buffer | Uint8Array} source The buffer or Uint8Array to copy data from.
|
|
213
|
-
* @param {Buffer | Uint8Array | Int8Array} target The buffer, Uint8Array, or Int8Array to copy data into.
|
|
214
|
-
* @param {number} targetOffset The offset in the target buffer where data should begin being placed.
|
|
215
|
-
* @param {number} sourceStart The starting index in the source buffer to begin copying from.
|
|
216
|
-
* @param {number} sourceEnd The ending index (exclusive) in the source buffer to stop copying.
|
|
217
|
-
* @return {void} Does not return a value. The target buffer is modified in place.
|
|
218
|
-
*/
|
|
219
|
-
function copyToBuffer(source, target, targetOffset, sourceStart, sourceEnd) {
|
|
220
|
-
if (Buffer.isBuffer(source) && Buffer.isBuffer(target)) {
|
|
221
|
-
source.copy(target, targetOffset, sourceStart, sourceEnd);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
const slicedSource = source.subarray(sourceStart, sourceEnd);
|
|
225
|
-
if (Buffer.isBuffer(target)) {
|
|
226
|
-
// Source is Uint8Array, target is Buffer
|
|
227
|
-
Uint8Array.prototype.set.call(target, slicedSource, targetOffset);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
// Handles Uint8Array and Int8Array or other TypedArrays safely
|
|
231
|
-
target.set(slicedSource, targetOffset);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function getUpdateModifiedFileCache(cwd, logger, manifest, filePath) {
|
|
236
|
-
const fsPath = filePath.fsPath;
|
|
237
|
-
if (!modifiedFileCache[fsPath] && (fsPath.endsWith('.dlo') || fsPath.endsWith('.inc'))) {
|
|
238
|
-
modifiedFileCache[fsPath] = precompileRequestedDloFile(cwd, logger, manifest, filePath);
|
|
239
|
-
}
|
|
240
|
-
return modifiedFileCache[fsPath];
|
|
241
|
-
}
|
|
242
|
-
function precompileRequestedDloFile(cwd, logger, manifest, filePath) {
|
|
243
|
-
// Simple example: convert buffer content to a string, modify and convert back
|
|
244
|
-
const originalContent = nodeFs.readFileSync(filePath.fsPath);
|
|
245
|
-
const fileBlob = convertBlobToStringArray(originalContent);
|
|
246
|
-
const preCompiled = preCompiler.preCompileDloFile(cwd, logger, manifest, filePath, fileBlob);
|
|
247
|
-
exports.precompilerDiagnostics.push(...preCompiled.diagnostics);
|
|
248
|
-
return iconv.encode(preCompiled.data, 'cp1252');
|
|
249
|
-
}
|
|
250
|
-
function uriToMemFsPath(path) {
|
|
251
|
-
return path.fsPath.replace(/\\/g, '/');
|
|
252
|
-
}
|
|
253
|
-
function relativeMemFsPath(cwd, path) {
|
|
254
|
-
const cwdPath = uriToMemFsPath(cwd);
|
|
255
|
-
const fsPath = uriToMemFsPath(path);
|
|
256
|
-
return fsPath.replace(cwdPath, '');
|
|
257
|
-
}
|
|
258
|
-
//# sourceMappingURL=CustomWasmFS.js.map
|