@makeswift/runtime 0.0.12 → 0.0.13

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.
@@ -13,9 +13,6 @@ require("./style.cjs.js");
13
13
  require("styled-components");
14
14
  require("framer-motion");
15
15
  require("@emotion/css");
16
- require("@apollo/client/react/ssr");
17
- require("slate");
18
- require("uuid/v4");
19
16
  require("react/jsx-runtime");
20
17
  require("html-react-parser");
21
18
  require("next/head");
@@ -24,12 +21,14 @@ require("scroll-into-view-if-needed");
24
21
  require("next/link");
25
22
  require("react-use-gesture");
26
23
  require("@popmotion/popcorn");
24
+ require("uuid/v4");
27
25
  require("next/image");
28
26
  require("formik");
29
27
  require("./box-models.cjs.js");
30
28
  require("css-box-model");
31
29
  require("polished");
32
30
  require("react-player");
31
+ require("slate");
33
32
  require("slate-hotkeys");
34
33
  require("corporate-ipsum");
35
34
  require("is-hotkey");
@@ -1 +1 @@
1
- {"version":3,"file":"components.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -11,9 +11,6 @@ import "./style.es.js";
11
11
  import "styled-components";
12
12
  import "framer-motion";
13
13
  import "@emotion/css";
14
- import "@apollo/client/react/ssr";
15
- import "slate";
16
- import "uuid/v4";
17
14
  import "react/jsx-runtime";
18
15
  import "html-react-parser";
19
16
  import "next/head";
@@ -22,12 +19,14 @@ import "scroll-into-view-if-needed";
22
19
  import "next/link";
23
20
  import "react-use-gesture";
24
21
  import "@popmotion/popcorn";
22
+ import "uuid/v4";
25
23
  import "next/image";
26
24
  import "formik";
27
25
  import "./box-models.es.js";
28
26
  import "css-box-model";
29
27
  import "polished";
30
28
  import "react-player";
29
+ import "slate";
31
30
  import "slate-hotkeys";
32
31
  import "corporate-ipsum";
33
32
  import "is-hotkey";
@@ -1 +1 @@
1
- {"version":3,"file":"components.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -43,9 +43,6 @@ var actions = require("./actions.cjs.js");
43
43
  var styled = require("styled-components");
44
44
  var framerMotion = require("framer-motion");
45
45
  var css = require("@emotion/css");
46
- var ssr = require("@apollo/client/react/ssr");
47
- var slate = require("slate");
48
- var uuid = require("uuid/v4");
49
46
  var jsxRuntime = require("react/jsx-runtime");
50
47
  var parse = require("html-react-parser");
51
48
  var Head = require("next/head");
@@ -55,11 +52,13 @@ var scrollIntoView = require("scroll-into-view-if-needed");
55
52
  var NextLink = require("next/link");
56
53
  var reactUseGesture = require("react-use-gesture");
57
54
  var popcorn = require("@popmotion/popcorn");
55
+ var uuid = require("uuid/v4");
58
56
  var NextImage = require("next/image");
59
57
  var formik = require("formik");
60
58
  var boxModels = require("./box-models.cjs.js");
61
59
  var polished = require("polished");
62
60
  var ReactPlayer = require("react-player");
61
+ var slate = require("slate");
63
62
  var Hotkeys = require("slate-hotkeys");
64
63
  var ipsum = require("corporate-ipsum");
65
64
  var isHotkey = require("is-hotkey");
@@ -94,12 +93,12 @@ function _interopNamespace(e) {
94
93
  }
95
94
  var React__namespace = /* @__PURE__ */ _interopNamespace(React);
96
95
  var styled__default = /* @__PURE__ */ _interopDefaultLegacy(styled);
97
- var uuid__default = /* @__PURE__ */ _interopDefaultLegacy(uuid);
98
96
  var parse__default = /* @__PURE__ */ _interopDefaultLegacy(parse);
99
97
  var Head__default = /* @__PURE__ */ _interopDefaultLegacy(Head);
100
98
  var ColorHelper__default = /* @__PURE__ */ _interopDefaultLegacy(ColorHelper);
101
99
  var scrollIntoView__default = /* @__PURE__ */ _interopDefaultLegacy(scrollIntoView);
102
100
  var NextLink__default = /* @__PURE__ */ _interopDefaultLegacy(NextLink);
101
+ var uuid__default = /* @__PURE__ */ _interopDefaultLegacy(uuid);
103
102
  var NextImage__default = /* @__PURE__ */ _interopDefaultLegacy(NextImage);
104
103
  var ReactPlayer__default = /* @__PURE__ */ _interopDefaultLegacy(ReactPlayer);
105
104
  var Hotkeys__default = /* @__PURE__ */ _interopDefaultLegacy(Hotkeys);
@@ -342,9 +341,13 @@ const typePolicies = {
342
341
  }
343
342
  }
344
343
  };
