heic-to 1.1.11 → 1.1.13

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/esbuild.mjs CHANGED
@@ -25,7 +25,7 @@ await esbuild.build({
25
25
  target: 'es6',
26
26
  platform: 'browser',
27
27
  outfile: 'tmp/worker.js',
28
- external: ['fs', 'path']
28
+ external: ['fs', 'path', 'crypto']
29
29
  });
30
30
 
31
31
  const workerFileContent = fs.readFileSync('tmp/worker.js', 'utf8')
@@ -58,7 +58,7 @@ await esbuild.build({
58
58
  target: 'es6',
59
59
  platform: 'browser',
60
60
  outfile: 'tmp/worker.min.js',
61
- external: ['fs', 'path']
61
+ external: ['fs', 'path', 'crypto']
62
62
  });
63
63
 
64
64
  const workerFileMinifyContent = fs.readFileSync('tmp/worker.min.js', 'utf8')
@@ -91,7 +91,7 @@ await esbuild.build({
91
91
  target: 'es6',
92
92
  platform: 'browser',
93
93
  outfile: 'tmp/csp/worker.js',
94
- external: ['fs', 'path'],
94
+ external: ['fs', 'path', 'crypto'],
95
95
  });
96
96
 
97
97
  const cspWorkerFileContent = fs.readFileSync('tmp/csp/worker.js', 'utf8')
@@ -124,7 +124,7 @@ await esbuild.build({
124
124
  target: 'es6',
125
125
  platform: 'browser',
126
126
  outfile: 'tmp/csp/worker.min.js',
127
- external: ['fs', 'path']
127
+ external: ['fs', 'path', 'crypto']
128
128
  });
129
129
 
130
130
  const cspWorkerFileMinifyContent = fs.readFileSync('tmp/csp/worker.min.js', 'utf8')
@@ -143,3 +143,38 @@ esbuild.build({
143
143
  WORKER_FILE_CONTENT: JSON.stringify(cspWorkerFileMinifyContent)
144
144
  }
145
145
  });
146
+
147
+ // ################
148
+ // Build for iife/heic-to.js
149
+ // ################
150
+
151
+ await esbuild.build({
152
+ entryPoints: [
153
+ 'tmp/src/worker.js'
154
+ ],
155
+ bundle: true,
156
+ minify: true,
157
+ target: 'es6',
158
+ platform: 'browser',
159
+ outfile: 'tmp/iife/worker.js',
160
+ external: ['fs', 'path', 'crypto']
161
+ });
162
+
163
+ const iifeWorkerFileMinifyContent = fs.readFileSync('tmp/iife/worker.js', 'utf8')
164
+
165
+ // Produce an IIFE bundle
166
+ esbuild.build({
167
+ entryPoints: [
168
+ 'src/iife.js'
169
+ ],
170
+ bundle: true,
171
+ minify: false,
172
+ target: 'es6',
173
+ platform: 'browser',
174
+ outfile: 'dist/iife/heic-to.js',
175
+ format: 'iife',
176
+ globalName: 'HeicTo',
177
+ define: {
178
+ WORKER_FILE_CONTENT: JSON.stringify(iifeWorkerFileMinifyContent)
179
+ }
180
+ });
@@ -0,0 +1,26 @@
1
+ const imagesContainer = document.querySelector(".images")
2
+ const messageLabel = document.querySelector("label")
3
+ const field = document.querySelector("input")
4
+
5
+ field.addEventListener('change', async (event) => {
6
+
7
+ let imageDom = document.querySelector("img")
8
+ if (!imageDom) {
9
+ imageDom = document.createElement('img')
10
+ imagesContainer.appendChild(imageDom)
11
+ }
12
+ imageDom.src = ''
13
+ imageDom.alt = "Loading..."
14
+ messageLabel.textContent = "Loading..."
15
+
16
+ const image = field.files[0]
17
+ if (await HeicTo.isHeic(image)) {
18
+ messageLabel.textContent = "It's a HEIC image"
19
+ const heifImage = await HeicTo({blob: image, type: 'image/jpeg', quality: 0.5})
20
+ imageDom.src = URL.createObjectURL(heifImage)
21
+ } else {
22
+ messageLabel.textContent = "It's not a HEIC image"
23
+ imageDom.src = URL.createObjectURL(image)
24
+ }
25
+
26
+ })
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>heic-to</title>
7
+ <style>
8
+ body {
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ flex-direction: column;
13
+ height: 100vh;
14
+ }
15
+ input {
16
+ border: 1px solid black;
17
+ padding: 10px;
18
+ }
19
+ label {
20
+ display: block;;
21
+ padding-top: 20px;
22
+ padding-bottom: 20px;
23
+ color: red;
24
+ }
25
+ .images {
26
+ width: 200px;
27
+ height: 200px;
28
+ }
29
+ img {
30
+ display: block;
31
+ width: 100%;
32
+ }
33
+ </style>
34
+ <script src="../../dist/iife/heic-to.js"></script>
35
+ </head>
36
+ <body>
37
+
38
+ <h1>heic-to</h1>
39
+
40
+ <main>
41
+ <input type="file">
42
+ <label></label>
43
+ <div class="images"></div>
44
+ </main>
45
+ <script src="./app.js"></script>
46
+ </body>
47
+ </html>
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "heic-to",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "Converting HEIF/HEIF image formats to PNG/JPEG in the browser",
5
5
  "main": "dist/heic-to.js",
6
6
  "exports": {
7
7
  ".": {
8
+ "types": "./dist/heic-to.d.ts",
8
9
  "import": "./dist/heic-to.js",
9
- "require": "./dist/heic-to.js",
10
- "types": "./dist/heic-to.d.ts"
10
+ "require": "./dist/heic-to.js"
11
11
  },
12
12
  "./csp": {
13
+ "types": "./dist/csp/heic-to.d.ts",
13
14
  "import": "./dist/csp/heic-to.js",
14
- "require": "./dist/csp/heic-to.js",
15
- "types": "./dist/csp/heic-to.d.ts"
15
+ "require": "./dist/csp/heic-to.js"
16
16
  }
17
17
  },
18
18
  "scripts": {
@@ -39,7 +39,7 @@
39
39
  "license": "LGPL-3.0",
40
40
  "homepage": "https://github.com/hoppergee/heic-to",
41
41
  "devDependencies": {
42
- "esbuild": "0.23.0",
42
+ "esbuild": "^0.25.4",
43
43
  "http-server": "^14.1.1"
44
44
  }
45
45
  }
package/src/iife.js ADDED
@@ -0,0 +1,5 @@
1
+ import { heicTo, isHeic } from "./index";
2
+
3
+ heicTo.isHeic = isHeic;
4
+
5
+ module.exports = heicTo;