@symbo.ls/sdk 2.34.35 → 3.1.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.
- package/README.md +2 -143
- package/dist/cjs/config/environment.js +30 -98
- package/dist/cjs/index.js +24 -144
- package/dist/cjs/services/AIService.js +155 -0
- package/dist/cjs/services/AuthService.js +305 -738
- package/dist/cjs/services/BaseService.js +6 -158
- package/dist/cjs/services/BasedService.js +1185 -0
- package/dist/cjs/services/CoreService.js +1751 -0
- package/dist/cjs/services/SocketIOService.js +307 -0
- package/dist/cjs/services/SocketService.js +161 -0
- package/dist/cjs/services/SymstoryService.js +571 -0
- package/dist/cjs/services/index.js +16 -64
- package/dist/cjs/utils/TokenManager.js +30 -78
- package/dist/cjs/utils/basedQuerys.js +181 -0
- package/dist/cjs/utils/services.js +103 -301
- package/dist/cjs/utils/symstoryClient.js +259 -0
- package/dist/cjs/utils/validation.js +3 -0
- package/dist/esm/config/environment.js +30 -98
- package/dist/esm/index.js +8797 -49416
- package/dist/esm/services/AIService.js +185 -0
- package/dist/esm/services/AuthService.js +386 -1493
- package/dist/esm/services/BaseService.js +6 -757
- package/dist/esm/services/BasedService.js +5278 -0
- package/dist/esm/services/CoreService.js +2264 -0
- package/dist/esm/services/SocketIOService.js +470 -0
- package/dist/esm/services/SocketService.js +191 -0
- package/dist/esm/services/SymstoryService.js +7041 -0
- package/dist/esm/services/index.js +8690 -49015
- package/dist/esm/utils/TokenManager.js +30 -78
- package/dist/esm/utils/basedQuerys.js +163 -0
- package/dist/esm/utils/services.js +103 -301
- package/dist/esm/utils/symstoryClient.js +370 -0
- package/dist/esm/utils/validation.js +7 -4
- package/dist/node/config/environment.js +30 -98
- package/dist/node/index.js +32 -175
- package/dist/node/services/AIService.js +136 -0
- package/dist/node/services/AuthService.js +310 -742
- package/dist/node/services/BaseService.js +6 -148
- package/dist/node/services/BasedService.js +1156 -0
- package/dist/node/services/CoreService.js +1722 -0
- package/dist/node/services/SocketIOService.js +278 -0
- package/dist/node/services/SocketService.js +142 -0
- package/dist/node/services/SymstoryService.js +542 -0
- package/dist/node/services/index.js +16 -64
- package/dist/node/utils/TokenManager.js +30 -78
- package/dist/node/utils/basedQuerys.js +162 -0
- package/dist/node/utils/services.js +103 -301
- package/dist/node/utils/symstoryClient.js +230 -0
- package/dist/node/utils/validation.js +3 -0
- package/package.json +16 -35
- package/src/config/environment.js +28 -99
- package/src/index.js +36 -181
- package/src/services/AIService.js +150 -0
- package/src/services/AuthService.js +328 -874
- package/src/services/BaseService.js +6 -166
- package/src/services/BasedService.js +1301 -0
- package/src/services/CoreService.js +1943 -0
- package/src/services/SocketIOService.js +334 -0
- package/src/services/SocketService.js +168 -0
- package/src/services/SymstoryService.js +649 -0
- package/src/services/index.js +13 -80
- package/src/utils/TokenManager.js +33 -88
- package/src/utils/basedQuerys.js +164 -0
- package/src/utils/services.js +107 -326
- package/src/utils/symstoryClient.js +252 -0
- package/src/utils/validation.js +3 -0
- package/dist/cjs/services/AdminService.js +0 -351
- package/dist/cjs/services/BranchService.js +0 -484
- package/dist/cjs/services/CollabService.js +0 -743
- package/dist/cjs/services/DnsService.js +0 -340
- package/dist/cjs/services/FeatureFlagService.js +0 -175
- package/dist/cjs/services/FileService.js +0 -201
- package/dist/cjs/services/IntegrationService.js +0 -538
- package/dist/cjs/services/MetricsService.js +0 -62
- package/dist/cjs/services/PaymentService.js +0 -271
- package/dist/cjs/services/PlanService.js +0 -426
- package/dist/cjs/services/ProjectService.js +0 -1207
- package/dist/cjs/services/PullRequestService.js +0 -503
- package/dist/cjs/services/ScreenshotService.js +0 -304
- package/dist/cjs/services/SubscriptionService.js +0 -396
- package/dist/cjs/services/TrackingService.js +0 -661
- package/dist/cjs/services/WaitlistService.js +0 -148
- package/dist/cjs/state/RootStateManager.js +0 -65
- package/dist/cjs/state/rootEventBus.js +0 -74
- package/dist/cjs/utils/CollabClient.js +0 -223
- package/dist/cjs/utils/changePreprocessor.js +0 -199
- package/dist/cjs/utils/jsonDiff.js +0 -145
- package/dist/cjs/utils/ordering.js +0 -309
- package/dist/esm/services/AdminService.js +0 -1132
- package/dist/esm/services/BranchService.js +0 -1265
- package/dist/esm/services/CollabService.js +0 -26838
- package/dist/esm/services/DnsService.js +0 -1121
- package/dist/esm/services/FeatureFlagService.js +0 -956
- package/dist/esm/services/FileService.js +0 -982
- package/dist/esm/services/IntegrationService.js +0 -1319
- package/dist/esm/services/MetricsService.js +0 -843
- package/dist/esm/services/PaymentService.js +0 -1052
- package/dist/esm/services/PlanService.js +0 -1207
- package/dist/esm/services/ProjectService.js +0 -2526
- package/dist/esm/services/PullRequestService.js +0 -1284
- package/dist/esm/services/ScreenshotService.js +0 -1085
- package/dist/esm/services/SubscriptionService.js +0 -1177
- package/dist/esm/services/TrackingService.js +0 -18343
- package/dist/esm/services/WaitlistService.js +0 -929
- package/dist/esm/state/RootStateManager.js +0 -90
- package/dist/esm/state/rootEventBus.js +0 -56
- package/dist/esm/utils/CollabClient.js +0 -18901
- package/dist/esm/utils/changePreprocessor.js +0 -542
- package/dist/esm/utils/jsonDiff.js +0 -7011
- package/dist/esm/utils/ordering.js +0 -291
- package/dist/node/services/AdminService.js +0 -332
- package/dist/node/services/BranchService.js +0 -465
- package/dist/node/services/CollabService.js +0 -724
- package/dist/node/services/DnsService.js +0 -321
- package/dist/node/services/FeatureFlagService.js +0 -156
- package/dist/node/services/FileService.js +0 -182
- package/dist/node/services/IntegrationService.js +0 -519
- package/dist/node/services/MetricsService.js +0 -43
- package/dist/node/services/PaymentService.js +0 -252
- package/dist/node/services/PlanService.js +0 -407
- package/dist/node/services/ProjectService.js +0 -1188
- package/dist/node/services/PullRequestService.js +0 -484
- package/dist/node/services/ScreenshotService.js +0 -285
- package/dist/node/services/SubscriptionService.js +0 -377
- package/dist/node/services/TrackingService.js +0 -632
- package/dist/node/services/WaitlistService.js +0 -129
- package/dist/node/state/RootStateManager.js +0 -36
- package/dist/node/state/rootEventBus.js +0 -55
- package/dist/node/utils/CollabClient.js +0 -194
- package/dist/node/utils/changePreprocessor.js +0 -180
- package/dist/node/utils/jsonDiff.js +0 -116
- package/dist/node/utils/ordering.js +0 -290
- package/src/services/AdminService.js +0 -374
- package/src/services/BranchService.js +0 -536
- package/src/services/CollabService.js +0 -900
- package/src/services/DnsService.js +0 -366
- package/src/services/FeatureFlagService.js +0 -174
- package/src/services/FileService.js +0 -213
- package/src/services/IntegrationService.js +0 -548
- package/src/services/MetricsService.js +0 -40
- package/src/services/PaymentService.js +0 -287
- package/src/services/PlanService.js +0 -468
- package/src/services/ProjectService.js +0 -1366
- package/src/services/PullRequestService.js +0 -537
- package/src/services/ScreenshotService.js +0 -258
- package/src/services/SubscriptionService.js +0 -425
- package/src/services/TrackingService.js +0 -853
- package/src/services/WaitlistService.js +0 -130
- package/src/services/tests/BranchService/createBranch.test.js +0 -153
- package/src/services/tests/BranchService/deleteBranch.test.js +0 -173
- package/src/services/tests/BranchService/getBranchChanges.test.js +0 -146
- package/src/services/tests/BranchService/listBranches.test.js +0 -87
- package/src/services/tests/BranchService/mergeBranch.test.js +0 -210
- package/src/services/tests/BranchService/publishVersion.test.js +0 -183
- package/src/services/tests/BranchService/renameBranch.test.js +0 -240
- package/src/services/tests/BranchService/resetBranch.test.js +0 -152
- package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +0 -67
- package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +0 -75
- package/src/services/tests/FileService/createFileFormData.test.js +0 -74
- package/src/services/tests/FileService/getFileUrl.test.js +0 -69
- package/src/services/tests/FileService/updateProjectIcon.test.js +0 -109
- package/src/services/tests/FileService/uploadDocument.test.js +0 -36
- package/src/services/tests/FileService/uploadFile.test.js +0 -78
- package/src/services/tests/FileService/uploadFileWithValidation.test.js +0 -114
- package/src/services/tests/FileService/uploadImage.test.js +0 -36
- package/src/services/tests/FileService/uploadMultipleFiles.test.js +0 -111
- package/src/services/tests/FileService/validateFile.test.js +0 -63
- package/src/services/tests/PlanService/createPlan.test.js +0 -104
- package/src/services/tests/PlanService/createPlanWithValidation.test.js +0 -523
- package/src/services/tests/PlanService/deletePlan.test.js +0 -92
- package/src/services/tests/PlanService/getActivePlans.test.js +0 -123
- package/src/services/tests/PlanService/getAdminPlans.test.js +0 -84
- package/src/services/tests/PlanService/getPlan.test.js +0 -50
- package/src/services/tests/PlanService/getPlanByKey.test.js +0 -109
- package/src/services/tests/PlanService/getPlanWithValidation.test.js +0 -85
- package/src/services/tests/PlanService/getPlans.test.js +0 -53
- package/src/services/tests/PlanService/getPlansByPriceRange.test.js +0 -109
- package/src/services/tests/PlanService/getPlansWithValidation.test.js +0 -48
- package/src/services/tests/PlanService/initializePlans.test.js +0 -75
- package/src/services/tests/PlanService/updatePlan.test.js +0 -111
- package/src/services/tests/PlanService/updatePlanWithValidation.test.js +0 -556
- package/src/state/RootStateManager.js +0 -76
- package/src/state/rootEventBus.js +0 -67
- package/src/utils/CollabClient.js +0 -248
- package/src/utils/changePreprocessor.js +0 -239
- package/src/utils/jsonDiff.js +0 -144
- package/src/utils/ordering.js +0 -271
|
@@ -1,542 +0,0 @@
|
|
|
1
|
-
// src/utils/jsonDiff.js
|
|
2
|
-
function isPlainObject(o) {
|
|
3
|
-
return o && typeof o === "object" && !Array.isArray(o);
|
|
4
|
-
}
|
|
5
|
-
function deepEqual(a, b) {
|
|
6
|
-
if (Object.is(a, b)) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
if (typeof a === "function" && typeof b === "function") {
|
|
10
|
-
try {
|
|
11
|
-
return a.toString() === b.toString();
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (typeof a === "function" || typeof b === "function") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
if (a instanceof Date && b instanceof Date) {
|
|
20
|
-
return a.getTime() === b.getTime();
|
|
21
|
-
}
|
|
22
|
-
if (a instanceof RegExp && b instanceof RegExp) {
|
|
23
|
-
return String(a) === String(b);
|
|
24
|
-
}
|
|
25
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
26
|
-
if (a.length !== b.length) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
for (let i = 0; i < a.length; i++) {
|
|
30
|
-
if (!deepEqual(a[i], b[i])) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
37
|
-
const aKeys = Object.keys(a);
|
|
38
|
-
const bKeys = Object.keys(b);
|
|
39
|
-
if (aKeys.length !== bKeys.length) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
for (let i = 0; i < aKeys.length; i++) {
|
|
43
|
-
const key = aKeys[i];
|
|
44
|
-
if (!Object.hasOwn(b, key)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
if (!deepEqual(a[key], b[key])) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
function diffJson(prev, next, prefix = []) {
|
|
56
|
-
const ops = [];
|
|
57
|
-
const _prefix = Array.isArray(prefix) ? prefix : [];
|
|
58
|
-
for (const key in prev) {
|
|
59
|
-
if (Object.hasOwn(prev, key) && !(key in next)) {
|
|
60
|
-
ops.push({ action: "del", path: [..._prefix, key] });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
for (const key in next) {
|
|
64
|
-
if (Object.hasOwn(next, key)) {
|
|
65
|
-
const pVal = prev == null ? void 0 : prev[key];
|
|
66
|
-
const nVal = next[key];
|
|
67
|
-
if (isPlainObject(pVal) && isPlainObject(nVal)) {
|
|
68
|
-
ops.push(...diffJson(pVal, nVal, [..._prefix, key]));
|
|
69
|
-
} else if (!deepEqual(pVal, nVal)) {
|
|
70
|
-
ops.push({ action: "set", path: [..._prefix, key], value: nVal });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return ops;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// src/utils/ordering.js
|
|
78
|
-
function isObjectLike(val) {
|
|
79
|
-
return val && typeof val === "object" && !Array.isArray(val);
|
|
80
|
-
}
|
|
81
|
-
function normalizePath(path) {
|
|
82
|
-
if (Array.isArray(path)) {
|
|
83
|
-
return path;
|
|
84
|
-
}
|
|
85
|
-
if (typeof path === "string") {
|
|
86
|
-
return [path];
|
|
87
|
-
}
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
function getParentPathsFromTuples(tuples = []) {
|
|
91
|
-
const seen = /* @__PURE__ */ new Set();
|
|
92
|
-
const parents = [];
|
|
93
|
-
const META_KEYS = /* @__PURE__ */ new Set([
|
|
94
|
-
"style",
|
|
95
|
-
"class",
|
|
96
|
-
"text",
|
|
97
|
-
"html",
|
|
98
|
-
"content",
|
|
99
|
-
"data",
|
|
100
|
-
"attr",
|
|
101
|
-
"state",
|
|
102
|
-
"scope",
|
|
103
|
-
"define",
|
|
104
|
-
"on",
|
|
105
|
-
"extend",
|
|
106
|
-
"extends",
|
|
107
|
-
"childExtend",
|
|
108
|
-
"childExtends",
|
|
109
|
-
"children",
|
|
110
|
-
"component",
|
|
111
|
-
"context",
|
|
112
|
-
"tag",
|
|
113
|
-
"key",
|
|
114
|
-
"__order",
|
|
115
|
-
"if"
|
|
116
|
-
]);
|
|
117
|
-
for (let i = 0; i < tuples.length; i++) {
|
|
118
|
-
const tuple = tuples[i];
|
|
119
|
-
if (!Array.isArray(tuple) || tuple.length < 2) {
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
const path = normalizePath(tuple[1]);
|
|
123
|
-
if (!path.length) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (path[0] === "schema") {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const immediateParent = path.slice(0, -1);
|
|
130
|
-
if (immediateParent.length) {
|
|
131
|
-
const key = JSON.stringify(immediateParent);
|
|
132
|
-
if (!seen.has(key)) {
|
|
133
|
-
seen.add(key);
|
|
134
|
-
parents.push(immediateParent);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const last = path[path.length - 1];
|
|
138
|
-
if (META_KEYS.has(last) && path.length >= 2) {
|
|
139
|
-
const containerParent = path.slice(0, -2);
|
|
140
|
-
if (containerParent.length) {
|
|
141
|
-
const key2 = JSON.stringify(containerParent);
|
|
142
|
-
if (!seen.has(key2)) {
|
|
143
|
-
seen.add(key2);
|
|
144
|
-
parents.push(containerParent);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
for (let j = 0; j < path.length; j++) {
|
|
149
|
-
const seg = path[j];
|
|
150
|
-
if (!META_KEYS.has(seg)) {
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const containerParent2 = path.slice(0, j);
|
|
154
|
-
if (!containerParent2.length) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
const key3 = JSON.stringify(containerParent2);
|
|
158
|
-
if (!seen.has(key3)) {
|
|
159
|
-
seen.add(key3);
|
|
160
|
-
parents.push(containerParent2);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return parents;
|
|
165
|
-
}
|
|
166
|
-
function computeOrdersFromState(root, parentPaths = []) {
|
|
167
|
-
if (!root || typeof root.getByPath !== "function") {
|
|
168
|
-
return [];
|
|
169
|
-
}
|
|
170
|
-
const orders = [];
|
|
171
|
-
const EXCLUDE_KEYS = /* @__PURE__ */ new Set(["__order"]);
|
|
172
|
-
for (let i = 0; i < parentPaths.length; i++) {
|
|
173
|
-
const parentPath = parentPaths[i];
|
|
174
|
-
const obj = (() => {
|
|
175
|
-
try {
|
|
176
|
-
return root.getByPath(parentPath);
|
|
177
|
-
} catch {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
})();
|
|
181
|
-
if (!isObjectLike(obj)) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const keys = Object.keys(obj).filter((k) => !EXCLUDE_KEYS.has(k));
|
|
185
|
-
orders.push({ path: parentPath, keys });
|
|
186
|
-
}
|
|
187
|
-
return orders;
|
|
188
|
-
}
|
|
189
|
-
function normaliseSchemaCode(code) {
|
|
190
|
-
if (typeof code !== "string" || !code.length) {
|
|
191
|
-
return "";
|
|
192
|
-
}
|
|
193
|
-
return code.replaceAll("/////n", "\n").replaceAll("/////tilde", "`");
|
|
194
|
-
}
|
|
195
|
-
function parseExportedObject(code) {
|
|
196
|
-
const src = normaliseSchemaCode(code);
|
|
197
|
-
if (!src) {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
const body = src.replace(/^\s*export\s+default\s*/u, "return ");
|
|
201
|
-
try {
|
|
202
|
-
return new Function(body)();
|
|
203
|
-
} catch {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function extractTopLevelKeysFromCode(code) {
|
|
208
|
-
const obj = parseExportedObject(code);
|
|
209
|
-
if (!obj || typeof obj !== "object") {
|
|
210
|
-
return [];
|
|
211
|
-
}
|
|
212
|
-
return Object.keys(obj);
|
|
213
|
-
}
|
|
214
|
-
function computeOrdersForTuples(root, tuples = []) {
|
|
215
|
-
const pendingChildrenByContainer = /* @__PURE__ */ new Map();
|
|
216
|
-
for (let i = 0; i < tuples.length; i++) {
|
|
217
|
-
const t = tuples[i];
|
|
218
|
-
if (!Array.isArray(t)) {
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
const [action, path] = t;
|
|
222
|
-
const p = normalizePath(path);
|
|
223
|
-
if (!Array.isArray(p) || p.length < 2) {
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (p[0] === "schema") {
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
const containerPath = p.slice(0, -1);
|
|
230
|
-
const childKey = p[p.length - 1];
|
|
231
|
-
const key = JSON.stringify(containerPath);
|
|
232
|
-
if (!pendingChildrenByContainer.has(key)) {
|
|
233
|
-
pendingChildrenByContainer.set(key, /* @__PURE__ */ new Set());
|
|
234
|
-
}
|
|
235
|
-
if (action === "update" || action === "set") {
|
|
236
|
-
pendingChildrenByContainer.get(key).add(childKey);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
const preferredOrderMap = /* @__PURE__ */ new Map();
|
|
240
|
-
for (let i = 0; i < tuples.length; i++) {
|
|
241
|
-
const t = tuples[i];
|
|
242
|
-
if (!Array.isArray(t)) {
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
const [action, path, value] = t;
|
|
246
|
-
const p = normalizePath(path);
|
|
247
|
-
if (action !== "update" || !Array.isArray(p) || p.length < 3) {
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
if (p[0] !== "schema") {
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
const [, type, key] = p;
|
|
254
|
-
const containerPath = [type, key];
|
|
255
|
-
const uses = value && Array.isArray(value.uses) ? value.uses : null;
|
|
256
|
-
const code = value && value.code;
|
|
257
|
-
const obj = (() => {
|
|
258
|
-
try {
|
|
259
|
-
return root && typeof root.getByPath === "function" ? root.getByPath(containerPath) : null;
|
|
260
|
-
} catch {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
})();
|
|
264
|
-
if (!obj) {
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
const present = new Set(Object.keys(obj));
|
|
268
|
-
const EXCLUDE_KEYS = /* @__PURE__ */ new Set(["__order"]);
|
|
269
|
-
const codeKeys = extractTopLevelKeysFromCode(code);
|
|
270
|
-
let resolved = [];
|
|
271
|
-
const pendingKey = JSON.stringify(containerPath);
|
|
272
|
-
const pendingChildren = pendingChildrenByContainer.get(pendingKey) || /* @__PURE__ */ new Set();
|
|
273
|
-
const eligible = /* @__PURE__ */ new Set([...present, ...pendingChildren]);
|
|
274
|
-
if (Array.isArray(codeKeys) && codeKeys.length) {
|
|
275
|
-
resolved = codeKeys.filter((k) => eligible.has(k) && !EXCLUDE_KEYS.has(k));
|
|
276
|
-
}
|
|
277
|
-
if (Array.isArray(uses) && uses.length) {
|
|
278
|
-
for (let u = 0; u < uses.length; u++) {
|
|
279
|
-
const keyName = uses[u];
|
|
280
|
-
if (eligible.has(keyName) && !EXCLUDE_KEYS.has(keyName) && !resolved.includes(keyName)) {
|
|
281
|
-
resolved.push(keyName);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if (pendingChildren.size) {
|
|
286
|
-
for (const child of pendingChildren) {
|
|
287
|
-
if (!EXCLUDE_KEYS.has(child) && !resolved.includes(child)) {
|
|
288
|
-
resolved.push(child);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
if (resolved.length) {
|
|
293
|
-
preferredOrderMap.set(JSON.stringify(containerPath), { path: containerPath, keys: resolved });
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
const parents = getParentPathsFromTuples(tuples);
|
|
297
|
-
const orders = [];
|
|
298
|
-
const seen = /* @__PURE__ */ new Set();
|
|
299
|
-
preferredOrderMap.forEach((v) => {
|
|
300
|
-
const k = JSON.stringify(v.path);
|
|
301
|
-
if (!seen.has(k)) {
|
|
302
|
-
seen.add(k);
|
|
303
|
-
orders.push(v);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
const fallbackOrders = computeOrdersFromState(root, parents);
|
|
307
|
-
for (let i = 0; i < fallbackOrders.length; i++) {
|
|
308
|
-
const v = fallbackOrders[i];
|
|
309
|
-
const k = JSON.stringify(v.path);
|
|
310
|
-
if (seen.has(k)) {
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
const pending = pendingChildrenByContainer.get(k);
|
|
314
|
-
if (pending && pending.size) {
|
|
315
|
-
const existingKeys = v.keys;
|
|
316
|
-
const existingSet = new Set(existingKeys);
|
|
317
|
-
const META_KEYS = /* @__PURE__ */ new Set([
|
|
318
|
-
"style",
|
|
319
|
-
"class",
|
|
320
|
-
"text",
|
|
321
|
-
"html",
|
|
322
|
-
"content",
|
|
323
|
-
"data",
|
|
324
|
-
"attr",
|
|
325
|
-
"state",
|
|
326
|
-
"scope",
|
|
327
|
-
"define",
|
|
328
|
-
"on",
|
|
329
|
-
"extend",
|
|
330
|
-
"extends",
|
|
331
|
-
"childExtend",
|
|
332
|
-
"childExtends",
|
|
333
|
-
"children",
|
|
334
|
-
"component",
|
|
335
|
-
"context",
|
|
336
|
-
"tag",
|
|
337
|
-
"key",
|
|
338
|
-
"__order",
|
|
339
|
-
"if"
|
|
340
|
-
]);
|
|
341
|
-
let firstMetaIndex = existingKeys.length;
|
|
342
|
-
for (let j = 0; j < existingKeys.length; j++) {
|
|
343
|
-
if (META_KEYS.has(existingKeys[j])) {
|
|
344
|
-
firstMetaIndex = j;
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
for (const child of pending) {
|
|
349
|
-
if (existingSet.has(child)) {
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
const insertIndex = firstMetaIndex;
|
|
353
|
-
existingKeys.splice(insertIndex, 0, child);
|
|
354
|
-
existingSet.add(child);
|
|
355
|
-
firstMetaIndex++;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
seen.add(k);
|
|
359
|
-
orders.push(v);
|
|
360
|
-
}
|
|
361
|
-
return orders;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// src/utils/changePreprocessor.js
|
|
365
|
-
function isPlainObject2(val) {
|
|
366
|
-
return val && typeof val === "object" && !Array.isArray(val);
|
|
367
|
-
}
|
|
368
|
-
function getByPathSafe(root, path) {
|
|
369
|
-
if (!root || typeof root.getByPath !== "function") {
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
try {
|
|
373
|
-
return root.getByPath(path);
|
|
374
|
-
} catch {
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
function resolveNextValueFromTuples(tuples, path) {
|
|
379
|
-
if (!Array.isArray(tuples) || !Array.isArray(path)) {
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
for (let i = tuples.length - 1; i >= 0; i--) {
|
|
383
|
-
const t = tuples[i];
|
|
384
|
-
if (!Array.isArray(t) || t.length < 3) {
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
const [action, tuplePath, tupleValue] = t;
|
|
388
|
-
if (action !== "update" && action !== "set" || !Array.isArray(tuplePath)) {
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
if (tuplePath.length > path.length) {
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
let isPrefix = true;
|
|
395
|
-
for (let j = 0; j < tuplePath.length; j++) {
|
|
396
|
-
if (tuplePath[j] !== path[j]) {
|
|
397
|
-
isPrefix = false;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
if (!isPrefix) {
|
|
402
|
-
continue;
|
|
403
|
-
}
|
|
404
|
-
if (tuplePath.length === path.length) {
|
|
405
|
-
return tupleValue;
|
|
406
|
-
}
|
|
407
|
-
let current = tupleValue;
|
|
408
|
-
for (let j = tuplePath.length; j < path.length; j++) {
|
|
409
|
-
if (current == null) {
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
current = current[path[j]];
|
|
413
|
-
}
|
|
414
|
-
if (current !== null) {
|
|
415
|
-
return current;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return null;
|
|
419
|
-
}
|
|
420
|
-
function preprocessChanges(root, tuples = [], options = {}) {
|
|
421
|
-
const expandTuple = (t) => {
|
|
422
|
-
const [action, path, value] = t || [];
|
|
423
|
-
const isSchemaPath = Array.isArray(path) && path[0] === "schema";
|
|
424
|
-
const isFilesPath = Array.isArray(path) && path[0] === "files";
|
|
425
|
-
if (action === "delete") {
|
|
426
|
-
return [t];
|
|
427
|
-
}
|
|
428
|
-
const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject2(value);
|
|
429
|
-
if (!canConsiderExpansion || isFilesPath || value && value.type === "files") {
|
|
430
|
-
return [t];
|
|
431
|
-
}
|
|
432
|
-
const prevRaw = getByPathSafe(root, path);
|
|
433
|
-
const isCreatePath = Array.isArray(path) && action === "update" && // e.g. ['update', ['components', 'NewKey'], {...}]
|
|
434
|
-
(!isSchemaPath && path.length === 2 || // e.g. ['update', ['schema', 'components', 'NewKey'], {...}]
|
|
435
|
-
isSchemaPath && path.length === 3) && (prevRaw === null || typeof prevRaw === "undefined");
|
|
436
|
-
if (isCreatePath) {
|
|
437
|
-
return [t];
|
|
438
|
-
}
|
|
439
|
-
const prev = prevRaw || {};
|
|
440
|
-
const next = value || {};
|
|
441
|
-
if (!isPlainObject2(prev) || !isPlainObject2(next)) {
|
|
442
|
-
return [t];
|
|
443
|
-
}
|
|
444
|
-
const ops = diffJson(prev, next, []);
|
|
445
|
-
if (!ops.length) {
|
|
446
|
-
return [t];
|
|
447
|
-
}
|
|
448
|
-
const out = [];
|
|
449
|
-
for (let i = 0; i < ops.length; i++) {
|
|
450
|
-
const op = ops[i];
|
|
451
|
-
const fullPath = [...path, ...op.path];
|
|
452
|
-
const last = fullPath[fullPath.length - 1];
|
|
453
|
-
if (op.action === "set") {
|
|
454
|
-
out.push(["update", fullPath, op.value]);
|
|
455
|
-
} else if (op.action === "del") {
|
|
456
|
-
if (last !== "__order") {
|
|
457
|
-
out.push(["delete", fullPath]);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return out;
|
|
462
|
-
};
|
|
463
|
-
const minimizeTuples = (input) => {
|
|
464
|
-
const out = [];
|
|
465
|
-
const seen2 = /* @__PURE__ */ new Set();
|
|
466
|
-
for (let i = 0; i < input.length; i++) {
|
|
467
|
-
const expanded = expandTuple(input[i]);
|
|
468
|
-
for (let k = 0; k < expanded.length; k++) {
|
|
469
|
-
const tuple = expanded[k];
|
|
470
|
-
const isDelete = Array.isArray(tuple) && tuple[0] === "delete";
|
|
471
|
-
const isOrderKey = isDelete && Array.isArray(tuple[1]) && tuple[1][tuple[1].length - 1] === "__order";
|
|
472
|
-
if (!isOrderKey) {
|
|
473
|
-
const key = JSON.stringify(tuple);
|
|
474
|
-
if (!seen2.has(key)) {
|
|
475
|
-
seen2.add(key);
|
|
476
|
-
out.push(tuple);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return out;
|
|
482
|
-
};
|
|
483
|
-
const granularChanges = (() => {
|
|
484
|
-
try {
|
|
485
|
-
const res = minimizeTuples(tuples);
|
|
486
|
-
if (options.append && options.append.length) {
|
|
487
|
-
res.push(...options.append);
|
|
488
|
-
}
|
|
489
|
-
return res;
|
|
490
|
-
} catch {
|
|
491
|
-
return Array.isArray(tuples) ? tuples.slice() : [];
|
|
492
|
-
}
|
|
493
|
-
})();
|
|
494
|
-
const hydratedGranularChanges = granularChanges.map((t) => {
|
|
495
|
-
if (!Array.isArray(t) || t.length < 3) {
|
|
496
|
-
return t;
|
|
497
|
-
}
|
|
498
|
-
const [action, path] = t;
|
|
499
|
-
if (action !== "update" && action !== "set" || !Array.isArray(path)) {
|
|
500
|
-
return t;
|
|
501
|
-
}
|
|
502
|
-
const nextValue = resolveNextValueFromTuples(tuples, path);
|
|
503
|
-
if (nextValue === null) {
|
|
504
|
-
return t;
|
|
505
|
-
}
|
|
506
|
-
return [action, path, nextValue];
|
|
507
|
-
});
|
|
508
|
-
const baseOrders = computeOrdersForTuples(root, hydratedGranularChanges);
|
|
509
|
-
const preferOrdersMap = /* @__PURE__ */ new Map();
|
|
510
|
-
for (let i = 0; i < tuples.length; i++) {
|
|
511
|
-
const t = tuples[i];
|
|
512
|
-
if (!Array.isArray(t) || t.length < 3) {
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
const [action, path, value] = t;
|
|
516
|
-
const isFilesPath = Array.isArray(path) && path[0] === "files";
|
|
517
|
-
if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject2(value) || isFilesPath || value && value.type === "files") {
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
const keys = Object.keys(value).filter((k) => k !== "__order");
|
|
521
|
-
const key = JSON.stringify(path);
|
|
522
|
-
preferOrdersMap.set(key, { path, keys });
|
|
523
|
-
}
|
|
524
|
-
const mergedOrders = [];
|
|
525
|
-
const seen = /* @__PURE__ */ new Set();
|
|
526
|
-
preferOrdersMap.forEach((v, k) => {
|
|
527
|
-
seen.add(k);
|
|
528
|
-
mergedOrders.push(v);
|
|
529
|
-
});
|
|
530
|
-
for (let i = 0; i < baseOrders.length; i++) {
|
|
531
|
-
const v = baseOrders[i];
|
|
532
|
-
const k = JSON.stringify(v.path);
|
|
533
|
-
if (!seen.has(k)) {
|
|
534
|
-
seen.add(k);
|
|
535
|
-
mergedOrders.push(v);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
return { granularChanges: hydratedGranularChanges, orders: mergedOrders };
|
|
539
|
-
}
|
|
540
|
-
export {
|
|
541
|
-
preprocessChanges
|
|
542
|
-
};
|