@almadar/ui 6.9.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{EntityBindingContext-Bn3ePJQC.d.cts → EntityBindingContext-D5lRu6p1.d.cts} +25 -2
  2. package/dist/{EntityBindingContext-Bn3ePJQC.d.ts → EntityBindingContext-D5lRu6p1.d.ts} +25 -2
  3. package/dist/{GameAudioProvider-Dk_Y3LN3.d.cts → GameAudioProvider-D8GynTNq.d.cts} +1 -1
  4. package/dist/{GameAudioProvider-Ctceau1s.d.ts → GameAudioProvider-Dozqx4sL.d.ts} +1 -1
  5. package/dist/avl/index.cjs +254 -108
  6. package/dist/avl/index.js +213 -67
  7. package/dist/{avl-schema-parser-DncJLEn9.d.ts → avl-schema-parser-DX-aVCCm.d.ts} +1 -1
  8. package/dist/{avl-schema-parser-FQ1474v8.d.cts → avl-schema-parser-PVu8rgsy.d.cts} +1 -1
  9. package/dist/{cn-C7fvp9gH.d.ts → cn-Do5gsPBm.d.cts} +2 -100
  10. package/dist/{cn-DnLYahyL.d.cts → cn-Do5gsPBm.d.ts} +2 -100
  11. package/dist/components/index.cjs +103 -68
  12. package/dist/components/index.d.cts +46 -22
  13. package/dist/components/index.d.ts +46 -22
  14. package/dist/components/index.js +64 -29
  15. package/dist/lib/drawable/three/index.d.cts +3 -4
  16. package/dist/lib/drawable/three/index.d.ts +3 -4
  17. package/dist/lib/index.cjs +7 -23
  18. package/dist/lib/index.d.cts +6 -28
  19. package/dist/lib/index.d.ts +6 -28
  20. package/dist/lib/index.js +5 -23
  21. package/dist/{paintDispatch-B5ObLnUv.d.ts → paintDispatch-CK5uwYEq.d.cts} +50 -3
  22. package/dist/{paintDispatch-D3R8NNmV.d.cts → paintDispatch-CK5uwYEq.d.ts} +50 -3
  23. package/dist/providers/index.cjs +158 -88
  24. package/dist/providers/index.d.cts +5 -3
  25. package/dist/providers/index.d.ts +5 -3
  26. package/dist/providers/index.js +119 -49
  27. package/dist/runtime/index.cjs +253 -107
  28. package/dist/runtime/index.d.cts +31 -7
  29. package/dist/runtime/index.d.ts +31 -7
  30. package/dist/runtime/index.js +212 -66
  31. package/dist/verificationRegistry-BLsjb1oU.d.cts +110 -0
  32. package/dist/verificationRegistry-D8bHWD8Q.d.ts +110 -0
  33. package/package.json +7 -7
  34. package/dist/types-B3nHgnMG.d.cts +0 -51
  35. package/dist/types-B3nHgnMG.d.ts +0 -51
@@ -4,13 +4,15 @@ export { ANONYMOUS_USER } from '@almadar/core';
4
4
  import { U as UIThemeDefinition, j as UserData } from '../UserContext-g_LcDiGN.cjs';
