@makeswift/runtime 0.6.5 → 0.6.6

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.es.js CHANGED
@@ -40,7 +40,7 @@ import { useEffect, createContext, useContext, useState, useMemo, useRef, Childr
40
40
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
41
41
  import dynamic from "next/dynamic";
42
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 isPropControllersHandle, p as getComponentPropControllerDescriptors, q as getPropControllers, r as configureStore$1, s as getDocument, t as getElementId, u as getIsPreview, v as getIsInBuilder, w as copyElementTree, x as getReactComponent, y as getBuilderEditMode } from "./constants.es.js";
43
- import { A as ActionTypes, g as introspectedResourcesFulfilled, h as apiResourceFulfilled, t as typographiesFulfilled, j as registerComponentHandleEffect, k as mountComponentEffect, l as registerComponentEffect, n as registerReactComponentEffect } from "./actions.es.js";
43
+ import { A as ActionTypes, h as introspectedResourcesFulfilled, j as apiResourceFulfilled, t as typographiesFulfilled, k as registerComponentHandleEffect, l as mountComponentEffect, n as registerComponentEffect, o as registerReactComponentEffect } from "./actions.es.js";
44
44
  import { cache, cx } from "@emotion/css";
45
45
  import { serializeStyles } from "@emotion/serialize";
46
46
  import { registerStyles, insertStyles } from "@emotion/utils";
@@ -119,6 +119,7 @@ async function introspect(element, client, store) {
119
119
  const tableIds = /* @__PURE__ */ new Set();
120
120
  const pageIds = /* @__PURE__ */ new Set();
121
121
  const remaining = [element];
122
+ const seen = /* @__PURE__ */ new Set();
122
123
  let current;
123
124
  while (current = remaining.pop()) {
124
125
  let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
@@ -130,7 +131,12 @@ async function introspect(element, client, store) {
130
131
  getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
131
132
  getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
132
133
  getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
133
- getElementChildren(descriptor, props[propName]).forEach((child) => remaining.push(child));
134
+ getElementChildren(descriptor, props[propName]).forEach((child) => {
135
+ if (!seen.has(child.key)) {
136
+ seen.add(child.key);
137
+ remaining.push(child);
138
+ }
139
+ });
134
140
  if (descriptor.type === ShapeControlType) {
135
141
  const prop = props[propName];
136
142
  if (prop == null)
@@ -1081,7 +1087,7 @@ function useCachedSite(siteId) {
1081
1087
  const site = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
1082
1088
  return site;
1083
1089
  }
1084
- const version = "0.6.5";
1090
+ const version = "0.6.6";
1085
1091
  class Makeswift {
1086
1092
  constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
1087
1093
  __publicField(this, "apiKey");
@@ -1500,7 +1506,8 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
1500
1506
  return res.json({
1501
1507
  version,
1502
1508
  previewMode: true,
1503
- interactionMode: true
1509
+ interactionMode: true,
1510
+ clientSideNavigation: true
1504
1511
  });
1505
1512
  }
1506
1513
  case "revalidate": {
@@ -4024,6 +4031,7 @@ const DocumentContext = createContext(null);
4024
4031
  function useDocumentKey() {
4025
4032
  return useContext(DocumentContext);
4026
4033
  }
4034
+ const DocumentCyclesContext = createContext([]);
4027
4035
  function useStore() {
4028
4036
  return useContext(StoreContext);
4029
4037
  }
@@ -4095,20 +4103,32 @@ const ElementReference = memo(forwardRef(function ElementReference2({
4095
4103
  const globalElement = useGlobalElement(elementReference.value);
4096
4104
  const globalElementData = globalElement == null ? void 0 : globalElement.data;
4097
4105
  const elementReferenceDocument = useDocument(elementReference.key);
4106
+ const documentKey = elementReference.key;
4107
+ const documentKeys = useContext(DocumentCyclesContext);
4108
+ const providedDocumentKeys = useMemo(() => [...documentKeys, documentKey], [documentKeys, documentKey]);
4098
4109
  if (globalElementData == null) {
4099
4110
  return /* @__PURE__ */ jsx(FallbackComponent, {
4100
4111
  ref,
4101
4112
  text: "This global component doesn't exist"
4102
4113
  });
4103
4114
  }
4104
- return elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
4105
- document: elementReferenceDocument,
4106
- ref
4107
- }) : /* @__PURE__ */ jsx(DisableRegisterElement.Provider, {
4108
- value: true,
4109
- children: /* @__PURE__ */ jsx(ElementData, {
4110
- elementData: globalElementData,
4115
+ if (documentKeys.includes(documentKey)) {
4116
+ return /* @__PURE__ */ jsx(FallbackComponent, {
4117
+ ref,
4118
+ text: "This global component contains itself!"
4119
+ });
4120
+ }
4121
+ return /* @__PURE__ */ jsx(DocumentCyclesContext.Provider, {
4122
+ value: providedDocumentKeys,
4123
+ children: elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
4124
+ document: elementReferenceDocument,
4111
4125
  ref
4126
+ }) : /* @__PURE__ */ jsx(DisableRegisterElement.Provider, {
4127
+ value: true,
4128
+ children: /* @__PURE__ */ jsx(ElementData, {
4129
+ elementData: globalElementData,
4130
+ ref
4131
+ })
4112
4132
  })
4113
4133
  });
4114
4134
  }));