quasar-ui-danx 0.3.33 → 0.3.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.33",
3
+ "version": "0.3.35",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  >
32
32
  <source
33
33
  :src="getPreviewUrl(file) + '#t=0.1'"
34
- :type="file.mime"
34
+ :type="getPreviewFileMime(file)"
35
35
  >
36
36
  </video>
37
37
  </template>
@@ -72,9 +72,16 @@ function isVideo(file) {
72
72
  return file.mime?.startsWith("video");
73
73
  }
74
74
 
75
+ function getPreviewFile(file) {
76
+ return file.transcodes?.mp4 || file.transcodes?.compress || file;
77
+ }
78
+ function getPreviewFileMime(file) {
79
+ return getPreviewFile(file).mime || (isVideo(file) ? "video/mp4" : "");
80
+ }
81
+
75
82
  function getPreviewUrl(file) {
76
- const transcodes = file?.transcodes;
77
- return transcodes?.mp4?.url || transcodes?.compress?.url || file.blobUrl || file.url;
83
+ file = getPreviewFile(file);
84
+ return file.blobUrl || file.url;
78
85
  }
79
86
 
80
87
  function getThumbUrl(file) {
@@ -161,20 +161,20 @@ const computedImage = computed(() => {
161
161
  }
162
162
  return null;
163
163
  });
164
+ const previewFile = computed(() => {
165
+ const transcodes = computedImage.value?.transcodes;
166
+ return transcodes?.mp4 || transcodes?.compress || computedImage.value;
167
+ });
168
+
164
169
  const mimeType = computed(
165
- () => computedImage.value?.type || computedImage.value?.mime || ""
170
+ () => previewFile.value?.type || previewFile.value?.mime || (computedImage.value?.transcodes?.mp4 ? "video/mp4" : "")
166
171
  );
