@jay-framework/dev-server 0.22.1 → 0.23.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.d.ts CHANGED
@@ -140,6 +140,8 @@ interface RouteInfo {
140
140
  path: string;
141
141
  jayHtmlPath: string;
142
142
  compPath: string;
143
+ /** Dev-server tooling route — consumers like AIditor may filter from page pickers. */
144
+ devOnly?: boolean;
143
145
  }
144
146
  type DevServerRouteRegistrar = (routes: DevServerRoute[]) => void;
145
147
  declare class DevServerService {
@@ -160,7 +162,7 @@ declare class DevServerService {
160
162
  * added since dev-server startup (e.g. after AIditor Add Page).
161
163
  */
162
164
  refreshRoutes(): Promise<RouteInfo[]>;
163
- /** List all page routes in the project. */
165
+ /** List all page routes in the project (includes dev-only plugin routes). */
164
166
  listRoutes(): RouteInfo[];
165
167
  /**
166
168
  * Run loadParams for a route, yielding param batches as an async generator.
package/dist/index.js CHANGED
@@ -616,7 +616,8 @@ const COMPONENT_SERVER_METHODS = /* @__PURE__ */ new Set([
616
616
  "withSlowlyRender",
617
617
  "withFastRender"
618
618
  ]);
619
- const COMPONENT_CLIENT_METHODS = /* @__PURE__ */ new Set(["withInteractive", "withContexts"]);
619
+ const COMPONENT_CLIENT_METHODS = /* @__PURE__ */ new Set(["withContexts"]);
620
+ const COMPONENT_CLIENT_REPLACE_METHODS = /* @__PURE__ */ new Map([["withInteractive", "withInteractiveMark"]]);
620
621
  const INIT_SERVER_METHODS = /* @__PURE__ */ new Set(["withServer"]);
621
622
  const INIT_CLIENT_METHODS = /* @__PURE__ */ new Set(["withClient"]);
622
623
  function shouldRemoveMethod(methodName, environment) {
@@ -630,14 +631,29 @@ function shouldRemoveMethod(methodName, environment) {
630
631
  return true;
631
632
  return false;
632
633
  }
634
+ function getReplacementMethod(methodName, environment) {
635
+ if (environment === "server")
636
+ return COMPONENT_CLIENT_REPLACE_METHODS.get(methodName);
637
+ return void 0;
638
+ }
633
639
  const { isCallExpression: isCallExpression$1, isPropertyAccessExpression: isPropertyAccessExpression$1, isIdentifier: isIdentifier$2, isStringLiteral: isStringLiteral$1 } = c$1;
634
640
  function findBuilderMethodsToRemove(sourceFile, bindingResolver, environment) {
635
641
  const callsToRemove = [];
636
642
  const removedVariables = /* @__PURE__ */ new Set();
643
+ const methodReplacements = [];
637
644
  const visit = (node) => {
638
645
  if (isCallExpression$1(node) && isPropertyAccessExpression$1(node.expression) && isPartOfJayStackChain(node, bindingResolver)) {
639
646
  const methodName = node.expression.name.text;
640
- if (shouldRemoveMethod(methodName, environment)) {
647
+ const replacementName = getReplacementMethod(methodName, environment);
648
+ if (replacementName) {
649
+ const nameNode = node.expression.name;
650
+ methodReplacements.push({
651
+ start: nameNode.getStart(),
652
+ end: nameNode.getEnd(),
653
+ replacement: replacementName
654
+ });
655
+ collectVariablesFromArguments(node.arguments, bindingResolver, removedVariables);
656
+ } else if (shouldRemoveMethod(methodName, environment)) {
641
657
  const variable = bindingResolver.explain(node.expression);
642
658
  const flattened = flattenVariable(variable);
643
659
  callsToRemove.push(flattened);
@@ -647,7 +663,7 @@ function findBuilderMethodsToRemove(sourceFile, bindingResolver, environment) {
647
663
  node.forEachChild(visit);
648
664
  };
649
665
  sourceFile.forEachChild(visit);
650
- return { callsToRemove, removedVariables };
666
+ return { callsToRemove, removedVariables, methodReplacements };
651
667
  }
652
668
  const JAY_BUILDER_FUNCTIONS = /* @__PURE__ */ new Set(["makeJayStackComponent", "makeJayInit"]);
653
669
  function isPartOfJayStackChain(callExpr, bindingResolver) {
@@ -828,11 +844,12 @@ function mkJayStackCodeSplitTransformer({
828
844
  workingSourceFile = factory.updateSourceFile(sourceFile, filtered);
829
845
  }
830
846
  }
831
- const { callsToRemove } = findBuilderMethodsToRemove(
847
+ const { callsToRemove, methodReplacements } = findBuilderMethodsToRemove(
832
848
  workingSourceFile,
833
849
  bindingResolver,
834
850
  environment
835
851
  );
852
+ const replacementPositions = new Map(methodReplacements.map((r) => [r.start, r]));
836
853
  const transformVisitor = (node) => {
837
854
  if (isCallExpression(node) && isPropertyAccessExpression(node.expression)) {
838
855
  const variable = bindingResolver.explain(node.expression);
@@ -841,6 +858,17 @@ function mkJayStackCodeSplitTransformer({
841
858
  const receiver = node.expression.expression;
842
859
  return transformVisitor(receiver);
843
860
  }
861
+ const nameNode = node.expression.name;
862
+ const repl = replacementPositions.get(nameNode.getStart());
863
+ if (repl) {
864
+ const newName = factory.createIdentifier(repl.replacement);
865
+ const newAccess = factory.updatePropertyAccessExpression(
866
+ node.expression,
867
+ visitEachChild(node.expression.expression, transformVisitor, context),
868
+ newName
869
+ );
870
+ return factory.updateCallExpression(node, newAccess, node.typeArguments, []);
871
+ }
844
872
  }
845
873
  return visitEachChild(node, transformVisitor, context);
846
874
  };
@@ -2239,12 +2267,13 @@ class DevServerService {
2239
2267
  }
2240
2268
  return this.listRoutes();
2241
2269
  }
2242
- /** List all page routes in the project. */
2270
+ /** List all page routes in the project (includes dev-only plugin routes). */
2243
2271
  listRoutes() {
2244
2272
  return this.routes.map((r) => ({
2245
2273
  path: r.path,
2246
2274
  jayHtmlPath: r.fsRoute.jayHtmlPath,
2247
- compPath: r.fsRoute.compPath
2275
+ compPath: r.fsRoute.compPath,
2276
+ ...r.fsRoute.devOnly && { devOnly: true }
2248
2277
  }));
2249
2278
  }
2250
2279
  /**
@@ -2303,8 +2332,14 @@ async function scanPluginRoutes(projectRoot, projectRoutes) {
2303
2332
  const isLocalComponent = route.component.startsWith(".");
2304
2333
  const compPath = isLocalComponent ? path__default.resolve(plugin.pluginPath, route.component) : resolvePluginModule(plugin);
2305
2334
  const componentExport = isLocalComponent ? void 0 : route.component;
2306
- pluginRoutes.push(createRoute(route.path, jayHtmlPath, compPath, componentExport));
2307
- getLogger().info(`[Routes] Plugin "${plugin.name}" provides route ${route.path}`);
2335
+ pluginRoutes.push(
2336
+ createRoute(route.path, jayHtmlPath, compPath, componentExport, {
2337
+ devOnly: route.devOnly === true
2338
+ })
2339
+ );
2340
+ getLogger().info(
2341
+ `[Routes] Plugin "${plugin.name}" provides route ${route.path}${route.devOnly ? " (dev-only)" : ""}`
2342
+ );
2308
2343
  }
2309
2344
  }
2310
2345
  return pluginRoutes;
@@ -2606,6 +2641,7 @@ async function handleCachedRequest(vite, route, options, cachedEntry, pageParams
2606
2641
  fastViewState,
2607
2642
  clientTrackByMap || {}
2608
2643
  );
2644
+ injectJayBindings(fullViewState, pageParams, url);
2609
2645
  await sendResponse(
2610
2646
  vite,
2611
2647
  res,
@@ -2803,6 +2839,7 @@ async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pagePa
2803
2839
  renderedFast.rendered,
2804
2840
  serverTrackByMap || {}
2805
2841
  );
2842
+ injectJayBindings(viewState, pageParams, url);
2806
2843
  const fastCF = renderedFast.carryForward;
2807
2844
  const pageHtml = await generateClientScript(
2808
2845
  viewState,
@@ -2886,6 +2923,11 @@ async function sendResponse(vite, res, url, jayHtmlPath, sourceJayHtmlPath, page
2886
2923
  await fs__default.mkdir(clientScriptDir, { recursive: true });
2887
2924
  await fs__default.writeFile(path__default.join(clientScriptDir, `${pageName}.html`), pageHtml, "utf-8");
2888
2925
  }
2926
+ for (const [id, mod] of vite.moduleGraph.idToModuleMap) {
2927
+ if (id.includes("html-proxy")) {
2928
+ vite.moduleGraph.invalidateModule(mod);
2929
+ }
2930
+ }
2889
2931
  const viteStart = Date.now();
2890
2932
  const compiledPageHtml = await vite.transformIndexHtml(!!url ? url : "/", pageHtml);
2891
2933
  timing?.recordViteClient(Date.now() - viteStart);
@@ -3230,6 +3272,13 @@ function setupFreezeEndpoint(vite, freezeStore) {
3230
3272
  });
3231
3273
  getLogger().info("[Freeze] Freeze endpoint mounted at /_jay/freeze");
3232
3274
  }
3275
+ function injectJayBindings(viewState, params, url) {
3276
+ const urlPath = url.split("?")[0];
3277
+ viewState.__jay = {
3278
+ params,
3279
+ url: { path: urlPath.startsWith("/") ? urlPath : "/" + urlPath }
3280
+ };
3281
+ }
3233
3282
  function getRouteDir(route) {
3234
3283
  return route.rawRoute.replace(/^\//, "") || "index";
3235
3284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/dev-server",
3
- "version": "0.22.1",
3
+ "version": "0.23.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.22.1",
27
- "@jay-framework/compiler-shared": "^0.22.1",
28
- "@jay-framework/component": "^0.22.1",
29
- "@jay-framework/fullstack-component": "^0.22.1",
30
- "@jay-framework/logger": "^0.22.1",
31
- "@jay-framework/runtime": "^0.22.1",
32
- "@jay-framework/stack-client-runtime": "^0.22.1",
33
- "@jay-framework/stack-route-scanner": "^0.22.1",
34
- "@jay-framework/stack-server-runtime": "^0.22.1",
35
- "@jay-framework/view-state-merge": "^0.22.1",
26
+ "@jay-framework/compiler-jay-stack": "^0.23.0",
27
+ "@jay-framework/compiler-shared": "^0.23.0",
28
+ "@jay-framework/component": "^0.23.0",
29
+ "@jay-framework/fullstack-component": "^0.23.0",
30
+ "@jay-framework/logger": "^0.23.0",
31
+ "@jay-framework/runtime": "^0.23.0",
32
+ "@jay-framework/stack-client-runtime": "^0.23.0",
33
+ "@jay-framework/stack-route-scanner": "^0.23.0",
34
+ "@jay-framework/stack-server-runtime": "^0.23.0",
35
+ "@jay-framework/view-state-merge": "^0.23.0",
36
36
  "busboy": "^1.6.0",
37
37
  "vite": "^5.0.11"
38
38
  },
39
39
  "devDependencies": {
40
- "@jay-framework/dev-environment": "^0.22.1",
41
- "@jay-framework/jay-cli": "^0.22.1",
42
- "@jay-framework/stack-client-runtime": "^0.22.1",
40
+ "@jay-framework/dev-environment": "^0.23.0",
41
+ "@jay-framework/jay-cli": "^0.23.0",
42
+ "@jay-framework/stack-client-runtime": "^0.23.0",
43
43
  "@playwright/test": "^1.58.2",
44
44
  "@types/busboy": "^1.5.4",
45
45
  "@types/express": "^5.0.2",