@starko-one/sdk 0.0.0-stage → 0.1.0-beta.1

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 (108) hide show
  1. package/CHANGELOG.md +248 -0
  2. package/LICENSE +17 -0
  3. package/NOTICE +58 -0
  4. package/README.md +81 -2
  5. package/dist/api-BAFm4Lxj.d.ts +558 -0
  6. package/dist/api-DNrctwJu.d.cts +558 -0
  7. package/dist/browser/index.cjs +168 -0
  8. package/dist/browser/index.d.cts +131 -0
  9. package/dist/browser/index.d.ts +131 -0
  10. package/dist/browser/index.js +7 -0
  11. package/dist/build/rollup.cjs +22 -0
  12. package/dist/build/rollup.d.cts +34 -0
  13. package/dist/build/rollup.d.ts +34 -0
  14. package/dist/build/rollup.js +3 -0
  15. package/dist/build/vite.cjs +51 -0
  16. package/dist/build/vite.d.cts +23 -0
  17. package/dist/build/vite.d.ts +23 -0
  18. package/dist/build/vite.js +46 -0
  19. package/dist/build/webpack.cjs +18 -0
  20. package/dist/build/webpack.d.cts +39 -0
  21. package/dist/build/webpack.d.ts +39 -0
  22. package/dist/build/webpack.js +3 -0
  23. package/dist/chunk-2PM4FRM5.cjs +431 -0
  24. package/dist/chunk-335HNCOJ.js +249 -0
  25. package/dist/chunk-3AW5B2WW.js +115 -0
  26. package/dist/chunk-3R5TQAWD.js +216 -0
  27. package/dist/chunk-6H5MOPTQ.cjs +1230 -0
  28. package/dist/chunk-7TKNT3QJ.cjs +2487 -0
  29. package/dist/chunk-A4WLNFMU.cjs +220 -0
  30. package/dist/chunk-ALYFFOPR.cjs +134 -0
  31. package/dist/chunk-BVVFVRMO.js +1113 -0
  32. package/dist/chunk-CIHNKN62.cjs +15 -0
  33. package/dist/chunk-CMGCH6HD.js +1212 -0
  34. package/dist/chunk-D6QAPQ7L.cjs +56 -0
  35. package/dist/chunk-DUO5V6WZ.js +213 -0
  36. package/dist/chunk-EC2WZ6PG.js +90 -0
  37. package/dist/chunk-EFURLFJT.cjs +187 -0
  38. package/dist/chunk-EROUORMY.js +53 -0
  39. package/dist/chunk-LXBXFOAP.cjs +96 -0
  40. package/dist/chunk-MF6SA6DB.js +563 -0
  41. package/dist/chunk-N5R6ORIB.js +413 -0
  42. package/dist/chunk-N6R6BWHK.cjs +142 -0
  43. package/dist/chunk-QAGGN2T7.cjs +225 -0
  44. package/dist/chunk-QV4HRIDD.cjs +659 -0
  45. package/dist/chunk-TKNDYQB3.cjs +583 -0
  46. package/dist/chunk-UI5YC4TH.js +131 -0
  47. package/dist/chunk-VEHZYLK6.cjs +1151 -0
  48. package/dist/chunk-VNCWOGTI.js +12 -0
  49. package/dist/chunk-VWNIOGE6.js +180 -0
  50. package/dist/chunk-WDKRKGYF.js +608 -0
  51. package/dist/chunk-XOZIXBUK.js +2462 -0
  52. package/dist/chunk-ZS3K3SDR.cjs +258 -0
  53. package/dist/cli/index.cjs +2780 -0
  54. package/dist/common-DLFAqL2d.d.cts +36 -0
  55. package/dist/common-DbSXkaw6.d.ts +36 -0
  56. package/dist/dedupe-Bh5riD8Z.d.cts +13 -0
  57. package/dist/dedupe-DoYiSx-9.d.ts +13 -0
  58. package/dist/handler-BcnsnvhF.d.cts +82 -0
  59. package/dist/handler-qHzilC9T.d.ts +82 -0
  60. package/dist/index.cjs +309 -0
  61. package/dist/index.d.cts +187 -0
  62. package/dist/index.d.ts +187 -0
  63. package/dist/index.js +4 -0
  64. package/dist/next/client.cjs +113 -0
  65. package/dist/next/client.d.cts +26 -0
  66. package/dist/next/client.d.ts +26 -0
  67. package/dist/next/client.js +41 -0
  68. package/dist/next/config.cjs +277 -0
  69. package/dist/next/config.d.cts +193 -0
  70. package/dist/next/config.d.ts +193 -0
  71. package/dist/next/config.js +263 -0
  72. package/dist/next/index.cjs +148 -0
  73. package/dist/next/index.d.cts +32 -0
  74. package/dist/next/index.d.ts +32 -0
  75. package/dist/next/index.js +59 -0
  76. package/dist/node/index.cjs +257 -0
  77. package/dist/node/index.d.cts +145 -0
  78. package/dist/node/index.d.ts +145 -0
  79. package/dist/node/index.js +83 -0
  80. package/dist/options-BUhWuWJX.d.cts +79 -0
  81. package/dist/options-BUhWuWJX.d.ts +79 -0
  82. package/dist/react/index.cjs +107 -0
  83. package/dist/react/index.d.cts +84 -0
  84. package/dist/react/index.d.ts +84 -0
  85. package/dist/react/index.js +103 -0
  86. package/dist/scope-D1ouJm2h.d.cts +628 -0
  87. package/dist/scope-D1ouJm2h.d.ts +628 -0
  88. package/dist/server-edge-7624N3WF.cjs +51 -0
  89. package/dist/server-edge-BEEXWL7T.js +48 -0
  90. package/dist/server-node-ET4LIPEC.cjs +27 -0
  91. package/dist/server-node-TQUVMZUC.js +24 -0
  92. package/dist/session-C_WzbEN2.d.cts +4 -0
  93. package/dist/session-C_WzbEN2.d.ts +4 -0
  94. package/dist/session-propagation-Pr0Zb9Zn.d.cts +30 -0
  95. package/dist/session-propagation-RM5py1bp.d.ts +30 -0
  96. package/dist/starko.min.js +6 -0
  97. package/docs/browser.md +386 -0
  98. package/docs/configuration.md +310 -0
  99. package/docs/nextjs.md +488 -0
  100. package/docs/node.md +427 -0
  101. package/docs/other-backends.md +232 -0
  102. package/docs/privacy.md +112 -0
  103. package/docs/react.md +187 -0
  104. package/docs/source-maps.md +482 -0
  105. package/docs/troubleshooting.md +263 -0
  106. package/docs/widget.md +84 -0
  107. package/docs/wire-format.md +547 -0
  108. package/package.json +191 -4
