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