@makeswift/runtime 0.5.5 → 0.6.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 (129) hide show
  1. package/dist/Box.cjs.js +11 -6
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +12 -7
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +2 -1
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +2 -1
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +2 -1
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +2 -1
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +2 -1
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +2 -1
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +2 -1
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +2 -1
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/EditableText.cjs.js +359 -0
  22. package/dist/EditableText.cjs.js.map +1 -0
  23. package/dist/EditableText.es.js +352 -0
  24. package/dist/EditableText.es.js.map +1 -0
  25. package/dist/Embed.cjs.js +2 -1
  26. package/dist/Embed.cjs.js.map +1 -1
  27. package/dist/Embed.es.js +2 -1
  28. package/dist/Embed.es.js.map +1 -1
  29. package/dist/Form.cjs.js +2 -1
  30. package/dist/Form.cjs.js.map +1 -1
  31. package/dist/Form.es.js +2 -1
  32. package/dist/Form.es.js.map +1 -1
  33. package/dist/Image.cjs.js +2 -1
  34. package/dist/Image.cjs.js.map +1 -1
  35. package/dist/Image.es.js +2 -1
  36. package/dist/Image.es.js.map +1 -1
  37. package/dist/LiveProvider.cjs.js +3 -11
  38. package/dist/LiveProvider.cjs.js.map +1 -1
  39. package/dist/LiveProvider.es.js +6 -14
  40. package/dist/LiveProvider.es.js.map +1 -1
  41. package/dist/Navigation.cjs.js +2 -1
  42. package/dist/Navigation.cjs.js.map +1 -1
  43. package/dist/Navigation.es.js +2 -1
  44. package/dist/Navigation.es.js.map +1 -1
  45. package/dist/PreviewProvider.cjs.js +6 -3
  46. package/dist/PreviewProvider.cjs.js.map +1 -1
  47. package/dist/PreviewProvider.es.js +8 -5
  48. package/dist/PreviewProvider.es.js.map +1 -1
  49. package/dist/ReadOnlyText.cjs.js +206 -0
  50. package/dist/ReadOnlyText.cjs.js.map +1 -0
  51. package/dist/ReadOnlyText.es.js +204 -0
  52. package/dist/ReadOnlyText.es.js.map +1 -0
  53. package/dist/Root.cjs.js +4 -3
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +3 -2
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +2 -1
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +2 -1
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Text.cjs.js +26 -405
  62. package/dist/Text.cjs.js.map +1 -1
  63. package/dist/Text.es.js +23 -405
  64. package/dist/Text.es.js.map +1 -1
  65. package/dist/Video.cjs.js +2 -1
  66. package/dist/Video.cjs.js.map +1 -1
  67. package/dist/Video.es.js +2 -1
  68. package/dist/Video.es.js.map +1 -1
  69. package/dist/actions.cjs.js.map +1 -1
  70. package/dist/actions.es.js.map +1 -1
  71. package/dist/components.cjs.js +2 -5
  72. package/dist/components.cjs.js.map +1 -1
  73. package/dist/components.es.js +2 -5
  74. package/dist/components.es.js.map +1 -1
  75. package/dist/constants.cjs.js +45 -26
  76. package/dist/constants.cjs.js.map +1 -1
  77. package/dist/constants.es.js +36 -20
  78. package/dist/constants.es.js.map +1 -1
  79. package/dist/index.cjs.js +78 -310
  80. package/dist/index.cjs.js.map +1 -1
  81. package/dist/index.cjs2.js +20 -21
  82. package/dist/index.cjs2.js.map +1 -1
  83. package/dist/index.cjs5.js +141 -0
  84. package/dist/index.cjs5.js.map +1 -0
  85. package/dist/index.es.js +77 -308
  86. package/dist/index.es.js.map +1 -1
  87. package/dist/index.es2.js +23 -24
  88. package/dist/index.es2.js.map +1 -1
  89. package/dist/index.es3.js +1 -1
  90. package/dist/index.es5.js +139 -0
  91. package/dist/index.es5.js.map +1 -0
  92. package/dist/next.cjs.js +2 -1
  93. package/dist/next.cjs.js.map +1 -1
  94. package/dist/next.es.js +3 -2
  95. package/dist/next.es.js.map +1 -1
  96. package/dist/react.cjs.js +2 -1
  97. package/dist/react.cjs.js.map +1 -1
  98. package/dist/react.es.js +2 -1
  99. package/dist/react.es.js.map +1 -1
  100. package/dist/types/src/api/react.d.ts.map +1 -1
  101. package/dist/types/src/components/builtin/Box/Box.d.ts.map +1 -1
  102. package/dist/types/src/components/builtin/Box/animations.d.ts +1 -1
  103. package/dist/types/src/components/builtin/Box/animations.d.ts.map +1 -1
  104. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  105. package/dist/types/src/components/builtin/Text/EditableText.d.ts +16 -0
  106. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +1 -0
  107. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +11 -0
  108. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -0
  109. package/dist/types/src/components/builtin/Text/Text.d.ts +3 -7
  110. package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
  111. package/dist/types/src/components/builtin/register.d.ts.map +1 -1
  112. package/dist/types/src/components/shared/BackgroundsContainer/index.d.ts.map +1 -1
  113. package/dist/types/src/next/document.d.ts.map +1 -1
  114. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -1
  115. package/dist/types/src/runtimes/react/element-imperative-handle.d.ts +12 -0
  116. package/dist/types/src/runtimes/react/element-imperative-handle.d.ts.map +1 -0
  117. package/dist/types/src/runtimes/react/find-dom-node.d.ts +1 -1
  118. package/dist/types/src/runtimes/react/find-dom-node.d.ts.map +1 -1
  119. package/dist/types/src/runtimes/react/index.d.ts +4 -2
  120. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  121. package/dist/types/src/state/actions.d.ts +4 -3
  122. package/dist/types/src/state/actions.d.ts.map +1 -1
  123. package/dist/types/src/state/modules/is-preview.d.ts +6 -0
  124. package/dist/types/src/state/modules/is-preview.d.ts.map +1 -0
  125. package/dist/types/src/state/react-builder-preview.d.ts +1 -0
  126. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  127. package/dist/types/src/state/react-page.d.ts +2 -0
  128. package/dist/types/src/state/react-page.d.ts.map +1 -1
  129. package/package.json +4 -1
