@bluelibs/runner 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/browser/index.cjs +1039 -467
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.mjs +1037 -467
- package/dist/browser/index.mjs.map +1 -1
- package/dist/edge/index.cjs +1039 -467
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.mjs +1037 -467
- package/dist/edge/index.mjs.map +1 -1
- package/dist/node/node.cjs +1490 -570
- package/dist/node/node.cjs.map +1 -1
- package/dist/node/node.mjs +1485 -570
- package/dist/node/node.mjs.map +1 -1
- package/dist/types/define.d.ts +9 -0
- package/dist/types/definers/builders/asyncContext/fluent-builder.d.ts +6 -0
- package/dist/types/definers/builders/asyncContext/fluent-builder.interface.d.ts +9 -0
- package/dist/types/definers/builders/asyncContext/index.d.ts +10 -0
- package/dist/types/definers/builders/asyncContext/types.d.ts +13 -0
- package/dist/types/definers/builders/asyncContext/utils.d.ts +5 -0
- package/dist/types/definers/builders/asyncContext.d.ts +1 -0
- package/dist/types/definers/builders/core.d.ts +30 -0
- package/dist/types/definers/builders/error/fluent-builder.d.ts +7 -0
- package/dist/types/definers/builders/error/fluent-builder.interface.d.ts +10 -0
- package/dist/types/definers/builders/error/index.d.ts +11 -0
- package/dist/types/definers/builders/error/types.d.ts +14 -0
- package/dist/types/definers/builders/error/utils.d.ts +6 -0
- package/dist/types/definers/builders/error.d.ts +1 -0
- package/dist/types/definers/builders/event/fluent-builder.d.ts +7 -0
- package/dist/types/definers/builders/event/fluent-builder.interface.d.ts +18 -0
- package/dist/types/definers/builders/event/index.d.ts +10 -0
- package/dist/types/definers/builders/event/types.d.ts +8 -0
- package/dist/types/definers/builders/event/utils.d.ts +9 -0
- package/dist/types/definers/builders/event.d.ts +1 -0
- package/dist/types/definers/builders/hook/fluent-builder.d.ts +8 -0
- package/dist/types/definers/builders/hook/fluent-builder.interface.d.ts +27 -0
- package/dist/types/definers/builders/hook/index.d.ts +12 -0
- package/dist/types/definers/builders/hook/types.d.ts +14 -0
- package/dist/types/definers/builders/hook/utils.d.ts +14 -0
- package/dist/types/definers/builders/hook.d.ts +1 -0
- package/dist/types/definers/builders/middleware/index.d.ts +19 -0
- package/dist/types/definers/builders/middleware/resource.d.ts +7 -0
- package/dist/types/definers/builders/middleware/resource.interface.d.ts +18 -0
- package/dist/types/definers/builders/middleware/task.d.ts +7 -0
- package/dist/types/definers/builders/middleware/task.interface.d.ts +18 -0
- package/dist/types/definers/builders/middleware/types.d.ts +13 -0
- package/dist/types/definers/builders/middleware/utils.d.ts +18 -0
- package/dist/types/definers/builders/middleware.d.ts +1 -0
- package/dist/types/definers/builders/override/hook.d.ts +16 -0
- package/dist/types/definers/builders/override/index.d.ts +11 -0
- package/dist/types/definers/builders/override/resource-middleware.d.ts +3 -0
- package/dist/types/definers/builders/override/resource.d.ts +3 -0
- package/dist/types/definers/builders/override/task-middleware.d.ts +3 -0
- package/dist/types/definers/builders/override/task.d.ts +3 -0
- package/dist/types/definers/builders/resource/fluent-builder.d.ts +8 -0
- package/dist/types/definers/builders/resource/fluent-builder.interface.d.ts +42 -0
- package/dist/types/definers/builders/resource/index.d.ts +13 -0
- package/dist/types/definers/builders/resource/types.d.ts +37 -0
- package/dist/types/definers/builders/resource/utils.d.ts +26 -0
- package/dist/types/definers/builders/resource.d.ts +1 -0
- package/dist/types/definers/builders/tag/fluent-builder.d.ts +6 -0
- package/dist/types/definers/builders/tag/fluent-builder.interface.d.ts +8 -0
- package/dist/types/definers/builders/tag/index.d.ts +10 -0
- package/dist/types/definers/builders/tag/types.d.ts +12 -0
- package/dist/types/definers/builders/tag/utils.d.ts +5 -0
- package/dist/types/definers/builders/tag.d.ts +1 -0
- package/dist/types/definers/builders/task/fluent-builder.d.ts +8 -0
- package/dist/types/definers/builders/task/fluent-builder.interface.d.ts +33 -0
- package/dist/types/definers/builders/task/index.d.ts +21 -0
- package/dist/types/definers/builders/task/phantom-builder.d.ts +8 -0
- package/dist/types/definers/builders/task/phantom-builder.interface.d.ts +31 -0
- package/dist/types/definers/builders/task/types.d.ts +34 -0
- package/dist/types/definers/builders/task/utils.d.ts +14 -0
- package/dist/types/definers/builders/task.d.ts +1 -0
- package/dist/types/definers/builders/task.phantom.d.ts +1 -0
- package/dist/types/definers/builders/utils.d.ts +4 -0
- package/dist/types/definers/defineAsyncContext.d.ts +15 -0
- package/dist/types/definers/defineError.d.ts +27 -0
- package/dist/types/definers/defineEvent.d.ts +2 -0
- package/dist/types/definers/defineHook.d.ts +6 -0
- package/dist/types/definers/defineOverride.d.ts +12 -0
- package/dist/types/definers/defineResource.d.ts +2 -0
- package/dist/types/definers/defineResourceMiddleware.d.ts +2 -0
- package/dist/types/definers/defineTag.d.ts +12 -0
- package/dist/types/definers/defineTask.d.ts +18 -0
- package/dist/types/definers/defineTaskMiddleware.d.ts +2 -0
- package/dist/types/definers/middlewareConfig.d.ts +1 -0
- package/dist/types/definers/resourceFork.d.ts +13 -0
- package/dist/types/definers/tools.d.ts +53 -0
- package/dist/types/defs.d.ts +32 -0
- package/dist/types/errors.d.ts +75 -0
- package/dist/types/globals/debug.d.ts +10 -0
- package/dist/types/globals/globalEvents.d.ts +8 -0
- package/dist/types/globals/globalMiddleware.d.ts +97 -0
- package/dist/types/globals/globalResources.d.ts +64 -0
- package/dist/types/globals/globalTags.d.ts +12 -0
- package/dist/types/globals/middleware/cache.middleware.d.ts +36 -0
- package/dist/types/globals/middleware/circuitBreaker.middleware.d.ts +56 -0
- package/dist/types/globals/middleware/concurrency.middleware.d.ts +47 -0
- package/dist/types/globals/middleware/fallback.middleware.d.ts +23 -0
- package/dist/types/globals/middleware/rateLimit.middleware.d.ts +47 -0
- package/dist/types/globals/middleware/requireContext.middleware.d.ts +5 -0
- package/dist/types/globals/middleware/retry.middleware.d.ts +31 -0
- package/dist/types/globals/middleware/temporal.middleware.d.ts +48 -0
- package/dist/types/globals/middleware/timeout.middleware.d.ts +24 -0
- package/dist/types/globals/middleware/tunnel.middleware.d.ts +3 -0
- package/dist/types/globals/resources/debug/debug.resource.d.ts +7 -0
- package/dist/types/globals/resources/debug/debug.tag.d.ts +2 -0
- package/dist/types/globals/resources/debug/debugConfig.resource.d.ts +22 -0
- package/dist/types/globals/resources/debug/executionTracker.middleware.d.ts +50 -0
- package/dist/types/globals/resources/debug/globalEvent.hook.d.ts +27 -0
- package/dist/types/globals/resources/debug/hook.hook.d.ts +30 -0
- package/dist/types/globals/resources/debug/index.d.ts +6 -0
- package/dist/types/globals/resources/debug/middleware.hook.d.ts +30 -0
- package/dist/types/globals/resources/debug/types.d.ts +25 -0
- package/dist/types/globals/resources/debug/utils.d.ts +2 -0
- package/dist/types/globals/resources/httpClientFactory.resource.d.ts +28 -0
- package/dist/types/globals/resources/queue.resource.d.ts +10 -0
- package/dist/types/globals/resources/tunnel/error-utils.d.ts +1 -0
- package/dist/types/globals/resources/tunnel/plan.d.ts +19 -0
- package/dist/types/globals/resources/tunnel/protocol.d.ts +48 -0
- package/dist/types/globals/resources/tunnel/tunnel.policy.tag.d.ts +26 -0
- package/dist/types/globals/resources/tunnel/tunnel.tag.d.ts +2 -0
- package/dist/types/globals/resources/tunnel/types.d.ts +48 -0
- package/dist/types/globals/tunnels/index.d.ts +23 -0
- package/dist/types/globals/types.d.ts +15 -0
- package/dist/types/http-client.d.ts +26 -0
- package/dist/types/http-fetch-tunnel.resource.d.ts +11 -0
- package/dist/types/index.d.ts +44 -0
- package/dist/types/models/DependencyProcessor.d.ts +46 -0
- package/dist/types/models/EventManager.d.ts +115 -0
- package/dist/types/models/ExecutionJournal.d.ts +35 -0
- package/dist/types/models/LogPrinter.d.ts +56 -0
- package/dist/types/models/Logger.d.ts +85 -0
- package/dist/types/models/MiddlewareManager.d.ts +73 -0
- package/dist/types/models/OverrideManager.d.ts +13 -0
- package/dist/types/models/Queue.d.ts +40 -0
- package/dist/types/models/ResourceInitializer.d.ts +20 -0
- package/dist/types/models/RunResult.d.ts +41 -0
- package/dist/types/models/Semaphore.d.ts +80 -0
- package/dist/types/models/Store.d.ts +76 -0
- package/dist/types/models/StoreRegistry.d.ts +49 -0
- package/dist/types/models/StoreValidator.d.ts +8 -0
- package/dist/types/models/TaskRunner.d.ts +28 -0
- package/dist/types/models/UnhandledError.d.ts +11 -0
- package/dist/types/models/event/CycleContext.d.ts +9 -0
- package/dist/types/models/event/EmissionExecutor.d.ts +11 -0
- package/dist/types/models/event/InterceptorPipeline.d.ts +5 -0
- package/dist/types/models/event/ListenerRegistry.d.ts +31 -0
- package/dist/types/models/event/types.d.ts +50 -0
- package/dist/types/models/index.d.ts +13 -0
- package/dist/types/models/middleware/InterceptorRegistry.d.ts +56 -0
- package/dist/types/models/middleware/MiddlewareResolver.d.ts +31 -0
- package/dist/types/models/middleware/ResourceMiddlewareComposer.d.ts +34 -0
- package/dist/types/models/middleware/TaskMiddlewareComposer.d.ts +44 -0
- package/dist/types/models/middleware/ValidationHelper.d.ts +20 -0
- package/dist/types/models/middleware/index.d.ts +6 -0
- package/dist/types/models/middleware/types.d.ts +10 -0
- package/dist/types/models/utils/findCircularDependencies.d.ts +16 -0
- package/dist/types/models/utils/safeStringify.d.ts +3 -0
- package/dist/types/node/durable/bus/MemoryEventBus.d.ts +7 -0
- package/dist/types/node/durable/bus/NoopEventBus.d.ts +6 -0
- package/dist/types/node/durable/bus/RedisEventBus.d.ts +30 -0
- package/dist/types/node/durable/core/CronParser.d.ts +15 -0
- package/dist/types/node/durable/core/DurableContext.d.ts +64 -0
- package/dist/types/node/durable/core/DurableOperator.d.ts +47 -0
- package/dist/types/node/durable/core/DurableResource.d.ts +80 -0
- package/dist/types/node/durable/core/DurableService.d.ts +73 -0
- package/dist/types/node/durable/core/DurableWorker.d.ts +19 -0
- package/dist/types/node/durable/core/StepBuilder.d.ts +23 -0
- package/dist/types/node/durable/core/audit.d.ts +152 -0
- package/dist/types/node/durable/core/createRunnerDurableRuntime.d.ts +18 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.audit.d.ts +14 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.determinism.d.ts +13 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.emit.d.ts +16 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.sleep.d.ts +16 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.steps.d.ts +25 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.switch.d.ts +22 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.waitForSignal.d.ts +23 -0
- package/dist/types/node/durable/core/flowShape.d.ts +50 -0
- package/dist/types/node/durable/core/ids.d.ts +11 -0
- package/dist/types/node/durable/core/index.d.ts +11 -0
- package/dist/types/node/durable/core/interfaces/bus.d.ts +13 -0
- package/dist/types/node/durable/core/interfaces/context.d.ts +105 -0
- package/dist/types/node/durable/core/interfaces/queue.d.ts +17 -0
- package/dist/types/node/durable/core/interfaces/service.d.ts +146 -0
- package/dist/types/node/durable/core/interfaces/store.d.ts +66 -0
- package/dist/types/node/durable/core/managers/AuditLogger.d.ts +29 -0
- package/dist/types/node/durable/core/managers/ExecutionManager.d.ts +48 -0
- package/dist/types/node/durable/core/managers/PollingManager.d.ts +48 -0
- package/dist/types/node/durable/core/managers/ScheduleManager.d.ts +33 -0
- package/dist/types/node/durable/core/managers/SignalHandler.d.ts +25 -0
- package/dist/types/node/durable/core/managers/TaskRegistry.d.ts +16 -0
- package/dist/types/node/durable/core/managers/WaitManager.d.ts +26 -0
- package/dist/types/node/durable/core/managers/index.d.ts +7 -0
- package/dist/types/node/durable/core/resource.d.ts +14 -0
- package/dist/types/node/durable/core/types.d.ts +84 -0
- package/dist/types/node/durable/core/utils.d.ts +28 -0
- package/dist/types/node/durable/dashboard/server.d.ts +20 -0
- package/dist/types/node/durable/emitters/runnerAuditEmitter.d.ts +6 -0
- package/dist/types/node/durable/events.d.ts +76 -0
- package/dist/types/node/durable/index.d.ts +34 -0
- package/dist/types/node/durable/optionalDeps/amqplib.d.ts +1 -0
- package/dist/types/node/durable/optionalDeps/ioredis.d.ts +1 -0
- package/dist/types/node/durable/queue/MemoryQueue.d.ts +12 -0
- package/dist/types/node/durable/queue/RabbitMQQueue.d.ts +30 -0
- package/dist/types/node/durable/resources/isolation.d.ts +15 -0
- package/dist/types/node/durable/resources/memoryDurableResource.d.ts +21 -0
- package/dist/types/node/durable/resources/redisDurableResource.d.ts +35 -0
- package/dist/types/node/durable/store/MemoryStore.d.ts +56 -0
- package/dist/types/node/durable/store/RedisStore.d.ts +89 -0
- package/dist/types/node/durable/test-utils.d.ts +29 -0
- package/dist/types/node/exposure/allowList.d.ts +3 -0
- package/dist/types/node/exposure/authenticator.d.ts +16 -0
- package/dist/types/node/exposure/cors.d.ts +4 -0
- package/dist/types/node/exposure/createNodeExposure.d.ts +2 -0
- package/dist/types/node/exposure/exposureServer.d.ts +18 -0
- package/dist/types/node/exposure/handlers/contextWrapper.d.ts +18 -0
- package/dist/types/node/exposure/handlers/errorHandlers.d.ts +23 -0
- package/dist/types/node/exposure/handlers/eventHandler.d.ts +20 -0
- package/dist/types/node/exposure/handlers/taskHandler.d.ts +24 -0
- package/dist/types/node/exposure/httpResponse.d.ts +10 -0
- package/dist/types/node/exposure/index.d.ts +3 -0
- package/dist/types/node/exposure/logging.d.ts +4 -0
- package/dist/types/node/exposure/multipart.d.ts +36 -0
- package/dist/types/node/exposure/requestBody.d.ts +11 -0
- package/dist/types/node/exposure/requestContext.d.ts +17 -0
- package/dist/types/node/exposure/requestHandlers.d.ts +29 -0
- package/dist/types/node/exposure/resource.d.ts +12 -0
- package/dist/types/node/exposure/resourceTypes.d.ts +73 -0
- package/dist/types/node/exposure/router.d.ts +17 -0
- package/dist/types/node/exposure/serverLifecycle.d.ts +13 -0
- package/dist/types/node/exposure/types.d.ts +45 -0
- package/dist/types/node/exposure/utils.d.ts +17 -0
- package/dist/types/node/files/createNodeFile.d.ts +9 -0
- package/dist/types/node/files/index.d.ts +4 -0
- package/dist/types/node/files/inputFile.model.d.ts +22 -0
- package/dist/types/node/files/inputFile.utils.d.ts +14 -0
- package/dist/types/node/http/http-mixed-client.d.ts +45 -0
- package/dist/types/node/http/http-mixed-client.factory.resource.d.ts +17 -0
- package/dist/types/node/http/http-smart-client.factory.resource.d.ts +16 -0
- package/dist/types/node/http/http-smart-client.model.d.ts +27 -0
- package/dist/types/node/http/index.d.ts +4 -0
- package/dist/types/node/index.d.ts +1 -0
- package/dist/types/node/node.d.ts +192 -0
- package/dist/types/node/platform/createFile.d.ts +9 -0
- package/dist/types/node/tunnel/allowlist.d.ts +7 -0
- package/dist/types/node/tunnel/index.d.ts +2 -0
- package/dist/types/node/upload/manifest.d.ts +23 -0
- package/dist/types/platform/adapters/browser.d.ts +14 -0
- package/dist/types/platform/adapters/edge.d.ts +5 -0
- package/dist/types/platform/adapters/node-als.d.ts +1 -0
- package/dist/types/platform/adapters/node.d.ts +15 -0
- package/dist/types/platform/adapters/universal-generic.d.ts +14 -0
- package/dist/types/platform/adapters/universal.d.ts +18 -0
- package/dist/types/platform/createFile.d.ts +10 -0
- package/dist/types/platform/createWebFile.d.ts +11 -0
- package/dist/types/platform/factory.d.ts +2 -0
- package/dist/types/platform/index.d.ts +27 -0
- package/dist/types/platform/types.d.ts +31 -0
- package/dist/types/processHooks.d.ts +2 -0
- package/dist/types/public-types.d.ts +13 -0
- package/dist/types/public.d.ts +210 -0
- package/dist/types/run.d.ts +14 -0
- package/dist/types/serializer/Serializer.d.ts +84 -0
- package/dist/types/serializer/binary-builtins.d.ts +5 -0
- package/dist/types/serializer/builtins.d.ts +47 -0
- package/dist/types/serializer/deserializer.d.ts +27 -0
- package/dist/types/serializer/error-url-builtins.d.ts +13 -0
- package/dist/types/serializer/graph-serializer.d.ts +27 -0
- package/dist/types/serializer/index.d.ts +6 -0
- package/dist/types/serializer/option-normalizers.d.ts +2 -0
- package/dist/types/serializer/regexp-validator.d.ts +34 -0
- package/dist/types/serializer/serialize-utils.d.ts +15 -0
- package/dist/types/serializer/special-values.d.ts +20 -0
- package/dist/types/serializer/tree-serializer.d.ts +20 -0
- package/dist/types/serializer/type-registry.d.ts +58 -0
- package/dist/types/serializer/types.d.ts +126 -0
- package/dist/types/serializer/validation.d.ts +34 -0
- package/dist/types/testing.d.ts +19 -0
- package/dist/types/tools/detectRunnerMode.d.ts +9 -0
- package/dist/types/tools/getCallerFile.d.ts +1 -0
- package/dist/types/tools/throws.d.ts +7 -0
- package/dist/types/tunnels/buildUniversalManifest.d.ts +24 -0
- package/dist/types/types/asyncContext.d.ts +41 -0
- package/dist/types/types/contracts.d.ts +62 -0
- package/dist/types/types/error.d.ts +39 -0
- package/dist/types/types/event.d.ts +79 -0
- package/dist/types/types/executionJournal.d.ts +29 -0
- package/dist/types/types/hook.d.ts +23 -0
- package/dist/types/types/inputFile.d.ts +34 -0
- package/dist/types/types/meta.d.ts +22 -0
- package/dist/types/types/resource.d.ts +133 -0
- package/dist/types/types/resourceMiddleware.d.ts +48 -0
- package/dist/types/types/runner.d.ts +68 -0
- package/dist/types/types/storeTypes.d.ts +46 -0
- package/dist/types/types/symbols.d.ts +34 -0
- package/dist/types/types/tag.d.ts +45 -0
- package/dist/types/types/task.d.ts +76 -0
- package/dist/types/types/taskMiddleware.d.ts +55 -0
- package/dist/types/types/utilities.d.ts +125 -0
- package/dist/universal/index.cjs +1039 -465
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.mjs +1037 -465
- package/dist/universal/index.mjs.map +1 -1
- package/package.json +14 -13
- package/readmes/AI.md +34 -12
- package/dist/browser/index.d.mts +0 -2890
- package/dist/browser/index.d.ts +0 -2890
- package/dist/edge/index.d.mts +0 -2890
- package/dist/edge/index.d.ts +0 -2890
- package/dist/node/node.d.mts +0 -4593
- package/dist/node/node.d.ts +0 -4593
- package/dist/universal/index.d.mts +0 -2890
- package/dist/universal/index.d.ts +0 -2890
package/dist/browser/index.mjs
CHANGED
|
@@ -164,6 +164,9 @@ var symbolPhantomTask = Symbol.for(
|
|
|
164
164
|
"runner.task.phantom"
|
|
165
165
|
);
|
|
166
166
|
var symbolResource = Symbol.for("runner.resource");
|
|
167
|
+
var symbolResourceForkedFrom = Symbol.for(
|
|
168
|
+
"runner.resourceForkedFrom"
|
|
169
|
+
);
|
|
167
170
|
var symbolResourceWithConfig = Symbol.for(
|
|
168
171
|
"runner.resourceWithConfig"
|
|
169
172
|
);
|
|
@@ -193,88 +196,227 @@ var symbolAsyncContext = Symbol.for(
|
|
|
193
196
|
"runner.asyncContext"
|
|
194
197
|
);
|
|
195
198
|
|
|
196
|
-
// src/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return mod.AsyncLocalStorage;
|
|
199
|
+
// src/tools/getCallerFile.ts
|
|
200
|
+
function isNodeInline() {
|
|
201
|
+
return typeof process !== "undefined" && typeof process?.versions?.node === "string";
|
|
200
202
|
}
|
|
201
|
-
__name(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
process.on("uncaughtException", h);
|
|
219
|
-
return () => process.off("uncaughtException", h);
|
|
220
|
-
}
|
|
221
|
-
onUnhandledRejection(handler) {
|
|
222
|
-
const h = /* @__PURE__ */ __name((reason) => handler(reason), "h");
|
|
223
|
-
process.on("unhandledRejection", h);
|
|
224
|
-
return () => process.off("unhandledRejection", h);
|
|
225
|
-
}
|
|
226
|
-
onShutdownSignal(handler) {
|
|
227
|
-
process.on("SIGINT", handler);
|
|
228
|
-
process.on("SIGTERM", handler);
|
|
229
|
-
return () => {
|
|
230
|
-
process.off("SIGINT", handler);
|
|
231
|
-
process.off("SIGTERM", handler);
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
exit(code) {
|
|
235
|
-
process.exit(code);
|
|
236
|
-
}
|
|
237
|
-
getEnv(key) {
|
|
238
|
-
return process.env[key];
|
|
239
|
-
}
|
|
240
|
-
hasAsyncLocalStorage() {
|
|
241
|
-
return true;
|
|
203
|
+
__name(isNodeInline, "isNodeInline");
|
|
204
|
+
function getCallerFile() {
|
|
205
|
+
const originalPrepare = Error.prepareStackTrace;
|
|
206
|
+
try {
|
|
207
|
+
if (isNodeInline()) {
|
|
208
|
+
const err = new Error();
|
|
209
|
+
Error.prepareStackTrace = (_err, stack2) => stack2;
|
|
210
|
+
const stack = err.stack;
|
|
211
|
+
stack.shift();
|
|
212
|
+
stack.shift();
|
|
213
|
+
const candidate = stack.shift();
|
|
214
|
+
const file = candidate?.getFileName?.();
|
|
215
|
+
return file;
|
|
216
|
+
}
|
|
217
|
+
return "unknown";
|
|
218
|
+
} finally {
|
|
219
|
+
Error.prepareStackTrace = originalPrepare;
|
|
242
220
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
221
|
+
}
|
|
222
|
+
__name(getCallerFile, "getCallerFile");
|
|
223
|
+
|
|
224
|
+
// src/defs.ts
|
|
225
|
+
var defs_exports = {};
|
|
226
|
+
__export(defs_exports, {
|
|
227
|
+
CONTRACT: () => CONTRACT,
|
|
228
|
+
HookDependencyState: () => HookDependencyState,
|
|
229
|
+
RunnerMode: () => RunnerMode,
|
|
230
|
+
isOneOf: () => isOneOf,
|
|
231
|
+
onAnyOf: () => onAnyOf,
|
|
232
|
+
symbolAsyncContext: () => symbolAsyncContext,
|
|
233
|
+
symbolError: () => symbolError,
|
|
234
|
+
symbolEvent: () => symbolEvent,
|
|
235
|
+
symbolFilePath: () => symbolFilePath,
|
|
236
|
+
symbolHook: () => symbolHook,
|
|
237
|
+
symbolMiddleware: () => symbolMiddleware,
|
|
238
|
+
symbolMiddlewareConfigured: () => symbolMiddlewareConfigured,
|
|
239
|
+
symbolOptionalDependency: () => symbolOptionalDependency,
|
|
240
|
+
symbolPhantomTask: () => symbolPhantomTask,
|
|
241
|
+
symbolResource: () => symbolResource,
|
|
242
|
+
symbolResourceForkedFrom: () => symbolResourceForkedFrom,
|
|
243
|
+
symbolResourceMiddleware: () => symbolResourceMiddleware,
|
|
244
|
+
symbolResourceWithConfig: () => symbolResourceWithConfig,
|
|
245
|
+
symbolTag: () => symbolTag,
|
|
246
|
+
symbolTagConfigured: () => symbolTagConfigured,
|
|
247
|
+
symbolTask: () => symbolTask,
|
|
248
|
+
symbolTaskMiddleware: () => symbolTaskMiddleware,
|
|
249
|
+
symbolTunneledBy: () => symbolTunneledBy
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// src/types/event.ts
|
|
253
|
+
function onAnyOf(...defs) {
|
|
254
|
+
return defs;
|
|
255
|
+
}
|
|
256
|
+
__name(onAnyOf, "onAnyOf");
|
|
257
|
+
function isOneOf(emission, defs) {
|
|
258
|
+
return defs.some((d) => d.id === emission.id);
|
|
259
|
+
}
|
|
260
|
+
__name(isOneOf, "isOneOf");
|
|
261
|
+
|
|
262
|
+
// src/types/runner.ts
|
|
263
|
+
var RunnerMode = /* @__PURE__ */ ((RunnerMode2) => {
|
|
264
|
+
RunnerMode2["TEST"] = "test";
|
|
265
|
+
RunnerMode2["DEV"] = "dev";
|
|
266
|
+
RunnerMode2["PROD"] = "prod";
|
|
267
|
+
return RunnerMode2;
|
|
268
|
+
})(RunnerMode || {});
|
|
269
|
+
|
|
270
|
+
// src/types/contracts.ts
|
|
271
|
+
var CONTRACT = Symbol.for("runner.contract");
|
|
272
|
+
|
|
273
|
+
// src/types/storeTypes.ts
|
|
274
|
+
var HookDependencyState = /* @__PURE__ */ ((HookDependencyState2) => {
|
|
275
|
+
HookDependencyState2["Pending"] = "pending";
|
|
276
|
+
HookDependencyState2["Computing"] = "computing";
|
|
277
|
+
HookDependencyState2["Ready"] = "ready";
|
|
278
|
+
return HookDependencyState2;
|
|
279
|
+
})(HookDependencyState || {});
|
|
280
|
+
|
|
281
|
+
// src/definers/tools.ts
|
|
282
|
+
function isTask(definition) {
|
|
283
|
+
return definition && definition[symbolTask];
|
|
284
|
+
}
|
|
285
|
+
__name(isTask, "isTask");
|
|
286
|
+
function isResource(definition) {
|
|
287
|
+
return definition && definition[symbolResource];
|
|
288
|
+
}
|
|
289
|
+
__name(isResource, "isResource");
|
|
290
|
+
function isResourceWithConfig(definition) {
|
|
291
|
+
return definition && definition[symbolResourceWithConfig];
|
|
292
|
+
}
|
|
293
|
+
__name(isResourceWithConfig, "isResourceWithConfig");
|
|
294
|
+
function isEvent(definition) {
|
|
295
|
+
return definition && definition[symbolEvent];
|
|
296
|
+
}
|
|
297
|
+
__name(isEvent, "isEvent");
|
|
298
|
+
function isHook(definition) {
|
|
299
|
+
return definition && definition[symbolHook];
|
|
300
|
+
}
|
|
301
|
+
__name(isHook, "isHook");
|
|
302
|
+
function isTaskMiddleware(definition) {
|
|
303
|
+
return definition && definition[symbolTaskMiddleware];
|
|
304
|
+
}
|
|
305
|
+
__name(isTaskMiddleware, "isTaskMiddleware");
|
|
306
|
+
function isResourceMiddleware(definition) {
|
|
307
|
+
return definition && definition[symbolResourceMiddleware];
|
|
308
|
+
}
|
|
309
|
+
__name(isResourceMiddleware, "isResourceMiddleware");
|
|
310
|
+
function isTag(definition) {
|
|
311
|
+
return definition && definition[symbolTag];
|
|
312
|
+
}
|
|
313
|
+
__name(isTag, "isTag");
|
|
314
|
+
function isOptional(definition) {
|
|
315
|
+
return definition && definition[symbolOptionalDependency];
|
|
316
|
+
}
|
|
317
|
+
__name(isOptional, "isOptional");
|
|
318
|
+
function isError(definition) {
|
|
319
|
+
return Boolean(definition && definition[symbolError]);
|
|
320
|
+
}
|
|
321
|
+
__name(isError, "isError");
|
|
322
|
+
function isAsyncContext(definition) {
|
|
323
|
+
return Boolean(definition && definition[symbolAsyncContext]);
|
|
324
|
+
}
|
|
325
|
+
__name(isAsyncContext, "isAsyncContext");
|
|
326
|
+
|
|
327
|
+
// src/tools/throws.ts
|
|
328
|
+
function invalidThrowsEntryError(owner, item) {
|
|
329
|
+
const got = item === null ? "null" : Array.isArray(item) ? "array" : typeof item === "object" ? "object" : typeof item;
|
|
330
|
+
return new Error(
|
|
331
|
+
`Invalid throws entry for ${owner.kind} ${owner.id}: expected error id string or Error helper, got ${got}`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
__name(invalidThrowsEntryError, "invalidThrowsEntryError");
|
|
335
|
+
function toErrorIdList(owner, list) {
|
|
336
|
+
const ids = [];
|
|
337
|
+
const seen = /* @__PURE__ */ new Set();
|
|
338
|
+
for (const item of list) {
|
|
339
|
+
let id2;
|
|
340
|
+
if (typeof item === "string") {
|
|
341
|
+
if (item.trim().length === 0) {
|
|
342
|
+
throw invalidThrowsEntryError(owner, item);
|
|
268
343
|
}
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
344
|
+
id2 = item;
|
|
345
|
+
} else if (isError(item)) {
|
|
346
|
+
id2 = item.id;
|
|
347
|
+
if (typeof id2 !== "string" || id2.trim().length === 0) {
|
|
348
|
+
throw invalidThrowsEntryError(owner, item);
|
|
349
|
+
}
|
|
350
|
+
} else {
|
|
351
|
+
throw invalidThrowsEntryError(owner, item);
|
|
352
|
+
}
|
|
353
|
+
if (seen.has(id2)) continue;
|
|
354
|
+
seen.add(id2);
|
|
355
|
+
ids.push(id2);
|
|
275
356
|
}
|
|
357
|
+
return ids;
|
|
358
|
+
}
|
|
359
|
+
__name(toErrorIdList, "toErrorIdList");
|
|
360
|
+
function normalizeThrows(owner, throwsList) {
|
|
361
|
+
if (throwsList === void 0) return void 0;
|
|
362
|
+
return toErrorIdList(owner, throwsList);
|
|
363
|
+
}
|
|
364
|
+
__name(normalizeThrows, "normalizeThrows");
|
|
365
|
+
|
|
366
|
+
// src/definers/defineTask.ts
|
|
367
|
+
function defineTask(taskConfig) {
|
|
368
|
+
const filePath = getCallerFile();
|
|
369
|
+
const id2 = taskConfig.id;
|
|
370
|
+
return {
|
|
371
|
+
[symbolTask]: true,
|
|
372
|
+
[symbolFilePath]: filePath,
|
|
373
|
+
id: id2,
|
|
374
|
+
dependencies: taskConfig.dependencies || {},
|
|
375
|
+
middleware: taskConfig.middleware || [],
|
|
376
|
+
run: taskConfig.run,
|
|
377
|
+
inputSchema: taskConfig.inputSchema,
|
|
378
|
+
resultSchema: taskConfig.resultSchema,
|
|
379
|
+
meta: taskConfig.meta || {},
|
|
380
|
+
tags: taskConfig.tags || [],
|
|
381
|
+
throws: normalizeThrows({ kind: "task", id: id2 }, taskConfig.throws),
|
|
382
|
+
// autorun,
|
|
383
|
+
optional() {
|
|
384
|
+
return {
|
|
385
|
+
inner: this,
|
|
386
|
+
[symbolOptionalDependency]: true
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
__name(defineTask, "defineTask");
|
|
392
|
+
defineTask.phantom = (taskConfig) => {
|
|
393
|
+
const taskDef = defineTask({
|
|
394
|
+
...taskConfig,
|
|
395
|
+
run: /* @__PURE__ */ __name(async (_input) => {
|
|
396
|
+
return void 0;
|
|
397
|
+
}, "run")
|
|
398
|
+
});
|
|
399
|
+
taskDef[symbolPhantomTask] = true;
|
|
400
|
+
return taskDef;
|
|
276
401
|
};
|
|
277
402
|
|
|
403
|
+
// src/definers/defineHook.ts
|
|
404
|
+
function defineHook(hookDef) {
|
|
405
|
+
const filePath = getCallerFile();
|
|
406
|
+
return {
|
|
407
|
+
[symbolHook]: true,
|
|
408
|
+
[symbolFilePath]: filePath,
|
|
409
|
+
id: hookDef.id,
|
|
410
|
+
dependencies: hookDef.dependencies || {},
|
|
411
|
+
on: hookDef.on,
|
|
412
|
+
order: hookDef.order,
|
|
413
|
+
run: hookDef.run,
|
|
414
|
+
meta: hookDef.meta || {},
|
|
415
|
+
tags: hookDef.tags || []
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
__name(defineHook, "defineHook");
|
|
419
|
+
|
|
278
420
|
// src/errors.ts
|
|
279
421
|
var errors_exports = {};
|
|
280
422
|
__export(errors_exports, {
|
|
@@ -316,9 +458,10 @@ var RunnerError = class extends Error {
|
|
|
316
458
|
var _a;
|
|
317
459
|
_a = symbolError;
|
|
318
460
|
var ErrorHelper = class {
|
|
319
|
-
constructor(definition) {
|
|
461
|
+
constructor(definition, filePath) {
|
|
320
462
|
this.definition = definition;
|
|
321
463
|
this[_a] = true;
|
|
464
|
+
this[symbolFilePath] = filePath;
|
|
322
465
|
}
|
|
323
466
|
static {
|
|
324
467
|
__name(this, "ErrorHelper");
|
|
@@ -341,11 +484,15 @@ var ErrorHelper = class {
|
|
|
341
484
|
};
|
|
342
485
|
}
|
|
343
486
|
};
|
|
344
|
-
function defineError(definition) {
|
|
487
|
+
function defineError(definition, filePath) {
|
|
345
488
|
if (!definition.format) {
|
|
346
489
|
definition.format = (data) => `${JSON.stringify(data)}`;
|
|
347
490
|
}
|
|
348
|
-
|
|
491
|
+
const resolvedFilePath = filePath ?? getCallerFile();
|
|
492
|
+
return new ErrorHelper(
|
|
493
|
+
definition,
|
|
494
|
+
resolvedFilePath
|
|
495
|
+
);
|
|
349
496
|
}
|
|
350
497
|
__name(defineError, "defineError");
|
|
351
498
|
|
|
@@ -383,14 +530,17 @@ function makeErrorBuilder(state) {
|
|
|
383
530
|
return makeErrorBuilder(next);
|
|
384
531
|
},
|
|
385
532
|
build() {
|
|
386
|
-
return defineError(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
533
|
+
return defineError(
|
|
534
|
+
{
|
|
535
|
+
id: state.id,
|
|
536
|
+
serialize: state.serialize,
|
|
537
|
+
parse: state.parse,
|
|
538
|
+
dataSchema: state.dataSchema,
|
|
539
|
+
format: state.format,
|
|
540
|
+
meta: state.meta
|
|
541
|
+
},
|
|
542
|
+
state.filePath
|
|
543
|
+
);
|
|
394
544
|
}
|
|
395
545
|
};
|
|
396
546
|
return builder;
|
|
@@ -399,8 +549,10 @@ __name(makeErrorBuilder, "makeErrorBuilder");
|
|
|
399
549
|
|
|
400
550
|
// src/definers/builders/error/index.ts
|
|
401
551
|
function errorBuilder(id2) {
|
|
552
|
+
const filePath = getCallerFile();
|
|
402
553
|
const initial = Object.freeze({
|
|
403
554
|
id: id2,
|
|
555
|
+
filePath,
|
|
404
556
|
serialize: void 0,
|
|
405
557
|
parse: void 0,
|
|
406
558
|
dataSchema: void 0,
|
|
@@ -411,103 +563,87 @@ function errorBuilder(id2) {
|
|
|
411
563
|
__name(errorBuilder, "errorBuilder");
|
|
412
564
|
var error = errorBuilder;
|
|
413
565
|
|
|
414
|
-
// src/
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
var dependencyNotFoundError = error("runner.errors.dependencyNotFound").format(
|
|
419
|
-
({ key }) => `Dependency ${key.toString()} not found. Did you forget to register it through a resource?`
|
|
420
|
-
).build();
|
|
421
|
-
var unknownItemTypeError = error(
|
|
422
|
-
"runner.errors.unknownItemType"
|
|
423
|
-
).format(
|
|
424
|
-
({ item }) => `Unknown item type: ${String(
|
|
425
|
-
item
|
|
426
|
-
)}. Please ensure you are not using different versions of '@bluelibs/runner'`
|
|
427
|
-
).build();
|
|
428
|
-
var contextError = error(
|
|
429
|
-
"runner.errors.context"
|
|
430
|
-
).format(({ details }) => details ?? "Context error").build();
|
|
431
|
-
var circularDependenciesError = error("runner.errors.circularDependencies").format(({ cycles }) => {
|
|
432
|
-
const cycleDetails = cycles.map((cycle) => ` \u2022 ${cycle}`).join("\n");
|
|
433
|
-
const hasMiddleware = cycles.some((cycle) => cycle.includes("middleware"));
|
|
434
|
-
let guidance = "\n\nTo resolve circular dependencies:";
|
|
435
|
-
guidance += "\n \u2022 Consider refactoring to reduce coupling between components";
|
|
436
|
-
guidance += "\n \u2022 Extract shared dependencies into separate resources";
|
|
437
|
-
if (hasMiddleware) {
|
|
438
|
-
guidance += "\n \u2022 For middleware: you can filter out tasks/resources using everywhere(fn)";
|
|
439
|
-
guidance += "\n \u2022 Consider using events for communication instead of direct dependencies";
|
|
440
|
-
}
|
|
441
|
-
return `Circular dependencies detected:
|
|
442
|
-
${cycleDetails}${guidance}`;
|
|
443
|
-
}).build();
|
|
444
|
-
var eventNotFoundError = error(
|
|
445
|
-
"runner.errors.eventNotFound"
|
|
446
|
-
).format(
|
|
447
|
-
({ id: id2 }) => `Event "${id2.toString()}" not found. Did you forget to register it?`
|
|
448
|
-
).build();
|
|
449
|
-
var resourceNotFoundError = error(
|
|
450
|
-
"runner.errors.resourceNotFound"
|
|
451
|
-
).format(
|
|
452
|
-
({ id: id2 }) => `Resource "${id2.toString()}" not found. Did you forget to register it or are you using the correct id?`
|
|
453
|
-
).build();
|
|
454
|
-
var middlewareNotRegisteredError = error("runner.errors.middlewareNotRegistered").format(
|
|
455
|
-
({ type, source, middlewareId }) => `Middleware inside ${type} "${source}" depends on "${middlewareId}" but it's not registered. Did you forget to register it?`
|
|
456
|
-
).build();
|
|
457
|
-
var tagNotFoundError = error(
|
|
458
|
-
"runner.errors.tagNotFound"
|
|
459
|
-
).format(
|
|
460
|
-
({ id: id2 }) => `Tag "${id2}" not registered. Did you forget to register it inside a resource?`
|
|
461
|
-
).build();
|
|
462
|
-
var lockedError = error(
|
|
463
|
-
"runner.errors.locked"
|
|
464
|
-
).format(
|
|
465
|
-
({ what }) => `Cannot modify the ${what.toString()} when it is locked.`
|
|
466
|
-
).build();
|
|
467
|
-
var storeAlreadyInitializedError = error(
|
|
468
|
-
"runner.errors.storeAlreadyInitialized"
|
|
469
|
-
).format(() => "Store already initialized. Cannot reinitialize.").build();
|
|
470
|
-
var validationError = error("runner.errors.validation").format(({ subject, id: id2, originalError }) => {
|
|
471
|
-
const errorMessage = originalError instanceof Error ? originalError.message : String(originalError);
|
|
472
|
-
return `${subject} validation failed for ${id2.toString()}: ${errorMessage}`;
|
|
473
|
-
}).build();
|
|
474
|
-
var eventCycleError = error("runner.errors.eventCycle").format(({ path }) => {
|
|
475
|
-
const chain = path.map((p) => `${p.id}\u2190${p.source}`).join(" -> ");
|
|
476
|
-
return `Event emission cycle detected:
|
|
477
|
-
${chain}
|
|
478
|
-
|
|
479
|
-
Break the cycle by changing hook logic (avoid mutual emits) or gate with conditions/tags.`;
|
|
480
|
-
}).build();
|
|
481
|
-
var eventEmissionCycleError = error("runner.errors.eventEmissionCycle").format(({ cycles }) => {
|
|
482
|
-
const list = cycles.map((c) => ` \u2022 ${c}`).join("\n");
|
|
483
|
-
return `Event emission cycles detected between hooks and events:
|
|
484
|
-
${list}
|
|
485
|
-
|
|
486
|
-
This was detected at compile time (dry-run). Break the cycle by avoiding mutual emits between hooks or scoping hooks using tags.`;
|
|
487
|
-
}).build();
|
|
488
|
-
var platformUnsupportedFunctionError = error("runner.errors.platformUnsupportedFunction").format(
|
|
489
|
-
({ functionName }) => `Platform function not supported in this environment: ${functionName}. Detected platform: ${detectEnvironment()}.`
|
|
490
|
-
).build();
|
|
491
|
-
var cancellationError = error(
|
|
492
|
-
"runner.errors.cancellation"
|
|
493
|
-
).format(({ reason }) => reason || "Operation cancelled").build();
|
|
494
|
-
var tunnelOwnershipConflictError = error("runner.errors.tunnelOwnershipConflict").format(
|
|
495
|
-
({ taskId, currentOwnerId, attemptedOwnerId }) => `Task "${taskId}" is already tunneled by resource "${currentOwnerId}". Resource "${attemptedOwnerId}" cannot tunnel it again. Ensure each task is owned by a single tunnel client.`
|
|
496
|
-
).build();
|
|
497
|
-
var phantomTaskNotRoutedError = error("runner.errors.phantomTaskNotRouted").format(
|
|
498
|
-
({ taskId }) => `Phantom task "${taskId}" is not routed through any tunnel. Ensure a tunnel client selects this task id (or avoid calling the phantom task directly).`
|
|
499
|
-
).build();
|
|
500
|
-
var taskNotRegisteredError = error("runner.errors.taskNotRegistered").format(
|
|
501
|
-
({ taskId }) => `Task "${taskId}" is not registered in the Store. This is an internal error\u2014ensure the task is registered before execution.`
|
|
502
|
-
).build();
|
|
503
|
-
var builderIncompleteError = error("runner.errors.builderIncomplete").format(({ type, builderId, missingFields }) => {
|
|
504
|
-
const typeLabel = type === "hook" ? "Hook" : type === "task-middleware" ? "Task middleware" : "Resource middleware";
|
|
505
|
-
return `${typeLabel} "${builderId}" is incomplete. Missing required: ${missingFields.join(", ")}. Call ${missingFields.map((f) => `.${f}()`).join(" and ")} before .build().`;
|
|
506
|
-
}).build();
|
|
507
|
-
function isCancellationError(err) {
|
|
508
|
-
return cancellationError.is(err);
|
|
566
|
+
// src/platform/adapters/node-als.ts
|
|
567
|
+
async function loadAsyncLocalStorageClass() {
|
|
568
|
+
const mod = __require("async_hooks");
|
|
569
|
+
return mod.AsyncLocalStorage;
|
|
509
570
|
}
|
|
510
|
-
__name(
|
|
571
|
+
__name(loadAsyncLocalStorageClass, "loadAsyncLocalStorageClass");
|
|
572
|
+
|
|
573
|
+
// src/platform/adapters/node.ts
|
|
574
|
+
var NodePlatformAdapter = class {
|
|
575
|
+
constructor() {
|
|
576
|
+
this.id = "node";
|
|
577
|
+
this.setTimeout = globalThis.setTimeout;
|
|
578
|
+
this.clearTimeout = globalThis.clearTimeout;
|
|
579
|
+
}
|
|
580
|
+
static {
|
|
581
|
+
__name(this, "NodePlatformAdapter");
|
|
582
|
+
}
|
|
583
|
+
async init() {
|
|
584
|
+
this.alsClass = await loadAsyncLocalStorageClass();
|
|
585
|
+
}
|
|
586
|
+
onUncaughtException(handler) {
|
|
587
|
+
const h = /* @__PURE__ */ __name((error2) => handler(error2), "h");
|
|
588
|
+
process.on("uncaughtException", h);
|
|
589
|
+
return () => process.off("uncaughtException", h);
|
|
590
|
+
}
|
|
591
|
+
onUnhandledRejection(handler) {
|
|
592
|
+
const h = /* @__PURE__ */ __name((reason) => handler(reason), "h");
|
|
593
|
+
process.on("unhandledRejection", h);
|
|
594
|
+
return () => process.off("unhandledRejection", h);
|
|
595
|
+
}
|
|
596
|
+
onShutdownSignal(handler) {
|
|
597
|
+
process.on("SIGINT", handler);
|
|
598
|
+
process.on("SIGTERM", handler);
|
|
599
|
+
return () => {
|
|
600
|
+
process.off("SIGINT", handler);
|
|
601
|
+
process.off("SIGTERM", handler);
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
exit(code) {
|
|
605
|
+
process.exit(code);
|
|
606
|
+
}
|
|
607
|
+
getEnv(key) {
|
|
608
|
+
return process.env[key];
|
|
609
|
+
}
|
|
610
|
+
hasAsyncLocalStorage() {
|
|
611
|
+
return true;
|
|
612
|
+
}
|
|
613
|
+
createAsyncLocalStorage() {
|
|
614
|
+
let instance;
|
|
615
|
+
const ensure = /* @__PURE__ */ __name(() => {
|
|
616
|
+
if (!this.alsClass) {
|
|
617
|
+
let als;
|
|
618
|
+
const forceNoop = typeof process !== "undefined" && !!process.env?.RUNNER_FORCE_NOOP_ALS;
|
|
619
|
+
if (!forceNoop) {
|
|
620
|
+
try {
|
|
621
|
+
const mod = __require("async_hooks");
|
|
622
|
+
als = mod?.AsyncLocalStorage;
|
|
623
|
+
} catch (_) {
|
|
624
|
+
als = void 0;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
this.alsClass = als || class NoopAsyncLocalStorage {
|
|
628
|
+
static {
|
|
629
|
+
__name(this, "NoopAsyncLocalStorage");
|
|
630
|
+
}
|
|
631
|
+
getStore() {
|
|
632
|
+
return void 0;
|
|
633
|
+
}
|
|
634
|
+
run(_store, callback) {
|
|
635
|
+
return callback();
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
return instance ??= new this.alsClass();
|
|
640
|
+
}, "ensure");
|
|
641
|
+
return {
|
|
642
|
+
getStore: /* @__PURE__ */ __name(() => ensure().getStore(), "getStore"),
|
|
643
|
+
run: /* @__PURE__ */ __name((store2, callback) => ensure().run(store2, callback), "run")
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
};
|
|
511
647
|
|
|
512
648
|
// src/platform/adapters/browser.ts
|
|
513
649
|
var BrowserPlatformAdapter = class {
|
|
@@ -800,16 +936,11 @@ function setPlatform(adapter) {
|
|
|
800
936
|
adapter.id;
|
|
801
937
|
}
|
|
802
938
|
__name(setPlatform, "setPlatform");
|
|
803
|
-
function isNode() {
|
|
804
|
-
{
|
|
805
|
-
return false;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
__name(isNode, "isNode");
|
|
809
939
|
var PlatformAdapter = class {
|
|
940
|
+
static {
|
|
941
|
+
__name(this, "PlatformAdapter");
|
|
942
|
+
}
|
|
810
943
|
constructor(env) {
|
|
811
|
-
this.setTimeout = globalThis.setTimeout;
|
|
812
|
-
this.clearTimeout = globalThis.clearTimeout;
|
|
813
944
|
const kind = env ?? detectEnvironment();
|
|
814
945
|
this.env = kind;
|
|
815
946
|
switch (kind) {
|
|
@@ -829,9 +960,8 @@ var PlatformAdapter = class {
|
|
|
829
960
|
this.inner = new UniversalPlatformAdapter();
|
|
830
961
|
}
|
|
831
962
|
this.id = this.inner.id;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
__name(this, "PlatformAdapter");
|
|
963
|
+
this.setTimeout = this.inner.setTimeout;
|
|
964
|
+
this.clearTimeout = this.inner.clearTimeout;
|
|
835
965
|
}
|
|
836
966
|
async init() {
|
|
837
967
|
return this.inner.init();
|
|
@@ -859,208 +989,285 @@ var PlatformAdapter = class {
|
|
|
859
989
|
}
|
|
860
990
|
};
|
|
861
991
|
|
|
862
|
-
// src/
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
992
|
+
// src/errors.ts
|
|
993
|
+
var duplicateRegistrationError = error("runner.errors.duplicateRegistration").format(
|
|
994
|
+
({ type, id: id2 }) => `${type} "${id2.toString()}" already registered. You might have used the same 'id' in two different components or you may have registered the same element twice.`
|
|
995
|
+
).build();
|
|
996
|
+
var dependencyNotFoundError = error("runner.errors.dependencyNotFound").format(
|
|
997
|
+
({ key }) => `Dependency ${key.toString()} not found. Did you forget to register it through a resource?`
|
|
998
|
+
).build();
|
|
999
|
+
var unknownItemTypeError = error(
|
|
1000
|
+
"runner.errors.unknownItemType"
|
|
1001
|
+
).format(
|
|
1002
|
+
({ item }) => `Unknown item type: ${String(
|
|
1003
|
+
item
|
|
1004
|
+
)}. Please ensure you are not using different versions of '@bluelibs/runner'`
|
|
1005
|
+
).build();
|
|
1006
|
+
var contextError = error(
|
|
1007
|
+
"runner.errors.context"
|
|
1008
|
+
).format(({ details }) => details ?? "Context error").build();
|
|
1009
|
+
var circularDependenciesError = error("runner.errors.circularDependencies").format(({ cycles }) => {
|
|
1010
|
+
const cycleDetails = cycles.map((cycle) => ` \u2022 ${cycle}`).join("\n");
|
|
1011
|
+
const hasMiddleware = cycles.some((cycle) => cycle.includes("middleware"));
|
|
1012
|
+
let guidance = "\n\nTo resolve circular dependencies:";
|
|
1013
|
+
guidance += "\n \u2022 Consider refactoring to reduce coupling between components";
|
|
1014
|
+
guidance += "\n \u2022 Extract shared dependencies into separate resources";
|
|
1015
|
+
if (hasMiddleware) {
|
|
1016
|
+
guidance += "\n \u2022 For middleware: you can filter out tasks/resources using everywhere(fn)";
|
|
1017
|
+
guidance += "\n \u2022 Consider using events for communication instead of direct dependencies";
|
|
879
1018
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
// src/types/runner.ts
|
|
919
|
-
var RunnerMode = /* @__PURE__ */ ((RunnerMode2) => {
|
|
920
|
-
RunnerMode2["TEST"] = "test";
|
|
921
|
-
RunnerMode2["DEV"] = "dev";
|
|
922
|
-
RunnerMode2["PROD"] = "prod";
|
|
923
|
-
return RunnerMode2;
|
|
924
|
-
})(RunnerMode || {});
|
|
1019
|
+
return `Circular dependencies detected:
|
|
1020
|
+
${cycleDetails}${guidance}`;
|
|
1021
|
+
}).build();
|
|
1022
|
+
var eventNotFoundError = error(
|
|
1023
|
+
"runner.errors.eventNotFound"
|
|
1024
|
+
).format(
|
|
1025
|
+
({ id: id2 }) => `Event "${id2.toString()}" not found. Did you forget to register it?`
|
|
1026
|
+
).build();
|
|
1027
|
+
var resourceNotFoundError = error(
|
|
1028
|
+
"runner.errors.resourceNotFound"
|
|
1029
|
+
).format(
|
|
1030
|
+
({ id: id2 }) => `Resource "${id2.toString()}" not found. Did you forget to register it or are you using the correct id?`
|
|
1031
|
+
).build();
|
|
1032
|
+
var middlewareNotRegisteredError = error("runner.errors.middlewareNotRegistered").format(
|
|
1033
|
+
({ type, source, middlewareId }) => `Middleware inside ${type} "${source}" depends on "${middlewareId}" but it's not registered. Did you forget to register it?`
|
|
1034
|
+
).build();
|
|
1035
|
+
var tagNotFoundError = error(
|
|
1036
|
+
"runner.errors.tagNotFound"
|
|
1037
|
+
).format(
|
|
1038
|
+
({ id: id2 }) => `Tag "${id2}" not registered. Did you forget to register it inside a resource?`
|
|
1039
|
+
).build();
|
|
1040
|
+
var lockedError = error(
|
|
1041
|
+
"runner.errors.locked"
|
|
1042
|
+
).format(
|
|
1043
|
+
({ what }) => `Cannot modify the ${what.toString()} when it is locked.`
|
|
1044
|
+
).build();
|
|
1045
|
+
var storeAlreadyInitializedError = error(
|
|
1046
|
+
"runner.errors.storeAlreadyInitialized"
|
|
1047
|
+
).format(() => "Store already initialized. Cannot reinitialize.").build();
|
|
1048
|
+
var validationError = error("runner.errors.validation").format(({ subject, id: id2, originalError }) => {
|
|
1049
|
+
const errorMessage = originalError instanceof Error ? originalError.message : String(originalError);
|
|
1050
|
+
return `${subject} validation failed for ${id2.toString()}: ${errorMessage}`;
|
|
1051
|
+
}).build();
|
|
1052
|
+
var eventCycleError = error("runner.errors.eventCycle").format(({ path }) => {
|
|
1053
|
+
const chain = path.map((p) => `${p.id}\u2190${p.source}`).join(" -> ");
|
|
1054
|
+
return `Event emission cycle detected:
|
|
1055
|
+
${chain}
|
|
925
1056
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return definition && definition[symbolResource];
|
|
933
|
-
}
|
|
934
|
-
__name(isResource, "isResource");
|
|
935
|
-
function isResourceWithConfig(definition) {
|
|
936
|
-
return definition && definition[symbolResourceWithConfig];
|
|
937
|
-
}
|
|
938
|
-
__name(isResourceWithConfig, "isResourceWithConfig");
|
|
939
|
-
function isEvent(definition) {
|
|
940
|
-
return definition && definition[symbolEvent];
|
|
941
|
-
}
|
|
942
|
-
__name(isEvent, "isEvent");
|
|
943
|
-
function isHook(definition) {
|
|
944
|
-
return definition && definition[symbolHook];
|
|
945
|
-
}
|
|
946
|
-
__name(isHook, "isHook");
|
|
947
|
-
function isTaskMiddleware(definition) {
|
|
948
|
-
return definition && definition[symbolTaskMiddleware];
|
|
949
|
-
}
|
|
950
|
-
__name(isTaskMiddleware, "isTaskMiddleware");
|
|
951
|
-
function isResourceMiddleware(definition) {
|
|
952
|
-
return definition && definition[symbolResourceMiddleware];
|
|
953
|
-
}
|
|
954
|
-
__name(isResourceMiddleware, "isResourceMiddleware");
|
|
955
|
-
function isTag(definition) {
|
|
956
|
-
return definition && definition[symbolTag];
|
|
957
|
-
}
|
|
958
|
-
__name(isTag, "isTag");
|
|
959
|
-
function isOptional(definition) {
|
|
960
|
-
return definition && definition[symbolOptionalDependency];
|
|
961
|
-
}
|
|
962
|
-
__name(isOptional, "isOptional");
|
|
963
|
-
function isError(definition) {
|
|
964
|
-
return Boolean(definition && definition[symbolError]);
|
|
965
|
-
}
|
|
966
|
-
__name(isError, "isError");
|
|
967
|
-
function isAsyncContext(definition) {
|
|
968
|
-
return Boolean(definition && definition[symbolAsyncContext]);
|
|
969
|
-
}
|
|
970
|
-
__name(isAsyncContext, "isAsyncContext");
|
|
1057
|
+
Break the cycle by changing hook logic (avoid mutual emits) or gate with conditions/tags.`;
|
|
1058
|
+
}).build();
|
|
1059
|
+
var eventEmissionCycleError = error("runner.errors.eventEmissionCycle").format(({ cycles }) => {
|
|
1060
|
+
const list = cycles.map((c) => ` \u2022 ${c}`).join("\n");
|
|
1061
|
+
return `Event emission cycles detected between hooks and events:
|
|
1062
|
+
${list}
|
|
971
1063
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1064
|
+
This was detected at compile time (dry-run). Break the cycle by avoiding mutual emits between hooks or scoping hooks using tags.`;
|
|
1065
|
+
}).build();
|
|
1066
|
+
var platformUnsupportedFunctionError = error("runner.errors.platformUnsupportedFunction").format(
|
|
1067
|
+
({ functionName }) => `Platform function not supported in this environment: ${functionName}. Detected platform: ${detectEnvironment()}.`
|
|
1068
|
+
).build();
|
|
1069
|
+
var cancellationError = error(
|
|
1070
|
+
"runner.errors.cancellation"
|
|
1071
|
+
).format(({ reason }) => reason || "Operation cancelled").build();
|
|
1072
|
+
var tunnelOwnershipConflictError = error("runner.errors.tunnelOwnershipConflict").format(
|
|
1073
|
+
({ taskId, currentOwnerId, attemptedOwnerId }) => `Task "${taskId}" is already tunneled by resource "${currentOwnerId}". Resource "${attemptedOwnerId}" cannot tunnel it again. Ensure each task is owned by a single tunnel client.`
|
|
1074
|
+
).build();
|
|
1075
|
+
var phantomTaskNotRoutedError = error("runner.errors.phantomTaskNotRouted").format(
|
|
1076
|
+
({ taskId }) => `Phantom task "${taskId}" is not routed through any tunnel. Ensure a tunnel client selects this task id (or avoid calling the phantom task directly).`
|
|
1077
|
+
).build();
|
|
1078
|
+
var taskNotRegisteredError = error("runner.errors.taskNotRegistered").format(
|
|
1079
|
+
({ taskId }) => `Task "${taskId}" is not registered in the Store. This is an internal error\u2014ensure the task is registered before execution.`
|
|
1080
|
+
).build();
|
|
1081
|
+
var builderIncompleteError = error("runner.errors.builderIncomplete").format(({ type, builderId, missingFields }) => {
|
|
1082
|
+
const typeLabel = type === "hook" ? "Hook" : type === "task-middleware" ? "Task middleware" : "Resource middleware";
|
|
1083
|
+
return `${typeLabel} "${builderId}" is incomplete. Missing required: ${missingFields.join(", ")}. Call ${missingFields.map((f) => `.${f}()`).join(" and ")} before .build().`;
|
|
1084
|
+
}).build();
|
|
1085
|
+
function isCancellationError(err) {
|
|
1086
|
+
return cancellationError.is(err);
|
|
978
1087
|
}
|
|
979
|
-
__name(
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1088
|
+
__name(isCancellationError, "isCancellationError");
|
|
1089
|
+
|
|
1090
|
+
// src/definers/resourceFork.ts
|
|
1091
|
+
function resolveReId(forkId, options) {
|
|
1092
|
+
const fallback = /* @__PURE__ */ __name((id2) => `${forkId}.${id2}`, "fallback");
|
|
1093
|
+
const reId = options?.reId ?? fallback;
|
|
1094
|
+
return (id2) => {
|
|
1095
|
+
const next = reId(id2);
|
|
1096
|
+
if (typeof next !== "string" || next.length === 0) {
|
|
1097
|
+
throw new Error(`fork(reId) must return a non-empty string for "${id2}"`);
|
|
1098
|
+
}
|
|
1099
|
+
return next;
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
__name(resolveReId, "resolveReId");
|
|
1103
|
+
function remapResourceDependenciesInObject(deps, options) {
|
|
1104
|
+
const remapObject = /* @__PURE__ */ __name((deps2) => {
|
|
1105
|
+
const out = { ...deps2 };
|
|
1106
|
+
for (const [key, value] of Object.entries(deps2)) {
|
|
1107
|
+
if (isOptional(value)) {
|
|
1108
|
+
const inner = value.inner;
|
|
1109
|
+
if (isResource(inner)) {
|
|
1110
|
+
const forked = options.getForkedResourceByBaseId(inner.id);
|
|
1111
|
+
if (forked) {
|
|
1112
|
+
out[key] = { ...value, inner: forked };
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
continue;
|
|
988
1116
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1117
|
+
if (isResource(value)) {
|
|
1118
|
+
const forked = options.getForkedResourceByBaseId(value.id);
|
|
1119
|
+
if (forked) {
|
|
1120
|
+
out[key] = forked;
|
|
1121
|
+
}
|
|
994
1122
|
}
|
|
995
|
-
} else {
|
|
996
|
-
throw invalidThrowsEntryError(owner, item);
|
|
997
1123
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
return ids;
|
|
1124
|
+
return out;
|
|
1125
|
+
}, "remapObject");
|
|
1126
|
+
return remapObject(deps);
|
|
1003
1127
|
}
|
|
1004
|
-
__name(
|
|
1005
|
-
function
|
|
1006
|
-
|
|
1007
|
-
|
|
1128
|
+
__name(remapResourceDependenciesInObject, "remapResourceDependenciesInObject");
|
|
1129
|
+
function toResourceOnlyRegisterItems(items) {
|
|
1130
|
+
const out = [];
|
|
1131
|
+
for (const item of items) {
|
|
1132
|
+
if (isResourceWithConfig(item)) {
|
|
1133
|
+
out.push({
|
|
1134
|
+
kind: "withConfig",
|
|
1135
|
+
resource: item.resource,
|
|
1136
|
+
config: item.config
|
|
1137
|
+
});
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
if (isResource(item)) {
|
|
1141
|
+
out.push({ kind: "resource", resource: item });
|
|
1142
|
+
continue;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return out;
|
|
1008
1146
|
}
|
|
1009
|
-
__name(
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1147
|
+
__name(toResourceOnlyRegisterItems, "toResourceOnlyRegisterItems");
|
|
1148
|
+
function createDeepForkContext(forkId, options) {
|
|
1149
|
+
const reId = resolveReId(forkId, options);
|
|
1150
|
+
const forkedResourceByBaseId = /* @__PURE__ */ new Map();
|
|
1151
|
+
const ensureForked = /* @__PURE__ */ __name((base) => {
|
|
1152
|
+
const cached = forkedResourceByBaseId.get(base.id);
|
|
1153
|
+
if (cached) return cached;
|
|
1154
|
+
const forked = base.fork(reId(base.id), { register: "drop" });
|
|
1155
|
+
forkedResourceByBaseId.set(base.id, forked);
|
|
1156
|
+
const baseRegister = base.register;
|
|
1157
|
+
const ensureForkedForRegisterConfig = /* @__PURE__ */ __name((config) => {
|
|
1158
|
+
const items = typeof baseRegister === "function" ? baseRegister(config) : baseRegister;
|
|
1159
|
+
for (const candidate of toResourceOnlyRegisterItems(items)) {
|
|
1160
|
+
ensureForked(candidate.resource);
|
|
1161
|
+
}
|
|
1162
|
+
return items;
|
|
1163
|
+
}, "ensureForkedForRegisterConfig");
|
|
1164
|
+
const mapRegisterItems2 = /* @__PURE__ */ __name((items) => {
|
|
1165
|
+
const resourceItems = toResourceOnlyRegisterItems(items);
|
|
1166
|
+
const out = [];
|
|
1167
|
+
for (const candidate of resourceItems) {
|
|
1168
|
+
if (candidate.kind === "resource") {
|
|
1169
|
+
out.push(ensureForked(candidate.resource));
|
|
1170
|
+
continue;
|
|
1171
|
+
}
|
|
1172
|
+
out.push(ensureForked(candidate.resource).with(candidate.config));
|
|
1173
|
+
}
|
|
1174
|
+
return out;
|
|
1175
|
+
}, "mapRegisterItems");
|
|
1176
|
+
forked.register = typeof baseRegister === "function" ? (config) => {
|
|
1177
|
+
const items = ensureForkedForRegisterConfig(config);
|
|
1178
|
+
return mapRegisterItems2(items);
|
|
1179
|
+
} : (() => {
|
|
1180
|
+
ensureForkedForRegisterConfig(void 0);
|
|
1181
|
+
return mapRegisterItems2(baseRegister);
|
|
1182
|
+
})();
|
|
1183
|
+
const baseDependencies = base.dependencies;
|
|
1184
|
+
const remapDepsObject = /* @__PURE__ */ __name((deps) => remapResourceDependenciesInObject(deps, {
|
|
1185
|
+
getForkedResourceByBaseId: /* @__PURE__ */ __name((id2) => forkedResourceByBaseId.get(id2), "getForkedResourceByBaseId")
|
|
1186
|
+
}), "remapDepsObject");
|
|
1187
|
+
if (!baseDependencies) {
|
|
1188
|
+
forked.dependencies = baseDependencies;
|
|
1189
|
+
} else {
|
|
1190
|
+
forked.dependencies = (config) => {
|
|
1191
|
+
ensureForkedForRegisterConfig(config);
|
|
1192
|
+
const deps = typeof baseDependencies === "function" ? baseDependencies(config) : baseDependencies;
|
|
1193
|
+
return remapDepsObject(deps);
|
|
1032
1194
|
};
|
|
1033
1195
|
}
|
|
1196
|
+
return forked;
|
|
1197
|
+
}, "ensureForked");
|
|
1198
|
+
const ensureForkedForRegisterItems = /* @__PURE__ */ __name((items) => {
|
|
1199
|
+
for (const candidate of toResourceOnlyRegisterItems(items)) {
|
|
1200
|
+
ensureForked(candidate.resource);
|
|
1201
|
+
}
|
|
1202
|
+
}, "ensureForkedForRegisterItems");
|
|
1203
|
+
const mapRegisterItems = /* @__PURE__ */ __name((items) => {
|
|
1204
|
+
ensureForkedForRegisterItems(items);
|
|
1205
|
+
const resourceItems = toResourceOnlyRegisterItems(items);
|
|
1206
|
+
const out = [];
|
|
1207
|
+
for (const candidate of resourceItems) {
|
|
1208
|
+
if (candidate.kind === "resource") {
|
|
1209
|
+
out.push(ensureForked(candidate.resource));
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
out.push(ensureForked(candidate.resource).with(candidate.config));
|
|
1213
|
+
}
|
|
1214
|
+
return out;
|
|
1215
|
+
}, "mapRegisterItems");
|
|
1216
|
+
const remapDependencies = /* @__PURE__ */ __name((dependencies) => {
|
|
1217
|
+
if (!dependencies) return dependencies;
|
|
1218
|
+
const remapObj = /* @__PURE__ */ __name((deps) => remapResourceDependenciesInObject(deps, {
|
|
1219
|
+
getForkedResourceByBaseId: /* @__PURE__ */ __name((id2) => forkedResourceByBaseId.get(id2), "getForkedResourceByBaseId")
|
|
1220
|
+
}), "remapObj");
|
|
1221
|
+
if (typeof dependencies === "function") {
|
|
1222
|
+
return (config) => remapObj(dependencies(config));
|
|
1223
|
+
}
|
|
1224
|
+
return remapObj(dependencies);
|
|
1225
|
+
}, "remapDependencies");
|
|
1226
|
+
return {
|
|
1227
|
+
reId,
|
|
1228
|
+
ensureForkedForRegisterItems,
|
|
1229
|
+
mapRegisterItems,
|
|
1230
|
+
remapDependencies,
|
|
1231
|
+
getForkedResourceByBaseId: /* @__PURE__ */ __name((id2) => forkedResourceByBaseId.get(id2), "getForkedResourceByBaseId")
|
|
1034
1232
|
};
|
|
1035
1233
|
}
|
|
1036
|
-
__name(
|
|
1037
|
-
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1234
|
+
__name(createDeepForkContext, "createDeepForkContext");
|
|
1235
|
+
function resolveForkedRegisterAndDependencies(params) {
|
|
1236
|
+
const { register, dependencies, forkId, options } = params;
|
|
1237
|
+
const mode = options?.register ?? "keep";
|
|
1238
|
+
if (mode === "drop") {
|
|
1239
|
+
return { register: [], dependencies };
|
|
1240
|
+
}
|
|
1241
|
+
if (mode !== "deep") {
|
|
1242
|
+
return { register, dependencies };
|
|
1243
|
+
}
|
|
1244
|
+
if (!register) {
|
|
1245
|
+
return { register, dependencies };
|
|
1246
|
+
}
|
|
1247
|
+
const ctx = createDeepForkContext(forkId, options);
|
|
1248
|
+
if (typeof register === "function") {
|
|
1249
|
+
return {
|
|
1250
|
+
register: /* @__PURE__ */ __name((config) => {
|
|
1251
|
+
const baseItems = register(config);
|
|
1252
|
+
return ctx.mapRegisterItems(baseItems);
|
|
1253
|
+
}, "register"),
|
|
1254
|
+
dependencies: dependencies ? (config) => {
|
|
1255
|
+
const baseItems = register(config);
|
|
1256
|
+
ctx.ensureForkedForRegisterItems(baseItems);
|
|
1257
|
+
const baseDeps = typeof dependencies === "function" ? dependencies(config) : dependencies;
|
|
1258
|
+
return remapResourceDependenciesInObject(baseDeps, {
|
|
1259
|
+
getForkedResourceByBaseId: ctx.getForkedResourceByBaseId
|
|
1260
|
+
});
|
|
1261
|
+
} : dependencies
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
ctx.ensureForkedForRegisterItems(register);
|
|
1051
1265
|
return {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
id: hookDef.id,
|
|
1055
|
-
dependencies: hookDef.dependencies || {},
|
|
1056
|
-
on: hookDef.on,
|
|
1057
|
-
order: hookDef.order,
|
|
1058
|
-
run: hookDef.run,
|
|
1059
|
-
meta: hookDef.meta || {},
|
|
1060
|
-
tags: hookDef.tags || []
|
|
1266
|
+
register: ctx.mapRegisterItems(register),
|
|
1267
|
+
dependencies: ctx.remapDependencies(dependencies)
|
|
1061
1268
|
};
|
|
1062
1269
|
}
|
|
1063
|
-
__name(
|
|
1270
|
+
__name(resolveForkedRegisterAndDependencies, "resolveForkedRegisterAndDependencies");
|
|
1064
1271
|
|
|
1065
1272
|
// src/definers/defineResource.ts
|
|
1066
1273
|
function defineResource(constConfig) {
|
|
@@ -1107,12 +1314,25 @@ function defineResource(constConfig) {
|
|
|
1107
1314
|
[symbolOptionalDependency]: true
|
|
1108
1315
|
};
|
|
1109
1316
|
},
|
|
1110
|
-
fork(newId) {
|
|
1111
|
-
|
|
1317
|
+
fork(newId, options) {
|
|
1318
|
+
const forkedParts = resolveForkedRegisterAndDependencies({
|
|
1319
|
+
register: constConfig.register,
|
|
1320
|
+
dependencies: constConfig.dependencies,
|
|
1321
|
+
forkId: newId,
|
|
1322
|
+
options
|
|
1323
|
+
});
|
|
1324
|
+
const forked = defineResource({
|
|
1112
1325
|
...constConfig,
|
|
1113
1326
|
id: newId,
|
|
1327
|
+
register: forkedParts.register,
|
|
1328
|
+
dependencies: forkedParts.dependencies,
|
|
1114
1329
|
[symbolFilePath]: filePath
|
|
1115
1330
|
});
|
|
1331
|
+
forked[symbolResourceForkedFrom] = {
|
|
1332
|
+
fromId: id2,
|
|
1333
|
+
forkedAtFilePath: getCallerFile()
|
|
1334
|
+
};
|
|
1335
|
+
return forked;
|
|
1116
1336
|
}
|
|
1117
1337
|
};
|
|
1118
1338
|
}
|
|
@@ -1240,7 +1460,7 @@ function defineOverride(base, patch) {
|
|
|
1240
1460
|
...patch,
|
|
1241
1461
|
id: base.id
|
|
1242
1462
|
};
|
|
1243
|
-
if (base.on !== void 0) {
|
|
1463
|
+
if ("on" in base && base.on !== void 0) {
|
|
1244
1464
|
overridden.on = base.on;
|
|
1245
1465
|
}
|
|
1246
1466
|
return overridden;
|
|
@@ -1360,6 +1580,309 @@ var SymbolPolicy = /* @__PURE__ */ ((SymbolPolicy2) => {
|
|
|
1360
1580
|
SymbolPolicy2["Disabled"] = "Disabled";
|
|
1361
1581
|
return SymbolPolicy2;
|
|
1362
1582
|
})(SymbolPolicy || {});
|
|
1583
|
+
var SymbolPolicyErrorMessage = /* @__PURE__ */ ((SymbolPolicyErrorMessage2) => {
|
|
1584
|
+
SymbolPolicyErrorMessage2["GlobalSymbolsNotAllowed"] = "Global symbols are not allowed";
|
|
1585
|
+
SymbolPolicyErrorMessage2["SymbolsNotAllowed"] = "Symbols are not allowed";
|
|
1586
|
+
SymbolPolicyErrorMessage2["UnsupportedSymbolPolicy"] = "Unsupported symbol policy";
|
|
1587
|
+
return SymbolPolicyErrorMessage2;
|
|
1588
|
+
})(SymbolPolicyErrorMessage || {});
|
|
1589
|
+
|
|
1590
|
+
// src/serializer/binary-builtins.ts
|
|
1591
|
+
var INVALID_PAYLOAD_MESSAGE_PREFIX = "Invalid";
|
|
1592
|
+
var typedArrayTypeIds = [
|
|
1593
|
+
"Int8Array",
|
|
1594
|
+
"Uint8Array",
|
|
1595
|
+
"Uint8ClampedArray",
|
|
1596
|
+
"Int16Array",
|
|
1597
|
+
"Uint16Array",
|
|
1598
|
+
"Int32Array",
|
|
1599
|
+
"Uint32Array",
|
|
1600
|
+
"Float32Array",
|
|
1601
|
+
"Float64Array",
|
|
1602
|
+
"BigInt64Array",
|
|
1603
|
+
"BigUint64Array"
|
|
1604
|
+
];
|
|
1605
|
+
var getTypedArrayConstructor = /* @__PURE__ */ __name((typeId) => {
|
|
1606
|
+
const value = globalThis[typeId];
|
|
1607
|
+
if (typeof value !== "function") {
|
|
1608
|
+
return null;
|
|
1609
|
+
}
|
|
1610
|
+
return value;
|
|
1611
|
+
}, "getTypedArrayConstructor");
|
|
1612
|
+
var getRuntimeBufferConstructor = /* @__PURE__ */ __name(() => {
|
|
1613
|
+
const value = globalThis.Buffer;
|
|
1614
|
+
if (typeof value !== "function") {
|
|
1615
|
+
return null;
|
|
1616
|
+
}
|
|
1617
|
+
const valueRecord = value;
|
|
1618
|
+
if (typeof valueRecord.from !== "function" || typeof valueRecord.isBuffer !== "function") {
|
|
1619
|
+
return null;
|
|
1620
|
+
}
|
|
1621
|
+
return value;
|
|
1622
|
+
}, "getRuntimeBufferConstructor");
|
|
1623
|
+
var isNodeBuffer = /* @__PURE__ */ __name((value) => {
|
|
1624
|
+
const runtimeBufferConstructor = getRuntimeBufferConstructor();
|
|
1625
|
+
if (!runtimeBufferConstructor) {
|
|
1626
|
+
return false;
|
|
1627
|
+
}
|
|
1628
|
+
return runtimeBufferConstructor.isBuffer(value);
|
|
1629
|
+
}, "isNodeBuffer");
|
|
1630
|
+
var assertBytePayload = /* @__PURE__ */ __name((payload, typeId) => {
|
|
1631
|
+
if (!Array.isArray(payload)) {
|
|
1632
|
+
throw new Error(`${INVALID_PAYLOAD_MESSAGE_PREFIX} ${typeId} payload`);
|
|
1633
|
+
}
|
|
1634
|
+
const bytes = new Array(payload.length);
|
|
1635
|
+
for (let index = 0; index < payload.length; index += 1) {
|
|
1636
|
+
const byteValue = payload[index];
|
|
1637
|
+
if (typeof byteValue !== "number" || !Number.isInteger(byteValue) || byteValue < 0 || byteValue > 255) {
|
|
1638
|
+
throw new Error(`${INVALID_PAYLOAD_MESSAGE_PREFIX} ${typeId} payload`);
|
|
1639
|
+
}
|
|
1640
|
+
bytes[index] = byteValue;
|
|
1641
|
+
}
|
|
1642
|
+
return bytes;
|
|
1643
|
+
}, "assertBytePayload");
|
|
1644
|
+
var toBytePayload = /* @__PURE__ */ __name((value) => Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength)), "toBytePayload");
|
|
1645
|
+
var bytesToArrayBuffer = /* @__PURE__ */ __name((payload, typeId) => {
|
|
1646
|
+
const bytes = assertBytePayload(payload, typeId);
|
|
1647
|
+
return Uint8Array.from(bytes).buffer;
|
|
1648
|
+
}, "bytesToArrayBuffer");
|
|
1649
|
+
var deserializeTypedArray = /* @__PURE__ */ __name((typeId, payload) => {
|
|
1650
|
+
const typedArrayConstructor = getTypedArrayConstructor(typeId);
|
|
1651
|
+
if (!typedArrayConstructor) {
|
|
1652
|
+
throw new Error(`${typeId} is not available in this runtime`);
|
|
1653
|
+
}
|
|
1654
|
+
const bytes = assertBytePayload(payload, typeId);
|
|
1655
|
+
const bytesPerElement = typedArrayConstructor.BYTES_PER_ELEMENT;
|
|
1656
|
+
if (bytes.length % bytesPerElement !== 0) {
|
|
1657
|
+
throw new Error(`${INVALID_PAYLOAD_MESSAGE_PREFIX} ${typeId} payload`);
|
|
1658
|
+
}
|
|
1659
|
+
const arrayBuffer = Uint8Array.from(bytes).buffer;
|
|
1660
|
+
return new typedArrayConstructor(arrayBuffer);
|
|
1661
|
+
}, "deserializeTypedArray");
|
|
1662
|
+
var createTypedArrayType = /* @__PURE__ */ __name((typeId) => ({
|
|
1663
|
+
id: typeId,
|
|
1664
|
+
is: /* @__PURE__ */ __name((value) => {
|
|
1665
|
+
const typedArrayConstructor = getTypedArrayConstructor(typeId);
|
|
1666
|
+
if (!typedArrayConstructor) {
|
|
1667
|
+
return false;
|
|
1668
|
+
}
|
|
1669
|
+
if (!(value instanceof typedArrayConstructor)) {
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
if (typeId === "Uint8Array" && isNodeBuffer(value)) {
|
|
1673
|
+
return false;
|
|
1674
|
+
}
|
|
1675
|
+
return true;
|
|
1676
|
+
}, "is"),
|
|
1677
|
+
serialize: /* @__PURE__ */ __name((value) => toBytePayload(value), "serialize"),
|
|
1678
|
+
deserialize: /* @__PURE__ */ __name((payload) => deserializeTypedArray(typeId, payload), "deserialize"),
|
|
1679
|
+
strategy: "value"
|
|
1680
|
+
}), "createTypedArrayType");
|
|
1681
|
+
var ArrayBufferType = {
|
|
1682
|
+
id: "ArrayBuffer",
|
|
1683
|
+
is: /* @__PURE__ */ __name((value) => value instanceof ArrayBuffer, "is"),
|
|
1684
|
+
serialize: /* @__PURE__ */ __name((value) => Array.from(new Uint8Array(value)), "serialize"),
|
|
1685
|
+
deserialize: /* @__PURE__ */ __name((payload) => bytesToArrayBuffer(payload, "ArrayBuffer"), "deserialize"),
|
|
1686
|
+
strategy: "value"
|
|
1687
|
+
};
|
|
1688
|
+
var DataViewType = {
|
|
1689
|
+
id: "DataView",
|
|
1690
|
+
is: /* @__PURE__ */ __name((value) => value instanceof DataView, "is"),
|
|
1691
|
+
serialize: /* @__PURE__ */ __name((value) => toBytePayload(value), "serialize"),
|
|
1692
|
+
deserialize: /* @__PURE__ */ __name((payload) => new DataView(bytesToArrayBuffer(payload, "DataView")), "deserialize"),
|
|
1693
|
+
strategy: "value"
|
|
1694
|
+
};
|
|
1695
|
+
var BufferType = {
|
|
1696
|
+
id: "Buffer",
|
|
1697
|
+
is: /* @__PURE__ */ __name((value) => isNodeBuffer(value), "is"),
|
|
1698
|
+
serialize: /* @__PURE__ */ __name((value) => toBytePayload(value), "serialize"),
|
|
1699
|
+
deserialize: /* @__PURE__ */ __name((payload) => {
|
|
1700
|
+
const bytes = assertBytePayload(payload, "Buffer");
|
|
1701
|
+
const runtimeBufferConstructor = getRuntimeBufferConstructor();
|
|
1702
|
+
if (runtimeBufferConstructor) {
|
|
1703
|
+
return runtimeBufferConstructor.from(bytes);
|
|
1704
|
+
}
|
|
1705
|
+
return Uint8Array.from(bytes);
|
|
1706
|
+
}, "deserialize"),
|
|
1707
|
+
strategy: "value"
|
|
1708
|
+
};
|
|
1709
|
+
var typedArrayTypes = typedArrayTypeIds.map(
|
|
1710
|
+
(typeId) => createTypedArrayType(typeId)
|
|
1711
|
+
);
|
|
1712
|
+
var binaryBuiltInTypes = [
|
|
1713
|
+
ArrayBufferType,
|
|
1714
|
+
DataViewType,
|
|
1715
|
+
BufferType,
|
|
1716
|
+
...typedArrayTypes
|
|
1717
|
+
];
|
|
1718
|
+
|
|
1719
|
+
// src/serializer/error-url-builtins.ts
|
|
1720
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1721
|
+
var errorReservedPropertyNames = /* @__PURE__ */ new Set([
|
|
1722
|
+
"name",
|
|
1723
|
+
"message",
|
|
1724
|
+
"stack",
|
|
1725
|
+
"cause"
|
|
1726
|
+
]);
|
|
1727
|
+
var isRecord = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
|
|
1728
|
+
var isUnsafePropertyName = /* @__PURE__ */ __name((propertyName) => propertyName === "__proto__" || propertyName === "constructor" || propertyName === "prototype", "isUnsafePropertyName");
|
|
1729
|
+
var collectErrorCustomFields = /* @__PURE__ */ __name((error2) => {
|
|
1730
|
+
const customFields = {};
|
|
1731
|
+
for (const propertyName of Object.getOwnPropertyNames(error2)) {
|
|
1732
|
+
if (errorReservedPropertyNames.has(propertyName)) {
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
if (isUnsafePropertyName(propertyName)) {
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
1738
|
+
const descriptor = Object.getOwnPropertyDescriptor(error2, propertyName);
|
|
1739
|
+
if (!descriptor || !("value" in descriptor)) {
|
|
1740
|
+
continue;
|
|
1741
|
+
}
|
|
1742
|
+
customFields[propertyName] = descriptor.value;
|
|
1743
|
+
}
|
|
1744
|
+
return customFields;
|
|
1745
|
+
}, "collectErrorCustomFields");
|
|
1746
|
+
var assertSerializedErrorPayload = /* @__PURE__ */ __name((value) => {
|
|
1747
|
+
if (!isRecord(value)) {
|
|
1748
|
+
throw new Error("Invalid Error payload");
|
|
1749
|
+
}
|
|
1750
|
+
const { name, message, stack, customFields } = value;
|
|
1751
|
+
if (typeof name !== "string" || typeof message !== "string") {
|
|
1752
|
+
throw new Error("Invalid Error payload");
|
|
1753
|
+
}
|
|
1754
|
+
if (stack !== void 0 && typeof stack !== "string") {
|
|
1755
|
+
throw new Error("Invalid Error payload");
|
|
1756
|
+
}
|
|
1757
|
+
if (customFields !== void 0 && !isRecord(customFields)) {
|
|
1758
|
+
throw new Error("Invalid Error payload");
|
|
1759
|
+
}
|
|
1760
|
+
const normalizedCustomFields = {};
|
|
1761
|
+
const customFieldEntries = Object.entries(customFields ?? {});
|
|
1762
|
+
for (const [propertyName, propertyValue] of customFieldEntries) {
|
|
1763
|
+
if (isUnsafePropertyName(propertyName)) {
|
|
1764
|
+
continue;
|
|
1765
|
+
}
|
|
1766
|
+
normalizedCustomFields[propertyName] = propertyValue;
|
|
1767
|
+
}
|
|
1768
|
+
return {
|
|
1769
|
+
name,
|
|
1770
|
+
message,
|
|
1771
|
+
stack,
|
|
1772
|
+
hasCause: hasOwn.call(value, "cause"),
|
|
1773
|
+
cause: value.cause,
|
|
1774
|
+
customFields: normalizedCustomFields
|
|
1775
|
+
};
|
|
1776
|
+
}, "assertSerializedErrorPayload");
|
|
1777
|
+
var getUrlConstructor = /* @__PURE__ */ __name(() => {
|
|
1778
|
+
const value = globalThis.URL;
|
|
1779
|
+
if (typeof value !== "function") {
|
|
1780
|
+
return null;
|
|
1781
|
+
}
|
|
1782
|
+
return value;
|
|
1783
|
+
}, "getUrlConstructor");
|
|
1784
|
+
var getUrlSearchParamsConstructor = /* @__PURE__ */ __name(() => {
|
|
1785
|
+
const value = globalThis.URLSearchParams;
|
|
1786
|
+
if (typeof value !== "function") {
|
|
1787
|
+
return null;
|
|
1788
|
+
}
|
|
1789
|
+
return value;
|
|
1790
|
+
}, "getUrlSearchParamsConstructor");
|
|
1791
|
+
var ErrorType = {
|
|
1792
|
+
id: "Error",
|
|
1793
|
+
is: /* @__PURE__ */ __name((value) => value instanceof Error, "is"),
|
|
1794
|
+
serialize: /* @__PURE__ */ __name((error2) => {
|
|
1795
|
+
const serializedErrorPayload = {
|
|
1796
|
+
name: error2.name,
|
|
1797
|
+
message: error2.message,
|
|
1798
|
+
customFields: collectErrorCustomFields(error2)
|
|
1799
|
+
};
|
|
1800
|
+
if (typeof error2.stack === "string") {
|
|
1801
|
+
serializedErrorPayload.stack = error2.stack;
|
|
1802
|
+
}
|
|
1803
|
+
if (hasOwn.call(error2, "cause")) {
|
|
1804
|
+
serializedErrorPayload.cause = error2.cause;
|
|
1805
|
+
}
|
|
1806
|
+
return serializedErrorPayload;
|
|
1807
|
+
}, "serialize"),
|
|
1808
|
+
deserialize: /* @__PURE__ */ __name((payload) => {
|
|
1809
|
+
const { name, message, stack, hasCause, cause, customFields } = assertSerializedErrorPayload(payload);
|
|
1810
|
+
const restoredError = new Error(message);
|
|
1811
|
+
restoredError.name = name;
|
|
1812
|
+
if (stack !== void 0) {
|
|
1813
|
+
Object.defineProperty(restoredError, "stack", {
|
|
1814
|
+
value: stack,
|
|
1815
|
+
writable: true,
|
|
1816
|
+
configurable: true,
|
|
1817
|
+
enumerable: false
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
if (hasCause) {
|
|
1821
|
+
Object.defineProperty(restoredError, "cause", {
|
|
1822
|
+
value: cause,
|
|
1823
|
+
writable: true,
|
|
1824
|
+
configurable: true,
|
|
1825
|
+
enumerable: false
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
for (const [propertyName, propertyValue] of Object.entries(customFields)) {
|
|
1829
|
+
if (errorReservedPropertyNames.has(propertyName)) {
|
|
1830
|
+
continue;
|
|
1831
|
+
}
|
|
1832
|
+
restoredError[propertyName] = propertyValue;
|
|
1833
|
+
}
|
|
1834
|
+
return restoredError;
|
|
1835
|
+
}, "deserialize")
|
|
1836
|
+
};
|
|
1837
|
+
var URLType = {
|
|
1838
|
+
id: "URL",
|
|
1839
|
+
is: /* @__PURE__ */ __name((value) => {
|
|
1840
|
+
const runtimeUrlConstructor = getUrlConstructor();
|
|
1841
|
+
if (!runtimeUrlConstructor) {
|
|
1842
|
+
return false;
|
|
1843
|
+
}
|
|
1844
|
+
return value instanceof runtimeUrlConstructor;
|
|
1845
|
+
}, "is"),
|
|
1846
|
+
serialize: /* @__PURE__ */ __name((value) => value.href, "serialize"),
|
|
1847
|
+
deserialize: /* @__PURE__ */ __name((payload) => {
|
|
1848
|
+
if (typeof payload !== "string") {
|
|
1849
|
+
throw new Error("Invalid URL payload");
|
|
1850
|
+
}
|
|
1851
|
+
const runtimeUrlConstructor = getUrlConstructor();
|
|
1852
|
+
if (!runtimeUrlConstructor) {
|
|
1853
|
+
throw new Error("URL is not available in this runtime");
|
|
1854
|
+
}
|
|
1855
|
+
return new runtimeUrlConstructor(payload);
|
|
1856
|
+
}, "deserialize"),
|
|
1857
|
+
strategy: "value"
|
|
1858
|
+
};
|
|
1859
|
+
var URLSearchParamsType = {
|
|
1860
|
+
id: "URLSearchParams",
|
|
1861
|
+
is: /* @__PURE__ */ __name((value) => {
|
|
1862
|
+
const runtimeUrlSearchParamsConstructor = getUrlSearchParamsConstructor();
|
|
1863
|
+
if (!runtimeUrlSearchParamsConstructor) {
|
|
1864
|
+
return false;
|
|
1865
|
+
}
|
|
1866
|
+
return value instanceof runtimeUrlSearchParamsConstructor;
|
|
1867
|
+
}, "is"),
|
|
1868
|
+
serialize: /* @__PURE__ */ __name((value) => value.toString(), "serialize"),
|
|
1869
|
+
deserialize: /* @__PURE__ */ __name((payload) => {
|
|
1870
|
+
if (typeof payload !== "string") {
|
|
1871
|
+
throw new Error("Invalid URLSearchParams payload");
|
|
1872
|
+
}
|
|
1873
|
+
const runtimeUrlSearchParamsConstructor = getUrlSearchParamsConstructor();
|
|
1874
|
+
if (!runtimeUrlSearchParamsConstructor) {
|
|
1875
|
+
throw new Error("URLSearchParams is not available in this runtime");
|
|
1876
|
+
}
|
|
1877
|
+
return new runtimeUrlSearchParamsConstructor(payload);
|
|
1878
|
+
}, "deserialize"),
|
|
1879
|
+
strategy: "value"
|
|
1880
|
+
};
|
|
1881
|
+
var errorAndUrlBuiltInTypes = [
|
|
1882
|
+
ErrorType,
|
|
1883
|
+
URLType,
|
|
1884
|
+
URLSearchParamsType
|
|
1885
|
+
];
|
|
1363
1886
|
|
|
1364
1887
|
// src/serializer/special-values.ts
|
|
1365
1888
|
var serializeUndefined = /* @__PURE__ */ __name(() => ({
|
|
@@ -1565,7 +2088,9 @@ var builtInTypes = [
|
|
|
1565
2088
|
UndefinedType,
|
|
1566
2089
|
NonFiniteNumberType,
|
|
1567
2090
|
BigIntType,
|
|
1568
|
-
SymbolType
|
|
2091
|
+
SymbolType,
|
|
2092
|
+
...errorAndUrlBuiltInTypes,
|
|
2093
|
+
...binaryBuiltInTypes
|
|
1569
2094
|
];
|
|
1570
2095
|
|
|
1571
2096
|
// src/serializer/type-registry.ts
|
|
@@ -2056,7 +2581,7 @@ var serializeTreeValue = /* @__PURE__ */ __name((value, context, depth, options)
|
|
|
2056
2581
|
}, "serializeTreeValue");
|
|
2057
2582
|
|
|
2058
2583
|
// src/serializer/deserializer.ts
|
|
2059
|
-
var
|
|
2584
|
+
var hasOwn2 = Object.prototype.hasOwnProperty;
|
|
2060
2585
|
var copyOwnProperties = /* @__PURE__ */ __name((target, source, unsafeKeys) => {
|
|
2061
2586
|
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
2062
2587
|
for (const key of Object.keys(descriptors)) {
|
|
@@ -2137,7 +2662,7 @@ var deserializeValue = /* @__PURE__ */ __name((value, context, depth, options) =
|
|
|
2137
2662
|
const obj = {};
|
|
2138
2663
|
const source = value;
|
|
2139
2664
|
for (const key in source) {
|
|
2140
|
-
if (!
|
|
2665
|
+
if (!hasOwn2.call(source, key)) {
|
|
2141
2666
|
continue;
|
|
2142
2667
|
}
|
|
2143
2668
|
if (isUnsafeKey(key, options.unsafeKeys)) {
|
|
@@ -2182,7 +2707,7 @@ var resolveReference = /* @__PURE__ */ __name((id2, context, depth, options) =>
|
|
|
2182
2707
|
context.resolved.set(id2, target);
|
|
2183
2708
|
const source = node.value;
|
|
2184
2709
|
for (const key in source) {
|
|
2185
|
-
if (!
|
|
2710
|
+
if (!hasOwn2.call(source, key)) {
|
|
2186
2711
|
continue;
|
|
2187
2712
|
}
|
|
2188
2713
|
if (isUnsafeKey(key, options.unsafeKeys)) {
|
|
@@ -2254,7 +2779,7 @@ var mergePlaceholder = /* @__PURE__ */ __name((placeholder, result, unsafeKeys)
|
|
|
2254
2779
|
const target = placeholder;
|
|
2255
2780
|
const source = result;
|
|
2256
2781
|
for (const key in source) {
|
|
2257
|
-
if (!
|
|
2782
|
+
if (!hasOwn2.call(source, key)) {
|
|
2258
2783
|
continue;
|
|
2259
2784
|
}
|
|
2260
2785
|
if (isUnsafeKey(key, unsafeKeys)) {
|
|
@@ -2287,7 +2812,7 @@ var deserializeLegacy = /* @__PURE__ */ __name((value, depth, options) => {
|
|
|
2287
2812
|
const obj = {};
|
|
2288
2813
|
const source = value;
|
|
2289
2814
|
for (const key in source) {
|
|
2290
|
-
if (!
|
|
2815
|
+
if (!hasOwn2.call(source, key)) {
|
|
2291
2816
|
continue;
|
|
2292
2817
|
}
|
|
2293
2818
|
if (isUnsafeKey(key, options.unsafeKeys)) {
|
|
@@ -2298,6 +2823,26 @@ var deserializeLegacy = /* @__PURE__ */ __name((value, depth, options) => {
|
|
|
2298
2823
|
return obj;
|
|
2299
2824
|
}, "deserializeLegacy");
|
|
2300
2825
|
|
|
2826
|
+
// src/serializer/option-normalizers.ts
|
|
2827
|
+
var normalizeMaxDepth = /* @__PURE__ */ __name((value, fallback) => {
|
|
2828
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
2829
|
+
return Number.POSITIVE_INFINITY;
|
|
2830
|
+
}
|
|
2831
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
|
|
2832
|
+
return Math.floor(value);
|
|
2833
|
+
}
|
|
2834
|
+
return fallback;
|
|
2835
|
+
}, "normalizeMaxDepth");
|
|
2836
|
+
var normalizeMaxRegExpPatternLength = /* @__PURE__ */ __name((value, fallback) => {
|
|
2837
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
2838
|
+
return Number.POSITIVE_INFINITY;
|
|
2839
|
+
}
|
|
2840
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
2841
|
+
return Math.floor(value);
|
|
2842
|
+
}
|
|
2843
|
+
return fallback;
|
|
2844
|
+
}, "normalizeMaxRegExpPatternLength");
|
|
2845
|
+
|
|
2301
2846
|
// src/serializer/Serializer.ts
|
|
2302
2847
|
var GRAPH_VERSION = 1;
|
|
2303
2848
|
var DEFAULT_MAX_DEPTH = 1e3;
|
|
@@ -2333,10 +2878,11 @@ var Serializer = class {
|
|
|
2333
2878
|
return check(pattern, index);
|
|
2334
2879
|
}, "isBoundedQuantifier");
|
|
2335
2880
|
this.indent = options.pretty ? 2 : void 0;
|
|
2336
|
-
|
|
2337
|
-
this.
|
|
2338
|
-
|
|
2339
|
-
|
|
2881
|
+
this.maxDepth = normalizeMaxDepth(options.maxDepth, DEFAULT_MAX_DEPTH);
|
|
2882
|
+
this.maxRegExpPatternLength = normalizeMaxRegExpPatternLength(
|
|
2883
|
+
options.maxRegExpPatternLength,
|
|
2884
|
+
DEFAULT_MAX_REGEXP_PATTERN_LENGTH
|
|
2885
|
+
);
|
|
2340
2886
|
this.allowUnsafeRegExp = options.allowUnsafeRegExp ?? false;
|
|
2341
2887
|
this.unsafeKeys = DEFAULT_UNSAFE_KEYS;
|
|
2342
2888
|
this.typeRegistry = new TypeRegistry({
|
|
@@ -2471,13 +3017,6 @@ var Serializer = class {
|
|
|
2471
3017
|
}
|
|
2472
3018
|
};
|
|
2473
3019
|
|
|
2474
|
-
// src/serializer/index.ts
|
|
2475
|
-
var defaultSerializer = new Serializer();
|
|
2476
|
-
function getDefaultSerializer() {
|
|
2477
|
-
return defaultSerializer;
|
|
2478
|
-
}
|
|
2479
|
-
__name(getDefaultSerializer, "getDefaultSerializer");
|
|
2480
|
-
|
|
2481
3020
|
// src/definers/defineAsyncContext.ts
|
|
2482
3021
|
var platform = getPlatform();
|
|
2483
3022
|
var storage = platform.createAsyncLocalStorage();
|
|
@@ -2485,13 +3024,14 @@ function getCurrentStore() {
|
|
|
2485
3024
|
return storage.getStore();
|
|
2486
3025
|
}
|
|
2487
3026
|
__name(getCurrentStore, "getCurrentStore");
|
|
2488
|
-
function defineAsyncContext(def) {
|
|
3027
|
+
function defineAsyncContext(def, filePath) {
|
|
2489
3028
|
if (!platform.hasAsyncLocalStorage()) {
|
|
2490
3029
|
platformUnsupportedFunctionError.throw({
|
|
2491
3030
|
functionName: `createAsyncLocalStorage: Cannot create context ${def.id}: no async storage available in this environment`
|
|
2492
3031
|
});
|
|
2493
3032
|
}
|
|
2494
3033
|
const ctxId = def.id;
|
|
3034
|
+
const resolvedFilePath = filePath ?? getCallerFile();
|
|
2495
3035
|
const use = /* @__PURE__ */ __name(() => {
|
|
2496
3036
|
const store2 = getCurrentStore();
|
|
2497
3037
|
if (!store2 || !store2.has(ctxId)) {
|
|
@@ -2508,10 +3048,11 @@ function defineAsyncContext(def) {
|
|
|
2508
3048
|
map.set(ctxId, value);
|
|
2509
3049
|
return storage.run(map, fn);
|
|
2510
3050
|
}, "provide");
|
|
2511
|
-
const serializer2 =
|
|
3051
|
+
const serializer2 = new Serializer();
|
|
2512
3052
|
const api = {
|
|
2513
3053
|
id: ctxId,
|
|
2514
3054
|
[symbolAsyncContext]: true,
|
|
3055
|
+
[symbolFilePath]: resolvedFilePath,
|
|
2515
3056
|
use,
|
|
2516
3057
|
/* istanbul ignore next */
|
|
2517
3058
|
provide(value, fn) {
|
|
@@ -3163,12 +3704,12 @@ var EventManager = class {
|
|
|
3163
3704
|
data,
|
|
3164
3705
|
timestamp: /* @__PURE__ */ new Date(),
|
|
3165
3706
|
source,
|
|
3166
|
-
meta: eventDefinition.meta || {},
|
|
3707
|
+
meta: { ...eventDefinition.meta || {} },
|
|
3167
3708
|
stopPropagation: /* @__PURE__ */ __name(() => {
|
|
3168
3709
|
propagationStopped = true;
|
|
3169
3710
|
}, "stopPropagation"),
|
|
3170
3711
|
isPropagationStopped: /* @__PURE__ */ __name(() => propagationStopped, "isPropagationStopped"),
|
|
3171
|
-
tags: eventDefinition.tags
|
|
3712
|
+
tags: [...eventDefinition.tags]
|
|
3172
3713
|
};
|
|
3173
3714
|
const baseEmit = /* @__PURE__ */ __name(async (eventToEmit) => {
|
|
3174
3715
|
if (allListeners.length === 0) {
|
|
@@ -3194,10 +3735,14 @@ var EventManager = class {
|
|
|
3194
3735
|
if (!interceptor) {
|
|
3195
3736
|
return baseEmit(eventToEmit);
|
|
3196
3737
|
}
|
|
3197
|
-
return interceptor(
|
|
3198
|
-
(
|
|
3199
|
-
|
|
3200
|
-
|
|
3738
|
+
return interceptor((nextEvent) => {
|
|
3739
|
+
this.assertPropagationMethodsUnchanged(
|
|
3740
|
+
eventDefinition.id,
|
|
3741
|
+
eventToEmit,
|
|
3742
|
+
nextEvent
|
|
3743
|
+
);
|
|
3744
|
+
return runInterceptor(index + 1, nextEvent);
|
|
3745
|
+
}, eventToEmit);
|
|
3201
3746
|
}, "runInterceptor");
|
|
3202
3747
|
await runInterceptor(0, event2);
|
|
3203
3748
|
return deepestEvent;
|
|
@@ -3308,21 +3853,24 @@ var EventManager = class {
|
|
|
3308
3853
|
lockedError.throw({ what: "EventManager" });
|
|
3309
3854
|
}
|
|
3310
3855
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3856
|
+
assertPropagationMethodsUnchanged(eventId, currentEvent, nextEvent) {
|
|
3857
|
+
if (nextEvent.stopPropagation !== currentEvent.stopPropagation || nextEvent.isPropagationStopped !== currentEvent.isPropagationStopped) {
|
|
3858
|
+
validationError.throw({
|
|
3859
|
+
subject: "Event interceptor",
|
|
3860
|
+
id: eventId,
|
|
3861
|
+
originalError: new Error(
|
|
3862
|
+
"Interceptors cannot override stopPropagation/isPropagationStopped"
|
|
3863
|
+
)
|
|
3864
|
+
});
|
|
3865
|
+
}
|
|
3319
3866
|
}
|
|
3320
3867
|
/**
|
|
3321
3868
|
* Disposes the EventManager, releasing all listeners and interceptors.
|
|
3322
|
-
* Alias for clear() following the IResource disposal pattern.
|
|
3323
3869
|
*/
|
|
3324
3870
|
dispose() {
|
|
3325
|
-
this.clear();
|
|
3871
|
+
this.registry.clear();
|
|
3872
|
+
this.emissionInterceptors.length = 0;
|
|
3873
|
+
this.hookInterceptors.length = 0;
|
|
3326
3874
|
}
|
|
3327
3875
|
/**
|
|
3328
3876
|
* Retrieves cached merged listeners for an event, or creates them if not cached.
|
|
@@ -4840,7 +5388,7 @@ var TaskRunner = class {
|
|
|
4840
5388
|
__name(this, "TaskRunner");
|
|
4841
5389
|
}
|
|
4842
5390
|
/**
|
|
4843
|
-
* Begins the execution of
|
|
5391
|
+
* Begins the execution of a task. These are registered tasks and all sanity checks have been performed at this stage to ensure consistency of the object.
|
|
4844
5392
|
* This function can throw only if any of the event listeners or run function throws
|
|
4845
5393
|
* @param task the task to be run
|
|
4846
5394
|
* @param input the input to be passed to the task
|
|
@@ -4869,8 +5417,6 @@ var TaskRunner = class {
|
|
|
4869
5417
|
/**
|
|
4870
5418
|
* Creates the function with the chain of middleware.
|
|
4871
5419
|
* @param task
|
|
4872
|
-
* @param input
|
|
4873
|
-
* @param taskDependencies
|
|
4874
5420
|
* @returns
|
|
4875
5421
|
*/
|
|
4876
5422
|
createRunnerWithMiddleware(task2) {
|
|
@@ -4890,7 +5436,7 @@ var ResourceInitializer = class {
|
|
|
4890
5436
|
__name(this, "ResourceInitializer");
|
|
4891
5437
|
}
|
|
4892
5438
|
/**
|
|
4893
|
-
* Begins the execution of
|
|
5439
|
+
* Begins the execution of a task. These are registered tasks and all sanity checks have been performed at this stage to ensure consistency of the object.
|
|
4894
5440
|
* This function can throw only if any of the event listeners or run function throws
|
|
4895
5441
|
*/
|
|
4896
5442
|
async initializeResource(resource2, config, dependencies) {
|
|
@@ -5380,23 +5926,28 @@ var DependencyProcessor = class {
|
|
|
5380
5926
|
middleware.computedDependencies = computedDependencies;
|
|
5381
5927
|
middleware.isInitialized = true;
|
|
5382
5928
|
}
|
|
5383
|
-
for (const resource2 of this.store.resources.values()) {
|
|
5384
|
-
await this.processResourceDependencies(resource2);
|
|
5385
|
-
}
|
|
5386
|
-
for (const task2 of this.store.tasks.values()) {
|
|
5387
|
-
await this.computeTaskDependencies(task2);
|
|
5388
|
-
}
|
|
5389
5929
|
for (const hookStoreElement of this.store.hooks.values()) {
|
|
5390
5930
|
const hook2 = hookStoreElement.hook;
|
|
5391
5931
|
const deps = hook2.dependencies;
|
|
5932
|
+
hookStoreElement.dependencyState = "computing" /* Computing */;
|
|
5392
5933
|
hookStoreElement.computedDependencies = await this.extractDependencies(
|
|
5393
5934
|
deps,
|
|
5394
5935
|
hook2.id
|
|
5395
5936
|
);
|
|
5937
|
+
hookStoreElement.dependencyState = "ready" /* Ready */;
|
|
5938
|
+
}
|
|
5939
|
+
for (const resource2 of this.store.resources.values()) {
|
|
5940
|
+
await this.processResourceDependencies(resource2);
|
|
5941
|
+
}
|
|
5942
|
+
for (const task2 of this.store.tasks.values()) {
|
|
5943
|
+
await this.computeTaskDependencies(task2);
|
|
5396
5944
|
}
|
|
5397
5945
|
await this.initializeUninitializedResources();
|
|
5398
5946
|
}
|
|
5399
5947
|
async computeTaskDependencies(task2) {
|
|
5948
|
+
if (task2.isInitialized) {
|
|
5949
|
+
return;
|
|
5950
|
+
}
|
|
5400
5951
|
const deps = task2.task.dependencies;
|
|
5401
5952
|
task2.computedDependencies = await this.extractDependencies(
|
|
5402
5953
|
deps,
|
|
@@ -5528,6 +6079,9 @@ var DependencyProcessor = class {
|
|
|
5528
6079
|
if (receivedEvent.source === hook2.id) {
|
|
5529
6080
|
return;
|
|
5530
6081
|
}
|
|
6082
|
+
if (hookStoreElement.dependencyState !== "ready" /* Ready */) {
|
|
6083
|
+
return;
|
|
6084
|
+
}
|
|
5531
6085
|
return this.eventManager.executeHookWithInterceptors(
|
|
5532
6086
|
hook2,
|
|
5533
6087
|
receivedEvent,
|
|
@@ -5644,7 +6198,7 @@ var DependencyProcessor = class {
|
|
|
5644
6198
|
}
|
|
5645
6199
|
const st = storeTask;
|
|
5646
6200
|
if (!st.isInitialized) {
|
|
5647
|
-
const dependencies =
|
|
6201
|
+
const dependencies = st.task.dependencies;
|
|
5648
6202
|
st.computedDependencies = await this.extractDependencies(
|
|
5649
6203
|
dependencies,
|
|
5650
6204
|
st.task.id
|
|
@@ -5670,14 +6224,19 @@ var DependencyProcessor = class {
|
|
|
5670
6224
|
wrapped = this.wrapResourceDependencies(depMap, raw);
|
|
5671
6225
|
sr.computedDependencies = wrapped;
|
|
5672
6226
|
}
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
6227
|
+
try {
|
|
6228
|
+
const { value, context } = await this.resourceInitializer.initializeResource(
|
|
6229
|
+
resource2,
|
|
6230
|
+
config,
|
|
6231
|
+
wrapped
|
|
6232
|
+
);
|
|
6233
|
+
sr.context = context;
|
|
6234
|
+
sr.value = value;
|
|
6235
|
+
sr.isInitialized = true;
|
|
6236
|
+
this.store.recordResourceInitialized(resource2.id);
|
|
6237
|
+
} catch (error2) {
|
|
6238
|
+
this.rethrowResourceInitError(resource2.id, error2);
|
|
6239
|
+
}
|
|
5681
6240
|
}
|
|
5682
6241
|
return sr.value;
|
|
5683
6242
|
}
|
|
@@ -5880,7 +6439,8 @@ var StoreRegistry = class {
|
|
|
5880
6439
|
const hook2 = this.getFreshValue(item, this.hooks, "hook", overrideMode);
|
|
5881
6440
|
this.hooks.set(hook2.id, {
|
|
5882
6441
|
hook: hook2,
|
|
5883
|
-
computedDependencies: {}
|
|
6442
|
+
computedDependencies: {},
|
|
6443
|
+
dependencyState: "pending" /* Pending */
|
|
5884
6444
|
});
|
|
5885
6445
|
}
|
|
5886
6446
|
storeTaskMiddleware(item, storingMode = "normal") {
|
|
@@ -5935,7 +6495,10 @@ var StoreRegistry = class {
|
|
|
5935
6495
|
return prepared;
|
|
5936
6496
|
}
|
|
5937
6497
|
computeRegistrationDeeply(element, config) {
|
|
5938
|
-
|
|
6498
|
+
let items = typeof element.register === "function" ? element.register(config) : element.register;
|
|
6499
|
+
if (!items) {
|
|
6500
|
+
items = [];
|
|
6501
|
+
}
|
|
5939
6502
|
element.register = items;
|
|
5940
6503
|
for (const item of items) {
|
|
5941
6504
|
this.storeGenericItem(item);
|
|
@@ -6473,25 +7036,27 @@ var InterceptorRegistry = class {
|
|
|
6473
7036
|
* Gets all global task interceptors
|
|
6474
7037
|
*/
|
|
6475
7038
|
getGlobalTaskInterceptors() {
|
|
6476
|
-
return this.taskInterceptors;
|
|
7039
|
+
return Object.freeze([...this.taskInterceptors]);
|
|
6477
7040
|
}
|
|
6478
7041
|
/**
|
|
6479
7042
|
* Gets all global resource interceptors
|
|
6480
7043
|
*/
|
|
6481
7044
|
getGlobalResourceInterceptors() {
|
|
6482
|
-
return this.resourceInterceptors;
|
|
7045
|
+
return Object.freeze([...this.resourceInterceptors]);
|
|
6483
7046
|
}
|
|
6484
7047
|
/**
|
|
6485
7048
|
* Gets interceptors for a specific task middleware
|
|
6486
7049
|
*/
|
|
6487
7050
|
getTaskMiddlewareInterceptors(middlewareId) {
|
|
6488
|
-
|
|
7051
|
+
const interceptors = this.perTaskMiddleware.get(middlewareId) ?? [];
|
|
7052
|
+
return Object.freeze([...interceptors]);
|
|
6489
7053
|
}
|
|
6490
7054
|
/**
|
|
6491
7055
|
* Gets interceptors for a specific resource middleware
|
|
6492
7056
|
*/
|
|
6493
7057
|
getResourceMiddlewareInterceptors(middlewareId) {
|
|
6494
|
-
|
|
7058
|
+
const interceptors = this.perResourceMiddleware.get(middlewareId) ?? [];
|
|
7059
|
+
return Object.freeze([...interceptors]);
|
|
6495
7060
|
}
|
|
6496
7061
|
};
|
|
6497
7062
|
|
|
@@ -6970,10 +7535,8 @@ var ResourceMiddlewareComposer = class {
|
|
|
6970
7535
|
|
|
6971
7536
|
// src/models/MiddlewareManager.ts
|
|
6972
7537
|
var MiddlewareManager = class {
|
|
6973
|
-
constructor(store2,
|
|
7538
|
+
constructor(store2, _eventManager, _logger) {
|
|
6974
7539
|
this.store = store2;
|
|
6975
|
-
this.eventManager = eventManager;
|
|
6976
|
-
this.logger = logger;
|
|
6977
7540
|
this.interceptorRegistry = new InterceptorRegistry();
|
|
6978
7541
|
this.middlewareResolver = new MiddlewareResolver(store2);
|
|
6979
7542
|
this.taskComposer = new TaskMiddlewareComposer(
|
|
@@ -7014,14 +7577,6 @@ var MiddlewareManager = class {
|
|
|
7014
7577
|
lock() {
|
|
7015
7578
|
this.interceptorRegistry.lock();
|
|
7016
7579
|
}
|
|
7017
|
-
/**
|
|
7018
|
-
* Adds an interceptor for task or resource middleware execution
|
|
7019
|
-
* Interceptors are executed in the order they are added, with the ability to
|
|
7020
|
-
* modify, log, or prevent middleware execution
|
|
7021
|
-
*
|
|
7022
|
-
* @param kind - The type of middleware to intercept ("task" or "resource")
|
|
7023
|
-
* @param interceptor - The interceptor function to add
|
|
7024
|
-
*/
|
|
7025
7580
|
intercept(kind, interceptor) {
|
|
7026
7581
|
if (kind === "task") {
|
|
7027
7582
|
this.interceptorRegistry.addGlobalTaskInterceptor(
|
|
@@ -7033,13 +7588,6 @@ var MiddlewareManager = class {
|
|
|
7033
7588
|
);
|
|
7034
7589
|
}
|
|
7035
7590
|
}
|
|
7036
|
-
/**
|
|
7037
|
-
* Adds an interceptor for a specific middleware instance with better type safety
|
|
7038
|
-
* This method automatically determines the type and provides type-safe access
|
|
7039
|
-
*
|
|
7040
|
-
* @param middleware - The middleware instance to intercept
|
|
7041
|
-
* @param interceptor - The interceptor function with proper typing
|
|
7042
|
-
*/
|
|
7043
7591
|
interceptMiddleware(middleware, interceptor) {
|
|
7044
7592
|
if (isTaskMiddleware(middleware)) {
|
|
7045
7593
|
this.interceptorRegistry.addTaskMiddlewareInterceptor(
|
|
@@ -7178,12 +7726,17 @@ var Store = class {
|
|
|
7178
7726
|
}
|
|
7179
7727
|
}
|
|
7180
7728
|
registerGlobalComponents() {
|
|
7729
|
+
if (!this.taskRunner) {
|
|
7730
|
+
throw new Error(
|
|
7731
|
+
"TaskRunner is not set. Call store.setTaskRunner() before initializeStore()."
|
|
7732
|
+
);
|
|
7733
|
+
}
|
|
7181
7734
|
const builtInResourcesMap = /* @__PURE__ */ new Map();
|
|
7182
7735
|
builtInResourcesMap.set(globalResources.store, this);
|
|
7183
7736
|
builtInResourcesMap.set(globalResources.eventManager, this.eventManager);
|
|
7184
7737
|
builtInResourcesMap.set(globalResources.logger, this.logger);
|
|
7185
7738
|
builtInResourcesMap.set(globalResources.taskRunner, this.taskRunner);
|
|
7186
|
-
builtInResourcesMap.set(globalResources.serializer,
|
|
7739
|
+
builtInResourcesMap.set(globalResources.serializer, new Serializer());
|
|
7187
7740
|
builtInResourcesMap.set(
|
|
7188
7741
|
globalResources.middlewareManager,
|
|
7189
7742
|
this.middlewareManager
|
|
@@ -7243,8 +7796,11 @@ var Store = class {
|
|
|
7243
7796
|
setTaskRunner(taskRunner) {
|
|
7244
7797
|
this.taskRunner = taskRunner;
|
|
7245
7798
|
}
|
|
7246
|
-
setupRootResource(
|
|
7247
|
-
root
|
|
7799
|
+
setupRootResource(rootDefinition, config) {
|
|
7800
|
+
const root = {
|
|
7801
|
+
...rootDefinition,
|
|
7802
|
+
dependencies: typeof rootDefinition.dependencies === "function" ? rootDefinition.dependencies(config) : rootDefinition.dependencies
|
|
7803
|
+
};
|
|
7248
7804
|
this.root = {
|
|
7249
7805
|
resource: root,
|
|
7250
7806
|
computedDependencies: {},
|
|
@@ -7797,6 +8353,18 @@ var RunResult = class {
|
|
|
7797
8353
|
}
|
|
7798
8354
|
return this.store.resources.get(resourceId).value;
|
|
7799
8355
|
}, "getResourceValue");
|
|
8356
|
+
/**
|
|
8357
|
+
* Get the config of a resource from the run result.
|
|
8358
|
+
* @param resource - The resource to get the config of.
|
|
8359
|
+
* @returns The config passed for the resource.
|
|
8360
|
+
*/
|
|
8361
|
+
this.getResourceConfig = /* @__PURE__ */ __name((resource2) => {
|
|
8362
|
+
const resourceId = typeof resource2 === "string" ? resource2 : resource2.id;
|
|
8363
|
+
if (!this.store.resources.has(resourceId)) {
|
|
8364
|
+
throw new Error(`Resource "${resourceId}" not found.`);
|
|
8365
|
+
}
|
|
8366
|
+
return this.store.resources.get(resourceId).config;
|
|
8367
|
+
}, "getResourceConfig");
|
|
7800
8368
|
this.dispose = /* @__PURE__ */ __name(() => {
|
|
7801
8369
|
return this.disposeFn();
|
|
7802
8370
|
}, "dispose");
|
|
@@ -8977,7 +9545,7 @@ function makeAsyncContextBuilder(state) {
|
|
|
8977
9545
|
configSchema: state.configSchema,
|
|
8978
9546
|
meta: state.meta
|
|
8979
9547
|
};
|
|
8980
|
-
return defineAsyncContext(def);
|
|
9548
|
+
return defineAsyncContext(def, state.filePath);
|
|
8981
9549
|
}
|
|
8982
9550
|
};
|
|
8983
9551
|
return builder;
|
|
@@ -8986,8 +9554,10 @@ __name(makeAsyncContextBuilder, "makeAsyncContextBuilder");
|
|
|
8986
9554
|
|
|
8987
9555
|
// src/definers/builders/asyncContext/index.ts
|
|
8988
9556
|
function asyncContextBuilder(id2) {
|
|
9557
|
+
const filePath = getCallerFile();
|
|
8989
9558
|
const initial = Object.freeze({
|
|
8990
9559
|
id: id2,
|
|
9560
|
+
filePath,
|
|
8991
9561
|
serialize: void 0,
|
|
8992
9562
|
parse: void 0,
|
|
8993
9563
|
configSchema: void 0,
|
|
@@ -9460,7 +10030,7 @@ function override(base) {
|
|
|
9460
10030
|
}
|
|
9461
10031
|
__name(override, "override");
|
|
9462
10032
|
|
|
9463
|
-
// src/
|
|
10033
|
+
// src/public.ts
|
|
9464
10034
|
var globals = {
|
|
9465
10035
|
events: globalEvents,
|
|
9466
10036
|
resources: globalResources,
|
|
@@ -9485,6 +10055,6 @@ var r = Object.freeze({
|
|
|
9485
10055
|
})
|
|
9486
10056
|
});
|
|
9487
10057
|
|
|
9488
|
-
export { DependencyProcessor, errors_exports as Errors, EventManager, Logger, MiddlewareManager, PlatformAdapter, Queue, ResourceInitializer, RunResult, Semaphore, Serializer, Store, TaskRunner, allFalse, defineAsyncContext as asyncContext, bindProcessErrorHandler, createContext2 as createContext, createDefaultUnhandledError, createExposureFetch, createHttpClient, createTestResource, debug, debugLevels, defs_exports as definitions, defineEvent as event, getConfig,
|
|
10058
|
+
export { DependencyProcessor, errors_exports as Errors, EventManager, LogPrinter, Logger, MiddlewareManager, PlatformAdapter, Queue, ResourceInitializer, RunResult, Semaphore, Serializer, Store, SymbolPolicy, SymbolPolicyErrorMessage, TaskRunner, allFalse, defineAsyncContext as asyncContext, bindProcessErrorHandler, createContext2 as createContext, createDefaultUnhandledError, createExposureFetch, createHttpClient, createTestResource, debug, debugLevels, defs_exports as definitions, defineEvent as event, getConfig, globals, defineHook as hook, journal, levelNormal, levelVerbose, normalizeError, defineOverride as override, r, defineResource as resource, defineResourceMiddleware as resourceMiddleware, run, safeReportUnhandledError, setPlatform, defineTag as tag, defineTask as task, defineTaskMiddleware as taskMiddleware };
|
|
9489
10059
|
//# sourceMappingURL=index.mjs.map
|
|
9490
10060
|
//# sourceMappingURL=index.mjs.map
|