dpzvc3-ui 3.1.5 → 3.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.
Files changed (276) hide show
  1. package/README.md +1 -1
  2. package/dist/dpzvc3.esm.js +5 -4
  3. package/dist/dpzvc3.esm.js.map +1 -1
  4. package/dist/dpzvc3.esm.min.js +1 -1
  5. package/dist/dpzvc3.esm.min.js.map +1 -1
  6. package/dist/dpzvc3.js +5 -4
  7. package/dist/dpzvc3.js.map +1 -1
  8. package/dist/dpzvc3.min.js +1 -1
  9. package/dist/dpzvc3.min.js.map +1 -1
  10. package/dist/types/components/actionSheet/index.d.ts +6 -1
  11. package/dist/types/components/actionSheet/index.d.ts.map +1 -1
  12. package/package.json +7 -2
  13. package/build-style.js +0 -58
  14. package/dist-prod/91.05c8ec5277a15f939b0f.js +0 -3
  15. package/dist-prod/91.05c8ec5277a15f939b0f.js.LICENSE.txt +0 -25
  16. package/dist-prod/91.05c8ec5277a15f939b0f.js.map +0 -1
  17. package/dist-prod/actionsheet.0d67b6b08a62cf9360be.chunk.js +0 -2
  18. package/dist-prod/actionsheet.0d67b6b08a62cf9360be.chunk.js.map +0 -1
  19. package/dist-prod/badge.16ab5c05734fe1530701.chunk.js +0 -2
  20. package/dist-prod/badge.16ab5c05734fe1530701.chunk.js.map +0 -1
  21. package/dist-prod/button.39ac33aa7aaccc24b6a1.chunk.js +0 -2
  22. package/dist-prod/button.39ac33aa7aaccc24b6a1.chunk.js.map +0 -1
  23. package/dist-prod/card.16ed7eafe471bcc60ec6.chunk.js +0 -2
  24. package/dist-prod/card.16ed7eafe471bcc60ec6.chunk.js.map +0 -1
  25. package/dist-prod/cell.70ff74fba57e27df7f5a.chunk.js +0 -2
  26. package/dist-prod/cell.70ff74fba57e27df7f5a.chunk.js.map +0 -1
  27. package/dist-prod/cellswipe.f3ec62abd60729d8bc5a.chunk.js +0 -2
  28. package/dist-prod/cellswipe.f3ec62abd60729d8bc5a.chunk.js.map +0 -1
  29. package/dist-prod/checkbox.05c63a947ac98293c9f2.chunk.js +0 -2
  30. package/dist-prod/checkbox.05c63a947ac98293c9f2.chunk.js.map +0 -1
  31. package/dist-prod/guide.24f1968a568f20fbc84b.chunk.js +0 -2
  32. package/dist-prod/guide.24f1968a568f20fbc84b.chunk.js.map +0 -1
  33. package/dist-prod/header.eb10433dd892738ee95a.chunk.js +0 -2
  34. package/dist-prod/header.eb10433dd892738ee95a.chunk.js.map +0 -1
  35. package/dist-prod/index.html +0 -19
  36. package/dist-prod/indicator.0c09e3f238791cb478e0.chunk.js +0 -2
  37. package/dist-prod/indicator.0c09e3f238791cb478e0.chunk.js.map +0 -1
  38. package/dist-prod/loadmore.9bad88767cc43603f473.chunk.js +0 -2
  39. package/dist-prod/loadmore.9bad88767cc43603f473.chunk.js.map +0 -1
  40. package/dist-prod/main.662ad15361e7f3d20234.js +0 -2
  41. package/dist-prod/main.662ad15361e7f3d20234.js.map +0 -1
  42. package/dist-prod/message.de17fea3de4daa70bab4.chunk.js +0 -2
  43. package/dist-prod/message.de17fea3de4daa70bab4.chunk.js.map +0 -1
  44. package/dist-prod/modal.f9ec857acd9fbdf53f3b.chunk.js +0 -2
  45. package/dist-prod/modal.f9ec857acd9fbdf53f3b.chunk.js.map +0 -1
  46. package/dist-prod/picker.bca059ef59e3c42a401f.chunk.js +0 -2
  47. package/dist-prod/picker.bca059ef59e3c42a401f.chunk.js.map +0 -1
  48. package/dist-prod/popup.538422c7e188363a468d.chunk.js +0 -2
  49. package/dist-prod/popup.538422c7e188363a468d.chunk.js.map +0 -1
  50. package/dist-prod/progress.240de4b633002f573030.chunk.js +0 -2
  51. package/dist-prod/progress.240de4b633002f573030.chunk.js.map +0 -1
  52. package/dist-prod/prompt.dcda0b05ea02d59106b7.chunk.js +0 -2
  53. package/dist-prod/prompt.dcda0b05ea02d59106b7.chunk.js.map +0 -1
  54. package/dist-prod/radiobox.7c10f77aba5ae04b2e5c.chunk.js +0 -2
  55. package/dist-prod/radiobox.7c10f77aba5ae04b2e5c.chunk.js.map +0 -1
  56. package/dist-prod/rater.d46ae462c598c458e5a8.chunk.js +0 -2
  57. package/dist-prod/rater.d46ae462c598c458e5a8.chunk.js.map +0 -1
  58. package/dist-prod/slidebar.833e75b9eb0abef92453.chunk.js +0 -2
  59. package/dist-prod/slidebar.833e75b9eb0abef92453.chunk.js.map +0 -1
  60. package/dist-prod/spinner.6afb4f84cc29f0e2f8eb.chunk.js +0 -2
  61. package/dist-prod/spinner.6afb4f84cc29f0e2f8eb.chunk.js.map +0 -1
  62. package/dist-prod/swipe.3fe6ee6638765ec52d94.chunk.js +0 -2
  63. package/dist-prod/swipe.3fe6ee6638765ec52d94.chunk.js.map +0 -1
  64. package/dist-prod/switchbar.f24c76a03120f1bd961a.chunk.js +0 -2
  65. package/dist-prod/switchbar.f24c76a03120f1bd961a.chunk.js.map +0 -1
  66. package/dist-prod/tab.29f19483f699b7811259.chunk.js +0 -2
  67. package/dist-prod/tab.29f19483f699b7811259.chunk.js.map +0 -1
  68. package/dist-prod/text.a6e4251f772d23843e2b.chunk.js +0 -2
  69. package/dist-prod/text.a6e4251f772d23843e2b.chunk.js.map +0 -1
  70. package/dist-prod/totop.713c5ab7f7dbcffbf2a3.chunk.js +0 -2
  71. package/dist-prod/totop.713c5ab7f7dbcffbf2a3.chunk.js.map +0 -1
  72. package/dist-prod/upload.0638581e551ed9afaba2.chunk.js +0 -2
  73. package/dist-prod/upload.0638581e551ed9afaba2.chunk.js.map +0 -1
  74. package/postcss.config.js +0 -5
  75. package/src/components/Indicator/Indicator.tsx +0 -67
  76. package/src/components/Indicator/Indicator.vue +0 -82
  77. package/src/components/Indicator/index.ts +0 -111
  78. package/src/components/Indicator/types.ts +0 -15
  79. package/src/components/Text/index.ts +0 -14
  80. package/src/components/Text/textBar.tsx +0 -104
  81. package/src/components/Text/types.ts +0 -13
  82. package/src/components/actionSheet/actionSheet.d.ts +0 -16
  83. package/src/components/actionSheet/actionSheet.tsx +0 -86
  84. package/src/components/actionSheet/index.ts +0 -6
  85. package/src/components/actionSheet/types.ts +0 -10
  86. package/src/components/app.vue +0 -59
  87. package/src/components/badge/badge.tsx +0 -80
  88. package/src/components/badge/index.ts +0 -12
  89. package/src/components/badge/types.ts +0 -8
  90. package/src/components/button/button.tsx +0 -105
  91. package/src/components/button/index.ts +0 -13
  92. package/src/components/button/types.ts +0 -13
  93. package/src/components/card/card.d.ts +0 -16
  94. package/src/components/card/card.tsx +0 -38
  95. package/src/components/card/index.ts +0 -12
  96. package/src/components/card/types.ts +0 -3
  97. package/src/components/cell/cell.tsx +0 -89
  98. package/src/components/cell/index.ts +0 -12
  99. package/src/components/cell/types.ts +0 -8
  100. package/src/components/cellSwipe/cellSwipe.tsx +0 -188
  101. package/src/components/cellSwipe/index.ts +0 -13
  102. package/src/components/cellSwipe/types.ts +0 -17
  103. package/src/components/checkBox/checkbox-group.tsx +0 -75
  104. package/src/components/checkBox/checkbox.tsx +0 -107
  105. package/src/components/checkBox/index.ts +0 -29
  106. package/src/components/checkBox/types.ts +0 -32
  107. package/src/components/header/header.tsx +0 -119
  108. package/src/components/header/index.ts +0 -13
  109. package/src/components/header/types.ts +0 -7
  110. package/src/components/loadMore/index.ts +0 -14
  111. package/src/components/loadMore/loadMore.tsx +0 -265
  112. package/src/components/loadMore/types.ts +0 -26
  113. package/src/components/message/confirm.ts +0 -104
  114. package/src/components/message/index.ts +0 -113
  115. package/src/components/message/message.tsx +0 -100
  116. package/src/components/message/messageGroup.tsx +0 -59
  117. package/src/components/message/types.ts +0 -48
  118. package/src/components/modal/confirm.ts +0 -123
  119. package/src/components/modal/index.ts +0 -68
  120. package/src/components/modal/modal.tsx +0 -248
  121. package/src/components/modal/types.ts +0 -51
  122. package/src/components/number/Number.tsx +0 -143
  123. package/src/components/number/index.ts +0 -10
  124. package/src/components/number/types.ts +0 -13
  125. package/src/components/picker/area-picker/area-picker.vue +0 -230
  126. package/src/components/picker/area-picker/props.js +0 -17
  127. package/src/components/picker/date-picker/date-picker.vue +0 -191
  128. package/src/components/picker/date-picker/props.js +0 -24
  129. package/src/components/picker/index.ts +0 -12
  130. package/src/components/picker/normal-picker/normal-picker.vue +0 -120
  131. package/src/components/picker/normal-picker/props.js +0 -20
  132. package/src/components/picker/picker-slot.vue +0 -217
  133. package/src/components/picker/picker.tsx +0 -112
  134. package/src/components/picker/types.ts +0 -17
  135. package/src/components/popup/index.ts +0 -12
  136. package/src/components/popup/popup.d.ts +0 -16
  137. package/src/components/popup/popup.tsx +0 -68
  138. package/src/components/popup/types.ts +0 -9
  139. package/src/components/progress/index.ts +0 -12
  140. package/src/components/progress/progress.tsx +0 -81
  141. package/src/components/progress/types.ts +0 -9
  142. package/src/components/prompt/confirm.ts +0 -104
  143. package/src/components/prompt/index.ts +0 -50
  144. package/src/components/prompt/prompt.tsx +0 -161
  145. package/src/components/prompt/types.ts +0 -45
  146. package/src/components/radioBox/index.ts +0 -34
  147. package/src/components/radioBox/radiobox-group.tsx +0 -66
  148. package/src/components/radioBox/radiobox.tsx +0 -115
  149. package/src/components/radioBox/types.ts +0 -24
  150. package/src/components/rater/index.ts +0 -12
  151. package/src/components/rater/rater.d.ts +0 -16
  152. package/src/components/rater/raters.tsx +0 -101
  153. package/src/components/rater/types.ts +0 -10
  154. package/src/components/slideBar/index.ts +0 -13
  155. package/src/components/slideBar/slideBar.tsx +0 -288
  156. package/src/components/slideBar/types.ts +0 -20
  157. package/src/components/spinner/behavior/blade.vue +0 -42
  158. package/src/components/spinner/behavior/double-bounce.vue +0 -38
  159. package/src/components/spinner/behavior/fading-circle.vue +0 -55
  160. package/src/components/spinner/behavior/snake.vue +0 -41
  161. package/src/components/spinner/behavior/triple-bounce.vue +0 -52
  162. package/src/components/spinner/index.ts +0 -13
  163. package/src/components/spinner/props.js +0 -28
  164. package/src/components/spinner/spinner.tsx +0 -85
  165. package/src/components/spinner/types.ts +0 -20
  166. package/src/components/swipe/index.ts +0 -13
  167. package/src/components/swipe/swipe.tsx +0 -292
  168. package/src/components/swipe/types.ts +0 -21
  169. package/src/components/switchbar/index.ts +0 -13
  170. package/src/components/switchbar/switchbar.tsx +0 -58
  171. package/src/components/switchbar/types.ts +0 -6
  172. package/src/components/tab/index.ts +0 -12
  173. package/src/components/tab/tab.tsx +0 -71
  174. package/src/components/tab/types.ts +0 -15
  175. package/src/components/toTop/index.ts +0 -13
  176. package/src/components/toTop/toTop.tsx +0 -54
  177. package/src/components/toTop/types.ts +0 -7
  178. package/src/components/upload/index.ts +0 -13
  179. package/src/components/upload/types.ts +0 -9
  180. package/src/components/upload/upload.tsx +0 -180
  181. package/src/config/config.js +0 -16
  182. package/src/directives/clickoutside.js +0 -42
  183. package/src/directives/tranferDom.js +0 -66
  184. package/src/index.d.ts +0 -131
  185. package/src/index.ts +0 -136
  186. package/src/lib/MegaPixImage.js +0 -164
  187. package/src/lib/MegaPixImageOld.js +0 -153
  188. package/src/lib/exif-js.js +0 -235
  189. package/src/lib/exif.js +0 -789
  190. package/src/lib/lib.js +0 -22
  191. package/src/main.ts +0 -33
  192. package/src/mixin/emitter.js +0 -72
  193. package/src/mixin/input.js +0 -41
  194. package/src/router.ts +0 -36
  195. package/src/shims-vue.d.ts +0 -37
  196. package/src/styles/base/font.less +0 -99
  197. package/src/styles/base/reset.less +0 -135
  198. package/src/styles/base/variable.less +0 -108
  199. package/src/styles/components/actionSheet.less +0 -43
  200. package/src/styles/components/badge.less +0 -81
  201. package/src/styles/components/button.less +0 -124
  202. package/src/styles/components/card.less +0 -31
  203. package/src/styles/components/cell-swipe.less +0 -20
  204. package/src/styles/components/cell.less +0 -75
  205. package/src/styles/components/checkBox.less +0 -113
  206. package/src/styles/components/editor.less +0 -3
  207. package/src/styles/components/header.less +0 -72
  208. package/src/styles/components/indicator.less +0 -39
  209. package/src/styles/components/loadmore.less +0 -48
  210. package/src/styles/components/message.less +0 -57
  211. package/src/styles/components/modal.less +0 -84
  212. package/src/styles/components/number.less +0 -60
  213. package/src/styles/components/picker.less +0 -152
  214. package/src/styles/components/popup.less +0 -46
  215. package/src/styles/components/progress.less +0 -52
  216. package/src/styles/components/prompt.less +0 -37
  217. package/src/styles/components/radioBox.less +0 -142
  218. package/src/styles/components/rater.less +0 -16
  219. package/src/styles/components/slide-Bar.less +0 -149
  220. package/src/styles/components/spinner.less +0 -329
  221. package/src/styles/components/swipe.less +0 -125
  222. package/src/styles/components/switchBar.less +0 -88
  223. package/src/styles/components/tab.less +0 -71
  224. package/src/styles/components/text.less +0 -82
  225. package/src/styles/components/toTop.less +0 -28
  226. package/src/styles/components/upload.less +0 -23
  227. package/src/styles/index.less +0 -39
  228. package/src/styles/utils/1px.less +0 -206
  229. package/src/styles/utils/animation.less +0 -165
  230. package/src/styles/utils/nowrap.less +0 -19
  231. package/src/template/index.ejs +0 -40
  232. package/src/types/index.d.ts +0 -127
  233. package/src/types/js-shims.d.ts +0 -36
  234. package/src/utils/test.ts +0 -2
  235. package/src/utils/util.ts +0 -168
  236. package/src/utils/util1.js +0 -202
  237. package/src/vconsole-resources.min.js +0 -6
  238. package/src/vconsole-sources.min.js +0 -6
  239. package/src/vconsole.min.js +0 -7
  240. package/src/views/ActionSheet.vue +0 -46
  241. package/src/views/Badge/Badge.less +0 -12
  242. package/src/views/Badge/Badge.tsx +0 -23
  243. package/src/views/Badge.vue +0 -53
  244. package/src/views/Button.vue +0 -69
  245. package/src/views/Card.vue +0 -89
  246. package/src/views/Cell.vue +0 -31
  247. package/src/views/CellSwipe.vue +0 -80
  248. package/src/views/CheckBox.vue +0 -78
  249. package/src/views/Header.vue +0 -71
  250. package/src/views/Indicator.vue +0 -82
  251. package/src/views/LoadMore.vue +0 -76
  252. package/src/views/Message.vue +0 -61
  253. package/src/views/Modal.vue +0 -69
  254. package/src/views/Picker.vue +0 -142
  255. package/src/views/Popup.vue +0 -103
  256. package/src/views/Progress.vue +0 -49
  257. package/src/views/Prompt.vue +0 -43
  258. package/src/views/RadioBox.vue +0 -70
  259. package/src/views/Rater.vue +0 -53
  260. package/src/views/SlideBar.vue +0 -62
  261. package/src/views/Spinner.vue +0 -27
  262. package/src/views/Swipe.vue +0 -59
  263. package/src/views/SwitchBar.vue +0 -49
  264. package/src/views/Tab.vue +0 -55
  265. package/src/views/Text.vue +0 -97
  266. package/src/views/ToTop.vue +0 -31
  267. package/src/views/Upload.vue +0 -65
  268. package/src/views/guide.vue +0 -164
  269. package/src/views/index.vue +0 -554
  270. package/tsconfig.build.json +0 -31
  271. package/tsconfig.json +0 -41
  272. package/webpack.base.config.js +0 -85
  273. package/webpack.dev.config.js +0 -43
  274. package/webpack.dist.dev.config.js +0 -76
  275. package/webpack.dist.prod.config.js +0 -90
  276. package/webpack.prod.config.js +0 -52
