@dimina-kit/compiler 0.0.2-dev.20260718143821 → 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
+ };
@@ -285,7 +285,7 @@ function __resetAssets() {
285
285
 
286
286
  // ../../dimina/fe/packages/compiler/src/env.js
287
287
  import os from "node:os";
288
- import path4 from "node:path";
288
+ import path5 from "node:path";
289
289
  import process2 from "node:process";
290
290
  import { parseSync } from "oxc-parser";
291
291
  import { walk } from "oxc-walker";
@@ -489,11 +489,164 @@ var NpmResolver = class {
489
489
  }
490
490
  };
491
491
 
492
+ // ../../dimina/fe/packages/compiler/src/common/dependency-graph.js
493
+ import path4 from "node:path";
494
+ function normalizeFilePath(filePath) {
495
+ return path4.resolve(filePath);
496
+ }
497
+ function normalizeKinds(kinds) {
498
+ if (!kinds) return null;
499
+ return new Set(Array.isArray(kinds) ? kinds : [kinds]);
500
+ }
501
+ var DependencyGraph = class _DependencyGraph {
502
+ constructor(snapshot) {
503
+ this.nodes = /* @__PURE__ */ new Map();
504
+ this.dependencies = /* @__PURE__ */ new Map();
505
+ this.dependents = /* @__PURE__ */ new Map();
506
+ this.fileOwners = /* @__PURE__ */ new Map();
507
+ this.fileKinds = /* @__PURE__ */ new Map();
508
+ if (snapshot) {
509
+ this.merge(snapshot);
510
+ }
511
+ }
512
+ addNode(id, metadata = {}) {
513
+ if (!id) return null;
514
+ const current2 = this.nodes.get(id) || {
515
+ id,
516
+ type: "module",
517
+ entry: false,
518
+ packageRoot: null,
519
+ files: /* @__PURE__ */ new Set()
520
+ };
521
+ if (metadata.type) current2.type = metadata.type;
522
+ if (metadata.entry === true) current2.entry = true;
523
+ if (metadata.packageRoot !== void 0) current2.packageRoot = metadata.packageRoot;
524
+ this.nodes.set(id, current2);
525
+ for (const filePath of metadata.files || []) {
526
+ this.addFile(id, filePath);
527
+ }
528
+ return current2;
529
+ }
530
+ addFile(id, filePath, kind = "module") {
531
+ if (!id || !filePath) return;
532
+ const node = this.addNode(id);
533
+ const normalizedPath = normalizeFilePath(filePath);
534
+ node.files.add(normalizedPath);
535
+ const owners = this.fileOwners.get(normalizedPath) || /* @__PURE__ */ new Set();
536
+ owners.add(id);
537
+ this.fileOwners.set(normalizedPath, owners);
538
+ const ownerKinds = this.fileKinds.get(normalizedPath) || /* @__PURE__ */ new Map();
539
+ const kinds = ownerKinds.get(id) || /* @__PURE__ */ new Set();
540
+ kinds.add(kind);
541
+ ownerKinds.set(id, kinds);
542
+ this.fileKinds.set(normalizedPath, ownerKinds);
543
+ }
544
+ addDependency(from, to, kind = "module") {
545
+ if (!from || !to) return;
546
+ this.addNode(from);
547
+ this.addNode(to);
548
+ const outgoing = this.dependencies.get(from) || /* @__PURE__ */ new Map();
549
+ const kinds = outgoing.get(to) || /* @__PURE__ */ new Set();
550
+ kinds.add(kind);
551
+ outgoing.set(to, kinds);
552
+ this.dependencies.set(from, outgoing);
553
+ const incoming = this.dependents.get(to) || /* @__PURE__ */ new Map();
554
+ const reverseKinds = incoming.get(from) || /* @__PURE__ */ new Set();
555
+ reverseKinds.add(kind);
556
+ incoming.set(from, reverseKinds);
557
+ this.dependents.set(to, incoming);
558
+ }
559
+ getDirectDependencies(id, kinds) {
560
+ return this.#filterEdges(this.dependencies.get(id), kinds);
561
+ }
562
+ getDirectDependents(id, kinds) {
563
+ return this.#filterEdges(this.dependents.get(id), kinds);
564
+ }
565
+ getAffectedEntries(filePath) {
566
+ const owners = this.fileOwners.get(normalizeFilePath(filePath)) || /* @__PURE__ */ new Set();
567
+ const pending = [...owners];
568
+ const visited = /* @__PURE__ */ new Set();
569
+ const entries = /* @__PURE__ */ new Set();
570
+ while (pending.length > 0) {
571
+ const id = pending.pop();
572
+ if (visited.has(id)) continue;
573
+ visited.add(id);
574
+ const node = this.nodes.get(id);
575
+ if (node?.entry) entries.add(id);
576
+ for (const dependent of this.getDirectDependents(id)) {
577
+ pending.push(dependent);
578
+ }
579
+ }
580
+ return [...entries].sort();
581
+ }
582
+ hasFile(filePath) {
583
+ return this.fileOwners.has(normalizeFilePath(filePath));
584
+ }
585
+ getFileKinds(filePath) {
586
+ const ownerKinds = this.fileKinds.get(normalizeFilePath(filePath));
587
+ if (!ownerKinds) return [];
588
+ return [...new Set(
589
+ [...ownerKinds.values()].flatMap((kinds) => [...kinds])
590
+ )].sort();
591
+ }
592
+ merge(snapshotOrGraph) {
593
+ const snapshot = snapshotOrGraph instanceof _DependencyGraph ? snapshotOrGraph.toJSON() : snapshotOrGraph;
594
+ const fileEdges = snapshot?.fileEdges || [];
595
+ for (const node of snapshot?.nodes || []) {
596
+ this.addNode(node.id, { ...node, files: [] });
597
+ if (fileEdges.length === 0) {
598
+ for (const filePath of node.files || []) {
599
+ this.addFile(node.id, filePath);
600
+ }
601
+ }
602
+ }
603
+ for (const fileEdge of fileEdges) {
604
+ for (const kind of fileEdge.kinds || ["module"]) {
605
+ this.addFile(fileEdge.owner, fileEdge.file, kind);
606
+ }
607
+ }
608
+ for (const edge of snapshot?.edges || []) {
609
+ for (const kind of edge.kinds || ["module"]) {
610
+ this.addDependency(edge.from, edge.to, kind);
611
+ }
612
+ }
613
+ return this;
614
+ }
615
+ toJSON() {
616
+ return {
617
+ nodes: [...this.nodes.values()].map((node) => ({
618
+ id: node.id,
619
+ type: node.type,
620
+ entry: node.entry,
621
+ packageRoot: node.packageRoot,
622
+ files: [...node.files].sort()
623
+ })).sort((a, b) => a.id.localeCompare(b.id)),
624
+ edges: [...this.dependencies.entries()].flatMap(([from, targets]) => [...targets.entries()].map(([to, kinds]) => ({
625
+ from,
626
+ to,
627
+ kinds: [...kinds].sort()
628
+ }))).sort((a, b) => a.from.localeCompare(b.from) || a.to.localeCompare(b.to)),
629
+ fileEdges: [...this.fileKinds.entries()].flatMap(([file, owners]) => [...owners.entries()].map(([owner, kinds]) => ({
630
+ file,
631
+ owner,
632
+ kinds: [...kinds].sort()
633
+ }))).sort((a, b) => a.file.localeCompare(b.file) || a.owner.localeCompare(b.owner))
634
+ };
635
+ }
636
+ #filterEdges(edges, kinds) {
637
+ if (!edges) return [];
638
+ const acceptedKinds = normalizeKinds(kinds);
639
+ return [...edges.entries()].filter(([, edgeKinds]) => !acceptedKinds || [...edgeKinds].some((kind) => acceptedKinds.has(kind))).map(([id]) => id);
640
+ }
641
+ };
642
+
492
643
  // ../../dimina/fe/packages/compiler/src/env.js
