@dimina-kit/compiler 0.0.2-dev.20260718095333 → 0.0.2-dev.20260728063215

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/compile-core.browser.js +5130 -4282
  2. package/dist/compile-core.node-chunks/chunk-23PCGQQU.js +141 -0
  3. package/dist/compile-core.node-chunks/{chunk-QVEZ34FP.js → chunk-M62ZDT7T.js} +281 -21
  4. package/dist/compile-core.node-chunks/{chunk-6734LXNU.js → chunk-QYHGF3MS.js} +75 -4
  5. package/dist/compile-core.node-chunks/{logic-compiler-VJWEQMXZ.js → logic-compiler-AEZPY2MO.js} +26 -102
  6. package/dist/compile-core.node-chunks/style-compiler-4PHMBQIC.js +470 -0
  7. package/dist/compile-core.node-chunks/{view-compiler-3OUFRVZF.js → view-compiler-2SMUHAPD.js} +232 -109
  8. package/dist/compile-core.node.js +11 -6
  9. package/dist/pool.node-chunks/{chunk-7F3E2G42.js → chunk-CKQISGZS.js} +281 -21
  10. package/dist/pool.node-chunks/{chunk-DQNLDQGT.js → chunk-LGB3AH5C.js} +75 -4
  11. package/dist/pool.node-chunks/chunk-VHWKAXDL.js +141 -0
  12. package/dist/pool.node-chunks/{chunk-LKL7FBHG.js → chunk-WX4462A5.js} +11 -6
  13. package/dist/pool.node-chunks/{logic-compiler-HMMTJJWY.js → logic-compiler-P4T4OMTG.js} +26 -102
  14. package/dist/pool.node-chunks/style-compiler-W7EA2Y7R.js +470 -0
  15. package/dist/pool.node-chunks/{view-compiler-2VZMJ65O.js → view-compiler-2D7HPYIN.js} +232 -109
  16. package/dist/pool.node.js +2 -2
  17. package/dist/stage-worker.browser.js +5337 -4489
  18. package/dist/stage-worker.node.js +2 -2
  19. package/package.json +8 -7
  20. package/scripts/check-wasm-alignment.js +173 -0
  21. package/dist/compile-core.node-chunks/chunk-2VRS523Z.js +0 -8
  22. package/dist/compile-core.node-chunks/style-compiler-YWVITCJW.js +0 -288
  23. package/dist/pool.node-chunks/chunk-KLXXOLDF.js +0 -8
  24. package/dist/pool.node-chunks/style-compiler-VGVCLQ7X.js +0 -288