package/dist/index.es.js CHANGED
@@ -36,25 +36,26 @@ var __publicField = (obj, key, value) => {
36
36
  };
37
37
  var _c;
38
38
  import * as React from "react";
39
- import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useCallback, Component, useImperativeHandle, Suspense } from "react";
39
+ import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useCallback, useImperativeHandle, Component, Suspense } from "react";
40
40
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
41
41
  import dynamic from "next/dynamic";
42
- import { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, M as MakeswiftComponentType, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, v as getReactComponent } from "./constants.es.js";
42
+ import { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, M as MakeswiftComponentType, k as getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as isPropControllersHandle, r as configureStore$1, s as getDocument, t as getElementId, u as getIsInBuilder, v as getIsPreview, w as copyElementTree, x as getReactComponent } from "./constants.es.js";
43
43
  import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as registerComponentHandleEffect, j as mountComponentEffect, k as registerComponentEffect, l as registerReactComponentEffect } from "./actions.es.js";
44
44
  import { cache, cx } from "@emotion/css";
45
+ import { serializeStyles } from "@emotion/serialize";
46
+ import { registerStyles, insertStyles } from "@emotion/utils";
45
47
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
46
48
  import { T as Types, E as ElementID, B as Backgrounds, W as Width, h as ResponsiveIconRadioGroup, M as Margin, P as Padding, i as Border, j as BorderRadius, k as Shadows, G as GapY, l as GapX, m as ResponsiveSelect, n as ResponsiveNumber, o as Checkbox, p as Grid, q as TextInput, L as Link, r as ResponsiveColor, s as TextStyle, t as Images, N as Number$1, D as Date$1, F as Font, u as ResponsiveLength, v as TextArea, w as Table, x as TableFormFields, y as Image, z as ResponsiveOpacity, A as NavigationLinks, H as SocialLinks, J as RichText, V as Video, K as StyleControlProperty, O as ImageControlValueFormat, I as ImageControlType, C as ColorControlType, Q as BorderPropControllerFormat, U as ShadowsPropControllerFormat, X as BorderRadiusPropControllerFormat, Y as MarginPropControllerFormat, Z as PaddingPropControllerFormat, _ as WidthPropControllerFormat, S as SlotControlType, a as StyleControlType } from "./slot.es.js";
47
49
  import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
