@vesk/adapter 0.2.82 → 0.2.84
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/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/platform-handler.d.ts.map +1 -1
- package/dist/platform-handler.js +21 -9
- package/dist/ssr-function.d.ts +2 -1
- package/dist/ssr-function.d.ts.map +1 -1
- package/dist/ssr-function.js +15 -12
- package/package.json +4 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACe,YAAY,EAAE,WAAW,EAC7B,UAAU,EAChC,MAAM,yBAAyB,CAAC;AAoDjC;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,GAC9C,UAAU,EAAE,CAQd;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,EAAE,EACrB,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GACxC,UAAU,EAAE,CAGd;AAkDD,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAwYpG;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { bundleRuntime } from '@vesk/adapter/src/runtime-bundle';
|
|
|
5
5
|
import { generateSsrFunction } from '@vesk/adapter/src/ssr-function';
|
|
6
6
|
import { resolveUserCssPath, isTailwindPlugin, resolveCssUrls, hasBuiltGlobalCss } from '@vesk/adapter/src/css';
|
|
7
7
|
import { collectActionIds } from '@vesk/compiler/src/actions';
|
|
8
|
+
import { ModuleRegistry } from '@vesk/compiler/src/module-imports';
|
|
8
9
|
import { generateApiFunction } from '@vesk/adapter/src/api-function';
|
|
9
10
|
import { describeAsset } from '@vesk/adapter/src/asset-hash';
|
|
10
11
|
// The adapter's own package.json, for the version stamped into the manifest.
|
|
@@ -332,7 +333,7 @@ export async function build(appDir, options) {
|
|
|
332
333
|
// For standalone routes the layout chain is cleared — only the
|
|
333
334
|
// standalone node's own layout (if any) applies, no root ancestors.
|
|
334
335
|
const ssrAncestorLayouts = isStandalone ? [] : ancestorLayouts;
|
|
335
|
-
const { funcPath, funcCode, name } = generateSsrFunction(node, appDir, outDir, componentMap, { ancestorLayouts: ssrAncestorLayouts, middlewareCode: mwCode, headExtra: pluginHeadExtra, clientScriptUrl: clientUrl, clientScriptIntegrity: clientIntegrity });
|
|
336
|
+
const { funcPath, funcCode, name } = generateSsrFunction(node, appDir, outDir, componentMap, { ancestorLayouts: ssrAncestorLayouts, middlewareCode: mwCode, headExtra: pluginHeadExtra, clientScriptUrl: clientUrl, clientScriptIntegrity: clientIntegrity }, registry);
|
|
336
337
|
writeFileSync(funcPath, funcCode, 'utf-8');
|
|
337
338
|
const pagePath = resolve(appDir, node.sourceDir, 'page.vsk');
|
|
338
339
|
if (existsSync(pagePath)) {
|
|
@@ -364,7 +365,12 @@ export async function build(appDir, options) {
|
|
|
364
365
|
walk(node.children || [], childAncestorLayouts);
|
|
365
366
|
}
|
|
366
367
|
}
|
|
368
|
+
const registry = new ModuleRegistry();
|
|
367
369
|
walk(routeTree);
|
|
370
|
+
// Every SSR function imports this shared registry: module source code is
|
|
371
|
+
// stored here ONCE instead of being re-embedded in every function plan,
|
|
372
|
+
// which keeps the cold-start bundle small enough to initialize.
|
|
373
|
+
writeFileSync(resolve(outDir, 'server', '__vesk-modules.mjs'), registry.toModuleSource(), 'utf-8');
|
|
368
374
|
markPhase('server runtime + ssr functions');
|
|
369
375
|
const apiRoutes = [];
|
|
370
376
|
function walkApi(nodes) {
|
|
@@ -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,CA8MjF;AAED,MAA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AAE,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
|
@@ -319,15 +319,27 @@ export const createHash = () => ({ update: () => {}, digest: () => '' });
|
|
|
319
319
|
outfile,
|
|
320
320
|
minify: false,
|
|
321
321
|
sourcemap: false,
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
|
|
322
|
+
// Edge targets have no node_modules so every package is bundled. Node
|
|
323
|
+
// targets bundle everything too — self-contained functions avoid the
|
|
324
|
+
// "Cannot find package" failures that externalization causes on hosts that
|
|
325
|
+
// don't install dependencies for Build Output API functions.
|
|
326
|
+
// Bundled CJS modules (e.g. pg's internals via slintorm) call
|
|
327
|
+
// require('events') etc. esbuild rewrites those into its `__require`
|
|
328
|
+
// shim, which throws 'Dynamic require of "events" is not supported' in
|
|
329
|
+
// ESM output. Define a real `require` anchored at the bundle URL before
|
|
330
|
+
// the shim initializes so Node loads builtins and node_modules for real.
|
|
331
|
+
// `node:module` stays external (platform: 'node'), so Node resolves it
|
|
332
|
+
// natively at runtime. Edge targets keep the empty-node builtin stubs and
|
|
333
|
+
// must not get this banner (it would collide with their stubbed
|
|
334
|
+
// `createRequire`).
|
|
335
|
+
...(nodeBuiltins
|
|
336
|
+
? {
|
|
337
|
+
banner: {
|
|
338
|
+
js: 'import { createRequire } from "node:module";\n' +
|
|
339
|
+
'const require = createRequire(import.meta.url);\n',
|
|
340
|
+
},
|
|
341
|
+
}
|
|
342
|
+
: {}),
|
|
331
343
|
logOverride: { 'direct-eval': 'silent' },
|
|
332
344
|
plugins,
|
|
333
345
|
});
|
package/dist/ssr-function.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ModuleRegistry } from '@vesk/compiler/src/module-imports';
|
|
1
2
|
import type { RouteNode, SsrFunctionOptions } from '@vesk/adapter/src/types';
|
|
2
3
|
/**
|
|
3
4
|
* The nearest `<file>` walking up from a route's own directory to the app root.
|
|
@@ -25,7 +26,7 @@ export declare function resolveBoundaryFileForUrl(pathname: string, appDir: stri
|
|
|
25
26
|
* in sync by calling this). Emit it AFTER the function declarations so the
|
|
26
27
|
* module-level `installPersistedStoreServerHooks` call runs on import. */
|
|
27
28
|
export declare function persistedStoreSsrCode(): string;
|
|
28
|
-
export declare function generateSsrFunction(routeNode: RouteNode, appDir: string, outDir: string, componentMap?: Map<string, string>, options?: SsrFunctionOptions): {
|
|
29
|
+
export declare function generateSsrFunction(routeNode: RouteNode, appDir: string, outDir: string, componentMap?: Map<string, string>, options?: SsrFunctionOptions, registry?: ModuleRegistry): {
|
|
29
30
|
funcPath: string;
|
|
30
31
|
funcCode: string;
|
|
31
32
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-function.d.ts","sourceRoot":"","sources":["../src/ssr-function.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAkB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7F;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQlG;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEpF;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,M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,QAAQ,CAAC,EAAE,cAAc,GACxB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuftD"}
|
package/dist/ssr-function.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolve, relative, join } from 'node:path';
|
|
|
3
3
|
import { resolveComponentName, precompileFile } from '@vesk/compiler/src/server-codegen';
|
|
4
4
|
import { resolveCssUrls, hasBuiltGlobalCss } from '@vesk/adapter/src/css';
|
|
5
5
|
import { renderDefaultErrorFragment } from '@vesk/adapter/src/default-pages';
|
|
6
|
+
import { ModuleRegistry } from '@vesk/compiler/src/module-imports';
|
|
6
7
|
/**
|
|
7
8
|
* The nearest `<file>` walking up from a route's own directory to the app root.
|
|
8
9
|
*
|
|
@@ -63,12 +64,12 @@ function extractCompName(src) {
|
|
|
63
64
|
* compile happens in the deployed function — `hydratePrecompile` rebuilds the
|
|
64
65
|
* render result at module load from this JSON alone.
|
|
65
66
|
*/
|
|
66
|
-
function precompilePlan(entryPath) {
|
|
67
|
+
function precompilePlan(entryPath, registry) {
|
|
67
68
|
const src = readFileSync(entryPath, 'utf-8');
|
|
68
|
-
return JSON.stringify(precompileFile(src, entryPath));
|
|
69
|
+
return JSON.stringify(precompileFile(src, entryPath, registry));
|
|
69
70
|
}
|
|
70
71
|
function hydrateInvoke(planExpr) {
|
|
71
|
-
return `(() => { try { return hydratePrecompile(${planExpr}); } catch { return null; } })()`;
|
|
72
|
+
return `(() => { try { return hydratePrecompile(${planExpr}, __veskModules); } catch { return null; } })()`;
|
|
72
73
|
}
|
|
73
74
|
function buildParamExtraction(node, urlParts) {
|
|
74
75
|
const parts = [];
|
|
@@ -158,7 +159,8 @@ export function persistedStoreSsrCode() {
|
|
|
158
159
|
'',
|
|
159
160
|
].join('\n');
|
|
160
161
|
}
|
|
161
|
-
export function generateSsrFunction(routeNode, appDir, outDir, componentMap, options) {
|
|
162
|
+
export function generateSsrFunction(routeNode, appDir, outDir, componentMap, options, registry) {
|
|
163
|
+
const reg = registry ?? new ModuleRegistry();
|
|
162
164
|
const ancestorLayouts = options?.ancestorLayouts || [];
|
|
163
165
|
const middlewareCode = options?.middlewareCode || null;
|
|
164
166
|
const headExtra = options?.headExtra || null;
|
|
@@ -184,20 +186,20 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
184
186
|
const entryPath = resolve(appDir, entry.sourceDir, 'layout.vsk');
|
|
185
187
|
const entrySrc = readFileSync(entryPath, 'utf-8');
|
|
186
188
|
const entryComp = extractCompName(entrySrc) || 'Layout';
|
|
187
|
-
const plan = precompilePlan(entryPath);
|
|
189
|
+
const plan = precompilePlan(entryPath, reg);
|
|
188
190
|
layoutDecls.push({
|
|
189
191
|
comp: JSON.stringify(entryComp),
|
|
190
192
|
plan,
|
|
191
193
|
compiled: hydrateInvoke(plan),
|
|
192
194
|
});
|
|
193
195
|
}
|
|
194
|
-
const pagePlan = precompilePlan(pagePath);
|
|
196
|
+
const pagePlan = precompilePlan(pagePath, reg);
|
|
195
197
|
const pageComp = extractCompName(readFileSync(pagePath, 'utf-8')) || 'Page';
|
|
196
198
|
const errorPath = resolveErrorFile(routeNode.sourceDir, appDir);
|
|
197
199
|
const errorSrc = errorPath ? readFileSync(errorPath, 'utf-8') : null;
|
|
198
200
|
const errorComp = errorPath ? (extractCompName(errorSrc) || 'Error') : null;
|
|
199
201
|
const errorCompDecl = errorPath ? `const _errorComp = ${JSON.stringify(errorComp)};\n` : 'const _errorComp = null;\n';
|
|
200
|
-
const errorPlanExpr = errorPath ? hydrateInvoke(precompilePlan(errorPath)) : 'null';
|
|
202
|
+
const errorPlanExpr = errorPath ? hydrateInvoke(precompilePlan(errorPath, reg)) : 'null';
|
|
201
203
|
// Not-found used to have no server-side resolution at all: a NotFoundError was
|
|
202
204
|
// re-thrown out of the function and the prod server answered with the ROOT
|
|
203
205
|
// not-found.vsk. A nested `app/admin/not-found.vsk` therefore did nothing on a
|
|
@@ -208,12 +210,12 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
208
210
|
const notFoundSrc = notFoundPath ? readFileSync(notFoundPath, 'utf-8') : null;
|
|
209
211
|
const notFoundComp = notFoundPath ? (extractCompName(notFoundSrc) || 'NotFound') : null;
|
|
210
212
|
const notFoundCompDecl = notFoundPath ? `const _notFoundComp = ${JSON.stringify(notFoundComp)};\n` : 'const _notFoundComp = null;\n';
|
|
211
|
-
const notFoundPlanExpr = notFoundPath ? hydrateInvoke(precompilePlan(notFoundPath)) : 'null';
|
|
213
|
+
const notFoundPlanExpr = notFoundPath ? hydrateInvoke(precompilePlan(notFoundPath, reg)) : 'null';
|
|
212
214
|
let src = '';
|
|
213
215
|
if (layoutDecls.length > 0) {
|
|
214
216
|
src = errorCompDecl + notFoundCompDecl;
|
|
215
217
|
src += `const _pageComp = ${JSON.stringify(pageComp)};\n`;
|
|
216
|
-
src += `let _pageCompiled = null;\nfunction __getPageCompiled() { if (!_pageCompiled) _pageCompiled = (() => { try { return hydratePrecompile(${pagePlan}); } catch { return null; } })(); return _pageCompiled; }\n`;
|
|
218
|
+
src += `let _pageCompiled = null;\nfunction __getPageCompiled() { if (!_pageCompiled) _pageCompiled = (() => { try { return hydratePrecompile(${pagePlan}, __veskModules); } catch { return null; } })(); return _pageCompiled; }\n`;
|
|
217
219
|
src += `const _layoutCompList = [${layoutDecls.map((d) => d.comp).join(', ')}];\n`;
|
|
218
220
|
src += `let _layoutCompiledList = null;\nfunction __getLayoutCompiledList() { if (!_layoutCompiledList) { _layoutCompiledList = [\n${layoutDecls.map((d) => ' ' + d.compiled + ',').join('\n')}\n]; } return _layoutCompiledList; }\n`;
|
|
219
221
|
src += `let _errorCompiled = null;\nfunction __getErrorCompiled() { if (!_errorCompiled) _errorCompiled = ${errorPlanExpr}; return _errorCompiled; }\n`;
|
|
@@ -222,7 +224,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
222
224
|
else {
|
|
223
225
|
src = errorCompDecl + notFoundCompDecl;
|
|
224
226
|
src += `const _comp = ${JSON.stringify(pageComp)};\n`;
|
|
225
|
-
src += `let _compiled = null;\nfunction __getCompiled() { if (!_compiled) _compiled = (() => { try { return hydratePrecompile(${pagePlan}); } catch { return null; } })(); return _compiled; }\n`;
|
|
227
|
+
src += `let _compiled = null;\nfunction __getCompiled() { if (!_compiled) _compiled = (() => { try { return hydratePrecompile(${pagePlan}, __veskModules); } catch { return null; } })(); return _compiled; }\n`;
|
|
226
228
|
src += `let _errorCompiled = null;\nfunction __getErrorCompiled() { if (!_errorCompiled) _errorCompiled = ${errorPlanExpr}; return _errorCompiled; }\n`;
|
|
227
229
|
src += `let _notFoundCompiled = null;\nfunction __getNotFoundCompiled() { if (!_notFoundCompiled) _notFoundCompiled = ${notFoundPlanExpr}; return _notFoundCompiled; }\n`;
|
|
228
230
|
}
|
|
@@ -239,9 +241,9 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
239
241
|
const compMap = componentMap || new Map();
|
|
240
242
|
const regPlans = [];
|
|
241
243
|
for (const [compName, compPath] of compMap) {
|
|
242
|
-
const plan = precompilePlan(compPath);
|
|
244
|
+
const plan = precompilePlan(compPath, reg);
|
|
243
245
|
regPlans.push(` __regPlans.set(${JSON.stringify(compName)}, ${JSON.stringify(plan)});`);
|
|
244
|
-
compRegEntries.push(` __componentRegistry.set(${JSON.stringify(compName)}, async (props, __registry, __vesk) => {\n let _compiled = __regCompiled.get(${JSON.stringify(compName)});\n if (!_compiled) { _compiled = hydratePrecompile(__regPlans.get(${JSON.stringify(compName)})); __regCompiled.set(${JSON.stringify(compName)}, _compiled); }\n const result = await renderPage('', ${JSON.stringify(compName)}, props, __registry, { hydrate: true, cached: _compiled });\n return result.body;\n });`);
|
|
246
|
+
compRegEntries.push(` __componentRegistry.set(${JSON.stringify(compName)}, async (props, __registry, __vesk) => {\n let _compiled = __regCompiled.get(${JSON.stringify(compName)});\n if (!_compiled) { _compiled = hydratePrecompile(__regPlans.get(${JSON.stringify(compName)}), __veskModules); __regCompiled.set(${JSON.stringify(compName)}, _compiled); }\n const result = await renderPage('', ${JSON.stringify(compName)}, props, __registry, { hydrate: true, cached: _compiled });\n return result.body;\n });`);
|
|
245
247
|
}
|
|
246
248
|
if (compRegEntries.length > 0) {
|
|
247
249
|
registryCode = 'const __componentRegistry = new Map();\nconst __regPlans = new Map();\nconst __regCompiled = new Map();\n{\n' + regPlans.join('\n') + '\n' + compRegEntries.join('\n') + '\n}\n';
|
|
@@ -616,6 +618,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
616
618
|
'',
|
|
617
619
|
].join('\n');
|
|
618
620
|
const funcCode = [
|
|
621
|
+
"import { __veskModules } from '../__vesk-modules.mjs';",
|
|
619
622
|
"import { renderFullPage, renderPageStream, renderPage, hydratePrecompile, parseCookies, getAction, validateActionInput, issuesToFieldMap, storeDataScriptGlobal, withSsrStore, assertSameOrigin, VeskRequest, installPersistedStoreServerHooks, persistedStoreCookieName, getPersistedStoreKeys, resetPersistedStoreKeys, buildStorePrePaintPayload, storeInitScriptGlobal, storeInitScriptTag } from '../runtime.js';",
|
|
620
623
|
'',
|
|
621
624
|
middlewareCode || '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.84",
|
|
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.84",
|
|
27
|
+
"@vesk/runtime": "^0.2.84",
|
|
28
|
+
"@vesk/types": "^0.2.84"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|