@makeswift/runtime 0.0.13 → 0.0.17

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 (72) hide show
  1. package/dist/builder.cjs.js +1 -1
  2. package/dist/builder.es.js +1 -1
  3. package/dist/components.cjs.js +4 -3
  4. package/dist/components.cjs.js.map +1 -1
  5. package/dist/components.es.js +4 -3
  6. package/dist/components.es.js.map +1 -1
  7. package/dist/control-serialization.cjs.js +43 -3
  8. package/dist/control-serialization.cjs.js.map +1 -1
  9. package/dist/control-serialization.es.js +41 -1
  10. package/dist/control-serialization.es.js.map +1 -1
  11. package/dist/controls.cjs.js +7 -5
  12. package/dist/controls.cjs.js.map +1 -1
  13. package/dist/controls.es.js +2 -2
  14. package/dist/descriptors.cjs.js.map +1 -1
  15. package/dist/descriptors.es.js.map +1 -1
  16. package/dist/index.cjs.js +82 -60
  17. package/dist/index.cjs.js.map +1 -1
  18. package/dist/index.es.js +46 -22
  19. package/dist/index.es.js.map +1 -1
  20. package/dist/next.cjs.js +16 -24
  21. package/dist/next.cjs.js.map +1 -1
  22. package/dist/next.es.js +18 -26
  23. package/dist/next.es.js.map +1 -1
  24. package/dist/react-builder-preview.cjs.js +4 -3
  25. package/dist/react-builder-preview.cjs.js.map +1 -1
  26. package/dist/react-builder-preview.es.js +5 -4
  27. package/dist/react-builder-preview.es.js.map +1 -1
  28. package/dist/react.cjs.js +4 -3
  29. package/dist/react.cjs.js.map +1 -1
  30. package/dist/react.es.js +4 -3
  31. package/dist/react.es.js.map +1 -1
  32. package/dist/shape.cjs.js +20 -0
  33. package/dist/shape.cjs.js.map +1 -0
  34. package/dist/shape.es.js +14 -0
  35. package/dist/shape.es.js.map +1 -0
  36. package/dist/text-input.cjs.js +0 -6
  37. package/dist/text-input.cjs.js.map +1 -1
  38. package/dist/text-input.es.js +1 -5
  39. package/dist/text-input.es.js.map +1 -1
  40. package/dist/types/api/react.d.ts +3 -2
  41. package/dist/types/api/react.d.ts.map +1 -1
  42. package/dist/types/builder/serialization/control-serialization.d.ts +3 -3
  43. package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
  44. package/dist/types/builder/serialization/controls/combobox.d.ts +5 -0
  45. package/dist/types/builder/serialization/controls/combobox.d.ts.map +1 -0
  46. package/dist/types/builder/serialization/controls/shape.d.ts +5 -0
  47. package/dist/types/builder/serialization/controls/shape.d.ts.map +1 -0
  48. package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
  49. package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
  50. package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
  51. package/dist/types/controls/combobox.d.ts +22 -0
  52. package/dist/types/controls/combobox.d.ts.map +1 -0
  53. package/dist/types/controls/control.d.ts +3 -2
  54. package/dist/types/controls/control.d.ts.map +1 -1
  55. package/dist/types/controls/index.d.ts +1 -0
  56. package/dist/types/controls/index.d.ts.map +1 -1
  57. package/dist/types/controls/types.d.ts +3 -0
  58. package/dist/types/controls/types.d.ts.map +1 -1
  59. package/dist/types/next.d.ts +4 -8
  60. package/dist/types/next.d.ts.map +1 -1
  61. package/dist/types/prop-controllers/descriptors.d.ts +4 -3
  62. package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
  63. package/dist/types/runtimes/react/controls/combobox.d.ts +4 -0
  64. package/dist/types/runtimes/react/controls/combobox.d.ts.map +1 -0
  65. package/dist/types/runtimes/react/controls/control.d.ts +3 -2
  66. package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
  67. package/dist/types/runtimes/react/controls.d.ts.map +1 -1
  68. package/package.json +1 -1
  69. package/dist/list.cjs.js +0 -8
  70. package/dist/list.cjs.js.map +0 -1
  71. package/dist/list.es.js +0 -6
  72. package/dist/list.es.js.map +0 -1
