@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,349 @@
|
|
|
1
|
+
import { createLogger } from '@almadar/logger';
|
|
2
|
+
import { createContext, useRef, useCallback, useEffect, useContext } from 'react';
|
|
3
|
+
import { componentMapping as componentMapping$1, patternsRegistry } from '@almadar/core/patterns';
|
|
4
|
+
|
|
5
|
+
var log = createLogger("almadar:ui:pattern-resolver");
|
|
6
|
+
var componentMapping = {};
|
|
7
|
+
var patternRegistry = {};
|
|
8
|
+
function initializePatternResolver(config) {
|
|
9
|
+
componentMapping = config.componentMapping;
|
|
10
|
+
patternRegistry = config.patternRegistry;
|
|
11
|
+
}
|
|
12
|
+
function setComponentMapping(mapping) {
|
|
13
|
+
componentMapping = mapping;
|
|
14
|
+
}
|
|
15
|
+
function setPatternRegistry(registry) {
|
|
16
|
+
patternRegistry = registry;
|
|
17
|
+
}
|
|
18
|
+
function resolvePattern(config) {
|
|
19
|
+
const { type } = config;
|
|
20
|
+
const mapping = componentMapping[type];
|
|
21
|
+
if (!mapping) {
|
|
22
|
+
if (Object.keys(componentMapping).length === 0) {
|
|
23
|
+
log.warn("Component mapping not initialized. Call initializePatternResolver() at app startup.");
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Unknown pattern type: ${type}`);
|
|
26
|
+
}
|
|
27
|
+
if (mapping.deprecated) {
|
|
28
|
+
log.warn("Pattern is deprecated", {
|
|
29
|
+
type,
|
|
30
|
+
replacedBy: mapping.replacedBy
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const validatedProps = validatePatternProps(config);
|
|
34
|
+
return {
|
|
35
|
+
component: mapping.component,
|
|
36
|
+
importPath: mapping.importPath,
|
|
37
|
+
category: mapping.category,
|
|
38
|
+
validatedProps
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function validatePatternProps(config) {
|
|
42
|
+
const { type: patternType, ...rest } = config;
|
|
43
|
+
const definition = patternRegistry[patternType];
|
|
44
|
+
const definedProps = Object.fromEntries(
|
|
45
|
+
Object.entries(rest).filter((entry) => {
|
|
46
|
+
const v = entry[1];
|
|
47
|
+
if (v === void 0 || typeof v === "function") return false;
|
|
48
|
+
return true;
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
if (!definition || !definition.propsSchema) {
|
|
52
|
+
return definedProps;
|
|
53
|
+
}
|
|
54
|
+
const validated = { ...definedProps };
|
|
55
|
+
const schema = definition.propsSchema;
|
|
56
|
+
for (const [propName, propDef] of Object.entries(schema)) {
|
|
57
|
+
if (propDef.required && !(propName in validated)) {
|
|
58
|
+
log.warn("Missing required prop", { propName, patternType });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return validated;
|
|
62
|
+
}
|
|
63
|
+
function isKnownPattern(type) {
|
|
64
|
+
return type in componentMapping;
|
|
65
|
+
}
|
|
66
|
+
function getKnownPatterns() {
|
|
67
|
+
return Object.keys(componentMapping);
|
|
68
|
+
}
|
|
69
|
+
function getPatternsByCategory(category) {
|
|
70
|
+
return Object.entries(componentMapping).filter(([, mapping]) => mapping.category === category).map(([type]) => type);
|
|
71
|
+
}
|
|
72
|
+
function getPatternMapping(type) {
|
|
73
|
+
return componentMapping[type];
|
|
74
|
+
}
|
|
75
|
+
function getPatternDefinition(type) {
|
|
76
|
+
return patternRegistry[type];
|
|
77
|
+
}
|
|
78
|
+
var log2 = createLogger("almadar:ui:effects:client");
|
|
79
|
+
function executeClientEffects(effects, config) {
|
|
80
|
+
if (!effects || effects.length === 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const effect of effects) {
|
|
84
|
+
try {
|
|
85
|
+
executeEffect(effect, config);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
log2.error("Error executing effect", () => ({
|
|
88
|
+
effect: JSON.stringify(effect),
|
|
89
|
+
error: error instanceof Error ? error : String(error)
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
config.onComplete?.();
|
|
94
|
+
}
|
|
95
|
+
function executeEffect(effect, config) {
|
|
96
|
+
const [effectType, ...args] = effect;
|
|
97
|
+
switch (effectType) {
|
|
98
|
+
case "render-ui": {
|
|
99
|
+
const [slot, patternConfig] = args;
|
|
100
|
+
executeRenderUI(slot, patternConfig, config);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case "navigate": {
|
|
104
|
+
const [path, params] = args;
|
|
105
|
+
executeNavigate(path, params, config);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "emit": {
|
|
109
|
+
const [event, payload] = args;
|
|
110
|
+
executeEmit(event, payload, config);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
default:
|
|
114
|
+
log2.warn("Unknown effect type", { effectType: String(effectType) });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function executeRenderUI(slot, patternConfig, config) {
|
|
118
|
+
config.renderToSlot(slot, patternConfig);
|
|
119
|
+
}
|
|
120
|
+
function executeNavigate(path, params, config) {
|
|
121
|
+
config.navigate(path, params);
|
|
122
|
+
}
|
|
123
|
+
function executeEmit(event, payload, config) {
|
|
124
|
+
config.eventBus.emit(event, payload);
|
|
125
|
+
}
|
|
126
|
+
function parseClientEffect(raw) {
|
|
127
|
+
if (!Array.isArray(raw) || raw.length < 1) {
|
|
128
|
+
log2.warn("Invalid effect format", () => ({ raw: JSON.stringify(raw) }));
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const [type, ...args] = raw;
|
|
132
|
+
if (typeof type !== "string") {
|
|
133
|
+
log2.warn("Effect type must be string", () => ({ raw: JSON.stringify(raw) }));
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
switch (type) {
|
|
137
|
+
case "render-ui":
|
|
138
|
+
return ["render-ui", args[0], args[1]];
|
|
139
|
+
case "navigate":
|
|
140
|
+
return ["navigate", args[0], args[1]];
|
|
141
|
+
case "emit":
|
|
142
|
+
return ["emit", args[0], args[1]];
|
|
143
|
+
default:
|
|
144
|
+
log2.warn("Unknown effect type", { type });
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function parseClientEffects(raw) {
|
|
149
|
+
if (!raw || !Array.isArray(raw)) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
return raw.map((effect) => parseClientEffect(effect)).filter((effect) => effect !== null);
|
|
153
|
+
}
|
|
154
|
+
function filterEffectsByType(effects, type) {
|
|
155
|
+
return effects.filter(
|
|
156
|
+
(effect) => effect[0] === type
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function getRenderUIEffects(effects) {
|
|
160
|
+
return filterEffectsByType(effects, "render-ui");
|
|
161
|
+
}
|
|
162
|
+
var log3 = createLogger("almadar:ui:effects:client-hook");
|
|
163
|
+
function useClientEffects(effects, options) {
|
|
164
|
+
const {
|
|
165
|
+
enabled = true,
|
|
166
|
+
debug = false,
|
|
167
|
+
onComplete,
|
|
168
|
+
...config
|
|
169
|
+
} = options;
|
|
170
|
+
const executedRef = useRef(/* @__PURE__ */ new Set());
|
|
171
|
+
const executingRef = useRef(false);
|
|
172
|
+
const executedCountRef = useRef(0);
|
|
173
|
+
const getEffectKey = useCallback((effect) => {
|
|
174
|
+
return JSON.stringify(effect);
|
|
175
|
+
}, []);
|
|
176
|
+
const execute = useCallback((effectsToExecute) => {
|
|
177
|
+
if (executingRef.current || effectsToExecute.length === 0) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
executingRef.current = true;
|
|
181
|
+
const newEffects = effectsToExecute.filter((effect) => {
|
|
182
|
+
const key = getEffectKey(effect);
|
|
183
|
+
if (executedRef.current.has(key)) {
|
|
184
|
+
if (debug) {
|
|
185
|
+
log3.debug("Skipping duplicate effect", () => ({ effect: JSON.stringify(effect) }));
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
return true;
|
|
190
|
+
});
|
|
191
|
+
if (newEffects.length === 0) {
|
|
192
|
+
executingRef.current = false;
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (debug) {
|
|
196
|
+
log3.debug("Executing effects", () => ({ effects: JSON.stringify(newEffects), count: newEffects.length }));
|
|
197
|
+
}
|
|
198
|
+
newEffects.forEach((effect) => {
|
|
199
|
+
executedRef.current.add(getEffectKey(effect));
|
|
200
|
+
});
|
|
201
|
+
executeClientEffects(newEffects, {
|
|
202
|
+
...config,
|
|
203
|
+
onComplete: () => {
|
|
204
|
+
executedCountRef.current = newEffects.length;
|
|
205
|
+
executingRef.current = false;
|
|
206
|
+
onComplete?.();
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}, [config, debug, getEffectKey, onComplete]);
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (!enabled || !effects || effects.length === 0) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
execute(effects);
|
|
215
|
+
}, [effects, enabled, execute]);
|
|
216
|
+
const prevEffectsRef = useRef(void 0);
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
if (effects !== prevEffectsRef.current) {
|
|
219
|
+
prevEffectsRef.current = effects;
|
|
220
|
+
}
|
|
221
|
+
}, [effects]);
|
|
222
|
+
return {
|
|
223
|
+
executedCount: executedCountRef.current,
|
|
224
|
+
executing: executingRef.current,
|
|
225
|
+
execute
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
var ClientEffectConfigContext = createContext(null);
|
|
229
|
+
var ClientEffectConfigProvider = ClientEffectConfigContext.Provider;
|
|
230
|
+
function useClientEffectConfig() {
|
|
231
|
+
const context = useContext(ClientEffectConfigContext);
|
|
232
|
+
if (!context) {
|
|
233
|
+
throw new Error(
|
|
234
|
+
"useClientEffectConfig must be used within a ClientEffectConfigProvider. Make sure your component tree is wrapped with OrbitalProvider."
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
return context;
|
|
238
|
+
}
|
|
239
|
+
function useClientEffectConfigOptional() {
|
|
240
|
+
return useContext(ClientEffectConfigContext);
|
|
241
|
+
}
|
|
242
|
+
var log4 = createLogger("almadar:ui:data-resolver");
|
|
243
|
+
function resolveEntityData(entityName, context) {
|
|
244
|
+
if (context.fetchedData && entityName in context.fetchedData) {
|
|
245
|
+
const data = context.fetchedData[entityName];
|
|
246
|
+
return {
|
|
247
|
+
data: Array.isArray(data) ? data : [],
|
|
248
|
+
loading: false
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
if (context.entityStore) {
|
|
252
|
+
try {
|
|
253
|
+
const data = context.entityStore.getRecords(entityName);
|
|
254
|
+
return {
|
|
255
|
+
data: Array.isArray(data) ? data : [],
|
|
256
|
+
loading: false
|
|
257
|
+
};
|
|
258
|
+
} catch (error) {
|
|
259
|
+
log4.warn("Error getting records from entity store", {
|
|
260
|
+
entityName,
|
|
261
|
+
error: error instanceof Error ? error : String(error)
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const hasAnySources = context.fetchedData || context.entityStore;
|
|
266
|
+
return {
|
|
267
|
+
data: [],
|
|
268
|
+
loading: !hasAnySources
|
|
269
|
+
// Only loading if no sources configured
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function resolveEntityDataWithQuery(entityName, queryRef, context) {
|
|
273
|
+
const resolution = resolveEntityData(entityName, context);
|
|
274
|
+
if (!queryRef || !context.querySingleton) {
|
|
275
|
+
return resolution;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
const filters = context.querySingleton.getFilters(queryRef);
|
|
279
|
+
const filteredData = applyFilters(resolution.data, filters);
|
|
280
|
+
return {
|
|
281
|
+
...resolution,
|
|
282
|
+
data: filteredData
|
|
283
|
+
};
|
|
284
|
+
} catch (error) {
|
|
285
|
+
log4.warn("Error applying query filters", {
|
|
286
|
+
queryRef,
|
|
287
|
+
error: error instanceof Error ? error : String(error)
|
|
288
|
+
});
|
|
289
|
+
return resolution;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function applyFilters(data, filters) {
|
|
293
|
+
if (!filters || Object.keys(filters).length === 0) {
|
|
294
|
+
return data;
|
|
295
|
+
}
|
|
296
|
+
return data.filter((item) => {
|
|
297
|
+
if (typeof item !== "object" || item === null) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
return Object.entries(filters).every(([key, value]) => {
|
|
301
|
+
if (value === void 0 || value === null) {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
const recordValue = item[key];
|
|
305
|
+
if (Array.isArray(value)) {
|
|
306
|
+
return value.includes(recordValue ?? null);
|
|
307
|
+
}
|
|
308
|
+
if (typeof value === "string" && typeof recordValue === "string") {
|
|
309
|
+
if (value.startsWith("*") && value.endsWith("*")) {
|
|
310
|
+
const pattern = value.slice(1, -1);
|
|
311
|
+
return recordValue.toLowerCase().includes(pattern.toLowerCase());
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return recordValue === value;
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function resolveEntityById(entityName, id, context) {
|
|
319
|
+
const { data } = resolveEntityData(entityName, context);
|
|
320
|
+
return data.find((item) => item.id === id || item["_id"] === id) ?? null;
|
|
321
|
+
}
|
|
322
|
+
function hasEntities(entityName, context) {
|
|
323
|
+
const { data } = resolveEntityData(entityName, context);
|
|
324
|
+
return data.length > 0;
|
|
325
|
+
}
|
|
326
|
+
var log5 = createLogger("almadar:ui:pattern-resolver");
|
|
327
|
+
function initializePatterns() {
|
|
328
|
+
log5.debug("initializePatterns called");
|
|
329
|
+
log5.debug("componentMappingJson loaded", () => ({ json: JSON.stringify(componentMapping$1) }));
|
|
330
|
+
log5.debug("registryJson keys", { keys: Object.keys(patternsRegistry) });
|
|
331
|
+
const componentMappingData = componentMapping$1;
|
|
332
|
+
const componentMapping2 = componentMappingData.mappings || {};
|
|
333
|
+
log5.debug("Extracted mappings count", { count: Object.keys(componentMapping2).length });
|
|
334
|
+
log5.debug("Sample mappings", { samples: Object.keys(componentMapping2).slice(0, 5) });
|
|
335
|
+
const registryData = patternsRegistry;
|
|
336
|
+
const patternRegistry2 = registryData.patterns || {};
|
|
337
|
+
log5.debug("Extracted patterns count", { count: Object.keys(patternRegistry2).length });
|
|
338
|
+
initializePatternResolver({
|
|
339
|
+
componentMapping: componentMapping2,
|
|
340
|
+
patternRegistry: patternRegistry2
|
|
341
|
+
});
|
|
342
|
+
log5.info("Initialized", {
|
|
343
|
+
componentMappings: Object.keys(componentMapping2).length,
|
|
344
|
+
patternDefinitions: Object.keys(patternRegistry2).length
|
|
345
|
+
});
|
|
346
|
+
return Object.keys(componentMapping2).length;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export { ClientEffectConfigContext, ClientEffectConfigProvider, executeClientEffects, getKnownPatterns, getPatternDefinition, getPatternMapping, getPatternsByCategory, getRenderUIEffects, hasEntities, initializePatternResolver, initializePatterns, isKnownPattern, parseClientEffect, parseClientEffects, resolveEntityById, resolveEntityData, resolveEntityDataWithQuery, resolvePattern, setComponentMapping, setPatternRegistry, useClientEffectConfig, useClientEffectConfigOptional, useClientEffects };
|