@symbo.ls/sdk 2.32.0 → 2.32.2

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 (82) hide show
  1. package/dist/cjs/config/environment.js +8 -43
  2. package/dist/cjs/index.js +4 -12
  3. package/dist/cjs/services/AdminService.js +4 -4
  4. package/dist/cjs/services/AuthService.js +149 -36
  5. package/dist/cjs/services/BaseService.js +18 -5
  6. package/dist/cjs/services/BranchService.js +10 -10
  7. package/dist/cjs/services/CollabService.js +18 -114
  8. package/dist/cjs/services/CoreService.js +19 -19
  9. package/dist/cjs/services/DnsService.js +4 -4
  10. package/dist/cjs/services/FileService.js +2 -2
  11. package/dist/cjs/services/PaymentService.js +2 -2
  12. package/dist/cjs/services/PlanService.js +12 -12
  13. package/dist/cjs/services/ProjectService.js +34 -39
  14. package/dist/cjs/services/PullRequestService.js +7 -7
  15. package/dist/cjs/services/SubscriptionService.js +14 -14
  16. package/dist/cjs/services/index.js +0 -4
  17. package/dist/cjs/utils/TokenManager.js +5 -16
  18. package/dist/cjs/utils/services.js +1 -14
  19. package/dist/esm/config/environment.js +8 -43
  20. package/dist/esm/index.js +300 -907
  21. package/dist/esm/services/AdminService.js +35 -68
  22. package/dist/esm/services/AuthService.js +168 -100
  23. package/dist/esm/services/BaseService.js +31 -64
  24. package/dist/esm/services/BranchService.js +41 -74
  25. package/dist/esm/services/CollabService.js +50 -452
  26. package/dist/esm/services/CoreService.js +50 -83
  27. package/dist/esm/services/DnsService.js +35 -68
  28. package/dist/esm/services/FileService.js +33 -66
  29. package/dist/esm/services/PaymentService.js +33 -66
  30. package/dist/esm/services/PlanService.js +43 -76
  31. package/dist/esm/services/ProjectService.js +65 -375
  32. package/dist/esm/services/PullRequestService.js +38 -71
  33. package/dist/esm/services/SubscriptionService.js +45 -78
  34. package/dist/esm/services/index.js +295 -884
  35. package/dist/esm/utils/CollabClient.js +8 -43
  36. package/dist/esm/utils/TokenManager.js +5 -16
  37. package/dist/esm/utils/services.js +1 -14
  38. package/dist/node/config/environment.js +8 -43
  39. package/dist/node/index.js +5 -14
  40. package/dist/node/services/AdminService.js +4 -4
  41. package/dist/node/services/AuthService.js +139 -36
  42. package/dist/node/services/BaseService.js +18 -5
  43. package/dist/node/services/BranchService.js +10 -10
  44. package/dist/node/services/CollabService.js +19 -115
  45. package/dist/node/services/CoreService.js +19 -19
  46. package/dist/node/services/DnsService.js +4 -4
  47. package/dist/node/services/FileService.js +2 -2
  48. package/dist/node/services/PaymentService.js +2 -2
  49. package/dist/node/services/PlanService.js +12 -12
  50. package/dist/node/services/ProjectService.js +34 -39
  51. package/dist/node/services/PullRequestService.js +7 -7
  52. package/dist/node/services/SubscriptionService.js +14 -14
  53. package/dist/node/services/index.js +0 -4
  54. package/dist/node/utils/TokenManager.js +5 -16
  55. package/dist/node/utils/services.js +1 -14
  56. package/package.json +6 -7
  57. package/src/config/environment.js +9 -48
  58. package/src/index.js +22 -38
  59. package/src/services/AdminService.js +4 -4
  60. package/src/services/AuthService.js +175 -42
  61. package/src/services/BaseService.js +24 -7
  62. package/src/services/BranchService.js +10 -10
  63. package/src/services/CollabService.js +19 -142
  64. package/src/services/CoreService.js +19 -19
  65. package/src/services/DnsService.js +4 -4
  66. package/src/services/FileService.js +2 -2
  67. package/src/services/PaymentService.js +2 -2
  68. package/src/services/PlanService.js +12 -12
  69. package/src/services/ProjectService.js +34 -41
  70. package/src/services/PullRequestService.js +7 -7
  71. package/src/services/SubscriptionService.js +14 -14
  72. package/src/services/index.js +1 -6
  73. package/src/utils/TokenManager.js +5 -19
  74. package/src/utils/services.js +1 -15
  75. package/dist/cjs/services/ScreenshotService.js +0 -304
  76. package/dist/cjs/utils/ordering.js +0 -295
  77. package/dist/esm/services/ScreenshotService.js +0 -992
  78. package/dist/esm/utils/ordering.js +0 -277
  79. package/dist/node/services/ScreenshotService.js +0 -285
  80. package/dist/node/utils/ordering.js +0 -276
  81. package/src/services/ScreenshotService.js +0 -258
  82. package/src/utils/ordering.js +0 -240