package/dist/index.es.js CHANGED
@@ -43,6 +43,9 @@ import { f as registerComponentHandleEffect, g as mountComponentEffect, h as reg
43
43
  import styled, { css, keyframes, createGlobalStyle } from "styled-components";
44
44
  import { useReducedMotion, useAnimation, motion } from "framer-motion";
45
45
  import { cx, css as css$1, cache } from "@emotion/css";
46
+ import { getDataFromTree } from "@apollo/client/react/ssr";
47
+ import { KeyUtils, Value } from "slate";
48
+ import uuid from "uuid/v4";
46
49
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
47
50
  import parse$1 from "html-react-parser";
48
51
  import Head from "next/head";
@@ -52,20 +55,18 @@ import scrollIntoView from "scroll-into-view-if-needed";
52
55
  import NextLink from "next/link";
53
56
  import { useGesture } from "react-use-gesture";
54
57
  import { wrap } from "@popmotion/popcorn";
55
- import uuid from "uuid/v4";
56
58
  import NextImage from "next/image";
57
59
  import { Field as Field$1, getIn, Formik } from "formik";
58
60
  import { p as parse, c as createBox, g as getBox } from "./box-models.es.js";
59
61
  import { normalize } from "polished";
60
62
  import ReactPlayer from "react-player";
61
- import { Value } from "slate";
62
63
  import Hotkeys from "slate-hotkeys";
63
64
  import ipsum from "corporate-ipsum";
64
65
  import { isHotkey } from "is-hotkey";
65
66
  import { Editor } from "slate-react";
66
67
  import Lists from "@convertkit/slate-lists";
67
- import { S as ShapeControlType, I as ImageControlType, C as ColorControlType, a as SelectControlType, T as TextAreaControlType, b as TextInputControlType, N as NumberControlType, c as CheckboxControlType } from "./text-input.es.js";
68
- import { L as ListControlType } from "./list.es.js";
68
+ import { I as ImageControlType, C as ColorControlType, S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, b as CheckboxControlType } from "./text-input.es.js";
69
+ import { L as ListControlType, S as ShapeControlType, C as ComboboxControlType } from "./shape.es.js";
69
70
  import { a as StyleControlProperty, S as StyleControlType } from "./style.es.js";
70
71
  import { findDOMNode } from "react-dom";
71
72
  const PlaceholderBase$1 = styled.div`
@@ -305,13 +306,9 @@ const typePolicies = {
305
306
  }
306
307
  }
307
308
  };
308
- const isServer$1 = typeof window === "undefined";
309
- let globalApolloClient = null;
310
- function garbageCollectGlobalCacheData() {
311
- globalApolloClient = null;
312
- }
313
- function getGlobalCacheData() {
314
- return globalApolloClient == null ? void 0 : globalApolloClient.cache.extract();
309
+ const PrefetchContext = createContext(false);
310
+ function useIsPrefetching() {
311
+ return useContext(PrefetchContext);
315
312
  }
316
313
  function createApolloClient({
317
314
  uri,
@@ -324,8 +321,7 @@ function createApolloClient({
324
321
  cache2.restore(cacheData);
325
322
  return new ApolloClient({
326
323
  uri,
327
- cache: cache2,
328
- ssrMode: isServer$1
324
+ cache: cache2
329
325
  });
330
326
  }
331
327
  class MakeswiftClient {
@@ -334,14 +330,25 @@ class MakeswiftClient {
334
330
  cacheData
335
331
  }) {
336
332
  __publicField(this, "apolloClient");
337
- if (globalApolloClient == null)
338
- globalApolloClient = createApolloClient({
339
- uri,
340
- cacheData
341
- });
342
- else if (cacheData != null)
343
- globalApolloClient.cache.restore(cacheData);
344
- this.apolloClient = globalApolloClient;
333
+ this.apolloClient = createApolloClient({
334
+ uri,
335
+ cacheData
336
+ });
337
+ }
338
+ async prefetch(element) {
339
+ const id = uuid();
340
+ await getDataFromTree(/* @__PURE__ */ jsx(PrefetchContext.Provider, {
341
+ value: true,
342
+ children: /* @__PURE__ */ jsx(RuntimeProvider, {
343
+ client: this,
344
+ rootElements: /* @__PURE__ */ new Map([[id, element]]),
345
+ children: /* @__PURE__ */ jsx(DocumentReference, {
346
+ documentReference: createDocumentReference(id)
347
+ })
348
+ })
349
+ }));
350
+ KeyUtils.resetGenerator();
351
+ return this.apolloClient.cache.extract();
345
352
  }
346
353
  updateCacheData(cacheData) {
347
354
  this.apolloClient.cache.restore(cacheData);
@@ -1360,6 +1367,9 @@ const BackgroundsContainer$1 = styled(Container$c)`
1360
1367
  function Backgrounds({
1361
1368
  backgrounds
1362
1369
  }) {
1370
+ const isPrefetching = useIsPrefetching();
1371
+ if (isPrefetching)
1372
+ return /* @__PURE__ */ jsx(Fragment, {});
1363
1373
  if (backgrounds == null)
1364
1374
  return /* @__PURE__ */ jsx(Fragment, {});
1365
1375
  return /* @__PURE__ */ jsx(Fragment, {
@@ -2339,6 +2349,7 @@ const ImageComponent = forwardRef(function Image2({
2339
2349
  const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder2.dimensions;
2340
2350
  const [measuredDimensions, setMeasuredDimensions] = useState(null);
2341
2351
  const isInBuilder = useIsInBuilder();
2352
+ const isPrefetching = useIsPrefetching();
2342
2353
  useEffect(() => {
2343
2354
  if (dataDimensions)
2344
2355
  return;
@@ -2359,6 +2370,8 @@ const ImageComponent = forwardRef(function Image2({
2359
2370
  if (!dimensions)
2360
2371
  return null;
2361
2372
  const widthClass = css$1(responsiveWidth(width, `${dimensions.width}px`));
2373
+ if (isPrefetching)
2374
+ return null;
2362
2375
  return /* @__PURE__ */ jsx(ImageContainer, {
2363
2376
  as: link ? Link : "div",
2364
2377
  link,
@@ -5605,6 +5618,7 @@ const StyledDropDownItem = styled(Link)`
5605
5618
  color: black;
5606
5619
  background-color: transparent;
5607
5620
  transition: background-color 0.2s;
5621
+ ${cssTextStyle()}
5608
5622
  ${(p) => cssMediaRules([p.color, p.textStyle], ([color, textStyle = {}]) => {
5609
5623
  const fontSize = textStyle.fontSize || {
5610
5624
  value: 14,
@@ -8545,6 +8559,9 @@ function useColorValue(data, definition) {
8545
8559
  const [swatch] = (_b = (_a = result.data) == null ? void 0 : _a.swatches) != null ? _b : [null];
8546
8560
  return ColorHelper({ h: swatch == null ? void 0 : swatch.hue, s: swatch == null ? void 0 : swatch.saturation, l: swatch == null ? void 0 : swatch.lightness }).alpha(data.alpha).rgb().string();
8547
8561
  }
8562
+ function useComboboxControlValue(data) {
8563
+ return data == null ? void 0 : data.value;
8564
+ }
8548
8565
  function useImageControlValue(data) {
8549
8566
  var _a;
8550
8567
  return (_a = useFile(data)) == null ? void 0 : _a.publicUrl;
@@ -8633,6 +8650,12 @@ function ControlValue({
8633
8650
  parameters: [data],
8634
8651
  children: (value) => children(value)
8635
8652
  }, definition.type);
8653
+ case ComboboxControlType:
8654
+ return /* @__PURE__ */ jsx(RenderHook, {
8655
+ hook: useComboboxControlValue,
8656
+ parameters: [data],
8657
+ children: (value) => children(value)
8658
+ }, definition.type);
8636
8659
  case ShapeControlType:
8637
8660
  return /* @__PURE__ */ jsx(ShapeControlValue, {
8638
8661
  definition,
@@ -8674,6 +8697,7 @@ function PropsValue({
8674
8697
  case SelectControlType:
8675
8698
  case ColorControlType:
8676
8699
  case ImageControlType:
8700
+ case ComboboxControlType:
8677
8701
  case ShapeControlType:
8678
8702
  case ListControlType:
8679
8703
  return /* @__PURE__ */ jsx(ControlValue, {
@@ -9008,5 +9032,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
9008
9032
  document: document2
9009
9033
  });
9010
9034
  }));
9011
- export { useBackgrounds as A, Box as B, Carousel as C, DocumentReference as D, Element$1 as E, Form as F, useBorder as G, useBoxShadow as H, ImageComponent as I, useResponsiveColor as J, useFile as K, useMediaQuery as L, usePage as M, Navigation as N, useTable as O, PageProvider as P, PAGE_SNIPPETS_QUERY as Q, RuntimeProvider as R, SocialLinks as S, Text as T, SITE_FONTS_QUERY as U, Page2 as V, garbageCollectGlobalCacheData as W, getGlobalCacheData as X, MakeswiftClient as Y, deepEqual as Z, ReactRuntime as a, usePageId as b, Button$1 as c, Countdown as d, Divider as e, Embed as f, Root as g, registerComponent$c as h, DEFAULT_BOX_ANIMATE_TYPE as i, DEFAULT_BOX_ANIMATE_DELAY as j, DEFAULT_BOX_ANIMATE_DURATION as k, DEFAULT_ITEM_ANIMATE_TYPE as l, DEFAULT_ITEM_ANIMATE_DELAY as m, DEFAULT_ITEM_ANIMATE_DURATION as n, DEFAULT_ITEM_STAGGER_DURATION as o, cssMediaRules as p, cssWidth as q, registerBuiltinComponents as r, cssMargin as s, cssPadding as t, useIsInBuilder as u, cssBorder as v, cssBorderRadius as w, cssBoxShadow as x, cssGridItem as y, cssTextStyle as z };
9035
+ export { useBackgrounds as A, Box as B, Carousel as C, DocumentReference as D, Element$1 as E, Form as F, useBorder as G, useBoxShadow as H, ImageComponent as I, useResponsiveColor as J, useFile as K, useMediaQuery as L, usePage as M, Navigation as N, useTable as O, PageProvider as P, PAGE_SNIPPETS_QUERY as Q, RuntimeProvider as R, SocialLinks as S, Text as T, SITE_FONTS_QUERY as U, Page2 as V, MakeswiftClient as W, deepEqual as X, ReactRuntime as a, usePageId as b, Button$1 as c, Countdown as d, Divider as e, Embed as f, Root as g, registerComponent$c as h, DEFAULT_BOX_ANIMATE_TYPE as i, DEFAULT_BOX_ANIMATE_DELAY as j, DEFAULT_BOX_ANIMATE_DURATION as k, DEFAULT_ITEM_ANIMATE_TYPE as l, DEFAULT_ITEM_ANIMATE_DELAY as m, DEFAULT_ITEM_ANIMATE_DURATION as n, DEFAULT_ITEM_STAGGER_DURATION as o, cssMediaRules as p, cssWidth as q, registerBuiltinComponents as r, cssMargin as s, cssPadding as t, useIsInBuilder as u, cssBorder as v, cssBorderRadius as w, cssBoxShadow as x, cssGridItem as y, cssTextStyle as z };
9012
9036
  //# sourceMappingURL=index.es.js.map