nuxt-tiff-provider 0.1.0 → 0.3.0

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
@@ -32,6 +32,8 @@ export default defineNuxtConfig({
32
32
  quality: 0.8, // default WebP quality 0..1
33
33
  scope: '/', // Service Worker scope
34
34
  autoRegister: true, // false → call registerTiffServiceWorker() yourself
35
+ retryRacedImages: true, // re-fetch images that raced the SW on first load
36
+ paramPrefix: 'tp', // query-param namespace + interception marker
35
37
  },
36
38
  })
37
39
  ```
@@ -39,6 +41,11 @@ export default defineNuxtConfig({
39
41
  ## Notes
40
42
 
41
43
  - Safari paints TIFF natively; the SW detects this and passes through.
44
+ - First cold visit: images requested before the SW took control are re-fetched
45
+ automatically once it does (disable with `retryRacedImages: false`).
42
46
  - Already run your own Service Worker? Set `autoRegister: false` and
43
47
  `importScripts('/tiff-sw.js')` inside it (see `@tiff-provider/core`).
44
- - Sources must be same-origin or CORS-readable.
48
+ - Sources must be same-origin or CORS-readable (cross-origin needs CORS headers).
49
+ - The SW intercepts by the `tp=1` marker the provider adds, not by file extension,
50
+ so extension-less sources (e.g. an S3 key served as TIFF via `Content-Type`)
51
+ work too. Building a URL by hand? Add the marker with `buildTiffUrl` or `?tp=1`.
package/dist/module.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { NuxtModule } from '@nuxt/schema';
1
+ import * as nuxt_schema from 'nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  /** Provider name used as <NuxtImg provider="..."> Default 'tiff'. */
@@ -11,8 +11,12 @@ interface ModuleOptions {
11
11
  scope: string;
12
12
  /** Auto-register the SW from a client plugin. Default true. */
13
13
  autoRegister: boolean;
14
+ /** Re-request TIFF images that raced the SW on a cold load. Default true. */
15
+ retryRacedImages: boolean;
16
+ /** Query-param namespace for modifiers and the interception marker. Default 'tp'. */
17
+ paramPrefix: string;
14
18
  }
15
- declare const module$1: NuxtModule<ModuleOptions>;
19
+ declare const module$1: nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
16
20
 
17
21
  export { module$1 as default };
18
22
  export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.1.0",
7
+ "version": "0.3.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -15,7 +15,9 @@ const module$1 = defineNuxtModule({
15
15
  cacheName: "tiff-webp-v1",
16
16
  quality: 0.8,
17
17
  scope: "/",
18
- autoRegister: true
18
+ autoRegister: true,
19
+ retryRacedImages: true,
20
+ paramPrefix: "tp"
19
21
  },
20
22
  async setup(options, nuxt) {
21
23
  const resolver = createResolver(import.meta.url);
@@ -25,7 +27,8 @@ const module$1 = defineNuxtModule({
25
27
  providers: {
26
28
  [options.providerName]: {
27
29
  name: options.providerName,
28
- provider: resolver.resolve("./runtime/provider")
30
+ provider: resolver.resolve("./runtime/provider"),
31
+ options: { paramPrefix: options.paramPrefix }
29
32
  }
30
33
  }
31
34
  }
@@ -58,7 +61,9 @@ const module$1 = defineNuxtModule({
58
61
  {
59
62
  cacheName: options.cacheName,
60
63
  quality: options.quality,
61
- scope: options.scope
64
+ scope: options.scope,
65
+ retryRacedImages: options.retryRacedImages,
66
+ paramPrefix: options.paramPrefix
62
67
  }
63
68
  );
64
69
  if (options.autoRegister) {
@@ -1,5 +1,9 @@
1
1
  import { buildTiffUrl } from "@tiff-provider/core/url";
2
- export const getImage = (src, ctx = {}) => {
3
- const { modifiers = {}, baseURL = "" } = ctx;
4
- return { url: buildTiffUrl(src, modifiers, baseURL) };
2
+ export const getImage = (src, options = {}) => {
3
+ const {
4
+ modifiers = {},
5
+ baseURL = "",
6
+ paramPrefix
7
+ } = options;
8
+ return { url: buildTiffUrl(src, modifiers, baseURL, { prefix: paramPrefix }) };
5
9
  };
@@ -6,6 +6,8 @@ export default defineNuxtPlugin(() => {
6
6
  void registerTiffServiceWorker({
7
7
  scope: cfg.scope,
8
8
  cacheName: cfg.cacheName,
9
- quality: cfg.quality
9
+ quality: cfg.quality,
10
+ retryRacedImages: cfg.retryRacedImages,
11
+ paramPrefix: cfg.paramPrefix
10
12
  });
11
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-tiff-provider",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Nuxt module: render TIFFs via @nuxt/image off the main thread in a Service Worker.",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -31,7 +31,7 @@
31
31
  "@nuxt/image": "^1.11.0",
32
32
  "@nuxt/kit": "^3.13.0",
33
33
  "defu": "^6.1.0",
34
- "@tiff-provider/core": "0.1.0"
34
+ "@tiff-provider/core": "0.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@nuxt/module-builder": "^1.0.0",