493
644
  var pathInfo = {};
494
645
  var configInfo = {};
495
646
  var npmResolver = null;
647
+ var dependencyGraph = new DependencyGraph();
496
648
  var DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
649
+ var DEFAULT_TEMPLATE_DIRECTIVE_PREFIXES = ["wx", "dd", "a"];
497
650
  var DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
498
651
  var DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
499
652
  var DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
@@ -548,29 +701,38 @@ function mergeUnique(builtins, custom, normalizer, reserved) {
548
701
  }
549
702
  function normalizeFileTypes(fileTypes = {}) {
550
703
  const ft = fileTypes || {};
704
+ const templateExts = mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS);
551
705
  return {
552
- templateExts: mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS),
706
+ templateExts,
707
+ templateDirectivePrefixes: [.../* @__PURE__ */ new Set([...DEFAULT_TEMPLATE_DIRECTIVE_PREFIXES, ...templateExts.map((extension) => {
708
+ const name = extension.slice(1);
709
+ return name.endsWith("ml") ? name.slice(0, -2) : name;
710
+ }).filter(Boolean)])],
553
711
  styleExts: mergeUnique(DEFAULT_STYLE_EXTS, ft.style, normalizeExt, RESERVED_EXTS),
554
712
  viewScriptExts: mergeUnique(DEFAULT_VIEW_SCRIPT_EXTS, ft.viewScript, normalizeExt, RESERVED_EXTS),
