@almadar/runtime 2.2.1 → 2.3.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 { I as IEventBus } from './types-E5o2Jqe6.js';
1
+ import { I as IEventBus } from './types-BrbvZxzX.js';
2
2
 
3
3
  /**
4
4
  * ServerBridge - Client-Server Trait Communication
@@ -226,6 +226,11 @@ function createContextFromBindings(bindings, strictBindings) {
226
226
  if (strictBindings) {
227
227
  ctx.strictBindings = true;
228
228
  }
229
+ for (const [key, value] of Object.entries(bindings)) {
230
+ if (key !== "entity" && key !== "payload" && key !== "state" && key !== "config" && key !== "user" && value != null) {
231
+ ctx.singletons.set(key, value);
232
+ }
233
+ }
229
234
  return ctx;
230
235
  }
231
236
  function findInitialState(trait) {
@@ -544,8 +549,8 @@ var StateMachineManager = class {
544
549
 
545
550
  // src/types.ts
546
551
  var HANDLER_MANIFEST = {
547
- client: ["render-ui", "render", "navigate", "notify", "emit", "set", "log"],
548
- server: ["persist", "fetch", "call-service", "emit", "set", "spawn", "despawn", "log", "os/watch-files", "os/watch-process", "os/watch-port", "os/watch-http", "os/watch-cron", "os/watch-signal", "os/watch-env", "os/debounce"],
552
+ client: ["render-ui", "render", "navigate", "notify", "emit", "set", "log", "ref", "deref", "watch"],
553
+ server: ["persist", "fetch", "call-service", "emit", "set", "spawn", "despawn", "log", "ref", "deref", "swap!", "atomic", "os/watch-files", "os/watch-process", "os/watch-port", "os/watch-http", "os/watch-cron", "os/watch-signal", "os/watch-env", "os/debounce"],
549
554
  test: [
550
555
  "render-ui",
551
556
  "render",
@@ -558,9 +563,14 @@ var HANDLER_MANIFEST = {
558
563
  "call-service",
559
564
  "spawn",
560
565
  "despawn",
561
- "log"
566
+ "log",
567
+ "ref",
568
+ "deref",
569
+ "swap!",
570
+ "watch",
571
+ "atomic"
562
572
  ],
563
- ssr: ["render-ui", "render", "fetch", "emit", "set", "log"]
573
+ ssr: ["render-ui", "render", "fetch", "emit", "set", "log", "ref", "deref"]
564
574
  };
565
575
 
566
576
  // src/EffectExecutor.ts
@@ -645,7 +655,12 @@ var EffectExecutor = class {
645
655
  "render": this.handlers.renderUI,
646
656
  "navigate": this.handlers.navigate,
647
657
  "notify": this.handlers.notify,
648
- "log": this.handlers.log
658
+ "log": this.handlers.log,
659
+ "ref": this.handlers.ref,
660
+ "deref": this.handlers.deref,
661
+ "swap!": this.handlers.swap,
662
+ "watch": this.handlers.watch,
663
+ "atomic": this.handlers.atomic
649
664
  };
650
665
  for (const [name, handler] of Object.entries(handlerMap)) {
651
666
  if (handler) {
@@ -787,6 +802,70 @@ var EffectExecutor = class {
787
802
  }
788
803
  break;
789
804
  }
805
+ // === Resource Operators ===
806
+ case "ref": {
807
+ if (this.handlers.ref) {
808
+ const refEntityType = args[0];
809
+ const refOptions = args[1];
810
+ await this.handlers.ref(refEntityType, refOptions);
811
+ } else if (this.handlers.fetch) {
812
+ const refEntityType = args[0];
813
+ const refOptions = args[1];
814
+ await this.handlers.fetch(refEntityType, refOptions);
815
+ } else {
816
+ this.logUnsupported("ref");
817
+ }
818
+ break;
819
+ }
820
+ case "deref": {
821
+ if (this.handlers.deref) {
822
+ const derefEntityType = args[0];
823
+ const derefOptions = args[1];
824
+ await this.handlers.deref(derefEntityType, derefOptions);
825
+ } else if (this.handlers.fetch) {
826
+ const derefEntityType = args[0];
827
+ const derefOptions = args[1];
828
+ await this.handlers.fetch(derefEntityType, derefOptions);
829
+ } else {
830
+ this.logUnsupported("deref");
831
+ }
832
+ break;
833
+ }
834
+ case "swap!": {
835
+ if (this.handlers.swap) {
836
+ const swapEntityType = args[0];
837
+ const swapEntityId = args[1];
838
+ const swapTransform = args[2];
839
+ await this.handlers.swap(swapEntityType, swapEntityId, swapTransform);
840
+ } else {
841
+ this.logUnsupported("swap!");
842
+ }
843
+ break;
844
+ }
845
+ case "watch": {
846
+ if (this.handlers.watch) {
847
+ const watchEntityType = args[0];
848
+ const watchOptions = args[1];
849
+ this.handlers.watch(watchEntityType, watchOptions);
850
+ } else {
851
+ if (this.debug) {
852
+ console.log("[EffectExecutor] watch is a no-op on server:", args[0]);
853
+ }
854
+ }
855
+ break;
856
+ }
857
+ case "atomic": {
858
+ if (this.handlers.atomic) {
859
+ const atomicEffects = args;
860
+ await this.handlers.atomic(atomicEffects);
861
+ } else {
862
+ const atomicEffects = args;
863
+ for (const inner of atomicEffects) {
864
+ await this.execute(inner);
865
+ }
866
+ }
867
+ break;
868
+ }
790
869
  case "spawn": {
791
870
  if (this.handlers.spawn) {
792
871
  const entityType = args[0];
@@ -2180,5 +2259,5 @@ function parseNamespacedEvent(eventName) {
2180
2259
  }
2181
2260
 
2182
2261
  export { EffectExecutor, EventBus, HANDLER_MANIFEST, StateMachineManager, containsBindings, createContextFromBindings, createInitialTraitState, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isNamespacedEvent, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent };
2183
- //# sourceMappingURL=chunk-54P2HYHQ.js.map
2184
- //# sourceMappingURL=chunk-54P2HYHQ.js.map
2262
+ //# sourceMappingURL=chunk-GCRRQAGZ.js.map
2263
+ //# sourceMappingURL=chunk-GCRRQAGZ.js.map