@vesk/adapter 0.2.74 → 0.2.77
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.
|
@@ -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;IACtH,WAAW,CAAC,EAAE;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1C,YAAY,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,CAAC,EAAE;gBAAE,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,M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
|
package/dist/client-bundle.js
CHANGED
|
@@ -1410,7 +1410,10 @@ export async function generateClientBundle(routeTree, appDir, componentMap, opti
|
|
|
1410
1410
|
// Concurrency is capped below the core count: esbuild's own service is
|
|
1411
1411
|
// already multi-process, so oversubscribing every chunk at once trades
|
|
1412
1412
|
// throughput for memory on the constrained machines this runs on.
|
|
1413
|
-
const
|
|
1413
|
+
const envConcurrency = process.env.VESK_CHUNK_CONCURRENCY ? Number(process.env.VESK_CHUNK_CONCURRENCY) : NaN;
|
|
1414
|
+
const CHUNK_CONCURRENCY = Number.isFinite(envConcurrency) && envConcurrency >= 1
|
|
1415
|
+
? Math.floor(envConcurrency)
|
|
1416
|
+
: Math.max(1, Math.min(6, (availableParallelism?.() ?? 4) - 1));
|
|
1414
1417
|
const built = await mapWithConcurrency(effectiveChunkEntries, CHUNK_CONCURRENCY, buildChunkEntry);
|
|
1415
1418
|
for (const c of built) {
|
|
1416
1419
|
if (c !== null)
|
|
@@ -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,MAAM,GA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AM,CAAC,EAClC,OAAO,CAAC,EAAE,kBAAkB,GAC3B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA+hBtD"}
|
package/dist/ssr-function.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, existsSync } from 'node:fs';
|
|
1
|
+
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
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';
|
|
@@ -163,6 +163,39 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
163
163
|
const middlewareCode = options?.middlewareCode || null;
|
|
164
164
|
const headExtra = options?.headExtra || null;
|
|
165
165
|
const pagePath = resolve(appDir, routeNode.sourceDir, 'page.vsk');
|
|
166
|
+
// Precompiled plans are written to static files and fetched at render time
|
|
167
|
+
// instead of being embedded inline. Embedding every page/layout/error plan as
|
|
168
|
+
// inline JSON makes each SSR function module large enough to OOM on memory-
|
|
169
|
+
// constrained build containers (e.g. Vercel's 2048 MB serverless limit).
|
|
170
|
+
const plansDir = resolve(outDir, 'static', 'ssr-plans');
|
|
171
|
+
mkdirSync(plansDir, { recursive: true });
|
|
172
|
+
function writePlan(planKey, planJSON) {
|
|
173
|
+
const fileName = `plan-${planKey}.mjs`;
|
|
174
|
+
const planFile = resolve(plansDir, fileName);
|
|
175
|
+
writeFileSync(planFile, `export const plan = ${planJSON};\n`, 'utf-8');
|
|
176
|
+
// Return a relative path from the SSR function directory so dynamic
|
|
177
|
+
// import() inside the generated function resolves to the plan module.
|
|
178
|
+
return relative(resolve(outDir, 'server', 'functions'), planFile);
|
|
179
|
+
}
|
|
180
|
+
/** Generates a lazy getter that imports a precompiled plan module and compiles
|
|
181
|
+
* it with hydratePrecompile on first use, caching the result. Import failures
|
|
182
|
+
* degrade to null (renderPage falls back to compiling from source).
|
|
183
|
+
* The IIFE form is a single expression so it can be placed anywhere — inside
|
|
184
|
+
* array literals, object literals, or at module scope — without syntax errors.
|
|
185
|
+
*/
|
|
186
|
+
function planGetterCode(varName, planUrl) {
|
|
187
|
+
return `const ${varName} = (() => {
|
|
188
|
+
let cache = null;
|
|
189
|
+
return async () => {
|
|
190
|
+
if (cache) return cache;
|
|
191
|
+
try {
|
|
192
|
+
const mod = await import(${JSON.stringify(planUrl)});
|
|
193
|
+
cache = hydratePrecompile(mod.plan);
|
|
194
|
+
} catch { cache = null; }
|
|
195
|
+
return cache;
|
|
196
|
+
};
|
|
197
|
+
})();`;
|
|
198
|
+
}
|
|
166
199
|
const parts = routeNode.fullPath.split('/').filter(Boolean);
|
|
167
200
|
const name = routeName(parts);
|
|
168
201
|
const funcDir = resolve(outDir, 'server', 'functions');
|
|
@@ -180,15 +213,15 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
180
213
|
...(routeNode.layout ? [{ sourceDir: routeNode.sourceDir, layoutCompName: routeNode.layout }] : []),
|
|
181
214
|
];
|
|
182
215
|
const layoutDecls = [];
|
|
183
|
-
for (
|
|
216
|
+
for (let li = 0; li < layoutStack.length; li++) {
|
|
217
|
+
const entry = layoutStack[li];
|
|
184
218
|
const entryPath = resolve(appDir, entry.sourceDir, 'layout.vsk');
|
|
185
219
|
const entrySrc = readFileSync(entryPath, 'utf-8');
|
|
186
220
|
const entryComp = extractCompName(entrySrc) || 'Layout';
|
|
187
221
|
const plan = precompilePlan(entryPath);
|
|
188
222
|
layoutDecls.push({
|
|
189
223
|
comp: JSON.stringify(entryComp),
|
|
190
|
-
plan,
|
|
191
|
-
compiled: hydrateInvoke(plan),
|
|
224
|
+
planUrl: writePlan('layout-' + name + '-' + li, plan),
|
|
192
225
|
});
|
|
193
226
|
}
|
|
194
227
|
const pagePlan = precompilePlan(pagePath);
|
|
@@ -197,8 +230,8 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
197
230
|
const errorSrc = errorPath ? readFileSync(errorPath, 'utf-8') : null;
|
|
198
231
|
const errorComp = errorPath ? (extractCompName(errorSrc) || 'Error') : null;
|
|
199
232
|
const errorVars = errorPath
|
|
200
|
-
? `const _errorComp = ${JSON.stringify(errorComp)};\
|
|
201
|
-
: 'const _errorComp = null;\
|
|
233
|
+
? `const _errorComp = ${JSON.stringify(errorComp)};\n${planGetterCode('_errorCompiled', writePlan('error-' + name, precompilePlan(errorPath)))}\n`
|
|
234
|
+
: 'const _errorComp = null;\nasync function _errorCompiled() { return null; }\n';
|
|
202
235
|
// Not-found used to have no server-side resolution at all: a NotFoundError was
|
|
203
236
|
// re-thrown out of the function and the prod server answered with the ROOT
|
|
204
237
|
// not-found.vsk. A nested `app/admin/not-found.vsk` therefore did nothing on a
|
|
@@ -209,19 +242,23 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
209
242
|
const notFoundSrc = notFoundPath ? readFileSync(notFoundPath, 'utf-8') : null;
|
|
210
243
|
const notFoundComp = notFoundPath ? (extractCompName(notFoundSrc) || 'NotFound') : null;
|
|
211
244
|
const notFoundVars = notFoundPath
|
|
212
|
-
? `const _notFoundComp = ${JSON.stringify(notFoundComp)};\
|
|
213
|
-
: 'const _notFoundComp = null;\
|
|
245
|
+
? `const _notFoundComp = ${JSON.stringify(notFoundComp)};\n${planGetterCode('_notFoundCompiled', writePlan('notfound-' + name, precompilePlan(notFoundPath)))}\n`
|
|
246
|
+
: 'const _notFoundComp = null;\nasync function _notFoundCompiled() { return null; }\n';
|
|
247
|
+
const pagePlanUrl = writePlan('page-' + name, pagePlan);
|
|
214
248
|
let src = '';
|
|
215
249
|
if (layoutDecls.length > 0) {
|
|
250
|
+
const pageGetter = planGetterCode('_pageCompiled', pagePlanUrl);
|
|
251
|
+
const layoutGetters = layoutDecls.map((d, i) => planGetterCode('_layoutCompiled_' + i, d.planUrl));
|
|
216
252
|
src = `const _pageComp = ${JSON.stringify(pageComp)};\n`;
|
|
217
|
-
src +=
|
|
253
|
+
src += pageGetter + '\n';
|
|
254
|
+
src += layoutGetters.join('\n') + '\n';
|
|
218
255
|
src += `const _layoutCompList = [${layoutDecls.map((d) => d.comp).join(', ')}];\n`;
|
|
219
|
-
src += `const _layoutCompiledList = [
|
|
256
|
+
src += `const _layoutCompiledList = [${layoutDecls.map((_, i) => '_layoutCompiled_' + i).join(', ')}];\n`;
|
|
220
257
|
src += errorVars + notFoundVars;
|
|
221
258
|
}
|
|
222
259
|
else {
|
|
223
260
|
src = `const _comp = ${JSON.stringify(pageComp)};\n`;
|
|
224
|
-
src +=
|
|
261
|
+
src += planGetterCode('_compiled', pagePlanUrl) + '\n';
|
|
225
262
|
src += errorVars + notFoundVars;
|
|
226
263
|
}
|
|
227
264
|
const urlParts = routeNode.fullPath.split('/').filter(Boolean);
|
|
@@ -235,9 +272,13 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
235
272
|
let registryCode = '';
|
|
236
273
|
const compRegEntries = [];
|
|
237
274
|
const compMap = componentMap || new Map();
|
|
275
|
+
let compCounter = 0;
|
|
238
276
|
for (const [compName, compPath] of compMap) {
|
|
239
277
|
const plan = precompilePlan(compPath);
|
|
240
|
-
|
|
278
|
+
const compPlanUrl = writePlan('comp-' + name + '-' + compCounter, plan);
|
|
279
|
+
const compGetter = '_compiled_' + compCounter;
|
|
280
|
+
compCounter++;
|
|
281
|
+
compRegEntries.push(` (() => {\n${planGetterCode(compGetter, compPlanUrl)}\n __componentRegistry.set(${JSON.stringify(compName)}, async (props, __registry, __vesk) => {\n const result = await renderPage('', ${JSON.stringify(compName)}, props, __registry, { hydrate: true, cached: await ${compGetter}() });\n return result.body;\n });\n })();`);
|
|
241
282
|
}
|
|
242
283
|
if (compRegEntries.length > 0) {
|
|
243
284
|
registryCode = 'const __componentRegistry = new Map();\n{\n' + compRegEntries.join('\n') + '\n}\n';
|
|
@@ -251,7 +292,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
251
292
|
'async function __renderErrorBody(props) {',
|
|
252
293
|
' if (!_errorComp) throw props.error || new Error("Internal Server Error");',
|
|
253
294
|
' try {',
|
|
254
|
-
' const result = await renderPage(\'\', _errorComp, props, __componentRegistry, { hydrate: true, cached: _errorCompiled });',
|
|
295
|
+
' const result = await renderPage(\'\', _errorComp, props, __componentRegistry, { hydrate: true, cached: await _errorCompiled() });',
|
|
255
296
|
' return result.body;',
|
|
256
297
|
' } catch {',
|
|
257
298
|
` return ${JSON.stringify(renderDefaultErrorFragment())};`,
|
|
@@ -264,7 +305,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
264
305
|
'async function __renderNotFoundBody(props) {',
|
|
265
306
|
' if (!_notFoundComp) return null;',
|
|
266
307
|
' try {',
|
|
267
|
-
' const result = await renderPage(\'\', _notFoundComp, props, __componentRegistry, { hydrate: true, cached: _notFoundCompiled });',
|
|
308
|
+
' const result = await renderPage(\'\', _notFoundComp, props, __componentRegistry, { hydrate: true, cached: await _notFoundCompiled() });',
|
|
268
309
|
' return result.body;',
|
|
269
310
|
' } catch {',
|
|
270
311
|
' return null;',
|
|
@@ -278,11 +319,11 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
278
319
|
' let _b = body;',
|
|
279
320
|
' let _h = head || "";',
|
|
280
321
|
' for (let _i = _layoutCompList.length - 1; _i > 0; _i--) {',
|
|
281
|
-
" const _inner = await renderPage('', _layoutCompList[_i], { params, children: _b }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[_i] });",
|
|
322
|
+
" const _inner = await renderPage('', _layoutCompList[_i], { params, children: _b }, __componentRegistry, { hydrate: true, cached: await _layoutCompiledList[_i]() });",
|
|
282
323
|
' _b = _inner.body;',
|
|
283
324
|
' if (_inner.head) _h = _inner.head + _h;',
|
|
284
325
|
' }',
|
|
285
|
-
" return renderFullPage('', _layoutCompList[0], { params, children: _b }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[0]" + bakedOptions + clientScriptOption + dataScriptOption + ", pageHead: _h });",
|
|
326
|
+
" return renderFullPage('', _layoutCompList[0], { params, children: _b }, __componentRegistry, { hydrate: true, cached: await _layoutCompiledList[0]()" + bakedOptions + clientScriptOption + dataScriptOption + ", pageHead: _h });",
|
|
286
327
|
'}',
|
|
287
328
|
'',
|
|
288
329
|
'async function __renderHtml(params, requestUrl) {',
|
|
@@ -293,7 +334,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
293
334
|
' let notFound = false;',
|
|
294
335
|
" const __expose = process.env.NODE_ENV !== 'production';",
|
|
295
336
|
' try {',
|
|
296
|
-
' page = await renderPage(\'\', _pageComp, { params }, __componentRegistry, { hydrate: true, cached: _pageCompiled });',
|
|
337
|
+
' page = await renderPage(\'\', _pageComp, { params }, __componentRegistry, { hydrate: true, cached: await _pageCompiled() });',
|
|
297
338
|
' } catch (err) {',
|
|
298
339
|
" if (err && err.name === 'Redirect') throw err;",
|
|
299
340
|
" if (err && err.name === 'NotFoundError') {",
|
|
@@ -331,7 +372,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
331
372
|
" const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : String(err);",
|
|
332
373
|
" const stack = err && typeof err === 'object' && 'stack' in err ? String(err.stack) : '';",
|
|
333
374
|
" const props = { params, statusCode: 500, error: __expose ? message : 'Internal Server Error', stack: __expose ? stack : '', url: requestUrl || '' };",
|
|
334
|
-
" return renderFullPage('', _errorComp, props, __componentRegistry, { hydrate: true, cached: _errorCompiled" + bakedOptions + clientScriptOption + dataScriptOption + " });",
|
|
375
|
+
" return renderFullPage('', _errorComp, props, __componentRegistry, { hydrate: true, cached: await _errorCompiled()" + bakedOptions + clientScriptOption + dataScriptOption + " });",
|
|
335
376
|
'}',
|
|
336
377
|
'',
|
|
337
378
|
'async function __renderHtml(params, requestUrl) {',
|
|
@@ -346,7 +387,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
346
387
|
// though it runs outside the ALS scope.
|
|
347
388
|
" const __streamToken = globalThis.__vsk_ssr_token || '';",
|
|
348
389
|
' try {',
|
|
349
|
-
" stream = renderPageStream('', _comp, { params }, __componentRegistry, { hydrate: true, cached: _compiled" + bakedOptions + clientScriptOption + dataScriptOption + ' });',
|
|
390
|
+
" stream = renderPageStream('', _comp, { params }, __componentRegistry, { hydrate: true, cached: await _compiled()" + bakedOptions + clientScriptOption + dataScriptOption + ' });',
|
|
350
391
|
' } catch (err) {',
|
|
351
392
|
' if (err && (err.name === \'NotFoundError\' || err.name === \'Redirect\')) throw err;',
|
|
352
393
|
' const html = await __renderErrorFullPage(params, requestUrl, err);',
|
|
@@ -433,7 +474,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
433
474
|
' try {',
|
|
434
475
|
' let dataPage;',
|
|
435
476
|
' try {',
|
|
436
|
-
" dataPage = await renderPage('', _pageComp, { params }, __componentRegistry, { hydrate: true, cached: _pageCompiled });",
|
|
477
|
+
" dataPage = await renderPage('', _pageComp, { params }, __componentRegistry, { hydrate: true, cached: await _pageCompiled() });",
|
|
437
478
|
' } catch (err) {',
|
|
438
479
|
" if (err && (err.name === 'NotFoundError' || err.name === 'Redirect')) throw err;",
|
|
439
480
|
' const message = err && typeof err === \'object\' && \'message\' in err ? String(err.message) : String(err);',
|
|
@@ -441,7 +482,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
441
482
|
' }',
|
|
442
483
|
' let _dataHead = dataPage.head || \'\';',
|
|
443
484
|
' for (let _i = _layoutCompList.length - 1; _i >= 0; _i--) {',
|
|
444
|
-
" const _dl = await renderPage('', _layoutCompList[_i], { params, children: '' }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[_i] });",
|
|
485
|
+
" const _dl = await renderPage('', _layoutCompList[_i], { params, children: '' }, __componentRegistry, { hydrate: true, cached: await _layoutCompiledList[_i]() });",
|
|
445
486
|
' _dataHead = (_dl.head || \'\') + _dataHead;',
|
|
446
487
|
' }',
|
|
447
488
|
" return new Response(JSON.stringify({ path: url.pathname, params, props: dataPage.props || { params }, head: _dataHead }), {",
|
|
@@ -460,7 +501,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
460
501
|
' try {',
|
|
461
502
|
' let dataPage;',
|
|
462
503
|
' try {',
|
|
463
|
-
" dataPage = await renderPage('', _comp, { params }, __componentRegistry, { hydrate: true, cached: _compiled });",
|
|
504
|
+
" dataPage = await renderPage('', _comp, { params }, __componentRegistry, { hydrate: true, cached: await _compiled() });",
|
|
464
505
|
' } catch (err) {',
|
|
465
506
|
" if (err && (err.name === 'NotFoundError' || err.name === 'Redirect')) throw err;",
|
|
466
507
|
' const message = err && typeof err === \'object\' && \'message\' in err ? String(err.message) : String(err);',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.77",
|
|
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.77",
|
|
27
|
+
"@vesk/runtime": "^0.2.77",
|
|
28
|
+
"@vesk/types": "^0.2.77"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|