@@ -0,0 +1,141 @@
1
+ // src/shims/worker_threads.js
2
+ var isMainThread = true;
3
+ var parentPort = null;
4
+
5
+ // ../../dimina/fe/packages/compiler/src/core/sourcemap.js
6
+ import { SourceMapConsumer, SourceMapGenerator } from "source-map-js";
7
+ function wrapModDefine(module) {
8
+ const code = module.code.endsWith("\n") ? module.code : module.code + "\n";
9
+ const extraLine = module.extraInfoCode || "";
10
+ const header = `modDefine('${module.path}', function(require, module, exports) {
11
+ ${extraLine}`;
12
+ const footer = "});\n";
13
+ return { header, code, footer };
14
+ }
15
+ function appendSourceMap(smg, map, lineOffset, columnOffset) {
16
+ const mapObject = typeof map === "string" ? JSON.parse(map) : map;
17
+ const consumer = new SourceMapConsumer(mapObject);
18
+ consumer.eachMapping((mapping) => {
19
+ if (mapping.source == null || mapping.originalLine == null || mapping.originalColumn == null) {
20
+ return;
21
+ }
22
+ smg.addMapping({
23
+ generated: {
24
+ line: mapping.generatedLine + lineOffset,
25
+ column: mapping.generatedColumn + (mapping.generatedLine === 1 ? columnOffset : 0)
26
+ },
27
+ original: {
28
+ line: mapping.originalLine,
29
+ column: mapping.originalColumn
30
+ },
31
+ source: mapping.source,
32
+ name: mapping.name
33
+ });
34
+ });
35
+ if (mapObject.sourcesContent) {
36
+ mapObject.sources.forEach((source, index) => {
37
+ smg.setSourceContent(source, mapObject.sourcesContent[index]);
38
+ });
39
+ }
40
+ }
41
+ function advanceGeneratedPosition(position, code) {
42
+ const lines = code.split("\n");
43
+ if (lines.length === 1) {
44
+ position.column += code.length;
45
+ return;
46
+ }
47
+ position.line += lines.length - 1;
48
+ position.column = lines.at(-1).length;
49
+ }
50
+ function concatSourcemap(chunks, file = "") {
51
+ const smg = new SourceMapGenerator({ file });
52
+ const position = { line: 1, column: 0 };
53
+ let code = "";
54
+ for (const chunk of chunks) {
55
+ const chunkCode = typeof chunk === "string" ? chunk : chunk.code;
56
+ if (typeof chunk !== "string" && chunk.map) {
57
+ appendSourceMap(smg, chunk.map, position.line - 1, position.column);
58
+ }
59
+ code += chunkCode;
60
+ advanceGeneratedPosition(position, chunkCode);
61
+ }
62
+ return { code, sourcemap: smg.toString() };
63
+ }
64
+ function createLineSourcemap(generatedCode, source, sourceContent, startLine = 1) {
65
+ const smg = new SourceMapGenerator({ file: source });
66
+ const generatedLineCount = generatedCode.split("\n").length;
67
+ const sourceLineCount = Math.max(1, sourceContent.split("\n").length);
68
+ for (let line = 1; line <= generatedLineCount; line++) {
69
+ smg.addMapping({
70
+ generated: { line, column: 0 },
71
+ original: {
72
+ line: Math.min(sourceLineCount, startLine + line - 1),
73
+ column: 0
74
+ },
75
+ source
76
+ });
77
+ }
78
+ smg.setSourceContent(source, sourceContent);
79
+ return JSON.parse(smg.toString());
80
+ }
81
+ function mergeSourcemap(compileRes, file = "logic.js") {
82
+ const chunks = [];
83
+ for (const module of compileRes) {
84
+ const { header, code, footer } = wrapModDefine(module);
85
+ chunks.push(header, { code, map: module.map }, footer);
86
+ }
87
+ const { code: bundleCode, sourcemap } = concatSourcemap(chunks, file);
88
+ return { bundleCode, sourcemap };
89
+ }
90
+ function remapSourcemap(nextMap, prevMap) {
91
+ if (!nextMap) {
92
+ return prevMap;
93
+ }
94
+ if (!prevMap) {
95
+ return nextMap;
96
+ }
97
+ const nextMapObj = typeof nextMap === "string" ? JSON.parse(nextMap) : nextMap;
98
+ const prevMapObj = typeof prevMap === "string" ? JSON.parse(prevMap) : prevMap;
99
+ const smg = new SourceMapGenerator({ file: nextMapObj.file || prevMapObj.file || "" });
100
+ const prevSmc = new SourceMapConsumer(prevMapObj);
101
+ const nextSmc = new SourceMapConsumer(nextMapObj);
102
+ nextSmc.eachMapping((mapping) => {
103
+ if (mapping.source == null || mapping.originalLine == null || mapping.originalColumn == null) {
104
+ return;
105
+ }
106
+ const original = prevSmc.originalPositionFor({
107
+ line: mapping.originalLine,
108
+ column: mapping.originalColumn
109
+ });
110
+ if (original.source == null || original.line == null || original.column == null) {
111
+ return;
112
+ }
113
+ smg.addMapping({
114
+ generated: {
115
+ line: mapping.generatedLine,
116
+ column: mapping.generatedColumn
117
+ },
118
+ original: {
119
+ line: original.line,
120
+ column: original.column
121
+ },
122
+ source: original.source,
123
+ name: original.name || mapping.name
124
+ });
125
+ });
126
+ if (prevMapObj.sourcesContent) {
127
+ prevMapObj.sources.forEach((src, i) => {
128
+ smg.setSourceContent(src, prevMapObj.sourcesContent[i]);
129
+ });
130
+ }
131
+ return smg.toString();
132
+ }
133
+
134
+ export {
135
+ isMainThread,
136
+ parentPort,
137
+ concatSourcemap,
138
+ createLineSourcemap,
139
+ mergeSourcemap,
140
+ remapSourcemap
141
+ };
@@ -12,18 +12,21 @@ import {
12
12
  getViewScriptExts,
13
13
  getWorkPath,
14
14
  storeInfo
15
- } from "./chunk-7F3E2G42.js";
15
+ } from "./chunk-CKQISGZS.js";
16
16
 
