@fragmentsx/client-core 0.1.4 → 0.2.0
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/dist/fragmentsClient.d.ts +26 -0
- package/dist/fragmentsClient.d.ts.map +1 -0
- package/dist/index.cjs.js +681 -740
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +681 -740
- package/dist/plugins/fetch/beacon.d.ts +4 -0
- package/dist/plugins/fetch/beacon.d.ts.map +1 -0
- package/dist/plugins/fetch/emptyFragment.d.ts +50 -0
- package/dist/plugins/fetch/emptyFragment.d.ts.map +1 -0
- package/dist/plugins/fetch/fetcher.d.ts +8 -0
- package/dist/plugins/fetch/fetcher.d.ts.map +1 -0
- package/dist/plugins/fetch/index.d.ts +30 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -0
- package/dist/plugins/fetch/queries/AreaListQuery.d.ts +43 -0
- package/dist/plugins/fetch/queries/AreaListQuery.d.ts.map +1 -0
- package/dist/plugins/fetch/queries/AreaQuery.d.ts +24 -0
- package/dist/plugins/fetch/queries/AreaQuery.d.ts.map +1 -0
- package/dist/plugins/fetch/queries/FragmentQuery.d.ts +31 -0
- package/dist/plugins/fetch/queries/FragmentQuery.d.ts.map +1 -0
- package/dist/plugins/fetch/queries/parts.d.ts +5 -0
- package/dist/plugins/fetch/queries/parts.d.ts.map +1 -0
- package/dist/plugins/fonts/index.d.ts +10 -0
- package/dist/plugins/fonts/index.d.ts.map +1 -0
- package/dist/plugins/fragments/index.d.ts +17 -0
- package/dist/plugins/fragments/index.d.ts.map +1 -0
- package/dist/plugins/lifecycle/globalManagerLifeCycle.d.ts +16 -0
- package/dist/plugins/lifecycle/globalManagerLifeCycle.d.ts.map +1 -0
- package/dist/plugins/load/index.d.ts +18 -0
- package/dist/plugins/load/index.d.ts.map +1 -0
- package/dist/plugins/metrics/globalMetrics.d.ts +11 -0
- package/dist/plugins/metrics/globalMetrics.d.ts.map +1 -0
- package/dist/plugins/metrics/index.d.ts +3 -0
- package/dist/plugins/metrics/index.d.ts.map +1 -0
- package/dist/plugins/metrics/queries/addClientMetric.d.ts +2 -0
- package/dist/plugins/metrics/queries/addClientMetric.d.ts.map +1 -0
- package/dist/plugins/metrics/trackAdPixel.d.ts +4 -0
- package/dist/plugins/metrics/trackAdPixel.d.ts.map +1 -0
- package/dist/plugins/scopes/index.d.ts +11 -0
- package/dist/plugins/scopes/index.d.ts.map +1 -0
- package/dist/plugins/ssr/index.d.ts +11 -0
- package/dist/plugins/ssr/index.d.ts.map +1 -0
- package/dist/plugins/styleSheet/fragment/index.d.ts +9 -0
- package/dist/plugins/styleSheet/fragment/index.d.ts.map +1 -0
- package/dist/plugins/styleSheet/global/index.d.ts +3 -0
- package/dist/plugins/styleSheet/global/index.d.ts.map +1 -0
- package/dist/plugins/styleSheet/index.d.ts +3 -0
- package/dist/plugins/styleSheet/index.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/autoInjector.d.ts +9 -0
- package/dist/plugins/styleSheet/utils/autoInjector.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/buildCssBlock.d.ts +6 -0
- package/dist/plugins/styleSheet/utils/buildCssBlock.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/compareRules.d.ts +3 -0
- package/dist/plugins/styleSheet/utils/compareRules.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/destroyStyle.d.ts +2 -0
- package/dist/plugins/styleSheet/utils/destroyStyle.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/findGroups.d.ts +11 -0
- package/dist/plugins/styleSheet/utils/findGroups.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/getAllChildren.d.ts +4 -0
- package/dist/plugins/styleSheet/utils/getAllChildren.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/injectStyle.d.ts +2 -0
- package/dist/plugins/styleSheet/utils/injectStyle.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/makeCss.d.ts +5 -0
- package/dist/plugins/styleSheet/utils/makeCss.d.ts.map +1 -0
- package/dist/plugins/styleSheet/utils/toCSS.d.ts +3 -0
- package/dist/plugins/styleSheet/utils/toCSS.d.ts.map +1 -0
- package/dist/plugins/styles/index.d.ts +3 -0
- package/dist/plugins/styles/index.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -4,619 +4,220 @@ var r = (e) => !e && e == null, y = (e) => !r(e), a = (e) => typeof e == "object
|
|
|
4
4
|
let o = null;
|
|
5
5
|
return s(n) && (o = (_a = n.split(":")) == null ? void 0 : _a[0]), t(n) && (o = n._type), o ? !e.includes(o) : false;
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!isObject$1(a2) || !isObject$1(b))
|
|
18
|
-
return false;
|
|
19
|
-
const keysA = Object.keys(a2);
|
|
20
|
-
const keysB = Object.keys(b);
|
|
21
|
-
if (keysA.length !== keysB.length)
|
|
22
|
-
return false;
|
|
23
|
-
for (const key of keysA) {
|
|
24
|
-
if (!keysB.includes(key))
|
|
25
|
-
return false;
|
|
26
|
-
const aValue = a2[key];
|
|
27
|
-
const bValue = b[key];
|
|
28
|
-
if (l(aValue) && l(bValue) && aValue !== bValue)
|
|
29
|
-
return false;
|
|
7
|
+
var D = (e) => s(e), re = (e) => i(e), se = (e) => t(e), T = (e) => a(e), ie = (e, r2) => {
|
|
8
|
+
if (e === r2) return true;
|
|
9
|
+
if (Array.isArray(e) && Array.isArray(r2)) return e.length === r2.length && e.every((c, o) => r2[o] === c);
|
|
10
|
+
if (!T(e) || !T(r2)) return false;
|
|
11
|
+
let f2 = Object.keys(e), p = Object.keys(r2);
|
|
12
|
+
if (f2.length !== p.length) return false;
|
|
13
|
+
for (let c of f2) {
|
|
14
|
+
if (!p.includes(c)) return false;
|
|
15
|
+
let o = e[c], E = r2[c];
|
|
16
|
+
if (l(o) && l(E) && o !== E) return false;
|
|
30
17
|
}
|
|
31
18
|
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!isObject$1(b) || !isObject$1(a2))
|
|
40
|
-
return a2 === b;
|
|
41
|
-
const keysA = Object.keys(a2);
|
|
42
|
-
const keysB = Object.keys(b);
|
|
43
|
-
if (keysA.length !== keysB.length)
|
|
44
|
-
return false;
|
|
45
|
-
for (const key of keysA) {
|
|
46
|
-
if (!keysB.includes(key))
|
|
47
|
-
return false;
|
|
48
|
-
if (!deepEqual(a2[key], b[key]))
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
19
|
+
}, z = (e, r2) => {
|
|
20
|
+
if (e === r2) return true;
|
|
21
|
+
if (Array.isArray(e) && Array.isArray(r2)) return e.length === r2.length && e.every((c, o) => z(c, r2[o]));
|
|
22
|
+
if (!T(r2) || !T(e)) return e === r2;
|
|
23
|
+
let f2 = Object.keys(e), p = Object.keys(r2);
|
|
24
|
+
if (f2.length !== p.length) return false;
|
|
25
|
+
for (let c of f2) if (!p.includes(c) || !z(e[c], r2[c])) return false;
|
|
51
26
|
return true;
|
|
52
27
|
};
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var isPartOfGraph = (entityKey, graphKey) => {
|
|
63
|
-
if (!entityKey || !graphKey)
|
|
64
|
-
return false;
|
|
65
|
-
if (typeof entityKey !== "string" || typeof graphKey !== "string")
|
|
66
|
-
return null;
|
|
67
|
-
const [entityType, entityId] = entityKey.split(":");
|
|
68
|
-
const [graphType, graphId] = graphKey.split(":");
|
|
69
|
-
if (entityType !== graphType)
|
|
70
|
-
return false;
|
|
71
|
-
return entityId.startsWith(graphId);
|
|
72
|
-
};
|
|
73
|
-
var getGraphLink = (input) => {
|
|
74
|
-
if (isLinkKey(input)) {
|
|
75
|
-
if (isPartialKey(input)) {
|
|
76
|
-
return input.split(".")[0];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return input;
|
|
80
|
-
};
|
|
81
|
-
var createCache = () => {
|
|
82
|
-
const listeners = /* @__PURE__ */ new Map();
|
|
83
|
-
const types2 = /* @__PURE__ */ new Map();
|
|
84
|
-
const links = /* @__PURE__ */ new Map();
|
|
85
|
-
const parentRefs = /* @__PURE__ */ new Map();
|
|
86
|
-
const childrenRefs = /* @__PURE__ */ new Map();
|
|
87
|
-
const refCount = /* @__PURE__ */ new Map();
|
|
88
|
-
const gbLinks = /* @__PURE__ */ new Set([]);
|
|
89
|
-
const addRefs = (targetKey, depKey) => {
|
|
28
|
+
var Q = (...e) => Array.from(new Set(e)), oe = (...e) => e.filter((r2, f2, p) => s(r2) ? p.indexOf(r2) === f2 : true);
|
|
29
|
+
var P = (e) => e && e.split(".").length > 1, X = (e, r2) => {
|
|
30
|
+
if (!e || !r2) return false;
|
|
31
|
+
if (typeof e != "string" || typeof r2 != "string") return null;
|
|
32
|
+
let [f2, p] = e.split(":"), [c, o] = r2.split(":");
|
|
33
|
+
return f2 !== c ? false : p.startsWith(o);
|
|
34
|
+
}, ae = (e) => D(e) && P(e) ? e.split(".")[0] : e;
|
|
35
|
+
var ce = () => {
|
|
36
|
+
let e = /* @__PURE__ */ new Map(), r2 = /* @__PURE__ */ new Map(), f2 = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set([]), V = (n, u2) => {
|
|
90
37
|
var _a;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
updateRefCountForLink(targetKey, ((_a = parentRefs.get(targetKey)) == null ? void 0 : _a.length) || 0);
|
|
94
|
-
};
|
|
95
|
-
const removeRefs = (targetKey, depKey) => {
|
|
38
|
+
p.set(n, Q(...p.get(n) || [], u2)), c.set(u2, Q(...c.get(u2) ?? [], n)), M(n, ((_a = p.get(n)) == null ? void 0 : _a.length) || 0);
|
|
39
|
+
}, x = (n, u2) => {
|
|
96
40
|
var _a;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
const getLinkedRefs = (key, stack = []) => {
|
|
108
|
-
const deps = parentRefs.get(key) || [];
|
|
109
|
-
stack.push(...deps);
|
|
110
|
-
const deepDeps = deps.map((ref) => getLinkedRefs(ref, stack)).flat();
|
|
111
|
-
stack.push(...deepDeps);
|
|
112
|
-
return Array.from(new Set(stack).values());
|
|
113
|
-
};
|
|
114
|
-
const invalidate = (key) => {
|
|
115
|
-
updateRefCountForLink(key, 0);
|
|
116
|
-
runGarbageCollector();
|
|
117
|
-
};
|
|
118
|
-
const readLink = (key) => {
|
|
119
|
-
if (key) {
|
|
120
|
-
return links.get(key);
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
123
|
-
};
|
|
124
|
-
const writeLink = (key, value, depKey) => {
|
|
41
|
+
p.set(u2, (p.get(u2) || []).filter((k) => k !== n)), c.set(n, (c.get(n) ?? []).filter((k) => k !== u2)), M(u2, ((_a = p.get(u2)) == null ? void 0 : _a.length) || 0);
|
|
42
|
+
}, I = (n, u2 = []) => {
|
|
43
|
+
let k = p.get(n) || [];
|
|
44
|
+
u2.push(...k);
|
|
45
|
+
let S = k.map((L) => I(L, u2)).flat();
|
|
46
|
+
return u2.push(...S), Array.from(new Set(u2).values());
|
|
47
|
+
}, A = (n) => {
|
|
48
|
+
M(n, 0), B();
|
|
49
|
+
}, Y = (n) => n ? f2.get(n) : null, w = (n, u2, k) => {
|
|
125
50
|
var _a;
|
|
126
|
-
if (typeof
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
const hasLink = (key) => {
|
|
142
|
-
if (key) {
|
|
143
|
-
return links.has(key);
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
147
|
-
const updateRefCountForLink = (link, count) => {
|
|
148
|
-
if (Array.isArray(link)) {
|
|
149
|
-
link.forEach((link2, index2) => updateRefCountForLink(link2, index2));
|
|
150
|
-
} else {
|
|
151
|
-
const prevCount = refCount.get(link);
|
|
152
|
-
refCount.set(link, count);
|
|
153
|
-
if (!count) {
|
|
154
|
-
gbLinks.add(link);
|
|
155
|
-
} else if (!prevCount && count) {
|
|
156
|
-
gbLinks.delete(link);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const getLinkEntries = () => Array.from(links.entries());
|
|
161
|
-
const getRefCount = (link) => refCount.get(link) ?? 0;
|
|
162
|
-
const runGarbageCollector = () => {
|
|
51
|
+
if (typeof n == "string") {
|
|
52
|
+
f2.set(n, u2);
|
|
53
|
+
let [S] = n.split(":");
|
|
54
|
+
P(n) || (r2.has(S) ? (_a = r2.get(S)) == null ? void 0 : _a.add(n) : r2.set(S, /* @__PURE__ */ new Set([n])));
|
|
55
|
+
}
|
|
56
|
+
k && n && n !== k && V(n, k);
|
|
57
|
+
}, j = (n) => n ? f2.has(n) : false, M = (n, u2) => {
|
|
58
|
+
if (Array.isArray(n)) n.forEach((k, S) => M(k, S));
|
|
59
|
+
else {
|
|
60
|
+
let k = o.get(n);
|
|
61
|
+
o.set(n, u2), u2 ? !k && u2 && E.delete(n) : E.add(n);
|
|
62
|
+
}
|
|
63
|
+
}, N = () => Array.from(f2.entries()), _ = (n) => o.get(n) ?? 0, B = () => {
|
|
163
64
|
var _a, _b;
|
|
164
|
-
for (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
links.delete(link);
|
|
171
|
-
refCount.delete(link);
|
|
172
|
-
const parents = parentRefs.get(link) ?? [];
|
|
173
|
-
const children = childrenRefs.get(link) ?? [];
|
|
174
|
-
parents.forEach((parentKey) => {
|
|
65
|
+
for (let n of E.keys()) {
|
|
66
|
+
if (_(n) > 0) continue;
|
|
67
|
+
let k = f2.get(n);
|
|
68
|
+
E.delete(n), f2.delete(n), o.delete(n);
|
|
69
|
+
let S = p.get(n) ?? [], L = c.get(n) ?? [];
|
|
70
|
+
S.forEach((K) => {
|
|
175
71
|
var _a2, _b2;
|
|
176
|
-
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
updateRefCountForLink(childKey, getRefCount(childKey) - 1);
|
|
72
|
+
c.set(K, ((_b2 = (_a2 = c.get(K)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (J) => J !== n)) ?? []);
|
|
73
|
+
}), L.forEach((K) => {
|
|
74
|
+
M(K, _(K) - 1);
|
|
180
75
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
(_a = types2.get(type)) == null ? void 0 : _a.delete(link);
|
|
184
|
-
if (!((_b = types2.get(type)) == null ? void 0 : _b.size)) {
|
|
185
|
-
types2.delete(type);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
parentRefs.delete(link);
|
|
189
|
-
(listeners.get("onRemoveLink") ?? []).forEach((listener) => listener(link, currentValue ?? null));
|
|
76
|
+
let [C] = n.split(":");
|
|
77
|
+
P(n) || ((_a = r2.get(C)) == null ? void 0 : _a.delete(n), ((_b = r2.get(C)) == null ? void 0 : _b.size) || r2.delete(C)), p.delete(n), (e.get("onRemoveLink") ?? []).forEach((K) => K(n, k ?? null));
|
|
190
78
|
}
|
|
191
79
|
};
|
|
192
|
-
return {
|
|
193
|
-
readLink,
|
|
194
|
-
writeLink,
|
|
195
|
-
hasLink,
|
|
196
|
-
getLinkEntries,
|
|
197
|
-
parentRefs,
|
|
198
|
-
childrenRefs,
|
|
199
|
-
addRefs,
|
|
200
|
-
removeRefs,
|
|
201
|
-
getChildren: (key) => childrenRefs.get(key),
|
|
202
|
-
getParents: (key) => parentRefs.get(key),
|
|
203
|
-
getLinkedRefs,
|
|
204
|
-
invalidate,
|
|
205
|
-
links,
|
|
206
|
-
types: types2,
|
|
207
|
-
refCount,
|
|
208
|
-
runGarbageCollector,
|
|
209
|
-
onRemoveLink: (callback) => listeners.set("onRemoveLink", [...(listeners == null ? void 0 : listeners.get("onRemoveLink")) ?? [], callback])
|
|
210
|
-
};
|
|
80
|
+
return { readLink: Y, writeLink: w, hasLink: j, getLinkEntries: N, parentRefs: p, childrenRefs: c, addRefs: V, removeRefs: x, getChildren: (n) => c.get(n), getParents: (n) => p.get(n), getLinkedRefs: I, invalidate: A, links: f2, types: r2, refCount: o, runGarbageCollector: B, onRemoveLink: (n) => e.set("onRemoveLink", [...(e == null ? void 0 : e.get("onRemoveLink")) ?? [], n]) };
|
|
211
81
|
};
|
|
212
|
-
var
|
|
82
|
+
var Z = (...e) => {
|
|
213
83
|
var _a;
|
|
214
|
-
return (_a =
|
|
84
|
+
return (_a = e == null ? void 0 : e.filter(Boolean)) == null ? void 0 : _a.join(".");
|
|
215
85
|
};
|
|
216
|
-
var
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
};
|
|
222
|
-
const runPlugins = (state) => {
|
|
223
|
-
return plugins.reduce((graphState, plugin) => plugin(graphState) ?? graphState, state);
|
|
224
|
-
};
|
|
225
|
-
initialPlugins.forEach(use);
|
|
226
|
-
return {
|
|
227
|
-
use,
|
|
228
|
-
runPlugins
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
var isGraphState = (input) => {
|
|
232
|
-
if (!input)
|
|
233
|
-
return false;
|
|
234
|
-
if (isObject$1(input)) {
|
|
235
|
-
const fields = ["_id", "_type", "key", "mutate", "resolve"];
|
|
236
|
-
return fields.every((field) => field in input);
|
|
237
|
-
}
|
|
238
|
-
return false;
|
|
86
|
+
var pe = process.env.NODE_ENV !== "production";
|
|
87
|
+
var fe = (e = []) => {
|
|
88
|
+
let r2 = [], f2 = (c) => {
|
|
89
|
+
r2.push(c);
|
|
90
|
+
}, p = (c) => r2.reduce((o, E) => E(o) ?? o, c);
|
|
91
|
+
return e.forEach(f2), { use: f2, runPlugins: p };
|
|
239
92
|
};
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
listeners.forEach((callback) => {
|
|
247
|
-
callback({ ...event, timestamp: Date.now() });
|
|
93
|
+
var le = (e) => e && T(e) ? ["_id", "_type", "key", "mutate", "resolve"].every((f2) => f2 in e) : false;
|
|
94
|
+
var ue = () => {
|
|
95
|
+
let e = /* @__PURE__ */ new Set();
|
|
96
|
+
return { debug: (p) => {
|
|
97
|
+
e.forEach((c) => {
|
|
98
|
+
c({ ...p, timestamp: Date.now() });
|
|
248
99
|
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
onDebugEvent
|
|
253
|
-
};
|
|
100
|
+
}, onDebugEvent: (p) => {
|
|
101
|
+
e.add(p);
|
|
102
|
+
} };
|
|
254
103
|
};
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (!cache.has(message)) {
|
|
259
|
-
console.warn(wrapMessage(message));
|
|
260
|
-
cache.add(message);
|
|
261
|
-
}
|
|
104
|
+
var ye = /* @__PURE__ */ new Set(), Se = (e) => `[GraphState]: ${e}`;
|
|
105
|
+
function ee(e) {
|
|
106
|
+
ye.has(e) || (console.warn(Se(e)), ye.add(e));
|
|
262
107
|
}
|
|
263
|
-
var
|
|
264
|
-
if (typeof
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
let entityId = null;
|
|
271
|
-
if (y(entity.id) || y(entity._id)) {
|
|
272
|
-
entityId = `${entity.id ?? entity._id}`;
|
|
273
|
-
}
|
|
274
|
-
return !entityId ? entityId : `${entity._type}:${entityId}`;
|
|
108
|
+
var $ = (e) => {
|
|
109
|
+
if (typeof e == "string") return q(e) ? e : null;
|
|
110
|
+
if (!(e == null ? void 0 : e._type)) return null;
|
|
111
|
+
let r2 = null;
|
|
112
|
+
return (y(e.id) || y(e._id)) && (r2 = `${e.id ?? e._id}`), r2 && `${e._type}:${r2}`;
|
|
275
113
|
};
|
|
276
|
-
var
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return null;
|
|
282
|
-
const [typeName, ...restTypes] = entity.split(":");
|
|
283
|
-
if (!typeName || restTypes.length < 1)
|
|
284
|
-
return null;
|
|
285
|
-
return {
|
|
286
|
-
_type: typeName,
|
|
287
|
-
_id: restTypes.join(":")
|
|
288
|
-
};
|
|
114
|
+
var q = (e) => {
|
|
115
|
+
if (T(e) && (e == null ? void 0 : e._type) && $(e)) return e;
|
|
116
|
+
if (!e || typeof e != "string") return null;
|
|
117
|
+
let [r2, ...f2] = e.split(":");
|
|
118
|
+
return !r2 || f2.length < 1 ? null : { _type: r2, _id: f2.join(":") };
|
|
289
119
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const pluginsStore = createPluginsState(options == null ? void 0 : options.plugins);
|
|
309
|
-
const subscribers = /* @__PURE__ */ new Map();
|
|
310
|
-
let deepIndex = 0;
|
|
311
|
-
const isSkipped = (entity) => {
|
|
312
|
-
return skipPredictors.some((predictor) => predictor(entity));
|
|
313
|
-
};
|
|
314
|
-
const getReferences = (entity, options2) => {
|
|
315
|
-
const withPartialKeys = (options2 == null ? void 0 : options2.withPartialKeys) ?? false;
|
|
316
|
-
const key = keyOfEntity2(entity);
|
|
317
|
-
if (!key)
|
|
318
|
-
return [];
|
|
319
|
-
const values = cache2.getParents(key) ?? [];
|
|
320
|
-
return values.filter((v) => withPartialKeys ? !isPartialKey(v) : v);
|
|
321
|
-
};
|
|
322
|
-
const resolve = (input, options2) => {
|
|
323
|
-
const isDeep = (options2 == null ? void 0 : options2.deep) ?? false;
|
|
324
|
-
const isSafe = (options2 == null ? void 0 : options2.safe) ?? false;
|
|
325
|
-
const keepLinks = (options2 == null ? void 0 : options2.keepLinks) ?? false;
|
|
326
|
-
const removeLinkFromSubGraph = (options2 == null ? void 0 : options2.removeLinkFromSubGraph) ?? true;
|
|
327
|
-
const { selector, ...coreOptions } = options2 || {};
|
|
328
|
-
const inputKey = y(input) ? keyOfEntity2(input) : null;
|
|
329
|
-
debugState.debug({ type: "resolve", entity: input, options: options2 });
|
|
330
|
-
let value = inputKey ? cache2.readLink(inputKey) : null;
|
|
331
|
-
if (isSkipped(value))
|
|
332
|
-
return value;
|
|
333
|
-
if (isObject$1(value) || Array.isArray(value)) {
|
|
334
|
-
value = Object.entries(value).reduce((acc, [key, value2]) => {
|
|
335
|
-
let resultValue = value2;
|
|
336
|
-
if (!isSkipped(resultValue)) {
|
|
337
|
-
if (Array.isArray(value2)) {
|
|
338
|
-
resultValue = value2.map((v) => {
|
|
339
|
-
if (isSkipped(v))
|
|
340
|
-
return v;
|
|
341
|
-
if (isLinkKey(v) && !isSafe && !cache2.hasLink(v)) {
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
return isPartOfGraph(v, inputKey) && !keepLinks || isDeep ? safeResolve(v, coreOptions) : v;
|
|
345
|
-
});
|
|
346
|
-
if (!isSafe) {
|
|
347
|
-
resultValue = resultValue.filter(y);
|
|
348
|
-
}
|
|
349
|
-
} else {
|
|
350
|
-
if (isLinkKey(value2) && !isSafe && !cache2.hasLink(value2)) {
|
|
351
|
-
resultValue = null;
|
|
352
|
-
} else if (isPartOfGraph(keyOfEntity2(value2), inputKey) && !keepLinks || isDeep) {
|
|
353
|
-
resultValue = safeResolve(value2, coreOptions);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
acc[key] = isPartialGraph(resultValue) && removeLinkFromSubGraph ? omit(resultValue, "_type", "_id") : resultValue;
|
|
358
|
-
return acc;
|
|
359
|
-
}, {});
|
|
360
|
-
}
|
|
361
|
-
return value ? selector ? selector({ ...value }) : { ...value } : isSafe ? input : null;
|
|
362
|
-
};
|
|
363
|
-
const safeResolve = (input, options2) => resolve(input, options2) ?? input;
|
|
364
|
-
const unlinkGraph = (entity) => {
|
|
365
|
-
const graphKey = keyOfEntity2(entity);
|
|
366
|
-
if (graphKey) {
|
|
367
|
-
const deps = cache2.getChildren(graphKey) || [];
|
|
368
|
-
deps.forEach((depLink) => {
|
|
369
|
-
if (!isPartialKey(depLink)) {
|
|
370
|
-
cache2.removeRefs(graphKey, depLink);
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
const mutateField = (input, parentFieldKey, options2) => {
|
|
120
|
+
var he = 0, Re = 100, we = "State", me = "$EACH:ROOT$", kt = (e) => {
|
|
121
|
+
let r2 = (e == null ? void 0 : e._id) ?? `${he++}`, f2 = (e == null ? void 0 : e._type) ?? we, p = `${f2}:${r2}`, c = [le, ...(e == null ? void 0 : e.skip) ?? []], o = ce(), E = ue(), V = fe(e == null ? void 0 : e.plugins), x = /* @__PURE__ */ new Map(), I = 0, A = (t2) => c.some((i2) => i2(t2)), Y = (t2, i2) => {
|
|
122
|
+
let a2 = (i2 == null ? void 0 : i2.withPartialKeys) ?? false, s2 = L(t2);
|
|
123
|
+
return s2 ? (o.getParents(s2) ?? []).filter((g2) => a2 ? !P(g2) : g2) : [];
|
|
124
|
+
}, w = (t2, i2) => {
|
|
125
|
+
let a2 = (i2 == null ? void 0 : i2.deep) ?? false, s2 = (i2 == null ? void 0 : i2.safe) ?? false, l2 = (i2 == null ? void 0 : i2.keepLinks) ?? false, { selector: g2, ...y$1 } = i2 || {}, d = y(t2) ? L(t2) : null;
|
|
126
|
+
E.debug({ type: "resolve", entity: t2, options: i2 });
|
|
127
|
+
let h = d ? o.readLink(d) : null;
|
|
128
|
+
return A(h) ? h : ((T(h) || Array.isArray(h)) && (h = Object.entries(h).reduce((b, [G, m]) => {
|
|
129
|
+
let R = m;
|
|
130
|
+
return A(R) || (Array.isArray(m) ? (R = m.map((O) => A(O) ? O : D(O) && !s2 && !o.hasLink(O) ? null : X(O, d) && !l2 || a2 ? j(O, y$1) : O), s2 || (R = R.filter(y))) : D(m) && !s2 && !o.hasLink(m) ? R = null : (X(L(m), d) && !l2 || a2) && (R = j(m, y$1))), b[G] = R, b;
|
|
131
|
+
}, {})), h ? g2 ? g2({ ...h }) : { ...h } : s2 ? t2 : null);
|
|
132
|
+
}, j = (t2, i2) => w(t2, i2) ?? t2, M = (t2) => {
|
|
133
|
+
let i2 = L(t2);
|
|
134
|
+
i2 && (o.getChildren(i2) || []).forEach((s2) => {
|
|
135
|
+
P(s2) || o.removeRefs(i2, s2);
|
|
136
|
+
});
|
|
137
|
+
}, N = (t2, i2, a2) => {
|
|
376
138
|
var _a, _b, _c, _d;
|
|
377
|
-
if ((!
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
(_d = (_c = options2 == null ? void 0 : options2.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(inputLinkKey, [...visitorsPaths, parentGraph]);
|
|
389
|
-
}
|
|
390
|
-
if (Array.isArray(input)) {
|
|
391
|
-
return input.map((item) => {
|
|
392
|
-
const indexKey = parentFieldKey ? joinKeys(parentFieldKey, `${ID++}`) : void 0;
|
|
393
|
-
return mutateField(item, indexKey, options2);
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
const entityKey = isLinkKey(input) ? input : isGraph(input) ? keyOfEntity2(input) : null;
|
|
397
|
-
const childKey = entityKey ?? parentFieldKey;
|
|
398
|
-
const mutateMethod = (options2 == null ? void 0 : options2.overrideMutateMethod) || mutate;
|
|
399
|
-
return mutateMethod(childKey, input, options2);
|
|
400
|
-
};
|
|
401
|
-
const mutate = (entity, ...args) => {
|
|
402
|
-
const { graphKey: entityGraphKey, options: options2, data: rawData } = getArgumentsForMutate(entity, ...args);
|
|
403
|
-
debugState.debug({ type: "beforeMutate", entity: entityGraphKey, data: rawData, options: options2 });
|
|
404
|
-
const data = isLinkKey(rawData) ? entityOfKey2(rawData) : rawData;
|
|
405
|
-
const graphKey = entityGraphKey ?? stateKey;
|
|
406
|
-
const partialKey = isPartialKey == null ? void 0 : isPartialKey(graphKey);
|
|
407
|
-
const parentKey = options2 == null ? void 0 : options2.parent;
|
|
408
|
-
const prevGraph = resolve(graphKey ?? "", { removeLinkFromSubGraph: false });
|
|
409
|
-
const internal = (options2 == null ? void 0 : options2.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) };
|
|
410
|
-
let graphData = {
|
|
411
|
-
...data,
|
|
412
|
-
...entityOfKey2(graphKey)
|
|
413
|
-
};
|
|
414
|
-
const isTopLevelGraph = !(options2 == null ? void 0 : options2.parent);
|
|
415
|
-
const isReplace = (options2 == null ? void 0 : options2.replace) ? typeof (options2 == null ? void 0 : options2.replace) === "function" ? options2.replace(graphData) : (options2 == null ? void 0 : options2.replace) === "deep" ? true : isTopLevelGraph || partialKey : false;
|
|
416
|
-
if (isSkipped(data)) {
|
|
417
|
-
cache2.writeLink(graphKey, data, parentKey);
|
|
418
|
-
return graphKey;
|
|
419
|
-
}
|
|
420
|
-
if (!isReplace && isObject$1(prevGraph) && isObject$1(graphData)) {
|
|
421
|
-
graphData = {
|
|
422
|
-
...prevGraph,
|
|
423
|
-
...graphData
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
if (isReplace) {
|
|
427
|
-
unlinkGraph(graphKey);
|
|
428
|
-
}
|
|
429
|
-
const nextGraph = Object.entries(graphData).reduce((acc, [key, value]) => {
|
|
430
|
-
const fieldKey = joinKeys(graphKey, key);
|
|
431
|
-
let fieldValue = value;
|
|
432
|
-
const prevValue = prevGraph == null ? void 0 : prevGraph[key];
|
|
433
|
-
const isUpdateField = isObject$1(data) && key in data;
|
|
434
|
-
if (!isSkipped(fieldValue)) {
|
|
435
|
-
if (!isReplace && isUpdateField && Array.isArray(fieldValue) && Array.isArray(prevValue)) {
|
|
436
|
-
fieldValue = [...prevValue, ...fieldValue];
|
|
437
|
-
}
|
|
438
|
-
if (isObject$1(fieldValue) || Array.isArray(fieldValue) || isLinkKey(fieldValue)) {
|
|
439
|
-
fieldValue = mutateField(fieldValue, fieldKey, {
|
|
440
|
-
...options2,
|
|
441
|
-
parent: graphKey,
|
|
442
|
-
internal
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
if (Array.isArray(fieldValue) && (options2 == null ? void 0 : options2.dedup) !== false) {
|
|
446
|
-
fieldValue = uniqueLinks(...fieldValue);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
const isEqual = shallowEqual(prevValue, fieldKey === fieldValue ? safeResolve(fieldValue) : fieldValue);
|
|
450
|
-
internal.hasChange = internal.hasChange || !isEqual;
|
|
451
|
-
if (!isReplace && isLinkKey(prevValue) && prevValue !== fieldValue) {
|
|
452
|
-
cache2.removeRefs(graphKey, prevValue);
|
|
453
|
-
}
|
|
454
|
-
acc[key] = fieldValue;
|
|
455
|
-
return acc;
|
|
456
|
-
}, {});
|
|
457
|
-
cache2.writeLink(graphKey, nextGraph, parentKey);
|
|
458
|
-
if (!parentKey) {
|
|
459
|
-
cache2.runGarbageCollector();
|
|
460
|
-
}
|
|
461
|
-
if ((internal.hasChange || isReplace) && !parentKey) {
|
|
462
|
-
notify(graphKey, prevGraph);
|
|
463
|
-
}
|
|
464
|
-
debugState.debug({
|
|
465
|
-
type: "afterMutate",
|
|
466
|
-
entity: entityGraphKey,
|
|
467
|
-
data: rawData,
|
|
468
|
-
nextData: nextGraph,
|
|
469
|
-
options: options2,
|
|
470
|
-
hasChange: internal.hasChange
|
|
139
|
+
if ((!t2 || l(t2)) && !D(t2) || A(t2)) return t2;
|
|
140
|
+
let s2 = re(t2) ? L(t2) : t2;
|
|
141
|
+
if (D(s2)) {
|
|
142
|
+
let d = ae(i2) ?? "", h = ((_a = a2 == null ? void 0 : a2.internal) == null ? void 0 : _a.visitors.get(d)) ?? [], b = ((_b = a2 == null ? void 0 : a2.internal) == null ? void 0 : _b.visitors.get(s2)) ?? [];
|
|
143
|
+
if (h.includes(s2) || s2 === d) return null;
|
|
144
|
+
(_d = (_c = a2 == null ? void 0 : a2.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(s2, [...b, d]);
|
|
145
|
+
}
|
|
146
|
+
if (Array.isArray(t2)) return t2.map((d) => {
|
|
147
|
+
let h = i2 ? Z(i2, `${he++}`) : void 0;
|
|
148
|
+
return N(d, h, a2);
|
|
471
149
|
});
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
150
|
+
let g2 = (D(t2) ? t2 : se(t2) ? L(t2) : null) ?? i2;
|
|
151
|
+
return ((a2 == null ? void 0 : a2.overrideMutateMethod) || _)(g2, t2, a2);
|
|
152
|
+
}, _ = (t2, ...i2) => {
|
|
153
|
+
let { graphKey: a2, options: s2, data: l2 } = K(t2, ...i2);
|
|
154
|
+
E.debug({ type: "beforeMutate", entity: a2, data: l2, options: s2 });
|
|
155
|
+
let g2 = D(l2) ? C(l2) : l2, y2 = a2 ?? p, d = P == null ? void 0 : P(y2), h = s2 == null ? void 0 : s2.parent, b = w(y2 ?? ""), G = (s2 == null ? void 0 : s2.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) }, m = { ...g2, ...C(y2) }, R = !(s2 == null ? void 0 : s2.parent), O = (s2 == null ? void 0 : s2.replace) ? typeof (s2 == null ? void 0 : s2.replace) == "function" ? s2.replace(m) : (s2 == null ? void 0 : s2.replace) === "deep" ? true : R || d : false;
|
|
156
|
+
if (A(g2)) return o.writeLink(y2, g2, h), y2;
|
|
157
|
+
!O && T(b) && T(m) && (m = { ...b, ...m }), O && M(y2);
|
|
158
|
+
let U = Object.entries(m).reduce((W, [H, be]) => {
|
|
159
|
+
let te = Z(y2, H), v = be, F = b == null ? void 0 : b[H], ve = T(g2) && H in g2;
|
|
160
|
+
A(v) || (!O && ve && Array.isArray(v) && Array.isArray(F) && (v = [...F, ...v]), (T(v) || Array.isArray(v) || D(v)) && (v = N(v, te, { ...s2, parent: y2, internal: G })), Array.isArray(v) && (s2 == null ? void 0 : s2.dedup) !== false && (v = oe(...v)));
|
|
161
|
+
let Le = ie(F, te === v ? j(v) : v);
|
|
162
|
+
return G.hasChange = G.hasChange || !Le, !O && D(F) && F !== v && o.removeRefs(y2, F), W[H] = v, W;
|
|
163
|
+
}, {});
|
|
164
|
+
return o.writeLink(y2, U, h), h || o.runGarbageCollector(), (G.hasChange || O) && !h && n(y2, b), E.debug({ type: "afterMutate", entity: a2, data: l2, nextData: U, options: s2, hasChange: G.hasChange }), y2;
|
|
165
|
+
}, B = (t2) => {
|
|
166
|
+
let i2 = L(t2);
|
|
167
|
+
if (E.debug({ type: "invalidate", entity: i2 }), i2) {
|
|
168
|
+
let a2 = o.getParents(i2) || [];
|
|
169
|
+
o.invalidate(i2), a2.forEach((s2) => {
|
|
170
|
+
let l2 = o.readLink(s2), g2 = w(s2, { safe: false, keepLinks: true });
|
|
171
|
+
o.writeLink(s2, g2), n(s2, l2);
|
|
485
172
|
});
|
|
486
173
|
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (key) {
|
|
496
|
-
deepIndex++;
|
|
497
|
-
const subs = [...subscribers.get(key) || [], ...subscribers.get(EACH_UPDATED) || []];
|
|
498
|
-
const deps = cache2.getChildren(key) || [];
|
|
499
|
-
const nextResult = resolve(key);
|
|
500
|
-
const getSelectedValues = (selector) => {
|
|
501
|
-
const next = nextResult && (selector == null ? void 0 : selector(nextResult));
|
|
502
|
-
const prev = prevState && (selector == null ? void 0 : selector(prevState));
|
|
503
|
-
return { next, prev, hasChange: !deepEqual(next, prev) };
|
|
174
|
+
}, n = (t2, i2, a2) => {
|
|
175
|
+
if (I > Re) throw new Error("Too deep notify.");
|
|
176
|
+
let s2 = (a2 == null ? void 0 : a2.depth) ?? 0, l2 = L(t2);
|
|
177
|
+
if (E.debug({ type: "notify", entity: l2 }), l2) {
|
|
178
|
+
I++;
|
|
179
|
+
let g2 = [...x.get(l2) || [], ...x.get(me) || []], y2 = o.getChildren(l2) || [], d = w(l2), h = (b) => {
|
|
180
|
+
let G = d && (b == null ? void 0 : b(d)), m = i2 && (b == null ? void 0 : b(i2));
|
|
181
|
+
return { next: G, prev: m, hasChange: !z(G, m) };
|
|
504
182
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
deepIndex = 0;
|
|
526
|
-
};
|
|
527
|
-
const subscribe = (...args) => {
|
|
528
|
-
const input = typeof args[0] === "function" ? EACH_UPDATED : args[0];
|
|
529
|
-
const callback = typeof args[0] === "function" ? args[0] : args[1];
|
|
530
|
-
const options2 = typeof args[0] === "function" ? args[1] : args[2];
|
|
531
|
-
const key = keyOfEntity2(input);
|
|
532
|
-
if (key) {
|
|
533
|
-
if (subscribers.has(key)) {
|
|
534
|
-
subscribers.set(key, [...Array.from(subscribers.get(key) || []), { callback, options: options2 }]);
|
|
535
|
-
} else {
|
|
536
|
-
subscribers.set(key, [{ callback, options: options2 }]);
|
|
537
|
-
}
|
|
538
|
-
cache2.onRemoveLink((link, prevValue) => {
|
|
539
|
-
if (link === key) {
|
|
540
|
-
notify(key, prevValue);
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
const unsubscribe = () => {
|
|
545
|
-
if (key) {
|
|
546
|
-
const subIndex = (subscribers.get(key) || []).findIndex((sub) => sub.callback === callback);
|
|
547
|
-
if (subIndex !== -1) {
|
|
548
|
-
const nextSubscribers = subscribers.get(key) || [];
|
|
549
|
-
nextSubscribers.splice(subIndex, 1);
|
|
550
|
-
subscribers.set(key, nextSubscribers);
|
|
183
|
+
g2.forEach(({ callback: b, options: G }) => {
|
|
184
|
+
let m = G == null ? void 0 : G.selector;
|
|
185
|
+
if (!(((G == null ? void 0 : G.directChangesOnly) ?? false) && s2 > 0)) if (m) {
|
|
186
|
+
let { next: O, prev: U, hasChange: W } = h(m);
|
|
187
|
+
W && b(O, U);
|
|
188
|
+
} else b(d, i2);
|
|
189
|
+
}), y2.forEach((b) => n(b, i2, { depth: s2 + 1 }));
|
|
190
|
+
}
|
|
191
|
+
I = 0;
|
|
192
|
+
}, u2 = (...t2) => {
|
|
193
|
+
let i2 = typeof t2[0] == "function" ? me : t2[0], a2 = typeof t2[0] == "function" ? t2[0] : t2[1], s2 = typeof t2[0] == "function" ? t2[1] : t2[2], l2 = L(i2);
|
|
194
|
+
l2 && (x.has(l2) ? x.set(l2, [...Array.from(x.get(l2) || []), { callback: a2, options: s2 }]) : x.set(l2, [{ callback: a2, options: s2 }]));
|
|
195
|
+
let g2 = () => {
|
|
196
|
+
if (l2) {
|
|
197
|
+
let y2 = (x.get(l2) || []).findIndex((d) => d.callback === a2);
|
|
198
|
+
if (y2 !== -1) {
|
|
199
|
+
let d = x.get(l2) || [];
|
|
200
|
+
d.splice(y2, 1), x.set(l2, d);
|
|
551
201
|
}
|
|
552
202
|
}
|
|
553
203
|
};
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
};
|
|
565
|
-
const keyOfEntity2 = (entity) => {
|
|
566
|
-
warn("Instance keyOfEntity is deprecated. Use static method keyOfEntity.");
|
|
567
|
-
return keyOfEntity(entity);
|
|
568
|
-
};
|
|
569
|
-
const entityOfKey2 = (entity) => {
|
|
570
|
-
warn("Instance entityOfKey is deprecated. Use static method entityOfKey.");
|
|
571
|
-
return entityOfKey(entity);
|
|
572
|
-
};
|
|
573
|
-
const getArgumentsForMutate = (entity, ...args) => {
|
|
574
|
-
let data = typeof entity === "string" ? args[0] : entity;
|
|
575
|
-
if (typeof data === "function") {
|
|
576
|
-
data = data(resolve(entity));
|
|
577
|
-
} else if (isLinkKey(data)) {
|
|
578
|
-
data = entityOfKey2(data);
|
|
579
|
-
}
|
|
580
|
-
return {
|
|
581
|
-
graphKey: typeof entity === "string" ? entity : keyOfEntity2(entity),
|
|
582
|
-
options: typeof entity === "string" ? args[1] : args[0],
|
|
583
|
-
data
|
|
584
|
-
};
|
|
585
|
-
};
|
|
586
|
-
function use(plugin) {
|
|
587
|
-
pluginsStore.use(plugin);
|
|
588
|
-
plugin(this);
|
|
204
|
+
return (s2 == null ? void 0 : s2.signal) && s2.signal.addEventListener("abort", g2, { once: true }), g2;
|
|
205
|
+
}, k = (t2) => [...o.types.get(t2) ?? []], S = (t2) => {
|
|
206
|
+
let i2 = (typeof t2 == "string" ? t2 : L(t2)) || "";
|
|
207
|
+
return (o.getParents(i2) ?? []).map((s2) => w(s2));
|
|
208
|
+
}, L = (t2) => (ee("Instance keyOfEntity is deprecated. Use static method keyOfEntity."), $(t2)), C = (t2) => (ee("Instance entityOfKey is deprecated. Use static method entityOfKey."), q(t2)), K = (t2, ...i2) => {
|
|
209
|
+
let a2 = typeof t2 == "string" ? i2[0] : t2;
|
|
210
|
+
return typeof a2 == "function" ? a2 = a2(w(t2)) : D(a2) && (a2 = C(a2)), { graphKey: typeof t2 == "string" ? t2 : L(t2), options: typeof t2 == "string" ? i2[1] : i2[0], data: a2 };
|
|
211
|
+
};
|
|
212
|
+
function J(t2) {
|
|
213
|
+
V.use(t2), t2(this);
|
|
589
214
|
}
|
|
590
|
-
|
|
591
|
-
|
|
215
|
+
let ke = (t2) => {
|
|
216
|
+
c.push(t2);
|
|
592
217
|
};
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
596
|
-
const graphState = {
|
|
597
|
-
_type: type,
|
|
598
|
-
_id: id,
|
|
599
|
-
key: stateKey,
|
|
600
|
-
getReferences,
|
|
601
|
-
mutate,
|
|
602
|
-
subscribe,
|
|
603
|
-
resolve,
|
|
604
|
-
safeResolve,
|
|
605
|
-
resolveParents,
|
|
606
|
-
inspectFields,
|
|
607
|
-
invalidate,
|
|
608
|
-
keyOfEntity: keyOfEntity2,
|
|
609
|
-
entityOfKey: entityOfKey2,
|
|
610
|
-
getArgumentsForMutate,
|
|
611
|
-
types: cache2.types,
|
|
612
|
-
cache: cache2,
|
|
613
|
-
use,
|
|
614
|
-
addSkip,
|
|
615
|
-
subscribers: isDev ? subscribers : void 0,
|
|
616
|
-
onDebugEvent: debugState.onDebugEvent
|
|
617
|
-
};
|
|
618
|
-
cache2.onRemoveLink((link, prevValue) => debugState.debug({ type: "garbageRemove", entity: link, prevValue }));
|
|
619
|
-
return pluginsStore.runPlugins(graphState);
|
|
218
|
+
(e == null ? void 0 : e.initialState) && _(e.initialState, { replace: "deep" });
|
|
219
|
+
let Ee = { _type: f2, _id: r2, key: p, getReferences: Y, mutate: _, subscribe: u2, resolve: w, safeResolve: j, resolveParents: S, inspectFields: k, invalidate: B, keyOfEntity: L, entityOfKey: C, getArgumentsForMutate: K, types: o.types, cache: o, use: J, addSkip: ke, subscribers: pe ? x : void 0, onDebugEvent: E.onDebugEvent };
|
|
220
|
+
return o.onRemoveLink((t2, i2) => E.debug({ type: "garbageRemove", entity: t2, prevValue: i2 })), o.onRemoveLink(n), V.runPlugins(Ee);
|
|
620
221
|
};
|
|
621
222
|
const createConstants$1 = (...constants) => {
|
|
622
223
|
return constants.reduce((acc, constant) => {
|
|
@@ -637,12 +238,27 @@ const nodes = createConstants$1(
|
|
|
637
238
|
"CssLink",
|
|
638
239
|
"Variable",
|
|
639
240
|
"ComputedValue",
|
|
640
|
-
"TransformValue"
|
|
241
|
+
"TransformValue",
|
|
242
|
+
"StopColor",
|
|
243
|
+
"LinearGradient",
|
|
244
|
+
"CssChunk",
|
|
245
|
+
"Border",
|
|
246
|
+
"Paint",
|
|
247
|
+
"Link",
|
|
248
|
+
"Classname",
|
|
249
|
+
"ImagePaint"
|
|
641
250
|
);
|
|
642
251
|
const fragmentGrowingMode = createConstants$1("auto", "fill");
|
|
643
252
|
const borderType = createConstants$1("None", "Solid", "Dashed", "Dotted");
|
|
644
253
|
const linkTarget = createConstants$1("_blank", "none");
|
|
645
|
-
const paintMode = createConstants$1(
|
|
254
|
+
const paintMode = createConstants$1(
|
|
255
|
+
"None",
|
|
256
|
+
"Solid",
|
|
257
|
+
"LinearGradient",
|
|
258
|
+
"RadialGradient",
|
|
259
|
+
"ConicGradient",
|
|
260
|
+
"Image"
|
|
261
|
+
);
|
|
646
262
|
const imagePaintScaleModes = createConstants$1("Auto", "Contain", "Cover");
|
|
647
263
|
const constrain = createConstants$1(
|
|
648
264
|
"Min",
|
|
@@ -739,11 +355,13 @@ const scopeTypes = createConstants$1(
|
|
|
739
355
|
"CollectionScope",
|
|
740
356
|
"CollectionItemScope"
|
|
741
357
|
);
|
|
358
|
+
const cssChunkScopeTypes = createConstants$1("Global", "Fragment");
|
|
742
359
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
743
360
|
__proto__: null,
|
|
744
361
|
borderType,
|
|
745
362
|
constrain,
|
|
746
363
|
createConstants: createConstants$1,
|
|
364
|
+
cssChunkScopeTypes,
|
|
747
365
|
effectName,
|
|
748
366
|
effectType,
|
|
749
367
|
eventMode,
|
|
@@ -1579,32 +1197,7 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
1579
1197
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
1580
1198
|
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1581
1199
|
zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1582
|
-
classnames: layerField(/* @__PURE__ */ array(
|
|
1583
|
-
});
|
|
1584
|
-
const FillSchema = /* @__PURE__ */ object({
|
|
1585
|
-
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
1586
|
-
fallback: paintMode.None
|
|
1587
|
-
}),
|
|
1588
|
-
solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" }),
|
|
1589
|
-
imageFill: layerField(/* @__PURE__ */ string()),
|
|
1590
|
-
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1591
|
-
fallback: imagePaintScaleModes.Auto
|
|
1592
|
-
})
|
|
1593
|
-
});
|
|
1594
|
-
const BorderSchema = /* @__PURE__ */ object({
|
|
1595
|
-
borderType: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
|
|
1596
|
-
fallback: borderType.None
|
|
1597
|
-
}),
|
|
1598
|
-
borderWidth: layerField(/* @__PURE__ */ string(), {
|
|
1599
|
-
fallback: "1px",
|
|
1600
|
-
transform: (value) => {
|
|
1601
|
-
if (typeof value === "number") {
|
|
1602
|
-
return `${value}px`;
|
|
1603
|
-
}
|
|
1604
|
-
return value;
|
|
1605
|
-
}
|
|
1606
|
-
}),
|
|
1607
|
-
borderColor: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
|
|
1200
|
+
classnames: layerField(/* @__PURE__ */ array(linkValidator), { fallback: [] })
|
|
1608
1201
|
});
|
|
1609
1202
|
const SizeSchema = /* @__PURE__ */ object({
|
|
1610
1203
|
widthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
@@ -1686,15 +1279,6 @@ const InteractionsSchema = /* @__PURE__ */ object({
|
|
|
1686
1279
|
const CssOverrideSchema = /* @__PURE__ */ object({
|
|
1687
1280
|
cssOverride: layerField(/* @__PURE__ */ string(), { fallback: "" })
|
|
1688
1281
|
});
|
|
1689
|
-
const LinkSchema = /* @__PURE__ */ object({
|
|
1690
|
-
href: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1691
|
-
hrefNewTab: layerField(/* @__PURE__ */ boolean(), {
|
|
1692
|
-
fallback: true
|
|
1693
|
-
})
|
|
1694
|
-
// hrefTarget: layerField(v.picklist(Object.keys(linkTarget)), {
|
|
1695
|
-
// fallback: linkTarget._blank,
|
|
1696
|
-
// }),
|
|
1697
|
-
});
|
|
1698
1282
|
/* @__PURE__ */ pipe(
|
|
1699
1283
|
/* @__PURE__ */ object({
|
|
1700
1284
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Frame", overridable: false }),
|
|
@@ -1703,19 +1287,19 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1703
1287
|
overridable: false
|
|
1704
1288
|
}),
|
|
1705
1289
|
isPrimary: layerField(/* @__PURE__ */ boolean(), { fallback: false, overridable: false }),
|
|
1706
|
-
|
|
1290
|
+
border: layerField(linkValidator),
|
|
1291
|
+
paint: layerField(linkValidator),
|
|
1292
|
+
link: layerField(linkValidator),
|
|
1707
1293
|
...ChildrenSchema.entries,
|
|
1708
1294
|
...GraphFieldSchema.entries,
|
|
1709
1295
|
...OverridesSchema.entries,
|
|
1296
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1710
1297
|
...PositionSchema.entries,
|
|
1711
1298
|
...SceneSchema.entries,
|
|
1712
|
-
...FillSchema.entries,
|
|
1713
|
-
...BorderSchema.entries,
|
|
1714
1299
|
...SizeSchema.entries,
|
|
1715
1300
|
...LayerSchema.entries,
|
|
1716
1301
|
...InteractionsSchema.entries,
|
|
1717
1302
|
...CssOverrideSchema.entries,
|
|
1718
|
-
...LinkSchema.entries,
|
|
1719
1303
|
overflow: OverflowSchema,
|
|
1720
1304
|
borderRadius: BorderRadiusSchema
|
|
1721
1305
|
})
|
|
@@ -1726,18 +1310,18 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1726
1310
|
fallback: ""
|
|
1727
1311
|
}),
|
|
1728
1312
|
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
1729
|
-
fallback: whiteSpace.
|
|
1313
|
+
fallback: whiteSpace.pre
|
|
1730
1314
|
}),
|
|
1731
1315
|
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
1732
1316
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1317
|
+
link: layerField(linkValidator),
|
|
1733
1318
|
...GraphFieldSchema.entries,
|
|
1734
1319
|
...OverridesSchema.entries,
|
|
1735
1320
|
...CssOverrideSchema.entries,
|
|
1736
1321
|
...PositionSchema.entries,
|
|
1737
1322
|
...SceneSchema.entries,
|
|
1738
1323
|
...SizeSchema.entries,
|
|
1739
|
-
...InteractionsSchema.entries
|
|
1740
|
-
...LinkSchema.entries
|
|
1324
|
+
...InteractionsSchema.entries
|
|
1741
1325
|
});
|
|
1742
1326
|
/* @__PURE__ */ object({
|
|
1743
1327
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
|
|
@@ -1754,6 +1338,10 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1754
1338
|
fallback: [],
|
|
1755
1339
|
overridable: false
|
|
1756
1340
|
}),
|
|
1341
|
+
cssChunks: layerField(/* @__PURE__ */ array(linkValidator), {
|
|
1342
|
+
fallback: [],
|
|
1343
|
+
overridable: false
|
|
1344
|
+
}),
|
|
1757
1345
|
...GraphFieldSchema.entries,
|
|
1758
1346
|
...ChildrenSchema.entries
|
|
1759
1347
|
});
|
|
@@ -1779,13 +1367,13 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1779
1367
|
fallback: {}
|
|
1780
1368
|
}
|
|
1781
1369
|
),
|
|
1370
|
+
link: layerField(linkValidator),
|
|
1782
1371
|
...GraphFieldSchema.entries,
|
|
1783
1372
|
...OverridesSchema.entries,
|
|
1784
1373
|
...PositionSchema.entries,
|
|
1785
1374
|
...SizeSchema.entries,
|
|
1786
1375
|
...SceneSchema.entries,
|
|
1787
|
-
...InteractionsSchema.entries
|
|
1788
|
-
...LinkSchema.entries
|
|
1376
|
+
...InteractionsSchema.entries
|
|
1789
1377
|
});
|
|
1790
1378
|
/* @__PURE__ */ object({
|
|
1791
1379
|
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
@@ -1932,9 +1520,6 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1932
1520
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1933
1521
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1934
1522
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1935
|
-
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1936
|
-
fallback: imagePaintScaleModes.Auto
|
|
1937
|
-
}),
|
|
1938
1523
|
...GraphFieldSchema.entries
|
|
1939
1524
|
});
|
|
1940
1525
|
/* @__PURE__ */ pipe(
|
|
@@ -1945,18 +1530,18 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1945
1530
|
}),
|
|
1946
1531
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1947
1532
|
source: layerField(linkValidator, {}),
|
|
1533
|
+
border: layerField(linkValidator),
|
|
1534
|
+
paint: layerField(linkValidator),
|
|
1535
|
+
link: layerField(linkValidator),
|
|
1948
1536
|
...ChildrenSchema.entries,
|
|
1949
1537
|
...GraphFieldSchema.entries,
|
|
1950
1538
|
...OverridesSchema.entries,
|
|
1951
1539
|
...PositionSchema.entries,
|
|
1952
1540
|
...SceneSchema.entries,
|
|
1953
|
-
...FillSchema.entries,
|
|
1954
|
-
...BorderSchema.entries,
|
|
1955
1541
|
...SizeSchema.entries,
|
|
1956
1542
|
...LayerSchema.entries,
|
|
1957
1543
|
...InteractionsSchema.entries,
|
|
1958
|
-
...CssOverrideSchema.entries
|
|
1959
|
-
...LinkSchema.entries
|
|
1544
|
+
...CssOverrideSchema.entries
|
|
1960
1545
|
})
|
|
1961
1546
|
);
|
|
1962
1547
|
/* @__PURE__ */ object({
|
|
@@ -1974,17 +1559,106 @@ const LinkSchema = /* @__PURE__ */ object({
|
|
|
1974
1559
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1975
1560
|
...GraphFieldSchema.entries
|
|
1976
1561
|
});
|
|
1562
|
+
/* @__PURE__ */ object({
|
|
1563
|
+
...OverridesSchema.entries,
|
|
1564
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1565
|
+
position: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ maxValue(1), /* @__PURE__ */ minValue(0)), {
|
|
1566
|
+
fallback: 0
|
|
1567
|
+
}),
|
|
1568
|
+
value: layerField(/* @__PURE__ */ string(), { fallback: "#000", variable: true }),
|
|
1569
|
+
...GraphFieldSchema.entries
|
|
1570
|
+
});
|
|
1571
|
+
/* @__PURE__ */ object({
|
|
1572
|
+
...OverridesSchema.entries,
|
|
1573
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1574
|
+
angle: layerField(/* @__PURE__ */ number(), {
|
|
1575
|
+
fallback: 0
|
|
1576
|
+
}),
|
|
1577
|
+
stops: layerField(/* @__PURE__ */ array(linkValidator), { fallback: [] }),
|
|
1578
|
+
...GraphFieldSchema.entries
|
|
1579
|
+
});
|
|
1580
|
+
/* @__PURE__ */ object({
|
|
1581
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1582
|
+
chunkId: layerField(/* @__PURE__ */ number()),
|
|
1583
|
+
// content: layerField(v.string(), {
|
|
1584
|
+
// fallback: "",
|
|
1585
|
+
// }),
|
|
1586
|
+
// scope: layerField(v.picklist(Object.keys(definition.cssChunkScopeTypes)), {
|
|
1587
|
+
// fallback: definition.cssChunkScopeTypes.Fragment,
|
|
1588
|
+
// }),
|
|
1589
|
+
enabled: layerField(/* @__PURE__ */ boolean(), {
|
|
1590
|
+
fallback: true,
|
|
1591
|
+
variable: true
|
|
1592
|
+
}),
|
|
1593
|
+
...GraphFieldSchema.entries
|
|
1594
|
+
});
|
|
1595
|
+
/* @__PURE__ */ object({
|
|
1596
|
+
...OverridesSchema.entries,
|
|
1597
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1598
|
+
type: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
|
|
1599
|
+
fallback: borderType.None
|
|
1600
|
+
}),
|
|
1601
|
+
width: layerField(/* @__PURE__ */ string(), {
|
|
1602
|
+
fallback: "1px",
|
|
1603
|
+
transform: (value) => {
|
|
1604
|
+
if (typeof value === "number") {
|
|
1605
|
+
return `${value}px`;
|
|
1606
|
+
}
|
|
1607
|
+
return value;
|
|
1608
|
+
}
|
|
1609
|
+
}),
|
|
1610
|
+
paint: layerField(linkValidator),
|
|
1611
|
+
...GraphFieldSchema.entries
|
|
1612
|
+
});
|
|
1613
|
+
/* @__PURE__ */ object({
|
|
1614
|
+
...OverridesSchema.entries,
|
|
1615
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1616
|
+
type: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
1617
|
+
fallback: paintMode.None
|
|
1618
|
+
}),
|
|
1619
|
+
solid: layerField(/* @__PURE__ */ string(), { fallback: "#fff" }),
|
|
1620
|
+
linearGradient: layerField(linkValidator),
|
|
1621
|
+
image: layerField(linkValidator),
|
|
1622
|
+
...GraphFieldSchema.entries
|
|
1623
|
+
});
|
|
1624
|
+
/* @__PURE__ */ object({
|
|
1625
|
+
...GraphFieldSchema.entries,
|
|
1626
|
+
...OverridesSchema.entries,
|
|
1627
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1628
|
+
src: layerField(/* @__PURE__ */ string()),
|
|
1629
|
+
scale: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1630
|
+
fallback: imagePaintScaleModes.Auto
|
|
1631
|
+
})
|
|
1632
|
+
});
|
|
1633
|
+
/* @__PURE__ */ object({
|
|
1634
|
+
...OverridesSchema.entries,
|
|
1635
|
+
...GraphFieldSchema.entries,
|
|
1636
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1637
|
+
href: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1638
|
+
isNewTab: layerField(/* @__PURE__ */ boolean(), {
|
|
1639
|
+
fallback: true
|
|
1640
|
+
})
|
|
1641
|
+
});
|
|
1642
|
+
/* @__PURE__ */ object({
|
|
1643
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1644
|
+
value: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1645
|
+
enabled: layerField(/* @__PURE__ */ boolean(), {
|
|
1646
|
+
fallback: true,
|
|
1647
|
+
variable: true
|
|
1648
|
+
}),
|
|
1649
|
+
...GraphFieldSchema.entries
|
|
1650
|
+
});
|
|
1977
1651
|
const BASE_HEADERS = {
|
|
1978
1652
|
"Content-Type": "application/json"
|
|
1979
1653
|
};
|
|
1980
1654
|
const createFetcher = (baseUrl, defaultHeaders = {}) => {
|
|
1981
|
-
const
|
|
1655
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1982
1656
|
const inflightRequests = /* @__PURE__ */ new Map();
|
|
1983
1657
|
const getCacheKey = (query2, variables, options) => JSON.stringify({ query: query2, variables, options });
|
|
1984
1658
|
const query = async (query2, variables = {}, options = {}) => {
|
|
1985
1659
|
const cacheKey = getCacheKey(query2, variables, options);
|
|
1986
|
-
if (
|
|
1987
|
-
return
|
|
1660
|
+
if (cache.has(cacheKey)) {
|
|
1661
|
+
return cache.get(cacheKey);
|
|
1988
1662
|
}
|
|
1989
1663
|
if (inflightRequests.has(cacheKey)) {
|
|
1990
1664
|
return inflightRequests.get(cacheKey);
|
|
@@ -2003,7 +1677,7 @@ const createFetcher = (baseUrl, defaultHeaders = {}) => {
|
|
|
2003
1677
|
if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
|
|
2004
1678
|
const data = await res.json();
|
|
2005
1679
|
if (!query2.includes("mutation")) {
|
|
2006
|
-
|
|
1680
|
+
cache.set(cacheKey, data);
|
|
2007
1681
|
}
|
|
2008
1682
|
return data;
|
|
2009
1683
|
}).finally(() => {
|
|
@@ -2013,33 +1687,48 @@ const createFetcher = (baseUrl, defaultHeaders = {}) => {
|
|
|
2013
1687
|
return request;
|
|
2014
1688
|
};
|
|
2015
1689
|
const invalidate = (endpoint, options) => {
|
|
2016
|
-
|
|
1690
|
+
cache.delete(getCacheKey(endpoint, options));
|
|
2017
1691
|
};
|
|
2018
|
-
const clearCache = () =>
|
|
1692
|
+
const clearCache = () => cache.clear();
|
|
2019
1693
|
return { query, invalidate, clearCache };
|
|
2020
1694
|
};
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
1695
|
+
const googleFonts = `googleFonts {
|
|
1696
|
+
id
|
|
1697
|
+
variants
|
|
1698
|
+
subsets
|
|
1699
|
+
family
|
|
1700
|
+
version
|
|
1701
|
+
files {
|
|
1702
|
+
url
|
|
1703
|
+
variant
|
|
1704
|
+
}
|
|
1705
|
+
category
|
|
1706
|
+
}`;
|
|
1707
|
+
const linkedCssChunk = `linkedCssChunk {
|
|
1708
|
+
id
|
|
1709
|
+
content
|
|
1710
|
+
}`;
|
|
1711
|
+
const fragment = `
|
|
1712
|
+
{
|
|
2026
1713
|
id
|
|
2027
1714
|
document
|
|
2028
1715
|
linkedFragments {
|
|
2029
1716
|
id
|
|
2030
1717
|
document
|
|
2031
1718
|
}
|
|
2032
|
-
|
|
1719
|
+
${googleFonts}
|
|
1720
|
+
${linkedCssChunk}
|
|
1721
|
+
}
|
|
1722
|
+
`;
|
|
1723
|
+
const getFragmentQuery = (fragmentId, isSelf) => {
|
|
1724
|
+
return {
|
|
1725
|
+
query: isSelf ? `
|
|
1726
|
+
query FragmentDocument($fragmentId: Int!) {
|
|
1727
|
+
fragment(fragmentIds: [$fragmentId]) ${fragment}
|
|
2033
1728
|
}
|
|
2034
1729
|
` : `
|
|
2035
1730
|
query FragmentDocument($fragmentId: Int!) {
|
|
2036
|
-
clientFragment(fragmentId: $fragmentId) {
|
|
2037
|
-
id
|
|
2038
|
-
document
|
|
2039
|
-
linkedFragments {
|
|
2040
|
-
id
|
|
2041
|
-
document
|
|
2042
|
-
}
|
|
1731
|
+
clientFragment(fragmentId: $fragmentId) ${fragment}
|
|
2043
1732
|
}
|
|
2044
1733
|
}`,
|
|
2045
1734
|
variables: {
|
|
@@ -2059,6 +1748,7 @@ var createConstants = (...constants) => {
|
|
|
2059
1748
|
return acc;
|
|
2060
1749
|
}, {});
|
|
2061
1750
|
};
|
|
1751
|
+
var noop = () => void 0;
|
|
2062
1752
|
var isBrowser_default = typeof window !== "undefined";
|
|
2063
1753
|
var getKey = (v) => isKey(v) ? v.slice(1) : null;
|
|
2064
1754
|
var isKey = (v) => typeof v === "string" && v.startsWith("$");
|
|
@@ -2073,6 +1763,137 @@ function hashGenerator(layerKey) {
|
|
|
2073
1763
|
const raw = Math.abs(hash).toString(36);
|
|
2074
1764
|
return /^[0-9]/.test(raw) ? `h${raw}` : raw;
|
|
2075
1765
|
}
|
|
1766
|
+
function toFontFamily(category, family) {
|
|
1767
|
+
const normalizedCategory = category.toLowerCase().trim();
|
|
1768
|
+
const safeFamily = family.includes(" ") || family.includes(",") ? `"${family}"` : family;
|
|
1769
|
+
let fallback;
|
|
1770
|
+
switch (normalizedCategory) {
|
|
1771
|
+
case "sans-serif":
|
|
1772
|
+
case "serif":
|
|
1773
|
+
const placeholder = `${family} Placeholder`;
|
|
1774
|
+
const safePlaceholder = placeholder.includes(" ") || placeholder.includes(",") ? `"${placeholder}"` : placeholder;
|
|
1775
|
+
fallback = `${safePlaceholder}, ${normalizedCategory}`;
|
|
1776
|
+
break;
|
|
1777
|
+
case "display":
|
|
1778
|
+
case "handwritten":
|
|
1779
|
+
fallback = "sans-serif";
|
|
1780
|
+
break;
|
|
1781
|
+
case "monospaced":
|
|
1782
|
+
fallback = "monospace";
|
|
1783
|
+
break;
|
|
1784
|
+
default:
|
|
1785
|
+
fallback = "sans-serif";
|
|
1786
|
+
}
|
|
1787
|
+
return `${safeFamily}, ${fallback}`;
|
|
1788
|
+
}
|
|
1789
|
+
var WEIGHT_NAMES = {
|
|
1790
|
+
100: "Thin",
|
|
1791
|
+
200: "Extra Light",
|
|
1792
|
+
300: "Light",
|
|
1793
|
+
400: "Regular",
|
|
1794
|
+
500: "Medium",
|
|
1795
|
+
600: "Semi Bold",
|
|
1796
|
+
700: "Bold",
|
|
1797
|
+
800: "Extra Bold",
|
|
1798
|
+
900: "Black"
|
|
1799
|
+
};
|
|
1800
|
+
var VARIANT_NAMES = {
|
|
1801
|
+
normal: "",
|
|
1802
|
+
italic: "Italic",
|
|
1803
|
+
"italic-normal": "Italic"
|
|
1804
|
+
};
|
|
1805
|
+
function parseFontWeight(value) {
|
|
1806
|
+
const strValue = String(value).toLowerCase();
|
|
1807
|
+
let weight = 400;
|
|
1808
|
+
let variant = "normal";
|
|
1809
|
+
const hasItalic = strValue.includes("italic");
|
|
1810
|
+
const numericMatch = strValue.match(/\d+/);
|
|
1811
|
+
if (numericMatch) {
|
|
1812
|
+
weight = parseInt(numericMatch[0], 10);
|
|
1813
|
+
} else {
|
|
1814
|
+
switch (strValue.replace("italic", "").trim()) {
|
|
1815
|
+
case "thin":
|
|
1816
|
+
weight = 100;
|
|
1817
|
+
break;
|
|
1818
|
+
case "extralight":
|
|
1819
|
+
case "extra-light":
|
|
1820
|
+
weight = 200;
|
|
1821
|
+
break;
|
|
1822
|
+
case "light":
|
|
1823
|
+
weight = 300;
|
|
1824
|
+
break;
|
|
1825
|
+
case "normal":
|
|
1826
|
+
case "regular":
|
|
1827
|
+
weight = 400;
|
|
1828
|
+
break;
|
|
1829
|
+
case "medium":
|
|
1830
|
+
weight = 500;
|
|
1831
|
+
break;
|
|
1832
|
+
case "semibold":
|
|
1833
|
+
case "semi-bold":
|
|
1834
|
+
weight = 600;
|
|
1835
|
+
break;
|
|
1836
|
+
case "bold":
|
|
1837
|
+
weight = 700;
|
|
1838
|
+
break;
|
|
1839
|
+
case "extrabold":
|
|
1840
|
+
case "extra-bold":
|
|
1841
|
+
weight = 800;
|
|
1842
|
+
break;
|
|
1843
|
+
case "black":
|
|
1844
|
+
weight = 900;
|
|
1845
|
+
break;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
if (hasItalic) {
|
|
1849
|
+
variant = "italic";
|
|
1850
|
+
if (!numericMatch && !WEIGHT_NAMES[weight]) {
|
|
1851
|
+
variant = "italic-normal";
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
return { weight, variant, name: "" };
|
|
1855
|
+
}
|
|
1856
|
+
function generateDisplayName(parsed) {
|
|
1857
|
+
const { weight, variant } = parsed;
|
|
1858
|
+
let baseName = WEIGHT_NAMES[weight] || `Weight ${weight}`;
|
|
1859
|
+
if (variant !== "normal") {
|
|
1860
|
+
if (weight === 400 && variant === "italic") {
|
|
1861
|
+
baseName = "Italic";
|
|
1862
|
+
} else if (variant === "italic-normal") {
|
|
1863
|
+
baseName = "Italic";
|
|
1864
|
+
} else if (variant === "italic") {
|
|
1865
|
+
if (weight >= 100 && weight <= 300) {
|
|
1866
|
+
baseName = `Thin Italic`;
|
|
1867
|
+
} else {
|
|
1868
|
+
const variantName = VARIANT_NAMES[variant];
|
|
1869
|
+
baseName = variantName ? `${baseName} ${variantName}` : baseName;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
return baseName.trim();
|
|
1874
|
+
}
|
|
1875
|
+
var variantOrder = {
|
|
1876
|
+
normal: 0,
|
|
1877
|
+
"italic-normal": 1,
|
|
1878
|
+
italic: 2
|
|
1879
|
+
};
|
|
1880
|
+
function getFontWeights(values) {
|
|
1881
|
+
return [...values].map((originalValue) => {
|
|
1882
|
+
const parsed = parseFontWeight(originalValue);
|
|
1883
|
+
const displayName = generateDisplayName(parsed);
|
|
1884
|
+
return {
|
|
1885
|
+
original: String(originalValue),
|
|
1886
|
+
weight: parsed.weight,
|
|
1887
|
+
variant: parsed.variant,
|
|
1888
|
+
displayName
|
|
1889
|
+
};
|
|
1890
|
+
}).sort((a2, b) => {
|
|
1891
|
+
if (a2.weight !== b.weight) {
|
|
1892
|
+
return a2.weight - b.weight;
|
|
1893
|
+
}
|
|
1894
|
+
return variantOrder[a2.variant] - variantOrder[b.variant];
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
2076
1897
|
const fetchBeacon = (baseUrl) => {
|
|
2077
1898
|
const sender = isBrowser_default && typeof (navigator == null ? void 0 : navigator.sendBeacon) === "function" ? navigator.sendBeacon : () => null;
|
|
2078
1899
|
const sendBeacon = (data) => {
|
|
@@ -2093,7 +1914,19 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2093
1914
|
areaId
|
|
2094
1915
|
campaignId
|
|
2095
1916
|
areaProperties
|
|
2096
|
-
projectProperties
|
|
1917
|
+
projectProperties
|
|
1918
|
+
font {
|
|
1919
|
+
id
|
|
1920
|
+
variants
|
|
1921
|
+
subsets
|
|
1922
|
+
family
|
|
1923
|
+
version
|
|
1924
|
+
files {
|
|
1925
|
+
url
|
|
1926
|
+
variant
|
|
1927
|
+
}
|
|
1928
|
+
category
|
|
1929
|
+
}
|
|
2097
1930
|
variant {
|
|
2098
1931
|
id
|
|
2099
1932
|
fragment {
|
|
@@ -2105,6 +1938,18 @@ projectProperties
|
|
|
2105
1938
|
id
|
|
2106
1939
|
document
|
|
2107
1940
|
}
|
|
1941
|
+
googleFonts {
|
|
1942
|
+
id
|
|
1943
|
+
variants
|
|
1944
|
+
subsets
|
|
1945
|
+
family
|
|
1946
|
+
version
|
|
1947
|
+
files {
|
|
1948
|
+
url
|
|
1949
|
+
variant
|
|
1950
|
+
}
|
|
1951
|
+
category
|
|
1952
|
+
}
|
|
2108
1953
|
}
|
|
2109
1954
|
}
|
|
2110
1955
|
}
|
|
@@ -2129,6 +1974,32 @@ const fetchPlugin = (state) => {
|
|
|
2129
1974
|
}
|
|
2130
1975
|
const fetcher = createFetcher(url, headers);
|
|
2131
1976
|
const beaconFetcher = fetchBeacon();
|
|
1977
|
+
const registerFragmentDocument = (fragmentId, fragment2) => {
|
|
1978
|
+
var _a2, _b2;
|
|
1979
|
+
const fragmentDocument = fragment2 == null ? void 0 : fragment2.document;
|
|
1980
|
+
if (!fragmentDocument) {
|
|
1981
|
+
console.error("Empty document");
|
|
1982
|
+
return null;
|
|
1983
|
+
}
|
|
1984
|
+
if (fragment2) {
|
|
1985
|
+
state.$fetch.cacheDocuments.set(fragmentId, fragmentDocument);
|
|
1986
|
+
if (Array.isArray(fragment2.linkedFragments)) {
|
|
1987
|
+
fragment2.linkedFragments.forEach(
|
|
1988
|
+
(linkedFragment) => registerFragmentDocument(linkedFragment.id, linkedFragment)
|
|
1989
|
+
);
|
|
1990
|
+
}
|
|
1991
|
+
if (Array.isArray(fragment2.linkedCssChunk)) {
|
|
1992
|
+
fragment2.linkedCssChunk.forEach(
|
|
1993
|
+
(linkedChunk) => state.$fetch.cacheCssChunks.set(linkedChunk.id, linkedChunk.content)
|
|
1994
|
+
);
|
|
1995
|
+
}
|
|
1996
|
+
if ("$fonts" in state) {
|
|
1997
|
+
(_b2 = fragment2 == null ? void 0 : fragment2.googleFonts) == null ? void 0 : _b2.forEach((_a2 = state.$fonts) == null ? void 0 : _a2.registerFont);
|
|
1998
|
+
}
|
|
1999
|
+
return fragmentDocument;
|
|
2000
|
+
}
|
|
2001
|
+
return null;
|
|
2002
|
+
};
|
|
2132
2003
|
const queryFragment = async (fragmentId) => {
|
|
2133
2004
|
var _a2;
|
|
2134
2005
|
if (!apiToken || !fragmentId) return null;
|
|
@@ -2141,45 +2012,28 @@ const fetchPlugin = (state) => {
|
|
|
2141
2012
|
fragmentQuery.variables,
|
|
2142
2013
|
{ referrerPolicy: "unsafe-url" }
|
|
2143
2014
|
);
|
|
2144
|
-
let
|
|
2015
|
+
let fragment2 = null;
|
|
2145
2016
|
if (!!(response == null ? void 0 : response.data) && "clientFragment" in response.data) {
|
|
2146
|
-
|
|
2017
|
+
fragment2 = response.data.clientFragment;
|
|
2147
2018
|
}
|
|
2148
2019
|
if (!!(response == null ? void 0 : response.data) && "fragment" in response.data) {
|
|
2149
|
-
|
|
2150
|
-
}
|
|
2151
|
-
const fragmentDocument = fragment == null ? void 0 : fragment.document;
|
|
2152
|
-
if (!fragmentDocument) {
|
|
2153
|
-
console.error("Empty document");
|
|
2154
|
-
return null;
|
|
2020
|
+
fragment2 = (_a2 = response.data.fragment) == null ? void 0 : _a2.at(0);
|
|
2155
2021
|
}
|
|
2156
|
-
|
|
2157
|
-
state.$fetch.cacheDocuments.set(fragmentId, fragmentDocument);
|
|
2158
|
-
if (Array.isArray(fragment.linkedFragments)) {
|
|
2159
|
-
fragment.linkedFragments.forEach(
|
|
2160
|
-
(linkedFragment) => state.$fetch.cacheDocuments.set(
|
|
2161
|
-
linkedFragment.id,
|
|
2162
|
-
linkedFragment.document
|
|
2163
|
-
)
|
|
2164
|
-
);
|
|
2165
|
-
}
|
|
2166
|
-
return fragmentDocument;
|
|
2167
|
-
}
|
|
2168
|
-
return null;
|
|
2022
|
+
return registerFragmentDocument(fragmentId, fragment2);
|
|
2169
2023
|
};
|
|
2170
2024
|
const queryArea = async (areaCode) => {
|
|
2171
2025
|
return queryAreaList([areaCode]).then((res) => res == null ? void 0 : res.at(0));
|
|
2172
2026
|
};
|
|
2173
|
-
const queryAreaList = async (
|
|
2027
|
+
const queryAreaList = async (areaCodes2) => {
|
|
2174
2028
|
var _a2;
|
|
2175
|
-
if (!apiToken || !
|
|
2176
|
-
const nonLoadedAreas =
|
|
2029
|
+
if (!apiToken || !areaCodes2) return null;
|
|
2030
|
+
const nonLoadedAreas = areaCodes2.filter(
|
|
2177
2031
|
(code) => !state.$fetch.cacheAreaDocuments.has(code)
|
|
2178
2032
|
);
|
|
2179
2033
|
if (!nonLoadedAreas.length) {
|
|
2180
|
-
return
|
|
2034
|
+
return areaCodes2.map(state.$fetch.cacheAreaDocuments.get);
|
|
2181
2035
|
}
|
|
2182
|
-
const areaQuery = getAreaListQuery(
|
|
2036
|
+
const areaQuery = getAreaListQuery(areaCodes2);
|
|
2183
2037
|
const response = await fetcher.query(
|
|
2184
2038
|
areaQuery.query,
|
|
2185
2039
|
areaQuery.variables,
|
|
@@ -2188,19 +2042,10 @@ const fetchPlugin = (state) => {
|
|
|
2188
2042
|
const areas = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.clientAreas;
|
|
2189
2043
|
if (areas) {
|
|
2190
2044
|
areas.forEach((area, index2) => {
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
);
|
|
2196
|
-
if (Array.isArray(area.variant.fragment.fragment.linkedFragments)) {
|
|
2197
|
-
area.variant.fragment.fragment.linkedFragments.forEach(
|
|
2198
|
-
(linkedFragment) => state.$fetch.cacheDocuments.set(
|
|
2199
|
-
linkedFragment.id,
|
|
2200
|
-
linkedFragment.document
|
|
2201
|
-
)
|
|
2202
|
-
);
|
|
2203
|
-
}
|
|
2045
|
+
var _a3;
|
|
2046
|
+
const areaCode = areaCodes2 == null ? void 0 : areaCodes2.at(index2);
|
|
2047
|
+
const areaFragment = area.variant.fragment.fragment;
|
|
2048
|
+
registerFragmentDocument(areaFragment.id, areaFragment);
|
|
2204
2049
|
const resultProps = [
|
|
2205
2050
|
...area.projectProperties ?? [],
|
|
2206
2051
|
...area.areaProperties ?? []
|
|
@@ -2213,15 +2058,20 @@ const fetchPlugin = (state) => {
|
|
|
2213
2058
|
campaignId: area.campaignId,
|
|
2214
2059
|
variantId: area.variant.id,
|
|
2215
2060
|
fragmentId: area.variant.fragment.fragment.id,
|
|
2061
|
+
font: area.font,
|
|
2216
2062
|
props: resultProps
|
|
2217
2063
|
};
|
|
2064
|
+
if ("$fonts" in state) {
|
|
2065
|
+
(_a3 = state.$fonts) == null ? void 0 : _a3.registerFont(area.font);
|
|
2066
|
+
}
|
|
2218
2067
|
state.$fetch.cacheAreaDocuments.set(areaCode, entity);
|
|
2219
2068
|
});
|
|
2220
|
-
return
|
|
2069
|
+
return areaCodes2.map((code) => state.$fetch.cacheAreaDocuments.get(code));
|
|
2221
2070
|
}
|
|
2222
2071
|
return null;
|
|
2223
2072
|
};
|
|
2224
2073
|
state.$fetch = {
|
|
2074
|
+
cacheCssChunks: /* @__PURE__ */ new Map(),
|
|
2225
2075
|
cacheDocuments: /* @__PURE__ */ new Map(),
|
|
2226
2076
|
cacheAreaDocuments: /* @__PURE__ */ new Map(),
|
|
2227
2077
|
queryFragment,
|
|
@@ -2229,6 +2079,7 @@ const fetchPlugin = (state) => {
|
|
|
2229
2079
|
queryAreaList,
|
|
2230
2080
|
query: fetcher.query,
|
|
2231
2081
|
sendBeacon: beaconFetcher.sendBeacon,
|
|
2082
|
+
readCssChunk: (id) => state.$fetch.cacheCssChunks.get(id) ?? null,
|
|
2232
2083
|
readFragment: (fragmentId) => state.$fetch.cacheDocuments.get(fragmentId) ?? null,
|
|
2233
2084
|
readArea: (areaCode) => state.$fetch.cacheAreaDocuments.get(areaCode) ?? null
|
|
2234
2085
|
};
|
|
@@ -2237,11 +2088,11 @@ const getAllChildren = (layerResolver, layerKey, acc = []) => {
|
|
|
2237
2088
|
var _a;
|
|
2238
2089
|
const layer = layerResolver(layerKey) ?? {};
|
|
2239
2090
|
if (acc.length === 0) {
|
|
2240
|
-
acc.push(
|
|
2091
|
+
acc.push($(layerKey));
|
|
2241
2092
|
}
|
|
2242
2093
|
(_a = layer == null ? void 0 : layer.children) == null ? void 0 : _a.forEach((child) => {
|
|
2243
2094
|
if (child) {
|
|
2244
|
-
acc.push(
|
|
2095
|
+
acc.push($(child));
|
|
2245
2096
|
getAllChildren(layerResolver, child, acc);
|
|
2246
2097
|
}
|
|
2247
2098
|
});
|
|
@@ -2303,53 +2154,56 @@ const makeCss = (styles, layerResolver) => (layerKey) => {
|
|
|
2303
2154
|
css: toCSS(resultCssRules) + cssOverride
|
|
2304
2155
|
};
|
|
2305
2156
|
};
|
|
2157
|
+
const injectStyle = (id, styles) => {
|
|
2158
|
+
if (!styles || !isBrowser_default) {
|
|
2159
|
+
return noop;
|
|
2160
|
+
}
|
|
2161
|
+
const existing = document.getElementById(id);
|
|
2162
|
+
if (existing && existing.tagName === "STYLE") {
|
|
2163
|
+
existing.textContent = styles;
|
|
2164
|
+
return;
|
|
2165
|
+
}
|
|
2166
|
+
if (existing) existing.remove();
|
|
2167
|
+
const style = document.createElement("style");
|
|
2168
|
+
style.id = id;
|
|
2169
|
+
style.textContent = styles;
|
|
2170
|
+
document.head.appendChild(style);
|
|
2171
|
+
return () => {
|
|
2172
|
+
style.remove();
|
|
2173
|
+
};
|
|
2174
|
+
};
|
|
2306
2175
|
const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
2307
2176
|
let countDepends = 0;
|
|
2308
|
-
const removeStyle = () => {
|
|
2177
|
+
const removeStyle = (customKey) => {
|
|
2178
|
+
const resultKey = customKey ?? key;
|
|
2309
2179
|
if (!isBrowser_default) return;
|
|
2310
2180
|
countDepends--;
|
|
2311
2181
|
if (countDepends <= 0) {
|
|
2312
|
-
const el = document.getElementById(
|
|
2182
|
+
const el = document.getElementById(resultKey);
|
|
2313
2183
|
if (el) el.remove();
|
|
2314
2184
|
}
|
|
2315
2185
|
};
|
|
2316
|
-
const injectStyle = (styles) => {
|
|
2317
|
-
if (!isBrowser_default) return;
|
|
2318
|
-
if (!styles) {
|
|
2319
|
-
removeStyle();
|
|
2320
|
-
return;
|
|
2321
|
-
}
|
|
2322
|
-
countDepends++;
|
|
2323
|
-
const existing = document.getElementById(key);
|
|
2324
|
-
if (existing && existing.tagName === "STYLE") {
|
|
2325
|
-
existing.textContent = styles;
|
|
2326
|
-
return;
|
|
2327
|
-
}
|
|
2328
|
-
if (existing) existing.remove();
|
|
2329
|
-
const style = document.createElement("style");
|
|
2330
|
-
style.id = key;
|
|
2331
|
-
style.textContent = styles;
|
|
2332
|
-
document.head.appendChild(style);
|
|
2333
|
-
};
|
|
2334
2186
|
let isMounted = false;
|
|
2335
2187
|
let pendingStyles = "";
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2188
|
+
if (graphKey) {
|
|
2189
|
+
state.subscribe(
|
|
2190
|
+
graphKey,
|
|
2191
|
+
(next) => {
|
|
2192
|
+
const styles = (transformStyles == null ? void 0 : transformStyles(next)) ?? (next == null ? void 0 : next.styles) ?? [];
|
|
2193
|
+
const resultStyle = styles.join("\n");
|
|
2194
|
+
pendingStyles = resultStyle;
|
|
2195
|
+
if (isMounted) {
|
|
2196
|
+
injectStyle(key, resultStyle);
|
|
2197
|
+
}
|
|
2198
|
+
},
|
|
2199
|
+
{ directChangesOnly: true }
|
|
2200
|
+
);
|
|
2201
|
+
}
|
|
2348
2202
|
const mount = () => {
|
|
2349
2203
|
isMounted = true;
|
|
2350
2204
|
if (pendingStyles) {
|
|
2351
2205
|
countDepends++;
|
|
2352
|
-
injectStyle(pendingStyles);
|
|
2206
|
+
injectStyle(key, pendingStyles);
|
|
2353
2207
|
} else {
|
|
2354
2208
|
removeStyle();
|
|
2355
2209
|
}
|
|
@@ -2358,7 +2212,7 @@ const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
|
2358
2212
|
isMounted = false;
|
|
2359
2213
|
removeStyle();
|
|
2360
2214
|
};
|
|
2361
|
-
return { mount, unmount };
|
|
2215
|
+
return { mount, unmount, injectStyle, removeStyle };
|
|
2362
2216
|
};
|
|
2363
2217
|
function generatePrimaryCssBlocks(layerResolver, group, cssMaker) {
|
|
2364
2218
|
const children = getAllChildren(layerResolver, group.primary);
|
|
@@ -2409,7 +2263,7 @@ function extractStyleSheet(styles, layerResolver) {
|
|
|
2409
2263
|
);
|
|
2410
2264
|
return fragmentCssRules;
|
|
2411
2265
|
}
|
|
2412
|
-
const fragmentStylesheetPlugin = (state) => {
|
|
2266
|
+
const fragmentStylesheetPlugin = (globalState) => (state) => {
|
|
2413
2267
|
const KEY = `${PLUGIN_TYPES.FragmentStylesheet}:root`;
|
|
2414
2268
|
const addStyle = (layerKey, style) => {
|
|
2415
2269
|
state.mutate(KEY, {
|
|
@@ -2421,9 +2275,26 @@ const fragmentStylesheetPlugin = (state) => {
|
|
|
2421
2275
|
state.mutate(KEY, {
|
|
2422
2276
|
styles: {}
|
|
2423
2277
|
});
|
|
2424
|
-
const fragmentStyleInjector = autoInjector(
|
|
2425
|
-
|
|
2426
|
-
|
|
2278
|
+
const fragmentStyleInjector = autoInjector(
|
|
2279
|
+
state.key,
|
|
2280
|
+
state,
|
|
2281
|
+
KEY,
|
|
2282
|
+
(graph) => {
|
|
2283
|
+
return extractStyleSheet(graph.styles, state.resolve);
|
|
2284
|
+
}
|
|
2285
|
+
);
|
|
2286
|
+
const addCssChunk = (chunkId) => {
|
|
2287
|
+
var _a, _b, _c, _d;
|
|
2288
|
+
const chunkContent = (_b = (_a = globalState == null ? void 0 : globalState.$fetch) == null ? void 0 : _a.readCssChunk) == null ? void 0 : _b.call(_a, chunkId);
|
|
2289
|
+
if (chunkContent) {
|
|
2290
|
+
return (_d = (_c = globalState == null ? void 0 : globalState.$globalStylesheet) == null ? void 0 : _c.addDependStyle) == null ? void 0 : _d.call(
|
|
2291
|
+
_c,
|
|
2292
|
+
`CssChunk:${chunkId}`,
|
|
2293
|
+
chunkContent
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
return noop;
|
|
2297
|
+
};
|
|
2427
2298
|
const destroyStyles = () => {
|
|
2428
2299
|
state.mutate(
|
|
2429
2300
|
KEY,
|
|
@@ -2437,12 +2308,16 @@ const fragmentStylesheetPlugin = (state) => {
|
|
|
2437
2308
|
state.$styleSheet = {
|
|
2438
2309
|
key: KEY,
|
|
2439
2310
|
addStyle,
|
|
2311
|
+
addCssChunk,
|
|
2440
2312
|
mount: fragmentStyleInjector.mount,
|
|
2441
2313
|
unmount: destroyStyles,
|
|
2442
2314
|
extract: (withTag) => {
|
|
2443
2315
|
var _a;
|
|
2444
2316
|
const graph = state.resolve(KEY);
|
|
2445
|
-
const styles = extractStyleSheet(
|
|
2317
|
+
const styles = extractStyleSheet(
|
|
2318
|
+
graph == null ? void 0 : graph.styles,
|
|
2319
|
+
state.resolve
|
|
2320
|
+
);
|
|
2446
2321
|
const resultStyle = styles.join("\n");
|
|
2447
2322
|
if (withTag) {
|
|
2448
2323
|
const id = state.entityOfKey((_a = state.$fragment) == null ? void 0 : _a.root);
|
|
@@ -2464,15 +2339,25 @@ const globalStylesheetPlugin = (state) => {
|
|
|
2464
2339
|
styles: [style]
|
|
2465
2340
|
});
|
|
2466
2341
|
};
|
|
2342
|
+
const addDependStyle = (key, style) => {
|
|
2343
|
+
globalStyleInjector.injectStyle(key, style);
|
|
2344
|
+
return () => globalStyleInjector.removeStyle(key);
|
|
2345
|
+
};
|
|
2467
2346
|
state.mutate({
|
|
2468
2347
|
_type: PLUGIN_TYPES.GlobalStylesheet,
|
|
2469
2348
|
_id: "root",
|
|
2470
2349
|
styles: []
|
|
2471
2350
|
});
|
|
2472
2351
|
const globalStyleInjector = autoInjector("global", state, KEY);
|
|
2352
|
+
const addStyleTag = (key, style) => {
|
|
2353
|
+
globalStyleInjector.injectStyle(style, key);
|
|
2354
|
+
return () => globalStyleInjector.removeStyle(key);
|
|
2355
|
+
};
|
|
2473
2356
|
state.$globalStylesheet = {
|
|
2474
2357
|
key: KEY,
|
|
2475
2358
|
addStyle,
|
|
2359
|
+
addDependStyle,
|
|
2360
|
+
addStyleTag,
|
|
2476
2361
|
mount: globalStyleInjector.mount,
|
|
2477
2362
|
unmount: globalStyleInjector.unmount,
|
|
2478
2363
|
extractStyles: () => {
|
|
@@ -2518,7 +2403,7 @@ const fragmentsPlugin = (options) => (state) => {
|
|
|
2518
2403
|
_type: "Spring",
|
|
2519
2404
|
_id: "root"
|
|
2520
2405
|
};
|
|
2521
|
-
const manager =
|
|
2406
|
+
const manager = kt({
|
|
2522
2407
|
_type: "FragmentManager",
|
|
2523
2408
|
_id: fragmentId,
|
|
2524
2409
|
initialState: initialDocument,
|
|
@@ -2530,7 +2415,7 @@ const fragmentsPlugin = (options) => (state) => {
|
|
|
2530
2415
|
};
|
|
2531
2416
|
},
|
|
2532
2417
|
// cssPlugin,
|
|
2533
|
-
fragmentStylesheetPlugin,
|
|
2418
|
+
fragmentStylesheetPlugin(state),
|
|
2534
2419
|
scopesPlugin,
|
|
2535
2420
|
...plugins
|
|
2536
2421
|
],
|
|
@@ -2705,7 +2590,11 @@ const loadPlugin = (state) => {
|
|
|
2705
2590
|
const readFragment = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.readFragment(fragmentId);
|
|
2706
2591
|
const fragmentManager = (_b = state == null ? void 0 : state.$fragments) == null ? void 0 : _b.getManager(fragmentId);
|
|
2707
2592
|
if (readFragment && !fragmentManager) {
|
|
2708
|
-
|
|
2593
|
+
const fragmentManager2 = state.$fragments.createFragmentManager(
|
|
2594
|
+
fragmentId,
|
|
2595
|
+
readFragment
|
|
2596
|
+
);
|
|
2597
|
+
return fragmentManager2;
|
|
2709
2598
|
}
|
|
2710
2599
|
if (readFragment && fragmentManager) return fragmentManager;
|
|
2711
2600
|
const loader = async () => {
|
|
@@ -2750,6 +2639,56 @@ const loadPlugin = (state) => {
|
|
|
2750
2639
|
readArea
|
|
2751
2640
|
};
|
|
2752
2641
|
};
|
|
2642
|
+
const fontsPlugin = (state) => {
|
|
2643
|
+
const fonts = /* @__PURE__ */ new Map();
|
|
2644
|
+
let defaultFontFamily = null;
|
|
2645
|
+
const registerFont = (font) => {
|
|
2646
|
+
const fontFamily = font.family;
|
|
2647
|
+
if (!fonts.has(fontFamily)) {
|
|
2648
|
+
fonts.set(fontFamily, font);
|
|
2649
|
+
getStyles();
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
const setDefaultFont = (fontFamily) => {
|
|
2653
|
+
defaultFontFamily = fontFamily;
|
|
2654
|
+
getStyles();
|
|
2655
|
+
};
|
|
2656
|
+
const getStyles = () => {
|
|
2657
|
+
const styles = [];
|
|
2658
|
+
for (const [fontFamily, font] of fonts) {
|
|
2659
|
+
const files = font.files ?? [];
|
|
2660
|
+
for (const file of files) {
|
|
2661
|
+
const [weightItem] = getFontWeights([file.variant]);
|
|
2662
|
+
styles.push(`@font-face {
|
|
2663
|
+
font-family: '${fontFamily}';
|
|
2664
|
+
font-style: ${weightItem.variant};
|
|
2665
|
+
font-weight: ${weightItem.weight};
|
|
2666
|
+
font-display: swap;
|
|
2667
|
+
src: url(${file.url}) format('woff2');
|
|
2668
|
+
}`);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
if (defaultFontFamily) {
|
|
2672
|
+
const font = fonts.get(defaultFontFamily);
|
|
2673
|
+
if (font) {
|
|
2674
|
+
const fontFamily = toFontFamily(font.category, font.family);
|
|
2675
|
+
styles.push(`
|
|
2676
|
+
[data-key^="Fragment"] {
|
|
2677
|
+
* {
|
|
2678
|
+
font-family: ${fontFamily}, sans-serif;
|
|
2679
|
+
}
|
|
2680
|
+
}`);
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
injectStyle("fonts", styles.join("\n"));
|
|
2684
|
+
};
|
|
2685
|
+
state.$fonts = {
|
|
2686
|
+
fonts,
|
|
2687
|
+
registerFont,
|
|
2688
|
+
setDefaultFont
|
|
2689
|
+
};
|
|
2690
|
+
return state;
|
|
2691
|
+
};
|
|
2753
2692
|
const PLUGIN_TYPES = createConstants(
|
|
2754
2693
|
"FragmentsPlugin",
|
|
2755
2694
|
"GlobalStylesheet",
|
|
@@ -2757,7 +2696,7 @@ const PLUGIN_TYPES = createConstants(
|
|
|
2757
2696
|
);
|
|
2758
2697
|
const createFragmentsClient = (options) => {
|
|
2759
2698
|
const BACKEND_TARGET = (options == null ? void 0 : options.isSelf) ? "/graphql" : "http://85.192.29.65/graphql";
|
|
2760
|
-
return
|
|
2699
|
+
return kt({
|
|
2761
2700
|
_type: "GlobalManager",
|
|
2762
2701
|
initialState: {},
|
|
2763
2702
|
skip: [
|
|
@@ -2776,12 +2715,14 @@ const createFragmentsClient = (options) => {
|
|
|
2776
2715
|
};
|
|
2777
2716
|
},
|
|
2778
2717
|
fetchPlugin,
|
|
2718
|
+
fontsPlugin,
|
|
2779
2719
|
fragmentsPlugin({
|
|
2780
2720
|
plugins: options == null ? void 0 : options.fragmentPlugins
|
|
2781
2721
|
}),
|
|
2782
2722
|
loadPlugin,
|
|
2783
2723
|
globalMetricsPlugin,
|
|
2784
2724
|
globalStylesheetPlugin
|
|
2725
|
+
// stylesPlugin,
|
|
2785
2726
|
]
|
|
2786
2727
|
});
|
|
2787
2728
|
};
|