@primate/core 0.9.7 → 0.9.9

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.
@@ -93,8 +93,15 @@ export default async function build_client(app) {
93
93
  const NO_HR = app.config("livereload.exclude") ?? [];
94
94
  app.entrypoint(`
95
95
  const NO_HR = ${JSON.stringify(NO_HR)};
96
- new EventSource("/esbuild").addEventListener("change", () => {
97
- if (!NO_HR.includes(location.pathname)) location.reload();
96
+ const live_reload = new EventSource("/esbuild");
97
+ const close_live_reload = () => live_reload.close();
98
+ addEventListener("pagehide", close_live_reload);
99
+ addEventListener("beforeunload", close_live_reload);
100
+ live_reload.addEventListener("change", () => {
101
+ if (!NO_HR.includes(location.pathname)) {
102
+ close_live_reload();
103
+ location.reload();
104
+ }
98
105
  });
99
106
  `);
100
107
  }
@@ -3,8 +3,12 @@ import root from "#client/root";
3
3
  import storage from "#client/storage";
4
4
  import submit from "#client/submit";
5
5
  import http from "@rcompat/http";
6
+ let booted = false;
6
7
  export default (frontend, u) => {
7
8
  root.set(u, frontend);
9
+ if (booted)
10
+ return;
11
+ booted = true;
8
12
  const { location, history } = globalThis;
9
13
  if (document.contentType === "application/json") {
10
14
  location.reload();
@@ -1,7 +1,14 @@
1
1
  import location from "#location";
2
2
  import http from "@rcompat/http";
3
3
  const sse_reload = `<script>
4
- new EventSource("/esbuild").addEventListener("change", () => location.reload());
4
+ const live_reload = new EventSource("/esbuild");
5
+ const close_live_reload = () => live_reload.close();
6
+ addEventListener("pagehide", close_live_reload);
7
+ addEventListener("beforeunload", close_live_reload);
8
+ live_reload.addEventListener("change", () => {
9
+ close_live_reload();
10
+ location.reload();
11
+ });
5
12
  </script>`;
6
13
  /**
7
14
  * Render an error page.
@@ -97,6 +97,7 @@ type ReadSort = Dict<"asc" | "desc">;
97
97
  export default class Store<T extends StoreInput, N extends string = string> implements Serializable {
98
98
  #private;
99
99
  [brand]: boolean;
100
+ readonly Insert: Insertable<T>;
100
101
  readonly Schema: Schema<T>;
101
102
  static is(x: unknown): x is Store<any, any>;
102
103
  constructor(init: Init<T, N>);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",