@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.26

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 (107) hide show
  1. package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
  2. package/dist/core-cPQWYD4K.cjs +1 -0
  3. package/dist/debug/api/Raph.cjs +1 -1
  4. package/dist/debug/api/Raph.js +46 -47
  5. package/dist/debug/api/RaphFacadeSession.cjs +1 -1
  6. package/dist/debug/api/RaphFacadeSession.js +85 -89
  7. package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
  8. package/dist/debug/api/RaphReactivityInstance.js +27 -30
  9. package/dist/debug/path/DataPath.cjs +1 -1
  10. package/dist/debug/path/DataPath.js +198 -202
  11. package/dist/debug/path/PathRouter.cjs +1 -1
  12. package/dist/debug/path/PathRouter.js +44 -50
  13. package/dist/debug/path/RaphKernel.cjs +1 -1
  14. package/dist/debug/path/RaphKernel.js +257 -228
  15. package/dist/debug/path/data-path.utils.cjs +1 -1
  16. package/dist/debug/path/data-path.utils.js +41 -41
  17. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
  18. package/dist/debug/path/derived/DerivedRegistry.js +52 -66
  19. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
  20. package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
  21. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
  22. package/dist/debug/path/derived/derived-collection.utils.js +70 -70
  23. package/dist/debug/path/meta/MetaController.cjs +1 -1
  24. package/dist/debug/path/meta/MetaController.js +57 -65
  25. package/dist/debug/path/meta/RaphMeta.cjs +1 -1
  26. package/dist/debug/path/meta/RaphMeta.js +26 -32
  27. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
  28. package/dist/debug/path/meta/RaphMetaStore.js +24 -30
  29. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
  30. package/dist/debug/path/storage/AdapterPathStore.js +49 -54
  31. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
  32. package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
  33. package/dist/debug/path/storage/PathEventHub.cjs +1 -1
  34. package/dist/debug/path/storage/PathEventHub.js +74 -61
  35. package/dist/debug/path/storage/PathStore.cjs +1 -1
  36. package/dist/debug/path/storage/PathStore.js +89 -99
  37. package/dist/debug/path/storage/createDataDraft.cjs +1 -1
  38. package/dist/debug/path/storage/createDataDraft.js +24 -28
  39. package/dist/debug/reactivity/disposal.cjs +1 -0
  40. package/dist/debug/reactivity/disposal.js +32 -0
  41. package/dist/debug/reactivity/engine.cjs +1 -1
  42. package/dist/debug/reactivity/engine.js +787 -392
  43. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  44. package/dist/debug/reactivity/reactive-object.js +81 -96
  45. package/dist/debug/reactivity/scope.cjs +1 -1
  46. package/dist/debug/reactivity/scope.js +221 -117
  47. package/dist/debug/reactivity/watch.cjs +1 -1
  48. package/dist/debug/reactivity/watch.js +1 -1
  49. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  50. package/dist/debug/runtime/RaphRuntime.js +764 -411
  51. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  52. package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
  53. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
  54. package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
  55. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  56. package/dist/debug/runtime/ownership/RaphNode.js +595 -136
  57. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  58. package/dist/debug/runtime/ownership/RaphScope.js +203 -68
  59. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
  60. package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
  61. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  62. package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
  63. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  64. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  65. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  67. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
  68. package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
  69. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
  70. package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
  71. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
  79. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  81. package/dist/entrypoints/runtime.d.ts +2 -1
  82. package/dist/machine-testing.cjs +1 -1
  83. package/dist/machine-testing.js +1 -1
  84. package/dist/machine.cjs +1 -1
  85. package/dist/machine.js +216 -231
  86. package/dist/path/RaphKernel.d.ts +24 -0
  87. package/dist/path/storage/PathEventHub.d.ts +14 -0
  88. package/dist/path/storage/PathStore.d.ts +4 -4
  89. package/dist/reactivity/disposal.d.ts +14 -0
  90. package/dist/reactivity/engine.d.ts +177 -4
  91. package/dist/reactivity/scope.d.ts +108 -30
  92. package/dist/runtime/RaphRuntime.d.ts +236 -17
  93. package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
  94. package/dist/runtime/ownership/RaphNode.d.ts +276 -6
  95. package/dist/runtime/ownership/RaphScope.d.ts +144 -14
  96. package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
  97. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  98. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  99. package/dist/runtime/phases/phase.types.d.ts +83 -4
  100. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  101. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
  102. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
  103. package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
  104. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  105. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
  106. package/package.json +10 -2
  107. package/dist/core-ugchZNqC.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var l=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var a=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../ownership/RaphNode.cjs"),p=Object.freeze(["action","machine","error"]),v=1024;class b{constructor(e){a(this,"_capacity",v);a(this,"_context","none");a(this,"_guards","failed");a(this,"_include",new Set(p));a(this,"_enabled",!1);a(this,"_events");a(this,"_eventStart",0);a(this,"_eventSize",0);a(this,"_sequence",0);a(this,"_operationSequence",0);a(this,"_machines");a(this,"trace");a(this,"machines");const t=e==null?void 0:e.trace;t!==void 0&&t!==!1&&(this._applyOptions(t),this._enabled=!0,this._ensureBuffer()),this.trace=Object.freeze({clear:()=>this.clear(),read:s=>this.read(s),start:s=>this.start(s),status:()=>this.status(),stop:()=>this.stop()}),this.machines=Object.freeze({list:()=>this.listMachines(),snapshot:s=>this.machineSnapshot(s)})}start(e){e!==void 0&&this._applyOptions(e),this._enabled=!0,this._ensureBuffer()}stop(){this._enabled=!1}clear(){var e;(e=this._events)==null||e.fill(void 0),this._eventStart=0,this._eventSize=0}read(e={}){const t=e.since??-1,s=e.limit??Number.POSITIVE_INFINITY;if(!Number.isFinite(s)&&s!==Number.POSITIVE_INFINITY)throw new TypeError("[Raph] Trace limit must be a positive integer.");if(s!==Number.POSITIVE_INFINITY&&(!Number.isInteger(s)||s<0))throw new TypeError("[Raph] Trace limit must be a positive integer.");const n=this._events;if(n===void 0||this._eventSize===0||s===0)return Object.freeze([]);const d=[];for(let r=0;r<this._eventSize;r++){const c=n[(this._eventStart+r)%this._capacity];if(!(c===void 0||c.sequence<=t)&&(d.push(c),d.length>=s))break}return Object.freeze(d)}status(){return Object.freeze({capacity:this._capacity,context:this._context,enabled:this._enabled,guards:this._guards,include:Object.freeze([...this._include]),size:this._eventSize})}nextOperationId(e){if(!(!this._enabled||!this._include.has(e)))return++this._operationSequence}traces(e){return this._enabled&&this._include.has(e)}record(e){if(!this._enabled||!this._include.has(e.kind)||e.guard!==void 0&&(this._guards==="none"||this._guards==="failed"&&e.guard!=="failed"))return;const t=Object.freeze({...e.causeId===void 0?{}:{causeId:e.causeId},...e.context===void 0||this._context==="none"?{}:{contextKeys:Object.freeze(Object.keys(e.context))},...e.details===void 0?{}:{details:Object.freeze({...e.details})},...e.guard===void 0?{}:{guard:e.guard},...e.operationId===void 0?{}:{operationId:e.operationId},...e.status===void 0?{}:{status:e.status},kind:e.kind,name:e.name,sequence:++this._sequence,timestamp:Date.now()}),s=this._ensureBuffer();if(this._eventSize<this._capacity){s[(this._eventStart+this._eventSize++)%this._capacity]=t;return}s[this._eventStart]=t,this._eventStart=(this._eventStart+1)%this._capacity}registerMachine(e){const t=this._machines??(this._machines=new Map);if(t.has(e.id))throw new Error(`[Raph] Machine diagnostic id "${e.id}" is already registered.`);return t.set(e.id,e),()=>{t.get(e.id)===e&&t.delete(e.id),t.size===0&&this._machines===t&&(this._machines=void 0)}}hasMachine(e){var t;return((t=this._machines)==null?void 0:t.has(e))??!1}listMachines(){var t;const e=[];for(const s of((t=this._machines)==null?void 0:t.values())??[]){const n=s.snapshot();e.push(Object.freeze({active:n.active,id:n.id,modelId:n.modelId,ownerId:n.ownerId,...n.parentId===void 0?{}:{parentId:n.parentId},revision:n.revision,status:n.status}))}return Object.freeze(e)}machineSnapshot(e){var t,s;return(s=(t=this._machines)==null?void 0:t.get(e))==null?void 0:s.snapshot()}get machineCount(){var e;return((e=this._machines)==null?void 0:e.size)??0}get traceSize(){return this._eventSize}get actorCount(){var t;let e=0;for(const s of((t=this._machines)==null?void 0:t.values())??[])e+=s.snapshot().actors.length;return e}machineTreeNodesByOwner(){var d;const e=[...((d=this._machines)==null?void 0:d.values())??[]],t=new Map(e.map(r=>[r.id,r])),s=new Map;for(const r of e){if(r.parentId===void 0||!t.has(r.parentId))continue;const c=s.get(r.parentId)??[];c.push(r),s.set(r.parentId,c)}const n=new Map;for(const r of e){if(r.parentId!==void 0&&t.has(r.parentId))continue;const c=n.get(r.ownerId)??[];c.push(_(r,s,!1)),n.set(r.ownerId,c)}return new Map([...n].map(([r,c])=>[r,Object.freeze(c)]))}_applyOptions(e){if(e.capacity!==void 0){if(!Number.isInteger(e.capacity)||e.capacity<=0)throw new TypeError("[Raph] Trace capacity must be a positive integer.");e.capacity!==this._capacity&&(this._capacity=e.capacity,this._events=void 0,this._eventStart=0,this._eventSize=0)}if(e.context!==void 0){if(e.context!=="none"&&e.context!=="keys")throw new TypeError('[Raph] Trace context must be "none" or "keys".');this._context=e.context}if(e.guards!==void 0){if(e.guards!=="none"&&e.guards!=="failed"&&e.guards!=="all")throw new TypeError('[Raph] Trace guards must be "none", "failed" or "all".');this._guards=e.guards}if(e.include!==void 0){const t=new Set;for(const s of e.include){if(s!=="action"&&s!=="machine"&&s!=="phase"&&s!=="error")throw new TypeError(`[Raph] Unsupported trace kind "${String(s)}".`);t.add(s)}this._include=t}}_ensureBuffer(){return this._events??(this._events=new Array(this._capacity))}}function o(i){const e=i instanceof h.RaphNode?i.children.map(o):[];return Object.freeze({children:Object.freeze(e),disposed:i.disposed,id:i.id,kind:i instanceof h.RaphNode?"node":"scope",resources:i._debugResourceCount(),sources:i._debugSourceCount()})}function u(i,e=new Map){const t=i instanceof h.RaphNode?i.children.map(n=>u(n,e)):[],s=i._debugResourceCount();return s!==0&&t.push(Object.freeze({children:Object.freeze([]),count:s,id:`${i.id}:resources`,kind:"resource"})),t.push(...e.get(i.id)??[]),Object.freeze({children:Object.freeze(t),disposed:i.disposed,id:i.id,kind:i instanceof h.RaphNode?"node":"scope"})}function _(i,e,t){const s=i.snapshot();return Object.freeze({children:Object.freeze((e.get(i.id)??[]).map(n=>_(n,e,!0))),id:s.id,kind:t?"actor":"machine",status:s.status})}exports.RaphDebugController=b;exports.createOwnerSnapshot=o;exports.createOwnerTree=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../ownership/RaphNode.cjs"),_=Object.freeze(["action","machine","error"]),f=1024;class l{_capacity=f;_context="none";_guards="failed";_include=new Set(_);_enabled=!1;_events;_eventStart=0;_eventSize=0;_sequence=0;_operationSequence=0;_machines;trace;machines;constructor(e){const s=e?.trace;s!==void 0&&s!==!1&&(this._applyOptions(s),this._enabled=!0,this._ensureBuffer()),this.trace=Object.freeze({clear:()=>this.clear(),read:t=>this.read(t),start:t=>this.start(t),status:()=>this.status(),stop:()=>this.stop()}),this.machines=Object.freeze({list:()=>this.listMachines(),snapshot:t=>this.machineSnapshot(t)})}start(e){e!==void 0&&this._applyOptions(e),this._enabled=!0,this._ensureBuffer()}stop(){this._enabled=!1}clear(){this._events?.fill(void 0),this._eventStart=0,this._eventSize=0}read(e={}){const s=e.since??-1,t=e.limit??Number.POSITIVE_INFINITY;if(!Number.isFinite(t)&&t!==Number.POSITIVE_INFINITY)throw new TypeError("[Raph] Trace limit must be a positive integer.");if(t!==Number.POSITIVE_INFINITY&&(!Number.isInteger(t)||t<0))throw new TypeError("[Raph] Trace limit must be a positive integer.");const a=this._events;if(a===void 0||this._eventSize===0||t===0)return Object.freeze([]);const n=[];for(let r=0;r<this._eventSize;r++){const d=a[(this._eventStart+r)%this._capacity];if(!(d===void 0||d.sequence<=s)&&(n.push(d),n.length>=t))break}return Object.freeze(n)}status(){return Object.freeze({capacity:this._capacity,context:this._context,enabled:this._enabled,guards:this._guards,include:Object.freeze([...this._include]),size:this._eventSize})}nextOperationId(e){if(!(!this._enabled||!this._include.has(e)))return++this._operationSequence}traces(e){return this._enabled&&this._include.has(e)}record(e){if(!this._enabled||!this._include.has(e.kind)||e.guard!==void 0&&(this._guards==="none"||this._guards==="failed"&&e.guard!=="failed"))return;const s=Object.freeze({...e.causeId===void 0?{}:{causeId:e.causeId},...e.context===void 0||this._context==="none"?{}:{contextKeys:Object.freeze(Object.keys(e.context))},...e.details===void 0?{}:{details:Object.freeze({...e.details})},...e.guard===void 0?{}:{guard:e.guard},...e.operationId===void 0?{}:{operationId:e.operationId},...e.status===void 0?{}:{status:e.status},kind:e.kind,name:e.name,sequence:++this._sequence,timestamp:Date.now()}),t=this._ensureBuffer();if(this._eventSize<this._capacity){t[(this._eventStart+this._eventSize++)%this._capacity]=s;return}t[this._eventStart]=s,this._eventStart=(this._eventStart+1)%this._capacity}registerMachine(e){const s=this._machines??=new Map;if(s.has(e.id))throw new Error(`[Raph] Machine diagnostic id "${e.id}" is already registered.`);return s.set(e.id,e),()=>{s.get(e.id)===e&&s.delete(e.id),s.size===0&&this._machines===s&&(this._machines=void 0)}}hasMachine(e){return this._machines?.has(e)??!1}listMachines(){const e=[];for(const s of this._machines?.values()??[]){const t=s.snapshot();e.push(Object.freeze({active:t.active,id:t.id,modelId:t.modelId,ownerId:t.ownerId,...t.parentId===void 0?{}:{parentId:t.parentId},revision:t.revision,status:t.status}))}return Object.freeze(e)}machineSnapshot(e){return this._machines?.get(e)?.snapshot()}get machineCount(){return this._machines?.size??0}get traceSize(){return this._eventSize}get actorCount(){let e=0;for(const s of this._machines?.values()??[])e+=s.snapshot().actors.length;return e}machineTreeNodesByOwner(){const e=[...this._machines?.values()??[]],s=new Map(e.map(n=>[n.id,n])),t=new Map;for(const n of e){if(n.parentId===void 0||!s.has(n.parentId))continue;const r=t.get(n.parentId)??[];r.push(n),t.set(n.parentId,r)}const a=new Map;for(const n of e){if(n.parentId!==void 0&&s.has(n.parentId))continue;const r=a.get(n.ownerId)??[];r.push(u(n,t,!1)),a.set(n.ownerId,r)}return new Map([...a].map(([n,r])=>[n,Object.freeze(r)]))}_applyOptions(e){if(e.capacity!==void 0){if(!Number.isInteger(e.capacity)||e.capacity<=0)throw new TypeError("[Raph] Trace capacity must be a positive integer.");e.capacity!==this._capacity&&(this._capacity=e.capacity,this._events=void 0,this._eventStart=0,this._eventSize=0)}if(e.context!==void 0){if(e.context!=="none"&&e.context!=="keys")throw new TypeError('[Raph] Trace context must be "none" or "keys".');this._context=e.context}if(e.guards!==void 0){if(e.guards!=="none"&&e.guards!=="failed"&&e.guards!=="all")throw new TypeError('[Raph] Trace guards must be "none", "failed" or "all".');this._guards=e.guards}if(e.include!==void 0){const s=new Set;for(const t of e.include){if(t!=="action"&&t!=="machine"&&t!=="phase"&&t!=="error")throw new TypeError(`[Raph] Unsupported trace kind "${String(t)}".`);s.add(t)}this._include=s}}_ensureBuffer(){return this._events??=new Array(this._capacity)}}function h(i){const e=i instanceof c.RaphNode?i.children.map(h):[];return Object.freeze({children:Object.freeze(e),disposed:i.disposed,id:i.id,kind:i instanceof c.RaphNode?"node":"scope",resources:i._debugResourceCount(),sources:i._debugSourceCount()})}function o(i,e=new Map){const s=i instanceof c.RaphNode?i.children.map(a=>o(a,e)):[],t=i._debugResourceCount();return t!==0&&s.push(Object.freeze({children:Object.freeze([]),count:t,id:`${i.id}:resources`,kind:"resource"})),s.push(...e.get(i.id)??[]),Object.freeze({children:Object.freeze(s),disposed:i.disposed,id:i.id,kind:i instanceof c.RaphNode?"node":"scope"})}function u(i,e,s){const t=i.snapshot();return Object.freeze({children:Object.freeze((e.get(i.id)??[]).map(a=>u(a,e,!0))),id:t.id,kind:s?"actor":"machine",status:t.status})}exports.RaphDebugController=l;exports.createOwnerSnapshot=h;exports.createOwnerTree=o;
