@vesk/adapter 0.2.93 → 0.2.94
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/dist/client-bundle.d.ts.map +1 -1
- package/dist/client-bundle.js +12 -6
- package/dist/platform-deploy.d.ts +28 -0
- package/dist/platform-deploy.d.ts.map +1 -1
- package/dist/platform-deploy.js +108 -23
- package/dist/platform-handler.d.ts.map +1 -1
- package/dist/platform-handler.js +17 -7
- package/dist/server-only.d.ts +9 -0
- package/dist/server-only.d.ts.map +1 -1
- package/dist/server-only.js +11 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-bundle.d.ts","sourceRoot":"","sources":["../src/client-bundle.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAmF,MAAM,yBAAyB,CAAC;AAuEnL;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA4BhE;AAED;;;;;GAKG;AACH,UAAU,YAAY;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC7B,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,IAAI,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE;gBAAE,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;IACt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AAU,EAAE,MAAM,GAAG,MAAM,CA+B3D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAkClE;AAoCD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAI/F"}
|
package/dist/client-bundle.js
CHANGED
|
@@ -1617,16 +1617,22 @@ export async function generateClientBundle(routeTree, appDir, componentMap, opti
|
|
|
1617
1617
|
loader: { '.js': 'tsx' },
|
|
1618
1618
|
legalComments: 'none',
|
|
1619
1619
|
...(appTsconfig ? { tsconfig: appTsconfig } : {}),
|
|
1620
|
-
// Stub
|
|
1621
|
-
//
|
|
1622
|
-
//
|
|
1623
|
-
//
|
|
1624
|
-
//
|
|
1620
|
+
// Stub only the OPTIONAL CJS deps (canvas for raster export, @zxing/*
|
|
1621
|
+
// for scan validation). They degrade gracefully and their absence must
|
|
1622
|
+
// not break the bundle.
|
|
1623
|
+
//
|
|
1624
|
+
// `qrcode-generator` must NOT be stubbed: it is the pure-JS encoder
|
|
1625
|
+
// every client-side QR (vesk-qr's dynamic `import("qrcode-generator")`)
|
|
1626
|
+
// runs on. Stubbing it to `export {}` makes `getQrcode()` resolve to an
|
|
1627
|
+
// empty object, so `CofoundrMatrix.generate()` throws
|
|
1628
|
+
// "QREncodingError: generator is not a function" during hydration and
|
|
1629
|
+
// the page falls back to the client error boundary. esbuild bundles it
|
|
1630
|
+
// as CJS fine; only genuinely Node-only/optional deps belong here.
|
|
1625
1631
|
plugins: [
|
|
1626
1632
|
{
|
|
1627
1633
|
name: 'stub-browser-packages',
|
|
1628
1634
|
setup(b) {
|
|
1629
|
-
b.onResolve({ filter: /^(
|
|
1635
|
+
b.onResolve({ filter: /^(canvas|@zxing\/(browser|node))(\/|$)/ }, (args) => ({ path: args.path, namespace: 'browser-stub' }));
|
|
1630
1636
|
b.onLoad({ filter: /.*/, namespace: 'browser-stub' }, () => ({
|
|
1631
1637
|
contents: 'export {}\n',
|
|
1632
1638
|
loader: 'js',
|
|
@@ -4,6 +4,22 @@ import type { Platform } from '@vesk/adapter/src/platform';
|
|
|
4
4
|
export interface DeployContext extends PlatformBuildContext {
|
|
5
5
|
prerenderedRoutes: SsgRouteResult[];
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Ship the installed TCP driver packages (and their transitive dependency
|
|
9
|
+
* closures) into a Node function's `node_modules`.
|
|
10
|
+
*
|
|
11
|
+
* A serverless function built by Vesk is otherwise self-contained — esbuild
|
|
12
|
+
* inlines everything. But a driver loaded through a variable `import(spec)`
|
|
13
|
+
* (e.g. `slintorm`'s `importDriver("pg")`) is invisible to esbuild *and* to the
|
|
14
|
+
* host's dependency tracer, and Build Output API functions do not install
|
|
15
|
+
* package.json dependencies. Without this the Postgres driver fails at runtime
|
|
16
|
+
* with `Cannot find module 'pg'` even though it is installed at build time.
|
|
17
|
+
*
|
|
18
|
+
* Only `dependencies`/`optionalDependencies` are followed (never dev deps), and
|
|
19
|
+
* nested `node_modules` are skipped because every dependency is flattened into
|
|
20
|
+
* the function's `node_modules` by name.
|
|
21
|
+
*/
|
|
22
|
+
export declare function shipNodeDriverClosures(projectRoot: string, funcDir: string): void;
|
|
7
23
|
/**
|
|
8
24
|
* Universal deployment emit. The handler, the bundle and the static layout are
|
|
9
25
|
* shared across every platform — only the ~10-line shell each runtime mandates
|
|
@@ -16,4 +32,16 @@ export interface DeployContext extends PlatformBuildContext {
|
|
|
16
32
|
* not a symlink).
|
|
17
33
|
*/
|
|
18
34
|
export declare function emitPlatformOutput(platform: Platform, ctx: DeployContext): Promise<string | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Vercel Node entry source.
|
|
37
|
+
*
|
|
38
|
+
* The request URL is the base that SSR helpers resolve relative
|
|
39
|
+
* `useFetch('/api/…')` calls against. On Vercel, `req.headers.host` can be the
|
|
40
|
+
* deployment-specific host, which sits behind deployment protection, while
|
|
41
|
+
* `x-forwarded-host` carries the public alias the browser used. Preferring the
|
|
42
|
+
* forwarded host/proto keeps internal SSR fetches on the public origin; hitting
|
|
43
|
+
* the protected host follows a redirect to Vercel's auth HTML, which then fails
|
|
44
|
+
* `res.json()` with `Unexpected token '<'`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function vercelBootstrapSource(): string;
|
|
19
47
|
//# sourceMappingURL=platform-deploy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-deploy.d.ts","sourceRoot":"","sources":["../src/platform-deploy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"platform-deploy.d.ts","sourceRoot":"","sources":["../src/platform-deploy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAGrI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD,iBAAiB,EAAE,cAAc,EAAE,CAAC;CACrC;AAkBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CA0BjF;AA0BD;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoFvG;AAqGD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CA2B9C"}
|
package/dist/platform-deploy.js
CHANGED
|
@@ -1,7 +1,71 @@
|
|
|
1
|
-
import { writeFileSync, mkdirSync, rmSync, cpSync } from 'node:fs';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
1
|
+
import { writeFileSync, mkdirSync, rmSync, cpSync, readFileSync, existsSync } from 'node:fs';
|
|
2
|
+
import { resolve, dirname, relative } from 'node:path';
|
|
3
3
|
import { generatePlatformHandlerSource, bundlePlatformHandler } from '@vesk/adapter/src/platform-handler';
|
|
4
4
|
import { ensureCleanDir, writePlatformStatic, writePrerenderedStatic, listStaticDir, mimeFor } from '@vesk/adapter/src/platform-output';
|
|
5
|
+
import { tcpDriverPackages } from '@vesk/adapter/src/server-only';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve an installed package directory the way Node does: walk up from the
|
|
8
|
+
* project root looking for `node_modules/<name>` (handles npm hoisting and
|
|
9
|
+
* monorepo workspaces). Returns null when the package is not installed.
|
|
10
|
+
*/
|
|
11
|
+
function resolveInstalledPackage(projectRoot, name) {
|
|
12
|
+
let dir = projectRoot;
|
|
13
|
+
while (true) {
|
|
14
|
+
const candidate = resolve(dir, 'node_modules', name);
|
|
15
|
+
if (existsSync(resolve(candidate, 'package.json')))
|
|
16
|
+
return candidate;
|
|
17
|
+
const parent = dirname(dir);
|
|
18
|
+
if (parent === dir)
|
|
19
|
+
return null;
|
|
20
|
+
dir = parent;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Ship the installed TCP driver packages (and their transitive dependency
|
|
25
|
+
* closures) into a Node function's `node_modules`.
|
|
26
|
+
*
|
|
27
|
+
* A serverless function built by Vesk is otherwise self-contained — esbuild
|
|
28
|
+
* inlines everything. But a driver loaded through a variable `import(spec)`
|
|
29
|
+
* (e.g. `slintorm`'s `importDriver("pg")`) is invisible to esbuild *and* to the
|
|
30
|
+
* host's dependency tracer, and Build Output API functions do not install
|
|
31
|
+
* package.json dependencies. Without this the Postgres driver fails at runtime
|
|
32
|
+
* with `Cannot find module 'pg'` even though it is installed at build time.
|
|
33
|
+
*
|
|
34
|
+
* Only `dependencies`/`optionalDependencies` are followed (never dev deps), and
|
|
35
|
+
* nested `node_modules` are skipped because every dependency is flattened into
|
|
36
|
+
* the function's `node_modules` by name.
|
|
37
|
+
*/
|
|
38
|
+
export function shipNodeDriverClosures(projectRoot, funcDir) {
|
|
39
|
+
const destModules = resolve(funcDir, 'node_modules');
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const queue = tcpDriverPackages();
|
|
42
|
+
while (queue.length > 0) {
|
|
43
|
+
const name = queue.shift();
|
|
44
|
+
if (seen.has(name))
|
|
45
|
+
continue;
|
|
46
|
+
seen.add(name);
|
|
47
|
+
const pkgDir = resolveInstalledPackage(projectRoot, name);
|
|
48
|
+
if (!pkgDir)
|
|
49
|
+
continue;
|
|
50
|
+
const dest = resolve(destModules, name);
|
|
51
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
52
|
+
cpSync(pkgDir, dest, {
|
|
53
|
+
recursive: true,
|
|
54
|
+
filter: (src) => !relative(pkgDir, src).split(/[\\/]/).includes('node_modules'),
|
|
55
|
+
});
|
|
56
|
+
let pkg = {};
|
|
57
|
+
try {
|
|
58
|
+
pkg = JSON.parse(readFileSync(resolve(pkgDir, 'package.json'), 'utf-8'));
|
|
59
|
+
}
|
|
60
|
+
catch { /* unreadable package.json: copy the package as-is */ }
|
|
61
|
+
const deps = {
|
|
62
|
+
...(pkg.dependencies || {}),
|
|
63
|
+
...(pkg.optionalDependencies || {}),
|
|
64
|
+
};
|
|
65
|
+
for (const dep of Object.keys(deps))
|
|
66
|
+
queue.push(dep);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
5
69
|
/**
|
|
6
70
|
* Universal deployment emit. The handler, the bundle and the static layout are
|
|
7
71
|
* shared across every platform — only the ~10-line shell each runtime mandates
|
|
@@ -60,6 +124,8 @@ export async function emitPlatformOutput(platform, ctx) {
|
|
|
60
124
|
}
|
|
61
125
|
handlerRel = `${shell.functionFile.dir}/${shell.functionFile.file}`;
|
|
62
126
|
await bundlePlatformHandler({ entry, outfile: resolve(funcDir, shell.functionFile.file), nodeBuiltins: shell.nodeBuiltins });
|
|
127
|
+
if (shell.nodeBuiltins)
|
|
128
|
+
shipNodeDriverClosures(projectRoot, funcDir);
|
|
63
129
|
}
|
|
64
130
|
else {
|
|
65
131
|
handlerRel = shell.outfile || 'index.js';
|
|
@@ -186,6 +252,45 @@ function serveEmbeddedStatic(request) {
|
|
|
186
252
|
return null;
|
|
187
253
|
}`;
|
|
188
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Vercel Node entry source.
|
|
257
|
+
*
|
|
258
|
+
* The request URL is the base that SSR helpers resolve relative
|
|
259
|
+
* `useFetch('/api/…')` calls against. On Vercel, `req.headers.host` can be the
|
|
260
|
+
* deployment-specific host, which sits behind deployment protection, while
|
|
261
|
+
* `x-forwarded-host` carries the public alias the browser used. Preferring the
|
|
262
|
+
* forwarded host/proto keeps internal SSR fetches on the public origin; hitting
|
|
263
|
+
* the protected host follows a redirect to Vercel's auth HTML, which then fails
|
|
264
|
+
* `res.json()` with `Unexpected token '<'`.
|
|
265
|
+
*/
|
|
266
|
+
export function vercelBootstrapSource() {
|
|
267
|
+
return [
|
|
268
|
+
'export default async function veskNodeEntry(req, res) {',
|
|
269
|
+
" const __fwdHost = String(req.headers['x-forwarded-host'] || '').split(',')[0].trim();",
|
|
270
|
+
" const __host = __fwdHost || req.headers.host || 'localhost';",
|
|
271
|
+
" const __fwdProto = String(req.headers['x-forwarded-proto'] || '').split(',')[0].trim();",
|
|
272
|
+
" const __local = __host === 'localhost' || __host.startsWith('127.') || __host === '[::1]';",
|
|
273
|
+
" const __proto = __fwdProto || (__local ? 'http' : 'https');",
|
|
274
|
+
' const url = new URL(req.url, `${__proto}://${__host}`);',
|
|
275
|
+
" const method = req.method || 'GET';",
|
|
276
|
+
' let body;',
|
|
277
|
+
" if (method !== 'GET' && method !== 'HEAD') {",
|
|
278
|
+
' body = await new Promise((resolveBody, reject) => {',
|
|
279
|
+
' const chunks = [];',
|
|
280
|
+
" req.on('data', (c) => chunks.push(c));",
|
|
281
|
+
' req.on("error", reject);',
|
|
282
|
+
' req.on("end", () => resolveBody(Buffer.concat(chunks)));',
|
|
283
|
+
' });',
|
|
284
|
+
' }',
|
|
285
|
+
' const headers = {};',
|
|
286
|
+
' for (const key in req.headers) headers[key] = req.headers[key];',
|
|
287
|
+
' const request = new Request(url, { method, headers, body });',
|
|
288
|
+
' const response = await handleRequest(request);',
|
|
289
|
+
' res.writeHead(response.status, Object.fromEntries(response.headers));',
|
|
290
|
+
' res.end(await response.text());',
|
|
291
|
+
'}',
|
|
292
|
+
].join('\n');
|
|
293
|
+
}
|
|
189
294
|
function shellFor(platform) {
|
|
190
295
|
switch (platform) {
|
|
191
296
|
case 'vercel':
|
|
@@ -206,27 +311,7 @@ function shellFor(platform) {
|
|
|
206
311
|
shouldAddSourcemapSupport: false,
|
|
207
312
|
supportsResponseStreaming: true,
|
|
208
313
|
},
|
|
209
|
-
bootstrap:
|
|
210
|
-
'export default async function veskNodeEntry(req, res) {',
|
|
211
|
-
" const url = new URL(req.url, 'http://' + (req.headers.host || 'localhost'));",
|
|
212
|
-
" const method = req.method || 'GET';",
|
|
213
|
-
' let body;',
|
|
214
|
-
" if (method !== 'GET' && method !== 'HEAD') {",
|
|
215
|
-
' body = await new Promise((resolveBody, reject) => {',
|
|
216
|
-
' const chunks = [];',
|
|
217
|
-
" req.on('data', (c) => chunks.push(c));",
|
|
218
|
-
' req.on("error", reject);',
|
|
219
|
-
' req.on("end", () => resolveBody(Buffer.concat(chunks)));',
|
|
220
|
-
' });',
|
|
221
|
-
' }',
|
|
222
|
-
' const headers = {};',
|
|
223
|
-
' for (const key in req.headers) headers[key] = req.headers[key];',
|
|
224
|
-
' const request = new Request(url, { method, headers, body });',
|
|
225
|
-
' const response = await handleRequest(request);',
|
|
226
|
-
' res.writeHead(response.status, Object.fromEntries(response.headers));',
|
|
227
|
-
' res.end(await response.text());',
|
|
228
|
-
'}',
|
|
229
|
-
].join('\n'),
|
|
314
|
+
bootstrap: vercelBootstrapSource(),
|
|
230
315
|
};
|
|
231
316
|
case 'netlify':
|
|
232
317
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAgBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CA4PjF;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAgBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CA4PjF;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6JzF;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/platform-handler.js
CHANGED
|
@@ -348,15 +348,25 @@ export const execSync = () => '';
|
|
|
348
348
|
// their require() calls into `__require` shims that throw in ESM output.
|
|
349
349
|
// esbuild 0.28's string `external` option does not externalize resolvable
|
|
350
350
|
// bare specifiers (it emits `__require` shims instead), so resolve these
|
|
351
|
-
// packages to empty stub modules.
|
|
352
|
-
//
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
//
|
|
351
|
+
// packages to empty stub modules. vesk-qr and its optional CJS deps
|
|
352
|
+
// (qrcode-generator, canvas, @zxing/*) are optional at runtime on edge (they
|
|
353
|
+
// fail gracefully), so stubbing them at build time is safe and keeps the
|
|
354
|
+
// bundle valid ESM.
|
|
355
|
+
//
|
|
356
|
+
// Node targets are different: the `createRequire` banner makes the
|
|
357
|
+
// `__require` shim resolve for real, so vesk-qr and its encoder (the CJS
|
|
358
|
+
// `qrcode-generator`) MUST be bundled. A Build Output function ships no
|
|
359
|
+
// package.json deps, and stubbing the encoder makes `buildQrSvg()` throw
|
|
360
|
+
// during SSR (500 on any page that awaits a QR). canvas/@zxing stay
|
|
361
|
+
// stubbed because they are optional and only back raster/scan validation,
|
|
362
|
+
// which degrades gracefully when the decoder is unavailable.
|
|
363
|
+
const qrStubPattern = nodeBuiltins
|
|
364
|
+
? /^(canvas|@zxing\/(browser|node))(\/|$)/
|
|
365
|
+
: /^(vesk-qr|qrcode-generator|canvas|@zxing\/(browser|node))(\/|$)/;
|
|
356
366
|
plugins.push({
|
|
357
|
-
name: 'stub-
|
|
367
|
+
name: 'stub-optional-qr-packages',
|
|
358
368
|
setup(build) {
|
|
359
|
-
build.onResolve({ filter:
|
|
369
|
+
build.onResolve({ filter: qrStubPattern }, (args) => ({ path: args.path, namespace: 'vesk-edge-stub' }));
|
|
360
370
|
build.onLoad({ filter: /.*/, namespace: 'vesk-edge-stub' }, () => ({
|
|
361
371
|
contents: [
|
|
362
372
|
'export const CofoundrMatrix = undefined;\n',
|
package/dist/server-only.d.ts
CHANGED
|
@@ -52,6 +52,15 @@
|
|
|
52
52
|
* `packages/adapter/AGENTS.md` for the three outcomes the plugin must
|
|
53
53
|
* distinguish.
|
|
54
54
|
*/
|
|
55
|
+
/**
|
|
56
|
+
* The TCP drivers that are real npm packages (not `node:` builtins). A Node
|
|
57
|
+
* serverless function bundles statically-imported code, but a driver loaded
|
|
58
|
+
* through a variable `import(spec)` (e.g. `slintorm`'s `importDriver("pg")`)
|
|
59
|
+
* cannot be traced by the bundler or the platform's dependency tracer. Node
|
|
60
|
+
* targets ship these package closures into the function's `node_modules` so
|
|
61
|
+
* that dynamic import resolves at runtime.
|
|
62
|
+
*/
|
|
63
|
+
export declare function tcpDriverPackages(): string[];
|
|
55
64
|
export type ServerOnlyKind = 'server-only-package' | 'tcp-driver';
|
|
56
65
|
/**
|
|
57
66
|
* Classify a bare import specifier. Returns null for anything that is fine on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-only.d.ts","sourceRoot":"","sources":["../src/server-only.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAsCH,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,YAAY,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAMrE;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAkB5F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,cAAc,GAAG,IAAwB,GAAG,MAAM,CAoBjI;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,2BAA2B;IAC3B,MAAM,EAAE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ages (not `node:` builtins). A Node
|
|
90
|
+
* serverless function bundles statically-imported code, but a driver loaded
|
|
91
|
+
* through a variable `import(spec)` (e.g. `slintorm`'s `importDriver("pg")`)
|
|
92
|
+
* cannot be traced by the bundler or the platform's dependency tracer. Node
|
|
93
|
+
* targets ship these package closures into the function's `node_modules` so
|
|
94
|
+
* that dynamic import resolves at runtime.
|
|
95
|
+
*/
|
|
96
|
+
export function tcpDriverPackages() {
|
|
97
|
+
return [...TCP_DRIVERS].filter((spec) => !spec.startsWith('node:'));
|
|
98
|
+
}
|
|
88
99
|
/**
|
|
89
100
|
* Classify a bare import specifier. Returns null for anything that is fine on
|
|
90
101
|
* the client — including a subpath of a listed package that is itself a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.94",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk adapter — builds deployable .vesk/ output for Deno and Node serverless",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"sharp": "^0.35.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vesk/compiler": "^0.2.
|
|
27
|
-
"@vesk/runtime": "^0.2.
|
|
28
|
-
"@vesk/types": "^0.2.
|
|
26
|
+
"@vesk/compiler": "^0.2.94",
|
|
27
|
+
"@vesk/runtime": "^0.2.94",
|
|
28
|
+
"@vesk/types": "^0.2.94"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|