@@ -0,0 +1,263 @@
1
+ import { StarkoWebpackPlugin } from '../chunk-VWNIOGE6.js';
2
+ import { resolveReleaseInfo, createLogger, resolveConnection, createFileFilter, injectDirectory, collectUploads, errorMessage, runUpload, shouldDeleteSourcemaps, deleteAllSourcemaps, NO_API_KEY_MESSAGE, findDebugId, hasNativeRegistration } from '../chunk-XOZIXBUK.js';
3
+ import { LIMITS } from '../chunk-3AW5B2WW.js';
4
+ import { existsSync } from 'fs';
5
+ import { createRequire } from 'module';
6
+ import path from 'path';
7
+
8
+ // src/next/release-env.ts
9
+ var BUILD_RELEASE_ENV = "STARKO_BUILD_RELEASE";
10
+
11
+ // src/next/config.ts
12
+ var PHASE_PRODUCTION_BUILD = "phase-production-build";
13
+ var PHASE_DEVELOPMENT_SERVER = "phase-development-server";
14
+ var PHASE_PRODUCTION_SERVER = "phase-production-server";
15
+ function detectNextVersion() {
16
+ try {
17
+ const require2 = createRequire(path.join(process.cwd(), "package.json"));
18
+ return require2("next/package.json").version;
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+ function inferPhase(env = process.env, argv = process.argv) {
24
+ if (env.NEXT_PHASE) return env.NEXT_PHASE;
25
+ const command = argv.slice(2).find((a) => !a.startsWith("-"));
26
+ if (command === "dev") return PHASE_DEVELOPMENT_SERVER;
27
+ if (command === "start") return PHASE_PRODUCTION_SERVER;
28
+ if (command === "build") return PHASE_PRODUCTION_BUILD;
29
+ return env.NODE_ENV === "development" ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;
30
+ }
31
+ function versionAtLeast(version, min) {
32
+ const parse = (v) => v.split(/[-+]/)[0].split(".").map((n) => Number.parseInt(n, 10) || 0);
33
+ const a = parse(version);
34
+ const b = parse(min);
35
+ for (let i = 0; i < 3; i++) {
36
+ const x = a[i] ?? 0;
37
+ const y = b[i] ?? 0;
38
+ if (x !== y) return x > y;
39
+ }
40
+ return true;
41
+ }
42
+ var warnedNoKey = false;
43
+ function warnNoKeyOnce(logger) {
44
+ if (warnedNoKey) return;
45
+ warnedNoKey = true;
46
+ logger.warn(NO_API_KEY_MESSAGE);
47
+ }
48
+ var SRI_MANIFEST = path.join("server", "subresource-integrity-manifest.json");
49
+ function keepsClientBytes(integrity) {
50
+ return (_relativePath, code) => {
51
+ if (integrity) return true;
52
+ const id = findDebugId(code);
53
+ return !!id && hasNativeRegistration(code, id);
54
+ };
55
+ }
56
+ function keepsServerMaps(distDir, standalone) {
57
+ return !!standalone && existsSync(path.join(distDir, "server", "webpack-runtime.js"));
58
+ }
59
+ var warnedNoRelease = false;
60
+ function warnNoReleaseOnce(logger) {
61
+ if (warnedNoRelease) return;
62
+ warnedNoRelease = true;
63
+ logger.warn(
64
+ "no release for this build: its events and source maps carry none. Set `release` in the withStarko options or STARKO_RELEASE in the build's environment (or build from a git checkout, or in a CI that sets the commit)."
65
+ );
66
+ }
67
+ function _resetNextConfigWarnings() {
68
+ warnedNoRelease = false;
69
+ }
70
+ function resolveNextRelease(userConfig, options, phase, resolve = resolveReleaseInfo, env = process.env) {
71
+ const userEnv = userConfig.env;
72
+ const own = userEnv && typeof userEnv === "object" && userEnv[BUILD_RELEASE_ENV] != null ? String(userEnv[BUILD_RELEASE_ENV]).trim() : void 0;
73
+ if (own) return { release: resolve(own), stamp: false };
74
+ const stamp = own === void 0;
75
+ if (phase === PHASE_DEVELOPMENT_SERVER) {
76
+ const explicit = (options.release ?? "").trim() || (env.STARKO_RELEASE ?? "").trim();
77
+ return { release: explicit ? { version: explicit.slice(0, LIMITS.MAX_RELEASE) } : void 0, stamp };
78
+ }
79
+ return { release: resolve(options.release), stamp };
80
+ }
81
+ async function processNextBuild(distDir, options, owners = { browser: "starko", server: "user" }, context = {}) {
82
+ const integrity = !!context.integrity || existsSync(path.join(distDir, SRI_MANIFEST));
83
+ const releaseKnown = context.release !== void 0;
84
+ let logger = createLogger({ silent: options.silent });
85
+ let failure;
86
+ try {
87
+ const connection = resolveConnection(options);
88
+ logger = createLogger({ silent: options.silent, secrets: [connection.apiKey] });
89
+ if (!connection.apiKey) {
90
+ warnNoKeyOnce(logger);
91
+ } else {
92
+ const filter = createFileFilter(options);
93
+ const release = releaseKnown ? context.release ?? void 0 : resolveReleaseInfo(options.release);
94
+ const entries = [];
95
+ for (const sub of ["static", "server"]) {
96
+ const dir = path.join(distDir, sub);
97
+ if (!existsSync(dir)) continue;
98
+ try {
99
+ const subFilter = (relativePath) => filter(`${sub}/${relativePath}`);
100
+ const readOnly = sub === "static" && integrity;
101
+ const injected = await injectDirectory(dir, { filter: subFilter, release: release?.version, dryRun: readOnly, keepNativelyRegistered: true });
102
+ for (const s of injected.skipped) logger.warn(`not injected: ${sub}/${s.file}: ${s.reason}`);
103
+ if (readOnly && injected.injected.length) {
104
+ logger.warn(
105
+ `not injected: ${injected.injected.length} client chunk(s) in ${path.basename(distDir)}/static without a debug id of their own (e.g. ${injected.injected[0].file}): experimental.sri is on, and a chunk changed after Next computed its integrity hash would not run. Errors in them are not resolved with source maps. Next 16's Turbopack gives every chunk a native debug id (turbopack.debugIds, set by withStarko).`
106
+ );
107
+ }
108
+ const collected = await collectUploads(dir, subFilter);
109
+ for (const u of collected.unreadable) logger.warn(`could not read ${sub}/${u.file}: ${u.reason}`);
110
+ for (const e of collected.entries) entries.push({ ...e, fileName: `${sub}/${e.fileName}` });
111
+ } catch (error) {
112
+ failure = `could not process ${sub}: ${errorMessage(error)}`;
113
+ logger.warn(failure);
114
+ }
115
+ }
116
+ const outcome = await runUpload(entries, {
117
+ apiKey: connection.apiKey,
118
+ host: connection.host,
119
+ release,
120
+ dryRun: options.dryRun,
121
+ uploadTimeoutMs: options.uploadTimeoutMs,
122
+ uploadConcurrency: options.uploadConcurrency,
123
+ uploadProtocol: options.uploadProtocol,
124
+ logger
125
+ });
126
+ if (!outcome.ok) failure = outcome.error ?? "source map upload failed";
127
+ }
128
+ } catch (error) {
129
+ failure = errorMessage(error);
130
+ try {
131
+ logger.error(`source maps: ${failure}`);
132
+ } catch {
133
+ }
134
+ } finally {
135
+ await cleanUpNextBuild(distDir, options, owners, logger, integrity, keepsServerMaps(distDir, context.standalone));
136
+ }
137
+ if (failure && options.failOnError) throw new Error(`[starko] ${failure}`);
138
+ }
139
+ async function cleanUpNextBuild(distDir, options, owners, logger, integrity, keepServerMaps = false) {
140
+ for (const [sub, owner] of [["static", owners.browser], ["server", owners.server]]) {
141
+ if (!shouldDeleteSourcemaps(owner, options)) continue;
142
+ if (sub === "server" && keepServerMaps) {
143
+ logger.info(`kept the server source maps in ${path.basename(distDir)}/server: output "standalone" copies them after this step (they are not served to browsers)`);
144
+ continue;
145
+ }
146
+ try {
147
+ let kept = 0;
148
+ const deleted = await deleteAllSourcemaps(
149
+ path.join(distDir, sub),
150
+ logger,
151
+ sub === "static" ? { keepComment: keepsClientBytes(integrity), onKept: () => kept++ } : {}
152
+ );
153
+ if (kept > 0) {
154
+ logger.warn(
155
+ `left ${kept} sourceMappingURL comment(s) in ${path.basename(distDir)}/static pointing at the deleted source maps: client chunks are not rewritten after Next hashed them (${integrity ? "experimental.sri integrity hashes, " : ""}content-hashed file names). Browsers only request a map when developer tools are open, and then get a 404.`
156
+ );
157
+ }
158
+ if (deleted > 0) logger.info(`deleted ${deleted} ${sub === "static" ? "browser" : "server"} source map(s) from ${path.basename(distDir)}/${sub}`);
159
+ } catch (error) {
160
+ try {
161
+ logger.error(`could not delete the source maps under ${sub}: ${errorMessage(error)}`);
162
+ } catch {
163
+ }
164
+ }
165
+ }
166
+ }
167
+ function withStarko(nextConfig = {}, options = {}, internals = {}) {
168
+ if (typeof nextConfig === "function") {
169
+ const fn = nextConfig;
170
+ return (phase, context = {}) => {
171
+ const resolved = fn(phase, { defaultConfig: context.defaultConfig ?? {} });
172
+ if (resolved && typeof resolved.then === "function") {
173
+ return Promise.resolve(resolved).then((config) => applyStarko(config, phase, options, internals));
174
+ }
175
+ return applyStarko(resolved, phase, options, internals);
176
+ };
177
+ }
178
+ return applyStarko(nextConfig, internals.phase ?? inferPhase(), options, internals);
179
+ }
180
+ function applyStarko(resolved, phase, options, internals) {
181
+ const enabled = options.enabled ?? phase === PHASE_PRODUCTION_BUILD;
182
+ if (!enabled || !resolved || typeof resolved !== "object") return resolved;
183
+ const connection = resolveConnection(options);
184
+ if (!connection.apiKey) {
185
+ try {
186
+ warnNoKeyOnce(createLogger({ silent: options.silent }));
187
+ } catch {
188
+ }
189
+ return resolved;
190
+ }
191
+ try {
192
+ return transformConfig(resolved, phase, { ...options, apiKey: connection.apiKey }, internals);
193
+ } catch (error) {
194
+ try {
195
+ createLogger({ silent: options.silent, secrets: [connection.apiKey] }).error(`withStarko: config left unchanged: ${errorMessage(error)}`);
196
+ } catch {
197
+ }
198
+ return resolved;
199
+ }
200
+ }
201
+ function transformConfig(resolved, phase, starkoOptions, internals) {
202
+ const userConfig = resolved;
203
+ const { release, stamp } = resolveNextRelease(userConfig, starkoOptions, phase, internals.resolveRelease);
204
+ if (!release && phase !== PHASE_DEVELOPMENT_SERVER) warnNoReleaseOnce(createLogger({ silent: starkoOptions.silent, secrets: [starkoOptions.apiKey] }));
205
+ const options = { ...starkoOptions, release: release?.version };
206
+ const version = internals.nextVersion !== void 0 ? internals.nextVersion : detectNextVersion();
207
+ const hasCompileHook = version === null || versionAtLeast(version, "15.4.1");
208
+ const hasNativeDebugIds = version === null || versionAtLeast(version, "16.0.0");
209
+ const owners = {
210
+ browser: userConfig.productionBrowserSourceMaps === true ? "user" : "starko",
211
+ server: userConfig.experimental?.serverSourceMaps === true ? "user" : "starko"
212
+ };
213
+ const deleteBrowserMaps = shouldDeleteSourcemaps(owners.browser, options);
214
+ const config = { ...userConfig };
215
+ if (release && stamp) config.env = { ...userConfig.env, [BUILD_RELEASE_ENV]: release.version };
216
+ if (hasCompileHook) {
217
+ config.productionBrowserSourceMaps = true;
218
+ config.experimental = { ...userConfig.experimental, serverSourceMaps: true };
219
+ }
220
+ if (hasNativeDebugIds) config.turbopack = { ...userConfig.turbopack, debugIds: true };
221
+ const userWebpack = userConfig.webpack;
222
+ config.webpack = (webpackConfig, webpackContext) => {
223
+ const out = (userWebpack ? userWebpack(webpackConfig, webpackContext) : webpackConfig) ?? webpackConfig;
224
+ if (webpackContext.dev) return out;
225
+ try {
226
+ const browser = !webpackContext.isServer;
227
+ if (browser && deleteBrowserMaps && out.devtool) out.devtool = "hidden-source-map";
228
+ const owner = browser ? owners.browser : owners.server;
229
+ out.plugins = [
230
+ ...out.plugins ?? [],
231
+ new StarkoWebpackPlugin(
232
+ { ...options, enabled: true, upload: !hasCompileHook },
233
+ // On older Next the flags are untouched: a devtool there is the user's (or Next's) own.
234
+ { sourcemapOwner: hasCompileHook ? owner : "user" }
235
+ )
236
+ ];
237
+ } catch (error) {
238
+ createLogger({ silent: options.silent, secrets: [options.apiKey] }).error(`withStarko: webpack config left unchanged: ${errorMessage(error)}`);
239
+ }
240
+ return out;
241
+ };
242
+ if (hasCompileHook) {
243
+ const userHook = userConfig.compiler?.runAfterProductionCompile;
244
+ config.compiler = {
245
+ ...userConfig.compiler,
246
+ runAfterProductionCompile: async (metadata) => {
247
+ try {
248
+ if (userHook) await userHook(metadata);
249
+ } finally {
250
+ try {
251
+ await processNextBuild(metadata.distDir, options, owners, { integrity: !!userConfig.experimental?.sri?.algorithm, release: release ?? null, standalone: userConfig.output === "standalone" });
252
+ } catch (error) {
253
+ if (options.failOnError) throw error;
254
+ }
255
+ }
256
+ }
257
+ };
258
+ }
259
+ return config;
260
+ }
261
+ var config_default = withStarko;
262
+
263
+ export { _resetNextConfigWarnings, config_default as default, inferPhase, processNextBuild, resolveNextRelease, versionAtLeast, withStarko };
@@ -0,0 +1,148 @@
1
+ 'use strict';
2
+
3
+ var chunk2PM4FRM5_cjs = require('../chunk-2PM4FRM5.cjs');
4
+ var chunkLXBXFOAP_cjs = require('../chunk-LXBXFOAP.cjs');
5
+ require('../chunk-CIHNKN62.cjs');
6
+ require('../chunk-ZS3K3SDR.cjs');
7
+ var chunkQV4HRIDD_cjs = require('../chunk-QV4HRIDD.cjs');
8
+ require('../chunk-N6R6BWHK.cjs');
9
+
10
+ // src/next/index.ts
11
+ var flushTimeout = 2e3;
12
+ var impl;
13
+ function pick(m) {
14
+ const mod = m;
15
+ if (typeof mod.init === "function") return mod;
16
+ if (mod.default && typeof mod.default.init === "function") return mod.default;
17
+ return void 0;
18
+ }
19
+ function loadRuntime() {
20
+ if (impl) return impl;
21
+ try {
22
+ if (process.env.NEXT_RUNTIME === "nodejs") {
23
+ impl = import('../server-node-ET4LIPEC.cjs').then(pick);
24
+ } else if (process.env.NEXT_RUNTIME === "edge") {
25
+ impl = import('../server-edge-7624N3WF.cjs').then(pick);
26
+ }
27
+ } catch {
28
+ }
29
+ if (!impl) impl = Promise.resolve(void 0);
30
+ impl = impl.catch(() => void 0);
31
+ return impl;
32
+ }
33
+ async function register(options) {
34
+ try {
35
+ if (typeof options.flushTimeout === "number" && options.flushTimeout >= 0) flushTimeout = options.flushTimeout;
36
+ const rt = await loadRuntime();
37
+ if (rt) {
38
+ const { flushTimeout: _ignored, ...rest } = options;
39
+ rt.init(rest);
40
+ }
41
+ } catch (err) {
42
+ try {
43
+ if (options && options.debug) console.warn("[starko] register failed", err);
44
+ } catch {
45
+ }
46
+ }
47
+ }
48
+ async function captureRequestError(error, request, context) {
49
+ try {
50
+ const rt = await loadRuntime();
51
+ if (rt) await rt.captureRequestError(error, request, context, flushTimeout);
52
+ } catch {
53
+ }
54
+ }
55
+ var onRequestError = (error, request, context) => captureRequestError(error, request, context);
56
+ function _resetNextRuntime() {
57
+ impl = void 0;
58
+ flushTimeout = 2e3;
59
+ }
60
+
61
+ Object.defineProperty(exports, "currentRequestKey", {
62
+ enumerable: true,
63
+ get: function () { return chunk2PM4FRM5_cjs.currentRequestKey; }
64
+ });
65
+ Object.defineProperty(exports, "getRequestData", {
66
+ enumerable: true,
67
+ get: function () { return chunk2PM4FRM5_cjs.getRequestData; }
68
+ });
69
+ Object.defineProperty(exports, "markServing", {
70
+ enumerable: true,
71
+ get: function () { return chunk2PM4FRM5_cjs.markServing; }
72
+ });
73
+ Object.defineProperty(exports, "runWithRequestScope", {
74
+ enumerable: true,
75
+ get: function () { return chunk2PM4FRM5_cjs.runWithRequestScope; }
76
+ });
77
+ Object.defineProperty(exports, "wrapHandler", {
78
+ enumerable: true,
79
+ get: function () { return chunk2PM4FRM5_cjs.wrapHandler; }
80
+ });
81
+ Object.defineProperty(exports, "isNextControlFlow", {
82
+ enumerable: true,
83
+ get: function () { return chunkLXBXFOAP_cjs.isNextControlFlow; }
84
+ });
85
+ Object.defineProperty(exports, "nextControlFlowIntegration", {
86
+ enumerable: true,
87
+ get: function () { return chunkLXBXFOAP_cjs.nextControlFlowIntegration; }
88
+ });
89
+ Object.defineProperty(exports, "addBreadcrumb", {
90
+ enumerable: true,
91
+ get: function () { return chunkQV4HRIDD_cjs.addBreadcrumb; }
92
+ });
93
+ Object.defineProperty(exports, "captureException", {
94
+ enumerable: true,
95
+ get: function () { return chunkQV4HRIDD_cjs.captureException; }
96
+ });
97
+ Object.defineProperty(exports, "captureMessage", {
98
+ enumerable: true,
99
+ get: function () { return chunkQV4HRIDD_cjs.captureMessage; }
100
+ });
101
+ Object.defineProperty(exports, "close", {
102
+ enumerable: true,
103
+ get: function () { return chunkQV4HRIDD_cjs.close; }
104
+ });
105
+ Object.defineProperty(exports, "flush", {
106
+ enumerable: true,
107
+ get: function () { return chunkQV4HRIDD_cjs.flush; }
108
+ });
109
+ Object.defineProperty(exports, "getClient", {
110
+ enumerable: true,
111
+ get: function () { return chunkQV4HRIDD_cjs.getClient; }
112
+ });
113
+ Object.defineProperty(exports, "identify", {
114
+ enumerable: true,
115
+ get: function () { return chunkQV4HRIDD_cjs.identify; }
116
+ });
117
+ Object.defineProperty(exports, "setContext", {
118
+ enumerable: true,
119
+ get: function () { return chunkQV4HRIDD_cjs.setContext; }
120
+ });
121
+ Object.defineProperty(exports, "setExtra", {
122
+ enumerable: true,
123
+ get: function () { return chunkQV4HRIDD_cjs.setExtra; }
124
+ });
125
+ Object.defineProperty(exports, "setExtras", {
126
+ enumerable: true,
127
+ get: function () { return chunkQV4HRIDD_cjs.setExtras; }
128
+ });
129
+ Object.defineProperty(exports, "setTag", {
130
+ enumerable: true,
131
+ get: function () { return chunkQV4HRIDD_cjs.setTag; }
132
+ });
133
+ Object.defineProperty(exports, "setTags", {
134
+ enumerable: true,
135
+ get: function () { return chunkQV4HRIDD_cjs.setTags; }
136
+ });
137
+ Object.defineProperty(exports, "setUser", {
138
+ enumerable: true,
139
+ get: function () { return chunkQV4HRIDD_cjs.setUser; }
140
+ });
141
+ Object.defineProperty(exports, "withScope", {
142
+ enumerable: true,
143
+ get: function () { return chunkQV4HRIDD_cjs.withScope; }
144
+ });
145
+ exports._resetNextRuntime = _resetNextRuntime;
146
+ exports.captureRequestError = captureRequestError;
147
+ exports.onRequestError = onRequestError;
148
+ exports.register = register;
@@ -0,0 +1,32 @@
1
+ import { N as NodeOptions } from '../handler-BcnsnvhF.cjs';
2
+ export { R as RequestData, W as WrapHandlerOptions, c as currentRequestKey, g as getRequestData, m as markServing, r as runWithRequestScope, w as wrapHandler } from '../handler-BcnsnvhF.cjs';
3
+ import { N as NextRequestErrorRequest, a as NextRequestErrorContext } from '../common-DLFAqL2d.cjs';
4
+ export { b as NextOnRequestError, i as isNextControlFlow, n as nextControlFlowIntegration } from '../common-DLFAqL2d.cjs';
5
+ export { C as Client, E as EventHint, I as Integration, c as addBreadcrumb, d as captureException, e as captureMessage, f as close, g as flush, h as getClient, k as identify, s as setContext, l as setExtra, m as setExtras, n as setTag, o as setTags, p as setUser, w as withScope } from '../api-DNrctwJu.cjs';
6
+ export { L as Level, W as WireEvent, a as WireUser } from '../scope-D1ouJm2h.cjs';
7
+
8
+ interface NextServerOptions extends NodeOptions {
9
+ /**
10
+ * Longest background flush `onRequestError` hands to the platform's
11
+ * `waitUntil`, ms. Default 2000. Without `waitUntil` on a serverless
12
+ * platform the hook waits at most min(this, 500 ms).
13
+ */
14
+ flushTimeout?: number;
15
+ }
16
+ /**
17
+ * Call from `instrumentation.ts`'s `register()`. Resolves once the SDK is
18
+ * started (or immediately where it does not apply). Never rejects.
19
+ */
20
+ declare function register(options: NextServerOptions): Promise<void>;
21
+ /**
22
+ * Capture an error Next reports through `onRequestError`. For an app that
23
+ * has its own `onRequestError`: `await captureRequestError(error, request, context)`.
24
+ * Never rejects.
25
+ */
26
+ declare function captureRequestError(error: unknown, request: Readonly<NextRequestErrorRequest>, context: Readonly<NextRequestErrorContext>): Promise<void>;
27
+ /** Next's `onRequestError` hook: `export const onRequestError = Starko.onRequestError;` */
28
+ declare const onRequestError: (error: unknown, request: Readonly<NextRequestErrorRequest>, context: Readonly<NextRequestErrorContext>) => Promise<void>;
29
+ /** Test seam: forget the loaded runtime. */
30
+ declare function _resetNextRuntime(): void;
31
+
32
+ export { NextRequestErrorContext, NextRequestErrorRequest, type NextServerOptions, NodeOptions, _resetNextRuntime, captureRequestError, onRequestError, register };
@@ -0,0 +1,32 @@
1
+ import { N as NodeOptions } from '../handler-qHzilC9T.js';
2
+ export { R as RequestData, W as WrapHandlerOptions, c as currentRequestKey, g as getRequestData, m as markServing, r as runWithRequestScope, w as wrapHandler } from '../handler-qHzilC9T.js';
3
+ import { N as NextRequestErrorRequest, a as NextRequestErrorContext } from '../common-DbSXkaw6.js';
4
+ export { b as NextOnRequestError, i as isNextControlFlow, n as nextControlFlowIntegration } from '../common-DbSXkaw6.js';
5
+ export { C as Client, E as EventHint, I as Integration, c as addBreadcrumb, d as captureException, e as captureMessage, f as close, g as flush, h as getClient, k as identify, s as setContext, l as setExtra, m as setExtras, n as setTag, o as setTags, p as setUser, w as withScope } from '../api-BAFm4Lxj.js';
6
+ export { L as Level, W as WireEvent, a as WireUser } from '../scope-D1ouJm2h.js';
7
+
8
+ interface NextServerOptions extends NodeOptions {
9
+ /**
10
+ * Longest background flush `onRequestError` hands to the platform's
11
+ * `waitUntil`, ms. Default 2000. Without `waitUntil` on a serverless
12
+ * platform the hook waits at most min(this, 500 ms).
13
+ */
14
+ flushTimeout?: number;
15
+ }
16
+ /**
17
+ * Call from `instrumentation.ts`'s `register()`. Resolves once the SDK is
18
+ * started (or immediately where it does not apply). Never rejects.
19
+ */
20
+ declare function register(options: NextServerOptions): Promise<void>;
21
+ /**
22
+ * Capture an error Next reports through `onRequestError`. For an app that
23
+ * has its own `onRequestError`: `await captureRequestError(error, request, context)`.
24
+ * Never rejects.
25
+ */
26
+ declare function captureRequestError(error: unknown, request: Readonly<NextRequestErrorRequest>, context: Readonly<NextRequestErrorContext>): Promise<void>;
27
+ /** Next's `onRequestError` hook: `export const onRequestError = Starko.onRequestError;` */
28
+ declare const onRequestError: (error: unknown, request: Readonly<NextRequestErrorRequest>, context: Readonly<NextRequestErrorContext>) => Promise<void>;
29
+ /** Test seam: forget the loaded runtime. */
30
+ declare function _resetNextRuntime(): void;
31
+
32
+ export { NextRequestErrorContext, NextRequestErrorRequest, type NextServerOptions, NodeOptions, _resetNextRuntime, captureRequestError, onRequestError, register };
@@ -0,0 +1,59 @@
1
+ export { currentRequestKey, getRequestData, markServing, runWithRequestScope, wrapHandler } from '../chunk-N5R6ORIB.js';
2
+ export { isNextControlFlow, nextControlFlowIntegration } from '../chunk-EC2WZ6PG.js';
3
+ import '../chunk-VNCWOGTI.js';
4
+ import '../chunk-335HNCOJ.js';
5
+ export { addBreadcrumb, captureException, captureMessage, close, flush, getClient, identify, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope } from '../chunk-WDKRKGYF.js';
6
+ import '../chunk-3AW5B2WW.js';
7
+
8
+ // src/next/index.ts
9
+ var flushTimeout = 2e3;
10
+ var impl;
11
+ function pick(m) {
12
+ const mod = m;
13
+ if (typeof mod.init === "function") return mod;
14
+ if (mod.default && typeof mod.default.init === "function") return mod.default;
15
+ return void 0;
16
+ }
17
+ function loadRuntime() {
18
+ if (impl) return impl;
19
+ try {
20
+ if (process.env.NEXT_RUNTIME === "nodejs") {
21
+ impl = import('../server-node-TQUVMZUC.js').then(pick);
22
+ } else if (process.env.NEXT_RUNTIME === "edge") {
23
+ impl = import('../server-edge-BEEXWL7T.js').then(pick);
24
+ }
25
+ } catch {
26
+ }
27
+ if (!impl) impl = Promise.resolve(void 0);
28
+ impl = impl.catch(() => void 0);
29
+ return impl;
30
+ }
31
+ async function register(options) {
32
+ try {
33
+ if (typeof options.flushTimeout === "number" && options.flushTimeout >= 0) flushTimeout = options.flushTimeout;
34
+ const rt = await loadRuntime();
35
+ if (rt) {
36
+ const { flushTimeout: _ignored, ...rest } = options;
37
+ rt.init(rest);
38
+ }
39
+ } catch (err) {
40
+ try {
41
+ if (options && options.debug) console.warn("[starko] register failed", err);
42
+ } catch {
43
+ }
44
+ }
45
+ }
46
+ async function captureRequestError(error, request, context) {
47
+ try {
48
+ const rt = await loadRuntime();
49
+ if (rt) await rt.captureRequestError(error, request, context, flushTimeout);
50
+ } catch {
51
+ }
52
+ }
53
+ var onRequestError = (error, request, context) => captureRequestError(error, request, context);
54
+ function _resetNextRuntime() {
55
+ impl = void 0;
56
+ flushTimeout = 2e3;
57
+ }
58
+
59
+ export { _resetNextRuntime, captureRequestError, onRequestError, register };