@plitzi/sdk-shared 0.37.9 → 0.37.10

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 (130) hide show
  1. package/CHANGELOG.md +585 -0
  2. package/dist/actions/index.d.ts +1 -1
  3. package/dist/actions/index.mjs +3 -3
  4. package/dist/actions/triggerParams.mjs +7 -6
  5. package/dist/actions/validateDocument.d.ts +3 -0
  6. package/dist/actions/validateDocument.mjs +89 -88
  7. package/dist/authoring/elementCallbacks.d.ts +65 -0
  8. package/dist/authoring/elementCallbacks.mjs +72 -8
  9. package/dist/authoring/index.mjs +3 -3
  10. package/dist/builder/contexts/BuilderContext.d.ts +18 -7
  11. package/dist/connectors/index.d.ts +1 -1
  12. package/dist/connectors/index.mjs +2 -2
  13. package/dist/connectors/validateManifest.d.ts +3 -0
  14. package/dist/connectors/validateManifest.mjs +77 -76
  15. package/dist/dataSource/computed.mjs +25 -29
  16. package/dist/dataSource/globalSources.d.ts +15 -0
  17. package/dist/dataSource/globalSources.mjs +13 -0
  18. package/dist/dataSource/index.d.ts +2 -0
  19. package/dist/dataSource/index.mjs +8 -7
  20. package/dist/devTools/utils/PlitziConsole.d.ts +9 -0
  21. package/dist/devTools/utils/PlitziConsole.mjs +27 -7
  22. package/dist/flags/flagsCookie.d.ts +26 -0
  23. package/dist/flags/flagsCookie.mjs +20 -0
  24. package/dist/flags/index.d.ts +3 -0
  25. package/dist/flags/index.mjs +4 -0
  26. package/dist/flags/resolveFlags.d.ts +60 -0
  27. package/dist/flags/resolveFlags.mjs +38 -0
  28. package/dist/flags/schemaFlag.d.ts +11 -0
  29. package/dist/flags/schemaFlag.mjs +9 -0
  30. package/dist/flags/useFlagResolution.d.ts +13 -0
  31. package/dist/flags/useFlagResolution.mjs +43 -0
  32. package/dist/helpers/eventTarget.d.ts +10 -0
  33. package/dist/helpers/eventTarget.mjs +4 -0
  34. package/dist/helpers/images.d.ts +18 -0
  35. package/dist/helpers/images.mjs +13 -0
  36. package/dist/helpers/index.d.ts +3 -0
  37. package/dist/helpers/index.mjs +21 -18
  38. package/dist/helpers/interval.d.ts +18 -0
  39. package/dist/helpers/interval.mjs +7 -0
  40. package/dist/helpers/isRecord.d.ts +2 -0
  41. package/dist/helpers/isRecord.mjs +4 -0
  42. package/dist/helpers/scroll.d.ts +42 -0
  43. package/dist/helpers/scroll.mjs +30 -0
  44. package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +1 -1
  45. package/dist/helpers/twigWrapper/filters/filters.mjs +38 -2
  46. package/dist/history/describe.mjs +3 -1
  47. package/dist/history/diff.d.ts +1 -1
  48. package/dist/history/diff.mjs +1 -0
  49. package/dist/history/types.d.ts +1 -1
  50. package/dist/hooks/index.mjs +5 -5
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.mjs +90 -76
  53. package/dist/navigation/routes.mjs +6 -4
  54. package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.d.ts +2 -0
  55. package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.mjs +4 -0
  56. package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.d.ts +12 -0
  57. package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.mjs +4 -0
  58. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.d.ts +2 -0
  59. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.mjs +4 -0
  60. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.d.ts +3 -0
  61. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.mjs +4 -0
  62. package/dist/network/graphql/builder/Mutations/index.d.ts +5 -1
  63. package/dist/network/graphql/builder/Mutations/index.mjs +122 -116
  64. package/dist/network/graphql/builder/Queries/InitQuery.d.ts +3 -1
  65. package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
  66. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +16 -2
  67. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +1 -1
  68. package/dist/network/graphql/builder/Queries/index.d.ts +1 -1
  69. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +1 -1
  70. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
  71. package/dist/network/index.mjs +8 -7
  72. package/dist/network/spaceEvents.d.ts +12 -6
  73. package/dist/network/spaceEvents.mjs +153 -154
  74. package/dist/realtime/client.mjs +123 -95
  75. package/dist/realtime/topics.mjs +18 -17
  76. package/dist/schema/anchor.d.ts +8 -0
  77. package/dist/schema/anchor.mjs +4 -0
  78. package/dist/schema/index.d.ts +2 -0
  79. package/dist/schema/index.mjs +6 -4
  80. package/dist/schema/serverElements.d.ts +6 -2
  81. package/dist/schema/serverElements.mjs +17 -16
  82. package/dist/schema/snippet.d.ts +7 -0
  83. package/dist/schema/snippet.mjs +9 -0
  84. package/dist/schema/wire.d.ts +11 -0
  85. package/dist/schema/wire.mjs +27 -0
  86. package/dist/server/actions/useImagesSync.d.ts +9 -0
  87. package/dist/server/actions/useImagesSync.mjs +7 -0
  88. package/dist/server/rsc/refreshRsc.mjs +8 -8
  89. package/dist/source/snapshot.mjs +23 -22
  90. package/dist/state/paintedState.mjs +13 -12
  91. package/dist/state/runtimeStatePersist.mjs +50 -49
  92. package/dist/store/index.d.ts +45 -45
  93. package/dist/style/breakpoints.d.ts +11 -0
  94. package/dist/style/breakpoints.mjs +8 -0
  95. package/dist/style/displayModes.d.ts +5 -0
  96. package/dist/style/displayModes.mjs +8 -0
  97. package/dist/style/fontValidation.mjs +52 -51
  98. package/dist/style/fonts.d.ts +0 -12
  99. package/dist/style/fonts.mjs +11 -11
  100. package/dist/style/index.d.ts +4 -0
  101. package/dist/style/index.mjs +11 -7
  102. package/dist/style/layoutGrid.d.ts +30 -0
  103. package/dist/style/layoutGrid.mjs +33 -0
  104. package/dist/style/notifications.d.ts +52 -0
  105. package/dist/style/notifications.mjs +55 -0
  106. package/dist/style/snippetStyle.d.ts +23 -0
  107. package/dist/style/snippetStyle.mjs +32 -0
  108. package/dist/style/styleConstants.d.ts +7 -2
  109. package/dist/style/styleConstants.mjs +10 -0
  110. package/dist/style/styleStates.d.ts +11 -2
  111. package/dist/style/styleStates.mjs +12 -9
  112. package/dist/theme/ThemeProvider.mjs +20 -20
  113. package/dist/types/CommonTypes.d.ts +3 -0
  114. package/dist/types/DevToolsTypes.d.ts +29 -4
  115. package/dist/types/EventBridgeTypes.d.ts +2 -2
  116. package/dist/types/PluginTypes.d.ts +1 -1
  117. package/dist/types/ResourceTypes.d.ts +2 -2
  118. package/dist/types/SchemaTypes.d.ts +62 -3
  119. package/dist/types/ServerTypes.d.ts +47 -0
  120. package/dist/types/SnippetTypes.d.ts +28 -0
  121. package/dist/types/StoreTypes.d.ts +25 -0
  122. package/dist/types/StyleTypes.d.ts +1 -1
  123. package/dist/types/index.d.ts +1 -1
  124. package/package.json +104 -8
  125. package/tailwind.config.js +1 -6
  126. package/vite.config.ts +16 -4
  127. package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.d.ts +0 -2
  128. package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +0 -4
  129. package/dist/types/TemplateTypes.d.ts +0 -20
  130. /package/dist/types/{TemplateTypes.mjs → SnippetTypes.mjs} +0 -0
