@netlify/spark-ui 1.25.0 → 1.26.0-alpha.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/dist/assets/DropZone.css +1 -0
- package/dist/chunks/{AskNetlify.jaxhKBOK.js → AskNetlify.bx0blyGV.js} +124 -126
- package/dist/chunks/_commonjsHelpers.C6fGbg64.js +6 -0
- package/dist/chunks/browser.D58rdxmc.js +444 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/preact/AskNetlify/AskNetlify.js +1 -1
- package/dist/components/preact/DropZone/DropZone.d.ts +19 -0
- package/dist/components/preact/DropZone/DropZone.js +207 -0
- package/dist/components/preact/DropZone/drop-core/client.d.ts +19 -0
- package/dist/components/preact/DropZone/drop-core/client.js +41 -0
- package/dist/components/preact/DropZone/drop-core/deploy.d.ts +6 -0
- package/dist/components/preact/DropZone/drop-core/deploy.js +30 -0
- package/dist/components/preact/DropZone/drop-core/digest.d.ts +3 -0
- package/dist/components/preact/DropZone/drop-core/digest.js +12 -0
- package/dist/components/preact/DropZone/drop-core/index.d.ts +5 -0
- package/dist/components/preact/DropZone/drop-core/index.js +16 -0
- package/dist/components/preact/DropZone/drop-core/readFiles.d.ts +15 -0
- package/dist/components/preact/DropZone/drop-core/readFiles.js +616 -0
- package/dist/components/preact/DropZone/drop-core/types.d.ts +30 -0
- package/dist/components/preact/DropZone/drop-core/types.js +1 -0
- package/dist/components/preact/SearchModal/components/SearchModal/SearchModal.js +1 -1
- package/dist/components/preact/index.js +1 -1
- package/package.json +4 -2
- package/packages/components/index.ts +16 -0
- package/packages/components/preact/DropZone/DropZone.css +340 -0
- package/packages/components/preact/DropZone/DropZone.tsx +295 -0
- package/packages/components/preact/DropZone/drop-core/client.ts +61 -0
- package/packages/components/preact/DropZone/drop-core/deploy.ts +55 -0
- package/packages/components/preact/DropZone/drop-core/digest.ts +11 -0
- package/packages/components/preact/DropZone/drop-core/index.ts +5 -0
- package/packages/components/preact/DropZone/drop-core/readFiles.ts +136 -0
- package/packages/components/preact/DropZone/drop-core/types.ts +35 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Deploy, Digest } from './types';
|
|
2
|
+
export interface DropClient {
|
|
3
|
+
getToken(): Promise<string>;
|
|
4
|
+
createDeploy(digest: Digest, token: string): Promise<Deploy>;
|
|
5
|
+
uploadFile(deployId: string, path: string, content: ArrayBuffer, token: string): Promise<void>;
|
|
6
|
+
waitUntilReady(deploy: Deploy, token: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Unauthenticated drop client. Authorized server-side by the Referer header,
|
|
10
|
+
* so it only works from an allowlisted origin (see backend checklist).
|
|
11
|
+
*/
|
|
12
|
+
export declare class AnonymousDropClient implements DropClient {
|
|
13
|
+
private apiBase;
|
|
14
|
+
constructor(apiBase?: string);
|
|
15
|
+
getToken(): Promise<string>;
|
|
16
|
+
createDeploy(files: Digest, token: string): Promise<Deploy>;
|
|
17
|
+
uploadFile(deployId: string, path: string, content: ArrayBuffer, token: string): Promise<void>;
|
|
18
|
+
waitUntilReady(deploy: Deploy, token: string): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const i = "https://api.netlify.com/api/v1";
|
|
2
|
+
class n {
|
|
3
|
+
constructor(e = i) {
|
|
4
|
+
this.apiBase = e;
|
|
5
|
+
}
|
|
6
|
+
async getToken() {
|
|
7
|
+
const e = await fetch(`${this.apiBase}/drop/token`, { method: "POST" });
|
|
8
|
+
if (!e.ok) throw new Error(`drop/token failed: ${e.status}`);
|
|
9
|
+
return (await e.json()).token;
|
|
10
|
+
}
|
|
11
|
+
async createDeploy(e, o) {
|
|
12
|
+
const t = await fetch(`${this.apiBase}/drop`, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: { "Content-Type": "application/json" },
|
|
15
|
+
body: JSON.stringify({ files: e, token: o })
|
|
16
|
+
});
|
|
17
|
+
if (!t.ok) throw new Error(`drop failed: ${t.status}`);
|
|
18
|
+
return t.json();
|
|
19
|
+
}
|
|
20
|
+
async uploadFile(e, o, t, a) {
|
|
21
|
+
const r = await fetch(`${this.apiBase}/deploys/${e}/files${o}`, {
|
|
22
|
+
method: "PUT",
|
|
23
|
+
headers: { "Content-Type": "application/octet-stream", Authorization: `Bearer ${a}` },
|
|
24
|
+
body: t
|
|
25
|
+
});
|
|
26
|
+
if (!r.ok) throw new Error(`upload ${o} failed: ${r.status}`);
|
|
27
|
+
}
|
|
28
|
+
async waitUntilReady(e, o) {
|
|
29
|
+
for (let t = 0; t < 600; t++) {
|
|
30
|
+
const a = await fetch(`${this.apiBase}/deploys/${e.id}`, {
|
|
31
|
+
headers: { Authorization: `Bearer ${o}` }
|
|
32
|
+
});
|
|
33
|
+
if (a.ok && (await a.json()).state === "ready") return;
|
|
34
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
35
|
+
}
|
|
36
|
+
throw new Error("Deploy did not become ready in time");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
n as AnonymousDropClient
|
|
41
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DropClient } from './client';
|
|
2
|
+
import { DeployProgress, DeployResult, ProcessedFile } from './types';
|
|
3
|
+
export interface DeployOptions {
|
|
4
|
+
onProgress?: (e: DeployProgress) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function deployFiles(client: DropClient, files: ProcessedFile[], opts?: DeployOptions): Promise<DeployResult>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getDigest as w, getShas as y } from "./digest.js";
|
|
2
|
+
const r = 5;
|
|
3
|
+
async function d(e, h, u, t, i, a) {
|
|
4
|
+
const n = u.filter((p) => t.has(p.sha));
|
|
5
|
+
let l = 0, c = 0;
|
|
6
|
+
const o = async () => {
|
|
7
|
+
for (; l < n.length; ) {
|
|
8
|
+
const p = n[l++];
|
|
9
|
+
await e.uploadFile(h, p.path, p.content, i), a == null || a(++c);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
await Promise.all(Array.from({ length: Math.min(r, n.length) }, o));
|
|
13
|
+
}
|
|
14
|
+
async function f(e, h, u = {}) {
|
|
15
|
+
if (!h.length) throw new Error("No files to deploy");
|
|
16
|
+
const { onProgress: t } = u;
|
|
17
|
+
t == null || t({ phase: "creating" });
|
|
18
|
+
const i = await e.getToken(), a = await e.createDeploy(w(h), i), n = a.required.length;
|
|
19
|
+
return t == null || t({ phase: "uploading", uploaded: 0, total: n }), await d(
|
|
20
|
+
e,
|
|
21
|
+
a.id,
|
|
22
|
+
h,
|
|
23
|
+
y(a.required),
|
|
24
|
+
i,
|
|
25
|
+
(l) => t == null ? void 0 : t({ phase: "uploading", uploaded: l, total: n })
|
|
26
|
+
), t == null || t({ phase: "processing" }), await e.waitUntilReady(a, i), t == null || t({ phase: "ready" }), { deploy: a, token: i, url: `https://${a.subdomain}.netlify.app` };
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
f as deployFiles
|
|
30
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getDigest as o, getShas as r } from "./digest.js";
|
|
2
|
+
import { getSingleNonIndexHtmlFileName as l, hasMultipleHtmlFilesWithoutIndex as a, normalizeFiles as m, readDataTransfer as n, readFileList as s, readZip as p } from "./readFiles.js";
|
|
3
|
+
import { AnonymousDropClient as x } from "./client.js";
|
|
4
|
+
import { deployFiles as g } from "./deploy.js";
|
|
5
|
+
export {
|
|
6
|
+
x as AnonymousDropClient,
|
|
7
|
+
g as deployFiles,
|
|
8
|
+
o as getDigest,
|
|
9
|
+
r as getShas,
|
|
10
|
+
l as getSingleNonIndexHtmlFileName,
|
|
11
|
+
a as hasMultipleHtmlFilesWithoutIndex,
|
|
12
|
+
m as normalizeFiles,
|
|
13
|
+
n as readDataTransfer,
|
|
14
|
+
s as readFileList,
|
|
15
|
+
p as readZip
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProcessedFile } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Read a DataTransfer from a drop event into ProcessedFiles.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: `webkitGetAsEntry()` must be called synchronously inside the drop
|
|
6
|
+
* handler — the DataTransfer is detached once the event turn ends. The
|
|
7
|
+
* component captures entries first (see `readDroppedEntries`) then calls the
|
|
8
|
+
* async readers, so this function is safe to `await`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readDataTransfer(dt: DataTransfer): Promise<ProcessedFile[]>;
|
|
11
|
+
export declare function readFileList(files: FileList): Promise<ProcessedFile[]>;
|
|
12
|
+
export declare function readZip(zip: File): Promise<ProcessedFile[]>;
|
|
13
|
+
export declare function normalizeFiles(files: ProcessedFile[]): ProcessedFile[];
|
|
14
|
+
export declare function getSingleNonIndexHtmlFileName(files: ProcessedFile[]): string | null;
|
|
15
|
+
export declare function hasMultipleHtmlFilesWithoutIndex(files: ProcessedFile[]): boolean;
|