@vesk/adapter 0.2.28 → 0.2.29
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 +85 -0
- package/dist/client-bundle.d.ts.map +1 -1
- package/dist/client-bundle.js +73 -10
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +50 -25
- package/package.json +4 -4
package/dist/client-bundle.d.ts
CHANGED
|
@@ -14,6 +14,78 @@ import type { RouteNode, ClientBundleOptions, ClientBundleResult } from '@vesk/a
|
|
|
14
14
|
* than guess.
|
|
15
15
|
*/
|
|
16
16
|
export declare function extractRuntimeImportNames(code: string): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Minimal structural view of a compiled client module's top-level statements.
|
|
19
|
+
* Everything here is read from the compiler's AST — no text scanning — so
|
|
20
|
+
* import-shaped doc samples inside template literals are never treated as real
|
|
21
|
+
* statements (see `removeCompiledNodes`).
|
|
22
|
+
*/
|
|
23
|
+
interface CompiledNode {
|
|
24
|
+
type?: string;
|
|
25
|
+
importKind?: string;
|
|
26
|
+
source?: {
|
|
27
|
+
value?: unknown;
|
|
28
|
+
};
|
|
29
|
+
id?: {
|
|
30
|
+
name?: string;
|
|
31
|
+
};
|
|
32
|
+
declarations?: Array<{
|
|
33
|
+
id?: {
|
|
34
|
+
name?: string;
|
|
35
|
+
};
|
|
36
|
+
init?: {
|
|
37
|
+
type?: string;
|
|
38
|
+
object?: {
|
|
39
|
+
type?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
declaration?: {
|
|
45
|
+
type?: string;
|
|
46
|
+
object?: {
|
|
47
|
+
type?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
};
|
|
50
|
+
declarations?: Array<{
|
|
51
|
+
init?: {
|
|
52
|
+
type?: string;
|
|
53
|
+
object?: {
|
|
54
|
+
type?: string;
|
|
55
|
+
name?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
start?: number;
|
|
61
|
+
end?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Top-level statements an HMR eval snippet must never carry: imports,
|
|
65
|
+
* re-exports and the registry preamble (`const __components = …`,
|
|
66
|
+
* `const __hydrators = …`) plus the `__cleanup` / `__place` helpers. The
|
|
67
|
+
* eval runs against a live chunk scope where those already exist.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isSnippetDrop(node: CompiledNode): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Demotes surviving value exports to plain declarations (`export const x`
|
|
72
|
+
* becomes `const x`) and drops bare re-export lists (`export { x }`,
|
|
73
|
+
* `export default …`). Code-split chunks execute as classic scripts inside
|
|
74
|
+
* an IIFE, so any `export` statement is a SyntaxError — and the chunk-local
|
|
75
|
+
* binding is all cross-file references need (components resolve through the
|
|
76
|
+
* `__components` / `__hydrators` registries). Offset-based on the parser AST.
|
|
77
|
+
*/
|
|
78
|
+
export declare function demoteExports(code: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Single-parse composition of `demoteExports(removeCompiledNodes(code,
|
|
81
|
+
* isSnippetDrop))`: drop matches and demote surviving exports in ONE acorn
|
|
82
|
+
* pass over the original offsets. The two operations never overlap (dropped
|
|
83
|
+
* statements are imports/preamble/component-re-exports; demoted ones are
|
|
84
|
+
* other export declarations), so composing their edits yields byte-identical
|
|
85
|
+
* output — at roughly half the parse cost of the two-pass chain the HMR
|
|
86
|
+
* hot path used to run on every edit.
|
|
87
|
+
*/
|
|
88
|
+
export declare function stripAndDemoteInOnePass(code: string): string;
|
|
17
89
|
/**
|
|
18
90
|
* Builds the eval-safe HMR update snippet for one compiled file: drops
|
|
19
91
|
* imports, re-exports and the registry preamble (`const __components = …`,
|
|
@@ -26,8 +98,20 @@ export declare function extractRuntimeImportNames(code: string): string[];
|
|
|
26
98
|
* scope, an updated component renders against missing bindings and the
|
|
27
99
|
* swap fails with a ReferenceError that surfaces nowhere the tests assert
|
|
28
100
|
* (no reload, stale DOM, zero page errors).
|
|
101
|
+
*
|
|
102
|
+
* Single-parse strip+demote (see `stripAndDemoteInOnePass`) — this sits on
|
|
103
|
+
* the dev-server's per-edit hot path, where the old two-pass chain cost a
|
|
104
|
+
* second full acorn parse on every file save.
|
|
29
105
|
*/
|
|
30
106
|
export declare function buildHmrEvalSnippet(code: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Removes matched top-level statements from a compiled client module using the
|
|
109
|
+
* parser's exact `start`/`end` offsets — never a text scan, so a doc sample
|
|
110
|
+
* stored inside a template literal can never be mistaken for a real statement.
|
|
111
|
+
* If the module cannot be parsed it is returned untouched (the compiler's own
|
|
112
|
+
* output is always valid ESM, so that branch is unreachable in practice).
|
|
113
|
+
*/
|
|
114
|
+
export declare function removeCompiledNodes(code: string, isTarget: (node: CompiledNode) => boolean): string;
|
|
31
115
|
export declare function generateClientBundle(routeTree: RouteNode[], appDir: string, componentMap?: Map<string, string>, options?: ClientBundleOptions): Promise<ClientBundleResult>;
|
|
32
116
|
export declare function buildRuntimeCode(runtimeDir: string): string;
|
|
33
117
|
/**
|
|
@@ -45,4 +129,5 @@ export declare function runtimeExportNames(runtimeDir: string): Set<string>;
|
|
|
45
129
|
* leaked runtime module-scope names into the page scope.
|
|
46
130
|
*/
|
|
47
131
|
export declare function buildTreeShakenRuntime(runtimeDir: string, usedNames: string[]): Promise<string>;
|
|
132
|
+
export {};
|
|
48
133
|
//# sourceMappingURL=client-bundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-bundle.d.ts","sourceRoot":"","sources":["../src/client-bundle.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAmF,MAAM,yBAAyB,CAAC;AAoCnL;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,G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
+
/**
|
|
132
|
+
* Top-level statements an HMR eval snippet must never carry: imports,
|
|
133
|
+
* re-exports and the registry preamble (`const __components = …`,
|
|
134
|
+
* `const __hydrators = …`) plus the `__cleanup` / `__place` helpers. The
|
|
135
|
+
* eval runs against a live chunk scope where those already exist.
|
|
136
|
+
*/
|
|
137
|
+
export function isSnippetDrop(node) {
|
|
138
|
+
if (isAnyImport(node) || isComponentExport(node) || isRuntimePreamble(node))
|
|
139
|
+
return true;
|
|
140
|
+
return node.type === 'VariableDeclaration'
|
|
141
|
+
&& (node.declarations?.[0]?.id?.name === '__components'
|
|
142
|
+
|| node.declarations?.[0]?.id?.name === '__hydrators');
|
|
143
|
+
}
|
|
131
144
|
/**
|
|
132
145
|
* Extracts matched top-level statements from a compiled client module using
|
|
133
146
|
* the parser's exact `start`/`end` offsets — the complement of
|
|
@@ -168,7 +181,7 @@ function isModuleLevel(node) {
|
|
|
168
181
|
* binding is all cross-file references need (components resolve through the
|
|
169
182
|
* `__components` / `__hydrators` registries). Offset-based on the parser AST.
|
|
170
183
|
*/
|
|
171
|
-
function demoteExports(code) {
|
|
184
|
+
export function demoteExports(code) {
|
|
172
185
|
let ast;
|
|
173
186
|
try {
|
|
174
187
|
ast = parse(code);
|
|
@@ -411,6 +424,59 @@ function scopeFileContribution(code) {
|
|
|
411
424
|
return code;
|
|
412
425
|
}
|
|
413
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* Single-parse composition of `demoteExports(removeCompiledNodes(code,
|
|
429
|
+
* isSnippetDrop))`: drop matches and demote surviving exports in ONE acorn
|
|
430
|
+
* pass over the original offsets. The two operations never overlap (dropped
|
|
431
|
+
* statements are imports/preamble/component-re-exports; demoted ones are
|
|
432
|
+
* other export declarations), so composing their edits yields byte-identical
|
|
433
|
+
* output — at roughly half the parse cost of the two-pass chain the HMR
|
|
434
|
+
* hot path used to run on every edit.
|
|
435
|
+
*/
|
|
436
|
+
export function stripAndDemoteInOnePass(code) {
|
|
437
|
+
let ast;
|
|
438
|
+
try {
|
|
439
|
+
ast = parse(code);
|
|
440
|
+
}
|
|
441
|
+
catch {
|
|
442
|
+
return code;
|
|
443
|
+
}
|
|
444
|
+
const body = ast.body ?? [];
|
|
445
|
+
const edits = [];
|
|
446
|
+
for (const raw of body) {
|
|
447
|
+
const node = raw;
|
|
448
|
+
if (typeof node.start !== 'number' || typeof node.end !== 'number')
|
|
449
|
+
continue;
|
|
450
|
+
const isExport = node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration';
|
|
451
|
+
if (isSnippetDrop(node)) {
|
|
452
|
+
let cut = node.end;
|
|
453
|
+
if (code[cut] === ';')
|
|
454
|
+
cut++;
|
|
455
|
+
if (code.startsWith('\r\n', cut))
|
|
456
|
+
cut += 2;
|
|
457
|
+
else if (code[cut] === '\n' || code[cut] === '\r')
|
|
458
|
+
cut++;
|
|
459
|
+
edits.push({ start: node.start, end: cut });
|
|
460
|
+
}
|
|
461
|
+
else if (isExport && node.type === 'ExportNamedDeclaration' && node.declaration
|
|
462
|
+
&& typeof node.declaration.start === 'number' && typeof node.declaration.end === 'number') {
|
|
463
|
+
edits.push({ start: node.start, end: node.end, text: code.slice(node.declaration.start, node.declaration.end) });
|
|
464
|
+
}
|
|
465
|
+
else if (isExport) {
|
|
466
|
+
let cut = node.end;
|
|
467
|
+
if (code[cut] === ';')
|
|
468
|
+
cut++;
|
|
469
|
+
edits.push({ start: node.start, end: cut });
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (edits.length === 0)
|
|
473
|
+
return code;
|
|
474
|
+
edits.sort((a, b) => b.start - a.start);
|
|
475
|
+
for (const e of edits) {
|
|
476
|
+
code = code.slice(0, e.start) + (e.text ?? '') + code.slice(e.end);
|
|
477
|
+
}
|
|
478
|
+
return code;
|
|
479
|
+
}
|
|
414
480
|
/**
|
|
415
481
|
* Builds the eval-safe HMR update snippet for one compiled file: drops
|
|
416
482
|
* imports, re-exports and the registry preamble (`const __components = …`,
|
|
@@ -423,16 +489,13 @@ function scopeFileContribution(code) {
|
|
|
423
489
|
* scope, an updated component renders against missing bindings and the
|
|
424
490
|
* swap fails with a ReferenceError that surfaces nowhere the tests assert
|
|
425
491
|
* (no reload, stale DOM, zero page errors).
|
|
492
|
+
*
|
|
493
|
+
* Single-parse strip+demote (see `stripAndDemoteInOnePass`) — this sits on
|
|
494
|
+
* the dev-server's per-edit hot path, where the old two-pass chain cost a
|
|
495
|
+
* second full acorn parse on every file save.
|
|
426
496
|
*/
|
|
427
497
|
export function buildHmrEvalSnippet(code) {
|
|
428
|
-
const
|
|
429
|
-
if (isAnyImport(node) || isComponentExport(node) || isRuntimePreamble(node))
|
|
430
|
-
return true;
|
|
431
|
-
return node.type === 'VariableDeclaration'
|
|
432
|
-
&& (node.declarations?.[0]?.id?.name === '__components'
|
|
433
|
-
|| node.declarations?.[0]?.id?.name === '__hydrators');
|
|
434
|
-
};
|
|
435
|
-
const body = demoteExports(removeCompiledNodes(code, isSnippetDrop)).trim();
|
|
498
|
+
const body = stripAndDemoteInOnePass(code).trim();
|
|
436
499
|
if (!body)
|
|
437
500
|
return '';
|
|
438
501
|
const scoped = `{\n${body}\n}`;
|
|
@@ -453,7 +516,7 @@ export function buildHmrEvalSnippet(code) {
|
|
|
453
516
|
* If the module cannot be parsed it is returned untouched (the compiler's own
|
|
454
517
|
* output is always valid ESM, so that branch is unreachable in practice).
|
|
455
518
|
*/
|
|
456
|
-
function removeCompiledNodes(code, isTarget) {
|
|
519
|
+
export function removeCompiledNodes(code, isTarget) {
|
|
457
520
|
let ast;
|
|
458
521
|
try {
|
|
459
522
|
ast = parse(code);
|
package/dist/dev-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAA6C,MAAM,WAAW,CAAC;AAOjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAA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,IAAI,MAAM,CAa3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AA8CD,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoqBvG"}
|
package/dist/dev-server.js
CHANGED
|
@@ -440,6 +440,12 @@ export async function startDevServer(appDir, options) {
|
|
|
440
440
|
await doBuild().catch(() => { });
|
|
441
441
|
const server = createServer(async (req, res) => {
|
|
442
442
|
const url = new URL(req.url || '/', `http://localhost:${port}`);
|
|
443
|
+
// SSR fetches may run while concurrent sub-requests (e.g. the page's own
|
|
444
|
+
// API fetches) have clobbered globalThis.__vesk_request with their own
|
|
445
|
+
// request context, so resolveFetchUrl cannot rely on ctx.resolveUrl alone.
|
|
446
|
+
// Set the per-request base so relative useFetch URLs resolve to this
|
|
447
|
+
// server regardless (mirrors packages/cli/src/dev-server.ts:1308).
|
|
448
|
+
globalThis.__vesk_ssr_base_url = `http://127.0.0.1:${port}`;
|
|
443
449
|
// Dev panel endpoints (/__vesk/...): HMR state, plugin list, activate/
|
|
444
450
|
// deactivate/install/uninstall. Routed through the pure injectable router.
|
|
445
451
|
// Chain: agent router (CheckpointManager + AgentCapabilityTable + Provider
|
|
@@ -673,6 +679,8 @@ export async function startDevServer(appDir, options) {
|
|
|
673
679
|
const t0 = process.hrtime.bigint();
|
|
674
680
|
const tImport0 = process.hrtime.bigint();
|
|
675
681
|
const mod = await import(`${handlerPath}?t=${ssrVersion}`);
|
|
682
|
+
const _origFetch = globalThis.fetch;
|
|
683
|
+
globalThis.fetch = function _fetchDebug(u, init) { console.error('FETCH-DEBUG', typeof u === 'string' ? u : String(u), (new Error()).stack); return _origFetch(u, init); };
|
|
676
684
|
const tImport1 = process.hrtime.bigint();
|
|
677
685
|
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
678
686
|
const response = await mod.handle(webRequest);
|
|
@@ -690,6 +698,7 @@ export async function startDevServer(appDir, options) {
|
|
|
690
698
|
console.error(`[vdtime] ${url.pathname} ssrVersion=${ssrVersion} total=${Number(tHandle1 - t0) / 1e6 | 0}ms import=${Number(tImport1 - tImport0) / 1e6 | 0}ms handle=${Number(tHandle1 - tImport1) / 1e6 | 0}ms text=${Number(tText1 - tHandle1) / 1e6 | 0}ms`);
|
|
691
699
|
}
|
|
692
700
|
catch (e) {
|
|
701
|
+
console.error('[nbsp-debug] DEV-SSR-ERROR', e instanceof Error ? (e.stack || e.message) : String(e));
|
|
693
702
|
res.writeHead(500, { 'Content-Type': 'text/html' });
|
|
694
703
|
res.end(renderSsrErrorPage(e, url.pathname));
|
|
695
704
|
}
|
|
@@ -768,56 +777,72 @@ export async function startDevServer(appDir, options) {
|
|
|
768
777
|
}
|
|
769
778
|
}
|
|
770
779
|
}
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
780
|
+
const projectDir = resolve(appDir, '..');
|
|
781
|
+
// The legacy adapter dev server watches the whole project (not just app/):
|
|
782
|
+
// every `.vsk`/`.md`, `.css`, config and `.ts`/`.js` file anywhere in the
|
|
783
|
+
// project is covered by HMR — only node_modules, build outputs and VCS
|
|
784
|
+
// internals are excluded. `handleFileChange` reboots or reloads per kind;
|
|
785
|
+
// anything else (non-API helpers, root scripts) falls through to a full
|
|
786
|
+
// rebuild + reload.
|
|
787
|
+
const adapterSkipDirs = new Set(['node_modules', '.vesk', 'tarballs', '.git']);
|
|
788
|
+
const adapterSkipMarkers = ['node_modules/', '.vesk/', 'tmp-vesk-chunk-'];
|
|
789
|
+
const adapterScriptExts = ['.mts', '.ts', '.tsx', '.mjs', '.js', '.cjs'];
|
|
790
|
+
const adapterConfigNames = new Set([
|
|
791
|
+
'vesk.config.ts', 'vesk.config.js', 'vesk.config.mjs', 'vesk.config.mts',
|
|
792
|
+
'postcss.config.js', 'postcss.config.ts', 'tailwind.config.js', 'tailwind.config.ts',
|
|
793
|
+
'tsconfig.json', 'package.json',
|
|
794
|
+
]);
|
|
786
795
|
let debounceTimer = null;
|
|
787
796
|
let pendingFiles = new Set();
|
|
788
797
|
try {
|
|
789
|
-
watch(
|
|
798
|
+
watch(projectDir, { recursive: true }, (_eventType, filename) => {
|
|
790
799
|
if (!filename)
|
|
791
800
|
return;
|
|
801
|
+
if (adapterSkipDirs.has(filename.split('/')[0]) || adapterSkipMarkers.some((m) => filename.includes(m)))
|
|
802
|
+
return;
|
|
803
|
+
const name = filename.slice(filename.lastIndexOf('/') + 1);
|
|
804
|
+
const isVsk = filename.endsWith('.vsk') || filename.endsWith('.md') || filename.endsWith('.markdown');
|
|
805
|
+
const isCss = filename.endsWith('.css');
|
|
806
|
+
const isScript = adapterScriptExts.some((ext) => filename.endsWith(ext));
|
|
807
|
+
if (!isVsk && !isCss && !isScript && !adapterConfigNames.has(name))
|
|
808
|
+
return;
|
|
809
|
+
if (isCss) {
|
|
810
|
+
doBuild();
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
792
813
|
if (debounceTimer)
|
|
793
814
|
clearTimeout(debounceTimer);
|
|
794
815
|
pendingFiles.add(filename);
|
|
795
816
|
debounceTimer = setTimeout(() => {
|
|
796
817
|
const files = [...pendingFiles];
|
|
797
818
|
pendingFiles = new Set();
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
819
|
+
if (files.length === 0)
|
|
820
|
+
return;
|
|
821
|
+
// Watch root is the project dir (projectDir = app/..) so fs.watch
|
|
822
|
+
// filenames are project-relative (e.g. `app/page.vsk`), but
|
|
823
|
+
// `handleFileChange` resolves them against `appDir` and `extractSourceDir`
|
|
824
|
+
// expects app-relative names — normalize before handing off.
|
|
825
|
+
const toAppRelative = (f) => f.startsWith('app/') ? f.slice(4) : f;
|
|
826
|
+
const configFiles = files.filter(f => adapterConfigNames.has(f.slice(f.lastIndexOf('/') + 1)));
|
|
802
827
|
const apiMiddlewareFiles = files.filter(f => (f.includes('/api/') || f === 'middleware.ts' || f.endsWith('/middleware.ts')) &&
|
|
803
|
-
|
|
828
|
+
adapterScriptExts.some(ext => f.endsWith(ext)));
|
|
804
829
|
const vskFiles = files.filter(f => f.endsWith('.vsk'));
|
|
805
830
|
if (configFiles.length > 0) {
|
|
806
|
-
hmr.handleFileChange(configFiles[0], doBuild, routeTree);
|
|
831
|
+
hmr.handleFileChange(toAppRelative(configFiles[0]), doBuild, routeTree);
|
|
807
832
|
}
|
|
808
833
|
else if (apiMiddlewareFiles.length > 0) {
|
|
809
|
-
hmr.handleFileChange(apiMiddlewareFiles[0], doBuild, routeTree);
|
|
834
|
+
hmr.handleFileChange(toAppRelative(apiMiddlewareFiles[0]), doBuild, routeTree);
|
|
810
835
|
}
|
|
811
836
|
else if (vskFiles.length > 0) {
|
|
812
837
|
(async () => {
|
|
813
838
|
for (const f of vskFiles) {
|
|
814
|
-
await hmr.handleFileChange(f, doBuild, routeTree);
|
|
839
|
+
await hmr.handleFileChange(toAppRelative(f), doBuild, routeTree);
|
|
815
840
|
}
|
|
816
841
|
ssrVersion = Date.now();
|
|
817
842
|
})();
|
|
818
843
|
}
|
|
819
844
|
else if (files.length > 0) {
|
|
820
|
-
hmr.handleFileChange(files[0], doBuild, routeTree);
|
|
845
|
+
hmr.handleFileChange(toAppRelative(files[0]), doBuild, routeTree);
|
|
821
846
|
}
|
|
822
847
|
}, 40);
|
|
823
848
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
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.29",
|
|
27
|
+
"@vesk/runtime": "^0.2.29",
|
|
28
|
+
"@vesk/types": "^0.2.29"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|