@@ -1,164 +0,0 @@
1
- // MegaPixImage.js
2
- // 将原先的 UMD/CommonJS 改为 ESM export default
3
-
4
- // -------------------------
5
- // Helper functions
6
- // -------------------------
7
- function detectSubsampling (img) {
8
- const iw = img.naturalWidth; const ih = img.naturalHeight
9
- if (iw * ih > 1024 * 1024) {
10
- const canvas = document.createElement('canvas')
11
- canvas.width = canvas.height = 1
12
- const ctx = canvas.getContext('2d')
13
- ctx.drawImage(img, -iw + 1, 0)
14
- return ctx.getImageData(0, 0, 1, 1).data[3] === 0
15
- }
16
- return false
17
- }
18
-
19
- function detectVerticalSquash (img, iw, ih) {
20
- const canvas = document.createElement('canvas')
21
- canvas.width = 1
22
- canvas.height = ih
23
- const ctx = canvas.getContext('2d')
24
- ctx.drawImage(img, 0, 0)
25
- const data = ctx.getImageData(0, 0, 1, ih).data
26
- let sy = 0; let ey = ih; let py = ih
27
- while (py > sy) {
28
- const alpha = data[(py - 1) * 4 + 3]
29
- if (alpha === 0) ey = py
30
- else sy = py
31
- py = (ey + sy) >> 1
32
- }
33
- const ratio = py / ih
34
- return ratio === 0 ? 1 : ratio
35
- }
36
-
37
- function renderImageToDataURL (img, options, doSquash) {
38
- const canvas = document.createElement('canvas')
39
- renderImageToCanvas(img, canvas, options, doSquash)
40
- return canvas.toDataURL('image/jpeg', options.quality || 0.8)
41
- }
42
-
43
- function renderImageToCanvas (img, canvas, options, doSquash) {
44
- let iw = img.naturalWidth; let ih = img.naturalHeight
45
- if (!(iw + ih)) return
46
-
47
- const width = options.width; const height = options.height
48
- const ctx = canvas.getContext('2d')
49
- ctx.save()
50
- transformCoordinate(canvas, ctx, width, height, options.orientation)
51
-
52
- const subsampled = detectSubsampling(img)
53
- if (subsampled) { iw /= 2; ih /= 2 }
54
-
55
- const d = 1024
56
- const tmpCanvas = document.createElement('canvas')
57
- tmpCanvas.width = tmpCanvas.height = d
58
- const tmpCtx = tmpCanvas.getContext('2d')
59
-
60
- const vertSquashRatio = doSquash ? detectVerticalSquash(img, iw, ih) : 1
61
- const dw = Math.ceil(d * width / iw)
62
- const dh = Math.ceil(d * height / ih / vertSquashRatio)
63
-
64
- let sy = 0; let dy = 0
65
- while (sy < ih) {
66
- let sx = 0; let dx = 0
67
- while (sx < iw) {
68
- tmpCtx.clearRect(0, 0, d, d)
69
- tmpCtx.drawImage(img, -sx, -sy)
70
- ctx.drawImage(tmpCanvas, 0, 0, d, d, dx, dy, dw, dh)
71
- sx += d
72
- dx += dw
73
- }
74
- sy += d
75
- dy += dh
76
- }
77
- ctx.restore()
78
- }
79
-
80
- function transformCoordinate (canvas, ctx, width, height, orientation) {
81
- switch (orientation) {
82
- case 5: case 6: case 7: case 8:
83
- canvas.width = height
84
- canvas.height = width
85
- break
86
- default:
87
- canvas.width = width
88
- canvas.height = height
89
- }
90
- switch (orientation) {
91
- case 2: ctx.translate(width, 0); ctx.scale(-1, 1); break
92
- case 3: ctx.translate(width, height); ctx.rotate(Math.PI); break
93
- case 4: ctx.translate(0, height); ctx.scale(1, -1); break
94
- case 5: ctx.rotate(0.5 * Math.PI); ctx.scale(1, -1); break
95
- case 6: ctx.rotate(0.5 * Math.PI); ctx.translate(0, -height); break
96
- case 7: ctx.rotate(0.5 * Math.PI); ctx.translate(width, -height); ctx.scale(-1, 1); break
97
- case 8: ctx.rotate(-0.5 * Math.PI); ctx.translate(-width, 0); break
98
- }
99
- }
100
-
101
- const URL = window.URL && window.URL.createObjectURL
102
- ? window.URL
103
- : window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL : null
104
-
105
- // -------------------------
106
- // MegaPixImage class
107
- // -------------------------
108
- class MegaPixImage {
109
- constructor (srcImage) {
110
- if (window.Blob && srcImage instanceof Blob) {
111
- if (!URL) throw Error('No createObjectURL function found')
112
- const img = new Image()
113
- img.src = URL.createObjectURL(srcImage)
114
- this.blob = srcImage
115
- srcImage = img
116
- }
117
- if (!srcImage.naturalWidth && !srcImage.naturalHeight) {
118
- this.imageLoadListeners = []
119
- // eslint-disable-next-line @typescript-eslint/no-this-alias
120
- const _this = this
121
- srcImage.onload = srcImage.onerror = function () {
122
- const listeners = _this.imageLoadListeners
123
- if (listeners) {
124
- _this.imageLoadListeners = null
125
- listeners.forEach(fn => fn())
126
- }
127
- }
128
- }
129
- this.srcImage = srcImage
130
- }
131
-
132
- render (target, options, callback) {
133
- if (this.imageLoadListeners) {
134
- this.imageLoadListeners.push(() => { this.render(target, options, callback) })
135
- return
136
- }
137
- options = options || {}
138
- const imgWidth = this.srcImage.naturalWidth; const imgHeight = this.srcImage.naturalHeight
139
- let width = options.width; let height = options.height
140
- const maxWidth = options.maxWidth; const maxHeight = options.maxHeight
141
- const doSquash = !this.blob || this.blob.type === 'image/jpeg'
142
-
143
- if (width && !height) height = (imgHeight * width / imgWidth) << 0
144
- else if (height && !width) width = (imgWidth * height / imgHeight) << 0
145
- else { width = imgWidth; height = imgHeight }
146
-
147
- if (maxWidth && width > maxWidth) { width = maxWidth; height = (imgHeight * width / imgWidth) << 0 }
148
- if (maxHeight && height > maxHeight) { height = maxHeight; width = (imgWidth * height / imgHeight) << 0 }
149
-
150
- const opt = { width, height, ...options }
151
- const tagName = target.tagName.toLowerCase()
152
- if (tagName === 'img') target.src = renderImageToDataURL(this.srcImage, opt, doSquash)
153
- else if (tagName === 'canvas') renderImageToCanvas(this.srcImage, target, opt, doSquash)
154
-
155
- if (typeof this.onrender === 'function') this.onrender(target)
156
- if (callback) callback()
157
- if (this.blob) { this.blob = null; URL.revokeObjectURL(this.srcImage.src) }
158
- }
159
- }
160
-
161
- // -------------------------
162
- // ESM export default
163
- // -------------------------
164
- export default MegaPixImage
@@ -1,153 +0,0 @@
1
- (function (global, factory) {
2
- if (typeof module === 'object' && typeof module.exports === 'object') {
3
- module.exports = factory() // CommonJS
4
- } else if (typeof define === 'function' && define.amd) {
5
- define([], factory) // AMD
6
- } else {
7
- global.MegaPixImage = factory() // Browser global
8
- }
9
- }(typeof window !== 'undefined' ? window : this, function () {
10
- // -------------------------
11
- // Helper functions
12
- // -------------------------
13
- function detectSubsampling (img) {
14
- const iw = img.naturalWidth; const ih = img.naturalHeight
15
- if (iw * ih > 1024 * 1024) {
16
- const canvas = document.createElement('canvas')
17
- canvas.width = canvas.height = 1
18
- const ctx = canvas.getContext('2d')
19
- ctx.drawImage(img, -iw + 1, 0)
20
- return ctx.getImageData(0, 0, 1, 1).data[3] === 0
21
- } else {
22
- return false
23
- }
24
- }
25
-
26
- function detectVerticalSquash (img, iw, ih) {
27
- const canvas = document.createElement('canvas')
28
- canvas.width = 1
29
- canvas.height = ih
30
- const ctx = canvas.getContext('2d')
31
- ctx.drawImage(img, 0, 0)
32
- const data = ctx.getImageData(0, 0, 1, ih).data
33
- let sy = 0; let ey = ih; let py = ih
34
- while (py > sy) {
35
- const alpha = data[(py - 1) * 4 + 3]
36
- if (alpha === 0) { ey = py } else { sy = py }
37
- py = (ey + sy) >> 1
38
- }
39
- const ratio = py / ih
40
- return (ratio === 0) ? 1 : ratio
41
- }
42
-
43
- function renderImageToDataURL (img, options, doSquash) {
44
- const canvas = document.createElement('canvas')
45
- renderImageToCanvas(img, canvas, options, doSquash)
46
- return canvas.toDataURL('image/jpeg', options.quality || 0.8)
47
- }
48
-
49
- function renderImageToCanvas (img, canvas, options, doSquash) {
50
- let iw = img.naturalWidth; let ih = img.naturalHeight
51
- if (!(iw + ih)) return
52
- const width = options.width; const height = options.height
53
- const ctx = canvas.getContext('2d')
54
- ctx.save()
55
- transformCoordinate(canvas, ctx, width, height, options.orientation)
56
- const subsampled = detectSubsampling(img)
57
- if (subsampled) { iw /= 2; ih /= 2 }
58
- const d = 1024
59
- let tmpCanvas = document.createElement('canvas')
60
- tmpCanvas.width = tmpCanvas.height = d
61
- let tmpCtx = tmpCanvas.getContext('2d')
62
- const vertSquashRatio = doSquash ? detectVerticalSquash(img, iw, ih) : 1
63
- const dw = Math.ceil(d * width / iw)
64
- const dh = Math.ceil(d * height / ih / vertSquashRatio)
65
- let sy = 0; let dy = 0
66
- while (sy < ih) {
67
- let sx = 0; let dx = 0
68
- while (sx < iw) {
69
- tmpCtx.clearRect(0, 0, d, d)
70
- tmpCtx.drawImage(img, -sx, -sy)
71
- ctx.drawImage(tmpCanvas, 0, 0, d, d, dx, dy, dw, dh)
72
- sx += d; dx += dw
73
- }
74
- sy += d; dy += dh
75
- }
76
- ctx.restore()
77
- tmpCanvas = tmpCtx = null
78
- }
79
-
80
- function transformCoordinate (canvas, ctx, width, height, orientation) {
81
- switch (orientation) {
82
- case 5: case 6: case 7: case 8: canvas.width = height; canvas.height = width; break
83
- default: canvas.width = width; canvas.height = height
84
- }
85
- switch (orientation) {
86
- case 2: ctx.translate(width, 0); ctx.scale(-1, 1); break
87
- case 3: ctx.translate(width, height); ctx.rotate(Math.PI); break
88
- case 4: ctx.translate(0, height); ctx.scale(1, -1); break
89
- case 5: ctx.rotate(0.5 * Math.PI); ctx.scale(1, -1); break
90
- case 6: ctx.rotate(0.5 * Math.PI); ctx.translate(0, -height); break
91
- case 7: ctx.rotate(0.5 * Math.PI); ctx.translate(width, -height); ctx.scale(-1, 1); break
92
- case 8: ctx.rotate(-0.5 * Math.PI); ctx.translate(-width, 0); break
93
- }
94
- }
95
-
96
- const URL = window.URL && window.URL.createObjectURL
97
- ? window.URL
98
- : window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL : null
99
-
100
- // -------------------------
101
- // MegaPixImage class
102
- // -------------------------
103
- function MegaPixImage (srcImage) {
104
- if (window.Blob && srcImage instanceof Blob) {
105
- if (!URL) { throw Error('No createObjectURL function found') }
106
- const img = new Image()
107
- img.src = URL.createObjectURL(srcImage)
108
- this.blob = srcImage
109
- srcImage = img
110
- }
111
- if (!srcImage.naturalWidth && !srcImage.naturalHeight) {
112
- const _this = this
113
- srcImage.onload = srcImage.onerror = function () {
114
- const listeners = _this.imageLoadListeners
115
- if (listeners) {
116
- _this.imageLoadListeners = null
117
- for (let i = 0; i < listeners.length; i++) { listeners[i]() }
118
- }
119
- }
120
- this.imageLoadListeners = []
121
- }
122
- this.srcImage = srcImage
123
- }
124
-
125
- MegaPixImage.prototype.render = function (target, options, callback) {
126
- if (this.imageLoadListeners) {
127
- const _this = this
128
- this.imageLoadListeners.push(function () { _this.render(target, options, callback) })
129
- return
130
- }
131
- options = options || {}
132
- const imgWidth = this.srcImage.naturalWidth; const imgHeight = this.srcImage.naturalHeight
133
- let width = options.width; let height = options.height
134
- const maxWidth = options.maxWidth; const maxHeight = options.maxHeight
135
- const doSquash = !this.blob || this.blob.type === 'image/jpeg'
136
- if (width && !height) { height = (imgHeight * width / imgWidth) << 0 } else if (height && !width) { width = (imgWidth * height / imgHeight) << 0 } else { width = imgWidth; height = imgHeight }
137
- if (maxWidth && width > maxWidth) { width = maxWidth; height = (imgHeight * width / imgWidth) << 0 }
138
- if (maxHeight && height > maxHeight) { height = maxHeight; width = (imgWidth * height / imgHeight) << 0 }
139
- const opt = { width, height }
140
- for (const k in options) opt[k] = options[k]
141
-
142
- const tagName = target.tagName.toLowerCase()
143
- if (tagName === 'img') { target.src = renderImageToDataURL(this.srcImage, opt, doSquash) } else if (tagName === 'canvas') { renderImageToCanvas(this.srcImage, target, opt, doSquash) }
144
- if (typeof this.onrender === 'function') { this.onrender(target) }
145
- if (callback) { callback() }
146
- if (this.blob) { this.blob = null; URL.revokeObjectURL(this.srcImage.src) }
147
- }
148
-
149
- // -------------------------
150
- // Export as ESM default
151
- // -------------------------
152
- return MegaPixImage
153
- }))
@@ -1,235 +0,0 @@
1
- /*!
2
- * JavaScript EXIF Reader
3
- * https://github.com/exif-js/exif-js
4
- * 修复版:解决 strict mode 下未声明变量问题
5
- */
6
-
7
- (function () {
8
- const debug = false
9
- const root = this
10
-
11
- const EXIF = function (obj) {
12
- if (obj instanceof EXIF) return obj
13
- if (!(this instanceof EXIF)) return new EXIF(obj)
14
- this.EXIFwrapped = obj
15
- }
16
-
17
- if (typeof exports !== 'undefined') {
18
- if (typeof module !== 'undefined' && module.exports) {
19
- exports = module.exports = EXIF
20
- }
21
- exports.EXIF = EXIF
22
- } else {
23
- root.EXIF = EXIF
24
- }
25
-
26
- /* ========================= TAG MAPS ========================= */
27
-
28
- const ExifTags = EXIF.Tags = {
29
- 0x9000: 'ExifVersion',
30
- 0xA000: 'FlashpixVersion',
31
- 0xA001: 'ColorSpace',
32
- 0xA002: 'PixelXDimension',
33
- 0xA003: 'PixelYDimension',
34
- 0x9101: 'ComponentsConfiguration',
35
- 0x9102: 'CompressedBitsPerPixel',
36
- 0x927C: 'MakerNote',
37
- 0x9286: 'UserComment',
38
- 0xA004: 'RelatedSoundFile',
39
- 0x9003: 'DateTimeOriginal',
40
- 0x9004: 'DateTimeDigitized',
41
- 0x9290: 'SubsecTime',
42
- 0x9291: 'SubsecTimeOriginal',
43
- 0x9292: 'SubsecTimeDigitized',
44
- 0x829A: 'ExposureTime',
45
- 0x829D: 'FNumber',
46
- 0x8822: 'ExposureProgram',
47
- 0x8824: 'SpectralSensitivity',
48
- 0x8827: 'ISOSpeedRatings',
49
- 0x8828: 'OECF',
50
- 0x9201: 'ShutterSpeedValue',
51
- 0x9202: 'ApertureValue',
52
- 0x9203: 'BrightnessValue',
53
- 0x9204: 'ExposureBias',
54
- 0x9205: 'MaxApertureValue',
55
- 0x9206: 'SubjectDistance',
56
- 0x9207: 'MeteringMode',
57
- 0x9208: 'LightSource',
58
- 0x9209: 'Flash',
59
- 0x920A: 'FocalLength',
60
- 0xA300: 'FileSource',
61
- 0xA301: 'SceneType',
62
- 0xA401: 'CustomRendered',
63
- 0xA402: 'ExposureMode',
64
- 0xA403: 'WhiteBalance',
65
- 0xA406: 'SceneCaptureType'
66
- }
67
-
68
- const TiffTags = EXIF.TiffTags = {
69
- 0x0100: 'ImageWidth',
70
- 0x0101: 'ImageHeight',
71
- 0x8769: 'ExifIFDPointer',
72
- 0x8825: 'GPSInfoIFDPointer',
73
- 0x0112: 'Orientation',
74
- 0x0132: 'DateTime',
75
- 0x010F: 'Make',
76
- 0x0110: 'Model',
77
- 0x0131: 'Software'
78
- }
79
-
80
- const GPSTags = EXIF.GPSTags = {
81
- 0x0000: 'GPSVersionID',
82
- 0x0001: 'GPSLatitudeRef',
83
- 0x0002: 'GPSLatitude',
84
- 0x0003: 'GPSLongitudeRef',
85
- 0x0004: 'GPSLongitude'
86
- }
87
-
88
- /* ========================= CORE ========================= */
89
-
90
- function getStringFromDB (buffer, start, length) {
91
- let outstr = ''
92
- let n
93
- for (n = start; n < start + length; n++) {
94
- outstr += String.fromCharCode(buffer.getUint8(n))
95
- }
96
- return outstr
97
- }
98
-
99
- function readEXIFData (file, start) {
100
- if (getStringFromDB(file, start, 4) !== 'Exif') {
101
- return false
102
- }
103
-
104
- let bigEnd
105
- const tiffOffset = start + 6
106
-
107
- if (file.getUint16(tiffOffset) === 0x4949) {
108
- bigEnd = false
109
- } else if (file.getUint16(tiffOffset) === 0x4D4D) {
110
- bigEnd = true
111
- } else {
112
- return false
113
- }
114
-
115
- const firstIFDOffset = file.getUint32(tiffOffset + 4, !bigEnd)
116
- const tags = readTags(file, tiffOffset, tiffOffset + firstIFDOffset, TiffTags, bigEnd)
117
-
118
- if (tags.ExifIFDPointer) {
119
- const exifData = readTags(
120
- file,
121
- tiffOffset,
122
- tiffOffset + tags.ExifIFDPointer,
123
- ExifTags,
124
- bigEnd
125
- )
126
- let tag
127
- for (tag in exifData) {
128
- tags[tag] = exifData[tag]
129
- }
130
- }
131
-
132
- return tags
133
- }
134
-
135
- function readTags (file, tiffStart, dirStart, strings, bigEnd) {
136
- const entries = file.getUint16(dirStart, !bigEnd)
137
- const tags = {}
138
- let i
139
-
140
- for (i = 0; i < entries; i++) {
141
- const entryOffset = dirStart + i * 12 + 2
142
- const tag = strings[file.getUint16(entryOffset, !bigEnd)]
143
- if (tag) {
144
- tags[tag] = readTagValue(file, entryOffset, tiffStart, bigEnd)
145
- }
146
- }
147
- return tags
148
- }
149
-
150
- function readTagValue (file, entryOffset, tiffStart, bigEnd) {
151
- const type = file.getUint16(entryOffset + 2, !bigEnd)
152
- const numValues = file.getUint32(entryOffset + 4, !bigEnd)
153
- const valueOffset = file.getUint32(entryOffset + 8, !bigEnd) + tiffStart
154
- let n, vals
155
-
156
- if (type === 2) {
157
- return getStringFromDB(file, valueOffset, numValues - 1)
158
- }
159
-
160
- if (type === 3) {
161
- if (numValues === 1) {
162
- return file.getUint16(entryOffset + 8, !bigEnd)
163
- }
164
- vals = []
165
- for (n = 0; n < numValues; n++) {
166
- vals[n] = file.getUint16(valueOffset + 2 * n, !bigEnd)
167
- }
168
- return vals
169
- }
170
-
171
- if (type === 4) {
172
- if (numValues === 1) {
173
- return file.getUint32(entryOffset + 8, !bigEnd)
174
- }
175
- vals = []
176
- for (n = 0; n < numValues; n++) {
177
- vals[n] = file.getUint32(valueOffset + 4 * n, !bigEnd)
178
- }
179
- return vals
180
- }
181
-
182
- return null
183
- }
184
-
185
- function findEXIFinJPEG (file) {
186
- const dataView = new DataView(file)
187
- if (dataView.getUint8(0) !== 0xFF || dataView.getUint8(1) !== 0xD8) {
188
- return false
189
- }
190
-
191
- let offset = 2
192
- const length = file.byteLength
193
-
194
- while (offset < length) {
195
- if (dataView.getUint8(offset) !== 0xFF) {
196
- return false
197
- }
198
-
199
- const marker = dataView.getUint8(offset + 1)
200
- if (marker === 225) {
201
- return readEXIFData(
202
- dataView,
203
- offset + 4,
204
- dataView.getUint16(offset + 2) - 2
205
- )
206
- } else {
207
- offset += 2 + dataView.getUint16(offset + 2)
208
- }
209
- }
210
- return false
211
- }
212
-
213
- EXIF.getData = function (img, callback) {
214
- const reader = new FileReader()
215
- reader.onload = function (e) {
216
- img.exifdata = findEXIFinJPEG(e.target.result) || {}
217
- if (callback) callback.call(img)
218
- }
219
- reader.readAsArrayBuffer(img)
220
- }
221
-
222
- EXIF.getAllTags = function (img) {
223
- return img.exifdata || {}
224
- }
225
-
226
- EXIF.readFromBinaryFile = function (file) {
227
- return findEXIFinJPEG(file)
228
- }
229
-
230
- if (typeof define === 'function' && define.amd) {
231
- define('exif-js', [], function () {
232
- return EXIF
233
- })
234
- }
235
- }.call(this))