@jay-framework/stack-server-runtime 0.15.4 → 0.15.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 +30 -8
  2. package/package.json +13 -13
package/dist/index.js CHANGED
@@ -15,10 +15,10 @@ import { parseJayFile, JAY_IMPORT_RESOLVER, generateServerElementFile, discoverH
15
15
  import fs$2 from "node:fs/promises";
16
16
  import * as path from "node:path";
17
17
  import path__default from "node:path";
18
+ import crypto from "node:crypto";
18
19
  import { getLogger } from "@jay-framework/logger";
19
20
  import * as fs from "node:fs";
20
21
  import { createRequire as createRequire$1 } from "node:module";
21
- import crypto from "node:crypto";
22
22
  const serviceRegistry = /* @__PURE__ */ new Map();
23
23
  function registerService(marker, service) {
24
24
  serviceRegistry.set(marker, service);
@@ -203,7 +203,7 @@ new JayObjectType("Error", {
203
203
  stack: new JayAtomicType("string")
204
204
  });
205
205
  function isOptionalType(aType) {
206
- return aType.kind === 13;
206
+ return aType.kind === 14;
207
207
  }
208
208
  function isAtomicType(aType) {
209
209
  return aType.kind === 0;
@@ -220,6 +220,9 @@ function isObjectType(aType) {
220
220
  function isArrayType(aType) {
221
221
  return aType.kind === 9;
222
222
  }
223
+ function isRecordType(aType) {
224
+ return aType.kind === 11;
225
+ }
223
226
  function jayTypeToJsonSchema(type) {
224
227
  if (isOptionalType(type)) {
225
228
  return jayTypeToJsonSchema(type.innerType);
@@ -244,6 +247,13 @@ function jayTypeToJsonSchema(type) {
244
247
  }
245
248
  return { type: "array" };
246
249
  }
250
+ if (isRecordType(type)) {
251
+ const valueSchema = jayTypeToJsonSchema(type.itemType);
252
+ if (valueSchema) {
253
+ return { type: "object", additionalProperties: valueSchema };
254
+ }
255
+ return { type: "object" };
256
+ }
247
257
  if (isObjectType(type)) {
248
258
  const properties = {};
249
259
  const required = [];
@@ -717,10 +727,8 @@ async function generateSSRPageHtml(vite, jayHtmlContent, jayHtmlFilename, jayHtm
717
727
  const attrs = Object.entries(link.attributes).map(([k, v]) => ` ${k}="${v}"`).join("");
718
728
  return ` <link rel="${link.rel}" href="${link.href}"${attrs} />`;
719
729
  }).join("\n");
720
- const inlineCss = cached.css ? ` <style>
721
- ${cached.css}
722
- </style>` : "";
723
- const headExtras = [headLinksHtml, inlineCss].filter((_) => _).join("\n");
730
+ const cssLink = cached.cssHref ? ` <link rel="stylesheet" href="${cached.cssHref}" />` : "";
731
+ const headExtras = [headLinksHtml, cssLink].filter((_) => _).join("\n");
724
732
  return `<!doctype html>
725
733
  <html lang="en">
726
734
  <head>
@@ -778,10 +786,24 @@ async function compileAndLoadServerElement(vite, jayHtmlContent, jayHtmlFilename
778
786
  vite.moduleGraph.invalidateModule(existingModule);
779
787
  }
780
788
  const serverModule = await vite.ssrLoadModule(serverElementPath);
789
+ let cssHref;
790
+ if (parsedJayFile.css) {
791
+ const cssFilename = jayHtmlFilename.replace(".jay-html", ".css");
792
+ const cssPath = path__default.join(serverElementDir, cssFilename);
793
+ await fs$2.writeFile(cssPath, parsedJayFile.css, "utf-8");
794
+ const cssModules = vite.moduleGraph.getModulesByFile(cssPath);
795
+ if (cssModules) {
796
+ for (const mod of cssModules) {
797
+ vite.moduleGraph.invalidateModule(mod);
798
+ }
799
+ }
800
+ const hash = crypto.createHash("md5").update(parsedJayFile.css).digest("hex").slice(0, 8);
801
+ cssHref = "/@fs" + cssPath + "?v=" + hash + "&direct";
802
+ }
781
803
  return {
782
804
  renderToStream: serverModule.renderToStream,
783
805
  headLinks: parsedJayFile.headLinks,
784
- css: parsedJayFile.css
806
+ cssHref
785
807
  };
786
808
  }
787
809
  function generateHydrationScript(defaultViewState, fastCarryForward, parts, jayHtmlPath, trackByMap = {}, clientInitData2 = {}, projectInit, pluginInits = [], options = {}, asyncOutcomes = []) {
@@ -1957,7 +1979,7 @@ class SlowRenderCache {
1957
1979
  try {
1958
1980
  const files = await fs$2.readdir(cacheSubDir);
1959
1981
  for (const file of files) {
1960
- if (file.startsWith(basename) && file.endsWith(".jay-html")) {
1982
+ if (file.startsWith(basename)) {
1961
1983
  try {
1962
1984
  await fs$2.unlink(path__default.join(cacheSubDir, file));
1963
1985
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/stack-server-runtime",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.mts",
@@ -26,21 +26,21 @@
26
26
  "test:watch": "vitest"
27
27
  },
28
28
  "dependencies": {
29
- "@jay-framework/compiler-jay-html": "^0.15.4",
30
- "@jay-framework/compiler-shared": "^0.15.4",
31
- "@jay-framework/component": "^0.15.4",
32
- "@jay-framework/fullstack-component": "^0.15.4",
33
- "@jay-framework/logger": "^0.15.4",
34
- "@jay-framework/runtime": "^0.15.4",
35
- "@jay-framework/ssr-runtime": "^0.15.4",
36
- "@jay-framework/stack-route-scanner": "^0.15.4",
37
- "@jay-framework/view-state-merge": "^0.15.4",
29
+ "@jay-framework/compiler-jay-html": "^0.15.5",
30
+ "@jay-framework/compiler-shared": "^0.15.5",
31
+ "@jay-framework/component": "^0.15.5",
32
+ "@jay-framework/fullstack-component": "^0.15.5",
33
+ "@jay-framework/logger": "^0.15.5",
34
+ "@jay-framework/runtime": "^0.15.5",
35
+ "@jay-framework/ssr-runtime": "^0.15.5",
36
+ "@jay-framework/stack-route-scanner": "^0.15.5",
37
+ "@jay-framework/view-state-merge": "^0.15.5",
38
38
  "yaml": "^2.3.4"
39
39
  },
40
40
  "devDependencies": {
41
- "@jay-framework/dev-environment": "^0.15.4",
42
- "@jay-framework/jay-cli": "^0.15.4",
43
- "@jay-framework/stack-client-runtime": "^0.15.4",
41
+ "@jay-framework/dev-environment": "^0.15.5",
42
+ "@jay-framework/jay-cli": "^0.15.5",
43
+ "@jay-framework/stack-client-runtime": "^0.15.5",
44
44
  "@types/express": "^5.0.2",
45
45
  "@types/node": "^22.15.21",
46
46
  "nodemon": "^3.0.3",