@fragmentsx/definition 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/index.d.ts +173 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/helpers/findSchemaByPath.d.ts +9 -0
- package/dist/helpers/findSchemaByPath.d.ts.map +1 -0
- package/dist/helpers/getLayerSchema.d.ts +2 -0
- package/dist/helpers/getLayerSchema.d.ts.map +1 -0
- package/dist/helpers/getNormalizeLayer.d.ts +4 -0
- package/dist/helpers/getNormalizeLayer.d.ts.map +1 -0
- package/dist/helpers/layerField.d.ts +12 -0
- package/dist/helpers/layerField.d.ts.map +1 -0
- package/dist/helpers/normalizeLayer.d.ts +10 -0
- package/dist/helpers/normalizeLayer.d.ts.map +1 -0
- package/dist/helpers/parseLayerField.d.ts +20 -0
- package/dist/helpers/parseLayerField.d.ts.map +1 -0
- package/dist/index.cjs.js +417 -53
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +417 -53
- package/dist/schemas/ChildrenSchema.d.ts +5 -0
- package/dist/schemas/ChildrenSchema.d.ts.map +1 -0
- package/dist/schemas/CssOverrideSchema.d.ts +5 -0
- package/dist/schemas/CssOverrideSchema.d.ts.map +1 -0
- package/dist/schemas/GraphFieldSchema.d.ts +6 -0
- package/dist/schemas/GraphFieldSchema.d.ts.map +1 -0
- package/dist/schemas/InteractionsSchema.d.ts +5 -0
- package/dist/schemas/InteractionsSchema.d.ts.map +1 -0
- package/dist/schemas/LinkSchema.d.ts +6 -0
- package/dist/schemas/LinkSchema.d.ts.map +1 -0
- package/dist/schemas/OverridesSchema.d.ts +6 -0
- package/dist/schemas/OverridesSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/CollectionSchema.d.ts +54 -0
- package/dist/schemas/nodes/CollectionSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/FragmentSchema.d.ts +12 -0
- package/dist/schemas/nodes/FragmentSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/FrameSchema.d.ts +57 -0
- package/dist/schemas/nodes/FrameSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/InstanceSchema.d.ts +39 -0
- package/dist/schemas/nodes/InstanceSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/TextSchema.d.ts +41 -0
- package/dist/schemas/nodes/TextSchema.d.ts.map +1 -0
- package/dist/schemas/styles/BorderSchema.d.ts +7 -0
- package/dist/schemas/styles/BorderSchema.d.ts.map +1 -0
- package/dist/schemas/styles/FillSchema.d.ts +8 -0
- package/dist/schemas/styles/FillSchema.d.ts.map +1 -0
- package/dist/schemas/styles/LayerSchema.d.ts +11 -0
- package/dist/schemas/styles/LayerSchema.d.ts.map +1 -0
- package/dist/schemas/styles/PositionSchema.d.ts +11 -0
- package/dist/schemas/styles/PositionSchema.d.ts.map +1 -0
- package/dist/schemas/styles/SceneSchema.d.ts +8 -0
- package/dist/schemas/styles/SceneSchema.d.ts.map +1 -0
- package/dist/schemas/styles/SizeSchema.d.ts +17 -0
- package/dist/schemas/styles/SizeSchema.d.ts.map +1 -0
- package/dist/schemas/styles/fields/BorderRadiusSchema.d.ts +3 -0
- package/dist/schemas/styles/fields/BorderRadiusSchema.d.ts.map +1 -0
- package/dist/schemas/styles/fields/OverflowSchema.d.ts +3 -0
- package/dist/schemas/styles/fields/OverflowSchema.d.ts.map +1 -0
- package/dist/schemas/variables/ArrayVariableSchema.d.ts +13 -0
- package/dist/schemas/variables/ArrayVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/BooleanVariableSchema.d.ts +12 -0
- package/dist/schemas/variables/BooleanVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/ColorVariableSchema.d.ts +12 -0
- package/dist/schemas/variables/ColorVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/EnumVariableSchema.d.ts +13 -0
- package/dist/schemas/variables/EnumVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/EventVariableSchema.d.ts +13 -0
- package/dist/schemas/variables/EventVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/ImageVariableSchema.d.ts +13 -0
- package/dist/schemas/variables/ImageVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/LinkVariableSchema.d.ts +12 -0
- package/dist/schemas/variables/LinkVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/NumberVariableSchema.d.ts +16 -0
- package/dist/schemas/variables/NumberVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/ObjectVariableSchema.d.ts +13 -0
- package/dist/schemas/variables/ObjectVariableSchema.d.ts.map +1 -0
- package/dist/schemas/variables/StringVariableSchema.d.ts +14 -0
- package/dist/schemas/variables/StringVariableSchema.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +4 -1
package/dist/index.cjs.js
CHANGED
|
@@ -10,6 +10,7 @@ const nodes = createConstants(
|
|
|
10
10
|
"Fragment",
|
|
11
11
|
"FragmentInstance",
|
|
12
12
|
"Instance",
|
|
13
|
+
"Collection",
|
|
13
14
|
"Breakpoint",
|
|
14
15
|
"Frame",
|
|
15
16
|
"Image",
|
|
@@ -22,14 +23,9 @@ const nodes = createConstants(
|
|
|
22
23
|
);
|
|
23
24
|
const fragmentGrowingMode = createConstants("auto", "fill");
|
|
24
25
|
const borderType = createConstants("None", "Solid", "Dashed", "Dotted");
|
|
25
|
-
const linkTarget = createConstants("_blank");
|
|
26
|
+
const linkTarget = createConstants("_blank", "none");
|
|
26
27
|
const paintMode = createConstants("None", "Solid", "Image");
|
|
27
|
-
const imagePaintScaleModes = createConstants(
|
|
28
|
-
"Fill",
|
|
29
|
-
"Fit",
|
|
30
|
-
"Crop",
|
|
31
|
-
"Tile"
|
|
32
|
-
);
|
|
28
|
+
const imagePaintScaleModes = createConstants("Auto", "Contain", "Cover");
|
|
33
29
|
const constrain = createConstants(
|
|
34
30
|
"Min",
|
|
35
31
|
"Center",
|
|
@@ -69,7 +65,9 @@ const effectName = createConstants(
|
|
|
69
65
|
"increase"
|
|
70
66
|
);
|
|
71
67
|
const variableType = createConstants(
|
|
68
|
+
"Event",
|
|
72
69
|
"String",
|
|
70
|
+
"Link",
|
|
73
71
|
"Boolean",
|
|
74
72
|
"Array",
|
|
75
73
|
"Color",
|
|
@@ -77,6 +75,7 @@ const variableType = createConstants(
|
|
|
77
75
|
"Date",
|
|
78
76
|
"Enum",
|
|
79
77
|
"Number",
|
|
78
|
+
"Image",
|
|
80
79
|
"Object"
|
|
81
80
|
);
|
|
82
81
|
const whiteSpace = createConstants(
|
|
@@ -113,6 +112,14 @@ const variableTransforms = createConstants(
|
|
|
113
112
|
);
|
|
114
113
|
const renderTarget = createConstants("canvas", "document");
|
|
115
114
|
const renderMode = createConstants("viewport", "parent", "fixed");
|
|
115
|
+
const interactions = createConstants("click", "mouseover", "appear");
|
|
116
|
+
const eventMode = createConstants("goal", "callback", "tracker");
|
|
117
|
+
const scopeTypes = createConstants(
|
|
118
|
+
"InstanceScope",
|
|
119
|
+
"FragmentScope",
|
|
120
|
+
"CollectionScope",
|
|
121
|
+
"CollectionItemScope"
|
|
122
|
+
);
|
|
116
123
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
117
124
|
__proto__: null,
|
|
118
125
|
borderType,
|
|
@@ -120,8 +127,10 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
120
127
|
createConstants,
|
|
121
128
|
effectName,
|
|
122
129
|
effectType,
|
|
130
|
+
eventMode,
|
|
123
131
|
fragmentGrowingMode,
|
|
124
132
|
imagePaintScaleModes,
|
|
133
|
+
interactions,
|
|
125
134
|
layerAlign,
|
|
126
135
|
layerDirection,
|
|
127
136
|
layerDistribute,
|
|
@@ -133,6 +142,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
133
142
|
positionType,
|
|
134
143
|
renderMode,
|
|
135
144
|
renderTarget,
|
|
145
|
+
scopeTypes,
|
|
136
146
|
sizing,
|
|
137
147
|
textDecorations,
|
|
138
148
|
textTransform,
|
|
@@ -322,6 +332,20 @@ function minValue(requirement, message) {
|
|
|
322
332
|
};
|
|
323
333
|
}
|
|
324
334
|
// @__NO_SIDE_EFFECTS__
|
|
335
|
+
function transform(operation) {
|
|
336
|
+
return {
|
|
337
|
+
kind: "transformation",
|
|
338
|
+
type: "transform",
|
|
339
|
+
reference: transform,
|
|
340
|
+
async: false,
|
|
341
|
+
operation,
|
|
342
|
+
"~run"(dataset) {
|
|
343
|
+
dataset.value = this.operation(dataset.value);
|
|
344
|
+
return dataset;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
// @__NO_SIDE_EFFECTS__
|
|
325
349
|
function getFallback(schema, dataset, config2) {
|
|
326
350
|
return typeof schema.fallback === "function" ? (
|
|
327
351
|
// @ts-expect-error
|
|
@@ -342,6 +366,23 @@ function getDefault(schema, dataset, config2) {
|
|
|
342
366
|
);
|
|
343
367
|
}
|
|
344
368
|
// @__NO_SIDE_EFFECTS__
|
|
369
|
+
function any() {
|
|
370
|
+
return {
|
|
371
|
+
kind: "schema",
|
|
372
|
+
type: "any",
|
|
373
|
+
reference: any,
|
|
374
|
+
expects: "any",
|
|
375
|
+
async: false,
|
|
376
|
+
get "~standard"() {
|
|
377
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
378
|
+
},
|
|
379
|
+
"~run"(dataset) {
|
|
380
|
+
dataset.typed = true;
|
|
381
|
+
return dataset;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
// @__NO_SIDE_EFFECTS__
|
|
345
386
|
function array(item, message) {
|
|
346
387
|
return {
|
|
347
388
|
kind: "schema",
|
|
@@ -475,6 +516,33 @@ function literal(literal_, message) {
|
|
|
475
516
|
};
|
|
476
517
|
}
|
|
477
518
|
// @__NO_SIDE_EFFECTS__
|
|
519
|
+
function nullable(wrapped, default_) {
|
|
520
|
+
return {
|
|
521
|
+
kind: "schema",
|
|
522
|
+
type: "nullable",
|
|
523
|
+
reference: nullable,
|
|
524
|
+
expects: `(${wrapped.expects} | null)`,
|
|
525
|
+
async: false,
|
|
526
|
+
wrapped,
|
|
527
|
+
default: default_,
|
|
528
|
+
get "~standard"() {
|
|
529
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
530
|
+
},
|
|
531
|
+
"~run"(dataset, config2) {
|
|
532
|
+
if (dataset.value === null) {
|
|
533
|
+
if (this.default !== void 0) {
|
|
534
|
+
dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
535
|
+
}
|
|
536
|
+
if (dataset.value === null) {
|
|
537
|
+
dataset.typed = true;
|
|
538
|
+
return dataset;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return this.wrapped["~run"](dataset, config2);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
// @__NO_SIDE_EFFECTS__
|
|
478
546
|
function number(message) {
|
|
479
547
|
return {
|
|
480
548
|
kind: "schema",
|
|
@@ -864,14 +932,34 @@ const linkValidator = /* @__PURE__ */ check(
|
|
|
864
932
|
return !!value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
|
|
865
933
|
}
|
|
866
934
|
);
|
|
935
|
+
const isLink = (value) => {
|
|
936
|
+
var _a;
|
|
937
|
+
return (_a = /* @__PURE__ */ safeParse(linkValidator, value)) == null ? void 0 : _a.success;
|
|
938
|
+
};
|
|
939
|
+
const isVariableLink = (value) => {
|
|
940
|
+
var _a, _b;
|
|
941
|
+
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;
|
|
942
|
+
};
|
|
867
943
|
const getMetadata = (schema) => {
|
|
868
944
|
var _a;
|
|
869
945
|
const pipelines = (schema == null ? void 0 : schema.pipe) ?? [];
|
|
870
946
|
return ((_a = pipelines == null ? void 0 : pipelines.find((pipe2) => /* @__PURE__ */ isOfKind("metadata", pipe2))) == null ? void 0 : _a.metadata) ?? null;
|
|
871
947
|
};
|
|
872
948
|
const layerField = (schema, meta) => {
|
|
873
|
-
const
|
|
874
|
-
|
|
949
|
+
const overridable = (meta == null ? void 0 : meta.overridable) ?? true;
|
|
950
|
+
const variable = (meta == null ? void 0 : meta.variable) ?? false;
|
|
951
|
+
const schemaParts = [schema];
|
|
952
|
+
if (variable) {
|
|
953
|
+
schemaParts.push(/* @__PURE__ */ pipe(/* @__PURE__ */ string(), linkValidator));
|
|
954
|
+
}
|
|
955
|
+
if (overridable) {
|
|
956
|
+
schemaParts.push(/* @__PURE__ */ any());
|
|
957
|
+
}
|
|
958
|
+
return /* @__PURE__ */ pipe(
|
|
959
|
+
/* @__PURE__ */ optional(/* @__PURE__ */ union(schemaParts)),
|
|
960
|
+
/* @__PURE__ */ transform((meta == null ? void 0 : meta.transform) ?? ((v2) => v2)),
|
|
961
|
+
/* @__PURE__ */ metadata(meta ?? {})
|
|
962
|
+
);
|
|
875
963
|
};
|
|
876
964
|
const ChildrenSchema = /* @__PURE__ */ object({
|
|
877
965
|
children: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
|
|
@@ -884,14 +972,35 @@ const GraphFieldSchema = /* @__PURE__ */ object({
|
|
|
884
972
|
_type: /* @__PURE__ */ picklist(Object.keys(nodes))
|
|
885
973
|
});
|
|
886
974
|
const OverridesSchema = /* @__PURE__ */ object({
|
|
887
|
-
overrides: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), { overridable: false })
|
|
975
|
+
overrides: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), { overridable: false }),
|
|
976
|
+
overrideFrom: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false })
|
|
888
977
|
});
|
|
889
978
|
const PositionSchema = /* @__PURE__ */ object({
|
|
890
979
|
position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
|
|
891
980
|
fallback: positionType.absolute
|
|
892
981
|
}),
|
|
893
|
-
top: layerField(/* @__PURE__ */ number(), {
|
|
894
|
-
|
|
982
|
+
top: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
983
|
+
fallback: null,
|
|
984
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
985
|
+
}),
|
|
986
|
+
left: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
987
|
+
fallback: null,
|
|
988
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
989
|
+
}),
|
|
990
|
+
right: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
991
|
+
fallback: null,
|
|
992
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
993
|
+
}),
|
|
994
|
+
bottom: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
|
|
995
|
+
fallback: null,
|
|
996
|
+
transform: (value) => typeof value === "number" ? Math.ceil(value) : value
|
|
997
|
+
}),
|
|
998
|
+
centerAnchorX: layerField(/* @__PURE__ */ number(), {
|
|
999
|
+
fallback: 0.5
|
|
1000
|
+
}),
|
|
1001
|
+
centerAnchorY: layerField(/* @__PURE__ */ number(), {
|
|
1002
|
+
fallback: 0.5
|
|
1003
|
+
})
|
|
895
1004
|
});
|
|
896
1005
|
const SceneSchema = /* @__PURE__ */ object({
|
|
897
1006
|
opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
|
|
@@ -899,23 +1008,32 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
899
1008
|
variable: true
|
|
900
1009
|
}),
|
|
901
1010
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
overflow: layerField(/* @__PURE__ */ picklist(Object.keys(overflow)), {
|
|
905
|
-
fallback: overflow.hidden
|
|
906
|
-
})
|
|
1011
|
+
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1012
|
+
zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
|
|
907
1013
|
});
|
|
908
1014
|
const FillSchema = /* @__PURE__ */ object({
|
|
909
1015
|
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
910
1016
|
fallback: paintMode.None
|
|
911
1017
|
}),
|
|
912
|
-
solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
|
|
1018
|
+
solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" }),
|
|
1019
|
+
imageFill: layerField(/* @__PURE__ */ string()),
|
|
1020
|
+
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1021
|
+
fallback: imagePaintScaleModes.Auto
|
|
1022
|
+
})
|
|
913
1023
|
});
|
|
914
1024
|
const BorderSchema = /* @__PURE__ */ object({
|
|
915
1025
|
borderType: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
|
|
916
1026
|
fallback: borderType.None
|
|
917
1027
|
}),
|
|
918
|
-
borderWidth: layerField(/* @__PURE__ */
|
|
1028
|
+
borderWidth: layerField(/* @__PURE__ */ string(), {
|
|
1029
|
+
fallback: "1px",
|
|
1030
|
+
transform: (value) => {
|
|
1031
|
+
if (typeof value === "number") {
|
|
1032
|
+
return `${value}px`;
|
|
1033
|
+
}
|
|
1034
|
+
return value;
|
|
1035
|
+
}
|
|
1036
|
+
}),
|
|
919
1037
|
borderColor: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
|
|
920
1038
|
});
|
|
921
1039
|
const SizeSchema = /* @__PURE__ */ object({
|
|
@@ -925,9 +1043,43 @@ const SizeSchema = /* @__PURE__ */ object({
|
|
|
925
1043
|
heightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
926
1044
|
fallback: sizing.Fixed
|
|
927
1045
|
}),
|
|
928
|
-
width: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
|
|
929
|
-
|
|
930
|
-
|
|
1046
|
+
width: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
|
|
1047
|
+
fallback: 0,
|
|
1048
|
+
transform: Math.ceil
|
|
1049
|
+
}),
|
|
1050
|
+
height: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
|
|
1051
|
+
fallback: 0,
|
|
1052
|
+
transform: Math.ceil
|
|
1053
|
+
}),
|
|
1054
|
+
aspectRatio: layerField(/* @__PURE__ */ number(), { fallback: -1 }),
|
|
1055
|
+
minWidth: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1056
|
+
fallback: -1,
|
|
1057
|
+
transform: Math.ceil
|
|
1058
|
+
}),
|
|
1059
|
+
minWidthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1060
|
+
fallback: sizing.Fixed
|
|
1061
|
+
}),
|
|
1062
|
+
maxWidth: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1063
|
+
fallback: -1,
|
|
1064
|
+
transform: Math.ceil
|
|
1065
|
+
}),
|
|
1066
|
+
maxWidthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1067
|
+
fallback: sizing.Fixed
|
|
1068
|
+
}),
|
|
1069
|
+
minHeight: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1070
|
+
fallback: -1,
|
|
1071
|
+
transform: Math.ceil
|
|
1072
|
+
}),
|
|
1073
|
+
minHeightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1074
|
+
fallback: sizing.Fixed
|
|
1075
|
+
}),
|
|
1076
|
+
maxHeight: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(-1))), {
|
|
1077
|
+
fallback: -1,
|
|
1078
|
+
transform: Math.ceil
|
|
1079
|
+
}),
|
|
1080
|
+
maxHeightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
|
|
1081
|
+
fallback: sizing.Fixed
|
|
1082
|
+
})
|
|
931
1083
|
});
|
|
932
1084
|
const LayerSchema = /* @__PURE__ */ object({
|
|
933
1085
|
layerMode: layerField(/* @__PURE__ */ picklist(Object.keys(layerMode)), {
|
|
@@ -946,6 +1098,33 @@ const LayerSchema = /* @__PURE__ */ object({
|
|
|
946
1098
|
layerGap: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
|
|
947
1099
|
padding: layerField(/* @__PURE__ */ string(), { fallback: "0px" })
|
|
948
1100
|
});
|
|
1101
|
+
const OverflowSchema = layerField(/* @__PURE__ */ picklist(Object.keys(overflow)), {
|
|
1102
|
+
fallback: overflow.hidden
|
|
1103
|
+
});
|
|
1104
|
+
const BorderRadiusSchema = layerField(/* @__PURE__ */ string(), { fallback: "0px" });
|
|
1105
|
+
const InteractionsSchema = /* @__PURE__ */ object({
|
|
1106
|
+
interactions: layerField(
|
|
1107
|
+
/* @__PURE__ */ array(
|
|
1108
|
+
/* @__PURE__ */ object({
|
|
1109
|
+
on: /* @__PURE__ */ enum_(Object.keys(interactions)),
|
|
1110
|
+
event: /* @__PURE__ */ nullable(linkValidator)
|
|
1111
|
+
})
|
|
1112
|
+
),
|
|
1113
|
+
{ fallback: [] }
|
|
1114
|
+
)
|
|
1115
|
+
});
|
|
1116
|
+
const CssOverrideSchema = /* @__PURE__ */ object({
|
|
1117
|
+
cssOverride: layerField(/* @__PURE__ */ string(), { fallback: "" })
|
|
1118
|
+
});
|
|
1119
|
+
const LinkSchema = /* @__PURE__ */ object({
|
|
1120
|
+
href: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1121
|
+
hrefNewTab: layerField(/* @__PURE__ */ boolean(), {
|
|
1122
|
+
fallback: true
|
|
1123
|
+
})
|
|
1124
|
+
// hrefTarget: layerField(v.picklist(Object.keys(linkTarget)), {
|
|
1125
|
+
// fallback: linkTarget._blank,
|
|
1126
|
+
// }),
|
|
1127
|
+
});
|
|
949
1128
|
const FrameSchema = /* @__PURE__ */ pipe(
|
|
950
1129
|
/* @__PURE__ */ object({
|
|
951
1130
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Frame", overridable: false }),
|
|
@@ -954,10 +1133,7 @@ const FrameSchema = /* @__PURE__ */ pipe(
|
|
|
954
1133
|
overridable: false
|
|
955
1134
|
}),
|
|
956
1135
|
isPrimary: layerField(/* @__PURE__ */ boolean(), { fallback: false, overridable: false }),
|
|
957
|
-
|
|
958
|
-
fallback: 320,
|
|
959
|
-
overridable: false
|
|
960
|
-
}),
|
|
1136
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
961
1137
|
...ChildrenSchema.entries,
|
|
962
1138
|
...GraphFieldSchema.entries,
|
|
963
1139
|
...OverridesSchema.entries,
|
|
@@ -966,7 +1142,12 @@ const FrameSchema = /* @__PURE__ */ pipe(
|
|
|
966
1142
|
...FillSchema.entries,
|
|
967
1143
|
...BorderSchema.entries,
|
|
968
1144
|
...SizeSchema.entries,
|
|
969
|
-
...LayerSchema.entries
|
|
1145
|
+
...LayerSchema.entries,
|
|
1146
|
+
...InteractionsSchema.entries,
|
|
1147
|
+
...CssOverrideSchema.entries,
|
|
1148
|
+
...LinkSchema.entries,
|
|
1149
|
+
overflow: OverflowSchema,
|
|
1150
|
+
borderRadius: BorderRadiusSchema
|
|
970
1151
|
})
|
|
971
1152
|
);
|
|
972
1153
|
const TextSchema = /* @__PURE__ */ object({
|
|
@@ -974,25 +1155,25 @@ const TextSchema = /* @__PURE__ */ object({
|
|
|
974
1155
|
content: layerField(/* @__PURE__ */ string(), {
|
|
975
1156
|
fallback: ""
|
|
976
1157
|
}),
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" })
|
|
983
|
-
}),
|
|
984
|
-
{ fallback: {} }
|
|
985
|
-
),
|
|
1158
|
+
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
1159
|
+
fallback: whiteSpace.pre
|
|
1160
|
+
}),
|
|
1161
|
+
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
1162
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
986
1163
|
...GraphFieldSchema.entries,
|
|
987
1164
|
...OverridesSchema.entries,
|
|
1165
|
+
...CssOverrideSchema.entries,
|
|
988
1166
|
...PositionSchema.entries,
|
|
989
1167
|
...SceneSchema.entries,
|
|
990
|
-
...SizeSchema.entries
|
|
1168
|
+
...SizeSchema.entries,
|
|
1169
|
+
...InteractionsSchema.entries,
|
|
1170
|
+
...LinkSchema.entries
|
|
991
1171
|
});
|
|
992
1172
|
const FragmentSchema = /* @__PURE__ */ object({
|
|
993
1173
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
|
|
1174
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
994
1175
|
horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
|
|
995
|
-
fallback: fragmentGrowingMode.
|
|
1176
|
+
fallback: fragmentGrowingMode.fill,
|
|
996
1177
|
overridable: false
|
|
997
1178
|
}),
|
|
998
1179
|
verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
|
|
@@ -1008,9 +1189,22 @@ const FragmentSchema = /* @__PURE__ */ object({
|
|
|
1008
1189
|
});
|
|
1009
1190
|
const InstanceSchema = /* @__PURE__ */ object({
|
|
1010
1191
|
name: layerField(/* @__PURE__ */ string(), { fallback: "Instance", overridable: false }),
|
|
1011
|
-
fragment: layerField(/* @__PURE__ */
|
|
1192
|
+
fragment: layerField(/* @__PURE__ */ number()),
|
|
1193
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1012
1194
|
props: layerField(
|
|
1013
|
-
/* @__PURE__ */ record(
|
|
1195
|
+
/* @__PURE__ */ record(
|
|
1196
|
+
/* @__PURE__ */ string(),
|
|
1197
|
+
/* @__PURE__ */ union([
|
|
1198
|
+
/* @__PURE__ */ string(),
|
|
1199
|
+
/* @__PURE__ */ number(),
|
|
1200
|
+
/* @__PURE__ */ boolean(),
|
|
1201
|
+
// For goals
|
|
1202
|
+
/* @__PURE__ */ object({
|
|
1203
|
+
code: /* @__PURE__ */ string(),
|
|
1204
|
+
name: /* @__PURE__ */ string()
|
|
1205
|
+
})
|
|
1206
|
+
])
|
|
1207
|
+
),
|
|
1014
1208
|
{
|
|
1015
1209
|
fallback: {}
|
|
1016
1210
|
}
|
|
@@ -1019,13 +1213,17 @@ const InstanceSchema = /* @__PURE__ */ object({
|
|
|
1019
1213
|
...OverridesSchema.entries,
|
|
1020
1214
|
...PositionSchema.entries,
|
|
1021
1215
|
...SizeSchema.entries,
|
|
1022
|
-
...SceneSchema.entries
|
|
1216
|
+
...SceneSchema.entries,
|
|
1217
|
+
...InteractionsSchema.entries,
|
|
1218
|
+
...LinkSchema.entries
|
|
1023
1219
|
});
|
|
1024
1220
|
const NumberVariableSchema = /* @__PURE__ */ object({
|
|
1221
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1025
1222
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1026
1223
|
fallback: "Number",
|
|
1027
1224
|
overridable: false
|
|
1028
1225
|
}),
|
|
1226
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1029
1227
|
type: layerField(/* @__PURE__ */ literal(variableType.Number), {
|
|
1030
1228
|
fallback: variableType.Number
|
|
1031
1229
|
}),
|
|
@@ -1038,10 +1236,12 @@ const NumberVariableSchema = /* @__PURE__ */ object({
|
|
|
1038
1236
|
...GraphFieldSchema.entries
|
|
1039
1237
|
});
|
|
1040
1238
|
const BooleanVariableSchema = /* @__PURE__ */ object({
|
|
1239
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1041
1240
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1042
1241
|
fallback: "Boolean",
|
|
1043
1242
|
overridable: false
|
|
1044
1243
|
}),
|
|
1244
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1045
1245
|
type: layerField(/* @__PURE__ */ literal(variableType.Boolean), {
|
|
1046
1246
|
fallback: variableType.Boolean
|
|
1047
1247
|
}),
|
|
@@ -1050,10 +1250,12 @@ const BooleanVariableSchema = /* @__PURE__ */ object({
|
|
|
1050
1250
|
...GraphFieldSchema.entries
|
|
1051
1251
|
});
|
|
1052
1252
|
const ColorVariableSchema = /* @__PURE__ */ object({
|
|
1253
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1053
1254
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1054
1255
|
fallback: "String",
|
|
1055
1256
|
overridable: false
|
|
1056
1257
|
}),
|
|
1258
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1057
1259
|
type: layerField(/* @__PURE__ */ literal(variableType.Color), {
|
|
1058
1260
|
fallback: variableType.Color
|
|
1059
1261
|
}),
|
|
@@ -1063,6 +1265,7 @@ const ColorVariableSchema = /* @__PURE__ */ object({
|
|
|
1063
1265
|
...GraphFieldSchema.entries
|
|
1064
1266
|
});
|
|
1065
1267
|
const StringVariableSchema = /* @__PURE__ */ object({
|
|
1268
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1066
1269
|
name: layerField(/* @__PURE__ */ string(), {
|
|
1067
1270
|
fallback: "String",
|
|
1068
1271
|
overridable: false
|
|
@@ -1070,33 +1273,165 @@ const StringVariableSchema = /* @__PURE__ */ object({
|
|
|
1070
1273
|
type: layerField(/* @__PURE__ */ literal(variableType.String), {
|
|
1071
1274
|
fallback: variableType.String
|
|
1072
1275
|
}),
|
|
1276
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1073
1277
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1074
1278
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1075
1279
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1076
1280
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1077
1281
|
...GraphFieldSchema.entries
|
|
1078
1282
|
});
|
|
1283
|
+
const EventVariableSchema = /* @__PURE__ */ object({
|
|
1284
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1285
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1286
|
+
fallback: "Event",
|
|
1287
|
+
overridable: false
|
|
1288
|
+
}),
|
|
1289
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1290
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Event), {
|
|
1291
|
+
fallback: variableType.Event
|
|
1292
|
+
}),
|
|
1293
|
+
mode: layerField(/* @__PURE__ */ picklist(Object.keys(eventMode)), {
|
|
1294
|
+
fallback: eventMode.callback
|
|
1295
|
+
}),
|
|
1296
|
+
defaultValue: layerField(/* @__PURE__ */ any()),
|
|
1297
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1298
|
+
...GraphFieldSchema.entries
|
|
1299
|
+
});
|
|
1300
|
+
const LinkVariableSchema = /* @__PURE__ */ object({
|
|
1301
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1302
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1303
|
+
fallback: "Link",
|
|
1304
|
+
overridable: false
|
|
1305
|
+
}),
|
|
1306
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1307
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Link), {
|
|
1308
|
+
fallback: variableType.Link
|
|
1309
|
+
}),
|
|
1310
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1311
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1312
|
+
...GraphFieldSchema.entries
|
|
1313
|
+
});
|
|
1314
|
+
const EnumVariableSchema = /* @__PURE__ */ object({
|
|
1315
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1316
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1317
|
+
fallback: "Option",
|
|
1318
|
+
overridable: false
|
|
1319
|
+
}),
|
|
1320
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1321
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Enum), {
|
|
1322
|
+
fallback: variableType.Enum
|
|
1323
|
+
}),
|
|
1324
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1325
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1326
|
+
cases: layerField(
|
|
1327
|
+
/* @__PURE__ */ array(
|
|
1328
|
+
/* @__PURE__ */ object({
|
|
1329
|
+
id: /* @__PURE__ */ string(),
|
|
1330
|
+
name: /* @__PURE__ */ string()
|
|
1331
|
+
})
|
|
1332
|
+
),
|
|
1333
|
+
{ fallback: [] }
|
|
1334
|
+
),
|
|
1335
|
+
...GraphFieldSchema.entries
|
|
1336
|
+
});
|
|
1337
|
+
const ObjectVariableSchema = /* @__PURE__ */ object({
|
|
1338
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1339
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1340
|
+
fallback: "Object",
|
|
1341
|
+
overridable: false
|
|
1342
|
+
}),
|
|
1343
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Object), {
|
|
1344
|
+
fallback: variableType.Object
|
|
1345
|
+
}),
|
|
1346
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1347
|
+
defaultValue: layerField(/* @__PURE__ */ object({}), { fallback: {} }),
|
|
1348
|
+
fields: layerField(/* @__PURE__ */ record(/* @__PURE__ */ string(), linkValidator), { fallback: {} }),
|
|
1349
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1350
|
+
...GraphFieldSchema.entries
|
|
1351
|
+
});
|
|
1352
|
+
const ImageVariableSchema = /* @__PURE__ */ object({
|
|
1353
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1354
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1355
|
+
fallback: "Image",
|
|
1356
|
+
overridable: false
|
|
1357
|
+
}),
|
|
1358
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Image), {
|
|
1359
|
+
fallback: variableType.Image
|
|
1360
|
+
}),
|
|
1361
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1362
|
+
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1363
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1364
|
+
imageSize: layerField(/* @__PURE__ */ picklist(Object.keys(imagePaintScaleModes)), {
|
|
1365
|
+
fallback: imagePaintScaleModes.Auto
|
|
1366
|
+
}),
|
|
1367
|
+
...GraphFieldSchema.entries
|
|
1368
|
+
});
|
|
1369
|
+
const CollectionSchema = /* @__PURE__ */ pipe(
|
|
1370
|
+
/* @__PURE__ */ object({
|
|
1371
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1372
|
+
fallback: "Collection",
|
|
1373
|
+
overridable: false
|
|
1374
|
+
}),
|
|
1375
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1376
|
+
source: layerField(linkValidator, {}),
|
|
1377
|
+
...ChildrenSchema.entries,
|
|
1378
|
+
...GraphFieldSchema.entries,
|
|
1379
|
+
...OverridesSchema.entries,
|
|
1380
|
+
...PositionSchema.entries,
|
|
1381
|
+
...SceneSchema.entries,
|
|
1382
|
+
...FillSchema.entries,
|
|
1383
|
+
...BorderSchema.entries,
|
|
1384
|
+
...SizeSchema.entries,
|
|
1385
|
+
...LayerSchema.entries,
|
|
1386
|
+
...InteractionsSchema.entries,
|
|
1387
|
+
...CssOverrideSchema.entries,
|
|
1388
|
+
...LinkSchema.entries
|
|
1389
|
+
})
|
|
1390
|
+
);
|
|
1391
|
+
const ArrayVariableSchema = /* @__PURE__ */ object({
|
|
1392
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1393
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1394
|
+
fallback: "Collection",
|
|
1395
|
+
overridable: false
|
|
1396
|
+
}),
|
|
1397
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Array), {
|
|
1398
|
+
fallback: variableType.Array
|
|
1399
|
+
}),
|
|
1400
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1401
|
+
defaultValue: layerField(/* @__PURE__ */ array(/* @__PURE__ */ any()), { fallback: [] }),
|
|
1402
|
+
definition: layerField(linkValidator, { fallback: null }),
|
|
1403
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1404
|
+
...GraphFieldSchema.entries
|
|
1405
|
+
});
|
|
1079
1406
|
const getLayerSchema = (layer) => {
|
|
1080
1407
|
if (!(layer == null ? void 0 : layer._type)) return null;
|
|
1081
1408
|
if ((layer == null ? void 0 : layer._type) === nodes.Frame) return FrameSchema;
|
|
1082
1409
|
if ((layer == null ? void 0 : layer._type) === nodes.Text) return TextSchema;
|
|
1083
1410
|
if ((layer == null ? void 0 : layer._type) === nodes.Fragment) return FragmentSchema;
|
|
1084
1411
|
if ((layer == null ? void 0 : layer._type) === nodes.Instance) return InstanceSchema;
|
|
1412
|
+
if ((layer == null ? void 0 : layer._type) === nodes.Collection) return CollectionSchema;
|
|
1085
1413
|
if (layer._type === nodes.Variable) {
|
|
1086
1414
|
const types = {
|
|
1087
1415
|
[variableType.Number]: NumberVariableSchema,
|
|
1088
1416
|
[variableType.Boolean]: BooleanVariableSchema,
|
|
1089
1417
|
[variableType.String]: StringVariableSchema,
|
|
1090
|
-
[variableType.Color]: ColorVariableSchema
|
|
1418
|
+
[variableType.Color]: ColorVariableSchema,
|
|
1419
|
+
[variableType.Event]: EventVariableSchema,
|
|
1420
|
+
[variableType.Link]: LinkVariableSchema,
|
|
1421
|
+
[variableType.Enum]: EnumVariableSchema,
|
|
1422
|
+
[variableType.Object]: ObjectVariableSchema,
|
|
1423
|
+
[variableType.Image]: ImageVariableSchema,
|
|
1424
|
+
[variableType.Array]: ArrayVariableSchema
|
|
1091
1425
|
};
|
|
1092
1426
|
if (layer.type in types) {
|
|
1093
1427
|
return types[layer.type];
|
|
1094
1428
|
}
|
|
1095
1429
|
}
|
|
1096
1430
|
};
|
|
1431
|
+
const isObject = (x) => !!x && typeof x === "object" && !Array.isArray(x);
|
|
1097
1432
|
const normalizeLayer = (schema, rawLayer, options) => {
|
|
1098
1433
|
try {
|
|
1099
|
-
if (!rawLayer) return null;
|
|
1434
|
+
if (!rawLayer || !schema.entries) return null;
|
|
1100
1435
|
const withFallback = (options == null ? void 0 : options.withFallback) ?? true;
|
|
1101
1436
|
const overrideTarget = options == null ? void 0 : options.overrideTarget;
|
|
1102
1437
|
const parsedLayer = parse(schema, rawLayer);
|
|
@@ -1105,7 +1440,19 @@ const normalizeLayer = (schema, rawLayer, options) => {
|
|
|
1105
1440
|
const schemaMeta = getMetadata(schemaEntity);
|
|
1106
1441
|
const fallback = withFallback ? schemaMeta == null ? void 0 : schemaMeta.fallback : null;
|
|
1107
1442
|
const overrideValue = (schemaMeta == null ? void 0 : schemaMeta.overridable) !== false && overrideTarget ? overrideTarget == null ? void 0 : overrideTarget[key] : null;
|
|
1108
|
-
|
|
1443
|
+
let layerValue = parsedLayer[key];
|
|
1444
|
+
if (isObject(layerValue) && isObject(overrideValue)) {
|
|
1445
|
+
layerValue = { ...overrideValue, ...layerValue };
|
|
1446
|
+
}
|
|
1447
|
+
if (schemaEntity && "wrapped" in schemaEntity && "entries" in schemaEntity.wrapped && isObject(schemaEntity.wrapped.entries)) {
|
|
1448
|
+
layerValue = normalizeLayer(
|
|
1449
|
+
schemaEntity.wrapped,
|
|
1450
|
+
layerValue,
|
|
1451
|
+
options
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
const resultValue = layerValue ?? overrideValue ?? fallback;
|
|
1455
|
+
return [key, resultValue];
|
|
1109
1456
|
})
|
|
1110
1457
|
);
|
|
1111
1458
|
} catch (e) {
|
|
@@ -1113,23 +1460,40 @@ const normalizeLayer = (schema, rawLayer, options) => {
|
|
|
1113
1460
|
return null;
|
|
1114
1461
|
}
|
|
1115
1462
|
};
|
|
1116
|
-
const getNormalizeLayer = (layer, overrider) => {
|
|
1463
|
+
const getNormalizeLayer = (layer, overrider, withFallback) => {
|
|
1117
1464
|
if (!layer) return null;
|
|
1118
1465
|
const schema = getLayerSchema(layer);
|
|
1119
1466
|
if (!schema) return null;
|
|
1120
1467
|
return normalizeLayer(schema, layer, {
|
|
1121
|
-
overrideTarget: overrider
|
|
1468
|
+
overrideTarget: overrider,
|
|
1469
|
+
withFallback
|
|
1122
1470
|
});
|
|
1123
1471
|
};
|
|
1124
|
-
|
|
1125
|
-
|
|
1472
|
+
function findSchemaByPath(schema, path) {
|
|
1473
|
+
if (!path) return void 0;
|
|
1474
|
+
const parts = path.split(".");
|
|
1475
|
+
let current = schema;
|
|
1476
|
+
for (const part of parts) {
|
|
1477
|
+
if (!current || typeof current !== "object") return void 0;
|
|
1478
|
+
if ("entries" in current) {
|
|
1479
|
+
if (!(part in current.entries)) return void 0;
|
|
1480
|
+
current = current.entries[part];
|
|
1481
|
+
} else if ("wrapped" in current && "entries" in current.wrapped) {
|
|
1482
|
+
current = current.wrapped.entries[part];
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
return current;
|
|
1486
|
+
}
|
|
1487
|
+
const parseLayerField = (layer, field, value) => {
|
|
1126
1488
|
const schema = getLayerSchema(layer);
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
return
|
|
1489
|
+
const fieldSchema = findSchemaByPath(schema, field);
|
|
1490
|
+
if (fieldSchema) {
|
|
1491
|
+
return /* @__PURE__ */ safeParse(fieldSchema, value);
|
|
1130
1492
|
}
|
|
1131
|
-
return false;
|
|
1493
|
+
return { success: false, output: value };
|
|
1132
1494
|
};
|
|
1133
1495
|
exports.definition = index;
|
|
1134
1496
|
exports.getNormalizeLayer = getNormalizeLayer;
|
|
1135
|
-
exports.
|
|
1497
|
+
exports.isLink = isLink;
|
|
1498
|
+
exports.isVariableLink = isVariableLink;
|
|
1499
|
+
exports.parseLayerField = parseLayerField;
|