@almadar/runtime 4.4.3 → 4.5.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-
|
|
1
|
+
import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-32BOI7LH.js';
|
|
2
2
|
import './chunk-PZ5AY32C.js';
|
|
3
3
|
import { Router } from 'express';
|
|
4
4
|
import * as fs from 'fs';
|
|
@@ -2120,6 +2120,53 @@ function renameEventsInEffects(effects, rename) {
|
|
|
2120
2120
|
return effect;
|
|
2121
2121
|
});
|
|
2122
2122
|
}
|
|
2123
|
+
function renameEntityInRenderUiConfig(node, oldName, newName) {
|
|
2124
|
+
if (node === null || node === void 0) return node;
|
|
2125
|
+
if (Array.isArray(node)) {
|
|
2126
|
+
return node.map((item) => renameEntityInRenderUiConfig(item, oldName, newName));
|
|
2127
|
+
}
|
|
2128
|
+
if (typeof node !== "object") return node;
|
|
2129
|
+
const obj = node;
|
|
2130
|
+
const next = { ...obj };
|
|
2131
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2132
|
+
if (key === "entity" && value === oldName) {
|
|
2133
|
+
next[key] = newName;
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
2136
|
+
next[key] = renameEntityInRenderUiConfig(value, oldName, newName);
|
|
2137
|
+
}
|
|
2138
|
+
return next;
|
|
2139
|
+
}
|
|
2140
|
+
function renameEntityInEffects(effects, oldName, newName) {
|
|
2141
|
+
return effects.map((effect) => {
|
|
2142
|
+
if (!Array.isArray(effect)) return effect;
|
|
2143
|
+
if (effect[0] === "render-ui" && effect.length >= 3) {
|
|
2144
|
+
const [op, slot, config, ...rest] = effect;
|
|
2145
|
+
const nextConfig = renameEntityInRenderUiConfig(config, oldName, newName);
|
|
2146
|
+
return [op, slot, nextConfig, ...rest];
|
|
2147
|
+
}
|
|
2148
|
+
return effect;
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
function applyLinkedEntityRename(trait, linkedEntity) {
|
|
2152
|
+
const atomLinked = trait.linkedEntity;
|
|
2153
|
+
if (!linkedEntity || !atomLinked || linkedEntity === atomLinked) return trait;
|
|
2154
|
+
const sm = trait.stateMachine;
|
|
2155
|
+
if (!sm) return { ...trait, linkedEntity };
|
|
2156
|
+
const nextTransitions = (sm.transitions ?? []).map((t) => {
|
|
2157
|
+
const nextEffects = t.effects ? renameEntityInEffects(
|
|
2158
|
+
t.effects,
|
|
2159
|
+
atomLinked,
|
|
2160
|
+
linkedEntity
|
|
2161
|
+
) : t.effects;
|
|
2162
|
+
return { ...t, effects: nextEffects };
|
|
2163
|
+
});
|
|
2164
|
+
return {
|
|
2165
|
+
...trait,
|
|
2166
|
+
linkedEntity,
|
|
2167
|
+
stateMachine: { ...sm, transitions: nextTransitions }
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2123
2170
|
function applyEventRenames(trait, renames) {
|
|
2124
2171
|
if (!renames || Object.keys(renames).length === 0) return trait;
|
|
2125
2172
|
const rename = (k) => k !== void 0 && k in renames ? renames[k] : k;
|
|
@@ -2425,7 +2472,8 @@ var ReferenceResolver = class {
|
|
|
2425
2472
|
};
|
|
2426
2473
|
}
|
|
2427
2474
|
const baseTrait = overrideName ? { ...trait, name: overrideName } : trait;
|
|
2428
|
-
const
|
|
2475
|
+
const reboundTrait = applyLinkedEntityRename(baseTrait, linkedEntity);
|
|
2476
|
+
const renamedTrait = applyEventRenames(reboundTrait, eventRenames);
|
|
2429
2477
|
return {
|
|
2430
2478
|
success: true,
|
|
2431
2479
|
data: {
|
|
@@ -2440,7 +2488,8 @@ var ReferenceResolver = class {
|
|
|
2440
2488
|
const localTrait = this.localTraits.get(ref);
|
|
2441
2489
|
if (localTrait) {
|
|
2442
2490
|
const baseLocal = overrideName ? { ...localTrait, name: overrideName } : localTrait;
|
|
2443
|
-
const
|
|
2491
|
+
const reboundLocal = applyLinkedEntityRename(baseLocal, linkedEntity);
|
|
2492
|
+
const renamedLocalTrait = applyEventRenames(reboundLocal, eventRenames);
|
|
2444
2493
|
return {
|
|
2445
2494
|
success: true,
|
|
2446
2495
|
data: {
|
|
@@ -2783,5 +2832,5 @@ function parseNamespacedEvent(eventName) {
|
|
|
2783
2832
|
}
|
|
2784
2833
|
|
|
2785
2834
|
export { EffectExecutor, EventBus, HANDLER_MANIFEST, StateMachineManager, containsBindings, createContextFromBindings, createInitialTraitState, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent };
|
|
2786
|
-
//# sourceMappingURL=chunk-
|
|
2787
|
-
//# sourceMappingURL=chunk-
|
|
2835
|
+
//# sourceMappingURL=chunk-32BOI7LH.js.map
|
|
2836
|
+
//# sourceMappingURL=chunk-32BOI7LH.js.map
|