@almadar/ui 5.101.0 → 5.103.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/avl/index.cjs +238 -40
- package/dist/avl/index.js +240 -42
- package/dist/components/index.cjs +89 -19
- package/dist/components/index.js +74 -8
- package/dist/hooks/index.cjs +71 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +69 -2
- package/dist/hooks/useSharedEntityStore.d.ts +53 -0
- package/dist/hooks/useTraitStateMachine.d.ts +32 -1
- package/dist/runtime/index.cjs +242 -44
- package/dist/runtime/index.js +244 -46
- package/package.json +2 -2
package/dist/avl/index.cjs
CHANGED
|
@@ -33295,12 +33295,12 @@ var init_MapView = __esm({
|
|
|
33295
33295
|
shadowSize: [41, 41]
|
|
33296
33296
|
});
|
|
33297
33297
|
L.Marker.prototype.options.icon = defaultIcon;
|
|
33298
|
-
const { useEffect: useEffect71, useRef:
|
|
33298
|
+
const { useEffect: useEffect71, useRef: useRef68, useCallback: useCallback104, useState: useState105 } = React105__namespace.default;
|
|
33299
33299
|
const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
|
|
33300
33300
|
const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
|
|
33301
33301
|
function MapUpdater({ centerLat, centerLng, zoom }) {
|
|
33302
33302
|
const map = useMap();
|
|
33303
|
-
const prevRef =
|
|
33303
|
+
const prevRef = useRef68({ centerLat, centerLng, zoom });
|
|
33304
33304
|
useEffect71(() => {
|
|
33305
33305
|
const prev = prevRef.current;
|
|
33306
33306
|
if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
|
|
@@ -46291,7 +46291,7 @@ function getAllEvents(traits2) {
|
|
|
46291
46291
|
function EventDispatcherTab({ traits: traits2, schema }) {
|
|
46292
46292
|
const eventBus = useEventBus();
|
|
46293
46293
|
const { t } = hooks.useTranslate();
|
|
46294
|
-
const [
|
|
46294
|
+
const [log12, setLog] = React105__namespace.useState([]);
|
|
46295
46295
|
const prevStatesRef = React105__namespace.useRef(/* @__PURE__ */ new Map());
|
|
46296
46296
|
React105__namespace.useEffect(() => {
|
|
46297
46297
|
for (const trait of traits2) {
|
|
@@ -46355,9 +46355,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
|
|
|
46355
46355
|
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.otherEvents") }),
|
|
46356
46356
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
|
|
46357
46357
|
] }),
|
|
46358
|
-
|
|
46358
|
+
log12.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
46359
46359
|
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.recentTransitions") }),
|
|
46360
|
-
/* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children:
|
|
46360
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log12.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
|
|
46361
46361
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-400", children: entry.traitName }),
|
|
46362
46362
|
" ",
|
|
46363
46363
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: entry.from }),
|
|
@@ -53642,7 +53642,67 @@ function convertFnFormLambdasInProps(props) {
|
|
|
53642
53642
|
|
|
53643
53643
|
// hooks/index.ts
|
|
53644
53644
|
init_useEventBus();
|
|
53645
|
-
var log7 = logger.createLogger("almadar:ui:
|
|
53645
|
+
var log7 = logger.createLogger("almadar:ui:shared-entity-store");
|
|
53646
|
+
var EMPTY_ENTITY_STATE = {};
|
|
53647
|
+
function createSharedEntityStore() {
|
|
53648
|
+
const states = /* @__PURE__ */ new Map();
|
|
53649
|
+
const subscribers2 = /* @__PURE__ */ new Map();
|
|
53650
|
+
const getSnapshot2 = (entityId) => states.get(entityId) ?? EMPTY_ENTITY_STATE;
|
|
53651
|
+
const subscribe = (entityId, callback) => {
|
|
53652
|
+
let set = subscribers2.get(entityId);
|
|
53653
|
+
if (!set) {
|
|
53654
|
+
set = /* @__PURE__ */ new Set();
|
|
53655
|
+
subscribers2.set(entityId, set);
|
|
53656
|
+
}
|
|
53657
|
+
set.add(callback);
|
|
53658
|
+
return () => {
|
|
53659
|
+
const current = subscribers2.get(entityId);
|
|
53660
|
+
if (!current) return;
|
|
53661
|
+
current.delete(callback);
|
|
53662
|
+
if (current.size === 0) {
|
|
53663
|
+
subscribers2.delete(entityId);
|
|
53664
|
+
}
|
|
53665
|
+
};
|
|
53666
|
+
};
|
|
53667
|
+
const commit = (entityId, nextState) => {
|
|
53668
|
+
states.set(entityId, nextState);
|
|
53669
|
+
const set = subscribers2.get(entityId);
|
|
53670
|
+
if (!set) return;
|
|
53671
|
+
set.forEach((callback) => {
|
|
53672
|
+
try {
|
|
53673
|
+
callback();
|
|
53674
|
+
} catch (error) {
|
|
53675
|
+
log7.error("Shared entity subscriber error", {
|
|
53676
|
+
entityId,
|
|
53677
|
+
error: error instanceof Error ? error : String(error)
|
|
53678
|
+
});
|
|
53679
|
+
}
|
|
53680
|
+
});
|
|
53681
|
+
};
|
|
53682
|
+
const seed = (entityId, initialState) => {
|
|
53683
|
+
if (!states.has(entityId)) {
|
|
53684
|
+
states.set(entityId, initialState);
|
|
53685
|
+
}
|
|
53686
|
+
};
|
|
53687
|
+
return { getSnapshot: getSnapshot2, subscribe, commit, seed };
|
|
53688
|
+
}
|
|
53689
|
+
function useSharedEntityStore() {
|
|
53690
|
+
const storeRef = React105.useRef(null);
|
|
53691
|
+
if (storeRef.current === null) {
|
|
53692
|
+
storeRef.current = createSharedEntityStore();
|
|
53693
|
+
}
|
|
53694
|
+
return storeRef.current;
|
|
53695
|
+
}
|
|
53696
|
+
function runTickFrame(entityId, orderedWriters, store) {
|
|
53697
|
+
let scratch = store.getSnapshot(entityId);
|
|
53698
|
+
for (const writer of orderedWriters) {
|
|
53699
|
+
const writes = writer(scratch);
|
|
53700
|
+
scratch = core.mergeEntityFrame(scratch, writes);
|
|
53701
|
+
}
|
|
53702
|
+
store.commit(entityId, scratch);
|
|
53703
|
+
return scratch;
|
|
53704
|
+
}
|
|
53705
|
+
var log8 = logger.createLogger("almadar:ui:effects:client-handlers");
|
|
53646
53706
|
function createClientEffectHandlers(options) {
|
|
53647
53707
|
const { eventBus, slotSetter, navigate, notify, callService, liveEntity } = options;
|
|
53648
53708
|
return {
|
|
@@ -53651,12 +53711,12 @@ function createClientEffectHandlers(options) {
|
|
|
53651
53711
|
eventBus.emit(prefixedEvent, payload);
|
|
53652
53712
|
},
|
|
53653
53713
|
persist: async () => {
|
|
53654
|
-
|
|
53714
|
+
log8.warn("persist is server-side only, ignored on client");
|
|
53655
53715
|
},
|
|
53656
53716
|
// @almadar/runtime EffectHandlers.set types value:unknown — should be FieldValue (upstream fix queued)
|
|
53657
53717
|
set: ((_entityId, field, value) => {
|
|
53658
53718
|
if (!liveEntity) {
|
|
53659
|
-
|
|
53719
|
+
log8.warn("set is server-side only, ignored on client (no live entity)");
|
|
53660
53720
|
return;
|
|
53661
53721
|
}
|
|
53662
53722
|
liveEntity[field] = value;
|
|
@@ -53688,10 +53748,10 @@ function createClientEffectHandlers(options) {
|
|
|
53688
53748
|
slotSetter.addPattern(slot, pattern, props);
|
|
53689
53749
|
},
|
|
53690
53750
|
navigate: navigate ?? ((path) => {
|
|
53691
|
-
|
|
53751
|
+
log8.warn("No navigate handler, ignoring", { path });
|
|
53692
53752
|
}),
|
|
53693
53753
|
notify: notify ?? ((msg, type) => {
|
|
53694
|
-
|
|
53754
|
+
log8.debug("notify", { type, message: msg });
|
|
53695
53755
|
})
|
|
53696
53756
|
};
|
|
53697
53757
|
}
|
|
@@ -53736,11 +53796,101 @@ function toTraitDefinition(binding) {
|
|
|
53736
53796
|
function normalizeEventKey(eventKey) {
|
|
53737
53797
|
return eventKey.startsWith("UI:") ? eventKey.slice(3) : eventKey;
|
|
53738
53798
|
}
|
|
53799
|
+
var SHARED_ENTITY_WRITE_OPS = /* @__PURE__ */ new Set(["set"]);
|
|
53800
|
+
var SHARED_ENTITY_RENDER_OPS = /* @__PURE__ */ new Set(["render-ui", "render"]);
|
|
53801
|
+
function collectAllTraitEffects(trait) {
|
|
53802
|
+
return [
|
|
53803
|
+
...trait.ticks.flatMap((t) => t.effects),
|
|
53804
|
+
...trait.transitions.flatMap((t) => t.effects)
|
|
53805
|
+
];
|
|
53806
|
+
}
|
|
53807
|
+
function effectsCallOp(effects, ops) {
|
|
53808
|
+
for (const effect of effects) {
|
|
53809
|
+
let found = false;
|
|
53810
|
+
core.walkSExpr(effect, (node) => {
|
|
53811
|
+
if (!found && Array.isArray(node) && typeof node[0] === "string" && ops.has(node[0])) {
|
|
53812
|
+
found = true;
|
|
53813
|
+
}
|
|
53814
|
+
});
|
|
53815
|
+
if (found) return true;
|
|
53816
|
+
}
|
|
53817
|
+
return false;
|
|
53818
|
+
}
|
|
53819
|
+
function createSharedEntityWriter(binding, tick, traitStatesRef, emit) {
|
|
53820
|
+
return (scratch) => {
|
|
53821
|
+
const traitName = binding.trait.name;
|
|
53822
|
+
const currentState = traitStatesRef.current.get(traitName)?.currentState ?? "";
|
|
53823
|
+
if (tick.appliesTo.length > 0 && !tick.appliesTo.includes(currentState)) return [];
|
|
53824
|
+
const scratchEntity = { ...scratch };
|
|
53825
|
+
const writes = [];
|
|
53826
|
+
const ctx = evaluator.createMinimalContext(scratchEntity, {}, currentState);
|
|
53827
|
+
const declaredDefaults = runtime.collectDeclaredConfigDefaults(binding.trait);
|
|
53828
|
+
const callSiteConfig = binding.config;
|
|
53829
|
+
if (declaredDefaults || callSiteConfig) {
|
|
53830
|
+
ctx.config = { ...declaredDefaults ?? {}, ...callSiteConfig ?? {} };
|
|
53831
|
+
}
|
|
53832
|
+
ctx.mutateEntity = (changes) => {
|
|
53833
|
+
for (const [field, value] of Object.entries(changes)) {
|
|
53834
|
+
const fieldValue = value;
|
|
53835
|
+
scratchEntity[field] = fieldValue;
|
|
53836
|
+
writes.push({ field, value: fieldValue });
|
|
53837
|
+
}
|
|
53838
|
+
};
|
|
53839
|
+
ctx.emit = (event, payload) => {
|
|
53840
|
+
emit(event, payload);
|
|
53841
|
+
};
|
|
53842
|
+
if (tick.guard !== void 0 && !evaluator.evaluateGuard(tick.guard, ctx)) {
|
|
53843
|
+
tickLog.debug("guard-blocked", { traitName, tick: tick.name, state: currentState });
|
|
53844
|
+
return [];
|
|
53845
|
+
}
|
|
53846
|
+
evaluator.executeEffects(tick.effects, ctx);
|
|
53847
|
+
return writes;
|
|
53848
|
+
};
|
|
53849
|
+
}
|
|
53739
53850
|
function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
53740
53851
|
const eventBus = useEventBus();
|
|
53741
53852
|
const { entities } = providers.useEntitySchema();
|
|
53742
53853
|
const traitConfigsByName = options?.traitConfigsByName;
|
|
53743
53854
|
const orbitalsByTrait = options?.orbitalsByTrait;
|
|
53855
|
+
const sharedEntityStore = useSharedEntityStore();
|
|
53856
|
+
const sharedGroups = React105.useMemo(() => {
|
|
53857
|
+
const groups = /* @__PURE__ */ new Map();
|
|
53858
|
+
for (const binding of traitBindings) {
|
|
53859
|
+
const linkedEntityName = binding.linkedEntity ?? binding.trait.linkedEntity;
|
|
53860
|
+
if (!linkedEntityName) continue;
|
|
53861
|
+
const entityDef = entities.get(linkedEntityName);
|
|
53862
|
+
if (!entityDef?.shared) continue;
|
|
53863
|
+
const orbitalName = orbitalsByTrait?.[binding.trait.name] ?? "";
|
|
53864
|
+
const storeKey = `${orbitalName}::${linkedEntityName}`;
|
|
53865
|
+
let group = groups.get(storeKey);
|
|
53866
|
+
if (!group) {
|
|
53867
|
+
let defaults;
|
|
53868
|
+
for (const field of entityDef.fields) {
|
|
53869
|
+
if (field.default !== void 0) {
|
|
53870
|
+
(defaults ?? (defaults = {}))[field.name] = field.default;
|
|
53871
|
+
}
|
|
53872
|
+
}
|
|
53873
|
+
group = { storeKey, entityName: linkedEntityName, writerBindings: [], renderBindings: [], defaults };
|
|
53874
|
+
groups.set(storeKey, group);
|
|
53875
|
+
}
|
|
53876
|
+
const allEffects = collectAllTraitEffects(binding.trait);
|
|
53877
|
+
if (effectsCallOp(allEffects, SHARED_ENTITY_WRITE_OPS)) group.writerBindings.push(binding);
|
|
53878
|
+
if (effectsCallOp(allEffects, SHARED_ENTITY_RENDER_OPS)) group.renderBindings.push(binding);
|
|
53879
|
+
}
|
|
53880
|
+
return groups;
|
|
53881
|
+
}, [traitBindings, entities, orbitalsByTrait]);
|
|
53882
|
+
for (const group of sharedGroups.values()) {
|
|
53883
|
+
if (group.defaults) sharedEntityStore.seed(group.storeKey, group.defaults);
|
|
53884
|
+
}
|
|
53885
|
+
const sharedKeyByTraitNameRef = React105.useRef(/* @__PURE__ */ new Map());
|
|
53886
|
+
React105.useEffect(() => {
|
|
53887
|
+
const map = /* @__PURE__ */ new Map();
|
|
53888
|
+
for (const group of sharedGroups.values()) {
|
|
53889
|
+
for (const binding of group.writerBindings) map.set(binding.trait.name, group.storeKey);
|
|
53890
|
+
for (const binding of group.renderBindings) map.set(binding.trait.name, group.storeKey);
|
|
53891
|
+
}
|
|
53892
|
+
sharedKeyByTraitNameRef.current = map;
|
|
53893
|
+
}, [sharedGroups]);
|
|
53744
53894
|
const manager = React105.useMemo(() => {
|
|
53745
53895
|
const traitDefs = traitBindings.map(toTraitDefinition);
|
|
53746
53896
|
const m = new runtime.StateMachineManager(traitDefs);
|
|
@@ -53923,14 +54073,21 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
53923
54073
|
};
|
|
53924
54074
|
}, [traitBindings]);
|
|
53925
54075
|
const executeTransitionEffects = React105.useCallback(async (params) => {
|
|
53926
|
-
const { binding, previousState, newState, payload, flushEvent, syncOnly, log:
|
|
54076
|
+
const { binding, previousState, newState, payload, flushEvent, syncOnly, log: log12 } = params;
|
|
53927
54077
|
const traitName = binding.trait.name;
|
|
53928
54078
|
const linkedEntity = binding.linkedEntity || "";
|
|
53929
54079
|
const entityId = payload?.entityId;
|
|
53930
|
-
|
|
53931
|
-
|
|
53932
|
-
|
|
53933
|
-
|
|
54080
|
+
const sharedKey = sharedKeyByTraitNameRef.current.get(traitName);
|
|
54081
|
+
let liveEntity;
|
|
54082
|
+
if (sharedKey !== void 0) {
|
|
54083
|
+
liveEntity = { ...sharedEntityStore.getSnapshot(sharedKey) };
|
|
54084
|
+
} else {
|
|
54085
|
+
let existing = traitFieldStatesRef.current.get(traitName);
|
|
54086
|
+
if (!existing) {
|
|
54087
|
+
existing = {};
|
|
54088
|
+
traitFieldStatesRef.current.set(traitName, existing);
|
|
54089
|
+
}
|
|
54090
|
+
liveEntity = existing;
|
|
53934
54091
|
}
|
|
53935
54092
|
const effects = syncOnly ? params.effects.filter(
|
|
53936
54093
|
(e) => Array.isArray(e) && SYNC_TICK_OPERATORS.has(String(e[0]))
|
|
@@ -54012,7 +54169,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
54012
54169
|
...handlers,
|
|
54013
54170
|
set: async (targetId, field, value) => {
|
|
54014
54171
|
if (baseSet) await baseSet(targetId, field, value);
|
|
54015
|
-
|
|
54172
|
+
log12.debug("set:write", {
|
|
54016
54173
|
traitName,
|
|
54017
54174
|
field,
|
|
54018
54175
|
value: JSON.stringify(value),
|
|
@@ -54052,17 +54209,20 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
54052
54209
|
const executor = new runtime.EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
|
|
54053
54210
|
try {
|
|
54054
54211
|
await executor.executeAll(effects);
|
|
54055
|
-
|
|
54212
|
+
if (sharedKey !== void 0) {
|
|
54213
|
+
sharedEntityStore.commit(sharedKey, liveEntity);
|
|
54214
|
+
}
|
|
54215
|
+
log12.debug("effects:executed", () => ({
|
|
54056
54216
|
traitName,
|
|
54057
54217
|
transition: `${previousState}->${newState}`,
|
|
54058
54218
|
event: flushEvent,
|
|
54059
54219
|
effectCount: effects.length,
|
|
54060
54220
|
emitted: emittedDuringExec.join(","),
|
|
54061
|
-
entityAfter: JSON.stringify(
|
|
54221
|
+
entityAfter: JSON.stringify(liveEntity ?? {}),
|
|
54062
54222
|
slotsTouched: Array.from(pendingSlots.keys()).join(",")
|
|
54063
54223
|
}));
|
|
54064
54224
|
for (const [slot, patterns] of pendingSlots) {
|
|
54065
|
-
|
|
54225
|
+
log12.debug("flush:slot", {
|
|
54066
54226
|
traitName,
|
|
54067
54227
|
slot,
|
|
54068
54228
|
patternCount: patterns.length,
|
|
@@ -54077,7 +54237,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
54077
54237
|
});
|
|
54078
54238
|
}
|
|
54079
54239
|
} catch (error) {
|
|
54080
|
-
|
|
54240
|
+
log12.error("effects:error", {
|
|
54081
54241
|
traitName,
|
|
54082
54242
|
transition: `${previousState}->${newState}`,
|
|
54083
54243
|
event: flushEvent,
|
|
@@ -54086,14 +54246,16 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
54086
54246
|
});
|
|
54087
54247
|
}
|
|
54088
54248
|
return emittedDuringExec;
|
|
54089
|
-
}, [eventBus, flushSlot]);
|
|
54249
|
+
}, [eventBus, flushSlot, sharedEntityStore]);
|
|
54090
54250
|
const runTickEffects = React105.useCallback((tick, binding) => {
|
|
54091
54251
|
const traitName = binding.trait.name;
|
|
54092
54252
|
const currentState = traitStatesRef.current.get(traitName)?.currentState ?? "";
|
|
54093
54253
|
if (tick.appliesTo.length > 0 && !tick.appliesTo.includes(currentState)) return;
|
|
54094
54254
|
if (tick.guard !== void 0) {
|
|
54255
|
+
const sharedKey = sharedKeyByTraitNameRef.current.get(traitName);
|
|
54256
|
+
const entity = sharedKey !== void 0 ? sharedEntityStore.getSnapshot(sharedKey) : traitFieldStatesRef.current.get(traitName) ?? {};
|
|
54095
54257
|
const guardCtx = {
|
|
54096
|
-
entity
|
|
54258
|
+
entity,
|
|
54097
54259
|
payload: {},
|
|
54098
54260
|
state: currentState
|
|
54099
54261
|
};
|
|
@@ -54118,10 +54280,46 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
54118
54280
|
syncOnly: true,
|
|
54119
54281
|
log: tickLog
|
|
54120
54282
|
});
|
|
54121
|
-
}, [executeTransitionEffects]);
|
|
54283
|
+
}, [executeTransitionEffects, sharedEntityStore]);
|
|
54284
|
+
const emitFromSharedWriter = React105.useCallback((event, payload) => {
|
|
54285
|
+
const prefixedEvent = event.startsWith("UI:") ? event : `UI:${event}`;
|
|
54286
|
+
eventBus.emit(prefixedEvent, payload);
|
|
54287
|
+
}, [eventBus]);
|
|
54122
54288
|
React105.useEffect(() => {
|
|
54123
54289
|
const scheduler = runtime.createTickScheduler();
|
|
54290
|
+
const writerTraitNames = /* @__PURE__ */ new Set();
|
|
54291
|
+
for (const group of sharedGroups.values()) {
|
|
54292
|
+
const ticksByInterval = /* @__PURE__ */ new Map();
|
|
54293
|
+
for (const binding of group.writerBindings) {
|
|
54294
|
+
writerTraitNames.add(binding.trait.name);
|
|
54295
|
+
for (const tick of binding.trait.ticks ?? []) {
|
|
54296
|
+
const intervalKey = String(tick.interval);
|
|
54297
|
+
const entries = ticksByInterval.get(intervalKey) ?? [];
|
|
54298
|
+
entries.push({ binding, tick });
|
|
54299
|
+
ticksByInterval.set(intervalKey, entries);
|
|
54300
|
+
}
|
|
54301
|
+
}
|
|
54302
|
+
for (const entries of ticksByInterval.values()) {
|
|
54303
|
+
const interval = entries[0].tick.interval;
|
|
54304
|
+
const onDue = () => {
|
|
54305
|
+
const writers = entries.map(
|
|
54306
|
+
({ binding, tick }) => createSharedEntityWriter(binding, tick, traitStatesRef, emitFromSharedWriter)
|
|
54307
|
+
);
|
|
54308
|
+
runTickFrame(group.storeKey, writers, sharedEntityStore);
|
|
54309
|
+
};
|
|
54310
|
+
if (interval === "frame") {
|
|
54311
|
+
scheduler.add(0, onDue);
|
|
54312
|
+
} else if (typeof interval === "number") {
|
|
54313
|
+
scheduler.add(interval, onDue);
|
|
54314
|
+
} else if (runtime.isValidCronExpression(interval)) {
|
|
54315
|
+
scheduler.addCron(interval, onDue);
|
|
54316
|
+
} else {
|
|
54317
|
+
scheduler.add(runtime.parseDurationString(interval), onDue);
|
|
54318
|
+
}
|
|
54319
|
+
}
|
|
54320
|
+
}
|
|
54124
54321
|
for (const binding of traitBindings) {
|
|
54322
|
+
if (writerTraitNames.has(binding.trait.name)) continue;
|
|
54125
54323
|
for (const tick of binding.trait.ticks ?? []) {
|
|
54126
54324
|
if (tick.interval === "frame") {
|
|
54127
54325
|
scheduler.add(0, () => runTickEffects(tick, binding));
|
|
@@ -54135,7 +54333,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
54135
54333
|
}
|
|
54136
54334
|
}
|
|
54137
54335
|
return () => scheduler.stopAll();
|
|
54138
|
-
}, [traitBindings, runTickEffects]);
|
|
54336
|
+
}, [traitBindings, runTickEffects, sharedGroups, sharedEntityStore, emitFromSharedWriter]);
|
|
54139
54337
|
const processEventQueued = React105.useCallback(async (eventKey, payload) => {
|
|
54140
54338
|
const normalizedEvent = normalizeEventKey(eventKey);
|
|
54141
54339
|
const bindings = traitBindingsRef.current;
|
|
@@ -54479,7 +54677,7 @@ function buildOrbitalsByTrait(schema, resolvedPages = []) {
|
|
|
54479
54677
|
// runtime/OrbPreview.tsx
|
|
54480
54678
|
init_verificationRegistry();
|
|
54481
54679
|
var PERF_NAMESPACE = "almadar:perf:canvas";
|
|
54482
|
-
var
|
|
54680
|
+
var log9 = logger.createLogger(PERF_NAMESPACE);
|
|
54483
54681
|
var RING_SIZE = 50;
|
|
54484
54682
|
var ring = [];
|
|
54485
54683
|
var writeIdx = 0;
|
|
@@ -54530,7 +54728,7 @@ function perfEnd(name, startToken, detail) {
|
|
|
54530
54728
|
}
|
|
54531
54729
|
}
|
|
54532
54730
|
push({ name, durationMs, ts: endTs, detail });
|
|
54533
|
-
|
|
54731
|
+
log9.debug(name, () => ({ durationMs, ...detail ?? {} }));
|
|
54534
54732
|
}
|
|
54535
54733
|
var profilerOnRender = (id, phase, actualDuration, baseDuration, _startTime, commitTime) => {
|
|
54536
54734
|
if (!isEnabled()) return;
|
|
@@ -54540,7 +54738,7 @@ var profilerOnRender = (id, phase, actualDuration, baseDuration, _startTime, com
|
|
|
54540
54738
|
ts: commitTime,
|
|
54541
54739
|
detail: { baseDuration }
|
|
54542
54740
|
});
|
|
54543
|
-
|
|
54741
|
+
log9.debug(`profiler:${id}:${phase}`, () => ({ actualDuration, baseDuration }));
|
|
54544
54742
|
};
|
|
54545
54743
|
|
|
54546
54744
|
// lib/prepareSchemaForPreview.ts
|
|
@@ -55182,7 +55380,7 @@ init_useEventBus();
|
|
|
55182
55380
|
// components/avl/hooks/useCanvasDnd.tsx
|
|
55183
55381
|
init_useEventBus();
|
|
55184
55382
|
init_useAlmadarDndCollision();
|
|
55185
|
-
var
|
|
55383
|
+
var log10 = logger.createLogger("almadar:ui:canvas-dnd");
|
|
55186
55384
|
function useCanvasDraggable({
|
|
55187
55385
|
id,
|
|
55188
55386
|
payload,
|
|
@@ -55221,7 +55419,7 @@ function defaultEmit(eventBus, drop) {
|
|
|
55221
55419
|
if (payload.kind === "pattern") {
|
|
55222
55420
|
const patternType = payload.data["type"];
|
|
55223
55421
|
if (typeof patternType !== "string") {
|
|
55224
|
-
|
|
55422
|
+
log10.warn("default-emit:pattern:missing-type");
|
|
55225
55423
|
return;
|
|
55226
55424
|
}
|
|
55227
55425
|
const out = { patternType, containerNode: target.containerNode };
|
|
@@ -55230,23 +55428,23 @@ function defaultEmit(eventBus, drop) {
|
|
|
55230
55428
|
out.index = resolved.index;
|
|
55231
55429
|
}
|
|
55232
55430
|
eventBus.emit("UI:PATTERN_DROP", out);
|
|
55233
|
-
|
|
55431
|
+
log10.info("default-emit:pattern", { patternType, level: target.level });
|
|
55234
55432
|
return;
|
|
55235
55433
|
}
|
|
55236
55434
|
if (payload.kind === "behavior") {
|
|
55237
55435
|
const behaviorName = payload.data["name"];
|
|
55238
55436
|
if (typeof behaviorName !== "string") {
|
|
55239
|
-
|
|
55437
|
+
log10.warn("default-emit:behavior:missing-name");
|
|
55240
55438
|
return;
|
|
55241
55439
|
}
|
|
55242
55440
|
eventBus.emit("UI:BEHAVIOR_DROP", {
|
|
55243
55441
|
behaviorName,
|
|
55244
55442
|
containerNode: target.containerNode
|
|
55245
55443
|
});
|
|
55246
|
-
|
|
55444
|
+
log10.info("default-emit:behavior", { behaviorName, level: target.level });
|
|
55247
55445
|
return;
|
|
55248
55446
|
}
|
|
55249
|
-
|
|
55447
|
+
log10.debug("default-emit:unhandled-kind", { kind: payload.kind });
|
|
55250
55448
|
}
|
|
55251
55449
|
function CanvasDndProvider({
|
|
55252
55450
|
children,
|
|
@@ -55262,9 +55460,9 @@ function CanvasDndProvider({
|
|
|
55262
55460
|
if (payload) {
|
|
55263
55461
|
setActivePayload(payload);
|
|
55264
55462
|
eventBus.emit("UI:DRAG_START", { kind: payload.kind, data: payload.data });
|
|
55265
|
-
|
|
55463
|
+
log10.info("dragStart", { id: e.active.id, kind: payload.kind });
|
|
55266
55464
|
} else {
|
|
55267
|
-
|
|
55465
|
+
log10.warn("dragStart:missing-payload", { id: e.active.id });
|
|
55268
55466
|
}
|
|
55269
55467
|
}, [eventBus]);
|
|
55270
55468
|
const handleDragEnd = React105__namespace.default.useCallback((e) => {
|
|
@@ -55274,7 +55472,7 @@ function CanvasDndProvider({
|
|
|
55274
55472
|
const overData = e.over?.data.current;
|
|
55275
55473
|
const target = overData?.target;
|
|
55276
55474
|
const accepts = overData?.accepts;
|
|
55277
|
-
|
|
55475
|
+
log10.info("dragEnd", {
|
|
55278
55476
|
activeId: e.active.id,
|
|
55279
55477
|
overId: e.over?.id,
|
|
55280
55478
|
hasPayload: !!payload,
|
|
@@ -55286,7 +55484,7 @@ function CanvasDndProvider({
|
|
|
55286
55484
|
}
|
|
55287
55485
|
if (!payload || !target) return;
|
|
55288
55486
|
if (accepts && !accepts.includes(payload.kind)) {
|
|
55289
|
-
|
|
55487
|
+
log10.debug("dragEnd:rejected:kind", { kind: payload.kind, accepts: [...accepts] });
|
|
55290
55488
|
return;
|
|
55291
55489
|
}
|
|
55292
55490
|
const activator = e.activatorEvent;
|
|
@@ -55298,7 +55496,7 @@ function CanvasDndProvider({
|
|
|
55298
55496
|
}, [eventBus, onDrop]);
|
|
55299
55497
|
const handleDragCancel = React105__namespace.default.useCallback(() => {
|
|
55300
55498
|
setActivePayload(null);
|
|
55301
|
-
|
|
55499
|
+
log10.info("dragCancel");
|
|
55302
55500
|
}, []);
|
|
55303
55501
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
55304
55502
|
core$1.DndContext,
|
|
@@ -57131,7 +57329,7 @@ init_AvlTransitionLane();
|
|
|
57131
57329
|
init_AvlSwimLane();
|
|
57132
57330
|
init_avl_atom_types();
|
|
57133
57331
|
init_avl_elk_layout();
|
|
57134
|
-
var
|
|
57332
|
+
var log11 = logger.createLogger("almadar:ui:avl:trait-scene");
|
|
57135
57333
|
var SWIM_GUTTER2 = 120;
|
|
57136
57334
|
var CENTER_W2 = 360;
|
|
57137
57335
|
var AvlTraitScene = ({
|
|
@@ -57144,7 +57342,7 @@ var AvlTraitScene = ({
|
|
|
57144
57342
|
const dataKey = React105.useMemo(() => JSON.stringify(data), [data]);
|
|
57145
57343
|
React105.useEffect(() => {
|
|
57146
57344
|
computeTraitLayout(data).then(setLayout).catch((error) => {
|
|
57147
|
-
|
|
57345
|
+
log11.error("computeTraitLayout failed", { error: error instanceof Error ? error : String(error) });
|
|
57148
57346
|
});
|
|
57149
57347
|
}, [dataKey]);
|
|
57150
57348
|
if (!layout) {
|