nuxt-tiff-provider 0.1.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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/module.d.mts +18 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +70 -0
- package/dist/runtime/provider.d.ts +2 -0
- package/dist/runtime/provider.js +5 -0
- package/dist/runtime/register.client.d.ts +2 -0
- package/dist/runtime/register.client.js +11 -0
- package/dist/types.d.mts +3 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 San Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# nuxt-tiff-provider
|
|
2
|
+
|
|
3
|
+
Render TIFF images in any browser through `@nuxt/image`, transcoding TIFF → WebP
|
|
4
|
+
off the main thread in a Service Worker.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm add nuxt-tiff-provider
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
// nuxt.config.ts — do NOT also list @nuxt/image; this module installs it.
|
|
14
|
+
export default defineNuxtConfig({
|
|
15
|
+
modules: ['nuxt-tiff-provider'],
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<NuxtImg provider="tiff" src="/photo.tif" width="640" sizes="100vw md:640px" />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Options
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
export default defineNuxtConfig({
|
|
29
|
+
tiff: {
|
|
30
|
+
providerName: 'tiff', // <NuxtImg provider="...">
|
|
31
|
+
cacheName: 'tiff-webp-v1', // Cache API bucket
|
|
32
|
+
quality: 0.8, // default WebP quality 0..1
|
|
33
|
+
scope: '/', // Service Worker scope
|
|
34
|
+
autoRegister: true, // false → call registerTiffServiceWorker() yourself
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Notes
|
|
40
|
+
|
|
41
|
+
- Safari paints TIFF natively; the SW detects this and passes through.
|
|
42
|
+
- Already run your own Service Worker? Set `autoRegister: false` and
|
|
43
|
+
`importScripts('/tiff-sw.js')` inside it (see `@tiff-provider/core`).
|
|
44
|
+
- Sources must be same-origin or CORS-readable.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/** Provider name used as <NuxtImg provider="..."> Default 'tiff'. */
|
|
5
|
+
providerName: string;
|
|
6
|
+
/** Cache API bucket name. Default 'tiff-webp-v1'. */
|
|
7
|
+
cacheName: string;
|
|
8
|
+
/** Default WebP quality 0..1. Default 0.8. */
|
|
9
|
+
quality: number;
|
|
10
|
+
/** SW registration scope. Default '/'. */
|
|
11
|
+
scope: string;
|
|
12
|
+
/** Auto-register the SW from a client plugin. Default true. */
|
|
13
|
+
autoRegister: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const module$1: NuxtModule<ModuleOptions>;
|
|
16
|
+
|
|
17
|
+
export { module$1 as default };
|
|
18
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { mkdirSync, copyFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { defineNuxtModule, createResolver, hasNuxtModule, installModule, addPlugin } from '@nuxt/kit';
|
|
5
|
+
import { defu } from 'defu';
|
|
6
|
+
|
|
7
|
+
const module$1 = defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "nuxt-tiff-provider",
|
|
10
|
+
configKey: "tiff",
|
|
11
|
+
compatibility: { nuxt: ">=3.0.0" }
|
|
12
|
+
},
|
|
13
|
+
defaults: {
|
|
14
|
+
providerName: "tiff",
|
|
15
|
+
cacheName: "tiff-webp-v1",
|
|
16
|
+
quality: 0.8,
|
|
17
|
+
scope: "/",
|
|
18
|
+
autoRegister: true
|
|
19
|
+
},
|
|
20
|
+
async setup(options, nuxt) {
|
|
21
|
+
const resolver = createResolver(import.meta.url);
|
|
22
|
+
nuxt.options.image = defu(
|
|
23
|
+
nuxt.options.image || {},
|
|
24
|
+
{
|
|
25
|
+
providers: {
|
|
26
|
+
[options.providerName]: {
|
|
27
|
+
name: options.providerName,
|
|
28
|
+
provider: resolver.resolve("./runtime/provider")
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
if (!hasNuxtModule("@nuxt/image")) {
|
|
34
|
+
await installModule("@nuxt/image");
|
|
35
|
+
}
|
|
36
|
+
const require = createRequire(import.meta.url);
|
|
37
|
+
let swSource;
|
|
38
|
+
try {
|
|
39
|
+
swSource = require.resolve("@tiff-provider/core/tiff-sw.js");
|
|
40
|
+
} catch {
|
|
41
|
+
throw new Error(
|
|
42
|
+
'nuxt-tiff-provider: could not resolve "@tiff-provider/core/tiff-sw.js". Ensure @tiff-provider/core is installed and built (run `pnpm run build:core`).'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const swDir = join(nuxt.options.buildDir, "cache", "tiff-sw");
|
|
46
|
+
mkdirSync(swDir, { recursive: true });
|
|
47
|
+
copyFileSync(swSource, join(swDir, "tiff-sw.js"));
|
|
48
|
+
nuxt.hook("nitro:config", (nitro) => {
|
|
49
|
+
nitro.publicAssets ||= [];
|
|
50
|
+
nitro.publicAssets.push({ baseURL: "/", dir: swDir });
|
|
51
|
+
});
|
|
52
|
+
const nitroOptions = nuxt.options.nitro ??= {};
|
|
53
|
+
nitroOptions.routeRules = defu(nitroOptions.routeRules, {
|
|
54
|
+
"/tiff-sw.js": { headers: { "cache-control": "no-cache" } }
|
|
55
|
+
});
|
|
56
|
+
nuxt.options.runtimeConfig.public.tiff = defu(
|
|
57
|
+
nuxt.options.runtimeConfig.public.tiff || {},
|
|
58
|
+
{
|
|
59
|
+
cacheName: options.cacheName,
|
|
60
|
+
quality: options.quality,
|
|
61
|
+
scope: options.scope
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
if (options.autoRegister) {
|
|
65
|
+
addPlugin(resolver.resolve("./runtime/register.client"));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerTiffServiceWorker } from "@tiff-provider/core/register";
|
|
2
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
3
|
+
export default defineNuxtPlugin(() => {
|
|
4
|
+
if (!import.meta.client) return;
|
|
5
|
+
const cfg = useRuntimeConfig().public.tiff;
|
|
6
|
+
void registerTiffServiceWorker({
|
|
7
|
+
scope: cfg.scope,
|
|
8
|
+
cacheName: cfg.cacheName,
|
|
9
|
+
quality: cfg.quality
|
|
10
|
+
});
|
|
11
|
+
});
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nuxt-tiff-provider",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Nuxt module: render TIFFs via @nuxt/image off the main thread in a Service Worker.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nuxt",
|
|
7
|
+
"nuxt-module",
|
|
8
|
+
"@nuxt/image",
|
|
9
|
+
"image",
|
|
10
|
+
"tiff",
|
|
11
|
+
"geotiff",
|
|
12
|
+
"webp",
|
|
13
|
+
"service-worker",
|
|
14
|
+
"transcode"
|
|
15
|
+
],
|
|
16
|
+
"author": "San Chen <bigsan.chen@gmail.com>",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/module.mjs",
|
|
20
|
+
"types": "./dist/types.d.mts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/types.d.mts",
|
|
24
|
+
"import": "./dist/module.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@nuxt/image": "^1.11.0",
|
|
32
|
+
"@nuxt/kit": "^3.13.0",
|
|
33
|
+
"defu": "^6.1.0",
|
|
34
|
+
"@tiff-provider/core": "0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@nuxt/module-builder": "^1.0.0",
|
|
38
|
+
"@nuxt/schema": "^3.13.0",
|
|
39
|
+
"@nuxt/test-utils": "^3.14.0",
|
|
40
|
+
"@types/node": "^22",
|
|
41
|
+
"nuxt": "^4.0.0",
|
|
42
|
+
"typescript": "^5.6.0",
|
|
43
|
+
"vitest": "^3.2.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"nuxt": "^3.0.0 || ^4.0.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "nuxt-module-build build",
|
|
50
|
+
"dev:prepare": "nuxt-module-build build --stub",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json"
|
|
53
|
+
}
|
|
54
|
+
}
|