@primate/core 0.9.13 → 0.9.15

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,4 +1,5 @@
1
1
  import E from "#errors";
2
+ import html_safe_json from "#html-safe-json";
2
3
  import inline from "#inline";
3
4
  import location from "#location";
4
5
  import hash from "@rcompat/crypto/hash";
@@ -58,7 +59,7 @@ export default function frontend_module(init) {
58
59
  if (app_asset === undefined)
59
60
  throw E.frontend_missing_app_js();
60
61
  const app_script = `<script type="module" src="${app_asset.src}"></script>`;
61
- const props = JSON.stringify(client);
62
+ const props = html_safe_json(client);
62
63
  const hydrated = await inline(props, http.MIME.APPLICATION_JSON, "hydration");
63
64
  const script_src = [hydrated.integrity];
64
65
  return {
@@ -0,0 +1,2 @@
1
+ export default function html_safe_json(value: unknown): string;
2
+ //# sourceMappingURL=html-safe-json.d.ts.map
@@ -0,0 +1,12 @@
1
+ const unsafe = /[<>&\u2028\u2029]/g;
2
+ const escapes = {
3
+ "<": "\\u003c",
4
+ ">": "\\u003e",
5
+ "&": "\\u0026",
6
+ "\u2028": "\\u2028",
7
+ "\u2029": "\\u2029",
8
+ };
9
+ export default function html_safe_json(value) {
10
+ return JSON.stringify(value).replace(unsafe, char => escapes[char]);
11
+ }
12
+ //# sourceMappingURL=html-safe-json.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.9.13",
3
+ "version": "0.9.15",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",