@almadar/ui 6.56.0 → 6.58.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/dist/{ArbitraryClassCompiler-DvzdeHxc.d.ts → ArbitraryClassCompiler-tChQ3nVq.d.ts} +15 -1
- package/dist/{AwaitingSkeletonContext-DPgW__WV.d.ts → AwaitingSkeletonContext-Bh399p1x.d.ts} +1 -3
- package/dist/{Canvas3DHost-DfAhg6EH.d.ts → Canvas3DHost-BTvRPfsr.d.ts} +1 -1
- package/dist/{FileTree-DUi7e7Z8.d.ts → FileTree-BSfgp-HH.d.ts} +29 -2
- package/dist/{GameAudioProvider-DyBvYP2c.d.ts → GameAudioProvider-kXbonWTv.d.ts} +1 -1
- package/dist/Typography-LZTP72Y4.js +5 -0
- package/dist/{UISlotRenderer-QTHFT6Z4.js → UISlotRenderer-N5DFYE6K.js} +8 -8
- package/dist/avl/index.cjs +4940 -4265
- package/dist/avl/index.d.ts +74 -5
- package/dist/avl/index.js +68 -711
- package/dist/{avl-schema-parser-C0wnAp5x.d.ts → avl-schema-parser-CH1QoZw1.d.ts} +1 -1
- package/dist/{chunk-HCSJHRC4.js → chunk-4ZGXIW3B.js} +1 -1
- package/dist/{chunk-RNY5LJXJ.js → chunk-723MJUU3.js} +1 -1
- package/dist/{chunk-6EV3OEBQ.js → chunk-CHNC4UYE.js} +3 -2
- package/dist/{chunk-SGJHVPHC.js → chunk-GZGDBS4S.js} +2 -2
- package/dist/{chunk-Y53Q55H5.js → chunk-HA7CJWQX.js} +1123 -1121
- package/dist/{chunk-FQM37C56.js → chunk-HB3D3HUJ.js} +129 -79
- package/dist/{chunk-XZKGRSIO.js → chunk-I2ZNE5TD.js} +2522 -1188
- package/dist/{chunk-JRW33U35.js → chunk-I5QOYW2Z.js} +1 -1
- package/dist/{chunk-KQXXO42S.js → chunk-KJGVLXEN.js} +78 -1
- package/dist/{chunk-HRCR53OW.js → chunk-LZRW6GXG.js} +18 -3
- package/dist/{chunk-2LFBQ4IS.js → chunk-MZIDOJMD.js} +2 -2
- package/dist/{chunk-QGH4NAQO.js → chunk-N7JIG57B.js} +9 -4
- package/dist/chunk-YYYHH5BA.js +2519 -0
- package/dist/{cn-ClXGlIOY.d.ts → cn-DIql5232.d.ts} +152 -24
- package/dist/components/index.cjs +6917 -3102
- package/dist/components/index.d.ts +54 -101
- package/dist/components/index.js +14 -16
- package/dist/context/index.cjs +23 -0
- package/dist/context/index.d.ts +2 -2
- package/dist/context/index.js +20 -1
- package/dist/hooks/index.cjs +2544 -7
- package/dist/hooks/index.d.ts +4 -1
- package/dist/hooks/index.js +7 -6
- package/dist/lib/drawable/three/index.cjs +22 -6
- package/dist/lib/drawable/three/index.d.ts +4 -4
- package/dist/lib/drawable/three/index.js +7 -7
- package/dist/lib/index.cjs +18 -3
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +4 -5
- package/dist/locales/index.cjs +54 -9
- package/dist/locales/index.js +2 -2489
- package/dist/{paintDispatch-_6EhJCiL.d.ts → paintDispatch-BN8Vbzgs.d.ts} +1 -1
- package/dist/providers/index.cjs +4075 -2415
- package/dist/providers/index.d.ts +6 -6
- package/dist/providers/index.js +26 -18
- package/dist/runtime/index.cjs +4198 -2498
- package/dist/runtime/index.d.ts +4 -17
- package/dist/runtime/index.js +11 -10
- package/dist/ssr/index.cjs +23 -6
- package/dist/ssr/index.js +23 -6
- package/dist/{useEventBus-JUAH3EFW.js → useEventBus-SWRN475O.js} +1 -1
- package/dist/{verificationRegistry-CD7Xb40L.d.ts → verificationRegistry-CK76GUfH.d.ts} +1 -1
- package/locales/ar.json +18 -3
- package/locales/en.json +18 -3
- package/locales/sl.json +18 -3
- package/package.json +9 -8
- package/tailwind-preset.cjs +3 -0
- package/themes/_fonts.css +1 -1
- package/themes/_presets.css +1 -0
- package/themes/kflow.css +299 -0
- package/dist/Typography-7PDT62PG.js +0 -5
- package/dist/chunk-F4ZTPKZL.js +0 -284
- package/dist/chunk-OKWD7LPO.js +0 -80
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useTranslate, useRenderI18n, runTickFrame } from './chunk-
|
|
1
|
+
import { useTranslate, useRenderI18n, runTickFrame } from './chunk-N7JIG57B.js';
|
|
2
2
|
import { ALL_SLOTS } from './chunk-VHTJRS2N.js';
|
|
3
|
-
import { LoadingState, ErrorState, UISlotRenderer } from './chunk-
|
|
4
|
-
import { Box } from './chunk-
|
|
5
|
-
import { Typography } from './chunk-
|
|
6
|
-
import { beginPending, endPending } from './chunk-
|
|
7
|
-
import { useEventBus } from './chunk-
|
|
8
|
-
import { registerTrait, unregisterTrait, perfTimeAsync } from './chunk-
|
|
3
|
+
import { LoadingState, ErrorState, UISlotRenderer } from './chunk-I2ZNE5TD.js';
|
|
4
|
+
import { Box } from './chunk-HA7CJWQX.js';
|
|
5
|
+
import { Typography } from './chunk-4ZGXIW3B.js';
|
|
6
|
+
import { beginPending, endPending } from './chunk-I5QOYW2Z.js';
|
|
7
|
+
import { useEventBus } from './chunk-CHNC4UYE.js';
|
|
8
|
+
import { registerTrait, unregisterTrait, perfTimeAsync } from './chunk-KJGVLXEN.js';
|
|
9
9
|
import { bindTraitStateGetter, registerTraitSnapshot, recordTransition, recordingTransport, recordServerResponse } from './chunk-Q47ZN2DW.js';
|
|
10
10
|
import { isNotificationSlot } from './chunk-PEST66PN.js';
|
|
11
|
-
import React, { useState, useMemo, useEffect, useRef, useCallback, useSyncExternalStore } from 'react';
|
|
11
|
+
import React, { createContext, useState, useMemo, useEffect, useRef, useCallback, useSyncExternalStore, useContext } from 'react';
|
|
12
12
|
import { schemaToIR, getPage, clearSchemaCache as clearSchemaCache$1, traitsEmbeddedByEvent, traitReferencesCallsitePayload, configReferencesCallsitePayload, TRAIT_MOUNT_ERROR_TESTID, traitsEmbeddedByEffects, applyListenPayloadMapping, buildResolvedTraitConfigs, collectCallsiteCaptureChildren, orbitalInlineEntities, storesRowsInBrowser, walkSExpr, isRenderBindingMarker, containsEntityBinding, isSExpr, isEventPayloadValue, RENDER_BINDING_MARKER } from '@almadar/core';
|
|
13
13
|
import { createLogger } from '@almadar/logger';
|
|
14
|
-
import { collectListenerTargets, LIFECYCLE_EVENTS, TraitMountError,
|
|
15
|
-
import { useUser,
|
|
14
|
+
import { collectListenerTargets, LIFECYCLE_EVENTS, TraitMountError, loadLazyPage, createInProcessTransport, buildTraitIndex, createMemoryCircuitStore, createLocalStoreTransport, createResidenceTransport, createClientKernel, createTickScheduler, isValidCronExpression, parseDurationString, UNMOUNT_EVENT, createClientEffectHandlers, EffectExecutor, isSExpression, collectDeclaredConfigDefaults, createContextFromBindings, openBrowserStore, browserStoreName, normalizeCallSiteConfigToValues } from '@almadar/runtime';
|
|
15
|
+
import { useUser, useArbitraryClassStyles, getAllPages, matchPathAmong, CurrentPagePathProvider, NavStackProvider, OrbitalProvider, ServerBridgeProvider, useNavStack, VerificationProvider, EntitySchemaProvider, OrbitalThemeProvider, useServerBridge, EntityBindingContext, AwaitingSkeletonContext } from '@almadar/ui/providers';
|
|
16
16
|
import { evaluateListenPayloadExpr, evaluate, createMinimalContext, evaluateGuard, executeEffects } from '@almadar/evaluator';
|
|
17
17
|
import { getPatternDefinition } from '@almadar/core/patterns';
|
|
18
18
|
import { isKnownStdOperator } from '@almadar/std/registry';
|
|
@@ -21,6 +21,7 @@ export { adjustSchemaForMockData, buildMockData, collectEmbeddedTraits, prepareS
|
|
|
21
21
|
import { useInRouterContext, useHref } from 'react-router-dom';
|
|
22
22
|
import { UISlotProvider, useUISlots } from '@almadar/ui/context';
|
|
23
23
|
import { useTranslate as useTranslate$1, createTranslate, I18nProvider } from '@almadar/ui/hooks';
|
|
24
|
+
import { InMemoryPersistence } from '@almadar/db/mock';
|
|
24
25
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
25
26
|
import { OrbitalServerRuntime } from '@almadar/runtime/OrbitalServerRuntime';
|
|
26
27
|
import { localeDirection } from '@almadar/core/i18n';
|
|
@@ -440,6 +441,22 @@ function useBusIngress(traitBindings, traitIndex, settle, eventBus, appTraitName
|
|
|
440
441
|
});
|
|
441
442
|
unsubscribes.push(unsub);
|
|
442
443
|
}
|
|
444
|
+
const routedBareEvents = /* @__PURE__ */ new Set();
|
|
445
|
+
for (const binding of traitBindings) {
|
|
446
|
+
for (const listen of binding.trait.listens ?? []) {
|
|
447
|
+
if (listen.source !== void 0 && listen.source.kind !== "any") routedBareEvents.add(listen.event);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
for (const eventKey of routedBareEvents) {
|
|
451
|
+
const unsub = eventBus.on(`UI:${eventKey}`, (event) => {
|
|
452
|
+
if (deliveredHere(event.source) || event.source?.trait === void 0) return;
|
|
453
|
+
for (const target of collectListenerTargets(traitIndex, event.source, eventKey, event.payload)) {
|
|
454
|
+
log2.debug("listen-bare:fire", { event: eventKey, source: event.source.trait, listener: target.listenerTrait, triggers: target.triggers });
|
|
455
|
+
dispatch(target.listenerTrait, target.triggers, target.payload, event.source);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
unsubscribes.push(unsub);
|
|
459
|
+
}
|
|
443
460
|
return () => {
|
|
444
461
|
for (const unsub of unsubscribes) unsub();
|
|
445
462
|
};
|
|
@@ -518,7 +535,7 @@ function resolveLambdaBindings(body, params, item, index) {
|
|
|
518
535
|
return body;
|
|
519
536
|
}
|
|
520
537
|
var LazySlotContentRenderer = React.lazy(
|
|
521
|
-
() => import('./UISlotRenderer-
|
|
538
|
+
() => import('./UISlotRenderer-N5DFYE6K.js').then((m) => ({ default: m.SlotContentRenderer }))
|
|
522
539
|
);
|
|
523
540
|
function deferLambdaEntityExprs(value) {
|
|
524
541
|
if (typeof value === "string") {
|
|
@@ -953,6 +970,7 @@ function createSharedEntityWriter(binding, tick, traitStatesRef, emit, traitConf
|
|
|
953
970
|
}
|
|
954
971
|
function useClientTicks(traitBindings, store, traitIndex, options) {
|
|
955
972
|
useEffect(() => {
|
|
973
|
+
if (options.hostRunsProgram === true) return;
|
|
956
974
|
const scheduler = createTickScheduler();
|
|
957
975
|
const traitStatesRef = { current: store.manager.getAllStates() };
|
|
958
976
|
const refreshStates = () => {
|
|
@@ -1098,7 +1116,7 @@ function useClientTicks(traitBindings, store, traitIndex, options) {
|
|
|
1098
1116
|
}
|
|
1099
1117
|
}
|
|
1100
1118
|
return () => scheduler.stopAll();
|
|
1101
|
-
}, [traitBindings, store, traitIndex, options.eventBus, options.slotFlush, options.traitConfigsByName, options.navigate, options.navigateBack, options.user]);
|
|
1119
|
+
}, [traitBindings, store, traitIndex, options.eventBus, options.slotFlush, options.traitConfigsByName, options.navigate, options.navigateBack, options.user, options.hostRunsProgram]);
|
|
1102
1120
|
}
|
|
1103
1121
|
var EMPTY_ENTITY = {};
|
|
1104
1122
|
function useEntityBindingSource(store, traitIndex) {
|
|
@@ -1195,6 +1213,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
1195
1213
|
useClientTicks(traitBindings, store, traitIndex, {
|
|
1196
1214
|
eventBus,
|
|
1197
1215
|
slotFlush,
|
|
1216
|
+
hostRunsProgram: transport?.hostsBrowserStore === true,
|
|
1198
1217
|
...options.traitConfigsByName !== void 0 ? { traitConfigsByName: options.traitConfigsByName } : {},
|
|
1199
1218
|
...options.navigate !== void 0 ? { navigate: options.navigate } : {},
|
|
1200
1219
|
...options.navigateBack !== void 0 ? { navigateBack: options.navigateBack } : {},
|
|
@@ -1329,9 +1348,16 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
1329
1348
|
useEffect(() => {
|
|
1330
1349
|
if (!transport?.subscribe) return;
|
|
1331
1350
|
return transport.subscribe((emitted, target) => {
|
|
1332
|
-
|
|
1333
|
-
|
|
1351
|
+
const listeners = collectListenerTargets(traitIndex, emitted.source, emitted.event, emitted.payload);
|
|
1352
|
+
if (target !== "origin") {
|
|
1353
|
+
for (const t2 of listeners) void dispatchAndSettle(t2.listenerTrait, t2.triggers, t2.payload);
|
|
1354
|
+
return;
|
|
1334
1355
|
}
|
|
1356
|
+
const caller = emitted.source?.trait;
|
|
1357
|
+
if (caller !== void 0 && traitIndex.byName.has(caller) && !listeners.some((t2) => t2.listenerTrait === caller && t2.triggers === emitted.event)) {
|
|
1358
|
+
void progressAndSettle(caller, emitted.event, emitted.payload);
|
|
1359
|
+
}
|
|
1360
|
+
for (const t2 of listeners) void progressAndSettle(t2.listenerTrait, t2.triggers, t2.payload);
|
|
1335
1361
|
}, { clientId: getTabClientId() });
|
|
1336
1362
|
}, [transport, traitIndex, progressAndSettle, dispatchAndSettle]);
|
|
1337
1363
|
useEffect(() => {
|
|
@@ -1341,7 +1367,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
1341
1367
|
if (traitName === void 0 || !traitIndex.byName.has(traitName)) return;
|
|
1342
1368
|
const composedBefore = new Map(store.callsitePayloads);
|
|
1343
1369
|
void kernel.foldHostDispatch(request, response).then((outcome) => settleOutcome(traitName, request.event, request.payload, outcome, composedBefore));
|
|
1344
|
-
});
|
|
1370
|
+
}, { clientId: getTabClientId() });
|
|
1345
1371
|
}, [transport, traitIndex, kernel, store, settleOutcome]);
|
|
1346
1372
|
const mountAndSettle = useCallback(async (seeds, payload) => {
|
|
1347
1373
|
const composedBefore = new Map(store.callsitePayloads);
|
|
@@ -1402,6 +1428,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
1402
1428
|
prevActiveTraitNamesRef.current = nextActiveTraitNames;
|
|
1403
1429
|
}, [traitBindings, uiSlots]);
|
|
1404
1430
|
const mountedRef = useRef(null);
|
|
1431
|
+
const aliveRef = useRef(true);
|
|
1432
|
+
useEffect(() => {
|
|
1433
|
+
aliveRef.current = true;
|
|
1434
|
+
return () => {
|
|
1435
|
+
aliveRef.current = false;
|
|
1436
|
+
};
|
|
1437
|
+
}, []);
|
|
1405
1438
|
const mountKey = `${options.mountKey ?? ""}\0${JSON.stringify(Object.entries(options.initPayload ?? {}).sort(([a], [b]) => a.localeCompare(b)))}`;
|
|
1406
1439
|
useEffect(() => {
|
|
1407
1440
|
const prev = mountedRef.current;
|
|
@@ -1432,6 +1465,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
1432
1465
|
const failed = err instanceof TraitMountError ? err.trait : traits.join(", ");
|
|
1433
1466
|
const cause = err instanceof TraitMountError ? err.original : err;
|
|
1434
1467
|
stateLog.warn("mount:failed", { traits, failed, error: message, stack: cause instanceof Error ? cause.stack : void 0 });
|
|
1468
|
+
if (!aliveRef.current) return;
|
|
1435
1469
|
uiSlots.render({
|
|
1436
1470
|
target: "main",
|
|
1437
1471
|
pattern: "error-state",
|
|
@@ -1560,6 +1594,7 @@ function TraitInitializer({ traits, routeParams, mountKey, orbitals, onNavigate,
|
|
|
1560
1594
|
}
|
|
1561
1595
|
var CONTENT_STAGE_WIDTH = 480;
|
|
1562
1596
|
var NO_ORBITALS = [];
|
|
1597
|
+
var LazyPageOfRegisteredProgram = createContext(false);
|
|
1563
1598
|
function FitToBox({ children, mode = "box" }) {
|
|
1564
1599
|
const outerRef = useRef(null);
|
|
1565
1600
|
const innerRef = useRef(null);
|
|
@@ -1789,6 +1824,17 @@ function resolvePreviewTheme(schema, pageName) {
|
|
|
1789
1824
|
}
|
|
1790
1825
|
return schema.orbitals[0]?.theme ?? schema.theme;
|
|
1791
1826
|
}
|
|
1827
|
+
function NavigateListener({ onNavigate }) {
|
|
1828
|
+
const bus = useEventBus();
|
|
1829
|
+
useEffect(
|
|
1830
|
+
() => bus.on("UI:NAVIGATE", (event) => {
|
|
1831
|
+
const url = event.payload?.url;
|
|
1832
|
+
if (typeof url === "string" && url.length > 0) onNavigate(url);
|
|
1833
|
+
}),
|
|
1834
|
+
[bus, onNavigate]
|
|
1835
|
+
);
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1792
1838
|
function OrbPreview({
|
|
1793
1839
|
schema,
|
|
1794
1840
|
mockData,
|
|
@@ -1814,14 +1860,13 @@ function OrbPreview({
|
|
|
1814
1860
|
}
|
|
1815
1861
|
const { t } = useTranslate$1();
|
|
1816
1862
|
const [localFallback, setLocalFallback] = useState(false);
|
|
1817
|
-
const eventBus = useEventBus();
|
|
1818
1863
|
const inHostRouter = useInRouterContext();
|
|
1819
1864
|
const [hostHrefBase, setHostHrefBase] = useState("/");
|
|
1820
1865
|
const handleLocalFallback = useCallback(() => {
|
|
1821
1866
|
if (localFallback) return;
|
|
1822
1867
|
setLocalFallback(true);
|
|
1823
1868
|
}, [localFallback]);
|
|
1824
|
-
const
|
|
1869
|
+
const isLazyPageOfRegisteredProgram = useContext(LazyPageOfRegisteredProgram);
|
|
1825
1870
|
const parseResult = useMemo(() => {
|
|
1826
1871
|
let parsed;
|
|
1827
1872
|
if (typeof schema === "string") {
|
|
@@ -1968,15 +2013,6 @@ function OrbPreview({
|
|
|
1968
2013
|
const handleNavigateBack = useCallback(() => {
|
|
1969
2014
|
navStackRef.current?.back();
|
|
1970
2015
|
}, []);
|
|
1971
|
-
useEffect(() => {
|
|
1972
|
-
const unsubscribe = eventBus.on("UI:NAVIGATE", (event) => {
|
|
1973
|
-
const url = event.payload?.url;
|
|
1974
|
-
if (typeof url === "string" && url.length > 0) {
|
|
1975
|
-
handleNavigate(url);
|
|
1976
|
-
}
|
|
1977
|
-
});
|
|
1978
|
-
return unsubscribe;
|
|
1979
|
-
}, [eventBus, handleNavigate]);
|
|
1980
2016
|
if (!parseResult.ok) {
|
|
1981
2017
|
return /* @__PURE__ */ jsx(Box, { className, style: { height }, children: /* @__PURE__ */ jsxs(Typography, { as: "pre", color: "error", variant: "small", className: "font-mono whitespace-pre-wrap break-all m-0 p-4", children: [
|
|
1982
2018
|
"Parse error: ",
|
|
@@ -2022,13 +2058,13 @@ function OrbPreview({
|
|
|
2022
2058
|
navLog.info("interceptor:installed", { pageCount: pages.length, paths: pages.map((p) => p.page.path) });
|
|
2023
2059
|
return () => el.removeEventListener("click", handler, true);
|
|
2024
2060
|
}, [pages, handleNavigate, isolated, hostHrefBase]);
|
|
2025
|
-
const withBridge = (node) => (serverUrl || transport) && !
|
|
2061
|
+
const withBridge = (node) => (serverUrl || transport) && !isLazyPageOfRegisteredProgram ? /* @__PURE__ */ jsx(ServerBridgeProvider, { schema: parseResult.schema, serverUrl, transport, getAccessToken, children: node }) : node;
|
|
2026
2062
|
if (lazyRoute) {
|
|
2027
2063
|
return withBridge(
|
|
2028
2064
|
/* @__PURE__ */ jsxs(Box, { ref: containerRef, className: `overflow-auto ${className ?? ""}`, style: { height }, children: [
|
|
2029
2065
|
lazyLoad.status === "loading" && /* @__PURE__ */ jsx(LoadingState, {}),
|
|
2030
2066
|
lazyLoad.status === "error" && /* @__PURE__ */ jsx(ErrorState, { "data-testid": "lazy-page-error", message: lazyLoad.error }),
|
|
2031
|
-
lazyLoad.status === "ready" && /* @__PURE__ */ jsx(
|
|
2067
|
+
lazyLoad.status === "ready" && /* @__PURE__ */ jsx(LazyPageOfRegisteredProgram.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
2032
2068
|
OrbPreview,
|
|
2033
2069
|
{
|
|
2034
2070
|
schema: lazyLoad.schema,
|
|
@@ -2048,7 +2084,7 @@ function OrbPreview({
|
|
|
2048
2084
|
onUnmatchedNavigate: handleNavigate
|
|
2049
2085
|
},
|
|
2050
2086
|
lazyRoute.page.orbRef
|
|
2051
|
-
)
|
|
2087
|
+
) })
|
|
2052
2088
|
] })
|
|
2053
2089
|
);
|
|
2054
2090
|
}
|
|
@@ -2071,41 +2107,44 @@ function OrbPreview({
|
|
|
2071
2107
|
storageKey: `almadar:navstack:${parseResult.schema.name ?? "preview"}`,
|
|
2072
2108
|
children: [
|
|
2073
2109
|
/* @__PURE__ */ jsx(NavStackRefBridge, { apiRef: navStackRef }),
|
|
2074
|
-
/* @__PURE__ */
|
|
2075
|
-
|
|
2076
|
-
{
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2110
|
+
/* @__PURE__ */ jsxs(OrbitalProvider, { initialData: effectiveMockData, skipTheme: true, verification: true, isolated, user, children: [
|
|
2111
|
+
/* @__PURE__ */ jsx(NavigateListener, { onNavigate: handleNavigate }),
|
|
2112
|
+
/* @__PURE__ */ jsx(UISlotProvider, { children: fit ? /* @__PURE__ */ jsx(FitToBox, { mode: fit === "content" ? "content" : "box", children: /* @__PURE__ */ jsx(
|
|
2113
|
+
SchemaRunner,
|
|
2114
|
+
{
|
|
2115
|
+
schema: parseResult.schema,
|
|
2116
|
+
serverUrl,
|
|
2117
|
+
transport,
|
|
2118
|
+
getAccessToken,
|
|
2119
|
+
mockData: effectiveMockData,
|
|
2120
|
+
pageName: currentPage,
|
|
2121
|
+
routeParams,
|
|
2122
|
+
onNavigate: handleNavigateEffect,
|
|
2123
|
+
onNavigateBack: handleNavigateBack,
|
|
2124
|
+
onLocalFallback: handleLocalFallback,
|
|
2125
|
+
localFallbackTimeoutMs,
|
|
2126
|
+
persistence,
|
|
2127
|
+
themeOverride
|
|
2128
|
+
}
|
|
2129
|
+
) }) : /* @__PURE__ */ jsx(
|
|
2130
|
+
SchemaRunner,
|
|
2131
|
+
{
|
|
2132
|
+
schema: parseResult.schema,
|
|
2133
|
+
serverUrl,
|
|
2134
|
+
transport,
|
|
2135
|
+
getAccessToken,
|
|
2136
|
+
mockData: effectiveMockData,
|
|
2137
|
+
pageName: currentPage,
|
|
2138
|
+
routeParams,
|
|
2139
|
+
onNavigate: handleNavigateEffect,
|
|
2140
|
+
onNavigateBack: handleNavigateBack,
|
|
2141
|
+
onLocalFallback: handleLocalFallback,
|
|
2142
|
+
localFallbackTimeoutMs,
|
|
2143
|
+
persistence,
|
|
2144
|
+
themeOverride
|
|
2145
|
+
}
|
|
2146
|
+
) })
|
|
2147
|
+
] })
|
|
2109
2148
|
]
|
|
2110
2149
|
}
|
|
2111
2150
|
) })
|
|
@@ -2142,21 +2181,28 @@ function BrowserPlayground({
|
|
|
2142
2181
|
runtime.resumeTicks();
|
|
2143
2182
|
}
|
|
2144
2183
|
}, [runtime, paused]);
|
|
2145
|
-
const
|
|
2146
|
-
const orbitalNames = schema.orbitals.map((o) => o.name);
|
|
2147
|
-
playgroundLog.debug("register:start", { schema: schema.name, orbitalNames });
|
|
2184
|
+
const lazySchemas = useMemo(() => {
|
|
2148
2185
|
const lazyPages = schema.lazyPages ?? [];
|
|
2149
|
-
|
|
2186
|
+
if (lazyPages.length === 0 || lazyLoader === void 0) return Promise.resolve([]);
|
|
2187
|
+
return Promise.all(lazyPages.map(async (page) => {
|
|
2150
2188
|
const loaded = await loadLazyPage(lazyLoader, page, schemaPath);
|
|
2151
2189
|
if (!loaded.success) throw new Error(loaded.error);
|
|
2152
2190
|
return loaded.data;
|
|
2153
|
-
}))
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2191
|
+
}));
|
|
2192
|
+
}, [schema.lazyPages, lazyLoader, schemaPath]);
|
|
2193
|
+
const registerProgram = useCallback((program) => {
|
|
2194
|
+
const orbitalNames = program.orbitals.map((o) => o.name);
|
|
2195
|
+
playgroundLog.debug("register:start", { schema: program.name, orbitalNames });
|
|
2196
|
+
return lazySchemas.then((lazy) => runtime.register(program, { ...messages !== void 0 ? { messages } : {}, lazy })).then(() => {
|
|
2197
|
+
playgroundLog.debug("register:done", { schema: program.name, orbitalNames });
|
|
2158
2198
|
});
|
|
2159
|
-
}, [runtime,
|
|
2199
|
+
}, [runtime, lazySchemas, messages]);
|
|
2200
|
+
const latestRegistration = useRef(Promise.resolve());
|
|
2201
|
+
const registrationReady = useMemo(() => {
|
|
2202
|
+
const ready = registerProgram(schema);
|
|
2203
|
+
latestRegistration.current = ready;
|
|
2204
|
+
return ready;
|
|
2205
|
+
}, [registerProgram, schema]);
|
|
2160
2206
|
const teardownTimerRef = useRef(null);
|
|
2161
2207
|
useEffect(() => {
|
|
2162
2208
|
if (teardownTimerRef.current !== null) {
|
|
@@ -2174,24 +2220,28 @@ function BrowserPlayground({
|
|
|
2174
2220
|
const transport = useMemo(
|
|
2175
2221
|
() => createInProcessTransport(
|
|
2176
2222
|
async (orbitalName, request) => {
|
|
2177
|
-
await
|
|
2223
|
+
await latestRegistration.current;
|
|
2178
2224
|
return runtime.processOrbitalEvent(orbitalName, request);
|
|
2179
2225
|
},
|
|
2180
2226
|
{
|
|
2181
|
-
//
|
|
2182
|
-
onRegister: () =>
|
|
2227
|
+
// Registers what the bridge hands over (lazy behaviors included): a bridge that unregistered first gets it back.
|
|
2228
|
+
onRegister: (program) => {
|
|
2229
|
+
const ready = registerProgram(program);
|
|
2230
|
+
latestRegistration.current = ready;
|
|
2231
|
+
return ready;
|
|
2232
|
+
},
|
|
2183
2233
|
onUnregister: () => {
|
|
2184
2234
|
runtime.unregisterAll();
|
|
2185
2235
|
}
|
|
2186
2236
|
}
|
|
2187
2237
|
),
|
|
2188
|
-
[runtime, registrationReady]
|
|
2238
|
+
[runtime, registerProgram, registrationReady]
|
|
2189
2239
|
);
|
|
2190
2240
|
const viewerLocale = locale ?? schema.locales?.[0];
|
|
2191
2241
|
const i18n = useMemo(() => {
|
|
2192
2242
|
if (viewerLocale === void 0 || messages === void 0) return void 0;
|
|
2193
2243
|
const catalog = messages[viewerLocale] ?? {};
|
|
2194
|
-
return { locale: viewerLocale, direction: localeDirection(viewerLocale), t: createTranslate(catalog), messages: catalog };
|
|
2244
|
+
return { locale: viewerLocale, direction: localeDirection(viewerLocale), t: createTranslate(catalog, viewerLocale), messages: catalog };
|
|
2195
2245
|
}, [viewerLocale, messages]);
|
|
2196
2246
|
const preview = /* @__PURE__ */ jsx(
|
|
2197
2247
|
OrbPreview,
|