@netlify/spark-ui 1.30.0 → 1.31.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.
Files changed (51) hide show
  1. package/README.md +4 -3
  2. package/dist/chunks/browser.Ca2rTNTu.js +769 -0
  3. package/dist/components/articleCopyActions.d.ts +9 -0
  4. package/dist/components/articleCopyActions.test.d.ts +1 -0
  5. package/dist/components/index.d.ts +2 -2
  6. package/dist/components/preact/DropZone/DropZone.d.ts +69 -14
  7. package/dist/components/preact/DropZone/DropZone.js +109 -84
  8. package/dist/components/preact/DropZone/drop-core/authedDropClient.d.ts +77 -0
  9. package/dist/components/preact/DropZone/drop-core/authedDropClient.js +97 -0
  10. package/dist/components/preact/DropZone/drop-core/buildClient.d.ts +95 -0
  11. package/dist/components/preact/DropZone/drop-core/buildClient.js +92 -0
  12. package/dist/components/preact/DropZone/drop-core/client.d.ts +4 -0
  13. package/dist/components/preact/DropZone/drop-core/client.js +2 -1
  14. package/dist/components/preact/DropZone/drop-core/deploy.d.ts +31 -0
  15. package/dist/components/preact/DropZone/drop-core/deploy.js +36 -18
  16. package/dist/components/preact/DropZone/drop-core/detectBuild.d.ts +26 -0
  17. package/dist/components/preact/DropZone/drop-core/detectBuild.js +80 -53
  18. package/dist/components/preact/DropZone/drop-core/errors.d.ts +38 -0
  19. package/dist/components/preact/DropZone/drop-core/errors.js +50 -5
  20. package/dist/components/preact/DropZone/drop-core/index.d.ts +3 -0
  21. package/dist/components/preact/DropZone/drop-core/index.js +33 -18
  22. package/dist/components/preact/DropZone/drop-core/readFiles.js +1 -1
  23. package/dist/components/preact/DropZone/drop-core/types.d.ts +6 -1
  24. package/dist/components/preact/DropZone/drop-core/zip.d.ts +46 -0
  25. package/dist/components/preact/DropZone/drop-core/zip.js +43 -0
  26. package/dist/components/preact/DropZone/index.d.ts +3 -2
  27. package/dist/components/preact/DropZone/index.js +27 -11
  28. package/dist/components/preact/DropZone/useDropDeploy.d.ts +34 -4
  29. package/dist/components/preact/DropZone/useDropDeploy.js +138 -70
  30. package/dist/components/preact/index.d.ts +2 -1
  31. package/dist/components/preact/index.js +17 -12
  32. package/package.json +5 -2
  33. package/packages/components/ArticleCopyActions.astro +122 -0
  34. package/packages/components/articleCopyActions.test.ts +143 -0
  35. package/packages/components/articleCopyActions.ts +41 -0
  36. package/packages/components/index.ts +15 -0
  37. package/packages/components/preact/DropZone/DropZone.tsx +114 -20
  38. package/packages/components/preact/DropZone/drop-core/authedDropClient.ts +185 -0
  39. package/packages/components/preact/DropZone/drop-core/buildClient.ts +187 -0
  40. package/packages/components/preact/DropZone/drop-core/client.ts +1 -1
  41. package/packages/components/preact/DropZone/drop-core/deploy.ts +65 -0
  42. package/packages/components/preact/DropZone/drop-core/detectBuild.ts +125 -41
  43. package/packages/components/preact/DropZone/drop-core/errors.ts +84 -1
  44. package/packages/components/preact/DropZone/drop-core/index.ts +3 -0
  45. package/packages/components/preact/DropZone/drop-core/readFiles.ts +1 -1
  46. package/packages/components/preact/DropZone/drop-core/types.ts +12 -1
  47. package/packages/components/preact/DropZone/drop-core/zip.ts +118 -0
  48. package/packages/components/preact/DropZone/index.tsx +23 -0
  49. package/packages/components/preact/DropZone/useDropDeploy.ts +189 -30
  50. package/packages/components/preact/index.ts +2 -1
  51. package/dist/chunks/browser.D58rdxmc.js +0 -444