48
50
  import { C as ComboboxControlType } from "./combobox.es.js";
49
51
  import { S as ShapeControlType, L as ListControlType, b as LinkControlType } from "./control.es.js";
50
52
  import { useSyncExternalStore } from "use-sync-external-store/shim";
51
- import { KeyUtils } from "slate";
52
53
  import { createStore, applyMiddleware } from "redux";
53
54
  import thunk from "redux-thunk";
54
55
  import { A as APIResourceType } from "./types.es.js";
55
56
  import ColorHelper from "color";
56
57
  import scrollIntoView from "scroll-into-view-if-needed";
57
- import { g as getBox } from "./box-models.es.js";
58
+ import { g as getBox, i as isMeasurable, m as measure } from "./box-models.es.js";
58
59
  import { findDOMNode } from "react-dom";
59
60
  import parse from "html-react-parser";
60
61
  import Head from "next/head";
@@ -621,7 +622,6 @@ class MakeswiftClient {
621
622
  async prefetch(element) {
622
623
  const introspectionData = await introspect(element, this, storeContextDefaultValue);
623
624
  await this.makeswiftApiClient.dispatch(fetchIntrospectedResources(introspectionData));
624
- KeyUtils.resetGenerator();
625
625
  return getSerializedState(this.makeswiftApiClient.getState());
626
626
  }
627
627
  readSwatch(swatchId) {
@@ -1015,7 +1015,6 @@ if (originalUrl.searchParams.has(searchParamName)) {
1015
1015
  class Document$1 extends NextDocument {
1016
1016
  static async getInitialProps(ctx) {
1017
1017
  const initialProps = await NextDocument.getInitialProps(ctx);
1018
- KeyUtils.resetGenerator();
1019
1018
  const {
1020
1019
  extractCritical
1021
1020
  } = createEmotionServer(cache);
@@ -1049,7 +1048,7 @@ class Document$1 extends NextDocument {
1049
1048
  });
1050
1049
  }
1051
1050
  }
1052
- const version = "0.5.5";
1051
+ const version = "0.6.0";
1053
1052
  function isErrorWithMessage(error) {
1054
1053
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
1055
1054
  }
@@ -2306,268 +2305,9 @@ function registerBuiltinComponents(runtime) {
2306
2305
  unregisterRootComponent();
2307
2306
  unregisterSocialLinksComponent();
2308
2307
  unregisterTextComponent();
2309
- unregisterTextComponent();
2310
2308
  unregisterVideoComponent();
2311
2309
  };
2312
2310
  }
2313
- function murmur2(str) {
2314
- var h = 0;
2315
- var k, i = 0, len = str.length;
2316
- for (; len >= 4; ++i, len -= 4) {
2317
- k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
2318
- k = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
2319
- k ^= k >>> 24;
2320
- h = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
2321
- }
2322
- switch (len) {
2323
- case 3:
2324
- h ^= (str.charCodeAt(i + 2) & 255) << 16;
2325
- case 2:
2326
- h ^= (str.charCodeAt(i + 1) & 255) << 8;
2327
- case 1:
2328
- h ^= str.charCodeAt(i) & 255;
2329
- h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
2330
- }
2331
- h ^= h >>> 13;
2332
- h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
2333
- return ((h ^ h >>> 15) >>> 0).toString(36);
2334
- }
2335
- var unitlessKeys = {
2336
- animationIterationCount: 1,
2337
- borderImageOutset: 1,
2338
- borderImageSlice: 1,
2339
- borderImageWidth: 1,
2340
- boxFlex: 1,
2341
- boxFlexGroup: 1,
2342
- boxOrdinalGroup: 1,
2343
- columnCount: 1,
2344
- columns: 1,
2345
- flex: 1,
2346
- flexGrow: 1,
2347
- flexPositive: 1,
2348
- flexShrink: 1,
2349
- flexNegative: 1,
2350
- flexOrder: 1,
2351
- gridRow: 1,
2352
- gridRowEnd: 1,
2353
- gridRowSpan: 1,
2354
- gridRowStart: 1,
2355
- gridColumn: 1,
2356
- gridColumnEnd: 1,
2357
- gridColumnSpan: 1,
2358
- gridColumnStart: 1,
2359
- msGridRow: 1,
2360
- msGridRowSpan: 1,
2361
- msGridColumn: 1,
2362
- msGridColumnSpan: 1,
2363
- fontWeight: 1,
2364
- lineHeight: 1,
2365
- opacity: 1,
2366
- order: 1,
2367
- orphans: 1,
2368
- tabSize: 1,
2369
- widows: 1,
2370
- zIndex: 1,
2371
- zoom: 1,
2372
- WebkitLineClamp: 1,
2373
- fillOpacity: 1,
2374
- floodOpacity: 1,
2375
- stopOpacity: 1,
2376
- strokeDasharray: 1,
2377
- strokeDashoffset: 1,
2378
- strokeMiterlimit: 1,
2379
- strokeOpacity: 1,
2380
- strokeWidth: 1
2381
- };
2382
- function memoize(fn) {
2383
- var cache2 = /* @__PURE__ */ Object.create(null);
2384
- return function(arg) {
2385
- if (cache2[arg] === void 0)
2386
- cache2[arg] = fn(arg);
2387
- return cache2[arg];
2388
- };
2389
- }
2390
- var hyphenateRegex = /[A-Z]|^ms/g;
2391
- var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
2392
- var isCustomProperty = function isCustomProperty2(property) {
2393
- return property.charCodeAt(1) === 45;
2394
- };
2395
- var isProcessableValue = function isProcessableValue2(value) {
2396
- return value != null && typeof value !== "boolean";
2397
- };
2398
- var processStyleName = /* @__PURE__ */ memoize(function(styleName) {
2399
- return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase();
2400
- });
2401
- var processStyleValue = function processStyleValue2(key, value) {
2402
- switch (key) {
2403
- case "animation":
2404
- case "animationName": {
2405
- if (typeof value === "string") {
2406
- return value.replace(animationRegex, function(match, p1, p2) {
2407
- cursor = {
2408
- name: p1,
2409
- styles: p2,
2410
- next: cursor
2411
- };
2412
- return p1;
2413
- });
2414
- }
2415
- }
2416
- }
2417
- if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) {
2418
- return value + "px";
2419
- }
2420
- return value;
2421
- };
2422
- function handleInterpolation(mergedProps, registered, interpolation) {
2423
- if (interpolation == null) {
2424
- return "";
2425
- }
2426
- if (interpolation.__emotion_styles !== void 0) {
2427
- return interpolation;
2428
- }
2429
- switch (typeof interpolation) {
2430
- case "boolean": {
2431
- return "";
2432
- }
2433
- case "object": {
2434
- if (interpolation.anim === 1) {
2435
- cursor = {
2436
- name: interpolation.name,
2437
- styles: interpolation.styles,
2438
- next: cursor
2439
- };
2440
- return interpolation.name;
2441
- }
2442
- if (interpolation.styles !== void 0) {
2443
- var next = interpolation.next;
2444
- if (next !== void 0) {
2445
- while (next !== void 0) {
2446
- cursor = {
2447
- name: next.name,
2448
- styles: next.styles,
2449
- next: cursor
2450
- };
2451
- next = next.next;
2452
- }
2453
- }
2454
- var styles = interpolation.styles + ";";
2455
- return styles;
2456
- }
2457
- return createStringFromObject(mergedProps, registered, interpolation);
2458
- }
2459
- case "function": {
2460
- if (mergedProps !== void 0) {
2461
- var previousCursor = cursor;
2462
- var result = interpolation(mergedProps);
2463
- cursor = previousCursor;
2464
- return handleInterpolation(mergedProps, registered, result);
2465
- }
2466
- break;
2467
- }
2468
- }
2469
- if (registered == null) {
2470
- return interpolation;
2471
- }
2472
- var cached = registered[interpolation];
2473
- return cached !== void 0 ? cached : interpolation;
2474
- }
2475
- function createStringFromObject(mergedProps, registered, obj) {
2476
- var string = "";
2477
- if (Array.isArray(obj)) {
2478
- for (var i = 0; i < obj.length; i++) {
2479
- string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
2480
- }
2481
- } else {
2482
- for (var _key in obj) {
2483
- var value = obj[_key];
2484
- if (typeof value !== "object") {
2485
- if (registered != null && registered[value] !== void 0) {
2486
- string += _key + "{" + registered[value] + "}";
2487
- } else if (isProcessableValue(value)) {
2488
- string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
2489
- }
2490
- } else {
2491
- if (_key === "NO_COMPONENT_SELECTOR" && false) {
2492
- throw new Error("Component selectors can only be used in conjunction with @emotion/babel-plugin.");
2493
- }
2494
- if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
2495
- for (var _i = 0; _i < value.length; _i++) {
2496
- if (isProcessableValue(value[_i])) {
2497
- string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
2498
- }
2499
- }
2500
- } else {
2501
- var interpolated = handleInterpolation(mergedProps, registered, value);
2502
- switch (_key) {
2503
- case "animation":
2504
- case "animationName": {
2505
- string += processStyleName(_key) + ":" + interpolated + ";";
2506
- break;
2507
- }
2508
- default: {
2509
- string += _key + "{" + interpolated + "}";
2510
- }
2511
- }
2512
- }
2513
- }
2514
- }
2515
- }
2516
- return string;
2517
- }
2518
- var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
2519
- var cursor;
2520
- var serializeStyles = function serializeStyles2(args, registered, mergedProps) {
2521
- if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) {
2522
- return args[0];
2523
- }
2524
- var stringMode = true;
2525
- var styles = "";
2526
- cursor = void 0;
2527
- var strings = args[0];
2528
- if (strings == null || strings.raw === void 0) {
2529
- stringMode = false;
2530
- styles += handleInterpolation(mergedProps, registered, strings);
2531
- } else {
2532
- styles += strings[0];
2533
- }
2534
- for (var i = 1; i < args.length; i++) {
2535
- styles += handleInterpolation(mergedProps, registered, args[i]);
2536
- if (stringMode) {
2537
- styles += strings[i];
2538
- }
2539
- }
2540
- labelPattern.lastIndex = 0;
2541
- var identifierName = "";
2542
- var match;
2543
- while ((match = labelPattern.exec(styles)) !== null) {
2544
- identifierName += "-" + match[1];
2545
- }
2546
- var name = murmur2(styles) + identifierName;
2547
- return {
2548
- name,
2549
- styles,
2550
- next: cursor
2551
- };
2552
- };
2553
- var isBrowser = true;
2554
- var registerStyles = function registerStyles2(cache2, serialized, isStringTag) {
2555
- var className = cache2.key + "-" + serialized.name;
2556
- if ((isStringTag === false || isBrowser === false) && cache2.registered[className] === void 0) {
2557
- cache2.registered[className] = serialized.styles;
2558
- }
2559
- };
2560
- var insertStyles = function insertStyles2(cache2, serialized, isStringTag) {
2561
- registerStyles(cache2, serialized, isStringTag);
2562
- var className = cache2.key + "-" + serialized.name;
2563
- if (cache2.inserted[serialized.name] === void 0) {
2564
- var current = serialized;
2565
- do {
2566
- cache2.insert(serialized === current ? "." + className : "", current, cache2.sheet, true);
2567
- current = current.next;
2568
- } while (current !== void 0);
2569
- }
2570
- };
2571
2311
  const isServer = typeof window === "undefined";
