@contello/uploader 8.16.0-next.1753102198 → 8.16.0-next.1753102926
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 +1 -1
- package/dist/index.js +9 -9
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var I = /* @__PURE__ */ ((r) => (r.retain = "retain", r.
|
|
1
|
+
var I = /* @__PURE__ */ ((r) => (r.retain = "retain", r.deleteIfNotUsed = "deleteIfNotUsed", r))(I || {}), x = function(r, t) {
|
|
2
2
|
return x = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
|
|
3
3
|
e.__proto__ = n;
|
|
4
4
|
} || function(e, n) {
|
|
@@ -193,7 +193,7 @@ var T = function(r) {
|
|
|
193
193
|
P(t, r);
|
|
194
194
|
function t(e) {
|
|
195
195
|
var n = r.call(this) || this;
|
|
196
|
-
return n.isStopped = !1, e ? (n.destination = e, J(e) && e.add(n)) : n.destination =
|
|
196
|
+
return n.isStopped = !1, e ? (n.destination = e, J(e) && e.add(n)) : n.destination = N, n;
|
|
197
197
|
}
|
|
198
198
|
return t.create = function(e, n, o) {
|
|
199
199
|
return new w(e, n, o);
|
|
@@ -269,19 +269,19 @@ function S(r) {
|
|
|
269
269
|
function D(r) {
|
|
270
270
|
throw r;
|
|
271
271
|
}
|
|
272
|
-
var
|
|
272
|
+
var N = {
|
|
273
273
|
closed: !0,
|
|
274
274
|
next: W,
|
|
275
275
|
error: D,
|
|
276
276
|
complete: W
|
|
277
|
-
},
|
|
277
|
+
}, X = function() {
|
|
278
278
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
279
279
|
}();
|
|
280
|
-
function
|
|
280
|
+
function G(r) {
|
|
281
281
|
return r;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
return r.length === 0 ?
|
|
283
|
+
function K(r) {
|
|
284
|
+
return r.length === 0 ? G : r.length === 1 ? r[0] : function(e) {
|
|
285
285
|
return r.reduce(function(n, o) {
|
|
286
286
|
return o(n);
|
|
287
287
|
}, e);
|
|
@@ -325,12 +325,12 @@ var $ = function() {
|
|
|
325
325
|
}, r.prototype._subscribe = function(t) {
|
|
326
326
|
var e;
|
|
327
327
|
return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
|
|
328
|
-
}, r.prototype[
|
|
328
|
+
}, r.prototype[X] = function() {
|
|
329
329
|
return this;
|
|
330
330
|
}, r.prototype.pipe = function() {
|
|
331
331
|
for (var t = [], e = 0; e < arguments.length; e++)
|
|
332
332
|
t[e] = arguments[e];
|
|
333
|
-
return
|
|
333
|
+
return K(t)(this);
|
|
334
334
|
}, r.prototype.toPromise = function(t) {
|
|
335
335
|
var e = this;
|
|
336
336
|
return t = z(t), new t(function(n, o) {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(v,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(v=typeof globalThis<"u"?globalThis:v||self,S(v.ContelloUploader={}))})(this,function(v){"use strict";var S=(r=>(r.retain="retain",r.
|
|
1
|
+
(function(v,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(v=typeof globalThis<"u"?globalThis:v||self,S(v.ContelloUploader={}))})(this,function(v){"use strict";var S=(r=>(r.retain="retain",r.deleteIfNotUsed="deleteIfNotUsed",r))(S||{}),O=function(r,t){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},O(r,t)};function x(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");O(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function R(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),o,i=[],u;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){u={error:c}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return i}function P(r,t,e){if(e||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return r.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function d(r){return typeof r=="function"}function j(r){var t=function(n){Error.call(n),n.stack=new Error().stack},e=r(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var T=j(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(n,o){return o+1+") "+n.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function F(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var A=function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,n,o,i;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var c=R(u),s=c.next();!s.done;s=c.next()){var l=s.value;l.remove(this)}}catch(f){t={error:f}}finally{try{s&&!s.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else u.remove(this);var a=this.initialTeardown;if(d(a))try{a()}catch(f){i=f instanceof T?f.errors:[f]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var y=R(p),b=y.next();!b.done;b=y.next()){var E=b.value;try{W(E)}catch(f){i=i??[],f instanceof T?i=P(P([],_(i)),_(f.errors)):i.push(f)}}}catch(f){n={error:f}}finally{try{b&&!b.done&&(o=y.return)&&o.call(y)}finally{if(n)throw n.error}}}if(i)throw new T(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)W(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&F(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&F(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=function(){var t=new r;return t.closed=!0,t}(),r}();A.EMPTY;function L(r){return r instanceof A||r&&"closed"in r&&d(r.remove)&&d(r.add)&&d(r.unsubscribe)}function W(r){d(r)?r():r.unsubscribe()}var H={Promise:void 0},I={setTimeout:function(r,t){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,P([r,t],_(e)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function V(r){I.setTimeout(function(){throw r})}function z(){}function q(r){r()}var U=function(r){x(t,r);function t(e){var n=r.call(this)||this;return n.isStopped=!1,e?(n.destination=e,L(e)&&e.add(n)):n.destination=
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function F(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var A=function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,n,o,i;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var c=R(u),s=c.next();!s.done;s=c.next()){var l=s.value;l.remove(this)}}catch(f){t={error:f}}finally{try{s&&!s.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else u.remove(this);var a=this.initialTeardown;if(d(a))try{a()}catch(f){i=f instanceof T?f.errors:[f]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var y=R(p),b=y.next();!b.done;b=y.next()){var E=b.value;try{W(E)}catch(f){i=i??[],f instanceof T?i=P(P([],_(i)),_(f.errors)):i.push(f)}}}catch(f){n={error:f}}finally{try{b&&!b.done&&(o=y.return)&&o.call(y)}finally{if(n)throw n.error}}}if(i)throw new T(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)W(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&F(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&F(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=function(){var t=new r;return t.closed=!0,t}(),r}();A.EMPTY;function L(r){return r instanceof A||r&&"closed"in r&&d(r.remove)&&d(r.add)&&d(r.unsubscribe)}function W(r){d(r)?r():r.unsubscribe()}var H={Promise:void 0},I={setTimeout:function(r,t){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,P([r,t],_(e)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function V(r){I.setTimeout(function(){throw r})}function z(){}function q(r){r()}var U=function(r){x(t,r);function t(e){var n=r.call(this)||this;return n.isStopped=!1,e?(n.destination=e,L(e)&&e.add(n)):n.destination=N,n}return t.create=function(e,n,o){return new w(e,n,o)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(A),Y=function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(n){g(n)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(n){g(n)}else g(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){g(e)}},r}(),w=function(r){x(t,r);function t(e,n,o){var i=r.call(this)||this,u;return d(e)||!e?u={next:e??void 0,error:n??void 0,complete:o??void 0}:u=e,i.destination=new Y(u),i}return t}(U);function g(r){V(r)}function D(r){throw r}var N={closed:!0,next:z,error:D,complete:z},X=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function G(r){return r}function K(r){return r.length===0?G:r.length===1?r[0]:function(e){return r.reduce(function(n,o){return o(n)},e)}}var B=function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,n){var o=this,i=Z(t)?t:new w(t,e,n);return q(function(){var u=o,c=u.operator,s=u.source;i.add(c?c.call(i,s):s?o._subscribe(i):o._trySubscribe(i))}),i},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var n=this;return e=J(e),new e(function(o,i){var u=new w({next:function(c){try{t(c)}catch(s){i(s),u.unsubscribe()}},error:i,complete:o});n.subscribe(u)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[X]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return K(t)(this)},r.prototype.toPromise=function(t){var e=this;return t=J(t),new t(function(n,o){var i;e.subscribe(function(u){return i=u},function(u){return o(u)},function(){return n(i)})})},r.create=function(t){return new r(t)},r}();function J(r){var t;return(t=r??H.Promise)!==null&&t!==void 0?t:Promise}function Q(r){return r&&d(r.next)&&d(r.error)&&d(r.complete)}function Z(r){return r&&r instanceof U||Q(r)&&L(r)}function rr(r){return d(r?.lift)}function tr(r){return function(t){if(rr(t))return t.lift(function(e){try{return r(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function er(r,t,e,n,o){return new nr(r,t,e,n,o)}var nr=function(r){x(t,r);function t(e,n,o,i,u,c){var s=r.call(this,e)||this;return s.onFinalize=u,s.shouldUnsubscribe=c,s._next=n?function(l){try{n(l)}catch(a){e.error(a)}}:r.prototype._next,s._error=i?function(l){try{i(l)}catch(a){e.error(a)}finally{this.unsubscribe()}}:r.prototype._error,s._complete=o?function(){try{o()}catch(l){e.error(l)}finally{this.unsubscribe()}}:r.prototype._complete,s}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(U),or=j(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function ir(r,t){return new Promise(function(e,n){var o=new w({next:function(i){e(i),o.unsubscribe()},error:n,complete:function(){n(new or)}});r.subscribe(o)})}function sr(r,t){return tr(function(e,n){var o=0;e.subscribe(er(n,function(i){return r.call(t,i,o++)&&n.next(i)}))})}function ur({url:r,project:t,token:e,chunkSize:n},o,i,u){const c={...i??{},projectRef:t};return new B(s=>{const l=new URL(r),a=new WebSocket(`${l.protocol==="https:"?"wss":"ws"}://${l.host}/api/v1/assets/ws`,"contello-file-upload-v1"),p=typeof FileReader<"u"?new FileReader:null;let y=0,b=!1,E=!1;a.onopen=async()=>{const k={type:"init",metadata:{...c,name:o.name,mimeType:o.type,size:o.size},token:e};a.send(JSON.stringify(k));function $(){const m=o.slice(y,y+n);p?p.readAsArrayBuffer(m):m.arrayBuffer().then(h=>{C(h)}).catch(h=>{s.error(h)})}function M(){p?.abort(),a.send(JSON.stringify({type:"done"}))}function lr(){E&&$()}function C(m){a.readyState===WebSocket.OPEN?(a.send(m),y+=m.byteLength,y<o.size?$():M()):(s.error(new Error("WebSocket is closed")),p?.abort())}p&&(p.onload=()=>{p.result&&p.result instanceof ArrayBuffer?C(p.result):M()}),a.onmessage=m=>{const h=JSON.parse(m.data);if(h.type==="ack"){E=!0,lr();return}if(h.type==="progress")return s.next({progress:h.bytesReceived/o.size*100});if(h.type==="done")return h.id?(b=!0,s.next({id:h.id}),s.complete()):s.error(new Error("No asset id received")),a.close();s.error(new Error("WebSocket message with unknown type "+JSON.stringify(h))),a.close()}},a.onerror=k=>s.error(k),a.onclose=()=>{b||s.error(new Error("Connection closed"))};const f=()=>{b||(p?.abort(),a.close(),s.error(new Error("Upload aborted")))};return u?.abort?.addEventListener("abort",f),()=>{u?.abort?.removeEventListener("abort",f),a.close()}})}function cr({url:r,project:t,token:e},n,o,i){return new B(u=>{const c=new FormData;c.append("metadata",JSON.stringify({...o??{},projectRef:t})),c.append("file",n);const s=new XMLHttpRequest;return s.setRequestHeader("Authorization",`Bearer ${e}`),s.open("POST",`${r}/api/v1/assets`,!0),s.upload.onprogress=async l=>{l.lengthComputable&&u.next({progress:l.loaded/l.total*100})},s.onload=async()=>{if(s.status>=200&&s.status<300){const{id:l}=JSON.parse(s.responseText);return u.next({id:l}),u.complete()}u.error(new Error(`${s.status}: ${s.statusText}`))},s.onerror=l=>u.error(l),s.send(c),i?.abort?.addEventListener("abort",()=>s.abort()),()=>s.abort()})}class ar{params;constructor(t){this.params={url:t.url,project:t.project,token:t.token,transport:t.transport||"ws",chunkSize:t.chunkSize||4*1024*1024}}async upload(t,e,n){return ir(this.uploadWithEvents(t,e,n).pipe(sr(o=>"id"in o)))}uploadWithEvents(t,e,n){return this.params.transport==="http"?cr(this.params,t,e,n):ur(this.params,t,e,n)}}v.ContelloUploader=ar,v.UploadAssetRetentionPolicy=S,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED