@netlify/spark-ui 1.31.0-alpha.4 → 1.31.0-alpha.6
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/README.md +3 -4
- package/dist/components/preact/DropZone/DropZone.d.ts +23 -98
- package/dist/components/preact/DropZone/DropZone.js +5 -5
- package/dist/components/preact/DropZone/index.js +29 -29
- package/dist/components/preact/DropZone/useDropDeploy.d.ts +0 -1
- package/dist/components/preact/DropZone/useDropDeploy.js +25 -27
- package/dist/components/preact/index.js +10 -10
- package/dist/drop-core/analytics.d.ts +4 -15
- package/dist/drop-core/authedApi.d.ts +9 -32
- package/dist/drop-core/authedApi.js +15 -20
- package/dist/drop-core/authedDropClient.d.ts +15 -64
- package/dist/drop-core/authedDropClient.js +27 -49
- package/dist/drop-core/buildClient.d.ts +19 -53
- package/dist/drop-core/buildClient.js +32 -44
- package/dist/drop-core/buildStash.d.ts +6 -20
- package/dist/drop-core/client.d.ts +4 -2
- package/dist/drop-core/client.js +19 -17
- package/dist/drop-core/constants.d.ts +9 -0
- package/dist/drop-core/constants.js +10 -0
- package/dist/drop-core/deploy.d.ts +7 -17
- package/dist/drop-core/deploy.js +56 -43
- package/dist/drop-core/detectBuild.d.ts +8 -26
- package/dist/drop-core/errors.d.ts +27 -17
- package/dist/drop-core/errors.js +70 -33
- package/dist/drop-core/fileTypes.d.ts +4 -14
- package/dist/drop-core/index.d.ts +22 -11
- package/dist/drop-core/index.js +45 -49
- package/dist/drop-core/readFiles.d.ts +5 -11
- package/dist/drop-core/types.d.ts +2 -4
- package/dist/drop-core/zip.d.ts +7 -30
- package/package.json +1 -1
- package/packages/components/preact/DropZone/DropZone.tsx +27 -122
- package/packages/components/preact/DropZone/useDropDeploy.ts +31 -73
- package/packages/drop-core/README.md +91 -0
- package/packages/drop-core/analytics.ts +4 -15
- package/packages/drop-core/authedApi.ts +9 -35
- package/packages/drop-core/authedDropClient.ts +23 -86
- package/packages/drop-core/buildClient.test.ts +19 -4
- package/packages/drop-core/buildClient.ts +23 -66
- package/packages/drop-core/buildStash.ts +9 -25
- package/packages/drop-core/client.ts +19 -11
- package/packages/drop-core/constants.ts +25 -0
- package/packages/drop-core/deploy.test.ts +42 -0
- package/packages/drop-core/deploy.ts +42 -22
- package/packages/drop-core/detectBuild.ts +15 -50
- package/packages/drop-core/errors.test.ts +34 -3
- package/packages/drop-core/errors.ts +63 -27
- package/packages/drop-core/fileTypes.ts +5 -19
- package/packages/drop-core/index.ts +41 -11
- package/packages/drop-core/readFiles.test.ts +0 -1
- package/packages/drop-core/readFiles.ts +5 -12
- package/packages/drop-core/types.ts +2 -4
- package/packages/drop-core/zip.ts +7 -30
package/README.md
CHANGED
|
@@ -147,13 +147,13 @@ This repo includes a [Claude Code](https://claude.ai/code) skill for generating
|
|
|
147
147
|
|
|
148
148
|
The skill is available automatically. Run:
|
|
149
149
|
|
|
150
|
-
```
|
|
150
|
+
```
|
|
151
151
|
/project:landing-page <describe the page you want>
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
For example:
|
|
155
155
|
|
|
156
|
-
```
|
|
156
|
+
```
|
|
157
157
|
/project:landing-page A landing page for a new enterprise hosting product with a hero, feature cards, and a pricing comparison
|
|
158
158
|
```
|
|
159
159
|
|
|
@@ -185,7 +185,7 @@ When you’re ready to validate your component changes in a deploy preview, you
|
|
|
185
185
|
>
|
|
186
186
|
> Reach out to #internal-permissions in Slack
|
|
187
187
|
|
|
188
|
-
### Steps to Publish an Alpha Release
|
|
188
|
+
### Steps to Publish an Alpha Release:
|
|
189
189
|
|
|
190
190
|
1. **Make sure you're logged into npm locally**
|
|
191
191
|
|
|
@@ -206,7 +206,6 @@ When you’re ready to validate your component changes in a deploy preview, you
|
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
1. **Install the updated package:**
|
|
209
|
-
|
|
210
209
|
```bash
|
|
211
210
|
npm install
|
|
212
211
|
```
|
|
@@ -10,30 +10,17 @@ interface Props {
|
|
|
10
10
|
client?: DropClient;
|
|
11
11
|
/** Build the "claim this site" URL from the assigned site name (subdomain). */
|
|
12
12
|
claimUrl?: (siteName: string) => string;
|
|
13
|
-
/**
|
|
14
|
-
* Where an authenticated static deploy sends the visitor — the site already
|
|
15
|
-
* lives in their account, so there is no claim step. Defaults to the new
|
|
16
|
-
* site's project overview on app.netlify.com.
|
|
17
|
-
*/
|
|
13
|
+
/** Destination after an authenticated static deploy (no claim step). Default: the project overview. */
|
|
18
14
|
siteDashboardUrl?: (siteName: string) => string;
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* visitor who isn't logged in. Such projects can't deploy through the anonymous
|
|
23
|
-
* static drop API, so by default the user is redirected here — the app signup
|
|
24
|
-
* page with `next=/drop` — to build on the authenticated Drop page. Override to
|
|
25
|
-
* point at your own destination.
|
|
16
|
+
* Signup hand-off for a build drop with no session. The drop is stashed on
|
|
17
|
+
* this origin first — return the visitor here and it deploys automatically.
|
|
26
18
|
*/
|
|
27
19
|
buildSignupUrl?: string;
|
|
28
20
|
/**
|
|
29
|
-
* Mint
|
|
30
|
-
*
|
|
31
|
-
* drops
|
|
32
|
-
* build-required drops build in place instead of being handed off to the app.
|
|
33
|
-
* On netlify.com this reads `GET /access-control/generate-access-control-token`.
|
|
34
|
-
* Resolving `null` means "no session": static drops fall back to the anonymous
|
|
35
|
-
* claim flow, build drops to `buildSignupUrl`.
|
|
36
|
-
* See [Logged-in visitors](#logged-in-visitors).
|
|
21
|
+
* Mint the upload bearer — passing this switches on the whole authenticated
|
|
22
|
+
* path. `null` means "no session": static drops fall back to the anonymous
|
|
23
|
+
* claim flow; build drops stash and hand off. See the docs' Logged-in visitors.
|
|
37
24
|
*/
|
|
38
25
|
getUploadToken?: () => Promise<string | null>;
|
|
39
26
|
/**
|
|
@@ -41,111 +28,49 @@ interface Props {
|
|
|
41
28
|
* Takes precedence over `getUploadToken` for the build path.
|
|
42
29
|
*/
|
|
43
30
|
buildClient?: BuildClient;
|
|
44
|
-
/**
|
|
45
|
-
* Inject a custom authenticated `DropClient` for static drops (tests, staging,
|
|
46
|
-
* a different account flow). Takes precedence over `getUploadToken` for the
|
|
47
|
-
* static path. Distinct from `client`, which is the anonymous fallback.
|
|
48
|
-
*/
|
|
31
|
+
/** Custom authenticated static-drop client; wins over `getUploadToken`. (`client` is the anonymous fallback.) */
|
|
49
32
|
authenticatedDropClient?: DropClient;
|
|
50
|
-
/**
|
|
51
|
-
* API root for the authenticated paths' JSON calls, which go through your
|
|
52
|
-
* access-control rewrite so the session cookie authorizes them. Defaults to
|
|
53
|
-
* `/access-control/bb-api/api/v1`. (Uploads always go direct to
|
|
54
|
-
* `api.netlify.com` — the proxy can't carry bodies that large.)
|
|
55
|
-
*/
|
|
33
|
+
/** Root for the session-cookie JSON calls, via your access-control rewrite. Uploads always go direct. */
|
|
56
34
|
proxyBase?: string;
|
|
57
35
|
/** Create the visitor's new project in this account. Omit for their default account. */
|
|
58
36
|
accountSlug?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Where an enqueued build sends the visitor. Defaults to the new site's
|
|
61
|
-
* project overview, same as a static deploy; `build.deployId` is available for
|
|
62
|
-
* consumers who want the deploy-log page instead.
|
|
63
|
-
*/
|
|
37
|
+
/** Destination after a build is enqueued. Default: the project overview (`build.deployId` for the logs page). */
|
|
64
38
|
buildDeployUrl?: (build: DeployedBuild) => string;
|
|
65
39
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* its own error message here (via `onError` and the overlay) rather than the
|
|
69
|
-
* visitor discovering it on the deploy page — at the cost of holding them on a
|
|
70
|
-
* spinner for the length of the build, which is minutes. Off by default.
|
|
40
|
+
* Hold the visitor until the build finishes (off by default — builds take
|
|
41
|
+
* minutes). On is the only way a failing build's own message reaches `onError`.
|
|
71
42
|
*/
|
|
72
43
|
waitForBuild?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Called when a build-required drop is detected, instead of building it or
|
|
75
|
-
* redirecting. Use it to own the hand-off yourself (custom routing, persisting
|
|
76
|
-
* the drop, gating on auth). When set, the component neither builds nor
|
|
77
|
-
* redirects. The static drop path is unaffected either way.
|
|
78
|
-
*/
|
|
44
|
+
/** Take over build-required drops entirely — when set, the component neither builds nor redirects. */
|
|
79
45
|
onBuildRequired?: (info: BuildDetection) => void;
|
|
80
46
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* however fits your auth flow, e.g. open a signup popup that keeps the
|
|
85
|
-
* visitor on the page. Once they're back authenticated, a remount of the
|
|
86
|
-
* zone deploys the stash automatically.
|
|
47
|
+
* Own the signup hand-off instead of the `buildSignupUrl` redirect (e.g. an
|
|
48
|
+
* auth popup). The drop is already stashed; a remount while authenticated
|
|
49
|
+
* deploys it.
|
|
87
50
|
*/
|
|
88
51
|
onBuildSignupHandoff?: (info: {
|
|
89
52
|
stashed: boolean;
|
|
90
53
|
detection: BuildDetection;
|
|
91
54
|
}) => void;
|
|
92
|
-
/**
|
|
93
|
-
* Deploy a previously stashed build drop automatically when the zone mounts
|
|
94
|
-
* with an authenticated visitor (default `true`). The stash is written when a
|
|
95
|
-
* logged-out build drop is handed to signup; see
|
|
96
|
-
* [Signup hand-off and auto-resume](#signup-hand-off-and-auto-resume).
|
|
97
|
-
*/
|
|
55
|
+
/** Auto-deploy a stashed build drop on mount when authenticated (default true). */
|
|
98
56
|
resumeStashedBuilds?: boolean;
|
|
99
57
|
/** Called once the deploy is live. */
|
|
100
58
|
onDeploy?: (result: DeployedSite) => void;
|
|
101
|
-
/**
|
|
102
|
-
* Called once a build-required drop has been zipped, uploaded and enqueued —
|
|
103
|
-
* before the redirect to `buildDeployUrl`. The site exists at this point but
|
|
104
|
-
* won't serve content until the build finishes.
|
|
105
|
-
*/
|
|
59
|
+
/** Called once a build is enqueued, before the `buildDeployUrl` redirect. */
|
|
106
60
|
onBuildDeploy?: (build: DeployedBuild) => void;
|
|
107
|
-
/**
|
|
108
|
-
* Called when a deploy fails, with a humanized `message` (ready to show a
|
|
109
|
-
* user — the same copy the built-in overlay uses) and the raw `reason`. Pair
|
|
110
|
-
* this with `showStatus={false}` to render your own error UI.
|
|
111
|
-
*/
|
|
61
|
+
/** Deploy failures: humanized `message` (the overlay's copy) + raw `reason`. Pair with showStatus={false}. */
|
|
112
62
|
onError?: (error: DeployError) => void;
|
|
113
63
|
/**
|
|
114
|
-
* Render the built-in
|
|
115
|
-
*
|
|
116
|
-
* drive your own feedback from the `data-state` attribute on the root element.
|
|
117
|
-
* Note: in this mode you're responsible for surfacing errors yourself — use
|
|
118
|
-
* `onError` to get the message.
|
|
64
|
+
* Render the built-in overlay. `false` keeps children visible — drive your
|
|
65
|
+
* own feedback from `data-state`, and surface errors yourself via `onError`.
|
|
119
66
|
*/
|
|
120
67
|
showStatus?: boolean;
|
|
121
68
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* consuming app, e.g. `onTrack={(name, props) => new Analytics().track(name, props)}`.
|
|
125
|
-
* Emitted events (all include `dropzone_id` when `analyticsId` is set):
|
|
126
|
-
* - `dropzone_files_dropped` — files dropped via drag ({ method: 'drag', file_count, file_types })
|
|
127
|
-
* - `dropzone_browse_opened` — file picker opened ({ method: 'keyboard' | 'click' })
|
|
128
|
-
* - `dropzone_build_required` — drop needs a build (built here, or handed off) ({ method, reason, file_count, file_types })
|
|
129
|
-
* - `dropzone_deploy_succeeded` — static deploy went live ({ method, site_name, file_count, authenticated, auth_fallback?, file_types })
|
|
130
|
-
* - `dropzone_build_deploy_succeeded` — build enqueued for a logged-in visitor ({ method, reason, site_name, file_count, framework?, file_types })
|
|
131
|
-
* - `dropzone_deploy_failed` — deploy or build errored out ({ method, reason, file_count?, file_types })
|
|
132
|
-
*
|
|
133
|
-
* `authenticated` says whether the deploy landed in the visitor's account;
|
|
134
|
-
* `auth_fallback: true` is sent only when an authenticated attempt bounced
|
|
135
|
-
* (stale auth hint) and the drop completed anonymously — omitted otherwise.
|
|
136
|
-
* `file_types` is the sorted, de-duplicated list of MIME types in the
|
|
137
|
-
* selection, with `application/octet-stream` standing in wherever the browser
|
|
138
|
-
* reports none (a dragged folder, an `.exe`). It is omitted when the browser
|
|
139
|
-
* exposes no files at all. Note `dropzone_files_dropped` only fires for drag —
|
|
140
|
-
* a file-picker selection reports its types on the outcome events, as
|
|
141
|
-
* `dropzone_browse_opened` fires before any file exists.
|
|
69
|
+
* Provider-agnostic analytics hook. Event names and payload shapes live in
|
|
70
|
+
* DROPZONE_EVENTS / DropZoneEventProperties (drop-core/analytics.ts).
|
|
142
71
|
*/
|
|
143
72
|
onTrack?: TrackFn;
|
|
144
|
-
/**
|
|
145
|
-
* Stable identifier for this instance, attached to every tracked event as
|
|
146
|
-
* `dropzone_id`. Set it when a page renders more than one Drop Zone so the
|
|
147
|
-
* events can be told apart in Amplitude.
|
|
148
|
-
*/
|
|
73
|
+
/** Stamped on every event as `dropzone_id` — set when a page has more than one zone. */
|
|
149
74
|
analyticsId?: string;
|
|
150
75
|
className?: string;
|
|
151
76
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { u as e } from "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
|
|
2
2
|
import { A as E, d as K, y as L } from "../../../chunks/hooks.module.DRcxknIz.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DROPZONE_EVENTS as W } from "../../../drop-core/analytics.js";
|
|
4
|
+
import { readFileList as q, readDataTransfer as H } from "../../../drop-core/readFiles.js";
|
|
4
5
|
import { getFileTypes as z } from "../../../drop-core/fileTypes.js";
|
|
5
6
|
import "../../../drop-core/detectBuild.js";
|
|
6
7
|
import "../../../drop-core/zip.js";
|
|
7
|
-
import { DROPZONE_EVENTS as H } from "../../../drop-core/analytics.js";
|
|
8
8
|
import { useDropDeploy as J } from "./useDropDeploy.js";
|
|
9
9
|
import { Fragment as w } from "preact";
|
|
10
10
|
import '../../../assets/DropZone.css';const Q = 120, X = (r) => `https://app.netlify.com/drop/${r}`, Y = (r) => `https://app.netlify.com/projects/${r}`, ee = "https://app.netlify.com/signup?next=/drop&utm_campaign=drop", re = ({ siteName: r }) => `https://app.netlify.com/projects/${r}`;
|
|
@@ -55,7 +55,7 @@ function fe({
|
|
|
55
55
|
track: m
|
|
56
56
|
}), { active: p, keepActive: V, endDrag: M } = te(), h = E(null), v = (t) => {
|
|
57
57
|
var n;
|
|
58
|
-
m(
|
|
58
|
+
m(W.BROWSE_OPENED, { method: t }), (n = h.current) == null || n.click();
|
|
59
59
|
}, Z = f && (p || i || s.kind === "error"), G = [
|
|
60
60
|
"n-dropzone",
|
|
61
61
|
p && "is-active",
|
|
@@ -78,7 +78,7 @@ function fe({
|
|
|
78
78
|
onDrop: (t) => {
|
|
79
79
|
if (t.preventDefault(), M(), i) return;
|
|
80
80
|
const n = t.dataTransfer;
|
|
81
|
-
n && b(() =>
|
|
81
|
+
n && b(() => H(n), "drag", z(n.files));
|
|
82
82
|
},
|
|
83
83
|
onClick: (t) => {
|
|
84
84
|
!i && t.target === t.currentTarget && v("click");
|
|
@@ -102,7 +102,7 @@ function fe({
|
|
|
102
102
|
const n = t.currentTarget;
|
|
103
103
|
if ((D = n.files) != null && D.length) {
|
|
104
104
|
const k = n.files;
|
|
105
|
-
b(() =>
|
|
105
|
+
b(() => q(k), "browse", z(k));
|
|
106
106
|
}
|
|
107
107
|
n.value = "";
|
|
108
108
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { default as o } from "./DropZone.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
2
|
+
import { BuildCreateError as i, BuildFailedError as p, BuildTimeoutError as d, NotAuthenticatedError as l, SiteCreateError as u, UnsupportedDropError as a, humanizeDropError as f } from "../../../drop-core/errors.js";
|
|
3
|
+
import { DROPZONE_EVENTS as n } from "../../../drop-core/analytics.js";
|
|
4
|
+
import { readDataTransfer as E, readFileList as s } from "../../../drop-core/readFiles.js";
|
|
5
|
+
import { getFileTypes as D } from "../../../drop-core/fileTypes.js";
|
|
6
|
+
import { detectBuild as F, inferBuildSettings as c } from "../../../drop-core/detectBuild.js";
|
|
7
|
+
import { zipFiles as y } from "../../../drop-core/zip.js";
|
|
8
|
+
import { AnonymousDropClient as T } from "../../../drop-core/client.js";
|
|
9
|
+
import { AuthenticatedDropClient as S } from "../../../drop-core/authedDropClient.js";
|
|
10
|
+
import { AuthenticatedBuildClient as z } from "../../../drop-core/buildClient.js";
|
|
11
|
+
import { deployBuild as Z, deployFiles as L } from "../../../drop-core/deploy.js";
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
T as AnonymousDropClient,
|
|
14
|
+
z as AuthenticatedBuildClient,
|
|
15
|
+
S as AuthenticatedDropClient,
|
|
16
|
+
i as BuildCreateError,
|
|
17
|
+
p as BuildFailedError,
|
|
18
|
+
d as BuildTimeoutError,
|
|
19
|
+
n as DROPZONE_EVENTS,
|
|
20
20
|
o as DropZone,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
l as NotAuthenticatedError,
|
|
22
|
+
u as SiteCreateError,
|
|
23
|
+
a as UnsupportedDropError,
|
|
24
|
+
Z as deployBuild,
|
|
25
|
+
L as deployFiles,
|
|
26
|
+
F as detectBuild,
|
|
27
|
+
D as getFileTypes,
|
|
28
|
+
f as humanizeDropError,
|
|
29
|
+
c as inferBuildSettings,
|
|
30
|
+
E as readDataTransfer,
|
|
31
|
+
s as readFileList,
|
|
32
|
+
y as zipFiles
|
|
33
33
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { d as R, A as S, y as nt } from "../../../chunks/hooks.module.DRcxknIz.js";
|
|
2
|
-
import {
|
|
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";
|
|
2
|
+
import { humanizeDropError as rt, isNotAuthenticatedError as O } from "../../../drop-core/errors.js";
|
|
11
3
|
import { DROPZONE_EVENTS as c } from "../../../drop-core/analytics.js";
|
|
4
|
+
import { renameSingleNonIndexHtmlToIndex as at, getSingleNonIndexHtmlFileName as ot, hasMultipleHtmlFilesWithoutIndex as st } from "../../../drop-core/readFiles.js";
|
|
5
|
+
import { detectBuild as dt } from "../../../drop-core/detectBuild.js";
|
|
6
|
+
import { zipFiles as lt } from "../../../drop-core/zip.js";
|
|
7
|
+
import { AnonymousDropClient as ut } from "../../../drop-core/client.js";
|
|
8
|
+
import { AuthenticatedDropClient as ct } from "../../../drop-core/authedDropClient.js";
|
|
9
|
+
import { AuthenticatedBuildClient as mt } from "../../../drop-core/buildClient.js";
|
|
10
|
+
import { deployZippedBuild as ft, deployFiles as v } from "../../../drop-core/deploy.js";
|
|
11
|
+
import { hasDropStashMarker as gt, loadDropStash as ht, clearDropStash as E, saveDropStash as pt } from "../../../drop-core/buildStash.js";
|
|
12
12
|
function I(l) {
|
|
13
13
|
switch (l.phase) {
|
|
14
14
|
case "zipping":
|
|
@@ -25,8 +25,8 @@ function I(l) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function wt(l) {
|
|
28
|
-
const m =
|
|
29
|
-
return m ? `No index.html found — "${m}" won’t be served at the site root.` :
|
|
28
|
+
const m = ot(l);
|
|
29
|
+
return m ? `No index.html found — "${m}" won’t be served at the site root.` : st(l) ? "No index.html found — your site may not have a landing page." : null;
|
|
30
30
|
}
|
|
31
31
|
function St(l, m) {
|
|
32
32
|
try {
|
|
@@ -56,18 +56,16 @@ function Pt({
|
|
|
56
56
|
track: q
|
|
57
57
|
}) {
|
|
58
58
|
const u = (n, t) => (
|
|
59
|
-
// The
|
|
60
|
-
// signature (so payloads stay closed for consumers), and the checking that
|
|
61
|
-
// matters happened against DropZoneEventProperties[E] above.
|
|
59
|
+
// The event interfaces carry no index signature, hence the cast to TrackFn's record.
|
|
62
60
|
q(n, t)
|
|
63
|
-
), [b, a] = R({ kind: "idle" }), [U, _] = R(null), j = S(m ?? new
|
|
64
|
-
Y ?? (p ? new
|
|
61
|
+
), [b, a] = R({ kind: "idle" }), [U, _] = R(null), j = S(m ?? new ut(l)).current, w = S(
|
|
62
|
+
Y ?? (p ? new mt({ proxyBase: N, getUploadToken: p, accountSlug: A }) : null)
|
|
65
63
|
).current, y = S(
|
|
66
|
-
M ?? (p ? new
|
|
64
|
+
M ?? (p ? new ct({ proxyBase: N, getUploadToken: p, accountSlug: A }) : null)
|
|
67
65
|
).current, J = b.kind !== "idle" && b.kind !== "error";
|
|
68
66
|
async function x(n, t) {
|
|
69
67
|
try {
|
|
70
|
-
const { site: i, build: r, buildSettings: o, url: e } = await
|
|
68
|
+
const { site: i, build: r, buildSettings: o, url: e } = await ft(n, t, {
|
|
71
69
|
onProgress: (s) => a(I(s)),
|
|
72
70
|
waitForBuild: Z
|
|
73
71
|
});
|
|
@@ -80,7 +78,7 @@ function Pt({
|
|
|
80
78
|
buildSettings: o
|
|
81
79
|
};
|
|
82
80
|
} catch (i) {
|
|
83
|
-
if (i
|
|
81
|
+
if (O(i)) return null;
|
|
84
82
|
throw i;
|
|
85
83
|
}
|
|
86
84
|
}
|
|
@@ -90,7 +88,7 @@ function Pt({
|
|
|
90
88
|
a({ kind: "error", message: e }), u(c.DEPLOY_FAILED, { method: t, reason: s, ...r, ...d }), g == null || g({ message: e, reason: s });
|
|
91
89
|
};
|
|
92
90
|
try {
|
|
93
|
-
const e =
|
|
91
|
+
const e = at(await n());
|
|
94
92
|
if (!e.length) {
|
|
95
93
|
o("No files found to deploy.", "No files found to deploy.", { file_count: 0 });
|
|
96
94
|
return;
|
|
@@ -100,11 +98,11 @@ function Pt({
|
|
|
100
98
|
file_count: e.length,
|
|
101
99
|
...r
|
|
102
100
|
});
|
|
103
|
-
const s = { source: t, fileCount: e.length, typeProps: r }, d =
|
|
101
|
+
const s = { source: t, fileCount: e.length, typeProps: r }, d = dt(e);
|
|
104
102
|
d.buildRequired ? await T(e, d, s) : await G(e, s);
|
|
105
103
|
} catch (e) {
|
|
106
104
|
const s = e instanceof Error ? e.message : String(e);
|
|
107
|
-
o(
|
|
105
|
+
o(rt(e), s);
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
async function T(n, t, { source: i, fileCount: r, typeProps: o }) {
|
|
@@ -120,7 +118,7 @@ function Pt({
|
|
|
120
118
|
let e = !1;
|
|
121
119
|
if (w) {
|
|
122
120
|
a({ kind: "zipping" });
|
|
123
|
-
const s = await
|
|
121
|
+
const s = await lt(n), d = await x(w, s);
|
|
124
122
|
if (d) {
|
|
125
123
|
a({ kind: "redirecting", target: "build" }), u(c.BUILD_DEPLOY_SUCCEEDED, {
|
|
126
124
|
method: i,
|
|
@@ -132,7 +130,7 @@ function Pt({
|
|
|
132
130
|
}), f == null || f(d), window.location.assign(C(d));
|
|
133
131
|
return;
|
|
134
132
|
}
|
|
135
|
-
e = await
|
|
133
|
+
e = await pt(s.file, s.buildSettings), e && u(c.PROJECT_STASHED, {
|
|
136
134
|
method: i,
|
|
137
135
|
reason: t.reason,
|
|
138
136
|
file_count: r,
|
|
@@ -151,7 +149,7 @@ function Pt({
|
|
|
151
149
|
onProgress: (i) => a(I(i))
|
|
152
150
|
});
|
|
153
151
|
} catch (i) {
|
|
154
|
-
if (i
|
|
152
|
+
if (O(i)) return null;
|
|
155
153
|
throw i;
|
|
156
154
|
}
|
|
157
155
|
}
|
|
@@ -179,7 +177,7 @@ function Pt({
|
|
|
179
177
|
n ? window.location.assign(H(t)) : window.location.assign(`${z(t)}#drop_token=${i}`);
|
|
180
178
|
}
|
|
181
179
|
async function X(n) {
|
|
182
|
-
const t = await
|
|
180
|
+
const t = await ht();
|
|
183
181
|
if (!t) {
|
|
184
182
|
await E();
|
|
185
183
|
return;
|
|
@@ -205,7 +203,7 @@ function Pt({
|
|
|
205
203
|
}
|
|
206
204
|
const F = S(!1);
|
|
207
205
|
nt(() => {
|
|
208
|
-
F.current || !$ || !w || !
|
|
206
|
+
F.current || !$ || !w || !gt() || (F.current = !0, X(w));
|
|
209
207
|
}, []);
|
|
210
208
|
function tt() {
|
|
211
209
|
_(null), a({ kind: "idle" });
|
|
@@ -9,19 +9,19 @@ import "preact";
|
|
|
9
9
|
import "../../chunks/hooks.module.DRcxknIz.js";
|
|
10
10
|
import { default as D } from "./SearchModal/components/SearchModal/SearchModal.js";
|
|
11
11
|
import { default as N } from "./DropZone/DropZone.js";
|
|
12
|
+
import { humanizeDropError as k } from "../../drop-core/errors.js";
|
|
13
|
+
import { DROPZONE_EVENTS as K } from "../../drop-core/analytics.js";
|
|
12
14
|
import "../../drop-core/readFiles.js";
|
|
13
|
-
import { getFileTypes as
|
|
15
|
+
import { getFileTypes as O } from "../../drop-core/fileTypes.js";
|
|
14
16
|
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
17
|
import "../../drop-core/zip.js";
|
|
19
|
-
import {
|
|
18
|
+
import { AuthenticatedDropClient as b } from "../../drop-core/authedDropClient.js";
|
|
19
|
+
import { AuthenticatedBuildClient as B } from "../../drop-core/buildClient.js";
|
|
20
20
|
export {
|
|
21
21
|
y as AskNetlify,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
B as AuthenticatedBuildClient,
|
|
23
|
+
b as AuthenticatedDropClient,
|
|
24
|
+
K as DROPZONE_EVENTS,
|
|
25
25
|
N as DropZone,
|
|
26
26
|
x as Icon,
|
|
27
27
|
m as KeyboardKey,
|
|
@@ -30,6 +30,6 @@ export {
|
|
|
30
30
|
s as SearchLink,
|
|
31
31
|
D as SearchModal,
|
|
32
32
|
S as SearchToggle,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
O as getFileTypes,
|
|
34
|
+
k as humanizeDropError
|
|
35
35
|
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
/** The analytics contract: canonical event names + property shapes, so no consumer hand-writes them. */
|
|
8
3
|
/** How the files reached the zone — carried on every drop-initiated event as `method`. */
|
|
9
4
|
export type DropMethod = 'drag' | 'browse';
|
|
10
5
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* renaming a value silently forks every funnel built on it — treat them as
|
|
14
|
-
* append-only.
|
|
6
|
+
* The wire names. Amplitude/Segment history keys off these exact strings —
|
|
7
|
+
* append-only, never rename.
|
|
15
8
|
*/
|
|
16
9
|
export declare const DROPZONE_EVENTS: {
|
|
17
10
|
/** Files arrived via drag — the picker path reports its files on outcome events instead. */
|
|
@@ -99,9 +92,5 @@ export interface DropZoneEventProperties {
|
|
|
99
92
|
dropzone_project_stashed: ProjectStashedProps;
|
|
100
93
|
dropzone_resumed: ResumedProps;
|
|
101
94
|
}
|
|
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
|
-
*/
|
|
95
|
+
/** Provider-agnostic sink — loose on purpose, since hosts pipe their own events through it too. */
|
|
107
96
|
export type TrackFn = (event: string, properties?: Record<string, unknown>) => void;
|
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
import { BuildSite } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* (Uploads are the exception — the proxy's Lambda caps request bodies at
|
|
7
|
-
* ~6MB — and each client handles its own, bearer-authorized.)
|
|
3
|
+
* Transport shared by both authenticated clients: JSON rides the consumer's
|
|
4
|
+
* access-control rewrite on the session cookie. Uploads are each client's own
|
|
5
|
+
* (bearer-direct — the proxy can't carry them).
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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.
|
|
8
|
+
* `POST {proxyBase}/sites`, attributed `created_via: 'drop'`. A logged-out
|
|
9
|
+
* visitor 401s here, before anything is created — the one point an anonymous
|
|
10
|
+
* fallback is still safe, hence NotAuthenticatedError.
|
|
28
11
|
*/
|
|
29
12
|
export declare function createSiteInAccount(proxyBase: string, accountSlug?: string): Promise<BuildSite>;
|
|
30
13
|
/** How a watched deploy ended. `errorMessage` is the API's own explanation, when it gave one. */
|
|
@@ -37,15 +20,9 @@ export type SettledDeploy = {
|
|
|
37
20
|
outcome: 'timed-out';
|
|
38
21
|
};
|
|
39
22
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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.
|
|
23
|
+
* Polls the deploy on the session cookie and reports the terminal outcome —
|
|
24
|
+
* callers map it onto their own error vocabulary. Non-ok reads are skipped,
|
|
25
|
+
* not fatal: a proxy hiccup shouldn't kill a progressing deploy.
|
|
49
26
|
*/
|
|
50
27
|
export declare function pollDeployUntilSettled(options: {
|
|
51
28
|
proxyBase: string;
|
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
import { NotAuthenticatedError as d, SiteCreateError as l } from "./errors.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const r = o ? `/${o}/sites` : "/sites", t = await fetch(`${s}${r}`, {
|
|
2
|
+
async function f(r, o) {
|
|
3
|
+
const s = o ? `/${o}/sites` : "/sites", e = await fetch(`${r}${s}`, {
|
|
5
4
|
method: "POST",
|
|
6
5
|
credentials: "include",
|
|
7
6
|
headers: { "Content-Type": "application/json" },
|
|
8
7
|
body: JSON.stringify({ created_via: "drop" })
|
|
9
8
|
});
|
|
10
|
-
if (
|
|
11
|
-
if (!
|
|
12
|
-
return
|
|
9
|
+
if (e.status === 401 || e.status === 403) throw new d();
|
|
10
|
+
if (!e.ok) throw new l(e.status);
|
|
11
|
+
return e.json();
|
|
13
12
|
}
|
|
14
|
-
const
|
|
15
|
-
async function
|
|
16
|
-
const { proxyBase: o, deployId:
|
|
13
|
+
const u = /* @__PURE__ */ new Set(["ready", "error", "rejected"]);
|
|
14
|
+
async function y(r) {
|
|
15
|
+
const { proxyBase: o, deployId: s, pollIntervalMs: e, timeoutMs: i } = r, c = i / e;
|
|
17
16
|
for (let n = 0; n < c; n++) {
|
|
18
|
-
const a = await fetch(`${o}/deploys/${
|
|
17
|
+
const a = await fetch(`${o}/deploys/${s}`, { credentials: "include" });
|
|
19
18
|
if (a.ok) {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
19
|
+
const t = await a.json();
|
|
20
|
+
if (t.state && u.has(t.state))
|
|
21
|
+
return t.state === "ready" ? { outcome: "ready" } : { outcome: "failed", errorMessage: t.error_message };
|
|
23
22
|
}
|
|
24
|
-
await new Promise((
|
|
23
|
+
await new Promise((t) => setTimeout(t, e));
|
|
25
24
|
}
|
|
26
25
|
return { outcome: "timed-out" };
|
|
27
26
|
}
|
|
28
27
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
f as DEFAULT_PROXY_BASE,
|
|
32
|
-
m as DEFAULT_TIMEOUT_MS,
|
|
33
|
-
A as createSiteInAccount,
|
|
34
|
-
E as pollDeployUntilSettled
|
|
28
|
+
f as createSiteInAccount,
|
|
29
|
+
y as pollDeployUntilSettled
|
|
35
30
|
};
|