@exactjs/core 0.6.1 → 0.6.3
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/AGENTS.md +12 -14
- package/README.md +6 -8
- package/dist/client/component-contract/continuation-validation.d.ts +5 -0
- package/dist/client/component-contract/continuation-validation.d.ts.map +1 -1
- package/dist/client/component-contract/continuation-validation.js +7 -0
- package/dist/client/component-contract/continuation-validation.js.map +1 -1
- package/dist/client/component-contract/contract-validation.d.ts.map +1 -1
- package/dist/client/component-contract/contract-validation.js +4 -1
- package/dist/client/component-contract/contract-validation.js.map +1 -1
- package/dist/client/component-contracts.d.ts +5 -0
- package/dist/client/component-contracts.d.ts.map +1 -1
- package/dist/client/component-contracts.js.map +1 -1
- package/dist/client/framework/component-contract-validation.d.ts +1 -1
- package/dist/client/framework/component-contract-validation.d.ts.map +1 -1
- package/dist/client/framework/component-contract-validation.js +1 -1
- package/dist/client/framework/component-contract-validation.js.map +1 -1
- package/dist/client/framework/operation-protocol.d.ts +9 -0
- package/dist/client/framework/operation-protocol.d.ts.map +1 -1
- package/dist/client/framework/operation-protocol.js.map +1 -1
- package/dist/client/framework/server-task-helpers.d.ts +1 -0
- package/dist/client/framework/server-task-helpers.d.ts.map +1 -1
- package/dist/client/framework/server-task-helpers.js +1 -0
- package/dist/client/framework/server-task-helpers.js.map +1 -1
- package/dist/client/framework/task-frames.d.ts +2 -1
- package/dist/client/framework/task-frames.d.ts.map +1 -1
- package/dist/client/framework/task-frames.js +1 -0
- package/dist/client/framework/task-frames.js.map +1 -1
- package/dist/client/runtime/tasks.d.ts +1 -0
- package/dist/client/runtime/tasks.d.ts.map +1 -1
- package/dist/client/runtime/tasks.js +1 -0
- package/dist/client/runtime/tasks.js.map +1 -1
- package/dist/client/tasks/contracts.d.ts +2 -0
- package/dist/client/tasks/contracts.d.ts.map +1 -1
- package/dist/client/tasks/contracts.js.map +1 -1
- package/dist/client/tasks/frame-continuation.d.ts +1 -1
- package/dist/client/tasks/frame-continuation.d.ts.map +1 -1
- package/dist/client/tasks/frame-continuation.js +21 -10
- package/dist/client/tasks/frame-continuation.js.map +1 -1
- package/dist/client/tasks/frame-runtime.d.ts +2 -2
- package/dist/client/tasks/frame-runtime.d.ts.map +1 -1
- package/dist/client/tasks/frame-runtime.js +14 -6
- package/dist/client/tasks/frame-runtime.js.map +1 -1
- package/dist/client/tasks/progress-bindings.d.ts +20 -0
- package/dist/client/tasks/progress-bindings.d.ts.map +1 -0
- package/dist/client/tasks/progress-bindings.js +51 -0
- package/dist/client/tasks/progress-bindings.js.map +1 -0
- package/dist/client/tasks/progress-receiver.d.ts +24 -0
- package/dist/client/tasks/progress-receiver.d.ts.map +1 -0
- package/dist/client/tasks/progress-receiver.js +71 -0
- package/dist/client/tasks/progress-receiver.js.map +1 -0
- package/dist/client/tasks/resources.d.ts.map +1 -1
- package/dist/client/tasks/resources.js +6 -3
- package/dist/client/tasks/resources.js.map +1 -1
- package/dist/client/tasks/scheduled-reactions.d.ts.map +1 -1
- package/dist/client/tasks/scheduled-reactions.js +9 -2
- package/dist/client/tasks/scheduled-reactions.js.map +1 -1
- package/dist/component-contract/continuation-validation.d.ts +5 -0
- package/dist/component-contract/continuation-validation.d.ts.map +1 -1
- package/dist/component-contract/continuation-validation.js +7 -0
- package/dist/component-contract/continuation-validation.js.map +1 -1
- package/dist/component-contract/contract-validation.d.ts.map +1 -1
- package/dist/component-contract/contract-validation.js +4 -1
- package/dist/component-contract/contract-validation.js.map +1 -1
- package/dist/component-contracts.d.ts +5 -0
- package/dist/component-contracts.d.ts.map +1 -1
- package/dist/component-contracts.js.map +1 -1
- package/dist/framework/component-contract-validation.d.ts +1 -1
- package/dist/framework/component-contract-validation.d.ts.map +1 -1
- package/dist/framework/component-contract-validation.js +1 -1
- package/dist/framework/component-contract-validation.js.map +1 -1
- package/dist/framework/operation-protocol.d.ts +9 -0
- package/dist/framework/operation-protocol.d.ts.map +1 -1
- package/dist/framework/operation-protocol.js.map +1 -1
- package/dist/framework/server-task-helpers.d.ts +1 -0
- package/dist/framework/server-task-helpers.d.ts.map +1 -1
- package/dist/framework/server-task-helpers.js +1 -0
- package/dist/framework/server-task-helpers.js.map +1 -1
- package/dist/framework/task-frames.d.ts +2 -1
- package/dist/framework/task-frames.d.ts.map +1 -1
- package/dist/framework/task-frames.js +1 -0
- package/dist/framework/task-frames.js.map +1 -1
- package/dist/runtime/tasks.d.ts +1 -0
- package/dist/runtime/tasks.d.ts.map +1 -1
- package/dist/runtime/tasks.js +1 -0
- package/dist/runtime/tasks.js.map +1 -1
- package/dist/server/component-contract/continuation-validation.d.ts +5 -0
- package/dist/server/component-contract/continuation-validation.d.ts.map +1 -1
- package/dist/server/component-contract/continuation-validation.js +7 -0
- package/dist/server/component-contract/continuation-validation.js.map +1 -1
- package/dist/server/component-contract/contract-validation.d.ts.map +1 -1
- package/dist/server/component-contract/contract-validation.js +4 -1
- package/dist/server/component-contract/contract-validation.js.map +1 -1
- package/dist/server/component-contracts.d.ts +5 -0
- package/dist/server/component-contracts.d.ts.map +1 -1
- package/dist/server/component-contracts.js.map +1 -1
- package/dist/server/framework/component-contract-validation.d.ts +1 -1
- package/dist/server/framework/component-contract-validation.d.ts.map +1 -1
- package/dist/server/framework/component-contract-validation.js +1 -1
- package/dist/server/framework/component-contract-validation.js.map +1 -1
- package/dist/server/framework/operation-protocol.d.ts +9 -0
- package/dist/server/framework/operation-protocol.d.ts.map +1 -1
- package/dist/server/framework/operation-protocol.js.map +1 -1
- package/dist/server/framework/server-task-helpers.d.ts +1 -0
- package/dist/server/framework/server-task-helpers.d.ts.map +1 -1
- package/dist/server/framework/server-task-helpers.js +1 -0
- package/dist/server/framework/server-task-helpers.js.map +1 -1
- package/dist/server/framework/task-frames.d.ts +2 -1
- package/dist/server/framework/task-frames.d.ts.map +1 -1
- package/dist/server/framework/task-frames.js +1 -0
- package/dist/server/framework/task-frames.js.map +1 -1
- package/dist/server/runtime/tasks.d.ts +1 -0
- package/dist/server/runtime/tasks.d.ts.map +1 -1
- package/dist/server/runtime/tasks.js +1 -0
- package/dist/server/runtime/tasks.js.map +1 -1
- package/dist/server/tasks/contracts.d.ts +2 -0
- package/dist/server/tasks/contracts.d.ts.map +1 -1
- package/dist/server/tasks/contracts.js.map +1 -1
- package/dist/server/tasks/frame-continuation.d.ts +1 -1
- package/dist/server/tasks/frame-continuation.d.ts.map +1 -1
- package/dist/server/tasks/frame-continuation.js +21 -10
- package/dist/server/tasks/frame-continuation.js.map +1 -1
- package/dist/server/tasks/frame-runtime.d.ts +2 -2
- package/dist/server/tasks/frame-runtime.d.ts.map +1 -1
- package/dist/server/tasks/frame-runtime.js +14 -6
- package/dist/server/tasks/frame-runtime.js.map +1 -1
- package/dist/server/tasks/progress-bindings.d.ts +20 -0
- package/dist/server/tasks/progress-bindings.d.ts.map +1 -0
- package/dist/server/tasks/progress-bindings.js +51 -0
- package/dist/server/tasks/progress-bindings.js.map +1 -0
- package/dist/server/tasks/progress-receiver.d.ts +24 -0
- package/dist/server/tasks/progress-receiver.d.ts.map +1 -0
- package/dist/server/tasks/progress-receiver.js +71 -0
- package/dist/server/tasks/progress-receiver.js.map +1 -0
- package/dist/server/tasks/resources.d.ts.map +1 -1
- package/dist/server/tasks/resources.js +6 -3
- package/dist/server/tasks/resources.js.map +1 -1
- package/dist/server/tasks/scheduled-reactions.d.ts.map +1 -1
- package/dist/server/tasks/scheduled-reactions.js +9 -2
- package/dist/server/tasks/scheduled-reactions.js.map +1 -1
- package/dist/tasks/contracts.d.ts +2 -0
- package/dist/tasks/contracts.d.ts.map +1 -1
- package/dist/tasks/contracts.js.map +1 -1
- package/dist/tasks/frame-continuation.d.ts +1 -1
- package/dist/tasks/frame-continuation.d.ts.map +1 -1
- package/dist/tasks/frame-continuation.js +21 -10
- package/dist/tasks/frame-continuation.js.map +1 -1
- package/dist/tasks/frame-runtime.d.ts +2 -2
- package/dist/tasks/frame-runtime.d.ts.map +1 -1
- package/dist/tasks/frame-runtime.js +14 -6
- package/dist/tasks/frame-runtime.js.map +1 -1
- package/dist/tasks/progress-bindings.d.ts +20 -0
- package/dist/tasks/progress-bindings.d.ts.map +1 -0
- package/dist/tasks/progress-bindings.js +51 -0
- package/dist/tasks/progress-bindings.js.map +1 -0
- package/dist/tasks/progress-receiver.d.ts +24 -0
- package/dist/tasks/progress-receiver.d.ts.map +1 -0
- package/dist/tasks/progress-receiver.js +71 -0
- package/dist/tasks/progress-receiver.js.map +1 -0
- package/dist/tasks/resources.d.ts.map +1 -1
- package/dist/tasks/resources.js +6 -3
- package/dist/tasks/resources.js.map +1 -1
- package/dist/tasks/scheduled-reactions.d.ts.map +1 -1
- package/dist/tasks/scheduled-reactions.js +9 -2
- package/dist/tasks/scheduled-reactions.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/component/error-boundary.js.map +0 -1
- package/dist/server/component/error-boundary.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame-runtime.js","sourceRoot":"","sources":["../../src/tasks/frame-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,EAE9B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EACN,mBAAmB,EACnB,cAAc,EAKd,MAAM,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ime';\nimport type { TaskContext, TaskOwner } from './contracts.js';\nimport { raceTaskCancellation, TaskCancellation } from './cancellation.js';\nimport {\n\tregisterTaskFrameSignal,\n\treleaseTaskFrameSignal,\n\tresumeTaskFrameContinuation\n} from './frame-continuation.js';\nimport { createTaskFrameContext, frameForTaskContext } from './frame-context.js';\nimport {\n\tpublishTaskFrameEvent,\n\ttaskFrameInspectionAttached\n} from './frame-inspection-capability.js';\nimport {\n\tregisterTaskFrameSettlement,\n\trunTaskFrameCleanups,\n\tsettleTaskFrameChildren\n} from './frame-settlement.js';\nimport { createLazyTaskOwnerRecord } from './owner-record.js';\nimport { acquireScheduledReactionBatch } from './scheduled-reactions.js';\n\nimport {\n\ttaskFrameTokenBrand,\n\ttaskOwnerBrand,\n\ttype InternalTaskFrameOptions,\n\ttype TaskFrameCleanup,\n\ttype TaskFrameRecord,\n\ttype TaskOwnerRecord\n} from './frame-contracts.js';\nexport type {\n\tInternalTaskFrameOptions,\n\tTaskActivationRegistration,\n\tTaskFrameRecord,\n\tTaskOwnerRecord\n} from './frame-contracts.js';\nlet nextFrameId = 1;\nlet currentFrame: TaskFrameRecord | undefined;\nlet currentOwner: TaskOwnerRecord | undefined;\nlet deferredFrameMaterializer: (() => TaskFrameRecord) | undefined;\nlet scheduledWorkCaptureInstalled = false;\nconst synchronousFrameErrors = new WeakMap<Promise<unknown>, { readonly error: unknown }>();\n\n/** Creates a durable task owner and its cancellation lifetime. */\nexport function createTaskOwnerRecord(label?: string): TaskOwnerRecord {\n\treturn createLazyTaskOwnerRecord(label);\n}\n\n/** Retains setup-owned cleanup until its durable task owner is disposed. */\nexport function registerTaskOwnerCleanup(owner: TaskOwnerRecord, cleanup: TaskFrameCleanup): void {\n\tif (owner.disposed) throw new Error('Task owner has been disposed');\n\towner.ownerCleanups.add(cleanup);\n}\n\n/** Validates and returns the internal representation of a public owner. */\nexport function taskOwnerRecord(owner: TaskOwner): TaskOwnerRecord {\n\tif (!(taskOwnerBrand in owner)) throw new TypeError('Task owner was not created by eXact');\n\treturn owner as TaskOwnerRecord;\n}\n\n/** Returns the frame active for the current synchronous execution segment. */\nexport function currentTaskFrameRecord(): TaskFrameRecord | undefined {\n\treturn currentFrame;\n}\n\n/** Materializes an interaction frame only when synchronous work requests structural ownership. */\nexport function materializeDeferredTaskFrame(): TaskFrameRecord | undefined {\n\treturn deferredFrameMaterializer?.();\n}\n\n/** Installs the lazy structural parent available to task and navigation operations during work. */\nexport function withDeferredTaskFrame<T>(materialize: () => TaskFrameRecord, work: () => T): T {\n\tconst previous = deferredFrameMaterializer;\n\tdeferredFrameMaterializer = materialize;\n\ttry {\n\t\treturn work();\n\t} finally {\n\t\tdeferredFrameMaterializer = previous;\n\t}\n}\n\n/** Returns the durable owner supplied by the current framework host. */\nexport function currentTaskOwnerRecord(): TaskOwnerRecord | undefined {\n\treturn currentFrame?.owner ?? currentOwner;\n}\n\n/** Establishes a durable host owner during component state-machine construction or adapter setup. */\nexport function withTaskOwnerRecord<T>(owner: TaskOwnerRecord, work: () => T): T {\n\tconst previous = currentOwner;\n\tcurrentOwner = owner;\n\ttry {\n\t\treturn work();\n\t} finally {\n\t\tcurrentOwner = previous;\n\t}\n}\n\n/** Runs a synchronous segment with one frame as ambient context. */\nexport function withTaskFrameRecord<T>(frame: TaskFrameRecord, work: () => T): T {\n\tif (frame.settled) throw new Error('Cannot resume a settled task frame');\n\tensureScheduledWorkContextCapture();\n\tconst previous = currentFrame;\n\tcurrentFrame = frame;\n\ttry {\n\t\treturn work();\n\t} finally {\n\t\tcurrentFrame = previous;\n\t}\n}\n\n/**\n * Runs work in a frame, then waits for dynamically attached descendants and\n * executes cleanup in last-in-first-out order.\n */\nexport function executeTaskFrame<T>(\n\toptions: InternalTaskFrameOptions,\n\twork: (context: TaskContext) => T | PromiseLike<T>\n): Promise<T> {\n\tconst structuralParent = options.detached ? undefined : (options.parent ?? currentFrame);\n\tif (\n\t\tstructuralParent &&\n\t\t!options.parentReserved &&\n\t\t(!structuralParent.producerOpen || structuralParent.settled)\n\t)\n\t\treturn Promise.reject(\n\t\t\tnew Error('Cannot attach work after the parent task producer has closed')\n\t\t);\n\tconst owner =\n\t\toptions.owner ?? structuralParent?.owner ?? createTaskOwnerRecord('implicit task invocation');\n\tif (owner.disposed) return Promise.reject(new Error('Task owner has been disposed'));\n\tconst controller = options.controller ?? new AbortController();\n\t// The owner cancels its active frame controllers directly during disposal. Subscribing every\n\t// frame to its durable signal would retain settled controllers until the owner itself is released.\n\tif (structuralParent) linkAbort(structuralParent.controller.signal, controller);\n\n\tlet resolveSettlement!: () => void;\n\tlet rejectSettlement!: (error: unknown) => void;\n\tconst settlement = new Promise<void>((resolve, reject) => {\n\t\tresolveSettlement = resolve;\n\t\trejectSettlement = reject;\n\t});\n\tconst frame: TaskFrameRecord = {\n\t\t[taskFrameTokenBrand]: true as const,\n\t\tid: nextFrameId++,\n\t\towner,\n\t\tparent: structuralParent,\n\t\tcontroller,\n\t\t...(options.label === undefined ? {} : { label: options.label }),\n\t\t...(options.sourceEntityId === undefined ? {} : { sourceEntityId: options.sourceEntityId }),\n\t\tactivation: options.activation ?? 'invoked',\n\t\tgeneration: options.generation ?? 1,\n\t\tplacement: options.placement ?? 'current',\n\t\tconcurrency: options.concurrency ?? 'parallel',\n\t\tpriority: options.priority ?? structuralParent?.priority ?? 'normal',\n\t\treadiness:\n\t\t\toptions.readiness ??\n\t\t\t(options.priority === 'deferred'\n\t\t\t\t? 'nonblocking'\n\t\t\t\t: (structuralParent?.readiness ?? 'blocking')),\n\t\tkind: options.kind ?? 'task',\n\t\tproducerOpen: true,\n\t\tsettled: false,\n\t\tstartedAt: monotonicTimestamp()\n\t};\n\tif (options.publicContext !== false)\n\t\t(frame as { context: TaskContext }).context = createTaskFrameContext(frame, options);\n\tregisterTaskFrameSignal(controller.signal, frame);\n\tregisterTaskFrameSettlement(frame, settlement);\n\towner.frames.add(frame);\n\tconst inspectedAtStart = taskFrameInspectionAttached(frame);\n\tif (inspectedAtStart) {\n\t\tpublishTaskFrameEvent(frame, 'task.frame.enter');\n\t\tpublishTaskFrameEvent(frame, 'task.start', undefined, {\n\t\t\tkind: 'start',\n\t\t\targuments: options.inspectionArguments\n\t\t});\n\t} else uninspectedSynchronousFrames.add(frame);\n\tif (structuralParent) {\n\t\t(structuralParent.children ??= new Set()).add(settlement);\n\t\tvoid settlement\n\t\t\t.finally(() => structuralParent.children?.delete(settlement))\n\t\t\t.catch(() => undefined);\n\t} else {\n\t\t// Root settlement is observed through executeTaskFrame's returned\n\t\t// promise; the internal structural signal has no parent consumer.\n\t\tvoid settlement.catch(() => undefined);\n\t}\n\n\tlet directResult: T | PromiseLike<T>;\n\tlet synchronousError: unknown;\n\ttry {\n\t\tif (controller.signal.aborted) throw new TaskCancellation(controller.signal.reason);\n\t\tdirectResult = withTaskFrameRecord(frame, () => work(frame.context!));\n\t} catch (error) {\n\t\tsynchronousError = error;\n\t\tdirectResult = Promise.reject(error);\n\t} finally {\n\t\tuninspectedSynchronousFrames.delete(frame);\n\t}\n\tconst execution = raceTaskCancellation(controller.signal, directResult);\n\n\tconst result = execution.then(\n\t\tasync (value) => {\n\t\t\tframe.producerOpen = false;\n\t\t\tpublishTaskFrameEvent(frame, 'task.foreground-settle');\n\t\t\tlet structuralError: unknown;\n\t\t\tlet structuralFailed = false;\n\t\t\ttry {\n\t\t\t\tawait settleTaskFrameChildren(frame);\n\t\t\t} catch (error) {\n\t\t\t\tstructuralError = error;\n\t\t\t\tstructuralFailed = true;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait runTaskFrameCleanups(frame);\n\t\t\t} catch (cleanupError) {\n\t\t\t\tif (!structuralFailed) throw cleanupError;\n\t\t\t\tif (structuralError && typeof structuralError === 'object')\n\t\t\t\t\tObject.defineProperty(structuralError, 'suppressed', {\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tvalue: [cleanupError]\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (controller.signal.aborted) throw new TaskCancellation(controller.signal.reason);\n\t\t\tif (structuralFailed) throw structuralError;\n\t\t\treturn value;\n\t\t},\n\t\tasync (error) => {\n\t\t\tconst outcomeError =\n\t\t\t\tcontroller.signal.aborted && !(error instanceof TaskCancellation)\n\t\t\t\t\t? new TaskCancellation(controller.signal.reason)\n\t\t\t\t\t: error;\n\t\t\tframe.producerOpen = false;\n\t\t\tpublishTaskFrameEvent(frame, 'task.foreground-settle');\n\t\t\tcontroller.abort(error);\n\t\t\tlet childError: unknown;\n\t\t\tlet childFailed = false;\n\t\t\ttry {\n\t\t\t\tawait settleTaskFrameChildren(frame);\n\t\t\t} catch (error) {\n\t\t\t\tchildError = error;\n\t\t\t\tchildFailed = true;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait runTaskFrameCleanups(frame);\n\t\t\t} catch (cleanupError) {\n\t\t\t\tif (outcomeError && typeof outcomeError === 'object')\n\t\t\t\t\tObject.defineProperty(outcomeError, 'suppressed', {\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tvalue: [cleanupError]\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (outcomeError === undefined && childFailed) throw childError;\n\t\t\tthrow outcomeError;\n\t\t}\n\t);\n\tconst output = result.then(\n\t\t(value) => {\n\t\t\tframe.settled = true;\n\t\t\treleaseTaskFrameSignal(controller.signal);\n\t\t\towner.frames.delete(frame);\n\t\t\tresolveSettlement();\n\t\t\tpublishTaskFrameEvent(frame, 'task.frame.exit');\n\t\t\tpublishTaskFrameEvent(frame, 'task.structural-settle');\n\t\t\tpublishTaskFrameEvent(frame, 'task.settle', undefined, {\n\t\t\t\tkind: 'outcome',\n\t\t\t\tstatus: 'settled',\n\t\t\t\tvalue\n\t\t\t});\n\t\t\treturn value;\n\t\t},\n\t\t(error) => {\n\t\t\tframe.settled = true;\n\t\t\treleaseTaskFrameSignal(controller.signal);\n\t\t\towner.frames.delete(frame);\n\t\t\tif (options.propagateFailure?.() === false) resolveSettlement();\n\t\t\telse rejectSettlement(error);\n\t\t\tpublishTaskFrameEvent(frame, 'task.frame.exit');\n\t\t\tconst cancelled = error instanceof TaskCancellation;\n\t\t\tpublishTaskFrameEvent(frame, cancelled ? 'task.cancel' : 'task.fail', error, {\n\t\t\t\tkind: 'outcome',\n\t\t\t\tstatus: cancelled ? 'cancelled' : 'failed',\n\t\t\t\tvalue: error\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t);\n\tif (synchronousError !== undefined) {\n\t\tsynchronousFrameErrors.set(output, { error: synchronousError });\n\t\t// Callers that preserve a synchronous host contract rethrow this error\n\t\t// immediately. The frame still settles asynchronously to release ownership.\n\t\tvoid output.catch(() => undefined);\n\t}\n\treturn output;\n}\n\n/** Returns an error thrown before a task frame's producer yielded to asynchronous work. */\nexport function taskFrameSynchronousError(\n\texecution: PromiseLike<unknown>\n): { readonly error: unknown } | undefined {\n\treturn execution instanceof Promise ? synchronousFrameErrors.get(execution) : undefined;\n}\n\n/** Adds a structural contribution to a frame before its producer closes. */\nexport function attachTaskFrameSettlement(\n\tframe: TaskFrameRecord,\n\tsettlement: PromiseLike<unknown>\n): void {\n\tif (frame.settled || !frame.producerOpen)\n\t\tthrow new Error('Cannot attach work after the task frame producer has closed');\n\tconst normalized = Promise.resolve(settlement).then(() => undefined);\n\t(frame.children ??= new Set()).add(normalized);\n\tvoid normalized.finally(() => frame.children?.delete(normalized)).catch(() => undefined);\n}\n\n/** Adds structural work to the synchronously active task frame, when present. */\nexport function joinTask(settlement: PromiseLike<unknown>): void {\n\tconst frame = currentTaskFrameRecord() ?? materializeDeferredTaskFrame();\n\tif (frame) attachTaskFrameSettlement(frame, settlement);\n}\n\n/** Publishes a task-owned mutation only while its generation remains current. */\nexport function taskMutation<Result>(signal: AbortSignal, mutation: () => Result): Result {\n\tif (signal.aborted) throw new TaskCancellation(signal.reason);\n\treturn mutation();\n}\n\n/** Restores the owning task frame around one compiler-lowered async continuation. */\nexport function resumeTaskFrame(signal: AbortSignal, resume: () => void): void {\n\tresumeTaskFrameContinuation(signal, resume, (frame) => {\n\t\tif (frame.settled) throw new Error('Cannot resume a settled task frame');\n\t\tconst previous = currentFrame;\n\t\tcurrentFrame = frame;\n\t\treturn () => {\n\t\t\tcurrentFrame = previous;\n\t\t};\n\t});\n}\n\nexport { frameForTaskContext };\nconst interactiveReactionContexts = new WeakMap<TaskFrameRecord, ScheduledWorkContext>();\nconst uninspectedSynchronousFrames = new WeakSet<TaskFrameRecord>();\n\nfunction linkAbort(signal: AbortSignal, target: AbortController): void {\n\tif (signal.aborted) {\n\t\ttarget.abort(signal.reason);\n\t\treturn;\n\t}\n\tsignal.addEventListener('abort', () => target.abort(signal.reason), { once: true });\n}\n\nfunction monotonicTimestamp(): number {\n\treturn globalThis.performance?.now() ?? Date.now();\n}\n\n/** Allocates one process-local frame identity for internal consequence frames. */\nexport function allocateTaskFrameId(): number {\n\treturn nextFrameId++;\n}\n\nfunction ensureScheduledWorkContextCapture(): void {\n\tif (scheduledWorkCaptureInstalled) return;\n\tscheduledWorkCaptureInstalled = true;\n\tsetScheduledWorkContextCapture((priority) => {\n\t\tconst parent = currentTaskFrameRecord();\n\t\tif (!parent || !parent.producerOpen || parent.settled) return undefined;\n\t\tif (priority === 'interactive' && uninspectedSynchronousFrames.has(parent))\n\t\t\treturn interactiveReactionContext(parent);\n\t\treturn acquireScheduledReactionBatch(parent);\n\t});\n}\n\n/** Reuses an open interaction producer for consequences drained inside the same DOM callback. */\nfunction interactiveReactionContext(parent: TaskFrameRecord): ScheduledWorkContext {\n\tlet context = interactiveReactionContexts.get(parent);\n\tif (context) return context;\n\tcontext = {\n\t\trun: (work) => withTaskFrameRecord(parent, work),\n\t\tcancel() {}\n\t};\n\tinteractiveReactionContexts.set(parent, context);\n\treturn context;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"frame-runtime.js","sourceRoot":"","sources":["../../src/tasks/frame-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,EAE9B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,E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E,EAAE;QAC3C,MAAM,MAAM,GAAG,sBAAsB,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QACxE,IAAI,QAAQ,KAAK,aAAa,IAAI,4BAA4B,CAAC,GAAG,CAAC,MAAM,CAAC;YACzE,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,6BAA6B,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,iGAAiG;AACjG,SAAS,0BAA0B,CAAC,MAAuB;IAC1D,IAAI,OAAO,GAAG,2BAA2B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,OAAO,GAAG;QACT,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,MAAM,KAAI,CAAC;KACX,CAAC;IACF,2BAA2B,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import {\n\tsetScheduledWorkContextCapture,\n\ttype ScheduledWorkContext\n} from '@exactjs/reactive/framework/runtime';\nimport type { TaskContext, TaskOwner } from './contracts.js';\nimport { raceTaskCancellation, TaskCancellation } from './cancellation.js';\nimport {\n\tregisterTaskFrameSignal,\n\treleaseTaskFrameSignal,\n\tresumeTaskFrameContinuation\n} from './frame-continuation.js';\nimport { createTaskFrameContext, frameForTaskContext } from './frame-context.js';\nimport {\n\tpublishTaskFrameEvent,\n\ttaskFrameInspectionAttached\n} from './frame-inspection-capability.js';\nimport {\n\tregisterTaskFrameSettlement,\n\trunTaskFrameCleanups,\n\tsettleTaskFrameChildren\n} from './frame-settlement.js';\nimport { createLazyTaskOwnerRecord } from './owner-record.js';\nimport { acquireScheduledReactionBatch } from './scheduled-reactions.js';\n\nimport {\n\ttaskFrameTokenBrand,\n\ttaskOwnerBrand,\n\ttype InternalTaskFrameOptions,\n\ttype TaskFrameCleanup,\n\ttype TaskFrameRecord,\n\ttype TaskOwnerRecord\n} from './frame-contracts.js';\nexport type {\n\tInternalTaskFrameOptions,\n\tTaskActivationRegistration,\n\tTaskFrameRecord,\n\tTaskOwnerRecord\n} from './frame-contracts.js';\nlet nextFrameId = 1;\nlet currentFrame: TaskFrameRecord | undefined;\nlet currentOwner: TaskOwnerRecord | undefined;\nlet deferredFrameMaterializer: (() => TaskFrameRecord) | undefined;\nlet scheduledWorkCaptureInstalled = false;\nconst synchronousFrameErrors = new WeakMap<Promise<unknown>, { readonly error: unknown }>();\n\n/** Creates a durable task owner and its cancellation lifetime. */\nexport function createTaskOwnerRecord(label?: string): TaskOwnerRecord {\n\treturn createLazyTaskOwnerRecord(label);\n}\n\n/** Retains setup-owned cleanup until its durable task owner is disposed. */\nexport function registerTaskOwnerCleanup(owner: TaskOwnerRecord, cleanup: TaskFrameCleanup): void {\n\tif (owner.disposed) throw new Error('Task owner has been disposed');\n\towner.ownerCleanups.add(cleanup);\n}\n\n/** Validates and returns the internal representation of a public owner. */\nexport function taskOwnerRecord(owner: TaskOwner): TaskOwnerRecord {\n\tif (!(taskOwnerBrand in owner)) throw new TypeError('Task owner was not created by eXact');\n\treturn owner as TaskOwnerRecord;\n}\n\n/** Returns the frame active for the current synchronous execution segment. */\nexport function currentTaskFrameRecord(): TaskFrameRecord | undefined {\n\treturn currentFrame;\n}\n\n/** Materializes an interaction frame only when synchronous work requests structural ownership. */\nexport function materializeDeferredTaskFrame(): TaskFrameRecord | undefined {\n\treturn deferredFrameMaterializer?.();\n}\n\n/** Installs the lazy structural parent available to task and navigation operations during work. */\nexport function withDeferredTaskFrame<T>(materialize: () => TaskFrameRecord, work: () => T): T {\n\tconst previous = deferredFrameMaterializer;\n\tdeferredFrameMaterializer = materialize;\n\ttry {\n\t\treturn work();\n\t} finally {\n\t\tdeferredFrameMaterializer = previous;\n\t}\n}\n\n/** Returns the durable owner supplied by the current framework host. */\nexport function currentTaskOwnerRecord(): TaskOwnerRecord | undefined {\n\treturn currentFrame?.owner ?? currentOwner;\n}\n\n/** Establishes a durable host owner during component state-machine construction or adapter setup. */\nexport function withTaskOwnerRecord<T>(owner: TaskOwnerRecord, work: () => T): T {\n\tconst previous = currentOwner;\n\tcurrentOwner = owner;\n\ttry {\n\t\treturn work();\n\t} finally {\n\t\tcurrentOwner = previous;\n\t}\n}\n\n/** Runs a synchronous segment with the supplied frame, or clears ambient frame ownership. */\nexport function withTaskFrameRecord<T>(frame: TaskFrameRecord | undefined, work: () => T): T {\n\tif (frame?.settled) throw new Error('Cannot resume a settled task frame');\n\tensureScheduledWorkContextCapture();\n\tconst previous = currentFrame;\n\tconst previousMaterializer = deferredFrameMaterializer;\n\tcurrentFrame = frame;\n\tif (!frame) deferredFrameMaterializer = undefined;\n\ttry {\n\t\treturn work();\n\t} finally {\n\t\tcurrentFrame = previous;\n\t\tdeferredFrameMaterializer = previousMaterializer;\n\t}\n}\n\n/**\n * Runs work in a frame, then waits for dynamically attached descendants and\n * executes cleanup in last-in-first-out order.\n */\nexport function executeTaskFrame<T>(\n\toptions: InternalTaskFrameOptions,\n\twork: (context: TaskContext) => T | PromiseLike<T>\n): Promise<T> {\n\tconst structuralParent = options.detached ? undefined : (options.parent ?? currentFrame);\n\tif (\n\t\tstructuralParent &&\n\t\t!options.parentReserved &&\n\t\t(!structuralParent.producerOpen || structuralParent.settled)\n\t)\n\t\treturn Promise.reject(\n\t\t\tnew Error('Cannot attach work after the parent task producer has closed')\n\t\t);\n\tconst owner =\n\t\toptions.owner ?? structuralParent?.owner ?? createTaskOwnerRecord('implicit task invocation');\n\tif (owner.disposed) {\n\t\toptions.controller?.abort('task-owner-disposed');\n\t\treturn Promise.reject(\n\t\t\tnew TaskCancellation(options.controller?.signal.reason ?? 'task-owner-disposed')\n\t\t);\n\t}\n\tconst controller = options.controller ?? new AbortController();\n\t// The owner cancels its active frame controllers directly during disposal. Subscribing every\n\t// frame to its durable signal would retain settled controllers until the owner itself is released.\n\tif (structuralParent) linkAbort(structuralParent.controller.signal, controller);\n\n\tlet resolveSettlement!: () => void;\n\tlet rejectSettlement!: (error: unknown) => void;\n\tconst settlement = new Promise<void>((resolve, reject) => {\n\t\tresolveSettlement = resolve;\n\t\trejectSettlement = reject;\n\t});\n\tconst frame: TaskFrameRecord = {\n\t\t[taskFrameTokenBrand]: true as const,\n\t\tid: nextFrameId++,\n\t\towner,\n\t\tparent: structuralParent,\n\t\tcontroller,\n\t\t...(options.label === undefined ? {} : { label: options.label }),\n\t\t...(options.sourceEntityId === undefined ? {} : { sourceEntityId: options.sourceEntityId }),\n\t\tactivation: options.activation ?? 'invoked',\n\t\tgeneration: options.generation ?? 1,\n\t\tplacement: options.placement ?? 'current',\n\t\tconcurrency: options.concurrency ?? 'parallel',\n\t\tpriority: options.priority ?? structuralParent?.priority ?? 'normal',\n\t\treadiness:\n\t\t\toptions.readiness ??\n\t\t\t(options.priority === 'deferred'\n\t\t\t\t? 'nonblocking'\n\t\t\t\t: (structuralParent?.readiness ?? 'blocking')),\n\t\tkind: options.kind ?? 'task',\n\t\tproducerOpen: true,\n\t\tsettled: false,\n\t\tstartedAt: monotonicTimestamp()\n\t};\n\tif (options.publicContext !== false)\n\t\t(frame as { context: TaskContext }).context = createTaskFrameContext(frame, options);\n\tregisterTaskFrameSignal(controller.signal, frame);\n\tregisterTaskFrameSettlement(frame, settlement);\n\towner.frames.add(frame);\n\tconst inspectedAtStart = taskFrameInspectionAttached(frame);\n\tif (inspectedAtStart) {\n\t\tpublishTaskFrameEvent(frame, 'task.frame.enter');\n\t\tpublishTaskFrameEvent(frame, 'task.start', undefined, {\n\t\t\tkind: 'start',\n\t\t\targuments: options.inspectionArguments\n\t\t});\n\t} else uninspectedSynchronousFrames.add(frame);\n\tif (structuralParent) {\n\t\t(structuralParent.children ??= new Set()).add(settlement);\n\t\tvoid settlement\n\t\t\t.finally(() => structuralParent.children?.delete(settlement))\n\t\t\t.catch(() => undefined);\n\t} else {\n\t\t// Root settlement is observed through executeTaskFrame's returned\n\t\t// promise; the internal structural signal has no parent consumer.\n\t\tvoid settlement.catch(() => undefined);\n\t}\n\n\tlet directResult: T | PromiseLike<T>;\n\tlet synchronousError: unknown;\n\ttry {\n\t\tif (controller.signal.aborted) throw new TaskCancellation(controller.signal.reason);\n\t\tdirectResult = withTaskFrameRecord(frame, () => work(frame.context!));\n\t} catch (error) {\n\t\tsynchronousError = error;\n\t\tdirectResult = Promise.reject(error);\n\t} finally {\n\t\tuninspectedSynchronousFrames.delete(frame);\n\t}\n\tconst execution = raceTaskCancellation(controller.signal, directResult);\n\n\tconst result = execution.then(\n\t\tasync (value) => {\n\t\t\tframe.producerOpen = false;\n\t\t\tpublishTaskFrameEvent(frame, 'task.foreground-settle');\n\t\t\tlet structuralError: unknown;\n\t\t\tlet structuralFailed = false;\n\t\t\ttry {\n\t\t\t\tawait settleTaskFrameChildren(frame);\n\t\t\t} catch (error) {\n\t\t\t\tstructuralError = error;\n\t\t\t\tstructuralFailed = true;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait runTaskFrameCleanups(frame);\n\t\t\t} catch (cleanupError) {\n\t\t\t\tif (!structuralFailed) throw cleanupError;\n\t\t\t\tif (structuralError && typeof structuralError === 'object')\n\t\t\t\t\tObject.defineProperty(structuralError, 'suppressed', {\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tvalue: [cleanupError]\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (controller.signal.aborted) throw new TaskCancellation(controller.signal.reason);\n\t\t\tif (structuralFailed) throw structuralError;\n\t\t\treturn value;\n\t\t},\n\t\tasync (error) => {\n\t\t\tconst outcomeError =\n\t\t\t\tcontroller.signal.aborted && !(error instanceof TaskCancellation)\n\t\t\t\t\t? new TaskCancellation(controller.signal.reason)\n\t\t\t\t\t: error;\n\t\t\tframe.producerOpen = false;\n\t\t\tpublishTaskFrameEvent(frame, 'task.foreground-settle');\n\t\t\tcontroller.abort(error);\n\t\t\tlet childError: unknown;\n\t\t\tlet childFailed = false;\n\t\t\ttry {\n\t\t\t\tawait settleTaskFrameChildren(frame);\n\t\t\t} catch (error) {\n\t\t\t\tchildError = error;\n\t\t\t\tchildFailed = true;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait runTaskFrameCleanups(frame);\n\t\t\t} catch (cleanupError) {\n\t\t\t\tif (outcomeError && typeof outcomeError === 'object')\n\t\t\t\t\tObject.defineProperty(outcomeError, 'suppressed', {\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tvalue: [cleanupError]\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (outcomeError === undefined && childFailed) throw childError;\n\t\t\tthrow outcomeError;\n\t\t}\n\t);\n\tconst output = result.then(\n\t\t(value) => {\n\t\t\tframe.settled = true;\n\t\t\treleaseTaskFrameSignal(controller.signal);\n\t\t\towner.frames.delete(frame);\n\t\t\tresolveSettlement();\n\t\t\tpublishTaskFrameEvent(frame, 'task.frame.exit');\n\t\t\tpublishTaskFrameEvent(frame, 'task.structural-settle');\n\t\t\tpublishTaskFrameEvent(frame, 'task.settle', undefined, {\n\t\t\t\tkind: 'outcome',\n\t\t\t\tstatus: 'settled',\n\t\t\t\tvalue\n\t\t\t});\n\t\t\treturn value;\n\t\t},\n\t\t(error) => {\n\t\t\tframe.settled = true;\n\t\t\treleaseTaskFrameSignal(controller.signal);\n\t\t\towner.frames.delete(frame);\n\t\t\tif (options.propagateFailure?.() === false) resolveSettlement();\n\t\t\telse rejectSettlement(error);\n\t\t\tpublishTaskFrameEvent(frame, 'task.frame.exit');\n\t\t\tconst cancelled = error instanceof TaskCancellation;\n\t\t\tpublishTaskFrameEvent(frame, cancelled ? 'task.cancel' : 'task.fail', error, {\n\t\t\t\tkind: 'outcome',\n\t\t\t\tstatus: cancelled ? 'cancelled' : 'failed',\n\t\t\t\tvalue: error\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t);\n\tif (synchronousError !== undefined) {\n\t\tsynchronousFrameErrors.set(output, { error: synchronousError });\n\t\t// Callers that preserve a synchronous host contract rethrow this error\n\t\t// immediately. The frame still settles asynchronously to release ownership.\n\t\tvoid output.catch(() => undefined);\n\t}\n\treturn output;\n}\n\n/** Returns an error thrown before a task frame's producer yielded to asynchronous work. */\nexport function taskFrameSynchronousError(\n\texecution: PromiseLike<unknown>\n): { readonly error: unknown } | undefined {\n\treturn execution instanceof Promise ? synchronousFrameErrors.get(execution) : undefined;\n}\n\n/** Adds a structural contribution to a frame before its producer closes. */\nexport function attachTaskFrameSettlement(\n\tframe: TaskFrameRecord,\n\tsettlement: PromiseLike<unknown>\n): void {\n\tif (frame.settled || !frame.producerOpen)\n\t\tthrow new Error('Cannot attach work after the task frame producer has closed');\n\tconst normalized = Promise.resolve(settlement).then(() => undefined);\n\t(frame.children ??= new Set()).add(normalized);\n\tvoid normalized.finally(() => frame.children?.delete(normalized)).catch(() => undefined);\n}\n\n/** Adds structural work to the synchronously active task frame, when present. */\nexport function joinTask(settlement: PromiseLike<unknown>): void {\n\tconst frame = currentTaskFrameRecord() ?? materializeDeferredTaskFrame();\n\tif (frame) attachTaskFrameSettlement(frame, settlement);\n}\n\n/** Publishes a task-owned mutation only while its generation remains current. */\nexport function taskMutation<Result>(signal: AbortSignal, mutation: () => Result): Result {\n\tif (signal.aborted) throw new TaskCancellation(signal.reason);\n\treturn mutation();\n}\n\n/** Restores the owning task frame around one compiler-lowered async continuation. */\nexport function resumeTaskFrame(signal: AbortSignal, resume: () => void): void {\n\tresumeTaskFrameContinuation(signal, resume, (frame) => {\n\t\tconst previous = currentFrame;\n\t\tconst previousMaterializer = deferredFrameMaterializer;\n\t\tcurrentFrame = frame;\n\t\tif (!frame) deferredFrameMaterializer = undefined;\n\t\treturn () => {\n\t\t\tcurrentFrame = previous;\n\t\t\tdeferredFrameMaterializer = previousMaterializer;\n\t\t};\n\t});\n}\n\nexport { frameForTaskContext };\nconst interactiveReactionContexts = new WeakMap<TaskFrameRecord, ScheduledWorkContext>();\nconst uninspectedSynchronousFrames = new WeakSet<TaskFrameRecord>();\n\nfunction linkAbort(signal: AbortSignal, target: AbortController): void {\n\tif (signal.aborted) {\n\t\ttarget.abort(signal.reason);\n\t\treturn;\n\t}\n\tsignal.addEventListener('abort', () => target.abort(signal.reason), { once: true });\n}\n\nfunction monotonicTimestamp(): number {\n\treturn globalThis.performance?.now() ?? Date.now();\n}\n\n/** Allocates one process-local frame identity for internal consequence frames. */\nexport function allocateTaskFrameId(): number {\n\treturn nextFrameId++;\n}\n\nfunction ensureScheduledWorkContextCapture(): void {\n\tif (scheduledWorkCaptureInstalled) return;\n\tscheduledWorkCaptureInstalled = true;\n\tsetScheduledWorkContextCapture((priority) => {\n\t\tconst parent = currentTaskFrameRecord();\n\t\tif (!parent || !parent.producerOpen || parent.settled) return undefined;\n\t\tif (priority === 'interactive' && uninspectedSynchronousFrames.has(parent))\n\t\t\treturn interactiveReactionContext(parent);\n\t\treturn acquireScheduledReactionBatch(parent);\n\t});\n}\n\n/** Reuses an open interaction producer for consequences drained inside the same DOM callback. */\nfunction interactiveReactionContext(parent: TaskFrameRecord): ScheduledWorkContext {\n\tlet context = interactiveReactionContexts.get(parent);\n\tif (context) return context;\n\tcontext = {\n\t\trun: (work) => withTaskFrameRecord(parent, work),\n\t\tcancel() {}\n\t};\n\tinteractiveReactionContexts.set(parent, context);\n\treturn context;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RuntimeTaskOptions, TaskContext } from './contracts.js';
|
|
2
|
+
import type { AnyComponentInstance } from '../component/contracts.js';
|
|
3
|
+
import { type TaskProgressReceiver } from './progress-receiver.js';
|
|
4
|
+
/** Compiler-owned receiver work. Only validated snapshot arguments reach this boundary. */
|
|
5
|
+
export type TaskProgressWork = (snapshot: unknown, task: TaskContext) => void | Promise<void>;
|
|
6
|
+
type ProgressReceiverOptions = Pick<RuntimeTaskOptions<[unknown]>, 'label' | 'priority' | 'readiness'>;
|
|
7
|
+
/** Registers one compiled receiver against its durable component, without activating it. */
|
|
8
|
+
export declare function registerTaskProgressReceiver<Snapshot>(host: object, id: string, work: (snapshot: Snapshot, task: TaskContext) => void | Promise<void>, options: ProgressReceiverOptions): (snapshot: Snapshot) => void;
|
|
9
|
+
/** Binds a server frame to its trusted, invocation-local progress transport. */
|
|
10
|
+
export declare function attachTaskProgressReporter(task: TaskContext, report: (id: string, snapshot: unknown) => void): void;
|
|
11
|
+
/**
|
|
12
|
+
* Captures explicit server progress authority while an executor establishes its lexical tasks.
|
|
13
|
+
* SSR has no transport and therefore creates a no-op. Retained callbacks stop at cancellation
|
|
14
|
+
* or settlement even if application code invokes them after the originating frame has closed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTaskProgressReporter(id: string, task?: TaskContext): (snapshot: unknown) => void;
|
|
17
|
+
/** Creates an isolated receiver lane for a validated operation and live component instance. */
|
|
18
|
+
export declare function taskProgressReceiverForHost(host: AnyComponentInstance, id: string, signal: AbortSignal): TaskProgressReceiver<unknown>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=progress-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-bindings.d.ts","sourceRoot":"","sources":["../../src/tasks/progress-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKtE,OAAO,EAA8B,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,2FAA2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9F,KAAK,uBAAuB,GAAG,IAAI,CAClC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,EAC7B,OAAO,GAAG,UAAU,GAAG,WAAW,CAClC,CAAC;AAOF,4FAA4F;AAC5F,wBAAgB,4BAA4B,CAAC,QAAQ,EACpD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACrE,OAAO,EAAE,uBAAuB,GAC9B,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAQ9B;AAED,gFAAgF;AAChF,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,GAC7C,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACzC,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,WAAW,GAChB,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAO7B;AAED,+FAA+F;AAC/F,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,oBAAoB,EAC1B,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,GACjB,oBAAoB,CAAC,OAAO,CAAC,CAgB/B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { componentLogMethod } from '../component/log.js';
|
|
2
|
+
import { frameForTaskContext } from './frame-runtime.js';
|
|
3
|
+
import { taskOwnerForHost } from './owner-hosts.js';
|
|
4
|
+
import { createTaskProgressReceiver } from './progress-receiver.js';
|
|
5
|
+
const receivers = new WeakMap();
|
|
6
|
+
const reporters = new WeakMap();
|
|
7
|
+
/** Registers one compiled receiver against its durable component, without activating it. */
|
|
8
|
+
export function registerTaskProgressReceiver(host, id, work, options) {
|
|
9
|
+
let registry = receivers.get(host);
|
|
10
|
+
if (!registry)
|
|
11
|
+
receivers.set(host, (registry = new Map()));
|
|
12
|
+
if (registry.has(id))
|
|
13
|
+
throw new Error(`Duplicate task progress receiver ${id}`);
|
|
14
|
+
registry.set(id, { work: work, options });
|
|
15
|
+
return () => {
|
|
16
|
+
throw new Error('Progress receivers are invoked by server continuation progress');
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Binds a server frame to its trusted, invocation-local progress transport. */
|
|
20
|
+
export function attachTaskProgressReporter(task, report) {
|
|
21
|
+
reporters.set(frameForTaskContext(task), report);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Captures explicit server progress authority while an executor establishes its lexical tasks.
|
|
25
|
+
* SSR has no transport and therefore creates a no-op. Retained callbacks stop at cancellation
|
|
26
|
+
* or settlement even if application code invokes them after the originating frame has closed.
|
|
27
|
+
*/
|
|
28
|
+
export function createTaskProgressReporter(id, task) {
|
|
29
|
+
const ownedFrame = task && frameForTaskContext(task);
|
|
30
|
+
const report = ownedFrame && reporters.get(ownedFrame);
|
|
31
|
+
return (snapshot) => {
|
|
32
|
+
if (ownedFrame && !ownedFrame.settled && !ownedFrame.controller.signal.aborted)
|
|
33
|
+
report?.(id, snapshot);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Creates an isolated receiver lane for a validated operation and live component instance. */
|
|
37
|
+
export function taskProgressReceiverForHost(host, id, signal) {
|
|
38
|
+
const owner = taskOwnerForHost(host);
|
|
39
|
+
const receiver = receivers.get(host)?.get(id);
|
|
40
|
+
if (!owner || !receiver)
|
|
41
|
+
throw new Error(`Unknown component task progress receiver ${id}`);
|
|
42
|
+
return createTaskProgressReceiver({
|
|
43
|
+
owner,
|
|
44
|
+
signal,
|
|
45
|
+
...receiver.options,
|
|
46
|
+
label: receiver.options.label ?? id,
|
|
47
|
+
receive: receiver.work,
|
|
48
|
+
onError: (error) => componentLogMethod(host, 'error')?.(() => ['Task progress receiver failed', error, { receiver: id }])
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=progress-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-bindings.js","sourceRoot":"","sources":["../../src/tasks/progress-bindings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAA6B,MAAM,wBAAwB,CAAC;AAS/F,MAAM,SAAS,GAAG,IAAI,OAAO,EAG1B,CAAC;AACJ,MAAM,SAAS,GAAG,IAAI,OAAO,EAA4D,CAAC;AAE1F,4FAA4F;AAC5F,MAAM,UAAU,4BAA4B,CAC3C,IAAY,EACZ,EAAU,EACV,IAAqE,EACrE,OAAgC;IAEhC,IAAI,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,QAAQ;QAAE,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,EAAE,EAAE,CAAC,CAAC;IAChF,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAwB,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9D,OAAO,GAAG,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACnF,CAAC,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,0BAA0B,CACzC,IAAiB,EACjB,MAA+C;IAE/C,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAED;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entInstance } from '../component/contracts.js';\nimport { componentLogMethod } from '../component/log.js';\nimport { frameForTaskContext } from './frame-runtime.js';\nimport type { TaskFrameRecord } from './frame-contracts.js';\nimport { taskOwnerForHost } from './owner-hosts.js';\nimport { createTaskProgressReceiver, type TaskProgressReceiver } from './progress-receiver.js';\n\n/** Compiler-owned receiver work. Only validated snapshot arguments reach this boundary. */\nexport type TaskProgressWork = (snapshot: unknown, task: TaskContext) => void | Promise<void>;\n\ntype ProgressReceiverOptions = Pick<\n\tRuntimeTaskOptions<[unknown]>,\n\t'label' | 'priority' | 'readiness'\n>;\nconst receivers = new WeakMap<\n\tobject,\n\tMap<string, { work: TaskProgressWork; options: ProgressReceiverOptions }>\n>();\nconst reporters = new WeakMap<TaskFrameRecord, (id: string, snapshot: unknown) => void>();\n\n/** Registers one compiled receiver against its durable component, without activating it. */\nexport function registerTaskProgressReceiver<Snapshot>(\n\thost: object,\n\tid: string,\n\twork: (snapshot: Snapshot, task: TaskContext) => void | Promise<void>,\n\toptions: ProgressReceiverOptions\n): (snapshot: Snapshot) => void {\n\tlet registry = receivers.get(host);\n\tif (!registry) receivers.set(host, (registry = new Map()));\n\tif (registry.has(id)) throw new Error(`Duplicate task progress receiver ${id}`);\n\tregistry.set(id, { work: work as TaskProgressWork, options });\n\treturn () => {\n\t\tthrow new Error('Progress receivers are invoked by server continuation progress');\n\t};\n}\n\n/** Binds a server frame to its trusted, invocation-local progress transport. */\nexport function attachTaskProgressReporter(\n\ttask: TaskContext,\n\treport: (id: string, snapshot: unknown) => void\n): void {\n\treporters.set(frameForTaskContext(task), report);\n}\n\n/**\n * Captures explicit server progress authority while an executor establishes its lexical tasks.\n * SSR has no transport and therefore creates a no-op. Retained callbacks stop at cancellation\n * or settlement even if application code invokes them after the originating frame has closed.\n */\nexport function createTaskProgressReporter(\n\tid: string,\n\ttask?: TaskContext\n): (snapshot: unknown) => void {\n\tconst ownedFrame = task && frameForTaskContext(task);\n\tconst report = ownedFrame && reporters.get(ownedFrame);\n\treturn (snapshot) => {\n\t\tif (ownedFrame && !ownedFrame.settled && !ownedFrame.controller.signal.aborted)\n\t\t\treport?.(id, snapshot);\n\t};\n}\n\n/** Creates an isolated receiver lane for a validated operation and live component instance. */\nexport function taskProgressReceiverForHost(\n\thost: AnyComponentInstance,\n\tid: string,\n\tsignal: AbortSignal\n): TaskProgressReceiver<unknown> {\n\tconst owner = taskOwnerForHost(host);\n\tconst receiver = receivers.get(host)?.get(id);\n\tif (!owner || !receiver) throw new Error(`Unknown component task progress receiver ${id}`);\n\treturn createTaskProgressReceiver({\n\t\towner,\n\t\tsignal,\n\t\t...receiver.options,\n\t\tlabel: receiver.options.label ?? id,\n\t\treceive: receiver.work,\n\t\tonError: (error) =>\n\t\t\tcomponentLogMethod(\n\t\t\t\thost,\n\t\t\t\t'error'\n\t\t\t)?.(() => ['Task progress receiver failed', error, { receiver: id }])\n\t});\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TaskContext, TaskOwner } from './contracts.js';
|
|
2
|
+
/** One replaceable observation lane, owned by an originating invocation. */
|
|
3
|
+
export interface TaskProgressReceiver<Snapshot> {
|
|
4
|
+
/** Offers a captured snapshot, replacing any snapshot which has not started. */
|
|
5
|
+
report(snapshot: Snapshot): void;
|
|
6
|
+
/** Fences publication immediately; asynchronous cleanup does not delay the caller. */
|
|
7
|
+
close(reason?: unknown): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Serializes asynchronous progress activations while retaining only the latest pending value.
|
|
11
|
+
* Each activation is an ordinary task with independent staged publication and structural children.
|
|
12
|
+
* It belongs to the durable component owner, but never extends the originating invocation.
|
|
13
|
+
* Callers must capture/validate snapshots before offering them and route errors to diagnostics.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createTaskProgressReceiver<Snapshot>(options: {
|
|
16
|
+
readonly owner: TaskOwner;
|
|
17
|
+
readonly signal: AbortSignal;
|
|
18
|
+
readonly label: string;
|
|
19
|
+
readonly priority?: 'immediate' | 'normal' | 'deferred';
|
|
20
|
+
readonly readiness?: 'blocking' | 'nonblocking';
|
|
21
|
+
readonly receive: (snapshot: Snapshot, task: TaskContext) => void | Promise<void>;
|
|
22
|
+
readonly onError: (error: unknown) => void;
|
|
23
|
+
}): TaskProgressReceiver<Snapshot>;
|
|
24
|
+
//# sourceMappingURL=progress-receiver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-receiver.d.ts","sourceRoot":"","sources":["../../src/tasks/progress-receiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK7D,4EAA4E;AAC5E,MAAM,WAAW,oBAAoB,CAAC,QAAQ;IAC7C,gFAAgF;IAChF,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,sFAAsF;IACtF,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,EAAE;IAC7D,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;IACxD,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3C,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAoEjC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isTaskCancellation } from './cancellation.js';
|
|
2
|
+
import { bindTask, defineTask } from './runtime.js';
|
|
3
|
+
import { logFrameworkEvent } from '../component/log.js';
|
|
4
|
+
/**
|
|
5
|
+
* Serializes asynchronous progress activations while retaining only the latest pending value.
|
|
6
|
+
* Each activation is an ordinary task with independent staged publication and structural children.
|
|
7
|
+
* It belongs to the durable component owner, but never extends the originating invocation.
|
|
8
|
+
* Callers must capture/validate snapshots before offering them and route errors to diagnostics.
|
|
9
|
+
*/
|
|
10
|
+
export function createTaskProgressReceiver(options) {
|
|
11
|
+
const task = bindTask(defineTask({
|
|
12
|
+
label: options.label,
|
|
13
|
+
placement: 'client',
|
|
14
|
+
readiness: options.readiness ?? 'nonblocking',
|
|
15
|
+
priority: options.priority,
|
|
16
|
+
detached: true,
|
|
17
|
+
owner: options.owner
|
|
18
|
+
}, options.receive), { owner: options.owner });
|
|
19
|
+
let closed = false;
|
|
20
|
+
let running = false;
|
|
21
|
+
let pending;
|
|
22
|
+
const close = (reason = 'progress-complete') => {
|
|
23
|
+
if (closed)
|
|
24
|
+
return;
|
|
25
|
+
closed = true;
|
|
26
|
+
pending = undefined;
|
|
27
|
+
options.signal.removeEventListener('abort', abort);
|
|
28
|
+
options.owner.signal.removeEventListener('abort', abort);
|
|
29
|
+
task.cancel(reason);
|
|
30
|
+
};
|
|
31
|
+
const abort = () => close(options.signal.reason ?? options.owner.signal.reason);
|
|
32
|
+
const drain = () => {
|
|
33
|
+
if (closed || running || !pending)
|
|
34
|
+
return;
|
|
35
|
+
const { snapshot } = pending;
|
|
36
|
+
pending = undefined;
|
|
37
|
+
running = true;
|
|
38
|
+
// Observe the invocation's rejection before work can settle. Cancellation is lifecycle,
|
|
39
|
+
// while failures still remain inspectable on the task and reach the supplied diagnostic.
|
|
40
|
+
void Promise.resolve(task(snapshot)).then(() => finish(), (error) => {
|
|
41
|
+
try {
|
|
42
|
+
if (!isTaskCancellation(error))
|
|
43
|
+
options.onError(error);
|
|
44
|
+
}
|
|
45
|
+
catch (diagnosticError) {
|
|
46
|
+
logFrameworkEvent('error', 'core', 'task', 'progress error diagnostic failed', diagnosticError);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
finish();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const finish = () => {
|
|
54
|
+
running = false;
|
|
55
|
+
drain();
|
|
56
|
+
};
|
|
57
|
+
options.signal.addEventListener('abort', abort, { once: true });
|
|
58
|
+
options.owner.signal.addEventListener('abort', abort, { once: true });
|
|
59
|
+
if (options.signal.aborted || options.owner.signal.aborted)
|
|
60
|
+
abort();
|
|
61
|
+
return {
|
|
62
|
+
report(snapshot) {
|
|
63
|
+
if (closed)
|
|
64
|
+
return;
|
|
65
|
+
pending = { snapshot };
|
|
66
|
+
drain();
|
|
67
|
+
},
|
|
68
|
+
close
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=progress-receiver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-receiver.js","sourceRoot":"","sources":["../../src/tasks/progress-receiver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAUxD;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAW,OAQpD;IACA,MAAM,IAAI,GAAG,QAAQ,CACpB,UAAU,CACT;QACC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,aAAa;QAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,OAAO,CAAC,KAAK;KACpB,EACD,OAA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1B,iBAAiB,CAChB,OAAO,EACP,MAAM,EACN,MAAM,EACN,kCAAkC,EAClC,eAAe,CACf,CAAC;YACH,CAAC;oBAAS,CAAC;gBACV,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,MAAM,MAAM,GAAG,GAAG,EAAE;QACnB,OAAO,GAAG,KAAK,CAAC;QAChB,KAAK,EAAE,CAAC;IACT,CAAC,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;QAAE,KAAK,EAAE,CAAC;IACpE,OAAO;QACN,MAAM,CAAC,QAAQ;YACd,IAAI,MAAM;gBAAE,OAAO;YACnB,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAC;YACvB,KAAK,EAAE,CAAC;QACT,CAAC;QACD,KAAK;KACL,CAAC;AACH,CAAC","sourcesContent":["import type { TaskContext, TaskOwner } from './contracts.js';\nimport { isTaskCancellation } from './cancellation.js';\nimport { bindTask, defineTask } from './runtime.js';\nimport { logFrameworkEvent } from '../component/log.js';\n\n/** One replaceable observation lane, owned by an originating invocation. */\nexport interface TaskProgressReceiver<Snapshot> {\n\t/** Offers a captured snapshot, replacing any snapshot which has not started. */\n\treport(snapshot: Snapshot): void;\n\t/** Fences publication immediately; asynchronous cleanup does not delay the caller. */\n\tclose(reason?: unknown): void;\n}\n\n/**\n * Serializes asynchronous progress activations while retaining only the latest pending value.\n * Each activation is an ordinary task with independent staged publication and structural children.\n * It belongs to the durable component owner, but never extends the originating invocation.\n * Callers must capture/validate snapshots before offering them and route errors to diagnostics.\n */\nexport function createTaskProgressReceiver<Snapshot>(options: {\n\treadonly owner: TaskOwner;\n\treadonly signal: AbortSignal;\n\treadonly label: string;\n\treadonly priority?: 'immediate' | 'normal' | 'deferred';\n\treadonly readiness?: 'blocking' | 'nonblocking';\n\treadonly receive: (snapshot: Snapshot, task: TaskContext) => void | Promise<void>;\n\treadonly onError: (error: unknown) => void;\n}): TaskProgressReceiver<Snapshot> {\n\tconst task = bindTask(\n\t\tdefineTask<[Snapshot], void>(\n\t\t\t{\n\t\t\t\tlabel: options.label,\n\t\t\t\tplacement: 'client',\n\t\t\t\treadiness: options.readiness ?? 'nonblocking',\n\t\t\t\tpriority: options.priority,\n\t\t\t\tdetached: true,\n\t\t\t\towner: options.owner\n\t\t\t},\n\t\t\toptions.receive\n\t\t),\n\t\t{ owner: options.owner }\n\t);\n\tlet closed = false;\n\tlet running = false;\n\tlet pending: { snapshot: Snapshot } | undefined;\n\tconst close = (reason: unknown = 'progress-complete') => {\n\t\tif (closed) return;\n\t\tclosed = true;\n\t\tpending = undefined;\n\t\toptions.signal.removeEventListener('abort', abort);\n\t\toptions.owner.signal.removeEventListener('abort', abort);\n\t\ttask.cancel(reason);\n\t};\n\tconst abort = () => close(options.signal.reason ?? options.owner.signal.reason);\n\tconst drain = () => {\n\t\tif (closed || running || !pending) return;\n\t\tconst { snapshot } = pending;\n\t\tpending = undefined;\n\t\trunning = true;\n\t\t// Observe the invocation's rejection before work can settle. Cancellation is lifecycle,\n\t\t// while failures still remain inspectable on the task and reach the supplied diagnostic.\n\t\tvoid Promise.resolve(task(snapshot)).then(\n\t\t\t() => finish(),\n\t\t\t(error: unknown) => {\n\t\t\t\ttry {\n\t\t\t\t\tif (!isTaskCancellation(error)) options.onError(error);\n\t\t\t\t} catch (diagnosticError) {\n\t\t\t\t\tlogFrameworkEvent(\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\t'core',\n\t\t\t\t\t\t'task',\n\t\t\t\t\t\t'progress error diagnostic failed',\n\t\t\t\t\t\tdiagnosticError\n\t\t\t\t\t);\n\t\t\t\t} finally {\n\t\t\t\t\tfinish();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t};\n\tconst finish = () => {\n\t\trunning = false;\n\t\tdrain();\n\t};\n\toptions.signal.addEventListener('abort', abort, { once: true });\n\toptions.owner.signal.addEventListener('abort', abort, { once: true });\n\tif (options.signal.aborted || options.owner.signal.aborted) abort();\n\treturn {\n\t\treport(snapshot) {\n\t\t\tif (closed) return;\n\t\t\tpending = { snapshot };\n\t\t\tdrain();\n\t\t},\n\t\tclose\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/tasks/resources.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACX,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAUzE,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAErF;AAKD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CASjF;AAED,yFAAyF;AACzF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAO9D;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAG9D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,WAAW,EAAE,EAC5B,IAAI,EAAE,KAAK,GAAG,KAAK,EACnB,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,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S,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA4CvF"}
|
package/dist/tasks/resources.js
CHANGED
|
@@ -302,8 +302,11 @@ function ignoreSettlement() { }
|
|
|
302
302
|
* remains parked until the scope resumes, and cancellation can still reject during that wait.
|
|
303
303
|
*/
|
|
304
304
|
export function taskAwait(signal, value) {
|
|
305
|
-
if (signal.aborted)
|
|
305
|
+
if (signal.aborted) {
|
|
306
|
+
// The source expression has already executed and still owns a possible rejection.
|
|
307
|
+
void Promise.resolve(value).catch(ignoreSettlement);
|
|
306
308
|
return Promise.reject(new TaskCancellation(signal.reason));
|
|
309
|
+
}
|
|
307
310
|
return new Promise((resolve, reject) => {
|
|
308
311
|
let settled = false;
|
|
309
312
|
let releaseWaiter;
|
|
@@ -334,10 +337,10 @@ export function taskAwait(signal, value) {
|
|
|
334
337
|
if (settled)
|
|
335
338
|
return;
|
|
336
339
|
const owner = taskOwners.get(signal);
|
|
337
|
-
if (owner?.scope.paused) {
|
|
340
|
+
if (owner?.scope.active && owner.scope.paused) {
|
|
338
341
|
releaseWaiter = scheduleEffectScopeResume(owner.scope, () => {
|
|
339
342
|
releaseWaiter = undefined;
|
|
340
|
-
|
|
343
|
+
continueTask(result, failed);
|
|
341
344
|
});
|
|
342
345
|
return;
|
|
343
346
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/tasks/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,wBAAwB,EACxB,MAAM,EACN,yBAAyB,EACzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW5D,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,E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M,EAAE,MAAM,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAC1B,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,EACvC,CAAC,KAAc,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAC7C,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\tbatch,\n\tmutateReactiveCollection,\n\tunwrap,\n\tscheduleEffectScopeResume\n} from '@exactjs/reactive/framework/runtime';\n\nimport { createDisposableAbortSignal, isAbortSignal } from './signals.js';\nimport { isPromiseLike } from '../component/async-value.js';\n\nimport type {\n\tAnyComponentInstance,\n\tTaskCleanup,\n\tTaskIdleDeadline,\n\tTaskIdleOptions,\n\tTaskResourceDisposal\n} from '../component/contracts.js';\nimport type { ExactCollectionMutation } from '../component-contracts.js';\n\nimport { createErrorReport, handleComponentError } from '../component/errors.js';\nimport { TaskCancellation } from './cancellation.js';\nimport { resumeTaskFrame } from './frame-runtime.js';\n\nimport { logFrameworkEvent } from '../component/log.js';\n\nconst taskOwners = new WeakMap<AbortSignal, AnyComponentInstance>();\n\n/** Associates a task generation signal with its component owner. */\nexport function trackTaskOwner(signal: AbortSignal, owner: AnyComponentInstance): void {\n\ttaskOwners.set(signal, owner);\n}\nconst taskCleanupPromises = new WeakMap<AbortSignal, Set<Promise<void>>>();\nconst taskMutations = new WeakMap<AbortSignal, Array<() => void>>();\nconst taskCollectionMutations = new WeakMap<AbortSignal, ExactCollectionMutation[]>();\n\n/** Stages a compiler-generated mutation until its blocking task generation commits. */\nexport function stageTaskMutation(signal: AbortSignal, mutation: () => void): void {\n\tif (signal.aborted) return;\n\tlet staged = taskMutations.get(signal);\n\tif (!staged) {\n\t\tstaged = [];\n\t\ttaskMutations.set(signal, staged);\n\t\tsignal.addEventListener('abort', () => discardTaskMutations(signal), { once: true });\n\t}\n\tstaged.push(mutation);\n}\n\n/** Publishes staged mutations for a successful task generation as one reactive batch. */\nexport function publishTaskMutations(signal: AbortSignal): void {\n\tconst staged = taskMutations.get(signal);\n\tif (!staged) return;\n\ttaskMutations.delete(signal);\n\tbatch(() => {\n\t\tfor (const mutation of staged) mutation();\n\t});\n}\n\n/** Discards every unpublished mutation owned by a task generation. */\nexport function discardTaskMutations(signal: AbortSignal): void {\n\ttaskMutations.delete(signal);\n\ttaskCollectionMutations.delete(signal);\n}\n\n/**\n * Applies a server-task collection mutation and records the smallest ordered\n * response delta that can reproduce the successful change in the browser.\n */\nexport function mutateTaskCollection(\n\tsignal: AbortSignal,\n\ttarget: object,\n\tpath: readonly PropertyKey[],\n\tkind: 'map' | 'set',\n\tmethod: 'set' | 'add' | 'delete' | 'clear',\n\targs: unknown[] | (() => unknown[])\n): unknown {\n\tif (signal.aborted) return undefined;\n\tconst input = typeof args === 'function' ? args() : args;\n\tconst collection = readTaskCollection(target, path);\n\tconst raw = unwrap(collection);\n\tconst changed = collectionMutationChanges(raw, kind, method, input);\n\tconst result = mutateReactiveCollection(target, path, kind, method, input);\n\tif (changed) {\n\t\tlet mutations = taskCollectionMutations.get(signal);\n\t\tif (!mutations) {\n\t\t\tmutations = [];\n\t\t\ttaskCollectionMutations.set(signal, mutations);\n\t\t\tsignal.addEventListener('abort', () => discardTaskMutations(signal), { once: true });\n\t\t}\n\t\tmutations.push(collectionMutation(path, kind, method, input));\n\t}\n\treturn result;\n}\n\n/** Takes the ordered collection deltas produced by one successful task generation. */\nexport function takeTaskCollectionMutations(\n\tsignal: AbortSignal\n): readonly ExactCollectionMutation[] | undefined {\n\tconst mutations = taskCollectionMutations.get(signal);\n\ttaskCollectionMutations.delete(signal);\n\treturn mutations?.length ? mutations : undefined;\n}\n\nfunction readTaskCollection(target: object, path: readonly PropertyKey[]): unknown {\n\tlet value: unknown = target;\n\tfor (const segment of path) value = Reflect.get(value as object, segment);\n\treturn value;\n}\n\nfunction collectionMutationChanges(\n\tvalue: unknown,\n\tkind: 'map' | 'set',\n\tmethod: string,\n\targs: readonly unknown[]\n): boolean {\n\tif (kind === 'map' && value instanceof Map) {\n\t\tif (method === 'clear') return value.size > 0;\n\t\tif (method === 'delete') return value.has(unwrap(args[0]));\n\t\tconst key = unwrap(args[0]);\n\t\treturn !value.has(key) || !Object.is(value.get(key), unwrap(args[1]));\n\t}\n\tif (kind === 'set' && value instanceof Set) {\n\t\tif (method === 'clear') return value.size > 0;\n\t\tif (method === 'delete') return value.has(unwrap(args[0]));\n\t\treturn !value.has(unwrap(args[0]));\n\t}\n\treturn true;\n}\n\nfunction collectionMutation(\n\tpath: readonly PropertyKey[],\n\tkind: 'map' | 'set',\n\tmethod: string,\n\targs: readonly unknown[]\n): ExactCollectionMutation {\n\tconst location = path.map(String).join('.');\n\tif (kind === 'map') {\n\t\tif (method === 'set')\n\t\t\treturn { path: location, operation: 'map-set', key: unwrap(args[0]), value: unwrap(args[1]) };\n\t\tif (method === 'delete')\n\t\t\treturn { path: location, operation: 'map-delete', key: unwrap(args[0]) };\n\t\treturn { path: location, operation: 'map-clear' };\n\t}\n\tif (method === 'add') return { path: location, operation: 'set-add', value: unwrap(args[0]) };\n\tif (method === 'delete')\n\t\treturn { path: location, operation: 'set-delete', value: unwrap(args[0]) };\n\treturn { path: location, operation: 'set-clear' };\n}\n\n/** Registers once-only task cleanup and reports asynchronous disposal failures. */\nexport function registerTaskCleanup(signal: AbortSignal, cleanup: TaskCleanup): void {\n\tlet active = true;\n\tconst run = (): void => {\n\t\tif (!active) return;\n\t\tactive = false;\n\t\tsignal.removeEventListener('abort', run);\n\t\ttry {\n\t\t\tconst result = cleanup(signal.reason);\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\ttrackTaskCleanupPromise(\n\t\t\t\t\tsignal,\n\t\t\t\t\tPromise.resolve(result).catch((error) => {\n\t\t\t\t\t\treportTaskResourceError(signal, error);\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treportTaskResourceError(signal, error);\n\t\t}\n\t};\n\tif (signal.aborted) run();\n\telse signal.addEventListener('abort', run, { once: true });\n}\n\nfunction trackTaskCleanupPromise(signal: AbortSignal, promise: Promise<void>): void {\n\tlet pending = taskCleanupPromises.get(signal);\n\tif (!pending) {\n\t\tpending = new Set();\n\t\ttaskCleanupPromises.set(signal, pending);\n\t}\n\tpending.add(promise);\n\tvoid promise.finally(() => {\n\t\tpending!.delete(promise);\n\t\tif (!pending!.size) taskCleanupPromises.delete(signal);\n\t});\n}\n\n/** Waits for registered task cleanup promises and preserves failures for aggregate reporting. */\nexport function drainTaskCleanupPromises(\n\tsignal: AbortSignal | undefined\n): Promise<void> | undefined {\n\tif (!signal) return undefined;\n\tconst pending = taskCleanupPromises.get(signal);\n\tif (!pending?.size) return undefined;\n\treturn Promise.all([...pending]).then(() => undefined);\n}\n\n/** Owns a disposable value while preserving the value and expression result. */\nexport function ownTaskResource<T>(\n\tsignal: AbortSignal,\n\tresource: T,\n\tdisposal?: TaskResourceDisposal | ((resource: T, reason?: unknown) => void | Promise<void>)\n): T {\n\tregisterTaskCleanup(signal, (reason) => disposeTaskResource(resource, disposal, reason));\n\treturn resource;\n}\n\n/** Compiler helper for idle callbacks owned by one task generation. */\nexport function taskIdleCallback(\n\tsignal: AbortSignal,\n\tcallback: (deadline: TaskIdleDeadline) => void,\n\toptions?: TaskIdleOptions\n): number {\n\tconst platform = globalThis as typeof globalThis & {\n\t\trequestIdleCallback(\n\t\t\tcallback: (deadline: TaskIdleDeadline) => void,\n\t\t\toptions?: TaskIdleOptions\n\t\t): number;\n\t\tcancelIdleCallback(handle: number): void;\n\t};\n\tlet handle = 0;\n\tconst cancel = () => platform.cancelIdleCallback(handle);\n\thandle = platform.requestIdleCallback((deadline) => {\n\t\tsignal.removeEventListener('abort', cancel);\n\t\tif (!signal.aborted) runTaskCallback(signal, 'idle-callback', () => callback(deadline));\n\t}, options);\n\tif (signal.aborted) cancel();\n\telse signal.addEventListener('abort', cancel, { once: true });\n\treturn handle;\n}\n\nfunction disposeTaskResource<T>(\n\tresource: T,\n\tdisposal:\n\t\t| TaskResourceDisposal\n\t\t| ((resource: T, reason?: unknown) => void | Promise<void>)\n\t\t| undefined,\n\treason: unknown\n): void | Promise<void> {\n\tif (typeof disposal === 'function') return disposal(resource, reason);\n\tif (disposal === 'call') {\n\t\tif (typeof resource === 'function') return resource();\n\t\treturn;\n\t}\n\tif (!resource || (typeof resource !== 'object' && typeof resource !== 'function')) return;\n\tif (disposal === 'cancel') return invokeResourceMethod(resource, 'cancel', reason);\n\tif (disposal) return invokeResourceMethod(resource, disposal);\n\tconst symbols = Symbol as SymbolConstructor & { asyncDispose?: symbol; dispose?: symbol };\n\tif (symbols.asyncDispose) {\n\t\tconst result = invokeResourceMethod(resource, symbols.asyncDispose);\n\t\tif (result !== undefined) return result;\n\t}\n\tif (symbols.dispose) return invokeResourceMethod(resource, symbols.dispose);\n}\n\nfunction invokeResourceMethod(\n\tresource: object,\n\tkey: PropertyKey,\n\t...args: unknown[]\n): void | Promise<void> | undefined {\n\tconst method = Reflect.get(resource, key) as unknown;\n\tif (typeof method === 'function') return method.apply(resource, args) as void | Promise<void>;\n}\n\nfunction reportTaskResourceError(signal: AbortSignal, error: unknown): void {\n\tconst instance = taskOwners.get(signal);\n\tif (instance) {\n\t\thandleComponentError(instance, createErrorReport(error, 'task', instance, 'resource-cleanup'));\n\t\treturn;\n\t}\n\tlogFrameworkEvent('error', 'core', 'task', 'task resource cleanup failed', error);\n}\n\n/** Compiler helpers for resources whose lifetime is owned by a task generation. */\nexport function taskTimeout<Args extends unknown[]>(\n\tsignal: AbortSignal,\n\thandler: (...args: Args) => void,\n\tdelay?: number,\n\t...args: Args\n): ReturnType<typeof setTimeout> {\n\tconst abort = () => clearTimeout(timeout);\n\tconst timeout = setTimeout(\n\t\t(...values: Args) => {\n\t\t\tsignal.removeEventListener('abort', abort);\n\t\t\tif (!signal.aborted) runTaskCallback(signal, 'timeout', () => handler(...values));\n\t\t},\n\t\tdelay,\n\t\t...args\n\t);\n\tif (signal.aborted) abort();\n\telse signal.addEventListener('abort', abort, { once: true });\n\treturn timeout;\n}\n\n/** Starts an interval whose timer is cleared automatically when the task signal aborts. */\nexport function taskInterval<Args extends unknown[]>(\n\tsignal: AbortSignal,\n\thandler: (...args: Args) => void,\n\tdelay?: number,\n\t...args: Args\n): ReturnType<typeof setInterval> {\n\tconst interval = setInterval(\n\t\t(...values: Args) => {\n\t\t\tif (!signal.aborted) runTaskCallback(signal, 'interval', () => handler(...values));\n\t\t},\n\t\tdelay,\n\t\t...args\n\t);\n\tif (signal.aborted) clearInterval(interval);\n\telse signal.addEventListener('abort', () => clearInterval(interval), { once: true });\n\treturn interval;\n}\n\n/** Requests an animation frame that is cancelled automatically with the owning task. */\nexport function taskAnimationFrame(signal: AbortSignal, handler: (time: number) => void): number {\n\tconst platform = globalThis as typeof globalThis & {\n\t\trequestAnimationFrame(callback: (time: number) => void): number;\n\t\tcancelAnimationFrame(id: number): void;\n\t};\n\tlet frame = 0;\n\tconst cancel = () => platform.cancelAnimationFrame(frame);\n\tframe = platform.requestAnimationFrame((time) => {\n\t\tsignal.removeEventListener('abort', cancel);\n\t\tif (!signal.aborted) runTaskCallback(signal, 'animation-frame', () => handler(time));\n\t});\n\tif (signal.aborted) cancel();\n\telse signal.addEventListener('abort', cancel, { once: true });\n\treturn frame;\n}\n\n/** Owns an observer instance and disconnects it when the task is cancelled. */\nexport function taskObserver<T extends { disconnect(): void }>(\n\tsignal: AbortSignal,\n\tobserver: T\n): T {\n\tregisterTaskCleanup(signal, () => observer.disconnect());\n\treturn observer;\n}\n\nfunction runTaskCallback(signal: AbortSignal, phase: string, callback: () => void): void {\n\ttry {\n\t\tcallback();\n\t} catch (error) {\n\t\tconst instance = taskOwners.get(signal);\n\t\tif (instance) handleComponentError(instance, createErrorReport(error, 'task', instance, phase));\n\t\telse reportTaskResourceError(signal, error);\n\t}\n}\n\n/** Runs fetch with the task signal combined with any caller-provided cancellation signal. */\nexport function taskFetch<T>(\n\tsignal: AbortSignal,\n\tfetcher: (input: unknown, init?: Record<string, unknown>) => T,\n\tinput: unknown,\n\tinit?: Record<string, unknown>\n): T {\n\tconst options = init ? { ...init } : {};\n\tconst existing = options.signal;\n\tconst combined = isAbortSignal(existing)\n\t\t? createDisposableAbortSignal(existing, signal)\n\t\t: undefined;\n\toptions.signal = combined?.signal ?? signal;\n\ttry {\n\t\tconst result = fetcher(input, options);\n\t\tif (combined && isPromiseLike(result)) {\n\t\t\tvoid Promise.resolve(result).finally(combined.dispose).catch(ignoreSettlement);\n\t\t} else combined?.dispose();\n\t\treturn result;\n\t} catch (error) {\n\t\tcombined?.dispose();\n\t\tthrow error;\n\t}\n}\n\nfunction ignoreSettlement(): void {}\n\n/**\n * Awaits a value while retaining task cancellation and Activity parking semantics.\n *\n * The source promise continues while its component scope is paused. Its authored continuation\n * remains parked until the scope resumes, and cancellation can still reject during that wait.\n */\nexport function taskAwait<T>(signal: AbortSignal, value: T | PromiseLike<T>): Promise<T> {\n\tif (signal.aborted) return Promise.reject(new TaskCancellation(signal.reason));\n\treturn new Promise<T>((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet releaseWaiter: (() => void) | undefined;\n\t\tconst abort = () => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\treleaseWaiter?.();\n\t\t\treleaseWaiter = undefined;\n\t\t\tresumeTaskFrame(signal, () => reject(new TaskCancellation(signal.reason)));\n\t\t};\n\t\tsignal.addEventListener('abort', abort, { once: true });\n\t\tconst finish = (result: unknown, failed: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tsignal.removeEventListener('abort', abort);\n\t\t\tresumeTaskFrame(signal, () => {\n\t\t\t\tif (failed) reject(result);\n\t\t\t\telse if (signal.aborted) reject(new TaskCancellation(signal.reason));\n\t\t\t\telse resolve(result as T);\n\t\t\t});\n\t\t};\n\t\tconst continueTask = (result: unknown, failed: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tconst owner = taskOwners.get(signal);\n\t\t\tif (owner?.scope.paused) {\n\t\t\t\treleaseWaiter = scheduleEffectScopeResume(owner.scope, () => {\n\t\t\t\t\treleaseWaiter = undefined;\n\t\t\t\t\tfinish(result, failed);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinish(result, failed);\n\t\t};\n\t\tPromise.resolve(value).then(\n\t\t\t(result) => continueTask(result, false),\n\t\t\t(error: unknown) => continueTask(error, true)\n\t\t);\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/tasks/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,wBAAwB,EACxB,MAAM,EACN,yBAAyB,EACzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW5D,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,UAAU,GAAG,IAAI,OAAO,EAAqC,CAAC;AAEpE,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,KAA2B;IAC9E,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC/B,CAAC;AACD,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAmC,CAAC;AAC3E,MAAM,aAAa,GAAG,IAAI,OAAO,EAAkC,CAAC;AACpE,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAA0C,CAAC;AAEtF,uFAAuF;AACvF,MAAM,UA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import { createDisposableAbortSignal, isAbortSignal } from './signals.js';\nimport { isPromiseLike } from '../component/async-value.js';\n\nimport type {\n\tAnyComponentInstance,\n\tTaskCleanup,\n\tTaskIdleDeadline,\n\tTaskIdleOptions,\n\tTaskResourceDisposal\n} from '../component/contracts.js';\nimport type { ExactCollectionMutation } from '../component-contracts.js';\n\nimport { createErrorReport, handleComponentError } from '../component/errors.js';\nimport { TaskCancellation } from './cancellation.js';\nimport { resumeTaskFrame } from './frame-runtime.js';\n\nimport { logFrameworkEvent } from '../component/log.js';\n\nconst taskOwners = new WeakMap<AbortSignal, AnyComponentInstance>();\n\n/** Associates a task generation signal with its component owner. */\nexport function trackTaskOwner(signal: AbortSignal, owner: AnyComponentInstance): void {\n\ttaskOwners.set(signal, owner);\n}\nconst taskCleanupPromises = new WeakMap<AbortSignal, Set<Promise<void>>>();\nconst taskMutations = new WeakMap<AbortSignal, Array<() => void>>();\nconst taskCollectionMutations = new WeakMap<AbortSignal, ExactCollectionMutation[]>();\n\n/** Stages a compiler-generated mutation until its blocking task generation commits. */\nexport function stageTaskMutation(signal: AbortSignal, mutation: () => void): void {\n\tif (signal.aborted) return;\n\tlet staged = taskMutations.get(signal);\n\tif (!staged) {\n\t\tstaged = [];\n\t\ttaskMutations.set(signal, staged);\n\t\tsignal.addEventListener('abort', () => discardTaskMutations(signal), { once: true });\n\t}\n\tstaged.push(mutation);\n}\n\n/** Publishes staged mutations for a successful task generation as one reactive batch. */\nexport function publishTaskMutations(signal: AbortSignal): void {\n\tconst staged = taskMutations.get(signal);\n\tif (!staged) return;\n\ttaskMutations.delete(signal);\n\tbatch(() => {\n\t\tfor (const mutation of staged) mutation();\n\t});\n}\n\n/** Discards every unpublished mutation owned by a task generation. */\nexport function discardTaskMutations(signal: AbortSignal): void {\n\ttaskMutations.delete(signal);\n\ttaskCollectionMutations.delete(signal);\n}\n\n/**\n * Applies a server-task collection mutation and records the smallest ordered\n * response delta that can reproduce the successful change in the browser.\n */\nexport function mutateTaskCollection(\n\tsignal: AbortSignal,\n\ttarget: object,\n\tpath: readonly PropertyKey[],\n\tkind: 'map' | 'set',\n\tmethod: 'set' | 'add' | 'delete' | 'clear',\n\targs: unknown[] | (() => unknown[])\n): unknown {\n\tif (signal.aborted) return undefined;\n\tconst input = typeof args === 'function' ? args() : args;\n\tconst collection = readTaskCollection(target, path);\n\tconst raw = unwrap(collection);\n\tconst changed = collectionMutationChanges(raw, kind, method, input);\n\tconst result = mutateReactiveCollection(target, path, kind, method, input);\n\tif (changed) {\n\t\tlet mutations = taskCollectionMutations.get(signal);\n\t\tif (!mutations) {\n\t\t\tmutations = [];\n\t\t\ttaskCollectionMutations.set(signal, mutations);\n\t\t\tsignal.addEventListener('abort', () => discardTaskMutations(signal), { once: true });\n\t\t}\n\t\tmutations.push(collectionMutation(path, kind, method, input));\n\t}\n\treturn result;\n}\n\n/** Takes the ordered collection deltas produced by one successful task generation. */\nexport function takeTaskCollectionMutations(\n\tsignal: AbortSignal\n): readonly ExactCollectionMutation[] | undefined {\n\tconst mutations = taskCollectionMutations.get(signal);\n\ttaskCollectionMutations.delete(signal);\n\treturn mutations?.length ? mutations : undefined;\n}\n\nfunction readTaskCollection(target: object, path: readonly PropertyKey[]): unknown {\n\tlet value: unknown = target;\n\tfor (const segment of path) value = Reflect.get(value as object, segment);\n\treturn value;\n}\n\nfunction collectionMutationChanges(\n\tvalue: unknown,\n\tkind: 'map' | 'set',\n\tmethod: string,\n\targs: readonly unknown[]\n): boolean {\n\tif (kind === 'map' && value instanceof Map) {\n\t\tif (method === 'clear') return value.size > 0;\n\t\tif (method === 'delete') return value.has(unwrap(args[0]));\n\t\tconst key = unwrap(args[0]);\n\t\treturn !value.has(key) || !Object.is(value.get(key), unwrap(args[1]));\n\t}\n\tif (kind === 'set' && value instanceof Set) {\n\t\tif (method === 'clear') return value.size > 0;\n\t\tif (method === 'delete') return value.has(unwrap(args[0]));\n\t\treturn !value.has(unwrap(args[0]));\n\t}\n\treturn true;\n}\n\nfunction collectionMutation(\n\tpath: readonly PropertyKey[],\n\tkind: 'map' | 'set',\n\tmethod: string,\n\targs: readonly unknown[]\n): ExactCollectionMutation {\n\tconst location = path.map(String).join('.');\n\tif (kind === 'map') {\n\t\tif (method === 'set')\n\t\t\treturn { path: location, operation: 'map-set', key: unwrap(args[0]), value: unwrap(args[1]) };\n\t\tif (method === 'delete')\n\t\t\treturn { path: location, operation: 'map-delete', key: unwrap(args[0]) };\n\t\treturn { path: location, operation: 'map-clear' };\n\t}\n\tif (method === 'add') return { path: location, operation: 'set-add', value: unwrap(args[0]) };\n\tif (method === 'delete')\n\t\treturn { path: location, operation: 'set-delete', value: unwrap(args[0]) };\n\treturn { path: location, operation: 'set-clear' };\n}\n\n/** Registers once-only task cleanup and reports asynchronous disposal failures. */\nexport function registerTaskCleanup(signal: AbortSignal, cleanup: TaskCleanup): void {\n\tlet active = true;\n\tconst run = (): void => {\n\t\tif (!active) return;\n\t\tactive = false;\n\t\tsignal.removeEventListener('abort', run);\n\t\ttry {\n\t\t\tconst result = cleanup(signal.reason);\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\ttrackTaskCleanupPromise(\n\t\t\t\t\tsignal,\n\t\t\t\t\tPromise.resolve(result).catch((error) => {\n\t\t\t\t\t\treportTaskResourceError(signal, error);\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treportTaskResourceError(signal, error);\n\t\t}\n\t};\n\tif (signal.aborted) run();\n\telse signal.addEventListener('abort', run, { once: true });\n}\n\nfunction trackTaskCleanupPromise(signal: AbortSignal, promise: Promise<void>): void {\n\tlet pending = taskCleanupPromises.get(signal);\n\tif (!pending) {\n\t\tpending = new Set();\n\t\ttaskCleanupPromises.set(signal, pending);\n\t}\n\tpending.add(promise);\n\tvoid promise.finally(() => {\n\t\tpending!.delete(promise);\n\t\tif (!pending!.size) taskCleanupPromises.delete(signal);\n\t});\n}\n\n/** Waits for registered task cleanup promises and preserves failures for aggregate reporting. */\nexport function drainTaskCleanupPromises(\n\tsignal: AbortSignal | undefined\n): Promise<void> | undefined {\n\tif (!signal) return undefined;\n\tconst pending = taskCleanupPromises.get(signal);\n\tif (!pending?.size) return undefined;\n\treturn Promise.all([...pending]).then(() => undefined);\n}\n\n/** Owns a disposable value while preserving the value and expression result. */\nexport function ownTaskResource<T>(\n\tsignal: AbortSignal,\n\tresource: T,\n\tdisposal?: TaskResourceDisposal | ((resource: T, reason?: unknown) => void | Promise<void>)\n): T {\n\tregisterTaskCleanup(signal, (reason) => disposeTaskResource(resource, disposal, reason));\n\treturn resource;\n}\n\n/** Compiler helper for idle callbacks owned by one task generation. */\nexport function taskIdleCallback(\n\tsignal: AbortSignal,\n\tcallback: (deadline: TaskIdleDeadline) => void,\n\toptions?: TaskIdleOptions\n): number {\n\tconst platform = globalThis as typeof globalThis & {\n\t\trequestIdleCallback(\n\t\t\tcallback: (deadline: TaskIdleDeadline) => void,\n\t\t\toptions?: TaskIdleOptions\n\t\t): number;\n\t\tcancelIdleCallback(handle: number): void;\n\t};\n\tlet handle = 0;\n\tconst cancel = () => platform.cancelIdleCallback(handle);\n\thandle = platform.requestIdleCallback((deadline) => {\n\t\tsignal.removeEventListener('abort', cancel);\n\t\tif (!signal.aborted) runTaskCallback(signal, 'idle-callback', () => callback(deadline));\n\t}, options);\n\tif (signal.aborted) cancel();\n\telse signal.addEventListener('abort', cancel, { once: true });\n\treturn handle;\n}\n\nfunction disposeTaskResource<T>(\n\tresource: T,\n\tdisposal:\n\t\t| TaskResourceDisposal\n\t\t| ((resource: T, reason?: unknown) => void | Promise<void>)\n\t\t| undefined,\n\treason: unknown\n): void | Promise<void> {\n\tif (typeof disposal === 'function') return disposal(resource, reason);\n\tif (disposal === 'call') {\n\t\tif (typeof resource === 'function') return resource();\n\t\treturn;\n\t}\n\tif (!resource || (typeof resource !== 'object' && typeof resource !== 'function')) return;\n\tif (disposal === 'cancel') return invokeResourceMethod(resource, 'cancel', reason);\n\tif (disposal) return invokeResourceMethod(resource, disposal);\n\tconst symbols = Symbol as SymbolConstructor & { asyncDispose?: symbol; dispose?: symbol };\n\tif (symbols.asyncDispose) {\n\t\tconst result = invokeResourceMethod(resource, symbols.asyncDispose);\n\t\tif (result !== undefined) return result;\n\t}\n\tif (symbols.dispose) return invokeResourceMethod(resource, symbols.dispose);\n}\n\nfunction invokeResourceMethod(\n\tresource: object,\n\tkey: PropertyKey,\n\t...args: unknown[]\n): void | Promise<void> | undefined {\n\tconst method = Reflect.get(resource, key) as unknown;\n\tif (typeof method === 'function') return method.apply(resource, args) as void | Promise<void>;\n}\n\nfunction reportTaskResourceError(signal: AbortSignal, error: unknown): void {\n\tconst instance = taskOwners.get(signal);\n\tif (instance) {\n\t\thandleComponentError(instance, createErrorReport(error, 'task', instance, 'resource-cleanup'));\n\t\treturn;\n\t}\n\tlogFrameworkEvent('error', 'core', 'task', 'task resource cleanup failed', error);\n}\n\n/** Compiler helpers for resources whose lifetime is owned by a task generation. */\nexport function taskTimeout<Args extends unknown[]>(\n\tsignal: AbortSignal,\n\thandler: (...args: Args) => void,\n\tdelay?: number,\n\t...args: Args\n): ReturnType<typeof setTimeout> {\n\tconst abort = () => clearTimeout(timeout);\n\tconst timeout = setTimeout(\n\t\t(...values: Args) => {\n\t\t\tsignal.removeEventListener('abort', abort);\n\t\t\tif (!signal.aborted) runTaskCallback(signal, 'timeout', () => handler(...values));\n\t\t},\n\t\tdelay,\n\t\t...args\n\t);\n\tif (signal.aborted) abort();\n\telse signal.addEventListener('abort', abort, { once: true });\n\treturn timeout;\n}\n\n/** Starts an interval whose timer is cleared automatically when the task signal aborts. */\nexport function taskInterval<Args extends unknown[]>(\n\tsignal: AbortSignal,\n\thandler: (...args: Args) => void,\n\tdelay?: number,\n\t...args: Args\n): ReturnType<typeof setInterval> {\n\tconst interval = setInterval(\n\t\t(...values: Args) => {\n\t\t\tif (!signal.aborted) runTaskCallback(signal, 'interval', () => handler(...values));\n\t\t},\n\t\tdelay,\n\t\t...args\n\t);\n\tif (signal.aborted) clearInterval(interval);\n\telse signal.addEventListener('abort', () => clearInterval(interval), { once: true });\n\treturn interval;\n}\n\n/** Requests an animation frame that is cancelled automatically with the owning task. */\nexport function taskAnimationFrame(signal: AbortSignal, handler: (time: number) => void): number {\n\tconst platform = globalThis as typeof globalThis & {\n\t\trequestAnimationFrame(callback: (time: number) => void): number;\n\t\tcancelAnimationFrame(id: number): void;\n\t};\n\tlet frame = 0;\n\tconst cancel = () => platform.cancelAnimationFrame(frame);\n\tframe = platform.requestAnimationFrame((time) => {\n\t\tsignal.removeEventListener('abort', cancel);\n\t\tif (!signal.aborted) runTaskCallback(signal, 'animation-frame', () => handler(time));\n\t});\n\tif (signal.aborted) cancel();\n\telse signal.addEventListener('abort', cancel, { once: true });\n\treturn frame;\n}\n\n/** Owns an observer instance and disconnects it when the task is cancelled. */\nexport function taskObserver<T extends { disconnect(): void }>(\n\tsignal: AbortSignal,\n\tobserver: T\n): T {\n\tregisterTaskCleanup(signal, () => observer.disconnect());\n\treturn observer;\n}\n\nfunction runTaskCallback(signal: AbortSignal, phase: string, callback: () => void): void {\n\ttry {\n\t\tcallback();\n\t} catch (error) {\n\t\tconst instance = taskOwners.get(signal);\n\t\tif (instance) handleComponentError(instance, createErrorReport(error, 'task', instance, phase));\n\t\telse reportTaskResourceError(signal, error);\n\t}\n}\n\n/** Runs fetch with the task signal combined with any caller-provided cancellation signal. */\nexport function taskFetch<T>(\n\tsignal: AbortSignal,\n\tfetcher: (input: unknown, init?: Record<string, unknown>) => T,\n\tinput: unknown,\n\tinit?: Record<string, unknown>\n): T {\n\tconst options = init ? { ...init } : {};\n\tconst existing = options.signal;\n\tconst combined = isAbortSignal(existing)\n\t\t? createDisposableAbortSignal(existing, signal)\n\t\t: undefined;\n\toptions.signal = combined?.signal ?? signal;\n\ttry {\n\t\tconst result = fetcher(input, options);\n\t\tif (combined && isPromiseLike(result)) {\n\t\t\tvoid Promise.resolve(result).finally(combined.dispose).catch(ignoreSettlement);\n\t\t} else combined?.dispose();\n\t\treturn result;\n\t} catch (error) {\n\t\tcombined?.dispose();\n\t\tthrow error;\n\t}\n}\n\nfunction ignoreSettlement(): void {}\n\n/**\n * Awaits a value while retaining task cancellation and Activity parking semantics.\n *\n * The source promise continues while its component scope is paused. Its authored continuation\n * remains parked until the scope resumes, and cancellation can still reject during that wait.\n */\nexport function taskAwait<T>(signal: AbortSignal, value: T | PromiseLike<T>): Promise<T> {\n\tif (signal.aborted) {\n\t\t// The source expression has already executed and still owns a possible rejection.\n\t\tvoid Promise.resolve(value).catch(ignoreSettlement);\n\t\treturn Promise.reject(new TaskCancellation(signal.reason));\n\t}\n\treturn new Promise<T>((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet releaseWaiter: (() => void) | undefined;\n\t\tconst abort = () => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\treleaseWaiter?.();\n\t\t\treleaseWaiter = undefined;\n\t\t\tresumeTaskFrame(signal, () => reject(new TaskCancellation(signal.reason)));\n\t\t};\n\t\tsignal.addEventListener('abort', abort, { once: true });\n\t\tconst finish = (result: unknown, failed: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tsignal.removeEventListener('abort', abort);\n\t\t\tresumeTaskFrame(signal, () => {\n\t\t\t\tif (failed) reject(result);\n\t\t\t\telse if (signal.aborted) reject(new TaskCancellation(signal.reason));\n\t\t\t\telse resolve(result as T);\n\t\t\t});\n\t\t};\n\t\tconst continueTask = (result: unknown, failed: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tconst owner = taskOwners.get(signal);\n\t\t\tif (owner?.scope.active && owner.scope.paused) {\n\t\t\t\treleaseWaiter = scheduleEffectScopeResume(owner.scope, () => {\n\t\t\t\t\treleaseWaiter = undefined;\n\t\t\t\t\tcontinueTask(result, failed);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinish(result, failed);\n\t\t};\n\t\tPromise.resolve(value).then(\n\t\t\t(result) => continueTask(result, false),\n\t\t\t(error: unknown) => continueTask(error, true)\n\t\t);\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduled-reactions.d.ts","sourceRoot":"","sources":["../../src/tasks/scheduled-reactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwBjF,sFAAsF;AACtF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,eAAe,GAAG,oBAAoB,
|
|
1
|
+
{"version":3,"file":"scheduled-reactions.d.ts","sourceRoot":"","sources":["../../src/tasks/scheduled-reactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwBjF,sFAAsF;AACtF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,eAAe,GAAG,oBAAoB,CA2C3F"}
|
|
@@ -35,9 +35,16 @@ export function acquireScheduledReactionBatch(parent) {
|
|
|
35
35
|
run(work) {
|
|
36
36
|
if (released)
|
|
37
37
|
return;
|
|
38
|
+
if (batch.signal.aborted) {
|
|
39
|
+
// Invalidation observes already committed state, and the live observer may have
|
|
40
|
+
// coalesced newer writes. Retire its cancelled task lease without discarding the
|
|
41
|
+
// observation or resuming the stale producer. Reaction scope disposal is owned
|
|
42
|
+
// by the scheduler; genuine observer failures still propagate normally.
|
|
43
|
+
release(new TaskCancellation(batch.signal.reason), true);
|
|
44
|
+
withTaskFrameRecord(undefined, work);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
38
47
|
try {
|
|
39
|
-
if (batch.signal.aborted)
|
|
40
|
-
throw new TaskCancellation(batch.signal.reason);
|
|
41
48
|
withTaskFrameRecord(batch.frame, work);
|
|
42
49
|
}
|
|
43
50
|
catch (error) {
|
|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,MAAM;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;KACb,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,MAAmB,EAAE,MAAuB;IAC9D,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;QAC3C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,kBAAkB;IAC1B,OAAO,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import type { ScheduledWorkContext } from '@exactjs/reactive/framework/runtime';\nimport { TaskCancellation } from './cancellation.js';\nimport { taskFrameTokenBrand, type TaskFrameRecord } from './frame-contracts.js';\nimport { taskFrameInspectionAttached } from './frame-inspection-capability.js';\nimport {\n\tallocateTaskFrameId,\n\tattachTaskFrameSettlement,\n\tcurrentTaskFrameRecord,\n\texecuteTaskFrame,\n\twithTaskFrameRecord\n} from './frame-runtime.js';\nimport { settleTaskFrameChildren } from './frame-settlement.js';\n\ntype ScheduledReactionBatch = {\n\treadonly frame: TaskFrameRecord;\n\treadonly signal: AbortSignal;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n\tpending: number;\n\tfailed: boolean;\n\tfailure?: unknown;\n\tclosed: boolean;\n};\n\nconst scheduledReactionBatches = new WeakMap<TaskFrameRecord, ScheduledReactionBatch>();\n\n/** Acquires one lease on the consequence frame shared by a task invalidation wave. */\nexport function acquireScheduledReactionBatch(parent: TaskFrameRecord): ScheduledWorkContext {\n\tlet batch = scheduledReactionBatches.get(parent);\n\tif (!batch || batch.closed) {\n\t\tbatch = createScheduledReactionBatch(parent);\n\t\tscheduledReactionBatches.set(parent, batch);\n\t}\n\tbatch.pending++;\n\tlet released = false;\n\tconst release = (error?: unknown, failed = false) => {\n\t\tif (released) return;\n\t\treleased = true;\n\t\tif (failed && !batch!.failed) {\n\t\t\tbatch!.failed = true;\n\t\t\tbatch!.failure = error;\n\t\t}\n\t\tif (--batch!.pending !== 0) return;\n\t\tbatch!.closed = true;\n\t\tif (scheduledReactionBatches.get(parent) === batch) scheduledReactionBatches.delete(parent);\n\t\tif (batch!.failed) batch!.reject(batch!.failure);\n\t\telse batch!.resolve();\n\t};\n\treturn {\n\t\trun(work) {\n\t\t\tif (released) return;\n\t\t\ttry {\n\t\t\t\tif (batch!.signal.aborted) throw new TaskCancellation(batch!.signal.reason);\n\t\t\t\twithTaskFrameRecord(batch!.frame, work);\n\t\t\t} catch (error) {\n\t\t\t\trelease(error, true);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\trelease();\n\t\t},\n\t\tcancel: release\n\t};\n}\n\nfunction createScheduledReactionBatch(parent: TaskFrameRecord): ScheduledReactionBatch {\n\treturn taskFrameInspectionAttached(parent)\n\t\t? createInspectedScheduledReactionBatch(parent)\n\t\t: createInlineScheduledReactionBatch(parent);\n}\n\n/** Attaches one completion lease without a complete public task frame. */\nfunction createInlineScheduledReactionBatch(parent: TaskFrameRecord): ScheduledReactionBatch {\n\tlet controller: AbortController | undefined;\n\tlet acceptCompletion!: () => void;\n\tlet rejectCompletion!: (error: unknown) => void;\n\tconst completion = new Promise<void>((accept, fail) => {\n\t\tacceptCompletion = accept;\n\t\trejectCompletion = fail;\n\t});\n\tconst frame: TaskFrameRecord = {\n\t\t[taskFrameTokenBrand]: true,\n\t\tid: allocateTaskFrameId(),\n\t\towner: parent.owner,\n\t\tparent,\n\t\tget controller() {\n\t\t\tif (!controller) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tlinkAbort(parent.controller.signal, controller);\n\t\t\t}\n\t\t\treturn controller;\n\t\t},\n\t\tkind: 'reactive',\n\t\tlabel: 'reactive consequences',\n\t\tactivation: parent.activation,\n\t\tgeneration: parent.generation,\n\t\tplacement: parent.placement,\n\t\tconcurrency: parent.concurrency,\n\t\tpriority: parent.priority,\n\t\treadiness: parent.readiness,\n\t\tstartedAt: monotonicTimestamp(),\n\t\tproducerOpen: true,\n\t\tsettled: false\n\t};\n\tattachTaskFrameSettlement(parent, completion);\n\treturn {\n\t\tframe,\n\t\tsignal: parent.controller.signal,\n\t\tresolve() {\n\t\t\tframe.producerOpen = false;\n\t\t\tvoid settleTaskFrameChildren(frame).then(\n\t\t\t\t() => finishInlineFrame(frame, acceptCompletion),\n\t\t\t\t(error) => finishInlineFrame(frame, () => rejectCompletion(error))\n\t\t\t);\n\t\t},\n\t\treject(error) {\n\t\t\tframe.producerOpen = false;\n\t\t\tcontroller?.abort(error);\n\t\t\tconst finish = () => finishInlineFrame(frame, () => rejectCompletion(error));\n\t\t\tvoid settleTaskFrameChildren(frame).then(finish, finish);\n\t\t},\n\t\tpending: 0,\n\t\tfailed: false,\n\t\tclosed: false\n\t};\n}\n\nfunction finishInlineFrame(frame: TaskFrameRecord, settle: () => void): void {\n\tframe.settled = true;\n\tsettle();\n}\n\n/** Retains the complete consequence projection while DevTools inspection is attached. */\nfunction createInspectedScheduledReactionBatch(parent: TaskFrameRecord): ScheduledReactionBatch {\n\tlet resolve!: () => void;\n\tlet reject!: (error: unknown) => void;\n\tconst completion = new Promise<void>((accept, fail) => {\n\t\tresolve = accept;\n\t\treject = fail;\n\t});\n\tlet frame!: TaskFrameRecord;\n\tconst execution = executeTaskFrame(\n\t\t{\n\t\t\tparent,\n\t\t\towner: parent.owner,\n\t\t\tactivation: parent.activation,\n\t\t\tkind: 'reactive',\n\t\t\tlabel: 'reactive consequences',\n\t\t\tpublicContext: false\n\t\t},\n\t\t() => {\n\t\t\tframe = currentTaskFrameRecord()!;\n\t\t\treturn completion;\n\t\t}\n\t);\n\tvoid execution.catch(() => undefined);\n\treturn {\n\t\tframe,\n\t\tsignal: frame.controller.signal,\n\t\tresolve,\n\t\treject,\n\t\tpending: 0,\n\t\tfailed: false,\n\t\tclosed: false\n\t};\n}\n\nfunction linkAbort(signal: AbortSignal, target: AbortController): void {\n\tif (signal.aborted) target.abort(signal.reason);\n\telse signal.addEventListener('abort', () => target.abort(signal.reason), { once: true });\n}\n\nfunction monotonicTimestamp(): number {\n\treturn globalThis.performance?.now() ?? Date.now();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scheduled-reactions.js","sourceRoot":"","sources":["../../src/tasks/scheduled-reactions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAwB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACN,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAahE,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAA2C,CAAC;AAExF,sFAAsF;AACtF,MAAM,UAAU,6BAA6B,CAAC,MAAuB;IACpE,IAAI,KAAK,GAAG,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC5B,KAAK,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC;QAC7C,wBAAwB,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,OAAO,EAAE,CAAC;IAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,OAAO,GAAG,CAAC,KAAe,EAAE,MAAM,GAAG,KAAK,EAAE,EAAE;QACnD,IAAI,QAAQ;YAAE,OAAO;QACrB,QAAQ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ACC,MAAM;QACN,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,uBAAuB;QAC9B,aAAa,EAAE,KAAK;KACpB,EACD,GAAG,EAAE;QACJ,KAAK,GAAG,sBAAsB,EAAG,CAAC;QAClC,OAAO,UAAU,CAAC;IACnB,CAAC,CACD,CAAC;IACF,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACtC,OAAO;QACN,KAAK;QACL,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM;QAC/B,OAAO;QACP,MAAM;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;KACb,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,MAAmB,EAAE,MAAuB;IAC9D,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;QAC3C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,kBAAkB;IAC1B,OAAO,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import type { ScheduledWorkContext } from '@exactjs/reactive/framework/runtime';\nimport { TaskCancellation } from './cancellation.js';\nimport { taskFrameTokenBrand, type TaskFrameRecord } from './frame-contracts.js';\nimport { taskFrameInspectionAttached } from './frame-inspection-capability.js';\nimport {\n\tallocateTaskFrameId,\n\tattachTaskFrameSettlement,\n\tcurrentTaskFrameRecord,\n\texecuteTaskFrame,\n\twithTaskFrameRecord\n} from './frame-runtime.js';\nimport { settleTaskFrameChildren } from './frame-settlement.js';\n\ntype ScheduledReactionBatch = {\n\treadonly frame: TaskFrameRecord;\n\treadonly signal: AbortSignal;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n\tpending: number;\n\tfailed: boolean;\n\tfailure?: unknown;\n\tclosed: boolean;\n};\n\nconst scheduledReactionBatches = new WeakMap<TaskFrameRecord, ScheduledReactionBatch>();\n\n/** Acquires one lease on the consequence frame shared by a task invalidation wave. */\nexport function acquireScheduledReactionBatch(parent: TaskFrameRecord): ScheduledWorkContext {\n\tlet batch = scheduledReactionBatches.get(parent);\n\tif (!batch || batch.closed) {\n\t\tbatch = createScheduledReactionBatch(parent);\n\t\tscheduledReactionBatches.set(parent, batch);\n\t}\n\tbatch.pending++;\n\tlet released = false;\n\tconst release = (error?: unknown, failed = false) => {\n\t\tif (released) return;\n\t\treleased = true;\n\t\tif (failed && !batch!.failed) {\n\t\t\tbatch!.failed = true;\n\t\t\tbatch!.failure = error;\n\t\t}\n\t\tif (--batch!.pending !== 0) return;\n\t\tbatch!.closed = true;\n\t\tif (scheduledReactionBatches.get(parent) === batch) scheduledReactionBatches.delete(parent);\n\t\tif (batch!.failed) batch!.reject(batch!.failure);\n\t\telse batch!.resolve();\n\t};\n\treturn {\n\t\trun(work) {\n\t\t\tif (released) return;\n\t\t\tif (batch!.signal.aborted) {\n\t\t\t\t// Invalidation observes already committed state, and the live observer may have\n\t\t\t\t// coalesced newer writes. Retire its cancelled task lease without discarding the\n\t\t\t\t// observation or resuming the stale producer. Reaction scope disposal is owned\n\t\t\t\t// by the scheduler; genuine observer failures still propagate normally.\n\t\t\t\trelease(new TaskCancellation(batch!.signal.reason), true);\n\t\t\t\twithTaskFrameRecord(undefined, work);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\twithTaskFrameRecord(batch!.frame, work);\n\t\t\t} catch (error) {\n\t\t\t\trelease(error, true);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\trelease();\n\t\t},\n\t\tcancel: release\n\t};\n}\n\nfunction createScheduledReactionBatch(parent: TaskFrameRecord): ScheduledReactionBatch {\n\treturn taskFrameInspectionAttached(parent)\n\t\t? createInspectedScheduledReactionBatch(parent)\n\t\t: createInlineScheduledReactionBatch(parent);\n}\n\n/** Attaches one completion lease without a complete public task frame. */\nfunction createInlineScheduledReactionBatch(parent: TaskFrameRecord): ScheduledReactionBatch {\n\tlet controller: AbortController | undefined;\n\tlet acceptCompletion!: () => void;\n\tlet rejectCompletion!: (error: unknown) => void;\n\tconst completion = new Promise<void>((accept, fail) => {\n\t\tacceptCompletion = accept;\n\t\trejectCompletion = fail;\n\t});\n\tconst frame: TaskFrameRecord = {\n\t\t[taskFrameTokenBrand]: true,\n\t\tid: allocateTaskFrameId(),\n\t\towner: parent.owner,\n\t\tparent,\n\t\tget controller() {\n\t\t\tif (!controller) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tlinkAbort(parent.controller.signal, controller);\n\t\t\t}\n\t\t\treturn controller;\n\t\t},\n\t\tkind: 'reactive',\n\t\tlabel: 'reactive consequences',\n\t\tactivation: parent.activation,\n\t\tgeneration: parent.generation,\n\t\tplacement: parent.placement,\n\t\tconcurrency: parent.concurrency,\n\t\tpriority: parent.priority,\n\t\treadiness: parent.readiness,\n\t\tstartedAt: monotonicTimestamp(),\n\t\tproducerOpen: true,\n\t\tsettled: false\n\t};\n\tattachTaskFrameSettlement(parent, completion);\n\treturn {\n\t\tframe,\n\t\tsignal: parent.controller.signal,\n\t\tresolve() {\n\t\t\tframe.producerOpen = false;\n\t\t\tvoid settleTaskFrameChildren(frame).then(\n\t\t\t\t() => finishInlineFrame(frame, acceptCompletion),\n\t\t\t\t(error) => finishInlineFrame(frame, () => rejectCompletion(error))\n\t\t\t);\n\t\t},\n\t\treject(error) {\n\t\t\tframe.producerOpen = false;\n\t\t\tcontroller?.abort(error);\n\t\t\tconst finish = () => finishInlineFrame(frame, () => rejectCompletion(error));\n\t\t\tvoid settleTaskFrameChildren(frame).then(finish, finish);\n\t\t},\n\t\tpending: 0,\n\t\tfailed: false,\n\t\tclosed: false\n\t};\n}\n\nfunction finishInlineFrame(frame: TaskFrameRecord, settle: () => void): void {\n\tframe.settled = true;\n\tsettle();\n}\n\n/** Retains the complete consequence projection while DevTools inspection is attached. */\nfunction createInspectedScheduledReactionBatch(parent: TaskFrameRecord): ScheduledReactionBatch {\n\tlet resolve!: () => void;\n\tlet reject!: (error: unknown) => void;\n\tconst completion = new Promise<void>((accept, fail) => {\n\t\tresolve = accept;\n\t\treject = fail;\n\t});\n\tlet frame!: TaskFrameRecord;\n\tconst execution = executeTaskFrame(\n\t\t{\n\t\t\tparent,\n\t\t\towner: parent.owner,\n\t\t\tactivation: parent.activation,\n\t\t\tkind: 'reactive',\n\t\t\tlabel: 'reactive consequences',\n\t\t\tpublicContext: false\n\t\t},\n\t\t() => {\n\t\t\tframe = currentTaskFrameRecord()!;\n\t\t\treturn completion;\n\t\t}\n\t);\n\tvoid execution.catch(() => undefined);\n\treturn {\n\t\tframe,\n\t\tsignal: frame.controller.signal,\n\t\tresolve,\n\t\treject,\n\t\tpending: 0,\n\t\tfailed: false,\n\t\tclosed: false\n\t};\n}\n\nfunction linkAbort(signal: AbortSignal, target: AbortController): void {\n\tif (signal.aborted) target.abort(signal.reason);\n\telse signal.addEventListener('abort', () => target.abort(signal.reason), { once: true });\n}\n\nfunction monotonicTimestamp(): number {\n\treturn globalThis.performance?.now() ?? Date.now();\n}\n"]}
|