@lowdefy/build 4.7.2 → 4.7.3

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.
@@ -0,0 +1,75 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ // Walk an object/array tree collecting non-enumerable ~r ref IDs.
16
+ // ~r is set by buildRefs (walker.js) on every resolved object/array
17
+ // and is non-enumerable, so Object.keys() won't find it.
18
+ function walkRefIds(obj, refIds) {
19
+ if (obj === null || typeof obj !== 'object') return;
20
+ if (obj['~r'] !== undefined) {
21
+ refIds.add(obj['~r']);
22
+ }
23
+ if (Array.isArray(obj)) {
24
+ for(let i = 0; i < obj.length; i++){
25
+ walkRefIds(obj[i], refIds);
26
+ }
27
+ } else {
28
+ for (const key of Object.keys(obj)){
29
+ walkRefIds(obj[key], refIds);
30
+ }
31
+ }
32
+ }
33
+ // Collect file paths that contribute to skeleton (non-page) config.
34
+ // Walks ~r markers on non-page components, traces each through the
35
+ // refMap parent chain, and scans for scalar-resolving descendants.
36
+ function collectSkeletonSourceFiles({ components, context }) {
37
+ const refIds = new Set();
38
+ for (const key of Object.keys(components)){
39
+ if (key === 'pages') continue;
40
+ walkRefIds(components[key], refIds);
41
+ }
42
+ const sourceFiles = new Set();
43
+ // Walk parent chains for each collected ref ID
44
+ for (const refId of refIds){
45
+ let current = refId;
46
+ while(current != null){
47
+ const entry = context.refMap[current];
48
+ if (!entry) break;
49
+ if (entry.path) {
50
+ sourceFiles.add(entry.path);
51
+ }
52
+ current = entry.parent;
53
+ }
54
+ }
55
+ // Scan for scalar-resolving descendants: refs that resolved to primitives
56
+ // have no ~r marker in the tree but are recorded in the refMap. Include
57
+ // their paths if any ancestor in their parent chain is a collected ref ID.
58
+ for (const [id, entry] of Object.entries(context.refMap)){
59
+ if (refIds.has(id)) continue;
60
+ let current = entry.parent;
61
+ while(current != null){
62
+ if (refIds.has(current)) {
63
+ if (entry.path) {
64
+ sourceFiles.add(entry.path);
65
+ }
66
+ break;
67
+ }
68
+ const parentEntry = context.refMap[current];
69
+ if (!parentEntry) break;
70
+ current = parentEntry.parent;
71
+ }
72
+ }
73
+ return sourceFiles;
74
+ }
75
+ export default collectSkeletonSourceFiles;
@@ -48,6 +48,7 @@ import writePluginImports from '../writePluginImports/writePluginImports.js';
48
48
  import addInstalledTypes from './addInstalledTypes.js';
49
49
  import buildJsShallow from './buildJsShallow.js';
50
50
  import buildShallowPages from './buildShallowPages.js';
51
+ import collectSkeletonSourceFiles from './collectSkeletonSourceFiles.js';
51
52
  import writeSourcelessPages from './writeSourcelessPages.js';
52
53
  async function shallowBuild(options) {
53
54
  makeId.reset();
@@ -67,6 +68,11 @@ async function shallowBuild(options) {
67
68
  }
68
69
  throw err;
69
70
  }
71
+ // Collect skeleton source files while ~r markers still exist on objects.
72
+ const skeletonSourceFiles = collectSkeletonSourceFiles({
73
+ components,
74
+ context
75
+ });
70
76
  // addKeys + testSchema first for error location info
71
77
  tryBuildStep(addKeys, 'addKeys', {
72
78
  components,
@@ -188,7 +194,10 @@ async function shallowBuild(options) {
188
194
  });
189
195
  await context.writeBuildArtifact('connectionIds.json', JSON.stringify([
190
196
  ...context.connectionIds
191
- ]));
197
+ ].sort()));
198
+ await context.writeBuildArtifact('skeletonSourceFiles.json', JSON.stringify([
199
+ ...skeletonSourceFiles
200
+ ].sort()));
192
201
  await writeMenus({
193
202
  components,
194
203
  context