@sentry/cloudflare 10.69.0 → 11.0.0-alpha.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 +3 -7
- package/build/cjs/{sdk.js → dev/baseSdk.js} +27 -17
- package/build/cjs/dev/baseSdk.js.map +1 -0
- package/build/cjs/dev/client.js.map +1 -0
- package/build/cjs/dev/debug-build.js.map +1 -0
- package/build/cjs/dev/defineCloudflareOptions.js.map +1 -0
- package/build/cjs/dev/durableobject.js +234 -0
- package/build/cjs/dev/durableobject.js.map +1 -0
- package/build/cjs/dev/flush.js.map +1 -0
- package/build/cjs/{index.js → dev/index.js} +15 -17
- package/build/cjs/{index.js.map → dev/index.js.map} +1 -1
- package/build/cjs/dev/instrument.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/agents/index.js +2 -0
- package/build/cjs/dev/instrumentations/agents/index.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +2 -2
- package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +3 -3
- package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/cjs/dev/instrumentations/agents/types.js +77 -0
- package/build/cjs/dev/instrumentations/agents/types.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +3 -3
- package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +0 -4
- package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
- package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
- package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +9 -3
- package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +3 -2
- package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
- package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/cjs/{integrations → dev/integrations}/fetch.js +1 -1
- package/build/cjs/dev/integrations/fetch.js.map +1 -0
- package/build/cjs/{integrations → dev/integrations}/httpServer.js +5 -4
- package/build/cjs/dev/integrations/httpServer.js.map +1 -0
- package/build/cjs/dev/integrations/spotlight.js.map +1 -0
- package/build/cjs/{nodejs_compat → dev}/integrations/tracing/vercelai.js +6 -6
- package/build/cjs/dev/integrations/tracing/vercelai.js.map +1 -0
- package/build/cjs/dev/opentelemetry/tracer.js.map +1 -0
- package/build/cjs/{options.js → dev/options.js} +8 -0
- package/build/cjs/dev/options.js.map +1 -0
- package/build/cjs/{pages-plugin.js → dev/pages-plugin.js} +8 -3
- package/build/cjs/dev/pages-plugin.js.map +1 -0
- package/build/cjs/{request.js → dev/request.js} +23 -12
- package/build/cjs/dev/request.js.map +1 -0
- package/build/cjs/dev/scope-utils.js.map +1 -0
- package/build/cjs/dev/sdk.js +19 -0
- package/build/cjs/dev/sdk.js.map +1 -0
- package/build/cjs/dev/transport.js.map +1 -0
- package/build/cjs/{utils → dev/utils}/instrumentContext.js +8 -13
- package/build/cjs/dev/utils/instrumentContext.js.map +1 -0
- package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -0
- package/build/cjs/dev/utils/internalStorageKey.js.map +1 -0
- package/build/cjs/dev/utils/invocationScope.js +12 -0
- package/build/cjs/dev/utils/invocationScope.js.map +1 -0
- package/build/cjs/dev/utils/isBinding.js.map +1 -0
- package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -0
- package/build/cjs/{utils → dev/utils}/rpcMeta.js +4 -0
- package/build/cjs/dev/utils/rpcMeta.js.map +1 -0
- package/build/cjs/dev/utils/streaming.js.map +1 -0
- package/build/cjs/dev/utils/traceLinks.js.map +1 -0
- package/build/cjs/dev/vendor/stacktrace.js.map +1 -0
- package/build/cjs/dev/vite/agentClass.js.map +1 -0
- package/build/cjs/dev/vite/autoInstrument.js.map +1 -0
- package/build/cjs/{vite → dev/vite}/index.js +3 -1
- package/build/cjs/dev/vite/index.js.map +1 -0
- package/build/cjs/dev/vite/instrumentFile.js.map +1 -0
- package/build/cjs/dev/vite/moduleShape.js.map +1 -0
- package/build/cjs/dev/vite/transform.js.map +1 -0
- package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -0
- package/build/cjs/dev/vite/wranglerConfig.js.map +1 -0
- package/build/cjs/{withSentry.js → dev/withSentry.js} +2 -19
- package/build/cjs/dev/withSentry.js.map +1 -0
- package/build/cjs/{workflows.js → dev/workflows.js} +9 -4
- package/build/cjs/dev/workflows.js.map +1 -0
- package/build/cjs/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +2 -3
- package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -0
- package/build/cjs/prod/baseSdk.js +73 -0
- package/build/cjs/prod/baseSdk.js.map +1 -0
- package/build/cjs/prod/client.js +122 -0
- package/build/cjs/prod/client.js.map +1 -0
- package/build/cjs/prod/debug-build.js +6 -0
- package/build/cjs/prod/debug-build.js.map +1 -0
- package/build/cjs/prod/defineCloudflareOptions.js +11 -0
- package/build/cjs/prod/defineCloudflareOptions.js.map +1 -0
- package/build/cjs/prod/durableobject.js +234 -0
- package/build/cjs/prod/durableobject.js.map +1 -0
- package/build/cjs/prod/flush.js +87 -0
- package/build/cjs/prod/flush.js.map +1 -0
- package/build/cjs/{nodejs_compat → prod}/index.js +33 -37
- package/build/cjs/{nodejs_compat → prod}/index.js.map +1 -1
- package/build/cjs/prod/instrument.js +52 -0
- package/build/cjs/prod/instrument.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/index.js +16 -0
- package/build/cjs/prod/instrumentations/agents/index.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/types.js +77 -0
- package/build/cjs/prod/instrumentations/agents/types.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +41 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +72 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +40 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +42 -0
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +139 -0
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js +161 -0
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +90 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +54 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +24 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +82 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +80 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js +124 -0
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +29 -0
- package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +78 -0
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js +60 -0
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/cjs/prod/integrations/fetch.js +119 -0
- package/build/cjs/prod/integrations/fetch.js.map +1 -0
- package/build/cjs/prod/integrations/httpServer.js +36 -0
- package/build/cjs/prod/integrations/httpServer.js.map +1 -0
- package/build/cjs/prod/integrations/spotlight.js +64 -0
- package/build/cjs/prod/integrations/spotlight.js.map +1 -0
- package/build/cjs/{integrations → prod/integrations}/tracing/vercelai.js +5 -5
- package/build/cjs/prod/integrations/tracing/vercelai.js.map +1 -0
- package/build/cjs/prod/opentelemetry/tracer.js +49 -0
- package/build/cjs/prod/opentelemetry/tracer.js.map +1 -0
- package/build/cjs/prod/options.js +33 -0
- package/build/cjs/prod/options.js.map +1 -0
- package/build/cjs/prod/pages-plugin.js +24 -0
- package/build/cjs/prod/pages-plugin.js.map +1 -0
- package/build/cjs/prod/request.js +132 -0
- package/build/cjs/prod/request.js.map +1 -0
- package/build/cjs/prod/scope-utils.js +22 -0
- package/build/cjs/prod/scope-utils.js.map +1 -0
- package/build/cjs/prod/sdk.js +19 -0
- package/build/cjs/prod/sdk.js.map +1 -0
- package/build/cjs/prod/transport.js +75 -0
- package/build/cjs/prod/transport.js.map +1 -0
- package/build/cjs/prod/utils/instrumentContext.js +63 -0
- package/build/cjs/prod/utils/instrumentContext.js.map +1 -0
- package/build/cjs/prod/utils/internalSqlQuery.js +25 -0
- package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -0
- package/build/cjs/prod/utils/internalStorageKey.js +44 -0
- package/build/cjs/prod/utils/internalStorageKey.js.map +1 -0
- package/build/cjs/prod/utils/invocationScope.js +12 -0
- package/build/cjs/prod/utils/invocationScope.js.map +1 -0
- package/build/cjs/prod/utils/isBinding.js +37 -0
- package/build/cjs/prod/utils/isBinding.js.map +1 -0
- package/build/cjs/prod/utils/isCloudflareClass.js +23 -0
- package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -0
- package/build/cjs/prod/utils/rpcMeta.js +39 -0
- package/build/cjs/prod/utils/rpcMeta.js.map +1 -0
- package/build/cjs/prod/utils/streaming.js +16 -0
- package/build/cjs/prod/utils/streaming.js.map +1 -0
- package/build/cjs/prod/utils/traceLinks.js +54 -0
- package/build/cjs/prod/utils/traceLinks.js.map +1 -0
- package/build/cjs/prod/vendor/stacktrace.js +28 -0
- package/build/cjs/prod/vendor/stacktrace.js.map +1 -0
- package/build/cjs/prod/vite/agentClass.js +114 -0
- package/build/cjs/prod/vite/agentClass.js.map +1 -0
- package/build/cjs/prod/vite/autoInstrument.js +94 -0
- package/build/cjs/prod/vite/autoInstrument.js.map +1 -0
- package/build/cjs/prod/vite/index.js +16 -0
- package/build/cjs/prod/vite/index.js.map +1 -0
- package/build/cjs/prod/vite/instrumentFile.js +31 -0
- package/build/cjs/prod/vite/instrumentFile.js.map +1 -0
- package/build/cjs/prod/vite/moduleShape.js +231 -0
- package/build/cjs/prod/vite/moduleShape.js.map +1 -0
- package/build/cjs/prod/vite/transform.js +149 -0
- package/build/cjs/prod/vite/transform.js.map +1 -0
- package/build/cjs/prod/vite/workerEntrypoint.js +66 -0
- package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -0
- package/build/cjs/prod/vite/wranglerConfig.js +54 -0
- package/build/cjs/prod/vite/wranglerConfig.js.map +1 -0
- package/build/cjs/prod/withSentry.js +29 -0
- package/build/cjs/prod/withSentry.js.map +1 -0
- package/build/cjs/prod/workflows.js +139 -0
- package/build/cjs/prod/workflows.js.map +1 -0
- package/build/cjs/prod/wrapMethodWithSentry.js +134 -0
- package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -0
- package/build/esm/{sdk.js → dev/baseSdk.js} +26 -17
- package/build/esm/dev/baseSdk.js.map +1 -0
- package/build/esm/dev/client.js.map +1 -0
- package/build/esm/dev/debug-build.js.map +1 -0
- package/build/esm/dev/defineCloudflareOptions.js.map +1 -0
- package/build/esm/dev/durableobject.js +229 -0
- package/build/esm/dev/durableobject.js.map +1 -0
- package/build/esm/dev/flush.js.map +1 -0
- package/build/esm/dev/index.js +15 -0
- package/build/esm/{index.js.map → dev/index.js.map} +1 -1
- package/build/esm/dev/instrument.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/agents/index.js +2 -0
- package/build/esm/dev/instrumentations/agents/index.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +2 -2
- package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +4 -4
- package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/esm/dev/instrumentations/agents/types.js +69 -0
- package/build/esm/dev/instrumentations/agents/types.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +2 -2
- package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +1 -4
- package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
- package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
- package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +10 -4
- package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +4 -3
- package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
- package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/esm/{integrations → dev/integrations}/fetch.js +1 -1
- package/build/esm/dev/integrations/fetch.js.map +1 -0
- package/build/esm/{integrations → dev/integrations}/httpServer.js +5 -4
- package/build/esm/dev/integrations/httpServer.js.map +1 -0
- package/build/esm/dev/integrations/spotlight.js.map +1 -0
- package/build/esm/{integrations → dev/integrations}/tracing/vercelai.js +5 -5
- package/build/esm/dev/integrations/tracing/vercelai.js.map +1 -0
- package/build/esm/dev/opentelemetry/tracer.js.map +1 -0
- package/build/esm/{options.js → dev/options.js} +8 -0
- package/build/esm/dev/options.js.map +1 -0
- package/build/esm/dev/package.json +1 -0
- package/build/esm/{pages-plugin.js → dev/pages-plugin.js} +8 -3
- package/build/esm/dev/pages-plugin.js.map +1 -0
- package/build/esm/{request.js → dev/request.js} +24 -14
- package/build/esm/dev/request.js.map +1 -0
- package/build/esm/dev/scope-utils.js.map +1 -0
- package/build/esm/dev/sdk.js +16 -0
- package/build/esm/dev/sdk.js.map +1 -0
- package/build/esm/dev/transport.js.map +1 -0
- package/build/esm/{utils → dev/utils}/instrumentContext.js +8 -13
- package/build/esm/dev/utils/instrumentContext.js.map +1 -0
- package/build/esm/dev/utils/internalSqlQuery.js.map +1 -0
- package/build/esm/dev/utils/internalStorageKey.js.map +1 -0
- package/build/esm/dev/utils/invocationScope.js +10 -0
- package/build/esm/dev/utils/invocationScope.js.map +1 -0
- package/build/esm/dev/utils/isBinding.js.map +1 -0
- package/build/esm/dev/utils/isCloudflareClass.js.map +1 -0
- package/build/esm/{utils → dev/utils}/rpcMeta.js +4 -1
- package/build/esm/dev/utils/rpcMeta.js.map +1 -0
- package/build/esm/dev/utils/streaming.js.map +1 -0
- package/build/esm/{utils → dev/utils}/traceLinks.js +1 -1
- package/build/esm/dev/utils/traceLinks.js.map +1 -0
- package/build/esm/dev/vendor/stacktrace.js.map +1 -0
- package/build/esm/dev/vite/agentClass.js.map +1 -0
- package/build/esm/dev/vite/autoInstrument.js.map +1 -0
- package/build/esm/{vite → dev/vite}/index.js +3 -1
- package/build/esm/dev/vite/index.js.map +1 -0
- package/build/esm/dev/vite/instrumentFile.js.map +1 -0
- package/build/esm/dev/vite/moduleShape.js.map +1 -0
- package/build/esm/dev/vite/transform.js.map +1 -0
- package/build/esm/dev/vite/workerEntrypoint.js.map +1 -0
- package/build/esm/dev/vite/wranglerConfig.js.map +1 -0
- package/build/esm/{withSentry.js → dev/withSentry.js} +1 -18
- package/build/esm/dev/withSentry.js.map +1 -0
- package/build/esm/{workflows.js → dev/workflows.js} +9 -4
- package/build/esm/dev/workflows.js.map +1 -0
- package/build/esm/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +3 -4
- package/build/esm/dev/wrapMethodWithSentry.js.map +1 -0
- package/build/esm/prod/baseSdk.js +69 -0
- package/build/esm/prod/baseSdk.js.map +1 -0
- package/build/esm/prod/client.js +120 -0
- package/build/esm/prod/client.js.map +1 -0
- package/build/esm/prod/debug-build.js +4 -0
- package/build/esm/prod/debug-build.js.map +1 -0
- package/build/esm/prod/defineCloudflareOptions.js +9 -0
- package/build/esm/prod/defineCloudflareOptions.js.map +1 -0
- package/build/esm/prod/durableobject.js +229 -0
- package/build/esm/prod/durableobject.js.map +1 -0
- package/build/esm/prod/flush.js +83 -0
- package/build/esm/prod/flush.js.map +1 -0
- package/build/esm/prod/index.js +15 -0
- package/build/esm/{nodejs_compat → prod}/index.js.map +1 -1
- package/build/esm/prod/instrument.js +48 -0
- package/build/esm/prod/instrument.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/index.js +14 -0
- package/build/esm/prod/instrumentations/agents/index.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/types.js +69 -0
- package/build/esm/prod/instrumentations/agents/types.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +38 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +38 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js +40 -0
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +137 -0
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentD1.js +159 -0
- package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js +61 -0
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js +88 -0
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js +51 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +22 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js +79 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +78 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentR2.js +122 -0
- package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +27 -0
- package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +75 -0
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentTail.js +57 -0
- package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/esm/prod/integrations/fetch.js +117 -0
- package/build/esm/prod/integrations/fetch.js.map +1 -0
- package/build/esm/prod/integrations/httpServer.js +33 -0
- package/build/esm/prod/integrations/httpServer.js.map +1 -0
- package/build/esm/prod/integrations/spotlight.js +61 -0
- package/build/esm/prod/integrations/spotlight.js.map +1 -0
- package/build/esm/prod/integrations/tracing/vercelai.js +16 -0
- package/build/esm/prod/integrations/tracing/vercelai.js.map +1 -0
- package/build/esm/prod/opentelemetry/tracer.js +47 -0
- package/build/esm/prod/opentelemetry/tracer.js.map +1 -0
- package/build/esm/prod/options.js +31 -0
- package/build/esm/prod/options.js.map +1 -0
- package/build/esm/prod/package.json +1 -0
- package/build/esm/prod/pages-plugin.js +22 -0
- package/build/esm/prod/pages-plugin.js.map +1 -0
- package/build/esm/prod/request.js +129 -0
- package/build/esm/prod/request.js.map +1 -0
- package/build/esm/prod/scope-utils.js +18 -0
- package/build/esm/prod/scope-utils.js.map +1 -0
- package/build/esm/prod/sdk.js +16 -0
- package/build/esm/prod/sdk.js.map +1 -0
- package/build/esm/prod/transport.js +72 -0
- package/build/esm/prod/transport.js.map +1 -0
- package/build/esm/prod/utils/instrumentContext.js +61 -0
- package/build/esm/prod/utils/instrumentContext.js.map +1 -0
- package/build/esm/prod/utils/internalSqlQuery.js +23 -0
- package/build/esm/prod/utils/internalSqlQuery.js.map +1 -0
- package/build/esm/prod/utils/internalStorageKey.js +41 -0
- package/build/esm/prod/utils/internalStorageKey.js.map +1 -0
- package/build/esm/prod/utils/invocationScope.js +10 -0
- package/build/esm/prod/utils/invocationScope.js.map +1 -0
- package/build/esm/prod/utils/isBinding.js +29 -0
- package/build/esm/prod/utils/isBinding.js.map +1 -0
- package/build/esm/prod/utils/isCloudflareClass.js +21 -0
- package/build/esm/prod/utils/isCloudflareClass.js.map +1 -0
- package/build/esm/prod/utils/rpcMeta.js +35 -0
- package/build/esm/prod/utils/rpcMeta.js.map +1 -0
- package/build/esm/prod/utils/streaming.js +14 -0
- package/build/esm/prod/utils/streaming.js.map +1 -0
- package/build/esm/prod/utils/traceLinks.js +49 -0
- package/build/esm/prod/utils/traceLinks.js.map +1 -0
- package/build/esm/prod/vendor/stacktrace.js +25 -0
- package/build/esm/prod/vendor/stacktrace.js.map +1 -0
- package/build/esm/prod/vite/agentClass.js +111 -0
- package/build/esm/prod/vite/agentClass.js.map +1 -0
- package/build/esm/prod/vite/autoInstrument.js +92 -0
- package/build/esm/prod/vite/autoInstrument.js.map +1 -0
- package/build/esm/prod/vite/index.js +14 -0
- package/build/esm/prod/vite/index.js.map +1 -0
- package/build/esm/prod/vite/instrumentFile.js +27 -0
- package/build/esm/prod/vite/instrumentFile.js.map +1 -0
- package/build/esm/prod/vite/moduleShape.js +227 -0
- package/build/esm/prod/vite/moduleShape.js.map +1 -0
- package/build/esm/prod/vite/transform.js +147 -0
- package/build/esm/prod/vite/transform.js.map +1 -0
- package/build/esm/prod/vite/workerEntrypoint.js +64 -0
- package/build/esm/prod/vite/workerEntrypoint.js.map +1 -0
- package/build/esm/prod/vite/wranglerConfig.js +52 -0
- package/build/esm/prod/vite/wranglerConfig.js.map +1 -0
- package/build/esm/prod/withSentry.js +27 -0
- package/build/esm/prod/withSentry.js.map +1 -0
- package/build/esm/prod/workflows.js +136 -0
- package/build/esm/prod/workflows.js.map +1 -0
- package/build/esm/prod/wrapMethodWithSentry.js +132 -0
- package/build/esm/prod/wrapMethodWithSentry.js.map +1 -0
- package/build/types/baseSdk.d.ts +28 -0
- package/build/types/baseSdk.d.ts.map +1 -0
- package/build/types/client.d.ts +12 -39
- package/build/types/client.d.ts.map +1 -1
- package/build/types/defineCloudflareOptions.d.ts +2 -2
- package/build/types/defineCloudflareOptions.d.ts.map +1 -1
- package/build/types/durableobject.d.ts +22 -12
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/flush.d.ts +1 -1
- package/build/types/flush.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -5
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/agents/index.d.ts +4 -3
- package/build/types/instrumentations/agents/index.d.ts.map +1 -1
- package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts +4 -1
- package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -1
- package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
- package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts.map +1 -0
- package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts +10 -9
- package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts.map +1 -1
- package/build/types/instrumentations/agents/types.d.ts +63 -18
- package/build/types/instrumentations/agents/types.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -1
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentD1.d.ts +0 -16
- package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentFetch.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentQueue.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentTail.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
- package/build/types/integrations/httpServer.d.ts.map +1 -1
- package/build/types/integrations/spotlight.d.ts +1 -1
- package/build/types/integrations/tracing/vercelai.d.ts +2 -9
- package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
- package/build/types/options.d.ts.map +1 -1
- package/build/types/pages-plugin.d.ts +1 -1
- package/build/types/pages-plugin.d.ts.map +1 -1
- package/build/types/request.d.ts +17 -2
- package/build/types/request.d.ts.map +1 -1
- package/build/types/sdk.d.ts +8 -3
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/transport.d.ts.map +1 -1
- package/build/types/types.d.ts +85 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils/instrumentContext.d.ts.map +1 -1
- package/build/types/utils/invocationScope.d.ts +24 -0
- package/build/types/utils/invocationScope.d.ts.map +1 -0
- package/build/types/utils/isCloudflareClass.d.ts +1 -1
- package/build/types/utils/isCloudflareClass.d.ts.map +1 -1
- package/build/types/utils/rpcMeta.d.ts +8 -0
- package/build/types/utils/rpcMeta.d.ts.map +1 -1
- package/build/types/vite/autoInstrument.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +20 -44
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/withSentry.d.ts +2 -2
- package/build/types/withSentry.d.ts.map +1 -1
- package/build/types/workflows.d.ts +5 -4
- package/build/types/workflows.d.ts.map +1 -1
- package/build/types/wrapMethodWithSentry.d.ts +1 -1
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/package.json +28 -51
- package/build/cjs/async.js +0 -63
- package/build/cjs/async.js.map +0 -1
- package/build/cjs/client.js.map +0 -1
- package/build/cjs/debug-build.js.map +0 -1
- package/build/cjs/defineCloudflareOptions.js.map +0 -1
- package/build/cjs/durableobject.js +0 -155
- package/build/cjs/durableobject.js.map +0 -1
- package/build/cjs/flush.js.map +0 -1
- package/build/cjs/instrument.js.map +0 -1
- package/build/cjs/instrumentations/agents/index.js.map +0 -1
- package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
- package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
- package/build/cjs/instrumentations/agents/types.js +0 -32
- package/build/cjs/instrumentations/agents/types.js.map +0 -1
- package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
- package/build/cjs/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js.map +0 -1
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentD1.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentEmail.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentEnv.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentFetch.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentQueue.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentR2.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentRateLimit.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentTail.js.map +0 -1
- package/build/cjs/integrations/fetch.js.map +0 -1
- package/build/cjs/integrations/hono.js +0 -52
- package/build/cjs/integrations/hono.js.map +0 -1
- package/build/cjs/integrations/httpServer.js.map +0 -1
- package/build/cjs/integrations/spotlight.js.map +0 -1
- package/build/cjs/integrations/tracing/vercelai.js.map +0 -1
- package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
- package/build/cjs/opentelemetry/tracer.js.map +0 -1
- package/build/cjs/options.js.map +0 -1
- package/build/cjs/pages-plugin.js.map +0 -1
- package/build/cjs/request.js.map +0 -1
- package/build/cjs/scope-utils.js.map +0 -1
- package/build/cjs/sdk.js.map +0 -1
- package/build/cjs/transport.js.map +0 -1
- package/build/cjs/utils/instrumentContext.js.map +0 -1
- package/build/cjs/utils/internalSqlQuery.js.map +0 -1
- package/build/cjs/utils/internalStorageKey.js.map +0 -1
- package/build/cjs/utils/isBinding.js.map +0 -1
- package/build/cjs/utils/isCloudflareClass.js.map +0 -1
- package/build/cjs/utils/rpcMeta.js.map +0 -1
- package/build/cjs/utils/rpcOptions.js +0 -26
- package/build/cjs/utils/rpcOptions.js.map +0 -1
- package/build/cjs/utils/streaming.js.map +0 -1
- package/build/cjs/utils/traceLinks.js.map +0 -1
- package/build/cjs/vendor/stacktrace.js.map +0 -1
- package/build/cjs/vite/agentClass.js.map +0 -1
- package/build/cjs/vite/autoInstrument.js.map +0 -1
- package/build/cjs/vite/index.js.map +0 -1
- package/build/cjs/vite/instrumentFile.js.map +0 -1
- package/build/cjs/vite/moduleShape.js.map +0 -1
- package/build/cjs/vite/transform.js.map +0 -1
- package/build/cjs/vite/workerEntrypoint.js.map +0 -1
- package/build/cjs/vite/wranglerConfig.js.map +0 -1
- package/build/cjs/withSentry.js.map +0 -1
- package/build/cjs/workflows.js.map +0 -1
- package/build/cjs/wrapMethodWithSentry.js.map +0 -1
- package/build/esm/async.js +0 -61
- package/build/esm/async.js.map +0 -1
- package/build/esm/client.js.map +0 -1
- package/build/esm/debug-build.js.map +0 -1
- package/build/esm/defineCloudflareOptions.js.map +0 -1
- package/build/esm/durableobject.js +0 -150
- package/build/esm/durableobject.js.map +0 -1
- package/build/esm/flush.js.map +0 -1
- package/build/esm/index.js +0 -17
- package/build/esm/instrument.js.map +0 -1
- package/build/esm/instrumentations/agents/index.js.map +0 -1
- package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
- package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
- package/build/esm/instrumentations/agents/types.js +0 -26
- package/build/esm/instrumentations/agents/types.js.map +0 -1
- package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
- package/build/esm/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js.map +0 -1
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentD1.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentEmail.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentEnv.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentFetch.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentFetcher.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentQueue.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentR2.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentRateLimit.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentScheduled.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentTail.js.map +0 -1
- package/build/esm/integrations/fetch.js.map +0 -1
- package/build/esm/integrations/hono.js +0 -49
- package/build/esm/integrations/hono.js.map +0 -1
- package/build/esm/integrations/httpServer.js.map +0 -1
- package/build/esm/integrations/spotlight.js.map +0 -1
- package/build/esm/integrations/tracing/vercelai.js.map +0 -1
- package/build/esm/nodejs_compat/index.js +0 -18
- package/build/esm/nodejs_compat/integrations/tracing/vercelai.js +0 -16
- package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
- package/build/esm/opentelemetry/tracer.js.map +0 -1
- package/build/esm/options.js.map +0 -1
- package/build/esm/package.json +0 -1
- package/build/esm/pages-plugin.js.map +0 -1
- package/build/esm/request.js.map +0 -1
- package/build/esm/scope-utils.js.map +0 -1
- package/build/esm/sdk.js.map +0 -1
- package/build/esm/transport.js.map +0 -1
- package/build/esm/utils/instrumentContext.js.map +0 -1
- package/build/esm/utils/internalSqlQuery.js.map +0 -1
- package/build/esm/utils/internalStorageKey.js.map +0 -1
- package/build/esm/utils/isBinding.js.map +0 -1
- package/build/esm/utils/isCloudflareClass.js.map +0 -1
- package/build/esm/utils/rpcMeta.js.map +0 -1
- package/build/esm/utils/rpcOptions.js +0 -24
- package/build/esm/utils/rpcOptions.js.map +0 -1
- package/build/esm/utils/streaming.js.map +0 -1
- package/build/esm/utils/traceLinks.js.map +0 -1
- package/build/esm/vendor/stacktrace.js.map +0 -1
- package/build/esm/vite/agentClass.js.map +0 -1
- package/build/esm/vite/autoInstrument.js.map +0 -1
- package/build/esm/vite/index.js.map +0 -1
- package/build/esm/vite/instrumentFile.js.map +0 -1
- package/build/esm/vite/moduleShape.js.map +0 -1
- package/build/esm/vite/transform.js.map +0 -1
- package/build/esm/vite/workerEntrypoint.js.map +0 -1
- package/build/esm/vite/wranglerConfig.js.map +0 -1
- package/build/esm/withSentry.js.map +0 -1
- package/build/esm/workflows.js.map +0 -1
- package/build/esm/wrapMethodWithSentry.js.map +0 -1
- package/build/types/async.d.ts +0 -11
- package/build/types/async.d.ts.map +0 -1
- package/build/types/integrations/hono.d.ts +0 -42
- package/build/types/integrations/hono.d.ts.map +0 -1
- package/build/types/nodejs_compat/index.d.ts +0 -4
- package/build/types/nodejs_compat/index.d.ts.map +0 -1
- package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
- package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +0 -1
- package/build/types/utils/rpcOptions.d.ts +0 -13
- package/build/types/utils/rpcOptions.d.ts.map +0 -1
- package/build/types-ts3.8/async.d.ts +0 -11
- package/build/types-ts3.8/client.d.ts +0 -203
- package/build/types-ts3.8/debug-build.d.ts +0 -7
- package/build/types-ts3.8/defineCloudflareOptions.d.ts +0 -38
- package/build/types-ts3.8/durableobject.d.ts +0 -118
- package/build/types-ts3.8/executionContext.d.ts +0 -13
- package/build/types-ts3.8/flush.d.ts +0 -47
- package/build/types-ts3.8/index.d.ts +0 -19
- package/build/types-ts3.8/instrument.d.ts +0 -20
- package/build/types-ts3.8/instrumentations/agents/index.d.ts +0 -24
- package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +0 -11
- package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +0 -22
- package/build/types-ts3.8/instrumentations/agents/types.d.ts +0 -49
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +0 -13
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +0 -19
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectSyncKvStorage.d.ts +0 -3
- package/build/types-ts3.8/instrumentations/instrumentSqlStorage.d.ts +0 -9
- package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +0 -42
- package/build/types-ts3.8/instrumentations/worker/instrumentD1.d.ts +0 -19
- package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +0 -8
- package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +0 -18
- package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +0 -12
- package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +0 -10
- package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +0 -12
- package/build/types-ts3.8/instrumentations/worker/instrumentQueueProducer.d.ts +0 -10
- package/build/types-ts3.8/instrumentations/worker/instrumentR2.d.ts +0 -9
- package/build/types-ts3.8/instrumentations/worker/instrumentRateLimit.d.ts +0 -6
- package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +0 -12
- package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +0 -12
- package/build/types-ts3.8/integrations/fetch.d.ts +0 -19
- package/build/types-ts3.8/integrations/hono.d.ts +0 -42
- package/build/types-ts3.8/integrations/httpServer.d.ts +0 -63
- package/build/types-ts3.8/integrations/spotlight.d.ts +0 -22
- package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +0 -47
- package/build/types-ts3.8/nodejs_compat/index.d.ts +0 -4
- package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
- package/build/types-ts3.8/opentelemetry/tracer.d.ts +0 -6
- package/build/types-ts3.8/options.d.ts +0 -17
- package/build/types-ts3.8/pages-plugin.d.ts +0 -34
- package/build/types-ts3.8/request.d.ts +0 -25
- package/build/types-ts3.8/scope-utils.d.ts +0 -15
- package/build/types-ts3.8/sdk.d.ts +0 -10
- package/build/types-ts3.8/transport.d.ts +0 -34
- package/build/types-ts3.8/utils/instrumentContext.d.ts +0 -16
- package/build/types-ts3.8/utils/internalSqlQuery.d.ts +0 -20
- package/build/types-ts3.8/utils/internalStorageKey.d.ts +0 -22
- package/build/types-ts3.8/utils/isBinding.d.ts +0 -77
- package/build/types-ts3.8/utils/isCloudflareClass.d.ts +0 -30
- package/build/types-ts3.8/utils/rpcMeta.d.ts +0 -15
- package/build/types-ts3.8/utils/rpcOptions.d.ts +0 -13
- package/build/types-ts3.8/utils/streaming.d.ts +0 -17
- package/build/types-ts3.8/utils/traceLinks.d.ts +0 -28
- package/build/types-ts3.8/vendor/stacktrace.d.ts +0 -11
- package/build/types-ts3.8/vite/agentClass.d.ts +0 -41
- package/build/types-ts3.8/vite/autoInstrument.d.ts +0 -22
- package/build/types-ts3.8/vite/index.d.ts +0 -98
- package/build/types-ts3.8/vite/instrumentFile.d.ts +0 -22
- package/build/types-ts3.8/vite/moduleShape.d.ts +0 -52
- package/build/types-ts3.8/vite/transform.d.ts +0 -65
- package/build/types-ts3.8/vite/workerEntrypoint.d.ts +0 -12
- package/build/types-ts3.8/vite/wranglerConfig.d.ts +0 -43
- package/build/types-ts3.8/withSentry.d.ts +0 -16
- package/build/types-ts3.8/workflows.d.ts +0 -25
- package/build/types-ts3.8/wrapMethodWithSentry.d.ts +0 -43
- /package/build/cjs/{client.js → dev/client.js} +0 -0
- /package/build/cjs/{debug-build.js → dev/debug-build.js} +0 -0
- /package/build/cjs/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
- /package/build/cjs/{flush.js → dev/flush.js} +0 -0
- /package/build/cjs/{instrument.js → dev/instrument.js} +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
- /package/build/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
- /package/build/cjs/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
- /package/build/cjs/{scope-utils.js → dev/scope-utils.js} +0 -0
- /package/build/cjs/{transport.js → dev/transport.js} +0 -0
- /package/build/cjs/{utils → dev/utils}/internalSqlQuery.js +0 -0
- /package/build/cjs/{utils → dev/utils}/internalStorageKey.js +0 -0
- /package/build/cjs/{utils → dev/utils}/isBinding.js +0 -0
- /package/build/cjs/{utils → dev/utils}/isCloudflareClass.js +0 -0
- /package/build/cjs/{utils → dev/utils}/streaming.js +0 -0
- /package/build/cjs/{utils → dev/utils}/traceLinks.js +0 -0
- /package/build/cjs/{vendor → dev/vendor}/stacktrace.js +0 -0
- /package/build/cjs/{vite → dev/vite}/agentClass.js +0 -0
- /package/build/cjs/{vite → dev/vite}/autoInstrument.js +0 -0
- /package/build/cjs/{vite → dev/vite}/instrumentFile.js +0 -0
- /package/build/cjs/{vite → dev/vite}/moduleShape.js +0 -0
- /package/build/cjs/{vite → dev/vite}/transform.js +0 -0
- /package/build/cjs/{vite → dev/vite}/workerEntrypoint.js +0 -0
- /package/build/cjs/{vite → dev/vite}/wranglerConfig.js +0 -0
- /package/build/esm/{client.js → dev/client.js} +0 -0
- /package/build/esm/{debug-build.js → dev/debug-build.js} +0 -0
- /package/build/esm/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
- /package/build/esm/{flush.js → dev/flush.js} +0 -0
- /package/build/esm/{instrument.js → dev/instrument.js} +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
- /package/build/esm/{integrations → dev/integrations}/spotlight.js +0 -0
- /package/build/esm/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
- /package/build/esm/{scope-utils.js → dev/scope-utils.js} +0 -0
- /package/build/esm/{transport.js → dev/transport.js} +0 -0
- /package/build/esm/{utils → dev/utils}/internalSqlQuery.js +0 -0
- /package/build/esm/{utils → dev/utils}/internalStorageKey.js +0 -0
- /package/build/esm/{utils → dev/utils}/isBinding.js +0 -0
- /package/build/esm/{utils → dev/utils}/isCloudflareClass.js +0 -0
- /package/build/esm/{utils → dev/utils}/streaming.js +0 -0
- /package/build/esm/{vendor → dev/vendor}/stacktrace.js +0 -0
- /package/build/esm/{vite → dev/vite}/agentClass.js +0 -0
- /package/build/esm/{vite → dev/vite}/autoInstrument.js +0 -0
- /package/build/esm/{vite → dev/vite}/instrumentFile.js +0 -0
- /package/build/esm/{vite → dev/vite}/moduleShape.js +0 -0
- /package/build/esm/{vite → dev/vite}/transform.js +0 -0
- /package/build/esm/{vite → dev/vite}/workerEntrypoint.js +0 -0
- /package/build/esm/{vite → dev/vite}/wranglerConfig.js +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve, relative } from 'node:path';
|
|
3
|
+
|
|
4
|
+
const ENV_FALLBACK_OPTIONS_FN = "() => undefined";
|
|
5
|
+
const OPTIONS_IMPORT_IDENTIFIER = "__SENTRY_OPTIONS_CALLBACK__";
|
|
6
|
+
const INSTRUMENT_FILE_BASENAME = "instrument.server";
|
|
7
|
+
const INSTRUMENT_FILE_EXTENSIONS = ["ts", "mts", "js", "mjs", "cjs"];
|
|
8
|
+
function resolveInstrumentFile(entryFilePath) {
|
|
9
|
+
const dir = dirname(entryFilePath);
|
|
10
|
+
for (const ext of INSTRUMENT_FILE_EXTENSIONS) {
|
|
11
|
+
const candidate = resolve(dir, `${INSTRUMENT_FILE_BASENAME}.${ext}`);
|
|
12
|
+
if (existsSync(candidate)) return candidate;
|
|
13
|
+
}
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
function buildOptionsImport(entryFilePath, instrumentFilePath) {
|
|
17
|
+
let relativePath = relative(dirname(entryFilePath), instrumentFilePath).replace(/\\/g, "/");
|
|
18
|
+
if (!relativePath.startsWith(".")) relativePath = `./${relativePath}`;
|
|
19
|
+
return {
|
|
20
|
+
optionsFn: OPTIONS_IMPORT_IDENTIFIER,
|
|
21
|
+
importStmt: `import ${OPTIONS_IMPORT_IDENTIFIER} from '${relativePath}';
|
|
22
|
+
`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ENV_FALLBACK_OPTIONS_FN, buildOptionsImport, resolveInstrumentFile };
|
|
27
|
+
//# sourceMappingURL=instrumentFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentFile.js","sources":["../../../../src/vite/instrumentFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, relative, resolve } from 'node:path';\n\n// Fallback options callback used when no instrument file is present. Returning\n// `undefined` makes the SDK read all configuration (DSN, release, environment,\n// sample rate, …) from the worker's `env` at runtime.\nexport const ENV_FALLBACK_OPTIONS_FN = '() => undefined';\n\n// Identifier the generated import binds the user's options module to.\nconst OPTIONS_IMPORT_IDENTIFIER = '__SENTRY_OPTIONS_CALLBACK__';\n\n// Conventional, non-configurable name of the Sentry options module. It is\n// looked up next to the worker entry file; its default export is the options\n// callback `(env) => CloudflareOptions`.\nconst INSTRUMENT_FILE_BASENAME = 'instrument.server';\nconst INSTRUMENT_FILE_EXTENSIONS = ['ts', 'mts', 'js', 'mjs', 'cjs'];\n\n/**\n * Locate the conventional `instrument.server.*` module sitting next to the\n * worker entry file. Returns its absolute path, or `undefined` when absent.\n */\nexport function resolveInstrumentFile(entryFilePath: string): string | undefined {\n const dir = dirname(entryFilePath);\n for (const ext of INSTRUMENT_FILE_EXTENSIONS) {\n const candidate = resolve(dir, `${INSTRUMENT_FILE_BASENAME}.${ext}`);\n if (existsSync(candidate)) return candidate;\n }\n return undefined;\n}\n\n/**\n * Build the `optionsFn` reference and `import` statement for the instrument\n * module whose **default export** is the options callback\n * `(env) => CloudflareOptions`.\n *\n * The import is emitted relative to `entryFilePath` because it is injected into\n * the entry file's source. The file extension is kept: extensionless specifiers\n * only resolve for extensions in Vite's default `resolve.extensions` (which\n * excludes `.cjs`), and keeping it makes our probe order authoritative when\n * several `instrument.server.*` files coexist.\n */\nexport function buildOptionsImport(\n entryFilePath: string,\n instrumentFilePath: string,\n): { optionsFn: string; importStmt: string } {\n let relativePath = relative(dirname(entryFilePath), instrumentFilePath).replace(/\\\\/g, '/');\n if (!relativePath.startsWith('.')) relativePath = `./${relativePath}`;\n\n return {\n optionsFn: OPTIONS_IMPORT_IDENTIFIER,\n importStmt: `import ${OPTIONS_IMPORT_IDENTIFIER} from '${relativePath}';\\n`,\n };\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,uBAAA,GAA0B;AAGvC,MAAM,yBAAA,GAA4B,6BAAA;AAKlC,MAAM,wBAAA,GAA2B,mBAAA;AACjC,MAAM,6BAA6B,CAAC,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,OAAO,KAAK,CAAA;AAM5D,SAAS,sBAAsB,aAAA,EAA2C;AAC/E,EAAA,MAAM,GAAA,GAAM,QAAQ,aAAa,CAAA;AACjC,EAAA,KAAA,MAAW,OAAO,0BAAA,EAA4B;AAC5C,IAAA,MAAM,YAAY,OAAA,CAAQ,GAAA,EAAK,GAAG,wBAAwB,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAA;AACnE,IAAA,IAAI,UAAA,CAAW,SAAS,CAAA,EAAG,OAAO,SAAA;AAAA,EACpC;AACA,EAAA,OAAO,MAAA;AACT;AAaO,SAAS,kBAAA,CACd,eACA,kBAAA,EAC2C;AAC3C,EAAA,IAAI,YAAA,GAAe,SAAS,OAAA,CAAQ,aAAa,GAAG,kBAAkB,CAAA,CAAE,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AAC1F,EAAA,IAAI,CAAC,YAAA,CAAa,UAAA,CAAW,GAAG,CAAA,EAAG,YAAA,GAAe,KAAK,YAAY,CAAA,CAAA;AAEnE,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,yBAAA;AAAA,IACX,UAAA,EAAY,CAAA,OAAA,EAAU,yBAAyB,CAAA,OAAA,EAAU,YAAY,CAAA;AAAA;AAAA,GACvE;AACF;;;;"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
const DEFAULT_EXPORT = "default";
|
|
2
|
+
function emptyShape() {
|
|
3
|
+
return {
|
|
4
|
+
classes: /* @__PURE__ */ new Map(),
|
|
5
|
+
imports: /* @__PURE__ */ new Map(),
|
|
6
|
+
namespaces: /* @__PURE__ */ new Map(),
|
|
7
|
+
reexports: /* @__PURE__ */ new Map(),
|
|
8
|
+
localExports: /* @__PURE__ */ new Map(),
|
|
9
|
+
starExports: []
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function shapeFromAst(ast) {
|
|
13
|
+
const shape = emptyShape();
|
|
14
|
+
for (const node of ast.body) {
|
|
15
|
+
switch (node.type) {
|
|
16
|
+
case "ClassDeclaration":
|
|
17
|
+
addAstClass(shape, node);
|
|
18
|
+
break;
|
|
19
|
+
case "ImportDeclaration":
|
|
20
|
+
addAstImports(shape, node);
|
|
21
|
+
break;
|
|
22
|
+
case "ExportNamedDeclaration":
|
|
23
|
+
addAstNamedExport(shape, node);
|
|
24
|
+
break;
|
|
25
|
+
case "ExportDefaultDeclaration": {
|
|
26
|
+
const decl = node.declaration;
|
|
27
|
+
if (decl.type === "ClassDeclaration" || decl.type === "ClassExpression") {
|
|
28
|
+
shape.defaultExportIsClass = true;
|
|
29
|
+
shape.defaultExportSuper = superRefFromNode(decl.superClass);
|
|
30
|
+
addAstClass(shape, decl);
|
|
31
|
+
} else if (decl.type === "Identifier") {
|
|
32
|
+
shape.defaultExportName = decl.name;
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "ExportAllDeclaration": {
|
|
37
|
+
const starNode = node;
|
|
38
|
+
const source = starNode.exported ? void 0 : asString(starNode.source?.value);
|
|
39
|
+
if (source) shape.starExports.push(source);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return shape;
|
|
45
|
+
}
|
|
46
|
+
function superRefFromNode(superClass) {
|
|
47
|
+
if (!superClass) return void 0;
|
|
48
|
+
if (superClass.type === "Identifier") {
|
|
49
|
+
return { kind: "identifier", name: superClass.name };
|
|
50
|
+
}
|
|
51
|
+
if (superClass.type === "MemberExpression") {
|
|
52
|
+
const member = superClass;
|
|
53
|
+
const object = member.object?.type === "Identifier" ? member.object.name : void 0;
|
|
54
|
+
const property = member.property?.name;
|
|
55
|
+
if (object && property) return { kind: "member", object, property };
|
|
56
|
+
}
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
function addAstClass(shape, classNode) {
|
|
60
|
+
if (classNode.id?.name) shape.classes.set(classNode.id.name, superRefFromNode(classNode.superClass));
|
|
61
|
+
}
|
|
62
|
+
function addAstImports(shape, node) {
|
|
63
|
+
const source = asString(node.source?.value);
|
|
64
|
+
if (!source) return;
|
|
65
|
+
for (const specifier of node.specifiers ?? []) {
|
|
66
|
+
const local = specifier.local?.name;
|
|
67
|
+
if (!local) continue;
|
|
68
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported?.name) {
|
|
69
|
+
shape.imports.set(local, { source, imported: specifier.imported.name });
|
|
70
|
+
} else if (specifier.type === "ImportDefaultSpecifier") {
|
|
71
|
+
shape.imports.set(local, { source, imported: DEFAULT_EXPORT });
|
|
72
|
+
} else if (specifier.type === "ImportNamespaceSpecifier") {
|
|
73
|
+
shape.namespaces.set(local, source);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function addAstNamedExport(shape, node) {
|
|
78
|
+
if (node.declaration?.type === "ClassDeclaration") {
|
|
79
|
+
addAstClass(shape, node.declaration);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const source = asString(node.source?.value);
|
|
83
|
+
for (const specifier of node.specifiers ?? []) {
|
|
84
|
+
const exported = specifier.exported?.name;
|
|
85
|
+
const local = specifier.local?.name;
|
|
86
|
+
if (!exported || !local) continue;
|
|
87
|
+
if (source) {
|
|
88
|
+
shape.reexports.set(exported, { source, imported: local });
|
|
89
|
+
} else {
|
|
90
|
+
shape.localExports.set(exported, local);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function shapeFromSource(rawCode) {
|
|
95
|
+
const code = stripComments(rawCode);
|
|
96
|
+
const shape = emptyShape();
|
|
97
|
+
const CLASS_RE = /\b(?:export\s+(?:default\s+)?)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)([^{]*)\{/g;
|
|
98
|
+
for (const match of code.matchAll(CLASS_RE)) {
|
|
99
|
+
const className = match[1];
|
|
100
|
+
const isDefault = /\bexport\s+default\b/.test(match[0]);
|
|
101
|
+
const superRef = superRefFromHeader(match[2] ?? "");
|
|
102
|
+
shape.classes.set(className, superRef);
|
|
103
|
+
if (isDefault) {
|
|
104
|
+
shape.defaultExportIsClass = true;
|
|
105
|
+
shape.defaultExportSuper = superRef;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const defaultExprMatch = /\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;/.exec(code);
|
|
109
|
+
if (defaultExprMatch && !shape.defaultExportIsClass) {
|
|
110
|
+
shape.defaultExportName = defaultExprMatch[1];
|
|
111
|
+
}
|
|
112
|
+
for (const match of code.matchAll(/\bexport\s*\*\s*from\s*['"]([^'"]+)['"]/g)) {
|
|
113
|
+
if (match[1]) shape.starExports.push(match[1]);
|
|
114
|
+
}
|
|
115
|
+
for (const match of code.matchAll(/\bexport\s*\{([^}]*)\}\s*(?:from\s*['"]([^'"]+)['"])?/g)) {
|
|
116
|
+
const source = match[2];
|
|
117
|
+
for (const { imported, local } of parseSpecifierList(match[1] ?? "")) {
|
|
118
|
+
if (source) {
|
|
119
|
+
shape.reexports.set(local, { source, imported });
|
|
120
|
+
} else {
|
|
121
|
+
shape.localExports.set(local, imported);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const match of code.matchAll(/\bimport\s+([^'";]+?)\s+from\s*['"]([^'"]+)['"]/g)) {
|
|
126
|
+
addSourceImports(shape, match[1] ?? "", match[2]);
|
|
127
|
+
}
|
|
128
|
+
return shape;
|
|
129
|
+
}
|
|
130
|
+
function superRefFromHeader(header) {
|
|
131
|
+
const withoutParams = stripLeadingGenerics(header);
|
|
132
|
+
const match = /\bextends\s+([A-Za-z_$][\w$]*)\s*(?:\.\s*([A-Za-z_$][\w$]*))?/.exec(withoutParams);
|
|
133
|
+
if (!match) return void 0;
|
|
134
|
+
return match[2] ? { kind: "member", object: match[1], property: match[2] } : { kind: "identifier", name: match[1] };
|
|
135
|
+
}
|
|
136
|
+
function stripLeadingGenerics(header) {
|
|
137
|
+
const start = header.indexOf("<");
|
|
138
|
+
if (start === -1 || header.slice(0, start).trim() !== "") return header;
|
|
139
|
+
let depth = 0;
|
|
140
|
+
for (let i = start; i < header.length; i++) {
|
|
141
|
+
const char = header[i];
|
|
142
|
+
if (char === "<") depth++;
|
|
143
|
+
else if (char === ">") {
|
|
144
|
+
depth--;
|
|
145
|
+
if (depth === 0) return header.slice(i + 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return header;
|
|
149
|
+
}
|
|
150
|
+
function parseSpecifierList(clause) {
|
|
151
|
+
const specifiers = [];
|
|
152
|
+
for (const rawPart of clause.split(",")) {
|
|
153
|
+
const part = rawPart.trim().replace(/^type\s+/, "");
|
|
154
|
+
if (!part) continue;
|
|
155
|
+
const aliased = /^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/.exec(part);
|
|
156
|
+
if (aliased) {
|
|
157
|
+
specifiers.push({ imported: aliased[1], local: aliased[2] });
|
|
158
|
+
} else if (/^[A-Za-z_$][\w$]*$/.test(part)) {
|
|
159
|
+
specifiers.push({ imported: part, local: part });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return specifiers;
|
|
163
|
+
}
|
|
164
|
+
function addSourceImports(shape, clause, source) {
|
|
165
|
+
if (/^type\s/.test(clause.trim())) return;
|
|
166
|
+
const namespaceMatch = /\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(clause);
|
|
167
|
+
if (namespaceMatch) {
|
|
168
|
+
shape.namespaces.set(namespaceMatch[1], source);
|
|
169
|
+
}
|
|
170
|
+
const bracesMatch = /\{([^}]*)\}/.exec(clause);
|
|
171
|
+
if (bracesMatch) {
|
|
172
|
+
for (const { imported, local } of parseSpecifierList(bracesMatch[1] ?? "")) {
|
|
173
|
+
shape.imports.set(local, { source, imported });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const defaultMatch = /^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(clause);
|
|
177
|
+
if (defaultMatch) {
|
|
178
|
+
shape.imports.set(defaultMatch[1], { source, imported: DEFAULT_EXPORT });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function stripComments(code) {
|
|
182
|
+
let result = "";
|
|
183
|
+
let index = 0;
|
|
184
|
+
while (index < code.length) {
|
|
185
|
+
const char = code[index];
|
|
186
|
+
const next = code[index + 1];
|
|
187
|
+
if (char === "/" && next === "/") {
|
|
188
|
+
while (index < code.length && code[index] !== "\n") index++;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (char === "/" && next === "*") {
|
|
192
|
+
index += 2;
|
|
193
|
+
while (index < code.length && !(code[index] === "*" && code[index + 1] === "/")) index++;
|
|
194
|
+
index += 2;
|
|
195
|
+
result += " ";
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
199
|
+
const quote = char;
|
|
200
|
+
result += char;
|
|
201
|
+
index++;
|
|
202
|
+
while (index < code.length) {
|
|
203
|
+
const inner = code[index];
|
|
204
|
+
result += inner;
|
|
205
|
+
index++;
|
|
206
|
+
if (inner === "\\") {
|
|
207
|
+
if (index < code.length) {
|
|
208
|
+
result += code[index];
|
|
209
|
+
index++;
|
|
210
|
+
}
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (inner === quote) break;
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
result += char;
|
|
218
|
+
index++;
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
function asString(value) {
|
|
223
|
+
return typeof value === "string" && value ? value : void 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export { DEFAULT_EXPORT, shapeFromAst, shapeFromSource };
|
|
227
|
+
//# sourceMappingURL=moduleShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleShape.js","sources":["../../../../src/vite/moduleShape.ts"],"sourcesContent":["import type { BaseNode, ProgramBody } from './transform';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node shapes for structural Agent detection.\n// ---------------------------------------------------------------------------\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface ClassNode extends BaseNode {\n id?: IdentifierNode | null;\n superClass?: BaseNode | null;\n}\n\ninterface MemberExpressionNode extends BaseNode {\n object?: { type: string; name?: string };\n property?: { type: string; name?: string };\n}\n\ninterface ImportSpecifierNode {\n type: string;\n imported?: { type: string; name?: string };\n local?: { type: string; name?: string };\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n source?: { value?: unknown };\n specifiers?: ImportSpecifierNode[];\n}\n\ninterface ExportSpecifierNode {\n type: string;\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: { value?: unknown } | null;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportAllNode extends BaseNode {\n source?: { value?: unknown };\n exported?: { type: string; name?: string } | null;\n}\n\n/** Binding name used for a module's default export. */\nexport const DEFAULT_EXPORT = 'default';\n\n/** A resolved superclass reference: a bare identifier or a `ns.Member` expression. */\nexport type SuperRef = { kind: 'identifier'; name: string } | { kind: 'member'; object: string; property: string };\n\n/** The declarations of a single module that binding resolution needs. */\nexport interface ModuleShape {\n /** Top-level class names → their superclass reference (absent when the class has no `extends`). */\n classes: Map<string, SuperRef | undefined>;\n /** Local binding name → the import it came from (`imported` is `default` for a default import). */\n imports: Map<string, { source: string; imported: string }>;\n /** Local binding name → module specifier, for `import * as ns from '...'`. */\n namespaces: Map<string, string>;\n /** Exported name → the re-export it came from, for `export { x as y } from '...'`. */\n reexports: Map<string, { source: string; imported: string }>;\n /** Exported name → local binding name, for `export { x as y }` without a source. */\n localExports: Map<string, string>;\n /** Module specifiers of bare `export * from '...'` declarations. */\n starExports: string[];\n /** `export default <Identifier>` — the local name it refers to. */\n defaultExportName?: string;\n /** True when the module's default export is a class declaration/expression. */\n defaultExportIsClass?: boolean;\n /** Superclass of an anonymous `export default class extends X`. */\n defaultExportSuper?: SuperRef;\n}\n\nfunction emptyShape(): ModuleShape {\n return {\n classes: new Map(),\n imports: new Map(),\n namespaces: new Map(),\n reexports: new Map(),\n localExports: new Map(),\n starExports: [],\n };\n}\n\n// ---------------------------------------------------------------------------\n// Shape from a parsed AST (used for the entry module)\n// ---------------------------------------------------------------------------\n\n/** Collect the shape of a module from its parsed AST — used for the already-parsed entry module. */\nexport function shapeFromAst(ast: ProgramBody): ModuleShape {\n const shape = emptyShape();\n\n for (const node of ast.body) {\n switch (node.type) {\n case 'ClassDeclaration':\n addAstClass(shape, node);\n break;\n case 'ImportDeclaration':\n addAstImports(shape, node);\n break;\n case 'ExportNamedDeclaration':\n addAstNamedExport(shape, node);\n break;\n case 'ExportDefaultDeclaration': {\n const decl = (node as ExportDefaultNode).declaration;\n if (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') {\n shape.defaultExportIsClass = true;\n shape.defaultExportSuper = superRefFromNode((decl as ClassNode).superClass);\n // `export default class Foo {}` also binds `Foo` locally.\n addAstClass(shape, decl);\n } else if (decl.type === 'Identifier') {\n shape.defaultExportName = (decl as IdentifierNode).name;\n }\n break;\n }\n case 'ExportAllDeclaration': {\n const starNode = node as ExportAllNode;\n // `export * as ns from '...'` binds a namespace object, not the individual exports.\n const source = starNode.exported ? undefined : asString(starNode.source?.value);\n if (source) shape.starExports.push(source);\n break;\n }\n }\n }\n\n return shape;\n}\n\nfunction superRefFromNode(superClass: BaseNode | null | undefined): SuperRef | undefined {\n if (!superClass) return undefined;\n\n if (superClass.type === 'Identifier') {\n return { kind: 'identifier', name: (superClass as IdentifierNode).name };\n }\n\n if (superClass.type === 'MemberExpression') {\n const member = superClass as MemberExpressionNode;\n const object = member.object?.type === 'Identifier' ? member.object.name : undefined;\n const property = member.property?.name;\n if (object && property) return { kind: 'member', object, property };\n }\n\n return undefined;\n}\n\nfunction addAstClass(shape: ModuleShape, classNode: ClassNode): void {\n if (classNode.id?.name) shape.classes.set(classNode.id.name, superRefFromNode(classNode.superClass));\n}\n\nfunction addAstImports(shape: ModuleShape, node: ImportDeclarationNode): void {\n const source = asString(node.source?.value);\n if (!source) return;\n\n for (const specifier of node.specifiers ?? []) {\n const local = specifier.local?.name;\n if (!local) continue;\n\n if (specifier.type === 'ImportSpecifier' && specifier.imported?.name) {\n shape.imports.set(local, { source, imported: specifier.imported.name });\n } else if (specifier.type === 'ImportDefaultSpecifier') {\n shape.imports.set(local, { source, imported: DEFAULT_EXPORT });\n } else if (specifier.type === 'ImportNamespaceSpecifier') {\n shape.namespaces.set(local, source);\n }\n }\n}\n\nfunction addAstNamedExport(shape: ModuleShape, node: ExportNamedNode): void {\n if (node.declaration?.type === 'ClassDeclaration') {\n addAstClass(shape, node.declaration);\n return;\n }\n\n const source = asString(node.source?.value);\n for (const specifier of node.specifiers ?? []) {\n const exported = specifier.exported?.name;\n const local = specifier.local?.name;\n if (!exported || !local) continue;\n\n if (source) {\n shape.reexports.set(exported, { source, imported: local });\n } else {\n shape.localExports.set(exported, local);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shape from raw source (used for sibling modules read off disk)\n// ---------------------------------------------------------------------------\n\n/**\n * Extract the module shape from **unprocessed source**.\n *\n * Sibling modules are read straight from disk (the plugin context's `load()` would deadlock inside a\n * transform hook), so they may still be TypeScript — which no JS parser will accept. Only\n * import/export statements and `class X extends Y` headers matter here, and those are\n * declaration-level syntax a scan can pick out reliably; class bodies, type annotations and generics\n * are irrelevant and simply skipped.\n */\nexport function shapeFromSource(rawCode: string): ModuleShape {\n const code = stripComments(rawCode);\n const shape = emptyShape();\n\n // `class X extends Y {` / `class X<T> extends Y<T> {`, optionally exported and/or abstract.\n const CLASS_RE = /\\b(?:export\\s+(?:default\\s+)?)?(?:abstract\\s+)?class\\s+([A-Za-z_$][\\w$]*)([^{]*)\\{/g;\n for (const match of code.matchAll(CLASS_RE)) {\n const className = match[1]!;\n const isDefault = /\\bexport\\s+default\\b/.test(match[0]);\n const superRef = superRefFromHeader(match[2] ?? '');\n\n shape.classes.set(className, superRef);\n if (isDefault) {\n shape.defaultExportIsClass = true;\n shape.defaultExportSuper = superRef;\n }\n }\n\n // `export default Identifier;`\n const defaultExprMatch = /\\bexport\\s+default\\s+([A-Za-z_$][\\w$]*)\\s*;/.exec(code);\n if (defaultExprMatch && !shape.defaultExportIsClass) {\n shape.defaultExportName = defaultExprMatch[1];\n }\n\n // `export * from '...'` (but not `export * as ns from '...'`).\n for (const match of code.matchAll(/\\bexport\\s*\\*\\s*from\\s*['\"]([^'\"]+)['\"]/g)) {\n if (match[1]) shape.starExports.push(match[1]);\n }\n\n // `export { a, b as c } from '...'` and `export { a, b as c }`.\n for (const match of code.matchAll(/\\bexport\\s*\\{([^}]*)\\}\\s*(?:from\\s*['\"]([^'\"]+)['\"])?/g)) {\n const source = match[2];\n for (const { imported, local } of parseSpecifierList(match[1] ?? '')) {\n // In an export clause the first name is local and the alias is the exported name.\n if (source) {\n shape.reexports.set(local, { source, imported });\n } else {\n shape.localExports.set(local, imported);\n }\n }\n }\n\n // `import Default, { a as b }, * as ns from '...'` in its various shapes.\n for (const match of code.matchAll(/\\bimport\\s+([^'\";]+?)\\s+from\\s*['\"]([^'\"]+)['\"]/g)) {\n addSourceImports(shape, match[1] ?? '', match[2]!);\n }\n\n return shape;\n}\n\n/** Pull the superclass out of the text between a class name and its body. */\nfunction superRefFromHeader(header: string): SuperRef | undefined {\n // The header still carries the class's own generic parameter list (`<T extends S>`), whose\n // constraint `extends` would otherwise be mistaken for the superclass clause. Strip a leading\n // balanced `<...>` first, then read the (possibly dotted) base name. Trailing generic args on the\n // base (`extends Agent<Env>`) stop the match naturally.\n const withoutParams = stripLeadingGenerics(header);\n const match = /\\bextends\\s+([A-Za-z_$][\\w$]*)\\s*(?:\\.\\s*([A-Za-z_$][\\w$]*))?/.exec(withoutParams);\n if (!match) return undefined;\n\n return match[2] ? { kind: 'member', object: match[1]!, property: match[2] } : { kind: 'identifier', name: match[1]! };\n}\n\n/**\n * Remove a leading `<...>` generic parameter list, honoring nesting (`<T extends Map<K, V>>`).\n * Anything after the balanced close — the superclass clause — is returned unchanged. When the\n * header doesn't start with `<` (no generics), it is returned as-is.\n */\nfunction stripLeadingGenerics(header: string): string {\n const start = header.indexOf('<');\n // Only treat it as a parameter list when `<` is the first meaningful token — a `<` appearing\n // later is part of the superclass's own generic args and must be left alone.\n if (start === -1 || header.slice(0, start).trim() !== '') return header;\n\n let depth = 0;\n for (let i = start; i < header.length; i++) {\n const char = header[i];\n if (char === '<') depth++;\n else if (char === '>') {\n depth--;\n if (depth === 0) return header.slice(i + 1);\n }\n }\n // Unbalanced `<` — fall back to the untouched header rather than dropping the superclass.\n return header;\n}\n\n/** Parse `a, b as c` into `{ imported: 'b', local: 'c' }` pairs (type-only specifiers dropped). */\nfunction parseSpecifierList(clause: string): Array<{ imported: string; local: string }> {\n const specifiers: Array<{ imported: string; local: string }> = [];\n\n for (const rawPart of clause.split(',')) {\n const part = rawPart.trim().replace(/^type\\s+/, '');\n if (!part) continue;\n\n const aliased = /^([A-Za-z_$][\\w$]*)\\s+as\\s+([A-Za-z_$][\\w$]*)$/.exec(part);\n if (aliased) {\n specifiers.push({ imported: aliased[1]!, local: aliased[2]! });\n } else if (/^[A-Za-z_$][\\w$]*$/.test(part)) {\n specifiers.push({ imported: part, local: part });\n }\n }\n\n return specifiers;\n}\n\nfunction addSourceImports(shape: ModuleShape, clause: string, source: string): void {\n // Type-only imports never contribute a runtime base class.\n if (/^type\\s/.test(clause.trim())) return;\n\n const namespaceMatch = /\\*\\s*as\\s+([A-Za-z_$][\\w$]*)/.exec(clause);\n if (namespaceMatch) {\n shape.namespaces.set(namespaceMatch[1]!, source);\n }\n\n const bracesMatch = /\\{([^}]*)\\}/.exec(clause);\n if (bracesMatch) {\n for (const { imported, local } of parseSpecifierList(bracesMatch[1] ?? '')) {\n shape.imports.set(local, { source, imported });\n }\n }\n\n // A leading bare identifier (before any brace/star) is the default import.\n const defaultMatch = /^\\s*([A-Za-z_$][\\w$]*)\\s*(?:,|$)/.exec(clause);\n if (defaultMatch) {\n shape.imports.set(defaultMatch[1]!, { source, imported: DEFAULT_EXPORT });\n }\n}\n\n/** Remove line and block comments, leaving string literals (module specifiers) intact. */\nfunction stripComments(code: string): string {\n let result = '';\n let index = 0;\n\n while (index < code.length) {\n const char = code[index]!;\n const next = code[index + 1];\n\n if (char === '/' && next === '/') {\n while (index < code.length && code[index] !== '\\n') index++;\n continue;\n }\n\n if (char === '/' && next === '*') {\n index += 2;\n while (index < code.length && !(code[index] === '*' && code[index + 1] === '/')) index++;\n index += 2;\n // Keep a separator so `*/class` doesn't fuse into one token.\n result += ' ';\n continue;\n }\n\n if (char === '\"' || char === \"'\" || char === '`') {\n const quote = char;\n result += char;\n index++;\n while (index < code.length) {\n const inner = code[index]!;\n result += inner;\n index++;\n if (inner === '\\\\') {\n if (index < code.length) {\n result += code[index]!;\n index++;\n }\n continue;\n }\n if (inner === quote) break;\n }\n continue;\n }\n\n result += char;\n index++;\n }\n\n return result;\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === 'string' && value ? value : undefined;\n}\n"],"names":[],"mappings":"AAqDO,MAAM,cAAA,GAAiB;AA2B9B,SAAS,UAAA,GAA0B;AACjC,EAAA,OAAO;AAAA,IACL,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,UAAA,sBAAgB,GAAA,EAAI;AAAA,IACpB,SAAA,sBAAe,GAAA,EAAI;AAAA,IACnB,YAAA,sBAAkB,GAAA,EAAI;AAAA,IACtB,aAAa;AAAC,GAChB;AACF;AAOO,SAAS,aAAa,GAAA,EAA+B;AAC1D,EAAA,MAAM,QAAQ,UAAA,EAAW;AAEzB,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAI,IAAA,EAAM;AAC3B,IAAA,QAAQ,KAAK,IAAA;AAAM,MACjB,KAAK,kBAAA;AACH,QAAA,WAAA,CAAY,OAAO,IAAI,CAAA;AACvB,QAAA;AAAA,MACF,KAAK,mBAAA;AACH,QAAA,aAAA,CAAc,OAAO,IAAI,CAAA;AACzB,QAAA;AAAA,MACF,KAAK,wBAAA;AACH,QAAA,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A,KAAS,GAAA,IAAO,IAAA,KAAS,GAAA,IAAO,SAAS,GAAA,EAAK;AAChD,MAAA,MAAM,KAAA,GAAQ,IAAA;AACd,MAAA,MAAA,IAAU,IAAA;AACV,MAAA,KAAA,EAAA;AACA,MAAA,OAAO,KAAA,GAAQ,KAAK,MAAA,EAAQ;AAC1B,QAAA,MAAM,KAAA,GAAQ,KAAK,KAAK,CAAA;AACxB,QAAA,MAAA,IAAU,KAAA;AACV,QAAA,KAAA,EAAA;AACA,QAAA,IAAI,UAAU,IAAA,EAAM;AAClB,UAAA,IAAI,KAAA,GAAQ,KAAK,MAAA,EAAQ;AACvB,YAAA,MAAA,IAAU,KAAK,KAAK,CAAA;AACpB,YAAA,KAAA,EAAA;AAAA,UACF;AACA,UAAA;AAAA,QACF;AACA,QAAA,IAAI,UAAU,KAAA,EAAO;AAAA,MACvB;AACA,MAAA;AAAA,IACF;AAEA,IAAA,MAAA,IAAU,IAAA;AACV,IAAA,KAAA,EAAA;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,SAAS,KAAA,EAAoC;AACpD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,GAAQ,KAAA,GAAQ,MAAA;AACtD;;;;"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
|
+
import { detectWorkerEntrypointClasses } from './workerEntrypoint.js';
|
|
3
|
+
|
|
4
|
+
function isCallToMethod(node, methodName) {
|
|
5
|
+
if (node.type !== "CallExpression") return false;
|
|
6
|
+
const callee = node.callee;
|
|
7
|
+
if (!callee) return false;
|
|
8
|
+
if (callee.type === "Identifier" && callee.name === methodName) return true;
|
|
9
|
+
return callee.type === "MemberExpression" && callee.property?.type === "Identifier" && callee.property.name === methodName;
|
|
10
|
+
}
|
|
11
|
+
const WRAPPER_METHODS = {
|
|
12
|
+
durableObject: "instrumentDurableObjectWithSentry",
|
|
13
|
+
agent: "instrumentAgentWithSentry",
|
|
14
|
+
workflow: "instrumentWorkflowWithSentry",
|
|
15
|
+
workerEntrypoint: "withSentry"
|
|
16
|
+
};
|
|
17
|
+
function applyAutoInstrumentTransforms(code, ast, ctx) {
|
|
18
|
+
const ms = new MagicString(code);
|
|
19
|
+
const topLevelClasses = collectTopLevelClasses(ast);
|
|
20
|
+
const state = {
|
|
21
|
+
ms,
|
|
22
|
+
needsImport: false,
|
|
23
|
+
wrappedClasses: /* @__PURE__ */ new Set(),
|
|
24
|
+
topLevelClasses,
|
|
25
|
+
renamedLocals: /* @__PURE__ */ new Set(),
|
|
26
|
+
classWrappers: ctx.classWrappers,
|
|
27
|
+
agentClasses: ctx.agentClasses ?? /* @__PURE__ */ new Set(),
|
|
28
|
+
workerEntrypointClasses: detectWorkerEntrypointClasses(ast)
|
|
29
|
+
};
|
|
30
|
+
const { wrappedClasses } = state;
|
|
31
|
+
for (const node of ast.body) {
|
|
32
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
33
|
+
handleNamedExport(node, ctx, state);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const node of ast.body) {
|
|
37
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
38
|
+
wrapDefaultExport(node, ctx, state);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!state.needsImport) {
|
|
42
|
+
if (wrappedClasses.size === 0) return void 0;
|
|
43
|
+
return { code, map: ms.generateMap({ hires: true }), wrappedClasses };
|
|
44
|
+
}
|
|
45
|
+
if (ctx.optionsImport) ms.prepend(ctx.optionsImport);
|
|
46
|
+
ms.prepend("import * as __SENTRY__ from '@sentry/cloudflare';\n");
|
|
47
|
+
return {
|
|
48
|
+
code: ms.toString(),
|
|
49
|
+
map: ms.generateMap({ hires: true }),
|
|
50
|
+
wrappedClasses
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function resolveWrapperKind(exportedName, localName, state) {
|
|
54
|
+
const configured = state.classWrappers.get(exportedName);
|
|
55
|
+
if (configured === "durableObject" && localName && state.agentClasses.has(localName)) return "agent";
|
|
56
|
+
if (configured) return configured;
|
|
57
|
+
if (localName && state.workerEntrypointClasses.has(localName)) return "workerEntrypoint";
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
function collectTopLevelClasses(ast) {
|
|
61
|
+
const classes = /* @__PURE__ */ new Map();
|
|
62
|
+
for (const node of ast.body) {
|
|
63
|
+
if (node.type !== "ClassDeclaration") continue;
|
|
64
|
+
const classNode = node;
|
|
65
|
+
if (classNode.id?.name) classes.set(classNode.id.name, classNode);
|
|
66
|
+
}
|
|
67
|
+
return classes;
|
|
68
|
+
}
|
|
69
|
+
function wrapDefaultExport(node, ctx, state) {
|
|
70
|
+
const decl = node.declaration;
|
|
71
|
+
if (isCallToMethod(decl, "withSentry")) return;
|
|
72
|
+
if (decl.type === "Identifier" && state.renamedLocals.has(decl.name)) return;
|
|
73
|
+
state.ms.overwrite(node.start, decl.start, "const __SENTRY_DEFAULT_EXPORT__ = ");
|
|
74
|
+
state.ms.append(`
|
|
75
|
+
export default __SENTRY__.withSentry(${ctx.optionsFn}, __SENTRY_DEFAULT_EXPORT__);
|
|
76
|
+
`);
|
|
77
|
+
state.needsImport = true;
|
|
78
|
+
}
|
|
79
|
+
function handleNamedExport(node, ctx, state) {
|
|
80
|
+
const decl = node.declaration;
|
|
81
|
+
if (decl?.type === "VariableDeclaration") {
|
|
82
|
+
collectManuallyWrappedClassExports(decl, ctx, state);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (decl?.type === "ClassDeclaration") {
|
|
86
|
+
wrapInlineClassExport(node, decl, ctx, state);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (node.source) return;
|
|
90
|
+
for (const specifier of node.specifiers ?? []) {
|
|
91
|
+
wrapSpecifierExport(specifier, ctx, state);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function collectManuallyWrappedClassExports(varDecl, ctx, state) {
|
|
95
|
+
for (const declarator of varDecl.declarations ?? []) {
|
|
96
|
+
const name = declarator.id?.type === "Identifier" ? declarator.id.name : void 0;
|
|
97
|
+
const kind = name ? ctx.classWrappers.get(name) : void 0;
|
|
98
|
+
if (!name || !kind || !declarator.init) continue;
|
|
99
|
+
const accepted = kind === "durableObject" ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];
|
|
100
|
+
if (accepted.some((method) => isCallToMethod(declarator.init, method))) {
|
|
101
|
+
state.wrappedClasses.add(name);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function wrapInlineClassExport(exportNode, classDecl, ctx, state) {
|
|
106
|
+
const classId = classDecl.id;
|
|
107
|
+
const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : void 0;
|
|
108
|
+
if (!classId || !kind) return;
|
|
109
|
+
const className = classId.name;
|
|
110
|
+
const renamedClass = `__SENTRY_ORIGINAL_${className}__`;
|
|
111
|
+
state.ms.overwrite(exportNode.start, classDecl.start, "");
|
|
112
|
+
state.ms.overwrite(classId.start, classId.end, renamedClass);
|
|
113
|
+
state.ms.appendLeft(
|
|
114
|
+
exportNode.end,
|
|
115
|
+
`
|
|
116
|
+
export const ${className} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});
|
|
117
|
+
`
|
|
118
|
+
);
|
|
119
|
+
state.wrappedClasses.add(className);
|
|
120
|
+
state.renamedLocals.add(className);
|
|
121
|
+
state.needsImport = true;
|
|
122
|
+
}
|
|
123
|
+
function wrapSpecifierExport(specifier, ctx, state) {
|
|
124
|
+
if (specifier.type !== "ExportSpecifier" || specifier.exported?.type !== "Identifier") return;
|
|
125
|
+
const exportedName = specifier.exported.name;
|
|
126
|
+
if (!exportedName) return;
|
|
127
|
+
const localName = specifier.local?.type === "Identifier" ? specifier.local.name : void 0;
|
|
128
|
+
const kind = resolveWrapperKind(exportedName, localName, state);
|
|
129
|
+
if (!kind) return;
|
|
130
|
+
const localClass = localName ? state.topLevelClasses.get(localName) : void 0;
|
|
131
|
+
if (!localName || !localClass?.id) return;
|
|
132
|
+
state.wrappedClasses.add(exportedName);
|
|
133
|
+
state.needsImport = true;
|
|
134
|
+
if (state.renamedLocals.has(localName)) return;
|
|
135
|
+
state.renamedLocals.add(localName);
|
|
136
|
+
const renamedClass = `__SENTRY_ORIGINAL_${localName}__`;
|
|
137
|
+
state.ms.overwrite(localClass.id.start, localClass.id.end, renamedClass);
|
|
138
|
+
state.ms.appendLeft(
|
|
139
|
+
localClass.end,
|
|
140
|
+
`
|
|
141
|
+
const ${localName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});
|
|
142
|
+
`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { applyAutoInstrumentTransforms };
|
|
147
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sources":["../../../../src/vite/transform.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport { detectWorkerEntrypointClasses } from './workerEntrypoint';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node types for the AST nodes we inspect.\n// ---------------------------------------------------------------------------\n\nexport interface BaseNode {\n type: string;\n start: number;\n end: number;\n}\n\nexport interface ProgramBody {\n body: BaseNode[];\n}\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface CalleeNode {\n type: string;\n name?: string;\n property?: { type: string; name?: string };\n}\n\ninterface CallExpressionNode extends BaseNode {\n callee?: CalleeNode;\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportSpecifierNode {\n type: string;\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: unknown;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface VariableDeclaratorNode {\n id?: { type: string; name?: string };\n init?: BaseNode | null;\n}\n\ninterface VariableDeclarationNode extends BaseNode {\n declarations?: VariableDeclaratorNode[];\n}\n\nfunction isCallToMethod(node: BaseNode, methodName: string): boolean {\n if (node.type !== 'CallExpression') return false;\n const callee = (node as CallExpressionNode).callee;\n if (!callee) return false;\n if (callee.type === 'Identifier' && callee.name === methodName) return true;\n return (\n callee.type === 'MemberExpression' && callee.property?.type === 'Identifier' && callee.property.name === methodName\n );\n}\n\n/**\n * The kind of Sentry wrapper to apply to an exported class.\n *\n * `durableObject` and `workflow` are keyed by name from the wrangler config\n * (`durable_objects.bindings`, `workflows`), since those class names are\n * authoritative there. `workerEntrypoint` is different: a worker's own\n * entrypoints aren't enumerated in its config, so they're detected structurally\n * (a class extending `WorkerEntrypoint` from `cloudflare:workers`), with the\n * config providing only a fallback for self-bound entrypoints whose base class\n * lives in another module.\n */\nexport type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';\n\n/**\n * The `@sentry/cloudflare` helper each wrapper kind emits. All share the same\n * `(optionsCallback, Class)` signature. `WorkerEntrypoint` classes use\n * `withSentry`, which runtime-detects the class type and routes accordingly.\n */\nconst WRAPPER_METHODS: Record<ClassWrapperKind, string> = {\n durableObject: 'instrumentDurableObjectWithSentry',\n agent: 'instrumentAgentWithSentry',\n workflow: 'instrumentWorkflowWithSentry',\n workerEntrypoint: 'withSentry',\n};\n\nexport interface TransformContext {\n /**\n * Exported class name → the kind of Sentry wrapper to apply. Populated from\n * the wrangler config, so the transform can wrap by name without resolving\n * each class's base type.\n */\n classWrappers: Map<string, ClassWrapperKind>;\n /**\n * Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in\n * wrangler, so this upgrades those entries from `durableObject` to `agent`.\n */\n agentClasses?: ReadonlySet<string>;\n optionsFn: string;\n /** Import statement prepended when `optionsFn` references a separate module. */\n optionsImport?: string;\n}\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n /**\n * The configured class names that were actually wrapped. Lets the plugin warn\n * about configured classes it could not find, instead of silently leaving\n * them uninstrumented.\n */\n wrappedClasses: Set<string>;\n}\n\n/**\n * Rewrite the worker entry source to wrap its default export with `withSentry`\n * and any configured class export with its matching Sentry wrapper (see\n * {@link TransformContext.classWrappers}, e.g. Durable Object classes with\n * `instrumentDurableObjectWithSentry`).\n *\n * Handles both `export class MyDO {}` and the specifier form\n * (`class MyDO {}` … `export { MyDO }` / `export { Foo as MyDO }`).\n * Re-exports from other modules (`export { MyDO } from './do'`) cannot be\n * wrapped here and are left alone — the plugin warns about them via\n * {@link TransformResult.wrappedClasses}.\n *\n * Exported (rather than inlined into the plugin) so it can be unit-tested with a\n * plain AST and no Vite context. Returns `undefined` when nothing was wrapped and\n * there are no already-manually-wrapped classes to report.\n */\nexport function applyAutoInstrumentTransforms(\n code: string,\n ast: ProgramBody,\n ctx: TransformContext,\n): TransformResult | undefined {\n const ms = new MagicString(code);\n const topLevelClasses = collectTopLevelClasses(ast);\n const state: TransformState = {\n ms,\n needsImport: false,\n wrappedClasses: new Set<string>(),\n topLevelClasses,\n renamedLocals: new Set<string>(),\n classWrappers: ctx.classWrappers,\n agentClasses: ctx.agentClasses ?? new Set<string>(),\n workerEntrypointClasses: detectWorkerEntrypointClasses(ast),\n };\n const { wrappedClasses } = state;\n\n // Named exports first, regardless of source order: the default-export handler\n // needs to know which local bindings a named export already wrapped, so it can\n // skip a class that is both exported by name and re-exported as default (which\n // would otherwise wrap it twice).\n for (const node of ast.body) {\n if (node.type === 'ExportNamedDeclaration') {\n handleNamedExport(node, ctx, state);\n }\n }\n for (const node of ast.body) {\n if (node.type === 'ExportDefaultDeclaration') {\n wrapDefaultExport(node as ExportDefaultNode, ctx, state);\n }\n }\n\n if (!state.needsImport) {\n // Nothing was rewritten. Still surface any classes found already wrapped\n // manually (via `wrappedClasses`) so the caller doesn't warn about them;\n // return undefined only when there was nothing to report either.\n if (wrappedClasses.size === 0) return undefined;\n return { code, map: ms.generateMap({ hires: true }), wrappedClasses };\n }\n\n if (ctx.optionsImport) ms.prepend(ctx.optionsImport);\n ms.prepend(\"import * as __SENTRY__ from '@sentry/cloudflare';\\n\");\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: true }),\n wrappedClasses,\n };\n}\n\ninterface TransformState {\n ms: MagicString;\n needsImport: boolean;\n wrappedClasses: Set<string>;\n /**\n * Top-level (non-exported) class declarations, so specifier exports like\n * `export { MyDO }` can locate the class they refer to.\n */\n topLevelClasses: Map<string, ClassDeclarationNode>;\n /**\n * Local class names already renamed + wrapped, so two specifiers pointing at\n * the same class don't produce duplicate bindings.\n */\n renamedLocals: Set<string>;\n /** Class name → wrapper kind, keyed by the *exported* name (from config). */\n classWrappers: Map<string, ClassWrapperKind>;\n /** Local class names detected as `agents` Agents (see {@link TransformContext.agentClasses}). */\n agentClasses: ReadonlySet<string>;\n /**\n * Local class names detected as `WorkerEntrypoint` subclasses in this module,\n * so they can be wrapped without a config entry.\n */\n workerEntrypointClasses: Set<string>;\n}\n\n/**\n * Resolve the wrapper kind for a class export.\n *\n * Config (`classWrappers`) wins — it's authoritative for Durable Objects and\n * Workflows, and provides the self-binding fallback for WorkerEntrypoints whose\n * base class this module can't see. Otherwise a structurally-detected\n * `WorkerEntrypoint` subclass (matched by its *local* name) gets wrapped with\n * `withSentry`.\n *\n * The one case where config is refined rather than obeyed is an `agents` Agent:\n * it *is* a Durable Object, so wrangler can only ever describe it as one, and\n * only the detected base chain distinguishes the two.\n */\nfunction resolveWrapperKind(\n exportedName: string,\n localName: string | undefined,\n state: TransformState,\n): ClassWrapperKind | undefined {\n const configured = state.classWrappers.get(exportedName);\n if (configured === 'durableObject' && localName && state.agentClasses.has(localName)) return 'agent';\n if (configured) return configured;\n if (localName && state.workerEntrypointClasses.has(localName)) return 'workerEntrypoint';\n return undefined;\n}\n\nfunction collectTopLevelClasses(ast: ProgramBody): Map<string, ClassDeclarationNode> {\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n if (node.type !== 'ClassDeclaration') continue;\n const classNode = node as ClassDeclarationNode;\n if (classNode.id?.name) classes.set(classNode.id.name, classNode);\n }\n return classes;\n}\n\nfunction wrapDefaultExport(node: ExportDefaultNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // Already wrapped — leave it alone\n if (isCallToMethod(decl, 'withSentry')) return;\n\n // `export default Foo` where `Foo` is a local class already wrapped by a named\n // export (e.g. a self-bound WorkerEntrypoint also used as the default handler).\n // Wrapping again would produce `withSentry(withSentry(...))`.\n if (decl.type === 'Identifier' && state.renamedLocals.has((decl as IdentifierNode).name)) return;\n\n // `export default <expr>` → `const __SENTRY_DEFAULT_EXPORT__ = <expr>`\n // MagicString positions are always relative to the original source.\n state.ms.overwrite(node.start, decl.start, 'const __SENTRY_DEFAULT_EXPORT__ = ');\n state.ms.append(`\\nexport default __SENTRY__.withSentry(${ctx.optionsFn}, __SENTRY_DEFAULT_EXPORT__);\\n`);\n state.needsImport = true;\n}\n\nfunction handleNamedExport(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // ---- Manually wrapped class export ----\n // `export const MyDO = instrumentDurableObjectWithSentry(...)` — count it\n // as wrapped so the plugin doesn't warn about it, but leave it alone.\n if (decl?.type === 'VariableDeclaration') {\n collectManuallyWrappedClassExports(decl, ctx, state);\n return;\n }\n\n // ---- Named class export matching a configured binding ----\n if (decl?.type === 'ClassDeclaration') {\n wrapInlineClassExport(node, decl, ctx, state);\n return;\n }\n\n // ---- Specifier export of a local class (`export { Foo as MyDO }`) ----\n // Re-exports from another module carry a `source` — nothing local to wrap.\n if (node.source) return;\n for (const specifier of node.specifiers ?? []) {\n wrapSpecifierExport(specifier, ctx, state);\n }\n}\n\nfunction collectManuallyWrappedClassExports(\n varDecl: VariableDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n for (const declarator of varDecl.declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const kind = name ? ctx.classWrappers.get(name) : undefined;\n if (!name || !kind || !declarator.init) continue;\n\n // A hand-wrapped Agent is configured as a Durable Object, so accept either helper there —\n // otherwise an already-instrumented Agent would be reported as unwrapped.\n const accepted =\n kind === 'durableObject' ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];\n\n if (accepted.some(method => isCallToMethod(declarator.init as BaseNode, method))) {\n state.wrappedClasses.add(name);\n }\n }\n}\n\nfunction wrapInlineClassExport(\n exportNode: ExportNamedNode,\n classDecl: ClassDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n const classId = classDecl.id;\n // Inline export: the exported name and the local class name are the same.\n const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : undefined;\n if (!classId || !kind) return;\n\n const className = classId.name;\n const renamedClass = `__SENTRY_ORIGINAL_${className}__`;\n\n // Strip the `export ` keyword\n state.ms.overwrite(exportNode.start, classDecl.start, '');\n\n // Rename the class to avoid a duplicate binding\n state.ms.overwrite(classId.start, classId.end, renamedClass);\n\n // Insert the wrapped re-export after the class body\n state.ms.appendLeft(\n exportNode.end,\n `\\nexport const ${className} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});\\n`,\n );\n\n state.wrappedClasses.add(className);\n state.renamedLocals.add(className);\n state.needsImport = true;\n}\n\nfunction wrapSpecifierExport(specifier: ExportSpecifierNode, ctx: TransformContext, state: TransformState): void {\n if (specifier.type !== 'ExportSpecifier' || specifier.exported?.type !== 'Identifier') return;\n const exportedName = specifier.exported.name;\n if (!exportedName) return;\n\n const localName = specifier.local?.type === 'Identifier' ? specifier.local.name : undefined;\n const kind = resolveWrapperKind(exportedName, localName, state);\n if (!kind) return;\n\n const localClass = localName ? state.topLevelClasses.get(localName) : undefined;\n if (!localName || !localClass?.id) return;\n\n state.wrappedClasses.add(exportedName);\n state.needsImport = true;\n if (state.renamedLocals.has(localName)) return;\n state.renamedLocals.add(localName);\n\n const renamedClass = `__SENTRY_ORIGINAL_${localName}__`;\n state.ms.overwrite(localClass.id.start, localClass.id.end, renamedClass);\n // The existing `export { ... }` statement keeps exporting the (now\n // wrapped) `localName` binding, so the wrapper is NOT exported here.\n state.ms.appendLeft(\n localClass.end,\n `\\nconst ${localName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});\\n`,\n );\n}\n"],"names":[],"mappings":";;;AA4DA,SAAS,cAAA,CAAe,MAAgB,UAAA,EAA6B;AACnE,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,gBAAA,EAAkB,OAAO,KAAA;AAC3C,EAAA,MAAM,SAAU,IAAA,CAA4B,MAAA;AAC5C,EAAA,IAAI,CAAC,QAAQ,OAAO,KAAA;AACpB,EAAA,IAAI,OAAO,IAAA,KAAS,YAAA,IAAgB,MAAA,CAAO,IAAA,KAAS,YAAY,OAAO,IAAA;AACvE,EAAA,OACE,MAAA,CAAO,SAAS,kBAAA,IAAsB,MAAA,CAAO,UAAU,IAAA,KAAS,YAAA,IAAgB,MAAA,CAAO,QAAA,CAAS,IAAA,KAAS,UAAA;AAE7G;AAoBA,MAAM,eAAA,GAAoD;AAAA,EACxD,aAAA,EAAe,mCAAA;AAAA,EACf,KAAA,EAAO,2BAAA;AAAA,EACP,QAAA,EAAU,8BAAA;AAAA,EACV,gBAAA,EAAkB;AACpB,CAAA;AA8CO,SAAS,6BAAA,CACd,IAAA,EACA,GAAA,EACA,GAAA,EAC6B;AAC7B,EAAA,MAAM,EAAA,GAAK,IAAI,WAAA,CAAY,IAAI,CAAA;AAC/B,EAAA,MAAM,eAAA,GAAkB,uBAAuB,GAAG,CAAA;AAClD,EAAA,MAAM,KAAA,GAAwB;AAAA,IAC5B,EAAA;AAAA,IACA,WAAA,EAAa,KAAA;AAAA,IACb,cAAA,sBAAoB,GAAA,EAAY;AAAA,IAChC,eAAA;AAAA,IAC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espaces.size === 0) {
|
|
4
|
+
return /* @__PURE__ */ new Set();
|
|
5
|
+
}
|
|
6
|
+
const classes = /* @__PURE__ */ new Map();
|
|
7
|
+
for (const node of ast.body) {
|
|
8
|
+
const classNode = asClassDeclaration(node);
|
|
9
|
+
if (classNode?.id?.name) classes.set(classNode.id.name, classNode);
|
|
10
|
+
}
|
|
11
|
+
const entrypoints = /* @__PURE__ */ new Set();
|
|
12
|
+
let changed = true;
|
|
13
|
+
while (changed) {
|
|
14
|
+
changed = false;
|
|
15
|
+
for (const [name, classNode] of classes) {
|
|
16
|
+
if (entrypoints.has(name)) continue;
|
|
17
|
+
if (extendsWorkerEntrypoint(classNode.superClass, bases, entrypoints)) {
|
|
18
|
+
entrypoints.add(name);
|
|
19
|
+
changed = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return entrypoints;
|
|
24
|
+
}
|
|
25
|
+
function asClassDeclaration(node) {
|
|
26
|
+
if (node.type === "ClassDeclaration") return node;
|
|
27
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
28
|
+
const decl = node.declaration;
|
|
29
|
+
if (decl?.type === "ClassDeclaration") return decl;
|
|
30
|
+
}
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
function collectWorkerEntrypointImports(ast) {
|
|
34
|
+
const named = /* @__PURE__ */ new Set();
|
|
35
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
36
|
+
for (const node of ast.body) {
|
|
37
|
+
if (node.type !== "ImportDeclaration") continue;
|
|
38
|
+
const importNode = node;
|
|
39
|
+
if (importNode.source?.value !== "cloudflare:workers") continue;
|
|
40
|
+
for (const specifier of importNode.specifiers ?? []) {
|
|
41
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported?.name === "WorkerEntrypoint" && specifier.local?.name) {
|
|
42
|
+
named.add(specifier.local.name);
|
|
43
|
+
} else if (specifier.type === "ImportNamespaceSpecifier" && specifier.local?.name) {
|
|
44
|
+
namespaces.add(specifier.local.name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { named, namespaces };
|
|
49
|
+
}
|
|
50
|
+
function extendsWorkerEntrypoint(superClass, bases, detected) {
|
|
51
|
+
if (!superClass) return false;
|
|
52
|
+
if (superClass.type === "Identifier") {
|
|
53
|
+
const name = superClass.name;
|
|
54
|
+
return bases.named.has(name) || detected.has(name);
|
|
55
|
+
}
|
|
56
|
+
if (superClass.type === "MemberExpression") {
|
|
57
|
+
const member = superClass;
|
|
58
|
+
return member.object?.type === "Identifier" && !!member.object.name && bases.namespaces.has(member.object.name) && member.property?.name === "WorkerEntrypoint";
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { detectWorkerEntrypointClasses };
|
|
64
|
+
//# sourceMappingURL=workerEntrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerEntrypoint.js","sources":["../../../../src/vite/workerEntrypoint.ts"],"sourcesContent":["import type { BaseNode, ProgramBody } from './transform';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node shapes for structural WorkerEntrypoint detection.\n// ---------------------------------------------------------------------------\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface MemberExpressionNode extends BaseNode {\n object?: { type: string; name?: string };\n property?: { type: string; name?: string };\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n superClass?: BaseNode | null;\n}\n\ninterface ExportNamedDeclNode extends BaseNode {\n declaration?: BaseNode | null;\n}\n\ninterface ImportSpecifierNode {\n type: string;\n imported?: { type: string; name?: string };\n local?: { type: string; name?: string };\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n source?: { value?: unknown };\n specifiers?: ImportSpecifierNode[];\n}\n\ninterface WorkerEntrypointBases {\n /** Local identifiers bound to the named `WorkerEntrypoint` import. */\n named: Set<string>;\n /** Local identifiers bound to a `* as ns` import of `cloudflare:workers`. */\n namespaces: Set<string>;\n}\n\n/**\n * Find top-level classes that (transitively, within this module) extend\n * `WorkerEntrypoint` imported from `cloudflare:workers`. esbuild has already\n * stripped TypeScript by transform time, so a superclass is a plain identifier\n * (`extends WorkerEntrypoint`) or member access (`extends cf.WorkerEntrypoint`).\n *\n * Only same-file base chains are resolvable here; a base class imported from\n * another module is invisible and relies on the config self-binding fallback.\n */\nexport function detectWorkerEntrypointClasses(ast: ProgramBody): Set<string> {\n const bases = collectWorkerEntrypointImports(ast);\n if (bases.named.size === 0 && bases.namespaces.size === 0) {\n return new Set<string>();\n }\n\n // Every top-level class, including the `export class Foo {}` form (where the\n // class is nested inside an ExportNamedDeclaration) so directly-exported\n // entrypoints are seen too.\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n const classNode = asClassDeclaration(node);\n if (classNode?.id?.name) classes.set(classNode.id.name, classNode);\n }\n\n const entrypoints = new Set<string>();\n // Iterate to a fixed point so an indirect chain (A extends B extends WE) is\n // fully resolved regardless of declaration order.\n let changed = true;\n while (changed) {\n changed = false;\n for (const [name, classNode] of classes) {\n if (entrypoints.has(name)) continue;\n if (extendsWorkerEntrypoint(classNode.superClass, bases, entrypoints)) {\n entrypoints.add(name);\n changed = true;\n }\n }\n }\n return entrypoints;\n}\n\n/** Unwrap `export class Foo {}` to its ClassDeclaration; pass bare classes through. */\nfunction asClassDeclaration(node: BaseNode): ClassDeclarationNode | undefined {\n if (node.type === 'ClassDeclaration') return node;\n if (node.type === 'ExportNamedDeclaration') {\n const decl = (node as ExportNamedDeclNode).declaration;\n if (decl?.type === 'ClassDeclaration') return decl;\n }\n return undefined;\n}\n\nfunction collectWorkerEntrypointImports(ast: ProgramBody): WorkerEntrypointBases {\n const named = new Set<string>();\n const namespaces = new Set<string>();\n for (const node of ast.body) {\n if (node.type !== 'ImportDeclaration') continue;\n const importNode = node as ImportDeclarationNode;\n if (importNode.source?.value !== 'cloudflare:workers') continue;\n for (const specifier of importNode.specifiers ?? []) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported?.name === 'WorkerEntrypoint' &&\n specifier.local?.name\n ) {\n named.add(specifier.local.name);\n } else if (specifier.type === 'ImportNamespaceSpecifier' && specifier.local?.name) {\n namespaces.add(specifier.local.name);\n }\n }\n }\n return { named, namespaces };\n}\n\n/**\n * Whether a superclass expression resolves to `WorkerEntrypoint` — either a bare\n * identifier from the named import (or an already-detected local subclass), or a\n * `ns.WorkerEntrypoint` member access off a namespace import.\n */\nfunction extendsWorkerEntrypoint(\n superClass: BaseNode | null | undefined,\n bases: WorkerEntrypointBases,\n detected: Set<string>,\n): boolean {\n if (!superClass) return false;\n if (superClass.type === 'Identifier') {\n const name = (superClass as IdentifierNode).name;\n return bases.named.has(name) || detected.has(name);\n }\n if (superClass.type === 'MemberExpression') {\n const member = superClass as MemberExpressionNode;\n return (\n member.object?.type === 'Identifier' &&\n !!member.object.name &&\n bases.namespaces.has(member.object.name) &&\n member.property?.name === 'WorkerEntrypoint'\n );\n }\n return false;\n}\n"],"names":[],"mappings":"AAmDO,SAAS,8BAA8B,GAAA,EAA+B;AAC3E,EAAA,MAAM,KAAA,GAAQ,+BAA+B,GAAG,CAAA;AAChD,EAAA,IAAI,MAAM,KAAA,CAAM,IAAA,KAAS,KAAK,KAAA,CAAM,UAAA,CAAW,SAAS,CAAA,EAAG;AACzD,IAAA,2BAAW,GAAA,EAAY;AAAA,EACzB;AAKA,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAkC;AACtD,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAI,IAAA,EAAM;AAC3B,IAAA,MAAM,SAAA,GAAY,mBAAmB,IAAI,CAAA;AACzC,IAAA,IAAI,SAAA,EAAW,IAAI,IAAA,EAAM,OAAA,CAAQ,IAAI,SAAA,CAAU,EAAA,CAAG,MAAM,SAAS,CAAA;AAAA,EACnE;AAEA,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAY;AAGpC,EAAA,IAAI,OAAA,GAAU,IAAA;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U,KAAA,EAAO,IAAA,EACjB;AACA,QAAA,KAAA,CAAM,GAAA,CAAI,SAAA,CAAU,KAAA,CAAM,IAAI,CAAA;AAAA,MAChC,WAAW,SAAA,CAAU,IAAA,KAAS,0BAAA,IAA8B,SAAA,CAAU,OAAO,IAAA,EAAM;AACjF,QAAA,UAAA,CAAW,GAAA,CAAI,SAAA,CAAU,KAAA,CAAM,IAAI,CAAA;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,EAAE,OAAO,UAAA,EAAW;AAC7B;AAOA,SAAS,uBAAA,CACP,UAAA,EACA,KAAA,EACA,QAAA,EACS;AACT,EAAA,IAAI,CAAC,YAAY,OAAO,KAAA;AACxB,EAAA,IAAI,UAAA,CAAW,SAAS,YAAA,EAAc;AACpC,IAAA,MAAM,OAAQ,UAAA,CAA8B,IAAA;AAC5C,IAAA,OAAO,MAAM,KAAA,CAAM,GAAA,CAAI,IAAI,CAAA,IAAK,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,UAAA,CAAW,SAAS,kBAAA,EAAoB;AAC1C,IAAA,MAAM,MAAA,GAAS,UAAA;AACf,IAAA,OACE,OAAO,MAAA,EAAQ,IAAA,KAAS,gBACxB,CAAC,CAAC,OAAO,MAAA,CAAO,IAAA,IAChB,KAAA,CAAM,UAAA,CAAW,IAAI,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,IACvC,MAAA,CAAO,UAAU,IAAA,KAAS,kBAAA;AAAA,EAE9B;AACA,EAAA,OAAO,KAAA;AACT;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { resolve, dirname } from 'node:path';
|
|
3
|
+
import { unstable_readConfig } from 'wrangler';
|
|
4
|
+
|
|
5
|
+
function resolveWranglerConfig(root, explicitPath) {
|
|
6
|
+
const configPath = explicitPath ? resolve(root, explicitPath) : ["wrangler.json", "wrangler.jsonc", "wrangler.toml"].map((name) => resolve(root, name)).find(existsSync);
|
|
7
|
+
if (!configPath || !existsSync(configPath)) {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
let raw;
|
|
11
|
+
try {
|
|
12
|
+
raw = unstable_readConfig({ config: configPath }, { hideWarnings: true });
|
|
13
|
+
} catch {
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
config: {
|
|
18
|
+
main: raw.main,
|
|
19
|
+
durableObjects: collectClassBindings(raw.durable_objects?.bindings),
|
|
20
|
+
workflows: collectClassBindings(raw.workflows),
|
|
21
|
+
workerEntrypoints: collectSelfBoundEntrypoints(raw)
|
|
22
|
+
},
|
|
23
|
+
configDir: dirname(raw.configPath ?? configPath)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function collectSelfBoundEntrypoints(raw) {
|
|
27
|
+
if (!raw.name) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const entrypoints = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const binding of raw.services ?? []) {
|
|
32
|
+
if (binding?.service === raw.name && typeof binding.entrypoint === "string") {
|
|
33
|
+
entrypoints.add(binding.entrypoint);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [...entrypoints];
|
|
37
|
+
}
|
|
38
|
+
function collectClassBindings(bindings) {
|
|
39
|
+
const result = [];
|
|
40
|
+
const seenClassNames = /* @__PURE__ */ new Set();
|
|
41
|
+
for (const binding of bindings ?? []) {
|
|
42
|
+
if (typeof binding?.class_name !== "string" || binding.script_name || seenClassNames.has(binding.class_name)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
seenClassNames.add(binding.class_name);
|
|
46
|
+
result.push({ name: binding.name, className: binding.class_name });
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { resolveWranglerConfig };
|
|
52
|
+
//# sourceMappingURL=wranglerConfig.js.map
|