@jay-framework/dev-server 0.23.0 → 0.24.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/dist/index.js +158 -138
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
import { createServer } from "vite";
|
|
8
5
|
import { jayRuntime } from "@jay-framework/vite-plugin";
|
|
9
6
|
import { createRequire } from "module";
|
|
10
7
|
import "@jay-framework/compiler-shared";
|
|
11
8
|
import * as path from "node:path";
|
|
12
9
|
import path__default from "node:path";
|
|
13
|
-
import {
|
|
10
|
+
import { injectHeadfullFSTemplates, JAY_IMPORT_RESOLVER, parseContract, slowRenderTransform, assignCoordinatesToJayHtml, discoverHeadlessInstances } from "@jay-framework/compiler-jay-html";
|
|
14
11
|
import { getLogger, getDevLogger } from "@jay-framework/logger";
|
|
15
12
|
import { createRequire as createRequire$1 } from "node:module";
|
|
16
13
|
import * as fsSync from "node:fs";
|
|
17
14
|
import fsSync__default from "node:fs";
|
|
18
15
|
import { scanRoutes, createRoute, routeToExpressRoute } from "@jay-framework/stack-route-scanner";
|
|
19
|
-
import { discoverPluginsWithInit, sortPluginsByDependencies, executePluginServerInits, runInitCallbacks,
|
|
16
|
+
import { discoverPluginsWithInit, sortPluginsByDependencies, executePluginServerInits, runInitCallbacks, discoverAndRegisterActions, actionRegistry, discoverAllPluginActions, runShutdownCallbacks, clearLifecycleCallbacks, clearServiceRegistry, clearClientInitData, loadPageParts, runLoadParams, DevSlowlyChangingPhase, SlowRenderCache, preparePluginClientInits, registerService, getServiceRegistry, materializeContracts, scanPlugins, clearServerElementCache, parseCookies, generateFrozenPageHtml, renderFastChangingData, generateClientScript, getClientInitData, mergeHeadTags, generateSSRPageHtml, slowRenderInstances, normalizeAndResolveInstanceProps } from "@jay-framework/stack-server-runtime";
|
|
20
17
|
import * as fs from "node:fs/promises";
|
|
21
18
|
import fs__default from "node:fs/promises";
|
|
22
19
|
import { pathToFileURL } from "node:url";
|
|
@@ -33,10 +30,7 @@ const s$1 = createRequire(import.meta.url), e$1 = s$1("typescript"), c$1 = new P
|
|
|
33
30
|
});
|
|
34
31
|
var __defProp2 = Object.defineProperty;
|
|
35
32
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
36
|
-
var __publicField2 = (obj, key, value) =>
|
|
37
|
-
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
38
|
-
return value;
|
|
39
|
-
};
|
|
33
|
+
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
34
|
const s = createRequire(import.meta.url), e = s("typescript"), c = new Proxy(e, {
|
|
41
35
|
get(t, r) {
|
|
42
36
|
return t[r];
|
|
@@ -72,6 +66,9 @@ function mkTransformer(fileTransformer, config) {
|
|
|
72
66
|
};
|
|
73
67
|
};
|
|
74
68
|
}
|
|
69
|
+
const { isStringLiteral: isStringLiteral$a, isImportDeclaration: isImportDeclaration$5, forEachChild: forEachChild$4, isNamedImports: isNamedImports$1 } = c;
|
|
70
|
+
const { isStringLiteral: isStringLiteral$9, forEachChild: forEachChild$3, isImportDeclaration: isImportDeclaration$4 } = c;
|
|
71
|
+
const { isIdentifier: isIdentifier$a, isArrowFunction: isArrowFunction$3, isFunctionDeclaration: isFunctionDeclaration$2, isVariableStatement: isVariableStatement$3, forEachChild: forEachChild$2 } = c;
|
|
75
72
|
const {
|
|
76
73
|
isIdentifier: isIdentifier$9,
|
|
77
74
|
isStatement: isStatement$3,
|
|
@@ -89,7 +86,7 @@ const {
|
|
|
89
86
|
isNumericLiteral,
|
|
90
87
|
isToken,
|
|
91
88
|
isNamespaceImport,
|
|
92
|
-
isNamedImports: isNamedImports$
|
|
89
|
+
isNamedImports: isNamedImports$2,
|
|
93
90
|
isArrowFunction: isArrowFunction$2,
|
|
94
91
|
isFunctionExpression,
|
|
95
92
|
isCallExpression: isCallExpression$6,
|
|
@@ -138,12 +135,9 @@ const getAccessedByProperty = (binding, accessedFrom, propertyName) => {
|
|
|
138
135
|
return accessedFrom ? propertyName ? isIdentifier$9(propertyName) ? propertyName.text : void 0 : binding.text : void 0;
|
|
139
136
|
};
|
|
140
137
|
function findDeclaringStatement(node) {
|
|
141
|
-
if (!node)
|
|
142
|
-
|
|
143
|
-
else
|
|
144
|
-
return node;
|
|
145
|
-
else
|
|
146
|
-
return findDeclaringStatement(node.parent);
|
|
138
|
+
if (!node) return void 0;
|
|
139
|
+
else if (isStatement$3(node)) return node;
|
|
140
|
+
else return findDeclaringStatement(node.parent);
|
|
147
141
|
}
|
|
148
142
|
function tsBindingNameToVariable(binding, accessedFrom, assignedFrom, propertyName, root) {
|
|
149
143
|
if (isIdentifier$9(binding)) {
|
|
@@ -202,8 +196,7 @@ class NameBindingResolver {
|
|
|
202
196
|
mkParameterVariableRoot(param, paramIndex)
|
|
203
197
|
);
|
|
204
198
|
paramVariables.forEach((variable) => {
|
|
205
|
-
if (variable.name)
|
|
206
|
-
this.variables.set(variable.name, variable);
|
|
199
|
+
if (variable.name) this.variables.set(variable.name, variable);
|
|
207
200
|
});
|
|
208
201
|
});
|
|
209
202
|
}
|
|
@@ -304,8 +297,7 @@ class NameBindingResolver {
|
|
|
304
297
|
let resolved;
|
|
305
298
|
while ((resolved = nameResolver.getVariable(variableName)) === UNKNOWN_VARIABLE && nameResolver.parentNameResolver)
|
|
306
299
|
nameResolver = nameResolver.parentNameResolver;
|
|
307
|
-
if (resolved === UNKNOWN_VARIABLE)
|
|
308
|
-
return { root: mkGlobalVariableRoot(variableName) };
|
|
300
|
+
if (resolved === UNKNOWN_VARIABLE) return { root: mkGlobalVariableRoot(variableName) };
|
|
309
301
|
return resolved;
|
|
310
302
|
}
|
|
311
303
|
addImportDeclaration(node) {
|
|
@@ -336,7 +328,7 @@ class NameBindingResolver {
|
|
|
336
328
|
root
|
|
337
329
|
});
|
|
338
330
|
this.variables.set(namedBindings.name.text, variable);
|
|
339
|
-
} else if (isNamedImports$
|
|
331
|
+
} else if (isNamedImports$2(namedBindings)) {
|
|
340
332
|
namedBindings.elements.forEach((importSpecifier) => {
|
|
341
333
|
if (!importSpecifier.isTypeOnly) {
|
|
342
334
|
let variable = mkVariable({
|
|
@@ -356,8 +348,7 @@ class NameBindingResolver {
|
|
|
356
348
|
}
|
|
357
349
|
}
|
|
358
350
|
function flattenVariable(variable, path2 = []) {
|
|
359
|
-
if (variable.assignedFrom)
|
|
360
|
-
return flattenVariable(variable.assignedFrom, path2);
|
|
351
|
+
if (variable.assignedFrom) return flattenVariable(variable.assignedFrom, path2);
|
|
361
352
|
else if (variable.accessedFrom) {
|
|
362
353
|
return flattenVariable(variable.accessedFrom, [variable.accessedByProperty, ...path2]);
|
|
363
354
|
} else if (variable.properties && !!variable.properties.find((_) => _.name === path2[0])) {
|
|
@@ -365,12 +356,19 @@ function flattenVariable(variable, path2 = []) {
|
|
|
365
356
|
variable.properties.find((_) => _.name === path2[0]),
|
|
366
357
|
path2.slice(1)
|
|
367
358
|
);
|
|
368
|
-
} else
|
|
369
|
-
return { path: path2, root: variable.root };
|
|
359
|
+
} else return { path: path2, root: variable.root };
|
|
370
360
|
}
|
|
361
|
+
const { isIdentifier: isIdentifier$8, isPropertyAccessExpression: isPropertyAccessExpression$4 } = c;
|
|
371
362
|
function byAnd() {
|
|
372
363
|
return (agg, value) => agg && value;
|
|
373
364
|
}
|
|
365
|
+
const {
|
|
366
|
+
isCallExpression: isCallExpression$5,
|
|
367
|
+
isExpressionStatement: isExpressionStatement$1,
|
|
368
|
+
isIdentifier: isIdentifier$7,
|
|
369
|
+
isPropertyAccessExpression: isPropertyAccessExpression$3,
|
|
370
|
+
isBlock: isBlock$3
|
|
371
|
+
} = c;
|
|
374
372
|
const {
|
|
375
373
|
isIdentifier: isIdentifier$6,
|
|
376
374
|
SyntaxKind: SyntaxKind$4,
|
|
@@ -442,12 +440,8 @@ class UnionResolvedType {
|
|
|
442
440
|
if (rightSide instanceof UnionResolvedType) {
|
|
443
441
|
for (const item1 of this.types)
|
|
444
442
|
for (const item2 of rightSide.types)
|
|
445
|
-
if (item1.canBeAssignedFrom(item2))
|
|
446
|
-
|
|
447
|
-
} else
|
|
448
|
-
for (const item1 of this.types)
|
|
449
|
-
if (item1.canBeAssignedFrom(rightSide))
|
|
450
|
-
return true;
|
|
443
|
+
if (item1.canBeAssignedFrom(item2)) return true;
|
|
444
|
+
} else for (const item1 of this.types) if (item1.canBeAssignedFrom(rightSide)) return true;
|
|
451
445
|
return false;
|
|
452
446
|
}
|
|
453
447
|
}
|
|
@@ -475,15 +469,11 @@ class SourceFileBindingResolver {
|
|
|
475
469
|
return node;
|
|
476
470
|
};
|
|
477
471
|
const visitor = (node) => {
|
|
478
|
-
if (isFunctionDeclaration$1(node))
|
|
479
|
-
|
|
480
|
-
if (
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
nbResolversQueue[0].addImportDeclaration(node);
|
|
484
|
-
else if (isBlock$2(node))
|
|
485
|
-
return doWithChildBindingResolver(node, () => {
|
|
486
|
-
});
|
|
472
|
+
if (isFunctionDeclaration$1(node)) nbResolversQueue[0].addFunctionDeclaration(node);
|
|
473
|
+
if (isVariableStatement$2(node)) nbResolversQueue[0].addVariableStatement(node);
|
|
474
|
+
else if (isImportDeclaration$3(node)) nbResolversQueue[0].addImportDeclaration(node);
|
|
475
|
+
else if (isBlock$2(node)) return doWithChildBindingResolver(node, () => {
|
|
476
|
+
});
|
|
487
477
|
else if (isFunctionLikeDeclarationBase(node)) {
|
|
488
478
|
return doWithChildBindingResolver(
|
|
489
479
|
node,
|
|
@@ -516,8 +506,7 @@ class SourceFileBindingResolver {
|
|
|
516
506
|
}
|
|
517
507
|
findBindingResolver(node) {
|
|
518
508
|
let found;
|
|
519
|
-
while (!(found = this.nameBindingResolvers.get(node)) && node.parent)
|
|
520
|
-
node = node.parent;
|
|
509
|
+
while (!(found = this.nameBindingResolvers.get(node)) && node.parent) node = node.parent;
|
|
521
510
|
return found;
|
|
522
511
|
}
|
|
523
512
|
explain(identifier) {
|
|
@@ -528,8 +517,7 @@ class SourceFileBindingResolver {
|
|
|
528
517
|
if (isImportModuleVariableRoot(flattened.root) && isStringLiteral$7(flattened.root.module)) {
|
|
529
518
|
return new ImportFromModuleResolvedType(flattened.root.module.text, flattened.path);
|
|
530
519
|
}
|
|
531
|
-
} else
|
|
532
|
-
return void 0;
|
|
520
|
+
} else return void 0;
|
|
533
521
|
}
|
|
534
522
|
explainType(type) {
|
|
535
523
|
if (type) {
|
|
@@ -539,10 +527,8 @@ class SourceFileBindingResolver {
|
|
|
539
527
|
let resolved = this.findBindingResolver(typeName).resolveIdentifier(typeName);
|
|
540
528
|
let flattened = flattenVariable(resolved);
|
|
541
529
|
let typeFromFlattened = this.explainFlattenedVariableType(flattened);
|
|
542
|
-
if (typeFromFlattened)
|
|
543
|
-
|
|
544
|
-
if (builtInType(typeName.text))
|
|
545
|
-
return new BuiltInResolvedType(typeName.text);
|
|
530
|
+
if (typeFromFlattened) return typeFromFlattened;
|
|
531
|
+
if (builtInType(typeName.text)) return new BuiltInResolvedType(typeName.text);
|
|
546
532
|
}
|
|
547
533
|
} else if (type.kind === SyntaxKind$4.StringKeyword)
|
|
548
534
|
return new BuiltInResolvedType("string");
|
|
@@ -550,10 +536,8 @@ class SourceFileBindingResolver {
|
|
|
550
536
|
return new BuiltInResolvedType("number");
|
|
551
537
|
else if (type.kind === SyntaxKind$4.BooleanKeyword)
|
|
552
538
|
return new BuiltInResolvedType("boolean");
|
|
553
|
-
else if (type.kind === SyntaxKind$4.AnyKeyword)
|
|
554
|
-
|
|
555
|
-
else if (type.kind === SyntaxKind$4.VoidKeyword)
|
|
556
|
-
return new BuiltInResolvedType("void");
|
|
539
|
+
else if (type.kind === SyntaxKind$4.AnyKeyword) return new BuiltInResolvedType("any");
|
|
540
|
+
else if (type.kind === SyntaxKind$4.VoidKeyword) return new BuiltInResolvedType("void");
|
|
557
541
|
else if (isArrayTypeNode(type))
|
|
558
542
|
return new ArrayResolvedType(this.explainType(type.elementType));
|
|
559
543
|
else if (isFunctionTypeNode(type)) {
|
|
@@ -569,7 +553,67 @@ class SourceFileBindingResolver {
|
|
|
569
553
|
return new GlobalResolvedType(globalVariableRoot.name);
|
|
570
554
|
}
|
|
571
555
|
}
|
|
572
|
-
const {
|
|
556
|
+
const {
|
|
557
|
+
isSpreadElement,
|
|
558
|
+
isFunctionDeclaration: isFunctionDeclaration$4,
|
|
559
|
+
isDecorator,
|
|
560
|
+
isCallExpression: isCallExpression$4,
|
|
561
|
+
isIdentifier: isIdentifier$5,
|
|
562
|
+
isPropertyAccessExpression: isPropertyAccessExpression$2,
|
|
563
|
+
isReturnStatement,
|
|
564
|
+
isNewExpression: isNewExpression$1,
|
|
565
|
+
isExpressionStatement,
|
|
566
|
+
isBinaryExpression: isBinaryExpression$1,
|
|
567
|
+
SyntaxKind: SyntaxKind$3,
|
|
568
|
+
transform: transform$5,
|
|
569
|
+
visitEachChild: visitEachChild$4
|
|
570
|
+
} = c;
|
|
571
|
+
const { visitEachChild: visitEachChild$3, transform: transform$4, visitNode: visitNode$3 } = c;
|
|
572
|
+
const { isTypeReferenceNode } = c;
|
|
573
|
+
const {
|
|
574
|
+
visitEachChild: visitEachChild$2,
|
|
575
|
+
isIdentifier: isIdentifier$4,
|
|
576
|
+
SyntaxKind: SyntaxKind$2,
|
|
577
|
+
transform: transform$3,
|
|
578
|
+
isStatement: isStatement$2,
|
|
579
|
+
isBlock: isBlock$1,
|
|
580
|
+
isExpression: isExpression$1,
|
|
581
|
+
isLiteralExpression: isLiteralExpression$1,
|
|
582
|
+
visitNode: visitNode$2
|
|
583
|
+
} = c;
|
|
584
|
+
const { visitEachChild: visitEachChild$1, isCallExpression: isCallExpression$3, isPropertyAccessExpression: isPropertyAccessExpression$1$1 } = c;
|
|
585
|
+
const {
|
|
586
|
+
isBinaryExpression,
|
|
587
|
+
isCallExpression: isCallExpression$2,
|
|
588
|
+
isIdentifier: isIdentifier$3,
|
|
589
|
+
isNewExpression,
|
|
590
|
+
isPropertyAccessExpression: isPropertyAccessExpression$6,
|
|
591
|
+
SyntaxKind: SyntaxKind$1,
|
|
592
|
+
isArrowFunction: isArrowFunction$1,
|
|
593
|
+
isLiteralExpression,
|
|
594
|
+
isStatement: isStatement$1,
|
|
595
|
+
isVariableStatement: isVariableStatement$1,
|
|
596
|
+
isBlock,
|
|
597
|
+
isIfStatement,
|
|
598
|
+
isForStatement,
|
|
599
|
+
isForOfStatement,
|
|
600
|
+
isForInStatement,
|
|
601
|
+
isWhileStatement,
|
|
602
|
+
isDoStatement,
|
|
603
|
+
isElementAccessExpression,
|
|
604
|
+
isPropertyAssignment
|
|
605
|
+
} = c;
|
|
606
|
+
const { isCallExpression: isCallExpression$1$1, isIdentifier: isIdentifier$2$1, isStringLiteral: isStringLiteral$6, isVariableStatement: isVariableStatement$4, forEachChild: forEachChild$1 } = c;
|
|
607
|
+
const { isCallExpression: isCallExpression$7, isIdentifier: isIdentifier$1$1, isStringLiteral: isStringLiteral$5, forEachChild } = c;
|
|
608
|
+
const { transform: transform$2, isArrowFunction, isExpression, visitNode: visitNode$1 } = c;
|
|
609
|
+
const { SyntaxKind: SyntaxKind$6, transform: transform$1, isStringLiteral: isStringLiteral$4, isInterfaceDeclaration: isInterfaceDeclaration$1, isImportDeclaration: isImportDeclaration$2 } = c;
|
|
610
|
+
const { isStringLiteral: isStringLiteral$3 } = c;
|
|
611
|
+
const { isImportDeclaration: isImportDeclaration$1$1 } = c;
|
|
612
|
+
const { visitEachChild: visitEachChild$6, transform, isStringLiteral: isStringLiteral$2, isImportDeclaration: isImportDeclaration$6 } = c;
|
|
613
|
+
const { createSourceFile: createSourceFile$2, ScriptTarget: ScriptTarget$2, ScriptKind } = c;
|
|
614
|
+
const { isStringLiteral: isStringLiteral$1$1 } = c;
|
|
615
|
+
const { isIdentifier: isIdentifier$b, isStatement, visitNode } = c;
|
|
616
|
+
const { isStringLiteral: isStringLiteral$b } = c;
|
|
573
617
|
function areFlattenedAccessChainsEqual(chain1, chain2) {
|
|
574
618
|
if (chain1.path.length !== chain2.path.length) {
|
|
575
619
|
return false;
|
|
@@ -593,8 +637,8 @@ function areVariableRootsEqual(root1, root2) {
|
|
|
593
637
|
switch (root1.kind) {
|
|
594
638
|
case VariableRootType.ImportModule:
|
|
595
639
|
if (isImportModuleVariableRoot(root1) && isImportModuleVariableRoot(root2)) {
|
|
596
|
-
const module1 = isStringLiteral$
|
|
597
|
-
const module2 = isStringLiteral$
|
|
640
|
+
const module1 = isStringLiteral$b(root1.module) ? root1.module.text : String(root1.module);
|
|
641
|
+
const module2 = isStringLiteral$b(root2.module) ? root2.module.text : String(root2.module);
|
|
598
642
|
return module1 === module2 && root1.importType === root2.importType;
|
|
599
643
|
}
|
|
600
644
|
return false;
|
|
@@ -621,19 +665,14 @@ const COMPONENT_CLIENT_REPLACE_METHODS = /* @__PURE__ */ new Map([["withInteract
|
|
|
621
665
|
const INIT_SERVER_METHODS = /* @__PURE__ */ new Set(["withServer"]);
|
|
622
666
|
const INIT_CLIENT_METHODS = /* @__PURE__ */ new Set(["withClient"]);
|
|
623
667
|
function shouldRemoveMethod(methodName, environment) {
|
|
624
|
-
if (environment === "client" && COMPONENT_SERVER_METHODS.has(methodName))
|
|
625
|
-
|
|
626
|
-
if (environment === "
|
|
627
|
-
|
|
628
|
-
if (environment === "client" && INIT_SERVER_METHODS.has(methodName))
|
|
629
|
-
return true;
|
|
630
|
-
if (environment === "server" && INIT_CLIENT_METHODS.has(methodName))
|
|
631
|
-
return true;
|
|
668
|
+
if (environment === "client" && COMPONENT_SERVER_METHODS.has(methodName)) return true;
|
|
669
|
+
if (environment === "server" && COMPONENT_CLIENT_METHODS.has(methodName)) return true;
|
|
670
|
+
if (environment === "client" && INIT_SERVER_METHODS.has(methodName)) return true;
|
|
671
|
+
if (environment === "server" && INIT_CLIENT_METHODS.has(methodName)) return true;
|
|
632
672
|
return false;
|
|
633
673
|
}
|
|
634
674
|
function getReplacementMethod(methodName, environment) {
|
|
635
|
-
if (environment === "server")
|
|
636
|
-
return COMPONENT_CLIENT_REPLACE_METHODS.get(methodName);
|
|
675
|
+
if (environment === "server") return COMPONENT_CLIENT_REPLACE_METHODS.get(methodName);
|
|
637
676
|
return void 0;
|
|
638
677
|
}
|
|
639
678
|
const { isCallExpression: isCallExpression$1, isPropertyAccessExpression: isPropertyAccessExpression$1, isIdentifier: isIdentifier$2, isStringLiteral: isStringLiteral$1 } = c$1;
|
|
@@ -925,8 +964,7 @@ function findChainRootBuilderName(statement, bindingResolver) {
|
|
|
925
964
|
if (c$1.isExpressionStatement(statement) && isCallExpression(statement.expression)) {
|
|
926
965
|
expr = statement.expression;
|
|
927
966
|
}
|
|
928
|
-
if (!expr)
|
|
929
|
-
return void 0;
|
|
967
|
+
if (!expr) return void 0;
|
|
930
968
|
let current = expr;
|
|
931
969
|
while (true) {
|
|
932
970
|
if (isCallExpression(current) && isPropertyAccessExpression(current.expression)) {
|
|
@@ -1089,8 +1127,7 @@ function createImportChainTracker(options = {}) {
|
|
|
1089
1127
|
let current = moduleId;
|
|
1090
1128
|
for (let i = 0; i < 100; i++) {
|
|
1091
1129
|
const importer = importChain.get(current);
|
|
1092
|
-
if (!importer)
|
|
1093
|
-
break;
|
|
1130
|
+
if (!importer) break;
|
|
1094
1131
|
chain.push(importer);
|
|
1095
1132
|
current = importer;
|
|
1096
1133
|
}
|
|
@@ -1207,7 +1244,7 @@ function createImportChainTracker(options = {}) {
|
|
|
1207
1244
|
}
|
|
1208
1245
|
};
|
|
1209
1246
|
}
|
|
1210
|
-
const
|
|
1247
|
+
const require$1 = createRequire$1(import.meta.url);
|
|
1211
1248
|
function createDefaultPluginDetector() {
|
|
1212
1249
|
const cache = /* @__PURE__ */ new Map();
|
|
1213
1250
|
return {
|
|
@@ -1218,9 +1255,9 @@ function createDefaultPluginDetector() {
|
|
|
1218
1255
|
}
|
|
1219
1256
|
let result = false;
|
|
1220
1257
|
try {
|
|
1221
|
-
|
|
1258
|
+
require$1.resolve(`${packageName}/plugin.yaml`, { paths: [projectRoot] });
|
|
1222
1259
|
try {
|
|
1223
|
-
|
|
1260
|
+
require$1.resolve(`${packageName}/client`, { paths: [projectRoot] });
|
|
1224
1261
|
result = true;
|
|
1225
1262
|
} catch {
|
|
1226
1263
|
result = false;
|
|
@@ -1258,12 +1295,9 @@ function transformImports(options) {
|
|
|
1258
1295
|
let result = code;
|
|
1259
1296
|
result = result.replace(IMPORT_REGEX, (match, clause, quote, source) => {
|
|
1260
1297
|
const packageName = extractPackageName(source);
|
|
1261
|
-
if (!packageName)
|
|
1262
|
-
|
|
1263
|
-
if (
|
|
1264
|
-
return match;
|
|
1265
|
-
if (!pluginDetector.isJayPluginWithClientExport(packageName, projectRoot))
|
|
1266
|
-
return match;
|
|
1298
|
+
if (!packageName) return match;
|
|
1299
|
+
if (isSubpathImport(source, packageName)) return match;
|
|
1300
|
+
if (!pluginDetector.isJayPluginWithClientExport(packageName, projectRoot)) return match;
|
|
1267
1301
|
hasChanges = true;
|
|
1268
1302
|
const newSource = `${packageName}/client`;
|
|
1269
1303
|
if (verbose) {
|
|
@@ -1275,12 +1309,9 @@ function transformImports(options) {
|
|
|
1275
1309
|
});
|
|
1276
1310
|
result = result.replace(EXPORT_FROM_REGEX, (match, clause, quote, source) => {
|
|
1277
1311
|
const packageName = extractPackageName(source);
|
|
1278
|
-
if (!packageName)
|
|
1279
|
-
|
|
1280
|
-
if (
|
|
1281
|
-
return match;
|
|
1282
|
-
if (!pluginDetector.isJayPluginWithClientExport(packageName, projectRoot))
|
|
1283
|
-
return match;
|
|
1312
|
+
if (!packageName) return match;
|
|
1313
|
+
if (isSubpathImport(source, packageName)) return match;
|
|
1314
|
+
if (!pluginDetector.isJayPluginWithClientExport(packageName, projectRoot)) return match;
|
|
1284
1315
|
hasChanges = true;
|
|
1285
1316
|
const newSource = `${packageName}/client`;
|
|
1286
1317
|
if (verbose) {
|
|
@@ -1371,7 +1402,7 @@ function jayStackCompiler(options = {}) {
|
|
|
1371
1402
|
// Second: Action import transformation (client builds only)
|
|
1372
1403
|
// Uses resolveId + load to replace action modules with virtual modules
|
|
1373
1404
|
// containing createActionCaller calls BEFORE bundling happens.
|
|
1374
|
-
(() => {
|
|
1405
|
+
/* @__PURE__ */ (() => {
|
|
1375
1406
|
let isSSRBuild = false;
|
|
1376
1407
|
return {
|
|
1377
1408
|
name: "jay-stack:action-transform",
|
|
@@ -1436,10 +1467,8 @@ function jayStackCompiler(options = {}) {
|
|
|
1436
1467
|
const hasRegularActions = actions.some((a) => !a.isStreaming);
|
|
1437
1468
|
const hasStreamActions = actions.some((a) => a.isStreaming);
|
|
1438
1469
|
const importNames = [];
|
|
1439
|
-
if (hasRegularActions)
|
|
1440
|
-
|
|
1441
|
-
if (hasStreamActions)
|
|
1442
|
-
importNames.push("createStreamCaller");
|
|
1470
|
+
if (hasRegularActions) importNames.push("createActionCaller");
|
|
1471
|
+
if (hasStreamActions) importNames.push("createStreamCaller");
|
|
1443
1472
|
const lines = [
|
|
1444
1473
|
`import { ${importNames.join(", ")} } from '@jay-framework/stack-client-runtime';`,
|
|
1445
1474
|
""
|
|
@@ -1468,17 +1497,12 @@ function jayStackCompiler(options = {}) {
|
|
|
1468
1497
|
// from component files in client builds. These are server-only
|
|
1469
1498
|
// constructs that shouldn't appear in client bundles.
|
|
1470
1499
|
transform(code, id, options2) {
|
|
1471
|
-
if (options2?.ssr || isSSRBuild)
|
|
1472
|
-
|
|
1473
|
-
if (
|
|
1474
|
-
|
|
1475
|
-
if (id.includes(".jay-html"))
|
|
1476
|
-
return null;
|
|
1477
|
-
if (isActionImport(id))
|
|
1478
|
-
return null;
|
|
1500
|
+
if (options2?.ssr || isSSRBuild) return null;
|
|
1501
|
+
if (!id.endsWith(".ts") && !id.includes(".ts?")) return null;
|
|
1502
|
+
if (id.includes(".jay-html")) return null;
|
|
1503
|
+
if (isActionImport(id)) return null;
|
|
1479
1504
|
const ACTION_BUILDERS = ["makeJayAction", "makeJayQuery", "makeJayStream"];
|
|
1480
|
-
if (!ACTION_BUILDERS.some((b) => code.includes(b)))
|
|
1481
|
-
return null;
|
|
1505
|
+
if (!ACTION_BUILDERS.some((b) => code.includes(b))) return null;
|
|
1482
1506
|
return stripInlineActionBuilders(code, ACTION_BUILDERS);
|
|
1483
1507
|
}
|
|
1484
1508
|
};
|
|
@@ -1786,12 +1810,9 @@ class ServiceLifecycleManager {
|
|
|
1786
1810
|
}
|
|
1787
1811
|
}
|
|
1788
1812
|
function deepMergeViewStates(base, overlay, trackByMap, path2 = "") {
|
|
1789
|
-
if (!base && !overlay)
|
|
1790
|
-
|
|
1791
|
-
if (!base
|
|
1792
|
-
return overlay || {};
|
|
1793
|
-
if (!overlay)
|
|
1794
|
-
return base || {};
|
|
1813
|
+
if (!base && !overlay) return {};
|
|
1814
|
+
if (!base) return overlay || {};
|
|
1815
|
+
if (!overlay) return base || {};
|
|
1795
1816
|
const result = {};
|
|
1796
1817
|
const allKeys = /* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(overlay)]);
|
|
1797
1818
|
for (const key of allKeys) {
|
|
@@ -1925,8 +1946,7 @@ function createActionRouter(options) {
|
|
|
1925
1946
|
);
|
|
1926
1947
|
const tempDir = req._jayTempDir;
|
|
1927
1948
|
const cleanup = () => {
|
|
1928
|
-
if (tempDir)
|
|
1929
|
-
cleanupTempDir(tempDir);
|
|
1949
|
+
if (tempDir) cleanupTempDir(tempDir);
|
|
1930
1950
|
};
|
|
1931
1951
|
if (registry.isStreaming(actionName)) {
|
|
1932
1952
|
res.setHeader("Content-Type", "application/x-ndjson");
|
|
@@ -1990,8 +2010,7 @@ function getStatusCodeForError(code, isActionError) {
|
|
|
1990
2010
|
function mergeDottedMultipartKeys(body) {
|
|
1991
2011
|
const keys = Object.keys(body);
|
|
1992
2012
|
for (const key of keys) {
|
|
1993
|
-
if (!key.includes("."))
|
|
1994
|
-
continue;
|
|
2013
|
+
if (!key.includes(".")) continue;
|
|
1995
2014
|
const val = body[key];
|
|
1996
2015
|
delete body[key];
|
|
1997
2016
|
const parts = key.split(".");
|
|
@@ -2019,8 +2038,7 @@ function parseMultipart(req, tempDir) {
|
|
|
2019
2038
|
headers: req.headers
|
|
2020
2039
|
});
|
|
2021
2040
|
bb.on("file", (fieldname, stream, info) => {
|
|
2022
|
-
if (errored)
|
|
2023
|
-
return;
|
|
2041
|
+
if (errored) return;
|
|
2024
2042
|
fileCount++;
|
|
2025
2043
|
const filename = info.filename || `upload-${fileCount}`;
|
|
2026
2044
|
const tempPath = path$1.join(tempDir, `${fileCount}-${filename}`);
|
|
@@ -2055,8 +2073,7 @@ function parseMultipart(req, tempDir) {
|
|
|
2055
2073
|
);
|
|
2056
2074
|
});
|
|
2057
2075
|
bb.on("field", (fieldname, value) => {
|
|
2058
|
-
if (errored)
|
|
2059
|
-
return;
|
|
2076
|
+
if (errored) return;
|
|
2060
2077
|
if (fieldname === "_json") {
|
|
2061
2078
|
try {
|
|
2062
2079
|
jsonData = JSON.parse(value);
|
|
@@ -2067,8 +2084,7 @@ function parseMultipart(req, tempDir) {
|
|
|
2067
2084
|
}
|
|
2068
2085
|
});
|
|
2069
2086
|
bb.on("close", () => {
|
|
2070
|
-
if (errored)
|
|
2071
|
-
return;
|
|
2087
|
+
if (errored) return;
|
|
2072
2088
|
Promise.all(pendingWrites).then(() => {
|
|
2073
2089
|
const body = { ...jsonData, ...files };
|
|
2074
2090
|
mergeDottedMultipartKeys(body);
|
|
@@ -2192,8 +2208,7 @@ class FreezeStore {
|
|
|
2192
2208
|
const files = await fs.readdir(this.dir);
|
|
2193
2209
|
const entries = [];
|
|
2194
2210
|
for (const file of files) {
|
|
2195
|
-
if (!file.endsWith(".json"))
|
|
2196
|
-
continue;
|
|
2211
|
+
if (!file.endsWith(".json")) continue;
|
|
2197
2212
|
try {
|
|
2198
2213
|
const content = await fs.readFile(path.join(this.dir, file), "utf-8");
|
|
2199
2214
|
const entry = JSON.parse(content);
|
|
@@ -2212,8 +2227,7 @@ class FreezeStore {
|
|
|
2212
2227
|
}
|
|
2213
2228
|
async rename(id, name) {
|
|
2214
2229
|
const entry = await this.get(id);
|
|
2215
|
-
if (!entry)
|
|
2216
|
-
return false;
|
|
2230
|
+
if (!entry) return false;
|
|
2217
2231
|
entry.name = name;
|
|
2218
2232
|
await fs.writeFile(
|
|
2219
2233
|
path.join(this.dir, `${id}.json`),
|
|
@@ -2313,8 +2327,7 @@ async function scanPluginRoutes(projectRoot, projectRoutes) {
|
|
|
2313
2327
|
const projectPaths = new Set(projectRoutes.map((r) => r.rawRoute));
|
|
2314
2328
|
const pluginRoutes = [];
|
|
2315
2329
|
for (const [, plugin] of plugins) {
|
|
2316
|
-
if (!plugin.manifest.routes)
|
|
2317
|
-
continue;
|
|
2330
|
+
if (!plugin.manifest.routes) continue;
|
|
2318
2331
|
for (const route of plugin.manifest.routes) {
|
|
2319
2332
|
if (projectPaths.has(route.path)) {
|
|
2320
2333
|
getLogger().info(
|
|
@@ -2381,8 +2394,7 @@ function resolvePluginModule(plugin) {
|
|
|
2381
2394
|
const mainPath = typeof mainExport === "string" ? mainExport : mainExport?.default || mainExport?.import || pkg.main;
|
|
2382
2395
|
if (mainPath) {
|
|
2383
2396
|
const resolved = path__default.join(plugin.pluginPath, mainPath);
|
|
2384
|
-
if (fsSync__default.existsSync(resolved))
|
|
2385
|
-
return resolved;
|
|
2397
|
+
if (fsSync__default.existsSync(resolved)) return resolved;
|
|
2386
2398
|
}
|
|
2387
2399
|
} catch {
|
|
2388
2400
|
}
|
|
@@ -2435,8 +2447,7 @@ function handleOtherResponseCodes(res, renderedResult) {
|
|
|
2435
2447
|
res.status(renderedResult.status).end("server error");
|
|
2436
2448
|
else if (renderedResult.kind === `ClientError`)
|
|
2437
2449
|
res.status(renderedResult.status).end("client error");
|
|
2438
|
-
else
|
|
2439
|
-
res.status(renderedResult.status).end("redirect to " + renderedResult.location);
|
|
2450
|
+
else res.status(renderedResult.status).end("redirect to " + renderedResult.location);
|
|
2440
2451
|
}
|
|
2441
2452
|
function filterPluginsForPage(allPluginClientInits, allPluginsWithInit, usedPackages) {
|
|
2442
2453
|
const pluginsByPackage = /* @__PURE__ */ new Map();
|
|
@@ -2453,8 +2464,7 @@ function filterPluginsForPage(allPluginClientInits, allPluginsWithInit, usedPack
|
|
|
2453
2464
|
while (toProcess.length > 0) {
|
|
2454
2465
|
const packageName = toProcess.pop();
|
|
2455
2466
|
const plugin = pluginsByPackage.get(packageName);
|
|
2456
|
-
if (!plugin)
|
|
2457
|
-
continue;
|
|
2467
|
+
if (!plugin) continue;
|
|
2458
2468
|
for (const dep of plugin.dependencies) {
|
|
2459
2469
|
if (pluginsByPackage.has(dep) && !expandedPackages.has(dep)) {
|
|
2460
2470
|
expandedPackages.add(dep);
|
|
@@ -2590,6 +2600,11 @@ async function handleCachedRequest(vite, route, options, cachedEntry, pageParams
|
|
|
2590
2600
|
timing?.end();
|
|
2591
2601
|
return;
|
|
2592
2602
|
}
|
|
2603
|
+
if (pagePartsResult.validations.length > 0) {
|
|
2604
|
+
for (const v of pagePartsResult.validations) {
|
|
2605
|
+
getLogger().warn(v);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2593
2608
|
const {
|
|
2594
2609
|
parts: pageParts,
|
|
2595
2610
|
clientTrackByMap,
|
|
@@ -2680,6 +2695,11 @@ async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRen
|
|
|
2680
2695
|
timing?.end();
|
|
2681
2696
|
return;
|
|
2682
2697
|
}
|
|
2698
|
+
if (initialPartsResult.validations.length > 0) {
|
|
2699
|
+
for (const v of initialPartsResult.validations) {
|
|
2700
|
+
getLogger().warn(v);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2683
2703
|
const { linkedCssFiles: initCss, linkedComponentFiles: initComps } = initialPartsResult.val;
|
|
2684
2704
|
_watchLinkedFiles([...initCss || [], ...initComps || []], route);
|
|
2685
2705
|
const slowStart = Date.now();
|
|
@@ -2771,6 +2791,11 @@ async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pagePa
|
|
|
2771
2791
|
timing?.end();
|
|
2772
2792
|
return;
|
|
2773
2793
|
}
|
|
2794
|
+
if (pagePartsResult.validations.length > 0) {
|
|
2795
|
+
for (const v of pagePartsResult.validations) {
|
|
2796
|
+
getLogger().warn(v);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2774
2799
|
const {
|
|
2775
2800
|
parts: pageParts,
|
|
2776
2801
|
serverTrackByMap,
|
|
@@ -2995,8 +3020,7 @@ async function preRenderJayHtml(route, slowViewState, headlessContracts, headles
|
|
|
2995
3020
|
try {
|
|
2996
3021
|
const contractContent = await fs__default.readFile(contractPath, "utf-8");
|
|
2997
3022
|
const parseResult = parseContract(contractContent, path__default.basename(contractPath));
|
|
2998
|
-
if (parseResult.val)
|
|
2999
|
-
contract = parseResult.val;
|
|
3023
|
+
if (parseResult.val) contract = parseResult.val;
|
|
3000
3024
|
} catch {
|
|
3001
3025
|
}
|
|
3002
3026
|
const result = slowRenderTransform({
|
|
@@ -3094,8 +3118,7 @@ async function mkDevServer(rawOptions) {
|
|
|
3094
3118
|
try {
|
|
3095
3119
|
const entries = await fs__default.readdir(buildFolder).catch(() => []);
|
|
3096
3120
|
for (const entry of entries) {
|
|
3097
|
-
if (entry === "freezes")
|
|
3098
|
-
continue;
|
|
3121
|
+
if (entry === "freezes") continue;
|
|
3099
3122
|
await fs__default.rm(path__default.join(buildFolder, entry), { recursive: true, force: true });
|
|
3100
3123
|
}
|
|
3101
3124
|
} catch {
|
|
@@ -3169,8 +3192,7 @@ async function mkDevServer(rawOptions) {
|
|
|
3169
3192
|
const existingRawRoutes = new Set(devServerRoutes.map((r) => r.fsRoute.rawRoute));
|
|
3170
3193
|
const added = [];
|
|
3171
3194
|
for (const jayRoute of scannedJayRoutes) {
|
|
3172
|
-
if (existingRawRoutes.has(jayRoute.rawRoute))
|
|
3173
|
-
continue;
|
|
3195
|
+
if (existingRawRoutes.has(jayRoute.rawRoute)) continue;
|
|
3174
3196
|
const devRoute = mkRoute(
|
|
3175
3197
|
jayRoute,
|
|
3176
3198
|
vite,
|
|
@@ -3287,8 +3309,7 @@ function getRoutePrefix(jayHtmlPath, pagesRootFolder) {
|
|
|
3287
3309
|
const segments = rel.split(path__default.sep).filter(Boolean);
|
|
3288
3310
|
const staticSegments = [];
|
|
3289
3311
|
for (const seg of segments) {
|
|
3290
|
-
if (seg.startsWith("["))
|
|
3291
|
-
break;
|
|
3312
|
+
if (seg.startsWith("[")) break;
|
|
3292
3313
|
staticSegments.push(seg);
|
|
3293
3314
|
}
|
|
3294
3315
|
return "/" + staticSegments.join("/");
|
|
@@ -3313,8 +3334,7 @@ function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectR
|
|
|
3313
3334
|
getLogger().info(`[SlowRender] Watching: ${file}`);
|
|
3314
3335
|
}
|
|
3315
3336
|
if (routePrefix) {
|
|
3316
|
-
if (!fileToRoutes.has(file))
|
|
3317
|
-
fileToRoutes.set(file, /* @__PURE__ */ new Set());
|
|
3337
|
+
if (!fileToRoutes.has(file)) fileToRoutes.set(file, /* @__PURE__ */ new Set());
|
|
3318
3338
|
fileToRoutes.get(file).add(routePrefix);
|
|
3319
3339
|
}
|
|
3320
3340
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,23 +23,23 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@jay-framework/compiler-jay-stack": "^0.
|
|
27
|
-
"@jay-framework/compiler-shared": "^0.
|
|
28
|
-
"@jay-framework/component": "^0.
|
|
29
|
-
"@jay-framework/fullstack-component": "^0.
|
|
30
|
-
"@jay-framework/logger": "^0.
|
|
31
|
-
"@jay-framework/runtime": "^0.
|
|
32
|
-
"@jay-framework/stack-client-runtime": "^0.
|
|
33
|
-
"@jay-framework/stack-route-scanner": "^0.
|
|
34
|
-
"@jay-framework/stack-server-runtime": "^0.
|
|
35
|
-
"@jay-framework/view-state-merge": "^0.
|
|
26
|
+
"@jay-framework/compiler-jay-stack": "^0.24.0",
|
|
27
|
+
"@jay-framework/compiler-shared": "^0.24.0",
|
|
28
|
+
"@jay-framework/component": "^0.24.0",
|
|
29
|
+
"@jay-framework/fullstack-component": "^0.24.0",
|
|
30
|
+
"@jay-framework/logger": "^0.24.0",
|
|
31
|
+
"@jay-framework/runtime": "^0.24.0",
|
|
32
|
+
"@jay-framework/stack-client-runtime": "^0.24.0",
|
|
33
|
+
"@jay-framework/stack-route-scanner": "^0.24.0",
|
|
34
|
+
"@jay-framework/stack-server-runtime": "^0.24.0",
|
|
35
|
+
"@jay-framework/view-state-merge": "^0.24.0",
|
|
36
36
|
"busboy": "^1.6.0",
|
|
37
37
|
"vite": "^5.0.11"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@jay-framework/dev-environment": "^0.
|
|
41
|
-
"@jay-framework/jay-cli": "^0.
|
|
42
|
-
"@jay-framework/stack-client-runtime": "^0.
|
|
40
|
+
"@jay-framework/dev-environment": "^0.24.0",
|
|
41
|
+
"@jay-framework/jay-cli": "^0.24.0",
|
|
42
|
+
"@jay-framework/stack-client-runtime": "^0.24.0",
|
|
43
43
|
"@playwright/test": "^1.58.2",
|
|
44
44
|
"@types/busboy": "^1.5.4",
|
|
45
45
|
"@types/express": "^5.0.2",
|