@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.25
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/README.md +1096 -0
- package/dist/api/Raph.d.ts +59 -190
- package/dist/api/RaphFacadeSession.d.ts +90 -0
- package/dist/api/RaphReactivityInstance.d.ts +72 -0
- package/dist/api/errors.d.ts +9 -4
- package/dist/api/types.d.ts +162 -17
- package/dist/core-CClhT8WR.js +1044 -0
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +368 -367
- package/dist/debug/api/RaphFacadeSession.cjs +1 -0
- package/dist/debug/api/RaphFacadeSession.js +302 -0
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
- package/dist/debug/api/RaphReactivityInstance.js +146 -0
- package/dist/debug/api/errors.cjs +1 -1
- package/dist/debug/api/errors.js +10 -7
- package/dist/debug/path/DataPath.cjs +1 -0
- package/dist/debug/path/DataPath.js +390 -0
- package/dist/debug/path/PathRouter.cjs +1 -0
- package/dist/debug/path/PathRouter.js +80 -0
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +316 -236
- package/dist/debug/path/data-path.utils.cjs +1 -0
- package/dist/debug/path/data-path.utils.js +56 -0
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
- package/dist/debug/path/derived/DerivedRegistry.js +143 -0
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
- package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
- package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
- package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
- package/dist/debug/path/derived/derived-strategy.types.js +1 -0
- package/dist/debug/path/meta/MetaController.cjs +1 -0
- package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
- package/dist/debug/path/meta/RaphMeta.cjs +1 -0
- package/dist/debug/path/meta/RaphMeta.js +62 -0
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
- package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
- package/dist/debug/path/meta/meta.types.cjs +1 -0
- package/dist/debug/path/meta/meta.types.js +1 -0
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
- package/dist/debug/path/storage/AdapterPathStore.js +128 -0
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
- package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
- package/dist/debug/path/storage/PathEventHub.cjs +1 -0
- package/dist/debug/path/storage/PathEventHub.js +161 -0
- package/dist/debug/path/storage/PathStore.cjs +1 -0
- package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
- package/dist/debug/path/storage/createDataDraft.cjs +1 -0
- package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -28
- package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
- package/dist/debug/path/storage/data-adapter.types.js +1 -0
- package/dist/debug/reactivity/disposal.cjs +1 -0
- package/dist/debug/reactivity/disposal.js +32 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +888 -321
- package/dist/debug/reactivity/reactive-object.cjs +1 -0
- package/dist/debug/reactivity/reactive-object.js +265 -0
- package/dist/debug/reactivity/scope.cjs +1 -1
- package/dist/debug/reactivity/scope.js +221 -117
- package/dist/debug/reactivity/watch.cjs +1 -1
- package/dist/debug/reactivity/watch.js +1 -1
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +1134 -502
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -0
- package/dist/debug/runtime/errors.cjs +1 -1
- package/dist/debug/runtime/errors.js +6 -3
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphEffectScope.js +304 -0
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphNode.js +665 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphScope.js +236 -0
- package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
- package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
- package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
- package/dist/debug/runtime/reactivity/PathHandle.js +165 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -0
- package/dist/entrypoints/machine.d.ts +5 -0
- package/dist/entrypoints/path.d.ts +14 -0
- package/dist/entrypoints/reactivity.d.ts +1 -0
- package/dist/entrypoints/runtime.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +46 -38
- package/dist/machine/compiler.d.ts +71 -0
- package/dist/machine/core.d.ts +50 -0
- package/dist/machine/persistence.d.ts +5 -0
- package/dist/machine/runtime.d.ts +4 -0
- package/dist/machine/testing.d.ts +43 -0
- package/dist/machine/types.d.ts +155 -0
- package/dist/machine-testing.cjs +1 -0
- package/dist/machine-testing.js +188 -0
- package/dist/machine.cjs +1 -0
- package/dist/machine.js +822 -0
- package/dist/main.d.ts +20 -0
- package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
- package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
- package/dist/path/RaphKernel.d.ts +37 -10
- package/dist/path/data-path.types.d.ts +34 -0
- package/dist/path/data-path.utils.d.ts +9 -0
- package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
- package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +12 -0
- package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
- package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
- package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
- package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
- package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
- package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
- package/dist/path/path.types.d.ts +3 -2
- package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
- package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
- package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
- package/dist/path/storage/PathEventHub.d.ts +62 -0
- package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
- package/dist/path/storage/data-adapter.types.d.ts +17 -0
- package/dist/path.cjs +1 -1
- package/dist/path.js +16 -16
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +46 -38
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +193 -6
- package/dist/reactivity/reactive-object.d.ts +36 -0
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/reactivity/types.d.ts +25 -0
- package/dist/reactivity.cjs +1 -1
- package/dist/reactivity.js +12 -12
- package/dist/runtime/RaphRuntime.d.ts +319 -160
- package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
- package/dist/runtime/errors.d.ts +5 -0
- package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
- package/dist/runtime/ownership/RaphNode.d.ts +310 -0
- package/dist/runtime/ownership/RaphScope.d.ts +168 -0
- package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
- package/dist/runtime/ownership/parentGraph.d.ts +3 -0
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +253 -0
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
- package/dist/runtime/phases/phase.types.d.ts +171 -0
- package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
- package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +21 -16
- package/package.json +76 -35
- package/ReadMe.md +0 -153
- package/dist/api/public.d.ts +0 -22
- package/dist/debug/api/public.cjs +0 -1
- package/dist/debug/api/public.js +0 -40
- package/dist/debug/path/AdapterPathStore.cjs +0 -1
- package/dist/debug/path/AdapterPathStore.js +0 -133
- package/dist/debug/path/DerivedRegistry.cjs +0 -1
- package/dist/debug/path/DerivedRegistry.js +0 -157
- package/dist/debug/path/MetaController.cjs +0 -1
- package/dist/debug/path/PathEventHub.cjs +0 -1
- package/dist/debug/path/PathEventHub.js +0 -148
- package/dist/debug/path/PathStore.cjs +0 -1
- package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
- package/dist/debug/path/RaphMeta.cjs +0 -1
- package/dist/debug/path/RaphMeta.js +0 -68
- package/dist/debug/path/RaphMetaStore.cjs +0 -1
- package/dist/debug/path/data-adapter.cjs +0 -1
- package/dist/debug/path/data-draft.cjs +0 -1
- package/dist/debug/path/data-path.cjs +0 -1
- package/dist/debug/path/data-path.js +0 -423
- package/dist/debug/path/derived-collection.cjs +0 -1
- package/dist/debug/path/path-router.cjs +0 -1
- package/dist/debug/path/path-router.js +0 -86
- package/dist/debug/path/public.cjs +0 -1
- package/dist/debug/path/public.js +0 -18
- package/dist/debug/runtime/PathHandle.cjs +0 -1
- package/dist/debug/runtime/PathHandle.js +0 -139
- package/dist/debug/runtime/RaphDebug.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.js +0 -15
- package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
- package/dist/debug/runtime/RaphNode.cjs +0 -1
- package/dist/debug/runtime/RaphNode.js +0 -143
- package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
- package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
- package/dist/debug/runtime/RaphScope.cjs +0 -1
- package/dist/debug/runtime/RaphScope.js +0 -64
- package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
- package/dist/debug/runtime/RuntimeReactivity.js +0 -154
- package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
- package/dist/debug/runtime/RuntimeWatch.js +0 -71
- package/dist/debug/runtime/public.cjs +0 -1
- package/dist/debug/runtime/public.js +0 -18
- package/dist/path/PathEventHub.d.ts +0 -48
- package/dist/path/public.d.ts +0 -14
- package/dist/runtime/RaphDebug.d.ts +0 -32
- package/dist/runtime/RaphNode.d.ts +0 -68
- package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
- package/dist/runtime/RaphScope.d.ts +0 -50
- package/dist/runtime/RuntimeReactivity.d.ts +0 -40
- package/dist/runtime/phase.types.d.ts +0 -49
- package/dist/runtime/public.d.ts +0 -13
- package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
- /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
- /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
- /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
- /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
- /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
- /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
- /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
- /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
- /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
- /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
- /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
- /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
- /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
- /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
- /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=Symbol("raph.reactive-object.identity"),x=new Set(["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"]),f=new WeakMap,g=new WeakMap,l=new WeakMap,T=Object.freeze({}),O=Object.freeze({assertRead:p,assertWrite:p,throwForeign:p});function j(s,e){g.set(s,e)}function A(s,e=O){g.delete(s);const t=f.get(s);t!==void 0&&(f.delete(s),t.dispose(e))}function M(s,e,t){const r=d(e),i=f.get(s);if(r!==void 0){if(r.context===i)return e;throw(g.get(s)??T).throwForeign?.(r.context.owner),new TypeError("[Raph] Reactive object belongs to another reactivity engine.")}return D(e),(i??W(s,t)).wrap(e)}class P{_rawToProxy=new WeakMap;_rawToTracking=new WeakMap;_arrayMethods=new Map;_bridge;_policy;_writeDepth=0;_disposed=!1;_handler;_weakSelf;constructor(e,t){this._bridge=e,this._policy=t,this._weakSelf=new WeakRef(this),this._handler={defineProperty:(r,i,n)=>this._define(r,i,n),deleteProperty:(r,i)=>this._delete(r,i),get:(r,i,n)=>this._get(r,i,n),has:(r,i)=>this._has(r,i),ownKeys:r=>this._ownKeys(r),set:(r,i,n)=>this._set(r,i,n)}}get owner(){return this._policy.owner}get disposed(){return this._disposed}wrap(e){const t=d(e);if(t!==void 0){if(t.context===this)return e;throw this._policy.throwForeign?.(t.context.owner),new TypeError("[Raph] Reactive object belongs to another reactivity engine.")}D(e);const r=v(e);if(r!==void 0&&r!==this&&!r.disposed)throw this._policy.throwForeign?.(r.owner),new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.");const i=this._rawToProxy.get(e);if(i!==void 0)return i;const n=new Proxy(e,this._handler);return l.set(e,this._weakSelf),this._rawToProxy.set(e,n),n}dispose(e){this._disposed=!0,this._policy=e,this._bridge=void 0,this._rawToProxy=new WeakMap,this._rawToTracking=new WeakMap,this._arrayMethods.clear()}_get(e,t,r){if(t===R)return{context:this,raw:e};this._policy.assertRead?.();const i=Reflect.get(e,t,r);return this._trackValue(e,t),Array.isArray(e)&&x.has(t)&&i===Array.prototype[t]?this._arrayMutator(t):w(i)?this.wrap(i):i}_set(e,t,r){return this._write(()=>{const i=this._unwrap(r),n=Object.hasOwn(e,t),o=Reflect.get(e,t,e),c=Array.isArray(e)?e.length:0;if(n&&o===i)return!0;if(!Reflect.set(e,t,i,e))return!1;const h=this._rawToTracking.get(e);return h===void 0||(this._trigger(h.valueDeps?.get(t)),n||(this._trigger(h.hasDeps?.get(t)),this._trigger(h.iterateDep)),this._triggerArrayShape(e,t,i,c,h)),!0})}_define(e,t,r){return this._write(()=>{const i=Object.hasOwn(e,t),n=Reflect.getOwnPropertyDescriptor(e,t),o=Reflect.get(e,t,e),c=Array.isArray(e)?e.length:0,a="value"in r?{...r,value:this._unwrap(r.value)}:r;if(!Reflect.defineProperty(e,t,a))return!1;const u=this._rawToTracking.get(e);if(u===void 0)return!0;const y=Reflect.getOwnPropertyDescriptor(e,t),b=Reflect.get(e,t,e);return(!i||o!==b||!m(n,y))&&this._trigger(u.valueDeps?.get(t)),i?n?.enumerable!==y?.enumerable&&this._trigger(u.iterateDep):(this._trigger(u.hasDeps?.get(t)),this._trigger(u.iterateDep)),this._triggerArrayShape(e,t,b,c,u),!0})}_delete(e,t){return this._write(()=>{if(!Object.hasOwn(e,t))return!0;if(!Reflect.deleteProperty(e,t))return!1;const i=this._rawToTracking.get(e);return i!==void 0&&(this._trigger(i.valueDeps?.get(t)),this._trigger(i.hasDeps?.get(t)),this._trigger(i.iterateDep)),!0})}_has(e,t){return this._policy.assertRead?.(),this._trackHas(e,t),Reflect.has(e,t)}_ownKeys(e){return this._policy.assertRead?.(),this._trackIterate(e),Reflect.ownKeys(e)}_arrayMutator(e){const t=this._arrayMethods.get(e);if(t!==void 0)return t;const r=n=>this._write(n),i=function(...n){return r(()=>Reflect.apply(Array.prototype[e],this,n))};return this._arrayMethods.set(e,i),i}_trackValue(e,t){const r=this._requireBridge();if(!r.isTracking())return;const i=this._ensureTracking(e),n=i.valueDeps??=new Map;let o=n.get(t);o===void 0&&(o=r.create(),n.set(t,o)),r.track(o)}_trackHas(e,t){const r=this._requireBridge();if(!r.isTracking())return;const i=this._ensureTracking(e),n=i.hasDeps??=new Map;let o=n.get(t);o===void 0&&(o=r.create(),n.set(t,o)),r.track(o)}_trackIterate(e){const t=this._requireBridge();if(!t.isTracking())return;const r=this._ensureTracking(e),i=r.iterateDep??=t.create();t.track(i)}_ensureTracking(e){let t=this._rawToTracking.get(e);return t===void 0&&(t={},this._rawToTracking.set(e,t)),t}_trigger(e){e!==void 0&&this._requireBridge().trigger(e)}_triggerArrayShape(e,t,r,i,n){if(!Array.isArray(e))return;if(_(t)&&Number(t)>=i){this._trigger(n.valueDeps?.get("length"));return}if(t!=="length"||Number(r)>=i)return;const o=Number(r);for(const[c,a]of n.valueDeps?.entries()??[])_(c)&&Number(c)>=o&&this._trigger(a);for(const[c,a]of n.hasDeps?.entries()??[])_(c)&&Number(c)>=o&&this._trigger(a);this._trigger(n.iterateDep)}_write(e){if(this._policy.assertWrite?.(),this._writeDepth!==0)return e();const t=()=>{++this._writeDepth;try{return this._requireBridge().batch(e)}finally{--this._writeDepth}};return this._policy.runWrite===void 0?t():this._policy.runWrite(t)}_unwrap(e){const t=d(e);if(t===void 0){if(w(e)){const r=v(e);if(r!==void 0&&r!==this&&!r.disposed)throw this._policy.throwForeign?.(r.owner),new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.")}return e}if(t.context!==this)throw this._policy.throwForeign?.(t.context.owner),new TypeError("[Raph] Reactive object belongs to another reactivity engine.");return t.raw}_requireBridge(){const e=this._bridge;return e===void 0&&p(),e}}function W(s,e){const t=new P(e(),g.get(s)??T);return f.set(s,t),t}function v(s){const e=l.get(s),t=e?.deref();return e!==void 0&&t===void 0&&l.delete(s),t}function d(s){if(!(s===null||typeof s!="object"))return Reflect.get(s,R)}function w(s){if(s===null||typeof s!="object")return!1;if(Array.isArray(s))return!0;const e=Object.getPrototypeOf(s);return e===Object.prototype||e===null}function D(s){if(!w(s))throw new TypeError("[Raph] reactive() accepts only plain objects and arrays.")}function _(s){if(typeof s!="string"||s==="")return!1;const e=Number(s);return Number.isInteger(e)&&e>=0&&e<4294967295&&String(e)===s}function m(s,e){return s===e?!0:s===void 0||e===void 0?!1:s.configurable===e.configurable&&s.enumerable===e.enumerable&&s.get===e.get&&s.set===e.set&&s.value===e.value&&s.writable===e.writable}function p(){throw new Error("[Raph] Reactive object owner is disposed.")}exports.configureReactiveObjectPolicy=j;exports.disposeReactiveObjectContext=A;exports.reactiveObject=M;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
const R = Symbol("raph.reactive-object.identity"), x = /* @__PURE__ */ new Set([
|
|
2
|
+
"copyWithin",
|
|
3
|
+
"fill",
|
|
4
|
+
"pop",
|
|
5
|
+
"push",
|
|
6
|
+
"reverse",
|
|
7
|
+
"shift",
|
|
8
|
+
"sort",
|
|
9
|
+
"splice",
|
|
10
|
+
"unshift"
|
|
11
|
+
]), f = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), T = Object.freeze({}), O = Object.freeze({
|
|
12
|
+
assertRead: p,
|
|
13
|
+
assertWrite: p,
|
|
14
|
+
throwForeign: p
|
|
15
|
+
});
|
|
16
|
+
function P(s, e) {
|
|
17
|
+
_.set(s, e);
|
|
18
|
+
}
|
|
19
|
+
function W(s, e = O) {
|
|
20
|
+
_.delete(s);
|
|
21
|
+
const t = f.get(s);
|
|
22
|
+
t !== void 0 && (f.delete(s), t.dispose(e));
|
|
23
|
+
}
|
|
24
|
+
function m(s, e, t) {
|
|
25
|
+
const r = w(e), i = f.get(s);
|
|
26
|
+
if (r !== void 0) {
|
|
27
|
+
if (r.context === i)
|
|
28
|
+
return e;
|
|
29
|
+
throw (_.get(s) ?? T).throwForeign?.(r.context.owner), new TypeError("[Raph] Reactive object belongs to another reactivity engine.");
|
|
30
|
+
}
|
|
31
|
+
return D(e), (i ?? A(s, t)).wrap(e);
|
|
32
|
+
}
|
|
33
|
+
class j {
|
|
34
|
+
_rawToProxy = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
_rawToTracking = /* @__PURE__ */ new WeakMap();
|
|
36
|
+
_arrayMethods = /* @__PURE__ */ new Map();
|
|
37
|
+
_bridge;
|
|
38
|
+
_policy;
|
|
39
|
+
_writeDepth = 0;
|
|
40
|
+
_disposed = !1;
|
|
41
|
+
_handler;
|
|
42
|
+
_weakSelf;
|
|
43
|
+
constructor(e, t) {
|
|
44
|
+
this._bridge = e, this._policy = t, this._weakSelf = new WeakRef(this), this._handler = {
|
|
45
|
+
defineProperty: (r, i, n) => this._define(r, i, n),
|
|
46
|
+
deleteProperty: (r, i) => this._delete(r, i),
|
|
47
|
+
get: (r, i, n) => this._get(r, i, n),
|
|
48
|
+
has: (r, i) => this._has(r, i),
|
|
49
|
+
ownKeys: (r) => this._ownKeys(r),
|
|
50
|
+
set: (r, i, n) => this._set(r, i, n)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
get owner() {
|
|
54
|
+
return this._policy.owner;
|
|
55
|
+
}
|
|
56
|
+
get disposed() {
|
|
57
|
+
return this._disposed;
|
|
58
|
+
}
|
|
59
|
+
wrap(e) {
|
|
60
|
+
const t = w(e);
|
|
61
|
+
if (t !== void 0) {
|
|
62
|
+
if (t.context === this)
|
|
63
|
+
return e;
|
|
64
|
+
throw this._policy.throwForeign?.(t.context.owner), new TypeError("[Raph] Reactive object belongs to another reactivity engine.");
|
|
65
|
+
}
|
|
66
|
+
D(e);
|
|
67
|
+
const r = v(e);
|
|
68
|
+
if (r !== void 0 && r !== this && !r.disposed)
|
|
69
|
+
throw this._policy.throwForeign?.(r.owner), new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.");
|
|
70
|
+
const i = this._rawToProxy.get(e);
|
|
71
|
+
if (i !== void 0)
|
|
72
|
+
return i;
|
|
73
|
+
const n = new Proxy(e, this._handler);
|
|
74
|
+
return l.set(e, this._weakSelf), this._rawToProxy.set(e, n), n;
|
|
75
|
+
}
|
|
76
|
+
dispose(e) {
|
|
77
|
+
this._disposed = !0, this._policy = e, this._bridge = void 0, this._rawToProxy = /* @__PURE__ */ new WeakMap(), this._rawToTracking = /* @__PURE__ */ new WeakMap(), this._arrayMethods.clear();
|
|
78
|
+
}
|
|
79
|
+
_get(e, t, r) {
|
|
80
|
+
if (t === R)
|
|
81
|
+
return { context: this, raw: e };
|
|
82
|
+
this._policy.assertRead?.();
|
|
83
|
+
const i = Reflect.get(e, t, r);
|
|
84
|
+
return this._trackValue(e, t), Array.isArray(e) && x.has(t) && i === Array.prototype[t] ? this._arrayMutator(t) : d(i) ? this.wrap(i) : i;
|
|
85
|
+
}
|
|
86
|
+
_set(e, t, r) {
|
|
87
|
+
return this._write(() => {
|
|
88
|
+
const i = this._unwrap(r), n = Object.hasOwn(e, t), o = Reflect.get(e, t, e), c = Array.isArray(e) ? e.length : 0;
|
|
89
|
+
if (n && o === i)
|
|
90
|
+
return !0;
|
|
91
|
+
if (!Reflect.set(e, t, i, e))
|
|
92
|
+
return !1;
|
|
93
|
+
const h = this._rawToTracking.get(e);
|
|
94
|
+
return h === void 0 || (this._trigger(h.valueDeps?.get(t)), n || (this._trigger(h.hasDeps?.get(t)), this._trigger(h.iterateDep)), this._triggerArrayShape(e, t, i, c, h)), !0;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
_define(e, t, r) {
|
|
98
|
+
return this._write(() => {
|
|
99
|
+
const i = Object.hasOwn(e, t), n = Reflect.getOwnPropertyDescriptor(e, t), o = Reflect.get(e, t, e), c = Array.isArray(e) ? e.length : 0, a = "value" in r ? { ...r, value: this._unwrap(r.value) } : r;
|
|
100
|
+
if (!Reflect.defineProperty(e, t, a))
|
|
101
|
+
return !1;
|
|
102
|
+
const u = this._rawToTracking.get(e);
|
|
103
|
+
if (u === void 0)
|
|
104
|
+
return !0;
|
|
105
|
+
const y = Reflect.getOwnPropertyDescriptor(e, t), b = Reflect.get(e, t, e);
|
|
106
|
+
return (!i || o !== b || !M(n, y)) && this._trigger(u.valueDeps?.get(t)), i ? n?.enumerable !== y?.enumerable && this._trigger(u.iterateDep) : (this._trigger(u.hasDeps?.get(t)), this._trigger(u.iterateDep)), this._triggerArrayShape(
|
|
107
|
+
e,
|
|
108
|
+
t,
|
|
109
|
+
b,
|
|
110
|
+
c,
|
|
111
|
+
u
|
|
112
|
+
), !0;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
_delete(e, t) {
|
|
116
|
+
return this._write(() => {
|
|
117
|
+
if (!Object.hasOwn(e, t))
|
|
118
|
+
return !0;
|
|
119
|
+
if (!Reflect.deleteProperty(e, t))
|
|
120
|
+
return !1;
|
|
121
|
+
const i = this._rawToTracking.get(e);
|
|
122
|
+
return i !== void 0 && (this._trigger(i.valueDeps?.get(t)), this._trigger(i.hasDeps?.get(t)), this._trigger(i.iterateDep)), !0;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
_has(e, t) {
|
|
126
|
+
return this._policy.assertRead?.(), this._trackHas(e, t), Reflect.has(e, t);
|
|
127
|
+
}
|
|
128
|
+
_ownKeys(e) {
|
|
129
|
+
return this._policy.assertRead?.(), this._trackIterate(e), Reflect.ownKeys(e);
|
|
130
|
+
}
|
|
131
|
+
_arrayMutator(e) {
|
|
132
|
+
const t = this._arrayMethods.get(e);
|
|
133
|
+
if (t !== void 0)
|
|
134
|
+
return t;
|
|
135
|
+
const r = (n) => this._write(n), i = function(...n) {
|
|
136
|
+
return r(() => Reflect.apply(
|
|
137
|
+
Array.prototype[e],
|
|
138
|
+
this,
|
|
139
|
+
n
|
|
140
|
+
));
|
|
141
|
+
};
|
|
142
|
+
return this._arrayMethods.set(e, i), i;
|
|
143
|
+
}
|
|
144
|
+
_trackValue(e, t) {
|
|
145
|
+
const r = this._requireBridge();
|
|
146
|
+
if (!r.isTracking())
|
|
147
|
+
return;
|
|
148
|
+
const i = this._ensureTracking(e), n = i.valueDeps ??= /* @__PURE__ */ new Map();
|
|
149
|
+
let o = n.get(t);
|
|
150
|
+
o === void 0 && (o = r.create(), n.set(t, o)), r.track(o);
|
|
151
|
+
}
|
|
152
|
+
_trackHas(e, t) {
|
|
153
|
+
const r = this._requireBridge();
|
|
154
|
+
if (!r.isTracking())
|
|
155
|
+
return;
|
|
156
|
+
const i = this._ensureTracking(e), n = i.hasDeps ??= /* @__PURE__ */ new Map();
|
|
157
|
+
let o = n.get(t);
|
|
158
|
+
o === void 0 && (o = r.create(), n.set(t, o)), r.track(o);
|
|
159
|
+
}
|
|
160
|
+
_trackIterate(e) {
|
|
161
|
+
const t = this._requireBridge();
|
|
162
|
+
if (!t.isTracking())
|
|
163
|
+
return;
|
|
164
|
+
const r = this._ensureTracking(e), i = r.iterateDep ??= t.create();
|
|
165
|
+
t.track(i);
|
|
166
|
+
}
|
|
167
|
+
_ensureTracking(e) {
|
|
168
|
+
let t = this._rawToTracking.get(e);
|
|
169
|
+
return t === void 0 && (t = {}, this._rawToTracking.set(e, t)), t;
|
|
170
|
+
}
|
|
171
|
+
_trigger(e) {
|
|
172
|
+
e !== void 0 && this._requireBridge().trigger(e);
|
|
173
|
+
}
|
|
174
|
+
_triggerArrayShape(e, t, r, i, n) {
|
|
175
|
+
if (!Array.isArray(e))
|
|
176
|
+
return;
|
|
177
|
+
if (g(t) && Number(t) >= i) {
|
|
178
|
+
this._trigger(n.valueDeps?.get("length"));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (t !== "length" || Number(r) >= i)
|
|
182
|
+
return;
|
|
183
|
+
const o = Number(r);
|
|
184
|
+
for (const [c, a] of n.valueDeps?.entries() ?? [])
|
|
185
|
+
g(c) && Number(c) >= o && this._trigger(a);
|
|
186
|
+
for (const [c, a] of n.hasDeps?.entries() ?? [])
|
|
187
|
+
g(c) && Number(c) >= o && this._trigger(a);
|
|
188
|
+
this._trigger(n.iterateDep);
|
|
189
|
+
}
|
|
190
|
+
_write(e) {
|
|
191
|
+
if (this._policy.assertWrite?.(), this._writeDepth !== 0)
|
|
192
|
+
return e();
|
|
193
|
+
const t = () => {
|
|
194
|
+
++this._writeDepth;
|
|
195
|
+
try {
|
|
196
|
+
return this._requireBridge().batch(e);
|
|
197
|
+
} finally {
|
|
198
|
+
--this._writeDepth;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
return this._policy.runWrite === void 0 ? t() : this._policy.runWrite(t);
|
|
202
|
+
}
|
|
203
|
+
_unwrap(e) {
|
|
204
|
+
const t = w(e);
|
|
205
|
+
if (t === void 0) {
|
|
206
|
+
if (d(e)) {
|
|
207
|
+
const r = v(e);
|
|
208
|
+
if (r !== void 0 && r !== this && !r.disposed)
|
|
209
|
+
throw this._policy.throwForeign?.(r.owner), new TypeError("[Raph] Raw reactive object belongs to another reactivity engine.");
|
|
210
|
+
}
|
|
211
|
+
return e;
|
|
212
|
+
}
|
|
213
|
+
if (t.context !== this)
|
|
214
|
+
throw this._policy.throwForeign?.(t.context.owner), new TypeError("[Raph] Reactive object belongs to another reactivity engine.");
|
|
215
|
+
return t.raw;
|
|
216
|
+
}
|
|
217
|
+
_requireBridge() {
|
|
218
|
+
const e = this._bridge;
|
|
219
|
+
return e === void 0 && p(), e;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function A(s, e) {
|
|
223
|
+
const t = new j(
|
|
224
|
+
e(),
|
|
225
|
+
_.get(s) ?? T
|
|
226
|
+
);
|
|
227
|
+
return f.set(s, t), t;
|
|
228
|
+
}
|
|
229
|
+
function v(s) {
|
|
230
|
+
const e = l.get(s), t = e?.deref();
|
|
231
|
+
return e !== void 0 && t === void 0 && l.delete(s), t;
|
|
232
|
+
}
|
|
233
|
+
function w(s) {
|
|
234
|
+
if (!(s === null || typeof s != "object"))
|
|
235
|
+
return Reflect.get(s, R);
|
|
236
|
+
}
|
|
237
|
+
function d(s) {
|
|
238
|
+
if (s === null || typeof s != "object")
|
|
239
|
+
return !1;
|
|
240
|
+
if (Array.isArray(s))
|
|
241
|
+
return !0;
|
|
242
|
+
const e = Object.getPrototypeOf(s);
|
|
243
|
+
return e === Object.prototype || e === null;
|
|
244
|
+
}
|
|
245
|
+
function D(s) {
|
|
246
|
+
if (!d(s))
|
|
247
|
+
throw new TypeError("[Raph] reactive() accepts only plain objects and arrays.");
|
|
248
|
+
}
|
|
249
|
+
function g(s) {
|
|
250
|
+
if (typeof s != "string" || s === "")
|
|
251
|
+
return !1;
|
|
252
|
+
const e = Number(s);
|
|
253
|
+
return Number.isInteger(e) && e >= 0 && e < 4294967295 && String(e) === s;
|
|
254
|
+
}
|
|
255
|
+
function M(s, e) {
|
|
256
|
+
return s === e ? !0 : s === void 0 || e === void 0 ? !1 : s.configurable === e.configurable && s.enumerable === e.enumerable && s.get === e.get && s.set === e.set && s.value === e.value && s.writable === e.writable;
|
|
257
|
+
}
|
|
258
|
+
function p() {
|
|
259
|
+
throw new Error("[Raph] Reactive object owner is disposed.");
|
|
260
|
+
}
|
|
261
|
+
export {
|
|
262
|
+
P as configureReactiveObjectPolicy,
|
|
263
|
+
W as disposeReactiveObjectContext,
|
|
264
|
+
m as reactiveObject
|
|
265
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./disposal.cjs");class v{constructor(e,s,t){this.scopeParent=e,this.scopePrevious=s,this.scopeNext=void 0,this._cleanup=t}dispose(){const e=this._cleanup;e!==void 0&&(this._cleanup=void 0,this.scopeParent._releaseRecord(this),e())}}let p;class a{_cleanup;constructor(e){this._cleanup=e}dispose(){u.throwDisposalFailure(p.call(this))}_disposeWithOutcome(){const e=this._cleanup;if(e!==void 0)return this._cleanup=void 0,this.scopeParent._releaseRecord(this),e()}}const f=a.prototype.dispose;p=a.prototype._disposeWithOutcome;class w{constructor(e,s){this._previousSource=e,this._finalizer=s}_finalizeSource(){const e=this._finalizer;return e()}}class h{constructor(){this.scopeFirstChild=void 0,this.scopeLastChild=void 0,this._resourceCount=0,this._lastSource=void 0,this._sourceCount=0,this._disposed=!1,this._disposing=!1}get disposed(){return this._disposed}get active(){return!this._disposed&&!this._disposing}_debugResourceCount(){return this._resourceCount}_debugSourceCount(){return this._sourceCount}_lastOwnedSource(){return this._lastSource}_releaseRecord(e){if(e.scopeParent!==this)return;const s=e.scopePrevious,t=e.scopeNext;s===void 0?this.scopeFirstChild=t:s.scopeNext=t,t===void 0?this.scopeLastChild=s:t.scopePrevious=s,e.scopeParent=void 0,e.scopePrevious=void 0,e.scopeNext=void 0,--this._resourceCount}_ownCleanup(e){const s=this.scopeLastChild,t=new v(this,s,e);return s===void 0?this.scopeFirstChild=t:s.scopeNext=t,this.scopeLastChild=t,++this._resourceCount,()=>t.dispose()}_ownCompleted(e){const s=new a(e);return this._ownRecord(s),()=>s.dispose()}_ownRecord(e){const s=this.scopeLastChild;e.scopeParent=this,e.scopePrevious=s,e.scopeNext=void 0,s===void 0?this.scopeFirstChild=e:s.scopeNext=e,this.scopeLastChild=e,++this._resourceCount}_ownSourceFinalizer(e){this._lastSource=new w(this._lastSource,e),++this._sourceCount}_ownSourceEntry(e){e._previousSource=this._lastSource,this._lastSource=e,++this._sourceCount}_releaseOwned(){let e,s=this.scopeLastChild;for(;s!==void 0;){try{const i=s.dispose;if(s instanceof a&&i===f){const c=p.call(s);c!==void 0&&(e??=[]).push(c)}else i.call(s)}catch(i){(e??=[]).push(u.unroutedDisposalFailure(i))}s=this.scopeLastChild}const t=this._lastSource;return t!==void 0&&(this._lastSource=void 0,this._sourceCount=0,e=S(t,e)),e}}class C extends h{constructor(e){super(),this.reactivity=e}signal(e){this._assertAlive();const s=this._adoptSource(this.reactivity._ownedSignal(e));return{get:()=>(this._assertAlive(),s.get()),peek:()=>(this._assertAlive(),s.peek()),set:t=>{this._assertAlive(),s.set(t)}}}computed(e){this._assertAlive();const s=typeof e=="function"?e:e.get,t=this._adoptSource(this.reactivity._ownedComputed(s)),i={get:()=>(this._assertAlive(),t.get()),peek:()=>(this._assertAlive(),t.peek())};if(typeof e=="function")return i;let c=e.set;this._own(()=>{c=void 0});const n=i;return n.set=r=>{this._assertAlive(),c(r)},n}effect(e){return this._assertAlive(),this._adoptResource(this.reactivity.effect(e))}watch(e,s,t){return this._assertAlive(),this._adoptResource(this.reactivity.watch(e,s,t))}own(e){return this._disposed||this._disposing?(e(),A):this._ownCleanup(e)}dispose(){if(this._disposed)return;this._disposed=!0,this._disposing=!0;let e;try{e=this._releaseOwned()}finally{this._disposing=!1;try{this._afterDispose()}catch(s){(e??=[]).push(u.unroutedDisposalFailure(s))}}e!==void 0&&u.throwDisposalFailure(u.combineDisposalFailures(e,this._disposalMessage()))}_own(e){return this._assertAlive(),this._ownCleanup(e)}_adoptResource(e){try{return this._own(e)}catch(s){try{e()}catch(t){throw new AggregateError([s,t],"Resource registration and cleanup failed.")}throw s}}_adoptSource(e){try{this._ownSource(e.dispose)}catch(s){try{e.dispose()}catch(t){throw new AggregateError([s,t],"Source registration and cleanup failed.")}throw s}return e.source}_ownSource(e){this._assertAlive(),this._ownSourceFinalizer(e)}_assertAlive(){if(this._disposed||this._disposing)throw new Error("ScopeNode is disposed.")}_afterDispose(){}_disposalMessage(){return"ScopeNode disposal failed."}}function S(o,e){let s=e,t=o;for(;t!==void 0;){let i,c,n=!1,r=t;for(;r!==void 0;){const d=r._previousSource;let l=!0;try{r._previousSource=void 0,l=r._finalizeSource()}catch(_){(s??=[]).push(u.unroutedDisposalFailure(_))}l?n=!0:(c===void 0?i=r:c._previousSource=r,c=r),r=d}if(!n)return s;t=i}return s}function g(o,e){const s=o.scopeLastChild;e.scopeParent=o,e.scopePrevious=s,e.scopeNext=void 0,s===void 0?o.scopeFirstChild=e:s.scopeNext=e,o.scopeLastChild=e}function P(o){const e=o.scopeParent;if(e===void 0)return;const s=o.scopePrevious,t=o.scopeNext;s===void 0?e.scopeFirstChild=t:s.scopeNext=t,t===void 0?e.scopeLastChild=s:t.scopePrevious=s,o.scopeParent=void 0,o.scopePrevious=void 0,o.scopeNext=void 0}function x(o,e){if(o.length===1)throw o[0];if(o.length>1)throw new AggregateError(o,e)}function A(){}exports.ScopeNode=C;exports.ScopeOwner=h;exports.appendScopeChild=g;exports.detachScopeChild=P;exports.throwScopeErrors=x;
|