@starko-one/sdk 0.0.0-stage → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -0
- package/LICENSE +17 -0
- package/NOTICE +58 -0
- package/README.md +81 -2
- package/dist/api-B5IHeINe.d.ts +558 -0
- package/dist/api-DR4HazCu.d.cts +558 -0
- package/dist/browser/index.cjs +168 -0
- package/dist/browser/index.d.cts +131 -0
- package/dist/browser/index.d.ts +131 -0
- package/dist/browser/index.js +7 -0
- package/dist/build/rollup.cjs +22 -0
- package/dist/build/rollup.d.cts +34 -0
- package/dist/build/rollup.d.ts +34 -0
- package/dist/build/rollup.js +3 -0
- package/dist/build/vite.cjs +51 -0
- package/dist/build/vite.d.cts +23 -0
- package/dist/build/vite.d.ts +23 -0
- package/dist/build/vite.js +46 -0
- package/dist/build/webpack.cjs +18 -0
- package/dist/build/webpack.d.cts +39 -0
- package/dist/build/webpack.d.ts +39 -0
- package/dist/build/webpack.js +3 -0
- package/dist/chunk-7HYGODU6.cjs +583 -0
- package/dist/chunk-A5M4NOVT.js +413 -0
- package/dist/chunk-A7MYYWMP.cjs +15 -0
- package/dist/chunk-BAQA47FM.js +1113 -0
- package/dist/chunk-CM7HM6CC.js +563 -0
- package/dist/chunk-DFYNIWUN.js +608 -0
- package/dist/chunk-DMVVCGKO.cjs +96 -0
- package/dist/chunk-FARGXYJ4.cjs +56 -0
- package/dist/chunk-G3MYIAX2.js +1226 -0
- package/dist/chunk-G4NAVZQ4.js +249 -0
- package/dist/chunk-GH7RYPKS.js +96 -0
- package/dist/chunk-HADYYQNL.cjs +134 -0
- package/dist/chunk-HOQPAB4X.js +178 -0
- package/dist/chunk-J5RU73SW.js +214 -0
- package/dist/chunk-JNAJ3YZB.cjs +223 -0
- package/dist/chunk-KN7H22EQ.cjs +659 -0
- package/dist/chunk-LDQ4I7FZ.cjs +1151 -0
- package/dist/chunk-NPGESRVQ.js +1212 -0
- package/dist/chunk-OPWM5V7A.cjs +258 -0
- package/dist/chunk-PYYWPIFL.cjs +1230 -0
- package/dist/chunk-R7JLZ4WO.cjs +115 -0
- package/dist/chunk-SC6VQSES.js +213 -0
- package/dist/chunk-TPSJGLR3.cjs +220 -0
- package/dist/chunk-UKBY6HPC.js +131 -0
- package/dist/chunk-VRSEHRBX.cjs +185 -0
- package/dist/chunk-X74AONZA.js +90 -0
- package/dist/chunk-XW3I5CJN.js +12 -0
- package/dist/chunk-XW56FKKJ.js +53 -0
- package/dist/chunk-Z3G5SW7R.cjs +1251 -0
- package/dist/chunk-ZVMAN7OO.cjs +431 -0
- package/dist/cli/index.cjs +1487 -0
- package/dist/common-ARWXbeS3.d.ts +36 -0
- package/dist/common-CwIFh2hK.d.cts +36 -0
- package/dist/dedupe-eHBIfUUD.d.cts +13 -0
- package/dist/dedupe-fw8aNtt4.d.ts +13 -0
- package/dist/handler-DTZ4Rzcf.d.ts +82 -0
- package/dist/handler-_00lctTI.d.cts +82 -0
- package/dist/index.cjs +277 -0
- package/dist/index.d.cts +187 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +4 -0
- package/dist/next/client.cjs +113 -0
- package/dist/next/client.d.cts +26 -0
- package/dist/next/client.d.ts +26 -0
- package/dist/next/client.js +41 -0
- package/dist/next/config.cjs +275 -0
- package/dist/next/config.d.cts +193 -0
- package/dist/next/config.d.ts +193 -0
- package/dist/next/config.js +261 -0
- package/dist/next/index.cjs +148 -0
- package/dist/next/index.d.cts +32 -0
- package/dist/next/index.d.ts +32 -0
- package/dist/next/index.js +59 -0
- package/dist/node/index.cjs +257 -0
- package/dist/node/index.d.cts +145 -0
- package/dist/node/index.d.ts +145 -0
- package/dist/node/index.js +83 -0
- package/dist/options-0BhybO54.d.cts +47 -0
- package/dist/options-0BhybO54.d.ts +47 -0
- package/dist/react/index.cjs +107 -0
- package/dist/react/index.d.cts +84 -0
- package/dist/react/index.d.ts +84 -0
- package/dist/react/index.js +103 -0
- package/dist/scope-Bvh45bOf.d.cts +404 -0
- package/dist/scope-Bvh45bOf.d.ts +404 -0
- package/dist/server-edge-BPOGA3GH.cjs +51 -0
- package/dist/server-edge-GYKAJREU.js +48 -0
- package/dist/server-node-HYK2OB2J.js +24 -0
- package/dist/server-node-J2DBAHDV.cjs +27 -0
- package/dist/session-C_WzbEN2.d.cts +4 -0
- package/dist/session-C_WzbEN2.d.ts +4 -0
- package/dist/session-propagation-B7REA7uy.d.cts +30 -0
- package/dist/session-propagation-BnJjKJbR.d.ts +30 -0
- package/dist/starko.min.js +6 -0
- package/docs/browser.md +381 -0
- package/docs/configuration.md +269 -0
- package/docs/nextjs.md +312 -0
- package/docs/node.md +376 -0
- package/docs/other-backends.md +232 -0
- package/docs/privacy.md +112 -0
- package/docs/react.md +187 -0
- package/docs/source-maps.md +332 -0
- package/docs/troubleshooting.md +171 -0
- package/docs/widget.md +84 -0
- package/docs/wire-format.md +367 -0
- package/package.json +98 -4
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkZ3G5SW7R_cjs = require('./chunk-Z3G5SW7R.cjs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
9
|
+
|
|
10
|
+
var PLUGIN_NAME = "StarkoWebpackPlugin";
|
|
11
|
+
var INFO_KEY = "starkoDebugId";
|
|
12
|
+
function relatedSourceMaps(info) {
|
|
13
|
+
const related = info.related?.sourceMap;
|
|
14
|
+
return related === void 0 ? [] : Array.isArray(related) ? related : [related];
|
|
15
|
+
}
|
|
16
|
+
var StarkoWebpackPlugin = class {
|
|
17
|
+
constructor(options = {}, internals = {}) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.internals = internals;
|
|
20
|
+
this.logger = chunkZ3G5SW7R_cjs.createLogger({ silent: options.silent, secrets: [chunkZ3G5SW7R_cjs.resolveConnection(options).apiKey] });
|
|
21
|
+
}
|
|
22
|
+
apply(compiler) {
|
|
23
|
+
const options = this.options;
|
|
24
|
+
const logger = this.logger;
|
|
25
|
+
const enabled = options.enabled ?? compiler.options.mode === "production";
|
|
26
|
+
if (!enabled) return;
|
|
27
|
+
const connection = chunkZ3G5SW7R_cjs.resolveConnection(options);
|
|
28
|
+
if (!connection.apiKey) {
|
|
29
|
+
logger.warn(chunkZ3G5SW7R_cjs.NO_API_KEY_MESSAGE);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const devtool = compiler.options.devtool;
|
|
33
|
+
const userPlugin = findSourceMapPlugin(compiler);
|
|
34
|
+
let owner = this.internals.sourcemapOwner ?? "user";
|
|
35
|
+
let addedMaps = false;
|
|
36
|
+
if (userPlugin === "eval") {
|
|
37
|
+
logger.warn('an EvalSourceMapDevToolPlugin puts the source maps inside the bundle; use SourceMapDevToolPlugin or devtool "source-map". Nothing is injected or uploaded.');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!devtool && !userPlugin) {
|
|
41
|
+
new compiler.webpack.SourceMapDevToolPlugin({ filename: "[file].map", append: false }).apply(compiler);
|
|
42
|
+
owner = "starko";
|
|
43
|
+
addedMaps = true;
|
|
44
|
+
} else if (typeof devtool === "string" && /eval|inline/.test(devtool)) {
|
|
45
|
+
logger.warn(`devtool "${devtool}" puts the source map inside the bundle; use "source-map" or "hidden-source-map". Nothing is injected or uploaded.`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const filter = chunkZ3G5SW7R_cjs.createFileFilter(options);
|
|
49
|
+
const releases = /* @__PURE__ */ new WeakMap();
|
|
50
|
+
const releaseFor = (compilation) => {
|
|
51
|
+
if (!releases.has(compilation)) releases.set(compilation, chunkZ3G5SW7R_cjs.resolveReleaseInfo(options.release));
|
|
52
|
+
return releases.get(compilation);
|
|
53
|
+
};
|
|
54
|
+
const { Compilation: CompilationClass, sources, WebpackError } = compiler.webpack;
|
|
55
|
+
const before = /* @__PURE__ */ new WeakMap();
|
|
56
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
57
|
+
compilation.hooks.processAssets.tap({ name: PLUGIN_NAME, stage: CompilationClass.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1 }, () => {
|
|
58
|
+
before.set(compilation, new Set(compilation.getAssets().map((a) => a.name).filter((name) => name.endsWith(".map"))));
|
|
59
|
+
});
|
|
60
|
+
compilation.hooks.processAssets.tap(
|
|
61
|
+
{ name: PLUGIN_NAME, stage: CompilationClass.PROCESS_ASSETS_STAGE_DEV_TOOLING + 1 },
|
|
62
|
+
() => {
|
|
63
|
+
for (const chunk of compilation.chunks) {
|
|
64
|
+
for (const file of chunk.files) {
|
|
65
|
+
if (!filter(file)) continue;
|
|
66
|
+
try {
|
|
67
|
+
const asset = compilation.getAsset(file);
|
|
68
|
+
if (!asset || typeof asset.info[INFO_KEY] === "string") continue;
|
|
69
|
+
const mapName = relatedSourceMaps(asset.info)[0] ?? `${file}.map`;
|
|
70
|
+
const mapAsset = compilation.getAsset(mapName);
|
|
71
|
+
if (!mapAsset) continue;
|
|
72
|
+
const code = asset.source.source().toString();
|
|
73
|
+
const map = JSON.parse(mapAsset.source.source().toString());
|
|
74
|
+
const out = chunkZ3G5SW7R_cjs.injectDebugId(code, map, { release: releaseFor(compilation)?.version });
|
|
75
|
+
if (out.injected) compilation.updateAsset(file, new sources.RawSource(out.code), { ...asset.info, [INFO_KEY]: out.debugId });
|
|
76
|
+
else compilation.updateAsset(file, asset.source, { ...asset.info, [INFO_KEY]: out.debugId });
|
|
77
|
+
compilation.updateAsset(mapName, new sources.RawSource(JSON.stringify(out.map)));
|
|
78
|
+
} catch (error) {
|
|
79
|
+
logger.warn(`could not inject ${file}: ${chunkZ3G5SW7R_cjs.errorMessage(error)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
if (options.upload === false) return;
|
|
87
|
+
const removeMapAssets = (compilation) => {
|
|
88
|
+
const preexisting = addedMaps ? before.get(compilation) : void 0;
|
|
89
|
+
const removed = new Set(
|
|
90
|
+
compilation.getAssets().map((a) => a.name).filter((name) => name.endsWith(".map") && !(preexisting && preexisting.has(name)))
|
|
91
|
+
);
|
|
92
|
+
for (const name of removed) compilation.deleteAsset(name);
|
|
93
|
+
if (removed.size === 0) return 0;
|
|
94
|
+
const pointsAtRemoved = (fileName, url) => {
|
|
95
|
+
const local = chunkZ3G5SW7R_cjs.localMapReference(url);
|
|
96
|
+
return local !== void 0 && removed.has(path__default.default.posix.normalize(path__default.default.posix.join(path__default.default.posix.dirname(fileName), local)));
|
|
97
|
+
};
|
|
98
|
+
for (const asset of compilation.getAssets()) {
|
|
99
|
+
const js = /\.(?:m|c)?js$/.test(asset.name);
|
|
100
|
+
if (!js && !asset.name.endsWith(".css")) continue;
|
|
101
|
+
const code = asset.source.source().toString();
|
|
102
|
+
let next = code;
|
|
103
|
+
if (js) {
|
|
104
|
+
const ref = chunkZ3G5SW7R_cjs.findSourceMappingUrl(code);
|
|
105
|
+
if (ref && pointsAtRemoved(asset.name, ref.url)) next = chunkZ3G5SW7R_cjs.stripSourceMappingUrl(code, ref);
|
|
106
|
+
} else {
|
|
107
|
+
next = chunkZ3G5SW7R_cjs.stripCssSourceMappingUrl(code, (url) => pointsAtRemoved(asset.name, url));
|
|
108
|
+
}
|
|
109
|
+
if (next !== code) compilation.updateAsset(asset.name, new sources.RawSource(next));
|
|
110
|
+
}
|
|
111
|
+
return removed.size;
|
|
112
|
+
};
|
|
113
|
+
compiler.hooks.emit.tapPromise(PLUGIN_NAME, async (compilation) => {
|
|
114
|
+
let failure;
|
|
115
|
+
try {
|
|
116
|
+
if (compilation.errors.length > 0) {
|
|
117
|
+
logger.warn("the compilation has errors; source maps are not uploaded");
|
|
118
|
+
} else {
|
|
119
|
+
const entries = [];
|
|
120
|
+
for (const asset of compilation.getAssets()) {
|
|
121
|
+
const chunkId = asset.info[INFO_KEY];
|
|
122
|
+
if (typeof chunkId !== "string") continue;
|
|
123
|
+
const mapName = relatedSourceMaps(asset.info)[0] ?? `${asset.name}.map`;
|
|
124
|
+
if (!compilation.getAsset(mapName)) continue;
|
|
125
|
+
entries.push({
|
|
126
|
+
chunkId,
|
|
127
|
+
fileName: asset.name,
|
|
128
|
+
// Read from the compilation when it is sent, not held here.
|
|
129
|
+
load: async () => {
|
|
130
|
+
const source = compilation.getAsset(mapName)?.source.source();
|
|
131
|
+
if (source === void 0) throw new Error(`${mapName} is no longer in the compilation`);
|
|
132
|
+
return typeof source === "string" ? source : Buffer.from(source);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const outcome = await chunkZ3G5SW7R_cjs.runUpload(entries, {
|
|
137
|
+
apiKey: connection.apiKey,
|
|
138
|
+
host: connection.host,
|
|
139
|
+
release: releaseFor(compilation),
|
|
140
|
+
dryRun: options.dryRun,
|
|
141
|
+
uploadTimeoutMs: options.uploadTimeoutMs,
|
|
142
|
+
logger
|
|
143
|
+
});
|
|
144
|
+
if (!outcome.ok) failure = outcome.error ?? "source map upload failed";
|
|
145
|
+
}
|
|
146
|
+
} catch (error) {
|
|
147
|
+
failure = chunkZ3G5SW7R_cjs.errorMessage(error);
|
|
148
|
+
logger.error(`source maps: ${failure}`);
|
|
149
|
+
} finally {
|
|
150
|
+
if (chunkZ3G5SW7R_cjs.shouldDeleteSourcemaps(owner, options)) {
|
|
151
|
+
try {
|
|
152
|
+
const removed = removeMapAssets(compilation);
|
|
153
|
+
if (removed > 0) {
|
|
154
|
+
logger.info(
|
|
155
|
+
owner === "starko" ? `removed ${removed} source map(s) from the output (switched on for the upload only)` : `removed ${removed} source map(s) from the output`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
logger.error(`could not remove the source maps from the output: ${chunkZ3G5SW7R_cjs.errorMessage(error)}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (failure && options.failOnError) compilation.errors.push(new WebpackError(`[starko] ${failure}`));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
function findSourceMapPlugin(compiler) {
|
|
168
|
+
try {
|
|
169
|
+
const { SourceMapDevToolPlugin, EvalSourceMapDevToolPlugin } = compiler.webpack;
|
|
170
|
+
let found;
|
|
171
|
+
for (const p of compiler.options.plugins || []) {
|
|
172
|
+
if (!p || typeof p !== "object") continue;
|
|
173
|
+
const name = p.constructor?.name;
|
|
174
|
+
if (EvalSourceMapDevToolPlugin && p instanceof EvalSourceMapDevToolPlugin || name === "EvalSourceMapDevToolPlugin") return "eval";
|
|
175
|
+
if (SourceMapDevToolPlugin && p instanceof SourceMapDevToolPlugin || name === "SourceMapDevToolPlugin") found = "maps";
|
|
176
|
+
}
|
|
177
|
+
return found;
|
|
178
|
+
} catch {
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var webpack_default = StarkoWebpackPlugin;
|
|
183
|
+
|
|
184
|
+
exports.StarkoWebpackPlugin = StarkoWebpackPlugin;
|
|
185
|
+
exports.webpack_default = webpack_default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { parseSessionHeader, SESSION_HEADER } from './chunk-XW3I5CJN.js';
|
|
2
|
+
import { unwrapThrown } from './chunk-G4NAVZQ4.js';
|
|
3
|
+
|
|
4
|
+
// src/next/common.ts
|
|
5
|
+
function buildTimeRelease() {
|
|
6
|
+
try {
|
|
7
|
+
const v = process.env.STARKO_BUILD_RELEASE;
|
|
8
|
+
return typeof v === "string" && v ? v : void 0;
|
|
9
|
+
} catch {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
var CONTROL_FLOW = ["NEXT_REDIRECT", "NEXT_HTTP_ERROR_FALLBACK", "NEXT_NOT_FOUND", "BAILOUT_TO_CLIENT_SIDE_RENDERING", "DYNAMIC_SERVER_USAGE", "NEXT_STATIC_GEN_BAILOUT", "HANGING_PROMISE_REJECTION", "NEXT_PRERENDER_INTERRUPTED"];
|
|
14
|
+
var REACT_POSTPONE = typeof Symbol === "function" ? /* @__PURE__ */ Symbol.for("react.postpone") : void 0;
|
|
15
|
+
var isControlCode = (s) => typeof s === "string" && CONTROL_FLOW.some((c) => s === c || s.startsWith(`${c};`));
|
|
16
|
+
function isNextControlFlow(error, depth = 0) {
|
|
17
|
+
try {
|
|
18
|
+
if (!error || typeof error !== "object") return false;
|
|
19
|
+
const e = error;
|
|
20
|
+
if (REACT_POSTPONE && e.$$typeof === REACT_POSTPONE) return true;
|
|
21
|
+
if (isControlCode(e.digest)) return true;
|
|
22
|
+
if (e.digest === void 0 && isControlCode(e.message)) return true;
|
|
23
|
+
return depth < 5 && isNextControlFlow(e.cause, depth + 1);
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function nextControlFlowIntegration() {
|
|
29
|
+
return {
|
|
30
|
+
name: "NextControlFlow",
|
|
31
|
+
processEvent(event, hint) {
|
|
32
|
+
const thrown = unwrapThrown(hint.originalException);
|
|
33
|
+
if (isNextControlFlow(thrown)) return null;
|
|
34
|
+
const first = event.exception_list[0];
|
|
35
|
+
if (thrown === hint.originalException && first && /^(?:Uncaught )?(?:Error: )?NEXT_(?:REDIRECT|HTTP_ERROR_FALLBACK|NOT_FOUND)\b/.test(first.value || "")) return null;
|
|
36
|
+
return event;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function digestOf(error) {
|
|
41
|
+
try {
|
|
42
|
+
const d = error && typeof error === "object" ? error.digest : void 0;
|
|
43
|
+
return typeof d === "string" && d ? d : void 0;
|
|
44
|
+
} catch {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function header(headers, name) {
|
|
49
|
+
if (!headers || typeof headers !== "object") return void 0;
|
|
50
|
+
try {
|
|
51
|
+
const h = headers;
|
|
52
|
+
if (name in h) return h[name];
|
|
53
|
+
for (const k of Object.keys(h)) if (k.toLowerCase() === name) return h[k];
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
function describeRequestError(error, request, context) {
|
|
59
|
+
const r = request || {};
|
|
60
|
+
const c = context || {};
|
|
61
|
+
const tags = {};
|
|
62
|
+
if (c.routerKind) tags["next.router_kind"] = String(c.routerKind);
|
|
63
|
+
if (c.routeType) tags["next.route_type"] = String(c.routeType);
|
|
64
|
+
if (c.renderSource) tags["next.render_source"] = String(c.renderSource);
|
|
65
|
+
if (typeof r.method === "string" && r.method) tags["next.method"] = r.method.toUpperCase();
|
|
66
|
+
const digest = digestOf(error);
|
|
67
|
+
if (digest) tags["next.digest"] = digest;
|
|
68
|
+
const nextjs = {};
|
|
69
|
+
for (const [k, v] of [
|
|
70
|
+
["router_kind", c.routerKind],
|
|
71
|
+
["route_path", c.routePath],
|
|
72
|
+
["route_type", c.routeType],
|
|
73
|
+
["render_source", c.renderSource],
|
|
74
|
+
["revalidate_reason", c.revalidateReason],
|
|
75
|
+
["render_type", c.renderType]
|
|
76
|
+
]) {
|
|
77
|
+
if (v !== void 0) nextjs[k] = v;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
hint: { mechanism: { type: "next.onRequestError", handled: false }, tags, contexts: { nextjs } },
|
|
81
|
+
request: {
|
|
82
|
+
method: typeof r.method === "string" && r.method ? r.method.toUpperCase() : void 0,
|
|
83
|
+
url: typeof r.path === "string" && r.path ? r.path : void 0,
|
|
84
|
+
route: typeof c.routePath === "string" && c.routePath ? c.routePath : void 0,
|
|
85
|
+
sessionId: parseSessionHeader(header(r.headers, SESSION_HEADER))
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { buildTimeRelease, describeRequestError, digestOf, isNextControlFlow, nextControlFlowIntegration };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SESSION_ID_PATTERN } from './chunk-GH7RYPKS.js';
|
|
2
|
+
|
|
3
|
+
// src/core/session.ts
|
|
4
|
+
var SESSION_HEADER = "x-starko-session-id";
|
|
5
|
+
function parseSessionHeader(value) {
|
|
6
|
+
const v = Array.isArray(value) ? value[0] : value;
|
|
7
|
+
if (typeof v !== "string") return void 0;
|
|
8
|
+
const id = v.trim();
|
|
9
|
+
return SESSION_ID_PATTERN.test(id) ? id : void 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { SESSION_HEADER, parseSessionHeader };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { openRequestScope, readScope, currentRequestKey, platformWaitUntil, flushIfPending } from './chunk-A5M4NOVT.js';
|
|
2
|
+
import { isNextControlFlow, describeRequestError, nextControlFlowIntegration } from './chunk-X74AONZA.js';
|
|
3
|
+
import { captureException } from './chunk-DFYNIWUN.js';
|
|
4
|
+
|
|
5
|
+
// src/next/server-common.ts
|
|
6
|
+
var LAST_RESORT_FLUSH_MS = 500;
|
|
7
|
+
function isServerless() {
|
|
8
|
+
try {
|
|
9
|
+
const env = typeof process !== "undefined" && process.env ? process.env : {};
|
|
10
|
+
return !!(env.VERCEL || env.AWS_LAMBDA_FUNCTION_NAME || env.NETLIFY || env.FUNCTION_TARGET || env.FUNCTIONS_WORKER_RUNTIME);
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function scheduleFlush(flushTimeout, runtime) {
|
|
16
|
+
try {
|
|
17
|
+
const waitUntil = platformWaitUntil();
|
|
18
|
+
if (waitUntil) {
|
|
19
|
+
waitUntil(flushIfPending(flushTimeout, true));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (runtime === "nodejs" && !isServerless()) return;
|
|
23
|
+
await flushIfPending(Math.min(flushTimeout, LAST_RESORT_FLUSH_MS), true);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function captureNextRequestError(error, request, context, flushTimeout, runtime) {
|
|
28
|
+
if (isNextControlFlow(error)) return;
|
|
29
|
+
const d = describeRequestError(error, request, context);
|
|
30
|
+
openRequestScope(
|
|
31
|
+
() => {
|
|
32
|
+
captureException(error, d.hint);
|
|
33
|
+
},
|
|
34
|
+
d.request,
|
|
35
|
+
void 0,
|
|
36
|
+
readScope(),
|
|
37
|
+
currentRequestKey()
|
|
38
|
+
);
|
|
39
|
+
await scheduleFlush(flushTimeout, runtime);
|
|
40
|
+
}
|
|
41
|
+
function withNextDefaults(options) {
|
|
42
|
+
if (!options || options.defaultIntegrations === false) return options;
|
|
43
|
+
const user = options.integrations;
|
|
44
|
+
return {
|
|
45
|
+
...options,
|
|
46
|
+
integrations: (defaults) => {
|
|
47
|
+
const withNext = [...defaults, nextControlFlowIntegration()];
|
|
48
|
+
return typeof user === "function" ? user(withNext) : [...withNext, ...user || []];
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { captureNextRequestError, withNextDefaults };
|