@qooal/vault 0.0.0-stage → 0.1.0
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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +270 -2
- package/dist/chunks/chunk-2AAWIHQO.js +1028 -0
- package/dist/chunks/chunk-MKUYQFGG.js +90 -0
- package/dist/chunks/chunk-PEWIUW3U.js +484 -0
- package/dist/chunks/chunk-Z5XT6XS2.js +115 -0
- package/dist/index.js +24 -0
- package/dist/next.js +65 -0
- package/dist/react.js +259 -0
- package/dist/server.js +357 -0
- package/dist/sign.js +20 -0
- package/dist/types/http.d.ts +49 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/next.d.ts +39 -0
- package/dist/types/react/index.d.ts +93 -0
- package/dist/types/react/props.d.ts +56 -0
- package/dist/types/server/client.d.ts +160 -0
- package/dist/types/server/index.d.ts +16 -0
- package/dist/types/server/sign-url.d.ts +28 -0
- package/dist/types/server/webhook.d.ts +31 -0
- package/dist/types/sign.d.ts +48 -0
- package/dist/types/types.d.ts +415 -0
- package/dist/types/upload/element.d.ts +45 -0
- package/dist/types/upload/index.d.ts +14 -0
- package/dist/types/upload/perform.d.ts +66 -0
- package/dist/types/upload/uploader.d.ts +62 -0
- package/dist/types/url.d.ts +163 -0
- package/dist/upload.js +28 -0
- package/dist/widget.js +34 -0
- package/package.json +82 -4
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qooal Vault's delivery URL grammar: build, parse and check delivery URLs.
|
|
3
|
+
*
|
|
4
|
+
* Pure: no I/O, no dependencies, runs in browsers, Node and edge runtimes.
|
|
5
|
+
*/
|
|
6
|
+
export type VaultResourceType = "image" | "video" | "raw";
|
|
7
|
+
export type VaultDelivery = "upload" | "private" | "authenticated";
|
|
8
|
+
export type VaultHostName = "media" | "video" | "files" | "dl";
|
|
9
|
+
/** Every grammar refusal; the edge answers 400 with this `code`. */
|
|
10
|
+
export type VaultGrammarCode = "bad_library" | "bad_resource" | "bad_delivery" | "bad_signature_format" | "unknown_param" | "duplicate_param" | "bad_value" | "out_of_range" | "conflicting_params" | "too_many_components" | "bad_public_id" | "bad_extension" | "bad_version" | "bad_query" | "path_too_long" | "not_canonical";
|
|
11
|
+
export declare class VaultGrammarError extends Error {
|
|
12
|
+
readonly code: VaultGrammarCode;
|
|
13
|
+
constructor(code: VaultGrammarCode, detail?: string);
|
|
14
|
+
}
|
|
15
|
+
export type VaultCrop = "scale" | "fit" | "limit" | "fill" | "pad" | "thumb" | "crop";
|
|
16
|
+
export type VaultGravity = "auto" | "center" | "north" | "north_east" | "east" | "south_east" | "south" | "south_west" | "west" | "north_west";
|
|
17
|
+
/**
|
|
18
|
+
* A parsed, normalised transformation: `dpr` and foldable `ar` are folded into `w`/`h`, defaults are
|
|
19
|
+
* removed (unless a `t_` preset is present, because then an explicit default overrides the preset), `jpeg` is `jpg`,
|
|
20
|
+
* `e` and `fl` are sorted. A concrete `f` stays here; a delivery path folds it into the extension.
|
|
21
|
+
*/
|
|
22
|
+
export interface VaultTransformation {
|
|
23
|
+
t?: string;
|
|
24
|
+
c?: VaultCrop;
|
|
25
|
+
g?: VaultGravity;
|
|
26
|
+
/** reduced by the GCD; present only when neither `w` nor `h` is */
|
|
27
|
+
ar?: [number, number];
|
|
28
|
+
w?: number;
|
|
29
|
+
h?: number;
|
|
30
|
+
x?: number;
|
|
31
|
+
y?: number;
|
|
32
|
+
a?: 90 | 180 | 270;
|
|
33
|
+
/** sorted: `blur:<n>`, `grayscale`, `sharpen` */
|
|
34
|
+
e: string[];
|
|
35
|
+
/** `white` is the default and removed; `black`, `transparent`, `rgb:<6 lowercase hex>` */
|
|
36
|
+
b?: string;
|
|
37
|
+
/** `auto` (only kept beside `t_`), `auto:low`, `auto:eco`, `auto:best`, or `1`-`100` */
|
|
38
|
+
q?: string;
|
|
39
|
+
/** `auto`, `jpg`, `png`, `gif`, `webp`, `avif` */
|
|
40
|
+
f?: string;
|
|
41
|
+
/** sorted: `animated`, `attachment` or `attachment:<name>`, `progressive`, `sanitize` */
|
|
42
|
+
fl: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parses and normalises one transformation component. Throws VaultGrammarError. The empty string is the
|
|
46
|
+
* empty transformation.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseTransformation(s: string): VaultTransformation;
|
|
49
|
+
/**
|
|
50
|
+
* The canonical form of a transformation: parameters in the order t, c, g, ar, w, h, x, y, a, e, b, q, f, fl;
|
|
51
|
+
* repeated e and fl sorted; defaults removed; dpr and foldable ar folded; jpeg → jpg. "" for the empty one.
|
|
52
|
+
* A string is parsed first (and may throw VaultGrammarError).
|
|
53
|
+
*/
|
|
54
|
+
export declare function canonicalTransformation(t: string | VaultTransformation): string;
|
|
55
|
+
/**
|
|
56
|
+
* Checks a public ID: 1-10 `/`-joined segments of `[A-Za-z0-9][A-Za-z0-9_-]{0,99}`, at most 255 bytes, no
|
|
57
|
+
* dots; reserved: a first segment that looks like a transformation, any `v<digits>` or `s--…--` segment.
|
|
58
|
+
* Throws `bad_public_id`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function assertPublicId(publicId: string): void;
|
|
61
|
+
export interface ParsedVaultPath {
|
|
62
|
+
/** the `/_fa/<format>/` prefix the CDN adds in front of a path, never signed */
|
|
63
|
+
fa: "avif" | "webp" | "legacy" | null;
|
|
64
|
+
library: string;
|
|
65
|
+
resource: VaultResourceType;
|
|
66
|
+
delivery: VaultDelivery;
|
|
67
|
+
/** the full `s--…--` component */
|
|
68
|
+
signature: string | null;
|
|
69
|
+
/** the canonical transformation without `t_` (and without a concrete `f`, which moved into the extension) */
|
|
70
|
+
transformation: string | null;
|
|
71
|
+
/** the `t_<preset>` name */
|
|
72
|
+
preset: string | null;
|
|
73
|
+
version: number | null;
|
|
74
|
+
publicId: string;
|
|
75
|
+
/** canonical (`jpeg` → `jpg`); for an HLS child this is null */
|
|
76
|
+
extension: string | null;
|
|
77
|
+
/** an HLS child: `<public_id>.hls/<rung>/<file>` */
|
|
78
|
+
hls: {
|
|
79
|
+
rung: string;
|
|
80
|
+
file: string;
|
|
81
|
+
} | null;
|
|
82
|
+
exp: number | null;
|
|
83
|
+
tok: string | null;
|
|
84
|
+
/** what a signature covers: `<resource>/<delivery>/<rest>`, rest exactly as sent after the signature component */
|
|
85
|
+
signedPart: string;
|
|
86
|
+
/** whether the path (without `/_fa/…` and the query) is already canonical */
|
|
87
|
+
canonical: boolean;
|
|
88
|
+
/** the canonical path (no `/_fa/…`), with the query in the order exp, tok */
|
|
89
|
+
canonicalPath: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Parses a delivery path with its optional query, e.g. `/acme-shop/image/upload/c_fill,w_400/v3/shoes/red.jpg`.
|
|
93
|
+
* Throws VaultGrammarError; a signed path that is not canonical throws `not_canonical`. Custom domains: the edge
|
|
94
|
+
* prefixes `/<slug>` before parsing. Download links (`/<library>/dl/…`) are routed before the grammar.
|
|
95
|
+
*/
|
|
96
|
+
export declare function parseVaultPath(input: string): ParsedVaultPath;
|
|
97
|
+
/**
|
|
98
|
+
* Default delivery hosts: every host is under the one Vault domain, `qooalcdn.com`. Prefer each library's own base
|
|
99
|
+
* URLs from the API (`VaultLibrary.urls`).
|
|
100
|
+
*/
|
|
101
|
+
export declare const VAULT_PLACEHOLDER_HOSTS: {
|
|
102
|
+
readonly media: "https://media.qooalcdn.com";
|
|
103
|
+
readonly video: "https://video.qooalcdn.com";
|
|
104
|
+
readonly files: "https://files.qooalcdn.com";
|
|
105
|
+
readonly dl: "https://dl.qooalcdn.com";
|
|
106
|
+
readonly upload: "https://upload.qooalcdn.com";
|
|
107
|
+
};
|
|
108
|
+
/** A library's base URLs, each including the slug (e.g. https://media.qooalcdn.com/acme-shop). */
|
|
109
|
+
export declare function vaultLibraryUrls(slug: string, hosts?: Record<VaultHostName | "upload", string>): {
|
|
110
|
+
media: string;
|
|
111
|
+
video: string;
|
|
112
|
+
files: string;
|
|
113
|
+
dl: string;
|
|
114
|
+
upload: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A library for the URL builder: one base URL including the slug (used for every resource), or the library's base
|
|
118
|
+
* URLs per host (a `VaultLibrary` from the API fits as is).
|
|
119
|
+
*/
|
|
120
|
+
export type VaultUrlLibrary = string | {
|
|
121
|
+
urls: {
|
|
122
|
+
media: string;
|
|
123
|
+
video?: string;
|
|
124
|
+
files?: string;
|
|
125
|
+
dl?: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export interface VaultUrlOptions {
|
|
129
|
+
/** default "image" */
|
|
130
|
+
resourceType?: VaultResourceType;
|
|
131
|
+
/** default "upload" (public assets); private and authenticated URLs need a signature */
|
|
132
|
+
delivery?: VaultDelivery;
|
|
133
|
+
/** any valid transformation; emitted in canonical form */
|
|
134
|
+
transformation?: string;
|
|
135
|
+
/**
|
|
136
|
+
* The extension: the output format for images and posters (`f_<format>` folds into it), `m3u8` or `mp4` for video
|
|
137
|
+
* streams, the stored extension for raw files.
|
|
138
|
+
*/
|
|
139
|
+
format?: string;
|
|
140
|
+
/** `v<n>`: the asset's current version gets immutable caching */
|
|
141
|
+
version?: number;
|
|
142
|
+
/** the host to use; default media for images and posters, video for streams, files for raw */
|
|
143
|
+
host?: VaultHostName;
|
|
144
|
+
/** a precomputed `s--…--` component (signPath, or the server's signUrl) */
|
|
145
|
+
signature?: string;
|
|
146
|
+
/** Unix seconds; emitted as `?exp=` (required for authenticated delivery) */
|
|
147
|
+
expiresAt?: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* What a signature covers for this URL: `<resource>/<delivery>/<rest>`. Sign it with `signPath` (from
|
|
151
|
+
* `@qooal/vault/sign`, or the server), then pass the result as `signature`.
|
|
152
|
+
*/
|
|
153
|
+
export declare function vaultSignedPart(publicId: string, opts?: VaultUrlOptions): string;
|
|
154
|
+
/**
|
|
155
|
+
* A canonical delivery URL, e.g. `vaultUrl(lib, "shoes/red", { transformation: "w_400,c_fill,h_400",
|
|
156
|
+
* format: "webp" })`. Throws VaultGrammarError for anything the grammar refuses.
|
|
157
|
+
*/
|
|
158
|
+
export declare function vaultUrl(lib: VaultUrlLibrary, publicId: string, opts?: VaultUrlOptions): string;
|
|
159
|
+
/**
|
|
160
|
+
* A `srcset` value: one URL per width (`url 320w, url 640w`). The width replaces `w`; a given `h` scales with it
|
|
161
|
+
* (half up), and an `ar` folds into it.
|
|
162
|
+
*/
|
|
163
|
+
export declare function srcSet(lib: VaultUrlLibrary, publicId: string, widths: readonly number[], opts?: VaultUrlOptions): string;
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LABELS,
|
|
3
|
+
VAULT_UPLOADER_TAG,
|
|
4
|
+
acceptsFile,
|
|
5
|
+
createUploader,
|
|
6
|
+
defineVaultUploader,
|
|
7
|
+
fetchPut,
|
|
8
|
+
formatBytes,
|
|
9
|
+
performUpload,
|
|
10
|
+
xhrPut
|
|
11
|
+
} from "./chunks/chunk-2AAWIHQO.js";
|
|
12
|
+
import {
|
|
13
|
+
VAULT_API_BASE,
|
|
14
|
+
VaultApiError
|
|
15
|
+
} from "./chunks/chunk-Z5XT6XS2.js";
|
|
16
|
+
export {
|
|
17
|
+
DEFAULT_LABELS,
|
|
18
|
+
VAULT_API_BASE,
|
|
19
|
+
VAULT_UPLOADER_TAG,
|
|
20
|
+
VaultApiError,
|
|
21
|
+
acceptsFile,
|
|
22
|
+
createUploader,
|
|
23
|
+
defineVaultUploader,
|
|
24
|
+
fetchPut,
|
|
25
|
+
formatBytes,
|
|
26
|
+
performUpload,
|
|
27
|
+
xhrPut
|
|
28
|
+
};
|
package/dist/widget.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* Qooal Vault upload widget. https://qooal.com/vault */
|
|
2
|
+
"use strict";var QooalVault=(()=>{var N=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var st=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},nt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of et(t))!rt.call(e,n)&&n!==r&&N(e,n,{get:()=>t[n],enumerable:!(s=tt(t,n))||s.enumerable});return e};var at=e=>nt(N({},"__esModule",{value:!0}),e);var kt={};st(kt,{VAULT_UPLOADER_TAG:()=>J,VaultApiError:()=>b,createUploader:()=>F,defineVaultUploader:()=>B,performUpload:()=>O});var X="https://api.qooal.com/v1/vault",b=class extends Error{status;code;reason;errors;requestId;retryAfter;constructor(t){super(t.message??(t.reason?`${t.code}: ${t.reason}`:`${t.code} (HTTP ${t.status})`)),this.name="VaultApiError",this.status=t.status,this.code=t.code,this.reason=t.reason??null,this.errors=t.errors??[],this.requestId=t.requestId??null,this.retryAfter=t.retryAfter??null}};function G(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function M(e,t,r){let s=null;try{s=G(JSON.parse(t))}catch{s=null}let n=y=>{let u=s?.[y];return typeof u=="string"?u:null},i=[];if(Array.isArray(s?.errors))for(let y of s.errors){let u=G(y);if(!u)continue;let T={pointer:typeof u.pointer=="string"?u.pointer:typeof u.field=="string"?u.field:"",code:typeof u.code=="string"?u.code:"invalid"};typeof u.message=="string"?T.message=u.message:typeof u.detail=="string"&&(T.message=u.detail),i.push(T)}let a=r!==null&&/^\d{1,6}$/.test(r.trim())?Number(r.trim()):null,f=n("detail")??n("title")??void 0;return new b({status:e,code:n("code")??(e===0?"network":`http_${e}`),reason:n("reason"),...f!==void 0?{message:f}:{},errors:i,requestId:n("requestId"),retryAfter:a})}function R(e){return e===0||e===408||e===425||e===429||e>=500}function _(e){return Math.floor(Math.random()*Math.min(8e3,500*2**e))}function A(e){return e?.reason??new DOMException("The upload was aborted.","AbortError")}function z(e,t){return new Promise((r,s)=>{if(t?.aborted)return s(A(t));if(e<=0)return r();let i=setTimeout(()=>{t?.removeEventListener("abort",a),r()},e);function a(){clearTimeout(i),s(A(t))}t?.addEventListener("abort",a,{once:!0})})}function H(){let e=globalThis.crypto.getRandomValues(new Uint8Array(16)),t=Date.now(),r=Math.floor(t/2**32),s=t>>>0;e[0]=r>>>8&255,e[1]=r&255,e[2]=s>>>24,e[3]=s>>>16&255,e[4]=s>>>8&255,e[5]=s&255,e[6]=e[6]&15|112,e[8]=e[8]&63|128;let n=Array.from(e,i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function j(e){if(e==="")throw new TypeError("an empty path segment");return encodeURIComponent(e)}var ot=new Set(["host","content-length","connection","expect","transfer-encoding"]),it=e=>new Promise((t,r)=>{if(e.signal.aborted)return r(A(e.signal));let s=new XMLHttpRequest,n=()=>s.abort(),i=a=>{e.signal.removeEventListener("abort",n),t({status:a,etag:a?s.getResponseHeader("ETag"):null,text:a?s.responseText:"",retryAfter:a?s.getResponseHeader("Retry-After"):null})};s.open("PUT",e.url);for(let[a,f]of Object.entries(e.headers))s.setRequestHeader(a,f);s.upload.addEventListener("progress",a=>e.onProgress(a.loaded)),s.addEventListener("load",()=>i(s.status)),s.addEventListener("error",()=>i(0)),s.addEventListener("timeout",()=>i(0)),s.addEventListener("abort",()=>{e.signal.removeEventListener("abort",n),r(A(e.signal))}),e.signal.addEventListener("abort",n,{once:!0}),s.send(e.body)});function lt(e=globalThis.fetch){return async t=>{try{let r=await e(t.url,{method:"PUT",body:t.body,headers:t.headers,signal:t.signal}),s=await r.text();return t.onProgress(t.body.size),{status:r.status,etag:r.headers.get("etag"),text:s,retryAfter:r.headers.get("retry-after")}}catch{if(t.signal.aborted)throw A(t.signal);return{status:0,etag:null,text:"",retryAfter:null}}}}function dt(e){return e.put?e.put:!e.fetch&&typeof XMLHttpRequest=="function"?it:lt(e.fetch)}function Q(e,t,r,s,n){if(e===void 0)return t;if(!Number.isInteger(e)||e<r||e>s)throw new RangeError(`${n} must be an integer ${r}-${s}`);return e}function ut(e){if(e.text.trimStart().startsWith("<")){let t=/<Code>([A-Za-z]+)<\/Code>/.exec(e.text)?.[1]??null;return new b({status:e.status,code:"storage_error",reason:t})}return M(e.status,e.text,e.retryAfter)}function ct(e){return R(e.status)||e.status===400&&e.text.includes("<Code>RequestTimeout</Code>")}function pt(e){let t={};for(let r of e){let s=r.name.toLowerCase();ot.has(s)||(t[s]=r.value)}return t}async function O(e,t,r={}){if(t.method==="simulated")throw new b({status:0,code:"invalid",reason:"simulated_upload",message:"Simulated uploads are sample data: there is nowhere to send the bytes."});let s=Q(r.concurrency,4,1,16,"concurrency"),n=Q(r.retries,3,0,10,"retries"),i=dt(r),a=r.signal;if(a?.aborted)throw A(a);let f=r.retryDelay??((v,E)=>E!==null?Math.min(E,30)*1e3:_(v)),y=e.size,u=new AbortController,P=()=>u.abort(A(a));a?.addEventListener("abort",P,{once:!0});let T=new Map,U=()=>{if(!r.onProgress)return;let v=0;for(let E of T.values())v+=E;r.onProgress({loaded:Math.min(v,y),total:y})},V=async(v,E,h,o,p)=>{let c=await o();for(let m=0;;m++){if(u.signal.aborted)throw A(u.signal);T.set(v,0);let d=await i({url:c,body:E,headers:h,signal:u.signal,onProgress:x=>{T.set(v,Math.min(x,E.size)),U()}});if(d.status>=200&&d.status<300)return T.set(v,E.size),U(),d;T.set(v,0),U();let w=m<n;if(w&&d.status===403&&p){c=await p();continue}if(!w||!ct(d))throw ut(d);let g=d.retryAfter!==null&&/^\d+$/.test(d.retryAfter)?Number(d.retryAfter):null;await z(f(m,g),u.signal)}};try{if(t.method==="proxy"||t.method==="single"){let l=pt(t.headers),S=t.uploadToken??r.uploadToken;t.method==="proxy"&&!l.authorization&&S&&(l.authorization=`VaultUpload ${S}`);let L=e.slice(0,y,l["content-type"]??""),$=await V(1,L,l,async()=>t.url,null),q={uploadId:t.uploadId,method:t.method};if(t.method==="proxy"&&$.text)try{q.asset=JSON.parse($.text)}catch{}return q}let{partSize:v,partCount:E}=t;if(!Number.isInteger(v)||v<1||E!==Math.max(1,Math.ceil(y/v)))throw new b({status:0,code:"invalid",reason:"size_mismatch",message:`The file is ${y} bytes, which does not make ${E} parts of ${v} bytes.`});let h=l=>Math.min(v,y-(l-1)*v),o=new Map;for(let l of t.parts)o.set(l.n,l.url);let p=new Map;for(let l of r.done??[])Number.isInteger(l.n)&&l.n>=1&&l.n<=E&&l.etag&&(p.set(l.n,l.etag),T.set(l.n,h(l.n)));U();let c=[];for(let l=1;l<=E;l++)p.has(l)||c.push(l);let m=0,d=null,w=async l=>{for(;;){let S=o.get(l);if(S!==void 0)return S;if(d){await d;continue}if(!r.requestParts)throw new b({status:0,code:"invalid",reason:"missing_part_url",message:`No URL for part ${l}, and no requestParts callback to ask for one.`});let L=[l];for(let q=m;q<c.length&&L.length<100;q++){let C=c[q];C!==l&&!o.has(C)&&L.push(C)}let $=r.requestParts(L).then(q=>{for(let C of q)o.set(C.n,C.url)});d=$;try{await $}finally{d=null}if(u.signal.aborted)throw A(u.signal);if(!o.has(l))throw new b({status:0,code:"invalid",reason:"missing_part_url",message:`requestParts did not return part ${l}.`})}},g={failure:null},x=async()=>{for(;g.failure===null&&m<c.length;){let l=c[m++],S=(l-1)*v,L=await V(l,e.slice(S,S+h(l),""),{},()=>w(l),()=>(o.delete(l),w(l)));if(!L.etag)throw new b({status:L.status,code:"storage_error",reason:"etag_missing",message:"S3 answered without an ETag header (the bucket's CORS rules must expose ETag)."});p.set(l,L.etag),r.onPartDone?.({n:l,etag:L.etag})}};if(await Promise.all(Array.from({length:Math.min(s,Math.max(c.length,1))},()=>x().catch(l=>{g.failure===null&&(g.failure={error:l},u.abort(l))}))),a?.aborted)throw A(a);if(g.failure!==null)throw g.failure.error;let I=[];for(let l=1;l<=E;l++)I.push({n:l,etag:p.get(l)});return{uploadId:t.uploadId,method:"multipart",parts:I}}finally{a?.removeEventListener("abort",P)}}var ft=new Set(["ticket_exhausted","ticket_expired","ticket_revoked"]);function gt(){try{return globalThis.localStorage??null}catch{return null}}function ht(e,t,r){let s=t.lastModified??0;return`qooal-vault:upload:${e}:${r}:${t.size}:${s}`}var K=e=>`VaultUpload ${e}`;function F(e){if(!e.library)throw new TypeError("createUploader: `library` is required");if(e.ticket===void 0==(e.preset===void 0))throw new TypeError("createUploader: give exactly one of `ticket` and `preset`");if(e.preset!==void 0&&e.turnstile===void 0)throw new TypeError("createUploader: an unsigned preset needs a `turnstile` token provider");let t=(e.apiBase??X).replace(/\/+$/,""),r=e.fetch??globalThis.fetch.bind(globalThis),s=e.retries??3,n=e.retryDelay??((h,o)=>o!==null?Math.min(o,30)*1e3:_(h)),i=e.storage===void 0?gt():e.storage,a=j(e.library),f=null,y=async h=>typeof e.ticket=="string"?e.ticket:((f===null||h)&&(f=await e.ticket()),f),u=async()=>typeof e.turnstile=="function"?await e.turnstile():e.turnstile,P=async(h,o,p)=>{let c={accept:"application/json"};p.auth&&(c.authorization=p.auth),p.body!==void 0&&(c["content-type"]="application/json"),p.idem&&(c["idempotency-key"]=p.idem);for(let m=0;;m++){if(p.signal?.aborted)throw A(p.signal);let d;try{let g=await r(`${t}${o}`,{method:h,headers:c,body:p.body===void 0?null:JSON.stringify(p.body),credentials:"omit",signal:p.signal??null}),x=await g.text();if(g.ok)return x?JSON.parse(x):void 0;d=M(g.status,x,g.headers.get("retry-after"))}catch(g){if(p.signal?.aborted)throw A(p.signal);if(g instanceof SyntaxError)throw g;d=new b({status:0,code:"network",message:g instanceof Error?g.message:String(g)})}let w=p.retry==="unprocessed"?d.status===429||d.status===503:R(d.status);if(p.retry===!1||m>=s||!w)throw d;await z(n(m,d.retryAfter),p.signal)}},T=h=>`/libraries/${a}/uploads/${j(h)}`,U=async(h,o)=>{try{await P("DELETE",T(h),{auth:K(o),retry:!1})}catch{}},V=async(h,o,p)=>{let c=o.contentType||h.type||"application/octet-stream",m=o.idempotencyKey??H(),d=`/libraries/${a}/uploads`;if(e.preset!==void 0){if(o.folderId!==void 0||o.publicId!==void 0||o.overwrite!==void 0||o.access!==void 0||o.tags!==void 0)throw new TypeError("An unsigned preset fixes folder, public ID, overwrite, access and tags; use a ticket.");let g={uploadPreset:e.preset,turnstileToken:await u(),filename:p,bytes:h.size,contentType:c};return P("POST",d,{body:g,idem:m,signal:o.signal})}let w={filename:p,bytes:h.size,contentType:c};o.folderId!==void 0&&(w.folderId=o.folderId),o.publicId!==void 0&&(w.publicId=o.publicId),o.overwrite!==void 0&&(w.overwrite=o.overwrite),o.access!==void 0&&(w.access=o.access),o.tags!==void 0&&(w.tags=o.tags);try{return await P("POST",d,{auth:`VaultTicket ${await y(!1)}`,body:w,idem:m,signal:o.signal})}catch(g){if(!(g instanceof b&&(g.status===401||g.reason!==null&&ft.has(g.reason)))||typeof e.ticket!="function")throw g;return P("POST",d,{auth:`VaultTicket ${await y(!0)}`,body:w,idem:H(),signal:o.signal})}},v=async(h,o,p)=>{if(!i)return null;let c=null;try{let m=i.getItem(h);c=m?JSON.parse(m):null}catch{c=null}if(!c||!(Date.parse(c.expiresAt)>Date.now())||!(c.partSize>0)||c.partCount!==Math.max(1,Math.ceil(o/c.partSize)))return c&&i.removeItem(h),null;try{let m=await P("GET",T(c.uploadId),{auth:K(c.uploadToken),signal:p});if(m.state!=="open"||m.method!=="multipart")throw new Error("not resumable");let{partSize:d,partCount:w}=c,g=m.parts.filter(x=>x.n>=1&&x.n<=w&&x.etag).filter(x=>x.size===Math.min(d,o-(x.n-1)*d)).map(x=>({n:x.n,etag:x.etag}));return{token:c.uploadToken,done:g,ins:{uploadId:c.uploadId,method:"multipart",partSize:c.partSize,partCount:c.partCount,parts:[],expiresAt:c.expiresAt,asset:void 0,uploadToken:c.uploadToken}}}catch{if(p?.aborted)throw A(p);return i.removeItem(h),null}};return{upload:async(h,o={})=>{let p=o.filename??h.name??"upload",c=ht(e.library,h,p);if(o.signal?.aborted)throw A(o.signal);let m=o.resume===!1?null:await v(c,h.size,o.signal),d,w;if(m)d=m.ins,w=m.token;else{if(d=await V(h,o,p),d.method==="simulated")throw new b({status:0,code:"invalid",reason:"simulated_upload",message:"Simulated uploads are sample data: there is nowhere to send the bytes."});if(!d.uploadToken)throw new b({status:0,code:"invalid",reason:"missing_upload_token"});if(w=d.uploadToken,d.method==="multipart"&&i)try{let I={uploadId:d.uploadId,uploadToken:w,partSize:d.partSize,partCount:d.partCount,expiresAt:d.expiresAt};i.setItem(c,JSON.stringify(I))}catch{}}let g=K(w),x=()=>{try{i?.removeItem(c)}catch{}};try{let I=await O(h,d,{...o.onProgress?{onProgress:o.onProgress}:{},...o.signal?{signal:o.signal}:{},...e.concurrency!==void 0?{concurrency:e.concurrency}:{},retries:s,retryDelay:n,uploadToken:w,...e.put?{put:e.put}:e.fetch?{fetch:e.fetch}:{},...m?{done:m.done}:{},requestParts:async L=>(await P("POST",`${T(d.uploadId)}/parts`,{auth:g,body:{partNumbers:L},signal:o.signal})).parts});if(I.method==="proxy"){if(x(),I.asset)return I.asset;throw new b({status:0,code:"invalid",reason:"missing_asset"})}let l=I.parts?{parts:I.parts}:{},S=await P("POST",`${T(d.uploadId)}/complete`,{auth:g,body:l,signal:o.signal,retry:"unprocessed"});return x(),S}catch(I){let l=o.signal?.aborted===!0;throw(l||d.method!=="multipart")&&(x(),await U(d.uploadId,w)),l?A(o.signal):I}},abort:U}}var J="qooal-vault-uploader",Y={drop:"Drag and drop files here, or paste them",browse:"Choose files",camera:"Take a photo",list:"Uploads",waiting:"Waiting",uploading:"Uploading",processing:"Processing",done:"Uploaded",failed:"Failed",cancelled:"Cancelled",cancel:"Cancel",retry:"Retry",remove:"Remove",tooLarge:"File is too large",tooMany:"Too many files",wrongType:"This file type is not accepted",maxSize:"Up to {size} per file",errors:{file_too_large:"File is too large",type_not_allowed:"This file type is not allowed",storage_quota_exceeded:"Storage is full",uploads_blocked:"Uploads are paused for this library",origin_not_allowed:"Uploads are not allowed from this site",turnstile_failed:"Verification failed, please retry",ticket_exhausted:"Upload limit reached",preset_rate_limited:"Too many uploads, try again shortly",preset_cap_reached:"Upload limit reached",library_suspended:"Uploads are unavailable",network:"Network problem, please retry",default:"Upload failed"}},Z=["library","ticket","ticket-endpoint","preset","turnstile-sitekey","api-base"],mt="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",W=null;function bt(){let e=globalThis;return e.turnstile?Promise.resolve(e.turnstile):(W??=new Promise((t,r)=>{let s=document.createElement("script");s.src=mt,s.async=!0,s.addEventListener("load",()=>e.turnstile?t(e.turnstile):r(new Error("Turnstile did not load"))),s.addEventListener("error",()=>{W=null,r(new Error("Turnstile did not load"))}),document.head.appendChild(s)}),W)}function D(e){if(e<1e3)return`${e} B`;let t=["KB","MB","GB","TB"],r=e,s=-1;for(;r>=1e3&&s<t.length-1;)r/=1e3,s++;return`${r>=100?Math.round(r):Math.round(r*10)/10} ${t[s]}`}function yt(e,t){if(!t?.trim())return!0;let r=e.name.toLowerCase(),s=e.type.toLowerCase();return t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>n.startsWith(".")?r.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n)}var vt=`
|
|
3
|
+
:host{--qv-bg:#fff;--qv-fg:#020b1f;--qv-muted:#4f566a;--qv-border:rgba(2,11,31,.18);--qv-accent:#1e4dff;--qv-accent-fg:#fff;--qv-soft:#e7ecff;--qv-link:#1e4dff;--qv-track:#eceef7;--qv-danger:#c9252f;--qv-success:#0e7a52;--qv-radius:14px;display:block;font:inherit;color:var(--qv-fg);color-scheme:light}
|
|
4
|
+
:host([hidden]){display:none}
|
|
5
|
+
@media (prefers-color-scheme:dark){:host(:not([theme=light])){--qv-bg:#0a1633;--qv-fg:#ebeef6;--qv-muted:#a3abc4;--qv-border:rgba(255,255,255,.18);--qv-soft:#142154;--qv-link:#a493ff;--qv-track:#0e1c40;--qv-danger:#ff7a7a;--qv-success:#4ade9a;color-scheme:dark}}
|
|
6
|
+
:host([theme=dark]){--qv-bg:#0a1633;--qv-fg:#ebeef6;--qv-muted:#a3abc4;--qv-border:rgba(255,255,255,.18);--qv-soft:#142154;--qv-link:#a493ff;--qv-track:#0e1c40;--qv-danger:#ff7a7a;--qv-success:#4ade9a;color-scheme:dark}
|
|
7
|
+
*{box-sizing:border-box}
|
|
8
|
+
.zone{display:flex;flex-direction:column;align-items:center;gap:12px;padding:28px 20px;text-align:center;background:var(--qv-bg);border:1.5px dashed var(--qv-border);border-radius:var(--qv-radius);transition:border-color .15s,background-color .15s}
|
|
9
|
+
.zone.over{border-color:var(--qv-accent);background:var(--qv-soft)}
|
|
10
|
+
:host([disabled]) .zone{opacity:.55}
|
|
11
|
+
svg{width:28px;height:28px;color:var(--qv-accent)}
|
|
12
|
+
p{margin:0}
|
|
13
|
+
.hint{font-size:.875em;color:var(--qv-muted)}
|
|
14
|
+
.actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
|
|
15
|
+
button{font:inherit;font-size:.875em;font-weight:600;cursor:pointer;border-radius:999px;padding:8px 16px;border:1px solid transparent}
|
|
16
|
+
button:disabled{cursor:not-allowed}
|
|
17
|
+
button:focus-visible{outline:2px solid var(--qv-accent);outline-offset:2px}
|
|
18
|
+
.primary{background:var(--qv-accent);color:var(--qv-accent-fg)}
|
|
19
|
+
.secondary{background:transparent;color:var(--qv-fg);border-color:var(--qv-border)}
|
|
20
|
+
.link{background:none;border:0;padding:4px 6px;color:var(--qv-link);font-weight:600}
|
|
21
|
+
ul{list-style:none;margin:12px 0 0;padding:0;display:grid;gap:8px}
|
|
22
|
+
ul:empty{display:none}
|
|
23
|
+
li{display:grid;grid-template-columns:1fr auto;gap:6px 12px;align-items:center;padding:12px 14px;background:var(--qv-bg);border:1px solid var(--qv-border);border-radius:var(--qv-radius)}
|
|
24
|
+
.name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;font-size:.9em}
|
|
25
|
+
.status{font-size:.8em;color:var(--qv-muted)}
|
|
26
|
+
li[data-state=done] .status{color:var(--qv-success)}
|
|
27
|
+
li[data-state=failed] .status{color:var(--qv-danger)}
|
|
28
|
+
.bar{grid-column:1/-1;height:6px;border-radius:999px;background:var(--qv-track);overflow:hidden}
|
|
29
|
+
.bar>span{display:block;height:100%;width:0;background:var(--qv-accent);transition:width .2s}
|
|
30
|
+
li[data-state=done] .bar,li[data-state=failed] .bar,li[data-state=cancelled] .bar{display:none}
|
|
31
|
+
.btns{display:flex;gap:2px}
|
|
32
|
+
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
33
|
+
@media (prefers-reduced-motion:reduce){.zone,.bar>span{transition:none}}
|
|
34
|
+
`,wt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 15V4m0 0L8 8m4-4 4 4"/><path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/></svg>';function k(e,t={},r){let s=document.createElement(e);for(let[n,i]of Object.entries(t))s.setAttribute(n,i);return r!==void 0&&(s.textContent=r),s}function xt(){return class extends HTMLElement{static formAssociated=!0;static get observedAttributes(){return["accept","multiple","disabled","label","max-bytes","camera",...Z]}#w;#c=null;#p={};#e=[];#f=0;#n=null;#g=0;#h=null;#I=Promise.resolve();#x=null;#r;#i;#l;#a;#k;#m;#b;#P;#t;constructor(){super(),this.#w=this.attachShadow({mode:"open"});try{this.#c=this.attachInternals()}catch{this.#c=null}let t=k("style");t.textContent=vt,this.#t=k("div",{class:"zone",part:"dropzone"}),this.#t.innerHTML=wt,this.#k=k("p",{class:"title"}),this.#m=k("p",{class:"hint"});let r=k("div",{class:"actions"});this.#l=k("button",{type:"button",class:"primary",part:"button"}),this.#a=k("button",{type:"button",class:"secondary",part:"button",hidden:""}),this.#r=k("input",{type:"file",hidden:"",tabindex:"-1"}),this.#i=k("input",{type:"file",hidden:"",tabindex:"-1",capture:"environment"}),r.append(this.#l,this.#a),this.#t.append(this.#k,this.#m,r,this.#r,this.#i),this.#b=k("ul",{part:"list"}),this.#P=k("div",{class:"sr","aria-live":"polite",role:"status"});let s=k("slot",{name:"turnstile"});this.#w.append(t,this.#t,s,this.#b,this.#P),this.#l.addEventListener("click",()=>this.#r.click()),this.#a.addEventListener("click",()=>this.#i.click());for(let n of[this.#r,this.#i])n.addEventListener("change",()=>{n.files&&this.addFiles(n.files),n.value=""});this.#t.addEventListener("dragenter",n=>this.#v(n,1)),this.#t.addEventListener("dragover",n=>this.#v(n,0)),this.#t.addEventListener("dragleave",n=>this.#v(n,-1)),this.#t.addEventListener("drop",n=>{this.#v(n,-this.#g),n.dataTransfer?.files.length&&this.addFiles(n.dataTransfer.files)}),this.#t.addEventListener("click",n=>{n.target===this.#t&&!this.#d&&this.#r.click()}),this.#w.addEventListener("paste",n=>{n instanceof ClipboardEvent&&this.#L(n)}),this.#y()}connectedCallback(){this.getAttribute("paste")==="global"&&document.addEventListener("paste",this.#V),this.#y()}disconnectedCallback(){document.removeEventListener("paste",this.#V);for(let t of this.#e)t.ctl?.abort()}attributeChangedCallback(t){Z.includes(t)&&(this.#n=null),this.#y()}get options(){return this.#p}set options(t){this.#p=t??{},this.#n=null,this.#y()}configure(t){this.options=t}get assets(){return this.#e.flatMap(t=>t.asset?[t.asset]:[])}addFiles(t){if(this.#d)return;let r=this.#o,s=Array.from(t),n=this.#T("max-files")??(this.hasAttribute("multiple")?Number.POSITIVE_INFINITY:1),i=this.#T("max-bytes"),a=this.getAttribute("accept");for(let f of s){let y=this.#e.filter(T=>T.state!=="failed"&&T.state!=="cancelled").length,u=null;y>=n?u=r.tooMany:yt(f,a)?i!==null&&f.size>i&&(u=r.tooLarge):u=r.wrongType;let P=this.#q(f);u&&this.#s(P,"failed",u,!1)}this.#U()}clear(){for(let t of this.#e.slice())t.state!=="uploading"&&t.state!=="waiting"&&this.#E(t)}get#d(){return this.hasAttribute("disabled")}get#o(){let t=this.#p.labels??{};return{...Y,...t,errors:{...Y.errors,...t.errors}}}#T(t){let r=this.getAttribute(t);return r!==null&&/^\d+$/.test(r.trim())?Number(r.trim()):null}#y(){let t=this.#o,r=this.getAttribute("accept")??"",s=this.#d;this.#k.textContent=this.getAttribute("label")??t.drop;let n=this.#T("max-bytes");this.#m.textContent=n!==null?t.maxSize.replace("{size}",D(n)):"",this.#m.hidden=n===null,this.#l.textContent=t.browse,this.#a.textContent=t.camera,this.#l.disabled=s,this.#a.disabled=s,this.#r.accept=r,this.#r.multiple=this.hasAttribute("multiple"),this.#i.accept=/video/.test(r)?"image/*,video/*":"image/*";let i=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,a=!r||/image|\.(jpe?g|png|heic|webp)/i.test(r);this.#a.hidden=!i||!a||this.getAttribute("camera")==="off",this.#b.setAttribute("aria-label",t.list)}#v(t,r){!t.dataTransfer||this.#d||(t.preventDefault(),t.dataTransfer.dropEffect="copy",this.#g=Math.max(0,this.#g+r),this.#t.classList.toggle("over",this.#g>0))}#L(t){let r=t.clipboardData?.files;!r?.length||this.#d||(t.preventDefault(),this.addFiles(r))}#V=t=>{t.composedPath().includes(this)||this.#L(t)};#q(t){let r=k("li",{part:"item"}),s={file:t,state:"waiting",loaded:0,message:"",asset:null,ctl:null,row:r};return this.#e.push(s),this.#b.append(r),this.#A(s),s}#E(t){t.ctl?.abort(),this.#e=this.#e.filter(r=>r!==t),t.row.remove(),this.#S()}#A(t){let r=this.#o,{file:s,state:n,row:i}=t;i.dataset.state=n,i.replaceChildren();let a=k("span",{class:"name",title:s.name},s.name),f=s.size?Math.floor(t.loaded/s.size*100):0,y=n==="uploading"?`${r.uploading} ${f}% · ${D(s.size)}`:n==="failed"?`${r.failed}: ${t.message}`:`${r[n]} · ${D(s.size)}`,u=k("span",{class:"status"},y),P=k("div");P.append(a,k("br"),u);let T=k("div",{class:"btns"}),U=(V,v)=>{let E=k("button",{type:"button",class:"link","aria-label":`${V}: ${s.name}`},V);E.addEventListener("click",v),T.append(E)};if((n==="uploading"||n==="waiting")&&U(r.cancel,()=>this.#C(t)),(n==="failed"||n==="cancelled")&&(t.message!==r.tooMany&&t.message!==r.wrongType&&t.message!==r.tooLarge&&U(r.retry,()=>this.#M(t)),U(r.remove,()=>this.#E(t))),(n==="done"||n==="processing")&&U(r.remove,()=>this.#E(t)),i.append(P,T),n==="uploading"||n==="waiting"){let V=k("div",{class:"bar",role:"progressbar","aria-label":`${r.uploading}: ${s.name}`,"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":String(f)}),v=k("span");v.style.width=`${f}%`,V.append(v),i.append(V)}}#$(t){let r=this.#o,s=t.file.size?Math.floor(t.loaded/t.file.size*100):0,n=t.row.querySelector(".status"),i=t.row.querySelector(".bar"),a=i?.querySelector("span");if(!n||!i||!a)return this.#A(t);n.textContent=`${r.uploading} ${s}% · ${D(t.file.size)}`,i.setAttribute("aria-valuenow",String(s)),a.style.width=`${s}%`}#s(t,r,s,n=!0){if(t.state=r,t.message=s,this.#A(t),n){let i=this.#o,a=r==="failed"?`${i.failed}: ${s}`:i[r];this.#P.textContent=`${t.file.name}: ${a}`}}#C(t){t.state==="waiting"?this.#s(t,"cancelled",""):t.ctl?.abort()}#M(t){t.loaded=0,this.#s(t,"waiting","",!1),this.#U()}#u(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}#S(){let t=this.getAttribute("name");if(!this.#c||!t)return;let r=new FormData;for(let s of this.assets)r.append(t,s.id);try{this.#c.setFormValue(r)}catch{}}#R=()=>{let t=async()=>{let s=this.getAttribute("turnstile-sitekey");if(!s)throw new b({status:0,code:"invalid",reason:"turnstile_failed"});let n=await bt();return new Promise((i,a)=>{if(this.#x={resolve:i,reject:a},this.#h===null){let f=k("div",{slot:"turnstile"});this.append(f),this.#h=n.render(f,{sitekey:s,execution:"execute",appearance:"interaction-only",callback:y=>this.#x?.resolve(y),"error-callback":()=>this.#x?.reject(new b({status:0,code:"forbidden",reason:"turnstile_failed"}))})}else n.reset(this.#h);n.execute(this.#h)})},r=this.#I.then(t,t);return this.#I=r.catch(()=>{}),r};#_(){if(this.#n)return this.#n;let t=this.#p,r=this.getAttribute("library");if(!r)throw new b({status:0,code:"invalid",reason:"missing_library"});let s=this.getAttribute("preset"),n=this.getAttribute("ticket-endpoint"),i=this.getAttribute("ticket"),a={library:r},f=this.getAttribute("api-base")??t.apiBase;if(f&&(a.apiBase=f),t.fetch&&(a.fetch=t.fetch),t.put&&(a.put=t.put),t.retryDelay&&(a.retryDelay=t.retryDelay),t.concurrency!==void 0&&(a.concurrency=t.concurrency),t.retries!==void 0&&(a.retries=t.retries),t.storage!==void 0&&(a.storage=t.storage),s)a.preset=s,a.turnstile=t.turnstile??this.#R;else if(t.ticket!==void 0)a.ticket=t.ticket;else if(i)a.ticket=i;else if(n){let y=t.fetch??globalThis.fetch.bind(globalThis);a.ticket=async()=>{let u=await y(n,{method:"POST",credentials:"same-origin",headers:{accept:"application/json"}}),P=await u.json().catch(()=>null);if(!u.ok||typeof P?.ticket!="string")throw new b({status:u.status,code:"unauthorized",reason:"ticket_unavailable"});return P.ticket}}else throw new b({status:0,code:"invalid",reason:"missing_credentials"});return this.#n=F(a),this.#n}#U(){for(let r of this.#e){if(this.#f>=2)break;r.state==="waiting"&&(this.#f++,this.#z(r).finally(()=>{this.#f--,this.#U(),this.#f===0&&!this.#e.some(s=>s.state==="waiting")&&this.#u("vault-complete",{assets:this.assets})}))}}async#z(t){let r=this.#o,s=new AbortController;t.ctl=s,t.loaded=0,this.#s(t,"uploading","",!1),this.#u("vault-start",{file:t.file});try{let n=this.getAttribute("tags"),i={signal:s.signal,onProgress:f=>{t.loaded=f.loaded,this.#$(t),this.#u("vault-progress",{file:t.file,loaded:f.loaded,total:f.total})}};if(!this.hasAttribute("preset")){let f=this.getAttribute("folder-id"),y=this.getAttribute("public-id"),u=this.getAttribute("access");f&&(i.folderId=f),y&&(i.publicId=y),(u==="public"||u==="private"||u==="authenticated")&&(i.access=u),n&&(i.tags=n.split(",").map(P=>P.trim()).filter(Boolean))}let a=await this.#_().upload(t.file,i);t.asset=a,this.#s(t,a.state==="ready"?"done":"processing",""),this.#S(),this.#u("vault-upload",{file:t.file,asset:a})}catch(n){if(s.signal.aborted)this.#s(t,"cancelled","");else{let i=n instanceof b?n.reason??n.code:"default";this.#s(t,"failed",r.errors[i]??r.errors.default??r.failed),this.#u("vault-error",{file:t.file,error:n})}}finally{t.ctl=null}}}}function B(e=J){typeof customElements>"u"||customElements.get(e)||customElements.define(e,xt())}B();return at(kt);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qooal/vault",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The JavaScript SDK for Qooal Vault: delivery URLs with image transformations, signed URLs, browser uploads, an upload widget, React components, a Next.js image loader and server helpers.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://qooal.com/docs/vault",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"qooal",
|
|
9
|
+
"vault",
|
|
10
|
+
"image-cdn",
|
|
11
|
+
"image-transformations",
|
|
12
|
+
"uploads",
|
|
13
|
+
"hls",
|
|
14
|
+
"video",
|
|
15
|
+
"signed-urls",
|
|
16
|
+
"react",
|
|
17
|
+
"nextjs",
|
|
18
|
+
"next-image-loader"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./dist/widget.js"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./upload": {
|
|
34
|
+
"types": "./dist/types/upload/index.d.ts",
|
|
35
|
+
"import": "./dist/upload.js",
|
|
36
|
+
"default": "./dist/upload.js"
|
|
37
|
+
},
|
|
38
|
+
"./react": {
|
|
39
|
+
"types": "./dist/types/react/index.d.ts",
|
|
40
|
+
"import": "./dist/react.js",
|
|
41
|
+
"default": "./dist/react.js"
|
|
42
|
+
},
|
|
43
|
+
"./next": {
|
|
44
|
+
"types": "./dist/types/next.d.ts",
|
|
45
|
+
"import": "./dist/next.js",
|
|
46
|
+
"default": "./dist/next.js"
|
|
47
|
+
},
|
|
48
|
+
"./server": {
|
|
49
|
+
"types": "./dist/types/server/index.d.ts",
|
|
50
|
+
"import": "./dist/server.js",
|
|
51
|
+
"default": "./dist/server.js"
|
|
52
|
+
},
|
|
53
|
+
"./sign": {
|
|
54
|
+
"types": "./dist/types/sign.d.ts",
|
|
55
|
+
"import": "./dist/sign.js",
|
|
56
|
+
"default": "./dist/sign.js"
|
|
57
|
+
},
|
|
58
|
+
"./widget.js": "./dist/widget.js",
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"README.md",
|
|
64
|
+
"LICENSE",
|
|
65
|
+
"CHANGELOG.md"
|
|
66
|
+
],
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"hls.js": "^1.5.0",
|
|
72
|
+
"react": "^19.0.0"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"hls.js": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"react": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"main": "./dist/index.js",
|
|
83
|
+
"types": "./dist/types/index.d.ts"
|
|
84
|
+
}
|