@plitzi/sdk-shared 0.36.1 → 0.37.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.
@@ -1,4 +1,5 @@
1
1
  import e from "./SchemaContext.mjs";
2
2
  import { EMPTY_SCHEMA as t, VARIABLE_REGEX as n } from "./schemaConstants.mjs";
3
- import { collectServerElements as r, hasServerElements as i } from "./serverElements.mjs";
4
- export { t as EMPTY_SCHEMA, e as SchemaContext, n as VARIABLE_REGEX, r as collectServerElements, i as hasServerElements };
3
+ import { findLayoutCycle as r, resolveLayoutChain as i } from "./layoutChain.mjs";
4
+ import { collectServerElements as a, hasServerElements as o } from "./serverElements.mjs";
5
+ export { t as EMPTY_SCHEMA, e as SchemaContext, n as VARIABLE_REGEX, a as collectServerElements, r as findLayoutCycle, o as hasServerElements, i as resolveLayoutChain };
@@ -0,0 +1,17 @@
1
+ import { Element } from '../types';
2
+ /** One shell a page is rendered inside: the layoutContainer element, and the container in it that takes the body. */
3
+ export type LayoutLink = {
4
+ layout: string;
5
+ slot: string;
6
+ };
7
+ /**
8
+ * The shells around a page, innermost first.
9
+ *
10
+ * A page names ONE shell (`layout`) and the container in it its body goes into (`layoutContainer`). That shell may
11
+ * name one of its own the same way — analytics pages share a header and tabs, and that header sits inside the
12
+ * platform's sidebar shell — so the chain is followed until a shell names none. A shell the document does not hold, or
13
+ * one already in the chain, ends it: a cycle is a mistake in the document, and rendering it would never finish.
14
+ */
15
+ export declare const resolveLayoutChain: (getElement: (id: string) => Element | undefined, layout: string, layoutContainer: string) => LayoutLink[];
16
+ /** The layouts a chain passes through that close it on itself, if any: `layout` → … → `layout`. */
17
+ export declare const findLayoutCycle: (getElement: (id: string) => Element | undefined, layout: string) => string[];
@@ -0,0 +1,25 @@
1
+ //#region src/schema/layoutChain.ts
2
+ var e = (e, t) => {
3
+ let n = e?.attributes[t];
4
+ return typeof n == "string" ? n : "";
5
+ }, t = (t, n, r) => {
6
+ let i = [], a = /* @__PURE__ */ new Set(), o = n, s = r;
7
+ for (; o && !a.has(o) && i.length < 16;) {
8
+ let n = t(o);
9
+ if (n?.definition.type !== "layoutContainer") break;
10
+ a.add(o), i.push({
11
+ layout: o,
12
+ slot: s || o
13
+ }), o = e(n, "layout"), s = e(n, "layoutContainer");
14
+ }
15
+ return i;
16
+ }, n = (t, n) => {
17
+ let r = [], i = n;
18
+ for (; i && r.length <= 16;) {
19
+ if (r.includes(i)) return [...r.slice(r.indexOf(i)), i];
20
+ r.push(i), i = e(t(i), "layout");
21
+ }
22
+ return [];
23
+ };
24
+ //#endregion
25
+ export { n as findLayoutCycle, t as resolveLayoutChain };