@@ -1,12 +1,13 @@
1
+ import { pConsole as e } from "../devTools/utils/PlitziConsole.mjs";
1
2
  import "./topics.mjs";
2
3
  //#region src/realtime/client.ts
3
- var e = 30, t = [
4
+ var t = 30, n = [
4
5
  500,
5
6
  1e3,
6
7
  2e3,
7
8
  5e3,
8
9
  1e4
9
- ], n = 5e3, r = (e) => typeof e == "object" && !!e && "connection" in e && typeof e.connection == "string" && "refused" in e && Array.isArray(e.refused), i = (e) => typeof e == "object" && !!e && "topic" in e && typeof e.topic == "string" && "type" in e && typeof e.type == "string", a = (e) => typeof e == "object" && !!e && "id" in e && typeof e.id == "number" && "ok" in e && typeof e.ok == "boolean", o = (e) => {
10
+ ], r = 5e3, i = (e) => typeof e == "object" && !!e && "connection" in e && typeof e.connection == "string" && "refused" in e && Array.isArray(e.refused), a = (e) => typeof e == "object" && !!e && "topic" in e && typeof e.topic == "string" && "type" in e && typeof e.type == "string", o = (e) => typeof e == "object" && !!e && "id" in e && typeof e.id == "number" && "ok" in e && typeof e.ok == "boolean", s = (e) => {
10
11
  let t = "message", n = [];
11
12
  for (let r of e.split("\n")) r.startsWith("event: ") ? t = r.slice(7) : r.startsWith("data: ") && n.push(r.slice(6));
12
13
  if (n.length) try {
@@ -17,7 +18,7 @@ var e = 30, t = [
17
18
  } catch {
18
19
  return;
19
20
  }
20
- }, s = (e) => {
21
+ }, c = (e) => {
21
22
  try {
22
23
  let t = JSON.parse(String(e));
23
24
  return typeof t == "object" && t && "event" in t && typeof t.event == "string" ? {
@@ -27,166 +28,193 @@ var e = 30, t = [
27
28
  } catch {
28
29
  return;
29
30
  }
30
- }, c = (e, t) => {
31
+ }, l = (e, t) => {
31
32
  let n = new URL(`${e}?${t}`, globalThis.location.href);
32
33
  return n.protocol = n.protocol === "https:" ? "wss:" : "ws:", n.href;
33
- }, l = (l, { transport: u = "sse", fetchImpl: d = fetch, WebSocketImpl: f = globalThis.WebSocket } = {}) => {
34
- let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), g = "idle", _, v = /* @__PURE__ */ new Map(), y, b, x = 0, S = u === "websocket" && typeof f == "function", C = (e) => {
35
- g = e, h.forEach((t) => t(e));
36
- }, w = () => [...p.keys()].sort().join(","), T = (e) => {
37
- let t = e.split(",").flatMap((e) => m.get(e) ?? []);
38
- return `topics=${encodeURIComponent(e)}${t.length ? `&grants=${encodeURIComponent(t.join(","))}` : ""}`;
34
+ }, u = (e, { transport: u = "sse", fetchImpl: f = fetch, WebSocketImpl: p = globalThis.WebSocket } = {}) => {
35
+ let m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), _ = "idle", v, y = /* @__PURE__ */ new Map(), b, x, S = 0, C = u === "websocket" && typeof p == "function", w = () => [...m.keys()].sort().join(","), T = (e) => {
36
+ _ = e;
37
+ let t = w().split(",").filter(Boolean), n = v?.transport ?? (C ? "websocket" : "sse");
38
+ d(e === "open" ? "success" : e === "closed" ? "warning" : "info", `${e} · ${t.join(", ") || "no topics"}`, {
39
+ event: "status",
40
+ status: e,
41
+ topics: t,
42
+ transport: n
43
+ }), g.forEach((t) => t(e));
39
44
  }, E = (e) => {
40
- e.type === "$revoked" && e.from === "server" && v.set(e.topic, "revoked"), p.get(e.topic)?.forEach((t) => t(e));
41
- }, D = (e, t) => {
42
- e.me = t.connection, v = new Map(t.refused.map((e) => [e.topic, e.reason])), x = 0, C("open");
45
+ for (let [t, n] of e) y.set(t, n), d("danger", `${t} refused: ${n}`, {
46
+ event: "refused",
47
+ topic: t,
48
+ reason: n
49
+ });
50
+ }, D = (e) => {
51
+ let t = e.split(",").flatMap((e) => h.get(e) ?? []);
52
+ return `topics=${encodeURIComponent(e)}${t.length ? `&grants=${encodeURIComponent(t.join(","))}` : ""}`;
43
53
  }, O = (e) => {
44
- if (_ !== e) return;
45
- C("connecting");
46
- let n = t[Math.min(x, t.length - 1)];
47
- x += 1, b = setTimeout(j, n);
54
+ e.type === "$revoked" && e.from === "server" && E([[e.topic, "revoked"]]), d("info", `${e.topic} ← ${e.type}`, {
55
+ event: "received",
56
+ message: e
57
+ }), m.get(e.topic)?.forEach((t) => t(e));
48
58
  }, k = (e, t) => {
49
- let n = new AbortController(), a, s = {
50
- topics: e,
59
+ e.me = t.connection, y = /* @__PURE__ */ new Map(), E(t.refused.map((e) => [e.topic, e.reason])), S = 0, T("open");
60
+ }, A = (e) => {
61
+ if (v !== e) return;
62
+ T("connecting");
63
+ let t = n[Math.min(S, n.length - 1)];
64
+ S += 1, x = setTimeout(N, t);
65
+ }, j = (t, n) => {
66
+ let r = new AbortController(), o, c = {
67
+ topics: t,
51
68
  transport: "sse",
52
- close: () => n.abort(),
53
- publish: async (e, t, n) => {
54
- if (!a) return !1;
55
- let r = await d(l, {
69
+ close: () => r.abort(),
70
+ publish: async (t, n, r) => {
71
+ if (!o) return !1;
72
+ let i = await f(e, {
56
73
  method: "POST",
57
74
  headers: { "content-type": "application/json" },
58
75
  credentials: "same-origin",
59
76
  body: JSON.stringify({
60
- token: a,
61
- topic: e,
62
- type: t,
63
- data: n
77
+ token: o,
78
+ topic: t,
79
+ type: n,
80
+ data: r
64
81
  })
65
82
  }).catch(() => void 0);
66
- return r?.status === 401 && _ === s && j(), r?.ok ?? !1;
83
+ return i?.status === 401 && v === c && N(), i?.ok ?? !1;
67
84
  }
68
- }, c = async (e) => {
85
+ }, l = async (e) => {
69
86
  let t = e.body?.getReader();
70
87
  if (!t) return;
71
- let n = new TextDecoder(), c = "";
88
+ let n = new TextDecoder(), r = "";
72
89
  for (;;) {
73
90
  let { done: e, value: l } = await t.read();
74
91
  if (e) return;
75
- c += n.decode(l, { stream: !0 });
76
- let u = c.indexOf("\n\n");
92
+ r += n.decode(l, { stream: !0 });
93
+ let u = r.indexOf("\n\n");
77
94
  for (; u !== -1;) {
78
- let e = o(c.slice(0, u));
79
- c = c.slice(u + 2), u = c.indexOf("\n\n"), e?.event === "ready" && r(e.data) ? (a = e.data.token, D(s, e.data)) : e?.event === "message" && i(e.data) && E(e.data);
95
+ let e = s(r.slice(0, u));
96
+ r = r.slice(u + 2), u = r.indexOf("\n\n"), e?.event === "ready" && i(e.data) ? (o = e.data.token, k(c, e.data)) : e?.event === "message" && a(e.data) && O(e.data);
80
97
  }
81
98
  }
82
99
  };
83
- return d(`${l}?${t}`, {
100
+ return f(`${e}?${n}`, {
84
101
  headers: { accept: "text/event-stream" },
85
102
  credentials: "same-origin",
86
- signal: n.signal
87
- }).then(async (t) => {
88
- if (!t.ok) {
89
- v = new Map(e.split(",").map((e) => [e, `http_${t.status}`])), C("closed");
103
+ signal: r.signal
104
+ }).then(async (e) => {
105
+ if (!e.ok) {
106
+ y = /* @__PURE__ */ new Map(), E(t.split(",").map((t) => [t, `http_${String(e.status)}`])), T("closed");
90
107
  return;
91
108
  }
92
- throw await c(t), Error("The realtime stream ended");
109
+ throw await l(e), Error("The realtime stream ended");
93
110
  }).catch(() => {
94
- n.signal.aborted || O(s);
95
- }), s;
96
- }, A = (e, t) => {
97
- let o = new f(c(l, t)), u = /* @__PURE__ */ new Map(), d = 0, p = !1, m = !1, h = () => {
111
+ r.signal.aborted || A(c);
112
+ }), c;
113
+ }, M = (t, n) => {
114
+ let s = new p(l(e, n)), u = /* @__PURE__ */ new Map(), d = 0, f = !1, m = !1, h = () => {
98
115
  u.forEach((e) => e(!1)), u.clear();
99
116
  }, g = {
100
- topics: e,
117
+ topics: t,
101
118
  transport: "websocket",
102
119
  close: () => {
103
- m = !0, h(), o.close();
120
+ m = !0, h(), s.close();
104
121
  },
105
- publish: (e, t, r) => new Promise((i) => {
106
- if (o.readyState !== o.OPEN) {
122
+ publish: (e, t, n) => new Promise((i) => {
123
+ if (s.readyState !== s.OPEN) {
107
124
  i(!1);
108
125
  return;
109
126
  }
110
127
  d += 1;
111
- let a = d, s = setTimeout(() => {
128
+ let a = d, o = setTimeout(() => {
112
129
  u.delete(a), i(!1);
113
- }, n);
130
+ }, r);
114
131
  u.set(a, (e) => {
115
- clearTimeout(s), i(e);
116
- }), o.send(JSON.stringify({
132
+ clearTimeout(o), i(e);
133
+ }), s.send(JSON.stringify({
117
134
  id: a,
118
135
  topic: e,
119
136
  type: t,
120
- data: r
137
+ data: n
121
138
  }));
122
139
  })
123
140
  };
124
- return o.onmessage = (e) => {
125
- let t = s(e.data);
126
- t?.event === "ready" && r(t.data) ? (p = !0, D(g, t.data)) : t?.event === "message" && i(t.data) ? E(t.data) : t?.event === "ack" && a(t.data) && (u.get(t.data.id)?.(t.data.ok), u.delete(t.data.id));
127
- }, o.onclose = () => {
128
- if (h(), !(m || _ !== g)) {
129
- if (!p) {
130
- S = !1, j();
141
+ return s.onmessage = (e) => {
142
+ let t = c(e.data);
143
+ t?.event === "ready" && i(t.data) ? (f = !0, k(g, t.data)) : t?.event === "message" && a(t.data) ? O(t.data) : t?.event === "ack" && o(t.data) && (u.get(t.data.id)?.(t.data.ok), u.delete(t.data.id));
144
+ }, s.onclose = () => {
145
+ if (h(), !(m || v !== g)) {
146
+ if (!f) {
147
+ C = !1, N();
131
148
  return;
132
149
  }
133
- O(g);
150
+ A(g);
134
151
  }
135
152
  }, g;
136
153
  };
137
- function j() {
138
- _?.close(), _ = void 0;
154
+ function N() {
155
+ v?.close(), v = void 0;
139
156
  let e = w();
140
157
  if (!e) {
141
- C("idle");
158
+ T("idle");
142
159
  return;
143
160
  }
144
- C("connecting");
145
- let t = T(e);
146
- _ = S ? A(e, t) : k(e, t);
161
+ T("connecting");
162
+ let t = D(e);
163
+ v = C ? M(e, t) : j(e, t);
147
164
  }
148
- let M = (t = !1) => {
149
- clearTimeout(y), clearTimeout(b), y = setTimeout(() => {
150
- (t || _?.topics !== w()) && j();
151
- }, e);
152
- }, N = (e) => g === "open" && _?.topics.split(",").includes(e) === !0, P = (e) => N(e) ? Promise.resolve(!0) : new Promise((t) => {
153
- let r = setTimeout(() => {
165
+ let P = (e = !1) => {
166
+ clearTimeout(b), clearTimeout(x), b = setTimeout(() => {
167
+ (e || v?.topics !== w()) && N();
168
+ }, t);
169
+ }, F = (e) => _ === "open" && v?.topics.split(",").includes(e) === !0, I = (e) => F(e) ? Promise.resolve(!0) : new Promise((t) => {
170
+ let n = setTimeout(() => {
154
171
  i(), t(!1);
155
- }, n), i = F.onStatus((n) => {
156
- (n === "closed" || N(e)) && (clearTimeout(r), i(), t(n !== "closed"));
172
+ }, r), i = L.onStatus((r) => {
173
+ (r === "closed" || F(e)) && (clearTimeout(n), i(), t(r !== "closed"));
157
174
  });
158
- }), F = {
175
+ }), L = {
159
176
  subscribe: (e, t) => {
160
- let n = p.get(e) ?? /* @__PURE__ */ new Set();
161
- return n.add(t), p.set(e, n), M(), () => {
162
- n.delete(t), n.size || (p.delete(e), m.delete(e), M());
177
+ let n = m.get(e) ?? /* @__PURE__ */ new Set();
178
+ return n.add(t), m.set(e, n), P(), () => {
179
+ n.delete(t), n.size || (m.delete(e), h.delete(e), P());
163
180
  };
164
181
  },
165
182
  grant: (e, t) => {
166
- if (m.get(e) === t) return;
167
- t ? m.set(e, t) : m.delete(e);
168
- let n = N(e) && !v.has(e);
169
- t && p.has(e) && !n && M(!0);
183
+ if (h.get(e) === t) return;
184
+ t ? h.set(e, t) : h.delete(e);
185
+ let n = F(e) && !y.has(e);
186
+ t && m.has(e) && !n && P(!0);
187
+ },
188
+ publish: async (e, t, n) => {
189
+ let r = await I(e) && v ? await v.publish(e, t, n) : !1;
190
+ return d(r ? "info" : "danger", `${e} → ${t}${r ? "" : " (not delivered)"}`, {
191
+ event: "published",
192
+ topic: e,
193
+ type: t,
194
+ data: n,
195
+ delivered: r
196
+ }), r;
170
197
  },
171
- publish: async (e, t, n) => !await P(e) || !_ ? !1 : _.publish(e, t, n),
172
- onStatus: (e) => (h.add(e), () => h.delete(e)),
198
+ onStatus: (e) => (g.add(e), () => g.delete(e)),
173
199
  get status() {
174
- return g;
200
+ return _;
175
201
  },
176
202
  get me() {
177
- return _?.me;
203
+ return v?.me;
178
204
  },
179
205
  get transport() {
180
- return _?.transport ?? (S ? "websocket" : "sse");
206
+ return v?.transport ?? (C ? "websocket" : "sse");
181
207
  },
182
- refusal: (e) => v.get(e)
208
+ refusal: (e) => y.get(e)
183
209
  };
184
- return F;
185
- }, u = /* @__PURE__ */ new Map(), d = (e, t = "sse") => {
186
- let n = `${t} ${e}`, r = u.get(n);
210
+ return L;
211
+ }, d = (t, n, r) => {
212
+ t === "success" ? e.success("realtime", n, r) : t === "warning" ? e.warning("realtime", n, r) : t === "danger" ? e.danger("realtime", n, r) : e.info("realtime", n, r);
213
+ }, f = /* @__PURE__ */ new Map(), p = (e, t = "sse") => {
214
+ let n = `${t} ${e}`, r = f.get(n);
187
215
  if (r) return r;
188
- let i = l(e, { transport: t });
189
- return u.set(n, i), i;
216
+ let i = u(e, { transport: t });
217
+ return f.set(n, i), i;
190
218
  };
191
219
  //#endregion
192
- export { l as createRealtimeClient, d as realtimeClientFor };
220
+ export { u as createRealtimeClient, p as realtimeClientFor };
@@ -1,25 +1,26 @@
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
1
2
  //#region src/realtime/topics.ts
2
- var e = /^[A-Za-z0-9:_.-]{1,128}$/, t = (t) => e.test(t), n = (e) => RegExp(`^${e.split(/(\{[A-Za-z0-9_]+\})/).map((e) => /^\{[A-Za-z0-9_]+\}$/.test(e) ? "[A-Za-z0-9_.-]{1,64}" : e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("")}$`), r = (e, r) => {
3
- if (!r || !t(e)) return;
4
- let i = Object.keys(r).find((t) => n(t).test(e));
5
- return i === void 0 ? void 0 : {
6
- pattern: i,
7
- declaration: r[i]
3
+ var t = /^[A-Za-z0-9:_.-]{1,128}$/, n = "[A-Za-z0-9_.-]{1,64}", r = (e) => t.test(e), i = (e) => RegExp(`^${e.split(/(\{[A-Za-z0-9_]+\})/).map((e) => /^\{[A-Za-z0-9_]+\}$/.test(e) ? n : e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("")}$`), a = (e, t) => {
4
+ if (!t || !r(e)) return;
5
+ let n = Object.keys(t).find((t) => i(t).test(e));
6
+ return n === void 0 ? void 0 : {
7
+ pattern: n,
8
+ declaration: t[n]
8
9
  };
9
- }, i = /^(?=.)[A-Za-z0-9:_.-]*(\{[A-Za-z0-9_]+\}[A-Za-z0-9:_.-]*)*$/, a = /* @__PURE__ */ new Set([
10
+ }, o = /^(?=.)[A-Za-z0-9:_.-]*(\{[A-Za-z0-9_]+\}[A-Za-z0-9:_.-]*)*$/, s = /* @__PURE__ */ new Set([
10
11
  "public",
11
12
  "session",
12
13
  "role"
13
- ]), o = (e) => typeof e == "object" && !!e && !Array.isArray(e), s = (e, t) => {
14
- let n = [];
15
- if (i.test(e) || n.push("a pattern is letters, digits and `:_.-`, with `{name}` for the part a page fills in — `board:{id}`"), !o(t)) return [...n, "a channel is an object: `{ access: { mode: \"public\" } }`"];
16
- let { access: r, publish: s, presence: c, grant: l, maxMessageBytes: u, messagesPerSecond: d } = t, f = o(r) ? r.mode : void 0;
17
- typeof f != "string" || !a.has(f) ? n.push("`access` is { mode: \"public\" }, { mode: \"session\" } or { mode: \"role\", permissions: […] }") : f === "role" && !(o(r) && Array.isArray(r.permissions) && r.permissions.every((e) => typeof e == "string")) && n.push("`access: { mode: \"role\" }` names the permissions it needs: `permissions: [\"boardEdit\"]`"), s !== void 0 && s !== "clients" && s !== "server" && n.push("`publish` is \"clients\" (pages send) or \"server\" (only a flow's realtime.publish)"), c !== void 0 && typeof c != "boolean" && n.push("`presence` is true or false"), l !== void 0 && typeof l != "boolean" && n.push("`grant` is true (a page needs a grant from `realtime.grant` to open a topic) or false");
18
- for (let [e, t] of [["maxMessageBytes", u], ["messagesPerSecond", d]]) t !== void 0 && (typeof t != "number" || !Number.isInteger(t) || t <= 0) && n.push(`\`${e}\` is a whole number above zero`);
19
- return n;
20
- }, c = (e) => ({
14
+ ]), c = (t, n) => {
15
+ let r = [];
16
+ if (o.test(t) || r.push("a pattern is letters, digits and `:_.-`, with `{name}` for the part a page fills in — `board:{id}`"), !e(n)) return [...r, "a channel is an object: `{ access: { mode: \"public\" } }`"];
17
+ let { access: i, publish: a, presence: c, grant: l, maxMessageBytes: u, messagesPerSecond: d } = n, f = e(i) ? i.mode : void 0;
18
+ typeof f != "string" || !s.has(f) ? r.push("`access` is { mode: \"public\" }, { mode: \"session\" } or { mode: \"role\", permissions: […] }") : f === "role" && !(e(i) && Array.isArray(i.permissions) && i.permissions.every((e) => typeof e == "string")) && r.push("`access: { mode: \"role\" }` names the permissions it needs: `permissions: [\"boardEdit\"]`"), a !== void 0 && a !== "clients" && a !== "server" && r.push("`publish` is \"clients\" (pages send) or \"server\" (only a flow's realtime.publish)"), c !== void 0 && typeof c != "boolean" && r.push("`presence` is true or false"), l !== void 0 && typeof l != "boolean" && r.push("`grant` is true (a page needs a grant from `realtime.grant` to open a topic) or false");
19
+ for (let [e, t] of [["maxMessageBytes", u], ["messagesPerSecond", d]]) t !== void 0 && (typeof t != "number" || !Number.isInteger(t) || t <= 0) && r.push(`\`${e}\` is a whole number above zero`);
20
+ return r;
21
+ }, l = (e) => ({
21
22
  maxMessageBytes: e.maxMessageBytes ?? 4096,
22
23
  messagesPerSecond: e.messagesPerSecond ?? 30
23
- }), l = "$presence", u = "$leave", d = "$join", f = "$revoked";
24
+ }), u = "$presence", d = "$leave", f = "$join", p = "$revoked";
24
25
  //#endregion
25
- export { d as JOIN_TYPE, u as LEAVE_TYPE, l as PRESENCE_TYPE, f as REVOKED_TYPE, c as channelLimits, s as channelProblems, t as isValidTopic, r as matchChannel };
26
+ export { f as JOIN_TYPE, d as LEAVE_TYPE, u as PRESENCE_TYPE, p as REVOKED_TYPE, l as channelLimits, c as channelProblems, r as isValidTopic, a as matchChannel };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * What an element's `anchor` may be: the `id` it carries in the DOM, so `/page#anchor` lands on it.
3
+ *
4
+ * Lowercase, starting with a letter, then letters, digits and hyphens — a fragment a person types in a URL, with no
5
+ * escaping and no case to get wrong. The one rule the authoring package, the builder and the MCP all hold it to.
6
+ */
7
+ export declare const ANCHOR_PATTERN: RegExp;
8
+ export declare const isAnchor: (value: unknown) => value is string;
@@ -0,0 +1,4 @@
1
+ //#region src/schema/anchor.ts
2
+ var e = /^[a-z][a-z0-9-]*$/, t = (t) => typeof t == "string" && e.test(t);
3
+ //#endregion
4
+ export { e as ANCHOR_PATTERN, t as isAnchor };
@@ -1,6 +1,8 @@
1
1
  import { default as SchemaContext } from './SchemaContext';
2
+ export * from './anchor';
2
3
  export * from './schemaConstants';
3
4
  export * from './SchemaContext';
4
5
  export * from './layoutChain';
5
6
  export * from './serverElements';
7
+ export * from './snippet';
6
8
  export { SchemaContext };
@@ -1,5 +1,7 @@
1
1
  import e from "./SchemaContext.mjs";
2
- import { COMPONENT_PROPS_SOURCE as t, EMPTY_SCHEMA as n, VARIABLE_REGEX as r } from "./schemaConstants.mjs";
3
- import { findLayoutCycle as i, resolveLayoutChain as a } from "./layoutChain.mjs";
4
- import { collectServerElements as o, hasServerElements as s } from "./serverElements.mjs";
5
- export { t as COMPONENT_PROPS_SOURCE, n as EMPTY_SCHEMA, e as SchemaContext, r as VARIABLE_REGEX, o as collectServerElements, i as findLayoutCycle, s as hasServerElements, a as resolveLayoutChain };
2
+ import { ANCHOR_PATTERN as t, isAnchor as n } from "./anchor.mjs";
3
+ import { COMPONENT_PROPS_SOURCE as r, EMPTY_SCHEMA as i, VARIABLE_REGEX as a } from "./schemaConstants.mjs";
4
+ import { findLayoutCycle as o, resolveLayoutChain as s } from "./layoutChain.mjs";
5
+ import { collectServerElements as c, hasServerElements as l } from "./serverElements.mjs";
6
+ import { isSnippet as u } from "./snippet.mjs";
7
+ export { t as ANCHOR_PATTERN, r as COMPONENT_PROPS_SOURCE, i as EMPTY_SCHEMA, e as SchemaContext, a as VARIABLE_REGEX, c as collectServerElements, o as findLayoutCycle, l as hasServerElements, n as isAnchor, u as isSnippet, s as resolveLayoutChain };
@@ -16,6 +16,10 @@ import { Element, Schema } from '../types';
16
16
  * a provider in the dashboard's sidebar was never resolved: the payload came back empty, the element rendered with
17
17
  * nothing, and no layer reported it.
18
18
  */
19
- export declare const collectServerElements: (schema: Schema, pageId: string | undefined, ids?: string[]) => Element[];
19
+ /**
20
+ * Given the flags as they resolved, an element gated off by one is skipped with its whole subtree — it will not be
21
+ * rendered, so nothing in it wants data, and resolving it would put a feature that is off into the payload anyway.
22
+ */
23
+ export declare const collectServerElements: (schema: Schema, pageId: string | undefined, ids?: string[], flags?: Record<string, boolean>) => Element[];
20
24
  /** Whether anything on this page consumes server data at all — the question both RSC gates actually ask. */
21
- export declare const hasServerElements: (schema: Schema, pageId: string | undefined) => boolean;
25
+ export declare const hasServerElements: (schema: Schema, pageId: string | undefined, flags?: Record<string, boolean>) => boolean;
@@ -1,19 +1,20 @@
1
- import { resolveLayoutChain as e } from "./layoutChain.mjs";
1
+ import { passesFlagGate as e } from "../flags/resolveFlags.mjs";
2
+ import { resolveLayoutChain as t } from "./layoutChain.mjs";
2
3
  //#region src/schema/serverElements.ts
3
- var t = (t, n, r) => {
4
- if (n === void 0) return [];
5
- let i = r ? new Set(r) : void 0, a = [], o = /* @__PURE__ */ new Set(), s = t.flat[n], c = (e) => typeof e == "string" ? e : "", l = [n, ...s ? e((e) => t.flat[e], c(s.attributes.layout), c(s.attributes.layoutContainer)).map((e) => e.layout) : []];
6
- for (; l.length > 0;) {
7
- let e = l.pop();
8
- if (e === void 0 || o.has(e)) continue;
9
- o.add(e);
10
- let n = t.flat[e];
11
- if (!n) continue;
12
- n.definition.runtime === "server" && (!i || i.has(n.id)) && a.push(n);
13
- let { items: r } = n.definition;
14
- r && l.push(...r);
4
+ var n = (n, r, i, a) => {
5
+ if (r === void 0) return [];
6
+ let o = i ? new Set(i) : void 0, s = [], c = /* @__PURE__ */ new Set(), l = n.flat[r], u = (e) => typeof e == "string" ? e : "", d = [r, ...l ? t((e) => n.flat[e], u(l.attributes.layout), u(l.attributes.layoutContainer)).map((e) => e.layout) : []];
7
+ for (; d.length > 0;) {
8
+ let t = d.pop();
9
+ if (t === void 0 || c.has(t)) continue;
10
+ c.add(t);
11
+ let r = n.flat[t];
12
+ if (!r || a && !e(r.definition.flag, a)) continue;
13
+ r.definition.runtime === "server" && (!o || o.has(r.id)) && s.push(r);
14
+ let { items: i } = r.definition;
15
+ i && d.push(...i);
15
16
  }
16
- return a;
17
- }, n = (e, n) => t(e, n).length > 0;
17
+ return s;
18
+ }, r = (e, t, r) => n(e, t, void 0, r).length > 0;
18
19
  //#endregion
19
- export { t as collectServerElements, n as hasServerElements };
20
+ export { n as collectServerElements, r as hasServerElements };
@@ -0,0 +1,7 @@
1
+ import { Snippet } from '../types';
2
+ /**
3
+ * Whether a document read from somewhere — an upload, a file on a CDN — is a snippet a builder can show and drop: a
4
+ * name, a base element that is in its elements, and a style to dress them. Its shape only; whether what it holds is
5
+ * sound is `validateSnippet`'s to say (`@plitzi/sdk-authoring`).
6
+ */
7
+ export declare const isSnippet: (value: unknown) => value is Snippet;
@@ -0,0 +1,9 @@
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
2
+ //#region src/schema/snippet.ts
3
+ var t = (t) => {
4
+ if (!e(t) || !e(t.definition) || !e(t.schema) || !e(t.style)) return !1;
5
+ let { definition: n, schema: r, style: i } = t;
6
+ return typeof n.name != "string" || typeof n.baseElementId != "string" ? !1 : e(r.flat) && e(r.flat[n.baseElementId]) && Array.isArray(r.variables) && e(i.platform);
7
+ };
8
+ //#endregion
9
+ export { t as isSnippet };
@@ -0,0 +1,11 @@
1
+ import { Element, Schema, SchemaRaw, WireElement } from '../types';
2
+ /** A schema as the channel carries it: `flat` as a list. What every publisher of a whole schema sends. */
3
+ export declare const schemaToWire: (schema: Schema) => SchemaRaw;
4
+ /** An element as the store holds it: what the wire sent `null` for is absent, as it is in the document. */
5
+ export declare const elementFromWire: ({ definition, ...element }: WireElement) => Element;
6
+ /**
7
+ * A schema off the wire — the live channel or a GraphQL answer — keyed again by element id: what a receiver stores.
8
+ * The one way in for both, so an element whose missing gate arrived as `null` never reaches code that reads absent as
9
+ * `undefined`.
10
+ */
11
+ export declare const schemaFromWire: (raw: SchemaRaw) => Schema;
@@ -0,0 +1,27 @@
1
+ //#region src/schema/wire.ts
2
+ var e = (e) => ({
3
+ ...e,
4
+ flat: Object.values(e.flat)
5
+ }), t = ({ definition: e, ...t }) => {
6
+ let { parentId: n, items: r, bindings: i, interactions: a, initialState: o, runtime: s, loadStrategy: c, flag: l, anchor: u, ...d } = e;
7
+ return {
8
+ ...t,
9
+ definition: {
10
+ ...d,
11
+ ...n == null ? {} : { parentId: n },
12
+ ...r == null ? {} : { items: r },
13
+ ...i == null ? {} : { bindings: i },
14
+ ...a == null ? {} : { interactions: a },
15
+ ...o == null ? {} : { initialState: o },
16
+ ...s == null ? {} : { runtime: s },
17
+ ...c == null ? {} : { loadStrategy: c },
18
+ ...l == null ? {} : { flag: l },
19
+ ...u == null ? {} : { anchor: u }
20
+ }
21
+ };
22
+ }, n = (e) => ({
23
+ ...e,
24
+ flat: Object.fromEntries(e.flat.map((e) => [e.id, t(e)]))
25
+ });
26
+ //#endregion
27
+ export { t as elementFromWire, n as schemaFromWire, e as schemaToWire };
@@ -0,0 +1,9 @@
1
+ import { ServerSSR } from '../../types';
2
+ /**
3
+ * Seeds where this origin resizes remote pictures, once, at the SDK root — as `useRealtimeSync` does for channels.
4
+ *
5
+ * Only a server that mounts the endpoint publishes the path, so a render without one (the builder, an embed, a client
6
+ * project) keeps every image on its own `src` rather than pointing it at a 404.
7
+ */
8
+ declare const useImagesSync: (ssr?: ServerSSR) => void;
9
+ export default useImagesSync;
@@ -0,0 +1,7 @@
1
+ import { useCommonStoreSync as e } from "../../store/index.mjs";
2
+ //#region src/server/actions/useImagesSync.ts
3
+ var t = (t) => {
4
+ e(["images.endpoint"], [t?.imagePath]);
5
+ };
6
+ //#endregion
7
+ export { t as default };
@@ -1,6 +1,6 @@
1
1
  import { authFailureFromResponse as e, reportAuthFailure as t } from "../../auth/failureChannel.mjs";
2
- import { hasServerElements as n } from "../../schema/serverElements.mjs";
3
- import { recordRenderActionRuns as r } from "../../store/actionRuns/actionRunsRecorder.mjs";
2
+ import { recordRenderActionRuns as n } from "../../store/actionRuns/actionRunsRecorder.mjs";
3
+ import { hasServerElements as r } from "../../schema/serverElements.mjs";
4
4
  import { getPaths as i, matchRoutePath as a } from "../../navigation/routes.mjs";
5
5
  //#region src/server/rsc/refreshRsc.ts
6
6
  var o = (e, t, n) => {
@@ -10,11 +10,11 @@ var o = (e, t, n) => {
10
10
  }, s = (e) => `rsc.data.${e}`, c = () => typeof window > "u" ? "" : `${window.location.pathname}${window.location.search}`, l = async (i, a, u, d, f = !1) => {
11
11
  let { enabled: p, endpoint: m } = i.get("rsc") ?? {};
12
12
  if (!p || !m || typeof window > "u") return;
13
- let h = d ?? c(), g = i.get("schema"), _ = i.get("runtime.sources.auth"), v = d ? o(g, d, !!_?.details) : i.get("navigation.currentPageId");
14
- if (g && n(g, v)) try {
15
- let n = new URLSearchParams({ location: h });
16
- a?.length && n.set("ids", a.join(",")), Object.entries(u ?? {}).forEach(([e, t]) => n.set(e, t));
17
- let o = await fetch(`${m}?${n.toString()}`, { headers: { Accept: "application/json" } });
13
+ let h = d ?? c(), g = i.get("schema"), _ = i.get("runtime.sources.auth"), v = d ? o(g, d, !!_?.details) : i.get("navigation.currentPageId"), y = d ? void 0 : i.get("runtime.sources.flags");
14
+ if (g && r(g, v, y)) try {
15
+ let r = new URLSearchParams({ location: h });
16
+ a?.length && r.set("ids", a.join(",")), Object.entries(u ?? {}).forEach(([e, t]) => r.set(e, t));
17
+ let o = await fetch(`${m}?${r.toString()}`, { headers: { Accept: "application/json" } });
18
18
  if (!o.ok) {
19
19
  let n = e(o.status, await o.json().catch(() => void 0));
20
20
  if (n && await t({
@@ -25,7 +25,7 @@ var o = (e, t, n) => {
25
25
  return;
26
26
  }
27
27
  let { serverData: c, actionRuns: p } = await o.json();
28
- p?.length && r(p), i.batch(() => {
28
+ p?.length && n(p), i.batch(() => {
29
29
  a?.length ? Object.entries(c ?? {}).forEach(([e, t]) => i.set(s(e), t)) : i.set("rsc.data", c ?? {}), i.set("rsc.loaded", !0), i.set("rsc.stale", !1), i.set("rsc.location", h);
30
30
  });
31
31
  } catch {