17
17
  // ../../dimina/fe/packages/compiler/src/common/publish.js
18
18
  import path from "node:path";
19
19
  import process from "node:process";
20
20
  import fs from "node:fs";
21
- function createDist() {
21
+ function createDist(seedPath) {
22
22
  const distPath = getTargetPath();
23
23
  if (fs.existsSync(distPath)) {
24
24
  fs.rmSync(distPath, { recursive: true, force: true });
25
25
  }
26
26
  fs.mkdirSync(distPath, { recursive: true });
27
+ if (seedPath && fs.existsSync(seedPath)) {
28
+ fs.cpSync(seedPath, distPath, { recursive: true });
29
+ }
27
30
  }
28
31
  function publishToDist(dist, useAppIdDir = true) {
29
32
  const distPath = getTargetPath();
@@ -129,9 +132,10 @@ var config_compiler_default = compileConfig;
129
132
  import fs3 from "node:fs";
130
133
  import path2 from "node:path";
131
134
  var NpmBuilder = class {
132
- constructor(workPath, targetPath) {
135
+ constructor(workPath, targetPath, dependencyGraph = null) {
133
136
  this.workPath = workPath;
134
137
  this.targetPath = targetPath;
138
+ this.dependencyGraph = dependencyGraph;
135
139
  this.builtPackages = /* @__PURE__ */ new Set();
136
140
  this.packageDependencies = /* @__PURE__ */ new Map();
137
141
  }
@@ -224,6 +228,7 @@ var NpmBuilder = class {
224
228
  await this.copyPackageFiles(sourceItemPath, targetItemPath);
225
229
  } else {
226
230
  if (this.isMiniprogramFile(item.name)) {
231
+ this.dependencyGraph?.addFile("app", sourceItemPath, "config");
227
232
  fs3.copyFileSync(sourceItemPath, targetItemPath);
228
233
  }
229
234
  }
@@ -318,9 +323,9 @@ var NpmBuilder = class {
318
323
 
319
324
  // src/compile-core.js
320
325
  var STAGE_IMPORTERS = {
321
- logic: () => import("./logic-compiler-HMMTJJWY.js"),
322
- view: () => import("./view-compiler-2VZMJ65O.js"),
323
- style: () => import("./style-compiler-VGVCLQ7X.js")
326
+ logic: () => import("./logic-compiler-P4T4OMTG.js"),
327
+ view: () => import("./view-compiler-2D7HPYIN.js"),
328
+ style: () => import("./style-compiler-W7EA2Y7R.js")
324
329
  };
325
330
  var stageLoads = /* @__PURE__ */ new Map();
326
331
  var stageModules = /* @__PURE__ */ new Map();
@@ -2,24 +2,28 @@ import {
2
2
  getWxMemberName,
3
3
  takeCompatibilityWarnings,
4
4
  warnUnsupportedWxApi
5
- } from "./chunk-DQNLDQGT.js";
5
+ } from "./chunk-LGB3AH5C.js";
6
6
  import {
7
7
  isMainThread,
8
- parentPort
9
- } from "./chunk-KLXXOLDF.js";
8
+ mergeSourcemap,
9
+ parentPort,
10
+ remapSourcemap
11
+ } from "./chunk-VHWKAXDL.js";
10
12
  import {
11
13
  collectAssets,
12
14
  getAppConfigInfo,
13
15
  getAppId,
14
16
  getComponent,
15
17
  getContentByPath,
18
+ getDependencyGraph,
16
19
  getNpmResolver,
17
20
  getTargetPath,
18
21
  getWorkPath,
19
22
  hasCompileInfo,
20
23
  resetStoreInfo,
21
- resolveAppAlias
22
- } from "./chunk-7F3E2G42.js";
24
+ resolveAppAlias,
25
+ resolveAssetSourcePath
26
+ } from "./chunk-CKQISGZS.js";
23
27
 
24
28
  // ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
25
29
  import fs from "node:fs";
@@ -28,102 +32,6 @@ import { parseSync } from "oxc-parser";
28
32
  import { walk } from "oxc-walker";
29
33
  import MagicString from "magic-string";
30
34
  import { transform } from "esbuild";
31
-
32
- // ../../dimina/fe/packages/compiler/src/core/sourcemap.js
33
- import { SourceMapConsumer, SourceMapGenerator } from "source-map-js";
34
- function wrapModDefine(module) {
35
- const code = module.code.endsWith("\n") ? module.code : module.code + "\n";
36
- const extraLine = module.extraInfoCode || "";
37
- const header = `modDefine('${module.path}', function(require, module, exports) {
38
- ${extraLine}`;
39
- const footer = "});\n";
40
- return { header, code, footer };
41
- }
42
- function mergeSourcemap(compileRes) {
43
- const smg = new SourceMapGenerator({ file: "logic.js" });
44
- let bundleCode = "";
45
- let lineOffset = 0;
46
- for (const module of compileRes) {
47
- const { header, code, footer } = wrapModDefine(module);
48
- bundleCode += header;
49
- const headerLineCount = header.split("\n").length - 1;
50
- lineOffset += headerLineCount;
51
- if (module.map) {
52
- const moduleMap = JSON.parse(module.map);
53
- const smc = new SourceMapConsumer(moduleMap);
54
- smc.eachMapping((mapping) => {
55
- if (mapping.source == null) return;
56
- smg.addMapping({
57
- generated: {
58
- line: mapping.generatedLine + lineOffset,
59
- column: mapping.generatedColumn
60
- },
61
- original: {
62
- line: mapping.originalLine,
63
- column: mapping.originalColumn
64
- },
65
- source: mapping.source,
66
- name: mapping.name
67
- });
68
- });
69
- if (moduleMap.sourcesContent) {
70
- moduleMap.sources.forEach((src, i) => {
71
- smg.setSourceContent(src, moduleMap.sourcesContent[i]);
72
- });
73
- }
74
- }
75
- bundleCode += code;
76
- lineOffset += code.split("\n").length - 1;
77
- bundleCode += footer;
78
- lineOffset += footer.split("\n").length - 1;
79
- }
80
- return { bundleCode, sourcemap: smg.toString() };
81
- }
82
- function remapSourcemap(nextMap, prevMap) {
83
- if (!nextMap) {
84
- return prevMap;
85
- }
86
- if (!prevMap) {
87
- return nextMap;
88
- }
89
- const nextMapObj = typeof nextMap === "string" ? JSON.parse(nextMap) : nextMap;
90
- const prevMapObj = typeof prevMap === "string" ? JSON.parse(prevMap) : prevMap;
91
- const smg = new SourceMapGenerator({ file: nextMapObj.file || prevMapObj.file || "" });
92
- const prevSmc = new SourceMapConsumer(prevMapObj);
93
- const nextSmc = new SourceMapConsumer(nextMapObj);
94
- nextSmc.eachMapping((mapping) => {
95
- if (mapping.source == null || mapping.originalLine == null || mapping.originalColumn == null) {
96
- return;
97
- }
98
- const original = prevSmc.originalPositionFor({
99
- line: mapping.originalLine,
100
- column: mapping.originalColumn
101
- });
102
- if (original.source == null || original.line == null || original.column == null) {
103
- return;
104
- }
105
- smg.addMapping({
106
- generated: {
107
- line: mapping.generatedLine,
108
- column: mapping.generatedColumn
109
- },
110
- original: {
111
- line: original.line,
112
- column: original.column
113
- },
114
- source: original.source,
115
- name: original.name || mapping.name
116
- });
117
- });
118
- if (prevMapObj.sourcesContent) {
119
- prevMapObj.sources.forEach((src, i) => {
120
- smg.setSourceContent(src, prevMapObj.sourcesContent[i]);
121
- });
122
- }
123
- return smg.toString();
124
- }
125
-
126
- // ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
127
35
  var processedModules = /* @__PURE__ */ new Set();
128
36
  var enableSourcemap = false;
129
37
  if (!isMainThread) {
@@ -160,7 +68,8 @@ ${error.stack}`);
160
68
  processedModules.clear();
161
69
  parentPort.postMessage({
162
70
  success: true,
163
- compatibilityWarnings: takeCompatibilityWarnings()
71
+ compatibilityWarnings: takeCompatibilityWarnings(),
72
+ dependencyGraph: getDependencyGraph().toJSON()
164
73
  });
165
74
  } catch (error) {
166
75
  processedModules.clear();
@@ -236,6 +145,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
236
145
  console.warn("[logic]", `\u627E\u4E0D\u5230\u6A21\u5757\u6587\u4EF6: ${src}`);
237
146
  return;
238
147
  }
148
+ getDependencyGraph().addFile(currentPath, modulePath, "logic");
239
149
  const diagnosticSource = modulePath.startsWith(getWorkPath()) ? modulePath.slice(getWorkPath().length) : src;
240
150
  const sourceCode = getContentByPath(modulePath);
241
151
  if (!sourceCode) {
@@ -263,7 +173,12 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
263
173
  if (module.usingComponents) {
264
174
  const componentsObj = {};
265
175
  const allSubPackages = getAppConfigInfo().subPackages;
176
+ const graphDependencies = getDependencyGraph().getDirectDependencies(module.path, "component");
177
+ const componentDependencies = graphDependencies.length > 0 ? new Set(graphDependencies) : null;
266
178
  for (const [name, path] of Object.entries(module.usingComponents)) {
179
+ if (componentDependencies && !componentDependencies.has(path)) {
180
+ continue;
181
+ }
267
182
  let toMainSubPackage = true;
268
183
  if (packageName) {
269
184
  const normalizedPath = path.startsWith("/") ? path.substring(1) : path;
@@ -312,6 +227,11 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
312
227
  );
313
228
  }
314
229
  if ((node.type === "StringLiteral" || node.type === "Literal") && isLocalAssetString(node.value)) {
230
+ getDependencyGraph().addFile(
231
+ currentPath,
232
+ resolveAssetSourcePath(getWorkPath(), modulePath, node.value),
233
+ "logic"
234
+ );
315
235
  pathReplacements.push({
316
236
  start: node.start,
317
237
  end: node.end,
@@ -327,6 +247,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
327
247
  if (requirePath) {
328
248
  const { id, shouldProcess } = resolveDependencyId(requirePath, modulePath, false);
329
249
  if (shouldProcess) {
250
+ getDependencyGraph().addDependency(currentPath, id, "logic");
330
251
  pathReplacements.push({
331
252
  start: arg.start,
332
253
  end: arg.end,
@@ -344,6 +265,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
344
265
  if (importPath) {
345
266
  const { id, shouldProcess } = resolveDependencyId(importPath, modulePath, true);
346
267
  if (shouldProcess) {
268
+ getDependencyGraph().addDependency(currentPath, id, "logic");
347
269
  pathReplacements.push({
348
270
  start: node.source.start,
349
271
  end: node.source.end,
@@ -361,6 +283,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
361
283
  if (importPath) {
362
284
  const { id, shouldProcess } = resolveDependencyId(importPath, modulePath, false);
363
285
  if (shouldProcess) {
286
+ getDependencyGraph().addDependency(currentPath, id, "logic");
364
287
  pathReplacements.push({
365
288
  start: importPathNode.start,
366
289
  end: importPathNode.end,
@@ -377,6 +300,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
377
300
  if (exportPath) {
378
301
  const { id, shouldProcess } = resolveDependencyId(exportPath, modulePath, true);
379
302
  if (shouldProcess) {
303
+ getDependencyGraph().addDependency(currentPath, id, "logic");
380
304
  pathReplacements.push({
381
305
  start: node.source.start,
382
306
  end: node.source.end,