@almadar/shell-web 0.0.0-stage → 1.0.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.
Files changed (266) hide show
  1. package/bundling.d.mts +18 -0
  2. package/bundling.mjs +28 -0
  3. package/dist/ArbitraryClassCompiler-CO_iASBn.d.ts +195 -0
  4. package/dist/AvlGlyph-EPJKFEO3.js +6 -0
  5. package/dist/AvlStateMachine-RKZIKNGC.js +9 -0
  6. package/dist/AvlTransitionDetail-63SD6GZF.js +11 -0
  7. package/dist/AvlTransitionExplainer-ZBTLOM3T.js +12 -0
  8. package/dist/BehaviorView-YS5G4GNB.js +11 -0
  9. package/dist/Canvas3DHost-BkZQB5l2.d.ts +552 -0
  10. package/dist/EventBusProvider-BFFHfN4O.d.ts +296 -0
  11. package/dist/FileTree-BCFnBEuQ.d.ts +254 -0
  12. package/dist/FlowCanvas-3JRMNJLV.css +1756 -0
  13. package/dist/FlowCanvas-AUMTWMNG.js +26 -0
  14. package/dist/GameAudioProvider-ceM_n0ey.d.ts +90 -0
  15. package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
  16. package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
  17. package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
  18. package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
  19. package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
  20. package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
  21. package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
  22. package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
  23. package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
  24. package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
  25. package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
  26. package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
  27. package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
  28. package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
  29. package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
  30. package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
  31. package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
  32. package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
  33. package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
  34. package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
  35. package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
  36. package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
  37. package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
  38. package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
  39. package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
  40. package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
  41. package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
  42. package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
  43. package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
  44. package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
  45. package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
  46. package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
  47. package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
  48. package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
  49. package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
  50. package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
  51. package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
  52. package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
  53. package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
  54. package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
  55. package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
  56. package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
  57. package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
  58. package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
  59. package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
  60. package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
  61. package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
  62. package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
  63. package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
  64. package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
  65. package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
  66. package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
  67. package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
  68. package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
  69. package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
  70. package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
  71. package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
  72. package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
  73. package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
  74. package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
  75. package/dist/KernelEngineContext-CcxGYtlr.d.ts +33 -0
  76. package/dist/LayersPanel-M2LHWUFF.js +6 -0
  77. package/dist/ModuleCard-QHDGK5XK.js +7 -0
  78. package/dist/OrbInspector-MHLJ6OEE.css +1756 -0
  79. package/dist/OrbInspector-QCPEPUPH.js +26 -0
  80. package/dist/Select-B-iDdnvE.d.ts +185 -0
  81. package/dist/ServerBridge-Bqsj-lOU.d.ts +124 -0
  82. package/dist/ThemeContext-DJmO59xd.d.ts +147 -0
  83. package/dist/UISlotContext-Dl_ewwCI.d.ts +79 -0
  84. package/dist/UISlotRenderer-C7WWOK43.js +26 -0
  85. package/dist/UISlotRenderer-KVFO6J7R.css +1756 -0
  86. package/dist/auth/browser/index.d.ts +2 -0
  87. package/dist/auth/browser/index.js +2 -0
  88. package/dist/auth/react/index.d.ts +56 -0
  89. package/dist/auth/react/index.js +157 -0
  90. package/dist/avl/index.css +1756 -0
  91. package/dist/avl/index.d.ts +2248 -0
  92. package/dist/avl/index.js +2693 -0
  93. package/dist/avl-3d-context-BycmO6tG.d.ts +201 -0
  94. package/dist/avl-schema-parser-CtJxJ9KU.d.ts +132 -0
  95. package/dist/avl-zoom-state-CKMVuBFg.d.ts +17 -0
  96. package/dist/chunk-3BBUBJFF.js +339 -0
  97. package/dist/chunk-3S54FWRC.js +131 -0
  98. package/dist/chunk-3VZ36ZKO.js +775 -0
  99. package/dist/chunk-4T3P43NS.js +1133 -0
  100. package/dist/chunk-4YXBKHHM.js +11488 -0
  101. package/dist/chunk-57DC34LY.js +525 -0
  102. package/dist/chunk-5QTYQTPS.js +15 -0
  103. package/dist/chunk-A2LR6VQQ.js +349 -0
  104. package/dist/chunk-AB3X7QTE.js +505 -0
  105. package/dist/chunk-AE7VCQB6.js +561 -0
  106. package/dist/chunk-AGXD77SL.js +98 -0
  107. package/dist/chunk-AU7O65OX.js +66 -0
  108. package/dist/chunk-CPLN6NBQ.js +701 -0
  109. package/dist/chunk-DZBQA2OW.js +176 -0
  110. package/dist/chunk-E6KA4J6N.js +227 -0
  111. package/dist/chunk-EOWMARUB.js +16 -0
  112. package/dist/chunk-G7DCAZ22.js +19 -0
  113. package/dist/chunk-GFXCPUMX.js +1334 -0
  114. package/dist/chunk-HH5KSMH5.js +311 -0
  115. package/dist/chunk-ILQXJ2AR.js +280 -0
  116. package/dist/chunk-ILZ7ORX7.js +432 -0
  117. package/dist/chunk-K4MOPSEL.js +674 -0
  118. package/dist/chunk-LHP2TK7O.js +47587 -0
  119. package/dist/chunk-P4ZFUQFF.js +93 -0
  120. package/dist/chunk-PCR37T3U.js +296 -0
  121. package/dist/chunk-PRXQGGCO.js +580 -0
  122. package/dist/chunk-REXYVBUO.js +191 -0
  123. package/dist/chunk-ROICKAU7.js +24 -0
  124. package/dist/chunk-SP5CDJ6K.js +338 -0
  125. package/dist/chunk-TUPZWTRE.js +1051 -0
  126. package/dist/chunk-TXAUOLWZ.js +490 -0
  127. package/dist/chunk-TZZBINQY.js +82 -0
  128. package/dist/chunk-UTDC2NEA.js +14 -0
  129. package/dist/chunk-UU57VNS2.js +1053 -0
  130. package/dist/chunk-UXLE3IPR.js +421 -0
  131. package/dist/chunk-VO2TTLS5.js +94 -0
  132. package/dist/chunk-X3DMMX27.js +11 -0
  133. package/dist/chunk-YHMRX6YA.js +455 -0
  134. package/dist/components/index.css +1756 -0
  135. package/dist/components/index.d.ts +11299 -0
  136. package/dist/components/index.js +1110 -0
  137. package/dist/context/index.d.ts +8 -0
  138. package/dist/context/index.js +8 -0
  139. package/dist/core.d.ts +2599 -0
  140. package/dist/core.js +3 -0
  141. package/dist/design-classes/index.cjs +431 -0
  142. package/dist/design-classes/index.d.cts +165 -0
  143. package/dist/design-classes/index.d.ts +165 -0
  144. package/dist/design-classes/index.js +399 -0
  145. package/dist/emojiItems-QGSNAABW.js +20 -0
  146. package/dist/fx-CmQjnHmT.d.ts +371 -0
  147. package/dist/hooks/index.d.ts +971 -0
  148. package/dist/hooks/index.js +8 -0
  149. package/dist/index.d.ts +408 -0
  150. package/dist/index.js +178 -0
  151. package/dist/katexPlugin-FA7NX4PE.css +1161 -0
  152. package/dist/katexPlugin-NCDKOOQY.js +2 -0
  153. package/dist/kernel-client-TZKGHJRY.js +516 -0
  154. package/dist/kernel-wire-wNdAPfhJ.d.ts +88 -0
  155. package/dist/lib/index.d.ts +602 -0
  156. package/dist/lib/index.js +1289 -0
  157. package/dist/paintDispatch-CuJLsr9Y.d.ts +688 -0
  158. package/dist/parseLessonSegments-GpCeMrb2.d.ts +334 -0
  159. package/dist/perf-CKiBKbkw.d.ts +22 -0
  160. package/dist/perf-Dr28-AgT.d.ts +57 -0
  161. package/dist/prism-X5YWKXO5.js +136 -0
  162. package/dist/providers/index.css +1756 -0
  163. package/dist/providers/index.d.ts +355 -0
  164. package/dist/providers/index.js +29 -0
  165. package/dist/renderer/index.d.ts +465 -0
  166. package/dist/renderer/index.js +4 -0
  167. package/dist/runtime/index.css +1756 -0
  168. package/dist/runtime/index.d.ts +239 -0
  169. package/dist/runtime/index.js +28 -0
  170. package/dist/slot-host-CPzrxLo9.d.ts +48 -0
  171. package/dist/ssr/index.cjs +9739 -0
  172. package/dist/ssr/index.d.cts +464 -0
  173. package/dist/ssr/index.d.ts +464 -0
  174. package/dist/ssr/index.js +9703 -0
  175. package/dist/storage/browser/index.d.ts +1 -0
  176. package/dist/storage/browser/index.js +2 -0
  177. package/dist/test-support.d.ts +42 -0
  178. package/dist/test-support.js +181 -0
  179. package/dist/themeTokens-CRd8AEDF.d.ts +125 -0
  180. package/dist/three/index.css +503 -0
  181. package/dist/three/index.d.ts +1185 -0
  182. package/dist/three/index.js +3908 -0
  183. package/dist/useUISlots-CiobNFGb.d.ts +211 -0
  184. package/dist/verification-C5pTeMJv.d.ts +66 -0
  185. package/dist/verificationRegistry-CVrcxG1s.d.ts +122 -0
  186. package/dist/wrapCallbackForEvent-B9QLbhxX.d.ts +19 -0
  187. package/index.css +199 -0
  188. package/package.json +273 -3
  189. package/src/core/lib/band-shapes.json +7 -0
  190. package/src/core/locales/ar.json +1276 -0
  191. package/src/core/locales/en.json +1276 -0
  192. package/src/core/locales/index.ts +54 -0
  193. package/src/core/locales/sl.json +1276 -0
  194. package/src/core/tokens/native-tokens.json +369 -0
  195. package/tailwind-compile.cjs +29 -0
  196. package/tailwind-preset.cjs +1020 -0
  197. package/themes/_base.css +451 -0
  198. package/themes/_contract.md +307 -0
  199. package/themes/_fonts-kenney.css +11 -0
  200. package/themes/_fonts.css +12 -0
  201. package/themes/_foundation.css +105 -0
  202. package/themes/_head.css +22 -0
  203. package/themes/_presets.css +67 -0
  204. package/themes/almadar-heritage.css +455 -0
  205. package/themes/almadar-website.css +269 -0
  206. package/themes/almadar.css +269 -0
  207. package/themes/aqua.css +455 -0
  208. package/themes/arabesque.css +459 -0
  209. package/themes/art-deco.css +457 -0
  210. package/themes/art-nouveau.css +459 -0
  211. package/themes/atelier.css +463 -0
  212. package/themes/bauhaus.css +461 -0
  213. package/themes/bloomberg-dense.css +463 -0
  214. package/themes/blueprint.css +457 -0
  215. package/themes/clay.css +449 -0
  216. package/themes/comic.css +453 -0
  217. package/themes/constructivist.css +457 -0
  218. package/themes/corporate.css +449 -0
  219. package/themes/cyberpunk.css +453 -0
  220. package/themes/frutiger-aero.css +458 -0
  221. package/themes/game-adventure.css +201 -0
  222. package/themes/game-rpg.css +203 -0
  223. package/themes/game-sci-fi.css +201 -0
  224. package/themes/game-ui-pack.css +200 -0
  225. package/themes/gazette.css +449 -0
  226. package/themes/glass.css +457 -0
  227. package/themes/gothic.css +453 -0
  228. package/themes/index.css +21 -0
  229. package/themes/ink-wash.css +459 -0
  230. package/themes/kawaii.css +459 -0
  231. package/themes/kflow.css +310 -0
  232. package/themes/kiosk.css +449 -0
  233. package/themes/linear-clean.css +463 -0
  234. package/themes/luxury.css +451 -0
  235. package/themes/mac-classic.css +455 -0
  236. package/themes/material.css +463 -0
  237. package/themes/memphis.css +453 -0
  238. package/themes/mid-century.css +455 -0
  239. package/themes/minimalist.css +449 -0
  240. package/themes/mudcloth.css +459 -0
  241. package/themes/nata.css +310 -0
  242. package/themes/neon.css +453 -0
  243. package/themes/neumorphic.css +451 -0
  244. package/themes/newsprint.css +455 -0
  245. package/themes/notion-editorial.css +463 -0
  246. package/themes/orb.css +465 -0
  247. package/themes/pixel.css +449 -0
  248. package/themes/prism.css +309 -0
  249. package/themes/rawi.css +310 -0
  250. package/themes/retro.css +452 -0
  251. package/themes/risograph.css +463 -0
  252. package/themes/scandi.css +469 -0
  253. package/themes/sketch.css +455 -0
  254. package/themes/solarpunk.css +469 -0
  255. package/themes/steampunk.css +451 -0
  256. package/themes/swiss.css +455 -0
  257. package/themes/terminal.css +466 -0
  258. package/themes/trait-wars.css +487 -0
  259. package/themes/ukiyo-e.css +459 -0
  260. package/themes/vaporwave.css +455 -0
  261. package/themes/victorian.css +453 -0
  262. package/themes/wabi-sabi.css +459 -0
  263. package/themes/win95.css +455 -0
  264. package/themes/wireframe.css +439 -0
  265. package/themes/zine.css +455 -0
  266. package/README.md +0 -3
