@jay-framework/dev-server 0.16.3 → 0.16.5

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.
Files changed (2) hide show
  1. package/dist/index.js +53 -11
  2. package/package.json +14 -14
package/dist/index.js CHANGED
@@ -1880,6 +1880,26 @@ function getStatusCodeForError(code, isActionError) {
1880
1880
  }
1881
1881
  const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
1882
1882
  const DEFAULT_MAX_FILES = 10;
1883
+ function mergeDottedMultipartKeys(body) {
1884
+ const keys = Object.keys(body);
1885
+ for (const key of keys) {
1886
+ if (!key.includes("."))
1887
+ continue;
1888
+ const val = body[key];
1889
+ delete body[key];
1890
+ const parts = key.split(".");
1891
+ let cur = body;
1892
+ for (let i = 0; i < parts.length - 1; i++) {
1893
+ const p = parts[i];
1894
+ const next = cur[p];
1895
+ if (typeof next !== "object" || next === null || Array.isArray(next)) {
1896
+ cur[p] = {};
1897
+ }
1898
+ cur = cur[p];
1899
+ }
1900
+ cur[parts[parts.length - 1]] = val;
1901
+ }
1902
+ }
1883
1903
  function parseMultipart(req, tempDir, maxFileSize, maxFiles) {
1884
1904
  return new Promise((resolve, reject) => {
1885
1905
  fs$1.mkdirSync(tempDir, { recursive: true });
@@ -1958,7 +1978,11 @@ function parseMultipart(req, tempDir, maxFileSize, maxFiles) {
1958
1978
  bb.on("close", () => {
1959
1979
  if (errored)
1960
1980
  return;
1961
- Promise.all(pendingWrites).then(() => resolve({ body: { ...jsonData, ...files }, tempDir })).catch((err) => reject(err));
1981
+ Promise.all(pendingWrites).then(() => {
1982
+ const body = { ...jsonData, ...files };
1983
+ mergeDottedMultipartKeys(body);
1984
+ resolve({ body, tempDir });
1985
+ }).catch((err) => reject(err));
1962
1986
  });
1963
1987
  bb.on("error", (err) => {
1964
1988
  if (!errored) {
@@ -2450,7 +2474,7 @@ async function handleCachedRequest(vite, route, options, cachedEntry, pageParams
2450
2474
  linkedCssFiles,
2451
2475
  linkedComponentFiles
2452
2476
  } = pagePartsResult.val;
2453
- _watchLinkedFiles([...linkedCssFiles || [], ...linkedComponentFiles || []]);
2477
+ _watchLinkedFiles([...linkedCssFiles || [], ...linkedComponentFiles || []], route);
2454
2478
  const pluginsForPage = filterPluginsForPage(
2455
2479
  allPluginClientInits,
2456
2480
  allPluginsWithInit,
@@ -2518,7 +2542,7 @@ async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRen
2518
2542
  return;
2519
2543
  }
2520
2544
  const { linkedCssFiles: initCss, linkedComponentFiles: initComps } = initialPartsResult.val;
2521
- _watchLinkedFiles([...initCss || [], ...initComps || []]);
2545
+ _watchLinkedFiles([...initCss || [], ...initComps || []], route);
2522
2546
  const slowStart = Date.now();
2523
2547
  const renderedSlowly = await slowlyPhase.runSlowlyForPage(
2524
2548
  pageParams,
@@ -2616,7 +2640,7 @@ async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pagePa
2616
2640
  linkedCssFiles,
2617
2641
  linkedComponentFiles
2618
2642
  } = pagePartsResult.val;
2619
- _watchLinkedFiles([...linkedCssFiles || [], ...linkedComponentFiles || []]);
2643
+ _watchLinkedFiles([...linkedCssFiles || [], ...linkedComponentFiles || []], route);
2620
2644
  const pluginsForPage = filterPluginsForPage(
2621
2645
  allPluginClientInits,
2622
2646
  allPluginsWithInit,
@@ -3117,13 +3141,20 @@ function sendPageReload(vite, jayHtmlPath, pagesRootFolder) {
3117
3141
  }
3118
3142
  function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectRootFolder) {
3119
3143
  const watchedFiles = /* @__PURE__ */ new Set();
3120
- const watchLinkedFiles = (files) => {
3144
+ const fileToRoutes = /* @__PURE__ */ new Map();
3145
+ const watchLinkedFiles = (files, route) => {
3146
+ const routePrefix = route ? getRoutePrefix(route.jayHtmlPath, pagesRootFolder) : void 0;
3121
3147
  for (const file of files) {
3122
- if (watchedFiles.has(file))
3123
- continue;
3124
- watchedFiles.add(file);
3125
- vite.watcher.add(file);
3126
- getLogger().info(`[SlowRender] Watching: ${file}`);
3148
+ if (!watchedFiles.has(file)) {
3149
+ watchedFiles.add(file);
3150
+ vite.watcher.add(file);
3151
+ getLogger().info(`[SlowRender] Watching: ${file}`);
3152
+ }
3153
+ if (routePrefix) {
3154
+ if (!fileToRoutes.has(file))
3155
+ fileToRoutes.set(file, /* @__PURE__ */ new Set());
3156
+ fileToRoutes.get(file).add(routePrefix);
3157
+ }
3127
3158
  }
3128
3159
  };
3129
3160
  vite.watcher.on("change", (changedPath) => {
@@ -3133,7 +3164,18 @@ function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectR
3133
3164
  getLogger().info(
3134
3165
  `[SlowRender] Cache cleared (linked file changed: ${changedPath})`
3135
3166
  );
3136
- vite.ws.send({ type: "full-reload" });
3167
+ const routes = fileToRoutes.get(changedPath);
3168
+ if (routes && routes.size > 0) {
3169
+ for (const routePrefix of routes) {
3170
+ vite.ws.send({
3171
+ type: "custom",
3172
+ event: "jay:page-reload",
3173
+ data: { routePrefix }
3174
+ });
3175
+ }
3176
+ } else {
3177
+ vite.ws.send({ type: "full-reload" });
3178
+ }
3137
3179
  });
3138
3180
  return;
3139
3181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/dev-server",
3
- "version": "0.16.3",
3
+ "version": "0.16.5",
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.16.3",
27
- "@jay-framework/compiler-shared": "^0.16.3",
28
- "@jay-framework/component": "^0.16.3",
29
- "@jay-framework/fullstack-component": "^0.16.3",
30
- "@jay-framework/logger": "^0.16.3",
31
- "@jay-framework/runtime": "^0.16.3",
32
- "@jay-framework/stack-client-runtime": "^0.16.3",
33
- "@jay-framework/stack-route-scanner": "^0.16.3",
34
- "@jay-framework/stack-server-runtime": "^0.16.3",
35
- "@jay-framework/view-state-merge": "^0.16.3",
26
+ "@jay-framework/compiler-jay-stack": "^0.16.5",
27
+ "@jay-framework/compiler-shared": "^0.16.5",
28
+ "@jay-framework/component": "^0.16.5",
29
+ "@jay-framework/fullstack-component": "^0.16.5",
30
+ "@jay-framework/logger": "^0.16.5",
31
+ "@jay-framework/runtime": "^0.16.5",
32
+ "@jay-framework/stack-client-runtime": "^0.16.5",
33
+ "@jay-framework/stack-route-scanner": "^0.16.5",
34
+ "@jay-framework/stack-server-runtime": "^0.16.5",
35
+ "@jay-framework/view-state-merge": "^0.16.5",
36
36
  "busboy": "^1.6.0",
37
37
  "vite": "^5.0.11"
38
38
  },
39
39
  "devDependencies": {
40
- "@jay-framework/dev-environment": "^0.16.3",
41
- "@jay-framework/jay-cli": "^0.16.3",
42
- "@jay-framework/stack-client-runtime": "^0.16.3",
40
+ "@jay-framework/dev-environment": "^0.16.5",
41
+ "@jay-framework/jay-cli": "^0.16.5",
42
+ "@jay-framework/stack-client-runtime": "^0.16.5",
43
43
  "@playwright/test": "^1.58.2",
44
44
  "@types/busboy": "^1.5.4",
45
45
  "@types/express": "^5.0.2",