@netlify/spark-ui 1.31.0-alpha.3 → 1.31.0-alpha.4

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.
Files changed (92) hide show
  1. package/dist/components/index.d.ts +2 -2
  2. package/dist/components/preact/DropZone/DropZone.d.ts +21 -2
  3. package/dist/components/preact/DropZone/DropZone.js +59 -54
  4. package/dist/components/preact/DropZone/DropZone.test.d.ts +1 -0
  5. package/dist/components/preact/DropZone/index.d.ts +3 -3
  6. package/dist/components/preact/DropZone/index.js +25 -23
  7. package/dist/components/preact/DropZone/useDropDeploy.d.ts +10 -6
  8. package/dist/components/preact/DropZone/useDropDeploy.js +184 -131
  9. package/dist/components/preact/DropZone/useDropDeploy.test.d.ts +1 -0
  10. package/dist/components/preact/index.d.ts +2 -2
  11. package/dist/components/preact/index.js +25 -19
  12. package/dist/drop-core/analytics.d.ts +107 -0
  13. package/dist/drop-core/analytics.js +21 -0
  14. package/dist/drop-core/analytics.test.d.ts +1 -0
  15. package/dist/drop-core/authedApi.d.ts +55 -0
  16. package/dist/drop-core/authedApi.js +35 -0
  17. package/dist/drop-core/authedApi.test.d.ts +1 -0
  18. package/dist/drop-core/authedDropClient.js +109 -0
  19. package/dist/drop-core/authedDropClient.test.d.ts +1 -0
  20. package/dist/{components/preact/DropZone/drop-core → drop-core}/buildClient.d.ts +5 -13
  21. package/dist/drop-core/buildClient.js +84 -0
  22. package/dist/drop-core/buildClient.test.d.ts +1 -0
  23. package/dist/drop-core/buildStash.d.ts +37 -0
  24. package/dist/drop-core/buildStash.js +84 -0
  25. package/dist/drop-core/buildStash.test.d.ts +0 -0
  26. package/dist/{components/preact/DropZone/drop-core → drop-core}/deploy.d.ts +7 -0
  27. package/dist/drop-core/deploy.js +53 -0
  28. package/dist/drop-core/deploy.test.d.ts +1 -0
  29. package/dist/drop-core/detectBuild.test.d.ts +1 -0
  30. package/dist/drop-core/digest.test.d.ts +1 -0
  31. package/dist/{components/preact/DropZone/drop-core → drop-core}/errors.js +1 -1
  32. package/dist/drop-core/errors.test.d.ts +1 -0
  33. package/dist/drop-core/fileTypes.test.d.ts +1 -0
  34. package/dist/{components/preact/DropZone/drop-core → drop-core}/index.d.ts +3 -0
  35. package/dist/drop-core/index.js +51 -0
  36. package/dist/{components/preact/DropZone/drop-core → drop-core}/readFiles.js +2 -2
  37. package/dist/drop-core/readFiles.test.d.ts +1 -0
  38. package/dist/{components/preact/DropZone/drop-core → drop-core}/types.d.ts +10 -0
  39. package/dist/{components/preact/DropZone/drop-core → drop-core}/zip.js +1 -1
  40. package/dist/drop-core/zip.test.d.ts +1 -0
  41. package/package.json +4 -1
  42. package/packages/components/index.ts +19 -0
  43. package/packages/components/preact/DropZone/DropZone.test.ts +71 -0
  44. package/packages/components/preact/DropZone/DropZone.tsx +23 -2
  45. package/packages/components/preact/DropZone/index.tsx +14 -3
  46. package/packages/components/preact/DropZone/useDropDeploy.test.ts +376 -0
  47. package/packages/components/preact/DropZone/useDropDeploy.ts +297 -132
  48. package/packages/components/preact/index.ts +19 -2
  49. package/packages/drop-core/analytics.test.ts +17 -0
  50. package/packages/drop-core/analytics.ts +122 -0
  51. package/packages/drop-core/authedApi.test.ts +100 -0
  52. package/packages/drop-core/authedApi.ts +94 -0
  53. package/packages/drop-core/authedDropClient.test.ts +196 -0
  54. package/packages/{components/preact/DropZone/drop-core → drop-core}/authedDropClient.ts +30 -51
  55. package/packages/drop-core/buildClient.test.ts +112 -0
  56. package/packages/{components/preact/DropZone/drop-core → drop-core}/buildClient.ts +28 -57
  57. package/packages/drop-core/buildStash.test.ts +85 -0
  58. package/packages/drop-core/buildStash.ts +185 -0
  59. package/packages/drop-core/deploy.test.ts +135 -0
  60. package/packages/{components/preact/DropZone/drop-core → drop-core}/deploy.ts +18 -4
  61. package/packages/drop-core/detectBuild.test.ts +139 -0
  62. package/packages/drop-core/digest.test.ts +24 -0
  63. package/packages/drop-core/errors.test.ts +69 -0
  64. package/packages/{components/preact/DropZone/drop-core → drop-core}/errors.ts +1 -1
  65. package/packages/drop-core/fileTypes.test.ts +37 -0
  66. package/packages/{components/preact/DropZone/drop-core → drop-core}/index.ts +3 -0
  67. package/packages/drop-core/readFiles.test.ts +125 -0
  68. package/packages/{components/preact/DropZone/drop-core → drop-core}/types.ts +12 -6
  69. package/packages/drop-core/zip.test.ts +92 -0
  70. package/dist/components/preact/DropZone/drop-core/authedDropClient.js +0 -123
  71. package/dist/components/preact/DropZone/drop-core/buildClient.js +0 -99
  72. package/dist/components/preact/DropZone/drop-core/deploy.js +0 -48
  73. package/dist/components/preact/DropZone/drop-core/index.js +0 -36
  74. /package/dist/{components/preact/DropZone/drop-core → drop-core}/authedDropClient.d.ts +0 -0
  75. /package/dist/{components/preact/DropZone/drop-core → drop-core}/client.d.ts +0 -0
  76. /package/dist/{components/preact/DropZone/drop-core → drop-core}/client.js +0 -0
  77. /package/dist/{components/preact/DropZone/drop-core → drop-core}/detectBuild.d.ts +0 -0
  78. /package/dist/{components/preact/DropZone/drop-core → drop-core}/detectBuild.js +0 -0
  79. /package/dist/{components/preact/DropZone/drop-core → drop-core}/digest.d.ts +0 -0
  80. /package/dist/{components/preact/DropZone/drop-core → drop-core}/digest.js +0 -0
  81. /package/dist/{components/preact/DropZone/drop-core → drop-core}/errors.d.ts +0 -0
  82. /package/dist/{components/preact/DropZone/drop-core → drop-core}/fileTypes.d.ts +0 -0
  83. /package/dist/{components/preact/DropZone/drop-core → drop-core}/fileTypes.js +0 -0
  84. /package/dist/{components/preact/DropZone/drop-core → drop-core}/readFiles.d.ts +0 -0
  85. /package/dist/{components/preact/DropZone/drop-core → drop-core}/types.js +0 -0
  86. /package/dist/{components/preact/DropZone/drop-core → drop-core}/zip.d.ts +0 -0
  87. /package/packages/{components/preact/DropZone/drop-core → drop-core}/client.ts +0 -0
  88. /package/packages/{components/preact/DropZone/drop-core → drop-core}/detectBuild.ts +0 -0
  89. /package/packages/{components/preact/DropZone/drop-core → drop-core}/digest.ts +0 -0
  90. /package/packages/{components/preact/DropZone/drop-core → drop-core}/fileTypes.ts +0 -0
  91. /package/packages/{components/preact/DropZone/drop-core → drop-core}/readFiles.ts +0 -0
  92. /package/packages/{components/preact/DropZone/drop-core → drop-core}/zip.ts +0 -0
