@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 b=require("../path/RaphKernel.cjs"),f=require("../runtime/phases/phase.types.cjs"),l=require("../runtime/RaphRuntime.cjs"),i=require("./errors.cjs"),g=require("./RaphReactivityInstance.cjs");class u{static _runtimeCounter=0;static _reactivityCounter=0;_instances=new Map;_instanceOrder=[];_defaultInstance;_disposed=!1;constructor(){}static create(e){const t=I(e),n=new u,s=[];try{for(const a of t){const o=n._construct(a);n._register(o),a.default&&(n._defaultInstance=o)}return n}catch(a){s.push(a);try{n.dispose()}catch(o){o instanceof AggregateError?s.push(...o.errors):s.push(o)}throw s.length===1?a:new AggregateError(s,"[Raph] Facade configuration and cleanup failed.")}}get disposed(){return this._disposed}get defaultInstanceId(){return this._defaultInstance?.id}instance(e){if(this._assertActive(),e===void 0){if(this._defaultInstance===void 0)throw new i.RaphDefaultInstanceError("[Raph] Facade session has no default instance.");return this._defaultInstance}c(e);const t=this._instances.get(e);if(t===void 0)throw new i.RaphConfigurationError(`[Raph] Instance "${e}" is not registered.`);return t}getInstance(e){return this._assertActive(),c(e),this._instances.get(e)}hasInstance(e){return this.getInstance(e)!==void 0}runtime(e){const t=this.instance(e);if(!(t instanceof l.RaphRuntime))throw new i.RaphCapabilityError(`[Raph] Instance "${t.id}" uses reactivity mode and has no Runtime capabilities.`);return t}reactivity(e){const t=this.instance(e);if(!(t instanceof g.RaphReactivityInstance))throw new i.RaphCapabilityError(`[Raph] Instance "${t.id}" uses runtime mode and is not a pure reactivity instance.`);return t}createRuntime(e={}){this._assertActive();const t=e.id??this._generateId("runtime");c(t),this._assertFreeId(t);const n=new l.RaphRuntime({...e,id:t});return this._register(n),n}createReactivity(e={}){this._assertActive();const t=e.id??this._generateId("reactivity");c(t),this._assertFreeId(t);const n=new g.RaphReactivityInstance(t,e);return this._register(n),n}createKernel(e={}){return this._assertActive(),new b.RaphKernel(e)}disposeInstance(e){const t=this.getInstance(e);return t===void 0?!1:(t.dispose(),!0)}dispose(){if(this._disposed)return;this._disposed=!0;const e=[...this._instanceOrder].reverse();this._instances.clear(),this._instanceOrder.length=0,this._defaultInstance=void 0;const t=[];for(const n of e)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[Raph] Facade session reset failed.")}_construct(e){if(e.mode==="reactivity"){const s=e.config;return new g.RaphReactivityInstance(e.id,{...s.adaptiveDependencyIndex===void 0?{}:{adaptiveDependencyIndex:s.adaptiveDependencyIndex}})}const t=e.config,n=new l.RaphRuntime({...t.adaptiveDependencyIndex===void 0?{}:{adaptiveDependencyIndex:t.adaptiveDependencyIndex},...t.debug===void 0?{}:{debug:t.debug},...t.enforceActions===void 0?{}:{enforceActions:t.enforceActions},...t.kernel===void 0?{}:{kernel:t.kernel},...t.scheduler===void 0?{}:{scheduler:t.scheduler},id:e.id});try{return t.phases!==void 0&&n.definePhases(t.phases),n}catch(s){try{n.dispose()}catch(a){throw new AggregateError([s,a],`[Raph] Runtime "${e.id}" construction and cleanup failed.`)}throw s}}_register(e){this._assertFreeId(e.id),this._instances.set(e.id,e),this._instanceOrder.push(e),e._onDisposed(()=>this._forget(e))}_forget(e){this._instances.get(e.id)===e&&this._instances.delete(e.id);const t=this._instanceOrder.indexOf(e);t>=0&&this._instanceOrder.splice(t,1),this._defaultInstance===e&&(this._defaultInstance=void 0)}_generateId(e){let t;do t=e==="runtime"?`runtime-${u._runtimeCounter++}`:`reactivity-${u._reactivityCounter++}`;while(this._instances.has(t));return t}_assertFreeId(e){if(this._instances.has(e))throw new i.RaphConfigurationError(`[Raph] Instance id "${e}" is already registered.`)}_assertActive(){if(this._disposed)throw new i.RaphFacadeDisposedError("[Raph] Facade session is disposed.")}}function I(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new i.RaphConfigurationError("[Raph] Configure options must be an object.");if(Object.hasOwn(r,"instances")){R(r,new Set(["instances"]),"configure");const s=r.instances;if(typeof s!="object"||s===null||Array.isArray(s))throw new i.RaphConfigurationError("[Raph] instances must be an object.");const a=[],o=new Set;let y=0;for(const[w,p]of Object.entries(s)){if(typeof p!="object"||p===null||Array.isArray(p))throw new i.RaphConfigurationError(`[Raph] Instance definition "${w}" must be an object.`);const d=p;_(d,!0);const h=d.id??w;if(c(h),o.has(h))throw new i.RaphConfigurationError(`[Raph] Resolved instance id "${h}" is duplicated.`);o.add(h);const v=d.default===!0;v&&y++,a.push({config:d,default:v,id:h,mode:d.mode})}if(y>1)throw new i.RaphConfigurationError("[Raph] Exactly one instance may declare default: true.");return a}const e=r;_(e,!1);const t=e.mode??"runtime",n=e.id??"default";return c(n),[{config:e,default:!0,id:n,mode:t}]}function _(r,e){const t=r.mode??(e?void 0:"runtime");if(t!=="runtime"&&t!=="reactivity")throw new i.RaphConfigurationError(e?"[Raph] Every instances entry must declare mode.":"[Raph] Unsupported instance mode.");if(t==="reactivity"){if(R(r,new Set(e?["adaptiveDependencyIndex","default","id","mode"]:["adaptiveDependencyIndex","id","mode"]),"reactivity instance"),m(r.adaptiveDependencyIndex),e&&r.default!==void 0&&typeof r.default!="boolean")throw new i.RaphConfigurationError("[Raph] default must be boolean.");return}if(R(r,new Set(e?["adaptiveDependencyIndex","debug","default","enforceActions","id","kernel","mode","phases","scheduler"]:["adaptiveDependencyIndex","debug","enforceActions","id","kernel","mode","phases","scheduler"]),"runtime instance"),m(r.adaptiveDependencyIndex),e&&r.default!==void 0&&typeof r.default!="boolean")throw new i.RaphConfigurationError("[Raph] default must be boolean.");const n=r;if(n.enforceActions!==void 0&&typeof n.enforceActions!="boolean")throw new i.RaphConfigurationError("[Raph] enforceActions must be boolean.");if(n.kernel!==void 0&&!(n.kernel instanceof b.RaphKernel))throw new i.RaphConfigurationError("[Raph] kernel must be a RaphKernel instance.");if(n.phases!==void 0&&!Array.isArray(n.phases))throw new i.RaphConfigurationError("[Raph] phases must be an array.");if(n.scheduler!==void 0&&!E(n.scheduler))throw new i.RaphConfigurationError(`[Raph] Unsupported scheduler "${String(n.scheduler)}".`);if(n.debug!==void 0&&(typeof n.debug!="object"||n.debug===null))throw new i.RaphConfigurationError("[Raph] debug must be an object.")}function m(r){if(r!==void 0&&typeof r!="boolean")throw new i.RaphConfigurationError("[Raph] adaptiveDependencyIndex must be boolean.")}function R(r,e,t){for(const n of Object.keys(r))if(!e.has(n))throw new i.RaphConfigurationError(`[Raph] Unsupported ${t} option "${n}".`)}function c(r){if(typeof r!="string"||r.length===0||r.trim()!==r)throw new i.RaphConfigurationError("[Raph] Instance id must be a non-empty string without surrounding whitespace.")}function E(r){return r===f.RaphSchedulerType.Sync||r===f.RaphSchedulerType.Microtask||r===f.RaphSchedulerType.AnimationFrame}exports.RaphFacadeSession=u;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { RaphKernel as R } from "../path/RaphKernel.js";
|
|
2
|
+
import { RaphSchedulerType as p } from "../runtime/phases/phase.types.js";
|
|
3
|
+
import { RaphRuntime as l } from "../runtime/RaphRuntime.js";
|
|
4
|
+
import { RaphDefaultInstanceError as A, RaphConfigurationError as i, RaphCapabilityError as _, RaphFacadeDisposedError as D } from "./errors.js";
|
|
5
|
+
import { RaphReactivityInstance as w } from "./RaphReactivityInstance.js";
|
|
6
|
+
class f {
|
|
7
|
+
static _runtimeCounter = 0;
|
|
8
|
+
static _reactivityCounter = 0;
|
|
9
|
+
_instances = /* @__PURE__ */ new Map();
|
|
10
|
+
_instanceOrder = [];
|
|
11
|
+
_defaultInstance;
|
|
12
|
+
_disposed = !1;
|
|
13
|
+
constructor() {
|
|
14
|
+
}
|
|
15
|
+
// ---------------------------------------------
|
|
16
|
+
// PUBLIC API
|
|
17
|
+
// ---------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* Валидирует всю конфигурацию до construction и атомарно создаёт session.
|
|
20
|
+
*/
|
|
21
|
+
static create(e) {
|
|
22
|
+
const t = x(e), n = new f(), r = [];
|
|
23
|
+
try {
|
|
24
|
+
for (const a of t) {
|
|
25
|
+
const o = n._construct(a);
|
|
26
|
+
n._register(o), a.default && (n._defaultInstance = o);
|
|
27
|
+
}
|
|
28
|
+
return n;
|
|
29
|
+
} catch (a) {
|
|
30
|
+
r.push(a);
|
|
31
|
+
try {
|
|
32
|
+
n.dispose();
|
|
33
|
+
} catch (o) {
|
|
34
|
+
o instanceof AggregateError ? r.push(...o.errors) : r.push(o);
|
|
35
|
+
}
|
|
36
|
+
throw r.length === 1 ? a : new AggregateError(r, "[Raph] Facade configuration and cleanup failed.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Показывает, завершен ли lifecycle session.
|
|
41
|
+
*/
|
|
42
|
+
get disposed() {
|
|
43
|
+
return this._disposed;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Возвращает ID default instance без создания fallback.
|
|
47
|
+
*/
|
|
48
|
+
get defaultInstanceId() {
|
|
49
|
+
return this._defaultInstance?.id;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Возвращает default либо явно адресованный instance.
|
|
53
|
+
*/
|
|
54
|
+
instance(e) {
|
|
55
|
+
if (this._assertActive(), e === void 0) {
|
|
56
|
+
if (this._defaultInstance === void 0)
|
|
57
|
+
throw new A("[Raph] Facade session has no default instance.");
|
|
58
|
+
return this._defaultInstance;
|
|
59
|
+
}
|
|
60
|
+
c(e);
|
|
61
|
+
const t = this._instances.get(e);
|
|
62
|
+
if (t === void 0)
|
|
63
|
+
throw new i(`[Raph] Instance "${e}" is not registered.`);
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Читает registry без ошибки для неизвестного ID.
|
|
68
|
+
*/
|
|
69
|
+
getInstance(e) {
|
|
70
|
+
return this._assertActive(), c(e), this._instances.get(e);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Проверяет наличие managed instance.
|
|
74
|
+
*/
|
|
75
|
+
hasInstance(e) {
|
|
76
|
+
return this.getInstance(e) !== void 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Возвращает Runtime или сообщает о capability mismatch.
|
|
80
|
+
*/
|
|
81
|
+
runtime(e) {
|
|
82
|
+
const t = this.instance(e);
|
|
83
|
+
if (!(t instanceof l))
|
|
84
|
+
throw new _(
|
|
85
|
+
`[Raph] Instance "${t.id}" uses reactivity mode and has no Runtime capabilities.`
|
|
86
|
+
);
|
|
87
|
+
return t;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Возвращает pure-reactivity instance или сообщает о capability mismatch.
|
|
91
|
+
*/
|
|
92
|
+
reactivity(e) {
|
|
93
|
+
const t = this.instance(e);
|
|
94
|
+
if (!(t instanceof w))
|
|
95
|
+
throw new _(
|
|
96
|
+
`[Raph] Instance "${t.id}" uses runtime mode and is not a pure reactivity instance.`
|
|
97
|
+
);
|
|
98
|
+
return t;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Создаёт managed Runtime без неявного изменения default pointer.
|
|
102
|
+
*/
|
|
103
|
+
createRuntime(e = {}) {
|
|
104
|
+
this._assertActive();
|
|
105
|
+
const t = e.id ?? this._generateId("runtime");
|
|
106
|
+
c(t), this._assertFreeId(t);
|
|
107
|
+
const n = new l({ ...e, id: t });
|
|
108
|
+
return this._register(n), n;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Создаёт managed pure-reactivity instance без изменения default pointer.
|
|
112
|
+
*/
|
|
113
|
+
createReactivity(e = {}) {
|
|
114
|
+
this._assertActive();
|
|
115
|
+
const t = e.id ?? this._generateId("reactivity");
|
|
116
|
+
c(t), this._assertFreeId(t);
|
|
117
|
+
const n = new w(t, e);
|
|
118
|
+
return this._register(n), n;
|
|
119
|
+
}
|
|
120
|
+
/** Создаёт unmanaged Kernel, сохраняя generation-bound lifecycle check. */
|
|
121
|
+
createKernel(e = {}) {
|
|
122
|
+
return this._assertActive(), new R(e);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Освобождает managed instance и сразу удаляет его из registry.
|
|
126
|
+
*/
|
|
127
|
+
disposeInstance(e) {
|
|
128
|
+
const t = this.getInstance(e);
|
|
129
|
+
return t === void 0 ? !1 : (t.dispose(), !0);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Освобождает managed instances в обратном порядке construction.
|
|
133
|
+
*/
|
|
134
|
+
dispose() {
|
|
135
|
+
if (this._disposed)
|
|
136
|
+
return;
|
|
137
|
+
this._disposed = !0;
|
|
138
|
+
const e = [...this._instanceOrder].reverse();
|
|
139
|
+
this._instances.clear(), this._instanceOrder.length = 0, this._defaultInstance = void 0;
|
|
140
|
+
const t = [];
|
|
141
|
+
for (const n of e)
|
|
142
|
+
try {
|
|
143
|
+
n.dispose();
|
|
144
|
+
} catch (r) {
|
|
145
|
+
t.push(r);
|
|
146
|
+
}
|
|
147
|
+
if (t.length === 1)
|
|
148
|
+
throw t[0];
|
|
149
|
+
if (t.length > 1)
|
|
150
|
+
throw new AggregateError(t, "[Raph] Facade session reset failed.");
|
|
151
|
+
}
|
|
152
|
+
// ---------------------------------------------
|
|
153
|
+
// PRIVATE
|
|
154
|
+
// ---------------------------------------------
|
|
155
|
+
/**
|
|
156
|
+
* Создаёт instance из заранее проверенного definition.
|
|
157
|
+
*/
|
|
158
|
+
_construct(e) {
|
|
159
|
+
if (e.mode === "reactivity") {
|
|
160
|
+
const r = e.config;
|
|
161
|
+
return new w(e.id, {
|
|
162
|
+
...r.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: r.adaptiveDependencyIndex }
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const t = e.config, n = new l({
|
|
166
|
+
...t.adaptiveDependencyIndex === void 0 ? {} : { adaptiveDependencyIndex: t.adaptiveDependencyIndex },
|
|
167
|
+
...t.debug === void 0 ? {} : { debug: t.debug },
|
|
168
|
+
...t.enforceActions === void 0 ? {} : { enforceActions: t.enforceActions },
|
|
169
|
+
...t.kernel === void 0 ? {} : { kernel: t.kernel },
|
|
170
|
+
...t.scheduler === void 0 ? {} : { scheduler: t.scheduler },
|
|
171
|
+
id: e.id
|
|
172
|
+
});
|
|
173
|
+
try {
|
|
174
|
+
return t.phases !== void 0 && n.definePhases(t.phases), n;
|
|
175
|
+
} catch (r) {
|
|
176
|
+
try {
|
|
177
|
+
n.dispose();
|
|
178
|
+
} catch (a) {
|
|
179
|
+
throw new AggregateError(
|
|
180
|
+
[r, a],
|
|
181
|
+
`[Raph] Runtime "${e.id}" construction and cleanup failed.`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
throw r;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Регистрирует единственный managed owner и его terminal cleanup.
|
|
189
|
+
*/
|
|
190
|
+
_register(e) {
|
|
191
|
+
this._assertFreeId(e.id), this._instances.set(e.id, e), this._instanceOrder.push(e), e._onDisposed(() => this._forget(e));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Удаляет точную identity после её terminal disposal.
|
|
195
|
+
*/
|
|
196
|
+
_forget(e) {
|
|
197
|
+
this._instances.get(e.id) === e && this._instances.delete(e.id);
|
|
198
|
+
const t = this._instanceOrder.indexOf(e);
|
|
199
|
+
t >= 0 && this._instanceOrder.splice(t, 1), this._defaultInstance === e && (this._defaultInstance = void 0);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Формирует свободный ID для dynamic factory.
|
|
203
|
+
*/
|
|
204
|
+
_generateId(e) {
|
|
205
|
+
let t;
|
|
206
|
+
do
|
|
207
|
+
t = e === "runtime" ? `runtime-${f._runtimeCounter++}` : `reactivity-${f._reactivityCounter++}`;
|
|
208
|
+
while (this._instances.has(t));
|
|
209
|
+
return t;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Отклоняет duplicate resolved ID до registration.
|
|
213
|
+
*/
|
|
214
|
+
_assertFreeId(e) {
|
|
215
|
+
if (this._instances.has(e))
|
|
216
|
+
throw new i(`[Raph] Instance id "${e}" is already registered.`);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Запрещает stale typed/global handle после reset.
|
|
220
|
+
*/
|
|
221
|
+
_assertActive() {
|
|
222
|
+
if (this._disposed)
|
|
223
|
+
throw new D("[Raph] Facade session is disposed.");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function x(s) {
|
|
227
|
+
if (typeof s != "object" || s === null || Array.isArray(s))
|
|
228
|
+
throw new i("[Raph] Configure options must be an object.");
|
|
229
|
+
if (Object.hasOwn(s, "instances")) {
|
|
230
|
+
y(s, /* @__PURE__ */ new Set(["instances"]), "configure");
|
|
231
|
+
const r = s.instances;
|
|
232
|
+
if (typeof r != "object" || r === null || Array.isArray(r))
|
|
233
|
+
throw new i("[Raph] instances must be an object.");
|
|
234
|
+
const a = [], o = /* @__PURE__ */ new Set();
|
|
235
|
+
let v = 0;
|
|
236
|
+
for (const [g, u] of Object.entries(r)) {
|
|
237
|
+
if (typeof u != "object" || u === null || Array.isArray(u))
|
|
238
|
+
throw new i(`[Raph] Instance definition "${g}" must be an object.`);
|
|
239
|
+
const d = u;
|
|
240
|
+
I(d, !0);
|
|
241
|
+
const h = d.id ?? g;
|
|
242
|
+
if (c(h), o.has(h))
|
|
243
|
+
throw new i(`[Raph] Resolved instance id "${h}" is duplicated.`);
|
|
244
|
+
o.add(h);
|
|
245
|
+
const m = d.default === !0;
|
|
246
|
+
m && v++, a.push({ config: d, default: m, id: h, mode: d.mode });
|
|
247
|
+
}
|
|
248
|
+
if (v > 1)
|
|
249
|
+
throw new i("[Raph] Exactly one instance may declare default: true.");
|
|
250
|
+
return a;
|
|
251
|
+
}
|
|
252
|
+
const e = s;
|
|
253
|
+
I(e, !1);
|
|
254
|
+
const t = e.mode ?? "runtime", n = e.id ?? "default";
|
|
255
|
+
return c(n), [{ config: e, default: !0, id: n, mode: t }];
|
|
256
|
+
}
|
|
257
|
+
function I(s, e) {
|
|
258
|
+
const t = s.mode ?? (e ? void 0 : "runtime");
|
|
259
|
+
if (t !== "runtime" && t !== "reactivity")
|
|
260
|
+
throw new i(
|
|
261
|
+
e ? "[Raph] Every instances entry must declare mode." : "[Raph] Unsupported instance mode."
|
|
262
|
+
);
|
|
263
|
+
if (t === "reactivity") {
|
|
264
|
+
if (y(s, new Set(e ? ["adaptiveDependencyIndex", "default", "id", "mode"] : ["adaptiveDependencyIndex", "id", "mode"]), "reactivity instance"), b(s.adaptiveDependencyIndex), e && s.default !== void 0 && typeof s.default != "boolean")
|
|
265
|
+
throw new i("[Raph] default must be boolean.");
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (y(s, new Set(e ? ["adaptiveDependencyIndex", "debug", "default", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"] : ["adaptiveDependencyIndex", "debug", "enforceActions", "id", "kernel", "mode", "phases", "scheduler"]), "runtime instance"), b(s.adaptiveDependencyIndex), e && s.default !== void 0 && typeof s.default != "boolean")
|
|
269
|
+
throw new i("[Raph] default must be boolean.");
|
|
270
|
+
const n = s;
|
|
271
|
+
if (n.enforceActions !== void 0 && typeof n.enforceActions != "boolean")
|
|
272
|
+
throw new i("[Raph] enforceActions must be boolean.");
|
|
273
|
+
if (n.kernel !== void 0 && !(n.kernel instanceof R))
|
|
274
|
+
throw new i("[Raph] kernel must be a RaphKernel instance.");
|
|
275
|
+
if (n.phases !== void 0 && !Array.isArray(n.phases))
|
|
276
|
+
throw new i("[Raph] phases must be an array.");
|
|
277
|
+
if (n.scheduler !== void 0 && !k(n.scheduler))
|
|
278
|
+
throw new i(`[Raph] Unsupported scheduler "${String(n.scheduler)}".`);
|
|
279
|
+
if (n.debug !== void 0 && (typeof n.debug != "object" || n.debug === null))
|
|
280
|
+
throw new i("[Raph] debug must be an object.");
|
|
281
|
+
}
|
|
282
|
+
function b(s) {
|
|
283
|
+
if (s !== void 0 && typeof s != "boolean")
|
|
284
|
+
throw new i("[Raph] adaptiveDependencyIndex must be boolean.");
|
|
285
|
+
}
|
|
286
|
+
function y(s, e, t) {
|
|
287
|
+
for (const n of Object.keys(s))
|
|
288
|
+
if (!e.has(n))
|
|
289
|
+
throw new i(`[Raph] Unsupported ${t} option "${n}".`);
|
|
290
|
+
}
|
|
291
|
+
function c(s) {
|
|
292
|
+
if (typeof s != "string" || s.length === 0 || s.trim() !== s)
|
|
293
|
+
throw new i(
|
|
294
|
+
"[Raph] Instance id must be a non-empty string without surrounding whitespace."
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
function k(s) {
|
|
298
|
+
return s === p.Sync || s === p.Microtask || s === p.AnimationFrame;
|
|
299
|
+
}
|
|
300
|
+
export {
|
|
301
|
+
f as RaphFacadeSession
|
|
302
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../reactivity/engine.cjs"),r=require("../reactivity/reactive-object.cjs"),a=require("../reactivity/scope.cjs"),o=require("../runtime/errors.cjs");class h{constructor(e,t={}){this.id=e,this.engine=new c.RaphReactivity({adaptiveDependencyIndex:t.adaptiveDependencyIndex??!1}),this.rootScope=new a.ScopeNode(this.engine),r.configureReactiveObjectPolicy(this.engine,{owner:this,assertRead:()=>this._assertAlive(),assertWrite:()=>this._assertAlive(),throwForeign:()=>{throw new TypeError("[Raph] Reactive object belongs to another reactivity instance.")}})}mode="reactivity";engine;rootScope;_disposed=!1;_disposedListeners=new Set;get disposed(){return this._disposed}signal(e){return this._assertAlive(),this.rootScope.signal(e)}reactive(e){return this._assertAlive(),this.engine.reactive(e)}computed(e){return this._assertAlive(),typeof e=="function"?this.rootScope.computed(e):this.rootScope.computed(e)}effect(e){return this._assertAlive(),this.rootScope.effect(e)}watch(e,t,i){return this._assertAlive(),this.rootScope.watch(e,t,i)}batch(e){return this._assertAlive(),this.engine.batch(e)}untracked(e){return this._assertAlive(),this.engine.untracked(e)}scope(){this._assertAlive();const e=this.engine.scope();return this.rootScope.own(()=>e.dispose()),e}dispose(){if(this._disposed)return;this._disposed=!0;const e=[];try{this.rootScope.dispose()}catch(s){e.push(s)}const t=()=>{throw new o.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)};try{r.disposeReactiveObjectContext(this.engine,{assertRead:t,assertWrite:t,throwForeign:t})}catch(s){e.push(s)}const i=[...this._disposedListeners];this._disposedListeners.clear();for(const s of i)try{s()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,`[Raph] Reactivity instance "${this.id}" disposal failed.`)}_onDisposed(e){return this._disposed?(e(),()=>{}):(this._disposedListeners.add(e),()=>{this._disposedListeners.delete(e)})}_assertAlive(){if(this._disposed)throw new o.RaphDisposedError(`[Raph] Reactivity instance "${this.id}" is disposed.`)}}exports.RaphReactivityInstance=h;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { RaphReactivity as n } from "../reactivity/engine.js";
|
|
2
|
+
import { configureReactiveObjectPolicy as h, disposeReactiveObjectContext as a } from "../reactivity/reactive-object.js";
|
|
3
|
+
import { ScopeNode as c } from "../reactivity/scope.js";
|
|
4
|
+
import { RaphDisposedError as r } from "../runtime/errors.js";
|
|
5
|
+
class u {
|
|
6
|
+
/**
|
|
7
|
+
* Создаёт изолированный graph с общим lifecycle owner.
|
|
8
|
+
*/
|
|
9
|
+
constructor(e, t = {}) {
|
|
10
|
+
this.id = e, this.engine = new n({
|
|
11
|
+
adaptiveDependencyIndex: t.adaptiveDependencyIndex ?? !1
|
|
12
|
+
}), this.rootScope = new c(this.engine), h(this.engine, {
|
|
13
|
+
owner: this,
|
|
14
|
+
assertRead: () => this._assertAlive(),
|
|
15
|
+
assertWrite: () => this._assertAlive(),
|
|
16
|
+
throwForeign: () => {
|
|
17
|
+
throw new TypeError("[Raph] Reactive object belongs to another reactivity instance.");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
mode = "reactivity";
|
|
22
|
+
engine;
|
|
23
|
+
rootScope;
|
|
24
|
+
_disposed = !1;
|
|
25
|
+
_disposedListeners = /* @__PURE__ */ new Set();
|
|
26
|
+
// ---------------------------------------------
|
|
27
|
+
// PUBLIC API
|
|
28
|
+
// ---------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Показывает, завершён ли lifecycle instance.
|
|
31
|
+
*/
|
|
32
|
+
get disposed() {
|
|
33
|
+
return this._disposed;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Создаёт signal, принадлежащий root scope instance.
|
|
37
|
+
*/
|
|
38
|
+
signal(e) {
|
|
39
|
+
return this._assertAlive(), this.rootScope.signal(e);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Создаёт deep reactive Proxy в изолированном graph instance.
|
|
43
|
+
*/
|
|
44
|
+
reactive(e) {
|
|
45
|
+
return this._assertAlive(), this.engine.reactive(e);
|
|
46
|
+
}
|
|
47
|
+
computed(e) {
|
|
48
|
+
return this._assertAlive(), typeof e == "function" ? this.rootScope.computed(e) : this.rootScope.computed(e);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Создаёт синхронный effect в root scope instance.
|
|
52
|
+
*/
|
|
53
|
+
effect(e) {
|
|
54
|
+
return this._assertAlive(), this.rootScope.effect(e);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Создаёт value watch в root scope instance.
|
|
58
|
+
*/
|
|
59
|
+
watch(e, t, i) {
|
|
60
|
+
return this._assertAlive(), this.rootScope.watch(e, t, i);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Группирует propagation одного reactive graph.
|
|
64
|
+
*/
|
|
65
|
+
batch(e) {
|
|
66
|
+
return this._assertAlive(), this.engine.batch(e);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Выполняет операцию без dependency tracking.
|
|
70
|
+
*/
|
|
71
|
+
untracked(e) {
|
|
72
|
+
return this._assertAlive(), this.engine.untracked(e);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Создаёт дочерний resource scope, освобождаемый вместе с instance.
|
|
76
|
+
*/
|
|
77
|
+
scope() {
|
|
78
|
+
this._assertAlive();
|
|
79
|
+
const e = this.engine.scope();
|
|
80
|
+
return this.rootScope.own(() => e.dispose()), e;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Освобождает owned resources и делает retained reactive proxies терминальными.
|
|
84
|
+
*/
|
|
85
|
+
dispose() {
|
|
86
|
+
if (this._disposed)
|
|
87
|
+
return;
|
|
88
|
+
this._disposed = !0;
|
|
89
|
+
const e = [];
|
|
90
|
+
try {
|
|
91
|
+
this.rootScope.dispose();
|
|
92
|
+
} catch (s) {
|
|
93
|
+
e.push(s);
|
|
94
|
+
}
|
|
95
|
+
const t = () => {
|
|
96
|
+
throw new r(`[Raph] Reactivity instance "${this.id}" is disposed.`);
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
a(this.engine, {
|
|
100
|
+
assertRead: t,
|
|
101
|
+
assertWrite: t,
|
|
102
|
+
throwForeign: t
|
|
103
|
+
});
|
|
104
|
+
} catch (s) {
|
|
105
|
+
e.push(s);
|
|
106
|
+
}
|
|
107
|
+
const i = [...this._disposedListeners];
|
|
108
|
+
this._disposedListeners.clear();
|
|
109
|
+
for (const s of i)
|
|
110
|
+
try {
|
|
111
|
+
s();
|
|
112
|
+
} catch (o) {
|
|
113
|
+
e.push(o);
|
|
114
|
+
}
|
|
115
|
+
if (e.length === 1)
|
|
116
|
+
throw e[0];
|
|
117
|
+
if (e.length > 1)
|
|
118
|
+
throw new AggregateError(e, `[Raph] Reactivity instance "${this.id}" disposal failed.`);
|
|
119
|
+
}
|
|
120
|
+
// ---------------------------------------------
|
|
121
|
+
// INTERNAL
|
|
122
|
+
// ---------------------------------------------
|
|
123
|
+
/**
|
|
124
|
+
* Привязывает registry cleanup к lifecycle managed instance.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
_onDisposed(e) {
|
|
128
|
+
return this._disposed ? (e(), () => {
|
|
129
|
+
}) : (this._disposedListeners.add(e), () => {
|
|
130
|
+
this._disposedListeners.delete(e);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// ---------------------------------------------
|
|
134
|
+
// PRIVATE
|
|
135
|
+
// ---------------------------------------------
|
|
136
|
+
/**
|
|
137
|
+
* Запрещает операции после завершения lifecycle.
|
|
138
|
+
*/
|
|
139
|
+
_assertAlive() {
|
|
140
|
+
if (this._disposed)
|
|
141
|
+
throw new r(`[Raph] Reactivity instance "${this.id}" is disposed.`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
u as RaphReactivityInstance
|
|
146
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class e extends Error{}class a extends e{}class s extends a{}class o extends a{}class t extends a{}exports.RaphCapabilityError=s;exports.RaphConfigurationError=a;exports.RaphDefaultInstanceError=o;exports.RaphError=e;exports.RaphFacadeDisposedError=t;
|
package/dist/debug/api/errors.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
class
|
|
1
|
+
class a extends Error {
|
|
2
|
+
}
|
|
3
|
+
class s extends a {
|
|
2
4
|
}
|
|
3
5
|
class e extends s {
|
|
4
6
|
}
|
|
5
|
-
class
|
|
7
|
+
class o extends s {
|
|
6
8
|
}
|
|
7
|
-
class
|
|
9
|
+
class t extends s {
|
|
8
10
|
}
|
|
9
11
|
export {
|
|
10
|
-
e as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
a as
|
|
12
|
+
e as RaphCapabilityError,
|
|
13
|
+
s as RaphConfigurationError,
|
|
14
|
+
o as RaphDefaultInstanceError,
|
|
15
|
+
a as RaphError,
|
|
16
|
+
t as RaphFacadeDisposedError
|
|
14
17
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=2e4;class u{static _cache;_canonical;_segments;_exact;_mask;constructor(e,n){this._canonical=e,this._segments=Object.freeze(n.map(i=>Object.freeze({...i})))}static from(e,n){return e instanceof u?e:typeof e=="string"?this.fromString(e,n):this.fromPlain(e)}static fromString(e,n){const i=g(e,n?.vars,!0,n?.wildcardDynamic===!0,!0),s=this._cache??=new Map,r=s.get(i.canonical);if(r!==void 0)return r;s.size>=_&&s.clear();const a=new u(i.canonical,i.segments);return s.set(i.canonical,a),a}static fromPlain(e){const i=(Array.isArray(e.segs)?e.segs:[]).map(N);return new u(m(i),i)}static _parseExactString(e,n){const i=g(e,n?.vars,!1,!1,!0);return{canonical:i.canonical,segments:i.segments}}static _parseMaskString(e){const n=g(e,void 0,!0,!1,!0);for(let r=0;r<n.segments.length-1;r++){const a=n.segments[r];if(a.kind==="wildcard"&&!a.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${e}".`)}const i=n.segments[n.segments.length-1],s=i?.kind==="wildcard"&&!i.indexed;return{canonical:n.canonical,deep:s,segments:s?n.segments.slice(0,-1):n.segments}}static _renderSegments(e){return m(e)}toPlain(){return{segs:this._segments.map(e=>e.kind==="key"?{t:"key",k:e.key}:e.kind==="index"?{t:"idx",i:e.index}:e.kind==="selector"?{t:"param",pk:e.key,pv:e.value}:{t:"wc",indexed:e.indexed}),deepOnTail:b(this._segments)}}toStringPath(){return this._canonical}toString(){return this._canonical}segments(){return this._segments}static match(e,n){const i=this.from(e)._segments,s=this.from(n)._segments;let r=0;for(;r<i.length;r++){const a=i[r];if(a.kind==="wildcard"&&!a.indexed&&r===i.length-1)return!0;const c=s[r];if(c===void 0||!A(a,c))return!1}return r===s.length}_asExact(){for(const e of this._segments)if(e.kind==="wildcard")throw w(this._canonical);return this._exact??={canonical:this._canonical,segments:this._segments}}_asMask(){for(let n=0;n<this._segments.length-1;n++){const i=this._segments[n];if(i.kind==="wildcard"&&!i.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${this._canonical}".`)}const e=b(this._segments);return this._mask??={canonical:this._canonical,deep:e,segments:e?this._segments.slice(0,-1):this._segments}}}function g(t,e,n,i=!1,s=!1){const r=t.trim();if(r.length===0){if(s)return{canonical:"",segments:[]};throw new TypeError("[Raph] Data path must not be empty.")}const a=[];let c=0,o=!0;for(;c<r.length;){const y=r[c];if(y==="."){if(o)throw l(t);o=!0,c++;continue}if(y==="["){const x=$(r,c);a.push(v(r.slice(c+1,x),e,n,i)),c=x+1,o=!1;continue}if(!o)throw l(t);let d=c;for(;d<r.length&&r[d]!=="."&&r[d]!=="[";)d++;const f=r.slice(c,d).trim();if(f.length===0)throw l(t);if(f==="*"){if(!n)throw w(t);a.push({kind:"wildcard",indexed:!1})}else i&&f.startsWith("$")&&!h(f.slice(1),e)?a.push({kind:"wildcard",indexed:!1}):a.push({kind:"key",key:P(f,e)});c=d,o=!1}if(o||a.length===0)throw l(t);return{canonical:m(a),segments:a}}function $(t,e){let n,i=1;for(let s=e+1;s<t.length;s++){const r=t[s];if(r==="\\"){s++;continue}if(n!==void 0){r===n&&(n=void 0);continue}if(r==='"'||r==="'"){n=r;continue}if(r==="["){i++;continue}if(r==="]"&&--i===0)return s}throw l(t)}function v(t,e,n,i){const s=t.trim();if(s==="*"){if(!n)throw w(`[${t}]`);return{kind:"wildcard",indexed:!0}}if(/^\d+$/.test(s))return{kind:"index",index:Number(s)};if(/^\$[A-Z_$][\w$]*$/i.test(s)){if(i&&!h(s.slice(1),e))return{kind:"wildcard",indexed:!0};const o=p(s.slice(1),e);if(!Number.isInteger(o)||o<0)throw new TypeError(`[Raph] Index variable "${s}" must be a non-negative integer.`);return{kind:"index",index:o}}const r=S(s);if(r===-1)throw l(`[${t}]`);const a=s.slice(0,r).trim(),c=s.slice(r+1).trim();if(!a||!c)throw l(`[${t}]`);return i&&R(c,e)?{kind:"wildcard",indexed:!0}:{kind:"selector",key:a,value:E(c,e)}}function S(t){let e;for(let n=0;n<t.length;n++){const i=t[n];if(i==="\\"){n++;continue}if(e!==void 0){i===e&&(e=void 0);continue}if(i==='"'||i==="'")e=i;else if(i==="=")return n}return-1}function E(t,e){if(/^\$[A-Z_$][\w$]*$/i.test(t)){const n=p(t.slice(1),e);if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"&&Number.isFinite(n))return n;throw new TypeError(`[Raph] Selector variable "${t}" must be scalar.`)}if(t[0]==='"'||t[0]==="'")return T(t);if(/^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(t)){const n=Number(t);if(Number.isFinite(n))return n}return t==="true"?!0:t==="false"?!1:t==="null"?null:t}function T(t){const e=t[0];if(t.length<2||t[t.length-1]!==e)throw l(t);if(e==='"')try{const i=JSON.parse(t);if(typeof i=="string")return i}catch{throw l(t)}let n="";for(let i=1;i<t.length-1;i++){const s=t[i];if(s==="\\"){if(i++,i>=t.length-1)throw l(t);n+=t[i]}else n+=s}return n}function P(t,e){if(!t.startsWith("$"))return t;const n=p(t.slice(1),e);if(typeof n!="string"&&typeof n!="number")throw new TypeError(`[Raph] Key variable "${t}" must be a string or number.`);const i=String(n);if(!i||i.includes(".")||i.includes("[")||i.includes("]"))throw new TypeError(`[Raph] Key variable "${t}" contains path syntax.`);return i}function p(t,e){if(!h(t,e))throw new TypeError(`[Raph] Missing path variable "${t}".`);return e[t]}function h(t,e){return e!==void 0&&Object.hasOwn(e,t)}function R(t,e){for(const n of t.matchAll(/\$([A-Z_$][\w$]*)/gi))if(!h(n[1],e))return!0;return!1}function N(t){if(typeof t!="object"||t===null)throw k();const e=t;if(e.t==="key"&&typeof e.k=="string")return{kind:"key",key:e.k};if(e.t==="idx"&&typeof e.i=="number"&&Number.isInteger(e.i)&&e.i>=0)return{kind:"index",index:e.i};if(e.t==="wc")return{kind:"wildcard",indexed:e.indexed===!0};if(e.t==="param"&&typeof e.pk=="string"&&O(e.pv))return{kind:"selector",key:e.pk,value:e.pv};throw k()}function O(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function b(t){const e=t[t.length-1];return e?.kind==="wildcard"&&!e.indexed}function A(t,e){return t.kind==="wildcard"?!t.indexed||e.kind==="index"||e.kind==="selector":t.kind!==e.kind?!1:t.kind==="key"?t.key===e.key:t.kind==="index"?t.index===e.index:t.key===e.key&&Object.is(t.value,e.value)}function m(t){let e="";for(const n of t)n.kind==="key"?e+=e?`.${n.key}`:n.key:n.kind==="index"?e+=`[${n.index}]`:n.kind==="selector"?e+=`[${n.key}=${I(n.value)}]`:e+=n.indexed?"[*]":e?".*":"*";return e}function I(t){return typeof t=="string"?JSON.stringify(t):String(t)}function l(t){return new TypeError(`[Raph] Invalid data path "${t}".`)}function k(){return new TypeError("[Raph] Invalid plain DataPath representation.")}function w(t){return new TypeError(`[Raph] Wildcard is only allowed in watch masks: "${t}".`)}exports.DataPath=u;
|