2572
2312
  const useInsertionEffectSpecifier = "useInsertionEffect";
2573
2313
  const useInsertionEffect = (_c = React[useInsertionEffectSpecifier]) != null ? _c : React.useLayoutEffect;
@@ -3679,22 +3419,9 @@ function suppressWarningAndFindDomNode(instance) {
3679
3419
  return foundDomNode;
3680
3420
  }
3681
3421
  class FindDomNodeClassComponent extends Component {
3682
- componentDidMount() {
3683
- this.setInnerRef(suppressWarningAndFindDomNode(this));
3684
- }
3685
- componentDidUpdate() {
3686
- this.setInnerRef(suppressWarningAndFindDomNode(this));
3687
- }
3688
- setInnerRef(current) {
3689
- const {
3690
- innerRef
3691
- } = this.props;
3692
- if (innerRef == null)
3693
- return;
3694
- if (typeof innerRef === "function")
3695
- innerRef(current);
3696
- else
3697
- innerRef.current = current;
3422
+ constructor(props) {
3423
+ super(props);
3424
+ this.props.innerRef.current = () => suppressWarningAndFindDomNode(this);
3698
3425
  }
3699
3426
  render() {
3700
3427
  return /* @__PURE__ */ jsx(Fragment, {
@@ -3703,10 +3430,39 @@ class FindDomNodeClassComponent extends Component {
3703
3430
  }
3704
3431
  }
3705
3432
  const FindDomNode = forwardRef(function FindDomNode2(props, ref) {
3433
+ const findDomNodeRef = useRef(null);
3434
+ useImperativeHandle(ref, () => () => {
3435
+ var _a, _b;
3436
+ return (_b = (_a = findDomNodeRef.current) == null ? void 0 : _a.call(findDomNodeRef)) != null ? _b : null;
3437
+ }, []);
3706
3438
  return /* @__PURE__ */ jsx(FindDomNodeClassComponent, __spreadProps(__spreadValues({}, props), {
3707
- innerRef: ref
3439
+ innerRef: findDomNodeRef
3708
3440
  }));
3709
3441
  });
3442
+ class ElementImperativeHandle {
3443
+ constructor() {
3444
+ __publicField(this, "getCurrent", () => null);
3445
+ __publicField(this, "lastPropControllers", null);
3446
+ }
3447
+ callback(getCurrent) {
3448
+ const current = this.getCurrent();
3449
+ if (current === null)
3450
+ this.setPropControllers(null);
3451
+ else if (this.lastPropControllers !== null)
3452
+ this.setPropControllers(this.lastPropControllers);
3453
+ this.getCurrent = getCurrent;
3454
+ }
3455
+ getBoxModel() {
3456
+ const current = this.getCurrent();
3457
+ return isMeasurable(current) ? measure(current) : null;
3458
+ }
3459
+ setPropControllers(propControllers) {
3460
+ const current = this.getCurrent();
3461
+ if (isPropControllersHandle(current))
3462
+ current.setPropControllers(propControllers);
3463
+ this.lastPropControllers = propControllers;
3464
+ }
3465
+ }
3710
3466
  const storeContextDefaultValue = configureStore$1();
3711
3467
  function createReactRuntime(store) {
3712
3468
  return {
@@ -3789,6 +3545,9 @@ function useDocument(documentKey) {
3789
3545
  function useIsInBuilder() {
3790
3546
  return useSelector((state) => getIsInBuilder(state));
3791
3547
  }
3548
+ function useIsPreview() {
3549
+ return useSelector((state) => getIsPreview(state));
3550
+ }
3792
3551
  function useDispatch() {
3793
3552
  const store = useContext(StoreContext);
3794
3553
  return store.dispatch;
@@ -3810,26 +3569,20 @@ const ElementData = memo(forwardRef(function ElementData2({
3810
3569
  elementData
3811
3570
  }, ref) {
3812
3571
  const Component2 = useComponent(elementData.type);
3813
- const [handle, setHandle] = useState(null);
3814
- const [foundDomNode, setFoundDomNode] = useState(null);
3815
- useImperativeHandle(ref, () => handle != null ? handle : foundDomNode, [handle, foundDomNode]);
3816
3572
  suppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
3817
3573
  if (Component2 == null) {
3818
3574
  return /* @__PURE__ */ jsx(FallbackComponent, {
3819
- ref: setHandle,
3575
+ ref,
3820
3576
  text: "Component not found"
3821
3577
  });
3822
3578
  }
3823
3579
  return /* @__PURE__ */ jsx(Suspense, {
3824
- children: /* @__PURE__ */ jsx(FindDomNode, {
3825
- ref: setFoundDomNode,
3826
- children: /* @__PURE__ */ jsx(PropsValue, {
3827
- element: elementData,
3828
- children: (props) => /* @__PURE__ */ createElement(Component2, __spreadProps(__spreadValues({}, props), {
3829
- key: elementData.key,
3830
- ref: setHandle
3831
- }))
3832
- })
3580
+ children: /* @__PURE__ */ jsx(PropsValue, {
3581
+ element: elementData,
3582
+ children: (props) => /* @__PURE__ */ createElement(Component2, __spreadProps(__spreadValues({}, props), {
3583
+ key: elementData.key,
3584
+ ref
3585
+ }))
3833
3586
  })
3834
3587
  });
3835
3588
  }));
@@ -3863,26 +3616,42 @@ const Element = memo(forwardRef(function Element2({
3863
3616
  const elementKey = element.key;
3864
3617
  const dispatch = useDispatch();
3865
3618
  const documentKey = useDocumentKey();
3866
- const [handle, setHandle] = useState(null);
3619
+ const useFindDomNodeRef = useRef(true);
3620
+ const imperativeHandleRef = useRef(new ElementImperativeHandle());
3621
+ const findDomNodeCallbackRef = useCallback((current) => {
3622
+ if (useFindDomNodeRef.current === true) {
3623
+ imperativeHandleRef.current.callback(() => {
3624
+ var _a;
3625
+ return (_a = current == null ? void 0 : current()) != null ? _a : null;
3626
+ });
3627
+ }
3628
+ }, []);
3629
+ const elementCallbackRef = useCallback((current) => {
3630
+ useFindDomNodeRef.current = false;
3631
+ imperativeHandleRef.current.callback(() => current);
3632
+ }, []);
3867
3633
  const isRegisterElementDisabled = useContext(DisableRegisterElement);
3868
- useImperativeHandle(ref, () => handle, [handle]);
3634
+ useImperativeHandle(ref, () => imperativeHandleRef.current, []);
3869
3635
  useEffect(() => {
3870
3636
  if (documentKey == null || isRegisterElementDisabled)
3871
3637
  return;
3872
- return dispatch(registerComponentHandleEffect(documentKey, elementKey, handle));
3873
- }, [dispatch, documentKey, elementKey, handle, isRegisterElementDisabled]);
3638
+ return dispatch(registerComponentHandleEffect(documentKey, elementKey, imperativeHandleRef.current));
3639
+ }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
3874
3640
  useEffect(() => {
3875
3641
  if (documentKey == null || isRegisterElementDisabled)
3876
3642
  return;
3877
3643
  return dispatch(mountComponentEffect(documentKey, elementKey));
3878
3644
  }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
3879
- return isElementReference(element) ? /* @__PURE__ */ jsx(ElementReference, {
3880
- ref: setHandle,
3881
- elementReference: element
3882
- }, elementKey) : /* @__PURE__ */ jsx(ElementData, {
3883
- ref: setHandle,
3884
- elementData: element
3885
- }, elementKey);
3645
+ return /* @__PURE__ */ jsx(FindDomNode, {
3646
+ ref: findDomNodeCallbackRef,
3647
+ children: isElementReference(element) ? /* @__PURE__ */ jsx(ElementReference, {
3648
+ ref: elementCallbackRef,
3649
+ elementReference: element
3650
+ }, elementKey) : /* @__PURE__ */ jsx(ElementData, {
3651
+ ref: elementCallbackRef,
3652
+ elementData: element
3653
+ }, elementKey)
3654
+ });
3886
3655
  }));
3887
3656
  const Document = memo(forwardRef(function Document2({
3888
3657
  document: document2
@@ -3910,5 +3679,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
3910
3679
  document: document2
3911
3680
  });
3912
3681
  }));
3913
- export { Makeswift as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, serializeStyles as H, insertStyles as I, useTypography as J, useSwatches as K, shallowMergeFallbacks as L, useFiles as M, usePagePathnameSlice as N, useElementId as O, PageProvider as P, deepEqual as Q, RuntimeProvider as R, Shapes as S, storeContextDefaultValue as T, StoreContext as U, MakeswiftProvider as V, MakeswiftClient as W, getStaticPaths as X, getStaticProps as Y, getServerSideProps as Z, Page as _, ReactRuntime as a, PreviewModeScript as a0, Document$1 as a1, MakeswiftApiHandler as a2, forwardNextDynamicRef as a3, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, useMediaQuery as m, Page$1 as n, useStyle as o, responsiveWidth as p, responsiveTextStyle as q, responsiveStyle as r, colorToString as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
3682
+ export { Makeswift as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, forwardNextDynamicRef as H, useIsPreview as I, useFiles as J, useSwatches as K, usePagePathnameSlice as L, useElementId as M, deepEqual as N, storeContextDefaultValue as O, PageProvider as P, StoreContext as Q, RuntimeProvider as R, Shapes as S, MakeswiftProvider as T, useTypography as U, shallowMergeFallbacks as V, MakeswiftClient as W, getStaticPaths as X, getStaticProps as Y, getServerSideProps as Z, Page as _, ReactRuntime as a, PreviewModeScript as a0, Document$1 as a1, MakeswiftApiHandler as a2, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, useMediaQuery as m, Page$1 as n, useStyle as o, responsiveWidth as p, responsiveTextStyle as q, responsiveStyle as r, colorToString as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
3914
3683
  //# sourceMappingURL=index.es.js.map