@contello/uploader 8.21.0 → 8.21.2

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,33 +1,27 @@
1
1
  {
2
2
  "name": "@contello/uploader",
3
+ "version": "8.21.2",
4
+ "description": "File uploader for Contello CMS with WebSocket and HTTP transports",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "admin@entwico.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/entwico/contello-js",
11
+ "directory": "packages/uploader"
12
+ },
3
13
  "scripts": {
4
- "start": "vite build --watch",
5
- "build": "rm -rf dist/ && vite build",
6
- "lint": "eslint . --report-unused-disable-directives --max-warnings 0",
7
- "patch": "node ci/patcher.js"
14
+ "build": "tsup",
15
+ "lint": "eslint .",
16
+ "lint:fix": "eslint . --fix",
17
+ "typecheck": "tsc --noEmit"
8
18
  },
9
19
  "peerDependencies": {
10
20
  "rxjs": ">=5.0.0"
11
21
  },
12
22
  "devDependencies": {
13
- "rxjs": "^7.8.2",
14
- "@types/node": "^24.0.10",
15
- "@typescript-eslint/eslint-plugin": "^8.35.1",
16
- "eslint": "^9.30.1",
17
- "eslint-config-prettier": "^10.1.5",
18
- "eslint-plugin-import": "^2.32.0",
19
- "eslint-plugin-prettier": "^5.5.1",
20
- "npm-run-all": "^4.1.5",
21
- "typescript": "^5.8.3",
22
- "typescript-eslint": "^8.35.1",
23
- "graphql": "^16.11.0",
24
- "graphql-ws": "^6.0.5",
25
- "vite": "^7.0.2",
26
- "vite-plugin-dts": "^4.5.4"
23
+ "rxjs": "^7.8.2"
27
24
  },
28
- "author": "admin@entwico.com",
29
- "license": "MIT",
30
- "type": "module",
31
25
  "files": [
32
26
  "dist"
33
27
  ],
@@ -35,12 +29,11 @@
35
29
  "exports": {
36
30
  ".": {
37
31
  "import": "./dist/index.js",
38
- "require": "./dist/index.umd.cjs"
32
+ "require": "./dist/index.cjs"
39
33
  }
40
34
  },
41
35
  "publishConfig": {
42
36
  "access": "public",
43
37
  "registry": "https://registry.npmjs.org"
44
- },
45
- "version": "8.21.0"
46
- }
38
+ }
39
+ }
@@ -1,3 +0,0 @@
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
- `+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=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"})});