sveltekit-cache-first 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -11,7 +11,7 @@ npm install sveltekit-cache-first
11
11
  ```js
12
12
  // src/service-worker.js
13
13
  import { version, build, files } from '$service-worker';
14
- import { setupServiceWorker } from 'sveltekit-cache-first';
14
+ import { setupServiceWorker } from 'sveltekit-cache-first/sw';
15
15
 
16
16
  setupServiceWorker(self, { version, build, files });
17
17
  ```
@@ -29,6 +29,12 @@ setupServiceWorker(self, { version, build, files });
29
29
  <button onclick={() => accept()}>Refresh</button>
30
30
  {/snippet}
31
31
  </UpdateAvailable>
32
+
33
+ <!-- Optional -->
34
+ <!-- Note: This will disappear after the update has been detected, which may take a few seconds to appear. Only use this if your app must always be running the latest version. And if that is that is the case, strongly consider if cache-first is the right approach, or use other methods like api versioning. -->
35
+ <NoUpdate>
36
+ Main logic here
37
+ </NoUpdate>
32
38
  ```
33
39
 
34
40
  #### Custom handler method, using [svelte-sonner](https://github.com/wobsoriano/svelte-sonner)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { setupServiceWorker } from "./sw.ts";
2
1
  import UpdateAvailable from "./update-available.svelte";
3
2
  import { onUpdate } from "./update.ts";
4
- export { setupServiceWorker, onUpdate, UpdateAvailable };
3
+ import NoUpdate from "./no-update.svelte";
4
+ export { onUpdate, UpdateAvailable, NoUpdate };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Reexport your entry components here
2
- import { setupServiceWorker } from "./sw.js";
3
2
  import UpdateAvailable from "./update-available.svelte";
4
3
  import { onUpdate } from "./update.js";
5
- export { setupServiceWorker, onUpdate, UpdateAvailable };
4
+ import NoUpdate from "./no-update.svelte";
5
+ export { onUpdate, UpdateAvailable, NoUpdate };
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ import { onMount, type Snippet } from 'svelte';
3
+ import { onUpdate } from './update.js';
4
+
5
+ let { children }: { children?: Snippet } = $props();
6
+
7
+ let updateAvailable = $state(false);
8
+ onMount(() => {
9
+ onUpdate(() => {
10
+ updateAvailable = true;
11
+ });
12
+ });
13
+ </script>
14
+
15
+ {#if !updateAvailable}
16
+ {@render children?.()}
17
+ {/if}
@@ -0,0 +1,7 @@
1
+ import { type Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children?: Snippet;
4
+ };
5
+ declare const NoUpdate: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type NoUpdate = ReturnType<typeof NoUpdate>;
7
+ export default NoUpdate;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "sveltekit-cache-first",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "repository": "github:isaxk/sveltekit-cache-first",
5
+ "license": "MIT",
5
6
  "scripts": {
6
7
  "dev": "vite dev",
7
8
  "build": "vite build && npm run prepack",