@interfere/next 0.1.0-alpha.9 → 0.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +70 -277
  2. package/dist/_virtual/_rolldown/runtime.mjs +13 -0
  3. package/dist/config.d.mts +11 -0
  4. package/dist/config.d.mts.map +1 -0
  5. package/dist/config.mjs +107 -0
  6. package/dist/config.mjs.map +1 -0
  7. package/dist/instrument-client.d.mts +2 -0
  8. package/dist/instrument-client.mjs +2 -0
  9. package/dist/internal/build/configure-build.d.mts +22 -0
  10. package/dist/internal/build/configure-build.d.mts.map +1 -0
  11. package/dist/internal/build/configure-build.mjs +87 -0
  12. package/dist/internal/build/configure-build.mjs.map +1 -0
  13. package/dist/internal/build/injected.d.mts +12 -0
  14. package/dist/internal/build/injected.d.mts.map +1 -0
  15. package/dist/internal/build/injected.mjs +9 -0
  16. package/dist/internal/build/injected.mjs.map +1 -0
  17. package/dist/internal/build/release/destinations/vercel.d.mts +6 -0
  18. package/dist/internal/build/release/destinations/vercel.d.mts.map +1 -0
  19. package/dist/internal/build/release/destinations/vercel.mjs +25 -0
  20. package/dist/internal/build/release/destinations/vercel.mjs.map +1 -0
  21. package/dist/internal/build/release/git.d.mts +4 -0
  22. package/dist/internal/build/release/git.d.mts.map +1 -0
  23. package/dist/internal/build/release/git.mjs +21 -0
  24. package/dist/internal/build/release/git.mjs.map +1 -0
  25. package/dist/internal/build/release/index.d.mts +7 -0
  26. package/dist/internal/build/release/index.d.mts.map +1 -0
  27. package/dist/internal/build/release/index.mjs +24 -0
  28. package/dist/internal/build/release/index.mjs.map +1 -0
  29. package/dist/internal/build/release/sources/github.d.mts +6 -0
  30. package/dist/internal/build/release/sources/github.d.mts.map +1 -0
  31. package/dist/internal/build/release/sources/github.mjs +15 -0
  32. package/dist/internal/build/release/sources/github.mjs.map +1 -0
  33. package/dist/internal/build/release/types.d.mts +11 -0
  34. package/dist/internal/build/release/types.d.mts.map +1 -0
  35. package/dist/internal/build/release/types.mjs +1 -0
  36. package/dist/internal/build/source-maps/discover.d.mts +14 -0
  37. package/dist/internal/build/source-maps/discover.d.mts.map +1 -0
  38. package/dist/internal/build/source-maps/discover.mjs +61 -0
  39. package/dist/internal/build/source-maps/discover.mjs.map +1 -0
  40. package/dist/internal/build/source-maps/index.d.mts +23 -0
  41. package/dist/internal/build/source-maps/index.d.mts.map +1 -0
  42. package/dist/internal/build/source-maps/index.mjs +33 -0
  43. package/dist/internal/build/source-maps/index.mjs.map +1 -0
  44. package/dist/internal/build/value-injection-loader.d.mts +10 -0
  45. package/dist/internal/build/value-injection-loader.d.mts.map +1 -0
  46. package/dist/internal/build/value-injection-loader.mjs +24 -0
  47. package/dist/internal/build/value-injection-loader.mjs.map +1 -0
  48. package/dist/internal/env.d.mts +16 -0
  49. package/dist/internal/env.d.mts.map +1 -0
  50. package/dist/internal/env.mjs +19 -0
  51. package/dist/internal/env.mjs.map +1 -0
  52. package/dist/internal/logger.d.mts +8 -0
  53. package/dist/internal/logger.d.mts.map +1 -0
  54. package/dist/internal/logger.mjs +44 -0
  55. package/dist/internal/logger.mjs.map +1 -0
  56. package/dist/internal/route/cors.d.mts +4 -0
  57. package/dist/internal/route/cors.d.mts.map +1 -0
  58. package/dist/internal/route/cors.mjs +15 -0
  59. package/dist/internal/route/cors.mjs.map +1 -0
  60. package/dist/internal/route/handle-get.d.mts +4 -0
  61. package/dist/internal/route/handle-get.d.mts.map +1 -0
  62. package/dist/internal/route/handle-get.mjs +15 -0
  63. package/dist/internal/route/handle-get.mjs.map +1 -0
  64. package/dist/internal/route/handle-post.d.mts +4 -0
  65. package/dist/internal/route/handle-post.d.mts.map +1 -0
  66. package/dist/internal/route/handle-post.mjs +105 -0
  67. package/dist/internal/route/handle-post.mjs.map +1 -0
  68. package/dist/internal/route/sw-script.d.mts +4 -0
  69. package/dist/internal/route/sw-script.d.mts.map +1 -0
  70. package/dist/internal/route/sw-script.mjs +32 -0
  71. package/dist/internal/route/sw-script.mjs.map +1 -0
  72. package/dist/internal/server/capture.d.mts +9 -0
  73. package/dist/internal/server/capture.d.mts.map +1 -0
  74. package/dist/internal/server/capture.mjs +46 -0
  75. package/dist/internal/server/capture.mjs.map +1 -0
  76. package/dist/internal/server/dedupe.d.mts +5 -0
  77. package/dist/internal/server/dedupe.d.mts.map +1 -0
  78. package/dist/internal/server/dedupe.mjs +11 -0
  79. package/dist/internal/server/dedupe.mjs.map +1 -0
  80. package/dist/internal/server/envelope.d.mts +14 -0
  81. package/dist/internal/server/envelope.d.mts.map +1 -0
  82. package/dist/internal/server/envelope.mjs +41 -0
  83. package/dist/internal/server/envelope.mjs.map +1 -0
  84. package/dist/internal/server/mechanisms.d.mts +7 -0
  85. package/dist/internal/server/mechanisms.d.mts.map +1 -0
  86. package/dist/internal/server/mechanisms.mjs +12 -0
  87. package/dist/internal/server/mechanisms.mjs.map +1 -0
  88. package/dist/internal/server/normalize-request.d.mts +7 -0
  89. package/dist/internal/server/normalize-request.d.mts.map +1 -0
  90. package/dist/internal/server/normalize-request.mjs +50 -0
  91. package/dist/internal/server/normalize-request.mjs.map +1 -0
  92. package/dist/internal/server/runtime.d.mts +14 -0
  93. package/dist/internal/server/runtime.d.mts.map +1 -0
  94. package/dist/internal/server/runtime.mjs +18 -0
  95. package/dist/internal/server/runtime.mjs.map +1 -0
  96. package/dist/internal/server/session.d.mts +11 -0
  97. package/dist/internal/server/session.d.mts.map +1 -0
  98. package/dist/internal/server/session.mjs +15 -0
  99. package/dist/internal/server/session.mjs.map +1 -0
  100. package/dist/internal/server/transport.d.mts +14 -0
  101. package/dist/internal/server/transport.d.mts.map +1 -0
  102. package/dist/internal/server/transport.mjs +16 -0
  103. package/dist/internal/server/transport.mjs.map +1 -0
  104. package/dist/internal/server/types.d.mts +17 -0
  105. package/dist/internal/server/types.d.mts.map +1 -0
  106. package/dist/internal/server/types.mjs +1 -0
  107. package/dist/provider.d.mts +2 -0
  108. package/dist/provider.mjs +3 -0
  109. package/dist/route-handler.d.mts +7 -0
  110. package/dist/route-handler.d.mts.map +1 -0
  111. package/dist/route-handler.mjs +18 -0
  112. package/dist/route-handler.mjs.map +1 -0
  113. package/dist/server.d.mts +8 -0
  114. package/dist/server.d.mts.map +1 -0
  115. package/dist/server.mjs +6 -0
  116. package/dist/server.mjs.map +1 -0
  117. package/package.json +60 -73
  118. package/LICENSE +0 -21
  119. package/dist/build/env-config.d.mts +0 -7
  120. package/dist/build/env-config.d.mts.map +0 -1
  121. package/dist/build/env-config.mjs +0 -17
  122. package/dist/build/env-config.mjs.map +0 -1
  123. package/dist/build/loaders/value-injection-loader.d.mts +0 -28
  124. package/dist/build/loaders/value-injection-loader.d.mts.map +0 -1
  125. package/dist/build/loaders/value-injection-loader.mjs +0 -44
  126. package/dist/build/loaders/value-injection-loader.mjs.map +0 -1
  127. package/dist/build/logger.d.mts +0 -11
  128. package/dist/build/logger.d.mts.map +0 -1
  129. package/dist/build/logger.mjs +0 -155
  130. package/dist/build/logger.mjs.map +0 -1
  131. package/dist/build/release-program.d.mts +0 -19
  132. package/dist/build/release-program.d.mts.map +0 -1
  133. package/dist/build/release-program.mjs +0 -92
  134. package/dist/build/release-program.mjs.map +0 -1
  135. package/dist/build/secret-key.d.mts +0 -10
  136. package/dist/build/secret-key.d.mts.map +0 -1
  137. package/dist/build/secret-key.mjs +0 -16
  138. package/dist/build/secret-key.mjs.map +0 -1
  139. package/dist/build/services/config.service.d.mts +0 -9
  140. package/dist/build/services/config.service.d.mts.map +0 -1
  141. package/dist/build/services/config.service.mjs +0 -8
  142. package/dist/build/services/config.service.mjs.map +0 -1
  143. package/dist/build/services/instrumentation-detection.service.d.mts +0 -22
  144. package/dist/build/services/instrumentation-detection.service.d.mts.map +0 -1
  145. package/dist/build/services/instrumentation-detection.service.mjs +0 -60
  146. package/dist/build/services/instrumentation-detection.service.mjs.map +0 -1
  147. package/dist/build/services/preflight.service.d.mts +0 -19
  148. package/dist/build/services/preflight.service.d.mts.map +0 -1
  149. package/dist/build/services/preflight.service.mjs +0 -76
  150. package/dist/build/services/preflight.service.mjs.map +0 -1
  151. package/dist/build/services/release-identity.service.d.mts +0 -22
  152. package/dist/build/services/release-identity.service.d.mts.map +0 -1
  153. package/dist/build/services/release-identity.service.mjs +0 -48
  154. package/dist/build/services/release-identity.service.mjs.map +0 -1
  155. package/dist/build/services/source-map.service.d.mts +0 -24
  156. package/dist/build/services/source-map.service.d.mts.map +0 -1
  157. package/dist/build/services/source-map.service.mjs +0 -58
  158. package/dist/build/services/source-map.service.mjs.map +0 -1
  159. package/dist/build/source-maps/api.d.mts +0 -35
  160. package/dist/build/source-maps/api.d.mts.map +0 -1
  161. package/dist/build/source-maps/api.mjs +0 -61
  162. package/dist/build/source-maps/api.mjs.map +0 -1
  163. package/dist/build/source-maps/client.d.mts +0 -73
  164. package/dist/build/source-maps/client.d.mts.map +0 -1
  165. package/dist/build/source-maps/client.mjs +0 -228
  166. package/dist/build/source-maps/client.mjs.map +0 -1
  167. package/dist/build/source-maps/errors.d.mts +0 -109
  168. package/dist/build/source-maps/errors.d.mts.map +0 -1
  169. package/dist/build/source-maps/errors.mjs +0 -22
  170. package/dist/build/source-maps/errors.mjs.map +0 -1
  171. package/dist/build/source-maps/files.d.mts +0 -35
  172. package/dist/build/source-maps/files.d.mts.map +0 -1
  173. package/dist/build/source-maps/files.mjs +0 -222
  174. package/dist/build/source-maps/files.mjs.map +0 -1
  175. package/dist/build/source-maps/providers/deployment/detector.d.mts +0 -26
  176. package/dist/build/source-maps/providers/deployment/detector.d.mts.map +0 -1
  177. package/dist/build/source-maps/providers/deployment/detector.mjs +0 -22
  178. package/dist/build/source-maps/providers/deployment/detector.mjs.map +0 -1
  179. package/dist/build/source-maps/providers/deployment/types.d.mts +0 -12
  180. package/dist/build/source-maps/providers/deployment/types.d.mts.map +0 -1
  181. package/dist/build/source-maps/providers/deployment/types.mjs +0 -3
  182. package/dist/build/source-maps/providers/deployment/vercel.d.mts +0 -6
  183. package/dist/build/source-maps/providers/deployment/vercel.d.mts.map +0 -1
  184. package/dist/build/source-maps/providers/deployment/vercel.mjs +0 -44
  185. package/dist/build/source-maps/providers/deployment/vercel.mjs.map +0 -1
  186. package/dist/build/source-maps/providers/source-control/detector.d.mts +0 -15
  187. package/dist/build/source-maps/providers/source-control/detector.d.mts.map +0 -1
  188. package/dist/build/source-maps/providers/source-control/detector.mjs +0 -22
  189. package/dist/build/source-maps/providers/source-control/detector.mjs.map +0 -1
  190. package/dist/build/source-maps/providers/source-control/git.d.mts +0 -6
  191. package/dist/build/source-maps/providers/source-control/git.d.mts.map +0 -1
  192. package/dist/build/source-maps/providers/source-control/git.mjs +0 -50
  193. package/dist/build/source-maps/providers/source-control/git.mjs.map +0 -1
  194. package/dist/build/source-maps/providers/source-control/types.d.mts +0 -12
  195. package/dist/build/source-maps/providers/source-control/types.d.mts.map +0 -1
  196. package/dist/build/source-maps/providers/source-control/types.mjs +0 -3
  197. package/dist/build/with-interfere.d.mts +0 -70
  198. package/dist/build/with-interfere.d.mts.map +0 -1
  199. package/dist/build/with-interfere.mjs +0 -154
  200. package/dist/build/with-interfere.mjs.map +0 -1
  201. package/dist/client/auto-init.d.mts +0 -92
  202. package/dist/client/auto-init.d.mts.map +0 -1
  203. package/dist/client/auto-init.mjs +0 -121
  204. package/dist/client/auto-init.mjs.map +0 -1
  205. package/dist/client/client.d.mts +0 -3
  206. package/dist/client/client.mjs +0 -5
  207. package/dist/client/provider.d.mts +0 -22
  208. package/dist/client/provider.d.mts.map +0 -1
  209. package/dist/client/provider.mjs +0 -50
  210. package/dist/client/provider.mjs.map +0 -1
  211. package/dist/lib/env.d.mts +0 -12
  212. package/dist/lib/env.d.mts.map +0 -1
  213. package/dist/lib/env.mjs +0 -17
  214. package/dist/lib/env.mjs.map +0 -1
  215. package/dist/lib/test-utils/make-next-request.d.mts +0 -6
  216. package/dist/lib/test-utils/make-next-request.d.mts.map +0 -1
  217. package/dist/lib/test-utils/make-next-request.mjs +0 -12
  218. package/dist/lib/test-utils/make-next-request.mjs.map +0 -1
  219. package/dist/lib/types.d.mts +0 -22
  220. package/dist/lib/types.d.mts.map +0 -1
  221. package/dist/lib/types.mjs +0 -7
  222. package/dist/lib/types.mjs.map +0 -1
  223. package/dist/server/middleware.d.mts +0 -11
  224. package/dist/server/middleware.d.mts.map +0 -1
  225. package/dist/server/middleware.mjs +0 -85
  226. package/dist/server/middleware.mjs.map +0 -1
  227. package/dist/server/proxy.d.mts +0 -6
  228. package/dist/server/proxy.d.mts.map +0 -1
  229. package/dist/server/proxy.mjs +0 -30
  230. package/dist/server/proxy.mjs.map +0 -1
  231. package/dist/server/route-handler.d.mts +0 -9
  232. package/dist/server/route-handler.d.mts.map +0 -1
  233. package/dist/server/route-handler.mjs +0 -172
  234. package/dist/server/route-handler.mjs.map +0 -1
  235. package/dist/server/services/config.service.d.mts +0 -21
  236. package/dist/server/services/config.service.d.mts.map +0 -1
  237. package/dist/server/services/config.service.mjs +0 -43
  238. package/dist/server/services/config.service.mjs.map +0 -1
  239. package/dist/server/services/error-tracking.service.d.mts +0 -19
  240. package/dist/server/services/error-tracking.service.d.mts.map +0 -1
  241. package/dist/server/services/error-tracking.service.mjs +0 -31
  242. package/dist/server/services/error-tracking.service.mjs.map +0 -1
