@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
@@ -1,13 +1,14 @@
1
1
  import {
2
2
  isMainThread
3
- } from "./chunk-2VRS523Z.js";
3
+ } from "./chunk-23PCGQQU.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM,
7
+ getTemplateDirectivePrefixes,
7
8
  getViewScriptTags,
8
9
  miniProgramBuiltinTags,
9
10
  tagWhiteList
10
- } from "./chunk-QVEZ34FP.js";
11
+ } from "./chunk-M62ZDT7T.js";
11
12
 
12
13
  // ../../dimina/fe/node_modules/.pnpm/@vue+shared@3.5.40/node_modules/@vue/shared/dist/shared.cjs.prod.js
13
14
  var require_shared_cjs_prod = __commonJS({
@@ -1395,6 +1396,8 @@ var supportedWxApis = [
1395
1396
  "hideKeyboard",
1396
1397
  "getNetworkType",
1397
1398
  "makePhoneCall",
1399
+ "onUserCaptureScreen",
1400
+ "offUserCaptureScreen",
1398
1401
  "extBridge",
1399
1402
  "extOnBridge",
1400
1403
  "extOffBridge"
@@ -1404,6 +1407,61 @@ var supportedWxApis = [
1404
1407
  var cachedReference = null;
1405
1408
  var warnedItems = /* @__PURE__ */ new Set();
1406
1409
  var pendingWarnings = [];
1410
+ var TEMPLATE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
1411
+ "if",
1412
+ "elif",
1413
+ "else",
1414
+ "for",
1415
+ "for-items",
1416
+ "for-item",
1417
+ "for-index",
1418
+ "key"
1419
+ ]);
1420
+ var KNOWN_NON_TEMPLATE_PREFIXES = /* @__PURE__ */ new Set([
1421
+ "model",
1422
+ "change",
1423
+ "worklet",
1424
+ "data",
1425
+ "class",
1426
+ "style",
1427
+ "bind",
1428
+ "mut-bind",
1429
+ "catch",
1430
+ "capture-bind",
1431
+ "capture-mut-bind",
1432
+ "capture-catch",
1433
+ "mark",
1434
+ "generic",
1435
+ "extra-attr",
1436
+ "slot",
1437
+ "let"
1438
+ ]);
1439
+ function splitAttributePrefix(attributeName) {
1440
+ const segments = attributeName.split(":");
1441
+ if (segments.length !== 2 || !segments[0] || !segments[1]) {
1442
+ return null;
1443
+ }
1444
+ return { prefix: segments[0], name: segments[1] };
1445
+ }
1446
+ function getTemplateDirectiveName(attributeName) {
1447
+ const attribute = splitAttributePrefix(attributeName);
1448
+ if (!attribute || !getTemplateDirectivePrefixes().includes(attribute.prefix)) {
1449
+ return null;
1450
+ }
1451
+ return TEMPLATE_DIRECTIVE_NAMES.has(attribute.name) ? attribute.name : null;
1452
+ }
1453
+ function getInvalidAttributePrefix(attributeName) {
1454
+ const attribute = splitAttributePrefix(attributeName);
1455
+ if (!attribute) return null;
1456
+ const templatePrefixes = getTemplateDirectivePrefixes();
1457
+ if (templatePrefixes.includes(attribute.prefix)) {
1458
+ return TEMPLATE_DIRECTIVE_NAMES.has(attribute.name) ? null : attribute.prefix;
1459
+ }
1460
+ if (KNOWN_NON_TEMPLATE_PREFIXES.has(attribute.prefix)) {
1461
+ return null;
1462
+ }
1463
+ return attribute.prefix;
1464
+ }
1407
1465
  function loadReference() {
1408
1466
  if (cachedReference) {
1409
1467
  return cachedReference;
@@ -1452,11 +1510,23 @@ function checkTemplateCompatibility(content, filePath, components = {}) {
1452
1510
  let parser;
1453
1511
  parser = new Parser(
1454
1512
  {
1455
- onopentag(tagName) {
1513
+ onopentag(tagName, attrs) {
1514
+ const line = getLineByIndex(content, parser.startIndex);
1515
+ for (const attributeName of Object.keys(attrs)) {
1516
+ const invalidPrefix = getInvalidAttributePrefix(attributeName);
1517
+ if (invalidPrefix) {
1518
+ const location = formatLocation(filePath, line);
1519
+ warnOnce(
1520
+ "template-prefix",
1521
+ attributeName,
1522
+ location,
1523
+ `[compat] Invalid template attribute prefix: ${invalidPrefix}: (${attributeName})${location}`
1524
+ );
1525
+ }
1526
+ }
1456
1527
  if (components?.[tagName]) {
1457
1528
  return;
1458
1529
  }
1459
- const line = getLineByIndex(content, parser.startIndex);
1460
1530
  warnUnsupportedComponent(tagName, filePath, line);
1461
1531
  },
1462
1532
  onerror(error) {
@@ -1513,6 +1583,7 @@ function takeCompatibilityWarnings() {
1513
1583
  }
1514
1584
 
1515
1585
  export {
1586
+ getTemplateDirectiveName,
1516
1587
  getWxMemberName,
1517
1588
  warnUnsupportedWxApi,
1518
1589
  checkTemplateCompatibility,
@@ -2,11 +2,13 @@ import {
2
2
  getWxMemberName,
3
3
  takeCompatibilityWarnings,
4
4
  warnUnsupportedWxApi
5
- } from "./chunk-6734LXNU.js";
5
+ } from "./chunk-QYHGF3MS.js";
6
6
  import {
7
7
  isMainThread,
8
- parentPort
9
- } from "./chunk-2VRS523Z.js";
8
+ mergeSourcemap,
9
+ parentPort,
10
+ remapSourcemap
11
+ } from "./chunk-23PCGQQU.js";
10
12
  import {
11
13
  collectAssets,
12
14
  fs_default,
@@ -14,13 +16,15 @@ import {
14
16
  getAppId,
15
17
  getComponent,
16
18
  getContentByPath,
19
+ getDependencyGraph,
17
20
  getNpmResolver,
18
21
  getTargetPath,
19
22
  getWorkPath,
20
23
  hasCompileInfo,
21
24
  resetStoreInfo,
22
- resolveAppAlias
23
- } from "./chunk-QVEZ34FP.js";
25
+ resolveAppAlias,
26
+ resolveAssetSourcePath
27
+ } from "./chunk-M62ZDT7T.js";
24
28
 
25
29
  // ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
26
30
  import { resolve, sep } from "node:path";
@@ -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,