345
- const PrefetchContext = React.createContext(false);
346
- function useIsPrefetching() {
347
- return React.useContext(PrefetchContext);
344
+ const isServer$1 = typeof window === "undefined";
345
+ let globalApolloClient = null;
346
+ function garbageCollectGlobalCacheData() {
347
+ globalApolloClient = null;
348
+ }
349
+ function getGlobalCacheData() {
350
+ return globalApolloClient == null ? void 0 : globalApolloClient.cache.extract();
348
351
  }
349
352
  function createApolloClient({
350
353
  uri,
@@ -357,7 +360,8 @@ function createApolloClient({
357
360
  cache.restore(cacheData);
358
361
  return new client.ApolloClient({
359
362
  uri,
360
- cache
363
+ cache,
364
+ ssrMode: isServer$1
361
365
  });
362
366
  }
363
367
  class MakeswiftClient {
@@ -366,25 +370,14 @@ class MakeswiftClient {
366
370
  cacheData
367
371
  }) {
368
372
  __publicField(this, "apolloClient");
369
- this.apolloClient = createApolloClient({
370
- uri,
371
- cacheData
372
- });
373
- }
374
- async prefetch(element) {
375
- const id = uuid__default["default"]();
376
- await ssr.getDataFromTree(/* @__PURE__ */ jsxRuntime.jsx(PrefetchContext.Provider, {
377
- value: true,
378
- children: /* @__PURE__ */ jsxRuntime.jsx(RuntimeProvider, {
379
- client: this,
380
- rootElements: /* @__PURE__ */ new Map([[id, element]]),
381
- children: /* @__PURE__ */ jsxRuntime.jsx(DocumentReference, {
382
- documentReference: reactPage.createDocumentReference(id)
383
- })
384
- })
385
- }));
386
- slate.KeyUtils.resetGenerator();
387
- return this.apolloClient.cache.extract();
373
+ if (globalApolloClient == null)
374
+ globalApolloClient = createApolloClient({
375
+ uri,
376
+ cacheData
377
+ });
378
+ else if (cacheData != null)
379
+ globalApolloClient.cache.restore(cacheData);
380
+ this.apolloClient = globalApolloClient;
388
381
  }
389
382
  updateCacheData(cacheData) {
390
383
  this.apolloClient.cache.restore(cacheData);
@@ -1403,9 +1396,6 @@ const BackgroundsContainer$1 = styled__default["default"](Container$c)`
1403
1396
  function Backgrounds({
1404
1397
  backgrounds
1405
1398
  }) {
1406
- const isPrefetching = useIsPrefetching();
1407
- if (isPrefetching)
1408
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1409
1399
  if (backgrounds == null)
1410
1400
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1411
1401
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
@@ -2385,7 +2375,6 @@ const ImageComponent = React.forwardRef(function Image2({
2385
2375
  const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder2.dimensions;
2386
2376
  const [measuredDimensions, setMeasuredDimensions] = React.useState(null);
2387
2377
  const isInBuilder = useIsInBuilder();
2388
- const isPrefetching = useIsPrefetching();
2389
2378
  React.useEffect(() => {
2390
2379
  if (dataDimensions)
2391
2380
  return;
@@ -2406,8 +2395,6 @@ const ImageComponent = React.forwardRef(function Image2({
2406
2395
  if (!dimensions)
2407
2396
  return null;
2408
2397
  const widthClass = css.css(responsiveWidth(width, `${dimensions.width}px`));
2409
- if (isPrefetching)
2410
- return null;
2411
2398
  return /* @__PURE__ */ jsxRuntime.jsx(ImageContainer, {
2412
2399
  as: link ? Link : "div",
2413
2400
  link,
@@ -8552,8 +8539,11 @@ function useStyleControlCssObject(style$1, controlDefinition) {
8552
8539
  }
8553
8540
  const useInsertionEffectSpecifier = "useInsertionEffect";
8554
8541
  const useInsertionEffect = (_ea = React__namespace[useInsertionEffectSpecifier]) != null ? _ea : React__namespace.useLayoutEffect;
8542
+ const isServer = typeof window === "undefined";
8555
8543
  function useFormattedStyle(styleControlData, controlDefinition) {
8556
8544
  const style2 = useStyleControlCssObject(styleControlData, controlDefinition);
8545
+ if (isServer)
8546
+ return css.css(style2);
8557
8547
  const serialized = serializeStyles([style2], css.cache.registered);
8558
8548
  useInsertionEffect(() => {
8559
8549
  insertStyles(css.cache, serialized, false);
@@ -9094,6 +9084,8 @@ exports.cssPadding = cssPadding;
9094
9084
  exports.cssTextStyle = cssTextStyle;
9095
9085
  exports.cssWidth = cssWidth;
9096
9086
  exports.deepEqual = deepEqual;
9087
+ exports.garbageCollectGlobalCacheData = garbageCollectGlobalCacheData;
9088
+ exports.getGlobalCacheData = getGlobalCacheData;
9097
9089
  exports.registerBuiltinComponents = registerBuiltinComponents;
9098
9090
  exports.registerComponent = registerComponent$c;
9099
9091
  exports.useBackgrounds = useBackgrounds;