167
172
  const isImage = computed(() => !!mimeType.value.match(/^image\//));
168
173
  const isVideo = computed(() => !!mimeType.value.match(/^video\//));
169
174
  const isPdf = computed(() => !!mimeType.value.match(/^application\/pdf/));
170
- const previewUrl = computed(() => {
171
- const transcodes = computedImage.value?.transcodes;
172
-
173
- if (isVideo.value && transcodes?.mp4?.url) {
174
- return transcodes.mp4.url;
175
- }
176
175
 
177
- return transcodes?.compress?.url || computedImage.value?.blobUrl || computedImage.value?.url;
176
+ const previewUrl = computed(() => {
177
+ return previewFile.value?.blobUrl || previewFile.value?.url;
178
178
  });
179
179
  const thumbUrl = computed(() => {
180
180
  return computedImage.value?.transcodes?.thumb?.url;
@@ -9,192 +9,193 @@
9
9
 
10
10
  /* eslint-disable */
11
11
  export function download(data, strFileName, strMimeType) {
12
- var self = window;
13
- // this script is only for browsers anyway...
14
-
15
- var defaultMime = "application/octet-stream";
16
- // this default mime also triggers iframe downloads
17
-
18
- var mimeType = strMimeType || defaultMime;
19
-
20
- var payload = data;
21
-
22
- var url = !strFileName && !strMimeType && payload;
23
-
24
- var anchor = document.createElement("a");
25
-
26
- var toString = function (a) {
27
- return String(a);
28
- };
29
-
30
- // @ts-ignore
31
- var myBlob = self.Blob || self.MozBlob || self.WebKitBlob || toString;
32
-
33
- var fileName = strFileName || "download";
34
-
35
- var blob;
36
-
37
- var reader;
38
- myBlob = myBlob.call ? myBlob.bind(self) : Blob;
39
-
40
- if (String(this) === "true") {
41
- // reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
42
- payload = [payload, mimeType];
43
- mimeType = payload[0];
44
- payload = payload[1];
45
- }
46
-
47
- if (url && url.length < 2048) {
48
- // if no filename and no mime, assume a url was passed as the only argument
49
- fileName = url.split("/").pop().split("?")[0];
50
- anchor.href = url; // assign href prop to temp anchor
51
-
52
- // if the browser determines that it's a potentially valid url path:
53
- if (
54
- anchor.href.indexOf(url) !== -1 ||
55
- anchor.href.indexOf(encodeURI(url)) !== -1 ||
56
- anchor.href === encodeURI(url)
57
- ) {
58
- var ajax = new XMLHttpRequest();
59
- ajax.open("GET", url + "?no-cache=" + Date.now(), true);
60
- ajax.responseType = "blob";
61
- ajax.onload = function (e) {
62
- // @ts-ignore
63
- download(e.target.response, fileName, defaultMime);
64
- };
65
- ajax.onerror = function (e) {
66
- // As a fallback, just open the request in a new tab
67
- window.open(url, "_blank").focus();
68
- };
69
- setTimeout(function () {
70
- ajax.send();
71
- }, 0); // allows setting custom ajax headers using the return:
72
- return ajax;
73
- } else {
74
- throw new Error("Invalid URL given, cannot download file: " + url);
75
- }
76
- } // end if url?
77
-
78
- // go ahead and download dataURLs right away
79
- if (/^data:[\w+-]+\/[\w+-]+[,;]/.test(payload)) {
80
- if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
81
- payload = dataUrlToBlob(payload);
82
- mimeType = payload.type || defaultMime;
83
- } else {
84
- // IE10 can't do a[download], only Blobs
85
- // everyone else can save dataURLs un-processed
86
- // @ts-ignore
87
- return navigator.msSaveBlob ? navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : saver(payload);
88
- }
89
- } // end if dataURL passed?
90
-
91
- blob =
92
- payload instanceof myBlob
93
- ? payload
94
- : new myBlob([payload], { type: mimeType });
95
-
96
- function dataUrlToBlob(strUrl) {
97
- var parts = strUrl.split(/[:;,]/);
98
-
99
- var type = parts[1];
100
-
101
- var decoder = parts[2] === "base64" ? atob : decodeURIComponent;
102
-
103
- var binData = decoder(parts.pop());
104
-
105
- var mx = binData.length;
106
-
107
- var i = 0;
108
-
109
- var uiArr = new Uint8Array(mx);
110
-
111
- for (i; i < mx; ++i) uiArr[i] = binData.charCodeAt(i);
112
-
113
- return new myBlob([uiArr], { type: type });
114
- }
115
-
116
- function saver(url, winMode) {
117
- if ("download" in anchor) {
118
- // html5 A[download]
119
- anchor.href = url;
120
- anchor.setAttribute("download", fileName);
121
- anchor.className = "download-js-link";
122
- anchor.innerHTML = "downloading...";
123
- anchor.style.display = "none";
124
- document.body.appendChild(anchor);
125
- setTimeout(function () {
126
- anchor.click();
127
- document.body.removeChild(anchor);
128
- if (winMode === true) {
129
- setTimeout(function () {
130
- self.URL.revokeObjectURL(anchor.href);
131
- }, 250);
132
- }
133
- }, 66);
134
- return true;
135
- }
136
-
137
- // handle non-a[download] safari as best we can:
138
- if (
139
- /(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)
140
- ) {
141
- url = url.replace(/^data:([\w/\-+]+)/, defaultMime);
142
- if (!window.open(url)) {
143
- // popup blocked, offer direct download:
144
- if (
145
- confirm(
146
- "Displaying New Document\n\nUse Save As... to download, then click back to return to this page."
147
- )
148
- ) {
149
- location.href = url;
150
- }
151
- }
152
- return true;
153
- }
154
-
155
- // do iframe dataURL download (old ch+FF):
156
- var f = document.createElement("iframe");
157
- document.body.appendChild(f);
158
-
159
- if (!winMode) {
160
- // force a mime that will download:
161
- url = "data:" + url.replace(/^data:([\w/\-+]+)/, defaultMime);
162
- }
163
- f.src = url;
164
- setTimeout(function () {
165
- document.body.removeChild(f);
166
- }, 333);
167
- } // end saver
168
-
169
- // @ts-ignore
170
- if (navigator.msSaveBlob) {
171
- // IE10+ : (has Blob, but not a[download] or URL)
172
- // @ts-ignore
173
- return navigator.msSaveBlob(blob, fileName);
174
- }
175
-
176
- if (self.URL) {
177
- // simple fast and modern way using Blob and URL:
178
- saver(self.URL.createObjectURL(blob), true);
179
- } else {
180
- // handle non-Blob()+non-URL browsers:
181
- if (typeof blob === "string" || blob.constructor === toString) {
182
- try {
183
- // @ts-ignore
184
- return saver("data:" + mimeType + ";base64," + self.btoa(blob));
185
- } catch (y) {
186
- // @ts-ignore
187
- return saver("data:" + mimeType + "," + encodeURIComponent(blob));
188
- }
189
- }
190
-
191
- // Blob but not URL support:
192
- reader = new FileReader();
193
- reader.onload = function (e) {
194
- // @ts-ignore
195
- saver(this.result);
196
- };
197
- reader.readAsDataURL(blob);
198
- }
199
- return true;
12
+ var self = window;
13
+ // this script is only for browsers anyway...
14
+
15
+ var defaultMime = "application/octet-stream";
16
+ // this default mime also triggers iframe downloads
17
+
18
+ var mimeType = strMimeType || defaultMime;
19
+
20
+ var payload = data;
21
+
22
+ var url = !strFileName && !strMimeType && payload;
23
+
24
+ var anchor = document.createElement("a");
25
+
26
+ var toString = function (a) {
27
+ return String(a);
28
+ };
29
+
30
+ // @ts-ignore
31
+ var myBlob = self.Blob || self.MozBlob || self.WebKitBlob || toString;
32
+
33
+ var fileName = strFileName || "download";
34
+
35
+ var blob;
36
+
37
+ var reader;
38
+ myBlob = myBlob.call ? myBlob.bind(self) : Blob;
39
+
40
+ if (String(this) === "true") {
41
+ // reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
42
+ payload = [payload, mimeType];
43
+ mimeType = payload[0];
44
+ payload = payload[1];
45
+ }
46
+
47
+ if (url && url.length < 2048) {
48
+ // if no filename and no mime, assume a url was passed as the only argument
49
+ fileName = url.split("/").pop().split("?")[0];
50
+ anchor.href = url; // assign href prop to temp anchor
51
+
52
+ // if the browser determines that it's a potentially valid url path:
53
+ if (
54
+ anchor.href.indexOf(url) !== -1 ||
55
+ anchor.href.indexOf(encodeURI(url)) !== -1 ||
56
+ anchor.href === encodeURI(url)
57
+ ) {
58
+ var ajax = new XMLHttpRequest();
59
+ ajax.open("GET", url + "?no-cache=" + Date.now(), true);
60
+ ajax.responseType = "blob";
61
+ ajax.onload = function (e) {
62
+ // @ts-ignore
63
+ download(e.target.response, fileName, defaultMime);
64
+ };
65
+ ajax.onerror = function (e) {
66
+ // As a fallback, just open the request in a new tab
67
+ window.open(url, "_blank").focus();
68
+ };
69
+ setTimeout(function () {
70
+ ajax.send();
71
+ }, 0); // allows setting custom ajax headers using the return:
72
+ return ajax;
73
+ } else {
74
+ throw new Error("Invalid URL given, cannot download file: " + url);
75
+ }
76
+ } // end if url?
77
+
78
+ // go ahead and download dataURLs right away
79
+ if (/^data:[\w+-]+\/[\w+-]+[,;]/.test(payload)) {
80
+ if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
81
+ payload = dataUrlToBlob(payload);
82
+ mimeType = payload.type || defaultMime;
83
+ } else {
84
+ // IE10 can't do a[download], only Blobs
85
+ // everyone else can save dataURLs un-processed
86
+ // @ts-ignore
87
+ return navigator.msSaveBlob ? navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : saver(payload);
88
+ }
89
+ } // end if dataURL passed?
90
+
91
+ blob =
92
+ payload instanceof myBlob
93
+ ? payload
94
+ : new myBlob([payload], { type: mimeType });
95
+
96
+ function dataUrlToBlob(strUrl) {
97
+ var parts = strUrl.split(/[:;,]/);
98
+
99
+ var type = parts[1];
100
+
101
+ var decoder = parts[2] === "base64" ? atob : decodeURIComponent;
102
+
103
+ var binData = decoder(parts.pop());
104
+
105
+ var mx = binData.length;
106
+
107
+ var i = 0;
108
+
109
+ var uiArr = new Uint8Array(mx);
110
+
111
+ for (i; i < mx; ++i) uiArr[i] = binData.charCodeAt(i);
112
+
113
+ return new myBlob([uiArr], { type: type });
114
+ }
115
+
116
+ function saver(url, winMode) {
117
+ if ("download" in anchor) {
118
+ // html5 A[download]
119
+ anchor.href = url;
120
+ anchor.setAttribute("download", fileName);
121
+ anchor.className = "download-js-link";
122
+ anchor.innerHTML = "downloading...";
123
+ anchor.style.display = "none";
124
+ anchor.target = "_blank";
125
+ document.body.appendChild(anchor);
126
+ setTimeout(function () {
127
+ anchor.click();
128
+ document.body.removeChild(anchor);
129
+ if (winMode === true) {
130
+ setTimeout(function () {
131
+ self.URL.revokeObjectURL(anchor.href);
132
+ }, 250);
133
+ }
134
+ }, 66);
135
+ return true;
136
+ }
137
+
138
+ // handle non-a[download] safari as best we can:
139
+ if (
140
+ /(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)
141
+ ) {
142
+ url = url.replace(/^data:([\w/\-+]+)/, defaultMime);
143
+ if (!window.open(url)) {
144
+ // popup blocked, offer direct download:
145
+ if (
146
+ confirm(
147
+ "Displaying New Document\n\nUse Save As... to download, then click back to return to this page."
148
+ )
149
+ ) {
150
+ location.href = url;
151
+ }
152
+ }
153
+ return true;
154
+ }
155
+
156
+ // do iframe dataURL download (old ch+FF):
157
+ var f = document.createElement("iframe");
158
+ document.body.appendChild(f);
159
+
160
+ if (!winMode) {
161
+ // force a mime that will download:
162
+ url = "data:" + url.replace(/^data:([\w/\-+]+)/, defaultMime);
163
+ }
164
+ f.src = url;
165
+ setTimeout(function () {
166
+ document.body.removeChild(f);
167
+ }, 333);
168
+ } // end saver
169
+
170
+ // @ts-ignore
171
+ if (navigator.msSaveBlob) {
172
+ // IE10+ : (has Blob, but not a[download] or URL)
173
+ // @ts-ignore
174
+ return navigator.msSaveBlob(blob, fileName);
175
+ }
176
+
177
+ if (self.URL) {
178
+ // simple fast and modern way using Blob and URL:
179
+ saver(self.URL.createObjectURL(blob), true);
180
+ } else {
181
+ // handle non-Blob()+non-URL browsers:
182
+ if (typeof blob === "string" || blob.constructor === toString) {
183
+ try {
184
+ // @ts-ignore
185
+ return saver("data:" + mimeType + ";base64," + self.btoa(blob));
186
+ } catch (y) {
187
+ // @ts-ignore
188
+ return saver("data:" + mimeType + "," + encodeURIComponent(blob));
189
+ }
190
+ }
191
+
192
+ // Blob but not URL support:
193
+ reader = new FileReader();
194
+ reader.onload = function (e) {
195
+ // @ts-ignore
196
+ saver(this.result);
197
+ };
198
+ reader.readAsDataURL(blob);
199
+ }
200
+ return true;
200
201
  }