555
713
  viewScriptTags: mergeUnique(DEFAULT_VIEW_SCRIPT_TAGS, ft.viewScript, normalizeTag)
556
714
  };
557
715
  }
558
716
  function storeInfo(workPath, options = {}) {
717
+ compilerOptions = normalizeFileTypes(options.fileTypes);
559
718
  storePathInfo(workPath);
560
719
  storeProjectConfig();
561
720
  storeAppConfig();
562
721
  storePageConfig();
563
- compilerOptions = normalizeFileTypes(options.fileTypes);
722
+ dependencyGraph = createInitialDependencyGraph();
723
+ dependencyGraph.merge(options.dependencyGraph);
564
724
  return {
565
725
  pathInfo,
566
726
  configInfo,
567
- compilerOptions
727
+ compilerOptions,
728
+ dependencyGraph: dependencyGraph.toJSON()
568
729
  };
569
730
  }
570
731
  function resetStoreInfo(opts) {
571
732
  pathInfo = opts.pathInfo;
572
733
  configInfo = opts.configInfo;
573
734
  compilerOptions = opts.compilerOptions || normalizeFileTypes();
735
+ dependencyGraph = new DependencyGraph(opts.dependencyGraph);
574
736
  if (pathInfo.workPath) {
575
737
  npmResolver = new NpmResolver(pathInfo.workPath);
576
738
  }
@@ -578,6 +740,9 @@ function resetStoreInfo(opts) {
578
740
  function getTemplateExts() {
579
741
  return compilerOptions.templateExts;
580
742
  }
743
+ function getTemplateDirectivePrefixes() {
744
+ return compilerOptions.templateDirectivePrefixes || normalizeFileTypes({ template: compilerOptions.templateExts }).templateDirectivePrefixes;
745
+ }
581
746
  function getStyleExts() {
582
747
  return compilerOptions.styleExts;
583
748
  }
@@ -587,13 +752,16 @@ function getViewScriptExts() {
587
752
  function getViewScriptTags() {
588
753
  return compilerOptions.viewScriptTags;
589
754
  }
755
+ function getDependencyGraph() {
756
+ return dependencyGraph;
757
+ }
590
758
  function storePathInfo(workPath) {
591
759
  pathInfo.workPath = workPath;
592
760
  if (process2.env.TARGET_PATH) {
593
761
  pathInfo.targetPath = process2.env.TARGET_PATH;
594
762
  } else {
595
763
  const tempDir = process2.env.GITHUB_WORKSPACE || os.tmpdir();
596
- const targetDir = path4.join(tempDir, `dimina-fe-dist-${Date.now()}`);
764
+ const targetDir = path5.join(tempDir, `dimina-fe-dist-${Date.now()}`);
597
765
  if (!fs_default.existsSync(targetDir)) {
598
766
  fs_default.mkdirSync(targetDir, { recursive: true });
599
767
  }
@@ -637,11 +805,11 @@ function storeAppConfig() {
637
805
  }
638
806
  configInfo.appInfo = newObj;
639
807
  }
640
- function getContentByPath(path5) {
641
- return fs_default.readFileSync(path5, { encoding: "utf-8" });
808
+ function getContentByPath(path6) {
809
+ return fs_default.readFileSync(path6, { encoding: "utf-8" });
642
810
  }
643
- function parseContentByPath(path5) {
644
- return JSON.parse(getContentByPath(path5));
811
+ function parseContentByPath(path6) {
812
+ return JSON.parse(getContentByPath(path6));
645
813
  }
646
814
  function storePageConfig() {
647
815
  const { pages, subPackages } = configInfo.appInfo;
@@ -664,7 +832,7 @@ function storeCustomTabBarConfig() {
664
832
  if (tabBar?.custom !== true || !Array.isArray(tabBar.list)) {
665
833
  return;
666
834
  }
667
- const componentJsonPath = path4.join(pathInfo.workPath, "custom-tab-bar/index.json");
835
+ const componentJsonPath = path5.join(pathInfo.workPath, "custom-tab-bar/index.json");
668
836
  if (!fs_default.existsSync(componentJsonPath)) {
669
837
  console.warn("[env] tabBar.custom \u5DF2\u542F\u7528\uFF0C\u4F46\u627E\u4E0D\u5230 custom-tab-bar/index.json");
670
838
  return;
@@ -675,7 +843,7 @@ function storeCustomTabBarConfig() {
675
843
  [dependencyName]: CUSTOM_TAB_BAR_COMPONENT_PATH
676
844
  }
677
845
  };
678
- storeComponentConfig(internalConfig, path4.join(pathInfo.workPath, "app.json"));
846
+ storeComponentConfig(internalConfig, path5.join(pathInfo.workPath, "app.json"));
679
847
  const componentConfig = configInfo.componentInfo[CUSTOM_TAB_BAR_COMPONENT_PATH];
680
848
  if (componentConfig) {
681
849
  componentConfig.customTabBar = true;
@@ -732,12 +900,12 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
732
900
  if (configInfo.componentInfo[moduleId]) {
733
901
  continue;
734
902
  }
735
- let componentFilePath = path4.resolve(getWorkPath(), `./${moduleId}.json`);
903
+ let componentFilePath = path5.resolve(getWorkPath(), `./${moduleId}.json`);
736
904
  let cContent = null;
737
905
  if (fs_default.existsSync(componentFilePath)) {
738
906
  cContent = parseContentByPath(componentFilePath);
739
907
  } else {
740
- const indexJsonPath = path4.resolve(getWorkPath(), `./${moduleId}/index.json`);
908
+ const indexJsonPath = path5.resolve(getWorkPath(), `./${moduleId}/index.json`);
741
909
  if (fs_default.existsSync(indexJsonPath)) {
742
910
  componentFilePath = indexJsonPath;
743
911
  cContent = parseContentByPath(componentFilePath);
@@ -766,7 +934,8 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
766
934
  path: moduleId,
767
935
  component: isComponent,
768
936
  styleIsolation,
769
- usingComponents: cComponents
937
+ usingComponents: cComponents,
938
+ componentPlaceholder: { ...cContent.componentPlaceholder || {} }
770
939
  };
771
940
  if (cContent.usingComponents && Object.keys(cContent.usingComponents).length > 0) {
772
941
  storeComponentConfig(configInfo.componentInfo[moduleId], componentFilePath);
@@ -897,16 +1066,17 @@ function transSubDir(name) {
897
1066
  function getPages() {
898
1067
  const { pages, subPackages = [], usingComponents: globalComponents = {} } = getAppConfigInfo();
899
1068
  const pageInfo = getPageConfigInfo();
900
- const mainPages = pages.map((path5) => {
901
- const pageComponents = pageInfo[path5]?.usingComponents || {};
1069
+ const mainPages = pages.map((path6) => {
1070
+ const pageComponents = pageInfo[path6]?.usingComponents || {};
902
1071
  const mergedComponents = { ...globalComponents, ...pageComponents };
903
1072
  return {
904
- id: uuid(path5),
905
- path: path5,
1073
+ id: uuid(path6),
1074
+ path: path6,
906
1075
  appStyleScopeId: getAppStyleScopeId(),
907
1076
  sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
908
1077
  usingComponents: mergedComponents,
909
- customTabBar: pageInfo[path5]?.customTabBar
1078
+ componentPlaceholder: { ...pageInfo[path6]?.componentPlaceholder || {} },
1079
+ customTabBar: pageInfo[path6]?.customTabBar
910
1080
  };
911
1081
  });
912
1082
  const subPages = {};
@@ -915,8 +1085,8 @@ function getPages() {
915
1085
  const independent = subPkg.independent ? subPkg.independent : false;
916
1086
  subPages[transSubDir(rootPath)] = {
917
1087
  independent,
918
- info: subPkg.pages.map((path5) => {
919
- const fullPath = rootPath + path5;
1088
+ info: subPkg.pages.map((path6) => {
1089
+ const fullPath = rootPath + path6;
920
1090
  const pageComponents = pageInfo[fullPath]?.usingComponents || {};
921
1091
  const mergedComponents = { ...globalComponents, ...pageComponents };
922
1092
  return {
@@ -925,6 +1095,7 @@ function getPages() {
925
1095
  appStyleScopeId: getAppStyleScopeId(),
926
1096
  sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
927
1097
  usingComponents: mergedComponents,
1098
+ componentPlaceholder: { ...pageInfo[fullPath]?.componentPlaceholder || {} },
928
1099
  customTabBar: pageInfo[fullPath]?.customTabBar
929
1100
  };
930
1101
  })
@@ -935,6 +1106,92 @@ function getPages() {
935
1106
  subPages
936
1107
  };
937
1108
  }
1109
+ function addExistingModuleFiles(graph, moduleId) {
1110
+ const relativeId = moduleId.replace(/^\/+/, "");
1111
+ const basePath = path5.resolve(getWorkPath(), relativeId);
1112
+ const baseCandidates = [basePath, path5.join(basePath, "index")];
1113
+ const extensions = [
1114
+ ".json",
1115
+ ".js",
1116
+ ".ts",
1117
+ ...getTemplateExts(),
1118
+ ...getStyleExts(),
1119
+ ...getViewScriptExts()
1120
+ ];
1121
+ for (const candidateBase of baseCandidates) {
1122
+ for (const extension of extensions) {
1123
+ const filePath = `${candidateBase}${extension}`;
1124
+ if (fs_default.existsSync(filePath)) {
1125
+ graph.addFile(moduleId, filePath, getFileDependencyKind(filePath));
1126
+ }
1127
+ }
1128
+ }
1129
+ }
1130
+ function getFileDependencyKind(filePath) {
1131
+ const extension = path5.extname(filePath).toLowerCase();
1132
+ if (extension === ".json") return "config";
1133
+ if (extension === ".js" || extension === ".ts") return "logic";
1134
+ if (getTemplateExts().includes(extension) || getViewScriptExts().includes(extension)) return "view";
1135
+ if (getStyleExts().includes(extension)) return "style";
1136
+ return "module";
1137
+ }
1138
+ function createInitialDependencyGraph() {
1139
+ const graph = new DependencyGraph();
1140
+ graph.addNode("app", { type: "app" });
1141
+ for (const fileName of [
1142
+ "app.json",
1143
+ "app.js",
1144
+ "app.ts",
1145
+ "project.config.json",
1146
+ "project.private.config.json"
1147
+ ]) {
1148
+ const filePath = path5.resolve(getWorkPath(), fileName);
1149
+ if (fs_default.existsSync(filePath)) {
1150
+ graph.addFile("app", filePath, getFileDependencyKind(filePath));
1151
+ }
1152
+ }
1153
+ addExistingModuleFiles(graph, "app");
1154
+ for (const item of getAppConfigInfo().tabBar?.list || []) {
1155
+ for (const field of ["iconPath", "selectedIconPath"]) {
1156
+ if (!item[field]) continue;
1157
+ const assetPath = resolveAssetSourcePath(getWorkPath(), "", item[field]);
1158
+ if (fs_default.existsSync(assetPath)) {
1159
+ graph.addFile("app", assetPath, "config");
1160
+ }
1161
+ }
1162
+ }
1163
+ for (const component of Object.values(configInfo.componentInfo || {})) {
1164
+ graph.addNode(component.path, { type: "component" });
1165
+ addExistingModuleFiles(graph, component.path);
1166
+ }
1167
+ for (const component of Object.values(configInfo.componentInfo || {})) {
1168
+ for (const dependencyPath of Object.values(component.usingComponents || {})) {
1169
+ graph.addDependency(component.path, dependencyPath, "component");
1170
+ }
1171
+ }
1172
+ const pages = getPages();
1173
+ const addEntry = (page, packageRoot) => {
1174
+ graph.addNode(page.path, {
1175
+ type: "page",
1176
+ entry: true,
1177
+ packageRoot
1178
+ });
1179
+ addExistingModuleFiles(graph, page.path);
1180
+ graph.addDependency(page.path, "app", "app");
1181
+ for (const dependencyPath of Object.values(page.usingComponents || {})) {
1182
+ graph.addDependency(page.path, dependencyPath, "component");
1183
+ }
1184
+ };
1185
+ for (const page of pages.mainPages) {
1186
+ addEntry(page, null);
1187
+ }
1188
+ for (const [packageRoot, subPackage] of Object.entries(pages.subPages)) {
1189
+ for (const page of subPackage.info) {
1190
+ addEntry(page, packageRoot);
1191
+ }
1192
+ }
1193
+ return graph;
1194
+ }
938
1195
  function collectSharedStyleScopeIds(usingComponents) {
939
1196
  const result = [];
940
1197
  const visited = /* @__PURE__ */ new Set();
@@ -972,6 +1229,7 @@ export {
972
1229
  toMiniProgramModuleId,
973
1230
  hasCompileInfo,
974
1231
  getAbsolutePath,
1232
+ resolveAssetSourcePath,
975
1233
  collectAssets,
976
1234
  transformRpx,
977
1235
  tagWhiteList,
@@ -980,9 +1238,11 @@ export {
980
1238
  storeInfo,
981
1239
  resetStoreInfo,
982
1240
  getTemplateExts,
1241
+ getTemplateDirectivePrefixes,
983
1242
  getStyleExts,
984
1243
  getViewScriptExts,
985
1244
  getViewScriptTags,
1245
+ getDependencyGraph,
986
1246
  getContentByPath,
987
1247
  resolveAppAlias,
988
1248
  getTargetPath,