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