@@ -1,21 +1,36 @@
1
- import { getDigest as o } from "./digest.js";
2
- import { getSingleNonIndexHtmlFileName as l, hasMultipleHtmlFilesWithoutIndex as n, readDataTransfer as p, readFileList as i, renameSingleNonIndexHtmlToIndex as m } from "./readFiles.js";
3
- import { getFileTypes as d } from "./fileTypes.js";
4
- import { detectBuild as s } from "./detectBuild.js";
5
- import { AnonymousDropClient as g } from "./client.js";
6
- import { deployFiles as D } from "./deploy.js";
7
- import { UnsupportedDropError as I, humanizeDropError as h } from "./errors.js";
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";
8
11
  export {
9
12
  g as AnonymousDropClient,
10
- I as UnsupportedDropError,
11
- D as deployFiles,
12
- s as detectBuild,
13
- o as getDigest,
14
- d as getFileTypes,
15
- l as getSingleNonIndexHtmlFileName,
16
- n as hasMultipleHtmlFilesWithoutIndex,
17
- h as humanizeDropError,
18
- p as readDataTransfer,
19
- i as readFileList,
20
- m as renameSingleNonIndexHtmlToIndex
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
21
36
  };
@@ -579,7 +579,7 @@ async function Q(y) {
579
579
  return M(w);
580
580
  }
