@fragmentsx/render-react 0.0.4 → 0.0.5
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/components/Fragment/index.d.ts +8 -0
- package/dist/components/Fragment/index.d.ts.map +1 -0
- package/dist/components/Frame/index.d.ts +9 -0
- package/dist/components/Frame/index.d.ts.map +1 -0
- package/dist/components/GlobalManager/index.d.ts +5 -0
- package/dist/components/GlobalManager/index.d.ts.map +1 -0
- package/dist/components/Instance/index.d.ts +10 -0
- package/dist/components/Instance/index.d.ts.map +1 -0
- package/dist/components/Text/index.d.ts +8 -0
- package/dist/components/Text/index.d.ts.map +1 -0
- package/dist/helpers/collectStyles.d.ts +3 -0
- package/dist/helpers/collectStyles.d.ts.map +1 -0
- package/dist/helpers/hydration.d.ts +3 -0
- package/dist/helpers/hydration.d.ts.map +1 -0
- package/dist/helpers/isBrowser.d.ts +2 -0
- package/dist/helpers/isBrowser.d.ts.map +1 -0
- package/dist/helpers/loadFragmentManager.d.ts +3 -0
- package/dist/helpers/loadFragmentManager.d.ts.map +1 -0
- package/dist/hocs/reactCSRAdapter.d.ts +2 -0
- package/dist/hocs/reactCSRAdapter.d.ts.map +1 -0
- package/dist/hocs/reactSSRAdapter.d.ts +3 -0
- package/dist/hocs/reactSSRAdapter.d.ts.map +1 -0
- package/dist/index.cjs.js +2320 -105
- package/dist/index.d.ts +3 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +2317 -102
- package/dist/reactAdapter.d.ts +1 -2
- package/dist/reactAdapter.d.ts.map +1 -1
- package/package.json +17 -14
- package/dist/components/GlobalManager.d.ts +0 -2
- package/dist/components/GlobalManager.d.ts.map +0 -1
- package/dist/hooks/useFragmentManager.d.ts +0 -5
- package/dist/hooks/useFragmentManager.d.ts.map +0 -1
- package/dist/hooks/useFragmentProperties.d.ts +0 -2
- package/dist/hooks/useFragmentProperties.d.ts.map +0 -1
- package/dist/hooks/useGlobalManager.d.ts +0 -2
- package/dist/hooks/useGlobalManager.d.ts.map +0 -1
- package/dist/hooks/useRenderTarget.d.ts +0 -7
- package/dist/hooks/useRenderTarget.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,34 +1,1349 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const require$$0 = require("react");
|
|
5
|
-
require("
|
|
5
|
+
const core = require("@graph-state/core");
|
|
6
6
|
const definition = require("@fragmentsx/definition");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const collectStyles = (globalManager) => {
|
|
8
|
+
if (!globalManager) return null;
|
|
9
|
+
const allFragments = globalManager.$fragments.getManagers();
|
|
10
|
+
const extractors = Object.entries(allFragments).filter(([, value]) => !!(value == null ? void 0 : value.resolve)).map(([fragmentId, manager]) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const a = (_a = manager.extractStyleSheet()) == null ? void 0 : _a.at(0);
|
|
13
|
+
return a;
|
|
14
|
+
});
|
|
15
|
+
return extractors.map((extractor) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
16
|
+
"style",
|
|
17
|
+
{
|
|
18
|
+
id: `fragments-${extractor == null ? void 0 : extractor.fragment}`,
|
|
19
|
+
dangerouslySetInnerHTML: { __html: extractor == null ? void 0 : extractor.styles.join("") }
|
|
20
|
+
}
|
|
21
|
+
));
|
|
22
|
+
};
|
|
23
|
+
"function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;
|
|
24
|
+
(function() {
|
|
25
|
+
try {
|
|
26
|
+
if (typeof document != "undefined") {
|
|
27
|
+
var elementStyle = document.createElement("style");
|
|
28
|
+
elementStyle.appendChild(document.createTextNode("._fragment_1c708_1 {\n width: 100%;\n height: 100%;\n}\n\n._fragmentDocument_1c708_6 {\n display: contents;\n}\n._text_1liuf_1 {\n white-space: pre;\n :where(p) {\n margin: 0;\n }\n}"));
|
|
29
|
+
document.head.appendChild(elementStyle);
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error("vite-plugin-css-injected-by-js", e);
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
const createConstants = (...constants) => {
|
|
36
|
+
return constants.reduce((acc, constant) => {
|
|
37
|
+
acc[constant] = constant;
|
|
38
|
+
return acc;
|
|
39
|
+
}, {});
|
|
40
|
+
};
|
|
41
|
+
const nodes = createConstants(
|
|
42
|
+
"Fragment",
|
|
43
|
+
"FragmentInstance",
|
|
44
|
+
"Instance",
|
|
45
|
+
"Breakpoint",
|
|
46
|
+
"Frame",
|
|
47
|
+
"Image",
|
|
48
|
+
"Text",
|
|
49
|
+
"SolidPaintStyle",
|
|
50
|
+
"CssLink",
|
|
51
|
+
"Variable",
|
|
52
|
+
"ComputedValue",
|
|
53
|
+
"TransformValue"
|
|
54
|
+
);
|
|
55
|
+
const fragmentGrowingMode = createConstants("auto", "fill");
|
|
56
|
+
const borderType = createConstants("None", "Solid", "Dashed", "Dotted");
|
|
57
|
+
const linkTarget = createConstants("_blank");
|
|
58
|
+
const paintMode = createConstants("None", "Solid", "Image");
|
|
59
|
+
const imagePaintScaleModes = createConstants(
|
|
60
|
+
"Fill",
|
|
61
|
+
"Fit",
|
|
62
|
+
"Crop",
|
|
63
|
+
"Tile"
|
|
64
|
+
);
|
|
65
|
+
const constrain = createConstants(
|
|
66
|
+
"Min",
|
|
67
|
+
"Center",
|
|
68
|
+
"Max",
|
|
69
|
+
"Stretch",
|
|
70
|
+
"Scale"
|
|
71
|
+
);
|
|
72
|
+
const positionType = createConstants("absolute", "relative");
|
|
73
|
+
const sizing = createConstants("Fixed", "Hug", "Fill", "Relative");
|
|
74
|
+
const layerMode = createConstants("none", "flex");
|
|
75
|
+
const layerDirection = createConstants("vertical", "horizontal");
|
|
76
|
+
const layerAlign = createConstants("start", "center", "end");
|
|
77
|
+
const layerDistribute = createConstants(
|
|
78
|
+
"start",
|
|
79
|
+
"center",
|
|
80
|
+
"end",
|
|
81
|
+
"space-between",
|
|
82
|
+
"space-around"
|
|
83
|
+
);
|
|
84
|
+
const textTransform = createConstants(
|
|
85
|
+
"none",
|
|
86
|
+
"uppercase",
|
|
87
|
+
"lowercase",
|
|
88
|
+
"capitalize"
|
|
89
|
+
);
|
|
90
|
+
const textDecorations = createConstants(
|
|
91
|
+
"none",
|
|
92
|
+
"underline",
|
|
93
|
+
"line-through"
|
|
94
|
+
);
|
|
95
|
+
const effectType = createConstants("loop", "appear", "hover", "tap");
|
|
96
|
+
const effectName = createConstants(
|
|
97
|
+
"fade",
|
|
98
|
+
"slide",
|
|
99
|
+
"bounce",
|
|
100
|
+
"wiggle",
|
|
101
|
+
"increase"
|
|
102
|
+
);
|
|
103
|
+
const variableType = createConstants(
|
|
104
|
+
"Event",
|
|
105
|
+
"String",
|
|
106
|
+
"Boolean",
|
|
107
|
+
"Array",
|
|
108
|
+
"Color",
|
|
109
|
+
"ComponentInstance",
|
|
110
|
+
"Date",
|
|
111
|
+
"Enum",
|
|
112
|
+
"Number",
|
|
113
|
+
"Object"
|
|
114
|
+
);
|
|
115
|
+
const whiteSpace = createConstants(
|
|
116
|
+
"normal",
|
|
117
|
+
"nowrap",
|
|
118
|
+
"pre",
|
|
119
|
+
"pre-wrap",
|
|
120
|
+
"pre-line",
|
|
121
|
+
"break-spaces"
|
|
122
|
+
);
|
|
123
|
+
const overflow = createConstants("visible", "hidden", "scroll");
|
|
124
|
+
const variableTransforms = createConstants(
|
|
125
|
+
"convert",
|
|
126
|
+
"exists",
|
|
127
|
+
"equals",
|
|
128
|
+
"startWith",
|
|
129
|
+
"endWith",
|
|
130
|
+
"contains",
|
|
131
|
+
"dateBefore",
|
|
132
|
+
"dateAfter",
|
|
133
|
+
"dateBetween",
|
|
134
|
+
"feature",
|
|
135
|
+
"notFeature",
|
|
136
|
+
"gt",
|
|
137
|
+
// Greater than
|
|
138
|
+
"gte",
|
|
139
|
+
// Greater than or equals
|
|
140
|
+
"lt",
|
|
141
|
+
// Less than
|
|
142
|
+
"lte",
|
|
143
|
+
// Less than or equals,
|
|
144
|
+
"convertFromBoolean",
|
|
145
|
+
"negative"
|
|
146
|
+
);
|
|
147
|
+
const renderTarget = createConstants("canvas", "document");
|
|
148
|
+
const renderMode = createConstants("viewport", "parent", "fixed");
|
|
149
|
+
const interactions = createConstants("click", "mouseover");
|
|
150
|
+
const eventMode = createConstants("goal", "callback");
|
|
151
|
+
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
152
|
+
__proto__: null,
|
|
153
|
+
borderType,
|
|
154
|
+
constrain,
|
|
155
|
+
createConstants,
|
|
156
|
+
effectName,
|
|
157
|
+
effectType,
|
|
158
|
+
eventMode,
|
|
159
|
+
fragmentGrowingMode,
|
|
160
|
+
imagePaintScaleModes,
|
|
161
|
+
interactions,
|
|
162
|
+
layerAlign,
|
|
163
|
+
layerDirection,
|
|
164
|
+
layerDistribute,
|
|
165
|
+
layerMode,
|
|
166
|
+
linkTarget,
|
|
167
|
+
nodes,
|
|
168
|
+
overflow,
|
|
169
|
+
paintMode,
|
|
170
|
+
positionType,
|
|
171
|
+
renderMode,
|
|
172
|
+
renderTarget,
|
|
173
|
+
sizing,
|
|
174
|
+
textDecorations,
|
|
175
|
+
textTransform,
|
|
176
|
+
variableTransforms,
|
|
177
|
+
variableType,
|
|
178
|
+
whiteSpace
|
|
179
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
180
|
+
// @__NO_SIDE_EFFECTS__
|
|
181
|
+
function getGlobalConfig(config2) {
|
|
182
|
+
return {
|
|
183
|
+
lang: (config2 == null ? void 0 : config2.lang) ?? void 0,
|
|
184
|
+
message: config2 == null ? void 0 : config2.message,
|
|
185
|
+
abortEarly: (config2 == null ? void 0 : config2.abortEarly) ?? void 0,
|
|
186
|
+
abortPipeEarly: (config2 == null ? void 0 : config2.abortPipeEarly) ?? void 0
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// @__NO_SIDE_EFFECTS__
|
|
190
|
+
function getGlobalMessage(lang) {
|
|
191
|
+
return void 0;
|
|
192
|
+
}
|
|
193
|
+
// @__NO_SIDE_EFFECTS__
|
|
194
|
+
function getSchemaMessage(lang) {
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
// @__NO_SIDE_EFFECTS__
|
|
198
|
+
function getSpecificMessage(reference, lang) {
|
|
199
|
+
var _a;
|
|
200
|
+
return (_a = void 0) == null ? void 0 : _a.get(lang);
|
|
201
|
+
}
|
|
202
|
+
// @__NO_SIDE_EFFECTS__
|
|
203
|
+
function _stringify(input) {
|
|
204
|
+
var _a, _b;
|
|
205
|
+
const type = typeof input;
|
|
206
|
+
if (type === "string") {
|
|
207
|
+
return `"${input}"`;
|
|
208
|
+
}
|
|
209
|
+
if (type === "number" || type === "bigint" || type === "boolean") {
|
|
210
|
+
return `${input}`;
|
|
211
|
+
}
|
|
212
|
+
if (type === "object" || type === "function") {
|
|
213
|
+
return (input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) ?? "null";
|
|
214
|
+
}
|
|
215
|
+
return type;
|
|
216
|
+
}
|
|
217
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
218
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
219
|
+
const expected = (other == null ? void 0 : other.expected) ?? context.expects ?? null;
|
|
220
|
+
const received = (other == null ? void 0 : other.received) ?? /* @__PURE__ */ _stringify(input);
|
|
221
|
+
const issue = {
|
|
222
|
+
kind: context.kind,
|
|
223
|
+
type: context.type,
|
|
224
|
+
input,
|
|
225
|
+
expected,
|
|
226
|
+
received,
|
|
227
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
228
|
+
requirement: context.requirement,
|
|
229
|
+
path: other == null ? void 0 : other.path,
|
|
230
|
+
issues: other == null ? void 0 : other.issues,
|
|
231
|
+
lang: config2.lang,
|
|
232
|
+
abortEarly: config2.abortEarly,
|
|
233
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
234
|
+
};
|
|
235
|
+
const isSchema = context.kind === "schema";
|
|
236
|
+
const message = (other == null ? void 0 : other.message) ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
237
|
+
if (message !== void 0) {
|
|
238
|
+
issue.message = typeof message === "function" ? (
|
|
239
|
+
// @ts-expect-error
|
|
240
|
+
message(issue)
|
|
241
|
+
) : message;
|
|
242
|
+
}
|
|
243
|
+
if (isSchema) {
|
|
244
|
+
dataset.typed = false;
|
|
245
|
+
}
|
|
246
|
+
if (dataset.issues) {
|
|
247
|
+
dataset.issues.push(issue);
|
|
248
|
+
} else {
|
|
249
|
+
dataset.issues = [issue];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// @__NO_SIDE_EFFECTS__
|
|
253
|
+
function _getStandardProps(context) {
|
|
254
|
+
return {
|
|
255
|
+
version: 1,
|
|
256
|
+
vendor: "valibot",
|
|
257
|
+
validate(value2) {
|
|
258
|
+
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// @__NO_SIDE_EFFECTS__
|
|
263
|
+
function _isValidObjectKey(object2, key) {
|
|
264
|
+
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
265
|
+
}
|
|
266
|
+
// @__NO_SIDE_EFFECTS__
|
|
267
|
+
function _joinExpects(values2, separator) {
|
|
268
|
+
const list = [...new Set(values2)];
|
|
269
|
+
if (list.length > 1) {
|
|
270
|
+
return `(${list.join(` ${separator} `)})`;
|
|
271
|
+
}
|
|
272
|
+
return list[0] ?? "never";
|
|
273
|
+
}
|
|
274
|
+
// @__NO_SIDE_EFFECTS__
|
|
275
|
+
function isOfKind(kind, object2) {
|
|
276
|
+
return object2.kind === kind;
|
|
277
|
+
}
|
|
278
|
+
var ValiError = class extends Error {
|
|
279
|
+
/**
|
|
280
|
+
* Creates a Valibot error with useful information.
|
|
281
|
+
*
|
|
282
|
+
* @param issues The error issues.
|
|
283
|
+
*/
|
|
284
|
+
constructor(issues) {
|
|
285
|
+
super(issues[0].message);
|
|
286
|
+
this.name = "ValiError";
|
|
287
|
+
this.issues = issues;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
// @__NO_SIDE_EFFECTS__
|
|
291
|
+
function check(requirement, message) {
|
|
292
|
+
return {
|
|
293
|
+
kind: "validation",
|
|
294
|
+
type: "check",
|
|
295
|
+
reference: check,
|
|
296
|
+
async: false,
|
|
297
|
+
expects: null,
|
|
298
|
+
requirement,
|
|
299
|
+
message,
|
|
300
|
+
"~run"(dataset, config2) {
|
|
301
|
+
if (dataset.typed && !this.requirement(dataset.value)) {
|
|
302
|
+
_addIssue(this, "input", dataset, config2);
|
|
303
|
+
}
|
|
304
|
+
return dataset;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
// @__NO_SIDE_EFFECTS__
|
|
309
|
+
function maxValue(requirement, message) {
|
|
310
|
+
return {
|
|
311
|
+
kind: "validation",
|
|
312
|
+
type: "max_value",
|
|
313
|
+
reference: maxValue,
|
|
314
|
+
async: false,
|
|
315
|
+
expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
|
|
316
|
+
requirement,
|
|
317
|
+
message,
|
|
318
|
+
"~run"(dataset, config2) {
|
|
319
|
+
if (dataset.typed && !(dataset.value <= this.requirement)) {
|
|
320
|
+
_addIssue(this, "value", dataset, config2, {
|
|
321
|
+
received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return dataset;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
// @__NO_SIDE_EFFECTS__
|
|
329
|
+
function metadata(metadata_) {
|
|
330
|
+
return {
|
|
331
|
+
kind: "metadata",
|
|
332
|
+
type: "metadata",
|
|
333
|
+
reference: metadata,
|
|
334
|
+
metadata: metadata_
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
// @__NO_SIDE_EFFECTS__
|
|
338
|
+
function minValue(requirement, message) {
|
|
339
|
+
return {
|
|
340
|
+
kind: "validation",
|
|
341
|
+
type: "min_value",
|
|
342
|
+
reference: minValue,
|
|
343
|
+
async: false,
|
|
344
|
+
expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
|
|
345
|
+
requirement,
|
|
346
|
+
message,
|
|
347
|
+
"~run"(dataset, config2) {
|
|
348
|
+
if (dataset.typed && !(dataset.value >= this.requirement)) {
|
|
349
|
+
_addIssue(this, "value", dataset, config2, {
|
|
350
|
+
received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
|
|
351
|
+
});
|
|
21
352
|
}
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
353
|
+
return dataset;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
// @__NO_SIDE_EFFECTS__
|
|
358
|
+
function transform(operation) {
|
|
359
|
+
return {
|
|
360
|
+
kind: "transformation",
|
|
361
|
+
type: "transform",
|
|
362
|
+
reference: transform,
|
|
363
|
+
async: false,
|
|
364
|
+
operation,
|
|
365
|
+
"~run"(dataset) {
|
|
366
|
+
dataset.value = this.operation(dataset.value);
|
|
367
|
+
return dataset;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
// @__NO_SIDE_EFFECTS__
|
|
372
|
+
function getFallback(schema, dataset, config2) {
|
|
373
|
+
return typeof schema.fallback === "function" ? (
|
|
374
|
+
// @ts-expect-error
|
|
375
|
+
schema.fallback(dataset, config2)
|
|
376
|
+
) : (
|
|
377
|
+
// @ts-expect-error
|
|
378
|
+
schema.fallback
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
// @__NO_SIDE_EFFECTS__
|
|
382
|
+
function getDefault(schema, dataset, config2) {
|
|
383
|
+
return typeof schema.default === "function" ? (
|
|
384
|
+
// @ts-expect-error
|
|
385
|
+
schema.default(dataset, config2)
|
|
386
|
+
) : (
|
|
387
|
+
// @ts-expect-error
|
|
388
|
+
schema.default
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
// @__NO_SIDE_EFFECTS__
|
|
392
|
+
function any() {
|
|
393
|
+
return {
|
|
394
|
+
kind: "schema",
|
|
395
|
+
type: "any",
|
|
396
|
+
reference: any,
|
|
397
|
+
expects: "any",
|
|
398
|
+
async: false,
|
|
399
|
+
get "~standard"() {
|
|
400
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
401
|
+
},
|
|
402
|
+
"~run"(dataset) {
|
|
403
|
+
dataset.typed = true;
|
|
404
|
+
return dataset;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
// @__NO_SIDE_EFFECTS__
|
|
409
|
+
function array(item, message) {
|
|
410
|
+
return {
|
|
411
|
+
kind: "schema",
|
|
412
|
+
type: "array",
|
|
413
|
+
reference: array,
|
|
414
|
+
expects: "Array",
|
|
415
|
+
async: false,
|
|
416
|
+
item,
|
|
417
|
+
message,
|
|
418
|
+
get "~standard"() {
|
|
419
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
420
|
+
},
|
|
421
|
+
"~run"(dataset, config2) {
|
|
422
|
+
var _a;
|
|
423
|
+
const input = dataset.value;
|
|
424
|
+
if (Array.isArray(input)) {
|
|
425
|
+
dataset.typed = true;
|
|
426
|
+
dataset.value = [];
|
|
427
|
+
for (let key = 0; key < input.length; key++) {
|
|
428
|
+
const value2 = input[key];
|
|
429
|
+
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
430
|
+
if (itemDataset.issues) {
|
|
431
|
+
const pathItem = {
|
|
432
|
+
type: "array",
|
|
433
|
+
origin: "value",
|
|
434
|
+
input,
|
|
435
|
+
key,
|
|
436
|
+
value: value2
|
|
437
|
+
};
|
|
438
|
+
for (const issue of itemDataset.issues) {
|
|
439
|
+
if (issue.path) {
|
|
440
|
+
issue.path.unshift(pathItem);
|
|
441
|
+
} else {
|
|
442
|
+
issue.path = [pathItem];
|
|
443
|
+
}
|
|
444
|
+
(_a = dataset.issues) == null ? void 0 : _a.push(issue);
|
|
445
|
+
}
|
|
446
|
+
if (!dataset.issues) {
|
|
447
|
+
dataset.issues = itemDataset.issues;
|
|
448
|
+
}
|
|
449
|
+
if (config2.abortEarly) {
|
|
450
|
+
dataset.typed = false;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (!itemDataset.typed) {
|
|
455
|
+
dataset.typed = false;
|
|
456
|
+
}
|
|
457
|
+
dataset.value.push(itemDataset.value);
|
|
25
458
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
459
|
+
} else {
|
|
460
|
+
_addIssue(this, "type", dataset, config2);
|
|
461
|
+
}
|
|
462
|
+
return dataset;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
// @__NO_SIDE_EFFECTS__
|
|
467
|
+
function boolean(message) {
|
|
468
|
+
return {
|
|
469
|
+
kind: "schema",
|
|
470
|
+
type: "boolean",
|
|
471
|
+
reference: boolean,
|
|
472
|
+
expects: "boolean",
|
|
473
|
+
async: false,
|
|
474
|
+
message,
|
|
475
|
+
get "~standard"() {
|
|
476
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
477
|
+
},
|
|
478
|
+
"~run"(dataset, config2) {
|
|
479
|
+
if (typeof dataset.value === "boolean") {
|
|
480
|
+
dataset.typed = true;
|
|
481
|
+
} else {
|
|
482
|
+
_addIssue(this, "type", dataset, config2);
|
|
483
|
+
}
|
|
484
|
+
return dataset;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
// @__NO_SIDE_EFFECTS__
|
|
489
|
+
function enum_(enum__, message) {
|
|
490
|
+
const options2 = [];
|
|
491
|
+
for (const key in enum__) {
|
|
492
|
+
if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) {
|
|
493
|
+
options2.push(enum__[key]);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
kind: "schema",
|
|
498
|
+
type: "enum",
|
|
499
|
+
reference: enum_,
|
|
500
|
+
expects: /* @__PURE__ */ _joinExpects(options2.map(_stringify), "|"),
|
|
501
|
+
async: false,
|
|
502
|
+
enum: enum__,
|
|
503
|
+
options: options2,
|
|
504
|
+
message,
|
|
505
|
+
get "~standard"() {
|
|
506
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
507
|
+
},
|
|
508
|
+
"~run"(dataset, config2) {
|
|
509
|
+
if (this.options.includes(dataset.value)) {
|
|
510
|
+
dataset.typed = true;
|
|
511
|
+
} else {
|
|
512
|
+
_addIssue(this, "type", dataset, config2);
|
|
513
|
+
}
|
|
514
|
+
return dataset;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
// @__NO_SIDE_EFFECTS__
|
|
519
|
+
function literal(literal_, message) {
|
|
520
|
+
return {
|
|
521
|
+
kind: "schema",
|
|
522
|
+
type: "literal",
|
|
523
|
+
reference: literal,
|
|
524
|
+
expects: /* @__PURE__ */ _stringify(literal_),
|
|
525
|
+
async: false,
|
|
526
|
+
literal: literal_,
|
|
527
|
+
message,
|
|
528
|
+
get "~standard"() {
|
|
529
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
530
|
+
},
|
|
531
|
+
"~run"(dataset, config2) {
|
|
532
|
+
if (dataset.value === this.literal) {
|
|
533
|
+
dataset.typed = true;
|
|
534
|
+
} else {
|
|
535
|
+
_addIssue(this, "type", dataset, config2);
|
|
536
|
+
}
|
|
537
|
+
return dataset;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
// @__NO_SIDE_EFFECTS__
|
|
542
|
+
function nullable(wrapped, default_) {
|
|
543
|
+
return {
|
|
544
|
+
kind: "schema",
|
|
545
|
+
type: "nullable",
|
|
546
|
+
reference: nullable,
|
|
547
|
+
expects: `(${wrapped.expects} | null)`,
|
|
548
|
+
async: false,
|
|
549
|
+
wrapped,
|
|
550
|
+
default: default_,
|
|
551
|
+
get "~standard"() {
|
|
552
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
553
|
+
},
|
|
554
|
+
"~run"(dataset, config2) {
|
|
555
|
+
if (dataset.value === null) {
|
|
556
|
+
if (this.default !== void 0) {
|
|
557
|
+
dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
558
|
+
}
|
|
559
|
+
if (dataset.value === null) {
|
|
560
|
+
dataset.typed = true;
|
|
561
|
+
return dataset;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return this.wrapped["~run"](dataset, config2);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
// @__NO_SIDE_EFFECTS__
|
|
569
|
+
function number(message) {
|
|
570
|
+
return {
|
|
571
|
+
kind: "schema",
|
|
572
|
+
type: "number",
|
|
573
|
+
reference: number,
|
|
574
|
+
expects: "number",
|
|
575
|
+
async: false,
|
|
576
|
+
message,
|
|
577
|
+
get "~standard"() {
|
|
578
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
579
|
+
},
|
|
580
|
+
"~run"(dataset, config2) {
|
|
581
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
|
|
582
|
+
dataset.typed = true;
|
|
583
|
+
} else {
|
|
584
|
+
_addIssue(this, "type", dataset, config2);
|
|
585
|
+
}
|
|
586
|
+
return dataset;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
// @__NO_SIDE_EFFECTS__
|
|
591
|
+
function object(entries, message) {
|
|
592
|
+
return {
|
|
593
|
+
kind: "schema",
|
|
594
|
+
type: "object",
|
|
595
|
+
reference: object,
|
|
596
|
+
expects: "Object",
|
|
597
|
+
async: false,
|
|
598
|
+
entries,
|
|
599
|
+
message,
|
|
600
|
+
get "~standard"() {
|
|
601
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
602
|
+
},
|
|
603
|
+
"~run"(dataset, config2) {
|
|
604
|
+
var _a;
|
|
605
|
+
const input = dataset.value;
|
|
606
|
+
if (input && typeof input === "object") {
|
|
607
|
+
dataset.typed = true;
|
|
608
|
+
dataset.value = {};
|
|
609
|
+
for (const key in this.entries) {
|
|
610
|
+
const valueSchema = this.entries[key];
|
|
611
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
|
|
612
|
+
valueSchema.default !== void 0) {
|
|
613
|
+
const value2 = key in input ? (
|
|
614
|
+
// @ts-expect-error
|
|
615
|
+
input[key]
|
|
616
|
+
) : /* @__PURE__ */ getDefault(valueSchema);
|
|
617
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
618
|
+
if (valueDataset.issues) {
|
|
619
|
+
const pathItem = {
|
|
620
|
+
type: "object",
|
|
621
|
+
origin: "value",
|
|
622
|
+
input,
|
|
623
|
+
key,
|
|
624
|
+
value: value2
|
|
625
|
+
};
|
|
626
|
+
for (const issue of valueDataset.issues) {
|
|
627
|
+
if (issue.path) {
|
|
628
|
+
issue.path.unshift(pathItem);
|
|
629
|
+
} else {
|
|
630
|
+
issue.path = [pathItem];
|
|
631
|
+
}
|
|
632
|
+
(_a = dataset.issues) == null ? void 0 : _a.push(issue);
|
|
633
|
+
}
|
|
634
|
+
if (!dataset.issues) {
|
|
635
|
+
dataset.issues = valueDataset.issues;
|
|
636
|
+
}
|
|
637
|
+
if (config2.abortEarly) {
|
|
638
|
+
dataset.typed = false;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
if (!valueDataset.typed) {
|
|
643
|
+
dataset.typed = false;
|
|
644
|
+
}
|
|
645
|
+
dataset.value[key] = valueDataset.value;
|
|
646
|
+
} else if (valueSchema.fallback !== void 0) {
|
|
647
|
+
dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
648
|
+
} else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
649
|
+
_addIssue(this, "key", dataset, config2, {
|
|
650
|
+
input: void 0,
|
|
651
|
+
expected: `"${key}"`,
|
|
652
|
+
path: [
|
|
653
|
+
{
|
|
654
|
+
type: "object",
|
|
655
|
+
origin: "key",
|
|
656
|
+
input,
|
|
657
|
+
key,
|
|
658
|
+
// @ts-expect-error
|
|
659
|
+
value: input[key]
|
|
660
|
+
}
|
|
661
|
+
]
|
|
662
|
+
});
|
|
663
|
+
if (config2.abortEarly) {
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
_addIssue(this, "type", dataset, config2);
|
|
670
|
+
}
|
|
671
|
+
return dataset;
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
// @__NO_SIDE_EFFECTS__
|
|
676
|
+
function optional(wrapped, default_) {
|
|
677
|
+
return {
|
|
678
|
+
kind: "schema",
|
|
679
|
+
type: "optional",
|
|
680
|
+
reference: optional,
|
|
681
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
682
|
+
async: false,
|
|
683
|
+
wrapped,
|
|
684
|
+
default: default_,
|
|
685
|
+
get "~standard"() {
|
|
686
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
687
|
+
},
|
|
688
|
+
"~run"(dataset, config2) {
|
|
689
|
+
if (dataset.value === void 0) {
|
|
690
|
+
if (this.default !== void 0) {
|
|
691
|
+
dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
692
|
+
}
|
|
693
|
+
if (dataset.value === void 0) {
|
|
694
|
+
dataset.typed = true;
|
|
695
|
+
return dataset;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return this.wrapped["~run"](dataset, config2);
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
// @__NO_SIDE_EFFECTS__
|
|
703
|
+
function picklist(options2, message) {
|
|
704
|
+
return {
|
|
705
|
+
kind: "schema",
|
|
706
|
+
type: "picklist",
|
|
707
|
+
reference: picklist,
|
|
708
|
+
expects: /* @__PURE__ */ _joinExpects(options2.map(_stringify), "|"),
|
|
709
|
+
async: false,
|
|
710
|
+
options: options2,
|
|
711
|
+
message,
|
|
712
|
+
get "~standard"() {
|
|
713
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
714
|
+
},
|
|
715
|
+
"~run"(dataset, config2) {
|
|
716
|
+
if (this.options.includes(dataset.value)) {
|
|
717
|
+
dataset.typed = true;
|
|
718
|
+
} else {
|
|
719
|
+
_addIssue(this, "type", dataset, config2);
|
|
720
|
+
}
|
|
721
|
+
return dataset;
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
// @__NO_SIDE_EFFECTS__
|
|
726
|
+
function record(key, value2, message) {
|
|
727
|
+
return {
|
|
728
|
+
kind: "schema",
|
|
729
|
+
type: "record",
|
|
730
|
+
reference: record,
|
|
731
|
+
expects: "Object",
|
|
732
|
+
async: false,
|
|
733
|
+
key,
|
|
734
|
+
value: value2,
|
|
735
|
+
message,
|
|
736
|
+
get "~standard"() {
|
|
737
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
738
|
+
},
|
|
739
|
+
"~run"(dataset, config2) {
|
|
740
|
+
var _a, _b;
|
|
741
|
+
const input = dataset.value;
|
|
742
|
+
if (input && typeof input === "object") {
|
|
743
|
+
dataset.typed = true;
|
|
744
|
+
dataset.value = {};
|
|
745
|
+
for (const entryKey in input) {
|
|
746
|
+
if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
747
|
+
const entryValue = input[entryKey];
|
|
748
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
749
|
+
if (keyDataset.issues) {
|
|
750
|
+
const pathItem = {
|
|
751
|
+
type: "object",
|
|
752
|
+
origin: "key",
|
|
753
|
+
input,
|
|
754
|
+
key: entryKey,
|
|
755
|
+
value: entryValue
|
|
756
|
+
};
|
|
757
|
+
for (const issue of keyDataset.issues) {
|
|
758
|
+
issue.path = [pathItem];
|
|
759
|
+
(_a = dataset.issues) == null ? void 0 : _a.push(issue);
|
|
760
|
+
}
|
|
761
|
+
if (!dataset.issues) {
|
|
762
|
+
dataset.issues = keyDataset.issues;
|
|
763
|
+
}
|
|
764
|
+
if (config2.abortEarly) {
|
|
765
|
+
dataset.typed = false;
|
|
766
|
+
break;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
const valueDataset = this.value["~run"](
|
|
770
|
+
{ value: entryValue },
|
|
771
|
+
config2
|
|
772
|
+
);
|
|
773
|
+
if (valueDataset.issues) {
|
|
774
|
+
const pathItem = {
|
|
775
|
+
type: "object",
|
|
776
|
+
origin: "value",
|
|
777
|
+
input,
|
|
778
|
+
key: entryKey,
|
|
779
|
+
value: entryValue
|
|
780
|
+
};
|
|
781
|
+
for (const issue of valueDataset.issues) {
|
|
782
|
+
if (issue.path) {
|
|
783
|
+
issue.path.unshift(pathItem);
|
|
784
|
+
} else {
|
|
785
|
+
issue.path = [pathItem];
|
|
786
|
+
}
|
|
787
|
+
(_b = dataset.issues) == null ? void 0 : _b.push(issue);
|
|
788
|
+
}
|
|
789
|
+
if (!dataset.issues) {
|
|
790
|
+
dataset.issues = valueDataset.issues;
|
|
791
|
+
}
|
|
792
|
+
if (config2.abortEarly) {
|
|
793
|
+
dataset.typed = false;
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (!keyDataset.typed || !valueDataset.typed) {
|
|
798
|
+
dataset.typed = false;
|
|
799
|
+
}
|
|
800
|
+
if (keyDataset.typed) {
|
|
801
|
+
dataset.value[keyDataset.value] = valueDataset.value;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
} else {
|
|
806
|
+
_addIssue(this, "type", dataset, config2);
|
|
807
|
+
}
|
|
808
|
+
return dataset;
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
// @__NO_SIDE_EFFECTS__
|
|
813
|
+
function string(message) {
|
|
814
|
+
return {
|
|
815
|
+
kind: "schema",
|
|
816
|
+
type: "string",
|
|
817
|
+
reference: string,
|
|
818
|
+
expects: "string",
|
|
819
|
+
async: false,
|
|
820
|
+
message,
|
|
821
|
+
get "~standard"() {
|
|
822
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
823
|
+
},
|
|
824
|
+
"~run"(dataset, config2) {
|
|
825
|
+
if (typeof dataset.value === "string") {
|
|
826
|
+
dataset.typed = true;
|
|
827
|
+
} else {
|
|
828
|
+
_addIssue(this, "type", dataset, config2);
|
|
829
|
+
}
|
|
830
|
+
return dataset;
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
// @__NO_SIDE_EFFECTS__
|
|
835
|
+
function _subIssues(datasets) {
|
|
836
|
+
let issues;
|
|
837
|
+
if (datasets) {
|
|
838
|
+
for (const dataset of datasets) {
|
|
839
|
+
if (issues) {
|
|
840
|
+
issues.push(...dataset.issues);
|
|
841
|
+
} else {
|
|
842
|
+
issues = dataset.issues;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return issues;
|
|
847
|
+
}
|
|
848
|
+
// @__NO_SIDE_EFFECTS__
|
|
849
|
+
function union(options2, message) {
|
|
850
|
+
return {
|
|
851
|
+
kind: "schema",
|
|
852
|
+
type: "union",
|
|
853
|
+
reference: union,
|
|
854
|
+
expects: /* @__PURE__ */ _joinExpects(
|
|
855
|
+
options2.map((option) => option.expects),
|
|
856
|
+
"|"
|
|
857
|
+
),
|
|
858
|
+
async: false,
|
|
859
|
+
options: options2,
|
|
860
|
+
message,
|
|
861
|
+
get "~standard"() {
|
|
862
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
863
|
+
},
|
|
864
|
+
"~run"(dataset, config2) {
|
|
865
|
+
let validDataset;
|
|
866
|
+
let typedDatasets;
|
|
867
|
+
let untypedDatasets;
|
|
868
|
+
for (const schema of this.options) {
|
|
869
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
870
|
+
if (optionDataset.typed) {
|
|
871
|
+
if (optionDataset.issues) {
|
|
872
|
+
if (typedDatasets) {
|
|
873
|
+
typedDatasets.push(optionDataset);
|
|
874
|
+
} else {
|
|
875
|
+
typedDatasets = [optionDataset];
|
|
876
|
+
}
|
|
877
|
+
} else {
|
|
878
|
+
validDataset = optionDataset;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
} else {
|
|
882
|
+
if (untypedDatasets) {
|
|
883
|
+
untypedDatasets.push(optionDataset);
|
|
884
|
+
} else {
|
|
885
|
+
untypedDatasets = [optionDataset];
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (validDataset) {
|
|
890
|
+
return validDataset;
|
|
891
|
+
}
|
|
892
|
+
if (typedDatasets) {
|
|
893
|
+
if (typedDatasets.length === 1) {
|
|
894
|
+
return typedDatasets[0];
|
|
895
|
+
}
|
|
896
|
+
_addIssue(this, "type", dataset, config2, {
|
|
897
|
+
issues: /* @__PURE__ */ _subIssues(typedDatasets)
|
|
898
|
+
});
|
|
899
|
+
dataset.typed = true;
|
|
900
|
+
} else if ((untypedDatasets == null ? void 0 : untypedDatasets.length) === 1) {
|
|
901
|
+
return untypedDatasets[0];
|
|
902
|
+
} else {
|
|
903
|
+
_addIssue(this, "type", dataset, config2, {
|
|
904
|
+
issues: /* @__PURE__ */ _subIssues(untypedDatasets)
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
return dataset;
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function parse(schema, input, config2) {
|
|
912
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
913
|
+
if (dataset.issues) {
|
|
914
|
+
throw new ValiError(dataset.issues);
|
|
915
|
+
}
|
|
916
|
+
return dataset.value;
|
|
917
|
+
}
|
|
918
|
+
// @__NO_SIDE_EFFECTS__
|
|
919
|
+
function pipe(...pipe2) {
|
|
920
|
+
return {
|
|
921
|
+
...pipe2[0],
|
|
922
|
+
pipe: pipe2,
|
|
923
|
+
get "~standard"() {
|
|
924
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
925
|
+
},
|
|
926
|
+
"~run"(dataset, config2) {
|
|
927
|
+
for (const item of pipe2) {
|
|
928
|
+
if (item.kind !== "metadata") {
|
|
929
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
930
|
+
dataset.typed = false;
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
|
|
934
|
+
dataset = item["~run"](dataset, config2);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return dataset;
|
|
939
|
+
}
|
|
29
940
|
};
|
|
30
941
|
}
|
|
31
|
-
|
|
942
|
+
// @__NO_SIDE_EFFECTS__
|
|
943
|
+
function safeParse(schema, input, config2) {
|
|
944
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
945
|
+
return {
|
|
946
|
+
typed: dataset.typed,
|
|
947
|
+
success: !dataset.issues,
|
|
948
|
+
output: dataset.value,
|
|
949
|
+
issues: dataset.issues
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
const linkValidator = /* @__PURE__ */ check(
|
|
953
|
+
(value) => {
|
|
954
|
+
var _a, _b;
|
|
955
|
+
return !!value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
|
|
956
|
+
}
|
|
957
|
+
);
|
|
958
|
+
const isLink = (value) => {
|
|
959
|
+
var _a;
|
|
960
|
+
return (_a = /* @__PURE__ */ safeParse(linkValidator, value)) == null ? void 0 : _a.success;
|
|
961
|
+
};
|
|
962
|
+
const isVariableLink = (value) => {
|
|
963
|
+
var _a, _b;
|
|
964
|
+
return isLink(value) && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.at(0)) === nodes.Variable;
|
|
965
|
+
};
|
|
966
|
+
const getMetadata = (schema) => {
|
|
967
|
+
var _a;
|
|
968
|
+
const pipelines = (schema == null ? void 0 : schema.pipe) ?? [];
|
|
969
|
+
return ((_a = pipelines == null ? void 0 : pipelines.find((pipe2) => /* @__PURE__ */ isOfKind("metadata", pipe2))) == null ? void 0 : _a.metadata) ?? null;
|
|
970
|
+
};
|
|
971
|
+
const layerField = (schema, meta) => {
|
|
972
|
+
const modifiedSchema = (meta == null ? void 0 : meta.variable) ? /* @__PURE__ */ union([schema, /* @__PURE__ */ pipe(/* @__PURE__ */ string(), linkValidator)]) : schema;
|
|
973
|
+
return /* @__PURE__ */ pipe(
|
|
974
|
+
/* @__PURE__ */ optional(modifiedSchema),
|
|
975
|
+
/* @__PURE__ */ transform((meta == null ? void 0 : meta.transform) ?? ((v2) => v2)),
|
|
976
|
+
/* @__PURE__ */ metadata(meta ?? {})
|
|
977
|
+
);
|
|
978
|
+
};
|
|
979
|
+
const ChildrenSchema = /* @__PURE__ */ object({
|
|
980
|
+
children: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
|
|
981
|
+
fallback: [],
|
|
982
|
+
overridable: false
|
|
983
|
+
})
|
|
984
|
+
});
|
|
985
|
+
const GraphFieldSchema = /* @__PURE__ */ object({
|
|
986
|
+
_id: /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number()]),
|
|
987
|
+
_type: /* @__PURE__ */ picklist(Object.keys(nodes))
|
|
988
|
+
});
|
|
989
|
+
const OverridesSchema = /* @__PURE__ */ object({
|
|
990
|
+
overrides: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), { overridable: false }),
|
|
991
|
+
overrideFrom: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false })
|
|
992
|
+
});
|
|
993
|
+
const PositionSchema = /* @__PURE__ */ object({
|
|
994
|
+
position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
|
|
995
|
+
fallback: positionType.absolute
|
|
996
|
+
}),
|
|
997
|
+
top: layerField(/* @__PURE__ */ number(), { fallback: 0, transform: Math.ceil }),
|
|
998
|
+
left: layerField(/* @__PURE__ */ number(), { fallback: 0, transform: Math.ceil })
|
|
999
|
+
});
|
|
1000
|
+
const SceneSchema = /* @__PURE__ */ object({
|
|
1001
|
+
opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
|
|
1002
|
+
fallback: 1,
|
|
1003
|
+
variable: true
|
|
1004
|
+
}),
|
|
1005
|
+
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
1006
|
+
zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
|
|
1007
|
+
});
|
|
1008
|
+
const FillSchema = /* @__PURE__ */ object({
|
|
1009
|
+
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
1010
|
+
fallback: paintMode.None
|
|
1011
|
+
}),
|
|
1012
|
+
solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" }),
|
|
1013
|
+
imageFill: layerField(/* @__PURE__ */ string()),
|
|
1014
|
+
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1015
|
+
fallback: imagePaintScaleModes.Fill
|
|
1016
|
+
})
|
|
1017
|
+
});
|
|
1018
|
+
const BorderSchema = /* @__PURE__ */ object({
|
|
1019
|
+
borderType: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
|
|
1020
|
+
fallback: borderType.None
|
|
1021
|
+
}),
|
|
1022
|
+
borderWidth: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
|
|
1023
|
+
borderColor: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
|
|
1024
|
+
});
|
|
1025
|
+
const SizeSchema = /* @__PURE__ */ object({
|
|
1026
|
+
widthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1027
|
+
fallback: sizing.Fixed
|
|
1028
|
+
}),
|
|
1029
|
+
heightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1030
|
+
fallback: sizing.Fixed
|
|
1031
|
+
}),
|
|
1032
|
+
width: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
|
|
1033
|
+
fallback: 0,
|
|
1034
|
+
transform: Math.ceil
|
|
1035
|
+
}),
|
|
1036
|
+
height: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
|
|
1037
|
+
fallback: 0,
|
|
1038
|
+
transform: Math.ceil
|
|
1039
|
+
}),
|
|
1040
|
+
aspectRatio: layerField(/* @__PURE__ */ number(), { fallback: -1 }),
|
|
1041
|
+
minWidth: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1042
|
+
fallback: -1,
|
|
1043
|
+
transform: Math.ceil
|
|
1044
|
+
}),
|
|
1045
|
+
minWidthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1046
|
+
fallback: sizing.Fixed
|
|
1047
|
+
}),
|
|
1048
|
+
maxWidth: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1049
|
+
fallback: -1,
|
|
1050
|
+
transform: Math.ceil
|
|
1051
|
+
}),
|
|
1052
|
+
maxWidthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1053
|
+
fallback: sizing.Fixed
|
|
1054
|
+
}),
|
|
1055
|
+
minHeight: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1056
|
+
fallback: -1,
|
|
1057
|
+
transform: Math.ceil
|
|
1058
|
+
}),
|
|
1059
|
+
minHeightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1060
|
+
fallback: sizing.Fixed
|
|
1061
|
+
}),
|
|
1062
|
+
maxHeight: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1063
|
+
fallback: -1,
|
|
1064
|
+
transform: Math.ceil
|
|
1065
|
+
}),
|
|
1066
|
+
maxHeightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1067
|
+
fallback: sizing.Fixed
|
|
1068
|
+
})
|
|
1069
|
+
});
|
|
1070
|
+
const LayerSchema = /* @__PURE__ */ object({
|
|
1071
|
+
layerMode: layerField(/* @__PURE__ */ picklist(Object.keys(layerMode)), {
|
|
1072
|
+
fallback: layerMode.none
|
|
1073
|
+
}),
|
|
1074
|
+
layerAlign: layerField(/* @__PURE__ */ picklist(Object.keys(layerAlign)), {
|
|
1075
|
+
fallback: layerAlign.start
|
|
1076
|
+
}),
|
|
1077
|
+
layerDirection: layerField(/* @__PURE__ */ picklist(Object.keys(layerDirection)), {
|
|
1078
|
+
fallback: layerDirection.horizontal
|
|
1079
|
+
}),
|
|
1080
|
+
layerDistribute: layerField(/* @__PURE__ */ picklist(Object.keys(layerDistribute)), {
|
|
1081
|
+
fallback: layerDistribute.start
|
|
1082
|
+
}),
|
|
1083
|
+
layerWrap: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1084
|
+
layerGap: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
|
|
1085
|
+
padding: layerField(/* @__PURE__ */ string(), { fallback: "0px" })
|
|
1086
|
+
});
|
|
1087
|
+
const OverflowSchema = layerField(/* @__PURE__ */ picklist(Object.keys(overflow)), {
|
|
1088
|
+
fallback: overflow.hidden
|
|
1089
|
+
});
|
|
1090
|
+
const BorderRadiusSchema = layerField(/* @__PURE__ */ string(), { fallback: "0px" });
|
|
1091
|
+
const InteractionsSchema = /* @__PURE__ */ object({
|
|
1092
|
+
interactions: layerField(
|
|
1093
|
+
/* @__PURE__ */ array(
|
|
1094
|
+
/* @__PURE__ */ object({
|
|
1095
|
+
on: /* @__PURE__ */ enum_(Object.keys(interactions)),
|
|
1096
|
+
event: /* @__PURE__ */ nullable(linkValidator)
|
|
1097
|
+
})
|
|
1098
|
+
),
|
|
1099
|
+
{ fallback: [] }
|
|
1100
|
+
)
|
|
1101
|
+
});
|
|
1102
|
+
const CssOverrideSchema = /* @__PURE__ */ object({
|
|
1103
|
+
cssOverride: layerField(/* @__PURE__ */ string(), { fallback: "" })
|
|
1104
|
+
});
|
|
1105
|
+
const FrameSchema = /* @__PURE__ */ pipe(
|
|
1106
|
+
/* @__PURE__ */ object({
|
|
1107
|
+
name: layerField(/* @__PURE__ */ string(), { fallback: "Frame", overridable: false }),
|
|
1108
|
+
isBreakpoint: layerField(/* @__PURE__ */ boolean(), {
|
|
1109
|
+
fallback: false,
|
|
1110
|
+
overridable: false
|
|
1111
|
+
}),
|
|
1112
|
+
isPrimary: layerField(/* @__PURE__ */ boolean(), { fallback: false, overridable: false }),
|
|
1113
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1114
|
+
...ChildrenSchema.entries,
|
|
1115
|
+
...GraphFieldSchema.entries,
|
|
1116
|
+
...OverridesSchema.entries,
|
|
1117
|
+
...PositionSchema.entries,
|
|
1118
|
+
...SceneSchema.entries,
|
|
1119
|
+
...FillSchema.entries,
|
|
1120
|
+
...BorderSchema.entries,
|
|
1121
|
+
...SizeSchema.entries,
|
|
1122
|
+
...LayerSchema.entries,
|
|
1123
|
+
...InteractionsSchema.entries,
|
|
1124
|
+
...CssOverrideSchema.entries,
|
|
1125
|
+
overflow: OverflowSchema,
|
|
1126
|
+
borderRadius: BorderRadiusSchema
|
|
1127
|
+
})
|
|
1128
|
+
);
|
|
1129
|
+
const TextSchema = /* @__PURE__ */ object({
|
|
1130
|
+
name: layerField(/* @__PURE__ */ string(), { fallback: "Text", overridable: false }),
|
|
1131
|
+
content: layerField(/* @__PURE__ */ string(), {
|
|
1132
|
+
fallback: ""
|
|
1133
|
+
}),
|
|
1134
|
+
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
1135
|
+
fallback: whiteSpace.pre
|
|
1136
|
+
}),
|
|
1137
|
+
variableContent: layerField(/* @__PURE__ */ string(), { fallback: null, variable: true }),
|
|
1138
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1139
|
+
attributes: layerField(
|
|
1140
|
+
/* @__PURE__ */ object({
|
|
1141
|
+
fontSize: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
|
|
1142
|
+
color: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
|
|
1143
|
+
lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
|
|
1144
|
+
fontWeight: layerField(/* @__PURE__ */ string(), { fallback: "normal" }),
|
|
1145
|
+
letterSpacing: layerField(/* @__PURE__ */ string(), { fallback: "0px" }),
|
|
1146
|
+
textTransform: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
|
|
1147
|
+
textDecoration: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
|
|
1148
|
+
whiteSpace: layerField(/* @__PURE__ */ string(), { fallback: "pre" }),
|
|
1149
|
+
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" })
|
|
1150
|
+
}),
|
|
1151
|
+
{ fallback: {} }
|
|
1152
|
+
),
|
|
1153
|
+
...GraphFieldSchema.entries,
|
|
1154
|
+
...OverridesSchema.entries,
|
|
1155
|
+
...PositionSchema.entries,
|
|
1156
|
+
...SceneSchema.entries,
|
|
1157
|
+
...SizeSchema.entries
|
|
1158
|
+
});
|
|
1159
|
+
const FragmentSchema = /* @__PURE__ */ object({
|
|
1160
|
+
name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
|
|
1161
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1162
|
+
horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
|
|
1163
|
+
fallback: fragmentGrowingMode.auto,
|
|
1164
|
+
overridable: false
|
|
1165
|
+
}),
|
|
1166
|
+
verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
|
|
1167
|
+
fallback: fragmentGrowingMode.auto,
|
|
1168
|
+
overridable: false
|
|
1169
|
+
}),
|
|
1170
|
+
properties: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
|
|
1171
|
+
fallback: [],
|
|
1172
|
+
overridable: false
|
|
1173
|
+
}),
|
|
1174
|
+
...GraphFieldSchema.entries,
|
|
1175
|
+
...ChildrenSchema.entries
|
|
1176
|
+
});
|
|
1177
|
+
const InstanceSchema = /* @__PURE__ */ object({
|
|
1178
|
+
name: layerField(/* @__PURE__ */ string(), { fallback: "Instance", overridable: false }),
|
|
1179
|
+
fragment: layerField(/* @__PURE__ */ number()),
|
|
1180
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1181
|
+
props: layerField(
|
|
1182
|
+
/* @__PURE__ */ record(
|
|
1183
|
+
/* @__PURE__ */ string(),
|
|
1184
|
+
/* @__PURE__ */ union([
|
|
1185
|
+
/* @__PURE__ */ string(),
|
|
1186
|
+
/* @__PURE__ */ number(),
|
|
1187
|
+
/* @__PURE__ */ boolean(),
|
|
1188
|
+
// For goals
|
|
1189
|
+
/* @__PURE__ */ object({
|
|
1190
|
+
code: /* @__PURE__ */ string(),
|
|
1191
|
+
name: /* @__PURE__ */ string()
|
|
1192
|
+
})
|
|
1193
|
+
])
|
|
1194
|
+
),
|
|
1195
|
+
{
|
|
1196
|
+
fallback: {}
|
|
1197
|
+
}
|
|
1198
|
+
),
|
|
1199
|
+
...GraphFieldSchema.entries,
|
|
1200
|
+
...OverridesSchema.entries,
|
|
1201
|
+
...PositionSchema.entries,
|
|
1202
|
+
...SizeSchema.entries,
|
|
1203
|
+
...SceneSchema.entries
|
|
1204
|
+
});
|
|
1205
|
+
const NumberVariableSchema = /* @__PURE__ */ object({
|
|
1206
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1207
|
+
fallback: "Number",
|
|
1208
|
+
overridable: false
|
|
1209
|
+
}),
|
|
1210
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Number), {
|
|
1211
|
+
fallback: variableType.Number
|
|
1212
|
+
}),
|
|
1213
|
+
defaultValue: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
|
|
1214
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1215
|
+
min: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
|
|
1216
|
+
max: layerField(/* @__PURE__ */ number(), { fallback: 100 }),
|
|
1217
|
+
step: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
|
|
1218
|
+
displayStepper: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1219
|
+
...GraphFieldSchema.entries
|
|
1220
|
+
});
|
|
1221
|
+
const BooleanVariableSchema = /* @__PURE__ */ object({
|
|
1222
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1223
|
+
fallback: "Boolean",
|
|
1224
|
+
overridable: false
|
|
1225
|
+
}),
|
|
1226
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Boolean), {
|
|
1227
|
+
fallback: variableType.Boolean
|
|
1228
|
+
}),
|
|
1229
|
+
defaultValue: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1230
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1231
|
+
...GraphFieldSchema.entries
|
|
1232
|
+
});
|
|
1233
|
+
const ColorVariableSchema = /* @__PURE__ */ object({
|
|
1234
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1235
|
+
fallback: "String",
|
|
1236
|
+
overridable: false
|
|
1237
|
+
}),
|
|
1238
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Color), {
|
|
1239
|
+
fallback: variableType.Color
|
|
1240
|
+
}),
|
|
1241
|
+
// TODO Add color validator
|
|
1242
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
|
|
1243
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1244
|
+
...GraphFieldSchema.entries
|
|
1245
|
+
});
|
|
1246
|
+
const StringVariableSchema = /* @__PURE__ */ object({
|
|
1247
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1248
|
+
fallback: "String",
|
|
1249
|
+
overridable: false
|
|
1250
|
+
}),
|
|
1251
|
+
type: layerField(/* @__PURE__ */ literal(variableType.String), {
|
|
1252
|
+
fallback: variableType.String
|
|
1253
|
+
}),
|
|
1254
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1255
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1256
|
+
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1257
|
+
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1258
|
+
...GraphFieldSchema.entries
|
|
1259
|
+
});
|
|
1260
|
+
const EventVariableSchema = /* @__PURE__ */ object({
|
|
1261
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1262
|
+
fallback: "Event",
|
|
1263
|
+
overridable: false
|
|
1264
|
+
}),
|
|
1265
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Event), {
|
|
1266
|
+
fallback: variableType.Event
|
|
1267
|
+
}),
|
|
1268
|
+
mode: layerField(/* @__PURE__ */ picklist(Object.keys(eventMode)), {
|
|
1269
|
+
fallback: eventMode.callback
|
|
1270
|
+
}),
|
|
1271
|
+
defaultValue: layerField(/* @__PURE__ */ any()),
|
|
1272
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1273
|
+
...GraphFieldSchema.entries
|
|
1274
|
+
});
|
|
1275
|
+
const getLayerSchema = (layer) => {
|
|
1276
|
+
if (!(layer == null ? void 0 : layer._type)) return null;
|
|
1277
|
+
if ((layer == null ? void 0 : layer._type) === nodes.Frame) return FrameSchema;
|
|
1278
|
+
if ((layer == null ? void 0 : layer._type) === nodes.Text) return TextSchema;
|
|
1279
|
+
if ((layer == null ? void 0 : layer._type) === nodes.Fragment) return FragmentSchema;
|
|
1280
|
+
if ((layer == null ? void 0 : layer._type) === nodes.Instance) return InstanceSchema;
|
|
1281
|
+
if (layer._type === nodes.Variable) {
|
|
1282
|
+
const types = {
|
|
1283
|
+
[variableType.Number]: NumberVariableSchema,
|
|
1284
|
+
[variableType.Boolean]: BooleanVariableSchema,
|
|
1285
|
+
[variableType.String]: StringVariableSchema,
|
|
1286
|
+
[variableType.Color]: ColorVariableSchema,
|
|
1287
|
+
[variableType.Event]: EventVariableSchema
|
|
1288
|
+
};
|
|
1289
|
+
if (layer.type in types) {
|
|
1290
|
+
return types[layer.type];
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
const normalizeLayer = (schema, rawLayer, options2) => {
|
|
1295
|
+
try {
|
|
1296
|
+
if (!rawLayer) return null;
|
|
1297
|
+
const withFallback = (options2 == null ? void 0 : options2.withFallback) ?? true;
|
|
1298
|
+
const overrideTarget = options2 == null ? void 0 : options2.overrideTarget;
|
|
1299
|
+
const parsedLayer = parse(schema, rawLayer);
|
|
1300
|
+
return Object.fromEntries(
|
|
1301
|
+
Object.entries(schema.entries).map(([key, schemaEntity]) => {
|
|
1302
|
+
const schemaMeta = getMetadata(schemaEntity);
|
|
1303
|
+
const fallback = withFallback ? schemaMeta == null ? void 0 : schemaMeta.fallback : null;
|
|
1304
|
+
const overrideValue = (schemaMeta == null ? void 0 : schemaMeta.overridable) !== false && overrideTarget ? overrideTarget == null ? void 0 : overrideTarget[key] : null;
|
|
1305
|
+
const resultValue = parsedLayer[key] ?? overrideValue ?? fallback;
|
|
1306
|
+
return [key, resultValue];
|
|
1307
|
+
})
|
|
1308
|
+
);
|
|
1309
|
+
} catch (e) {
|
|
1310
|
+
console.error(e);
|
|
1311
|
+
return null;
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
const getNormalizeLayer$1 = (layer, overrider) => {
|
|
1315
|
+
if (!layer) return null;
|
|
1316
|
+
const schema = getLayerSchema(layer);
|
|
1317
|
+
if (!schema) return null;
|
|
1318
|
+
return normalizeLayer(schema, layer, {
|
|
1319
|
+
overrideTarget: overrider
|
|
1320
|
+
});
|
|
1321
|
+
};
|
|
1322
|
+
const parseLayerField = (layer, field, value) => {
|
|
1323
|
+
var _a, _b;
|
|
1324
|
+
const schema = getLayerSchema(layer);
|
|
1325
|
+
if (schema && ((_a = schema == null ? void 0 : schema.entries) == null ? void 0 : _a[field])) {
|
|
1326
|
+
return /* @__PURE__ */ safeParse((_b = schema.entries) == null ? void 0 : _b[field], value);
|
|
1327
|
+
}
|
|
1328
|
+
return { success: false, output: value };
|
|
1329
|
+
};
|
|
1330
|
+
const RenderTargetContext = require$$0.createContext(
|
|
1331
|
+
index.renderTarget.document
|
|
1332
|
+
);
|
|
1333
|
+
RenderTargetContext.Provider;
|
|
1334
|
+
const useRenderTarget = () => {
|
|
1335
|
+
const renderTarget2 = require$$0.useContext(RenderTargetContext);
|
|
1336
|
+
return {
|
|
1337
|
+
renderTarget: renderTarget2,
|
|
1338
|
+
isCanvas: renderTarget2 === index.renderTarget.canvas,
|
|
1339
|
+
isDocument: renderTarget2 === index.renderTarget.document
|
|
1340
|
+
};
|
|
1341
|
+
};
|
|
1342
|
+
const FragmentContext = require$$0.createContext({
|
|
1343
|
+
manager: null
|
|
1344
|
+
});
|
|
1345
|
+
var withSelector = { exports: {} };
|
|
1346
|
+
var withSelector_production_min = {};
|
|
32
1347
|
var shim = { exports: {} };
|
|
33
1348
|
var useSyncExternalStoreShim_production_min = {};
|
|
34
1349
|
/**
|
|
@@ -45,17 +1360,17 @@ function requireUseSyncExternalStoreShim_production_min() {
|
|
|
45
1360
|
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
46
1361
|
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
47
1362
|
var e = require$$0;
|
|
48
|
-
function h(a,
|
|
49
|
-
return a ===
|
|
1363
|
+
function h(a, b2) {
|
|
1364
|
+
return a === b2 && (0 !== a || 1 / a === 1 / b2) || a !== a && b2 !== b2;
|
|
50
1365
|
}
|
|
51
1366
|
var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
|
|
52
|
-
function q(a,
|
|
53
|
-
var d =
|
|
1367
|
+
function q(a, b2) {
|
|
1368
|
+
var d = b2(), f2 = l({ inst: { value: d, getSnapshot: b2 } }), c = f2[0].inst, g = f2[1];
|
|
54
1369
|
n(function() {
|
|
55
1370
|
c.value = d;
|
|
56
|
-
c.getSnapshot =
|
|
1371
|
+
c.getSnapshot = b2;
|
|
57
1372
|
r(c) && g({ inst: c });
|
|
58
|
-
}, [a, d,
|
|
1373
|
+
}, [a, d, b2]);
|
|
59
1374
|
m(function() {
|
|
60
1375
|
r(c) && g({ inst: c });
|
|
61
1376
|
return a(function() {
|
|
@@ -66,20 +1381,20 @@ function requireUseSyncExternalStoreShim_production_min() {
|
|
|
66
1381
|
return d;
|
|
67
1382
|
}
|
|
68
1383
|
function r(a) {
|
|
69
|
-
var
|
|
1384
|
+
var b2 = a.getSnapshot;
|
|
70
1385
|
a = a.value;
|
|
71
1386
|
try {
|
|
72
|
-
var d =
|
|
1387
|
+
var d = b2();
|
|
73
1388
|
return !k(a, d);
|
|
74
|
-
} catch (
|
|
1389
|
+
} catch (f2) {
|
|
75
1390
|
return true;
|
|
76
1391
|
}
|
|
77
1392
|
}
|
|
78
|
-
function t(a,
|
|
79
|
-
return
|
|
1393
|
+
function t(a, b2) {
|
|
1394
|
+
return b2();
|
|
80
1395
|
}
|
|
81
|
-
var
|
|
82
|
-
useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore :
|
|
1396
|
+
var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
|
|
1397
|
+
useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u2;
|
|
83
1398
|
return useSyncExternalStoreShim_production_min;
|
|
84
1399
|
}
|
|
85
1400
|
var useSyncExternalStoreShim_development = {};
|
|
@@ -132,7 +1447,7 @@ function requireUseSyncExternalStoreShim_development() {
|
|
|
132
1447
|
return x === y2 && (x !== 0 || 1 / x === 1 / y2) || x !== x && y2 !== y2;
|
|
133
1448
|
}
|
|
134
1449
|
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
135
|
-
var
|
|
1450
|
+
var useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
|
|
136
1451
|
var didWarnOld18Alpha = false;
|
|
137
1452
|
var didWarnUncachedGetSnapshot = false;
|
|
138
1453
|
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
@@ -154,7 +1469,7 @@ function requireUseSyncExternalStoreShim_development() {
|
|
|
154
1469
|
}
|
|
155
1470
|
}
|
|
156
1471
|
}
|
|
157
|
-
var _useState =
|
|
1472
|
+
var _useState = useState2({
|
|
158
1473
|
inst: {
|
|
159
1474
|
value,
|
|
160
1475
|
getSnapshot
|
|
@@ -169,7 +1484,7 @@ function requireUseSyncExternalStoreShim_development() {
|
|
|
169
1484
|
});
|
|
170
1485
|
}
|
|
171
1486
|
}, [subscribe, value, getSnapshot]);
|
|
172
|
-
|
|
1487
|
+
useEffect2(function() {
|
|
173
1488
|
if (checkIfSnapshotChanged(inst)) {
|
|
174
1489
|
forceUpdate({
|
|
175
1490
|
inst
|
|
@@ -223,9 +1538,6 @@ function requireShim() {
|
|
|
223
1538
|
}
|
|
224
1539
|
return shim.exports;
|
|
225
1540
|
}
|
|
226
|
-
var shimExports = requireShim();
|
|
227
|
-
var withSelector = { exports: {} };
|
|
228
|
-
var withSelector_production_min = {};
|
|
229
1541
|
/**
|
|
230
1542
|
* @license React
|
|
231
1543
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
@@ -240,46 +1552,46 @@ function requireWithSelector_production_min() {
|
|
|
240
1552
|
if (hasRequiredWithSelector_production_min) return withSelector_production_min;
|
|
241
1553
|
hasRequiredWithSelector_production_min = 1;
|
|
242
1554
|
var h = require$$0, n = requireShim();
|
|
243
|
-
function p(a,
|
|
244
|
-
return a ===
|
|
1555
|
+
function p(a, b2) {
|
|
1556
|
+
return a === b2 && (0 !== a || 1 / a === 1 / b2) || a !== a && b2 !== b2;
|
|
245
1557
|
}
|
|
246
|
-
var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef,
|
|
247
|
-
withSelector_production_min.useSyncExternalStoreWithSelector = function(a,
|
|
1558
|
+
var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u2 = h.useEffect, v = h.useMemo, w = h.useDebugValue;
|
|
1559
|
+
withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b2, e, l, g) {
|
|
248
1560
|
var c = t(null);
|
|
249
1561
|
if (null === c.current) {
|
|
250
|
-
var
|
|
251
|
-
c.current =
|
|
252
|
-
} else
|
|
1562
|
+
var f2 = { hasValue: false, value: null };
|
|
1563
|
+
c.current = f2;
|
|
1564
|
+
} else f2 = c.current;
|
|
253
1565
|
c = v(function() {
|
|
254
1566
|
function a2(a3) {
|
|
255
1567
|
if (!c2) {
|
|
256
1568
|
c2 = true;
|
|
257
1569
|
d2 = a3;
|
|
258
1570
|
a3 = l(a3);
|
|
259
|
-
if (void 0 !== g &&
|
|
260
|
-
var
|
|
261
|
-
if (g(
|
|
1571
|
+
if (void 0 !== g && f2.hasValue) {
|
|
1572
|
+
var b3 = f2.value;
|
|
1573
|
+
if (g(b3, a3)) return k = b3;
|
|
262
1574
|
}
|
|
263
1575
|
return k = a3;
|
|
264
1576
|
}
|
|
265
|
-
|
|
266
|
-
if (q(d2, a3)) return
|
|
1577
|
+
b3 = k;
|
|
1578
|
+
if (q(d2, a3)) return b3;
|
|
267
1579
|
var e2 = l(a3);
|
|
268
|
-
if (void 0 !== g && g(
|
|
1580
|
+
if (void 0 !== g && g(b3, e2)) return b3;
|
|
269
1581
|
d2 = a3;
|
|
270
1582
|
return k = e2;
|
|
271
1583
|
}
|
|
272
1584
|
var c2 = false, d2, k, m = void 0 === e ? null : e;
|
|
273
1585
|
return [function() {
|
|
274
|
-
return a2(
|
|
1586
|
+
return a2(b2());
|
|
275
1587
|
}, null === m ? void 0 : function() {
|
|
276
1588
|
return a2(m());
|
|
277
1589
|
}];
|
|
278
|
-
}, [
|
|
1590
|
+
}, [b2, e, l, g]);
|
|
279
1591
|
var d = r(a, c[0], c[1]);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
1592
|
+
u2(function() {
|
|
1593
|
+
f2.hasValue = true;
|
|
1594
|
+
f2.value = d;
|
|
283
1595
|
}, [d]);
|
|
284
1596
|
w(d);
|
|
285
1597
|
return d;
|
|
@@ -312,9 +1624,9 @@ function requireWithSelector_development() {
|
|
|
312
1624
|
}
|
|
313
1625
|
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
314
1626
|
var useSyncExternalStore = shim2.useSyncExternalStore;
|
|
315
|
-
var
|
|
1627
|
+
var useRef2 = React.useRef, useEffect2 = React.useEffect, useMemo2 = React.useMemo, useDebugValue = React.useDebugValue;
|
|
316
1628
|
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
317
|
-
var instRef =
|
|
1629
|
+
var instRef = useRef2(null);
|
|
318
1630
|
var inst;
|
|
319
1631
|
if (instRef.current === null) {
|
|
320
1632
|
inst = {
|
|
@@ -325,7 +1637,7 @@ function requireWithSelector_development() {
|
|
|
325
1637
|
} else {
|
|
326
1638
|
inst = instRef.current;
|
|
327
1639
|
}
|
|
328
|
-
var _useMemo =
|
|
1640
|
+
var _useMemo = useMemo2(function() {
|
|
329
1641
|
var hasMemo = false;
|
|
330
1642
|
var memoizedSnapshot;
|
|
331
1643
|
var memoizedSelection;
|
|
@@ -369,7 +1681,7 @@ function requireWithSelector_development() {
|
|
|
369
1681
|
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
370
1682
|
}, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
|
|
371
1683
|
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
372
|
-
|
|
1684
|
+
useEffect2(function() {
|
|
373
1685
|
inst.hasValue = true;
|
|
374
1686
|
inst.value = value;
|
|
375
1687
|
}, [value]);
|
|
@@ -395,70 +1707,973 @@ function requireWithSelector() {
|
|
|
395
1707
|
}
|
|
396
1708
|
return withSelector.exports;
|
|
397
1709
|
}
|
|
398
|
-
requireWithSelector();
|
|
399
|
-
var y = (t, e, n) => {
|
|
1710
|
+
var withSelectorExports = requireWithSelector();
|
|
1711
|
+
var b = (t) => t, y = (t, e, n) => {
|
|
400
1712
|
var _a, _b;
|
|
401
|
-
let r = require$$0.useRef((_a = t == null ? void 0 : t.resolve) == null ? void 0 : _a.call(t, e, n)),
|
|
1713
|
+
let r = require$$0.useRef((_a = t == null ? void 0 : t.resolve) == null ? void 0 : _a.call(t, e, n)), o = ((_b = t == null ? void 0 : t.keyOfEntity) == null ? void 0 : _b.call(t, e)) ?? e, p = require$$0.useCallback((s) => {
|
|
402
1714
|
var _a2, _b2;
|
|
403
|
-
return
|
|
1715
|
+
return o ? (r.current = (_a2 = t == null ? void 0 : t.resolve) == null ? void 0 : _a2.call(t, o, n), s(), (_b2 = t == null ? void 0 : t.subscribe) == null ? void 0 : _b2.call(t, o, () => {
|
|
404
1716
|
var _a3;
|
|
405
|
-
return r.current = (_a3 = t == null ? void 0 : t.resolve) == null ? void 0 : _a3.call(t,
|
|
1717
|
+
return r.current = (_a3 = t == null ? void 0 : t.resolve) == null ? void 0 : _a3.call(t, o, n), s();
|
|
406
1718
|
}, n)) : () => {
|
|
407
1719
|
};
|
|
408
|
-
}, [t,
|
|
409
|
-
let
|
|
410
|
-
e &&
|
|
1720
|
+
}, [t, o]), i = require$$0.useCallback((s, u2) => {
|
|
1721
|
+
let c = typeof e == "string" ? e : t.keyOfEntity(e);
|
|
1722
|
+
e && c && t.mutate(c, s, u2);
|
|
411
1723
|
}, [t, e]), a = () => r.current;
|
|
412
|
-
return [
|
|
1724
|
+
return [withSelectorExports.useSyncExternalStoreWithSelector(p, a, a, b), i];
|
|
413
1725
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1726
|
+
var __defProp = Object.defineProperty;
|
|
1727
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1728
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1729
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1730
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1731
|
+
var __spreadValues = (a, b2) => {
|
|
1732
|
+
for (var prop in b2 || (b2 = {}))
|
|
1733
|
+
if (__hasOwnProp.call(b2, prop))
|
|
1734
|
+
__defNormalProp(a, prop, b2[prop]);
|
|
1735
|
+
if (__getOwnPropSymbols)
|
|
1736
|
+
for (var prop of __getOwnPropSymbols(b2)) {
|
|
1737
|
+
if (__propIsEnum.call(b2, prop))
|
|
1738
|
+
__defNormalProp(a, prop, b2[prop]);
|
|
1739
|
+
}
|
|
1740
|
+
return a;
|
|
1741
|
+
};
|
|
1742
|
+
var toPx = (val) => typeof val === "string" || typeof val === "number" ? `${val}px` : "0px";
|
|
1743
|
+
var isEmptyValue = (value) => !value && (value === null || value === void 0);
|
|
1744
|
+
var isValue = (value) => !isEmptyValue(value);
|
|
1745
|
+
var toKebabCase = (value) => value.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
|
|
1746
|
+
var noop = () => void 0;
|
|
1747
|
+
var pick = (obj, ...props) => {
|
|
1748
|
+
return props.reduce((result, prop) => {
|
|
1749
|
+
result[prop] = obj[prop];
|
|
1750
|
+
return result;
|
|
1751
|
+
}, {});
|
|
1752
|
+
};
|
|
1753
|
+
function omit(obj, ...props) {
|
|
1754
|
+
const result = __spreadValues({}, obj);
|
|
1755
|
+
props.forEach((prop) => {
|
|
1756
|
+
delete result[prop];
|
|
1757
|
+
});
|
|
1758
|
+
return result;
|
|
1759
|
+
}
|
|
1760
|
+
var isBrowser_default = typeof window !== "undefined";
|
|
1761
|
+
function hashGenerator(layerKey) {
|
|
1762
|
+
let hash = 0;
|
|
1763
|
+
for (let i = 0; i < layerKey.length; i++) {
|
|
1764
|
+
hash = (hash << 5) - hash + layerKey.charCodeAt(i);
|
|
1765
|
+
hash |= 0;
|
|
1766
|
+
}
|
|
1767
|
+
const raw = Math.abs(hash).toString(36);
|
|
1768
|
+
return /^[0-9]/.test(raw) ? `h${raw}` : raw;
|
|
1769
|
+
}
|
|
1770
|
+
const getKey = (v) => isKey(v) ? v.slice(1) : null;
|
|
1771
|
+
const isKey = (v) => typeof v === "string" && v.startsWith("$");
|
|
1772
|
+
const getParent = (manager, layerKey) => {
|
|
1773
|
+
const layer = manager.resolve(layerKey);
|
|
1774
|
+
return manager.resolve(getKey(layer == null ? void 0 : layer.parent) ?? null);
|
|
1775
|
+
};
|
|
1776
|
+
const isTopLevel = (manager, layerKey) => {
|
|
1777
|
+
var _a;
|
|
1778
|
+
return ((_a = getParent(manager, layerKey)) == null ? void 0 : _a._type) === index.nodes.Fragment;
|
|
1779
|
+
};
|
|
1780
|
+
const getAllParents = (manager, layerKey, stack = []) => {
|
|
1781
|
+
const parent = getParent(manager, layerKey);
|
|
1782
|
+
if (parent) {
|
|
1783
|
+
stack.push(parent);
|
|
1784
|
+
getAllParents(manager, manager.keyOfEntity(parent), stack);
|
|
1785
|
+
}
|
|
1786
|
+
return stack;
|
|
1787
|
+
};
|
|
1788
|
+
const isPartOfPrimary = (manager, layerKey) => {
|
|
1789
|
+
var _a;
|
|
1790
|
+
const allParents = getAllParents(manager, manager.keyOfEntity(layerKey));
|
|
1791
|
+
const layer = manager.resolve(layerKey);
|
|
1792
|
+
return (layer == null ? void 0 : layer.isPrimary) ?? !!((_a = allParents == null ? void 0 : allParents.find) == null ? void 0 : _a.call(allParents, (parent) => !!(parent == null ? void 0 : parent.isPrimary)));
|
|
1793
|
+
};
|
|
1794
|
+
const getOverrider = (manager, layerEntity) => {
|
|
1795
|
+
const layer = manager.resolve(layerEntity);
|
|
1796
|
+
return manager.resolve(getKey(layer == null ? void 0 : layer.overrideFrom) ?? layerEntity);
|
|
1797
|
+
};
|
|
1798
|
+
const isInheritField = (manager, layerEntity, field) => {
|
|
1799
|
+
const layer = manager.resolve(layerEntity);
|
|
1800
|
+
if (layer) {
|
|
1801
|
+
const overrider = getOverrider(manager, layer);
|
|
1802
|
+
if ((overrider == null ? void 0 : overrider._id) === (layer == null ? void 0 : layer._id)) return false;
|
|
1803
|
+
return !!overrider && !isValue(layer == null ? void 0 : layer[field]);
|
|
1804
|
+
}
|
|
1805
|
+
return false;
|
|
1806
|
+
};
|
|
1807
|
+
const getLayer = (manager, layer) => {
|
|
1808
|
+
if (!manager || !layer) return null;
|
|
1809
|
+
const layerKey = manager.keyOfEntity(layer);
|
|
1810
|
+
const layerData = manager.resolve(layerKey);
|
|
1811
|
+
const overrider = getOverrider(manager, layerKey);
|
|
1812
|
+
return getNormalizeLayer$1(layerData, overrider);
|
|
1813
|
+
};
|
|
1814
|
+
const getNormalizeLayer = (layerKey, manager) => {
|
|
1815
|
+
const layer = manager == null ? void 0 : manager.resolve(layerKey);
|
|
1816
|
+
const parsedLayer = getLayer(manager, layerKey);
|
|
1817
|
+
return {
|
|
1818
|
+
rawLayer: layer,
|
|
1819
|
+
layer: parsedLayer
|
|
421
1820
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
1821
|
+
};
|
|
1822
|
+
const useNormalizeLayer = (layerKey, manager) => {
|
|
1823
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
1824
|
+
const resultManager = manager ?? fragmentManager;
|
|
1825
|
+
return getNormalizeLayer(layerKey, resultManager);
|
|
1826
|
+
};
|
|
1827
|
+
const useReadVariable = (variableKey) => {
|
|
1828
|
+
const isVariable = isVariableLink(variableKey);
|
|
1829
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
1830
|
+
const { props, innerManager, layerKey } = require$$0.useContext(InstanceContext);
|
|
1831
|
+
const resultManager = innerManager ?? fragmentManager;
|
|
1832
|
+
const { _id: propertyId } = (resultManager == null ? void 0 : resultManager.entityOfKey(variableKey)) ?? {};
|
|
1833
|
+
const [variableLayer] = y(
|
|
1834
|
+
isVariable ? fragmentManager : null,
|
|
1835
|
+
variableKey,
|
|
1836
|
+
{
|
|
1837
|
+
selector: (graph) => graph ? pick(graph, "defaultValue", "required") : graph
|
|
1838
|
+
}
|
|
1839
|
+
);
|
|
1840
|
+
(props == null ? void 0 : props[propertyId]) ?? null;
|
|
1841
|
+
(variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
1842
|
+
(variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
1843
|
+
const readVariable = (variableKey2) => {
|
|
1844
|
+
const isVariable2 = isVariableLink(variableKey2);
|
|
1845
|
+
if (!isVariable2) {
|
|
1846
|
+
return {
|
|
1847
|
+
value: null,
|
|
1848
|
+
layer: null
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
const variableLayer2 = pick(
|
|
1852
|
+
(resultManager == null ? void 0 : resultManager.resolve(variableKey2)) ?? {},
|
|
1853
|
+
"defaultValue",
|
|
1854
|
+
"required"
|
|
1855
|
+
);
|
|
1856
|
+
const { _id: propertyId2 } = (resultManager == null ? void 0 : resultManager.entityOfKey(variableKey2)) ?? {};
|
|
1857
|
+
const currentValue2 = (props == null ? void 0 : props[propertyId2]) ?? null;
|
|
1858
|
+
const required2 = (variableLayer2 == null ? void 0 : variableLayer2.required) ?? false;
|
|
1859
|
+
const defaultValue2 = (variableLayer2 == null ? void 0 : variableLayer2.defaultValue) ?? null;
|
|
1860
|
+
const resultValue2 = required2 ? currentValue2 : currentValue2 ?? defaultValue2;
|
|
1861
|
+
return {
|
|
1862
|
+
value: resultValue2,
|
|
1863
|
+
layer: variableLayer2
|
|
1864
|
+
};
|
|
428
1865
|
};
|
|
1866
|
+
const { layer, value } = readVariable(variableKey);
|
|
1867
|
+
return {
|
|
1868
|
+
value,
|
|
1869
|
+
layer,
|
|
1870
|
+
readVariable
|
|
1871
|
+
};
|
|
1872
|
+
};
|
|
1873
|
+
const useLayerCssVariable = (inputValue) => {
|
|
1874
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
1875
|
+
const isVariable = isVariableLink(inputValue);
|
|
1876
|
+
const [variableValue] = y(isVariable ? manager : null, inputValue, {
|
|
1877
|
+
selector: (graph) => pick(graph, "defaultValue", "_id")
|
|
1878
|
+
});
|
|
1879
|
+
return {
|
|
1880
|
+
value: isVariable ? `var(--${variableValue == null ? void 0 : variableValue._id}, ${variableValue == null ? void 0 : variableValue.defaultValue})` : null
|
|
1881
|
+
};
|
|
1882
|
+
};
|
|
1883
|
+
const useLayerValue = (layerKey, fieldKey, manager) => {
|
|
1884
|
+
const resultManager = manager;
|
|
1885
|
+
const key = layerKey;
|
|
1886
|
+
const [, updateLayerData] = y(resultManager, key, {
|
|
1887
|
+
selector: (data) => data ? pick(data, fieldKey) : data
|
|
1888
|
+
});
|
|
1889
|
+
const { layer, rawLayer } = useNormalizeLayer(key, resultManager);
|
|
1890
|
+
const rawValue = rawLayer == null ? void 0 : rawLayer[fieldKey];
|
|
1891
|
+
const layerValue = layer == null ? void 0 : layer[fieldKey];
|
|
1892
|
+
const { value: variableValue } = useReadVariable(layerValue);
|
|
1893
|
+
const currentValue = variableValue ?? layerValue;
|
|
1894
|
+
const isInherit = isInheritField(resultManager, key, fieldKey);
|
|
1895
|
+
const isOverride = !isInherit && !isPartOfPrimary(resultManager, key);
|
|
1896
|
+
const resetOverride = require$$0.useCallback(() => {
|
|
1897
|
+
resultManager.mutate(
|
|
1898
|
+
layerKey,
|
|
1899
|
+
(prev) => {
|
|
1900
|
+
const r = omit(prev, fieldKey);
|
|
1901
|
+
return r;
|
|
1902
|
+
},
|
|
1903
|
+
{ replace: true }
|
|
1904
|
+
);
|
|
1905
|
+
}, [updateLayerData]);
|
|
1906
|
+
const restore = require$$0.useCallback(
|
|
1907
|
+
(fallbackValue) => {
|
|
1908
|
+
var _a, _b, _c;
|
|
1909
|
+
const tempValue = (_c = (_b = resultManager.resolve((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp)) == null ? void 0 : _b[layerKey]) == null ? void 0 : _c[fieldKey];
|
|
1910
|
+
updateLayerData({ [fieldKey]: tempValue ?? fallbackValue });
|
|
1911
|
+
},
|
|
1912
|
+
[updateLayerData, resultManager]
|
|
1913
|
+
);
|
|
1914
|
+
const updateValue = require$$0.useCallback(
|
|
1915
|
+
(value, options2) => {
|
|
1916
|
+
var _a, _b;
|
|
1917
|
+
const { success, output } = parseLayerField(layer, fieldKey, value);
|
|
1918
|
+
if (success) {
|
|
1919
|
+
if (isVariableLink(value)) {
|
|
1920
|
+
resultManager.mutate((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp, {
|
|
1921
|
+
[layerKey]: {
|
|
1922
|
+
[fieldKey]: currentValue
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
resultManager.resolve((_b = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _b.temp);
|
|
1926
|
+
}
|
|
1927
|
+
updateLayerData({ [fieldKey]: output }, options2);
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
[layer, fieldKey, updateLayerData, resultManager, layerKey, currentValue]
|
|
1931
|
+
);
|
|
1932
|
+
const { value: cssValue } = useLayerCssVariable(rawValue);
|
|
1933
|
+
return [
|
|
1934
|
+
currentValue,
|
|
1935
|
+
updateValue,
|
|
1936
|
+
{
|
|
1937
|
+
isOverride,
|
|
1938
|
+
resetOverride,
|
|
1939
|
+
isVariable: isVariableLink(rawValue ?? layerValue),
|
|
1940
|
+
cssVariableValue: cssValue ?? currentValue,
|
|
1941
|
+
rawValue,
|
|
1942
|
+
restore,
|
|
1943
|
+
...resultManager.entityOfKey(key)
|
|
1944
|
+
}
|
|
1945
|
+
];
|
|
1946
|
+
};
|
|
1947
|
+
const autoSizes = [index.sizing.Hug];
|
|
1948
|
+
const useLayerSizeValue = (layerKey, sizeType) => {
|
|
1949
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
1950
|
+
const { layerKey: instanceLayerKey } = require$$0.useContext(InstanceContext);
|
|
1951
|
+
const { isDocument } = useRenderTarget();
|
|
1952
|
+
const isTop = isTopLevel(fragmentManager, layerKey);
|
|
1953
|
+
const isPartOfInstance = !!instanceLayerKey;
|
|
1954
|
+
const layerParent = getParent(fragmentManager, layerKey);
|
|
1955
|
+
const layerNode = fragmentManager.resolve(layerKey);
|
|
1956
|
+
const [instanceType] = useLayerValue(
|
|
1957
|
+
instanceLayerKey,
|
|
1958
|
+
`${sizeType}Type`,
|
|
1959
|
+
fragmentManager
|
|
1960
|
+
);
|
|
1961
|
+
const [valueType] = useLayerValue(
|
|
1962
|
+
layerKey,
|
|
1963
|
+
`${sizeType}Type`,
|
|
1964
|
+
fragmentManager
|
|
1965
|
+
);
|
|
1966
|
+
const growType = sizeType === "width" ? "horizontalGrow" : "verticalGrow";
|
|
1967
|
+
return require$$0.useCallback(
|
|
1968
|
+
(value) => {
|
|
1969
|
+
if (isTop && isDocument && (layerParent == null ? void 0 : layerParent[growType]) === index.fragmentGrowingMode.fill) {
|
|
1970
|
+
return "100%";
|
|
1971
|
+
}
|
|
1972
|
+
if (isTop && isPartOfInstance && !autoSizes.includes(instanceType)) {
|
|
1973
|
+
return "100%";
|
|
1974
|
+
}
|
|
1975
|
+
if (autoSizes.includes(valueType)) {
|
|
1976
|
+
return layerNode._type === index.nodes.Instance ? "auto" : "min-content";
|
|
1977
|
+
}
|
|
1978
|
+
if (valueType === index.sizing.Relative) {
|
|
1979
|
+
return `${value}%`;
|
|
1980
|
+
}
|
|
1981
|
+
if (valueType === index.sizing.Fill) {
|
|
1982
|
+
return `100%`;
|
|
1983
|
+
}
|
|
1984
|
+
return toPx(value);
|
|
1985
|
+
},
|
|
1986
|
+
[
|
|
1987
|
+
isTop,
|
|
1988
|
+
isDocument,
|
|
1989
|
+
layerParent,
|
|
1990
|
+
growType,
|
|
1991
|
+
isPartOfInstance,
|
|
1992
|
+
instanceType,
|
|
1993
|
+
valueType,
|
|
1994
|
+
layerNode
|
|
1995
|
+
]
|
|
1996
|
+
);
|
|
1997
|
+
};
|
|
1998
|
+
const processOptionalSize = (value, type) => {
|
|
1999
|
+
if (value === -1) return "";
|
|
2000
|
+
if (type === index.sizing.Fixed) return toPx(value);
|
|
2001
|
+
if (type === index.sizing.Relative) return `${value}%`;
|
|
2002
|
+
return "";
|
|
2003
|
+
};
|
|
2004
|
+
const useOptionalSize = (type, layerKey) => {
|
|
2005
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2006
|
+
const [value] = useLayerValue(layerKey, type, fragmentManager);
|
|
2007
|
+
const [valueType] = useLayerValue(layerKey, `${type}Type`, fragmentManager);
|
|
2008
|
+
return require$$0.useMemo(
|
|
2009
|
+
() => processOptionalSize(value, valueType),
|
|
2010
|
+
[valueType, value]
|
|
2011
|
+
);
|
|
2012
|
+
};
|
|
2013
|
+
const useLayerSize = (layerKey) => {
|
|
2014
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
2015
|
+
const [widthValue] = useLayerValue(layerKey, "width", manager);
|
|
2016
|
+
const [heightValue] = useLayerValue(layerKey, "height", manager);
|
|
2017
|
+
const widthCalc = useLayerSizeValue(layerKey, "width");
|
|
2018
|
+
const heightCalc = useLayerSizeValue(layerKey, "height");
|
|
2019
|
+
const minWidth = useOptionalSize("minWidth", layerKey);
|
|
2020
|
+
const minHeight = useOptionalSize("minHeight", layerKey);
|
|
2021
|
+
const maxWidth = useOptionalSize("maxWidth", layerKey);
|
|
2022
|
+
const maxHeight = useOptionalSize("maxHeight", layerKey);
|
|
2023
|
+
return {
|
|
2024
|
+
width: widthCalc(widthValue),
|
|
2025
|
+
height: heightCalc(heightValue),
|
|
2026
|
+
minWidth,
|
|
2027
|
+
minHeight,
|
|
2028
|
+
maxWidth,
|
|
2029
|
+
maxHeight
|
|
2030
|
+
};
|
|
2031
|
+
};
|
|
2032
|
+
const useLayerPosition = (layerKey) => {
|
|
2033
|
+
const { layerKey: instanceLayerKey } = require$$0.useContext(InstanceContext);
|
|
2034
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2035
|
+
const { isDocument } = useRenderTarget();
|
|
2036
|
+
const isTop = isTopLevel(fragmentManager, layerKey);
|
|
2037
|
+
const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
|
|
2038
|
+
const [position] = useLayerValue(layerKey, "position", fragmentManager);
|
|
2039
|
+
const [top] = useLayerValue(layerKey, "top", fragmentManager);
|
|
2040
|
+
const [left] = useLayerValue(layerKey, "left", fragmentManager);
|
|
2041
|
+
return require$$0.useMemo(
|
|
2042
|
+
() => ({
|
|
2043
|
+
position: skipPosition ? index.positionType.relative : position,
|
|
2044
|
+
top: position === index.positionType.absolute && !skipPosition ? toPx(top) : null,
|
|
2045
|
+
left: position === index.positionType.absolute && !skipPosition ? toPx(left) : null
|
|
2046
|
+
}),
|
|
2047
|
+
[skipPosition, position, top]
|
|
2048
|
+
);
|
|
2049
|
+
};
|
|
2050
|
+
const useLayerBackground = (layerKey) => {
|
|
2051
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2052
|
+
const [fillType] = useLayerValue(layerKey, "fillType", fragmentManager);
|
|
2053
|
+
const [, , { cssVariableValue: cssSolidFill }] = useLayerValue(
|
|
2054
|
+
layerKey,
|
|
2055
|
+
"solidFill",
|
|
2056
|
+
fragmentManager
|
|
2057
|
+
);
|
|
2058
|
+
const [, , { cssVariableValue: cssImageFill }] = useLayerValue(
|
|
2059
|
+
layerKey,
|
|
2060
|
+
"imageFill",
|
|
2061
|
+
fragmentManager
|
|
2062
|
+
);
|
|
2063
|
+
const [, , { cssVariableValue: cssImageSize }] = useLayerValue(
|
|
2064
|
+
layerKey,
|
|
2065
|
+
"imageSize",
|
|
2066
|
+
fragmentManager
|
|
2067
|
+
);
|
|
2068
|
+
return require$$0.useMemo(() => {
|
|
2069
|
+
if (fillType === index.paintMode.Solid) {
|
|
2070
|
+
return {
|
|
2071
|
+
background: cssSolidFill
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
if (fillType === index.paintMode.Image && cssImageFill) {
|
|
2075
|
+
const sizeMap = {
|
|
2076
|
+
[index.imagePaintScaleModes.Fill]: "cover",
|
|
2077
|
+
[index.imagePaintScaleModes.Fit]: "contain"
|
|
2078
|
+
};
|
|
2079
|
+
return {
|
|
2080
|
+
background: `url(${cssImageFill})`,
|
|
2081
|
+
backgroundSize: sizeMap[cssImageSize]
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
return {
|
|
2085
|
+
background: "transparent"
|
|
2086
|
+
};
|
|
2087
|
+
}, [fillType, cssImageFill, cssSolidFill]);
|
|
2088
|
+
};
|
|
2089
|
+
const useLayerDisplay = (layerKey) => {
|
|
2090
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
2091
|
+
const [layerModeValue] = useLayerValue(layerKey, "layerMode", manager);
|
|
2092
|
+
const [visible] = useLayerValue(layerKey, "visible", manager);
|
|
2093
|
+
return require$$0.useMemo(() => {
|
|
2094
|
+
if (!visible) {
|
|
2095
|
+
return "none";
|
|
2096
|
+
}
|
|
2097
|
+
return layerModeValue === index.layerMode.flex ? "flex" : null;
|
|
2098
|
+
}, [layerModeValue, visible]);
|
|
2099
|
+
};
|
|
2100
|
+
const useCalcLayerBorder = (layerKey) => {
|
|
2101
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2102
|
+
const [borderTypeValue] = useLayerValue(
|
|
2103
|
+
layerKey,
|
|
2104
|
+
"borderType",
|
|
2105
|
+
fragmentManager
|
|
2106
|
+
);
|
|
2107
|
+
return (width, color) => {
|
|
2108
|
+
let value = "";
|
|
2109
|
+
if (typeof borderTypeValue === "string" && borderTypeValue !== index.borderType.None) {
|
|
2110
|
+
value = `${toPx(width)} ${borderTypeValue.toLowerCase()} ${color}`;
|
|
2111
|
+
}
|
|
2112
|
+
return value;
|
|
2113
|
+
};
|
|
2114
|
+
};
|
|
2115
|
+
const useLayerBorder = (layerKey) => {
|
|
2116
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2117
|
+
const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
|
|
2118
|
+
const [borderColor] = useLayerValue(layerKey, "borderColor", fragmentManager);
|
|
2119
|
+
const calcBorder = useCalcLayerBorder(layerKey);
|
|
2120
|
+
return require$$0.useMemo(
|
|
2121
|
+
() => ({ border: calcBorder(borderWidth, borderColor) }),
|
|
2122
|
+
[borderWidth, borderColor]
|
|
2123
|
+
);
|
|
2124
|
+
};
|
|
2125
|
+
const useLayerLayout = (layerKey) => {
|
|
2126
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2127
|
+
const [layerModeValue] = useLayerValue(
|
|
2128
|
+
layerKey,
|
|
2129
|
+
"layerMode",
|
|
2130
|
+
fragmentManager
|
|
2131
|
+
);
|
|
2132
|
+
const [layerWrap] = useLayerValue(layerKey, "layerWrap", fragmentManager);
|
|
2133
|
+
const [layerDistribute2] = useLayerValue(
|
|
2134
|
+
layerKey,
|
|
2135
|
+
"layerDistribute",
|
|
2136
|
+
fragmentManager
|
|
2137
|
+
);
|
|
2138
|
+
const [layerDirectionValue] = useLayerValue(
|
|
2139
|
+
layerKey,
|
|
2140
|
+
"layerDirection",
|
|
2141
|
+
fragmentManager
|
|
2142
|
+
);
|
|
2143
|
+
const [layerAlign2] = useLayerValue(layerKey, "layerAlign", fragmentManager);
|
|
2144
|
+
const [padding] = useLayerValue(layerKey, "padding", fragmentManager);
|
|
2145
|
+
const [gap] = useLayerValue(layerKey, "layerGap", fragmentManager);
|
|
2146
|
+
const isFlex = layerModeValue === index.layerMode.flex;
|
|
2147
|
+
return require$$0.useMemo(
|
|
2148
|
+
() => ({
|
|
2149
|
+
display: isFlex ? "flex" : null,
|
|
2150
|
+
gap: toPx(gap),
|
|
2151
|
+
flexWrap: isFlex ? layerWrap ? "wrap" : null : null,
|
|
2152
|
+
justifyContent: isFlex ? layerDistribute2 : null,
|
|
2153
|
+
flexDirection: isFlex ? layerDirectionValue === index.layerDirection.vertical ? "column" : "row" : null,
|
|
2154
|
+
alignItems: isFlex ? layerAlign2 : null,
|
|
2155
|
+
padding: isFlex ? padding : null
|
|
2156
|
+
}),
|
|
2157
|
+
[
|
|
2158
|
+
isFlex,
|
|
2159
|
+
layerWrap,
|
|
2160
|
+
layerDistribute2,
|
|
2161
|
+
layerDirectionValue,
|
|
2162
|
+
layerAlign2,
|
|
2163
|
+
padding
|
|
2164
|
+
]
|
|
2165
|
+
);
|
|
2166
|
+
};
|
|
2167
|
+
const useLayerStyles = (layerKey) => {
|
|
2168
|
+
var _a;
|
|
2169
|
+
try {
|
|
2170
|
+
if (!layerKey) {
|
|
2171
|
+
throw new Error("Empty layer key");
|
|
2172
|
+
}
|
|
2173
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2174
|
+
const [opacity] = useLayerValue(layerKey, "opacity", fragmentManager);
|
|
2175
|
+
const layerSize = useLayerSize(layerKey);
|
|
2176
|
+
const { position, top, left } = useLayerPosition(layerKey);
|
|
2177
|
+
const display = useLayerDisplay(layerKey);
|
|
2178
|
+
const background = useLayerBackground(layerKey);
|
|
2179
|
+
const { border } = useLayerBorder(layerKey);
|
|
2180
|
+
const layout = useLayerLayout(layerKey);
|
|
2181
|
+
const [zIndex] = useLayerValue(layerKey, "zIndex", fragmentManager);
|
|
2182
|
+
const [borderRadius] = useLayerValue(
|
|
2183
|
+
layerKey,
|
|
2184
|
+
"borderRadius",
|
|
2185
|
+
fragmentManager
|
|
2186
|
+
);
|
|
2187
|
+
const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
|
|
2188
|
+
let props = {};
|
|
2189
|
+
const { _type } = fragmentManager.entityOfKey(layerKey) ?? {};
|
|
2190
|
+
if (_type === index.nodes.Instance) {
|
|
2191
|
+
const instanceProps = omit(
|
|
2192
|
+
(_a = fragmentManager == null ? void 0 : fragmentManager.resolve(layerKey)) == null ? void 0 : _a.props,
|
|
2193
|
+
"_id",
|
|
2194
|
+
"_type"
|
|
2195
|
+
);
|
|
2196
|
+
props = Object.entries(instanceProps).reduce((acc, [key, value]) => {
|
|
2197
|
+
acc[`--${key}`] = value;
|
|
2198
|
+
return acc;
|
|
2199
|
+
}, {});
|
|
2200
|
+
}
|
|
2201
|
+
return {
|
|
2202
|
+
...props ?? {},
|
|
2203
|
+
display,
|
|
2204
|
+
border,
|
|
2205
|
+
...background,
|
|
2206
|
+
position,
|
|
2207
|
+
top,
|
|
2208
|
+
left,
|
|
2209
|
+
opacity,
|
|
2210
|
+
"border-radius": borderRadius,
|
|
2211
|
+
"white-space": whiteSpace2,
|
|
2212
|
+
"z-index": zIndex !== -1 ? zIndex : null,
|
|
2213
|
+
...layout,
|
|
2214
|
+
...layerSize,
|
|
2215
|
+
"user-select": "none"
|
|
2216
|
+
};
|
|
2217
|
+
} catch (e) {
|
|
2218
|
+
console.debug(e);
|
|
2219
|
+
return {};
|
|
2220
|
+
}
|
|
2221
|
+
};
|
|
2222
|
+
const GlobalManager$1 = require$$0.createContext(null);
|
|
2223
|
+
const useGlobalManager = (globalManager) => {
|
|
2224
|
+
var _a, _b;
|
|
2225
|
+
const currentGlobalManager = require$$0.useContext(GlobalManager$1);
|
|
2226
|
+
const resultManager = globalManager ?? currentGlobalManager;
|
|
2227
|
+
const [fragmentsGraph] = y(
|
|
2228
|
+
resultManager,
|
|
2229
|
+
(_a = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _a.key
|
|
2230
|
+
);
|
|
2231
|
+
const queryFragmentManager = async (id) => {
|
|
2232
|
+
var _a2;
|
|
2233
|
+
const queryResult = await ((_a2 = resultManager == null ? void 0 : resultManager.$fetch) == null ? void 0 : _a2.queryFragment(id));
|
|
2234
|
+
const { document: document2, linkedFragments } = queryResult ?? {};
|
|
2235
|
+
if (linkedFragments) {
|
|
2236
|
+
linkedFragments.forEach(({ id: id2, document: document22 }) => {
|
|
2237
|
+
resultManager.$fragments.createFragmentManager(id2, document22);
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
return resultManager.$fragments.createFragmentManager(id, document2);
|
|
2241
|
+
};
|
|
2242
|
+
const setRenderTarget = (value) => {
|
|
2243
|
+
resultManager == null ? void 0 : resultManager.setRenderTarget(value);
|
|
2244
|
+
};
|
|
2245
|
+
return {
|
|
2246
|
+
fragmentsGraph,
|
|
2247
|
+
manager: resultManager,
|
|
2248
|
+
queryFragmentManager,
|
|
2249
|
+
getFragmentManager: ((_b = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _b.getManager) ?? noop,
|
|
2250
|
+
setRenderTarget
|
|
2251
|
+
};
|
|
2252
|
+
};
|
|
2253
|
+
const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
2254
|
+
const {
|
|
2255
|
+
fragmentsGraph,
|
|
2256
|
+
manager: globalManager,
|
|
2257
|
+
getFragmentManager,
|
|
2258
|
+
queryFragmentManager
|
|
2259
|
+
} = useGlobalManager(inputGlobalManager);
|
|
2260
|
+
const [loading, setLoading] = require$$0.useState(false);
|
|
429
2261
|
require$$0.useEffect(() => {
|
|
430
|
-
|
|
431
|
-
|
|
2262
|
+
(async () => {
|
|
2263
|
+
if (fragmentsGraph && !getFragmentManager(fragmentId)) {
|
|
2264
|
+
setLoading(true);
|
|
2265
|
+
await queryFragmentManager(fragmentId);
|
|
2266
|
+
setLoading(false);
|
|
2267
|
+
}
|
|
2268
|
+
})();
|
|
2269
|
+
}, [fragmentId, fragmentsGraph]);
|
|
432
2270
|
return {
|
|
433
2271
|
loading,
|
|
434
|
-
manager: getFragmentManager(fragmentId)
|
|
2272
|
+
manager: getFragmentManager(fragmentId),
|
|
2273
|
+
queryFragmentManager
|
|
2274
|
+
// loadFragmentManager,
|
|
435
2275
|
};
|
|
436
2276
|
};
|
|
437
2277
|
const useFragmentProperties = (fragmentId) => {
|
|
438
2278
|
var _a;
|
|
439
2279
|
const { manager } = useFragmentManager(fragmentId);
|
|
440
2280
|
const [instanceFragment] = y(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
|
|
441
|
-
return
|
|
2281
|
+
return {
|
|
2282
|
+
properties: (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [],
|
|
2283
|
+
manager
|
|
2284
|
+
};
|
|
442
2285
|
};
|
|
443
|
-
const
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
const
|
|
2286
|
+
const useHash = (layerKey) => {
|
|
2287
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
2288
|
+
if (!layerKey || !manager) return null;
|
|
2289
|
+
const layer = manager.resolve(layerKey);
|
|
2290
|
+
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
2291
|
+
return hashGenerator(overrideFrom ?? layerKey);
|
|
2292
|
+
};
|
|
2293
|
+
const useInstance = (instanceProps) => {
|
|
2294
|
+
const { manager: parentManager } = require$$0.useContext(FragmentContext);
|
|
2295
|
+
const [instanceLayer] = y(parentManager, instanceProps.layerKey);
|
|
2296
|
+
const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
|
|
2297
|
+
const styles2 = useLayerStyles(instanceProps.layerKey);
|
|
2298
|
+
const { manager: resultGlobalManager } = useGlobalManager(
|
|
2299
|
+
instanceProps == null ? void 0 : instanceProps.globalManager
|
|
2300
|
+
);
|
|
2301
|
+
const resultProps = { ...instanceLayerProps, ...instanceProps.props ?? {} };
|
|
2302
|
+
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
2303
|
+
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
2304
|
+
const hash = useHash(instanceProps.layerKey);
|
|
447
2305
|
return {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
2306
|
+
hash,
|
|
2307
|
+
styles: styles2,
|
|
2308
|
+
definitions,
|
|
2309
|
+
props: resultProps,
|
|
2310
|
+
parentManager,
|
|
2311
|
+
innerManager: innerFragmentManager,
|
|
2312
|
+
fragmentId: resultFragmentId,
|
|
2313
|
+
globalManager: resultGlobalManager
|
|
2314
|
+
};
|
|
2315
|
+
};
|
|
2316
|
+
const InstanceContext = require$$0.createContext({
|
|
2317
|
+
layerKey: null,
|
|
2318
|
+
parentManager: null,
|
|
2319
|
+
innerManager: null,
|
|
2320
|
+
props: {},
|
|
2321
|
+
definitions: []
|
|
2322
|
+
});
|
|
2323
|
+
const useLayerChildren = (layerKey, customManager) => {
|
|
2324
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2325
|
+
const [layerData] = y(customManager ?? fragmentManager, layerKey, {
|
|
2326
|
+
selector: (data) => pick(data, "children")
|
|
2327
|
+
});
|
|
2328
|
+
return (layerData == null ? void 0 : layerData.children) ?? [];
|
|
2329
|
+
};
|
|
2330
|
+
const useFragmentChildren = (fragmentId) => {
|
|
2331
|
+
const { layerKey: instanceLayerKey } = require$$0.useContext(InstanceContext);
|
|
2332
|
+
const { manager } = useFragmentManager(fragmentId);
|
|
2333
|
+
const layerKey = `${index.nodes.Fragment}:${fragmentId}`;
|
|
2334
|
+
const children = useLayerChildren(layerKey, manager);
|
|
2335
|
+
const { isDocument } = useRenderTarget();
|
|
2336
|
+
const [resizeChildren, setResizeChildren] = require$$0.useState(null);
|
|
2337
|
+
require$$0.useRef();
|
|
2338
|
+
const setRef = require$$0.useCallback(
|
|
2339
|
+
(node) => {
|
|
2340
|
+
},
|
|
2341
|
+
[isDocument, instanceLayerKey, manager, children]
|
|
2342
|
+
);
|
|
2343
|
+
const primary = children == null ? void 0 : children.find(
|
|
2344
|
+
(breakpoint) => {
|
|
2345
|
+
var _a;
|
|
2346
|
+
return (_a = manager.resolve(breakpoint)) == null ? void 0 : _a.isPrimary;
|
|
2347
|
+
}
|
|
2348
|
+
);
|
|
2349
|
+
return {
|
|
2350
|
+
primary,
|
|
2351
|
+
children,
|
|
2352
|
+
//isBrowser && resizeChildren ? resizeChildren : children, //isStyleSheetRender ? children ?? [] : primary ? [primary] : [],
|
|
2353
|
+
isResize: isBrowser_default && resizeChildren,
|
|
2354
|
+
setRef
|
|
2355
|
+
};
|
|
2356
|
+
};
|
|
2357
|
+
const getStylesheetKey = (fragmentKey) => {
|
|
2358
|
+
const isLink2 = core.isLinkKey(fragmentKey);
|
|
2359
|
+
if (isLink2) {
|
|
2360
|
+
const [type, id] = fragmentKey.split(":");
|
|
2361
|
+
return `stylesheet-${id}`;
|
|
2362
|
+
}
|
|
2363
|
+
return `stylesheet-unknown`;
|
|
2364
|
+
};
|
|
2365
|
+
function useInjectedStyle() {
|
|
2366
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
2367
|
+
const injectStyle = () => {
|
|
2368
|
+
var _a, _b;
|
|
2369
|
+
const styles2 = (_b = (_a = manager == null ? void 0 : manager.$styleSheet.extract()) == null ? void 0 : _a.at(0)) == null ? void 0 : _b.styles;
|
|
2370
|
+
if (isBrowser_default && styles2) {
|
|
2371
|
+
const stylesheetKey = getStylesheetKey(manager == null ? void 0 : manager.key);
|
|
2372
|
+
if (document.getElementById(stylesheetKey)) {
|
|
2373
|
+
const el = document.getElementById(stylesheetKey);
|
|
2374
|
+
if (el) el.remove();
|
|
2375
|
+
}
|
|
2376
|
+
const style = document.createElement("style");
|
|
2377
|
+
style.id = stylesheetKey;
|
|
2378
|
+
style.textContent = styles2.join("");
|
|
2379
|
+
document.head.appendChild(style);
|
|
453
2380
|
}
|
|
454
2381
|
};
|
|
2382
|
+
return {
|
|
2383
|
+
injectStyle
|
|
2384
|
+
};
|
|
2385
|
+
}
|
|
2386
|
+
const useStyleSheet = () => {
|
|
2387
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
2388
|
+
const { injectStyle } = useInjectedStyle();
|
|
2389
|
+
const addLayerStyle = require$$0.useCallback(
|
|
2390
|
+
(layerKey, styles2, layer) => {
|
|
2391
|
+
var _a;
|
|
2392
|
+
if ("addStyle" in (manager == null ? void 0 : manager.$styleSheet)) {
|
|
2393
|
+
(_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.addStyle(layerKey, styles2, layer);
|
|
2394
|
+
if (isBrowser_default) {
|
|
2395
|
+
injectStyle();
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
},
|
|
2399
|
+
[manager]
|
|
2400
|
+
);
|
|
2401
|
+
return {
|
|
2402
|
+
addLayerStyle
|
|
2403
|
+
};
|
|
2404
|
+
};
|
|
2405
|
+
const useFragment = (fragmentId, globalManager) => {
|
|
2406
|
+
const layerKey = `${index.nodes.Fragment}:${fragmentId}`;
|
|
2407
|
+
const { manager } = require$$0.useContext(FragmentContext);
|
|
2408
|
+
const { isDocument } = useRenderTarget();
|
|
2409
|
+
const { setRef, children, isResize } = useFragmentChildren(fragmentId);
|
|
2410
|
+
const hash = useHash(layerKey);
|
|
2411
|
+
const { addLayerStyle } = useStyleSheet();
|
|
2412
|
+
if (manager) {
|
|
2413
|
+
addLayerStyle(
|
|
2414
|
+
layerKey,
|
|
2415
|
+
{
|
|
2416
|
+
width: "100%",
|
|
2417
|
+
height: "100%",
|
|
2418
|
+
"container-type": (children == null ? void 0 : children.length) === 1 ? "normal" : "inline-size"
|
|
2419
|
+
},
|
|
2420
|
+
manager == null ? void 0 : manager.resolve(layerKey),
|
|
2421
|
+
manager == null ? void 0 : manager.key
|
|
2422
|
+
);
|
|
2423
|
+
}
|
|
2424
|
+
return {
|
|
2425
|
+
hash,
|
|
2426
|
+
isDocument,
|
|
2427
|
+
manager,
|
|
2428
|
+
setRef,
|
|
2429
|
+
children,
|
|
2430
|
+
isResize
|
|
2431
|
+
};
|
|
2432
|
+
};
|
|
2433
|
+
const useLayerInteractions = (layerKey) => {
|
|
2434
|
+
const { manager: globalManager } = useGlobalManager();
|
|
2435
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2436
|
+
const [interactions2] = useLayerValue(
|
|
2437
|
+
layerKey,
|
|
2438
|
+
"interactions",
|
|
2439
|
+
fragmentManager
|
|
2440
|
+
);
|
|
2441
|
+
const { readVariable } = useReadVariable();
|
|
2442
|
+
const fireEvent = require$$0.useCallback(
|
|
2443
|
+
(eventLink) => {
|
|
2444
|
+
var _a, _b;
|
|
2445
|
+
const event = fragmentManager.resolve(eventLink);
|
|
2446
|
+
const { value: eventValue } = readVariable(eventLink);
|
|
2447
|
+
if ((event == null ? void 0 : event.mode) === index.eventMode.goal) {
|
|
2448
|
+
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
|
|
2449
|
+
}
|
|
2450
|
+
},
|
|
2451
|
+
[globalManager, fragmentManager]
|
|
2452
|
+
);
|
|
2453
|
+
return require$$0.useMemo(() => {
|
|
2454
|
+
if (!interactions2 || !Array.isArray(interactions2)) return {};
|
|
2455
|
+
const clickEvents = interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.click).map((el) => el.event);
|
|
2456
|
+
return {
|
|
2457
|
+
onClick: () => {
|
|
2458
|
+
clickEvents.map(fireEvent);
|
|
2459
|
+
}
|
|
2460
|
+
};
|
|
2461
|
+
}, [interactions2, fireEvent]);
|
|
2462
|
+
};
|
|
2463
|
+
const useFrame = (layerKey) => {
|
|
2464
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2465
|
+
const layer = fragmentManager.entityOfKey(layerKey);
|
|
2466
|
+
const styles2 = useLayerStyles(layerKey);
|
|
2467
|
+
const children = useLayerChildren(layerKey);
|
|
2468
|
+
const hash = useHash(layerKey);
|
|
2469
|
+
const { addLayerStyle } = useStyleSheet();
|
|
2470
|
+
const events = useLayerInteractions(layerKey);
|
|
2471
|
+
addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
|
|
2472
|
+
return {
|
|
2473
|
+
type: layer == null ? void 0 : layer._type,
|
|
2474
|
+
hash,
|
|
2475
|
+
styles: {},
|
|
2476
|
+
//isBrowser ? pick(styles, "background") : {},
|
|
2477
|
+
children,
|
|
2478
|
+
events
|
|
2479
|
+
};
|
|
2480
|
+
};
|
|
2481
|
+
const allowAttributes = [
|
|
2482
|
+
"fontSize",
|
|
2483
|
+
"fontWeight",
|
|
2484
|
+
"color",
|
|
2485
|
+
"lineHeight",
|
|
2486
|
+
"letterSpacing",
|
|
2487
|
+
"textTransform",
|
|
2488
|
+
"textDecoration",
|
|
2489
|
+
"textAlign"
|
|
2490
|
+
];
|
|
2491
|
+
const wrapTextInParagraphWithAttributes = (text2, attributes) => {
|
|
2492
|
+
if (text2.startsWith("<p")) return text2;
|
|
2493
|
+
const style = Object.entries(attributes).filter(
|
|
2494
|
+
([key, value]) => isValue(value) && allowAttributes.includes(key) && typeof value === "string" && !!value.length
|
|
2495
|
+
).map(([key, value]) => `${toKebabCase(key)}: ${value}`).join("; ");
|
|
2496
|
+
return `<p style="${style}">${text2}</p>`;
|
|
2497
|
+
};
|
|
2498
|
+
const useTextContent = (layerKey, manager) => {
|
|
2499
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2500
|
+
const [content, , contentInfo] = useLayerValue(
|
|
2501
|
+
layerKey,
|
|
2502
|
+
"content",
|
|
2503
|
+
fragmentManager
|
|
2504
|
+
);
|
|
2505
|
+
const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
|
|
2506
|
+
return require$$0.useMemo(() => {
|
|
2507
|
+
if (typeof content === "string" && isValue(attributes)) {
|
|
2508
|
+
return wrapTextInParagraphWithAttributes(content, attributes);
|
|
2509
|
+
}
|
|
2510
|
+
return content;
|
|
2511
|
+
}, [contentInfo, content, attributes]);
|
|
2512
|
+
};
|
|
2513
|
+
const useTextAttributes = (layerKey) => {
|
|
2514
|
+
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
2515
|
+
const styles2 = useLayerStyles(layerKey);
|
|
2516
|
+
const content = useTextContent(layerKey);
|
|
2517
|
+
const hash = useHash(layerKey);
|
|
2518
|
+
const { addLayerStyle } = useStyleSheet();
|
|
2519
|
+
addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
|
|
2520
|
+
return {
|
|
2521
|
+
hash,
|
|
2522
|
+
content
|
|
2523
|
+
};
|
|
2524
|
+
};
|
|
2525
|
+
function useMounted() {
|
|
2526
|
+
const [isMounted, setIsMounted] = require$$0.useState(false);
|
|
2527
|
+
require$$0.useEffect(() => {
|
|
2528
|
+
setIsMounted(true);
|
|
2529
|
+
return () => {
|
|
2530
|
+
setIsMounted(false);
|
|
2531
|
+
};
|
|
2532
|
+
}, []);
|
|
2533
|
+
return isMounted;
|
|
2534
|
+
}
|
|
2535
|
+
const StyleSheetContext = require$$0.createContext(null);
|
|
2536
|
+
StyleSheetContext.Provider;
|
|
2537
|
+
const Text = ({ layerKey }) => {
|
|
2538
|
+
const { hash, content } = useTextAttributes(layerKey);
|
|
2539
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: hash, "data-key": layerKey, children: /* @__PURE__ */ jsxRuntime.jsx("div", { dangerouslySetInnerHTML: { __html: content } }) });
|
|
2540
|
+
};
|
|
2541
|
+
const Frame = ({ layerKey, hidden }) => {
|
|
2542
|
+
const { styles, hash, children, type, events } = useFrame(layerKey);
|
|
2543
|
+
const isMounted = useMounted();
|
|
2544
|
+
if (isMounted && hidden) {
|
|
2545
|
+
return null;
|
|
2546
|
+
}
|
|
2547
|
+
if (type === definition.definition.nodes.Text) {
|
|
2548
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Text, { layerKey });
|
|
2549
|
+
}
|
|
2550
|
+
if (type === definition.definition.nodes.Instance) {
|
|
2551
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Instance, { layerKey });
|
|
2552
|
+
}
|
|
2553
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2554
|
+
"div",
|
|
2555
|
+
{
|
|
2556
|
+
className: hash,
|
|
2557
|
+
"data-key": layerKey,
|
|
2558
|
+
style: { ...styles, display: hidden ? "none" : styles.display },
|
|
2559
|
+
...events,
|
|
2560
|
+
children: children.map((childLink) => /* @__PURE__ */ jsxRuntime.jsx(Frame, { layerKey: childLink }, childLink))
|
|
2561
|
+
}
|
|
2562
|
+
);
|
|
2563
|
+
};
|
|
2564
|
+
const FragmentInternal = ({ fragmentId, globalManager }) => {
|
|
2565
|
+
const { children, manager, hash, isResize } = useFragment(
|
|
2566
|
+
fragmentId
|
|
2567
|
+
);
|
|
2568
|
+
if (!manager) return null;
|
|
2569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2570
|
+
"div",
|
|
2571
|
+
{
|
|
2572
|
+
"data-key": `${definition.definition.nodes.Fragment}:${fragmentId}`,
|
|
2573
|
+
className: hash,
|
|
2574
|
+
children: children.map((childLink) => {
|
|
2575
|
+
const childLayer = manager == null ? void 0 : manager.resolve(childLink);
|
|
2576
|
+
const isPrimary = (childLayer == null ? void 0 : childLayer.isPrimary) ?? false;
|
|
2577
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2578
|
+
Frame,
|
|
2579
|
+
{
|
|
2580
|
+
layerKey: childLink,
|
|
2581
|
+
hidden: !isResize && !isPrimary
|
|
2582
|
+
},
|
|
2583
|
+
childLink
|
|
2584
|
+
);
|
|
2585
|
+
})
|
|
2586
|
+
}
|
|
2587
|
+
);
|
|
2588
|
+
};
|
|
2589
|
+
const Fragment = (props) => {
|
|
2590
|
+
const { manager: resultGlobalManager } = useGlobalManager();
|
|
2591
|
+
const { manager } = useFragmentManager(props.fragmentId, resultGlobalManager);
|
|
2592
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FragmentContext.Provider, { value: { manager }, children: /* @__PURE__ */ jsxRuntime.jsx(FragmentInternal, { ...props }) });
|
|
2593
|
+
};
|
|
2594
|
+
const isBrowser = typeof window !== "undefined";
|
|
2595
|
+
const loadFragmentManager = async (globalManager, fragmentId) => {
|
|
2596
|
+
var _a;
|
|
2597
|
+
const { document: document2, linkedFragments } = await ((_a = globalManager == null ? void 0 : globalManager.queryFragment) == null ? void 0 : _a.call(
|
|
2598
|
+
globalManager,
|
|
2599
|
+
fragmentId
|
|
2600
|
+
));
|
|
2601
|
+
if (fragmentId && document2) {
|
|
2602
|
+
if (linkedFragments) {
|
|
2603
|
+
linkedFragments.forEach(({ id, document: document22 }) => {
|
|
2604
|
+
globalManager == null ? void 0 : globalManager.createFragmentManager(id, document22);
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
return globalManager == null ? void 0 : globalManager.createFragmentManager(fragmentId, document2);
|
|
2608
|
+
}
|
|
2609
|
+
return null;
|
|
2610
|
+
};
|
|
2611
|
+
function createResource(resourceCache, key, fetcher) {
|
|
2612
|
+
if (resourceCache.has(key)) return resourceCache.get(key);
|
|
2613
|
+
let status = "pending";
|
|
2614
|
+
let result;
|
|
2615
|
+
const suspender = fetcher().then(
|
|
2616
|
+
(r) => {
|
|
2617
|
+
status = "success";
|
|
2618
|
+
result = r;
|
|
2619
|
+
},
|
|
2620
|
+
(e) => {
|
|
2621
|
+
status = "error";
|
|
2622
|
+
result = e;
|
|
2623
|
+
}
|
|
2624
|
+
);
|
|
2625
|
+
const resource = {
|
|
2626
|
+
read() {
|
|
2627
|
+
if (status === "pending") throw suspender;
|
|
2628
|
+
if (status === "error") throw result;
|
|
2629
|
+
return result;
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
resourceCache.set(key, resource);
|
|
2633
|
+
return resource;
|
|
2634
|
+
}
|
|
2635
|
+
const InstanceInitial = (instanceProps) => {
|
|
2636
|
+
const {
|
|
2637
|
+
fragmentId,
|
|
2638
|
+
parentManager,
|
|
2639
|
+
props,
|
|
2640
|
+
hash,
|
|
2641
|
+
innerManager,
|
|
2642
|
+
definitions,
|
|
2643
|
+
globalManager
|
|
2644
|
+
} = useInstance(instanceProps);
|
|
2645
|
+
if (!isBrowser) {
|
|
2646
|
+
if (globalManager && !("resourceCache" in globalManager)) {
|
|
2647
|
+
globalManager.resourceCache = /* @__PURE__ */ new Map();
|
|
2648
|
+
}
|
|
2649
|
+
const resource = createResource(
|
|
2650
|
+
globalManager.resourceCache,
|
|
2651
|
+
fragmentId,
|
|
2652
|
+
() => loadFragmentManager(globalManager, fragmentId)
|
|
2653
|
+
);
|
|
2654
|
+
resource.read();
|
|
2655
|
+
}
|
|
2656
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2657
|
+
InstanceContext.Provider,
|
|
2658
|
+
{
|
|
2659
|
+
value: {
|
|
2660
|
+
layerKey: instanceProps.layerKey,
|
|
2661
|
+
definitions,
|
|
2662
|
+
innerManager,
|
|
2663
|
+
parentManager,
|
|
2664
|
+
props
|
|
2665
|
+
},
|
|
2666
|
+
children: parentManager ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: hash, "data-key": instanceProps.layerKey, children: /* @__PURE__ */ jsxRuntime.jsx(Fragment, { fragmentId, globalManager }) }) : /* @__PURE__ */ jsxRuntime.jsx(Fragment, { fragmentId, globalManager })
|
|
2667
|
+
}
|
|
2668
|
+
);
|
|
2669
|
+
};
|
|
2670
|
+
const Instance = (props) => {
|
|
2671
|
+
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(GlobalManager$1, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(InstanceInitial, { ...props }) }) : /* @__PURE__ */ jsxRuntime.jsx(InstanceInitial, { ...props });
|
|
2672
|
+
};
|
|
2673
|
+
const GlobalManager = ({ children, value }) => {
|
|
2674
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GlobalManager$1, { value, children });
|
|
455
2675
|
};
|
|
456
|
-
const Fragment = createReactComponent(renderCore.Fragment);
|
|
457
|
-
const Instance = createReactComponent(renderCore.Instance);
|
|
458
|
-
exports.Fragment = Fragment;
|
|
459
2676
|
exports.GlobalManager = GlobalManager;
|
|
460
2677
|
exports.Instance = Instance;
|
|
461
|
-
exports.
|
|
462
|
-
exports.useFragmentProperties = useFragmentProperties;
|
|
2678
|
+
exports.collectStyles = collectStyles;
|
|
463
2679
|
exports.useGlobalManager = useGlobalManager;
|
|
464
|
-
exports.useRenderTarget = useRenderTarget;
|