@makeswift/runtime 0.2.19 → 0.2.21
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.cjs.js +29 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +29 -10
- package/dist/index.es.js.map +1 -1
- package/dist/types/src/api/introspection.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -293,6 +293,7 @@ async function introspect(element, client, store) {
|
|
|
293
293
|
const tableIds = /* @__PURE__ */ new Set();
|
|
294
294
|
const pageIds = /* @__PURE__ */ new Set();
|
|
295
295
|
const remaining = [element];
|
|
296
|
+
const seen = /* @__PURE__ */ new Set();
|
|
296
297
|
let current;
|
|
297
298
|
while (current = remaining.pop()) {
|
|
298
299
|
let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
|
|
@@ -304,7 +305,12 @@ async function introspect(element, client, store) {
|
|
|
304
305
|
getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
|
|
305
306
|
getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
|
|
306
307
|
getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
|
|
307
|
-
getElementChildren(descriptor, props[propName]).forEach((child) =>
|
|
308
|
+
getElementChildren(descriptor, props[propName]).forEach((child) => {
|
|
309
|
+
if (!seen.has(child.key)) {
|
|
310
|
+
seen.add(child.key);
|
|
311
|
+
remaining.push(child);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
308
314
|
if (descriptor.type === ShapeControlType) {
|
|
309
315
|
const prop = props[propName];
|
|
310
316
|
if (prop == null)
|
|
@@ -972,7 +978,7 @@ class Document$1 extends NextDocument {
|
|
|
972
978
|
});
|
|
973
979
|
}
|
|
974
980
|
}
|
|
975
|
-
const version = "0.2.
|
|
981
|
+
const version = "0.2.21";
|
|
976
982
|
function isErrorWithMessage(error) {
|
|
977
983
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
978
984
|
}
|
|
@@ -1218,7 +1224,7 @@ const Page = memo(({
|
|
|
1218
1224
|
rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
|
|
1219
1225
|
children: /* @__PURE__ */ jsx(Page$1, {
|
|
1220
1226
|
document: snapshot.document
|
|
1221
|
-
})
|
|
1227
|
+
}, snapshot.document.data.key)
|
|
1222
1228
|
});
|
|
1223
1229
|
});
|
|
1224
1230
|
const keys = (o) => Object.keys(o);
|
|
@@ -3333,6 +3339,7 @@ const DocumentContext = createContext(null);
|
|
|
3333
3339
|
function useDocumentKey() {
|
|
3334
3340
|
return useContext(DocumentContext);
|
|
3335
3341
|
}
|
|
3342
|
+
const DocumentCyclesContext = createContext([]);
|
|
3336
3343
|
function useStore() {
|
|
3337
3344
|
return useContext(Context);
|
|
3338
3345
|
}
|
|
@@ -3410,6 +3417,9 @@ const ElementReference = memo(forwardRef(function ElementReference2({
|
|
|
3410
3417
|
});
|
|
3411
3418
|
const globalElementData = (_a = data == null ? void 0 : data.globalElement) == null ? void 0 : _a.data;
|
|
3412
3419
|
const elementReferenceDocument = useDocument(elementReference.key);
|
|
3420
|
+
const documentKey = elementReference.key;
|
|
3421
|
+
const documentKeys = useContext(DocumentCyclesContext);
|
|
3422
|
+
const providedDocumentKeys = useMemo(() => [...documentKeys, documentKey], [documentKeys, documentKey]);
|
|
3413
3423
|
if (error != null) {
|
|
3414
3424
|
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
3415
3425
|
ref,
|
|
@@ -3422,14 +3432,23 @@ const ElementReference = memo(forwardRef(function ElementReference2({
|
|
|
3422
3432
|
text: "This global component doesn't exist"
|
|
3423
3433
|
});
|
|
3424
3434
|
}
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3435
|
+
if (documentKeys.includes(documentKey)) {
|
|
3436
|
+
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
3437
|
+
ref,
|
|
3438
|
+
text: "This global component contains itself!"
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3441
|
+
return /* @__PURE__ */ jsx(DocumentCyclesContext.Provider, {
|
|
3442
|
+
value: providedDocumentKeys,
|
|
3443
|
+
children: elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
|
|
3444
|
+
document: elementReferenceDocument,
|
|
3432
3445
|
ref
|
|
3446
|
+
}) : /* @__PURE__ */ jsx(DisableRegisterElement.Provider, {
|
|
3447
|
+
value: true,
|
|
3448
|
+
children: /* @__PURE__ */ jsx(ElementData, {
|
|
3449
|
+
elementData: globalElementData,
|
|
3450
|
+
ref
|
|
3451
|
+
})
|
|
3433
3452
|
})
|
|
3434
3453
|
});
|
|
3435
3454
|
}));
|