@fragmentsx/client-core 0.0.1 → 0.1.1
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 +19 -0
- package/dist/fragmentsClient.d.ts.map +1 -1
- package/dist/index.cjs.js +1508 -562
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1509 -563
- package/dist/plugins/fetch/fetcher.d.ts +3 -1
- package/dist/plugins/fetch/fetcher.d.ts.map +1 -1
- package/dist/plugins/fetch/index.d.ts +25 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/queries/AreaListQuery.d.ts +24 -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 +27 -1
- package/dist/plugins/fetch/queries/FragmentQuery.d.ts.map +1 -1
- package/dist/plugins/fragments/index.d.ts +16 -2
- package/dist/plugins/fragments/index.d.ts.map +1 -1
- 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.map +1 -1
- 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 +2 -2
- package/dist/plugins/styleSheet/index.d.ts.map +1 -1
- package/dist/plugins/styleSheet/utils/autoInjector.d.ts +7 -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/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/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/package.json +8 -5
- package/dist/plugins/fetch/queries/LandingQuery.d.ts +0 -2
- package/dist/plugins/fetch/queries/LandingQuery.d.ts.map +0 -1
- package/dist/plugins/styleSheet/buildCssBlock.d.ts +0 -2
- package/dist/plugins/styleSheet/buildCssBlock.d.ts.map +0 -1
- package/dist/plugins/styleSheet/compareRules.d.ts +0 -4
- package/dist/plugins/styleSheet/compareRules.d.ts.map +0 -1
- package/dist/plugins/styleSheet/findGroups.d.ts +0 -8
- package/dist/plugins/styleSheet/findGroups.d.ts.map +0 -1
- package/dist/plugins/styleSheet/getAllChildren.d.ts +0 -3
- package/dist/plugins/styleSheet/getAllChildren.d.ts.map +0 -1
- package/dist/plugins/styleSheet/makeCss.d.ts +0 -6
- package/dist/plugins/styleSheet/makeCss.d.ts.map +0 -1
- package/dist/plugins/styleSheet/toCSS.d.ts +0 -2
- package/dist/plugins/styleSheet/toCSS.d.ts.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,419 +1,634 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var r = (e) => !e && e == null, y = (e) => !r(e), a = (e) => typeof e == "object" && !Array.isArray(e) && y(e), f = (e) => typeof Node == "object" ? e instanceof Node : e && typeof e == "object" && typeof e.nodeType == "number" && typeof e.nodeName == "string", i = (e) => typeof e == "string" || t(e), t = (e) => typeof e == "object" && typeof e._type == "string", s = (e) => typeof e == "string" && e.split(":").length >= 2, l = (e) => typeof e != "object" && typeof e != "function" || e === null, g = (e) => typeof e == "string" ? /<\/?[a-z][\s\S]*>/i.test(e) : false, u = (e) => (n) => {
|
|
2
|
+
var _a;
|
|
3
|
+
if (!n) return false;
|
|
4
|
+
let o = null;
|
|
5
|
+
return s(n) && (o = (_a = n.split(":")) == null ? void 0 : _a[0]), t(n) && (o = n._type), o ? !e.includes(o) : false;
|
|
6
|
+
};
|
|
7
|
+
var isLinkKey = (input) => s(input);
|
|
8
|
+
var isGraphOrKey = (input) => i(input);
|
|
9
|
+
var isGraph = (input) => t(input);
|
|
10
|
+
var isObject$1 = (input) => a(input);
|
|
11
|
+
var shallowEqual = (a2, b) => {
|
|
12
|
+
if (a2 === b)
|
|
13
|
+
return true;
|
|
14
|
+
if (Array.isArray(a2) && Array.isArray(b)) {
|
|
15
|
+
return a2.length === b.length && a2.every((val, index2) => b[index2] === val);
|
|
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;
|
|
12
30
|
}
|
|
13
31
|
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
};
|
|
33
|
+
var deepEqual = (a2, b) => {
|
|
34
|
+
if (a2 === b)
|
|
35
|
+
return true;
|
|
36
|
+
if (Array.isArray(a2) && Array.isArray(b)) {
|
|
37
|
+
return a2.length === b.length && a2.every((val, i2) => deepEqual(val, b[i2]));
|
|
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
|
+
}
|
|
21
51
|
return true;
|
|
22
52
|
};
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
var unique = (...values) => Array.from(new Set(values));
|
|
54
|
+
var uniqueLinks = (...values) => values.filter((item, index2, arr) => s(item) ? arr.indexOf(item) === index2 : true);
|
|
55
|
+
var isPartialKey = (key) => key && key.split(".").length > 1;
|
|
56
|
+
var isPartialGraph = (entity) => {
|
|
57
|
+
if (isObject$1(entity) && "_id" in entity && typeof entity._id === "string") {
|
|
58
|
+
return entity._id.includes(".");
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
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) => {
|
|
32
90
|
var _a;
|
|
33
|
-
|
|
34
|
-
|
|
91
|
+
parentRefs.set(targetKey, unique(...parentRefs.get(targetKey) || [], depKey));
|
|
92
|
+
childrenRefs.set(depKey, unique(...childrenRefs.get(depKey) ?? [], targetKey));
|
|
93
|
+
updateRefCountForLink(targetKey, ((_a = parentRefs.get(targetKey)) == null ? void 0 : _a.length) || 0);
|
|
94
|
+
};
|
|
95
|
+
const removeRefs = (targetKey, depKey) => {
|
|
35
96
|
var _a;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
97
|
+
parentRefs.set(
|
|
98
|
+
depKey,
|
|
99
|
+
(parentRefs.get(depKey) || []).filter((key) => key !== targetKey)
|
|
100
|
+
);
|
|
101
|
+
childrenRefs.set(
|
|
102
|
+
targetKey,
|
|
103
|
+
(childrenRefs.get(targetKey) ?? []).filter((key) => key !== depKey)
|
|
104
|
+
);
|
|
105
|
+
updateRefCountForLink(depKey, ((_a = parentRefs.get(depKey)) == null ? void 0 : _a.length) || 0);
|
|
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) => {
|
|
45
125
|
var _a;
|
|
46
|
-
if (typeof
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
126
|
+
if (typeof key === "string") {
|
|
127
|
+
links.set(key, value);
|
|
128
|
+
const [type] = key.split(":");
|
|
129
|
+
if (!isPartialKey(key)) {
|
|
130
|
+
if (!types2.has(type)) {
|
|
131
|
+
types2.set(type, /* @__PURE__ */ new Set([key]));
|
|
132
|
+
} else {
|
|
133
|
+
(_a = types2.get(type)) == null ? void 0 : _a.add(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (depKey && key && key !== depKey) {
|
|
138
|
+
addRefs(key, depKey);
|
|
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 = () => {
|
|
59
163
|
var _a, _b;
|
|
60
|
-
for (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
164
|
+
for (const link of gbLinks.keys()) {
|
|
165
|
+
const count = getRefCount(link);
|
|
166
|
+
if (count > 0)
|
|
167
|
+
continue;
|
|
168
|
+
const currentValue = links.get(link);
|
|
169
|
+
gbLinks.delete(link);
|
|
170
|
+
links.delete(link);
|
|
171
|
+
refCount.delete(link);
|
|
172
|
+
const parents = parentRefs.get(link) ?? [];
|
|
173
|
+
const children = childrenRefs.get(link) ?? [];
|
|
174
|
+
parents.forEach((parentKey) => {
|
|
66
175
|
var _a2, _b2;
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
|
|
176
|
+
childrenRefs.set(parentKey, ((_b2 = (_a2 = childrenRefs.get(parentKey)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (childLink) => childLink !== link)) ?? []);
|
|
177
|
+
});
|
|
178
|
+
children.forEach((childKey) => {
|
|
179
|
+
updateRefCountForLink(childKey, getRefCount(childKey) - 1);
|
|
70
180
|
});
|
|
71
|
-
|
|
72
|
-
|
|
181
|
+
const [type] = link.split(":");
|
|
182
|
+
if (!isPartialKey(link)) {
|
|
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));
|
|
73
190
|
}
|
|
74
191
|
};
|
|
75
|
-
return {
|
|
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
|
+
};
|
|
76
211
|
};
|
|
77
|
-
var
|
|
212
|
+
var joinKeys = (...keys) => {
|
|
78
213
|
var _a;
|
|
79
|
-
return (_a =
|
|
80
|
-
};
|
|
81
|
-
var ae = process.env.NODE_ENV !== "production";
|
|
82
|
-
var ce = (t2 = []) => {
|
|
83
|
-
let s2 = [], p2 = (a2) => {
|
|
84
|
-
s2.push(a2);
|
|
85
|
-
}, c = (a2) => s2.reduce((h, l) => l(h) ?? h, a2);
|
|
86
|
-
return t2.forEach(p2), { use: p2, runPlugins: c };
|
|
87
|
-
};
|
|
88
|
-
var le = (t2) => t2 && S(t2) ? ["_id", "_type", "key", "mutate", "resolve"].every((p2) => p2 in t2) : false;
|
|
89
|
-
var ue = () => {
|
|
90
|
-
let t2 = /* @__PURE__ */ new Set();
|
|
91
|
-
return { debug: (c) => {
|
|
92
|
-
t2.forEach((a2) => {
|
|
93
|
-
a2({ ...c, timestamp: Date.now() });
|
|
94
|
-
});
|
|
95
|
-
}, onDebugEvent: (c) => {
|
|
96
|
-
t2.add(c);
|
|
97
|
-
} };
|
|
214
|
+
return (_a = keys == null ? void 0 : keys.filter(Boolean)) == null ? void 0 : _a.join(".");
|
|
98
215
|
};
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
I(o) || l.removeRefs(r2, o);
|
|
113
|
-
});
|
|
114
|
-
}, $ = (e, r2, i$1) => {
|
|
115
|
-
var _a, _b, _c, _d;
|
|
116
|
-
if ((!e || i(e)) && !G(e) || P(e)) return e;
|
|
117
|
-
let o = te(e) ? E(e) : e;
|
|
118
|
-
if (G(o)) {
|
|
119
|
-
let y2 = ie(r2) ?? "", u = ((_a = i$1 == null ? void 0 : i$1.internal) == null ? void 0 : _a.visitors.get(y2)) ?? [], L = ((_b = i$1 == null ? void 0 : i$1.internal) == null ? void 0 : _b.visitors.get(o)) ?? [];
|
|
120
|
-
if (u.includes(o) || o === y2) return null;
|
|
121
|
-
(_d = (_c = i$1 == null ? void 0 : i$1.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(o, [...L, y2]);
|
|
122
|
-
}
|
|
123
|
-
if (Array.isArray(e)) return e.map((y2) => {
|
|
124
|
-
let u = r2 ? J(r2, `${pe()}`) : void 0;
|
|
125
|
-
return $(y2, u, i$1);
|
|
126
|
-
});
|
|
127
|
-
let m = (G(e) ? e : ne(e) ? E(e) : null) ?? r2;
|
|
128
|
-
return ((i$1 == null ? void 0 : i$1.overrideMutateMethod) || j)(m, e, i$1);
|
|
129
|
-
}, j = (e, ...r2) => {
|
|
130
|
-
let { graphKey: i2, options: o, data: f } = A(e, ...r2);
|
|
131
|
-
O.debug({ type: "beforeMutate", entity: i2, data: f, options: o });
|
|
132
|
-
let m = G(f) ? C(f) : f, d = i2 ?? a2, y2 = I == null ? void 0 : I(d), u = o == null ? void 0 : o.parent, L = R(d ?? ""), w = (o == null ? void 0 : o.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) }, v = { ...m, ...C(d) }, K = !(o == null ? void 0 : o.parent), D = (o == null ? void 0 : o.replace) ? typeof (o == null ? void 0 : o.replace) == "function" ? o.replace(v) : (o == null ? void 0 : o.replace) === "deep" ? true : K || y2 : false;
|
|
133
|
-
if (P(m)) return l.writeLink(d, m, u), d;
|
|
134
|
-
!D && S(L) && S(v) && (v = { ...L, ...v }), D && M(d);
|
|
135
|
-
let Q = Object.entries(v).reduce((X, [N, de]) => {
|
|
136
|
-
let Z = J(d, N), b2 = de, F = L == null ? void 0 : L[N], he = S(m) && N in m;
|
|
137
|
-
P(b2) || (!D && he && Array.isArray(b2) && Array.isArray(F) && (b2 = [...F, ...b2]), (S(b2) || Array.isArray(b2) || G(b2)) && (b2 = $(b2, Z, { ...o, parent: d, internal: w })), Array.isArray(b2) && (o == null ? void 0 : o.dedup) !== false && (b2 = se(...b2)));
|
|
138
|
-
let me = re(F, Z === b2 ? _(b2) : b2);
|
|
139
|
-
return w.hasChange = w.hasChange || !me, !D && G(F) && F !== b2 && l.removeRefs(d, F), X[N] = b2, X;
|
|
140
|
-
}, {});
|
|
141
|
-
return l.writeLink(d, Q, u), u || l.runGarbageCollector(), (w.hasChange || D) && n2(d, L), O.debug({ type: "afterMutate", entity: i2, data: f, nextData: Q, options: o, hasChange: w.hasChange }), d;
|
|
142
|
-
}, B = (e) => {
|
|
143
|
-
let r2 = E(e);
|
|
144
|
-
if (O.debug({ type: "invalidate", entity: r2 }), r2) {
|
|
145
|
-
let i2 = l.getParents(r2) || [];
|
|
146
|
-
l.invalidate(r2), i2.forEach((o) => {
|
|
147
|
-
let f = l.readLink(o), m = R(o, { safe: false, keepLinks: true });
|
|
148
|
-
l.writeLink(o, m), n2(o, f);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}, n2 = (e, r2) => {
|
|
152
|
-
if (V > Se) throw new Error("Too deep notify.");
|
|
153
|
-
let i2 = E(e);
|
|
154
|
-
if (O.debug({ type: "notify", entity: i2 }), i2) {
|
|
155
|
-
V++;
|
|
156
|
-
let o = [...T.get(i2) || [], ...T.get(fe) || []], f = l.getChildren(i2) || [], m = R(i2), d = (y2) => {
|
|
157
|
-
let u = m && (y2 == null ? void 0 : y2(m)), L = r2 && (y2 == null ? void 0 : y2(r2));
|
|
158
|
-
return { next: u, prev: L, hasChange: !W(u, L) };
|
|
159
|
-
};
|
|
160
|
-
o.forEach(({ callback: y2, selector: u }) => {
|
|
161
|
-
if (u) {
|
|
162
|
-
let { next: L, prev: w, hasChange: v } = d(u);
|
|
163
|
-
v && y2(L, w);
|
|
164
|
-
} else y2(m, r2);
|
|
165
|
-
}), f.forEach((y2) => n2(y2, r2));
|
|
166
|
-
}
|
|
167
|
-
V = 0;
|
|
168
|
-
}, g = (...e) => {
|
|
169
|
-
let r2 = typeof e[0] == "function" ? fe : e[0], i2 = typeof e[0] == "function" ? e[0] : e[1], o = typeof e[0] == "function" ? e[1] : e[2], f = E(r2), m = o == null ? void 0 : o.selector;
|
|
170
|
-
f && (T.has(f) ? T.set(f, [...Array.from(T.get(f) || []), { callback: i2, selector: m }]) : T.set(f, [{ callback: i2, selector: m }]), l.onRemoveLink((y2, u) => {
|
|
171
|
-
y2 === f && n2(f, u);
|
|
172
|
-
}));
|
|
173
|
-
let d = () => {
|
|
174
|
-
if (f) {
|
|
175
|
-
let y2 = (T.get(f) || []).findIndex((u) => u.callback === i2);
|
|
176
|
-
if (y2 !== -1) {
|
|
177
|
-
let u = T.get(f) || [];
|
|
178
|
-
u.splice(y2, 1), T.set(f, u);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
return (o == null ? void 0 : o.signal) && o.signal.addEventListener("abort", d, { once: true }), d;
|
|
183
|
-
}, k = (e) => [...l.types.get(e) ?? []], x = (e) => {
|
|
184
|
-
let r2 = (typeof e == "string" ? e : E(e)) || "";
|
|
185
|
-
return (l.getParents(r2) ?? []).map((o) => R(o));
|
|
186
|
-
}, E = (e) => {
|
|
187
|
-
var _a;
|
|
188
|
-
if (typeof e == "string") return C(e) ? e : null;
|
|
189
|
-
if (!(e == null ? void 0 : e._type)) return null;
|
|
190
|
-
let r2 = null;
|
|
191
|
-
return e._type in c ? r2 = ((_a = c[e._type]) == null ? void 0 : _a.call(c, e)) ?? null : (s(e.id) || s(e._id)) && (r2 = `${e.id ?? e._id}`), r2 && `${e._type}:${r2}`;
|
|
192
|
-
}, C = (e) => {
|
|
193
|
-
if (S(e) && (e == null ? void 0 : e._type) && E(e)) return e;
|
|
194
|
-
if (!e || typeof e != "string") return null;
|
|
195
|
-
let [r2, ...i2] = e.split(":");
|
|
196
|
-
return !r2 || i2.length < 1 ? null : { _type: r2, _id: i2.join(":") };
|
|
197
|
-
}, A = (e, ...r2) => {
|
|
198
|
-
let i2 = typeof e == "string" ? r2[0] : e;
|
|
199
|
-
return typeof i2 == "function" ? i2 = i2(R(e)) : G(i2) && (i2 = C(i2)), { graphKey: typeof e == "string" ? e : E(e), options: typeof e == "string" ? r2[1] : r2[0], data: i2 };
|
|
200
|
-
};
|
|
201
|
-
function U(e) {
|
|
202
|
-
q.use(e), e(this);
|
|
203
|
-
}
|
|
204
|
-
let ye = (e) => {
|
|
205
|
-
h.push(e);
|
|
216
|
+
var isDev = process.env.NODE_ENV !== "production";
|
|
217
|
+
var createPluginsState = (initialPlugins = []) => {
|
|
218
|
+
const plugins = [];
|
|
219
|
+
const use = (plugin) => {
|
|
220
|
+
plugins.push(plugin);
|
|
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
|
|
206
229
|
};
|
|
207
|
-
(t2 == null ? void 0 : t2.initialState) && j(t2.initialState, { replace: true });
|
|
208
|
-
let ge = { _type: p2, _id: s$1, key: a2, mutate: j, subscribe: g, resolve: R, safeResolve: _, resolveParents: x, inspectFields: k, invalidate: B, keyOfEntity: E, entityOfKey: C, getArgumentsForMutate: A, types: l.types, cache: l, use: U, addSkip: ye, subscribers: ae ? T : void 0, onDebugEvent: O.onDebugEvent };
|
|
209
|
-
return l.onRemoveLink((e, r2) => O.debug({ type: "garbageRemove", entity: e, prevValue: r2 })), q.runPlugins(ge);
|
|
210
230
|
};
|
|
211
|
-
|
|
212
|
-
|
|
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;
|
|
213
239
|
};
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
if (inflightRequests.has(cacheKey)) {
|
|
224
|
-
return inflightRequests.get(cacheKey);
|
|
225
|
-
}
|
|
226
|
-
const request = fetch(baseUrl, {
|
|
227
|
-
...options,
|
|
228
|
-
method: "POST",
|
|
229
|
-
body: JSON.stringify({ query: query2, variables }),
|
|
230
|
-
headers: {
|
|
231
|
-
...BASE_HEADERS,
|
|
232
|
-
...defaultHeaders,
|
|
233
|
-
...options.headers
|
|
234
|
-
}
|
|
235
|
-
}).then(async (res) => {
|
|
236
|
-
if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
|
|
237
|
-
const data = await res.json();
|
|
238
|
-
if (!query2.includes("mutation")) {
|
|
239
|
-
cache.set(cacheKey, data);
|
|
240
|
-
}
|
|
241
|
-
return data;
|
|
242
|
-
}).finally(() => {
|
|
243
|
-
inflightRequests.delete(cacheKey);
|
|
240
|
+
var createDebugState = () => {
|
|
241
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
242
|
+
const onDebugEvent = (callback) => {
|
|
243
|
+
listeners.add(callback);
|
|
244
|
+
};
|
|
245
|
+
const debug = (event) => {
|
|
246
|
+
listeners.forEach((callback) => {
|
|
247
|
+
callback({ ...event, timestamp: Date.now() });
|
|
244
248
|
});
|
|
245
|
-
inflightRequests.set(cacheKey, request);
|
|
246
|
-
return request;
|
|
247
249
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
return {
|
|
251
|
+
debug,
|
|
252
|
+
onDebugEvent
|
|
250
253
|
};
|
|
251
|
-
const clearCache = () => cache.clear();
|
|
252
|
-
return { query, invalidate, clearCache };
|
|
253
254
|
};
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
document
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
` : `
|
|
266
|
-
query FragmentDocument($fragmentSlug: Int!) {
|
|
267
|
-
clientFragment(fragmentId: $fragmentSlug) {
|
|
268
|
-
id
|
|
269
|
-
document
|
|
270
|
-
linkedFragments {
|
|
271
|
-
id
|
|
272
|
-
document
|
|
273
|
-
}
|
|
274
|
-
}
|
|
255
|
+
var cache = /* @__PURE__ */ new Set();
|
|
256
|
+
var wrapMessage = (message) => `[GraphState]: ${message}`;
|
|
257
|
+
function warn(message) {
|
|
258
|
+
if (!cache.has(message)) {
|
|
259
|
+
console.warn(wrapMessage(message));
|
|
260
|
+
cache.add(message);
|
|
261
|
+
}
|
|
275
262
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
263
|
+
var keyOfEntity = (entity) => {
|
|
264
|
+
if (typeof entity === "string") {
|
|
265
|
+
return entityOfKey(entity) ? entity : null;
|
|
266
|
+
}
|
|
267
|
+
if (!(entity == null ? void 0 : entity._type)) {
|
|
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}`;
|
|
284
275
|
};
|
|
285
|
-
var
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
var getKey = (v) => isKey(v) ? v.slice(1) : null;
|
|
289
|
-
var isKey = (v) => typeof v === "string" && v.startsWith("$");
|
|
290
|
-
function hashGenerator(layerKey) {
|
|
291
|
-
let hash = 0;
|
|
292
|
-
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
293
|
-
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
294
|
-
hash |= 0;
|
|
276
|
+
var entityOfKey = (entity) => {
|
|
277
|
+
if (isObject$1(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity(entity)) {
|
|
278
|
+
return entity;
|
|
295
279
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
280
|
+
if (!entity || typeof entity !== "string")
|
|
281
|
+
return null;
|
|
282
|
+
const [typeName, ...restTypes] = entity.split(":");
|
|
283
|
+
if (!typeName || restTypes.length < 1)
|
|
284
|
+
return null;
|
|
301
285
|
return {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
_id: fragmentId,
|
|
305
|
-
children: [`Frame:${layerId}`],
|
|
306
|
-
layoutSizingHorizontal: "Fixed",
|
|
307
|
-
layoutSizingVertical: "Fixed",
|
|
308
|
-
horizontalGrow: "auto",
|
|
309
|
-
verticalGrow: "auto",
|
|
310
|
-
renderMode: "parent",
|
|
311
|
-
opacity: 1,
|
|
312
|
-
visible: true,
|
|
313
|
-
overflow: "hidden",
|
|
314
|
-
overrides: [],
|
|
315
|
-
properties: ["Variable:62218c840bd111"]
|
|
316
|
-
},
|
|
317
|
-
[`Frame:${layerId}`]: {
|
|
318
|
-
_type: "Frame",
|
|
319
|
-
_id: layerId,
|
|
320
|
-
opacity: 1,
|
|
321
|
-
parent: setKey(`Fragment:${fragmentId}`),
|
|
322
|
-
visible: true,
|
|
323
|
-
overflow: "visible",
|
|
324
|
-
children: [],
|
|
325
|
-
width: 320,
|
|
326
|
-
height: 200,
|
|
327
|
-
layoutSizingHorizontal: "Fixed",
|
|
328
|
-
layoutSizingVertical: "Fixed",
|
|
329
|
-
fillType: "Solid",
|
|
330
|
-
positionType: "absolute",
|
|
331
|
-
solidFill: "rgba(255, 255, 255, 1)",
|
|
332
|
-
name: "Frame",
|
|
333
|
-
isPrimary: true,
|
|
334
|
-
threshold: 320
|
|
335
|
-
}
|
|
286
|
+
_type: typeName,
|
|
287
|
+
_id: restTypes.join(":")
|
|
336
288
|
};
|
|
337
289
|
};
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
290
|
+
function omit(obj, ...props) {
|
|
291
|
+
const result = { ...obj };
|
|
292
|
+
props.forEach((prop) => {
|
|
293
|
+
delete result[prop];
|
|
294
|
+
});
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
var ID = 0;
|
|
298
|
+
var DEEP_LIMIT = 100;
|
|
299
|
+
var STATE_TYPE = "State";
|
|
300
|
+
var EACH_UPDATED = "$EACH:ROOT$";
|
|
301
|
+
var createState = (options) => {
|
|
302
|
+
const id = (options == null ? void 0 : options._id) ?? `${ID++}`;
|
|
303
|
+
const type = (options == null ? void 0 : options._type) ?? STATE_TYPE;
|
|
304
|
+
const stateKey = `${type}:${id}`;
|
|
305
|
+
const skipPredictors = [isGraphState, ...(options == null ? void 0 : options.skip) ?? []];
|
|
306
|
+
const cache2 = createCache();
|
|
307
|
+
const debugState = createDebugState();
|
|
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
|
+
}, {});
|
|
345
360
|
}
|
|
361
|
+
return value ? selector ? selector({ ...value }) : { ...value } : isSafe ? input : null;
|
|
346
362
|
};
|
|
347
|
-
|
|
348
|
-
|
|
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
|
+
}
|
|
349
374
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const url = ((_b = state == null ? void 0 : state.env) == null ? void 0 : _b.url) ?? "http://localhost/graphql";
|
|
355
|
-
const apiToken = (_c = state == null ? void 0 : state.env) == null ? void 0 : _c.apiToken;
|
|
356
|
-
const fetcher = createFetcher(url, {
|
|
357
|
-
Authorization: `Bearer ${apiToken}`
|
|
358
|
-
});
|
|
359
|
-
const beaconFetcher = fetchBeacon();
|
|
360
|
-
const queryFragment = async (fragmentId) => {
|
|
361
|
-
var _a2, _b2, _c2, _d;
|
|
362
|
-
if (!apiToken) return null;
|
|
363
|
-
if (state.$fetch.cacheLinks.get(fragmentId)) {
|
|
364
|
-
return state.$fetch.cacheLinks.get(fragmentId);
|
|
375
|
+
const mutateField = (input, parentFieldKey, options2) => {
|
|
376
|
+
var _a, _b, _c, _d;
|
|
377
|
+
if ((!input || l(input)) && !isLinkKey(input) || isSkipped(input)) {
|
|
378
|
+
return input;
|
|
365
379
|
}
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
380
|
+
const inputLinkKey = isGraphOrKey(input) ? keyOfEntity2(input) : input;
|
|
381
|
+
if (isLinkKey(inputLinkKey)) {
|
|
382
|
+
const parentGraph = getGraphLink(parentFieldKey) ?? "";
|
|
383
|
+
const parentPaths = ((_a = options2 == null ? void 0 : options2.internal) == null ? void 0 : _a.visitors.get(parentGraph)) ?? [];
|
|
384
|
+
const visitorsPaths = ((_b = options2 == null ? void 0 : options2.internal) == null ? void 0 : _b.visitors.get(inputLinkKey)) ?? [];
|
|
385
|
+
if (parentPaths.includes(inputLinkKey) || inputLinkKey === parentGraph) {
|
|
386
|
+
return null;
|
|
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);
|
|
375
447
|
}
|
|
376
|
-
} catch (e) {
|
|
377
|
-
console.error(e);
|
|
378
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();
|
|
379
460
|
}
|
|
380
|
-
if (
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
|
471
|
+
});
|
|
472
|
+
return graphKey;
|
|
473
|
+
};
|
|
474
|
+
const invalidate = (entity) => {
|
|
475
|
+
const key = keyOfEntity2(entity);
|
|
476
|
+
debugState.debug({ type: "invalidate", entity: key });
|
|
477
|
+
if (key) {
|
|
478
|
+
const parents = cache2.getParents(key) || [];
|
|
479
|
+
cache2.invalidate(key);
|
|
480
|
+
parents.forEach((parentKey) => {
|
|
481
|
+
const prevParent = cache2.readLink(parentKey);
|
|
482
|
+
const freshParent = resolve(parentKey, { safe: false, keepLinks: true, removeLinkFromSubGraph: false });
|
|
483
|
+
cache2.writeLink(parentKey, freshParent);
|
|
484
|
+
notify(parentKey, prevParent);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const notify = (entity, prevState, _internal) => {
|
|
489
|
+
if (deepIndex > DEEP_LIMIT) {
|
|
490
|
+
throw new Error("Too deep notify.");
|
|
491
|
+
}
|
|
492
|
+
const depth = (_internal == null ? void 0 : _internal.depth) ?? 0;
|
|
493
|
+
const key = keyOfEntity2(entity);
|
|
494
|
+
debugState.debug({ type: "notify", entity: key });
|
|
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) };
|
|
504
|
+
};
|
|
505
|
+
subs.forEach(({ callback, options: options2 }) => {
|
|
506
|
+
const selector = options2 == null ? void 0 : options2.selector;
|
|
507
|
+
const directChangesOnly = (options2 == null ? void 0 : options2.directChangesOnly) ?? false;
|
|
508
|
+
if (directChangesOnly && depth > 0) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (selector) {
|
|
512
|
+
const { next, prev, hasChange } = getSelectedValues(selector);
|
|
513
|
+
if (hasChange)
|
|
514
|
+
callback(next, prev);
|
|
515
|
+
} else {
|
|
516
|
+
callback(nextResult, prevState);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
deps.forEach(
|
|
520
|
+
(dep) => notify(dep, prevState, {
|
|
521
|
+
depth: depth + 1
|
|
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 }]);
|
|
389
537
|
}
|
|
390
|
-
(
|
|
391
|
-
|
|
392
|
-
|
|
538
|
+
cache2.onRemoveLink((link, prevValue) => {
|
|
539
|
+
if (link === key) {
|
|
540
|
+
notify(key, prevValue);
|
|
541
|
+
}
|
|
393
542
|
});
|
|
394
|
-
return state.$fetch.cacheLinks.get(fragmentId);
|
|
395
543
|
}
|
|
396
|
-
|
|
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);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
if (options2 == null ? void 0 : options2.signal) {
|
|
555
|
+
options2.signal.addEventListener("abort", unsubscribe, { once: true });
|
|
556
|
+
}
|
|
557
|
+
return unsubscribe;
|
|
397
558
|
};
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
559
|
+
const inspectFields = (graphType) => [...cache2.types.get(graphType) ?? []];
|
|
560
|
+
const resolveParents = (field) => {
|
|
561
|
+
const key = (typeof field === "string" ? field : keyOfEntity2(field)) || "";
|
|
562
|
+
const refs = cache2.getParents(key) ?? [];
|
|
563
|
+
return refs.map((ref) => resolve(ref));
|
|
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
|
+
};
|
|
405
585
|
};
|
|
586
|
+
function use(plugin) {
|
|
587
|
+
pluginsStore.use(plugin);
|
|
588
|
+
plugin(this);
|
|
589
|
+
}
|
|
590
|
+
const addSkip = (predictor) => {
|
|
591
|
+
skipPredictors.push(predictor);
|
|
592
|
+
};
|
|
593
|
+
if (options == null ? void 0 : options.initialState) {
|
|
594
|
+
mutate(options.initialState, { replace: "deep" });
|
|
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);
|
|
406
620
|
};
|
|
407
|
-
const createConstants = (...constants) => {
|
|
621
|
+
const createConstants$1 = (...constants) => {
|
|
408
622
|
return constants.reduce((acc, constant) => {
|
|
409
623
|
acc[constant] = constant;
|
|
410
624
|
return acc;
|
|
411
625
|
}, {});
|
|
412
626
|
};
|
|
413
|
-
const nodes = createConstants(
|
|
627
|
+
const nodes = createConstants$1(
|
|
414
628
|
"Fragment",
|
|
415
629
|
"FragmentInstance",
|
|
416
630
|
"Instance",
|
|
631
|
+
"Collection",
|
|
417
632
|
"Breakpoint",
|
|
418
633
|
"Frame",
|
|
419
634
|
"Image",
|
|
@@ -424,57 +639,53 @@ const nodes = createConstants(
|
|
|
424
639
|
"ComputedValue",
|
|
425
640
|
"TransformValue"
|
|
426
641
|
);
|
|
427
|
-
const fragmentGrowingMode = createConstants("auto", "fill");
|
|
428
|
-
const borderType = createConstants("None", "Solid", "Dashed", "Dotted");
|
|
429
|
-
const linkTarget = createConstants("_blank");
|
|
430
|
-
const paintMode = createConstants("None", "Solid", "Image");
|
|
431
|
-
const imagePaintScaleModes = createConstants(
|
|
432
|
-
|
|
433
|
-
"Fit",
|
|
434
|
-
"Crop",
|
|
435
|
-
"Tile"
|
|
436
|
-
);
|
|
437
|
-
const constrain = createConstants(
|
|
642
|
+
const fragmentGrowingMode = createConstants$1("auto", "fill");
|
|
643
|
+
const borderType = createConstants$1("None", "Solid", "Dashed", "Dotted");
|
|
644
|
+
const linkTarget = createConstants$1("_blank", "none");
|
|
645
|
+
const paintMode = createConstants$1("None", "Solid", "Image");
|
|
646
|
+
const imagePaintScaleModes = createConstants$1("Auto", "Contain", "Cover");
|
|
647
|
+
const constrain = createConstants$1(
|
|
438
648
|
"Min",
|
|
439
649
|
"Center",
|
|
440
650
|
"Max",
|
|
441
651
|
"Stretch",
|
|
442
652
|
"Scale"
|
|
443
653
|
);
|
|
444
|
-
const positionType = createConstants("absolute", "relative");
|
|
445
|
-
const sizing = createConstants("Fixed", "Hug", "Fill", "Relative");
|
|
446
|
-
const layerMode = createConstants("none", "flex");
|
|
447
|
-
const layerDirection = createConstants("vertical", "horizontal");
|
|
448
|
-
const layerAlign = createConstants("start", "center", "end");
|
|
449
|
-
const layerDistribute = createConstants(
|
|
654
|
+
const positionType = createConstants$1("absolute", "relative");
|
|
655
|
+
const sizing = createConstants$1("Fixed", "Hug", "Fill", "Relative");
|
|
656
|
+
const layerMode = createConstants$1("none", "flex");
|
|
657
|
+
const layerDirection = createConstants$1("vertical", "horizontal");
|
|
658
|
+
const layerAlign = createConstants$1("start", "center", "end");
|
|
659
|
+
const layerDistribute = createConstants$1(
|
|
450
660
|
"start",
|
|
451
661
|
"center",
|
|
452
662
|
"end",
|
|
453
663
|
"space-between",
|
|
454
664
|
"space-around"
|
|
455
665
|
);
|
|
456
|
-
const textTransform = createConstants(
|
|
666
|
+
const textTransform = createConstants$1(
|
|
457
667
|
"none",
|
|
458
668
|
"uppercase",
|
|
459
669
|
"lowercase",
|
|
460
670
|
"capitalize"
|
|
461
671
|
);
|
|
462
|
-
const textDecorations = createConstants(
|
|
672
|
+
const textDecorations = createConstants$1(
|
|
463
673
|
"none",
|
|
464
674
|
"underline",
|
|
465
675
|
"line-through"
|
|
466
676
|
);
|
|
467
|
-
const effectType = createConstants("loop", "appear", "hover", "tap");
|
|
468
|
-
const effectName = createConstants(
|
|
677
|
+
const effectType = createConstants$1("loop", "appear", "hover", "tap");
|
|
678
|
+
const effectName = createConstants$1(
|
|
469
679
|
"fade",
|
|
470
680
|
"slide",
|
|
471
681
|
"bounce",
|
|
472
682
|
"wiggle",
|
|
473
683
|
"increase"
|
|
474
684
|
);
|
|
475
|
-
const variableType = createConstants(
|
|
685
|
+
const variableType = createConstants$1(
|
|
476
686
|
"Event",
|
|
477
687
|
"String",
|
|
688
|
+
"Link",
|
|
478
689
|
"Boolean",
|
|
479
690
|
"Array",
|
|
480
691
|
"Color",
|
|
@@ -482,9 +693,10 @@ const variableType = createConstants(
|
|
|
482
693
|
"Date",
|
|
483
694
|
"Enum",
|
|
484
695
|
"Number",
|
|
696
|
+
"Image",
|
|
485
697
|
"Object"
|
|
486
698
|
);
|
|
487
|
-
const whiteSpace = createConstants(
|
|
699
|
+
const whiteSpace = createConstants$1(
|
|
488
700
|
"normal",
|
|
489
701
|
"nowrap",
|
|
490
702
|
"pre",
|
|
@@ -492,8 +704,8 @@ const whiteSpace = createConstants(
|
|
|
492
704
|
"pre-line",
|
|
493
705
|
"break-spaces"
|
|
494
706
|
);
|
|
495
|
-
const overflow = createConstants("visible", "hidden", "scroll");
|
|
496
|
-
const variableTransforms = createConstants(
|
|
707
|
+
const overflow = createConstants$1("visible", "hidden", "scroll");
|
|
708
|
+
const variableTransforms = createConstants$1(
|
|
497
709
|
"convert",
|
|
498
710
|
"exists",
|
|
499
711
|
"equals",
|
|
@@ -516,15 +728,21 @@ const variableTransforms = createConstants(
|
|
|
516
728
|
"convertFromBoolean",
|
|
517
729
|
"negative"
|
|
518
730
|
);
|
|
519
|
-
const renderTarget = createConstants("canvas", "document");
|
|
520
|
-
const renderMode = createConstants("viewport", "parent", "fixed");
|
|
521
|
-
const interactions = createConstants("click", "mouseover");
|
|
522
|
-
const eventMode = createConstants("goal", "callback");
|
|
731
|
+
const renderTarget = createConstants$1("canvas", "document");
|
|
732
|
+
const renderMode = createConstants$1("viewport", "parent", "fixed");
|
|
733
|
+
const interactions = createConstants$1("click", "mouseover", "appear");
|
|
734
|
+
const eventMode = createConstants$1("goal", "callback", "tracker");
|
|
735
|
+
const scopeTypes = createConstants$1(
|
|
736
|
+
"InstanceScope",
|
|
737
|
+
"FragmentScope",
|
|
738
|
+
"CollectionScope",
|
|
739
|
+
"CollectionItemScope"
|
|
740
|
+
);
|
|
523
741
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
524
742
|
__proto__: null,
|
|
525
743
|
borderType,
|
|
526
744
|
constrain,
|
|
527
|
-
createConstants,
|
|
745
|
+
createConstants: createConstants$1,
|
|
528
746
|
effectName,
|
|
529
747
|
effectType,
|
|
530
748
|
eventMode,
|
|
@@ -542,6 +760,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
542
760
|
positionType,
|
|
543
761
|
renderMode,
|
|
544
762
|
renderTarget,
|
|
763
|
+
scopeTypes,
|
|
545
764
|
sizing,
|
|
546
765
|
textDecorations,
|
|
547
766
|
textTransform,
|
|
@@ -1295,9 +1514,17 @@ const linkValidator = /* @__PURE__ */ check(
|
|
|
1295
1514
|
}
|
|
1296
1515
|
);
|
|
1297
1516
|
const layerField = (schema, meta) => {
|
|
1298
|
-
const
|
|
1517
|
+
const overridable = (meta == null ? void 0 : meta.overridable) ?? true;
|
|
1518
|
+
const variable = (meta == null ? void 0 : meta.variable) ?? false;
|
|
1519
|
+
const schemaParts = [schema];
|
|
1520
|
+
if (variable) {
|
|
1521
|
+
schemaParts.push(/* @__PURE__ */ pipe(/* @__PURE__ */ string(), linkValidator));
|
|
1522
|
+
}
|
|
1523
|
+
if (overridable) {
|
|
1524
|
+
schemaParts.push(/* @__PURE__ */ any());
|
|
1525
|
+
}
|
|
1299
1526
|
return /* @__PURE__ */ pipe(
|
|
1300
|
-
/* @__PURE__ */ optional(
|
|
1527
|
+
/* @__PURE__ */ optional(/* @__PURE__ */ union(schemaParts)),
|
|
1301
1528
|
/* @__PURE__ */ transform((meta == null ? void 0 : meta.transform) ?? ((v2) => v2)),
|
|
1302
1529
|
/* @__PURE__ */ metadata(meta ?? {})
|
|
1303
1530
|
);
|
|
@@ -1320,8 +1547,28 @@ const PositionSchema = /* @__PURE__ */ object({
|
|
|
1320
1547
|
position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
|
|
1321
1548
|
fallback: positionType.absolute
|
|
1322
1549
|
}),
|
|
1323
|
-
top: layerField(/* @__PURE__ */ number(), {
|
|
1324
|
-
|
|
1550
|
+
top: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
1551
|
+
fallback: null,
|
|
1552
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
1553
|
+
}),
|
|
1554
|
+
left: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
1555
|
+
fallback: null,
|
|
1556
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
1557
|
+
}),
|
|
1558
|
+
right: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
1559
|
+
fallback: null,
|
|
1560
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
1561
|
+
}),
|
|
1562
|
+
bottom: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
1563
|
+
fallback: null,
|
|
1564
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
1565
|
+
}),
|
|
1566
|
+
centerAnchorX: layerField(/* @__PURE__ */ number(), {
|
|
1567
|
+
fallback: 0.5
|
|
1568
|
+
}),
|
|
1569
|
+
centerAnchorY: layerField(/* @__PURE__ */ number(), {
|
|
1570
|
+
fallback: 0.5
|
|
1571
|
+
})
|
|
1325
1572
|
});
|
|
1326
1573
|
const SceneSchema = /* @__PURE__ */ object({
|
|
1327
1574
|
opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
|
|
@@ -1329,6 +1576,7 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
1329
1576
|
variable: true
|
|
1330
1577
|
}),
|
|
1331
1578
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
1579
|
+
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1332
1580
|
zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
|
|
1333
1581
|
});
|
|
1334
1582
|
const FillSchema = /* @__PURE__ */ object({
|
|
@@ -1338,14 +1586,22 @@ const FillSchema = /* @__PURE__ */ object({
|
|
|
1338
1586
|
solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" }),
|
|
1339
1587
|
imageFill: layerField(/* @__PURE__ */ string()),
|
|
1340
1588
|
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1341
|
-
fallback: imagePaintScaleModes.
|
|
1589
|
+
fallback: imagePaintScaleModes.Auto
|
|
1342
1590
|
})
|
|
1343
1591
|
});
|
|
1344
1592
|
const BorderSchema = /* @__PURE__ */ object({
|
|
1345
1593
|
borderType: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
|
|
1346
1594
|
fallback: borderType.None
|
|
1347
1595
|
}),
|
|
1348
|
-
borderWidth: layerField(/* @__PURE__ */
|
|
1596
|
+
borderWidth: layerField(/* @__PURE__ */ string(), {
|
|
1597
|
+
fallback: "1px",
|
|
1598
|
+
transform: (value) => {
|
|
1599
|
+
if (typeof value === "number") {
|
|
1600
|
+
return `${value}px`;
|
|
1601
|
+
}
|
|
1602
|
+
return value;
|
|
1603
|
+
}
|
|
1604
|
+
}),
|
|
1349
1605
|
borderColor: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
|
|
1350
1606
|
});
|
|
1351
1607
|
const SizeSchema = /* @__PURE__ */ object({
|
|
@@ -1428,6 +1684,15 @@ const InteractionsSchema = /* @__PURE__ */ object({
|
|
|
1428
1684
|
const CssOverrideSchema = /* @__PURE__ */ object({
|
|
1429
1685
|
cssOverride: layerField(/* @__PURE__ */ string(), { fallback: "" })
|
|
1430
1686
|
});
|
|
1687
|
+
const LinkSchema = /* @__PURE__ */ object({
|
|
1688
|
+
href: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1689
|
+
hrefNewTab: layerField(/* @__PURE__ */ boolean(), {
|
|
1690
|
+
fallback: true
|
|
1691
|
+
})
|
|
1692
|
+
// hrefTarget: layerField(v.picklist(Object.keys(linkTarget)), {
|
|
1693
|
+
// fallback: linkTarget._blank,
|
|
1694
|
+
// }),
|
|
1695
|
+
});
|
|
1431
1696
|
/* @__PURE__ */ pipe(
|
|
1432
1697
|
/* @__PURE__ */ object({
|
|
1433
1698
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Frame", overridable: false }),
|
|
@@ -1448,6 +1713,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1448
1713
|
...LayerSchema.entries,
|
|
1449
1714
|
...InteractionsSchema.entries,
|
|
1450
1715
|
...CssOverrideSchema.entries,
|
|
1716
|
+
...LinkSchema.entries,
|
|
1451
1717
|
overflow: OverflowSchema,
|
|
1452
1718
|
borderRadius: BorderRadiusSchema
|
|
1453
1719
|
})
|
|
@@ -1460,33 +1726,22 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1460
1726
|
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
1461
1727
|
fallback: whiteSpace.pre
|
|
1462
1728
|
}),
|
|
1463
|
-
|
|
1729
|
+
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
1464
1730
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1465
|
-
attributes: layerField(
|
|
1466
|
-
/* @__PURE__ */ object({
|
|
1467
|
-
fontSize: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
|
|
1468
|
-
color: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
|
|
1469
|
-
lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
|
|
1470
|
-
fontWeight: layerField(/* @__PURE__ */ string(), { fallback: "normal" }),
|
|
1471
|
-
letterSpacing: layerField(/* @__PURE__ */ string(), { fallback: "0px" }),
|
|
1472
|
-
textTransform: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
|
|
1473
|
-
textDecoration: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
|
|
1474
|
-
whiteSpace: layerField(/* @__PURE__ */ string(), { fallback: "pre" }),
|
|
1475
|
-
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" })
|
|
1476
|
-
}),
|
|
1477
|
-
{ fallback: {} }
|
|
1478
|
-
),
|
|
1479
1731
|
...GraphFieldSchema.entries,
|
|
1480
1732
|
...OverridesSchema.entries,
|
|
1733
|
+
...CssOverrideSchema.entries,
|
|
1481
1734
|
...PositionSchema.entries,
|
|
1482
1735
|
...SceneSchema.entries,
|
|
1483
|
-
...SizeSchema.entries
|
|
1736
|
+
...SizeSchema.entries,
|
|
1737
|
+
...InteractionsSchema.entries,
|
|
1738
|
+
...LinkSchema.entries
|
|
1484
1739
|
});
|
|
1485
1740
|
/* @__PURE__ */ object({
|
|
1486
1741
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
|
|
1487
1742
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1488
1743
|
horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
|
|
1489
|
-
fallback: fragmentGrowingMode.
|
|
1744
|
+
fallback: fragmentGrowingMode.fill,
|
|
1490
1745
|
overridable: false
|
|
1491
1746
|
}),
|
|
1492
1747
|
verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
|
|
@@ -1526,13 +1781,17 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1526
1781
|
...OverridesSchema.entries,
|
|
1527
1782
|
...PositionSchema.entries,
|
|
1528
1783
|
...SizeSchema.entries,
|
|
1529
|
-
...SceneSchema.entries
|
|
1784
|
+
...SceneSchema.entries,
|
|
1785
|
+
...InteractionsSchema.entries,
|
|
1786
|
+
...LinkSchema.entries
|
|
1530
1787
|
});
|
|
1531
1788
|
/* @__PURE__ */ object({
|
|
1789
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1532
1790
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1533
1791
|
fallback: "Number",
|
|
1534
1792
|
overridable: false
|
|
1535
1793
|
}),
|
|
1794
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1536
1795
|
type: layerField(/* @__PURE__ */ literal(variableType.Number), {
|
|
1537
1796
|
fallback: variableType.Number
|
|
1538
1797
|
}),
|
|
@@ -1545,10 +1804,12 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1545
1804
|
...GraphFieldSchema.entries
|
|
1546
1805
|
});
|
|
1547
1806
|
/* @__PURE__ */ object({
|
|
1807
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1548
1808
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1549
1809
|
fallback: "Boolean",
|
|
1550
1810
|
overridable: false
|
|
1551
1811
|
}),
|
|
1812
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1552
1813
|
type: layerField(/* @__PURE__ */ literal(variableType.Boolean), {
|
|
1553
1814
|
fallback: variableType.Boolean
|
|
1554
1815
|
}),
|
|
@@ -1557,10 +1818,12 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1557
1818
|
...GraphFieldSchema.entries
|
|
1558
1819
|
});
|
|
1559
1820
|
/* @__PURE__ */ object({
|
|
1821
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1560
1822
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1561
1823
|
fallback: "String",
|
|
1562
1824
|
overridable: false
|
|
1563
1825
|
}),
|
|
1826
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1564
1827
|
type: layerField(/* @__PURE__ */ literal(variableType.Color), {
|
|
1565
1828
|
fallback: variableType.Color
|
|
1566
1829
|
}),
|
|
@@ -1570,6 +1833,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1570
1833
|
...GraphFieldSchema.entries
|
|
1571
1834
|
});
|
|
1572
1835
|
/* @__PURE__ */ object({
|
|
1836
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1573
1837
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1574
1838
|
fallback: "String",
|
|
1575
1839
|
overridable: false
|
|
@@ -1577,6 +1841,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1577
1841
|
type: layerField(/* @__PURE__ */ literal(variableType.String), {
|
|
1578
1842
|
fallback: variableType.String
|
|
1579
1843
|
}),
|
|
1844
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1580
1845
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1581
1846
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1582
1847
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
@@ -1584,10 +1849,12 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1584
1849
|
...GraphFieldSchema.entries
|
|
1585
1850
|
});
|
|
1586
1851
|
/* @__PURE__ */ object({
|
|
1852
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1587
1853
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1588
1854
|
fallback: "Event",
|
|
1589
1855
|
overridable: false
|
|
1590
1856
|
}),
|
|
1857
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1591
1858
|
type: layerField(/* @__PURE__ */ literal(variableType.Event), {
|
|
1592
1859
|
fallback: variableType.Event
|
|
1593
1860
|
}),
|
|
@@ -1598,36 +1865,399 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1598
1865
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1599
1866
|
...GraphFieldSchema.entries
|
|
1600
1867
|
});
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
)
|
|
1607
|
-
|
|
1868
|
+
/* @__PURE__ */ object({
|
|
1869
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1870
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1871
|
+
fallback: "Link",
|
|
1872
|
+
overridable: false
|
|
1873
|
+
}),
|
|
1874
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1875
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Link), {
|
|
1876
|
+
fallback: variableType.Link
|
|
1877
|
+
}),
|
|
1878
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1879
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1880
|
+
...GraphFieldSchema.entries
|
|
1881
|
+
});
|
|
1882
|
+
/* @__PURE__ */ object({
|
|
1883
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1884
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1885
|
+
fallback: "Option",
|
|
1886
|
+
overridable: false
|
|
1887
|
+
}),
|
|
1888
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1889
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Enum), {
|
|
1890
|
+
fallback: variableType.Enum
|
|
1891
|
+
}),
|
|
1892
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1893
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1894
|
+
cases: layerField(
|
|
1895
|
+
/* @__PURE__ */ array(
|
|
1896
|
+
/* @__PURE__ */ object({
|
|
1897
|
+
id: /* @__PURE__ */ string(),
|
|
1898
|
+
name: /* @__PURE__ */ string()
|
|
1899
|
+
})
|
|
1900
|
+
),
|
|
1901
|
+
{ fallback: [] }
|
|
1902
|
+
),
|
|
1903
|
+
...GraphFieldSchema.entries
|
|
1904
|
+
});
|
|
1905
|
+
/* @__PURE__ */ object({
|
|
1906
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1907
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1908
|
+
fallback: "Object",
|
|
1909
|
+
overridable: false
|
|
1910
|
+
}),
|
|
1911
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Object), {
|
|
1912
|
+
fallback: variableType.Object
|
|
1913
|
+
}),
|
|
1914
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1915
|
+
defaultValue: layerField(/* @__PURE__ */ object({}), { fallback: {} }),
|
|
1916
|
+
fields: layerField(/* @__PURE__ */ record(/* @__PURE__ */ string(), linkValidator), { fallback: {} }),
|
|
1917
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1918
|
+
...GraphFieldSchema.entries
|
|
1919
|
+
});
|
|
1920
|
+
/* @__PURE__ */ object({
|
|
1921
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1922
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1923
|
+
fallback: "Image",
|
|
1924
|
+
overridable: false
|
|
1925
|
+
}),
|
|
1926
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Image), {
|
|
1927
|
+
fallback: variableType.Image
|
|
1928
|
+
}),
|
|
1929
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1930
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1931
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1932
|
+
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1933
|
+
fallback: imagePaintScaleModes.Auto
|
|
1934
|
+
}),
|
|
1935
|
+
...GraphFieldSchema.entries
|
|
1936
|
+
});
|
|
1937
|
+
/* @__PURE__ */ pipe(
|
|
1938
|
+
/* @__PURE__ */ object({
|
|
1939
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1940
|
+
fallback: "Collection",
|
|
1941
|
+
overridable: false
|
|
1942
|
+
}),
|
|
1943
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1944
|
+
source: layerField(linkValidator, {}),
|
|
1945
|
+
...ChildrenSchema.entries,
|
|
1946
|
+
...GraphFieldSchema.entries,
|
|
1947
|
+
...OverridesSchema.entries,
|
|
1948
|
+
...PositionSchema.entries,
|
|
1949
|
+
...SceneSchema.entries,
|
|
1950
|
+
...FillSchema.entries,
|
|
1951
|
+
...BorderSchema.entries,
|
|
1952
|
+
...SizeSchema.entries,
|
|
1953
|
+
...LayerSchema.entries,
|
|
1954
|
+
...InteractionsSchema.entries,
|
|
1955
|
+
...CssOverrideSchema.entries,
|
|
1956
|
+
...LinkSchema.entries
|
|
1957
|
+
})
|
|
1958
|
+
);
|
|
1959
|
+
/* @__PURE__ */ object({
|
|
1960
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1961
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1962
|
+
fallback: "Collection",
|
|
1963
|
+
overridable: false
|
|
1964
|
+
}),
|
|
1965
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Array), {
|
|
1966
|
+
fallback: variableType.Array
|
|
1967
|
+
}),
|
|
1968
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1969
|
+
defaultValue: layerField(/* @__PURE__ */ array(/* @__PURE__ */ any()), { fallback: [] }),
|
|
1970
|
+
definition: layerField(linkValidator, { fallback: null }),
|
|
1971
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1972
|
+
...GraphFieldSchema.entries
|
|
1973
|
+
});
|
|
1974
|
+
const BASE_HEADERS = {
|
|
1975
|
+
"Content-Type": "application/json"
|
|
1976
|
+
};
|
|
1977
|
+
const createFetcher = (baseUrl, defaultHeaders = {}) => {
|
|
1978
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
1979
|
+
const inflightRequests = /* @__PURE__ */ new Map();
|
|
1980
|
+
const getCacheKey = (query2, variables, options) => JSON.stringify({ query: query2, variables, options });
|
|
1981
|
+
const query = async (query2, variables = {}, options = {}) => {
|
|
1982
|
+
const cacheKey = getCacheKey(query2, variables, options);
|
|
1983
|
+
if (cache2.has(cacheKey)) {
|
|
1984
|
+
return cache2.get(cacheKey);
|
|
1985
|
+
}
|
|
1986
|
+
if (inflightRequests.has(cacheKey)) {
|
|
1987
|
+
return inflightRequests.get(cacheKey);
|
|
1988
|
+
}
|
|
1989
|
+
const request = fetch(baseUrl, {
|
|
1990
|
+
...options,
|
|
1991
|
+
method: "POST",
|
|
1992
|
+
body: JSON.stringify({ query: query2, variables }),
|
|
1993
|
+
credentials: "include",
|
|
1994
|
+
headers: {
|
|
1995
|
+
...BASE_HEADERS,
|
|
1996
|
+
...defaultHeaders,
|
|
1997
|
+
...options.headers
|
|
1998
|
+
}
|
|
1999
|
+
}).then(async (res) => {
|
|
2000
|
+
if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
|
|
2001
|
+
const data = await res.json();
|
|
2002
|
+
if (!query2.includes("mutation")) {
|
|
2003
|
+
cache2.set(cacheKey, data);
|
|
2004
|
+
}
|
|
2005
|
+
return data;
|
|
2006
|
+
}).finally(() => {
|
|
2007
|
+
inflightRequests.delete(cacheKey);
|
|
2008
|
+
});
|
|
2009
|
+
inflightRequests.set(cacheKey, request);
|
|
2010
|
+
return request;
|
|
2011
|
+
};
|
|
2012
|
+
const invalidate = (endpoint, options) => {
|
|
2013
|
+
cache2.delete(getCacheKey(endpoint, options));
|
|
2014
|
+
};
|
|
2015
|
+
const clearCache = () => cache2.clear();
|
|
2016
|
+
return { query, invalidate, clearCache };
|
|
2017
|
+
};
|
|
2018
|
+
const getFragmentQuery = (fragmentId, isSelf) => {
|
|
2019
|
+
return {
|
|
2020
|
+
query: isSelf ? `
|
|
2021
|
+
query FragmentDocument($fragmentId: Int!) {
|
|
2022
|
+
fragment(fragmentIds: [$fragmentId]) {
|
|
2023
|
+
id
|
|
2024
|
+
document
|
|
2025
|
+
linkedFragments {
|
|
2026
|
+
id
|
|
2027
|
+
document
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
` : `
|
|
2032
|
+
query FragmentDocument($fragmentId: Int!) {
|
|
2033
|
+
clientFragment(fragmentId: $fragmentId) {
|
|
2034
|
+
id
|
|
2035
|
+
document
|
|
2036
|
+
linkedFragments {
|
|
2037
|
+
id
|
|
2038
|
+
document
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
}`,
|
|
2042
|
+
variables: {
|
|
2043
|
+
fragmentId
|
|
2044
|
+
},
|
|
2045
|
+
_type: null
|
|
2046
|
+
};
|
|
2047
|
+
};
|
|
2048
|
+
var isObject = (input) => {
|
|
2049
|
+
return typeof input === "object" && input !== null && !Array.isArray(input);
|
|
2050
|
+
};
|
|
2051
|
+
var isEmptyValue = (value) => !value && (value === null || value === void 0);
|
|
2052
|
+
var isValue = (value) => !isEmptyValue(value);
|
|
2053
|
+
var createConstants = (...constants) => {
|
|
2054
|
+
return constants.reduce((acc, constant) => {
|
|
2055
|
+
acc[constant] = constant;
|
|
2056
|
+
return acc;
|
|
2057
|
+
}, {});
|
|
2058
|
+
};
|
|
2059
|
+
var isBrowser_default = typeof window !== "undefined";
|
|
2060
|
+
var getKey = (v) => isKey(v) ? v.slice(1) : null;
|
|
2061
|
+
var isKey = (v) => typeof v === "string" && v.startsWith("$");
|
|
2062
|
+
function hashGenerator(layerKey) {
|
|
2063
|
+
let hash = 0;
|
|
2064
|
+
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
2065
|
+
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
2066
|
+
hash |= 0;
|
|
2067
|
+
}
|
|
2068
|
+
const raw = Math.abs(hash).toString(36);
|
|
2069
|
+
return /^[0-9]/.test(raw) ? `h${raw}` : raw;
|
|
2070
|
+
}
|
|
2071
|
+
const fetchBeacon = (baseUrl) => {
|
|
2072
|
+
const sender = isBrowser_default && typeof (navigator == null ? void 0 : navigator.sendBeacon) === "function" ? navigator.sendBeacon : () => null;
|
|
2073
|
+
const sendBeacon = (data) => {
|
|
2074
|
+
try {
|
|
2075
|
+
sender("/graphql", "test");
|
|
2076
|
+
} catch (e) {
|
|
2077
|
+
console.error(e);
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
return {
|
|
2081
|
+
sendBeacon
|
|
2082
|
+
};
|
|
2083
|
+
};
|
|
2084
|
+
const getAreaListQuery = (areaCodes) => {
|
|
2085
|
+
return {
|
|
2086
|
+
query: `query($areaCodes: [String!]!) {
|
|
2087
|
+
clientAreas(areaCodes: $areaCodes) {
|
|
2088
|
+
variant {
|
|
2089
|
+
fragment {
|
|
2090
|
+
props
|
|
2091
|
+
fragment {
|
|
2092
|
+
id
|
|
2093
|
+
document
|
|
2094
|
+
linkedFragments {
|
|
2095
|
+
id
|
|
2096
|
+
document
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}`,
|
|
2103
|
+
variables: {
|
|
2104
|
+
areaCodes
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
};
|
|
2108
|
+
const fetchPlugin = (state) => {
|
|
2109
|
+
var _a, _b, _c, _d;
|
|
2110
|
+
const isSelf = ((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf) ?? false;
|
|
2111
|
+
const url = (_b = state == null ? void 0 : state.env) == null ? void 0 : _b.backendEndpoint;
|
|
2112
|
+
const apiToken = (_c = state == null ? void 0 : state.env) == null ? void 0 : _c.apiToken;
|
|
2113
|
+
const referer = (_d = state == null ? void 0 : state.env) == null ? void 0 : _d.referer;
|
|
2114
|
+
let headers = {
|
|
2115
|
+
Authorization: `Bearer ${apiToken}`
|
|
2116
|
+
};
|
|
2117
|
+
if (referer) {
|
|
2118
|
+
headers.Referer = referer;
|
|
2119
|
+
}
|
|
2120
|
+
const fetcher = createFetcher(url, headers);
|
|
2121
|
+
const beaconFetcher = fetchBeacon();
|
|
2122
|
+
const queryFragment = async (fragmentId) => {
|
|
1608
2123
|
var _a2;
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
(
|
|
1612
|
-
|
|
1613
|
-
|
|
2124
|
+
if (!apiToken || !fragmentId) return null;
|
|
2125
|
+
if (state.$fetch.cacheDocuments.has(fragmentId)) {
|
|
2126
|
+
return state.$fetch.cacheDocuments.get(fragmentId);
|
|
2127
|
+
}
|
|
2128
|
+
const fragmentQuery = getFragmentQuery(fragmentId, isSelf);
|
|
2129
|
+
const response = await fetcher.query(
|
|
2130
|
+
fragmentQuery.query,
|
|
2131
|
+
fragmentQuery.variables,
|
|
2132
|
+
{ referrerPolicy: "unsafe-url" }
|
|
2133
|
+
);
|
|
2134
|
+
let fragment = null;
|
|
2135
|
+
if (!!(response == null ? void 0 : response.data) && "clientFragment" in response.data) {
|
|
2136
|
+
fragment = response.data.clientFragment;
|
|
2137
|
+
}
|
|
2138
|
+
if (!!(response == null ? void 0 : response.data) && "fragment" in response.data) {
|
|
2139
|
+
fragment = (_a2 = response.data.fragment) == null ? void 0 : _a2.at(0);
|
|
2140
|
+
}
|
|
2141
|
+
const fragmentDocument = fragment == null ? void 0 : fragment.document;
|
|
2142
|
+
if (!fragmentDocument) {
|
|
2143
|
+
console.error("Empty document");
|
|
2144
|
+
return null;
|
|
2145
|
+
}
|
|
2146
|
+
if (fragment) {
|
|
2147
|
+
state.$fetch.cacheDocuments.set(fragmentId, fragmentDocument);
|
|
2148
|
+
if (Array.isArray(fragment.linkedFragments)) {
|
|
2149
|
+
fragment.linkedFragments.forEach(
|
|
2150
|
+
(linkedFragment) => state.$fetch.cacheDocuments.set(
|
|
2151
|
+
linkedFragment.id,
|
|
2152
|
+
linkedFragment.document
|
|
2153
|
+
)
|
|
2154
|
+
);
|
|
1614
2155
|
}
|
|
2156
|
+
return fragmentDocument;
|
|
2157
|
+
}
|
|
2158
|
+
return null;
|
|
2159
|
+
};
|
|
2160
|
+
const queryArea = async (areaCode) => {
|
|
2161
|
+
return queryAreaList([areaCode]).then((res) => res == null ? void 0 : res.at(0));
|
|
2162
|
+
};
|
|
2163
|
+
const queryAreaList = async (areaCodes) => {
|
|
2164
|
+
var _a2;
|
|
2165
|
+
if (!apiToken || !areaCodes) return null;
|
|
2166
|
+
const nonLoadedAreas = areaCodes.filter(
|
|
2167
|
+
(code) => !state.$fetch.cacheAreaDocuments.has(code)
|
|
2168
|
+
);
|
|
2169
|
+
if (!nonLoadedAreas.length) {
|
|
2170
|
+
return areaCodes.map(state.$fetch.cacheAreaDocuments.get);
|
|
2171
|
+
}
|
|
2172
|
+
const areaQuery = getAreaListQuery(areaCodes);
|
|
2173
|
+
const response = await fetcher.query(
|
|
2174
|
+
areaQuery.query,
|
|
2175
|
+
areaQuery.variables,
|
|
2176
|
+
{ referrerPolicy: "unsafe-url" }
|
|
2177
|
+
);
|
|
2178
|
+
const areas = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.clientAreas;
|
|
2179
|
+
if (areas) {
|
|
2180
|
+
areas.forEach((area, index2) => {
|
|
2181
|
+
const areaCode = areaCodes == null ? void 0 : areaCodes.at(index2);
|
|
2182
|
+
state.$fetch.cacheDocuments.set(
|
|
2183
|
+
area.variant.fragment.fragment.id,
|
|
2184
|
+
area.variant.fragment.fragment.document
|
|
2185
|
+
);
|
|
2186
|
+
if (Array.isArray(area.variant.fragment.fragment.linkedFragments)) {
|
|
2187
|
+
area.variant.fragment.fragment.linkedFragments.forEach(
|
|
2188
|
+
(linkedFragment) => state.$fetch.cacheDocuments.set(
|
|
2189
|
+
linkedFragment.id,
|
|
2190
|
+
linkedFragment.document
|
|
2191
|
+
)
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
const entity = {
|
|
2195
|
+
fragmentId: area.variant.fragment.fragment.id,
|
|
2196
|
+
props: area.variant.fragment.props
|
|
2197
|
+
};
|
|
2198
|
+
state.$fetch.cacheAreaDocuments.set(areaCode, entity);
|
|
2199
|
+
});
|
|
2200
|
+
return areaCodes.map((code) => state.$fetch.cacheAreaDocuments.get(code));
|
|
2201
|
+
}
|
|
2202
|
+
return null;
|
|
2203
|
+
};
|
|
2204
|
+
state.$fetch = {
|
|
2205
|
+
cacheDocuments: /* @__PURE__ */ new Map(),
|
|
2206
|
+
cacheAreaDocuments: /* @__PURE__ */ new Map(),
|
|
2207
|
+
queryFragment,
|
|
2208
|
+
queryArea,
|
|
2209
|
+
queryAreaList,
|
|
2210
|
+
query: fetcher.query,
|
|
2211
|
+
sendBeacon: beaconFetcher.sendBeacon,
|
|
2212
|
+
readFragment: (fragmentId) => state.$fetch.cacheDocuments.get(fragmentId) ?? null,
|
|
2213
|
+
readArea: (areaCode) => state.$fetch.cacheAreaDocuments.get(areaCode) ?? null
|
|
2214
|
+
};
|
|
2215
|
+
};
|
|
2216
|
+
const getAllChildren = (layerResolver, layerKey, acc = []) => {
|
|
2217
|
+
var _a;
|
|
2218
|
+
const layer = layerResolver(layerKey) ?? {};
|
|
2219
|
+
if (acc.length === 0) {
|
|
2220
|
+
acc.push(keyOfEntity(layerKey));
|
|
2221
|
+
}
|
|
2222
|
+
(_a = layer == null ? void 0 : layer.children) == null ? void 0 : _a.forEach((child) => {
|
|
2223
|
+
if (child) {
|
|
2224
|
+
acc.push(keyOfEntity(child));
|
|
2225
|
+
getAllChildren(layerResolver, child, acc);
|
|
2226
|
+
}
|
|
2227
|
+
});
|
|
2228
|
+
return acc;
|
|
2229
|
+
};
|
|
2230
|
+
const buildCssBlock = (block) => {
|
|
2231
|
+
if (!block || block.css === "") return "";
|
|
2232
|
+
return `.${block.hash} {${block.css}}`;
|
|
2233
|
+
};
|
|
2234
|
+
const findGroups = (styles, layerResolver) => {
|
|
2235
|
+
const fragments = Object.keys(styles).filter(
|
|
2236
|
+
(key) => key == null ? void 0 : key.includes(index.nodes.Fragment)
|
|
2237
|
+
);
|
|
2238
|
+
const createFragmentSlice = (fragmentLayerKey) => {
|
|
2239
|
+
const rootLayer = layerResolver(fragmentLayerKey);
|
|
2240
|
+
const breakpoints = ((rootLayer == null ? void 0 : rootLayer.children) ?? []).map(
|
|
2241
|
+
(child) => layerResolver(child)
|
|
1615
2242
|
);
|
|
1616
2243
|
const primaryBreakpoint = breakpoints.find(
|
|
1617
2244
|
(breakpoint) => breakpoint == null ? void 0 : breakpoint.isPrimary
|
|
1618
2245
|
);
|
|
1619
|
-
const smaller = breakpoints.filter((
|
|
1620
|
-
const larger = breakpoints.filter((
|
|
2246
|
+
const smaller = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) < (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b) => b.width - a2.width);
|
|
2247
|
+
const larger = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) > (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b) => a2.width - b.width);
|
|
1621
2248
|
return {
|
|
2249
|
+
fragmentLayerKey,
|
|
1622
2250
|
fragment: rootLayer,
|
|
1623
|
-
primary: primaryBreakpoint
|
|
2251
|
+
primary: `${primaryBreakpoint._type}:${primaryBreakpoint == null ? void 0 : primaryBreakpoint._id}`,
|
|
1624
2252
|
smaller: smaller ?? [],
|
|
1625
2253
|
larger: larger ?? []
|
|
1626
2254
|
};
|
|
1627
2255
|
};
|
|
1628
2256
|
return fragments.map(createFragmentSlice).filter((slice) => slice.primary);
|
|
1629
2257
|
};
|
|
1630
|
-
const toCSS = (styles) => Object.entries(styles).filter(
|
|
2258
|
+
const toCSS = (styles) => Object.entries(styles).filter(
|
|
2259
|
+
([key, value]) => isValue(value) && value !== "" && !["_type", "_id"].includes(key)
|
|
2260
|
+
).map(
|
|
1631
2261
|
([key, value]) => `${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${value};`
|
|
1632
2262
|
).join("\n");
|
|
1633
2263
|
function compareRules(prev = {}, next = {}) {
|
|
@@ -1639,92 +2269,216 @@ function compareRules(prev = {}, next = {}) {
|
|
|
1639
2269
|
}
|
|
1640
2270
|
return diff;
|
|
1641
2271
|
}
|
|
1642
|
-
const makeCss = (
|
|
1643
|
-
|
|
1644
|
-
const
|
|
1645
|
-
const
|
|
1646
|
-
const
|
|
1647
|
-
const
|
|
1648
|
-
const
|
|
1649
|
-
isPrimary ? layerKey : getKey((_c = cacheLayer == null ? void 0 : cacheLayer.layer) == null ? void 0 : _c.overrideFrom)
|
|
1650
|
-
);
|
|
1651
|
-
const layerCss = cacheLayer == null ? void 0 : cacheLayer.styles;
|
|
1652
|
-
const overriderLayerCss = ((_e = cache.get(getKey((_d = cacheLayer == null ? void 0 : cacheLayer.layer) == null ? void 0 : _d.overrideFrom))) == null ? void 0 : _e.styles) ?? {};
|
|
2272
|
+
const makeCss = (styles, layerResolver) => (layerKey) => {
|
|
2273
|
+
const cacheLayer = layerResolver(layerKey);
|
|
2274
|
+
const isPrimary = !(cacheLayer == null ? void 0 : cacheLayer.overrideFrom);
|
|
2275
|
+
const overrideFromKey = (cacheLayer == null ? void 0 : cacheLayer.overrideFrom) ? String(getKey(cacheLayer == null ? void 0 : cacheLayer.overrideFrom)) : void 0;
|
|
2276
|
+
const layerHash = hashGenerator(isPrimary ? layerKey : overrideFromKey);
|
|
2277
|
+
const layerCss = styles == null ? void 0 : styles[layerKey];
|
|
2278
|
+
const overriderLayerCss = overrideFromKey ? (styles == null ? void 0 : styles[overrideFromKey]) ?? {} : {};
|
|
1653
2279
|
const resultCssRules = compareRules(overriderLayerCss, layerCss);
|
|
2280
|
+
const cssOverride = (cacheLayer == null ? void 0 : cacheLayer.cssOverride) ?? "";
|
|
1654
2281
|
return {
|
|
1655
2282
|
hash: layerHash,
|
|
1656
|
-
css: toCSS(resultCssRules)
|
|
2283
|
+
css: toCSS(resultCssRules) + cssOverride
|
|
1657
2284
|
};
|
|
1658
2285
|
};
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
2286
|
+
const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
2287
|
+
const removeStyle = () => {
|
|
2288
|
+
if (!isBrowser_default) return;
|
|
2289
|
+
const el = document.getElementById(key);
|
|
2290
|
+
if (el) el.remove();
|
|
2291
|
+
};
|
|
2292
|
+
const injectStyle = (styles) => {
|
|
2293
|
+
if (!isBrowser_default) return;
|
|
2294
|
+
if (!styles) {
|
|
2295
|
+
removeStyle();
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
const existing = document.getElementById(key);
|
|
2299
|
+
if (existing && existing.tagName === "STYLE") {
|
|
2300
|
+
existing.textContent = styles;
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
if (existing) existing.remove();
|
|
2304
|
+
const style = document.createElement("style");
|
|
2305
|
+
style.id = key;
|
|
2306
|
+
style.textContent = styles;
|
|
2307
|
+
document.head.appendChild(style);
|
|
2308
|
+
};
|
|
2309
|
+
let isMounted = false;
|
|
2310
|
+
let pendingStyles = "";
|
|
2311
|
+
state.subscribe(
|
|
2312
|
+
graphKey,
|
|
2313
|
+
(next) => {
|
|
2314
|
+
const styles = (transformStyles == null ? void 0 : transformStyles(next)) ?? (next == null ? void 0 : next.styles) ?? [];
|
|
2315
|
+
const resultStyle = styles.join("\n");
|
|
2316
|
+
pendingStyles = resultStyle;
|
|
2317
|
+
if (isMounted) {
|
|
2318
|
+
injectStyle(resultStyle);
|
|
2319
|
+
}
|
|
2320
|
+
},
|
|
2321
|
+
{ directChangesOnly: true }
|
|
2322
|
+
);
|
|
2323
|
+
const mount = () => {
|
|
2324
|
+
isMounted = true;
|
|
2325
|
+
if (pendingStyles) {
|
|
2326
|
+
injectStyle(pendingStyles);
|
|
2327
|
+
} else {
|
|
2328
|
+
removeStyle();
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
const unmount = () => {
|
|
2332
|
+
isMounted = false;
|
|
2333
|
+
removeStyle();
|
|
2334
|
+
};
|
|
2335
|
+
return { mount, unmount };
|
|
2336
|
+
};
|
|
2337
|
+
function generatePrimaryCssBlocks(layerResolver, group, cssMaker) {
|
|
2338
|
+
const children = getAllChildren(layerResolver, group.primary);
|
|
2339
|
+
return children.map(cssMaker).map(buildCssBlock);
|
|
2340
|
+
}
|
|
2341
|
+
function generateSmallerCssBlocks(layerResolver, group, cssMaker) {
|
|
2342
|
+
return group.smaller.map(
|
|
2343
|
+
(smallerLayer, index2, arr) => {
|
|
2344
|
+
const smallerChildren = getAllChildren(layerResolver, smallerLayer);
|
|
2345
|
+
const smallerCssBlocks = smallerChildren.map(cssMaker);
|
|
2346
|
+
const max = index2 === 0 ? group.primary.width - 1 : arr[index2 - 1].width;
|
|
2347
|
+
return `@container (max-width: ${max}px) {${smallerCssBlocks.map(buildCssBlock).join("")}}`;
|
|
2348
|
+
}
|
|
2349
|
+
);
|
|
2350
|
+
}
|
|
2351
|
+
function generateLargerCssBlocks(layerResolver, group, cssMaker) {
|
|
2352
|
+
return group.larger.map(
|
|
2353
|
+
(largerLayer, index2, arr) => {
|
|
2354
|
+
const largerChildren = getAllChildren(layerResolver, largerLayer);
|
|
2355
|
+
const largerCssBlocks = largerChildren.map(cssMaker);
|
|
2356
|
+
const min = largerLayer.width;
|
|
2357
|
+
const max = index2 < arr.length - 1 ? arr[index2 + 1].width - 1 : null;
|
|
2358
|
+
const containerQuery = max ? `@container (min-width: ${min}px) and (max-width: ${max}px)` : `@container (min-width: ${min}px)`;
|
|
2359
|
+
return `${containerQuery} {${largerCssBlocks.map(buildCssBlock).join("")}}`;
|
|
2360
|
+
}
|
|
2361
|
+
);
|
|
2362
|
+
}
|
|
2363
|
+
function extractStyleSheet(styles, layerResolver) {
|
|
2364
|
+
const [group] = findGroups(styles, layerResolver);
|
|
2365
|
+
if (!group) {
|
|
2366
|
+
return [];
|
|
1666
2367
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
2368
|
+
const cssMaker = makeCss(styles, layerResolver);
|
|
2369
|
+
const fragmentCssRules = [];
|
|
2370
|
+
fragmentCssRules.push(buildCssBlock(cssMaker(group.fragmentLayerKey)));
|
|
2371
|
+
const primaryStyles = generatePrimaryCssBlocks(
|
|
2372
|
+
layerResolver,
|
|
2373
|
+
group,
|
|
2374
|
+
cssMaker
|
|
2375
|
+
);
|
|
2376
|
+
fragmentCssRules.push(...primaryStyles);
|
|
2377
|
+
fragmentCssRules.push(
|
|
2378
|
+
...generateSmallerCssBlocks(layerResolver, group, cssMaker)
|
|
2379
|
+
);
|
|
2380
|
+
fragmentCssRules.push(
|
|
2381
|
+
...generateLargerCssBlocks(layerResolver, group, cssMaker)
|
|
2382
|
+
);
|
|
2383
|
+
return fragmentCssRules;
|
|
2384
|
+
}
|
|
2385
|
+
const fragmentStylesheetPlugin = (state) => {
|
|
2386
|
+
const KEY = `${PLUGIN_TYPES.FragmentStylesheet}:root`;
|
|
2387
|
+
const addStyle = (layerKey, style) => {
|
|
2388
|
+
state.mutate(KEY, {
|
|
2389
|
+
styles: {
|
|
2390
|
+
[layerKey]: style
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
};
|
|
2394
|
+
state.mutate(KEY, {
|
|
2395
|
+
styles: {}
|
|
1670
2396
|
});
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
2397
|
+
const fragmentStyleInjector = autoInjector(state.key, state, KEY, (graph) => {
|
|
2398
|
+
return extractStyleSheet(graph.styles, state.resolve);
|
|
2399
|
+
});
|
|
2400
|
+
const destroyStyles = () => {
|
|
2401
|
+
state.mutate(
|
|
2402
|
+
KEY,
|
|
2403
|
+
{
|
|
2404
|
+
styles: {}
|
|
2405
|
+
},
|
|
2406
|
+
{ replace: true }
|
|
2407
|
+
);
|
|
2408
|
+
fragmentStyleInjector.unmount();
|
|
2409
|
+
};
|
|
2410
|
+
state.$styleSheet = {
|
|
2411
|
+
key: KEY,
|
|
2412
|
+
addStyle,
|
|
2413
|
+
mount: fragmentStyleInjector.mount,
|
|
2414
|
+
unmount: destroyStyles,
|
|
2415
|
+
extract: (withTag) => {
|
|
2416
|
+
var _a;
|
|
2417
|
+
const graph = state.resolve(KEY);
|
|
2418
|
+
const styles = extractStyleSheet(graph == null ? void 0 : graph.styles, state.resolve);
|
|
2419
|
+
const resultStyle = styles.join("\n");
|
|
2420
|
+
if (withTag) {
|
|
2421
|
+
const id = state.entityOfKey((_a = state.$fragment) == null ? void 0 : _a.root);
|
|
2422
|
+
return `<style id="fragment-${id._id}">${resultStyle}</style>`;
|
|
2423
|
+
}
|
|
2424
|
+
return resultStyle;
|
|
2425
|
+
}
|
|
2426
|
+
};
|
|
2427
|
+
return state;
|
|
1676
2428
|
};
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
primaryCssBlocks.forEach((block) => {
|
|
1687
|
-
fragmentCssRules.push(buildCssBlock(block));
|
|
1688
|
-
});
|
|
1689
|
-
group.smaller.forEach((smallerLayer, index2, arr) => {
|
|
1690
|
-
const smallerChildren = getAllChildren(state, smallerLayer);
|
|
1691
|
-
const smallerCssBlocks = smallerChildren.map(cssMaker);
|
|
1692
|
-
const max = index2 === 0 ? group.primary.width - 1 : arr[index2 - 1].width;
|
|
1693
|
-
fragmentCssRules.push(
|
|
1694
|
-
`@container (max-width: ${max}px) {${smallerCssBlocks.map(buildCssBlock).join("")}}`
|
|
1695
|
-
);
|
|
1696
|
-
});
|
|
1697
|
-
group.larger.forEach((largerLayer, index2, arr) => {
|
|
1698
|
-
const largerChildren = getAllChildren(state, largerLayer);
|
|
1699
|
-
const largerCssBlocks = largerChildren.map((l) => cssMaker(l, 123));
|
|
1700
|
-
const min = largerLayer.width;
|
|
1701
|
-
const max = index2 < arr.length - 1 ? arr[index2 + 1].width - 1 : null;
|
|
1702
|
-
const containerQuery = max ? `@container (min-width: ${min}px) and (max-width: ${max}px)` : `@container (min-width: ${min}px)`;
|
|
1703
|
-
fragmentCssRules.push(
|
|
1704
|
-
`${containerQuery} {${largerCssBlocks.map(buildCssBlock).join("")}}`
|
|
1705
|
-
);
|
|
1706
|
-
});
|
|
1707
|
-
fragmentCssRules.push(`[data-key^="Text"] { p {margin: 0;} }`);
|
|
1708
|
-
return {
|
|
1709
|
-
fragment: state.keyOfEntity(group.fragment),
|
|
1710
|
-
styles: fragmentCssRules
|
|
1711
|
-
};
|
|
2429
|
+
const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
|
|
2430
|
+
const globalStylesheetPlugin = (state) => {
|
|
2431
|
+
if (!("$fragments" in state)) {
|
|
2432
|
+
throw new Error("GlobalStylesheetPlugin need $fragments plugin");
|
|
2433
|
+
}
|
|
2434
|
+
const KEY = `${PLUGIN_TYPES.GlobalStylesheet}:root`;
|
|
2435
|
+
const addStyle = (style) => {
|
|
2436
|
+
state.mutate(KEY, {
|
|
2437
|
+
styles: [style]
|
|
1712
2438
|
});
|
|
1713
|
-
return fragmentsStyle;
|
|
1714
2439
|
};
|
|
1715
|
-
state
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
2440
|
+
state.mutate({
|
|
2441
|
+
_type: PLUGIN_TYPES.GlobalStylesheet,
|
|
2442
|
+
_id: "root",
|
|
2443
|
+
styles: []
|
|
2444
|
+
});
|
|
2445
|
+
const globalStyleInjector = autoInjector("global", state, KEY);
|
|
2446
|
+
state.$globalStylesheet = {
|
|
2447
|
+
key: KEY,
|
|
2448
|
+
addStyle,
|
|
2449
|
+
mount: globalStyleInjector.mount,
|
|
2450
|
+
unmount: globalStyleInjector.unmount,
|
|
2451
|
+
extractStyles: () => {
|
|
2452
|
+
const allFragments = state.$fragments.getManagers();
|
|
2453
|
+
const styles = Object.entries(allFragments).filter(([, value]) => !!(value == null ? void 0 : value.resolve)).map(([, manager]) => manager.$styleSheet.extract(true));
|
|
2454
|
+
return styles.join("");
|
|
2455
|
+
}
|
|
1722
2456
|
};
|
|
2457
|
+
addStyle(globalCss);
|
|
2458
|
+
globalStyleInjector.mount();
|
|
2459
|
+
return state;
|
|
1723
2460
|
};
|
|
1724
|
-
const
|
|
2461
|
+
const scopesPlugin = (state) => {
|
|
2462
|
+
const scopesMap = /* @__PURE__ */ new Map();
|
|
2463
|
+
const registerScope = (layerKey, scopeValue) => {
|
|
2464
|
+
scopesMap.set(layerKey, scopeValue);
|
|
2465
|
+
};
|
|
2466
|
+
state.$scopes = {
|
|
2467
|
+
scopes: scopesMap,
|
|
2468
|
+
registerScope
|
|
2469
|
+
};
|
|
2470
|
+
return state;
|
|
2471
|
+
};
|
|
2472
|
+
const fragmentsPlugin = (options) => (state) => {
|
|
2473
|
+
const plugins = (options == null ? void 0 : options.plugins) ?? [];
|
|
1725
2474
|
const createFragmentManager = (fragmentId, initialDocument = {}) => {
|
|
1726
2475
|
var _a, _b;
|
|
1727
2476
|
if (!fragmentId || !initialDocument) return null;
|
|
2477
|
+
const fragmentLayerId = (initialDocument == null ? void 0 : initialDocument._type) === index.nodes.Fragment ? initialDocument == null ? void 0 : initialDocument._id : null;
|
|
2478
|
+
if (!fragmentLayerId) {
|
|
2479
|
+
console.error("Cannot find fragment layer id");
|
|
2480
|
+
return;
|
|
2481
|
+
}
|
|
1728
2482
|
const cacheManager = (_b = (_a = state.resolve(state.$fragments.key)) == null ? void 0 : _a.managers) == null ? void 0 : _b[fragmentId];
|
|
1729
2483
|
if (cacheManager) {
|
|
1730
2484
|
return cacheManager;
|
|
@@ -1737,21 +2491,33 @@ const fragmentsPlugin = (state) => {
|
|
|
1737
2491
|
_type: "Spring",
|
|
1738
2492
|
_id: "root"
|
|
1739
2493
|
};
|
|
1740
|
-
const manager =
|
|
2494
|
+
const manager = createState({
|
|
1741
2495
|
_type: "FragmentManager",
|
|
1742
2496
|
_id: fragmentId,
|
|
1743
2497
|
initialState: initialDocument,
|
|
1744
2498
|
plugins: [
|
|
1745
2499
|
(state2) => {
|
|
1746
2500
|
state2.$fragment = {
|
|
1747
|
-
root: `${index.nodes.Fragment}:${
|
|
2501
|
+
root: `${index.nodes.Fragment}:${fragmentLayerId}`,
|
|
1748
2502
|
temp: "Temp:root"
|
|
1749
2503
|
};
|
|
1750
2504
|
},
|
|
1751
2505
|
// cssPlugin,
|
|
1752
|
-
|
|
2506
|
+
fragmentStylesheetPlugin,
|
|
2507
|
+
scopesPlugin,
|
|
2508
|
+
...plugins
|
|
1753
2509
|
],
|
|
1754
|
-
skip: [
|
|
2510
|
+
skip: [
|
|
2511
|
+
g,
|
|
2512
|
+
f,
|
|
2513
|
+
isKey,
|
|
2514
|
+
u([
|
|
2515
|
+
...Object.keys(index.nodes),
|
|
2516
|
+
"Temp",
|
|
2517
|
+
"Spring",
|
|
2518
|
+
PLUGIN_TYPES.FragmentStylesheet
|
|
2519
|
+
])
|
|
2520
|
+
]
|
|
1755
2521
|
});
|
|
1756
2522
|
manager.mutate(tempGraph);
|
|
1757
2523
|
manager.mutate(springGraph);
|
|
@@ -1770,13 +2536,13 @@ const fragmentsPlugin = (state) => {
|
|
|
1770
2536
|
return (_a = state.resolve(state.$fragments.key)) == null ? void 0 : _a.managers;
|
|
1771
2537
|
};
|
|
1772
2538
|
state.$fragments = {
|
|
1773
|
-
key:
|
|
2539
|
+
key: `${PLUGIN_TYPES.FragmentsPlugin}:root`,
|
|
1774
2540
|
createFragmentManager,
|
|
1775
2541
|
getManager,
|
|
1776
2542
|
getManagers
|
|
1777
2543
|
};
|
|
1778
2544
|
state.mutate({
|
|
1779
|
-
_type:
|
|
2545
|
+
_type: PLUGIN_TYPES.FragmentsPlugin,
|
|
1780
2546
|
_id: "root",
|
|
1781
2547
|
managers: {}
|
|
1782
2548
|
});
|
|
@@ -1785,78 +2551,258 @@ const fragmentsPlugin = (state) => {
|
|
|
1785
2551
|
const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value: String) {
|
|
1786
2552
|
addClientMetric(metric: {metricType: $type, metricValue: $value})
|
|
1787
2553
|
}`;
|
|
1788
|
-
const
|
|
2554
|
+
const pendingPixels = /* @__PURE__ */ new Set();
|
|
2555
|
+
const sendWithImage = (url) => {
|
|
2556
|
+
try {
|
|
2557
|
+
const pixel = new Image();
|
|
2558
|
+
pixel.referrerPolicy = "no-referrer";
|
|
2559
|
+
const handleCleanup = () => {
|
|
2560
|
+
pixel.removeEventListener("load", handleCleanup);
|
|
2561
|
+
pixel.removeEventListener("error", handleCleanup);
|
|
2562
|
+
pendingPixels.delete(pixel);
|
|
2563
|
+
};
|
|
2564
|
+
pixel.addEventListener("load", handleCleanup, { once: true });
|
|
2565
|
+
pixel.addEventListener("error", handleCleanup, { once: true });
|
|
2566
|
+
pendingPixels.add(pixel);
|
|
2567
|
+
pixel.src = url;
|
|
2568
|
+
} catch {
|
|
2569
|
+
}
|
|
2570
|
+
};
|
|
2571
|
+
const sendWithFetch = (url) => {
|
|
2572
|
+
if (typeof fetch !== "function") {
|
|
2573
|
+
return false;
|
|
2574
|
+
}
|
|
2575
|
+
try {
|
|
2576
|
+
fetch(url, {
|
|
2577
|
+
method: "GET",
|
|
2578
|
+
mode: "no-cors",
|
|
2579
|
+
keepalive: true
|
|
2580
|
+
}).catch(() => void 0);
|
|
2581
|
+
return true;
|
|
2582
|
+
} catch {
|
|
2583
|
+
return false;
|
|
2584
|
+
}
|
|
2585
|
+
};
|
|
2586
|
+
const sendWithNavigatorBeacon = (url) => {
|
|
2587
|
+
if (typeof navigator === "undefined" || typeof navigator.sendBeacon !== "function") {
|
|
2588
|
+
return false;
|
|
2589
|
+
}
|
|
2590
|
+
try {
|
|
2591
|
+
return navigator.sendBeacon(url);
|
|
2592
|
+
} catch {
|
|
2593
|
+
return false;
|
|
2594
|
+
}
|
|
2595
|
+
};
|
|
2596
|
+
const trackAdPixel = (pixelUrl, customBeacon) => {
|
|
2597
|
+
if (!isBrowser_default) {
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
const url = pixelUrl == null ? void 0 : pixelUrl.trim();
|
|
2601
|
+
if (!url) {
|
|
2602
|
+
return;
|
|
2603
|
+
}
|
|
2604
|
+
if (typeof customBeacon === "function") {
|
|
2605
|
+
try {
|
|
2606
|
+
const result = customBeacon(url);
|
|
2607
|
+
if (result === true) {
|
|
2608
|
+
return;
|
|
2609
|
+
}
|
|
2610
|
+
} catch {
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
if (sendWithNavigatorBeacon(url)) {
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
if (sendWithFetch(url)) {
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
sendWithImage(url);
|
|
2620
|
+
};
|
|
2621
|
+
const types = createConstants(
|
|
1789
2622
|
"INIT_SESSION",
|
|
1790
2623
|
"RELEASE_SESSION",
|
|
1791
2624
|
"REACH_PROJECT_GOAL"
|
|
1792
2625
|
);
|
|
1793
|
-
const
|
|
1794
|
-
const sendMetric = (type, value) => {
|
|
1795
|
-
var _a
|
|
1796
|
-
(_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.
|
|
1797
|
-
|
|
1798
|
-
query(addClientMetric, { type, value });
|
|
1799
|
-
};
|
|
1800
|
-
const initClient = async () => {
|
|
1801
|
-
console.log("initClient");
|
|
1802
|
-
sendMetric(types.INIT_SESSION);
|
|
1803
|
-
};
|
|
1804
|
-
const releaseClient = async () => {
|
|
1805
|
-
sendMetric(types.RELEASE_SESSION);
|
|
2626
|
+
const globalMetricsPlugin = (state) => {
|
|
2627
|
+
const sendMetric = async (type, value) => {
|
|
2628
|
+
var _a;
|
|
2629
|
+
const query = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.query;
|
|
2630
|
+
await query(addClientMetric, { type, value });
|
|
1806
2631
|
};
|
|
1807
2632
|
const reachGoal = (goal) => {
|
|
1808
2633
|
sendMetric(types.REACH_PROJECT_GOAL, goal);
|
|
1809
2634
|
};
|
|
2635
|
+
const sendAdPixel = (pixelUrl) => {
|
|
2636
|
+
var _a;
|
|
2637
|
+
trackAdPixel(pixelUrl, (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.sendBeacon);
|
|
2638
|
+
};
|
|
1810
2639
|
state.$metrics = {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
reachGoal
|
|
2640
|
+
reachGoal,
|
|
2641
|
+
trackAdPixel: sendAdPixel
|
|
1814
2642
|
};
|
|
1815
2643
|
};
|
|
2644
|
+
const loadPlugin = (state) => {
|
|
2645
|
+
if (!["$fetch", "$fragments"].every((field) => field in state)) {
|
|
2646
|
+
console.error("LoadFragmentPlugin depends from Fetch and Fragments plugin");
|
|
2647
|
+
return state;
|
|
2648
|
+
}
|
|
2649
|
+
const resourceCache = /* @__PURE__ */ new Map();
|
|
2650
|
+
const createSuspenseResource = (key, fetcher) => {
|
|
2651
|
+
if (resourceCache.has(key)) return resourceCache.get(key);
|
|
2652
|
+
let status = "pending";
|
|
2653
|
+
let result;
|
|
2654
|
+
const suspender = fetcher().then(
|
|
2655
|
+
(r2) => {
|
|
2656
|
+
status = "success";
|
|
2657
|
+
result = r2;
|
|
2658
|
+
},
|
|
2659
|
+
(e) => {
|
|
2660
|
+
status = "error";
|
|
2661
|
+
result = e;
|
|
2662
|
+
}
|
|
2663
|
+
);
|
|
2664
|
+
const resource = {
|
|
2665
|
+
read() {
|
|
2666
|
+
if (status === "pending") throw suspender;
|
|
2667
|
+
if (status === "error") throw result;
|
|
2668
|
+
return result;
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
resourceCache.set(key, resource);
|
|
2672
|
+
return resource;
|
|
2673
|
+
};
|
|
2674
|
+
const loadFragment = (fragmentId, options) => {
|
|
2675
|
+
var _a, _b;
|
|
2676
|
+
const suspense = options == null ? void 0 : options.suspense;
|
|
2677
|
+
const readFragment = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.readFragment(fragmentId);
|
|
2678
|
+
const fragmentManager = (_b = state == null ? void 0 : state.$fragments) == null ? void 0 : _b.getManager(fragmentId);
|
|
2679
|
+
if (readFragment && !fragmentManager) {
|
|
2680
|
+
return state.$fragments.createFragmentManager(fragmentId, readFragment);
|
|
2681
|
+
}
|
|
2682
|
+
if (readFragment && fragmentManager) return fragmentManager;
|
|
2683
|
+
const loader = async () => {
|
|
2684
|
+
var _a2;
|
|
2685
|
+
const fragmentDocument = await ((_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.queryFragment(fragmentId));
|
|
2686
|
+
return state.$fragments.createFragmentManager(
|
|
2687
|
+
fragmentId,
|
|
2688
|
+
fragmentDocument
|
|
2689
|
+
);
|
|
2690
|
+
};
|
|
2691
|
+
if (suspense) {
|
|
2692
|
+
const resource = createSuspenseResource(fragmentId, loader);
|
|
2693
|
+
return resource.read();
|
|
2694
|
+
}
|
|
2695
|
+
return loader();
|
|
2696
|
+
};
|
|
2697
|
+
const loadArea = (areaCode, options) => {
|
|
2698
|
+
var _a;
|
|
2699
|
+
const suspense = options == null ? void 0 : options.suspense;
|
|
2700
|
+
const readArea2 = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.readArea(areaCode);
|
|
2701
|
+
if (readArea2) return readArea2;
|
|
2702
|
+
const loader = async () => {
|
|
2703
|
+
var _a2;
|
|
2704
|
+
const areaEntity = await ((_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.queryArea(areaCode));
|
|
2705
|
+
console.log(areaEntity);
|
|
2706
|
+
await loadFragment(areaEntity == null ? void 0 : areaEntity.fragmentId, {
|
|
2707
|
+
suspense: false
|
|
2708
|
+
});
|
|
2709
|
+
return areaEntity;
|
|
2710
|
+
};
|
|
2711
|
+
if (suspense) {
|
|
2712
|
+
const resource = createSuspenseResource(areaCode, loader);
|
|
2713
|
+
return resource.read();
|
|
2714
|
+
}
|
|
2715
|
+
return loader();
|
|
2716
|
+
};
|
|
2717
|
+
const readArea = () => {
|
|
2718
|
+
return state;
|
|
2719
|
+
};
|
|
2720
|
+
state.$load = {
|
|
2721
|
+
loadFragment,
|
|
2722
|
+
loadArea,
|
|
2723
|
+
readArea
|
|
2724
|
+
};
|
|
2725
|
+
};
|
|
2726
|
+
const PLUGIN_TYPES = createConstants(
|
|
2727
|
+
"FragmentsPlugin",
|
|
2728
|
+
"GlobalStylesheet",
|
|
2729
|
+
"FragmentStylesheet"
|
|
2730
|
+
);
|
|
1816
2731
|
const createFragmentsClient = (options) => {
|
|
1817
|
-
|
|
2732
|
+
const BACKEND_TARGET = (options == null ? void 0 : options.isSelf) ? "/graphql" : "http://85.192.29.65/graphql";
|
|
2733
|
+
return createState({
|
|
1818
2734
|
_type: "GlobalManager",
|
|
1819
2735
|
initialState: {},
|
|
2736
|
+
skip: [
|
|
2737
|
+
u([
|
|
2738
|
+
...Object.keys(index.nodes),
|
|
2739
|
+
...Object.keys(PLUGIN_TYPES)
|
|
2740
|
+
])
|
|
2741
|
+
],
|
|
1820
2742
|
plugins: [
|
|
1821
2743
|
(state) => {
|
|
1822
2744
|
state.env = {
|
|
1823
2745
|
isSelf: (options == null ? void 0 : options.isSelf) ?? false,
|
|
1824
|
-
|
|
1825
|
-
apiToken: options == null ? void 0 : options.apiToken
|
|
1826
|
-
|
|
1827
|
-
state.$global = {};
|
|
1828
|
-
state.extractStyles = async () => {
|
|
1829
|
-
const allFragments = state.$fragments.getManagers();
|
|
1830
|
-
const extractors = Object.entries(allFragments).filter(([, value]) => !!(value == null ? void 0 : value.resolve)).map(([, manager]) => manager.$styleSheet.extract());
|
|
1831
|
-
const extractedStyles = await Promise.all(extractors);
|
|
1832
|
-
return Object.values(
|
|
1833
|
-
extractedStyles.reduce((acc, extrected) => {
|
|
1834
|
-
Object.entries(extrected).forEach(([key, styleTag]) => {
|
|
1835
|
-
acc[key] = styleTag;
|
|
1836
|
-
});
|
|
1837
|
-
return acc;
|
|
1838
|
-
}, {})
|
|
1839
|
-
);
|
|
2746
|
+
backendEndpoint: (options == null ? void 0 : options.backendEndpoint) ?? BACKEND_TARGET,
|
|
2747
|
+
apiToken: options == null ? void 0 : options.apiToken,
|
|
2748
|
+
referer: options == null ? void 0 : options.referer
|
|
1840
2749
|
};
|
|
1841
2750
|
},
|
|
1842
2751
|
fetchPlugin,
|
|
1843
|
-
fragmentsPlugin
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
(_c = (_b = state == null ? void 0 : state.$metrics) == null ? void 0 : _b.initClient) == null ? void 0 : _c.call(_b);
|
|
1850
|
-
window.addEventListener(
|
|
1851
|
-
"beforeunload",
|
|
1852
|
-
(_e = (_d = state == null ? void 0 : state.$metrics) == null ? void 0 : _d.releaseClient) == null ? void 0 : _e.call(_d)
|
|
1853
|
-
);
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
2752
|
+
fragmentsPlugin({
|
|
2753
|
+
plugins: options == null ? void 0 : options.fragmentPlugins
|
|
2754
|
+
}),
|
|
2755
|
+
loadPlugin,
|
|
2756
|
+
globalMetricsPlugin,
|
|
2757
|
+
globalStylesheetPlugin
|
|
1857
2758
|
]
|
|
1858
2759
|
});
|
|
1859
2760
|
};
|
|
2761
|
+
const ssrPlugin = (state) => {
|
|
2762
|
+
var _a, _b, _c;
|
|
2763
|
+
if (!["$fragments"].every((field) => field in state)) {
|
|
2764
|
+
console.error("SSRPlugin depends from Fragments plugin");
|
|
2765
|
+
return state;
|
|
2766
|
+
}
|
|
2767
|
+
const cacheDocuments = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.cacheDocuments;
|
|
2768
|
+
const cacheAreas = (_b = state == null ? void 0 : state.$fetch) == null ? void 0 : _b.cacheAreaDocuments;
|
|
2769
|
+
const createManager = (_c = state == null ? void 0 : state.$fragments) == null ? void 0 : _c.createFragmentManager;
|
|
2770
|
+
const fromMap = (map) => {
|
|
2771
|
+
return Array.from(map).reduce((acc, [key, value]) => {
|
|
2772
|
+
acc[key] = value;
|
|
2773
|
+
return acc;
|
|
2774
|
+
}, {});
|
|
2775
|
+
};
|
|
2776
|
+
const extractData = () => {
|
|
2777
|
+
const documents = fromMap(cacheDocuments.entries());
|
|
2778
|
+
const areas = fromMap(cacheAreas.entries());
|
|
2779
|
+
return {
|
|
2780
|
+
documents,
|
|
2781
|
+
areas
|
|
2782
|
+
};
|
|
2783
|
+
};
|
|
2784
|
+
const restoreData = (input) => {
|
|
2785
|
+
if (!input || typeof input !== "object" && !Array.isArray(input))
|
|
2786
|
+
return null;
|
|
2787
|
+
if ("documents" in input && isObject(input.documents)) {
|
|
2788
|
+
Object.entries(input.documents).forEach(([fragmentId, doc]) => {
|
|
2789
|
+
cacheDocuments.set(+fragmentId, doc);
|
|
2790
|
+
createManager(+fragmentId, doc);
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
if ("areas" in input && isObject(input.areas)) {
|
|
2794
|
+
Object.entries(input.areas).forEach(([areaCode, entity]) => {
|
|
2795
|
+
cacheAreas.set(areaCode, entity);
|
|
2796
|
+
});
|
|
2797
|
+
}
|
|
2798
|
+
};
|
|
2799
|
+
state.$ssr = {
|
|
2800
|
+
extractData,
|
|
2801
|
+
restoreData
|
|
2802
|
+
};
|
|
2803
|
+
return state;
|
|
2804
|
+
};
|
|
1860
2805
|
export {
|
|
1861
|
-
createFragmentsClient
|
|
2806
|
+
createFragmentsClient,
|
|
2807
|
+
ssrPlugin
|
|
1862
2808
|
};
|