5
5
  export { a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, h as UserContext, i as UserContextValue, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.cjs';
6
6
  import { E as EventBusContextType } from '../event-bus-types-Bl78kokd.cjs';
7
- export { E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-Bn3ePJQC.cjs';
7
+ export { A as AccessTokenProvider, E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-D5lRu6p1.cjs';
8
8
  import { j as UseOfflineExecutorResult, U as UseOfflineExecutorOptions } from '../offline-executor-QUdKOj7f.cjs';
9
9
  export { c as NavigationContextValue, d as NavigationProvider, e as NavigationProviderProps, f as NavigationState, k as comparePathSpecificity, m as extractRouteParams, n as findPageByName, o as findPageByPath, p as getAllPages, q as getDefaultPage, r as matchPath, s as matchPathAmong, t as pathMatches, u as useActivePage, v as useInitPayload, w as useNavigateTo, x as useNavigation, y as useNavigationId, z as useNavigationState } from '../offline-executor-QUdKOj7f.cjs';
10
- export { G as GameAudioContext, a as GameAudioContextValue, b as GameAudioProvider, c as GameAudioProviderProps, u as useGameAudioContext, d as useGameAudioContextOptional } from '../GameAudioProvider-Dk_Y3LN3.cjs';
10
+ import '../verificationRegistry-BLsjb1oU.cjs';
11
+ export { G as GameAudioContext, a as GameAudioContextValue, b as GameAudioProvider, c as GameAudioProviderProps, u as useGameAudioContext, d as useGameAudioContextOptional } from '../GameAudioProvider-D8GynTNq.cjs';
11
12
  export { N as NavPageDecl, a as NavStackApi, b as NavStackProvider, c as NavStackProviderProps, d as NavStackRouterBridge, e as NavStackRouterBridgeProps, u as useNavStack } from '../NavStackContext-bw2nlBgT.cjs';
12
13
  import '@almadar/core/patterns';
13
- import '../types-B3nHgnMG.cjs';
14
+ import '@almadar/runtime';
15
+ import '../paintDispatch-CK5uwYEq.cjs';
14
16
 
15
17
  /**
16
18
  * EventBusProvider - React context provider for the event bus
@@ -4,13 +4,15 @@ export { ANONYMOUS_USER } from '@almadar/core';
4
4
  import { U as UIThemeDefinition, j as UserData } from '../UserContext-g_LcDiGN.js';
5
5
  export { a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, h as UserContext, i as UserContextValue, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.js';
6
6
  import { E as EventBusContextType } from '../event-bus-types-Bl78kokd.js';
7
- export { E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-Bn3ePJQC.js';
7
+ export { A as AccessTokenProvider, E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-D5lRu6p1.js';
8
8
  import { j as UseOfflineExecutorResult, U as UseOfflineExecutorOptions } from '../offline-executor-QUdKOj7f.js';
9
9
  export { c as NavigationContextValue, d as NavigationProvider, e as NavigationProviderProps, f as NavigationState, k as comparePathSpecificity, m as extractRouteParams, n as findPageByName, o as findPageByPath, p as getAllPages, q as getDefaultPage, r as matchPath, s as matchPathAmong, t as pathMatches, u as useActivePage, v as useInitPayload, w as useNavigateTo, x as useNavigation, y as useNavigationId, z as useNavigationState } from '../offline-executor-QUdKOj7f.js';
10
- export { G as GameAudioContext, a as GameAudioContextValue, b as GameAudioProvider, c as GameAudioProviderProps, u as useGameAudioContext, d as useGameAudioContextOptional } from '../GameAudioProvider-Ctceau1s.js';
10
+ import '../verificationRegistry-D8bHWD8Q.js';
11
+ export { G as GameAudioContext, a as GameAudioContextValue, b as GameAudioProvider, c as GameAudioProviderProps, u as useGameAudioContext, d as useGameAudioContextOptional } from '../GameAudioProvider-Dozqx4sL.js';
11
12
  export { N as NavPageDecl, a as NavStackApi, b as NavStackProvider, c as NavStackProviderProps, d as NavStackRouterBridge, e as NavStackRouterBridgeProps, u as useNavStack } from '../NavStackContext-bw2nlBgT.js';
12
13
  import '@almadar/core/patterns';
13
- import '../types-B3nHgnMG.js';
14
+ import '@almadar/runtime';
15
+ import '../paintDispatch-CK5uwYEq.js';
14
16
 
15
17
  /**
16
18
  * EventBusProvider - React context provider for the event bus
@@ -3,7 +3,7 @@ import React89__default, { createContext, useContext, useMemo, useRef, useEffect
3
3
  import { EventBusContext, useTraitScopeChain, RenderSlotProvider, useEntitySchemaOptional, useEntityBindingSnapshot, useTraitScope, TraitScopeProvider, useNavStack, useCurrentPagePath, useRenderSlot, useGameAudioContextOptional, matchPathAmong } from '@almadar/ui/providers';
4
4
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
5
5
  import { createContextFromBindings, interpolateValue } from '@almadar/runtime';
6
- import { ANONYMOUS_USER, isRenderBindingMarker, isFileValue, isInlineTrait } from '@almadar/core';
6
+ import { ANONYMOUS_USER, isRenderBindingMarker, getNestedValue, isFileValue, isInlineTrait } from '@almadar/core';
7
7
  export { ANONYMOUS_USER } from '@almadar/core';
8
8
  import { clsx } from 'clsx';
9
9
  import { twMerge } from 'tailwind-merge';
@@ -20,7 +20,8 @@ import { useLocation, useNavigate, Link, Outlet } from 'react-router-dom';
20
20
  import ELK from 'elkjs/lib/elk.bundled.js';
21
21
  import SyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-light.js';
22
22
  import dark from 'react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js';
23
- import { orbLanguage, loloLanguage, ORB_COLORS } from '@almadar/syntax';
23
+ import { orbLanguage, loloLanguage, ORB_COLORS, translateLolo, translateOrb } from '@almadar/syntax';
24
+ import { coreTables } from '@almadar/core/i18n';
24
25
  import langJson from 'react-syntax-highlighter/dist/esm/languages/prism/json.js';
25
26
  import langJavascript from 'react-syntax-highlighter/dist/esm/languages/prism/javascript.js';
26
27
  import langTypescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript.js';
@@ -18210,6 +18211,15 @@ function buildLineProps(errorLines, extraClassName) {
18210
18211
  };
18211
18212
  };
18212
18213
  }
18214
+ function translateProgram(source, language, lang) {
18215
+ if (lang === "en") return source;
18216
+ if (language === "lolo") return translateLolo(source, lang);
18217
+ if (language === "orb") {
18218
+ const translated = translateOrb(source, lang);
18219
+ return typeof translated === "string" ? translated : source;
18220
+ }
18221
+ return source;
18222
+ }
18213
18223
  var dynamicallyLoaded, codeLanguageLoader, orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, log7, CODE_LANGUAGES, CODE_LANGUAGE_SET, DIFF_STYLES, DIFF_STYLE_FALLBACK, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, HIGHLIGHT_CAPACITY_BYTES, MONO_FONT_FAMILY, VIEWER_LINE_NUMBER_STYLE, CodeBlock;
18214
18224
  var init_CodeBlock = __esm({
18215
18225
  "components/core/molecules/markdown/CodeBlock.tsx"() {
@@ -18475,6 +18485,7 @@ var init_CodeBlock = __esm({
18475
18485
  showLineNumbers = false,
18476
18486
  wordWrap = false,
18477
18487
  files,
18488
+ naturalLanguages,
18478
18489
  actions,
18479
18490
  isLoading = false,
18480
18491
  error,
@@ -18521,7 +18532,48 @@ var init_CodeBlock = __esm({
18521
18532
  "replace"
18522
18533
  ]
18523
18534
  }) => {
18524
- const code = typeof rawCode === "string" ? rawCode : String(rawCode ?? "");
18535
+ const englishCode = typeof rawCode === "string" ? rawCode : String(rawCode ?? "");
18536
+ const naturalTabs = !editable && naturalLanguages && naturalLanguages.length > 1 ? naturalLanguages : void 0;
18537
+ const [naturalLanguage, setNaturalLanguage] = useState(() => naturalTabs?.[0] ?? "en");
18538
+ const activeNaturalLanguage = naturalTabs?.includes(naturalLanguage) === true ? naturalLanguage : naturalTabs?.[0] ?? "en";
18539
+ const translationCache = useMemo(() => /* @__PURE__ */ new Map(), [englishCode, files]);
18540
+ const translateFor = useCallback(
18541
+ (source, sourceLanguage, cacheKey) => {
18542
+ if (activeNaturalLanguage === "en") return source;
18543
+ const key = `${cacheKey}|${sourceLanguage}|${activeNaturalLanguage}`;
18544
+ const hit = translationCache.get(key);
18545
+ if (hit !== void 0) return hit;
18546
+ const translated = translateProgram(source, sourceLanguage, activeNaturalLanguage);
18547
+ translationCache.set(key, translated);
18548
+ return translated;
18549
+ },
18550
+ [translationCache, activeNaturalLanguage]
18551
+ );
18552
+ const code = translateFor(englishCode, language, "code");
18553
+ const naturalTabItems = naturalTabs?.map((lang) => ({
18554
+ id: `lang-${lang}`,
18555
+ label: coreTables[lang].meta.name,
18556
+ content: null
18557
+ }));
18558
+ const naturalTabStrip = naturalTabs && naturalTabItems ? /* @__PURE__ */ jsx(
18559
+ Box,
18560
+ {
18561
+ className: "border-b border-border",
18562
+ dir: coreTables[activeNaturalLanguage].meta.rtl ? "rtl" : "ltr",
18563
+ "data-testid": "codeblock-language-tabs",
18564
+ children: /* @__PURE__ */ jsx(
18565
+ Tabs,
18566
+ {
18567
+ tabs: naturalTabItems,
18568
+ activeTab: `lang-${activeNaturalLanguage}`,
18569
+ onTabChange: (id) => {
18570
+ const next = naturalTabs.find((lang) => `lang-${lang}` === id);
18571
+ if (next) setNaturalLanguage(next);
18572
+ }
18573
+ }
18574
+ )
18575
+ }
18576
+ ) : null;
18525
18577
  const activeStyle = resolveHighlightStyle(language);
18526
18578
  const overCapacity = code.length > HIGHLIGHT_CAPACITY_BYTES;
18527
18579
  const plainCodeColor = plainCodeColorOf(activeStyle);
@@ -18534,8 +18586,8 @@ var init_CodeBlock = __esm({
18534
18586
  const [wrap, setWrap] = useState(wordWrap);
18535
18587
  const [activeFileIndex, setActiveFileIndex] = useState(0);
18536
18588
  const activeFile = files?.[activeFileIndex];
18537
- const activeCode = activeFile?.code ?? code;
18538
18589
  const activeLanguage = activeFile?.language ?? language;
18590
+ const activeCode = activeFile ? translateFor(activeFile.code, activeLanguage, `file-${activeFileIndex}`) : code;
18539
18591
  const languageReady = useLanguageReady(activeLanguage);
18540
18592
  const viewerStyle = resolveHighlightStyle(activeLanguage);
18541
18593
  const viewerPlainCodeColor = plainCodeColorOf(viewerStyle);
@@ -19020,6 +19072,7 @@ var init_CodeBlock = __esm({
19020
19072
  content: null
19021
19073
  }));
19022
19074
  return /* @__PURE__ */ jsx(Card, { className: cn("overflow-hidden", className), children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
19075
+ naturalTabStrip,
19023
19076
  tabItems && tabItems.length > 1 && /* @__PURE__ */ jsx(Box, { className: "border-b border-border", children: /* @__PURE__ */ jsx(
19024
19077
  Tabs,
19025
19078
  {
@@ -19081,7 +19134,7 @@ var init_CodeBlock = __esm({
19081
19134
  ]
19082
19135
  }
19083
19136
  ),
19084
- /* @__PURE__ */ jsx(Box, { className: "overflow-auto bg-muted/20", style: { maxHeight }, children: diffLines ? /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column" }, className: "font-mono text-xs", children: diffRowElements }) : /* @__PURE__ */ jsx("div", { className: "font-mono text-xs", children: viewerHighlightedElement }) })
19137
+ /* @__PURE__ */ jsx(Box, { className: "overflow-auto bg-muted/20", style: { maxHeight }, dir: "ltr", children: diffLines ? /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column" }, className: "font-mono text-xs", children: diffRowElements }) : /* @__PURE__ */ jsx("div", { className: "font-mono text-xs", children: viewerHighlightedElement }) })
19085
19138
  ] }) });
19086
19139
  }
19087
19140
  const hasHeader = showLanguageBadge || effectiveCopy;
@@ -19108,6 +19161,7 @@ var init_CodeBlock = __esm({
19108
19161
  ]
19109
19162
  }
19110
19163
  ),
19164
+ naturalTabStrip,
19111
19165
  editable ? (
19112
19166
  /* GAP-77 / GAP-82 / GAP-83: editable mode = transparent textarea on
19113
19167
  top of a Prism-highlighted SyntaxHighlighter overlay.
@@ -19259,6 +19313,7 @@ var init_CodeBlock = __esm({
19259
19313
  {
19260
19314
  ref: scrollRef,
19261
19315
  onCopy: handleSelectionCopy,
19316
+ dir: "ltr",
19262
19317
  style: {
19263
19318
  flex: 1,
19264
19319
  minHeight: 0,
@@ -19277,7 +19332,7 @@ var init_CodeBlock = __esm({
19277
19332
  )
19278
19333
  ] });
19279
19334
  },
19280
- (prev, next) => prev.language === next.language && prev.code === next.code && prev.showCopyButton === next.showCopyButton && prev.showCopy === next.showCopy && prev.maxHeight === next.maxHeight && prev.foldable === next.foldable && prev.editable === next.editable && prev.onChange === next.onChange && prev.errorLines === next.errorLines && prev.mode === next.mode && prev.title === next.title && prev.diff === next.diff && prev.files === next.files && prev.actions === next.actions && prev.isLoading === next.isLoading && prev.error === next.error && prev.editorId === next.editorId && prev.onEditorFocus === next.onEditorFocus && prev.onEditorBlur === next.onEditorBlur && prev.onMotion === next.onMotion && prev.onOperate === next.onOperate && prev.onInsertText === next.onInsertText && prev.onSetMode === next.onSetMode && prev.motions === next.motions && prev.operators === next.operators
19335
+ (prev, next) => prev.language === next.language && prev.code === next.code && prev.showCopyButton === next.showCopyButton && prev.showCopy === next.showCopy && prev.maxHeight === next.maxHeight && prev.foldable === next.foldable && prev.editable === next.editable && prev.onChange === next.onChange && prev.errorLines === next.errorLines && prev.mode === next.mode && prev.title === next.title && prev.diff === next.diff && prev.files === next.files && prev.naturalLanguages === next.naturalLanguages && prev.actions === next.actions && prev.isLoading === next.isLoading && prev.error === next.error && prev.editorId === next.editorId && prev.onEditorFocus === next.onEditorFocus && prev.onEditorBlur === next.onEditorBlur && prev.onMotion === next.onMotion && prev.onOperate === next.onOperate && prev.onInsertText === next.onInsertText && prev.onSetMode === next.onSetMode && prev.motions === next.motions && prev.operators === next.operators
19281
19336
  );
19282
19337
  CodeBlock.displayName = "CodeBlock";
19283
19338
  }
@@ -22972,26 +23027,6 @@ var init_ButtonGroup = __esm({
22972
23027
  ButtonGroup.displayName = "ButtonGroup";
22973
23028
  }
22974
23029
  });
22975
- function getNestedValue(obj, path) {
22976
- if (obj === null || obj === void 0 || !path) {
22977
- return void 0;
22978
- }
22979
- if (!path.includes(".")) {
22980
- return obj[path];
22981
- }
22982
- const parts = path.split(".");
22983
- let value = obj;
22984
- for (const part of parts) {
22985
- if (value === null || value === void 0) {
22986
- return void 0;
22987
- }
22988
- if (typeof value !== "object" || Array.isArray(value)) {
22989
- return void 0;
22990
- }
22991
- value = value[part];
22992
- }
22993
- return value;
22994
- }
22995
23030
  function resolveImageUrl(value) {
22996
23031
  if (typeof value === "string") {
22997
23032
  return value;
@@ -41968,11 +42003,11 @@ var init_WizardContainer = __esm({
41968
42003
  });
41969
42004
  function calculateComplexity(schema) {
41970
42005
  if (!schema) return 1;
41971
- const entities = schema.dataEntities?.length || 0;
42006
+ const entities = schema.dataEntities || 0;
41972
42007
  const pages = schema.ui?.pages?.length || 0;
41973
- const traits2 = schema.traits?.length || 0;
42008
+ const traits2 = schema.traits || 0;
41974
42009
  const sections = schema.ui?.pages?.reduce(
41975
- (acc, page) => acc + (page.sections?.length || 0),
42010
+ (acc, page) => acc + (page.sections || 0),
41976
42011
  0
41977
42012
  ) || 0;
41978
42013
  return entities * 3 + pages * 2 + traits2 * 2 + sections * 1;
@@ -52941,6 +52976,29 @@ function parseLifecycleEvent(type) {
52941
52976
  }
52942
52977
  return null;
52943
52978
  }
52979
+ function mapServerEffectResults(effectResults) {
52980
+ return effectResults.map((er) => {
52981
+ const target = er["entityType"] ?? er["entity"] ?? er["service"];
52982
+ const entityName = typeof target === "string" && target !== "" ? target : void 0;
52983
+ const rawAction = er["action"];
52984
+ const action = rawAction === "create" || rawAction === "update" || rawAction === "delete" || rawAction === "batch" ? rawAction : void 0;
52985
+ const data = er["data"];
52986
+ const resultId = data !== null && typeof data === "object" && !Array.isArray(data) && typeof data["id"] === "string" ? data["id"] : void 0;
52987
+ const denied = er["denied"] === true;
52988
+ const success = er["success"] !== false;
52989
+ const outcome = denied ? "denied" : success ? "success" : "failed";
52990
+ return {
52991
+ type: String(er["type"] ?? er["effect"] ?? "server-effect"),
52992
+ ...entityName !== void 0 ? { entityName } : {},
52993
+ ...action !== void 0 ? { action } : {},
52994
+ ...resultId !== void 0 ? { resultId } : {},
52995
+ outcome,
52996
+ args: entityName !== void 0 ? [entityName] : [],
52997
+ status: outcome === "success" ? "executed" : "failed",
52998
+ error: er["error"]
52999
+ };
53000
+ });
53001
+ }
52944
53002
  function VerificationProvider({
52945
53003
  children,
52946
53004
  enabled,
@@ -52978,16 +53036,8 @@ function VerificationProvider({
52978
53036
  args: Array.isArray(e["args"]) ? e["args"] : [],
52979
53037
  status: "executed"
52980
53038
  }));
52981
- const effectResults = Array.isArray(payload["effectResults"]) ? payload["effectResults"] : [];
52982
- for (const er of effectResults) {
52983
- const target = er["entity"] ?? er["service"];
52984
- effects.push({
52985
- type: String(er["type"] ?? er["effect"] ?? "server-effect"),
52986
- args: typeof target === "string" && target !== "" ? [target] : [],
52987
- status: er["error"] ? "failed" : "executed",
52988
- error: er["error"]
52989
- });
52990
- }
53039
+ const effectResultsRaw = Array.isArray(payload["effectResults"]) ? payload["effectResults"] : [];
53040
+ effects.push(...mapServerEffectResults(effectResultsRaw));
52991
53041
  const dataEntities = {};
52992
53042
  const responseData = payload["data"];
52993
53043
  if (responseData && typeof responseData === "object") {
@@ -53872,13 +53922,19 @@ function deriveEventsUrl(serverUrl) {
53872
53922
  const apiRoot = trimmed.replace(/\/[^/]*$/, "");
53873
53923
  return `${apiRoot}/events`;
53874
53924
  }
53875
- function createHttpTransport(serverUrl) {
53925
+ async function authHeaders(getAccessToken) {
53926
+ const headers = { "Content-Type": "application/json" };
53927
+ const token = getAccessToken ? await getAccessToken() : void 0;
53928
+ if (token) headers.Authorization = `Bearer ${token}`;
53929
+ return headers;
53930
+ }
53931
+ function createHttpTransport(serverUrl, getAccessToken) {
53876
53932
  return {
53877
53933
  register: async (schema) => {
53878
53934
  try {
53879
53935
  const res = await fetch(`${serverUrl}/register`, {
53880
53936
  method: "POST",
53881
- headers: { "Content-Type": "application/json" },
53937
+ headers: await authHeaders(getAccessToken),
53882
53938
  body: JSON.stringify({ schema })
53883
53939
  });
53884
53940
  const result = await res.json();
@@ -53894,7 +53950,7 @@ function createHttpTransport(serverUrl) {
53894
53950
  },
53895
53951
  unregister: async () => {
53896
53952
  try {
53897
- await fetch(`${serverUrl}/unregister`, { method: "DELETE" });
53953
+ await fetch(`${serverUrl}/unregister`, { method: "DELETE", headers: await authHeaders(getAccessToken) });
53898
53954
  } catch {
53899
53955
  }
53900
53956
  },
@@ -53902,7 +53958,7 @@ function createHttpTransport(serverUrl) {
53902
53958
  const body = { event, payload, clientId, tick, sourceTrait };
53903
53959
  const res = await fetch(`${serverUrl}/${orbitalName}/events`, {
53904
53960
  method: "POST",
53905
- headers: { "Content-Type": "application/json" },
53961
+ headers: await authHeaders(getAccessToken),
53906
53962
  body: JSON.stringify(body)
53907
53963
  });
53908
53964
  return res.json();
@@ -53922,6 +53978,7 @@ function ServerBridgeProvider({
53922
53978
  schema,
53923
53979
  serverUrl,
53924
53980
  transport: customTransport,
53981
+ getAccessToken,
53925
53982
  children
53926
53983
  }) {
53927
53984
  if (!serverUrl && !customTransport) {
@@ -53933,8 +53990,8 @@ function ServerBridgeProvider({
53933
53990
  const eventBus = useEventBus();
53934
53991
  const [connected, setConnected] = useState(false);
53935
53992
  const transport = useMemo(
53936
- () => customTransport ?? createHttpTransport(serverUrl),
53937
- [serverUrl, customTransport]
53993
+ () => customTransport ?? createHttpTransport(serverUrl, getAccessToken),
53994
+ [serverUrl, customTransport, getAccessToken]
53938
53995
  );
53939
53996
  const registerSchema = useCallback(
53940
53997
  async () => transport.register(schema),
@@ -53982,6 +54039,7 @@ function ServerBridgeProvider({
53982
54039
  dataEntities,
53983
54040
  data: responseData,
53984
54041
  emittedEvents: result.emittedEvents?.map((e) => e.event) ?? [],
54042
+ effectResults: result.effectResults,
53985
54043
  error: result.error
53986
54044
  };
53987
54045
  if (result.success) {
@@ -54071,16 +54129,28 @@ function ServerBridgeProvider({
54071
54129
  useEffect(() => {
54072
54130
  if (!serverUrl) return;
54073
54131
  if (typeof EventSource === "undefined") return;
54074
- const url = `${deriveEventsUrl(serverUrl)}?clientId=${encodeURIComponent(getTabClientId())}`;
54075
- return acquirePushChannel(url, (parsed) => {
54132
+ let release;
54133
+ let cancelled = false;
54134
+ const subscribe = (parsed) => {
54076
54135
  serverBridgeLog.debug("push:received", {
54077
54136
  event: parsed.event,
54078
54137
  sourceOrbital: parsed.source?.orbital,
54079
54138
  sourceTrait: parsed.source?.trait
54080
54139
  });
54081
54140
  reEmitServerEvent(eventBus, parsed, "push");
54082
- });
54083
- }, [serverUrl, eventBus]);
54141
+ };
54142
+ void (async () => {
54143
+ const token = getAccessToken ? await getAccessToken() : void 0;
54144
+ if (cancelled) return;
54145
+ const params = new URLSearchParams({ clientId: getTabClientId() });
54146
+ if (token) params.set("access_token", token);
54147
+ release = acquirePushChannel(`${deriveEventsUrl(serverUrl)}?${params.toString()}`, subscribe);
54148
+ })();
54149
+ return () => {
54150
+ cancelled = true;
54151
+ release?.();
54152
+ };
54153
+ }, [serverUrl, eventBus, getAccessToken]);
54084
54154
  return /* @__PURE__ */ jsx(ServerBridgeContext.Provider, { value: { connected, sendEvent }, children });
54085
54155
  }
54086
54156
  var log13 = createLogger("almadar:ui:trait-provider");