@almadar/ui 2.61.1 → 3.0.1
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/avl/index.cjs +1325 -1502
- package/dist/avl/index.css +7 -2
- package/dist/avl/index.js +248 -425
- package/dist/components/index.cjs +32 -34
- package/dist/components/index.css +7 -2
- package/dist/components/index.js +33 -35
- package/dist/components/organisms/DataTable.d.ts +3 -2
- package/dist/components/organisms/JazariStateMachine.d.ts +10 -37
- package/dist/components/organisms/MasterDetail.d.ts +4 -3
- package/dist/components/organisms/MediaGallery.d.ts +3 -2
- package/dist/components/organisms/Sidebar.d.ts +7 -2
- package/dist/components/organisms/StateMachineView.d.ts +7 -2
- package/dist/components/organisms/Table.d.ts +2 -1
- package/dist/components/organisms/Timeline.d.ts +15 -2
- package/dist/components/organisms/book/BookChapterView.d.ts +3 -2
- package/dist/components/organisms/book/BookCoverPage.d.ts +3 -3
- package/dist/components/organisms/book/BookNavBar.d.ts +3 -3
- package/dist/components/organisms/book/BookTableOfContents.d.ts +3 -2
- package/dist/components/organisms/book/BookViewer.d.ts +2 -2
- package/dist/components/organisms/book/types.d.ts +9 -4
- package/dist/components/organisms/game/WorldMapBoard.d.ts +9 -3
- package/dist/components/organisms/marketing-types.d.ts +22 -12
- package/dist/components/organisms/types.d.ts +24 -12
- package/dist/components/templates/types.d.ts +7 -2
- package/dist/hooks/index.cjs +5 -2
- package/dist/hooks/index.js +5 -2
- package/dist/lib/index.cjs +5 -2
- package/dist/lib/index.js +5 -2
- package/dist/providers/index.cjs +984 -1163
- package/dist/providers/index.css +7 -2
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.js +227 -400
- package/dist/runtime/index.cjs +33 -66
- package/dist/runtime/index.css +7 -2
- package/dist/runtime/index.js +34 -67
- package/package.json +3 -3
- package/dist/providers/EntityStoreProvider.d.ts +0 -63
package/dist/runtime/index.cjs
CHANGED
|
@@ -34,8 +34,8 @@ var langDiff = require('react-syntax-highlighter/dist/esm/languages/prism/diff.j
|
|
|
34
34
|
var langToml = require('react-syntax-highlighter/dist/esm/languages/prism/toml.js');
|
|
35
35
|
var langGo = require('react-syntax-highlighter/dist/esm/languages/prism/go.js');
|
|
36
36
|
var langGraphql = require('react-syntax-highlighter/dist/esm/languages/prism/graphql.js');
|
|
37
|
-
require('@tanstack/react-query');
|
|
38
37
|
var core = require('@almadar/core');
|
|
38
|
+
require('@tanstack/react-query');
|
|
39
39
|
var runtime = require('@almadar/runtime');
|
|
40
40
|
|
|
41
41
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -10409,9 +10409,9 @@ var init_ScaledDiagram = __esm({
|
|
|
10409
10409
|
}
|
|
10410
10410
|
});
|
|
10411
10411
|
|
|
10412
|
-
// node_modules/.pnpm/katex@0.16.
|
|
10412
|
+
// node_modules/.pnpm/katex@0.16.45/node_modules/katex/dist/katex.min.css
|
|
10413
10413
|
var init_katex_min = __esm({
|
|
10414
|
-
"node_modules/.pnpm/katex@0.16.
|
|
10414
|
+
"node_modules/.pnpm/katex@0.16.45/node_modules/katex/dist/katex.min.css"() {
|
|
10415
10415
|
}
|
|
10416
10416
|
});
|
|
10417
10417
|
var MarkdownContent;
|
|
@@ -12410,7 +12410,9 @@ function extractTrait(schema, trait, traitIndex) {
|
|
|
12410
12410
|
for (const orbital of schema.orbitals) {
|
|
12411
12411
|
const traits2 = orbital.traits ?? [];
|
|
12412
12412
|
if (traitIndex < traits2.length) {
|
|
12413
|
-
|
|
12413
|
+
const traitRef = traits2[traitIndex];
|
|
12414
|
+
if (core.isInlineTrait(traitRef)) return traitRef;
|
|
12415
|
+
return null;
|
|
12414
12416
|
}
|
|
12415
12417
|
}
|
|
12416
12418
|
return null;
|
|
@@ -12418,8 +12420,10 @@ function extractTrait(schema, trait, traitIndex) {
|
|
|
12418
12420
|
function extractEntityFields(schema) {
|
|
12419
12421
|
if (!schema?.orbitals?.length) return [];
|
|
12420
12422
|
const entity = schema.orbitals[0].entity;
|
|
12421
|
-
if (!entity
|
|
12422
|
-
|
|
12423
|
+
if (!entity || typeof entity !== "object" || !("fields" in entity)) return [];
|
|
12424
|
+
const inlineEntity = entity;
|
|
12425
|
+
if (!inlineEntity.fields) return [];
|
|
12426
|
+
return inlineEntity.fields.map((f3) => f3.name);
|
|
12423
12427
|
}
|
|
12424
12428
|
function toStateMachineDefinition(sm) {
|
|
12425
12429
|
return {
|
|
@@ -12714,12 +12718,18 @@ var init_ContentRenderer = __esm({
|
|
|
12714
12718
|
);
|
|
12715
12719
|
case "orbital": {
|
|
12716
12720
|
const parsed = segment.schema;
|
|
12721
|
+
const inlineTrait = {
|
|
12722
|
+
name: "inline",
|
|
12723
|
+
scope: "instance",
|
|
12724
|
+
stateMachine: parsed
|
|
12725
|
+
};
|
|
12717
12726
|
const schema = Array.isArray(parsed.orbitals) ? parsed : {
|
|
12727
|
+
name: "inline",
|
|
12718
12728
|
orbitals: [{
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12729
|
+
name: "inline",
|
|
12730
|
+
entity: { name: "inline", fields: [] },
|
|
12731
|
+
traits: [inlineTrait],
|
|
12732
|
+
pages: []
|
|
12723
12733
|
}]
|
|
12724
12734
|
};
|
|
12725
12735
|
return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "sm", children: [
|
|
@@ -37574,19 +37584,15 @@ function SlotContentRenderer({
|
|
|
37574
37584
|
patternPath
|
|
37575
37585
|
}) {
|
|
37576
37586
|
const entityProp = content.props.entity;
|
|
37577
|
-
|
|
37578
|
-
|
|
37579
|
-
|
|
37580
|
-
|
|
37581
|
-
|
|
37582
|
-
|
|
37583
|
-
|
|
37584
|
-
console.warn(
|
|
37585
|
-
`[UISlotRenderer] String-entity binding '${entityType}' is deprecated. Pass 'items' or 'entity' as a value prop resolved from @payload.data. See docs/Almadar_Entity_V2_Plan.md \xA75.`
|
|
37586
|
-
);
|
|
37587
|
-
}, [entityType]);
|
|
37587
|
+
if (typeof entityProp === "string" && entityProp.length > 0) {
|
|
37588
|
+
if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production") {
|
|
37589
|
+
throw new Error(
|
|
37590
|
+
`[UISlotRenderer] Received string 'entity: "${entityProp}"' at render time. The V2 flow requires pre-resolved data; declare a fetch success listener and pass 'entity: @payload.data'. See docs/Almadar_Entity_V2_Plan.md \xA76.`
|
|
37591
|
+
);
|
|
37592
|
+
}
|
|
37593
|
+
}
|
|
37588
37594
|
const schemaCtx = useEntitySchemaOptional();
|
|
37589
|
-
const entityDef =
|
|
37595
|
+
const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
|
|
37590
37596
|
const PatternComponent = getComponentForPattern(content.pattern);
|
|
37591
37597
|
if (PatternComponent) {
|
|
37592
37598
|
const childrenConfig = content.props.children;
|
|
@@ -37595,12 +37601,7 @@ function SlotContentRenderer({
|
|
|
37595
37601
|
const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
|
|
37596
37602
|
const { children: _childrenConfig, ...restProps } = content.props;
|
|
37597
37603
|
const renderedProps = renderPatternProps(restProps, onDismiss);
|
|
37598
|
-
|
|
37599
|
-
if (entityType) {
|
|
37600
|
-
finalProps = { ...renderedProps, entity: storeData };
|
|
37601
|
-
} else {
|
|
37602
|
-
finalProps = renderedProps;
|
|
37603
|
-
}
|
|
37604
|
+
const finalProps = renderedProps;
|
|
37604
37605
|
const resolvedItems = Array.isArray(
|
|
37605
37606
|
finalProps.entity
|
|
37606
37607
|
) ? finalProps.entity : null;
|
|
@@ -37614,9 +37615,6 @@ function SlotContentRenderer({
|
|
|
37614
37615
|
const isFormPattern = FORM_PATTERNS.has(content.pattern) || content.pattern.includes("form");
|
|
37615
37616
|
if (isFormPattern && entityDef && Array.isArray(finalProps.fields)) {
|
|
37616
37617
|
finalProps.fields = enrichFormFields(finalProps.fields, entityDef);
|
|
37617
|
-
if (finalProps.mode === "edit" && !finalProps.initialData && storeData.length > 0) {
|
|
37618
|
-
finalProps.initialData = storeData[0];
|
|
37619
|
-
}
|
|
37620
37618
|
}
|
|
37621
37619
|
const acceptsChildren = PATTERNS_WITH_CHILDREN.has(content.pattern);
|
|
37622
37620
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -37710,7 +37708,7 @@ function UISlotRenderer({
|
|
|
37710
37708
|
}
|
|
37711
37709
|
return wrapped;
|
|
37712
37710
|
}
|
|
37713
|
-
var TRAIT_BINDING_RE,
|
|
37711
|
+
var TRAIT_BINDING_RE, SuspenseConfigContext, SlotContainedContext, SLOT_SKELETON_MAP, FORM_PATTERNS, PATTERNS_WITH_CHILDREN;
|
|
37714
37712
|
var init_UISlotRenderer = __esm({
|
|
37715
37713
|
"components/organisms/UISlotRenderer.tsx"() {
|
|
37716
37714
|
"use client";
|
|
@@ -37727,7 +37725,6 @@ var init_UISlotRenderer = __esm({
|
|
|
37727
37725
|
init_TraitFrame();
|
|
37728
37726
|
init_component_registry_generated();
|
|
37729
37727
|
TRAIT_BINDING_RE = /^@trait\.([A-Z][A-Za-z0-9]*)$/;
|
|
37730
|
-
STRING_ENTITY_WARNED = /* @__PURE__ */ new Set();
|
|
37731
37728
|
SuspenseConfigContext = React116.createContext({ enabled: false });
|
|
37732
37729
|
SlotContainedContext = React116.createContext(false);
|
|
37733
37730
|
SuspenseConfigProvider.displayName = "SuspenseConfigProvider";
|
|
@@ -38555,7 +38552,7 @@ function buildMockData(schema) {
|
|
|
38555
38552
|
}
|
|
38556
38553
|
return result;
|
|
38557
38554
|
}
|
|
38558
|
-
function
|
|
38555
|
+
function isInlineTrait2(traitRef) {
|
|
38559
38556
|
return typeof traitRef === "object" && traitRef !== null && "stateMachine" in traitRef;
|
|
38560
38557
|
}
|
|
38561
38558
|
function findDataState(sm, initialStateName) {
|
|
@@ -38587,7 +38584,7 @@ function adjustSchemaForMockData(schema, mockData) {
|
|
|
38587
38584
|
const updatedOrbitals = schema.orbitals.map((orbital) => {
|
|
38588
38585
|
const traits2 = orbital.traits ?? [];
|
|
38589
38586
|
const updatedTraits = traits2.map((traitRef) => {
|
|
38590
|
-
if (!
|
|
38587
|
+
if (!isInlineTrait2(traitRef)) return traitRef;
|
|
38591
38588
|
const updated = rewriteTraitInitialState(traitRef, mockData);
|
|
38592
38589
|
if (updated !== traitRef) changed = true;
|
|
38593
38590
|
return updated;
|
|
@@ -38665,23 +38662,14 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
38665
38662
|
const slotsActions = useSlotsActions();
|
|
38666
38663
|
const bridge = useServerBridge();
|
|
38667
38664
|
const uiSlots = context.useUISlots();
|
|
38668
|
-
const entityStore = providers.useEntityStore();
|
|
38669
38665
|
const onEventProcessed = React116.useCallback(async (event, payload) => {
|
|
38670
38666
|
if (!bridge.connected || !orbitalNames?.length) return;
|
|
38671
38667
|
for (const name of orbitalNames) {
|
|
38672
38668
|
const { effects, meta } = await bridge.sendEvent(name, event, payload);
|
|
38673
38669
|
recordServerResponse(name, event, meta);
|
|
38674
|
-
const responseData = meta?.data;
|
|
38675
|
-
if (responseData) {
|
|
38676
|
-
for (const [entityType, records] of Object.entries(responseData)) {
|
|
38677
|
-
if (Array.isArray(records)) {
|
|
38678
|
-
entityStore.setAll(entityType, records);
|
|
38679
|
-
}
|
|
38680
|
-
}
|
|
38681
|
-
}
|
|
38682
38670
|
applyServerEffects(effects, uiSlots, onNavigate);
|
|
38683
38671
|
}
|
|
38684
|
-
}, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate
|
|
38672
|
+
}, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate]);
|
|
38685
38673
|
const opts = orbitalNames ? { onEventProcessed, navigate: onNavigate } : { navigate: onNavigate };
|
|
38686
38674
|
const { sendEvent } = useTraitStateMachine(traits2, slotsActions, opts);
|
|
38687
38675
|
const initSentRef = React116.useRef(false);
|
|
@@ -38721,14 +38709,6 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
38721
38709
|
effects: effectTraces,
|
|
38722
38710
|
timestamp: Date.now()
|
|
38723
38711
|
});
|
|
38724
|
-
const initResponseData = meta?.data;
|
|
38725
|
-
if (initResponseData) {
|
|
38726
|
-
for (const [entityType, records] of Object.entries(initResponseData)) {
|
|
38727
|
-
if (Array.isArray(records)) {
|
|
38728
|
-
entityStore.setAll(entityType, records);
|
|
38729
|
-
}
|
|
38730
|
-
}
|
|
38731
|
-
}
|
|
38732
38712
|
applyServerEffects(effects, uiSlots, onNavigate);
|
|
38733
38713
|
}
|
|
38734
38714
|
})();
|
|
@@ -38761,19 +38741,6 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
|
|
|
38761
38741
|
if (!orbitals) return [];
|
|
38762
38742
|
return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
|
|
38763
38743
|
}, [schema]);
|
|
38764
|
-
const entityStore = providers.useEntityStore();
|
|
38765
|
-
const seededRef = React116.useRef("");
|
|
38766
|
-
const mockKey = mockData ? Object.keys(mockData).sort().join(",") : "";
|
|
38767
|
-
React116__namespace.default.useLayoutEffect(() => {
|
|
38768
|
-
if (!serverUrl && mockData && seededRef.current !== mockKey) {
|
|
38769
|
-
seededRef.current = mockKey;
|
|
38770
|
-
for (const [entityType, records] of Object.entries(mockData)) {
|
|
38771
|
-
if (Array.isArray(records)) {
|
|
38772
|
-
entityStore.setAll(entityType, records);
|
|
38773
|
-
}
|
|
38774
|
-
}
|
|
38775
|
-
}
|
|
38776
|
-
}, [mockKey, serverUrl, mockData, entityStore]);
|
|
38777
38744
|
const inner = /* @__PURE__ */ jsxRuntime.jsx(providers.VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(SlotsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(EntitySchemaProvider, { entities: Array.from(allEntities.values()), children: [
|
|
38778
38745
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
38779
38746
|
TraitInitializer,
|
package/dist/runtime/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* node_modules/.pnpm/katex@0.16.
|
|
1
|
+
/* node_modules/.pnpm/katex@0.16.45/node_modules/katex/dist/katex.min.css */
|
|
2
2
|
@font-face {
|
|
3
3
|
font-display: block;
|
|
4
4
|
font-family: KaTeX_AMS;
|
|
@@ -205,6 +205,7 @@
|
|
|
205
205
|
Times New Roman,
|
|
206
206
|
serif;
|
|
207
207
|
line-height: 1.2;
|
|
208
|
+
position: relative;
|
|
208
209
|
text-indent: 0;
|
|
209
210
|
text-rendering: auto;
|
|
210
211
|
}
|
|
@@ -213,7 +214,7 @@
|
|
|
213
214
|
border-color: currentColor;
|
|
214
215
|
}
|
|
215
216
|
.katex .katex-version:after {
|
|
216
|
-
content: "0.16.
|
|
217
|
+
content: "0.16.45";
|
|
217
218
|
}
|
|
218
219
|
.katex .katex-mathml {
|
|
219
220
|
clip: rect(1px, 1px, 1px, 1px);
|
|
@@ -389,6 +390,10 @@
|
|
|
389
390
|
.katex .mspace {
|
|
390
391
|
display: inline-block;
|
|
391
392
|
}
|
|
393
|
+
.katex .smash {
|
|
394
|
+
display: inline;
|
|
395
|
+
line-height: 0;
|
|
396
|
+
}
|
|
392
397
|
.katex .clap,
|
|
393
398
|
.katex .llap,
|
|
394
399
|
.katex .rlap {
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React116 from 'react';
|
|
2
2
|
import React116__default, { createContext, useContext, useRef, useEffect, useCallback, useMemo, Suspense, useState, useLayoutEffect, lazy, useId } from 'react';
|
|
3
|
-
import { EventBusContext,
|
|
3
|
+
import { EventBusContext, OrbitalProvider, VerificationProvider } from '@almadar/ui/providers';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -34,8 +34,8 @@ import langDiff from 'react-syntax-highlighter/dist/esm/languages/prism/diff.js'
|
|
|
34
34
|
import langToml from 'react-syntax-highlighter/dist/esm/languages/prism/toml.js';
|
|
35
35
|
import langGo from 'react-syntax-highlighter/dist/esm/languages/prism/go.js';
|
|
36
36
|
import langGraphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql.js';
|
|
37
|
+
import { isCircuitEvent, schemaToIR, getPage, clearSchemaCache as clearSchemaCache$1, isEntityCall, isInlineTrait } from '@almadar/core';
|
|
37
38
|
import '@tanstack/react-query';
|
|
38
|
-
import { isCircuitEvent, schemaToIR, getPage, clearSchemaCache as clearSchemaCache$1, isEntityCall } from '@almadar/core';
|
|
39
39
|
import { StateMachineManager, createContextFromBindings, interpolateValue, EffectExecutor } from '@almadar/runtime';
|
|
40
40
|
|
|
41
41
|
var __defProp = Object.defineProperty;
|
|
@@ -10364,9 +10364,9 @@ var init_ScaledDiagram = __esm({
|
|
|
10364
10364
|
}
|
|
10365
10365
|
});
|
|
10366
10366
|
|
|
10367
|
-
// node_modules/.pnpm/katex@0.16.
|
|
10367
|
+
// node_modules/.pnpm/katex@0.16.45/node_modules/katex/dist/katex.min.css
|
|
10368
10368
|
var init_katex_min = __esm({
|
|
10369
|
-
"node_modules/.pnpm/katex@0.16.
|
|
10369
|
+
"node_modules/.pnpm/katex@0.16.45/node_modules/katex/dist/katex.min.css"() {
|
|
10370
10370
|
}
|
|
10371
10371
|
});
|
|
10372
10372
|
var MarkdownContent;
|
|
@@ -12365,7 +12365,9 @@ function extractTrait(schema, trait, traitIndex) {
|
|
|
12365
12365
|
for (const orbital of schema.orbitals) {
|
|
12366
12366
|
const traits2 = orbital.traits ?? [];
|
|
12367
12367
|
if (traitIndex < traits2.length) {
|
|
12368
|
-
|
|
12368
|
+
const traitRef = traits2[traitIndex];
|
|
12369
|
+
if (isInlineTrait(traitRef)) return traitRef;
|
|
12370
|
+
return null;
|
|
12369
12371
|
}
|
|
12370
12372
|
}
|
|
12371
12373
|
return null;
|
|
@@ -12373,8 +12375,10 @@ function extractTrait(schema, trait, traitIndex) {
|
|
|
12373
12375
|
function extractEntityFields(schema) {
|
|
12374
12376
|
if (!schema?.orbitals?.length) return [];
|
|
12375
12377
|
const entity = schema.orbitals[0].entity;
|
|
12376
|
-
if (!entity
|
|
12377
|
-
|
|
12378
|
+
if (!entity || typeof entity !== "object" || !("fields" in entity)) return [];
|
|
12379
|
+
const inlineEntity = entity;
|
|
12380
|
+
if (!inlineEntity.fields) return [];
|
|
12381
|
+
return inlineEntity.fields.map((f3) => f3.name);
|
|
12378
12382
|
}
|
|
12379
12383
|
function toStateMachineDefinition(sm) {
|
|
12380
12384
|
return {
|
|
@@ -12669,12 +12673,18 @@ var init_ContentRenderer = __esm({
|
|
|
12669
12673
|
);
|
|
12670
12674
|
case "orbital": {
|
|
12671
12675
|
const parsed = segment.schema;
|
|
12676
|
+
const inlineTrait = {
|
|
12677
|
+
name: "inline",
|
|
12678
|
+
scope: "instance",
|
|
12679
|
+
stateMachine: parsed
|
|
12680
|
+
};
|
|
12672
12681
|
const schema = Array.isArray(parsed.orbitals) ? parsed : {
|
|
12682
|
+
name: "inline",
|
|
12673
12683
|
orbitals: [{
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12684
|
+
name: "inline",
|
|
12685
|
+
entity: { name: "inline", fields: [] },
|
|
12686
|
+
traits: [inlineTrait],
|
|
12687
|
+
pages: []
|
|
12678
12688
|
}]
|
|
12679
12689
|
};
|
|
12680
12690
|
return /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
@@ -37529,19 +37539,15 @@ function SlotContentRenderer({
|
|
|
37529
37539
|
patternPath
|
|
37530
37540
|
}) {
|
|
37531
37541
|
const entityProp = content.props.entity;
|
|
37532
|
-
|
|
37533
|
-
|
|
37534
|
-
|
|
37535
|
-
|
|
37536
|
-
|
|
37537
|
-
|
|
37538
|
-
|
|
37539
|
-
console.warn(
|
|
37540
|
-
`[UISlotRenderer] String-entity binding '${entityType}' is deprecated. Pass 'items' or 'entity' as a value prop resolved from @payload.data. See docs/Almadar_Entity_V2_Plan.md \xA75.`
|
|
37541
|
-
);
|
|
37542
|
-
}, [entityType]);
|
|
37542
|
+
if (typeof entityProp === "string" && entityProp.length > 0) {
|
|
37543
|
+
if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production") {
|
|
37544
|
+
throw new Error(
|
|
37545
|
+
`[UISlotRenderer] Received string 'entity: "${entityProp}"' at render time. The V2 flow requires pre-resolved data; declare a fetch success listener and pass 'entity: @payload.data'. See docs/Almadar_Entity_V2_Plan.md \xA76.`
|
|
37546
|
+
);
|
|
37547
|
+
}
|
|
37548
|
+
}
|
|
37543
37549
|
const schemaCtx = useEntitySchemaOptional();
|
|
37544
|
-
const entityDef =
|
|
37550
|
+
const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
|
|
37545
37551
|
const PatternComponent = getComponentForPattern(content.pattern);
|
|
37546
37552
|
if (PatternComponent) {
|
|
37547
37553
|
const childrenConfig = content.props.children;
|
|
@@ -37550,12 +37556,7 @@ function SlotContentRenderer({
|
|
|
37550
37556
|
const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
|
|
37551
37557
|
const { children: _childrenConfig, ...restProps } = content.props;
|
|
37552
37558
|
const renderedProps = renderPatternProps(restProps, onDismiss);
|
|
37553
|
-
|
|
37554
|
-
if (entityType) {
|
|
37555
|
-
finalProps = { ...renderedProps, entity: storeData };
|
|
37556
|
-
} else {
|
|
37557
|
-
finalProps = renderedProps;
|
|
37558
|
-
}
|
|
37559
|
+
const finalProps = renderedProps;
|
|
37559
37560
|
const resolvedItems = Array.isArray(
|
|
37560
37561
|
finalProps.entity
|
|
37561
37562
|
) ? finalProps.entity : null;
|
|
@@ -37569,9 +37570,6 @@ function SlotContentRenderer({
|
|
|
37569
37570
|
const isFormPattern = FORM_PATTERNS.has(content.pattern) || content.pattern.includes("form");
|
|
37570
37571
|
if (isFormPattern && entityDef && Array.isArray(finalProps.fields)) {
|
|
37571
37572
|
finalProps.fields = enrichFormFields(finalProps.fields, entityDef);
|
|
37572
|
-
if (finalProps.mode === "edit" && !finalProps.initialData && storeData.length > 0) {
|
|
37573
|
-
finalProps.initialData = storeData[0];
|
|
37574
|
-
}
|
|
37575
37573
|
}
|
|
37576
37574
|
const acceptsChildren = PATTERNS_WITH_CHILDREN.has(content.pattern);
|
|
37577
37575
|
return /* @__PURE__ */ jsx(
|
|
@@ -37665,7 +37663,7 @@ function UISlotRenderer({
|
|
|
37665
37663
|
}
|
|
37666
37664
|
return wrapped;
|
|
37667
37665
|
}
|
|
37668
|
-
var TRAIT_BINDING_RE,
|
|
37666
|
+
var TRAIT_BINDING_RE, SuspenseConfigContext, SlotContainedContext, SLOT_SKELETON_MAP, FORM_PATTERNS, PATTERNS_WITH_CHILDREN;
|
|
37669
37667
|
var init_UISlotRenderer = __esm({
|
|
37670
37668
|
"components/organisms/UISlotRenderer.tsx"() {
|
|
37671
37669
|
"use client";
|
|
@@ -37682,7 +37680,6 @@ var init_UISlotRenderer = __esm({
|
|
|
37682
37680
|
init_TraitFrame();
|
|
37683
37681
|
init_component_registry_generated();
|
|
37684
37682
|
TRAIT_BINDING_RE = /^@trait\.([A-Z][A-Za-z0-9]*)$/;
|
|
37685
|
-
STRING_ENTITY_WARNED = /* @__PURE__ */ new Set();
|
|
37686
37683
|
SuspenseConfigContext = createContext({ enabled: false });
|
|
37687
37684
|
SlotContainedContext = createContext(false);
|
|
37688
37685
|
SuspenseConfigProvider.displayName = "SuspenseConfigProvider";
|
|
@@ -38510,7 +38507,7 @@ function buildMockData(schema) {
|
|
|
38510
38507
|
}
|
|
38511
38508
|
return result;
|
|
38512
38509
|
}
|
|
38513
|
-
function
|
|
38510
|
+
function isInlineTrait2(traitRef) {
|
|
38514
38511
|
return typeof traitRef === "object" && traitRef !== null && "stateMachine" in traitRef;
|
|
38515
38512
|
}
|
|
38516
38513
|
function findDataState(sm, initialStateName) {
|
|
@@ -38542,7 +38539,7 @@ function adjustSchemaForMockData(schema, mockData) {
|
|
|
38542
38539
|
const updatedOrbitals = schema.orbitals.map((orbital) => {
|
|
38543
38540
|
const traits2 = orbital.traits ?? [];
|
|
38544
38541
|
const updatedTraits = traits2.map((traitRef) => {
|
|
38545
|
-
if (!
|
|
38542
|
+
if (!isInlineTrait2(traitRef)) return traitRef;
|
|
38546
38543
|
const updated = rewriteTraitInitialState(traitRef, mockData);
|
|
38547
38544
|
if (updated !== traitRef) changed = true;
|
|
38548
38545
|
return updated;
|
|
@@ -38620,23 +38617,14 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
38620
38617
|
const slotsActions = useSlotsActions();
|
|
38621
38618
|
const bridge = useServerBridge();
|
|
38622
38619
|
const uiSlots = useUISlots();
|
|
38623
|
-
const entityStore = useEntityStore();
|
|
38624
38620
|
const onEventProcessed = useCallback(async (event, payload) => {
|
|
38625
38621
|
if (!bridge.connected || !orbitalNames?.length) return;
|
|
38626
38622
|
for (const name of orbitalNames) {
|
|
38627
38623
|
const { effects, meta } = await bridge.sendEvent(name, event, payload);
|
|
38628
38624
|
recordServerResponse(name, event, meta);
|
|
38629
|
-
const responseData = meta?.data;
|
|
38630
|
-
if (responseData) {
|
|
38631
|
-
for (const [entityType, records] of Object.entries(responseData)) {
|
|
38632
|
-
if (Array.isArray(records)) {
|
|
38633
|
-
entityStore.setAll(entityType, records);
|
|
38634
|
-
}
|
|
38635
|
-
}
|
|
38636
|
-
}
|
|
38637
38625
|
applyServerEffects(effects, uiSlots, onNavigate);
|
|
38638
38626
|
}
|
|
38639
|
-
}, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate
|
|
38627
|
+
}, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate]);
|
|
38640
38628
|
const opts = orbitalNames ? { onEventProcessed, navigate: onNavigate } : { navigate: onNavigate };
|
|
38641
38629
|
const { sendEvent } = useTraitStateMachine(traits2, slotsActions, opts);
|
|
38642
38630
|
const initSentRef = useRef(false);
|
|
@@ -38676,14 +38664,6 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
38676
38664
|
effects: effectTraces,
|
|
38677
38665
|
timestamp: Date.now()
|
|
38678
38666
|
});
|
|
38679
|
-
const initResponseData = meta?.data;
|
|
38680
|
-
if (initResponseData) {
|
|
38681
|
-
for (const [entityType, records] of Object.entries(initResponseData)) {
|
|
38682
|
-
if (Array.isArray(records)) {
|
|
38683
|
-
entityStore.setAll(entityType, records);
|
|
38684
|
-
}
|
|
38685
|
-
}
|
|
38686
|
-
}
|
|
38687
38667
|
applyServerEffects(effects, uiSlots, onNavigate);
|
|
38688
38668
|
}
|
|
38689
38669
|
})();
|
|
@@ -38716,19 +38696,6 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
|
|
|
38716
38696
|
if (!orbitals) return [];
|
|
38717
38697
|
return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
|
|
38718
38698
|
}, [schema]);
|
|
38719
|
-
const entityStore = useEntityStore();
|
|
38720
|
-
const seededRef = useRef("");
|
|
38721
|
-
const mockKey = mockData ? Object.keys(mockData).sort().join(",") : "";
|
|
38722
|
-
React116__default.useLayoutEffect(() => {
|
|
38723
|
-
if (!serverUrl && mockData && seededRef.current !== mockKey) {
|
|
38724
|
-
seededRef.current = mockKey;
|
|
38725
|
-
for (const [entityType, records] of Object.entries(mockData)) {
|
|
38726
|
-
if (Array.isArray(records)) {
|
|
38727
|
-
entityStore.setAll(entityType, records);
|
|
38728
|
-
}
|
|
38729
|
-
}
|
|
38730
|
-
}
|
|
38731
|
-
}, [mockKey, serverUrl, mockData, entityStore]);
|
|
38732
38699
|
const inner = /* @__PURE__ */ jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsx(SlotsProvider, { children: /* @__PURE__ */ jsxs(EntitySchemaProvider, { entities: Array.from(allEntities.values()), children: [
|
|
38733
38700
|
/* @__PURE__ */ jsx(
|
|
38734
38701
|
TraitInitializer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "React UI components, hooks, and providers for Almadar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/components/index.js",
|
|
@@ -118,10 +118,10 @@
|
|
|
118
118
|
"access": "public"
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
|
-
"@almadar/core": ">=
|
|
121
|
+
"@almadar/core": ">=5.1.0",
|
|
122
122
|
"@almadar/evaluator": ">=2.8.1",
|
|
123
123
|
"@almadar/patterns": ">=2.14.1",
|
|
124
|
-
"@almadar/runtime": ">=
|
|
124
|
+
"@almadar/runtime": ">=4.0.0",
|
|
125
125
|
"@almadar/std": ">=6.4.1",
|
|
126
126
|
"@almadar/syntax": ">=1.3.1",
|
|
127
127
|
"@xyflow/react": "12.10.1",
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EntityStoreProvider
|
|
3
|
-
*
|
|
4
|
-
* Normalized reactive entity store for Orbital applications.
|
|
5
|
-
* Stores entities in ID-keyed Maps with ordered ID lists.
|
|
6
|
-
* Provides operation-specific methods (setAll, upsertOne, addOne,
|
|
7
|
-
* updateOne, removeOne) and selector hooks (useEntityRef for
|
|
8
|
-
* collections, useEntityById for single entities).
|
|
9
|
-
*
|
|
10
|
-
* Every mutation creates new Map/array objects (immutable values).
|
|
11
|
-
* Identity (the store key) advances to a new value on each write.
|
|
12
|
-
* Follows the Clojure epochal time model from Almadar_Orb_IO.md.
|
|
13
|
-
*
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
*/
|
|
16
|
-
import React, { type ReactNode } from 'react';
|
|
17
|
-
type StoreListener = () => void;
|
|
18
|
-
type WatchCallback = (oldData: unknown[], newData: unknown[]) => void;
|
|
19
|
-
export declare function subscribeToStore(listener: StoreListener): () => void;
|
|
20
|
-
/**
|
|
21
|
-
* Subscribe to an entity collection reactively.
|
|
22
|
-
* Returns the full ordered array. Re-renders when the collection changes.
|
|
23
|
-
*
|
|
24
|
-
* Client-side implementation of `["ref", "EntityType"]`.
|
|
25
|
-
*/
|
|
26
|
-
export declare function useEntityRef(entityType: string): unknown[];
|
|
27
|
-
/**
|
|
28
|
-
* Subscribe to a single entity by ID reactively.
|
|
29
|
-
* Returns the entity record or null. Re-renders when the entity changes.
|
|
30
|
-
*
|
|
31
|
-
* Client-side implementation of `["fetch", "EntityType", { id: ... }]`.
|
|
32
|
-
*/
|
|
33
|
-
export declare function useEntityById(entityType: string, id: string | undefined): Record<string, unknown> | null;
|
|
34
|
-
/**
|
|
35
|
-
* Register a callback that fires when an entity collection changes.
|
|
36
|
-
* Receives (oldData, newData) for side effects (notify, emit, log).
|
|
37
|
-
*
|
|
38
|
-
* Client-side implementation of `["watch", "EntityType", effects]`.
|
|
39
|
-
*/
|
|
40
|
-
export declare function useEntityWatch(entityType: string, callback: WatchCallback): void;
|
|
41
|
-
export interface EntityStoreContextValue {
|
|
42
|
-
setAll: (entityType: string, records: unknown[]) => void;
|
|
43
|
-
upsertOne: (entityType: string, record: Record<string, unknown>) => void;
|
|
44
|
-
addOne: (entityType: string, record: Record<string, unknown>) => void;
|
|
45
|
-
updateOne: (entityType: string, id: string, changes: Partial<Record<string, unknown>>) => void;
|
|
46
|
-
removeOne: (entityType: string, id: string) => void;
|
|
47
|
-
getSnapshot: (entityType: string) => unknown[];
|
|
48
|
-
getById: (entityType: string, id: string) => Record<string, unknown> | null;
|
|
49
|
-
}
|
|
50
|
-
export declare const EntityStoreContext: React.Context<EntityStoreContextValue>;
|
|
51
|
-
/**
|
|
52
|
-
* Access the entity store operations.
|
|
53
|
-
* Used by useOrbitalBridge and OrbPreview to push server response data into the store.
|
|
54
|
-
*/
|
|
55
|
-
export declare function useEntityStore(): EntityStoreContextValue;
|
|
56
|
-
/**
|
|
57
|
-
* Provider component. Wrap the app or page with this to enable entity reactivity.
|
|
58
|
-
* Already included in OrbitalProvider.
|
|
59
|
-
*/
|
|
60
|
-
export declare function EntityStoreProvider({ children }: {
|
|
61
|
-
children: ReactNode;
|
|
62
|
-
}): React.ReactElement;
|
|
63
|
-
export {};
|