@@ -1,99 +0,0 @@
1
- var d = Object.defineProperty;
2
- var p = (r, t, e) => t in r ? d(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var i = (r, t, e) => p(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { NotAuthenticatedError as n, SiteCreateError as h, BuildCreateError as u, BuildFailedError as w, BuildTimeoutError as y } from "./errors.js";
5
- const f = "/access-control/bb-api/api/v1", B = "https://api.netlify.com/api/v1", m = 1e3, S = 10 * 60 * 1e3, T = /* @__PURE__ */ new Set(["ready", "error", "rejected"]);
6
- class _ {
7
- constructor({
8
- proxyBase: t = f,
9
- apiBase: e = B,
10
- getUploadToken: a,
11
- accountSlug: o,
12
- title: s = "Build from drop deployment",
13
- pollIntervalMs: l = m,
14
- timeoutMs: c = S
15
- }) {
16
- i(this, "proxyBase");
17
- i(this, "apiBase");
18
- i(this, "getUploadToken");
19
- i(this, "accountSlug");
20
- i(this, "title");
21
- i(this, "pollIntervalMs");
22
- i(this, "timeoutMs");
23
- this.proxyBase = t, this.apiBase = e, this.getUploadToken = a, this.accountSlug = o, this.title = s, this.pollIntervalMs = l, this.timeoutMs = c;
24
- }
25
- /**
26
- * Create the site the build deploys into. Goes through the proxy with
27
- * `credentials: 'include'` so the app session authorizes it; without an
28
- * account slug the API picks the user's default account.
29
- */
30
- async createSite() {
31
- const t = this.accountSlug ? `/${this.accountSlug}/sites` : "/sites", e = await fetch(`${this.proxyBase}${t}`, {
32
- method: "POST",
33
- credentials: "include",
34
- headers: { "Content-Type": "application/json" },
35
- body: JSON.stringify({ created_via: "drop" })
36
- });
37
- if (e.status === 401 || e.status === 403) throw new n();
38
- if (!e.ok) throw new h(e.status);
39
- return e.json();
40
- }
41
- /**
42
- * Upload the source archive and enqueue a build. Direct to `api.netlify.com`
43
- * (see the note on `apiBase`), authorized by a freshly minted bearer token.
44
- * `Content-Type` is left unset on purpose so the browser adds the multipart
45
- * boundary itself.
46
- *
47
- * Known ceiling: this is one request on a 30s token, and re-minting can't
48
- * help once it is in flight. A zip that takes longer than that to upload will
49
- * fail — the app origin gets 300s for exactly this reason, and lifting the
50
- * limit for other origins is a platform-side change.
51
- */
52
- async createBuildFromZip(t, e) {
53
- const a = await this.getUploadToken();
54
- if (!a) throw new n();
55
- const o = new FormData();
56
- o.append("zip", e), o.append("title", this.title);
57
- const s = await fetch(`${this.apiBase}/sites/${t}/builds`, {
58
- method: "POST",
59
- headers: { Authorization: `Bearer ${a}` },
60
- body: o
61
- });
62
- if (s.status === 401 || s.status === 403) throw new n();
63
- if (!s.ok) throw new u(s.status);
64
- return s.json();
65
- }
66
- /**
67
- * Poll the build's deploy until it settles, mirroring
68
- * `AnonymousDropClient.waitUntilReady` — resolve on `ready`, throw on
69
- * `error`/`rejected`, throw on timeout. A build that hasn't been given a
70
- * deploy id yet has nothing pollable, so it resolves immediately and the
71
- * caller falls back to the site page.
72
- *
73
- * Optional in the drop flow, and off by default: a build takes minutes, so
74
- * the useful hand-off is usually the project page rather than a spinner.
75
- * Polling rides the session cookie, so it cannot outlive its credentials the
76
- * way a 30s bearer would.
77
- */
78
- async waitUntilBuildReady(t) {
79
- if (!t.deploy_id) return;
80
- const e = this.timeoutMs / this.pollIntervalMs;
81
- for (let a = 0; a < e; a++) {
82
- const o = await fetch(`${this.proxyBase}/deploys/${t.deploy_id}`, {
83
- credentials: "include"
84
- });
85
- if (o.ok) {
86
- const s = await o.json();
87
- if (s.state && T.has(s.state)) {
88
- if (s.state === "ready") return;
89
- throw new w(s.error_message);
90
- }
91
- }
92
- await new Promise((s) => setTimeout(s, this.pollIntervalMs));
93
- }
94
- throw new y();
95
- }
96
- }
97
- export {
98
- _ as AuthenticatedBuildClient
99
- };
@@ -1,48 +0,0 @@
1
- import { getDigest as w } from "./digest.js";
2
- import { zipFiles as y } from "./zip.js";
3
- const f = 5;
4
- async function m(i, l, n, t, p, a) {
5
- const u = n.filter((d) => t.has(d.sha));
6
- let e = 0, h = 0;
7
- const c = async () => {
8
- for (; e < u.length; ) {
9
- const d = u[e++];
10
- await i.uploadFile(l, d.path, d.content, p), a == null || a(++h);
11
- }
12
- };
13
- await Promise.all(Array.from({ length: Math.min(f, u.length) }, c));
14
- }
15
- async function s(i, l, n = {}) {
16
- if (!l.length) throw new Error("No files to deploy");
17
- const { onProgress: t } = n;
18
- t == null || t({ phase: "creating" });
19
- const p = await i.getToken(), a = await i.createDeploy(w(l), p), u = a.required.length;
20
- return t == null || t({ phase: "uploading", uploaded: 0, total: u }), await m(
21
- i,
22
- a.deploy_id,
23
- l,
24
- new Set(a.required),
25
- p,
26
- (e) => t == null ? void 0 : t({ phase: "uploading", uploaded: e, total: u })
27
- ), t == null || t({ phase: "processing" }), await i.waitUntilReady(a, p), t == null || t({ phase: "ready" }), { deploy: a, token: p, url: `https://${a.subdomain}.netlify.app` };
28
- }
29
- async function F(i, l, n = {}) {
30
- if (!l.length) throw new Error("No files to deploy");
31
- const { onProgress: t, waitForBuild: p = !1 } = n;
32
- t == null || t({ phase: "zipping" });
33
- const { file: a, buildSettings: u } = await y(l);
34
- t == null || t({ phase: "creating" });
35
- const e = await i.createSite();
36
- t == null || t({ phase: "uploading" });
37
- const h = await i.createBuildFromZip(e.id, a);
38
- return t == null || t({ phase: "building" }), p && await i.waitUntilBuildReady(h), t == null || t({ phase: "ready" }), {
39
- site: e,
40
- build: h,
41
- buildSettings: u,
42
- url: e.ssl_url || e.url || `https://${e.name}.netlify.app`
43
- };
44
- }
45
- export {
46
- F as deployBuild,
47
- s as deployFiles
48
- };
@@ -1,36 +0,0 @@
1
- import { getDigest as t } from "./digest.js";
2
- import { getSingleNonIndexHtmlFileName as i, hasMultipleHtmlFilesWithoutIndex as l, readDataTransfer as n, readFileList as p, renameSingleNonIndexHtmlToIndex as d } from "./readFiles.js";
3
- import { getFileTypes as a } from "./fileTypes.js";
4
- import { detectBuild as x, inferBuildSettings as f } from "./detectBuild.js";
5
- import { AnonymousDropClient as g, apiError as E } from "./client.js";
6
- import { AuthenticatedDropClient as F } from "./authedDropClient.js";
7
- import { AuthenticatedBuildClient as D } from "./buildClient.js";
8
- import { generateNetlifyToml as C, zipFiles as N } from "./zip.js";
9
- import { deployBuild as c, deployFiles as A } from "./deploy.js";
10
- import { BuildCreateError as S, BuildFailedError as H, BuildTimeoutError as z, NotAuthenticatedError as L, SiteCreateError as M, UnsupportedDropError as U, humanizeDropError as W } from "./errors.js";
11
- export {
12
- g as AnonymousDropClient,
13
- D as AuthenticatedBuildClient,
14
- F as AuthenticatedDropClient,
15
- S as BuildCreateError,
16
- H as BuildFailedError,
17
- z as BuildTimeoutError,
18
- L as NotAuthenticatedError,
19
- M as SiteCreateError,
20
- U as UnsupportedDropError,
21
- E as apiError,
22
- c as deployBuild,
23
- A as deployFiles,
24
- x as detectBuild,
25
- C as generateNetlifyToml,
26
- t as getDigest,
27
- a as getFileTypes,
28
- i as getSingleNonIndexHtmlFileName,
29
- l as hasMultipleHtmlFilesWithoutIndex,
30
- W as humanizeDropError,
31
- f as inferBuildSettings,
32
- n as readDataTransfer,
33
- p as readFileList,
34
- d as renameSingleNonIndexHtmlToIndex,
35
- N as zipFiles
36
- };