@@ -0,0 +1,775 @@
1
+ import { __export, __reExport } from './chunk-G7DCAZ22.js';
2
+ import { NativeMemoryPersistenceAdapter } from '@almadar/shell-runtime/persistence/native-memory';
3
+ import * as local_store_transport_star from '@almadar/shell-runtime/runtime/evaluation/local-store-transport';
4
+ import { openLocalKernel as openLocalKernel$1 } from '@almadar/shell-runtime/runtime/evaluation/local-store-transport';
5
+ import { readPageFacts } from '@almadar/shell-browser/page-facts';
6
+ import { instancesForLocale, orbitalInlineEntities, storesRowsInBrowser, isRoutePage, tickEventKey, isJsonObject } from '@almadar/core';
7
+ import { createLogger, isLogLevelEnabled } from '@almadar/logger';
8
+ import { HostAskError, consentFromRedirect, performHostAnswer, hostAskReturn } from '@almadar/shell-runtime/kernel/host';
9
+ import { dispatchDeclaredInput } from '@almadar/shell-runtime/client/declared-input-dispatch';
10
+ import { IndexedDbPersistence } from '@almadar/shell-browser/storage';
11
+ export { eventRouteKey } from '@almadar/shell-runtime/runtime/events/identity/routing';
12
+ export { createResidenceTransport } from '@almadar/shell-runtime/runtime/evaluation/residence-transport';
13
+
14
+ function hasMemoryStore(kernel) {
15
+ return "MemoryStore" in kernel;
16
+ }
17
+ function nativeMemoryPersistence(kernel) {
18
+ if (!hasMemoryStore(kernel)) throw new Error("nativeMemoryPersistence: this kernel module exports no MemoryStore; install a kernel build that carries it");
19
+ return new NativeMemoryPersistenceAdapter(new kernel.MemoryStore());
20
+ }
21
+
22
+ // src/runtime/evaluation/local-store-transport.ts
23
+ var local_store_transport_exports = {};
24
+ __export(local_store_transport_exports, {
25
+ openLocalKernel: () => openLocalKernel
26
+ });
27
+ __reExport(local_store_transport_exports, local_store_transport_star);
28
+ var POLL_MS = 250;
29
+ function consentByPopup(env) {
30
+ return async (request) => {
31
+ const popup = env.open(request.authorizeUrl);
32
+ if (popup === null) throw new HostAskError("unavailable", "the browser blocked the consent window");
33
+ for (; ; ) {
34
+ if (popup.closed) throw new HostAskError("cancelled", "the viewer closed the consent window");
35
+ let href;
36
+ try {
37
+ href = popup.location.href;
38
+ } catch {
39
+ href = void 0;
40
+ }
41
+ if (href !== void 0 && href !== "about:blank" && new URL(href).origin === env.origin) {
42
+ popup.close();
43
+ return consentFromRedirect(href);
44
+ }
45
+ await env.wait(POLL_MS);
46
+ }
47
+ };
48
+ }
49
+ function browserConsentEnv(win) {
50
+ return {
51
+ origin: win.location.origin,
52
+ open: (url) => win.open(url, "almadar-consent", "popup,width=520,height=720"),
53
+ wait: (ms) => new Promise((resolve) => win.setTimeout(resolve, ms))
54
+ };
55
+ }
56
+
57
+ // src/lib/host-actions.ts
58
+ var log = createLogger("almadar:ui:host-actions");
59
+ var audioHost;
60
+ var signOutHost;
61
+ var signInHost;
62
+ var consentHost;
63
+ function registerHostAudio(host) {
64
+ audioHost = host;
65
+ return () => {
66
+ if (audioHost === host) audioHost = void 0;
67
+ };
68
+ }
69
+ function registerHostSignOut(host) {
70
+ signOutHost = host;
71
+ return () => {
72
+ if (signOutHost === host) signOutHost = void 0;
73
+ };
74
+ }
75
+ function registerHostSignIn(host) {
76
+ signInHost = host;
77
+ return () => {
78
+ if (signInHost === host) signInHost = void 0;
79
+ };
80
+ }
81
+ function registerHostConsent(host) {
82
+ consentHost = host;
83
+ return () => {
84
+ if (consentHost === host) consentHost = void 0;
85
+ };
86
+ }
87
+ var webHostActions = {
88
+ get audio() {
89
+ return audioHost;
90
+ },
91
+ get signOut() {
92
+ return signOutHost;
93
+ },
94
+ get signIn() {
95
+ return signInHost;
96
+ },
97
+ get consent() {
98
+ return consentHost ?? (typeof window === "undefined" ? void 0 : consentByPopup(browserConsentEnv(window)));
99
+ }
100
+ };
101
+ var traceStreams = /* @__PURE__ */ new Map();
102
+ function streamTrace(args, completion, dispatch, source) {
103
+ const { key, onMessage, failure, trait } = completion;
104
+ if (key === void 0 || onMessage === void 0) return;
105
+ const refuse = (error) => {
106
+ log.error("trace stream refused", { trait, key, error });
107
+ if (failure !== void 0 && dispatch !== void 0) void dispatch(trait, failure, { error, key, ...completion.entityId !== void 0 ? { entityId: completion.entityId } : {} });
108
+ };
109
+ const options = args[0];
110
+ const named = options !== void 0 && options !== null && isJsonObject(options) ? options["traits"] : void 0;
111
+ const traits = Array.isArray(named) ? named.flatMap((t) => typeof t === "string" ? [t] : []) : [];
112
+ if (traits.length === 0) return refuse("program/live trace: name the traits it observes in `traits`");
113
+ if (source === void 0 || dispatch === void 0) return refuse("program/live trace: this host has no kernel trace to stream");
114
+ if (traceStreams.has(key)) return refuse(`key ${key} already has a stream open`);
115
+ traceStreams.set(key, source(traits, (item) => {
116
+ void dispatch(trait, onMessage, { ...item, key, ...completion.entityId !== void 0 ? { entityId: completion.entityId } : {} }).catch((error) => log.error("trace item return failed", { trait, key, error: error.message }));
117
+ }));
118
+ }
119
+ function cancelStreams(args) {
120
+ const named = args[0];
121
+ const keys = typeof named === "string" ? [named] : Array.isArray(named) ? named.flatMap((k) => typeof k === "string" ? [k] : []) : [];
122
+ for (const key of keys) {
123
+ traceStreams.get(key)?.();
124
+ traceStreams.delete(key);
125
+ }
126
+ }
127
+ async function answerHostAsk(op, args, completion, dispatch, trace) {
128
+ if (op === "cancel-call") return cancelStreams(args);
129
+ if (op === "program/live" && completion?.onMessage !== void 0) return streamTrace(args, completion, dispatch, trace);
130
+ const outcome = await performHostAnswer(webHostActions, op, args);
131
+ if ("error" in outcome) log.error("host-ask refused", { op, error: outcome.error, kind: outcome.kind });
132
+ if (completion === void 0) return;
133
+ const returned = hostAskReturn(completion, outcome);
134
+ if (returned === void 0) return;
135
+ if (dispatch === void 0) {
136
+ log.error("host-ask has no dispatch to return its answer to", { op, trait: returned.trait, event: returned.event });
137
+ return;
138
+ }
139
+ await dispatch(returned.trait, returned.event, returned.entityId !== void 0 ? { ...returned.payload, entityId: returned.entityId } : returned.payload);
140
+ }
141
+
142
+ // src/runtime/evaluation/local-store-transport.ts
143
+ function openLocalKernel(options) {
144
+ return openLocalKernel$1({ ...options, pageFacts: options.pageFacts ?? readPageFacts, hostActions: options.hostActions ?? webHostActions });
145
+ }
146
+ async function persistedMemory(kernel, database, entities, locale) {
147
+ const memory = nativeMemoryPersistence(kernel);
148
+ const firstVisit = (await database.changes()).length === 0;
149
+ for (const entity of entities) {
150
+ if (firstVisit) {
151
+ for (const row of instancesForLocale(entity, locale)) await database.create(entity.name, row);
152
+ }
153
+ for (const row of await database.list(entity.name)) {
154
+ await memory.writeWhere({ kind: "upsert", entityType: entity.name, data: row });
155
+ }
156
+ }
157
+ const keep = async (entityType, row) => {
158
+ await database.create(entityType, row);
159
+ };
160
+ const mirror = async (op, outcome) => {
161
+ if (outcome.kind === "created") await keep(op.entityType, outcome.row);
162
+ else if (outcome.kind === "updated") {
163
+ if (op.kind === "rekey") await database.delete(op.entityType, op.id);
164
+ await keep(op.entityType, outcome.row);
165
+ } else if (outcome.kind === "deleted" && op.kind !== "create" && op.kind !== "upsert") await database.delete(op.entityType, op.id);
166
+ };
167
+ return {
168
+ getById: (entityType, id) => memory.getById(entityType, id),
169
+ list: (entityType) => memory.list(entityType),
170
+ queryPage: (entityType, query) => memory.queryPage(entityType, query),
171
+ queryIds: (entityType, query) => memory.queryIds(entityType, query),
172
+ queryCapabilities: (entityType) => memory.queryCapabilities(entityType),
173
+ writeCapabilities: (entityType) => memory.writeCapabilities(entityType),
174
+ bindCollection: (entityType, collection) => memory.bindCollection(entityType, collection),
175
+ async create(entityType, data) {
176
+ const { id } = await memory.create(entityType, data);
177
+ const row = await memory.getById(entityType, id);
178
+ if (row !== null) await keep(entityType, row);
179
+ return { id };
180
+ },
181
+ async update(entityType, id, data) {
182
+ await memory.update(entityType, id, data);
183
+ const row = await memory.getById(entityType, id);
184
+ if (row !== null) await keep(entityType, row);
185
+ },
186
+ async delete(entityType, id) {
187
+ await memory.delete(entityType, id);
188
+ await database.delete(entityType, id);
189
+ },
190
+ async writeWhere(op) {
191
+ const outcome = await memory.writeWhere(op);
192
+ await mirror(op, outcome);
193
+ return outcome;
194
+ },
195
+ async writeBatch(batch) {
196
+ const outcomes = await memory.writeBatch(batch);
197
+ for (const [index, op] of batch.ops.entries()) {
198
+ const outcome = outcomes[index];
199
+ if (outcome !== void 0) await mirror(op, outcome);
200
+ }
201
+ return outcomes;
202
+ }
203
+ };
204
+ }
205
+ function browserStoreName(appName, locale) {
206
+ return locale !== void 0 ? `almadar:${appName}:${locale}` : `almadar:${appName}`;
207
+ }
208
+ async function openBrowserStore(databaseName, orbitals, factory) {
209
+ const entities = orbitals.flatMap(orbitalInlineEntities).filter(storesRowsInBrowser);
210
+ if (entities.length === 0) return null;
211
+ return IndexedDbPersistence.open({
212
+ databaseName,
213
+ entityTypes: entities.map((e) => e.name),
214
+ ...factory !== void 0 ? { factory } : {}
215
+ });
216
+ }
217
+ function browserEntities(orbitals) {
218
+ return orbitals.flatMap(orbitalInlineEntities).filter(storesRowsInBrowser);
219
+ }
220
+ async function openBrowserStoreTransport(options) {
221
+ const stored = await openBrowserStore(options.databaseName, options.schema.orbitals, options.factory);
222
+ if (stored === null && options.callService === void 0) {
223
+ throw new Error(`openBrowserStoreTransport: schema "${options.schema.name}" declares no browser-stored entity`);
224
+ }
225
+ const memory = nativeMemoryPersistence(options.kernel);
226
+ const persistence = (0, local_store_transport_exports.localStorePersistence)(options.schema, stored === null ? memory : await persistedMemory(options.kernel, stored, browserEntities(options.schema.orbitals), options.locale), memory);
227
+ return (0, local_store_transport_exports.createLocalStoreTransport)({
228
+ kernelEngine: openLocalKernel({
229
+ kernel: options.kernel,
230
+ schema: options.schema,
231
+ persistence,
232
+ ...options.callService !== void 0 ? { callService: options.callService } : {},
233
+ ...options.secretPorts !== void 0 ? { secretPorts: options.secretPorts } : {},
234
+ ...options.os !== void 0 ? { os: options.os } : {}
235
+ }),
236
+ ...options.locale !== void 0 ? { locale: () => options.locale } : {}
237
+ });
238
+ }
239
+ function openBundledBrowserStore(schema, kernel, locale, callService, secretPorts, os) {
240
+ return openBrowserStoreTransport({
241
+ databaseName: browserStoreName(schema.name, locale),
242
+ schema,
243
+ ...locale !== void 0 ? { locale } : {},
244
+ kernel,
245
+ ...callService !== void 0 ? { callService } : {},
246
+ ...secretPorts !== void 0 ? { secretPorts } : {},
247
+ ...os !== void 0 ? { os } : {}
248
+ });
249
+ }
250
+ var tickLog = createLogger("almadar:runtime:browser-host:ticks");
251
+ var queueLog = createLogger("almadar:runtime:browser-host:queue");
252
+ var TICK_PASS_MS = 16;
253
+ async function openBrowserHost(options) {
254
+ const browserStore = await openBrowserStore(options.databaseName, options.schema.orbitals, options.factory);
255
+ const memory = nativeMemoryPersistence(options.kernel);
256
+ const persistence = (0, local_store_transport_exports.localStorePersistence)(options.schema, browserStore === null ? memory : await persistedMemory(options.kernel, browserStore, browserEntities(options.schema.orbitals), options.locale), memory);
257
+ const { schema } = options;
258
+ let transport;
259
+ const listeners = /* @__PURE__ */ new Set();
260
+ const servicePorts = (caller, user, message, assertReentry) => {
261
+ return {
262
+ caller,
263
+ inputs: () => kernelEngine.externalInputs(),
264
+ readableEntities: () => kernelEngine.readableEntities(),
265
+ dispatchInput: (orbital, request) => {
266
+ const host = transport;
267
+ if (!host) return Promise.reject(new Error("openBrowserHost: the host is not open yet"));
268
+ assertReentry?.();
269
+ return dispatchDeclaredInput(kernelEngine, orbital, request, async (o, r) => {
270
+ const response = await host.send(o, r);
271
+ for (const listener of listeners) listener(o, r, response);
272
+ return response;
273
+ });
274
+ },
275
+ read: async (entity) => kernelEngine.readRows(entity, await persistence.list(entity), user),
276
+ message
277
+ };
278
+ };
279
+ let deferred;
280
+ const kernelEngine = openLocalKernel({
281
+ kernel: options.kernel,
282
+ schema,
283
+ persistence,
284
+ callService: options.callService,
285
+ servicePorts,
286
+ deferCallOutcome: () => deferred,
287
+ ...options.secretPorts !== void 0 ? { secretPorts: options.secretPorts } : {},
288
+ ...options.onDevice !== void 0 ? { onDevice: options.onDevice } : {},
289
+ ...options.tabs !== void 0 ? { tabs: options.tabs } : {},
290
+ ...options.os !== void 0 ? { os: options.os } : {}
291
+ });
292
+ const local = (0, local_store_transport_exports.createLocalStoreTransport)({ kernelEngine });
293
+ transport = local;
294
+ deferred = (call) => {
295
+ const request = {
296
+ event: call.event,
297
+ ...call.payload !== void 0 ? { payload: call.payload } : {},
298
+ targetTrait: call.traitName,
299
+ ...call.entityId !== void 0 ? { entityId: call.entityId } : {},
300
+ ...call.originClientId !== void 0 ? { clientId: call.originClientId } : {},
301
+ ...call.locale !== void 0 ? { locale: call.locale } : {}
302
+ };
303
+ void local.send(call.orbital, request).then((response) => {
304
+ for (const listener of listeners) listener(call.orbital, request, response);
305
+ }).catch((error) => {
306
+ queueLog.error("deferred-outcome:failed", { orbital: call.orbital, event: call.event, trait: call.traitName, error: error.message });
307
+ });
308
+ };
309
+ const runnable = /* @__PURE__ */ new Map();
310
+ for (const trait of kernelEngine.programSurface().traits) {
311
+ for (const tick of trait.ticks) {
312
+ runnable.set(`${trait.name}::${tick.name}`, { orbitalName: trait.orbital, traitName: trait.name, tickName: tick.name });
313
+ }
314
+ }
315
+ const firing = /* @__PURE__ */ new Set();
316
+ const fire = (key, tick) => {
317
+ if (firing.has(key)) return;
318
+ firing.add(key);
319
+ const request = {
320
+ event: tickEventKey(tick.tickName),
321
+ runTick: { trait: tick.traitName, tick: tick.tickName },
322
+ targetTrait: tick.traitName,
323
+ tick: tick.tickName
324
+ };
325
+ void local.send(tick.orbitalName, request).then((response) => {
326
+ if (response.transitioned) for (const listener of listeners) listener(tick.orbitalName, request, response);
327
+ }).catch((error) => {
328
+ tickLog.error("tick:failed", { orbital: tick.orbitalName, trait: tick.traitName, tick: tick.tickName, error: error.message });
329
+ }).finally(() => {
330
+ firing.delete(key);
331
+ });
332
+ };
333
+ const timer = runnable.size === 0 ? void 0 : setInterval(() => {
334
+ for (const due of Object.values(kernelEngine.tickPass(performance.now())).flat()) {
335
+ const key = `${due.trait}::${due.tick}`;
336
+ const tick = runnable.get(key);
337
+ if (tick !== void 0) fire(key, tick);
338
+ }
339
+ }, TICK_PASS_MS);
340
+ return {
341
+ ...local,
342
+ onInputDispatched(listener) {
343
+ listeners.add(listener);
344
+ return () => listeners.delete(listener);
345
+ },
346
+ routeMounts: (routePath) => kernelEngine.routeMounts(routePath),
347
+ close() {
348
+ if (timer !== void 0) clearInterval(timer);
349
+ }
350
+ };
351
+ }
352
+
353
+ // src/runtime/ui/contract-errors.ts
354
+ var RendererContractViolationError = class extends Error {
355
+ constructor(message) {
356
+ super(message);
357
+ this.name = "RendererContractViolationError";
358
+ }
359
+ };
360
+
361
+ // src/runtime/ui/slots.ts
362
+ function aggregateSlotContent(slot, sources) {
363
+ const entries = Array.from(sources.values());
364
+ if (entries.length === 0) return void 0;
365
+ if (entries.length === 1) return entries[0];
366
+ Array.from(sources.keys());
367
+ const children = entries.map((entry) => ({
368
+ type: entry.pattern?.type ?? "box",
369
+ ...entry.props
370
+ }));
371
+ return {
372
+ slot,
373
+ pattern: { type: "stack", direction: "vertical", gap: "lg", children },
374
+ props: { direction: "vertical", gap: "lg", children },
375
+ source: entries[0].source
376
+ };
377
+ }
378
+ function isNonNullObject(value) {
379
+ return typeof value === "object" && value !== null;
380
+ }
381
+ function assertHasFunctionMethods(label, value, methods) {
382
+ for (const method of methods) {
383
+ if (typeof value[method] !== "function") {
384
+ throw new RendererContractViolationError(`${label}.${method} must be a function`);
385
+ }
386
+ }
387
+ }
388
+ function assertIsSlotManager(value) {
389
+ if (!isNonNullObject(value)) {
390
+ throw new RendererContractViolationError("SlotManager must be a non-null object");
391
+ }
392
+ assertHasFunctionMethods("SlotManager", value, [
393
+ "getContent",
394
+ "setContent",
395
+ "clearSlot",
396
+ "getAllSlots",
397
+ "subscribe"
398
+ ]);
399
+ }
400
+ function assertIsMultiSourceSlotManager(value) {
401
+ if (!isNonNullObject(value)) {
402
+ throw new RendererContractViolationError("MultiSourceSlotManager must be a non-null object");
403
+ }
404
+ assertHasFunctionMethods("SlotManager", value, [
405
+ "getContent",
406
+ "setContent",
407
+ "clearSlot",
408
+ "getAllSlots",
409
+ "subscribe"
410
+ ]);
411
+ assertHasFunctionMethods("MultiSourceSlotManager", value, [
412
+ "getTraitContent",
413
+ "subscribeTrait",
414
+ "updateTraitContent"
415
+ ]);
416
+ }
417
+ function validateSlotContent(content) {
418
+ const errors = [];
419
+ if (content.slot === void 0 || content.slot === null) {
420
+ errors.push({ message: "SlotContent.slot is required", path: "slot" });
421
+ }
422
+ if (!("pattern" in content)) {
423
+ errors.push({ message: "SlotContent.pattern is required", path: "pattern" });
424
+ }
425
+ return errors;
426
+ }
427
+ function createSlotSetter(manager) {
428
+ return {
429
+ addPattern: (slot, pattern, props) => {
430
+ manager.setContent({
431
+ slot,
432
+ pattern,
433
+ props
434
+ });
435
+ },
436
+ clearSlot: (slot) => {
437
+ manager.clearSlot(slot);
438
+ }
439
+ };
440
+ }
441
+
442
+ // src/runtime/ui/wrapCallbackForEvent.ts
443
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
444
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
445
+ if (argNames.length === 0) {
446
+ return () => emit(qualifiedEvent);
447
+ }
448
+ return (...args) => {
449
+ const payload = {};
450
+ for (let i = 0; i < argNames.length; i += 1) {
451
+ payload[argNames[i]] = args[i];
452
+ }
453
+ emit(qualifiedEvent, payload);
454
+ };
455
+ }
456
+ function buildOrbitalsByTrait(schema, resolvedPages = []) {
457
+ const map = {};
458
+ if (!schema?.orbitals) return map;
459
+ const pagePathToOrbital = {};
460
+ for (const orb of schema.orbitals) {
461
+ for (const traitRef of orb.traits ?? []) {
462
+ let traitName;
463
+ if (typeof traitRef === "string") {
464
+ const parts = traitRef.split(".");
465
+ traitName = parts[parts.length - 1];
466
+ } else if ("ref" in traitRef && typeof traitRef.ref === "string") {
467
+ const parts = traitRef.ref.split(".");
468
+ traitName = traitRef.name ?? parts[parts.length - 1];
469
+ } else if ("name" in traitRef && typeof traitRef.name === "string") {
470
+ traitName = traitRef.name;
471
+ }
472
+ if (traitName) map[traitName] = orb.name;
473
+ }
474
+ for (const pg of orb.pages ?? []) {
475
+ const path = typeof pg === "string" ? pg : isRoutePage(pg) ? pg.path : void 0;
476
+ if (path) pagePathToOrbital[path] = orb.name;
477
+ }
478
+ }
479
+ for (const page of resolvedPages) {
480
+ const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
481
+ if (!orbital) continue;
482
+ for (const traitName of page.traitNames) {
483
+ if (traitName && !(traitName in map)) map[traitName] = orbital;
484
+ }
485
+ }
486
+ return map;
487
+ }
488
+
489
+ // src/runtime/ui/embedded-traits.ts
490
+ var TRAIT_BINDING_PREFIX = "@trait.";
491
+ function collectTraitRefsFromValue(value, into) {
492
+ if (value === null || value === void 0) return;
493
+ if (typeof value === "string") {
494
+ if (value.startsWith(TRAIT_BINDING_PREFIX)) {
495
+ const rest = value.slice(TRAIT_BINDING_PREFIX.length);
496
+ const dot = rest.indexOf(".");
497
+ const traitName = dot === -1 ? rest : rest.slice(0, dot);
498
+ if (traitName.length > 0) into.add(traitName);
499
+ }
500
+ return;
501
+ }
502
+ if (Array.isArray(value)) {
503
+ for (const item of value) collectTraitRefsFromValue(item, into);
504
+ return;
505
+ }
506
+ if (typeof value === "object") {
507
+ for (const v of Object.values(value)) {
508
+ collectTraitRefsFromValue(v, into);
509
+ }
510
+ }
511
+ }
512
+ function collectTraitRefsFromEffects(effects, into) {
513
+ if (!effects) return;
514
+ for (const effect of effects) {
515
+ if (!Array.isArray(effect)) continue;
516
+ if (effect[0] === "render-ui" && effect.length >= 3) {
517
+ collectTraitRefsFromValue(effect[2], into);
518
+ continue;
519
+ }
520
+ for (let i = 1; i < effect.length; i++) {
521
+ const arg = effect[i];
522
+ if (Array.isArray(arg)) collectTraitRefsFromEffects([arg], into);
523
+ else collectTraitRefsFromValue(arg, into);
524
+ }
525
+ }
526
+ }
527
+ function collectEmbeddedTraits(schema) {
528
+ const out = /* @__PURE__ */ new Set();
529
+ if (!schema?.orbitals) return out;
530
+ for (const orbital of schema.orbitals) {
531
+ const traits = orbital.traits;
532
+ if (!Array.isArray(traits)) continue;
533
+ for (const traitRef of traits) {
534
+ if (!traitRef || typeof traitRef !== "object") continue;
535
+ const resolved = traitRef._resolved;
536
+ const target = resolved && typeof resolved === "object" ? resolved : traitRef;
537
+ if (typeof traitRef !== "string" && "config" in traitRef && traitRef.config) {
538
+ collectTraitRefsFromValue(traitRef.config, out);
539
+ }
540
+ if (target.config) {
541
+ collectTraitRefsFromValue(target.config, out);
542
+ }
543
+ const transitions = target.stateMachine?.transitions;
544
+ if (!Array.isArray(transitions)) continue;
545
+ for (const t of transitions) {
546
+ collectTraitRefsFromEffects(t.effects, out);
547
+ }
548
+ collectTraitRefsFromEffects(target.initialEffects, out);
549
+ const ticks = target.ticks;
550
+ if (Array.isArray(ticks)) {
551
+ for (const tick of ticks) {
552
+ collectTraitRefsFromEffects(tick.effects, out);
553
+ }
554
+ }
555
+ }
556
+ }
557
+ return out;
558
+ }
559
+ var PERF_NAMESPACE = "almadar:perf:canvas";
560
+ var log2 = createLogger(PERF_NAMESPACE);
561
+ var RING_SIZE = 50;
562
+ var ring = [];
563
+ var writeIdx = 0;
564
+ var subscribers = /* @__PURE__ */ new Set();
565
+ var notifyScheduled = false;
566
+ var revision = 0;
567
+ var cachedSnapshot = [];
568
+ var cachedRevision = -1;
569
+ function scheduleNotify() {
570
+ if (notifyScheduled) return;
571
+ notifyScheduled = true;
572
+ queueMicrotask(() => {
573
+ notifyScheduled = false;
574
+ revision++;
575
+ for (const fn of subscribers) fn();
576
+ });
577
+ }
578
+ function push(entry) {
579
+ if (ring.length < RING_SIZE) {
580
+ ring.push(entry);
581
+ } else {
582
+ ring[writeIdx] = entry;
583
+ }
584
+ writeIdx = (writeIdx + 1) % RING_SIZE;
585
+ scheduleNotify();
586
+ }
587
+ function isEnabled() {
588
+ return isLogLevelEnabled("DEBUG", PERF_NAMESPACE) || globalThis.__ALMADAR_PERF__ === true;
589
+ }
590
+ function isVerbose() {
591
+ return isLogLevelEnabled("DEBUG", PERF_NAMESPACE);
592
+ }
593
+ function now() {
594
+ return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
595
+ }
596
+ function perfStart(name) {
597
+ if (!isEnabled()) return -1;
598
+ if (typeof performance !== "undefined" && typeof performance.mark === "function") {
599
+ try {
600
+ performance.mark(`${name}-start`);
601
+ } catch {
602
+ }
603
+ }
604
+ return now();
605
+ }
606
+ function perfEnd(name, startToken, detail) {
607
+ if (startToken < 0 || !isEnabled()) return;
608
+ const endTs = now();
609
+ const durationMs = endTs - startToken;
610
+ if (typeof performance !== "undefined" && typeof performance.measure === "function") {
611
+ try {
612
+ performance.mark(`${name}-end`);
613
+ performance.measure(name, `${name}-start`, `${name}-end`);
614
+ } catch {
615
+ }
616
+ }
617
+ push({ name, durationMs, ts: endTs, detail });
618
+ aggregate(name, durationMs);
619
+ if (isVerbose()) log2.debug(name, () => ({ durationMs, ...detail ?? {} }));
620
+ }
621
+ function perfTime(name, fn, detail) {
622
+ const t = perfStart(name);
623
+ try {
624
+ return fn();
625
+ } finally {
626
+ perfEnd(name, t, detail);
627
+ }
628
+ }
629
+ async function perfTimeAsync(name, fn) {
630
+ const t = perfStart(name);
631
+ try {
632
+ return await fn();
633
+ } finally {
634
+ perfEnd(name, t);
635
+ }
636
+ }
637
+ function perfGauge(name, value) {
638
+ if (!isEnabled()) return;
639
+ aggregate(name, value);
640
+ }
641
+ var buckets = /* @__PURE__ */ new Map();
642
+ var dumpTimer = null;
643
+ function aggregate(name, ms) {
644
+ const b = buckets.get(name);
645
+ if (b) {
646
+ b.count++;
647
+ b.totalMs += ms;
648
+ if (ms > b.maxMs) b.maxMs = ms;
649
+ } else {
650
+ buckets.set(name, { count: 1, totalMs: ms, maxMs: ms });
651
+ }
652
+ if (dumpTimer === null) {
653
+ dumpTimer = setInterval(dumpSummary, 5e3);
654
+ if (typeof dumpTimer === "object" && "unref" in dumpTimer) dumpTimer.unref();
655
+ }
656
+ }
657
+ function dumpSummary() {
658
+ if (buckets.size === 0) return;
659
+ const rows = [...buckets.entries()].map(([name, b]) => ({
660
+ name,
661
+ count: b.count,
662
+ totalMs: Math.round(b.totalMs),
663
+ avgMs: Math.round(b.totalMs / b.count * 100) / 100,
664
+ maxMs: Math.round(b.maxMs * 10) / 10
665
+ })).sort((a, b) => b.totalMs - a.totalMs);
666
+ log2.warn("[PROFILE] summary", { phases: JSON.stringify(rows) });
667
+ buckets.clear();
668
+ }
669
+ function getPerfSnapshot() {
670
+ if (ring.length < RING_SIZE) return ring.slice();
671
+ return [...ring.slice(writeIdx), ...ring.slice(0, writeIdx)];
672
+ }
673
+ function getSnapshot() {
674
+ if (cachedRevision !== revision) {
675
+ cachedSnapshot = getPerfSnapshot();
676
+ cachedRevision = revision;
677
+ }
678
+ return cachedSnapshot;
679
+ }
680
+ function subscribe(fn) {
681
+ subscribers.add(fn);
682
+ return () => {
683
+ subscribers.delete(fn);
684
+ };
685
+ }
686
+ function pushPerfEntry(entry) {
687
+ if (!isEnabled()) return;
688
+ push(entry);
689
+ }
690
+ function clearPerf() {
691
+ ring.length = 0;
692
+ writeIdx = 0;
693
+ scheduleNotify();
694
+ }
695
+ var perfStore = {
696
+ subscribe,
697
+ getSnapshot
698
+ };
699
+ var log3 = createLogger("almadar:runtime:verify");
700
+ var MAX_EVENT_LOG = 200;
701
+ var EMPTY_SUMMARY = {
702
+ totalChecks: 0,
703
+ passed: 0,
704
+ failed: 0,
705
+ warnings: 0,
706
+ pending: 0
707
+ };
708
+ function emptySnapshot() {
709
+ return {
710
+ checks: [],
711
+ transitions: [],
712
+ bridge: null,
713
+ summary: EMPTY_SUMMARY,
714
+ traits: []
715
+ };
716
+ }
717
+ function ensureVerificationApi() {
718
+ if (typeof window === "undefined") return void 0;
719
+ if (!window.__orbitalVerification) {
720
+ window.__orbitalVerification = {
721
+ getSnapshot: emptySnapshot,
722
+ getChecks: () => [],
723
+ getTransitions: () => [],
724
+ getBridge: () => null,
725
+ getSummary: () => EMPTY_SUMMARY,
726
+ waitForTransition: () => Promise.resolve(null),
727
+ getTraitSnapshots: () => []
728
+ };
729
+ }
730
+ return window.__orbitalVerification;
731
+ }
732
+ function getOrbitalVerification() {
733
+ if (typeof window === "undefined") return void 0;
734
+ return window.__orbitalVerification;
735
+ }
736
+ function bindEventBus(eventBus) {
737
+ const api = ensureVerificationApi();
738
+ if (!api) return;
739
+ api.sendEvent = (event, payload, traitScope) => {
740
+ const prefixed = event.startsWith("UI:") ? event : traitScope ? `UI:${traitScope}.${event}` : `UI:${event}`;
741
+ log3.debug("sendEvent", {
742
+ event: prefixed,
743
+ traitScope,
744
+ payloadKeys: payload ? Object.keys(payload) : []
745
+ });
746
+ eventBus.emit(prefixed, payload);
747
+ };
748
+ const eventLog = [];
749
+ api.eventLog = eventLog;
750
+ api.clearEventLog = () => {
751
+ eventLog.length = 0;
752
+ };
753
+ if (eventBus.onAny) {
754
+ const verificationEventLogger = (event) => {
755
+ if (eventLog.length < MAX_EVENT_LOG) {
756
+ eventLog.push({
757
+ type: event.type,
758
+ payload: event.payload,
759
+ timestamp: Date.now()
760
+ });
761
+ }
762
+ };
763
+ Object.defineProperty(verificationEventLogger, "name", {
764
+ value: "runtime-verify:eventLog"
765
+ });
766
+ eventBus.onAny(verificationEventLogger);
767
+ }
768
+ }
769
+ function bindTraitStateGetter(getter) {
770
+ const api = ensureVerificationApi();
771
+ if (!api) return;
772
+ api.getTraitState = getter;
773
+ }
774
+
775
+ export { PERF_NAMESPACE, RendererContractViolationError, aggregateSlotContent, answerHostAsk, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, browserStoreName, buildOrbitalsByTrait, clearPerf, collectEmbeddedTraits, createSlotSetter, ensureVerificationApi, getOrbitalVerification, local_store_transport_exports, nativeMemoryPersistence, openBrowserHost, openBrowserStore, openBrowserStoreTransport, openBundledBrowserStore, openLocalKernel, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, persistedMemory, pushPerfEntry, registerHostAudio, registerHostConsent, registerHostSignIn, registerHostSignOut, validateSlotContent, webHostActions, wrapCallbackForEvent };