@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,20 +1,22 @@
1
- import { d as H, A as I } from "../../../chunks/hooks.module.DRcxknIz.js";
2
- import { renameSingleNonIndexHtmlToIndex as Y, getSingleNonIndexHtmlFileName as Z, hasMultipleHtmlFilesWithoutIndex as B } from "./drop-core/readFiles.js";
3
- import { detectBuild as D } from "./drop-core/detectBuild.js";
4
- import { AnonymousDropClient as T } from "./drop-core/client.js";
5
- import { AuthenticatedDropClient as U } from "./drop-core/authedDropClient.js";
6
- import { AuthenticatedBuildClient as tt } from "./drop-core/buildClient.js";
7
- import "./drop-core/zip.js";
8
- import { deployFiles as W, deployBuild as et } from "./drop-core/deploy.js";
9
- import { NotAuthenticatedError as $, humanizeDropError as nt } from "./drop-core/errors.js";
10
- function S(o) {
11
- switch (o.phase) {
1
+ import { d as R, A as S, y as nt } from "../../../chunks/hooks.module.DRcxknIz.js";
2
+ import { renameSingleNonIndexHtmlToIndex as rt, getSingleNonIndexHtmlFileName as at, hasMultipleHtmlFilesWithoutIndex as ot } from "../../../drop-core/readFiles.js";
3
+ import { detectBuild as st } from "../../../drop-core/detectBuild.js";
4
+ import { AnonymousDropClient as dt } from "../../../drop-core/client.js";
5
+ import { humanizeDropError as lt, NotAuthenticatedError as O } from "../../../drop-core/errors.js";
6
+ import { AuthenticatedDropClient as ut } from "../../../drop-core/authedDropClient.js";
7
+ import { AuthenticatedBuildClient as ct } from "../../../drop-core/buildClient.js";
8
+ import { zipFiles as mt } from "../../../drop-core/zip.js";
9
+ import { hasDropStashMarker as ft, loadDropStash as gt, clearDropStash as E, saveDropStash as ht } from "../../../drop-core/buildStash.js";
10
+ import { deployZippedBuild as pt, deployFiles as v } from "../../../drop-core/deploy.js";
11
+ import { DROPZONE_EVENTS as c } from "../../../drop-core/analytics.js";
12
+ function I(l) {
13
+ switch (l.phase) {
12
14
  case "zipping":
13
15
  return { kind: "zipping" };
14
16
  case "creating":
15
17
  return { kind: "creating" };
16
18
  case "uploading":
17
- return { kind: "uploading", uploaded: o.uploaded ?? 0, total: o.total ?? 0 };
19
+ return { kind: "uploading", uploaded: l.uploaded ?? 0, total: l.total ?? 0 };
18
20
  case "building":
19
21
  return { kind: "building" };
20
22
  case "processing":
@@ -22,143 +24,194 @@ function S(o) {
22
24
  return { kind: "processing" };
23
25
  }
24
26
  }
25
- function it(o) {
26
- const f = Z(o);
27
- return f ? `No index.html found — "${f}" won’t be served at the site root.` : B(o) ? "No index.html found — your site may not have a landing page." : null;
27
+ function wt(l) {
28
+ const m = at(l);
29
+ return m ? `No index.html found — "${m}" won’t be served at the site root.` : ot(l) ? "No index.html found — your site may not have a landing page." : null;
28
30
  }
29
- function mt({
30
- apiBase: o,
31
- client: f,
32
- claimUrl: v,
33
- siteDashboardUrl: j,
34
- buildSignupUrl: q,
35
- buildClient: M,
36
- authenticatedDropClient: E,
37
- getUploadToken: m,
38
- proxyBase: x,
39
- accountSlug: z,
40
- buildDeployUrl: G,
41
- waitForBuild: J,
42
- onBuildRequired: C,
43
- onDeploy: p,
44
- onBuildDeploy: h,
45
- onError: b,
46
- track: c
31
+ function St(l, m) {
32
+ try {
33
+ localStorage.setItem("drop-token", l), localStorage.setItem("dropSiteName", m);
34
+ } catch {
35
+ }
36
+ }
37
+ function Pt({
38
+ apiBase: l,
39
+ client: m,
40
+ claimUrl: z,
41
+ siteDashboardUrl: H,
42
+ buildSignupUrl: W,
43
+ buildClient: Y,
44
+ authenticatedDropClient: M,
45
+ getUploadToken: p,
46
+ proxyBase: N,
47
+ accountSlug: A,
48
+ buildDeployUrl: C,
49
+ waitForBuild: Z,
50
+ onBuildRequired: L,
51
+ onBuildSignupHandoff: P,
52
+ resumeStashedBuilds: $ = !0,
53
+ onDeploy: k,
54
+ onBuildDeploy: f,
55
+ onError: g,
56
+ track: q
47
57
  }) {
48
- const [w, n] = H({ kind: "idle" }), [K, _] = H(null), L = I(f ?? new T(o)).current, A = I(
49
- M ?? (m ? new tt({ proxyBase: x, getUploadToken: m, accountSlug: z }) : null)
50
- ).current, F = I(
51
- E ?? (m ? new U({ proxyBase: x, getUploadToken: m, accountSlug: z }) : null)
52
- ).current, O = w.kind !== "idle" && w.kind !== "error";
53
- async function Q(y, r) {
58
+ const u = (n, t) => (
59
+ // The cast bridges to TrackFn's loose record: the interfaces have no index
60
+ // signature (so payloads stay closed for consumers), and the checking that
61
+ // matters happened against DropZoneEventProperties[E] above.
62
+ q(n, t)
63
+ ), [b, a] = R({ kind: "idle" }), [U, _] = R(null), j = S(m ?? new dt(l)).current, w = S(
64
+ Y ?? (p ? new ct({ proxyBase: N, getUploadToken: p, accountSlug: A }) : null)
65
+ ).current, y = S(
66
+ M ?? (p ? new ut({ proxyBase: N, getUploadToken: p, accountSlug: A }) : null)
67
+ ).current, J = b.kind !== "idle" && b.kind !== "error";
68
+ async function x(n, t) {
54
69
  try {
55
- const { site: d, build: l, buildSettings: g, url: k } = await et(y, r, {
56
- onProgress: (t) => n(S(t)),
57
- waitForBuild: J
70
+ const { site: i, build: r, buildSettings: o, url: e } = await pt(n, t, {
71
+ onProgress: (s) => a(I(s)),
72
+ waitForBuild: Z
58
73
  });
59
74
  return {
60
- url: k,
61
- siteName: d.name,
62
- siteId: d.id,
63
- buildId: l.id,
64
- deployId: l.deploy_id,
65
- buildSettings: g
75
+ url: e,
76
+ siteName: i.name,
77
+ siteId: i.id,
78
+ buildId: r.id,
79
+ deployId: r.deploy_id,
80
+ buildSettings: o
66
81
  };
67
- } catch (d) {
68
- if (d instanceof $) return null;
69
- throw d;
82
+ } catch (i) {
83
+ if (i instanceof O) return null;
84
+ throw i;
70
85
  }
71
86
  }
72
- async function R(y, r, d) {
73
- _(null), n({ kind: "reading" });
74
- const l = d.length ? { file_types: d } : {}, g = (t, i, a) => {
75
- n({ kind: "error", message: t }), c("dropzone_deploy_failed", { method: r, reason: i, ...l, ...a }), b == null || b({ message: t, reason: i });
76
- }, k = (t, i) => {
77
- const a = t instanceof Error ? t.message : String(t);
78
- g(nt(t), a, i);
87
+ async function Q(n, t, i) {
88
+ _(null), a({ kind: "reading" });
89
+ const r = i.length ? { file_types: i } : {}, o = (e, s, d) => {
90
+ a({ kind: "error", message: e }), u(c.DEPLOY_FAILED, { method: t, reason: s, ...r, ...d }), g == null || g({ message: e, reason: s });
79
91
  };
80
92
  try {
81
- const t = Y(await y());
82
- if (!t.length) {
83
- g("No files found to deploy.", "No files found to deploy.", { file_count: 0 });
93
+ const e = rt(await n());
94
+ if (!e.length) {
95
+ o("No files found to deploy.", "No files found to deploy.", { file_count: 0 });
84
96
  return;
85
97
  }
86
- r === "drag" && c("dropzone_files_dropped", {
87
- method: r,
88
- file_count: t.length,
89
- ...l
98
+ t === "drag" && u(c.FILES_DROPPED, {
99
+ method: t,
100
+ file_count: e.length,
101
+ ...r
90
102
  });
91
- const i = D(t);
92
- if (i.buildRequired) {
93
- if (c("dropzone_build_required", {
94
- method: r,
95
- reason: i.reason,
96
- file_count: t.length,
97
- ...l
98
- }), C) {
99
- n({ kind: "idle" }), C(i);
100
- return;
101
- }
102
- if (A) {
103
- const e = await Q(A, t);
104
- if (e) {
105
- n({ kind: "redirecting", target: "build" }), c("dropzone_build_deploy_succeeded", {
106
- method: r,
107
- reason: i.reason,
108
- site_name: e.siteName,
109
- file_count: t.length,
110
- ...e.buildSettings ? { framework: e.buildSettings.framework } : {},
111
- ...l
112
- }), h == null || h(e), window.location.assign(G(e));
113
- return;
114
- }
115
- }
116
- n({ kind: "redirecting", target: "signup" }), window.location.assign(q);
103
+ const s = { source: t, fileCount: e.length, typeProps: r }, d = st(e);
104
+ d.buildRequired ? await T(e, d, s) : await G(e, s);
105
+ } catch (e) {
106
+ const s = e instanceof Error ? e.message : String(e);
107
+ o(lt(e), s);
108
+ }
109
+ }
110
+ async function T(n, t, { source: i, fileCount: r, typeProps: o }) {
111
+ if (u(c.BUILD_REQUIRED, {
112
+ method: i,
113
+ reason: t.reason,
114
+ file_count: r,
115
+ ...o
116
+ }), L) {
117
+ a({ kind: "idle" }), L(t);
118
+ return;
119
+ }
120
+ let e = !1;
121
+ if (w) {
122
+ a({ kind: "zipping" });
123
+ const s = await mt(n), d = await x(w, s);
124
+ if (d) {
125
+ a({ kind: "redirecting", target: "build" }), u(c.BUILD_DEPLOY_SUCCEEDED, {
126
+ method: i,
127
+ reason: t.reason,
128
+ site_name: d.siteName,
129
+ file_count: r,
130
+ ...d.buildSettings ? { framework: d.buildSettings.framework } : {},
131
+ ...o
132
+ }), f == null || f(d), window.location.assign(C(d));
117
133
  return;
118
134
  }
119
- _(it(t));
120
- let a = null, s = !1, P = !1;
121
- if (F)
122
- try {
123
- a = await W(F, t, {
124
- onProgress: (e) => n(S(e))
125
- }), s = !0;
126
- } catch (e) {
127
- if (!(e instanceof $)) throw e;
128
- P = !0;
129
- }
130
- a || (a = await W(L, t, {
131
- onProgress: (e) => n(S(e))
132
- }));
133
- const { url: X, token: N, deploy: u } = a;
134
- if (!s)
135
- try {
136
- localStorage.setItem("drop-token", N), localStorage.setItem("dropSiteName", u.subdomain);
137
- } catch {
138
- }
139
- n({ kind: "redirecting", target: s ? "dashboard" : "claim" }), c("dropzone_deploy_succeeded", {
140
- method: r,
141
- site_name: u.subdomain,
142
- file_count: t.length,
143
- authenticated: s,
144
- ...P ? { auth_fallback: !0 } : {},
145
- ...l
146
- }), p == null || p({
147
- url: X,
148
- ...s ? {} : { token: N },
149
- siteName: u.subdomain,
150
- siteId: u.id,
151
- authenticated: s
152
- }), s ? window.location.assign(j(u.subdomain)) : window.location.assign(`${v(u.subdomain)}#drop_token=${N}`);
153
- } catch (t) {
154
- k(t);
135
+ e = await ht(s.file, s.buildSettings), e && u(c.PROJECT_STASHED, {
136
+ method: i,
137
+ reason: t.reason,
138
+ file_count: r,
139
+ ...o
140
+ });
141
+ }
142
+ if (P) {
143
+ a({ kind: "idle" }), P({ stashed: e, detection: t });
144
+ return;
155
145
  }
146
+ a({ kind: "redirecting", target: "signup" }), window.location.assign(W);
147
+ }
148
+ async function V(n, t) {
149
+ try {
150
+ return await v(n, t, {
151
+ onProgress: (i) => a(I(i))
152
+ });
153
+ } catch (i) {
154
+ if (i instanceof O) return null;
155
+ throw i;
156
+ }
157
+ }
158
+ async function G(n, { source: t, fileCount: i, typeProps: r }) {
159
+ _(wt(n));
160
+ const o = y ? await V(y, n) : null, e = o !== null, s = y !== null && !e, d = o ?? await v(j, n, {
161
+ onProgress: (it) => a(I(it))
162
+ }), { url: et, token: D, deploy: h } = d;
163
+ e || St(D, h.subdomain), a({ kind: "redirecting", target: e ? "dashboard" : "claim" }), u(c.DEPLOY_SUCCEEDED, {
164
+ method: t,
165
+ site_name: h.subdomain,
166
+ file_count: i,
167
+ authenticated: e,
168
+ ...s ? { auth_fallback: !0 } : {},
169
+ ...r
170
+ }), k == null || k({
171
+ url: et,
172
+ ...e ? {} : { token: D },
173
+ siteName: h.subdomain,
174
+ siteId: h.id,
175
+ authenticated: e
176
+ }), K(e, h.subdomain, D);
177
+ }
178
+ function K(n, t, i) {
179
+ n ? window.location.assign(H(t)) : window.location.assign(`${z(t)}#drop_token=${i}`);
180
+ }
181
+ async function X(n) {
182
+ const t = await gt();
183
+ if (!t) {
184
+ await E();
185
+ return;
186
+ }
187
+ u(c.RESUMED, {}), a({ kind: "creating" });
188
+ const i = { file: t.zipFile, buildSettings: t.buildSettings };
189
+ let r;
190
+ try {
191
+ r = await x(n, i);
192
+ } catch (o) {
193
+ await E(), B(o instanceof Error ? o.message : String(o));
194
+ return;
195
+ }
196
+ if (!r) {
197
+ a({ kind: "idle" });
198
+ return;
199
+ }
200
+ await E(), a({ kind: "redirecting", target: "build" }), f == null || f(r), window.location.assign(C(r));
201
+ }
202
+ function B(n) {
203
+ const t = "We couldn’t automatically deploy your project. Drop it again to publish it.";
204
+ a({ kind: "error", message: t }), u(c.DEPLOY_FAILED, { reason: "resume_failed" }), g == null || g({ message: t, reason: n });
156
205
  }
157
- function V() {
158
- _(null), n({ kind: "idle" });
206
+ const F = S(!1);
207
+ nt(() => {
208
+ F.current || !$ || !w || !ft() || (F.current = !0, X(w));
209
+ }, []);
210
+ function tt() {
211
+ _(null), a({ kind: "idle" });
159
212
  }
160
- return { status: w, warning: K, busy: O, deploy: R, reset: V };
213
+ return { status: b, warning: U, busy: J, deploy: Q, reset: tt };
161
214
  }
162
215
  export {
163
- mt as useDropDeploy
216
+ Pt as useDropDeploy
164
217
  };
@@ -6,6 +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, AuthenticatedBuildClient, AuthenticatedDropClient } from './DropZone';
10
- export type { BuildClient, DeployedBuild, DeployedSite, DropClient } from './DropZone';
9
+ export { DropZone, AuthenticatedBuildClient, AuthenticatedDropClient, DROPZONE_EVENTS, getFileTypes, humanizeDropError, } from './DropZone';
10
+ export type { BuildClient, DeployedBuild, DeployedSite, DeployError, DeployStatus, DropClient, DropZoneEventName, DropZoneEventProperties, TrackFn, } from './DropZone';
11
11
  export { type IconName } from './Icon';
@@ -1,29 +1,35 @@
1
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";
2
+ import { default as d } from "./Modal/Modal.js";
3
+ import { default as x } from "./Icon/index.js";
4
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 A } from "./SearchModal/components/SearchToggle/SearchToggle.js";
7
- import { A as g } from "../../chunks/AskNetlify.bx0blyGV.js";
6
+ import { default as S } from "./SearchModal/components/SearchToggle/SearchToggle.js";
7
+ import { A as y } from "../../chunks/AskNetlify.bx0blyGV.js";
8
8
  import "preact";
9
9
  import "../../chunks/hooks.module.DRcxknIz.js";
10
- import { default as k } from "./SearchModal/components/SearchModal/SearchModal.js";
11
- import { default as D } from "./DropZone/DropZone.js";
12
- import "./DropZone/drop-core/readFiles.js";
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";
10
+ import { default as D } from "./SearchModal/components/SearchModal/SearchModal.js";
11
+ import { default as N } from "./DropZone/DropZone.js";
12
+ import "../../drop-core/readFiles.js";
13
+ import { getFileTypes as k } from "../../drop-core/fileTypes.js";
14
+ import "../../drop-core/detectBuild.js";
15
+ import { humanizeDropError as K } from "../../drop-core/errors.js";
16
+ import { AuthenticatedDropClient as O } from "../../drop-core/authedDropClient.js";
17
+ import { AuthenticatedBuildClient as b } from "../../drop-core/buildClient.js";
18
+ import "../../drop-core/zip.js";
19
+ import { DROPZONE_EVENTS as B } from "../../drop-core/analytics.js";
17
20
  export {
18
- g as AskNetlify,
19
- B as AuthenticatedBuildClient,
20
- M as AuthenticatedDropClient,
21
- D as DropZone,
22
- u as Icon,
21
+ y as AskNetlify,
22
+ b as AuthenticatedBuildClient,
23
+ O as AuthenticatedDropClient,
24
+ B as DROPZONE_EVENTS,
25
+ N as DropZone,
26
+ x as Icon,
23
27
  m as KeyboardKey,
24
- l as Modal,
28
+ d as Modal,
25
29
  c as SearchHeading,
26
30
  s as SearchLink,
27
- k as SearchModal,
28
- A as SearchToggle
31
+ D as SearchModal,
32
+ S as SearchToggle,
33
+ k as getFileTypes,
34
+ K as humanizeDropError
29
35
  };
@@ -0,0 +1,107 @@
1
+ import { BuildReason } from './detectBuild';
2
+ /**
3
+ * The Drop Zone's analytics contract — the canonical event names and property
4
+ * shapes, exported so no consumer (this package's own component, a host site's
5
+ * GTM wiring, or another Netlify surface implementing its own Drop UI over
6
+ * drop-core) ever hand-writes the strings.
7
+ */
8
+ /** How the files reached the zone — carried on every drop-initiated event as `method`. */
9
+ export type DropMethod = 'drag' | 'browse';
10
+ /**
11
+ * Canonical Drop Zone lifecycle events. The values are the wire names:
12
+ * analytics history in Amplitude/Segment keys off these exact strings, so
13
+ * renaming a value silently forks every funnel built on it — treat them as
14
+ * append-only.
15
+ */
16
+ export declare const DROPZONE_EVENTS: {
17
+ /** Files arrived via drag — the picker path reports its files on outcome events instead. */
18
+ readonly FILES_DROPPED: "dropzone_files_dropped";
19
+ /** The native file picker was opened (keyboard or click). */
20
+ readonly BROWSE_OPENED: "dropzone_browse_opened";
21
+ /** The drop needs a build — it will be built in place, stashed, or handed off. */
22
+ readonly BUILD_REQUIRED: "dropzone_build_required";
23
+ /** A static deploy went live (anonymous or into the visitor's account). */
24
+ readonly DEPLOY_SUCCEEDED: "dropzone_deploy_succeeded";
25
+ /** A build was enqueued in the visitor's account. */
26
+ readonly BUILD_DEPLOY_SUCCEEDED: "dropzone_build_deploy_succeeded";
27
+ /** Any attempt ended in an error (including a failed resume). */
28
+ readonly DEPLOY_FAILED: "dropzone_deploy_failed";
29
+ /** A logged-out build drop was stashed locally before the signup hand-off. */
30
+ readonly PROJECT_STASHED: "dropzone_project_stashed";
31
+ /** A stashed build drop was picked up for automatic deployment. */
32
+ readonly RESUMED: "dropzone_resumed";
33
+ };
34
+ export type DropZoneEventName = (typeof DROPZONE_EVENTS)[keyof typeof DROPZONE_EVENTS];
35
+ /** Properties the component adds to every event. */
36
+ export interface DropZoneBaseEventProps {
37
+ /** Present when the consumer sets `analyticsId` — tells multiple zones apart. */
38
+ dropzone_id?: string;
39
+ }
40
+ export interface FilesDroppedProps extends DropZoneBaseEventProps {
41
+ method: 'drag';
42
+ file_count: number;
43
+ /** Omitted — never `[]` — when the browser exposes no files. */
44
+ file_types?: string[];
45
+ }
46
+ export interface BrowseOpenedProps extends DropZoneBaseEventProps {
47
+ method: 'keyboard' | 'click';
48
+ }
49
+ export interface BuildRequiredProps extends DropZoneBaseEventProps {
50
+ method: DropMethod;
51
+ reason: BuildReason | null;
52
+ file_count: number;
53
+ file_types?: string[];
54
+ }
55
+ export interface DeploySucceededProps extends DropZoneBaseEventProps {
56
+ method: DropMethod;
57
+ site_name: string;
58
+ file_count: number;
59
+ /** Whether the deploy landed directly in the visitor's account. */
60
+ authenticated: boolean;
61
+ /** Present only when an authenticated attempt bounced (stale login hint) and the drop completed anonymously. */
62
+ auth_fallback?: true;
63
+ file_types?: string[];
64
+ }
65
+ export interface BuildDeploySucceededProps extends DropZoneBaseEventProps {
66
+ method: DropMethod;
67
+ reason: BuildReason | null;
68
+ site_name: string;
69
+ file_count: number;
70
+ /** Present when build settings were synthesised into the archive. */
71
+ framework?: string;
72
+ file_types?: string[];
73
+ }
74
+ export interface DeployFailedProps extends DropZoneBaseEventProps {
75
+ /** Absent when the failure comes from a stash resume rather than a live drop gesture. */
76
+ method?: DropMethod;
77
+ /** Raw failure reason (e.g. "drop failed: 429", "resume_failed") — the humanized copy goes to the UI, not here. */
78
+ reason: string;
79
+ /** Present only when the file set is known (absent when reading itself threw). */
80
+ file_count?: number;
81
+ file_types?: string[];
82
+ }
83
+ export interface ProjectStashedProps extends DropZoneBaseEventProps {
84
+ method: DropMethod;
85
+ reason: BuildReason | null;
86
+ file_count: number;
87
+ file_types?: string[];
88
+ }
89
+ /** A resume starts from storage, not a fresh gesture — no method or file set to report. */
90
+ export type ResumedProps = DropZoneBaseEventProps;
91
+ /** Event name → its property shape, for typed emitters and sinks on either side of the seam. */
92
+ export interface DropZoneEventProperties {
93
+ dropzone_files_dropped: FilesDroppedProps;
94
+ dropzone_browse_opened: BrowseOpenedProps;
95
+ dropzone_build_required: BuildRequiredProps;
96
+ dropzone_deploy_succeeded: DeploySucceededProps;
97
+ dropzone_build_deploy_succeeded: BuildDeploySucceededProps;
98
+ dropzone_deploy_failed: DeployFailedProps;
99
+ dropzone_project_stashed: ProjectStashedProps;
100
+ dropzone_resumed: ResumedProps;
101
+ }
102
+ /**
103
+ * Provider-agnostic analytics sink. Deliberately loose (string, not the event
104
+ * union): hosts forward these to Segment/GA/GTM and often pipe their own
105
+ * events through the same function.
106
+ */
107
+ export type TrackFn = (event: string, properties?: Record<string, unknown>) => void;
@@ -0,0 +1,21 @@
1
+ const e = {
2
+ /** Files arrived via drag — the picker path reports its files on outcome events instead. */
3
+ FILES_DROPPED: "dropzone_files_dropped",
4
+ /** The native file picker was opened (keyboard or click). */
5
+ BROWSE_OPENED: "dropzone_browse_opened",
6
+ /** The drop needs a build — it will be built in place, stashed, or handed off. */
7
+ BUILD_REQUIRED: "dropzone_build_required",
8
+ /** A static deploy went live (anonymous or into the visitor's account). */
9
+ DEPLOY_SUCCEEDED: "dropzone_deploy_succeeded",
10
+ /** A build was enqueued in the visitor's account. */
11
+ BUILD_DEPLOY_SUCCEEDED: "dropzone_build_deploy_succeeded",
12
+ /** Any attempt ended in an error (including a failed resume). */
13
+ DEPLOY_FAILED: "dropzone_deploy_failed",
14
+ /** A logged-out build drop was stashed locally before the signup hand-off. */
15
+ PROJECT_STASHED: "dropzone_project_stashed",
16
+ /** A stashed build drop was picked up for automatic deployment. */
17
+ RESUMED: "dropzone_resumed"
18
+ };
19
+ export {
20
+ e as DROPZONE_EVENTS
21
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import { BuildSite } from './types';
2
+ /**
3
+ * The transport both authenticated clients share: JSON calls ride the
4
+ * consumer's access-control rewrite on the session cookie, so nothing
5
+ * credential-shaped lives in the browser and nothing can expire mid-deploy.
6
+ * (Uploads are the exception — the proxy's Lambda caps request bodies at
7
+ * ~6MB — and each client handles its own, bearer-authorized.)
8
+ */
9
+ /**
10
+ * Default root for proxied JSON calls. On netlify.com the `/access-control/*`
11
+ * rewrite targets the app's access-control function, making this path the API
12
+ * root. The paths a given origin may call are allowlisted server-side.
13
+ */
14
+ export declare const DEFAULT_PROXY_BASE = "/access-control/bb-api/api/v1";
15
+ /** Direct api.netlify.com root for the uploads the proxy can't carry. */
16
+ export declare const DEFAULT_API_BASE = "https://api.netlify.com/api/v1";
17
+ export declare const DEFAULT_POLL_INTERVAL_MS = 1000;
18
+ export declare const DEFAULT_TIMEOUT_MS: number;
19
+ /**
20
+ * Create a site in the visitor's account via `POST {proxyBase}/sites` (scoped
21
+ * to `accountSlug` when given, else the user's default account), attributed
22
+ * `created_via: 'drop'`.
23
+ *
24
+ * A logged-out visitor 401s here, before anything is created — the one
25
+ * pre-mutation point where callers may still safely fall back to an anonymous
26
+ * flow, which is why it maps to `NotAuthenticatedError`. Any other failure is
27
+ * a `SiteCreateError` carrying the status.
28
+ */
29
+ export declare function createSiteInAccount(proxyBase: string, accountSlug?: string): Promise<BuildSite>;
30
+ /** How a watched deploy ended. `errorMessage` is the API's own explanation, when it gave one. */
31
+ export type SettledDeploy = {
32
+ outcome: 'ready';
33
+ } | {
34
+ outcome: 'failed';
35
+ errorMessage?: string;
36
+ } | {
37
+ outcome: 'timed-out';
38
+ };
39
+ /**
40
+ * Poll `GET {proxyBase}/deploys/{deployId}` on the session cookie until the
41
+ * deploy settles, and report how. Purely mechanical on purpose: each caller
42
+ * maps the outcome onto its own error vocabulary (the drop client throws plain
43
+ * errors `humanizeDropError` understands; the build client throws
44
+ * `BuildFailedError`/`BuildTimeoutError`), so that knowledge stays next to the
45
+ * class it belongs to.
46
+ *
47
+ * A non-ok poll response is skipped, not fatal — a transient proxy hiccup
48
+ * shouldn't kill a deploy that is still progressing.
49
+ */
50
+ export declare function pollDeployUntilSettled(options: {
51
+ proxyBase: string;
52
+ deployId: string;
53
+ pollIntervalMs: number;
54
+ timeoutMs: number;
55
+ }): Promise<SettledDeploy>;
@@ -0,0 +1,35 @@
1
+ import { NotAuthenticatedError as d, SiteCreateError as l } from "./errors.js";
2
+ const f = "/access-control/bb-api/api/v1", y = "https://api.netlify.com/api/v1", T = 1e3, m = 10 * 60 * 1e3;
3
+ async function A(s, o) {
4
+ const r = o ? `/${o}/sites` : "/sites", t = await fetch(`${s}${r}`, {
5
+ method: "POST",
6
+ credentials: "include",
7
+ headers: { "Content-Type": "application/json" },
8
+ body: JSON.stringify({ created_via: "drop" })
9
+ });
10
+ if (t.status === 401 || t.status === 403) throw new d();
11
+ if (!t.ok) throw new l(t.status);
12
+ return t.json();
13
+ }
14
+ const p = /* @__PURE__ */ new Set(["ready", "error", "rejected"]);
15
+ async function E(s) {
16
+ const { proxyBase: o, deployId: r, pollIntervalMs: t, timeoutMs: i } = s, c = i / t;
17
+ for (let n = 0; n < c; n++) {
18
+ const a = await fetch(`${o}/deploys/${r}`, { credentials: "include" });
19
+ if (a.ok) {
20
+ const e = await a.json();
21
+ if (e.state && p.has(e.state))
22
+ return e.state === "ready" ? { outcome: "ready" } : { outcome: "failed", errorMessage: e.error_message };
23
+ }
24
+ await new Promise((e) => setTimeout(e, t));
25
+ }
26
+ return { outcome: "timed-out" };
27
+ }
28
+ export {
29
+ y as DEFAULT_API_BASE,
30
+ T as DEFAULT_POLL_INTERVAL_MS,
31
+ f as DEFAULT_PROXY_BASE,
32
+ m as DEFAULT_TIMEOUT_MS,
33
+ A as createSiteInAccount,
34
+ E as pollDeployUntilSettled
35
+ };
@@ -0,0 +1 @@
1
+ export {};