@@ -1,154 +0,0 @@
1
- import { nextBuildLogger } from "./logger.mjs";
2
- import { ReleaseIdentityService, ReleaseIdentityServiceLive } from "./services/release-identity.service.mjs";
3
- import { createReleaseLayers, releaseProgram } from "./release-program.mjs";
4
- import { detectInstrumentationFilesSync } from "./services/instrumentation-detection.service.mjs";
5
- import { PreflightService, PreflightServiceLive } from "./services/preflight.service.mjs";
6
- import { withInterfereLogger } from "@interfere/effect-utils/observability";
7
- import { Effect, Layer, LogLevel, Logger, Option } from "effect";
8
- import * as path$1 from "node:path";
9
- import { fileURLToPath } from "node:url";
10
-
11
- //#region src/build/with-interfere.ts
12
- /**
13
- * Next.js configuration wrapper that automatically uploads source maps in production builds
14
- *
15
- * SECURITY: Secret key must be set via INTERFERE_SECRET_KEY env var (without NEXT_PUBLIC_ prefix)
16
- *
17
- * @example
18
- * ```js
19
- * // next.config.js
20
- * import { withInterfere } from '@interfere/next/config';
21
- *
22
- * export default withInterfere({
23
- * environment: 'staging',
24
- * debug: true,
25
- * cleanupSourceMaps: true
26
- * })({
27
- * // Your Next.js config
28
- * });
29
- * ```
30
- */
31
- function withInterfere({ interfere = {}, ...nextConfig } = {}) {
32
- const interfereConfig = Effect.gen(function* () {
33
- return yield* (yield* PreflightService).buildConfig(interfere);
34
- }).pipe(Effect.provide(PreflightServiceLive), Effect.runSync);
35
- const identityProgram = Effect.gen(function* () {
36
- return yield* (yield* ReleaseIdentityService).pipe(Effect.option);
37
- }).pipe(Effect.provide(ReleaseIdentityServiceLive), Effect.runSync);
38
- const identity = Option.getOrUndefined(identityProgram);
39
- let instrumentationFiles;
40
- try {
41
- instrumentationFiles = detectInstrumentationFilesSync();
42
- } catch {
43
- instrumentationFiles = {
44
- server: null,
45
- client: null
46
- };
47
- }
48
- return function buildConfig() {
49
- const env = {
50
- ...nextConfig.env,
51
- NEXT_PUBLIC_INTERFERE_ENVIRONMENT: interfereConfig.environment,
52
- ...identity?.buildId ? { NEXT_PUBLIC_INTERFERE_BUILD_ID: identity.buildId } : {},
53
- ...identity?.releaseId ? { NEXT_PUBLIC_INTERFERE_RELEASE_ID: identity.releaseId } : {}
54
- };
55
- const compiler = !interfereConfig.enabled ? nextConfig.compiler : {
56
- ...nextConfig.compiler,
57
- runAfterProductionCompile: async (ctx) => {
58
- const debugEnabled = process.env.INTERFERE_PLUGIN_DEBUG === "1";
59
- const startTime = Date.now();
60
- if (debugEnabled) console.log("[Interfere Plugin] Starting runAfterProductionCompile");
61
- const existingHook = nextConfig.compiler?.runAfterProductionCompile;
62
- if (existingHook) {
63
- const hookStart = Date.now();
64
- await existingHook(ctx);
65
- if (debugEnabled) console.log(`[Interfere Plugin] Existing hook completed in ${Date.now() - hookStart}ms`);
66
- }
67
- const scopedProgram = releaseProgram.pipe(Effect.provide(createReleaseLayers(interfereConfig)), Effect.scoped, debugEnabled ? Logger.withMinimumLogLevel(LogLevel.Debug) : (x) => x);
68
- const programStart = Date.now();
69
- await Effect.runPromise(withInterfereLogger("next", scopedProgram, { logger: nextBuildLogger }));
70
- if (debugEnabled) {
71
- console.log(`[Interfere Plugin] Release program completed in ${Date.now() - programStart}ms`);
72
- console.log(`[Interfere Plugin] Total runAfterProductionCompile time: ${Date.now() - startTime}ms`);
73
- }
74
- }
75
- };
76
- const injectionValues = {
77
- __INTERFERE_BUILD_ID__: identity?.buildId ?? null,
78
- __INTERFERE_RELEASE_ID__: identity?.releaseId ?? null,
79
- __INTERFERE_ENVIRONMENT__: interfereConfig.environment,
80
- __INTERFERE_ENABLED__: interfereConfig.enabled,
81
- ...interfere.features && { __INTERFERE_FEATURES__: interfere.features }
82
- };
83
- const webpack = createWebpackConfig(nextConfig.webpack, instrumentationFiles.client, injectionValues);
84
- const turbopack = createTurbopackConfig(nextConfig.turbopack, instrumentationFiles.client, injectionValues);
85
- return {
86
- ...nextConfig,
87
- compiler,
88
- env,
89
- webpack,
90
- turbopack,
91
- productionBrowserSourceMaps: interfereConfig.enabled ? true : nextConfig.productionBrowserSourceMaps
92
- };
93
- };
94
- }
95
- /**
96
- * Creates webpack configuration that applies value injection loader to instrumentation-client files.
97
- */
98
- function createWebpackConfig(existingWebpack, clientFilePath, injectionValues) {
99
- if (!clientFilePath) return existingWebpack ?? ((config) => config);
100
- const webpackConfigFn = (config, options) => {
101
- const instrumentationRule = {
102
- test: (resource) => {
103
- if (!resource) return false;
104
- return path$1.normalize(resource) === path$1.normalize(clientFilePath);
105
- },
106
- use: {
107
- loader: path$1.resolve(path$1.dirname(fileURLToPath(import.meta.url)), "loaders", "value-injection-loader.js"),
108
- options: { values: injectionValues }
109
- }
110
- };
111
- let resultConfig = config;
112
- if (existingWebpack) resultConfig = existingWebpack(config, options);
113
- const webpackConfig = resultConfig;
114
- webpackConfig.module = webpackConfig.module ?? {};
115
- webpackConfig.module.rules = webpackConfig.module.rules ?? [];
116
- webpackConfig.module.rules.push(instrumentationRule);
117
- return resultConfig;
118
- };
119
- return webpackConfigFn;
120
- }
121
- /**
122
- * Converts values to a JSON string representation that preserves null semantics.
123
- * This avoids the issue of losing null values when they're converted to empty strings.
124
- * The loader will parse this string back to the original values.
125
- * @internal
126
- */
127
- function serializeForTurbopack(value) {
128
- return JSON.stringify(value);
129
- }
130
- /**
131
- * Creates turbopack configuration that applies value injection loader to instrumentation-client files.
132
- *
133
- * Note: Turbopack loader options must be JSON-serializable, so we serialize the injection values.
134
- */
135
- function createTurbopackConfig(existingTurbopack, clientFilePath, injectionValues) {
136
- const loaderPath = path$1.resolve(path$1.dirname(fileURLToPath(import.meta.url)), "loaders", "value-injection-loader.js");
137
- const baseTurbopack = existingTurbopack ?? {};
138
- if (!clientFilePath) return baseTurbopack;
139
- const clientFileName = path$1.basename(clientFilePath);
140
- const serializedValues = serializeForTurbopack(injectionValues);
141
- return {
142
- ...baseTurbopack,
143
- rules: {
144
- ...baseTurbopack.rules,
145
- [`**/${clientFileName}`]: { loaders: [{
146
- loader: loaderPath,
147
- options: { serializedValues }
148
- }] }
149
- }
150
- };
151
- }
152
-
153
- //#endregion
154
- export { withInterfere };
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-interfere.mjs","names":["instrumentationFiles: InstrumentationFiles","injectionValues: Record<string, unknown>","webpackConfigFn: NonNullable<NextConfig[\"webpack\"]>","instrumentationRule: RuleSetRule","path"],"sources":["../../src/build/with-interfere.ts"],"sourcesContent":["import { withInterfereLogger } from \"@interfere/effect-utils/observability\";\nimport { Effect, Layer, Logger, LogLevel, Option } from \"effect\";\nimport type { NextConfig } from \"next\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Configuration as WebpackConfiguration, RuleSetRule } from \"webpack\";\nimport { nextBuildLogger } from \"./logger.js\";\nimport type { ValueInjectionLoaderOptions } from \"./loaders/value-injection-loader.js\";\nimport { createReleaseLayers, releaseProgram } from \"./release-program.js\";\nimport {\n detectInstrumentationFilesSync,\n type InstrumentationFiles,\n} from \"./services/instrumentation-detection.service.js\";\nimport { PreflightService, PreflightServiceLive } from \"./services/preflight.service.js\";\nimport { ReleaseIdentityService, ReleaseIdentityServiceLive } from \"./services/release-identity.service.js\";\n\nexport type InterfereFeatures = {\n /**\n * Enable error tracking\n * @default true\n */\n errorTracking?: boolean;\n\n /**\n * Enable session replay\n * @default true in production, false in development\n */\n replay?: boolean;\n\n /**\n * Enable performance monitoring\n * @default true\n */\n performanceMonitoring?: boolean;\n};\n\nexport type InterfereOptions = {\n /**\n * Environment name\n * @default \"production\"\n */\n environment?: string;\n\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Whether to delete source maps after upload to prevent leakage\n * @default true\n */\n cleanupSourceMaps?: boolean;\n\n /**\n * Feature flags for the SDK.\n * These are injected at build time and available to the client SDK.\n */\n features?: InterfereFeatures;\n};\n\ntype NextConfigWithInterfere = NextConfig & {\n interfere?: InterfereOptions;\n};\n\n/**\n * Next.js configuration wrapper that automatically uploads source maps in production builds\n *\n * SECURITY: Secret key must be set via INTERFERE_SECRET_KEY env var (without NEXT_PUBLIC_ prefix)\n *\n * @example\n * ```js\n * // next.config.js\n * import { withInterfere } from '@interfere/next/config';\n *\n * export default withInterfere({\n * environment: 'staging',\n * debug: true,\n * cleanupSourceMaps: true\n * })({\n * // Your Next.js config\n * });\n * ```\n */\nexport function withInterfere({\n interfere = {},\n ...nextConfig\n}: NextConfigWithInterfere = {}): () => NextConfig {\n // Build the preflight config using the service\n const configProgram = Effect.gen(function* () {\n const preflight = yield* PreflightService;\n return yield* preflight.buildConfig(interfere);\n }).pipe(\n Effect.provide(PreflightServiceLive),\n Effect.runSync\n );\n\n const interfereConfig = configProgram;\n \n // Use the ReleaseIdentityService to infer build/release IDs\n // This runs the same logic that the release program uses\n const identityProgram = Effect.gen(function* () {\n const identityEffect = yield* ReleaseIdentityService;\n return yield* identityEffect.pipe(Effect.option);\n }).pipe(\n Effect.provide(ReleaseIdentityServiceLive),\n Effect.runSync\n );\n \n const identity = Option.getOrUndefined(identityProgram);\n\n // Detect instrumentation files for automatic client initialization\n let instrumentationFiles: InstrumentationFiles;\n try {\n instrumentationFiles = detectInstrumentationFilesSync();\n } catch {\n // If detection fails, assume no instrumentation files\n instrumentationFiles = { server: null, client: null };\n }\n\n return function buildConfig() {\n // Use the same release identity logic that the release program uses\n // This ensures consistency between what gets uploaded and what the client SDK sends\n const env = {\n ...nextConfig.env,\n // Pass the deduced/configured environment to the client SDK\n // (it defaults to NODE_ENV in preflight service)\n NEXT_PUBLIC_INTERFERE_ENVIRONMENT: interfereConfig.environment,\n // Pass the inferred build/release IDs to the client SDK\n // These come from the same ReleaseIdentityService that the release program uses\n ...(identity?.buildId\n ? { NEXT_PUBLIC_INTERFERE_BUILD_ID: identity.buildId }\n : {}),\n ...(identity?.releaseId\n ? { NEXT_PUBLIC_INTERFERE_RELEASE_ID: identity.releaseId }\n : {}),\n };\n\n // Set up compiler hook if enabled\n const compiler = !interfereConfig.enabled\n ? nextConfig.compiler\n : {\n ...nextConfig.compiler,\n runAfterProductionCompile: async (ctx: {\n projectDir: string;\n distDir: string;\n }) => {\n const debugEnabled = process.env.INTERFERE_PLUGIN_DEBUG === \"1\";\n const startTime = Date.now();\n\n if (debugEnabled) {\n console.log(\"[Interfere Plugin] Starting runAfterProductionCompile\");\n }\n\n // Run existing hook first\n const existingHook = nextConfig.compiler?.runAfterProductionCompile;\n if (existingHook) {\n const hookStart = Date.now();\n await existingHook(ctx);\n if (debugEnabled) {\n console.log(`[Interfere Plugin] Existing hook completed in ${Date.now() - hookStart}ms`);\n }\n }\n\n // Run the unified release program with all layers\n const scopedProgram = releaseProgram.pipe(\n Effect.provide(createReleaseLayers(interfereConfig)),\n Effect.scoped,\n debugEnabled\n ? Logger.withMinimumLogLevel(LogLevel.Debug)\n : (x) => x\n ) as Effect.Effect<unknown, unknown, never>;\n\n const programStart = Date.now();\n await Effect.runPromise(\n withInterfereLogger(\"next\", scopedProgram, { logger: nextBuildLogger })\n );\n if (debugEnabled) {\n console.log(`[Interfere Plugin] Release program completed in ${Date.now() - programStart}ms`);\n console.log(`[Interfere Plugin] Total runAfterProductionCompile time: ${Date.now() - startTime}ms`);\n }\n },\n };\n\n // Build-time values to inject into instrumentation-client.ts\n // These are read by @interfere/next/auto-init at runtime\n const injectionValues: Record<string, unknown> = {\n __INTERFERE_BUILD_ID__: identity?.buildId ?? null,\n __INTERFERE_RELEASE_ID__: identity?.releaseId ?? null,\n __INTERFERE_ENVIRONMENT__: interfereConfig.environment,\n __INTERFERE_ENABLED__: interfereConfig.enabled,\n // Feature flags - only include if explicitly set\n ...(interfere.features && {\n __INTERFERE_FEATURES__: interfere.features,\n }),\n };\n\n // Configure webpack to apply value injection loader to instrumentation-client files\n const webpack = createWebpackConfig(\n nextConfig.webpack,\n instrumentationFiles.client,\n injectionValues\n );\n\n // Configure turbopack to apply value injection loader to instrumentation-client files\n const turbopack = createTurbopackConfig(\n nextConfig.turbopack,\n instrumentationFiles.client,\n injectionValues\n );\n\n return {\n ...nextConfig,\n compiler,\n env,\n webpack,\n turbopack,\n // Automatically enable browser source maps when Interfere is enabled\n productionBrowserSourceMaps: interfereConfig.enabled\n ? true\n : nextConfig.productionBrowserSourceMaps,\n };\n };\n}\n\n/**\n * Creates webpack configuration that applies value injection loader to instrumentation-client files.\n */\nfunction createWebpackConfig(\n existingWebpack: NextConfig[\"webpack\"],\n clientFilePath: string | null,\n injectionValues: Record<string, unknown>\n): NextConfig[\"webpack\"] {\n // If no instrumentation-client file, return existing webpack config or identity function\n // This ensures webpack is never undefined, matching the turbopack pattern\n if (!clientFilePath) {\n return existingWebpack ?? ((config) => config);\n }\n\n const webpackConfigFn: NonNullable<NextConfig[\"webpack\"]> = (config, options) => {\n // Resolve the loader path relative to this file\n // Use fileURLToPath for cross-platform compatibility (Windows support)\n const loaderPath = path.resolve(\n path.dirname(fileURLToPath(import.meta.url)),\n \"loaders\",\n \"value-injection-loader.js\"\n );\n\n // Create a rule that matches only the instrumentation-client file\n const instrumentationRule: RuleSetRule = {\n test: (resource: string) => {\n if (!resource) return false;\n // Match the exact instrumentation-client file path\n const normalizedResource = path.normalize(resource);\n const normalizedClientPath = path.normalize(clientFilePath);\n return normalizedResource === normalizedClientPath;\n },\n use: {\n loader: loaderPath,\n options: { values: injectionValues } satisfies ValueInjectionLoaderOptions,\n },\n };\n\n // Call existing webpack config first, if provided\n // This ensures we add our rule to whatever config object is returned\n let resultConfig = config;\n if (existingWebpack) {\n resultConfig = existingWebpack(config, options);\n }\n\n // Add the rule to the result config\n // This ensures the rule is added regardless of whether the webpack function\n // returned the original config or created a new object\n const webpackConfig = resultConfig as WebpackConfiguration;\n webpackConfig.module = webpackConfig.module ?? {};\n webpackConfig.module.rules = webpackConfig.module.rules ?? [];\n webpackConfig.module.rules.push(instrumentationRule);\n\n return resultConfig;\n };\n\n return webpackConfigFn;\n}\n\n// JSONValue type from Next.js - doesn't allow null\ntype JSONValue = string | number | boolean | JSONValue[] | { [k: string]: JSONValue };\n\n/**\n * Converts values to a JSON string representation that preserves null semantics.\n * This avoids the issue of losing null values when they're converted to empty strings.\n * The loader will parse this string back to the original values.\n * @internal\n */\nfunction serializeForTurbopack(value: unknown): string {\n // Use JSON.stringify which correctly handles null, arrays, and objects\n return JSON.stringify(value);\n}\n\n/**\n * Creates turbopack configuration that applies value injection loader to instrumentation-client files.\n * \n * Note: Turbopack loader options must be JSON-serializable, so we serialize the injection values.\n */\nfunction createTurbopackConfig(\n existingTurbopack: NextConfig[\"turbopack\"],\n clientFilePath: string | null,\n injectionValues: Record<string, unknown>\n): NextConfig[\"turbopack\"] {\n // Resolve the loader path relative to this file\n // Use fileURLToPath for cross-platform compatibility (Windows support)\n const loaderPath = path.resolve(\n path.dirname(fileURLToPath(import.meta.url)),\n \"loaders\",\n \"value-injection-loader.js\"\n );\n\n // Base turbopack config (preserve existing or empty object)\n const baseTurbopack = existingTurbopack ?? {};\n\n // If no instrumentation-client file, return base config\n if (!clientFilePath) {\n return baseTurbopack;\n }\n\n // Create glob pattern for the instrumentation-client file\n // Turbopack rules use glob patterns\n const clientFileName = path.basename(clientFilePath);\n\n // Serialize injection values to preserve null semantics.\n // Turbopack options must be JSON-serializable, but the loader can receive\n // a serialized JSON string that it will parse to recover the original values.\n const serializedValues = serializeForTurbopack(injectionValues);\n\n return {\n ...baseTurbopack,\n rules: {\n ...baseTurbopack.rules,\n // Match instrumentation-client files in any location\n [`**/${clientFileName}`]: {\n loaders: [\n {\n loader: loaderPath,\n options: {\n // Pass as serialized JSON string to preserve null values\n serializedValues,\n } as Record<string, JSONValue>,\n },\n ],\n },\n },\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAgB,cAAc,EAC5B,YAAY,EAAE,EACd,GAAG,eACwB,EAAE,EAAoB;CAUjD,MAAM,kBARgB,OAAO,IAAI,aAAa;AAE5C,SAAO,QADW,OAAO,kBACD,YAAY,UAAU;GAC9C,CAAC,KACD,OAAO,QAAQ,qBAAqB,EACpC,OAAO,QACR;CAMD,MAAM,kBAAkB,OAAO,IAAI,aAAa;AAE9C,SAAO,QADgB,OAAO,wBACD,KAAK,OAAO,OAAO;GAChD,CAAC,KACD,OAAO,QAAQ,2BAA2B,EAC1C,OAAO,QACR;CAED,MAAM,WAAW,OAAO,eAAe,gBAAgB;CAGvD,IAAIA;AACJ,KAAI;AACF,yBAAuB,gCAAgC;SACjD;AAEN,yBAAuB;GAAE,QAAQ;GAAM,QAAQ;GAAM;;AAGvD,QAAO,SAAS,cAAc;EAG5B,MAAM,MAAM;GACV,GAAG,WAAW;GAGd,mCAAmC,gBAAgB;GAGnD,GAAI,UAAU,UACV,EAAE,gCAAgC,SAAS,SAAS,GACpD,EAAE;GACN,GAAI,UAAU,YACV,EAAE,kCAAkC,SAAS,WAAW,GACxD,EAAE;GACP;EAGD,MAAM,WAAW,CAAC,gBAAgB,UAC9B,WAAW,WACX;GACE,GAAG,WAAW;GACd,2BAA2B,OAAO,QAG5B;IACJ,MAAM,eAAe,QAAQ,IAAI,2BAA2B;IAC5D,MAAM,YAAY,KAAK,KAAK;AAE5B,QAAI,aACF,SAAQ,IAAI,wDAAwD;IAItE,MAAM,eAAe,WAAW,UAAU;AAC1C,QAAI,cAAc;KAChB,MAAM,YAAY,KAAK,KAAK;AAC5B,WAAM,aAAa,IAAI;AACvB,SAAI,aACF,SAAQ,IAAI,iDAAiD,KAAK,KAAK,GAAG,UAAU,IAAI;;IAK5F,MAAM,gBAAgB,eAAe,KACnC,OAAO,QAAQ,oBAAoB,gBAAgB,CAAC,EACpD,OAAO,QACP,eACI,OAAO,oBAAoB,SAAS,MAAM,IACzC,MAAM,EACZ;IAED,MAAM,eAAe,KAAK,KAAK;AAC/B,UAAM,OAAO,WACX,oBAAoB,QAAQ,eAAe,EAAE,QAAQ,iBAAiB,CAAC,CACxE;AACD,QAAI,cAAc;AAChB,aAAQ,IAAI,mDAAmD,KAAK,KAAK,GAAG,aAAa,IAAI;AAC7F,aAAQ,IAAI,4DAA4D,KAAK,KAAK,GAAG,UAAU,IAAI;;;GAGxG;EAIL,MAAMC,kBAA2C;GAC/C,wBAAwB,UAAU,WAAW;GAC7C,0BAA0B,UAAU,aAAa;GACjD,2BAA2B,gBAAgB;GAC3C,uBAAuB,gBAAgB;GAEvC,GAAI,UAAU,YAAY,EACxB,wBAAwB,UAAU,UACnC;GACF;EAGD,MAAM,UAAU,oBACd,WAAW,SACX,qBAAqB,QACrB,gBACD;EAGD,MAAM,YAAY,sBAChB,WAAW,WACX,qBAAqB,QACrB,gBACD;AAED,SAAO;GACL,GAAG;GACH;GACA;GACA;GACA;GAEA,6BAA6B,gBAAgB,UACzC,OACA,WAAW;GAChB;;;;;;AAOL,SAAS,oBACP,iBACA,gBACA,iBACuB;AAGvB,KAAI,CAAC,eACH,QAAO,qBAAqB,WAAW;CAGzC,MAAMC,mBAAuD,QAAQ,YAAY;EAU/E,MAAMC,sBAAmC;GACvC,OAAO,aAAqB;AAC1B,QAAI,CAAC,SAAU,QAAO;AAItB,WAF2BC,OAAK,UAAU,SAAS,KACtBA,OAAK,UAAU,eAAe;;GAG7D,KAAK;IACH,QAhBeA,OAAK,QACtBA,OAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAC5C,WACA,4BACD;IAaG,SAAS,EAAE,QAAQ,iBAAiB;IACrC;GACF;EAID,IAAI,eAAe;AACnB,MAAI,gBACF,gBAAe,gBAAgB,QAAQ,QAAQ;EAMjD,MAAM,gBAAgB;AACtB,gBAAc,SAAS,cAAc,UAAU,EAAE;AACjD,gBAAc,OAAO,QAAQ,cAAc,OAAO,SAAS,EAAE;AAC7D,gBAAc,OAAO,MAAM,KAAK,oBAAoB;AAEpD,SAAO;;AAGT,QAAO;;;;;;;;AAYT,SAAS,sBAAsB,OAAwB;AAErD,QAAO,KAAK,UAAU,MAAM;;;;;;;AAQ9B,SAAS,sBACP,mBACA,gBACA,iBACyB;CAGzB,MAAM,aAAaA,OAAK,QACtBA,OAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAC5C,WACA,4BACD;CAGD,MAAM,gBAAgB,qBAAqB,EAAE;AAG7C,KAAI,CAAC,eACH,QAAO;CAKT,MAAM,iBAAiBA,OAAK,SAAS,eAAe;CAKpD,MAAM,mBAAmB,sBAAsB,gBAAgB;AAE/D,QAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,cAAc;IAEhB,MAAM,mBAAmB,EACxB,SAAS,CACP;IACE,QAAQ;IACR,SAAS,EAEP,kBACD;IACF,CACF,EACF;GACF;EACF"}
@@ -1,92 +0,0 @@
1
- import { Config } from "@interfere/types/sdk/config";
2
-
3
- //#region src/client/auto-init.d.ts
4
-
5
- /**
6
- * Feature flags that can be injected at build time.
7
- */
8
- interface InjectedFeatures {
9
- errorTracking?: boolean;
10
- replay?: boolean;
11
- performanceMonitoring?: boolean;
12
- }
13
- /**
14
- * Build-time injected values set by the value-injection-loader.
15
- * These are populated when instrumentation-client.ts is processed during build.
16
- */
17
- declare global {
18
- var __INTERFERE_BUILD_ID__: string | null | undefined;
19
- var __INTERFERE_RELEASE_ID__: string | null | undefined;
20
- var __INTERFERE_ENVIRONMENT__: string | undefined;
21
- var __INTERFERE_ENABLED__: boolean | undefined;
22
- var __INTERFERE_FEATURES__: InjectedFeatures | undefined;
23
- var __INTERFERE_INITIALIZED__: boolean | undefined;
24
- }
25
- /**
26
- * The injected config keys that the value-injection-loader sets.
27
- * This is the canonical list of keys - keep in sync with withInterfere.
28
- */
29
- declare const INJECTED_CONFIG_KEYS: readonly ["__INTERFERE_BUILD_ID__", "__INTERFERE_RELEASE_ID__", "__INTERFERE_ENVIRONMENT__", "__INTERFERE_ENABLED__", "__INTERFERE_FEATURES__"];
30
- type InjectedConfigKey = (typeof INJECTED_CONFIG_KEYS)[number];
31
- /**
32
- * Partial config that can be provided by users to override injected values.
33
- */
34
- interface AutoInitConfigOverrides {
35
- features?: Config["features"];
36
- batch?: Config["batch"];
37
- offline?: Config["offline"];
38
- proxyUrl?: string;
39
- metadata?: Partial<Config["metadata"]>;
40
- }
41
- /**
42
- * Reads configuration from build-time injected values.
43
- *
44
- * The value-injection-loader prepends code to instrumentation-client.ts
45
- * that sets these globalThis values during the build process.
46
- *
47
- * @returns Partial config from injected values, or null if SDK is disabled
48
- */
49
- declare function getInjectedConfig(): Partial<Config> | null;
50
- /**
51
- * Initialize Interfere client automatically from build-time injected config.
52
- *
53
- * Call this from instrumentation-client.ts for zero-config initialization.
54
- * User-provided overrides take precedence over injected values.
55
- *
56
- * @param userConfig - Optional configuration overrides
57
- * @returns Parsed config if initialization succeeded, null if SDK is disabled or already initialized
58
- *
59
- * @example
60
- * ```ts
61
- * // instrumentation-client.ts
62
- * import { autoInitClient } from "@interfere/next/auto-init";
63
- *
64
- * const config = autoInitClient();
65
- * if (config) {
66
- * console.log("[Interfere] Client initialized", config.metadata);
67
- * }
68
- * ```
69
- *
70
- * @example
71
- * ```ts
72
- * // With overrides
73
- * import { autoInitClient } from "@interfere/next/auto-init";
74
- *
75
- * const config = autoInitClient({
76
- * features: { replay: false },
77
- * batch: { size: 25, ms: 500 }
78
- * });
79
- * ```
80
- */
81
- declare function autoInitClient(userConfig?: AutoInitConfigOverrides): Config | null;
82
- /**
83
- * Check if Interfere has already been initialized.
84
- */
85
- declare function isInitialized(): boolean;
86
- /**
87
- * Reset initialization state. Only use for testing.
88
- * @internal
89
- */
90
- declare function resetInitializationState(): void;
91
- //#endregion
92
- export { AutoInitConfigOverrides, INJECTED_CONFIG_KEYS, InjectedConfigKey, autoInitClient, getInjectedConfig, isInitialized, resetInitializationState };
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-init.d.mts","names":[],"sources":["../../src/client/auto-init.ts"],"sourcesContent":[],"mappings":";;;;;;AAEwE;AAM9C,UAAhB,gBAAA,CAAgB;EAAA,aAAA,CAAA,EAAA,OAAA;QAoBI,CAAA,EAAA,OAAA;EAAgB,qBAAA,CAAA,EAAA,OAAA;;AAS9C;AAQA;AAKA;;QAEU,MAAA,CAAA;EACE,IAAA,sBAAA,EAAA,MAAA,GAAA,IAAA,GAAA,SAAA;EAES,IAAA,wBAAA,EAAA,MAAA,GAAA,IAAA,GAAA,SAAA;EAAR,IAAA,yBAAA,EAAA,MAAA,GAAA,SAAA;EAAO,IAAA,qBAAA,EAAA,OAAA,GAAA,SAAA;EAWJ,IAAA,sBAAiB,EAtCH,gBAsCO,GAAA,SAAO;EAmE5B,IAAA,yBACD,EAAA,OAAA,GAAA,SAAA;AAiDf;AAQA;;;;cA1Ja;KAQD,iBAAA,WAA4B;;;;UAKvB,uBAAA;aACJ;UACH;YACE;;aAEC,QAAQ;;;;;;;;;;iBAWL,iBAAA,CAAA,GAAqB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmE7B,cAAA,cACD,0BACZ;;;;iBAgDa,aAAA,CAAA;;;;;iBAQA,wBAAA,CAAA"}
@@ -1,121 +0,0 @@
1
- "use client";
2
-
3
- import { configSchema } from "@interfere/types/sdk/config";
4
- import { envSchema } from "@interfere/types/sdk/runtime";
5
-
6
- //#region src/client/auto-init.ts
7
- /**
8
- * The injected config keys that the value-injection-loader sets.
9
- * This is the canonical list of keys - keep in sync with withInterfere.
10
- */
11
- const INJECTED_CONFIG_KEYS = [
12
- "__INTERFERE_BUILD_ID__",
13
- "__INTERFERE_RELEASE_ID__",
14
- "__INTERFERE_ENVIRONMENT__",
15
- "__INTERFERE_ENABLED__",
16
- "__INTERFERE_FEATURES__"
17
- ];
18
- /**
19
- * Reads configuration from build-time injected values.
20
- *
21
- * The value-injection-loader prepends code to instrumentation-client.ts
22
- * that sets these globalThis values during the build process.
23
- *
24
- * @returns Partial config from injected values, or null if SDK is disabled
25
- */
26
- function getInjectedConfig() {
27
- if (typeof globalThis === "undefined") return null;
28
- const buildId = globalThis.__INTERFERE_BUILD_ID__;
29
- const releaseId = globalThis.__INTERFERE_RELEASE_ID__;
30
- const environmentRaw = globalThis.__INTERFERE_ENVIRONMENT__;
31
- const enabled = globalThis.__INTERFERE_ENABLED__;
32
- const features = globalThis.__INTERFERE_FEATURES__;
33
- if (!enabled) return null;
34
- const environment = environmentRaw ? envSchema.safeParse(environmentRaw).data ?? "production" : "production";
35
- return {
36
- metadata: {
37
- buildId: buildId ?? null,
38
- releaseId: releaseId ?? null,
39
- environment,
40
- runtime: "browser"
41
- },
42
- proxyUrl: "/api/interfere",
43
- ...features && { features }
44
- };
45
- }
46
- /**
47
- * Initialize Interfere client automatically from build-time injected config.
48
- *
49
- * Call this from instrumentation-client.ts for zero-config initialization.
50
- * User-provided overrides take precedence over injected values.
51
- *
52
- * @param userConfig - Optional configuration overrides
53
- * @returns Parsed config if initialization succeeded, null if SDK is disabled or already initialized
54
- *
55
- * @example
56
- * ```ts
57
- * // instrumentation-client.ts
58
- * import { autoInitClient } from "@interfere/next/auto-init";
59
- *
60
- * const config = autoInitClient();
61
- * if (config) {
62
- * console.log("[Interfere] Client initialized", config.metadata);
63
- * }
64
- * ```
65
- *
66
- * @example
67
- * ```ts
68
- * // With overrides
69
- * import { autoInitClient } from "@interfere/next/auto-init";
70
- *
71
- * const config = autoInitClient({
72
- * features: { replay: false },
73
- * batch: { size: 25, ms: 500 }
74
- * });
75
- * ```
76
- */
77
- function autoInitClient(userConfig) {
78
- if (globalThis.__INTERFERE_INITIALIZED__) {
79
- if (process.env.NODE_ENV === "development") console.warn("[Interfere] Already initialized, skipping duplicate init");
80
- return null;
81
- }
82
- const injectedConfig = getInjectedConfig();
83
- if (!injectedConfig) {
84
- if (process.env.NODE_ENV === "development") console.info("[Interfere] No injected config found. SDK disabled. Ensure INTERFERE_SECRET_KEY is set and withInterfere() is configured.");
85
- return null;
86
- }
87
- const mergedConfig = {
88
- ...injectedConfig,
89
- ...userConfig?.features && { features: userConfig.features },
90
- ...userConfig?.batch && { batch: userConfig.batch },
91
- ...userConfig?.offline && { offline: userConfig.offline },
92
- ...userConfig?.proxyUrl && { proxyUrl: userConfig.proxyUrl },
93
- metadata: {
94
- ...injectedConfig.metadata,
95
- ...userConfig?.metadata
96
- }
97
- };
98
- const parseResult = configSchema.safeParse(mergedConfig);
99
- if (!parseResult.success) {
100
- console.error("[Interfere] Failed to parse config:", parseResult.error);
101
- return null;
102
- }
103
- globalThis.__INTERFERE_INITIALIZED__ = true;
104
- return parseResult.data;
105
- }
106
- /**
107
- * Check if Interfere has already been initialized.
108
- */
109
- function isInitialized() {
110
- return globalThis.__INTERFERE_INITIALIZED__ === true;
111
- }
112
- /**
113
- * Reset initialization state. Only use for testing.
114
- * @internal
115
- */
116
- function resetInitializationState() {
117
- globalThis.__INTERFERE_INITIALIZED__ = void 0;
118
- }
119
-
120
- //#endregion
121
- export { INJECTED_CONFIG_KEYS, autoInitClient, getInjectedConfig, isInitialized, resetInitializationState };
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto-init.mjs","names":[],"sources":["../../src/client/auto-init.ts"],"sourcesContent":["\"use client\";\n\nimport { type Config, configSchema } from \"@interfere/types/sdk/config\";\nimport { envSchema } from \"@interfere/types/sdk/runtime\";\n\n/**\n * Feature flags that can be injected at build time.\n */\ninterface InjectedFeatures {\n errorTracking?: boolean;\n replay?: boolean;\n performanceMonitoring?: boolean;\n}\n\n/**\n * Build-time injected values set by the value-injection-loader.\n * These are populated when instrumentation-client.ts is processed during build.\n */\ndeclare global {\n // eslint-disable-next-line no-var\n var __INTERFERE_BUILD_ID__: string | null | undefined;\n // eslint-disable-next-line no-var\n var __INTERFERE_RELEASE_ID__: string | null | undefined;\n // eslint-disable-next-line no-var\n var __INTERFERE_ENVIRONMENT__: string | undefined;\n // eslint-disable-next-line no-var\n var __INTERFERE_ENABLED__: boolean | undefined;\n // eslint-disable-next-line no-var\n var __INTERFERE_FEATURES__: InjectedFeatures | undefined;\n // eslint-disable-next-line no-var\n var __INTERFERE_INITIALIZED__: boolean | undefined;\n}\n\n/**\n * The injected config keys that the value-injection-loader sets.\n * This is the canonical list of keys - keep in sync with withInterfere.\n */\nexport const INJECTED_CONFIG_KEYS = [\n \"__INTERFERE_BUILD_ID__\",\n \"__INTERFERE_RELEASE_ID__\",\n \"__INTERFERE_ENVIRONMENT__\",\n \"__INTERFERE_ENABLED__\",\n \"__INTERFERE_FEATURES__\",\n] as const;\n\nexport type InjectedConfigKey = (typeof INJECTED_CONFIG_KEYS)[number];\n\n/**\n * Partial config that can be provided by users to override injected values.\n */\nexport interface AutoInitConfigOverrides {\n features?: Config[\"features\"];\n batch?: Config[\"batch\"];\n offline?: Config[\"offline\"];\n proxyUrl?: string;\n metadata?: Partial<Config[\"metadata\"]>;\n}\n\n/**\n * Reads configuration from build-time injected values.\n *\n * The value-injection-loader prepends code to instrumentation-client.ts\n * that sets these globalThis values during the build process.\n *\n * @returns Partial config from injected values, or null if SDK is disabled\n */\nexport function getInjectedConfig(): Partial<Config> | null {\n if (typeof globalThis === \"undefined\") {\n return null;\n }\n\n const buildId = globalThis.__INTERFERE_BUILD_ID__;\n const releaseId = globalThis.__INTERFERE_RELEASE_ID__;\n const environmentRaw = globalThis.__INTERFERE_ENVIRONMENT__;\n const enabled = globalThis.__INTERFERE_ENABLED__;\n const features = globalThis.__INTERFERE_FEATURES__;\n\n // If not enabled, SDK was disabled (no valid INTERFERE_SECRET_KEY was set)\n if (!enabled) {\n return null;\n }\n\n // Parse environment with fallback\n const environment = environmentRaw\n ? (envSchema.safeParse(environmentRaw).data ?? \"production\")\n : \"production\";\n\n // For Next.js, we always use proxy mode - the proxy handles authentication\n // This means the client doesn't need the surface token at all\n return {\n metadata: {\n buildId: buildId ?? null,\n releaseId: releaseId ?? null,\n environment,\n runtime: \"browser\",\n },\n proxyUrl: \"/api/interfere\",\n // Include features if they were injected\n ...(features && { features }),\n };\n}\n\n/**\n * Initialize Interfere client automatically from build-time injected config.\n *\n * Call this from instrumentation-client.ts for zero-config initialization.\n * User-provided overrides take precedence over injected values.\n *\n * @param userConfig - Optional configuration overrides\n * @returns Parsed config if initialization succeeded, null if SDK is disabled or already initialized\n *\n * @example\n * ```ts\n * // instrumentation-client.ts\n * import { autoInitClient } from \"@interfere/next/auto-init\";\n *\n * const config = autoInitClient();\n * if (config) {\n * console.log(\"[Interfere] Client initialized\", config.metadata);\n * }\n * ```\n *\n * @example\n * ```ts\n * // With overrides\n * import { autoInitClient } from \"@interfere/next/auto-init\";\n *\n * const config = autoInitClient({\n * features: { replay: false },\n * batch: { size: 25, ms: 500 }\n * });\n * ```\n */\nexport function autoInitClient(\n userConfig?: AutoInitConfigOverrides\n): Config | null {\n // Prevent double initialization\n if (globalThis.__INTERFERE_INITIALIZED__) {\n if (process.env.NODE_ENV === \"development\") {\n console.warn(\"[Interfere] Already initialized, skipping duplicate init\");\n }\n return null;\n }\n\n const injectedConfig = getInjectedConfig();\n if (!injectedConfig) {\n if (process.env.NODE_ENV === \"development\") {\n console.info(\n \"[Interfere] No injected config found. SDK disabled. \" +\n \"Ensure INTERFERE_SECRET_KEY is set and withInterfere() is configured.\"\n );\n }\n return null;\n }\n\n // Merge injected config with user overrides\n // User overrides take precedence\n const mergedConfig = {\n ...injectedConfig,\n ...(userConfig?.features && { features: userConfig.features }),\n ...(userConfig?.batch && { batch: userConfig.batch }),\n ...(userConfig?.offline && { offline: userConfig.offline }),\n ...(userConfig?.proxyUrl && { proxyUrl: userConfig.proxyUrl }),\n metadata: {\n ...injectedConfig.metadata,\n ...userConfig?.metadata,\n },\n };\n\n // Validate and parse the merged config\n const parseResult = configSchema.safeParse(mergedConfig);\n if (!parseResult.success) {\n console.error(\"[Interfere] Failed to parse config:\", parseResult.error);\n return null;\n }\n\n globalThis.__INTERFERE_INITIALIZED__ = true;\n return parseResult.data;\n}\n\n/**\n * Check if Interfere has already been initialized.\n */\nexport function isInitialized(): boolean {\n return globalThis.__INTERFERE_INITIALIZED__ === true;\n}\n\n/**\n * Reset initialization state. Only use for testing.\n * @internal\n */\nexport function resetInitializationState(): void {\n globalThis.__INTERFERE_INITIALIZED__ = undefined;\n}\n"],"mappings":";;;;;;;;;;AAqCA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACD;;;;;;;;;AAuBD,SAAgB,oBAA4C;AAC1D,KAAI,OAAO,eAAe,YACxB,QAAO;CAGT,MAAM,UAAU,WAAW;CAC3B,MAAM,YAAY,WAAW;CAC7B,MAAM,iBAAiB,WAAW;CAClC,MAAM,UAAU,WAAW;CAC3B,MAAM,WAAW,WAAW;AAG5B,KAAI,CAAC,QACH,QAAO;CAIT,MAAM,cAAc,iBACf,UAAU,UAAU,eAAe,CAAC,QAAQ,eAC7C;AAIJ,QAAO;EACL,UAAU;GACR,SAAS,WAAW;GACpB,WAAW,aAAa;GACxB;GACA,SAAS;GACV;EACD,UAAU;EAEV,GAAI,YAAY,EAAE,UAAU;EAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,SAAgB,eACd,YACe;AAEf,KAAI,WAAW,2BAA2B;AACxC,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,KAAK,2DAA2D;AAE1E,SAAO;;CAGT,MAAM,iBAAiB,mBAAmB;AAC1C,KAAI,CAAC,gBAAgB;AACnB,MAAI,QAAQ,IAAI,aAAa,cAC3B,SAAQ,KACN,4HAED;AAEH,SAAO;;CAKT,MAAM,eAAe;EACnB,GAAG;EACH,GAAI,YAAY,YAAY,EAAE,UAAU,WAAW,UAAU;EAC7D,GAAI,YAAY,SAAS,EAAE,OAAO,WAAW,OAAO;EACpD,GAAI,YAAY,WAAW,EAAE,SAAS,WAAW,SAAS;EAC1D,GAAI,YAAY,YAAY,EAAE,UAAU,WAAW,UAAU;EAC7D,UAAU;GACR,GAAG,eAAe;GAClB,GAAG,YAAY;GAChB;EACF;CAGD,MAAM,cAAc,aAAa,UAAU,aAAa;AACxD,KAAI,CAAC,YAAY,SAAS;AACxB,UAAQ,MAAM,uCAAuC,YAAY,MAAM;AACvE,SAAO;;AAGT,YAAW,4BAA4B;AACvC,QAAO,YAAY;;;;;AAMrB,SAAgB,gBAAyB;AACvC,QAAO,WAAW,8BAA8B;;;;;;AAOlD,SAAgB,2BAAiC;AAC/C,YAAW,4BAA4B"}
@@ -1,3 +0,0 @@
1
- import { useInterfere } from "@interfere/react/provider";
2
- export * from "@interfere/react/client";
3
- export { useInterfere };
@@ -1,5 +0,0 @@
1
- import { useInterfere } from "@interfere/react/provider";
2
-
3
- export * from "@interfere/react/client"
4
-
5
- export { useInterfere };
@@ -1,22 +0,0 @@
1
- import { ConfigInput } from "@interfere/types/sdk/config";
2
- import { InterfereProviderProps } from "@interfere/react/provider";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
4
-
5
- //#region src/client/provider.d.ts
6
- interface NextConfigInput {
7
- features?: ConfigInput["features"];
8
- metadata?: ConfigInput["metadata"];
9
- batch?: ConfigInput["batch"];
10
- proxyUrl?: string;
11
- ingestUrl?: string;
12
- surfaceToken?: string;
13
- }
14
- declare function InterfereProvider({
15
- children,
16
- config,
17
- ...rest
18
- }: Omit<InterfereProviderProps, "config"> & {
19
- config?: NextConfigInput;
20
- }): react_jsx_runtime0.JSX.Element;
21
- //#endregion
22
- export { InterfereProvider };
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.mts","names":[],"sources":["../../src/client/provider.tsx"],"sourcesContent":[],"mappings":";;;;;UA2CU,eAAA;aACG;aACA;EAFH,KAAA,CAAA,EAGA,WAHe,CAAA,OAAA,CAAA;EACZ,QAAA,CAAA,EAAA,MAAA;EACA,SAAA,CAAA,EAAA,MAAA;EACH,YAAA,CAAA,EAAA,MAAA;;AAiCM,iBAAA,iBAAA,CAAiB;EAAA,QAAA;EAAA,MAAA;EAAA,GAAA;CAAA,EAI9B,IAJ8B,CAIzB,sBAJyB,EAAA,QAAA,CAAA,GAAA;EAC/B,MAAA,CAAA,EAGqD,eAHrD;CACA,CAAA,EAEsE,kBAAA,CAAA,GAAA,CAAA,OAFtE"}
@@ -1,50 +0,0 @@
1
- "use client";
2
-
3
- import { getInjectedConfig } from "./auto-init.mjs";
4
- import { configSchema } from "@interfere/types/sdk/config";
5
- import { envSchema } from "@interfere/types/sdk/runtime";
6
- import { InterfereProvider as InterfereProvider$1 } from "@interfere/react/provider";
7
- import { getRuntime } from "@interfere/react/core/runtime/config";
8
- import { jsx } from "react/jsx-runtime";
9
-
10
- //#region src/client/provider.tsx
11
- /**
12
- * Get default metadata from environment variables (legacy approach)
13
- * or from injected config (instrumentation approach).
14
- */
15
- function getDefaultMetadata() {
16
- const injectedConfig = getInjectedConfig();
17
- if (injectedConfig?.metadata) return {
18
- ...injectedConfig.metadata,
19
- runtime: getRuntime()
20
- };
21
- return {
22
- buildId: process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID ?? null,
23
- releaseId: process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID ?? null,
24
- environment: process.env.NEXT_PUBLIC_INTERFERE_ENVIRONMENT ? envSchema.parse(process.env.NEXT_PUBLIC_INTERFERE_ENVIRONMENT) : "production",
25
- runtime: getRuntime()
26
- };
27
- }
28
- function mergeConfig(config) {
29
- const defaults = getDefaultMetadata();
30
- const incomingMeta = config.metadata ?? {};
31
- const transportConfig = typeof config.proxyUrl !== "undefined" || typeof config.ingestUrl !== "undefined" || typeof config.surfaceToken !== "undefined" ? config : { proxyUrl: "/api/interfere" };
32
- return configSchema.parse({
33
- ...transportConfig,
34
- ...config,
35
- metadata: {
36
- ...defaults,
37
- ...incomingMeta
38
- }
39
- });
40
- }
41
- function InterfereProvider({ children, config = {}, ...rest }) {
42
- return /* @__PURE__ */ jsx(InterfereProvider$1, {
43
- config: mergeConfig(config),
44
- ...rest,
45
- children
46
- });
47
- }
48
-
49
- //#endregion
50
- export { InterfereProvider };
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.mjs","names":["InterfereProviderReact"],"sources":["../../src/client/provider.tsx"],"sourcesContent":["\"use client\";\n\nimport { getRuntime } from \"@interfere/react/core/runtime/config\";\nimport {\n type InterfereProviderProps,\n InterfereProvider as InterfereProviderReact,\n} from \"@interfere/react/provider\";\nimport {\n type Config,\n type ConfigInput,\n configSchema,\n} from \"@interfere/types/sdk/config\";\nimport { envSchema } from \"@interfere/types/sdk/runtime\";\n\nimport { getInjectedConfig } from \"./auto-init.js\";\n\n/**\n * Get default metadata from environment variables (legacy approach)\n * or from injected config (instrumentation approach).\n */\nfunction getDefaultMetadata(): ConfigInput[\"metadata\"] {\n // First, try to get injected config from instrumentation-client.ts\n const injectedConfig = getInjectedConfig();\n if (injectedConfig?.metadata) {\n return {\n ...injectedConfig.metadata,\n runtime: getRuntime(),\n };\n }\n\n // Fallback to environment variables (legacy approach)\n return {\n buildId: process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID ?? null,\n releaseId: process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID ?? null,\n environment: process.env.NEXT_PUBLIC_INTERFERE_ENVIRONMENT\n ? envSchema.parse(process.env.NEXT_PUBLIC_INTERFERE_ENVIRONMENT)\n : \"production\",\n runtime: getRuntime(),\n };\n}\n\n// Next.js-specific config type that allows omitting transport\n// because Next.js can provide its own proxy endpoint\ninterface NextConfigInput {\n features?: ConfigInput[\"features\"];\n metadata?: ConfigInput[\"metadata\"];\n batch?: ConfigInput[\"batch\"];\n proxyUrl?: string;\n ingestUrl?: string;\n surfaceToken?: string;\n}\n\nfunction mergeConfig(config: NextConfigInput): Config {\n const defaults = getDefaultMetadata();\n const incomingMeta = config.metadata ?? {};\n\n // Determine transport config:\n // - If they explicitly set proxyUrl, use proxy mode\n // - If they set ingestUrl or surfaceToken, use direct mode (let schema validate)\n // - Otherwise, default to Next.js proxy\n const hasTransportConfig =\n typeof config.proxyUrl !== \"undefined\" ||\n typeof config.ingestUrl !== \"undefined\" ||\n typeof config.surfaceToken !== \"undefined\";\n\n const transportConfig = hasTransportConfig\n ? config\n : { proxyUrl: \"/api/interfere\" }; // Default Next.js proxy endpoint\n\n return configSchema.parse({\n ...transportConfig,\n ...config,\n metadata: {\n ...defaults,\n ...incomingMeta,\n },\n });\n}\n\nexport function InterfereProvider({\n children,\n config = {},\n ...rest\n}: Omit<InterfereProviderProps, \"config\"> & { config?: NextConfigInput }) {\n const mergedConfig = mergeConfig(config);\n\n return (\n <InterfereProviderReact config={mergedConfig} {...rest}>\n {children}\n </InterfereProviderReact>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,SAAS,qBAA8C;CAErD,MAAM,iBAAiB,mBAAmB;AAC1C,KAAI,gBAAgB,SAClB,QAAO;EACL,GAAG,eAAe;EAClB,SAAS,YAAY;EACtB;AAIH,QAAO;EACL,SAAS,QAAQ,IAAI,kCAAkC;EACvD,WAAW,QAAQ,IAAI,oCAAoC;EAC3D,aAAa,QAAQ,IAAI,oCACrB,UAAU,MAAM,QAAQ,IAAI,kCAAkC,GAC9D;EACJ,SAAS,YAAY;EACtB;;AAcH,SAAS,YAAY,QAAiC;CACpD,MAAM,WAAW,oBAAoB;CACrC,MAAM,eAAe,OAAO,YAAY,EAAE;CAW1C,MAAM,kBAJJ,OAAO,OAAO,aAAa,eAC3B,OAAO,OAAO,cAAc,eAC5B,OAAO,OAAO,iBAAiB,cAG7B,SACA,EAAE,UAAU,kBAAkB;AAElC,QAAO,aAAa,MAAM;EACxB,GAAG;EACH,GAAG;EACH,UAAU;GACR,GAAG;GACH,GAAG;GACJ;EACF,CAAC;;AAGJ,SAAgB,kBAAkB,EAChC,UACA,SAAS,EAAE,EACX,GAAG,QACqE;AAGxE,QACE,oBAACA;EAAuB,QAHL,YAAY,OAAO;EAGQ,GAAI;EAC/C;GACsB"}
@@ -1,12 +0,0 @@
1
- //#region src/lib/env.d.ts
2
- /**
3
- * Shared helpers for Interfere-specific environment values that can be used
4
- * safely at both build time and runtime.
5
- *
6
- * Provider-specific environment variables (Vercel, Netlify, etc.) should live
7
- * in their respective provider modules instead of this file.
8
- */
9
- declare function getEnvBuildId(): string | null;
10
- declare function getEnvReleaseId(): string | null;
11
- //#endregion
12
- export { getEnvBuildId, getEnvReleaseId };
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.mts","names":[],"sources":["../../src/lib/env.ts"],"sourcesContent":[],"mappings":";;AAQA;AAQA;;;;;iBARgB,aAAA,CAAA;iBAQA,eAAA,CAAA"}
package/dist/lib/env.mjs DELETED
@@ -1,17 +0,0 @@
1
- //#region src/lib/env.ts
2
- /**
3
- * Shared helpers for Interfere-specific environment values that can be used
4
- * safely at both build time and runtime.
5
- *
6
- * Provider-specific environment variables (Vercel, Netlify, etc.) should live
7
- * in their respective provider modules instead of this file.
8
- */
9
- function getEnvBuildId() {
10
- return process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID || process.env.NEXT_BUILD_ID || null;
11
- }
12
- function getEnvReleaseId() {
13
- return process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID || null;
14
- }
15
-
16
- //#endregion
17
- export { getEnvBuildId, getEnvReleaseId };
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.mjs","names":[],"sources":["../../src/lib/env.ts"],"sourcesContent":["/**\n * Shared helpers for Interfere-specific environment values that can be used\n * safely at both build time and runtime.\n *\n * Provider-specific environment variables (Vercel, Netlify, etc.) should live\n * in their respective provider modules instead of this file.\n */\n\nexport function getEnvBuildId(): string | null {\n return (\n process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID ||\n process.env.NEXT_BUILD_ID ||\n null\n );\n}\n\nexport function getEnvReleaseId(): string | null {\n return process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID || null;\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,gBAA+B;AAC7C,QACE,QAAQ,IAAI,kCACZ,QAAQ,IAAI,iBACZ;;AAIJ,SAAgB,kBAAiC;AAC/C,QAAO,QAAQ,IAAI,oCAAoC"}
@@ -1,6 +0,0 @@
1
- import { NextRequest } from "next/server";
2
-
3
- //#region src/lib/test-utils/make-next-request.d.ts
4
- declare function makeNextRequest(url: string | URL, init?: RequestInit): NextRequest;
5
- //#endregion
6
- export { makeNextRequest };
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-next-request.d.mts","names":[],"sources":["../../../src/lib/test-utils/make-next-request.ts"],"sourcesContent":[],"mappings":";;;iBAGgB,eAAA,eACA,YACP,cACN"}
@@ -1,12 +0,0 @@
1
- import { NextRequest } from "next/server";
2
-
3
- //#region src/lib/test-utils/make-next-request.ts
4
- function makeNextRequest(url, init) {
5
- return new NextRequest(url, {
6
- ...init,
7
- signal: init?.signal ?? void 0
8
- });
9
- }
10
-
11
- //#endregion
12
- export { makeNextRequest };
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-next-request.mjs","names":["NextRequestCtor"],"sources":["../../../src/lib/test-utils/make-next-request.ts"],"sourcesContent":["import type { NextRequest } from \"next/server\";\nimport { NextRequest as NextRequestCtor } from \"next/server\";\n\nexport function makeNextRequest(\n url: string | URL,\n init?: RequestInit\n): NextRequest {\n // The NextRequest constructor mirrors the standard Request but augments with nextUrl, cookies, etc.\n // Using the real constructor keeps types intact and avoids casts in tests.\n return new NextRequestCtor(url, {\n ...init,\n signal: init?.signal ?? undefined,\n });\n}\n"],"mappings":";;;AAGA,SAAgB,gBACd,KACA,MACa;AAGb,QAAO,IAAIA,YAAgB,KAAK;EAC9B,GAAG;EACH,QAAQ,MAAM,UAAU;EACzB,CAAC"}
@@ -1,22 +0,0 @@
1
- //#region src/lib/types.d.ts
2
- type NonEmptyString = string & {
3
- readonly __brand: unique symbol;
4
- };
5
- declare function toNonEmptyString(value: string): NonEmptyString | null;
6
- interface PreflightEnabled {
7
- enabled: true;
8
- surface: NonEmptyString;
9
- secretKey: NonEmptyString;
10
- environment: string;
11
- debug: boolean;
12
- cleanupSourceMaps: boolean;
13
- }
14
- interface PreflightDisabled {
15
- enabled: false;
16
- environment: string | undefined;
17
- debug: boolean;
18
- cleanupSourceMaps: boolean;
19
- }
20
- type PreflightConfig = PreflightEnabled | PreflightDisabled;
21
- //#endregion
22
- export { NonEmptyString, PreflightConfig, PreflightDisabled, PreflightEnabled, toNonEmptyString };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lib/types.ts"],"sourcesContent":[],"mappings":";KACY,cAAA;EAAA,SAAA,OAAA,EAAc,OAAA,MAAA;AAE1B,CAAA;AAIiB,iBAJD,gBAAA,CAML,KAAA,EAAA,MACE,CAAA,EAPoC,cAOtB,GAAA,IAAA;AAMV,UATA,gBAAA,CASiB;EAOtB,OAAA,EAAA,IAAA;WAdD;aACE;;;;;UAMI,iBAAA;;;;;;KAOL,eAAA,GAAkB,mBAAmB"}
@@ -1,7 +0,0 @@
1
- //#region src/lib/types.ts
2
- function toNonEmptyString(value) {
3
- return value.length > 0 ? value : null;
4
- }
5
-
6
- //#endregion
7
- export { toNonEmptyString };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../../src/lib/types.ts"],"sourcesContent":["// Branded non-empty string type to prevent passing empty strings accidentally\nexport type NonEmptyString = string & { readonly __brand: unique symbol };\n\nexport function toNonEmptyString(value: string): NonEmptyString | null {\n return value.length > 0 ? (value as NonEmptyString) : null;\n}\n\nexport interface PreflightEnabled {\n enabled: true;\n surface: NonEmptyString;\n secretKey: NonEmptyString;\n environment: string;\n debug: boolean;\n cleanupSourceMaps: boolean;\n}\n\nexport interface PreflightDisabled {\n enabled: false;\n environment: string | undefined;\n debug: boolean;\n cleanupSourceMaps: boolean;\n}\n\nexport type PreflightConfig = PreflightEnabled | PreflightDisabled;\n"],"mappings":";AAGA,SAAgB,iBAAiB,OAAsC;AACrE,QAAO,MAAM,SAAS,IAAK,QAA2B"}
@@ -1,11 +0,0 @@
1
- import { NextRequest, NextResponse } from "next/server";
2
-
3
- //#region src/server/middleware.d.ts
4
- declare function withInterfereMiddleware(middleware: (request: NextRequest) => Promise<NextResponse> | NextResponse): (request: NextRequest) => Promise<NextResponse<unknown>>;
5
- declare function withInterfereApiRoute(handler: (req: NextRequest) => Promise<Response>): (req: NextRequest) => Promise<Response>;
6
- declare function withInterfereServerComponent<T extends (...args: unknown[]) => Promise<unknown>>(component: T, componentName?: string): T;
7
- declare function createInterfereErrorHandler(): (error: Error, errorInfo: {
8
- digest?: string;
9
- }) => Promise<void>;
10
- //#endregion
11
- export { createInterfereErrorHandler, withInterfereApiRoute, withInterfereMiddleware, withInterfereServerComponent };