@almadar/shell-web 0.0.0-stage → 0.1.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.
- package/bundling.d.mts +18 -0
- package/bundling.mjs +28 -0
- package/dist/ArbitraryClassCompiler-Mzabq-UB.d.ts +100 -0
- package/dist/AvlGlyph-JKJOAH23.js +6 -0
- package/dist/AvlStateMachine-PI4YGREK.js +8 -0
- package/dist/AvlTransitionDetail-ZH7V24UG.js +12 -0
- package/dist/AvlTransitionExplainer-ZSRT7L6Y.js +13 -0
- package/dist/BehaviorValueFrame-6RUJXT4A.js +29 -0
- package/dist/BehaviorValueFrame-SSEMEBTG.css +1756 -0
- package/dist/BehaviorView-RFEE5J6E.js +10 -0
- package/dist/Canvas3DHost-_Y-5uLM_.d.ts +552 -0
- package/dist/EventBusProvider-CVwjkV_2.d.ts +284 -0
- package/dist/FileTree-BCFnBEuQ.d.ts +254 -0
- package/dist/FlowCanvas-3JRMNJLV.css +1756 -0
- package/dist/FlowCanvas-STDC4OWK.js +27 -0
- package/dist/GameAudioProvider-Cm9BnvmP.d.ts +93 -0
- package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/dist/KernelEngineContext-BOCQoFwk.d.ts +43 -0
- package/dist/LayersPanel-BBQ54IVG.js +7 -0
- package/dist/ModuleCard-3TT2X7IW.js +7 -0
- package/dist/OrbInspector-K6T6O7GI.js +27 -0
- package/dist/OrbInspector-MHLJ6OEE.css +1756 -0
- package/dist/Select-mDZIwNqN.d.ts +199 -0
- package/dist/ServerBridge-Cm1On51b.d.ts +233 -0
- package/dist/ThemeContext-DJmO59xd.d.ts +147 -0
- package/dist/TraitValueFrame-2PJGLLVI.js +28 -0
- package/dist/TraitValueFrame-4G3KOUBR.css +1756 -0
- package/dist/UISlotContext-Dl_ewwCI.d.ts +79 -0
- package/dist/UISlotRenderer-JKFSX24W.js +27 -0
- package/dist/UISlotRenderer-KVFO6J7R.css +1756 -0
- package/dist/UserContext-DqWeZkUZ.d.ts +100 -0
- package/dist/auth/browser/index.d.ts +2 -0
- package/dist/auth/browser/index.js +1 -0
- package/dist/auth/react/index.d.ts +49 -0
- package/dist/auth/react/index.js +119 -0
- package/dist/avl/index.css +1756 -0
- package/dist/avl/index.d.ts +2238 -0
- package/dist/avl/index.js +2693 -0
- package/dist/avl-3d-context-BIRKWpaL.d.ts +204 -0
- package/dist/avl-schema-parser-CtJxJ9KU.d.ts +132 -0
- package/dist/avl-zoom-state-CKMVuBFg.d.ts +17 -0
- package/dist/chunk-2PY54Z44.js +227 -0
- package/dist/chunk-2QOH2HWM.js +95 -0
- package/dist/chunk-3BBUBJFF.js +339 -0
- package/dist/chunk-42FY4RYA.js +191 -0
- package/dist/chunk-5QTYQTPS.js +15 -0
- package/dist/chunk-6P3MWXYE.js +440 -0
- package/dist/chunk-73SRAB4P.js +1053 -0
- package/dist/chunk-A2LR6VQQ.js +349 -0
- package/dist/chunk-AILY3XPS.js +562 -0
- package/dist/chunk-B4BU77LT.js +432 -0
- package/dist/chunk-DFNZUYX4.js +378 -0
- package/dist/chunk-DJ433ET5.js +1327 -0
- package/dist/chunk-DLZF4PVE.js +24 -0
- package/dist/chunk-DYEKAA4L.js +787 -0
- package/dist/chunk-DZ42OJQC.js +176 -0
- package/dist/chunk-EOWMARUB.js +16 -0
- package/dist/chunk-EQAMU2ZC.js +14 -0
- package/dist/chunk-FAJDTHWC.js +98 -0
- package/dist/chunk-FIW6WN23.js +508 -0
- package/dist/chunk-FP3WIKTC.js +303 -0
- package/dist/chunk-G7DCAZ22.js +19 -0
- package/dist/chunk-GAR5TQ5B.js +199 -0
- package/dist/chunk-GKIFONTE.js +131 -0
- package/dist/chunk-GYTPOFVC.js +47155 -0
- package/dist/chunk-KVQS4GXU.js +328 -0
- package/dist/chunk-L2DEKY4J.js +97 -0
- package/dist/chunk-L677XGY3.js +701 -0
- package/dist/chunk-MBQAMMSE.js +11877 -0
- package/dist/chunk-P4LNHAFI.js +1051 -0
- package/dist/chunk-P4ZFUQFF.js +93 -0
- package/dist/chunk-PC7K4SK7.js +1384 -0
- package/dist/chunk-R5O5AUPI.js +573 -0
- package/dist/chunk-SGM3FASH.js +672 -0
- package/dist/chunk-SJGJJKBY.js +502 -0
- package/dist/chunk-TESBIVUA.js +11 -0
- package/dist/chunk-TZZBINQY.js +82 -0
- package/dist/chunk-U6QRZASX.js +280 -0
- package/dist/chunk-VFF5OO47.js +319 -0
- package/dist/chunk-YDNJLLG6.js +516 -0
- package/dist/chunk-YHMRX6YA.js +455 -0
- package/dist/chunk-ZO6MXAS3.js +69 -0
- package/dist/components/index.css +1756 -0
- package/dist/components/index.d.ts +11093 -0
- package/dist/components/index.js +1110 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/index.js +7 -0
- package/dist/core.d.ts +2523 -0
- package/dist/core.js +2 -0
- package/dist/design-classes/index.cjs +429 -0
- package/dist/design-classes/index.d.cts +165 -0
- package/dist/design-classes/index.d.ts +165 -0
- package/dist/design-classes/index.js +397 -0
- package/dist/emojiItems-QGSNAABW.js +20 -0
- package/dist/fx-CmQjnHmT.d.ts +371 -0
- package/dist/hooks/index.d.ts +936 -0
- package/dist/hooks/index.js +7 -0
- package/dist/index.d.ts +486 -0
- package/dist/index.js +38 -0
- package/dist/katexPlugin-FA7NX4PE.css +1161 -0
- package/dist/katexPlugin-NCDKOOQY.js +2 -0
- package/dist/kernel-client-ZH4PSMCN.js +367 -0
- package/dist/kernel-wire-B4S8pnP3.d.ts +65 -0
- package/dist/lib/index.d.ts +602 -0
- package/dist/lib/index.js +1288 -0
- package/dist/paintDispatch-ChW5mVuK.d.ts +698 -0
- package/dist/parseLessonSegments-GpCeMrb2.d.ts +334 -0
- package/dist/perf-CKiBKbkw.d.ts +22 -0
- package/dist/perf-Dr28-AgT.d.ts +57 -0
- package/dist/prism-AIWGN2X5.js +134 -0
- package/dist/providers/index.css +1756 -0
- package/dist/providers/index.d.ts +340 -0
- package/dist/providers/index.js +30 -0
- package/dist/renderer/index.d.ts +467 -0
- package/dist/renderer/index.js +3 -0
- package/dist/runtime/index.css +1756 -0
- package/dist/runtime/index.d.ts +440 -0
- package/dist/runtime/index.js +31 -0
- package/dist/slot-host-CPzrxLo9.d.ts +48 -0
- package/dist/ssr/index.cjs +7631 -0
- package/dist/ssr/index.d.cts +487 -0
- package/dist/ssr/index.d.ts +487 -0
- package/dist/ssr/index.js +7599 -0
- package/dist/storage/browser/index.d.ts +1 -0
- package/dist/storage/browser/index.js +1 -0
- package/dist/test-support.d.ts +35 -0
- package/dist/test-support.js +114 -0
- package/dist/themeTokens-CRd8AEDF.d.ts +125 -0
- package/dist/three/index.css +503 -0
- package/dist/three/index.d.ts +1185 -0
- package/dist/three/index.js +3896 -0
- package/dist/useKeyboardRouter-Dsq553Ur.d.ts +42 -0
- package/dist/useUISlots-CiobNFGb.d.ts +211 -0
- package/dist/verification-C5pTeMJv.d.ts +66 -0
- package/dist/verificationRegistry-CabxhfTv.d.ts +122 -0
- package/dist/wrapCallbackForEvent-B9QLbhxX.d.ts +19 -0
- package/index.css +199 -0
- package/package.json +269 -3
- package/src/core/locales/ar.json +1263 -0
- package/src/core/locales/en.json +1263 -0
- package/src/core/locales/index.ts +54 -0
- package/src/core/locales/sl.json +1263 -0
- package/src/core/tokens/native-tokens.json +369 -0
- package/tailwind-compile.cjs +29 -0
- package/tailwind-preset.cjs +991 -0
- package/themes/_base.css +451 -0
- package/themes/_contract.md +307 -0
- package/themes/_fonts-kenney.css +11 -0
- package/themes/_fonts.css +12 -0
- package/themes/_foundation.css +105 -0
- package/themes/_head.css +22 -0
- package/themes/_presets.css +67 -0
- package/themes/almadar-heritage.css +455 -0
- package/themes/almadar-website.css +269 -0
- package/themes/almadar.css +269 -0
- package/themes/aqua.css +455 -0
- package/themes/arabesque.css +459 -0
- package/themes/art-deco.css +457 -0
- package/themes/art-nouveau.css +459 -0
- package/themes/atelier.css +463 -0
- package/themes/bauhaus.css +461 -0
- package/themes/bloomberg-dense.css +463 -0
- package/themes/blueprint.css +457 -0
- package/themes/clay.css +449 -0
- package/themes/comic.css +453 -0
- package/themes/constructivist.css +457 -0
- package/themes/corporate.css +449 -0
- package/themes/cyberpunk.css +453 -0
- package/themes/frutiger-aero.css +458 -0
- package/themes/game-adventure.css +201 -0
- package/themes/game-rpg.css +203 -0
- package/themes/game-sci-fi.css +201 -0
- package/themes/game-ui-pack.css +200 -0
- package/themes/gazette.css +449 -0
- package/themes/glass.css +457 -0
- package/themes/gothic.css +453 -0
- package/themes/index.css +21 -0
- package/themes/ink-wash.css +459 -0
- package/themes/kawaii.css +459 -0
- package/themes/kflow.css +310 -0
- package/themes/kiosk.css +449 -0
- package/themes/linear-clean.css +463 -0
- package/themes/luxury.css +451 -0
- package/themes/mac-classic.css +455 -0
- package/themes/material.css +463 -0
- package/themes/memphis.css +453 -0
- package/themes/mid-century.css +455 -0
- package/themes/minimalist.css +449 -0
- package/themes/mudcloth.css +459 -0
- package/themes/nata.css +310 -0
- package/themes/neon.css +453 -0
- package/themes/neumorphic.css +451 -0
- package/themes/newsprint.css +455 -0
- package/themes/notion-editorial.css +463 -0
- package/themes/orb.css +465 -0
- package/themes/pixel.css +449 -0
- package/themes/prism.css +309 -0
- package/themes/rawi.css +310 -0
- package/themes/retro.css +452 -0
- package/themes/risograph.css +463 -0
- package/themes/scandi.css +469 -0
- package/themes/sketch.css +455 -0
- package/themes/solarpunk.css +469 -0
- package/themes/steampunk.css +451 -0
- package/themes/swiss.css +455 -0
- package/themes/terminal.css +466 -0
- package/themes/trait-wars.css +487 -0
- package/themes/ukiyo-e.css +459 -0
- package/themes/vaporwave.css +455 -0
- package/themes/victorian.css +453 -0
- package/themes/wabi-sabi.css +459 -0
- package/themes/win95.css +455 -0
- package/themes/wireframe.css +439 -0
- package/themes/zine.css +455 -0
- package/README.md +0 -3
|
@@ -0,0 +1,787 @@
|
|
|
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 * as std_mock_seed_star from '@almadar/shell-runtime/runtime/entities/std-mock-seed';
|
|
7
|
+
import { orbitalInlineEntities, storesRowsInBrowser, parseOrbitalSchema, isRoutePage, applyRowAccess, readableEntitiesOf, externalInputsOf, tickEventKey } from '@almadar/core';
|
|
8
|
+
import { entityAccessPolicies } from '@almadar/core/mock';
|
|
9
|
+
import { dispatchDeclaredInput } from '@almadar/shell-runtime/client/declared-input-dispatch';
|
|
10
|
+
import { IndexedDbPersistence } from '@almadar/shell-browser/storage';
|
|
11
|
+
import * as seedBrowserStore_star from '@almadar/shell-runtime/runtime/entities/seedBrowserStore';
|
|
12
|
+
import * as trait_index_star from '@almadar/shell-runtime/runtime/traits/trait-index';
|
|
13
|
+
import * as TickScheduler_star from '@almadar/shell-runtime/runtime/time/TickScheduler';
|
|
14
|
+
import { createLogger, isLogLevelEnabled } from '@almadar/logger';
|
|
15
|
+
import * as cron_star from '@almadar/shell-runtime/runtime/time/cron';
|
|
16
|
+
import * as duration_star from '@almadar/shell-runtime/runtime/time/duration';
|
|
17
|
+
import * as composition_star from '@almadar/shell-runtime/runtime/effects/composition/index';
|
|
18
|
+
import * as types_star from '@almadar/shell-runtime/runtime/types';
|
|
19
|
+
import * as routing_star from '@almadar/shell-runtime/runtime/events/identity/routing';
|
|
20
|
+
import * as listen_targets_star from '@almadar/shell-runtime/runtime/traits/listen-targets';
|
|
21
|
+
import * as OrbitalTraitParsing_star from '@almadar/shell-runtime/runtime/traits/OrbitalTraitParsing';
|
|
22
|
+
import * as mockStoreSeed_star from '@almadar/shell-runtime/runtime/entities/mockStoreSeed';
|
|
23
|
+
import * as residence_transport_star from '@almadar/shell-runtime/runtime/evaluation/residence-transport';
|
|
24
|
+
|
|
25
|
+
function hasMemoryStore(kernel) {
|
|
26
|
+
return "MemoryStore" in kernel;
|
|
27
|
+
}
|
|
28
|
+
function nativeMemoryPersistence(kernel) {
|
|
29
|
+
if (!hasMemoryStore(kernel)) throw new Error("nativeMemoryPersistence: this kernel module exports no MemoryStore; install a kernel build that carries it");
|
|
30
|
+
return new NativeMemoryPersistenceAdapter(new kernel.MemoryStore());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/runtime/evaluation/local-store-transport.ts
|
|
34
|
+
var local_store_transport_exports = {};
|
|
35
|
+
__export(local_store_transport_exports, {
|
|
36
|
+
openLocalKernel: () => openLocalKernel
|
|
37
|
+
});
|
|
38
|
+
__reExport(local_store_transport_exports, local_store_transport_star);
|
|
39
|
+
function openLocalKernel(options) {
|
|
40
|
+
return openLocalKernel$1({ ...options, pageFacts: options.pageFacts ?? readPageFacts });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/runtime/entities/std-mock-seed.ts
|
|
44
|
+
var std_mock_seed_exports = {};
|
|
45
|
+
__reExport(std_mock_seed_exports, std_mock_seed_star);
|
|
46
|
+
|
|
47
|
+
// src/runtime/entities/seed-host.ts
|
|
48
|
+
async function withBrowserSeeder(seeding, use) {
|
|
49
|
+
const program = await seeding.loadSeedProgram();
|
|
50
|
+
let opened;
|
|
51
|
+
const engine = {
|
|
52
|
+
evaluate: async (orbital, request, scope) => {
|
|
53
|
+
opened ??= openLocalKernel({
|
|
54
|
+
kernel: seeding.kernel,
|
|
55
|
+
language: seeding.language,
|
|
56
|
+
schema: program,
|
|
57
|
+
persistence: nativeMemoryPersistence(seeding.kernel)
|
|
58
|
+
});
|
|
59
|
+
return opened.evaluate(orbital, request, scope);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
return await use({ seeder: new std_mock_seed_exports.StdMockSeed(engine, (0, std_mock_seed_exports.declaredSeedConfig)(program, seeding.app)), nowMs: Date.now() });
|
|
64
|
+
} finally {
|
|
65
|
+
opened?.dispose();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function withForkedSeeder(app, appSchema, loadSeedProgram, persistence, user, use) {
|
|
69
|
+
const program = await loadSeedProgram();
|
|
70
|
+
const fork = app.forkProgram(program);
|
|
71
|
+
try {
|
|
72
|
+
return await use({ seeder: new std_mock_seed_exports.StdMockSeed(fork, (0, std_mock_seed_exports.declaredSeedConfig)(program, appSchema), user), persistence, nowMs: Date.now() });
|
|
73
|
+
} finally {
|
|
74
|
+
fork.dispose();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/runtime/entities/seedBrowserStore.ts
|
|
79
|
+
var seedBrowserStore_exports = {};
|
|
80
|
+
__reExport(seedBrowserStore_exports, seedBrowserStore_star);
|
|
81
|
+
|
|
82
|
+
// src/runtime/traits/trait-index.ts
|
|
83
|
+
var trait_index_exports = {};
|
|
84
|
+
__reExport(trait_index_exports, trait_index_star);
|
|
85
|
+
|
|
86
|
+
// src/runtime/time/TickScheduler.ts
|
|
87
|
+
var TickScheduler_exports = {};
|
|
88
|
+
__reExport(TickScheduler_exports, TickScheduler_star);
|
|
89
|
+
|
|
90
|
+
// src/runtime/time/cron.ts
|
|
91
|
+
var cron_exports = {};
|
|
92
|
+
__reExport(cron_exports, cron_star);
|
|
93
|
+
|
|
94
|
+
// src/runtime/time/duration.ts
|
|
95
|
+
var duration_exports = {};
|
|
96
|
+
__reExport(duration_exports, duration_star);
|
|
97
|
+
|
|
98
|
+
// src/runtime/evaluation/browser-store-transport.ts
|
|
99
|
+
function browserStoreName(appName, locale) {
|
|
100
|
+
return locale !== void 0 ? `almadar:${appName}:${locale}` : `almadar:${appName}`;
|
|
101
|
+
}
|
|
102
|
+
async function openBrowserStore(databaseName, orbitals, seeding, factory, locale) {
|
|
103
|
+
const entities = orbitals.flatMap(orbitalInlineEntities).filter(storesRowsInBrowser);
|
|
104
|
+
if (entities.length === 0) return null;
|
|
105
|
+
const store = await IndexedDbPersistence.open({
|
|
106
|
+
databaseName,
|
|
107
|
+
entityTypes: entities.map((e) => e.name),
|
|
108
|
+
...factory !== void 0 ? { factory } : {}
|
|
109
|
+
});
|
|
110
|
+
await withBrowserSeeder(seeding, (host) => (0, seedBrowserStore_exports.seedBrowserStore)(store, entities, locale, host));
|
|
111
|
+
return store;
|
|
112
|
+
}
|
|
113
|
+
async function openBrowserStoreTransport(options) {
|
|
114
|
+
const stored = await openBrowserStore(options.databaseName, options.schema.orbitals, { kernel: options.kernel, language: options.language, loadSeedProgram: options.loadSeedProgram, app: options.schema }, options.factory, options.locale);
|
|
115
|
+
if (stored === null && options.callService === void 0) {
|
|
116
|
+
throw new Error(`openBrowserStoreTransport: schema "${options.schema.name}" declares no browser-stored entity`);
|
|
117
|
+
}
|
|
118
|
+
const memory = nativeMemoryPersistence(options.kernel);
|
|
119
|
+
const persistence = (0, local_store_transport_exports.localStorePersistence)(options.schema, stored ?? memory, memory);
|
|
120
|
+
return (0, local_store_transport_exports.createLocalStoreTransport)({
|
|
121
|
+
kernelEngine: openLocalKernel({
|
|
122
|
+
kernel: options.kernel,
|
|
123
|
+
language: options.language,
|
|
124
|
+
schema: options.schema,
|
|
125
|
+
persistence,
|
|
126
|
+
...options.callService !== void 0 ? { callService: options.callService } : {},
|
|
127
|
+
...options.http !== void 0 ? { http: options.http } : {},
|
|
128
|
+
...options.messages !== void 0 ? { messages: options.messages } : {}
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function openBundledBrowserStore(bundled, kernel, language, loadSeedProgram, locale, callService, messages, http) {
|
|
133
|
+
const schema = parseOrbitalSchema(bundled);
|
|
134
|
+
return openBrowserStoreTransport({
|
|
135
|
+
databaseName: browserStoreName(schema.name, locale),
|
|
136
|
+
schema,
|
|
137
|
+
kernel,
|
|
138
|
+
language,
|
|
139
|
+
loadSeedProgram,
|
|
140
|
+
...locale !== void 0 ? { locale } : {},
|
|
141
|
+
...callService !== void 0 ? { callService } : {},
|
|
142
|
+
...http !== void 0 ? { http } : {},
|
|
143
|
+
...messages !== void 0 ? { messages } : {}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
var tickLog = createLogger("almadar:runtime:browser-host:ticks");
|
|
147
|
+
var queueLog = createLogger("almadar:runtime:browser-host:queue");
|
|
148
|
+
function refuseUnhostedTicks(traitIndex) {
|
|
149
|
+
for (const entry of traitIndex.byName.values()) {
|
|
150
|
+
for (const tick of entry.irTrait.ticks ?? []) {
|
|
151
|
+
if (tick.interval === "frame") {
|
|
152
|
+
throw new Error(`openBrowserHost has no frame clock; ${entry.orbitalName}.${entry.traitDef.name} tick '${tick.name}' runs every frame`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function openBrowserHost(options) {
|
|
158
|
+
const browserStore = await openBrowserStore(options.databaseName, options.schema.orbitals, { kernel: options.kernel, language: options.language, loadSeedProgram: options.loadSeedProgram, app: options.schema }, options.factory, options.locale);
|
|
159
|
+
const memory = nativeMemoryPersistence(options.kernel);
|
|
160
|
+
const persistence = (0, local_store_transport_exports.localStorePersistence)(options.schema, browserStore ?? memory, memory);
|
|
161
|
+
const traitIndex = (0, trait_index_exports.buildTraitIndex)(options.schema.orbitals);
|
|
162
|
+
refuseUnhostedTicks(traitIndex);
|
|
163
|
+
const { schema } = options;
|
|
164
|
+
let transport;
|
|
165
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
166
|
+
let turns = 0;
|
|
167
|
+
const lane = [];
|
|
168
|
+
let pumping = false;
|
|
169
|
+
let running;
|
|
170
|
+
const pump = async () => {
|
|
171
|
+
if (pumping) return;
|
|
172
|
+
pumping = true;
|
|
173
|
+
for (let grant = lane.shift(); grant !== void 0; grant = lane.shift()) {
|
|
174
|
+
await new Promise(grant);
|
|
175
|
+
}
|
|
176
|
+
pumping = false;
|
|
177
|
+
};
|
|
178
|
+
const take = (turn) => new Promise((taken) => {
|
|
179
|
+
queueLog.debug("queue:wait", { turn: turn.id, running: running?.id });
|
|
180
|
+
turn.lane.push((free) => {
|
|
181
|
+
turn.held = true;
|
|
182
|
+
running = turn;
|
|
183
|
+
queueLog.debug("queue:take", { turn: turn.id });
|
|
184
|
+
turn.release = () => {
|
|
185
|
+
queueLog.debug("queue:release", { turn: turn.id });
|
|
186
|
+
turn.held = false;
|
|
187
|
+
if (running === turn) running = void 0;
|
|
188
|
+
free();
|
|
189
|
+
};
|
|
190
|
+
taken();
|
|
191
|
+
});
|
|
192
|
+
void pump();
|
|
193
|
+
});
|
|
194
|
+
const enqueue = async (lane2, work) => {
|
|
195
|
+
const turn = { id: ++turns, lane: lane2, held: false, done: false, release: () => void 0 };
|
|
196
|
+
await take(turn);
|
|
197
|
+
try {
|
|
198
|
+
return await work();
|
|
199
|
+
} finally {
|
|
200
|
+
turn.done = true;
|
|
201
|
+
if (turn.held) turn.release();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const serially = (work) => enqueue(lane, work);
|
|
205
|
+
const outsideEventQueue = async (work) => {
|
|
206
|
+
const turn = running;
|
|
207
|
+
queueLog.debug("queue:outside", { turn: turn?.id, held: turn?.held });
|
|
208
|
+
if (turn === void 0 || !turn.held) return work();
|
|
209
|
+
turn.release();
|
|
210
|
+
try {
|
|
211
|
+
return await work();
|
|
212
|
+
} finally {
|
|
213
|
+
await take(turn);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const servicePorts = (caller, user, message) => {
|
|
217
|
+
const lentBy = running;
|
|
218
|
+
return {
|
|
219
|
+
caller,
|
|
220
|
+
inputs: () => externalInputsOf(schema),
|
|
221
|
+
readableEntities: () => readableEntitiesOf(schema),
|
|
222
|
+
dispatchInput: (orbital, request) => {
|
|
223
|
+
const host = transport;
|
|
224
|
+
if (!host) return Promise.reject(new Error("openBrowserHost: the host is not open yet"));
|
|
225
|
+
const send = (o, r) => lentBy !== void 0 && lentBy.held && !lentBy.done ? host.send(o, r) : serially(() => host.send(o, r));
|
|
226
|
+
return dispatchDeclaredInput(schema, orbital, { ...request, ...user !== void 0 ? { user } : {} }, async (o, r) => {
|
|
227
|
+
const response = await send(o, r);
|
|
228
|
+
for (const listener of listeners) listener(o, r, response);
|
|
229
|
+
return response;
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
read: async (entity) => applyRowAccess(await persistence.list(entity), entityAccessPolicies(schema, entity)?.read, void 0, { user }, entity),
|
|
233
|
+
message
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
let deferred;
|
|
237
|
+
const kernelEngine = openLocalKernel({
|
|
238
|
+
kernel: options.kernel,
|
|
239
|
+
language: options.language,
|
|
240
|
+
schema,
|
|
241
|
+
persistence,
|
|
242
|
+
callService: options.callService,
|
|
243
|
+
servicePorts,
|
|
244
|
+
deferCallOutcome: () => deferred,
|
|
245
|
+
...options.http !== void 0 ? { http: options.http } : {},
|
|
246
|
+
...options.onDevice !== void 0 ? { onDevice: options.onDevice } : {},
|
|
247
|
+
...options.tabs !== void 0 ? { tabs: options.tabs } : {}
|
|
248
|
+
});
|
|
249
|
+
const local = (0, local_store_transport_exports.createLocalStoreTransport)({ kernelEngine, outsideEventQueue });
|
|
250
|
+
transport = local;
|
|
251
|
+
deferred = (call) => {
|
|
252
|
+
const request = {
|
|
253
|
+
event: call.event,
|
|
254
|
+
...call.payload !== void 0 ? { payload: call.payload } : {},
|
|
255
|
+
targetTrait: call.traitName,
|
|
256
|
+
...call.entityId !== void 0 ? { entityId: call.entityId } : {},
|
|
257
|
+
...call.originClientId !== void 0 ? { clientId: call.originClientId } : {},
|
|
258
|
+
...call.user !== void 0 ? { user: call.user } : {},
|
|
259
|
+
...call.locale !== void 0 ? { locale: call.locale } : {}
|
|
260
|
+
};
|
|
261
|
+
void serially(async () => {
|
|
262
|
+
const response = await local.send(call.orbital, request);
|
|
263
|
+
for (const listener of listeners) listener(call.orbital, request, response);
|
|
264
|
+
}).catch((error) => {
|
|
265
|
+
queueLog.error("deferred-outcome:failed", { orbital: call.orbital, event: call.event, trait: call.traitName, error: error.message });
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
const scheduler = (0, TickScheduler_exports.createTickScheduler)();
|
|
269
|
+
const tickHandles = [];
|
|
270
|
+
for (const entry of traitIndex.byName.values()) {
|
|
271
|
+
for (const tick of entry.irTrait.ticks ?? []) {
|
|
272
|
+
let firing = false;
|
|
273
|
+
const fire = () => {
|
|
274
|
+
if (firing) return;
|
|
275
|
+
firing = true;
|
|
276
|
+
const request = {
|
|
277
|
+
event: tickEventKey(tick.name),
|
|
278
|
+
runTick: { trait: entry.traitDef.name, tick: tick.name },
|
|
279
|
+
targetTrait: entry.traitDef.name,
|
|
280
|
+
tick: tick.name
|
|
281
|
+
};
|
|
282
|
+
void serially(async () => {
|
|
283
|
+
const response = await local.send(entry.orbitalName, request);
|
|
284
|
+
if (response.transitioned) for (const listener of listeners) listener(entry.orbitalName, request, response);
|
|
285
|
+
}).catch((error) => {
|
|
286
|
+
tickLog.error("tick:failed", { orbital: entry.orbitalName, trait: entry.traitDef.name, tick: tick.name, error: error.message });
|
|
287
|
+
}).finally(() => {
|
|
288
|
+
firing = false;
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
tickHandles.push(
|
|
292
|
+
typeof tick.interval === "string" && (0, cron_exports.isValidCronExpression)(tick.interval) ? scheduler.addCron(tick.interval, fire) : scheduler.add(typeof tick.interval === "number" ? tick.interval : (0, duration_exports.parseDurationString)(tick.interval), fire)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
...local,
|
|
298
|
+
send: (orbitalName, request) => serially(() => local.send(orbitalName, request)),
|
|
299
|
+
onInputDispatched(listener) {
|
|
300
|
+
listeners.add(listener);
|
|
301
|
+
return () => listeners.delete(listener);
|
|
302
|
+
},
|
|
303
|
+
routeMounts: (routePath) => kernelEngine.routeMounts(routePath),
|
|
304
|
+
close() {
|
|
305
|
+
for (const handle of tickHandles) handle.stop();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/runtime/effects/composition/index.ts
|
|
311
|
+
var composition_exports = {};
|
|
312
|
+
__reExport(composition_exports, composition_star);
|
|
313
|
+
|
|
314
|
+
// src/runtime/ui/contract-errors.ts
|
|
315
|
+
var RendererContractViolationError = class extends Error {
|
|
316
|
+
constructor(message) {
|
|
317
|
+
super(message);
|
|
318
|
+
this.name = "RendererContractViolationError";
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/runtime/ui/slots.ts
|
|
323
|
+
function aggregateSlotContent(slot, sources) {
|
|
324
|
+
const entries = Array.from(sources.values());
|
|
325
|
+
if (entries.length === 0) return void 0;
|
|
326
|
+
if (entries.length === 1) return entries[0];
|
|
327
|
+
Array.from(sources.keys());
|
|
328
|
+
const children = entries.map((entry) => ({
|
|
329
|
+
type: entry.pattern?.type ?? "box",
|
|
330
|
+
...entry.props
|
|
331
|
+
}));
|
|
332
|
+
return {
|
|
333
|
+
slot,
|
|
334
|
+
pattern: { type: "stack", direction: "vertical", gap: "lg", children },
|
|
335
|
+
props: { direction: "vertical", gap: "lg", children },
|
|
336
|
+
source: entries[0].source
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function isNonNullObject(value) {
|
|
340
|
+
return typeof value === "object" && value !== null;
|
|
341
|
+
}
|
|
342
|
+
function assertHasFunctionMethods(label, value, methods) {
|
|
343
|
+
for (const method of methods) {
|
|
344
|
+
if (typeof value[method] !== "function") {
|
|
345
|
+
throw new RendererContractViolationError(`${label}.${method} must be a function`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function assertIsSlotManager(value) {
|
|
350
|
+
if (!isNonNullObject(value)) {
|
|
351
|
+
throw new RendererContractViolationError("SlotManager must be a non-null object");
|
|
352
|
+
}
|
|
353
|
+
assertHasFunctionMethods("SlotManager", value, [
|
|
354
|
+
"getContent",
|
|
355
|
+
"setContent",
|
|
356
|
+
"clearSlot",
|
|
357
|
+
"getAllSlots",
|
|
358
|
+
"subscribe"
|
|
359
|
+
]);
|
|
360
|
+
}
|
|
361
|
+
function assertIsMultiSourceSlotManager(value) {
|
|
362
|
+
if (!isNonNullObject(value)) {
|
|
363
|
+
throw new RendererContractViolationError("MultiSourceSlotManager must be a non-null object");
|
|
364
|
+
}
|
|
365
|
+
assertHasFunctionMethods("SlotManager", value, [
|
|
366
|
+
"getContent",
|
|
367
|
+
"setContent",
|
|
368
|
+
"clearSlot",
|
|
369
|
+
"getAllSlots",
|
|
370
|
+
"subscribe"
|
|
371
|
+
]);
|
|
372
|
+
assertHasFunctionMethods("MultiSourceSlotManager", value, [
|
|
373
|
+
"getTraitContent",
|
|
374
|
+
"subscribeTrait",
|
|
375
|
+
"updateTraitContent"
|
|
376
|
+
]);
|
|
377
|
+
}
|
|
378
|
+
function validateSlotContent(content) {
|
|
379
|
+
const errors = [];
|
|
380
|
+
if (content.slot === void 0 || content.slot === null) {
|
|
381
|
+
errors.push({ message: "SlotContent.slot is required", path: "slot" });
|
|
382
|
+
}
|
|
383
|
+
if (!("pattern" in content)) {
|
|
384
|
+
errors.push({ message: "SlotContent.pattern is required", path: "pattern" });
|
|
385
|
+
}
|
|
386
|
+
return errors;
|
|
387
|
+
}
|
|
388
|
+
function createSlotSetter(manager) {
|
|
389
|
+
return {
|
|
390
|
+
addPattern: (slot, pattern, props) => {
|
|
391
|
+
manager.setContent({
|
|
392
|
+
slot,
|
|
393
|
+
pattern,
|
|
394
|
+
props
|
|
395
|
+
});
|
|
396
|
+
},
|
|
397
|
+
clearSlot: (slot) => {
|
|
398
|
+
manager.clearSlot(slot);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/runtime/ui/wrapCallbackForEvent.ts
|
|
404
|
+
function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
|
|
405
|
+
const argNames = (callbackArgs ?? []).map((a) => a.name);
|
|
406
|
+
if (argNames.length === 0) {
|
|
407
|
+
return () => emit(qualifiedEvent);
|
|
408
|
+
}
|
|
409
|
+
return (...args) => {
|
|
410
|
+
const payload = {};
|
|
411
|
+
for (let i = 0; i < argNames.length; i += 1) {
|
|
412
|
+
payload[argNames[i]] = args[i];
|
|
413
|
+
}
|
|
414
|
+
emit(qualifiedEvent, payload);
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function buildOrbitalsByTrait(schema, resolvedPages = []) {
|
|
418
|
+
const map = {};
|
|
419
|
+
if (!schema?.orbitals) return map;
|
|
420
|
+
const pagePathToOrbital = {};
|
|
421
|
+
for (const orb of schema.orbitals) {
|
|
422
|
+
for (const traitRef of orb.traits ?? []) {
|
|
423
|
+
let traitName;
|
|
424
|
+
if (typeof traitRef === "string") {
|
|
425
|
+
const parts = traitRef.split(".");
|
|
426
|
+
traitName = parts[parts.length - 1];
|
|
427
|
+
} else if ("ref" in traitRef && typeof traitRef.ref === "string") {
|
|
428
|
+
const parts = traitRef.ref.split(".");
|
|
429
|
+
traitName = traitRef.name ?? parts[parts.length - 1];
|
|
430
|
+
} else if ("name" in traitRef && typeof traitRef.name === "string") {
|
|
431
|
+
traitName = traitRef.name;
|
|
432
|
+
}
|
|
433
|
+
if (traitName) map[traitName] = orb.name;
|
|
434
|
+
}
|
|
435
|
+
for (const pg of orb.pages ?? []) {
|
|
436
|
+
const path = typeof pg === "string" ? pg : isRoutePage(pg) ? pg.path : void 0;
|
|
437
|
+
if (path) pagePathToOrbital[path] = orb.name;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
for (const page of resolvedPages) {
|
|
441
|
+
const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
|
|
442
|
+
if (!orbital) continue;
|
|
443
|
+
for (const traitName of page.traitNames) {
|
|
444
|
+
if (traitName && !(traitName in map)) map[traitName] = orbital;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return map;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// src/runtime/ui/traitLinkedEntities.ts
|
|
451
|
+
function buildTraitLinkedEntities(ir) {
|
|
452
|
+
const map = /* @__PURE__ */ new Map();
|
|
453
|
+
for (const page of ir.pages.values()) {
|
|
454
|
+
for (const binding of page.traits) {
|
|
455
|
+
if (binding.linkedEntity) map.set(binding.trait.name, binding.linkedEntity);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
for (const trait of ir.traits.values()) {
|
|
459
|
+
if (trait.linkedEntity && !map.has(trait.name)) map.set(trait.name, trait.linkedEntity);
|
|
460
|
+
}
|
|
461
|
+
return map;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/runtime/ui/embedded-traits.ts
|
|
465
|
+
var TRAIT_BINDING_PREFIX = "@trait.";
|
|
466
|
+
function collectTraitRefsFromValue(value, into) {
|
|
467
|
+
if (value === null || value === void 0) return;
|
|
468
|
+
if (typeof value === "string") {
|
|
469
|
+
if (value.startsWith(TRAIT_BINDING_PREFIX)) {
|
|
470
|
+
const rest = value.slice(TRAIT_BINDING_PREFIX.length);
|
|
471
|
+
const dot = rest.indexOf(".");
|
|
472
|
+
const traitName = dot === -1 ? rest : rest.slice(0, dot);
|
|
473
|
+
if (traitName.length > 0) into.add(traitName);
|
|
474
|
+
}
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (Array.isArray(value)) {
|
|
478
|
+
for (const item of value) collectTraitRefsFromValue(item, into);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (typeof value === "object") {
|
|
482
|
+
for (const v of Object.values(value)) {
|
|
483
|
+
collectTraitRefsFromValue(v, into);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function collectTraitRefsFromEffects(effects, into) {
|
|
488
|
+
if (!effects) return;
|
|
489
|
+
for (const effect of effects) {
|
|
490
|
+
if (!Array.isArray(effect)) continue;
|
|
491
|
+
if (effect[0] === "render-ui" && effect.length >= 3) {
|
|
492
|
+
collectTraitRefsFromValue(effect[2], into);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
for (let i = 1; i < effect.length; i++) {
|
|
496
|
+
const arg = effect[i];
|
|
497
|
+
if (Array.isArray(arg)) collectTraitRefsFromEffects([arg], into);
|
|
498
|
+
else collectTraitRefsFromValue(arg, into);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function collectTraitRefsFromResolvedTrait(trait) {
|
|
503
|
+
const out = /* @__PURE__ */ new Set();
|
|
504
|
+
for (const transition of trait.transitions ?? []) {
|
|
505
|
+
collectTraitRefsFromEffects(transition.effects, out);
|
|
506
|
+
}
|
|
507
|
+
for (const tick of trait.ticks ?? []) {
|
|
508
|
+
collectTraitRefsFromEffects(tick.effects, out);
|
|
509
|
+
}
|
|
510
|
+
for (const field of Object.values(trait.config ?? {})) {
|
|
511
|
+
if (field.default !== void 0) collectTraitRefsFromValue(field.default, out);
|
|
512
|
+
}
|
|
513
|
+
return out;
|
|
514
|
+
}
|
|
515
|
+
function collectEmbeddedTraits(schema) {
|
|
516
|
+
const out = /* @__PURE__ */ new Set();
|
|
517
|
+
if (!schema?.orbitals) return out;
|
|
518
|
+
for (const orbital of schema.orbitals) {
|
|
519
|
+
const traits = orbital.traits;
|
|
520
|
+
if (!Array.isArray(traits)) continue;
|
|
521
|
+
for (const traitRef of traits) {
|
|
522
|
+
if (!traitRef || typeof traitRef !== "object") continue;
|
|
523
|
+
const resolved = traitRef._resolved;
|
|
524
|
+
const target = resolved && typeof resolved === "object" ? resolved : traitRef;
|
|
525
|
+
if (typeof traitRef !== "string" && "config" in traitRef && traitRef.config) {
|
|
526
|
+
collectTraitRefsFromValue(traitRef.config, out);
|
|
527
|
+
}
|
|
528
|
+
if (target.config) {
|
|
529
|
+
collectTraitRefsFromValue(target.config, out);
|
|
530
|
+
}
|
|
531
|
+
const transitions = target.stateMachine?.transitions;
|
|
532
|
+
if (!Array.isArray(transitions)) continue;
|
|
533
|
+
for (const t of transitions) {
|
|
534
|
+
collectTraitRefsFromEffects(t.effects, out);
|
|
535
|
+
}
|
|
536
|
+
collectTraitRefsFromEffects(target.initialEffects, out);
|
|
537
|
+
const ticks = target.ticks;
|
|
538
|
+
if (Array.isArray(ticks)) {
|
|
539
|
+
for (const tick of ticks) {
|
|
540
|
+
collectTraitRefsFromEffects(tick.effects, out);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return out;
|
|
546
|
+
}
|
|
547
|
+
var PERF_NAMESPACE = "almadar:perf:canvas";
|
|
548
|
+
var log = createLogger(PERF_NAMESPACE);
|
|
549
|
+
var RING_SIZE = 50;
|
|
550
|
+
var ring = [];
|
|
551
|
+
var writeIdx = 0;
|
|
552
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
553
|
+
var notifyScheduled = false;
|
|
554
|
+
var revision = 0;
|
|
555
|
+
var cachedSnapshot = [];
|
|
556
|
+
var cachedRevision = -1;
|
|
557
|
+
function scheduleNotify() {
|
|
558
|
+
if (notifyScheduled) return;
|
|
559
|
+
notifyScheduled = true;
|
|
560
|
+
queueMicrotask(() => {
|
|
561
|
+
notifyScheduled = false;
|
|
562
|
+
revision++;
|
|
563
|
+
for (const fn of subscribers) fn();
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function push(entry) {
|
|
567
|
+
if (ring.length < RING_SIZE) {
|
|
568
|
+
ring.push(entry);
|
|
569
|
+
} else {
|
|
570
|
+
ring[writeIdx] = entry;
|
|
571
|
+
}
|
|
572
|
+
writeIdx = (writeIdx + 1) % RING_SIZE;
|
|
573
|
+
scheduleNotify();
|
|
574
|
+
}
|
|
575
|
+
function isEnabled() {
|
|
576
|
+
return isLogLevelEnabled("DEBUG", PERF_NAMESPACE) || globalThis.__ALMADAR_PERF__ === true;
|
|
577
|
+
}
|
|
578
|
+
function isVerbose() {
|
|
579
|
+
return isLogLevelEnabled("DEBUG", PERF_NAMESPACE);
|
|
580
|
+
}
|
|
581
|
+
function now() {
|
|
582
|
+
return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
583
|
+
}
|
|
584
|
+
function perfStart(name) {
|
|
585
|
+
if (!isEnabled()) return -1;
|
|
586
|
+
if (typeof performance !== "undefined" && typeof performance.mark === "function") {
|
|
587
|
+
try {
|
|
588
|
+
performance.mark(`${name}-start`);
|
|
589
|
+
} catch {
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return now();
|
|
593
|
+
}
|
|
594
|
+
function perfEnd(name, startToken, detail) {
|
|
595
|
+
if (startToken < 0 || !isEnabled()) return;
|
|
596
|
+
const endTs = now();
|
|
597
|
+
const durationMs = endTs - startToken;
|
|
598
|
+
if (typeof performance !== "undefined" && typeof performance.measure === "function") {
|
|
599
|
+
try {
|
|
600
|
+
performance.mark(`${name}-end`);
|
|
601
|
+
performance.measure(name, `${name}-start`, `${name}-end`);
|
|
602
|
+
} catch {
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
push({ name, durationMs, ts: endTs, detail });
|
|
606
|
+
aggregate(name, durationMs);
|
|
607
|
+
if (isVerbose()) log.debug(name, () => ({ durationMs, ...detail ?? {} }));
|
|
608
|
+
}
|
|
609
|
+
function perfTime(name, fn, detail) {
|
|
610
|
+
const t = perfStart(name);
|
|
611
|
+
try {
|
|
612
|
+
return fn();
|
|
613
|
+
} finally {
|
|
614
|
+
perfEnd(name, t, detail);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
async function perfTimeAsync(name, fn) {
|
|
618
|
+
const t = perfStart(name);
|
|
619
|
+
try {
|
|
620
|
+
return await fn();
|
|
621
|
+
} finally {
|
|
622
|
+
perfEnd(name, t);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function perfGauge(name, value) {
|
|
626
|
+
if (!isEnabled()) return;
|
|
627
|
+
aggregate(name, value);
|
|
628
|
+
}
|
|
629
|
+
var buckets = /* @__PURE__ */ new Map();
|
|
630
|
+
var dumpTimer = null;
|
|
631
|
+
function aggregate(name, ms) {
|
|
632
|
+
const b = buckets.get(name);
|
|
633
|
+
if (b) {
|
|
634
|
+
b.count++;
|
|
635
|
+
b.totalMs += ms;
|
|
636
|
+
if (ms > b.maxMs) b.maxMs = ms;
|
|
637
|
+
} else {
|
|
638
|
+
buckets.set(name, { count: 1, totalMs: ms, maxMs: ms });
|
|
639
|
+
}
|
|
640
|
+
if (dumpTimer === null) {
|
|
641
|
+
dumpTimer = setInterval(dumpSummary, 5e3);
|
|
642
|
+
if (typeof dumpTimer === "object" && "unref" in dumpTimer) dumpTimer.unref();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function dumpSummary() {
|
|
646
|
+
if (buckets.size === 0) return;
|
|
647
|
+
const rows = [...buckets.entries()].map(([name, b]) => ({
|
|
648
|
+
name,
|
|
649
|
+
count: b.count,
|
|
650
|
+
totalMs: Math.round(b.totalMs),
|
|
651
|
+
avgMs: Math.round(b.totalMs / b.count * 100) / 100,
|
|
652
|
+
maxMs: Math.round(b.maxMs * 10) / 10
|
|
653
|
+
})).sort((a, b) => b.totalMs - a.totalMs);
|
|
654
|
+
log.warn("[PROFILE] summary", { phases: JSON.stringify(rows) });
|
|
655
|
+
buckets.clear();
|
|
656
|
+
}
|
|
657
|
+
function getPerfSnapshot() {
|
|
658
|
+
if (ring.length < RING_SIZE) return ring.slice();
|
|
659
|
+
return [...ring.slice(writeIdx), ...ring.slice(0, writeIdx)];
|
|
660
|
+
}
|
|
661
|
+
function getSnapshot() {
|
|
662
|
+
if (cachedRevision !== revision) {
|
|
663
|
+
cachedSnapshot = getPerfSnapshot();
|
|
664
|
+
cachedRevision = revision;
|
|
665
|
+
}
|
|
666
|
+
return cachedSnapshot;
|
|
667
|
+
}
|
|
668
|
+
function subscribe(fn) {
|
|
669
|
+
subscribers.add(fn);
|
|
670
|
+
return () => {
|
|
671
|
+
subscribers.delete(fn);
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
function pushPerfEntry(entry) {
|
|
675
|
+
if (!isEnabled()) return;
|
|
676
|
+
push(entry);
|
|
677
|
+
}
|
|
678
|
+
function clearPerf() {
|
|
679
|
+
ring.length = 0;
|
|
680
|
+
writeIdx = 0;
|
|
681
|
+
scheduleNotify();
|
|
682
|
+
}
|
|
683
|
+
var perfStore = {
|
|
684
|
+
subscribe,
|
|
685
|
+
getSnapshot
|
|
686
|
+
};
|
|
687
|
+
var log2 = createLogger("almadar:runtime:verify");
|
|
688
|
+
var MAX_EVENT_LOG = 200;
|
|
689
|
+
var EMPTY_SUMMARY = {
|
|
690
|
+
totalChecks: 0,
|
|
691
|
+
passed: 0,
|
|
692
|
+
failed: 0,
|
|
693
|
+
warnings: 0,
|
|
694
|
+
pending: 0
|
|
695
|
+
};
|
|
696
|
+
function emptySnapshot() {
|
|
697
|
+
return {
|
|
698
|
+
checks: [],
|
|
699
|
+
transitions: [],
|
|
700
|
+
bridge: null,
|
|
701
|
+
summary: EMPTY_SUMMARY,
|
|
702
|
+
traits: []
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
function ensureVerificationApi() {
|
|
706
|
+
if (typeof window === "undefined") return void 0;
|
|
707
|
+
if (!window.__orbitalVerification) {
|
|
708
|
+
window.__orbitalVerification = {
|
|
709
|
+
getSnapshot: emptySnapshot,
|
|
710
|
+
getChecks: () => [],
|
|
711
|
+
getTransitions: () => [],
|
|
712
|
+
getBridge: () => null,
|
|
713
|
+
getSummary: () => EMPTY_SUMMARY,
|
|
714
|
+
waitForTransition: () => Promise.resolve(null),
|
|
715
|
+
getTraitSnapshots: () => []
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
return window.__orbitalVerification;
|
|
719
|
+
}
|
|
720
|
+
function getOrbitalVerification() {
|
|
721
|
+
if (typeof window === "undefined") return void 0;
|
|
722
|
+
return window.__orbitalVerification;
|
|
723
|
+
}
|
|
724
|
+
function bindEventBus(eventBus) {
|
|
725
|
+
const api = ensureVerificationApi();
|
|
726
|
+
if (!api) return;
|
|
727
|
+
api.sendEvent = (event, payload, traitScope) => {
|
|
728
|
+
const prefixed = event.startsWith("UI:") ? event : traitScope ? `UI:${traitScope}.${event}` : `UI:${event}`;
|
|
729
|
+
log2.debug("sendEvent", {
|
|
730
|
+
event: prefixed,
|
|
731
|
+
traitScope,
|
|
732
|
+
payloadKeys: payload ? Object.keys(payload) : []
|
|
733
|
+
});
|
|
734
|
+
eventBus.emit(prefixed, payload);
|
|
735
|
+
};
|
|
736
|
+
const eventLog = [];
|
|
737
|
+
api.eventLog = eventLog;
|
|
738
|
+
api.clearEventLog = () => {
|
|
739
|
+
eventLog.length = 0;
|
|
740
|
+
};
|
|
741
|
+
if (eventBus.onAny) {
|
|
742
|
+
const verificationEventLogger = (event) => {
|
|
743
|
+
if (eventLog.length < MAX_EVENT_LOG) {
|
|
744
|
+
eventLog.push({
|
|
745
|
+
type: event.type,
|
|
746
|
+
payload: event.payload,
|
|
747
|
+
timestamp: Date.now()
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
Object.defineProperty(verificationEventLogger, "name", {
|
|
752
|
+
value: "runtime-verify:eventLog"
|
|
753
|
+
});
|
|
754
|
+
eventBus.onAny(verificationEventLogger);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
function bindTraitStateGetter(getter) {
|
|
758
|
+
const api = ensureVerificationApi();
|
|
759
|
+
if (!api) return;
|
|
760
|
+
api.getTraitState = getter;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/runtime/types.ts
|
|
764
|
+
var types_exports = {};
|
|
765
|
+
__reExport(types_exports, types_star);
|
|
766
|
+
|
|
767
|
+
// src/runtime/events/identity/routing.ts
|
|
768
|
+
var routing_exports = {};
|
|
769
|
+
__reExport(routing_exports, routing_star);
|
|
770
|
+
|
|
771
|
+
// src/runtime/traits/listen-targets.ts
|
|
772
|
+
var listen_targets_exports = {};
|
|
773
|
+
__reExport(listen_targets_exports, listen_targets_star);
|
|
774
|
+
|
|
775
|
+
// src/runtime/traits/OrbitalTraitParsing.ts
|
|
776
|
+
var OrbitalTraitParsing_exports = {};
|
|
777
|
+
__reExport(OrbitalTraitParsing_exports, OrbitalTraitParsing_star);
|
|
778
|
+
|
|
779
|
+
// src/runtime/entities/mockStoreSeed.ts
|
|
780
|
+
var mockStoreSeed_exports = {};
|
|
781
|
+
__reExport(mockStoreSeed_exports, mockStoreSeed_star);
|
|
782
|
+
|
|
783
|
+
// src/runtime/evaluation/residence-transport.ts
|
|
784
|
+
var residence_transport_exports = {};
|
|
785
|
+
__reExport(residence_transport_exports, residence_transport_star);
|
|
786
|
+
|
|
787
|
+
export { OrbitalTraitParsing_exports, PERF_NAMESPACE, RendererContractViolationError, TickScheduler_exports, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, browserStoreName, buildOrbitalsByTrait, buildTraitLinkedEntities, clearPerf, collectEmbeddedTraits, collectTraitRefsFromResolvedTrait, composition_exports, createSlotSetter, cron_exports, duration_exports, ensureVerificationApi, getOrbitalVerification, listen_targets_exports, local_store_transport_exports, mockStoreSeed_exports, nativeMemoryPersistence, openBrowserHost, openBrowserStore, openBrowserStoreTransport, openBundledBrowserStore, openLocalKernel, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, pushPerfEntry, residence_transport_exports, routing_exports, seedBrowserStore_exports, std_mock_seed_exports, trait_index_exports, types_exports, validateSlotContent, withBrowserSeeder, withForkedSeeder, wrapCallbackForEvent };
|