@@ -1,304 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var ScreenshotService_exports = {};
19
- __export(ScreenshotService_exports, {
20
- ScreenshotService: () => ScreenshotService,
21
- default: () => ScreenshotService_default
22
- });
23
- module.exports = __toCommonJS(ScreenshotService_exports);
24
- var import_BaseService = require("./BaseService.js");
25
- class ScreenshotService extends import_BaseService.BaseService {
26
- constructor(config) {
27
- super(config);
28
- this._debounceTimers = /* @__PURE__ */ new Map();
29
- this._inflightRefreshes = /* @__PURE__ */ new Map();
30
- }
31
- // ==================== PROJECT-LEVEL OPERATIONS ====================
32
- async createScreenshotProject(payload) {
33
- this._requireReady("createScreenshotProject");
34
- try {
35
- const response = await this._request("/screenshots/projects", {
36
- method: "POST",
37
- body: JSON.stringify(payload),
38
- methodName: "createScreenshotProject"
39
- });
40
- if (response.success) {
41
- return response;
42
- }
43
- throw new Error(response.message);
44
- } catch (error) {
45
- throw new Error(`Failed to create screenshot project: ${error.message}`, { cause: error });
46
- }
47
- }
48
- async getProjectScreenshots(projectKey, params = {}) {
49
- this._requireReady("getProjectScreenshots");
50
- if (!projectKey) {
51
- throw new Error("projectKey is required");
52
- }
53
- const { type = "all", status, limit = 50, offset = 0 } = params;
54
- const qs = new URLSearchParams();
55
- if (type) {
56
- qs.set("type", type);
57
- }
58
- if (status) {
59
- qs.set("status", status);
60
- }
61
- if (limit != null) {
62
- qs.set("limit", String(limit));
63
- }
64
- if (offset != null) {
65
- qs.set("offset", String(offset));
66
- }
67
- try {
68
- const response = await this._request(
69
- `/screenshots/projects/${encodeURIComponent(projectKey)}${qs.toString() ? `?${qs.toString()}` : ""}`,
70
- { method: "GET", methodName: "getProjectScreenshots" }
71
- );
72
- if (response.success) {
73
- return response;
74
- }
75
- throw new Error(response.message);
76
- } catch (error) {
77
- throw new Error(`Failed to get project screenshots: ${error.message}`, { cause: error });
78
- }
79
- }
80
- async reprocessProjectScreenshots(projectKey, body = {}) {
81
- this._requireReady("reprocessProjectScreenshots");
82
- if (!projectKey) {
83
- throw new Error("projectKey is required");
84
- }
85
- try {
86
- const response = await this._request(
87
- `/screenshots/projects/${encodeURIComponent(projectKey)}/reprocess`,
88
- { method: "POST", body: JSON.stringify(body), methodName: "reprocessProjectScreenshots" }
89
- );
90
- if (response.success) {
91
- return response;
92
- }
93
- throw new Error(response.message);
94
- } catch (error) {
95
- throw new Error(`Failed to reprocess screenshots: ${error.message}`, { cause: error });
96
- }
97
- }
98
- async recreateProjectScreenshots(projectKey, body = {}) {
99
- this._requireReady("recreateProjectScreenshots");
100
- if (!projectKey) {
101
- throw new Error("projectKey is required");
102
- }
103
- try {
104
- const response = await this._request(
105
- `/screenshots/projects/${encodeURIComponent(projectKey)}/recreate`,
106
- { method: "POST", body: JSON.stringify(body), methodName: "recreateProjectScreenshots" }
107
- );
108
- if (response.success) {
109
- return response;
110
- }
111
- throw new Error(response.message);
112
- } catch (error) {
113
- throw new Error(`Failed to recreate screenshots: ${error.message}`, { cause: error });
114
- }
115
- }
116
- async deleteProjectScreenshots(projectKey) {
117
- this._requireReady("deleteProjectScreenshots");
118
- if (!projectKey) {
119
- throw new Error("projectKey is required");
120
- }
121
- try {
122
- const response = await this._request(
123
- `/screenshots/projects/${encodeURIComponent(projectKey)}`,
124
- { method: "DELETE", methodName: "deleteProjectScreenshots" }
125
- );
126
- if (response.success) {
127
- return response;
128
- }
129
- throw new Error(response.message);
130
- } catch (error) {
131
- throw new Error(`Failed to delete project screenshots: ${error.message}`, { cause: error });
132
- }
133
- }
134
- // ==================== THUMBNAIL ====================
135
- async getThumbnailCandidate(projectKey, options = {}) {
136
- this._requireReady("getThumbnailCandidate");
137
- if (!projectKey) {
138
- throw new Error("projectKey is required");
139
- }
140
- const { includeData = false } = options;
141
- const qs = new URLSearchParams();
142
- if (includeData) {
143
- qs.set("include_data", "true");
144
- }
145
- try {
146
- const response = await this._request(
147
- `/screenshots/projects/${encodeURIComponent(projectKey)}/thumbnail/candidate${qs.toString() ? `?${qs.toString()}` : ""}`,
148
- { method: "GET", methodName: "getThumbnailCandidate" }
149
- );
150
- if (response.success) {
151
- return response;
152
- }
153
- throw new Error(response.message);
154
- } catch (error) {
155
- throw new Error(`Failed to get thumbnail candidate: ${error.message}`, { cause: error });
156
- }
157
- }
158
- async updateProjectThumbnail(projectKey, body = {}) {
159
- this._requireReady("updateProjectThumbnail");
160
- if (!projectKey) {
161
- throw new Error("projectKey is required");
162
- }
163
- try {
164
- const response = await this._request(
165
- `/screenshots/projects/${encodeURIComponent(projectKey)}/thumbnail`,
166
- { method: "POST", body: JSON.stringify(body), methodName: "updateProjectThumbnail" }
167
- );
168
- if (response.success) {
169
- return response;
170
- }
171
- throw new Error(response.message);
172
- } catch (error) {
173
- throw new Error(`Failed to update project thumbnail: ${error.message}`, { cause: error });
174
- }
175
- }
176
- // ==================== INDIVIDUAL SHOTS ====================
177
- async getPageScreenshot(screenshotId, format = "json") {
178
- this._requireReady("getPageScreenshot");
179
- if (!screenshotId) {
180
- throw new Error("screenshotId is required");
181
- }
182
- const qs = new URLSearchParams();
183
- if (format) {
184
- qs.set("format", format);
185
- }
186
- try {
187
- return await this._request(
188
- `/screenshots/pages/${encodeURIComponent(screenshotId)}${qs.toString() ? `?${qs.toString()}` : ""}`,
189
- { method: "GET", methodName: "getPageScreenshot" }
190
- );
191
- } catch (error) {
192
- throw new Error(`Failed to get page screenshot: ${error.message}`, { cause: error });
193
- }
194
- }
195
- async getComponentScreenshot(screenshotId, format = "json") {
196
- this._requireReady("getComponentScreenshot");
197
- if (!screenshotId) {
198
- throw new Error("screenshotId is required");
199
- }
200
- const qs = new URLSearchParams();
201
- if (format) {
202
- qs.set("format", format);
203
- }
204
- try {
205
- return await this._request(
206
- `/screenshots/components/${encodeURIComponent(screenshotId)}${qs.toString() ? `?${qs.toString()}` : ""}`,
207
- { method: "GET", methodName: "getComponentScreenshot" }
208
- );
209
- } catch (error) {
210
- throw new Error(`Failed to get component screenshot: ${error.message}`, { cause: error });
211
- }
212
- }
213
- async getScreenshotByKey(projectKey, type, key, format = "json") {
214
- this._requireReady("getScreenshotByKey");
215
- if (!projectKey) {
216
- throw new Error("projectKey is required");
217
- }
218
- if (!type || !["component", "page"].includes(String(type))) {
219
- throw new Error("type must be 'component' or 'page'");
220
- }
221
- if (!key) {
222
- throw new Error("key is required");
223
- }
224
- const qs = new URLSearchParams();
225
- if (format) {
226
- qs.set("format", format);
227
- }
228
- const sub = type === "component" ? "components" : "pages";
229
- try {
230
- return await this._request(
231
- `/screenshots/projects/${encodeURIComponent(projectKey)}/${sub}/${encodeURIComponent(key)}${qs.toString() ? `?${qs.toString()}` : ""}`,
232
- { method: "GET", methodName: "getScreenshotByKey" }
233
- );
234
- } catch (error) {
235
- throw new Error(`Failed to get screenshot by key: ${error.message}`, { cause: error });
236
- }
237
- }
238
- async getQueueStatistics() {
239
- this._requireReady("getQueueStatistics");
240
- try {
241
- const response = await this._request("/screenshots/queue/stats", {
242
- method: "GET",
243
- methodName: "getQueueStatistics"
244
- });
245
- if (response.success) {
246
- return response;
247
- }
248
- throw new Error(response.message);
249
- } catch (error) {
250
- throw new Error(`Failed to get queue statistics: ${error.message}`, { cause: error });
251
- }
252
- }
253
- // ==================== COMBINATION/DEBOUNCED ====================
254
- /**
255
- * Debounced thumbnail refresh that recreates screenshots and then updates thumbnail.
256
- * Subsequent calls within debounce window reset the timer.
257
- */
258
- async refreshThumbnail(projectKey, options = {}) {
259
- this._requireReady("refreshThumbnail");
260
- if (!projectKey) {
261
- throw new Error("projectKey is required");
262
- }
263
- const {
264
- debounceMs = 15e3,
265
- waitAfterRecreateMs = 2e4,
266
- recreate = {
267
- process_pages: true,
268
- process_components: true,
269
- process_descriptions: true,
270
- force: false,
271
- priority: 5
272
- },
273
- thumbnail = {
274
- strategy: "auto",
275
- force: true
276
- }
277
- } = options;
278
- const existingTimer = this._debounceTimers.get(projectKey);
279
- if (existingTimer) {
280
- clearTimeout(existingTimer);
281
- }
282
- const executionPromise = await new Promise((resolve) => {
283
- const timer = setTimeout(async () => {
284
- try {
285
- await this.recreateProjectScreenshots(projectKey, recreate);
286
- await new Promise((resolveDelay) => {
287
- setTimeout(resolveDelay, waitAfterRecreateMs);
288
- });
289
- const result = await this.updateProjectThumbnail(projectKey, thumbnail);
290
- resolve(result);
291
- } catch (e) {
292
- resolve({ success: false, error: (e == null ? void 0 : e.message) || String(e) });
293
- } finally {
294
- this._debounceTimers.delete(projectKey);
295
- this._inflightRefreshes.delete(projectKey);
296
- }
297
- }, debounceMs);
298
- this._debounceTimers.set(projectKey, timer);
299
- });
300
- this._inflightRefreshes.set(projectKey, executionPromise);
301
- return executionPromise;
302
- }
303
- }
304
- var ScreenshotService_default = ScreenshotService;
@@ -1,295 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var ordering_exports = {};
19
- __export(ordering_exports, {
20
- computeOrdersForTuples: () => computeOrdersForTuples,
21
- computeOrdersFromState: () => computeOrdersFromState,
22
- getParentPathsFromTuples: () => getParentPathsFromTuples
23
- });
24
- module.exports = __toCommonJS(ordering_exports);
25
- function isObjectLike(val) {
26
- return val && typeof val === "object" && !Array.isArray(val);
27
- }
28
- function normalizePath(path) {
29
- if (Array.isArray(path)) {
30
- return path;
31
- }
32
- if (typeof path === "string") {
33
- return [path];
34
- }
35
- return [];
36
- }
37
- function getParentPathsFromTuples(tuples = []) {
38
- const seen = /* @__PURE__ */ new Set();
39
- const parents = [];
40
- const META_KEYS = /* @__PURE__ */ new Set([
41
- "style",
42
- "class",
43
- "text",
44
- "html",
45
- "content",
46
- "data",
47
- "attr",
48
- "state",
49
- "scope",
50
- "props",
51
- "define",
52
- "on",
53
- "extend",
54
- "extends",
55
- "childExtend",
56
- "childExtends",
57
- "childProps",
58
- "children",
59
- "component",
60
- "context",
61
- "tag",
62
- "key",
63
- "__order",
64
- "if"
65
- ]);
66
- for (let i = 0; i < tuples.length; i++) {
67
- const tuple = tuples[i];
68
- if (!Array.isArray(tuple) || tuple.length < 2) {
69
- continue;
70
- }
71
- const path = normalizePath(tuple[1]);
72
- if (!path.length) {
73
- continue;
74
- }
75
- if (path[0] === "schema") {
76
- continue;
77
- }
78
- const immediateParent = path.slice(0, -1);
79
- if (immediateParent.length) {
80
- const key = JSON.stringify(immediateParent);
81
- if (!seen.has(key)) {
82
- seen.add(key);
83
- parents.push(immediateParent);
84
- }
85
- }
86
- const last = path[path.length - 1];
87
- if (META_KEYS.has(last) && path.length >= 2) {
88
- const containerParent = path.slice(0, -2);
89
- if (containerParent.length) {
90
- const key2 = JSON.stringify(containerParent);
91
- if (!seen.has(key2)) {
92
- seen.add(key2);
93
- parents.push(containerParent);
94
- }
95
- }
96
- }
97
- for (let j = 0; j < path.length; j++) {
98
- const seg = path[j];
99
- if (!META_KEYS.has(seg)) {
100
- continue;
101
- }
102
- const containerParent2 = path.slice(0, j);
103
- if (!containerParent2.length) {
104
- continue;
105
- }
106
- const key3 = JSON.stringify(containerParent2);
107
- if (!seen.has(key3)) {
108
- seen.add(key3);
109
- parents.push(containerParent2);
110
- }
111
- }
112
- }
113
- return parents;
114
- }
115
- function computeOrdersFromState(root, parentPaths = []) {
116
- if (!root || typeof root.getByPath !== "function") {
117
- return [];
118
- }
119
- const orders = [];
120
- const EXCLUDE_KEYS = /* @__PURE__ */ new Set(["__order"]);
121
- for (let i = 0; i < parentPaths.length; i++) {
122
- const parentPath = parentPaths[i];
123
- const obj = (() => {
124
- try {
125
- return root.getByPath(parentPath);
126
- } catch {
127
- return null;
128
- }
129
- })();
130
- if (!isObjectLike(obj)) {
131
- continue;
132
- }
133
- const keys = Object.keys(obj).filter((k) => !EXCLUDE_KEYS.has(k));
134
- orders.push({ path: parentPath, keys });
135
- }
136
- return orders;
137
- }
138
- function normaliseSchemaCode(code) {
139
- if (typeof code !== "string" || !code.length) {
140
- return "";
141
- }
142
- return code.replaceAll("/////n", "\n").replaceAll("/////tilde", "`");
143
- }
144
- function extractTopLevelKeysFromCode(code) {
145
- const src = normaliseSchemaCode(code);
146
- if (!src) {
147
- return [];
148
- }
149
- const idx = src.indexOf("export default");
150
- if (idx === -1) {
151
- return [];
152
- }
153
- let i = src.indexOf("{", idx);
154
- if (i === -1) {
155
- return [];
156
- }
157
- const keys = [];
158
- let depth = 0;
159
- let inStr = false;
160
- let strCh = "";
161
- let inEsc = false;
162
- for (; i < src.length; i++) {
163
- const ch = src[i];
164
- if (inStr) {
165
- if (inEsc) {
166
- inEsc = false;
167
- } else if (ch === "\\") {
168
- inEsc = true;
169
- } else if (ch === strCh) {
170
- inStr = false;
171
- strCh = "";
172
- }
173
- continue;
174
- }
175
- if (ch === '"' || ch === "'" || ch === "`") {
176
- inStr = true;
177
- strCh = ch;
178
- continue;
179
- }
180
- if (ch === "{") {
181
- depth++;
182
- continue;
183
- }
184
- if (ch === "}") {
185
- depth--;
186
- if (depth === 0) {
187
- break;
188
- }
189
- continue;
190
- }
191
- if (depth !== 1) {
192
- continue;
193
- }
194
- if (/[A-Za-z_$]/u.test(ch)) {
195
- let j = i;
196
- while (j < src.length && /[A-Za-z0-9_$]/u.test(src[j])) {
197
- j++;
198
- }
199
- let k = j;
200
- while (k < src.length && /\s/u.test(src[k])) {
201
- k++;
202
- }
203
- if (src[k] === ":") {
204
- const key = src.slice(i, j);
205
- keys.push(key);
206
- }
207
- i = j;
208
- continue;
209
- }
210
- }
211
- if (!keys.length) {
212
- const bodyStart = src.indexOf("{", idx);
213
- const bodyEnd = src.lastIndexOf("}");
214
- if (bodyStart === -1 || bodyEnd === -1 || bodyEnd <= bodyStart) {
215
- return Array.from(new Set(keys));
216
- }
217
- const body = src.slice(bodyStart + 1, bodyEnd);
218
- const re = /(?:[A-Za-z_$][A-Za-z0-9_$]*|"[^"]+"|'[^']+')\s*:/gu;
219
- for (const m of body.matchAll(re)) {
220
- const raw = m[0].split(":")[0].trim();
221
- const key = raw[0] === '"' || raw[0] === "'" ? raw.slice(1, -1) : raw;
222
- keys.push(key);
223
- }
224
- }
225
- return Array.from(new Set(keys));
226
- }
227
- function computeOrdersForTuples(root, tuples = []) {
228
- const preferredOrderMap = /* @__PURE__ */ new Map();
229
- for (let i = 0; i < tuples.length; i++) {
230
- const t = tuples[i];
231
- if (!Array.isArray(t)) {
232
- continue;
233
- }
234
- const [action, path, value] = t;
235
- const p = normalizePath(path);
236
- if (action !== "update" || !Array.isArray(p) || p.length < 3) {
237
- continue;
238
- }
239
- if (p[0] !== "schema") {
240
- continue;
241
- }
242
- const [, type, key] = p;
243
- const containerPath = [type, key];
244
- const uses = value && Array.isArray(value.uses) ? value.uses : null;
245
- const code = value && value.code;
246
- const obj = (() => {
247
- try {
248
- return root && typeof root.getByPath === "function" ? root.getByPath(containerPath) : null;
249
- } catch {
250
- return null;
251
- }
252
- })();
253
- if (!obj) {
254
- continue;
255
- }
256
- const present = new Set(Object.keys(obj));
257
- const EXCLUDE_KEYS = /* @__PURE__ */ new Set(["__order"]);
258
- const codeKeys = extractTopLevelKeysFromCode(code);
259
- let resolved = [];
260
- if (Array.isArray(codeKeys) && codeKeys.length) {
261
- resolved = codeKeys.filter((k) => present.has(k) && !EXCLUDE_KEYS.has(k));
262
- }
263
- if (resolved.length && Array.isArray(uses) && uses.length) {
264
- for (let u = 0; u < uses.length; u++) {
265
- const keyName = uses[u];
266
- if (present.has(keyName) && !EXCLUDE_KEYS.has(keyName) && !resolved.includes(keyName)) {
267
- resolved.push(keyName);
268
- }
269
- }
270
- }
271
- if (resolved.length) {
272
- preferredOrderMap.set(JSON.stringify(containerPath), { path: containerPath, keys: resolved });
273
- }
274
- }
275
- const parents = getParentPathsFromTuples(tuples);
276
- const orders = [];
277
- const seen = /* @__PURE__ */ new Set();
278
- preferredOrderMap.forEach((v) => {
279
- const k = JSON.stringify(v.path);
280
- if (!seen.has(k)) {
281
- seen.add(k);
282
- orders.push(v);
283
- }
284
- });
285
- const fallbackOrders = computeOrdersFromState(root, parents);
286
- for (let i = 0; i < fallbackOrders.length; i++) {
287
- const v = fallbackOrders[i];
288
- const k = JSON.stringify(v.path);
289
- if (!seen.has(k)) {
290
- seen.add(k);
291
- orders.push(v);
292
- }
293
- }
294
- return orders;
295
- }