@almadar/ui 6.58.0 → 6.61.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/BehaviorValueFrame-3ORZHPWQ.css +1252 -0
- package/dist/BehaviorValueFrame-QTD7BWOI.js +18 -0
- package/dist/{Canvas3DHost-BTvRPfsr.d.ts → Canvas3DHost-CNjANoaU.d.ts} +1 -1
- package/dist/{GameAudioProvider-kXbonWTv.d.ts → GameAudioProvider-Dv_L-PHt.d.ts} +1 -1
- package/dist/TraitValueFrame-2WMYJOA5.css +1252 -0
- package/dist/TraitValueFrame-WOXNLLMM.js +17 -0
- package/dist/Typography-BY4A2NBY.js +5 -0
- package/dist/{UISlotRenderer-N5DFYE6K.js → UISlotRenderer-EEOXSJCI.js} +10 -8
- package/dist/avl/index.cjs +31960 -27831
- package/dist/avl/index.d.ts +36 -13
- package/dist/avl/index.js +331 -6147
- package/dist/{avl-3d-context-BpBKZIbc.d.ts → avl-3d-context-Dxun3-ri.d.ts} +2 -0
- package/dist/{chunk-I2ZNE5TD.js → chunk-6PV4LASE.js} +9495 -639
- package/dist/{chunk-723MJUU3.js → chunk-6ZCU3BQN.js} +1 -1
- package/dist/{chunk-GZGDBS4S.js → chunk-7NIU5GDC.js} +2 -2
- package/dist/{chunk-YYYHH5BA.js → chunk-CB64IOYD.js} +0 -4
- package/dist/{chunk-MZIDOJMD.js → chunk-EIIQGOZW.js} +2 -1
- package/dist/chunk-F7NZ3KZQ.js +434 -0
- package/dist/{chunk-LZRW6GXG.js → chunk-FYX64CDL.js} +0 -2
- package/dist/{chunk-4ZGXIW3B.js → chunk-KZRAMPM6.js} +1 -1
- package/dist/{chunk-VHTJRS2N.js → chunk-L3MTZ3RH.js} +7 -0
- package/dist/chunk-LUREMDI3.js +49 -0
- package/dist/{chunk-HA7CJWQX.js → chunk-MGN6B6OQ.js} +1477 -1177
- package/dist/{chunk-Q47ZN2DW.js → chunk-N23SVGTH.js} +83 -1
- package/dist/{chunk-KJGVLXEN.js → chunk-N4IJS5DD.js} +50 -116
- package/dist/{chunk-I5QOYW2Z.js → chunk-UTSDPJUP.js} +205 -2
- package/dist/{chunk-V3FGTQUE.js → chunk-ZR45FGW3.js} +7 -1
- package/dist/{cn-DIql5232.d.ts → cn-CDIhHCUC.d.ts} +40 -16
- package/dist/components/index.cjs +14455 -4099
- package/dist/components/index.d.ts +165 -177
- package/dist/components/index.js +14 -15
- package/dist/context/index.cjs +16 -1
- package/dist/context/index.js +4 -2
- package/dist/hooks/index.cjs +79 -6
- package/dist/hooks/index.d.ts +43 -2
- package/dist/hooks/index.js +6 -7
- package/dist/lib/drawable/three/index.cjs +350 -26
- package/dist/lib/drawable/three/index.d.ts +5 -5
- package/dist/lib/drawable/three/index.js +28 -7
- package/dist/lib/index.cjs +90 -4
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +74 -6
- package/dist/locales/index.cjs +0 -6
- package/dist/locales/index.js +2 -2
- package/dist/{paintDispatch-BN8Vbzgs.d.ts → paintDispatch-Cp1_S93j.d.ts} +30 -2
- package/dist/providers/index.cjs +13853 -1075
- package/dist/providers/index.d.ts +38 -6
- package/dist/providers/index.js +40 -30
- package/dist/runtime/index.cjs +28369 -18287
- package/dist/runtime/index.d.ts +65 -3
- package/dist/runtime/index.js +13 -379
- package/dist/ssr/index.cjs +508 -133
- package/dist/ssr/index.d.cts +56 -4
- package/dist/ssr/index.d.ts +56 -4
- package/dist/ssr/index.js +446 -71
- package/dist/{verificationRegistry-CK76GUfH.d.ts → verificationRegistry-B5aGl7WF.d.ts} +3 -2
- package/locales/ar.json +0 -2
- package/locales/en.json +0 -2
- package/locales/sl.json +0 -2
- package/package.json +7 -7
- package/tailwind-preset.cjs +78 -8
- package/themes/_contract.md +6 -0
- package/themes/_fonts.css +4 -4
- package/themes/_foundation.css +11 -0
- package/themes/_presets.css +2 -0
- package/themes/almadar-website.css +10 -0
- package/themes/almadar.css +10 -0
- package/themes/atelier.css +10 -0
- package/themes/bauhaus.css +10 -0
- package/themes/bloomberg-dense.css +10 -0
- package/themes/clay.css +10 -0
- package/themes/corporate.css +10 -0
- package/themes/gazette.css +10 -0
- package/themes/glass.css +10 -0
- package/themes/kflow.css +5 -0
- package/themes/kiosk.css +10 -0
- package/themes/linear-clean.css +10 -0
- package/themes/material.css +10 -0
- package/themes/minimalist.css +10 -0
- package/themes/nata.css +304 -0
- package/themes/neon.css +10 -0
- package/themes/notion-editorial.css +10 -0
- package/themes/orb.css +10 -0
- package/themes/prism.css +10 -0
- package/themes/rawi.css +304 -0
- package/themes/retro.css +10 -0
- package/themes/risograph.css +10 -0
- package/themes/scandi.css +10 -0
- package/themes/solarpunk.css +10 -0
- package/themes/terminal.css +138 -128
- package/dist/Typography-LZTP72Y4.js +0 -5
- package/dist/chunk-D2E44ODB.js +0 -350
- package/dist/chunk-HB3D3HUJ.js +0 -2265
- package/dist/chunk-N7JIG57B.js +0 -138
|
@@ -1,5 +1,74 @@
|
|
|
1
|
+
import { domPassthrough, cn } from './chunk-64WACXM7.js';
|
|
2
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
1
4
|
import { createLogger } from '@almadar/logger';
|
|
2
5
|
|
|
6
|
+
var SAFE_EXIT_MS = 1e3;
|
|
7
|
+
var motionEnabledCache = null;
|
|
8
|
+
function isMotionEnabled() {
|
|
9
|
+
if (typeof document === "undefined") return true;
|
|
10
|
+
if (motionEnabledCache !== null) return motionEnabledCache;
|
|
11
|
+
const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
|
|
12
|
+
motionEnabledCache = v !== "off";
|
|
13
|
+
return motionEnabledCache;
|
|
14
|
+
}
|
|
15
|
+
function usePresence(show, opts) {
|
|
16
|
+
const { animation, animate = true, onExited } = opts;
|
|
17
|
+
const [mounted, setMounted] = useState(show);
|
|
18
|
+
const [exiting, setExiting] = useState(false);
|
|
19
|
+
const prev = useRef(show);
|
|
20
|
+
const onExitedRef = useRef(onExited);
|
|
21
|
+
onExitedRef.current = onExited;
|
|
22
|
+
const safeTimer = useRef(null);
|
|
23
|
+
const clearSafe = useCallback(() => {
|
|
24
|
+
if (safeTimer.current) {
|
|
25
|
+
clearTimeout(safeTimer.current);
|
|
26
|
+
safeTimer.current = null;
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
const finishExit = useCallback(() => {
|
|
30
|
+
clearSafe();
|
|
31
|
+
setExiting(false);
|
|
32
|
+
setMounted(false);
|
|
33
|
+
onExitedRef.current?.();
|
|
34
|
+
}, [clearSafe]);
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
const moving = animate && isMotionEnabled();
|
|
37
|
+
if (show && !prev.current) {
|
|
38
|
+
setExiting(false);
|
|
39
|
+
setMounted(true);
|
|
40
|
+
} else if (!show && prev.current) {
|
|
41
|
+
if (moving) {
|
|
42
|
+
setExiting(true);
|
|
43
|
+
clearSafe();
|
|
44
|
+
safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
|
|
45
|
+
} else {
|
|
46
|
+
setMounted(false);
|
|
47
|
+
setExiting(false);
|
|
48
|
+
onExitedRef.current?.();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
prev.current = show;
|
|
52
|
+
}, [show, animate, clearSafe, finishExit]);
|
|
53
|
+
useEffect(() => () => clearSafe(), [clearSafe]);
|
|
54
|
+
const disabled = !animate || !isMotionEnabled();
|
|
55
|
+
const className = disabled ? "" : show ? `animate-${animation}-in` : `animate-${animation}-out`;
|
|
56
|
+
const onAnimationEnd = useCallback(
|
|
57
|
+
(e) => {
|
|
58
|
+
if (e.target !== e.currentTarget) return;
|
|
59
|
+
if (exiting) finishExit();
|
|
60
|
+
},
|
|
61
|
+
[exiting, finishExit]
|
|
62
|
+
);
|
|
63
|
+
return { mounted, exiting, className, onAnimationEnd };
|
|
64
|
+
}
|
|
65
|
+
var Presence = ({ show, className, children, ...rest }) => {
|
|
66
|
+
const { mounted, className: animClass, onAnimationEnd } = usePresence(show, rest);
|
|
67
|
+
if (!mounted) return null;
|
|
68
|
+
return /* @__PURE__ */ jsx("div", { className: cn(animClass, className), onAnimationEnd, ...domPassthrough(rest), children });
|
|
69
|
+
};
|
|
70
|
+
Presence.displayName = "Presence";
|
|
71
|
+
|
|
3
72
|
// lib/keyMapEvent.ts
|
|
4
73
|
function isEditableTarget(target) {
|
|
5
74
|
if (!(target instanceof HTMLElement)) return false;
|
|
@@ -343,6 +412,7 @@ function bindEventBus(eventBus) {
|
|
|
343
412
|
eventLog.push({
|
|
344
413
|
type: event.type,
|
|
345
414
|
payload: event.payload,
|
|
415
|
+
...event.source === void 0 ? {} : { source: event.source },
|
|
346
416
|
timestamp: Date.now()
|
|
347
417
|
});
|
|
348
418
|
if (eventLog.length > MAX_EVENT_LOG) {
|
|
@@ -358,6 +428,18 @@ function bindEventBus(eventBus) {
|
|
|
358
428
|
}
|
|
359
429
|
}
|
|
360
430
|
}
|
|
431
|
+
function bindConfigApplier(applyConfig) {
|
|
432
|
+
if (typeof window === "undefined") return () => {
|
|
433
|
+
};
|
|
434
|
+
exposeOnWindow();
|
|
435
|
+
const bridge = window.__orbitalVerification;
|
|
436
|
+
if (!bridge) return () => {
|
|
437
|
+
};
|
|
438
|
+
bridge.applyConfig = applyConfig;
|
|
439
|
+
return () => {
|
|
440
|
+
if (bridge.applyConfig === applyConfig) delete bridge.applyConfig;
|
|
441
|
+
};
|
|
442
|
+
}
|
|
361
443
|
function bindTraitStateGetter(getter) {
|
|
362
444
|
if (typeof window === "undefined") return;
|
|
363
445
|
exposeOnWindow();
|
|
@@ -411,4 +493,4 @@ function clearVerification() {
|
|
|
411
493
|
}
|
|
412
494
|
exposeOnWindow();
|
|
413
495
|
|
|
414
|
-
export { bindCanvasCapture, bindEventBus, bindLastDrawables, bindTraitStateGetter, clearVerification, getAllChecks, getBridgeHealth, getSnapshot, getSummary, getTraitSnapshots, getTransitions, getTransitionsForTrait, isEditableTarget, keyMapCode, recordOrbitalResponse, recordServerResponse, recordTransition, recordingTransport, registerCheck, registerTraitSnapshot, resolveKeyMapEvent, serverEffectTraces, subscribeToVerification, updateAssetStatus, updateBridgeHealth, updateCheck, waitForTransition };
|
|
496
|
+
export { Presence, bindCanvasCapture, bindConfigApplier, bindEventBus, bindLastDrawables, bindTraitStateGetter, clearVerification, getAllChecks, getBridgeHealth, getSnapshot, getSummary, getTraitSnapshots, getTransitions, getTransitionsForTrait, isEditableTarget, isMotionEnabled, keyMapCode, recordOrbitalResponse, recordServerResponse, recordTransition, recordingTransport, registerCheck, registerTraitSnapshot, resolveKeyMapEvent, serverEffectTraces, subscribeToVerification, updateAssetStatus, updateBridgeHealth, updateCheck, usePresence, waitForTransition };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { isMotionEnabled } from './chunk-N23SVGTH.js';
|
|
2
|
+
import { useRef, useLayoutEffect, useSyncExternalStore } from 'react';
|
|
4
3
|
import { ENTER_DELAY_STEPS, ENTER_ANIMATIONS, isFileValue } from '@almadar/core';
|
|
5
4
|
export { getNestedValue } from '@almadar/core';
|
|
6
5
|
import { perfStore, pushPerfEntry } from '@almadar/runtime/ui';
|
|
@@ -87,71 +86,6 @@ function eightPointedStarPath(cx, cy, outerR, innerR) {
|
|
|
87
86
|
function arrowheadPath(size) {
|
|
88
87
|
return `M 0 0 L ${size} ${size / 2} L 0 ${size} Z`;
|
|
89
88
|
}
|
|
90
|
-
var SAFE_EXIT_MS = 1e3;
|
|
91
|
-
var motionEnabledCache = null;
|
|
92
|
-
function isMotionEnabled() {
|
|
93
|
-
if (typeof document === "undefined") return true;
|
|
94
|
-
if (motionEnabledCache !== null) return motionEnabledCache;
|
|
95
|
-
const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
|
|
96
|
-
motionEnabledCache = v !== "off";
|
|
97
|
-
return motionEnabledCache;
|
|
98
|
-
}
|
|
99
|
-
function usePresence(show, opts) {
|
|
100
|
-
const { animation, animate = true, onExited } = opts;
|
|
101
|
-
const [mounted, setMounted] = useState(show);
|
|
102
|
-
const [exiting, setExiting] = useState(false);
|
|
103
|
-
const prev = useRef(show);
|
|
104
|
-
const onExitedRef = useRef(onExited);
|
|
105
|
-
onExitedRef.current = onExited;
|
|
106
|
-
const safeTimer = useRef(null);
|
|
107
|
-
const clearSafe = useCallback(() => {
|
|
108
|
-
if (safeTimer.current) {
|
|
109
|
-
clearTimeout(safeTimer.current);
|
|
110
|
-
safeTimer.current = null;
|
|
111
|
-
}
|
|
112
|
-
}, []);
|
|
113
|
-
const finishExit = useCallback(() => {
|
|
114
|
-
clearSafe();
|
|
115
|
-
setExiting(false);
|
|
116
|
-
setMounted(false);
|
|
117
|
-
onExitedRef.current?.();
|
|
118
|
-
}, [clearSafe]);
|
|
119
|
-
useLayoutEffect(() => {
|
|
120
|
-
const moving = animate && isMotionEnabled();
|
|
121
|
-
if (show && !prev.current) {
|
|
122
|
-
setExiting(false);
|
|
123
|
-
setMounted(true);
|
|
124
|
-
} else if (!show && prev.current) {
|
|
125
|
-
if (moving) {
|
|
126
|
-
setExiting(true);
|
|
127
|
-
clearSafe();
|
|
128
|
-
safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
|
|
129
|
-
} else {
|
|
130
|
-
setMounted(false);
|
|
131
|
-
setExiting(false);
|
|
132
|
-
onExitedRef.current?.();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
prev.current = show;
|
|
136
|
-
}, [show, animate, clearSafe, finishExit]);
|
|
137
|
-
useEffect(() => () => clearSafe(), [clearSafe]);
|
|
138
|
-
const disabled = !animate || !isMotionEnabled();
|
|
139
|
-
const className = disabled ? "" : show ? `animate-${animation}-in` : `animate-${animation}-out`;
|
|
140
|
-
const onAnimationEnd = useCallback(
|
|
141
|
-
(e) => {
|
|
142
|
-
if (e.target !== e.currentTarget) return;
|
|
143
|
-
if (exiting) finishExit();
|
|
144
|
-
},
|
|
145
|
-
[exiting, finishExit]
|
|
146
|
-
);
|
|
147
|
-
return { mounted, exiting, className, onAnimationEnd };
|
|
148
|
-
}
|
|
149
|
-
var Presence = ({ show, className, children, ...rest }) => {
|
|
150
|
-
const { mounted, className: animClass, onAnimationEnd } = usePresence(show, rest);
|
|
151
|
-
if (!mounted) return null;
|
|
152
|
-
return /* @__PURE__ */ jsx("div", { className: cn(animClass, className), onAnimationEnd, ...domPassthrough(rest), children });
|
|
153
|
-
};
|
|
154
|
-
Presence.displayName = "Presence";
|
|
155
89
|
var ENTER_SLOT_CLASS = "almadar-enter-slot";
|
|
156
90
|
function asEnterAnimation(value) {
|
|
157
91
|
return ENTER_ANIMATIONS.find((e) => e === value);
|
|
@@ -774,6 +708,53 @@ function parseContentSegments(content) {
|
|
|
774
708
|
}
|
|
775
709
|
return segments;
|
|
776
710
|
}
|
|
711
|
+
|
|
712
|
+
// lib/traitRegistry.ts
|
|
713
|
+
var traits = /* @__PURE__ */ new Map();
|
|
714
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
715
|
+
function notifyListeners() {
|
|
716
|
+
listeners.forEach((listener) => listener());
|
|
717
|
+
}
|
|
718
|
+
function registerTrait(info) {
|
|
719
|
+
traits.set(info.id, info);
|
|
720
|
+
notifyListeners();
|
|
721
|
+
}
|
|
722
|
+
function updateTraitState(id, newState) {
|
|
723
|
+
const trait = traits.get(id);
|
|
724
|
+
if (trait) {
|
|
725
|
+
trait.currentState = newState;
|
|
726
|
+
trait.transitionCount++;
|
|
727
|
+
notifyListeners();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function updateGuardResult(traitId, guardName, result) {
|
|
731
|
+
const trait = traits.get(traitId);
|
|
732
|
+
if (trait) {
|
|
733
|
+
const guard = trait.guards.find((g) => g.name === guardName);
|
|
734
|
+
if (guard) {
|
|
735
|
+
guard.lastResult = result;
|
|
736
|
+
notifyListeners();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function unregisterTrait(id) {
|
|
741
|
+
traits.delete(id);
|
|
742
|
+
notifyListeners();
|
|
743
|
+
}
|
|
744
|
+
function getAllTraits() {
|
|
745
|
+
return Array.from(traits.values());
|
|
746
|
+
}
|
|
747
|
+
function getTrait(id) {
|
|
748
|
+
return traits.get(id);
|
|
749
|
+
}
|
|
750
|
+
function subscribeToTraitChanges(listener) {
|
|
751
|
+
listeners.add(listener);
|
|
752
|
+
return () => listeners.delete(listener);
|
|
753
|
+
}
|
|
754
|
+
function clearTraits() {
|
|
755
|
+
traits.clear();
|
|
756
|
+
notifyListeners();
|
|
757
|
+
}
|
|
777
758
|
var NAMESPACE = "almadar:ui:debug";
|
|
778
759
|
var log = createLogger(NAMESPACE);
|
|
779
760
|
var inputLog = createLogger("almadar:ui:debug:input");
|
|
@@ -859,53 +840,6 @@ function toLogMetaValue(v) {
|
|
|
859
840
|
return String(v);
|
|
860
841
|
}
|
|
861
842
|
|
|
862
|
-
// lib/traitRegistry.ts
|
|
863
|
-
var traits = /* @__PURE__ */ new Map();
|
|
864
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
865
|
-
function notifyListeners() {
|
|
866
|
-
listeners.forEach((listener) => listener());
|
|
867
|
-
}
|
|
868
|
-
function registerTrait(info) {
|
|
869
|
-
traits.set(info.id, info);
|
|
870
|
-
notifyListeners();
|
|
871
|
-
}
|
|
872
|
-
function updateTraitState(id, newState) {
|
|
873
|
-
const trait = traits.get(id);
|
|
874
|
-
if (trait) {
|
|
875
|
-
trait.currentState = newState;
|
|
876
|
-
trait.transitionCount++;
|
|
877
|
-
notifyListeners();
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
function updateGuardResult(traitId, guardName, result) {
|
|
881
|
-
const trait = traits.get(traitId);
|
|
882
|
-
if (trait) {
|
|
883
|
-
const guard = trait.guards.find((g) => g.name === guardName);
|
|
884
|
-
if (guard) {
|
|
885
|
-
guard.lastResult = result;
|
|
886
|
-
notifyListeners();
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
function unregisterTrait(id) {
|
|
891
|
-
traits.delete(id);
|
|
892
|
-
notifyListeners();
|
|
893
|
-
}
|
|
894
|
-
function getAllTraits() {
|
|
895
|
-
return Array.from(traits.values());
|
|
896
|
-
}
|
|
897
|
-
function getTrait(id) {
|
|
898
|
-
return traits.get(id);
|
|
899
|
-
}
|
|
900
|
-
function subscribeToTraitChanges(listener) {
|
|
901
|
-
listeners.add(listener);
|
|
902
|
-
return () => listeners.delete(listener);
|
|
903
|
-
}
|
|
904
|
-
function clearTraits() {
|
|
905
|
-
traits.clear();
|
|
906
|
-
notifyListeners();
|
|
907
|
-
}
|
|
908
|
-
|
|
909
843
|
// lib/tickRegistry.ts
|
|
910
844
|
var ticks = /* @__PURE__ */ new Map();
|
|
911
845
|
var listeners2 = /* @__PURE__ */ new Set();
|
|
@@ -1195,4 +1129,4 @@ function parseLessonSegments(lesson) {
|
|
|
1195
1129
|
return segments;
|
|
1196
1130
|
}
|
|
1197
1131
|
|
|
1198
|
-
export { EDITOR_MOTIONS, EDITOR_OPERATORS, ENTER_SLOT_CLASS, INDENT_UNIT, MAX_ENTER_DELAY,
|
|
1132
|
+
export { EDITOR_MOTIONS, EDITOR_OPERATORS, ENTER_SLOT_CLASS, INDENT_UNIT, MAX_ENTER_DELAY, applyMotion, applyOperator, arrowheadPath, asEnterAnimation, brainIconPath, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, computeLineDiff, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, eightPointedStarPath, enterClassName, gearTeethPath, getAllTicks, getAllTraits, getDebugEvents, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, getTrait, initDebugShortcut, isDebugEnabled, isDebugEnabled2, isEditorMotion, isEditorOperator, lockIconPath, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, motionRange, onDebugToggle, parseContentSegments, parseLessonSegments, parseMarkdownWithCodeBlocks, parseMarkdownWithCodeBlocks2, pipeIconPath, profilerOnRender, recordGuardEvaluation, registerTick, registerTrait, resolveImageUrl, setDebugEnabled, setEntityProvider, setTickActive, slotPlaysDefaultEnter, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, toggleDebug, unregisterTick, unregisterTrait, updateGuardResult, updateTickExecution, updateTraitState, usePerfBuffer, useSlotEnterRestart };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { ar_default, sl_default } from './chunk-CB64IOYD.js';
|
|
1
2
|
import { useEventBus } from './chunk-CHNC4UYE.js';
|
|
2
|
-
import {
|
|
3
|
+
import { DEFAULT_CURRENCY } from './chunk-6ZCU3BQN.js';
|
|
4
|
+
import { en_default } from './chunk-FYX64CDL.js';
|
|
5
|
+
import React, { createContext, useCallback, useSyncExternalStore, useRef, useState, useContext, useEffect, useMemo } from 'react';
|
|
6
|
+
import { mergeEntityFrame, resolvePageMeta } from '@almadar/core';
|
|
7
|
+
import { createLogger } from '@almadar/logger';
|
|
3
8
|
|
|
4
9
|
function useMediaQuery(query) {
|
|
5
10
|
const subscribe = useCallback(
|
|
@@ -549,6 +554,204 @@ function parseQueryBinding(binding) {
|
|
|
549
554
|
field: parts.length > 1 ? parts.slice(1).join(".") : void 0
|
|
550
555
|
};
|
|
551
556
|
}
|
|
557
|
+
var { $meta: _meta, ...coreMessages } = en_default;
|
|
558
|
+
var coreLocale = coreMessages;
|
|
559
|
+
var { $meta: _arMeta, ...arMessages } = ar_default;
|
|
560
|
+
var { $meta: _slMeta, ...slMessages } = sl_default;
|
|
561
|
+
var uiLocales = { en: coreLocale, ar: arMessages, sl: slMessages };
|
|
562
|
+
var I18nContext = createContext({
|
|
563
|
+
locale: "en",
|
|
564
|
+
direction: "ltr",
|
|
565
|
+
t: (key, params) => {
|
|
566
|
+
let msg = coreLocale[key] ?? key;
|
|
567
|
+
if (params) {
|
|
568
|
+
for (const [k, v] of Object.entries(params)) {
|
|
569
|
+
msg = msg.split(`{{${k}}}`).join(String(v));
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return msg;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
I18nContext.displayName = "I18nContext";
|
|
576
|
+
function I18nProvider({ value, children, documentRoot }) {
|
|
577
|
+
useEffect(() => {
|
|
578
|
+
if (!documentRoot) return;
|
|
579
|
+
document.documentElement.lang = value.locale;
|
|
580
|
+
document.documentElement.dir = value.direction;
|
|
581
|
+
}, [documentRoot, value.locale, value.direction]);
|
|
582
|
+
return React.createElement(I18nContext.Provider, { value }, children);
|
|
583
|
+
}
|
|
584
|
+
function useTranslate() {
|
|
585
|
+
return useContext(I18nContext);
|
|
586
|
+
}
|
|
587
|
+
function useRenderI18n() {
|
|
588
|
+
const { locale, messages } = useContext(I18nContext);
|
|
589
|
+
return useMemo(() => messages !== void 0 ? { locale, messages } : void 0, [locale, messages]);
|
|
590
|
+
}
|
|
591
|
+
function useFormatContext() {
|
|
592
|
+
const { t, locale, currency } = useContext(I18nContext);
|
|
593
|
+
return useMemo(
|
|
594
|
+
() => ({ locale, currency: currency ?? DEFAULT_CURRENCY, booleanLabels: { yes: t("common.yes"), no: t("common.no") } }),
|
|
595
|
+
[t, locale, currency]
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
function createTranslate(messages, locale) {
|
|
599
|
+
const uiCatalog = locale !== void 0 ? uiLocales[locale] : void 0;
|
|
600
|
+
return (key, params) => {
|
|
601
|
+
let msg = messages[key] ?? uiCatalog?.[key] ?? coreLocale[key] ?? key;
|
|
602
|
+
if (params) {
|
|
603
|
+
for (const [k, v] of Object.entries(params)) {
|
|
604
|
+
msg = msg.split(`{{${k}}}`).join(String(v));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return msg;
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// lib/bus-claim.ts
|
|
612
|
+
var claims = /* @__PURE__ */ new WeakMap();
|
|
613
|
+
function claimDelivery(source, trait, event) {
|
|
614
|
+
if (source === void 0) return true;
|
|
615
|
+
const key = `${trait}\0${event}`;
|
|
616
|
+
const seen = claims.get(source);
|
|
617
|
+
if (seen === void 0) {
|
|
618
|
+
claims.set(source, /* @__PURE__ */ new Set([key]));
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
621
|
+
if (seen.has(key)) return false;
|
|
622
|
+
seen.add(key);
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
var log = createLogger("almadar:ui:shared-entity-store");
|
|
626
|
+
var EMPTY_ENTITY_STATE = {};
|
|
627
|
+
function createSharedEntityStore() {
|
|
628
|
+
const states = /* @__PURE__ */ new Map();
|
|
629
|
+
const subscribers = /* @__PURE__ */ new Map();
|
|
630
|
+
const getSnapshot = (entityId) => states.get(entityId) ?? EMPTY_ENTITY_STATE;
|
|
631
|
+
const subscribe = (entityId, callback) => {
|
|
632
|
+
let set = subscribers.get(entityId);
|
|
633
|
+
if (!set) {
|
|
634
|
+
set = /* @__PURE__ */ new Set();
|
|
635
|
+
subscribers.set(entityId, set);
|
|
636
|
+
}
|
|
637
|
+
set.add(callback);
|
|
638
|
+
return () => {
|
|
639
|
+
const current = subscribers.get(entityId);
|
|
640
|
+
if (!current) return;
|
|
641
|
+
current.delete(callback);
|
|
642
|
+
if (current.size === 0) {
|
|
643
|
+
subscribers.delete(entityId);
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
};
|
|
647
|
+
const commit = (entityId, nextState) => {
|
|
648
|
+
states.set(entityId, nextState);
|
|
649
|
+
const set = subscribers.get(entityId);
|
|
650
|
+
if (!set) return;
|
|
651
|
+
set.forEach((callback) => {
|
|
652
|
+
try {
|
|
653
|
+
callback();
|
|
654
|
+
} catch (error) {
|
|
655
|
+
log.error("Shared entity subscriber error", {
|
|
656
|
+
entityId,
|
|
657
|
+
error: error instanceof Error ? error : String(error)
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
};
|
|
662
|
+
const seed = (entityId, initialState) => {
|
|
663
|
+
if (!states.has(entityId)) {
|
|
664
|
+
states.set(entityId, initialState);
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
return { getSnapshot, subscribe, commit, seed };
|
|
668
|
+
}
|
|
669
|
+
function useSharedEntityStore() {
|
|
670
|
+
const storeRef = useRef(null);
|
|
671
|
+
if (storeRef.current === null) {
|
|
672
|
+
storeRef.current = createSharedEntityStore();
|
|
673
|
+
}
|
|
674
|
+
return storeRef.current;
|
|
675
|
+
}
|
|
676
|
+
var SharedEntityStoreContext = createContext(null);
|
|
677
|
+
function useSharedEntityStoreContext() {
|
|
678
|
+
const store = useContext(SharedEntityStoreContext);
|
|
679
|
+
if (!store) {
|
|
680
|
+
throw new Error(
|
|
681
|
+
"useSharedEntityStoreContext: no SharedEntityStoreContext.Provider found in the component tree"
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
return store;
|
|
685
|
+
}
|
|
686
|
+
function useSharedEntitySnapshot(store, entityId) {
|
|
687
|
+
return useSyncExternalStore(
|
|
688
|
+
(onStoreChange) => store.subscribe(entityId, onStoreChange),
|
|
689
|
+
() => store.getSnapshot(entityId)
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
function runTickFrame(entityId, orderedWriters, store) {
|
|
693
|
+
let scratch = store.getSnapshot(entityId);
|
|
694
|
+
for (const writer of orderedWriters) {
|
|
695
|
+
const writes = writer(scratch);
|
|
696
|
+
scratch = mergeEntityFrame(scratch, writes);
|
|
697
|
+
}
|
|
698
|
+
store.commit(entityId, scratch);
|
|
699
|
+
return scratch;
|
|
700
|
+
}
|
|
701
|
+
var OWNED = "data-orb-head";
|
|
702
|
+
var shellTitle;
|
|
703
|
+
function ownedTag(tag, attrs) {
|
|
704
|
+
const el = document.createElement(tag);
|
|
705
|
+
for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
|
|
706
|
+
el.setAttribute(OWNED, "");
|
|
707
|
+
return el;
|
|
708
|
+
}
|
|
709
|
+
function usePageHead(input) {
|
|
710
|
+
const { messages, locale } = useTranslate();
|
|
711
|
+
const title = input ? resolvePageMeta(input.title, (k) => messages?.[k]) : void 0;
|
|
712
|
+
const description = input ? resolvePageMeta(input.description, (k) => messages?.[k]) : void 0;
|
|
713
|
+
const isPublic = input?.access !== "authenticated" && input?.indexing !== "noindex";
|
|
714
|
+
const canonical = input?.origin !== void 0 ? `${input.origin.replace(/\/+$/, "")}${input.path}` : void 0;
|
|
715
|
+
const siteName = input?.siteName;
|
|
716
|
+
const active = input !== null;
|
|
717
|
+
const originBase = input?.origin?.replace(/\/+$/, "");
|
|
718
|
+
const hreflang = [];
|
|
719
|
+
if (originBase !== void 0) {
|
|
720
|
+
for (const alt of input?.alternates ?? []) hreflang.push([alt.locale, `${originBase}${alt.path}`]);
|
|
721
|
+
const fallback = input?.alternates?.find((alt) => alt.locale === input.defaultLocale);
|
|
722
|
+
if (fallback !== void 0) hreflang.push(["x-default", `${originBase}${fallback.path}`]);
|
|
723
|
+
}
|
|
724
|
+
const hreflangKey = hreflang.map(([lang, href]) => `${lang} ${href}`).join("\n");
|
|
725
|
+
useEffect(() => {
|
|
726
|
+
if (!active || typeof document === "undefined") return void 0;
|
|
727
|
+
shellTitle ?? (shellTitle = document.title);
|
|
728
|
+
document.title = title ?? siteName ?? shellTitle;
|
|
729
|
+
const tags = [];
|
|
730
|
+
if (!isPublic) tags.push(ownedTag("meta", { name: "robots", content: "noindex" }));
|
|
731
|
+
if (isPublic && description !== void 0) {
|
|
732
|
+
tags.push(ownedTag("meta", { name: "description", content: description }));
|
|
733
|
+
tags.push(ownedTag("meta", { property: "og:description", content: description }));
|
|
734
|
+
}
|
|
735
|
+
if (isPublic && title !== void 0) tags.push(ownedTag("meta", { property: "og:title", content: title }));
|
|
736
|
+
if (isPublic && canonical !== void 0) {
|
|
737
|
+
tags.push(ownedTag("link", { rel: "canonical", href: canonical }));
|
|
738
|
+
tags.push(ownedTag("meta", { property: "og:url", content: canonical }));
|
|
739
|
+
}
|
|
740
|
+
if (isPublic && siteName !== void 0) tags.push(ownedTag("meta", { property: "og:site_name", content: siteName }));
|
|
741
|
+
if (isPublic) tags.push(ownedTag("meta", { property: "og:locale", content: locale }));
|
|
742
|
+
if (isPublic && hreflangKey !== "") {
|
|
743
|
+
for (const line of hreflangKey.split("\n")) {
|
|
744
|
+
const space = line.indexOf(" ");
|
|
745
|
+
tags.push(ownedTag("link", { rel: "alternate", hreflang: line.slice(0, space), href: line.slice(space + 1) }));
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
for (const stale of Array.from(document.head.querySelectorAll(`[${OWNED}]`))) stale.remove();
|
|
749
|
+
for (const tag of tags) document.head.appendChild(tag);
|
|
750
|
+
return () => {
|
|
751
|
+
for (const tag of tags) tag.remove();
|
|
752
|
+
};
|
|
753
|
+
}, [active, title, description, isPublic, canonical, siteName, locale, hreflangKey]);
|
|
754
|
+
}
|
|
552
755
|
function usePullToRefresh(onRefresh, options = {}) {
|
|
553
756
|
const { threshold = 60, maxPull = 120 } = options;
|
|
554
757
|
const [pullDistance, setPullDistance] = useState(0);
|
|
@@ -678,4 +881,4 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
678
881
|
};
|
|
679
882
|
}
|
|
680
883
|
|
|
681
|
-
export { ALMADAR_DND_MIME, PendingScopeContext, beginPending, endPending, parseQueryBinding, useAuthContext, useCanvasGestures, useDragReorder, useDraggable, useDropZone, useInfiniteScroll, useLongPress, useMediaQuery, usePendingAction, usePendingRows, usePendingScopeValue, usePrefersReducedMotion, usePullToRefresh, useQuerySingleton, useScopeHasPending, useSwipeGesture };
|
|
884
|
+
export { ALMADAR_DND_MIME, I18nProvider, PendingScopeContext, SharedEntityStoreContext, beginPending, claimDelivery, createSharedEntityStore, createTranslate, endPending, parseQueryBinding, runTickFrame, useAuthContext, useCanvasGestures, useDragReorder, useDraggable, useDropZone, useFormatContext, useInfiniteScroll, useLongPress, useMediaQuery, usePageHead, usePendingAction, usePendingRows, usePendingScopeValue, usePrefersReducedMotion, usePullToRefresh, useQuerySingleton, useRenderI18n, useScopeHasPending, useSharedEntitySnapshot, useSharedEntityStore, useSharedEntityStoreContext, useSwipeGesture, useTranslate };
|
|
@@ -134,7 +134,13 @@ var SURFACE_VARS = [
|
|
|
134
134
|
{ cssVar: "--surface-card-image", key: "cardImage" },
|
|
135
135
|
{ cssVar: "--surface-page-image", key: "pageImage" },
|
|
136
136
|
{ cssVar: "--surface-page-image-size", key: "pageImageSize" },
|
|
137
|
-
{ cssVar: "--surface-diagram", key: "diagram" }
|
|
137
|
+
{ cssVar: "--surface-diagram", key: "diagram" },
|
|
138
|
+
{ cssVar: "--surface-edge-mask", key: "edgeMask" },
|
|
139
|
+
{ cssVar: "--surface-edge-height", key: "edgeHeight" },
|
|
140
|
+
{ cssVar: "--surface-texture-mask", key: "textureMask" },
|
|
141
|
+
{ cssVar: "--surface-texture-size", key: "textureSize" },
|
|
142
|
+
{ cssVar: "--surface-accent-image", key: "accentImage" },
|
|
143
|
+
{ cssVar: "--surface-scrim", key: "scrim" }
|
|
138
144
|
];
|
|
139
145
|
var DIAGRAM_VARS = [
|
|
140
146
|
{ cssVar: "--diagram-stroke-thin", key: "strokeThin" },
|
|
@@ -135,12 +135,14 @@ declare const BloomQuizBlock: React__default.FC<BloomQuizBlockProps>;
|
|
|
135
135
|
/**
|
|
136
136
|
* CodeRunnerPanel Organism Component
|
|
137
137
|
*
|
|
138
|
-
* Editable code block with Run/Reset buttons and
|
|
139
|
-
*
|
|
140
|
-
*
|
|
138
|
+
* Editable code block with Run/Reset buttons and a terminal output pane.
|
|
139
|
+
* Running is the program's job: Run emits the declared `runEvent` request and the
|
|
140
|
+
* program binds the result back through `output` / `running` / `error`.
|
|
141
141
|
*
|
|
142
142
|
* Event Contract:
|
|
143
|
-
* - Emits: UI
|
|
143
|
+
* - Emits: UI:<runEvent> { code, language, runId? } on Run
|
|
144
|
+
* - Emits: UI:<resetEvent> { runId? } on Reset (when declared)
|
|
145
|
+
* - Emits: UI:COPY_CODE { language, success } on Copy
|
|
144
146
|
* - entityAware: false
|
|
145
147
|
*/
|
|
146
148
|
|
|
@@ -160,16 +162,26 @@ interface CodeRunnerPanelProps extends Omit<React__default.AriaAttributes, keyof
|
|
|
160
162
|
code: string;
|
|
161
163
|
/** Programming language for syntax highlighting */
|
|
162
164
|
language: string;
|
|
163
|
-
/** Whether the panel
|
|
165
|
+
/** Whether the panel is editable and runnable (default false = read-only code block) */
|
|
164
166
|
runnable?: boolean;
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/** Event
|
|
172
|
-
|
|
167
|
+
/** Event emitted on Run as `UI:<runEvent>` with `{ code, language, runId }`. Defaults to 'RUN_CODE'. */
|
|
168
|
+
runEvent?: EventEmit<{
|
|
169
|
+
code: string;
|
|
170
|
+
language: string;
|
|
171
|
+
runId: string;
|
|
172
|
+
}>;
|
|
173
|
+
/** Event emitted on Reset as `UI:<resetEvent>` with `{ runId }`; Reset only restores the code when absent. */
|
|
174
|
+
resetEvent?: EventEmit<{
|
|
175
|
+
runId: string;
|
|
176
|
+
}>;
|
|
177
|
+
/** Identifies this panel in its run/reset payloads (e.g. a lesson segment); empty when one panel stands alone. */
|
|
178
|
+
runId?: string;
|
|
179
|
+
/** The program's result for the last run, bound back into the panel. */
|
|
180
|
+
output?: CodeSimulationOutput | null;
|
|
181
|
+
/** True while the program is running the code. */
|
|
182
|
+
running?: boolean;
|
|
183
|
+
/** A run failure message from the program; replaces the output body. */
|
|
184
|
+
error?: string | null;
|
|
173
185
|
/** Additional CSS classes */
|
|
174
186
|
className?: string;
|
|
175
187
|
}
|
|
@@ -280,10 +292,22 @@ interface SegmentRendererProps extends Omit<React__default.AriaAttributes, keyof
|
|
|
280
292
|
/** User progress for restoring activation/reflection state */
|
|
281
293
|
userProgress?: LessonUserProgress;
|
|
282
294
|
/**
|
|
283
|
-
*
|
|
284
|
-
*
|
|
295
|
+
* Event a runnable code block emits on Run (`{ code, language, runId }`, runId = the segment
|
|
296
|
+
* index). Omit to render runnable blocks read-only.
|
|
285
297
|
*/
|
|
286
|
-
|
|
298
|
+
runCodeEvent?: EventEmit<{
|
|
299
|
+
code: string;
|
|
300
|
+
language: string;
|
|
301
|
+
runId: string;
|
|
302
|
+
}>;
|
|
303
|
+
/** Event a runnable code block emits on Reset (`{ runId }`). */
|
|
304
|
+
resetCodeEvent?: EventEmit<{
|
|
305
|
+
runId: string;
|
|
306
|
+
}>;
|
|
307
|
+
/** The program's run results, keyed by segment runId. */
|
|
308
|
+
codeOutputs?: Record<string, CodeSimulationOutput>;
|
|
309
|
+
/** The runId the program is currently running. */
|
|
310
|
+
runningCode?: string;
|
|
287
311
|
/**
|
|
288
312
|
* Optional render slot for `visualization` segment types. When not provided,
|
|
289
313
|
* visualization segments are silently skipped. Callers can wire this to any
|