@squoosh-kit/vite-plugin 0.1.8 → 0.1.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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -16
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,MAAM,CAAC;AA+BxD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;gCAoClC,aAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,MAAM,CAAC;AA+BxD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;gCAoClC,aAAa;;EA2C1C"}
|
package/dist/index.js
CHANGED
|
@@ -64,7 +64,6 @@ function squooshVitePlugin(squooshKitRoot) {
|
|
|
64
64
|
assetsInclude: ["**/*.wasm"],
|
|
65
65
|
configureServer(server) {
|
|
66
66
|
server.middlewares.use((req, res, next) => {
|
|
67
|
-
debugger;
|
|
68
67
|
const url = req.url;
|
|
69
68
|
if (!url?.includes(".wasm")) {
|
|
70
69
|
next();
|
|
@@ -72,21 +71,21 @@ function squooshVitePlugin(squooshKitRoot) {
|
|
|
72
71
|
}
|
|
73
72
|
try {
|
|
74
73
|
const cleanUrl = url.split("?")[0];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
let filePath = null;
|
|
75
|
+
if (cleanUrl.startsWith("/@fs/")) {
|
|
76
|
+
filePath = cleanUrl.slice(5);
|
|
77
|
+
} else {
|
|
78
|
+
const urlPath = cleanUrl?.startsWith("/") ? cleanUrl.slice(1) : cleanUrl;
|
|
79
|
+
filePath = join(squooshKitRoot, urlPath ?? "");
|
|
80
|
+
}
|
|
81
|
+
if (filePath && existsSync(filePath)) {
|
|
82
|
+
const wasmData = readFileSync(filePath);
|
|
83
|
+
res.setHeader("Content-Type", "application/wasm");
|
|
84
|
+
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
|
|
85
|
+
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
|
|
86
|
+
res.setHeader("Content-Length", wasmData.length.toString());
|
|
87
|
+
res.end(wasmData);
|
|
88
|
+
return;
|
|
90
89
|
}
|
|
91
90
|
next();
|
|
92
91
|
} catch {
|
package/package.json
CHANGED