581
581
  async function I(y) {
582
- const { unzip: m } = await import("../../../../chunks/browser.D58rdxmc.js"), w = new Uint8Array(await y.arrayBuffer()), _ = await new Promise(
582
+ const { unzip: m } = await import("../../../../chunks/browser.Ca2rTNTu.js"), w = new Uint8Array(await y.arrayBuffer()), _ = await new Promise(
583
583
  (v, s) => m(w, (g, u) => g ? s(g) : v(u))
584
584
  ), h = [];
585
585
  for (const [v, s] of Object.entries(_)) {
@@ -30,7 +30,12 @@ export interface DeployResult {
30
30
  token: string;
31
31
  url: string;
32
32
  }
33
- export type DeployPhase = 'creating' | 'uploading' | 'processing' | 'ready';
33
+ /**
34
+ * Phases shared by both deploy paths. A static drop runs
35
+ * creating → uploading → processing → ready; a build drop runs
36
+ * zipping → creating → uploading → building → ready.
37
+ */
38
+ export type DeployPhase = 'zipping' | 'creating' | 'uploading' | 'processing' | 'building' | 'ready';
34
39
  export interface DeployProgress {
35
40
  phase: DeployPhase;
36
41
  uploaded?: number;
@@ -0,0 +1,46 @@
1
+ import { InferredBuildSettings } from './detectBuild';
2
+ import { ProcessedFile } from './types';
3
+ /**
4
+ * Render inferred settings as a `[build]` table. Only `command` and `publish`
5
+ * are written: everything else (functions directory, plugins, node version)
6
+ * is zero-config on Netlify's side and guessing at it would override detection
7
+ * that is better informed than we are.
8
+ */
9
+ export declare function generateNetlifyToml({ command, publish }: InferredBuildSettings): string;
10
+ export interface ZipOptions {
11
+ /** Filename given to the produced `File`. Shows up as the build's source archive. */
12
+ name?: string;
13
+ /**
14
+ * Synthesise a `netlify.toml` `[build]` table from `inferBuildSettings` when the
15
+ * drop doesn't declare one (default `true`). Set `false` to upload the files
16
+ * exactly as dropped and let buildbot resolve every setting itself.
17
+ */
18
+ synthesizeNetlifyToml?: boolean;
19
+ }
20
+ export interface ZipResult {
21
+ /** The archive, ready to hand to `createBuildFromZip`. */
22
+ file: File;
23
+ /**
24
+ * The settings written into `netlify.toml`, or `null` when the archive is a
25
+ * faithful copy of the drop — either because it already declared a `[build]`
26
+ * table, or because nothing could be inferred with confidence.
27
+ */
28
+ buildSettings: InferredBuildSettings | null;
29
+ }
30
+ /**
31
+ * Zip an already-read file set into the source archive that
32
+ * `POST /sites/{id}/builds` expects.
33
+ *
34
+ * The input is the same root-normalized `ProcessedFile[]` the static deploy path
35
+ * uses (see `readFiles`), so junk — dotfiles, `node_modules`, macOS metadata — is
36
+ * already gone and paths sit at the deploy root. Output directories (`dist/`,
37
+ * `build/`) are deliberately *not* stripped: buildbot regenerates them when
38
+ * there's a build command, and a drop whose `netlify.toml` publishes a committed
39
+ * directory without a command would break if we removed it.
40
+ *
41
+ * When the drop needs a build but declares no `[build]` table, an inferred one is
42
+ * written in (appended to an existing `netlify.toml`, or created if there is
43
+ * none) so buildbot doesn't publish the project's source. See
44
+ * `inferBuildSettings` for how conservative that inference is.
45
+ */
46
+ export declare function zipFiles(files: ProcessedFile[], { name, synthesizeNetlifyToml }?: ZipOptions): Promise<ZipResult>;
@@ -0,0 +1,43 @@
1
+ import { inferBuildSettings as d } from "./detectBuild.js";
2
+ const g = "/netlify.toml";
3
+ function a(e) {
4
+ return e.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
5
+ }
6
+ function y({ command: e, publish: i }) {
7
+ return [
8
+ "[build]",
9
+ ` command = "${a(e)}"`,
10
+ ` publish = "${a(i)}"`,
11
+ ""
12
+ ].join(`
13
+ `);
14
+ }
15
+ const m = new TextEncoder(), b = new TextDecoder();
16
+ function w(e) {
17
+ return new Uint8Array(e);
18
+ }
19
+ async function $(e, { name: i = "source.zip", synthesizeNetlifyToml: p = !0 } = {}) {
20
+ if (!e.length) throw new Error("No files to deploy");
21
+ const r = p ? d(e) : null, l = {};
22
+ for (const t of e) {
23
+ const n = t.path.replace(/^\//, "");
24
+ n && (l[n] = w(t.content));
25
+ }
26
+ if (r) {
27
+ const t = e.find((s) => s.path === g), n = y(r), c = t ? `${b.decode(t.content).replace(/\n*$/, `
28
+ `)}
29
+ ${n}` : n;
30
+ l["netlify.toml"] = m.encode(c);
31
+ }
32
+ const { zip: f } = await import("../../../../chunks/browser.Ca2rTNTu.js"), o = await new Promise(
33
+ (t, n) => f(l, { level: 6 }, (c, s) => c ? n(c) : t(s))
34
+ ), u = o.buffer.slice(
35
+ o.byteOffset,
36
+ o.byteOffset + o.byteLength
37
+ );
38
+ return { file: new File([u], i, { type: "application/zip" }), buildSettings: r };
39
+ }
40
+ export {
41
+ y as generateNetlifyToml,
42
+ $ as zipFiles
43
+ };
@@ -1,3 +1,4 @@
1
1
  export { default as DropZone } from './DropZone';
2
- export { AnonymousDropClient, deployFiles, detectBuild, getFileTypes, readDataTransfer, readFileList, } from './drop-core';
3
- export type { BuildDetection, BuildReason, DropClient, DropResponse, Digest, DeployResult, DeployProgress, DeployPhase, ProcessedFile, } from './drop-core';
2
+ export { AnonymousDropClient, AuthenticatedBuildClient, AuthenticatedDropClient, BuildCreateError, BuildFailedError, BuildTimeoutError, deployBuild, deployFiles, detectBuild, getFileTypes, humanizeDropError, inferBuildSettings, NotAuthenticatedError, readDataTransfer, readFileList, SiteCreateError, UnsupportedDropError, zipFiles, } from './drop-core';
3
+ export type { AuthenticatedBuildClientConfig, AuthenticatedDropClientConfig, BuildClient, BuildDeployOptions, BuildDeployResult, BuildDetection, BuildReason, BuildResponse, BuildSite, DropClient, DropResponse, Digest, DeployResult, DeployProgress, DeployPhase, InferredBuildSettings, ProcessedFile, ZipOptions, ZipResult, } from './drop-core';
4
+ export type { DeployedBuild, DeployedSite, DeployError, DeployStatus } from './useDropDeploy';
@@ -1,15 +1,31 @@
1
- import { default as r } from "./DropZone.js";
2
- import { readDataTransfer as p, readFileList as f } from "./drop-core/readFiles.js";
1
+ import { default as o } from "./DropZone.js";
2
+ import { readDataTransfer as i, readFileList as p } from "./drop-core/readFiles.js";
3
3
  import { getFileTypes as l } from "./drop-core/fileTypes.js";
4
- import { detectBuild as d } from "./drop-core/detectBuild.js";
5
- import { AnonymousDropClient as s } from "./drop-core/client.js";
6
- import { deployFiles as n } from "./drop-core/deploy.js";
4
+ import { detectBuild as a, inferBuildSettings as n } from "./drop-core/detectBuild.js";
5
+ import { AnonymousDropClient as m } from "./drop-core/client.js";
6
+ import { AuthenticatedDropClient as s } from "./drop-core/authedDropClient.js";
7
+ import { AuthenticatedBuildClient as E } from "./drop-core/buildClient.js";
8
+ import { zipFiles as C } from "./drop-core/zip.js";
9
+ import { deployBuild as c, deployFiles as h } from "./drop-core/deploy.js";
10
+ import { BuildCreateError as A, BuildFailedError as T, BuildTimeoutError as g, NotAuthenticatedError as z, SiteCreateError as S, UnsupportedDropError as L, humanizeDropError as N } from "./drop-core/errors.js";
7
11
  export {
8
- s as AnonymousDropClient,
9
- r as DropZone,
10
- n as deployFiles,
11
- d as detectBuild,
12
+ m as AnonymousDropClient,
13
+ E as AuthenticatedBuildClient,
14
+ s as AuthenticatedDropClient,
15
+ A as BuildCreateError,
16
+ T as BuildFailedError,
17
+ g as BuildTimeoutError,
18
+ o as DropZone,
19
+ z as NotAuthenticatedError,
20
+ S as SiteCreateError,
21
+ L as UnsupportedDropError,
22
+ c as deployBuild,
23
+ h as deployFiles,
24
+ a as detectBuild,
12
25
  l as getFileTypes,
13
- p as readDataTransfer,
14
- f as readFileList
26
+ N as humanizeDropError,
27
+ n as inferBuildSettings,
28
+ i as readDataTransfer,
29
+ p as readFileList,
30
+ C as zipFiles
15
31
  };
@@ -1,12 +1,18 @@
1
- import { BuildDetection, DropClient, ProcessedFile } from './drop-core';
1
+ import { BuildClient, BuildDetection, DropClient, InferredBuildSettings, ProcessedFile } from './drop-core';
2
2
  /** How the files reached the zone — carried through to analytics. */
3
3
  export type DeploySource = 'drag' | 'browse';
4
4
  /** The live site handed back once a deploy succeeds. */
5
5
  export interface DeployedSite {
6
6
  url: string;
7
- token: string;
7
+ /**
8
+ * Drop claim token — only present for anonymous deploys. An authenticated
9
+ * deploy lands directly in the visitor's account, so there is nothing to claim.
10
+ */
11
+ token?: string;
8
12
  siteName: string;
9
13
  siteId: string;
14
+ /** True when the deploy landed directly in the visitor's account. */
15
+ authenticated: boolean;
10
16
  }
11
17
  /** A deploy failure, handed to `onError` so consumers can render their own error UI. */
12
18
  export interface DeployError {
@@ -15,11 +21,25 @@ export interface DeployError {
15
21
  /** The raw underlying reason (e.g. "drop failed: 429"), useful for logging. */
16
22
  reason: string;
17
23
  }
24
+ /** The build handed back once a build-required drop is enqueued. */
25
+ export interface DeployedBuild {
26
+ /** The site created for the build — live once the build finishes. */
27
+ url: string;
28
+ siteName: string;
29
+ siteId: string;
30
+ buildId: string;
31
+ /** The deploy the build produces, if the API has assigned one yet. */
32
+ deployId?: string;
33
+ /** Build settings synthesised into the uploaded `netlify.toml`, if any. */
34
+ buildSettings: InferredBuildSettings | null;
35
+ }
18
36
  /** Finite states of a single deploy attempt. */
19
37
  export type DeployStatus = {
20
38
  kind: 'idle';
21
39
  } | {
22
40
  kind: 'reading';
41
+ } | {
42
+ kind: 'zipping';
23
43
  } | {
24
44
  kind: 'creating';
25
45
  } | {
@@ -28,9 +48,11 @@ export type DeployStatus = {
28
48
  total: number;
29
49
  } | {
30
50
  kind: 'processing';
51
+ } | {
52
+ kind: 'building';
31
53
  } | {
32
54
  kind: 'redirecting';
33
- target: 'claim' | 'signup';
55
+ target: 'claim' | 'dashboard' | 'signup' | 'build';
34
56
  } | {
35
57
  kind: 'error';
36
58
  message: string;
@@ -41,9 +63,17 @@ interface UseDropDeployOptions {
41
63
  apiBase?: string;
42
64
  client?: DropClient;
43
65
  claimUrl: (siteName: string) => string;
66
+ siteDashboardUrl: (siteName: string) => string;
44
67
  buildSignupUrl: string;
68
+ buildClient?: BuildClient;
69
+ authenticatedDropClient?: DropClient;
70
+ getUploadToken?: () => Promise<string | null>;
71
+ accountSlug?: string;
72
+ buildDeployUrl: (build: DeployedBuild) => string;
73
+ waitForBuild?: boolean;
45
74
  onBuildRequired?: (info: BuildDetection) => void;
46
75
  onDeploy?: (site: DeployedSite) => void;
76
+ onBuildDeploy?: (build: DeployedBuild) => void;
47
77
  onError?: (error: DeployError) => void;
48
78
  track: TrackFn;
49
79
  }
@@ -51,7 +81,7 @@ interface UseDropDeployOptions {
51
81
  * Owns the deploy state machine and its side effects (upload, local persistence,
52
82
  * analytics, redirect), keeping DropZone a thin view over the returned `status`.
53
83
  */
54
- export declare function useDropDeploy({ apiBase, client, claimUrl, buildSignupUrl, onBuildRequired, onDeploy, onError, track, }: UseDropDeployOptions): {
84
+ export declare function useDropDeploy({ apiBase, client, claimUrl, siteDashboardUrl, buildSignupUrl, buildClient, authenticatedDropClient, getUploadToken, accountSlug, buildDeployUrl, waitForBuild, onBuildRequired, onDeploy, onBuildDeploy, onError, track, }: UseDropDeployOptions): {
55
85
  status: DeployStatus;
56
86
  warning: string | null;
57
87
  busy: boolean;
@@ -1,95 +1,163 @@
1
- import { d as y, A as W } from "../../../chunks/hooks.module.DRcxknIz.js";
2
- import { renameSingleNonIndexHtmlToIndex as $, getSingleNonIndexHtmlFileName as v, hasMultipleHtmlFilesWithoutIndex as A } from "./drop-core/readFiles.js";
3
- import { detectBuild as C } from "./drop-core/detectBuild.js";
4
- import { AnonymousDropClient as P } from "./drop-core/client.js";
5
- import { deployFiles as q } from "./drop-core/deploy.js";
6
- import { humanizeDropError as M } from "./drop-core/errors.js";
7
- function T(n) {
8
- switch (n.phase) {
1
+ import { d as P, A as I } from "../../../chunks/hooks.module.DRcxknIz.js";
2
+ import { renameSingleNonIndexHtmlToIndex as X, getSingleNonIndexHtmlFileName as Y, hasMultipleHtmlFilesWithoutIndex as Z } from "./drop-core/readFiles.js";
3
+ import { detectBuild as B } from "./drop-core/detectBuild.js";
4
+ import { AnonymousDropClient as D } from "./drop-core/client.js";
5
+ import { AuthenticatedDropClient as T } from "./drop-core/authedDropClient.js";
6
+ import { AuthenticatedBuildClient as U } from "./drop-core/buildClient.js";
7
+ import "./drop-core/zip.js";
8
+ import { deployFiles as H, deployBuild as tt } from "./drop-core/deploy.js";
9
+ import { NotAuthenticatedError as W, humanizeDropError as et } from "./drop-core/errors.js";
10
+ function S(o) {
11
+ switch (o.phase) {
12
+ case "zipping":
13
+ return { kind: "zipping" };
9
14
  case "creating":
10
15
  return { kind: "creating" };
11
16
  case "uploading":
12
- return { kind: "uploading", uploaded: n.uploaded ?? 0, total: n.total ?? 0 };
17
+ return { kind: "uploading", uploaded: o.uploaded ?? 0, total: o.total ?? 0 };
18
+ case "building":
19
+ return { kind: "building" };
13
20
  case "processing":
14
21
  case "ready":
15
22
  return { kind: "processing" };
16
23
  }
17
24
  }
18
- function j(n) {
19
- const l = v(n);
20
- return l ? `No index.html found — "${l}" won’t be served at the site root.` : A(n) ? "No index.html found — your site may not have a landing page." : null;
25
+ function nt(o) {
26
+ const f = Y(o);
27
+ return f ? `No index.html found — "${f}" won’t be served at the site root.` : Z(o) ? "No index.html found — your site may not have a landing page." : null;
21
28
  }
22
- function O({
23
- apiBase: n,
24
- client: l,
25
- claimUrl: k,
26
- buildSignupUrl: w,
27
- onBuildRequired: f,
28
- onDeploy: u,
29
- onError: c,
30
- track: s
29
+ function ft({
30
+ apiBase: o,
31
+ client: f,
32
+ claimUrl: $,
33
+ siteDashboardUrl: v,
34
+ buildSignupUrl: j,
35
+ buildClient: q,
36
+ authenticatedDropClient: M,
37
+ getUploadToken: m,
38
+ accountSlug: x,
39
+ buildDeployUrl: E,
40
+ waitForBuild: G,
41
+ onBuildRequired: z,
42
+ onDeploy: g,
43
+ onBuildDeploy: h,
44
+ onError: b,
45
+ track: c
31
46
  }) {
32
- const [m, o] = y({ kind: "idle" }), [N, p] = y(null), b = W(l ?? new P(n)).current, x = m.kind !== "idle" && m.kind !== "error";
33
- async function I(z, i, h) {
34
- p(null), o({ kind: "reading" });
35
- const a = h.length ? { file_types: h } : {}, _ = (e, t, d) => {
36
- o({ kind: "error", message: e }), s("dropzone_deploy_failed", { method: i, reason: t, ...a, ...d }), c == null || c({ message: e, reason: t });
37
- }, F = (e, t) => {
38
- const d = e instanceof Error ? e.message : String(e);
39
- _(M(e), d, t);
47
+ const [w, n] = P({ kind: "idle" }), [J, _] = P(null), K = I(f ?? new D(o)).current, C = I(
48
+ q ?? (m ? new U({ getUploadToken: m, accountSlug: x }) : null)
49
+ ).current, A = I(
50
+ M ?? (m ? new T({ getUploadToken: m, accountSlug: x }) : null)
51
+ ).current, L = w.kind !== "idle" && w.kind !== "error";
52
+ async function O(y, r) {
53
+ try {
54
+ const { site: d, build: l, buildSettings: p, url: k } = await tt(y, r, {
55
+ onProgress: (t) => n(S(t)),
56
+ waitForBuild: G
57
+ });
58
+ return {
59
+ url: k,
60
+ siteName: d.name,
61
+ siteId: d.id,
62
+ buildId: l.id,
63
+ deployId: l.deploy_id,
64
+ buildSettings: p
65
+ };
66
+ } catch (d) {
67
+ if (d instanceof W) return null;
68
+ throw d;
69
+ }
70
+ }
71
+ async function Q(y, r, d) {
72
+ _(null), n({ kind: "reading" });
73
+ const l = d.length ? { file_types: d } : {}, p = (t, i, a) => {
74
+ n({ kind: "error", message: t }), c("dropzone_deploy_failed", { method: r, reason: i, ...l, ...a }), b == null || b({ message: t, reason: i });
75
+ }, k = (t, i) => {
76
+ const a = t instanceof Error ? t.message : String(t);
77
+ p(et(t), a, i);
40
78
  };
41
79
  try {
42
- const e = $(await z());
43
- if (!e.length) {
44
- _("No files found to deploy.", "No files found to deploy.", { file_count: 0 });
80
+ const t = X(await y());
81
+ if (!t.length) {
82
+ p("No files found to deploy.", "No files found to deploy.", { file_count: 0 });
45
83
  return;
46
84
  }
47
- i === "drag" && s("dropzone_files_dropped", {
48
- method: i,
49
- file_count: e.length,
50
- ...a
85
+ r === "drag" && c("dropzone_files_dropped", {
86
+ method: r,
87
+ file_count: t.length,
88
+ ...l
51
89
  });
52
- const t = C(e);
53
- if (t.buildRequired) {
54
- if (s("dropzone_build_required", {
55
- method: i,
56
- reason: t.reason,
57
- file_count: e.length,
58
- ...a
59
- }), f) {
60
- o({ kind: "idle" }), f(t);
90
+ const i = B(t);
91
+ if (i.buildRequired) {
92
+ if (c("dropzone_build_required", {
93
+ method: r,
94
+ reason: i.reason,
95
+ file_count: t.length,
96
+ ...l
97
+ }), z) {
98
+ n({ kind: "idle" }), z(i);
61
99
  return;
62
100
  }
63
- o({ kind: "redirecting", target: "signup" }), window.location.assign(w);
101
+ if (C) {
102
+ const e = await O(C, t);
103
+ if (e) {
104
+ n({ kind: "redirecting", target: "build" }), c("dropzone_build_deploy_succeeded", {
105
+ method: r,
106
+ reason: i.reason,
107
+ site_name: e.siteName,
108
+ file_count: t.length,
109
+ ...e.buildSettings ? { framework: e.buildSettings.framework } : {},
110
+ ...l
111
+ }), h == null || h(e), window.location.assign(E(e));
112
+ return;
113
+ }
114
+ }
115
+ n({ kind: "redirecting", target: "signup" }), window.location.assign(j);
64
116
  return;
65
117
  }
66
- p(j(e));
67
- const {
68
- url: d,
69
- token: g,
70
- deploy: r
71
- } = await q(b, e, {
72
- onProgress: (H) => o(T(H))
73
- });
74
- try {
75
- localStorage.setItem("drop-token", g), localStorage.setItem("dropSiteName", r.subdomain);
76
- } catch {
77
- }
78
- o({ kind: "redirecting", target: "claim" }), s("dropzone_deploy_succeeded", {
79
- method: i,
80
- site_name: r.subdomain,
81
- file_count: e.length,
82
- ...a
83
- }), u == null || u({ url: d, token: g, siteName: r.subdomain, siteId: r.id }), window.location.assign(`${k(r.subdomain)}#drop_token=${g}`);
84
- } catch (e) {
85
- F(e);
118
+ _(nt(t));
119
+ let a = null, s = !1, F = !1;
120
+ if (A)
121
+ try {
122
+ a = await H(A, t, {
123
+ onProgress: (e) => n(S(e))
124
+ }), s = !0;
125
+ } catch (e) {
126
+ if (!(e instanceof W)) throw e;
127
+ F = !0;
128
+ }
129
+ a || (a = await H(K, t, {
130
+ onProgress: (e) => n(S(e))
131
+ }));
132
+ const { url: V, token: N, deploy: u } = a;
133
+ if (!s)
134
+ try {
135
+ localStorage.setItem("drop-token", N), localStorage.setItem("dropSiteName", u.subdomain);
136
+ } catch {
137
+ }
138
+ n({ kind: "redirecting", target: s ? "dashboard" : "claim" }), c("dropzone_deploy_succeeded", {
139
+ method: r,
140
+ site_name: u.subdomain,
141
+ file_count: t.length,
142
+ authenticated: s,
143
+ ...F ? { auth_fallback: !0 } : {},
144
+ ...l
145
+ }), g == null || g({
146
+ url: V,
147
+ ...s ? {} : { token: N },
148
+ siteName: u.subdomain,
149
+ siteId: u.id,
150
+ authenticated: s
151
+ }), s ? window.location.assign(v(u.subdomain)) : window.location.assign(`${$(u.subdomain)}#drop_token=${N}`);
152
+ } catch (t) {
153
+ k(t);
86
154
  }
87
155
  }
88
- function S() {
89
- p(null), o({ kind: "idle" });
156
+ function R() {
157
+ _(null), n({ kind: "idle" });
90
158
  }
91
- return { status: m, warning: N, busy: x, deploy: I, reset: S };
159
+ return { status: w, warning: J, busy: L, deploy: Q, reset: R };
92
160
  }
93
161
  export {
94
- O as useDropDeploy
162
+ ft as useDropDeploy
95
163
  };
@@ -6,5 +6,6 @@ export { default as SearchHeading } from './SearchModal/components/SearchHeading
6
6
  export { default as SearchToggle } from './SearchModal/components/SearchToggle/SearchToggle';
7
7
  export { default as AskNetlify } from './AskNetlify/AskNetlify';
8
8
  export { SearchModal } from './SearchModal';
9
- export { DropZone } from './DropZone';
9
+ export { DropZone, AuthenticatedBuildClient, AuthenticatedDropClient } from './DropZone';
10
+ export type { BuildClient, DeployedBuild, DeployedSite, DropClient } from './DropZone';
10
11
  export { type IconName } from './Icon';
@@ -1,24 +1,29 @@
1
- import { default as p } from "./KeyboardKey/KeyboardKey.js";
2
- import { default as d } from "./Modal/Modal.js";
3
- import { default as s } from "./Icon/index.js";
4
- import { default as u } from "./SearchModal/components/SearchLink/SearchLink.js";
1
+ import { default as m } from "./KeyboardKey/KeyboardKey.js";
2
+ import { default as l } from "./Modal/Modal.js";
3
+ import { default as u } from "./Icon/index.js";
4
+ import { default as s } from "./SearchModal/components/SearchLink/SearchLink.js";
5
5
  import { default as c } from "./SearchModal/components/SearchHeading/SearchHeading.js";
6
- import { default as n } from "./SearchModal/components/SearchToggle/SearchToggle.js";
6
+ import { default as A } from "./SearchModal/components/SearchToggle/SearchToggle.js";
7
7
  import { A as g } from "../../chunks/AskNetlify.bx0blyGV.js";
8
8
  import "preact";
9
9
  import "../../chunks/hooks.module.DRcxknIz.js";
10
10
  import { default as k } from "./SearchModal/components/SearchModal/SearchModal.js";
11
- import { default as K } from "./DropZone/DropZone.js";
11
+ import { default as D } from "./DropZone/DropZone.js";
12
12
  import "./DropZone/drop-core/readFiles.js";
13
13
  import "./DropZone/drop-core/detectBuild.js";
14
+ import { AuthenticatedDropClient as M } from "./DropZone/drop-core/authedDropClient.js";
15
+ import { AuthenticatedBuildClient as B } from "./DropZone/drop-core/buildClient.js";
16
+ import "./DropZone/drop-core/zip.js";
14
17
  export {
15
18
  g as AskNetlify,
16
- K as DropZone,
17
- s as Icon,
18
- p as KeyboardKey,
19
- d as Modal,
19
+ B as AuthenticatedBuildClient,
20
+ M as AuthenticatedDropClient,
21
+ D as DropZone,
22
+ u as Icon,
23
+ m as KeyboardKey,
24
+ l as Modal,
20
25
  c as SearchHeading,
21
- u as SearchLink,
26
+ s as SearchLink,
22
27
  k as SearchModal,
23
- n as SearchToggle
28
+ A as SearchToggle
24
29
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "1.30.0",
4
+ "version": "1.31.0-alpha.2",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -15,6 +15,7 @@
15
15
  "lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx,.astro --fix",
16
16
  "format": "prettier --write \"**/*.{js,jsx,ts,tsx,astro,json,css,md,mdx}\" --ignore-path packages/styles/tokens.css",
17
17
  "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,astro,json,css,md,mdx}\" --ignore-path packages/styles/tokens.css",
18
+ "test": "vitest run",
18
19
  "prepublishOnly": "npm run build:vite"
19
20
  },
20
21
  "files": [
@@ -61,6 +62,7 @@
61
62
  "eslint-config-prettier": "^10.1.1",
62
63
  "eslint-plugin-astro": "^1.3.1",
63
64
  "glob": "^11.0.1",
65
+ "jsdom": "^30.0.0",
64
66
  "preact": "^10.26.4",
65
67
  "prettier": "^3.5.3",
66
68
  "prettier-plugin-astro": "^0.14.1",
@@ -70,7 +72,8 @@
70
72
  "vite": "^6.2.5",
71
73
  "vite-plugin-dts": "^4.5.3",
72
74
  "vite-plugin-lib-inject-css": "^2.2.1",
73
- "vite-tsconfig-paths": "^5.1.4"
75
+ "vite-tsconfig-paths": "^5.1.4",
76
+ "vitest": "^4.1.10"
74
77
  },
75
78
  "peerDependencies": {
76
79
  "preact": "^10.26.4"