@@ -1,40 +1,37 @@
1
- var u = Object.defineProperty;
2
- var f = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var a = (i, e, t) => f(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { RaphNode as h } from "../ownership/RaphNode.js";
5
- const _ = Object.freeze([
1
+ import { RaphNode as c } from "../ownership/RaphNode.js";
2
+ const o = Object.freeze([
6
3
  "action",
7
4
  "machine",
8
5
  "error"
9
- ]), l = 1024;
10
- class I {
6
+ ]), u = 1024;
7
+ class p {
8
+ _capacity = u;
9
+ _context = "none";
10
+ _guards = "failed";
11
+ _include = new Set(o);
12
+ _enabled = !1;
13
+ _events;
14
+ _eventStart = 0;
15
+ _eventSize = 0;
16
+ _sequence = 0;
17
+ _operationSequence = 0;
18
+ _machines;
19
+ trace;
20
+ machines;
11
21
  /**
12
22
  * Создаёт controller; ring buffer появляется только при включённом trace.
13
23
  */
14
24
  constructor(e) {
15
- a(this, "_capacity", l);
16
- a(this, "_context", "none");
17
- a(this, "_guards", "failed");
18
- a(this, "_include", new Set(_));
19
- a(this, "_enabled", !1);
20
- a(this, "_events");
21
- a(this, "_eventStart", 0);
22
- a(this, "_eventSize", 0);
23
- a(this, "_sequence", 0);
24
- a(this, "_operationSequence", 0);
25
- a(this, "_machines");
26
- a(this, "trace");
27
- a(this, "machines");
28
- const t = e == null ? void 0 : e.trace;
29
- t !== void 0 && t !== !1 && (this._applyOptions(t), this._enabled = !0, this._ensureBuffer()), this.trace = Object.freeze({
25
+ const s = e?.trace;
26
+ s !== void 0 && s !== !1 && (this._applyOptions(s), this._enabled = !0, this._ensureBuffer()), this.trace = Object.freeze({
30
27
  clear: () => this.clear(),
31
- read: (s) => this.read(s),
32
- start: (s) => this.start(s),
28
+ read: (t) => this.read(t),
29
+ start: (t) => this.start(t),
33
30
  status: () => this.status(),
34
31
  stop: () => this.stop()
35
32
  }), this.machines = Object.freeze({
36
33
  list: () => this.listMachines(),
37
- snapshot: (s) => this.machineSnapshot(s)
34
+ snapshot: (t) => this.machineSnapshot(t)
38
35
  });
39
36
  }
40
37
  // ---------------------------------------------
@@ -56,28 +53,27 @@ class I {
56
53
  * Удаляет все накопленные events, не меняя status trace.
57
54
  */
58
55
  clear() {
59
- var e;
60
- (e = this._events) == null || e.fill(void 0), this._eventStart = 0, this._eventSize = 0;
56
+ this._events?.fill(void 0), this._eventStart = 0, this._eventSize = 0;
61
57
  }
62
58
  /**
63
59
  * Формирует immutable chronological copy ring buffer.
64
60
  */
65
61
  read(e = {}) {
66
- const t = e.since ?? -1, s = e.limit ?? Number.POSITIVE_INFINITY;
67
- if (!Number.isFinite(s) && s !== Number.POSITIVE_INFINITY)
62
+ const s = e.since ?? -1, t = e.limit ?? Number.POSITIVE_INFINITY;
63
+ if (!Number.isFinite(t) && t !== Number.POSITIVE_INFINITY)
68
64
  throw new TypeError("[Raph] Trace limit must be a positive integer.");
69
- if (s !== Number.POSITIVE_INFINITY && (!Number.isInteger(s) || s < 0))
65
+ if (t !== Number.POSITIVE_INFINITY && (!Number.isInteger(t) || t < 0))
70
66
  throw new TypeError("[Raph] Trace limit must be a positive integer.");
71
- const n = this._events;
72
- if (n === void 0 || this._eventSize === 0 || s === 0)
67
+ const a = this._events;
68
+ if (a === void 0 || this._eventSize === 0 || t === 0)
73
69
  return Object.freeze([]);
74
- const d = [];
70
+ const n = [];
75
71
  for (let r = 0; r < this._eventSize; r++) {
76
- const c = n[(this._eventStart + r) % this._capacity];
77
- if (!(c === void 0 || c.sequence <= t) && (d.push(c), d.length >= s))
72
+ const d = a[(this._eventStart + r) % this._capacity];
73
+ if (!(d === void 0 || d.sequence <= s) && (n.push(d), n.length >= t))
78
74
  break;
79
75
  }
80
- return Object.freeze(d);
76
+ return Object.freeze(n);
81
77
  }
82
78
  /**
83
79
  * Возвращает текущую конфигурацию и заполнение buffer.
@@ -115,7 +111,7 @@ class I {
115
111
  record(e) {
116
112
  if (!this._enabled || !this._include.has(e.kind) || e.guard !== void 0 && (this._guards === "none" || this._guards === "failed" && e.guard !== "failed"))
117
113
  return;
118
- const t = Object.freeze({
114
+ const s = Object.freeze({
119
115
  ...e.causeId === void 0 ? {} : { causeId: e.causeId },
120
116
  ...e.context === void 0 || this._context === "none" ? {} : { contextKeys: Object.freeze(Object.keys(e.context)) },
121
117
  ...e.details === void 0 ? {} : { details: Object.freeze({ ...e.details }) },
@@ -126,23 +122,23 @@ class I {
126
122
  name: e.name,
127
123
  sequence: ++this._sequence,
128
124
  timestamp: Date.now()
129
- }), s = this._ensureBuffer();
125
+ }), t = this._ensureBuffer();
130
126
  if (this._eventSize < this._capacity) {
131
- s[(this._eventStart + this._eventSize++) % this._capacity] = t;
127
+ t[(this._eventStart + this._eventSize++) % this._capacity] = s;
132
128
  return;
133
129
  }
134
- s[this._eventStart] = t, this._eventStart = (this._eventStart + 1) % this._capacity;
130
+ t[this._eventStart] = s, this._eventStart = (this._eventStart + 1) % this._capacity;
135
131
  }
136
132
  /**
137
133
  * Регистрирует read-only machine projection без импорта machine engine в Runtime.
138
134
  * @internal
139
135
  */
140
136
  registerMachine(e) {
141
- const t = this._machines ?? (this._machines = /* @__PURE__ */ new Map());
142
- if (t.has(e.id))
137
+ const s = this._machines ??= /* @__PURE__ */ new Map();
138
+ if (s.has(e.id))
143
139
  throw new Error(`[Raph] Machine diagnostic id "${e.id}" is already registered.`);
144
- return t.set(e.id, e), () => {
145
- t.get(e.id) === e && t.delete(e.id), t.size === 0 && this._machines === t && (this._machines = void 0);
140
+ return s.set(e.id, e), () => {
141
+ s.get(e.id) === e && s.delete(e.id), s.size === 0 && this._machines === s && (this._machines = void 0);
146
142
  };
147
143
  }
148
144
  /**
@@ -151,25 +147,23 @@ class I {
151
147
  * @internal
152
148
  */
153
149
  hasMachine(e) {
154
- var t;
155
- return ((t = this._machines) == null ? void 0 : t.has(e)) ?? !1;
150
+ return this._machines?.has(e) ?? !1;
156
151
  }
157
152
  /**
158
153
  * Возвращает compact machine summaries без выполнения guards.
159
154
  */
160
155
  listMachines() {
161
- var t;
162
156
  const e = [];
163
- for (const s of ((t = this._machines) == null ? void 0 : t.values()) ?? []) {
164
- const n = s.snapshot();
157
+ for (const s of this._machines?.values() ?? []) {
158
+ const t = s.snapshot();
165
159
  e.push(Object.freeze({
166
- active: n.active,
167
- id: n.id,
168
- modelId: n.modelId,
169
- ownerId: n.ownerId,
170
- ...n.parentId === void 0 ? {} : { parentId: n.parentId },
171
- revision: n.revision,
172
- status: n.status
160
+ active: t.active,
161
+ id: t.id,
162
+ modelId: t.modelId,
163
+ ownerId: t.ownerId,
164
+ ...t.parentId === void 0 ? {} : { parentId: t.parentId },
165
+ revision: t.revision,
166
+ status: t.status
173
167
  }));
174
168
  }
175
169
  return Object.freeze(e);
@@ -178,16 +172,14 @@ class I {
178
172
  * Читает готовый machine snapshot; transition selection и guards не вызываются.
179
173
  */
180
174
  machineSnapshot(e) {
181
- var t, s;
182
- return (s = (t = this._machines) == null ? void 0 : t.get(e)) == null ? void 0 : s.snapshot();
175
+ return this._machines?.get(e)?.snapshot();
183
176
  }
184
177
  /**
185
178
  * Возвращает число зарегистрированных machines.
186
179
  * @internal
187
180
  */
188
181
  get machineCount() {
189
- var e;
190
- return ((e = this._machines) == null ? void 0 : e.size) ?? 0;
182
+ return this._machines?.size ?? 0;
191
183
  }
192
184
  /**
193
185
  * Возвращает число текущих trace events.
@@ -198,30 +190,28 @@ class I {
198
190
  }
199
191
  /** Возвращает число child actors по уже готовым snapshots. @internal */
200
192
  get actorCount() {
201
- var t;
202
193
  let e = 0;
203
- for (const s of ((t = this._machines) == null ? void 0 : t.values()) ?? [])
194
+ for (const s of this._machines?.values() ?? [])
204
195
  e += s.snapshot().actors.length;
205
196
  return e;
206
197
  }
207
198
  /** Группирует machine/actor ветви по фактическому lifecycle owner. @internal */
208
199
  machineTreeNodesByOwner() {
209
- var d;
210
- const e = [...((d = this._machines) == null ? void 0 : d.values()) ?? []], t = new Map(e.map((r) => [r.id, r])), s = /* @__PURE__ */ new Map();
211
- for (const r of e) {
212
- if (r.parentId === void 0 || !t.has(r.parentId))
200
+ const e = [...this._machines?.values() ?? []], s = new Map(e.map((n) => [n.id, n])), t = /* @__PURE__ */ new Map();
201
+ for (const n of e) {
202
+ if (n.parentId === void 0 || !s.has(n.parentId))
213
203
  continue;
214
- const c = s.get(r.parentId) ?? [];
215
- c.push(r), s.set(r.parentId, c);
204
+ const r = t.get(n.parentId) ?? [];
205
+ r.push(n), t.set(n.parentId, r);
216
206
  }
217
- const n = /* @__PURE__ */ new Map();
218
- for (const r of e) {
219
- if (r.parentId !== void 0 && t.has(r.parentId))
207
+ const a = /* @__PURE__ */ new Map();
208
+ for (const n of e) {
209
+ if (n.parentId !== void 0 && s.has(n.parentId))
220
210
  continue;
221
- const c = n.get(r.ownerId) ?? [];
222
- c.push(o(r, s, !1)), n.set(r.ownerId, c);
211
+ const r = a.get(n.ownerId) ?? [];
212
+ r.push(h(n, t, !1)), a.set(n.ownerId, r);
223
213
  }
224
- return new Map([...n].map(([r, c]) => [r, Object.freeze(c)]));
214
+ return new Map([...a].map(([n, r]) => [n, Object.freeze(r)]));
225
215
  }
226
216
  // ---------------------------------------------
227
217
  // PRIVATE
@@ -243,55 +233,55 @@ class I {
243
233
  this._guards = e.guards;
244
234
  }
245
235
  if (e.include !== void 0) {
246
- const t = /* @__PURE__ */ new Set();
247
- for (const s of e.include) {
248
- if (s !== "action" && s !== "machine" && s !== "phase" && s !== "error")
249
- throw new TypeError(`[Raph] Unsupported trace kind "${String(s)}".`);
250
- t.add(s);
236
+ const s = /* @__PURE__ */ new Set();
237
+ for (const t of e.include) {
238
+ if (t !== "action" && t !== "machine" && t !== "phase" && t !== "error")
239
+ throw new TypeError(`[Raph] Unsupported trace kind "${String(t)}".`);
240
+ s.add(t);
251
241
  }
252
- this._include = t;
242
+ this._include = s;
253
243
  }
254
244
  }
255
245
  _ensureBuffer() {
256
- return this._events ?? (this._events = new Array(this._capacity));
246
+ return this._events ??= new Array(this._capacity);
257
247
  }
258
248
  }
259
- function p(i) {
260
- const e = i instanceof h ? i.children.map(p) : [];
249
+ function f(i) {
250
+ const e = i instanceof c ? i.children.map(f) : [];
261
251
  return Object.freeze({
262
252
  children: Object.freeze(e),
263
253
  disposed: i.disposed,
264
254
  id: i.id,
265
- kind: i instanceof h ? "node" : "scope",
255
+ kind: i instanceof c ? "node" : "scope",
266
256
  resources: i._debugResourceCount(),
267
257
  sources: i._debugSourceCount()
268
258
  });
269
259
  }
270
- function v(i, e = /* @__PURE__ */ new Map()) {
271
- const t = i instanceof h ? i.children.map((n) => v(n, e)) : [], s = i._debugResourceCount();
272
- return s !== 0 && t.push(Object.freeze({
260
+ function _(i, e = /* @__PURE__ */ new Map()) {
261
+ const s = i instanceof c ? i.children.map((a) => _(a, e)) : [], t = i._debugResourceCount();
262
+ return t !== 0 && s.push(Object.freeze({
273
263
  children: Object.freeze([]),
274
- count: s,
264
+ count: t,
275
265
  id: `${i.id}:resources`,
276
266
  kind: "resource"
277
- })), t.push(...e.get(i.id) ?? []), Object.freeze({
278
- children: Object.freeze(t),
267
+ })), s.push(...e.get(i.id) ?? []), Object.freeze({
268
+ children: Object.freeze(s),
279
269
  disposed: i.disposed,
280
270
  id: i.id,
281
- kind: i instanceof h ? "node" : "scope"
271
+ kind: i instanceof c ? "node" : "scope"
282
272
  });
283
273
  }
284
- function o(i, e, t) {
285
- const s = i.snapshot();
274
+ function h(i, e, s) {
275
+ const t = i.snapshot();
286
276
  return Object.freeze({
287
- children: Object.freeze((e.get(i.id) ?? []).map((n) => o(n, e, !0))),
288
- id: s.id,
289
- kind: t ? "actor" : "machine",
290
- status: s.status
277
+ children: Object.freeze((e.get(i.id) ?? []).map((a) => h(a, e, !0))),
278
+ id: t.id,
279
+ kind: s ? "actor" : "machine",
280
+ status: t.status
291
281
  });
292
282
  }
293
283
  export {
294
- I as RaphDebugController,
295
- p as createOwnerSnapshot,
296
- v as createOwnerTree
284
+ p as RaphDebugController,
285
+ f as createOwnerSnapshot,
286
+ _ as createOwnerTree
297
287
  };
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var l=(i,e,s)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s;var o=(i,e,s)=>l(i,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../errors.cjs");class d{constructor(e,s=null){o(this,"_registrations");o(this,"_children");o(this,"_selfPaused",!1);o(this,"_ancestorPauses",0);o(this,"_disposed",!1);o(this,"_releaseOwner");o(this,"_parent");if(this._owner=e,e._assertAlive(),(s==null?void 0:s.disposed)===!0)throw new _.RaphDisposedError("[Raph] Parent effect scope is disposed.");if(s!==null&&s._owner.runtime!==e.runtime)throw new TypeError("[Raph] Parent effect scope belongs to another runtime.");this._parent=s,s==null||s._addChild(this),this._ancestorPauses=(s==null?void 0:s.paused)===!0?1:0,this._releaseOwner=e.own(()=>this.dispose())}get paused(){return this._selfPaused||this._ancestorPauses!==0}get disposed(){return this._disposed}fork(e){return this._assertAlive(),new d(e,this)}effect(e,s,t){return this._assertAlive(),this._add(this._owner.runtime._effectRegistration(this._owner,e,s,t,this.paused))}watch(e,s,t,r){return this._assertAlive(),this._add(this._owner.runtime._watchRegistration(this._owner,e,s,t,r,this.paused))}pause(){this._assertAlive(),this._owner.runtime._runPhaseTransition(()=>this._pause())}resume(){this._assertAlive(),this._owner.runtime._runPhaseTransition(()=>this._resume())}_pause(){if(this._selfPaused)return;const e=this.paused;if(this._selfPaused=!0,e)return;const s=[];for(const t of this._registrations??[])try{t.registration.pause()}catch(r){s.push(r)}for(const t of this._children??[])try{t._changeAncestorPause(1)}catch(r){s.push(r)}n(s,"[Raph] Pausable effect scope pause failed.")}_resume(){if(!this._selfPaused||(this._selfPaused=!1,this.paused))return;const e=[];for(const s of this._registrations??[])try{s.registration.resume()}catch(t){e.push(t)}for(const s of this._children??[])try{s._changeAncestorPause(-1)}catch(t){e.push(t)}n(e,"[Raph] Pausable effect scope resume failed.")}dispose(){var t,r,a,u;if(this._disposed)return;this._disposed=!0;const e=this._owner.disposed,s=[];for(const h of[...this._children??[]])try{h.dispose()}catch(c){s.push(c)}(t=this._children)==null||t.clear(),this._children=void 0;for(const h of this._registrations??[])if(h.active=!1,!e)try{h.registration.dispose()}catch(c){s.push(c)}if((r=this._registrations)==null||r.clear(),this._registrations=void 0,(u=(a=this._parent)==null?void 0:a._children)==null||u.delete(this),!e)try{this._releaseOwner()}catch(h){s.push(h)}n(s,"[Raph] Pausable effect scope disposal failed.")}_add(e){if(this._disposed||this._owner.disposed)return e.dispose(),p;const s={active:!0,registration:e};return(this._registrations??(this._registrations=new Set)).add(s),()=>{var t;s.active&&(s.active=!1,(t=this._registrations)==null||t.delete(s),e.dispose())}}_assertAlive(){if(this._disposed||this._owner.disposed)throw new _.RaphDisposedError("[Raph] Pausable effect scope is disposed.")}_addChild(e){(this._children??(this._children=new Set)).add(e)}_changeAncestorPause(e){if(this._disposed)return;const s=this.paused;if(this._ancestorPauses+=e,this._ancestorPauses<0)throw this._ancestorPauses=0,new Error("[Raph] Effect scope ancestor pause state is unbalanced.");if(s===this.paused)return;const t=[];for(const r of this._registrations??[])try{this.paused?r.registration.pause():r.registration.resume()}catch(a){t.push(a)}for(const r of this._children??[])try{r._changeAncestorPause(e)}catch(a){t.push(a)}n(t,"[Raph] Pausable effect scope ancestor transition failed.")}}function n(i,e){if(i.length===1)throw i[0];if(i.length>1)throw new AggregateError(i,e)}function p(){}exports.RaphEffectScope=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../errors.cjs"),_=16;class c{constructor(s,e=null){if(this._owner=s,s._assertAlive(),e?.disposed===!0)throw new u.RaphDisposedError("[Raph] Parent effect scope is disposed.");if(e!==null&&e._owner.runtime!==s.runtime)throw new TypeError("[Raph] Parent effect scope belongs to another runtime.");this._parent=e,e?._addChild(this),this._ancestorPauses=e?.paused===!0?1:0,this._releaseOwner=s.own(()=>this.dispose())}_registrations;_pruneAt=_;_children;_selfPaused=!1;_ancestorPauses=0;_disposed=!1;_releaseOwner;_parent;get paused(){return this._selfPaused||this._ancestorPauses!==0}get disposed(){return this._disposed}fork(s){return this._assertAlive(),new c(s,this)}effect(s,e,t){return this._assertAlive(),this._add(this._owner.runtime._effectRegistration(this._owner,s,e,t,this.paused))}bindEffect(s,e,t){this._assertAlive(),this._track(this._owner.runtime._effectRegistration(this._owner,s,e,t,this.paused,!0))}effectGroup(s,e,t,r,i){this._assertAlive();const o=this._owner.runtime._effectGroupRegistration(this._owner,s,e,t,r,i,this.paused);return this._track(o),o}watch(s,e,t,r){return this._assertAlive(),this._add(this._owner.runtime._watchRegistration(this._owner,s,e,t,r,this.paused))}_registerEffect(s,e,t,r,i,o){this._assertAlive();const h=this._owner.runtime._effectRegistration(this._owner,s,e,t,this.paused,r,i,o);o?.()||this._track(h)}_registerWatch(s,e,t,r,i,o){this._assertAlive();const h=this._owner.runtime._watchRegistration(this._owner,s,e,t,r,this.paused,i,o);o?.()||this._track(h)}_registerEffectGroup(s,e,t,r,i){this._assertAlive();const o=this._owner.runtime._effectGroupRegistration(this._owner,s,e,t,r,i,this.paused);return this._track(o),o}pause(){this._assertAlive(),this._owner.runtime._runPhaseTransition(()=>this._pause())}resume(){this._assertAlive(),this._owner.runtime._runPhaseTransition(()=>this._resume())}_pause(){if(this._selfPaused)return;const s=this.paused;if(this._selfPaused=!0,s)return;const e=[];for(const t of this._registrations??[])try{t.registration.pause()}catch(r){e.push(r)}for(const t of this._children??[])try{t._changeAncestorPause(1)}catch(r){e.push(r)}n(e,"[Raph] Pausable effect scope pause failed.")}_resume(){if(!this._selfPaused||(this._selfPaused=!1,this.paused))return;const s=[];for(const e of this._registrations??[])try{e.registration.resume()}catch(t){s.push(t)}for(const e of this._children??[])try{e._changeAncestorPause(-1)}catch(t){s.push(t)}n(s,"[Raph] Pausable effect scope resume failed.")}dispose(){if(this._disposed)return;this._disposed=!0;const s=this._owner.disposed,e=[];for(const t of[...this._children??[]])try{t.dispose()}catch(r){e.push(r)}this._children?.clear(),this._children=void 0;for(const t of this._registrations??[])if(t.active=!1,!s)try{t.registration.dispose()}catch(r){e.push(r)}if(this._registrations?.clear(),this._registrations=void 0,this._parent?._children?.delete(this),!s)try{this._releaseOwner()}catch(t){e.push(t)}n(e,"[Raph] Pausable effect scope disposal failed.")}_add(s){const e=this._track(s);return e===void 0?d:()=>{e.active&&(e.active=!1,this._registrations?.delete(e),e.registration.dispose())}}_track(s){if(this._disposed||this._owner.disposed){s.dispose();return}const e={active:!0,registration:s},t=this._registrations??=new Set;return t.add(e),t.size>=this._pruneAt&&this._prune(t),e}_prune(s){for(const e of s)e.registration.active||(e.active=!1,s.delete(e));this._pruneAt=Math.max(_,s.size*2)}_assertAlive(){if(this._disposed||this._owner.disposed)throw new u.RaphDisposedError("[Raph] Pausable effect scope is disposed.")}_addChild(s){(this._children??=new Set).add(s)}_changeAncestorPause(s){if(this._disposed)return;const e=this.paused;if(this._ancestorPauses+=s,this._ancestorPauses<0)throw this._ancestorPauses=0,new Error("[Raph] Effect scope ancestor pause state is unbalanced.");if(e===this.paused)return;const t=[];for(const r of this._registrations??[])try{this.paused?r.registration.pause():r.registration.resume()}catch(i){t.push(i)}for(const r of this._children??[])try{r._changeAncestorPause(s)}catch(i){t.push(i)}n(t,"[Raph] Pausable effect scope ancestor transition failed.")}}function n(a,s){if(a.length===1)throw a[0];if(a.length>1)throw new AggregateError(a,s)}function d(){}exports.RaphEffectScope=c;