wasm-image-optimization 0.1.5 → 0.1.6

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
@@ -2,9 +2,11 @@
2
2
 
3
3
  - Cloudflare workers
4
4
  `import { optimizeImage } from 'wasm-image-optimization';`
5
- - Edge runtime (Import here if using from Next.js)
6
- `import { optimizeImage } from 'wasm-image-optimization/edge';`
7
- - Node runtime (CJS)
5
+ - Next.js(Webpack)
6
+ `import { optimizeImage } from 'wasm-image-optimization/next';`
7
+ - ESM(import base)
8
+ `import { optimizeImage } from 'wasm-image-optimization/esm';`
9
+ - CJS(file base)
8
10
  `import { optimizeImage } from 'wasm-image-optimization/node';`
9
11
 
10
12
  - function
package/dist/cjs/index.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.optimizeImage = void 0;
7
- const libImage_1 = __importDefault(require("../workers/libImage"));
7
+ const libImage_1 = __importDefault(require("../esm/libImage"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const libImage = (0, libImage_1.default)({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cjs/index.ts"],"names":[],"mappings":";;;;;;AAAA,mEAA2C;AAC3C,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,QAAQ,GAAG,IAAA,kBAAQ,EAAC;IACxB,UAAU,EAAE,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;CAC7E,CAAC,CAAC;AAEI,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,GAOhB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAZ1E,QAAA,aAAa,iBAY6D","sourcesContent":["import LibImage from '../workers/libImage';\nimport path from 'path';\nimport fs from 'fs';\n\nconst libImage = LibImage({\n wasmBinary: fs.readFileSync(path.resolve(__dirname, '../esm/libImage.wasm')),\n});\n\nexport const optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = 'webp',\n}: {\n image: BufferSource;\n width?: number;\n height?: number;\n quality?: number;\n format?: 'jpeg' | 'png' | 'webp';\n}) => libImage.then(({ optimize }) => optimize(image, width, height, quality, format));\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cjs/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuC;AACvC,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,QAAQ,GAAG,IAAA,kBAAQ,EAAC;IACxB,UAAU,EAAE,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;CAC7E,CAAC,CAAC;AAEI,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,GAOhB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAZ1E,QAAA,aAAa,iBAY6D","sourcesContent":["import LibImage from '../esm/libImage';\nimport path from 'path';\nimport fs from 'fs';\n\nconst libImage = LibImage({\n wasmBinary: fs.readFileSync(path.resolve(__dirname, '../esm/libImage.wasm')),\n});\n\nexport const optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = 'webp',\n}: {\n image: BufferSource;\n width?: number;\n height?: number;\n quality?: number;\n format?: 'jpeg' | 'png' | 'webp';\n}) => libImage.then(({ optimize }) => optimize(image, width, height, quality, format));\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const optimizeImage: ({ image, width, height, quality, format, }: {
2
+ image: BufferSource;
3
+ width?: number | undefined;
4
+ height?: number | undefined;
5
+ quality?: number | undefined;
6
+ format?: "jpeg" | "png" | "webp" | undefined;
7
+ }) => Promise<Uint8Array | null>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.optimizeImage = void 0;
7
+ const libImage_js_1 = __importDefault(require("../esm/libImage.js"));
8
+ const libImage_wasm_module_1 = __importDefault(require("../esm/libImage.wasm?module"));
9
+ const libImage = (0, libImage_js_1.default)({
10
+ instantiateWasm: async (imports, receiver) => {
11
+ receiver(await WebAssembly.instantiate(libImage_wasm_module_1.default, imports));
12
+ },
13
+ });
14
+ const optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = 'webp', }) => libImage.then(({ optimize }) => optimize(image, width, height, quality, format));
15
+ exports.optimizeImage = optimizeImage;
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":";;;;;;AAAA,qEAA0C;AAC1C,uFAA+C;AAE/C,MAAM,QAAQ,GAAG,IAAA,qBAAQ,EAAC;IACxB,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC3C,QAAQ,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,8BAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;CACF,CAAC,CAAC;AAEI,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,GAOhB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAZ1E,QAAA,aAAa,iBAY6D","sourcesContent":["import LibImage from '../esm/libImage.js';\nimport WASM from '../esm/libImage.wasm?module';\n\nconst libImage = LibImage({\n instantiateWasm: async (imports, receiver) => {\n receiver(await WebAssembly.instantiate(WASM, imports));\n },\n});\n\nexport const optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = 'webp',\n}: {\n image: BufferSource;\n width?: number;\n height?: number;\n quality?: number;\n format?: 'jpeg' | 'png' | 'webp';\n}) => libImage.then(({ optimize }) => optimize(image, width, height, quality, format));\n"]}
@@ -1,5 +1,5 @@
1
- import LibImage from './libImage.js';
2
- import WASM from '../esm/libImage.wasm?module';
1
+ import LibImage from '../esm/libImage.js';
2
+ import WASM from '../esm/libImage.wasm';
3
3
  const libImage = LibImage({
4
4
  instantiateWasm: async (imports, receiver) => {
5
5
  receiver(await WebAssembly.instantiate(WASM, imports));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,IAAI,MAAM,6BAA6B,CAAC;AAE/C,MAAM,QAAQ,GAAG,QAAQ,CAAC;IACxB,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC3C,QAAQ,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,GAOhB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import LibImage from './libImage.js';\nimport WASM from '../esm/libImage.wasm?module';\n\nconst libImage = LibImage({\n instantiateWasm: async (imports, receiver) => {\n receiver(await WebAssembly.instantiate(WASM, imports));\n },\n});\n\nexport const optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = 'webp',\n}: {\n image: BufferSource;\n width?: number;\n height?: number;\n quality?: number;\n format?: 'jpeg' | 'png' | 'webp';\n}) => libImage.then(({ optimize }) => optimize(image, width, height, quality, format));\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,IAAI,MAAM,sBAAsB,CAAC;AAExC,MAAM,QAAQ,GAAG,QAAQ,CAAC;IACxB,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC3C,QAAQ,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,GAOhB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import LibImage from '../esm/libImage.js';\nimport WASM from '../esm/libImage.wasm';\n\nconst libImage = LibImage({\n instantiateWasm: async (imports, receiver) => {\n receiver(await WebAssembly.instantiate(WASM, imports));\n },\n});\n\nexport const optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = 'webp',\n}: {\n image: BufferSource;\n width?: number;\n height?: number;\n quality?: number;\n format?: 'jpeg' | 'png' | 'webp';\n}) => libImage.then(({ optimize }) => optimize(image, width, height, quality, format));\n"]}
package/package.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "name": "wasm-image-optimization",
3
3
  "description": "Optimize images with wasm on edge runtime",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "exports": {
6
- "./edge": {
6
+ "./esm": {
7
7
  "default": {
8
8
  "import": "./dist/esm/index.js",
9
9
  "types": "./dist/esm/index.d.ts"
10
10
  }
11
11
  },
12
+ "./next": {
13
+ "default": {
14
+ "import": "./dist/next/index.js",
15
+ "types": "./dist/next/index.d.ts"
16
+ }
17
+ },
12
18
  "./node": {
13
19
  "default": {
14
20
  "types": "./dist/cjs/index.d.ts",
@@ -27,6 +33,9 @@
27
33
  "edge": [
28
34
  "./dist/esm/index.d.ts"
29
35
  ],
36
+ "next": [
37
+ "./dist/next/index.d.ts"
38
+ ],
30
39
  "node": [
31
40
  "./dist/cjs/index.d.ts"
32
41
  ],