@supernova-studio/model 0.35.0 → 0.36.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/index.mjs CHANGED
@@ -1060,8 +1060,8 @@ var PageBlockItemSingleSelectValue = z35.object({
1060
1060
  var PageBlockItemStorybookValue = z35.object({
1061
1061
  caption: z35.string().optional(),
1062
1062
  height: z35.number().optional(),
1063
- showAddons: z35.boolean().optional(),
1064
- value: z35.string()
1063
+ embedUrl: z35.string().optional(),
1064
+ value: z35.string().optional()
1065
1065
  });
1066
1066
  var PageBlockItemTextValue = z35.object({
1067
1067
  value: z35.string()
@@ -1824,6 +1824,72 @@ var Theme = DesignElementBase.extend(DesignElementBrandedPart.shape).extend({
1824
1824
  overrides: z76.array(ThemeOverride)
1825
1825
  });
1826
1826
 
1827
+ // src/dsm/elements/utils.ts
1828
+ function mapPageBlockItemValuesV2(pageItems, definitionsMap, fn) {
1829
+ traversePageBlockItemsV2(pageItems, (block, item) => {
1830
+ Object.entries(item.props).forEach(([propKey, value]) => {
1831
+ const property = definitionsMap.getDefinitionProperty(block.data.packageId, propKey);
1832
+ if (!property)
1833
+ return;
1834
+ item.props[propKey] = fn(block, item, property, value);
1835
+ });
1836
+ });
1837
+ }
1838
+ function traversePageBlockItemValuesV2(pageItems, definitionsMap, fn) {
1839
+ traversePageBlockItemsV2(pageItems, (block, item) => {
1840
+ Object.entries(item.props).forEach(([propKey, value]) => {
1841
+ const property = definitionsMap.getDefinitionProperty(block.data.packageId, propKey);
1842
+ if (!property)
1843
+ return;
1844
+ fn(block, item, property, value);
1845
+ });
1846
+ });
1847
+ }
1848
+ function traversePageBlockItemsV2(pageItems, fn) {
1849
+ traversePageItemsV2(pageItems, (block) => {
1850
+ block.data.items.forEach((item) => {
1851
+ fn(block, item);
1852
+ });
1853
+ });
1854
+ }
1855
+ function traversePageItemsV2(pageItems, fn) {
1856
+ for (const item of pageItems) {
1857
+ switch (item.type) {
1858
+ case "Block":
1859
+ fn(item);
1860
+ break;
1861
+ case "Section":
1862
+ item.items.forEach((i) => {
1863
+ i.columns.forEach((c) => {
1864
+ traversePageItemsV2(c.blocks, fn);
1865
+ });
1866
+ });
1867
+ break;
1868
+ }
1869
+ }
1870
+ }
1871
+ var PageBlockDefinitionsMap = class {
1872
+ constructor(definitions) {
1873
+ this.definitionsMap = /* @__PURE__ */ new Map();
1874
+ this.propertiesMap = /* @__PURE__ */ new Map();
1875
+ definitions.forEach((d) => {
1876
+ this.definitionsMap.set(d.id, d);
1877
+ d.item.properties.forEach((p) => {
1878
+ this.propertiesMap.set(this.propertyKey(d.id, p.id), p);
1879
+ });
1880
+ });
1881
+ }
1882
+ getDefinition(id) {
1883
+ return this.definitionsMap.get(id);
1884
+ }
1885
+ getDefinitionProperty(defId, propId) {
1886
+ return this.propertiesMap.get(this.propertyKey(defId, propId));
1887
+ }
1888
+ propertyKey(defId, propId) {
1889
+ return `${defId}.${propId}`;
1890
+ }
1891
+ };
1892
+
1827
1893
  // src/dsm/import/support/figma-files.ts
1828
1894
  import { z as z77 } from "zod";
1829
1895
  var FigmaFileDownloadScope = z77.object({
@@ -4281,6 +4347,7 @@ export {
4281
4347
  PageBlockDefinitionTextPropertyStyle,
4282
4348
  PageBlockDefinitionUntypedPropertyOptions,
4283
4349
  PageBlockDefinitionVariant,
4350
+ PageBlockDefinitionsMap,
4284
4351
  PageBlockEditorModelV2,
4285
4352
  PageBlockFigmaFrameProperties,
4286
4353
  PageBlockFigmaNodeEntityMeta,
@@ -4489,6 +4556,7 @@ export {
4489
4556
  isSlugReserved,
4490
4557
  isTokenType,
4491
4558
  mapByUnique,
4559
+ mapPageBlockItemValuesV2,
4492
4560
  nonNullFilter,
4493
4561
  nonNullishFilter,
4494
4562
  nullishToOptional,
@@ -4500,7 +4568,10 @@ export {
4500
4568
  slugify,
4501
4569
  tokenAliasOrValue,
4502
4570
  tokenElementTypes,
4571
+ traversePageBlockItemValuesV2,
4572
+ traversePageBlockItemsV2,
4503
4573
  traversePageBlocksV1,
4574
+ traversePageItemsV2,
4504
4575
  traverseStructure,
4505
4576
  trimLeadingSlash,
4506
4577
  trimTrailingSlash,