@domainkit/react 0.1.0 → 0.3.0
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 +51 -5
- package/dist/index.d.mts +1012 -383
- package/dist/index.mjs +662 -606
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +25 -7
- package/package.json +10 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
-
import {
|
|
3
|
+
import { RegistryProvider, useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
4
|
+
import { Transport } from "domainkit";
|
|
5
|
+
import * as Data from "effect/Data";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Atom from "effect/unstable/reactivity/Atom";
|
|
8
|
+
import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
9
|
import { useRender } from "@base-ui/react/use-render";
|
|
5
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
|
12
|
+
//#region src/atom.ts
|
|
13
|
+
const Failure = Data.taggedEnum();
|
|
14
|
+
const failureFromError = (error) => Failure.Failure({
|
|
15
|
+
message: error.message,
|
|
16
|
+
operation: error.operation,
|
|
17
|
+
retry: error.retry
|
|
18
|
+
});
|
|
19
|
+
const failureFromDefect = (operation, message) => Failure.Failure({
|
|
20
|
+
message,
|
|
21
|
+
operation,
|
|
22
|
+
retry: "safe"
|
|
23
|
+
});
|
|
24
|
+
const recordsIdentity = (records) => JSON.stringify(records.map(({ id, name, priority, type, value }) => ({
|
|
25
|
+
id,
|
|
26
|
+
name,
|
|
27
|
+
priority,
|
|
28
|
+
type,
|
|
29
|
+
value
|
|
30
|
+
})));
|
|
31
|
+
//#endregion
|
|
6
32
|
//#region src/composition.tsx
|
|
7
33
|
function usePart(defaultTagName, componentProps, state, internalProps) {
|
|
8
34
|
const { className, render, style, ...externalProps } = componentProps;
|
|
@@ -81,6 +107,7 @@ const english = {
|
|
|
81
107
|
cleaningDns: "Removing records…",
|
|
82
108
|
connectProvider: () => "Connect",
|
|
83
109
|
connected: (provider) => `${provider} connected`,
|
|
110
|
+
providerAvailable: (provider) => `${provider} manages DNS for this domain`,
|
|
84
111
|
connecting: "Connecting…",
|
|
85
112
|
close: "Close",
|
|
86
113
|
detectingProvider: "Detecting DNS provider…",
|
|
@@ -128,7 +155,7 @@ function toStyle(theme = {}) {
|
|
|
128
155
|
//#endregion
|
|
129
156
|
//#region src/domain-kit.tsx
|
|
130
157
|
var domain_kit_exports = /* @__PURE__ */ __exportAll({
|
|
131
|
-
Root: () => Root$
|
|
158
|
+
Root: () => Root$6,
|
|
132
159
|
useDomainKit: () => useDomainKit
|
|
133
160
|
});
|
|
134
161
|
const Context = createContext(null);
|
|
@@ -154,7 +181,8 @@ const usePortalContainer = (container) => {
|
|
|
154
181
|
const getSnapshot = useCallback(() => resolvePortalContainer(container, ownerDocument), [container, ownerDocument]);
|
|
155
182
|
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
156
183
|
};
|
|
157
|
-
function Root$
|
|
184
|
+
function Root$6({ children, colorScheme = "inherit", icons, marks = {}, messages, navigate = navigateInBrowser, portalContainer = null, theme, transport, ...props }) {
|
|
185
|
+
const runtime = useMemo(() => Atom.runtime(transport), [transport]);
|
|
158
186
|
const themeStyle = toStyle(theme);
|
|
159
187
|
const resolvedPortalContainer = usePortalContainer(portalContainer);
|
|
160
188
|
const portalContainerRef = useMemo(() => ({ current: resolvedPortalContainer }), [resolvedPortalContainer]);
|
|
@@ -164,21 +192,21 @@ function Root$2({ children, colorScheme = "inherit", icons, marks = {}, messages
|
|
|
164
192
|
"data-domainkit-root": "",
|
|
165
193
|
style: themeStyle
|
|
166
194
|
});
|
|
167
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
195
|
+
return /* @__PURE__ */ jsx(RegistryProvider, { children: /* @__PURE__ */ jsx(Context.Provider, {
|
|
168
196
|
value: {
|
|
169
197
|
colorScheme,
|
|
170
198
|
marks,
|
|
171
199
|
messages: merge(messages),
|
|
172
200
|
navigate,
|
|
173
201
|
portalContainer: portalContainerRef,
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
runtime,
|
|
203
|
+
themeStyle
|
|
176
204
|
},
|
|
177
205
|
children: /* @__PURE__ */ jsx(IconsProvider, {
|
|
178
206
|
...icons === void 0 ? {} : { icons },
|
|
179
207
|
children: content
|
|
180
208
|
})
|
|
181
|
-
});
|
|
209
|
+
}) });
|
|
182
210
|
}
|
|
183
211
|
function useDomainKit() {
|
|
184
212
|
const value = useContext(Context);
|
|
@@ -186,229 +214,221 @@ function useDomainKit() {
|
|
|
186
214
|
return value;
|
|
187
215
|
}
|
|
188
216
|
//#endregion
|
|
189
|
-
//#region src/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
}, [identity]);
|
|
207
|
-
return {
|
|
208
|
-
begin: useCallback((state) => {
|
|
209
|
-
const request = ++revision.current;
|
|
210
|
-
setSnapshot({
|
|
211
|
-
identity: currentIdentity.current,
|
|
212
|
-
state
|
|
213
|
-
});
|
|
214
|
-
return request;
|
|
215
|
-
}, []),
|
|
216
|
-
commit: useCallback((request, state) => {
|
|
217
|
-
if (revision.current !== request) return false;
|
|
218
|
-
setSnapshot({
|
|
219
|
-
identity: currentIdentity.current,
|
|
220
|
-
state
|
|
221
|
-
});
|
|
222
|
-
return true;
|
|
223
|
-
}, []),
|
|
224
|
-
reset: useCallback((state) => {
|
|
225
|
-
revision.current += 1;
|
|
226
|
-
setSnapshot({
|
|
227
|
-
identity: currentIdentity.current,
|
|
228
|
-
state
|
|
229
|
-
});
|
|
230
|
-
}, []),
|
|
231
|
-
state: snapshot.identity === identity ? snapshot.state : initial
|
|
217
|
+
//#region src/operations.tsx
|
|
218
|
+
var operations_exports = /* @__PURE__ */ __exportAll({
|
|
219
|
+
Item: () => Item,
|
|
220
|
+
Kind: () => Kind,
|
|
221
|
+
List: () => List,
|
|
222
|
+
Name: () => Name,
|
|
223
|
+
Priority: () => Priority$1,
|
|
224
|
+
Reason: () => Reason,
|
|
225
|
+
Record: () => Record,
|
|
226
|
+
Root: () => Root$5,
|
|
227
|
+
Type: () => Type,
|
|
228
|
+
Value: () => Value$1
|
|
229
|
+
});
|
|
230
|
+
function leafPart$1(defaultTagName, part) {
|
|
231
|
+
return function Leaf(props) {
|
|
232
|
+
return usePart(defaultTagName, props, {}, { "data-domainkit-part": part });
|
|
232
233
|
};
|
|
233
234
|
}
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
const Kind = leafPart$1("span", "operation-kind");
|
|
236
|
+
const Type = leafPart$1("strong", "operation-type");
|
|
237
|
+
const Record = leafPart$1("span", "operation-record");
|
|
238
|
+
const Name = leafPart$1("span", "operation-name");
|
|
239
|
+
const Value$1 = leafPart$1("code", "operation-value");
|
|
240
|
+
const Priority$1 = leafPart$1("span", "operation-priority");
|
|
241
|
+
const Reason = leafPart$1("span", "operation-reason");
|
|
242
|
+
function Item({ operation, ...props }) {
|
|
243
|
+
return usePart("li", props, { operation: operation._tag }, {
|
|
244
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
245
|
+
/* @__PURE__ */ jsx(Kind, { children: operation._tag }),
|
|
246
|
+
" ",
|
|
247
|
+
/* @__PURE__ */ jsx(Type, { children: operation.record.type }),
|
|
248
|
+
" ",
|
|
249
|
+
/* @__PURE__ */ jsxs(Record, { children: [
|
|
250
|
+
/* @__PURE__ */ jsx(Name, { children: operation.record.name }),
|
|
251
|
+
/* @__PURE__ */ jsx(Value$1, { children: operation.record.value }),
|
|
252
|
+
operation.record.priority === void 0 ? null : /* @__PURE__ */ jsxs(Priority$1, { children: ["Priority ", operation.record.priority] }),
|
|
253
|
+
"reason" in operation ? /* @__PURE__ */ jsx(Reason, { children: operation.reason }) : null
|
|
254
|
+
] })
|
|
255
|
+
] }),
|
|
256
|
+
"data-domainkit-part": "operation-item",
|
|
257
|
+
"data-operation": operation._tag
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function Root$5({ count = 0, lifecycle, ...props }) {
|
|
261
|
+
return usePart("ul", props, {
|
|
262
|
+
count,
|
|
263
|
+
lifecycle
|
|
264
|
+
}, {
|
|
265
|
+
"data-domainkit-part": lifecycle === "provisioning" ? "plan-operations" : "cleanup-operations",
|
|
266
|
+
"data-lifecycle": lifecycle
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function List({ lifecycle, operations, ...props }) {
|
|
270
|
+
return /* @__PURE__ */ jsx(Root$5, {
|
|
271
|
+
count: operations.length,
|
|
272
|
+
lifecycle,
|
|
273
|
+
...props,
|
|
274
|
+
children: operations.map((operation) => /* @__PURE__ */ jsx(Item, { operation }, operation.id))
|
|
275
|
+
});
|
|
276
|
+
}
|
|
241
277
|
//#endregion
|
|
242
278
|
//#region src/cleanup.tsx
|
|
243
279
|
var cleanup_exports = /* @__PURE__ */ __exportAll({
|
|
280
|
+
Command: () => Command$3,
|
|
281
|
+
Dialog: () => Dialog$3,
|
|
244
282
|
Flow: () => Flow$3,
|
|
245
|
-
|
|
283
|
+
Outcome: () => Outcome$2,
|
|
284
|
+
Root: () => Root$4,
|
|
285
|
+
State: () => State$3,
|
|
286
|
+
useController: () => useController$3,
|
|
287
|
+
useModel: () => useModel$3
|
|
246
288
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
289
|
+
const State$3 = Data.taggedEnum();
|
|
290
|
+
const Command$3 = Data.taggedEnum();
|
|
291
|
+
function useModel$3(connection, receiptId) {
|
|
292
|
+
const { runtime } = useDomainKit();
|
|
293
|
+
return useMemo(() => {
|
|
294
|
+
const state = Atom.make(State$3.Idle());
|
|
295
|
+
return {
|
|
296
|
+
command: runtime.fn()((command, get) => {
|
|
297
|
+
if (command._tag === "Dismiss") {
|
|
298
|
+
get.set(state, State$3.Idle());
|
|
299
|
+
return Effect.void;
|
|
300
|
+
}
|
|
301
|
+
if (command._tag === "Plan") {
|
|
302
|
+
get.set(state, State$3.Planning());
|
|
303
|
+
return Effect.flatMap(Transport.Service, (transport) => transport.cleanup.plan({
|
|
304
|
+
connectionId: connection.connectionId,
|
|
305
|
+
domain: connection.domain,
|
|
306
|
+
receiptId
|
|
307
|
+
})).pipe(Effect.tap((plan) => Effect.sync(() => get.set(state, State$3.Review({ plan })))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
|
|
308
|
+
}
|
|
309
|
+
const current = get(state);
|
|
310
|
+
if (current._tag !== "Review" || current.plan.operations.some((operation) => operation._tag === "Blocked")) return Effect.void;
|
|
311
|
+
const plan = current.plan;
|
|
312
|
+
get.set(state, State$3.Cleaning({ plan }));
|
|
313
|
+
return Effect.flatMap(Transport.Service, (transport) => transport.cleanup.apply({
|
|
314
|
+
connectionId: connection.connectionId,
|
|
315
|
+
domain: connection.domain,
|
|
316
|
+
planDigest: plan.digest,
|
|
317
|
+
receiptId
|
|
318
|
+
})).pipe(Effect.tap((result) => Effect.sync(() => get.set(state, result._tag === "Cleaned" ? State$3.Cleaned({ result }) : result._tag === "Partial" ? State$3.Partial({ result }) : result))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
|
|
319
|
+
}),
|
|
320
|
+
state
|
|
321
|
+
};
|
|
266
322
|
}, [
|
|
267
323
|
connection.connectionId,
|
|
268
324
|
connection.domain,
|
|
269
325
|
receiptId,
|
|
270
|
-
|
|
271
|
-
transport
|
|
326
|
+
runtime
|
|
272
327
|
]);
|
|
328
|
+
}
|
|
329
|
+
function useController$3(connection, receiptId) {
|
|
330
|
+
const model = useModel$3(connection, receiptId);
|
|
331
|
+
const state = useAtomValue(model.state);
|
|
332
|
+
const execute = useAtomSet(model.command);
|
|
273
333
|
return {
|
|
274
|
-
apply:
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (reviewedPlan.operations.some((operation) => operation._tag === "Blocked")) return;
|
|
278
|
-
const request = requestState.begin({
|
|
279
|
-
_tag: "Cleaning",
|
|
280
|
-
plan: reviewedPlan
|
|
281
|
-
});
|
|
282
|
-
try {
|
|
283
|
-
const result = await transport.cleanup.apply({
|
|
284
|
-
connectionId: connection.connectionId,
|
|
285
|
-
domain: connection.domain,
|
|
286
|
-
planDigest: reviewedPlan.digest,
|
|
287
|
-
receiptId
|
|
288
|
-
});
|
|
289
|
-
requestState.commit(request, result._tag === "Cleaned" ? {
|
|
290
|
-
_tag: "Cleaned",
|
|
291
|
-
result
|
|
292
|
-
} : result._tag === "Partial" ? {
|
|
293
|
-
_tag: "Partial",
|
|
294
|
-
result
|
|
295
|
-
} : result);
|
|
296
|
-
} catch (cause) {
|
|
297
|
-
requestState.commit(request, toFailure(cause));
|
|
298
|
-
}
|
|
299
|
-
}, [
|
|
300
|
-
connection.connectionId,
|
|
301
|
-
connection.domain,
|
|
302
|
-
receiptId,
|
|
303
|
-
requestState,
|
|
304
|
-
state,
|
|
305
|
-
transport
|
|
306
|
-
]),
|
|
307
|
-
dismiss: () => requestState.reset({ _tag: "Idle" }),
|
|
308
|
-
plan,
|
|
334
|
+
apply: () => execute(Command$3.Apply()),
|
|
335
|
+
dismiss: () => execute(Command$3.Dismiss()),
|
|
336
|
+
plan: () => execute(Command$3.Plan()),
|
|
309
337
|
state
|
|
310
338
|
};
|
|
311
339
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
|
|
340
|
+
function Root$4({ status, ...props }) {
|
|
341
|
+
return usePart("div", props, { status }, {
|
|
342
|
+
"data-domainkit-part": "cleanup-flow",
|
|
343
|
+
"data-state": status
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function Outcome$2({ state }) {
|
|
347
|
+
const { messages } = useDomainKit();
|
|
348
|
+
if (state._tag === "Cleaned") return /* @__PURE__ */ jsx("p", {
|
|
349
|
+
"data-domainkit-part": "flow-outcome",
|
|
350
|
+
"data-tone": "success",
|
|
351
|
+
children: messages.cleanupComplete
|
|
352
|
+
});
|
|
353
|
+
if (state._tag === "Partial" || state._tag === "Failure" || state._tag === "Stale") return /* @__PURE__ */ jsx("p", {
|
|
354
|
+
"data-domainkit-part": "flow-outcome",
|
|
355
|
+
"data-tone": "danger",
|
|
356
|
+
role: "alert",
|
|
357
|
+
children: state._tag === "Partial" ? messages.cleanupPartial : state.message
|
|
358
|
+
});
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
function Dialog$3({ controller }) {
|
|
319
362
|
const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();
|
|
320
363
|
const state = controller.state;
|
|
321
364
|
const plan = state._tag === "Review" || state._tag === "Cleaning" ? state.plan : void 0;
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
})
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}, operation.id))
|
|
390
|
-
})
|
|
391
|
-
}),
|
|
392
|
-
/* @__PURE__ */ jsxs("div", {
|
|
393
|
-
"data-domainkit-part": "dialog-footer",
|
|
394
|
-
children: [/* @__PURE__ */ jsx(Dialog.Close, {
|
|
395
|
-
"data-domainkit-part": "dialog-cancel",
|
|
396
|
-
children: messages.cancel
|
|
397
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
398
|
-
"data-domainkit-part": "cleanup-apply",
|
|
399
|
-
disabled: state._tag === "Cleaning" || plan.operations.some((operation) => operation._tag === "Blocked"),
|
|
400
|
-
onClick: () => void controller.apply(),
|
|
401
|
-
type: "button",
|
|
402
|
-
children: state._tag === "Cleaning" ? messages.cleaningDns : messages.applyCleanup
|
|
403
|
-
})]
|
|
404
|
-
})
|
|
405
|
-
]
|
|
406
|
-
})]
|
|
407
|
-
})]
|
|
408
|
-
})
|
|
409
|
-
] }),
|
|
410
|
-
"data-domainkit-part": "cleanup-flow",
|
|
411
|
-
"data-state": state._tag
|
|
365
|
+
return /* @__PURE__ */ jsxs(Dialog.Root, {
|
|
366
|
+
onOpenChange: (open) => {
|
|
367
|
+
if (!open) controller.dismiss();
|
|
368
|
+
},
|
|
369
|
+
open: plan !== void 0,
|
|
370
|
+
children: [/* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
371
|
+
"data-domainkit-part": "cleanup-trigger",
|
|
372
|
+
disabled: state._tag === "Planning" || state._tag === "Cleaning",
|
|
373
|
+
onClick: () => controller.plan(),
|
|
374
|
+
children: state._tag === "Planning" ? messages.planningCleanup : messages.reviewCleanup
|
|
375
|
+
}), plan === void 0 ? null : /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
376
|
+
container: portalContainer ?? void 0,
|
|
377
|
+
children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { "data-domainkit-part": "dialog-backdrop" }), /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
378
|
+
"data-color-scheme": colorScheme,
|
|
379
|
+
"data-domainkit-part": "cleanup-dialog",
|
|
380
|
+
"data-domainkit-root": "",
|
|
381
|
+
style: themeStyle,
|
|
382
|
+
children: [
|
|
383
|
+
/* @__PURE__ */ jsxs("div", {
|
|
384
|
+
"data-domainkit-part": "dialog-header",
|
|
385
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
386
|
+
"data-domainkit-part": "dialog-heading",
|
|
387
|
+
children: [/* @__PURE__ */ jsx(Dialog.Title, {
|
|
388
|
+
"data-domainkit-part": "dialog-title",
|
|
389
|
+
children: messages.reviewCleanup
|
|
390
|
+
}), /* @__PURE__ */ jsx(Dialog.Description, {
|
|
391
|
+
"data-domainkit-part": "dialog-description",
|
|
392
|
+
children: messages.cleanupConsent
|
|
393
|
+
})]
|
|
394
|
+
}), /* @__PURE__ */ jsx(Dialog.Close, {
|
|
395
|
+
"aria-label": messages.close,
|
|
396
|
+
"data-domainkit-part": "dialog-close",
|
|
397
|
+
children: "×"
|
|
398
|
+
})]
|
|
399
|
+
}),
|
|
400
|
+
/* @__PURE__ */ jsx("div", {
|
|
401
|
+
"data-domainkit-part": "dialog-body",
|
|
402
|
+
children: /* @__PURE__ */ jsx(List, {
|
|
403
|
+
lifecycle: "cleanup",
|
|
404
|
+
operations: plan.operations
|
|
405
|
+
})
|
|
406
|
+
}),
|
|
407
|
+
/* @__PURE__ */ jsxs("div", {
|
|
408
|
+
"data-domainkit-part": "dialog-footer",
|
|
409
|
+
children: [/* @__PURE__ */ jsx(Dialog.Close, {
|
|
410
|
+
"data-domainkit-part": "dialog-cancel",
|
|
411
|
+
children: messages.cancel
|
|
412
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
413
|
+
"data-domainkit-part": "cleanup-apply",
|
|
414
|
+
disabled: state._tag === "Cleaning" || plan.operations.some((operation) => operation._tag === "Blocked"),
|
|
415
|
+
onClick: () => controller.apply(),
|
|
416
|
+
type: "button",
|
|
417
|
+
children: state._tag === "Cleaning" ? messages.cleaningDns : messages.applyCleanup
|
|
418
|
+
})]
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})]
|
|
422
|
+
})]
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function Flow$3({ connection, receiptId, ...props }) {
|
|
426
|
+
const controller = useController$3(connection, receiptId);
|
|
427
|
+
const state = controller.state;
|
|
428
|
+
return /* @__PURE__ */ jsxs(Root$4, {
|
|
429
|
+
status: state._tag,
|
|
430
|
+
...props,
|
|
431
|
+
children: [/* @__PURE__ */ jsx(Outcome$2, { state }), /* @__PURE__ */ jsx(Dialog$3, { controller })]
|
|
412
432
|
});
|
|
413
433
|
}
|
|
414
434
|
//#endregion
|
|
@@ -511,139 +531,128 @@ function Mark({ provider, ...props }) {
|
|
|
511
531
|
//#endregion
|
|
512
532
|
//#region src/connection.tsx
|
|
513
533
|
var connection_exports = /* @__PURE__ */ __exportAll({
|
|
514
|
-
|
|
534
|
+
Command: () => Command$2,
|
|
535
|
+
ConnectTrigger: () => ConnectTrigger,
|
|
536
|
+
Dialog: () => Dialog$2,
|
|
515
537
|
DisconnectAction: () => DisconnectAction,
|
|
538
|
+
DisconnectState: () => DisconnectState,
|
|
516
539
|
Flow: () => Flow$2,
|
|
517
540
|
OAuthAction: () => OAuthAction,
|
|
518
|
-
RetryAction: () => RetryAction,
|
|
541
|
+
RetryAction: () => RetryAction$1,
|
|
519
542
|
ReuseAction: () => ReuseAction,
|
|
520
|
-
Root: () => Root$
|
|
543
|
+
Root: () => Root$3,
|
|
544
|
+
State: () => State$2,
|
|
521
545
|
Status: () => Status$2,
|
|
522
546
|
TokenAction: () => TokenAction,
|
|
523
547
|
Trigger: () => Trigger,
|
|
524
548
|
useController: () => useController$2,
|
|
525
|
-
useDisconnect: () => useDisconnect
|
|
526
|
-
|
|
527
|
-
const failure$1 = (cause) => ({
|
|
528
|
-
_tag: "Failure",
|
|
529
|
-
message: cause instanceof Error ? cause.message : "The connection request failed",
|
|
530
|
-
retry: "safe"
|
|
549
|
+
useDisconnect: () => useDisconnect,
|
|
550
|
+
useModel: () => useModel$2
|
|
531
551
|
});
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
if (
|
|
542
|
-
|
|
543
|
-
|
|
552
|
+
const State$2 = Data.taggedEnum();
|
|
553
|
+
const Command$2 = Data.taggedEnum();
|
|
554
|
+
function useModel$2(domain) {
|
|
555
|
+
const { navigate, runtime } = useDomainKit();
|
|
556
|
+
return useMemo(() => {
|
|
557
|
+
const actionState = Atom.make(void 0);
|
|
558
|
+
const inspect = runtime.atom(Effect.flatMap(Transport.Service, (transport) => transport.connection.inspect({ domain })));
|
|
559
|
+
const state = Atom.make((get) => {
|
|
560
|
+
const action = get(actionState);
|
|
561
|
+
if (action !== void 0) return action;
|
|
562
|
+
const inspection = get(inspect);
|
|
563
|
+
return AsyncResult.matchWithError(inspection, {
|
|
564
|
+
onDefect: () => failureFromDefect("connection.inspect", "Provider detection failed"),
|
|
565
|
+
onError: failureFromError,
|
|
566
|
+
onInitial: () => State$2.Loading(),
|
|
567
|
+
onSuccess: ({ value }) => value
|
|
568
|
+
});
|
|
544
569
|
});
|
|
545
|
-
return
|
|
546
|
-
|
|
570
|
+
return {
|
|
571
|
+
command: runtime.fn()((input, get) => {
|
|
572
|
+
if (input._tag === "Retry") {
|
|
573
|
+
get.set(actionState, void 0);
|
|
574
|
+
get.refresh(inspect);
|
|
575
|
+
return Effect.void;
|
|
576
|
+
}
|
|
577
|
+
const snapshot = get(state);
|
|
578
|
+
if (snapshot._tag !== "Disconnected") return Effect.void;
|
|
579
|
+
const reusableConnection = snapshot.reusableConnection;
|
|
580
|
+
if (input._tag === "Reuse" && reusableConnection === void 0) return Effect.void;
|
|
581
|
+
get.set(actionState, State$2.Submitting({ snapshot }));
|
|
582
|
+
const complete = (request) => request.pipe(Effect.tap((result) => Effect.sync(() => {
|
|
583
|
+
if (result._tag === "Redirect") {
|
|
584
|
+
get.set(actionState, State$2.Redirecting({ snapshot }));
|
|
585
|
+
navigate(result.authorizationUrl);
|
|
586
|
+
} else get.set(actionState, result);
|
|
587
|
+
})), Effect.catch((error) => Effect.sync(() => get.set(actionState, failureFromError(error)))), Effect.asVoid);
|
|
588
|
+
if (input._tag === "Connect") return complete(Effect.flatMap(Transport.Service, (transport) => transport.connection.connect({
|
|
589
|
+
domain,
|
|
590
|
+
method: input.method,
|
|
591
|
+
providerId: snapshot.provider.id
|
|
592
|
+
})));
|
|
593
|
+
if (reusableConnection === void 0) return Effect.void;
|
|
594
|
+
return complete(Effect.flatMap(Transport.Service, (transport) => transport.connection.reuse({
|
|
595
|
+
connectionId: reusableConnection.connectionId,
|
|
596
|
+
domain
|
|
597
|
+
})));
|
|
598
|
+
}),
|
|
599
|
+
state
|
|
547
600
|
};
|
|
548
601
|
}, [
|
|
549
|
-
attempt,
|
|
550
602
|
domain,
|
|
551
|
-
|
|
603
|
+
navigate,
|
|
604
|
+
runtime
|
|
552
605
|
]);
|
|
606
|
+
}
|
|
607
|
+
function useController$2(domain) {
|
|
608
|
+
const model = useModel$2(domain);
|
|
609
|
+
const state = useAtomValue(model.state);
|
|
610
|
+
const execute = useAtomSet(model.command);
|
|
553
611
|
return {
|
|
554
|
-
connect:
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const snapshot = state;
|
|
558
|
-
setState({
|
|
559
|
-
_tag: "Submitting",
|
|
560
|
-
snapshot
|
|
561
|
-
});
|
|
562
|
-
try {
|
|
563
|
-
const result = await transport.connection.connect({
|
|
564
|
-
domain,
|
|
565
|
-
method,
|
|
566
|
-
...parameters === void 0 ? {} : { parameters },
|
|
567
|
-
providerId: snapshot.provider.id,
|
|
568
|
-
...token === void 0 ? {} : { token }
|
|
569
|
-
});
|
|
570
|
-
if (activeRequest.current !== request) return;
|
|
571
|
-
if (result._tag === "Redirect") {
|
|
572
|
-
setState({
|
|
573
|
-
_tag: "Redirecting",
|
|
574
|
-
snapshot
|
|
575
|
-
});
|
|
576
|
-
navigate(result.authorizationUrl);
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
setState(result);
|
|
580
|
-
} catch (cause) {
|
|
581
|
-
if (activeRequest.current === request) setState(failure$1(cause));
|
|
582
|
-
}
|
|
583
|
-
}, [
|
|
584
|
-
domain,
|
|
585
|
-
navigate,
|
|
586
|
-
state,
|
|
587
|
-
transport
|
|
588
|
-
]),
|
|
589
|
-
retry: () => setAttempt((current) => current + 1),
|
|
590
|
-
reuse: useCallback(async () => {
|
|
591
|
-
if (state._tag !== "Disconnected" || state.reusableConnection === void 0) return;
|
|
592
|
-
const request = ++activeRequest.current;
|
|
593
|
-
const snapshot = state;
|
|
594
|
-
const reusableConnection = state.reusableConnection;
|
|
595
|
-
setState({
|
|
596
|
-
_tag: "Submitting",
|
|
597
|
-
snapshot
|
|
598
|
-
});
|
|
599
|
-
try {
|
|
600
|
-
const result = await transport.connection.reuse({
|
|
601
|
-
connectionId: reusableConnection.connectionId,
|
|
602
|
-
domain
|
|
603
|
-
});
|
|
604
|
-
if (activeRequest.current === request) setState(result);
|
|
605
|
-
} catch (cause) {
|
|
606
|
-
if (activeRequest.current === request) setState(failure$1(cause));
|
|
607
|
-
}
|
|
608
|
-
}, [
|
|
609
|
-
domain,
|
|
610
|
-
state,
|
|
611
|
-
transport
|
|
612
|
-
]),
|
|
612
|
+
connect: (method) => execute(Command$2.Connect({ method })),
|
|
613
|
+
retry: () => execute(Command$2.Retry()),
|
|
614
|
+
reuse: () => execute(Command$2.Reuse()),
|
|
613
615
|
state
|
|
614
616
|
};
|
|
615
617
|
}
|
|
616
|
-
function Root$
|
|
618
|
+
function Root$3({ children, status = "Loading", ...props }) {
|
|
617
619
|
return usePart("div", props, { status }, {
|
|
618
620
|
children,
|
|
619
621
|
"data-domainkit-part": "connection-root"
|
|
620
622
|
});
|
|
621
623
|
}
|
|
622
|
-
function Status$2({ state, ...props }) {
|
|
624
|
+
function Status$2({ children, state, ...props }) {
|
|
623
625
|
const { messages } = useDomainKit();
|
|
624
|
-
const text = state._tag === "Loading" ? messages.detectingProvider : state._tag === "Connected" ? messages.connected(state.provider.name) : state._tag === "Unsupported" ? messages.automaticUnavailable : state._tag === "Failure" ? state.message : state._tag === "Redirecting" ? messages.openingAuthorization : state._tag === "Submitting" ? messages.connecting :
|
|
626
|
+
const text = state._tag === "Loading" ? messages.detectingProvider : state._tag === "Connected" ? messages.connected(state.provider.name) : state._tag === "Unsupported" ? messages.automaticUnavailable : state._tag === "Failure" ? state.message : state._tag === "Redirecting" ? messages.openingAuthorization : state._tag === "Submitting" ? messages.connecting : messages.providerAvailable(state.provider.name);
|
|
625
627
|
return usePart("div", props, { status: state._tag }, {
|
|
626
|
-
children: text,
|
|
628
|
+
children: children ?? text,
|
|
627
629
|
"data-domainkit-part": "connection-status",
|
|
628
630
|
"data-state": state._tag
|
|
629
631
|
});
|
|
630
632
|
}
|
|
631
|
-
function Trigger({
|
|
632
|
-
|
|
633
|
-
return /* @__PURE__ */ jsxs(Dialog.Trigger, {
|
|
633
|
+
function Trigger({ children, ...props }) {
|
|
634
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
634
635
|
"data-domainkit-part": "connection-trigger",
|
|
635
636
|
...props,
|
|
636
|
-
children
|
|
637
|
+
children
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
function ConnectTrigger({ children, provider, ...props }) {
|
|
641
|
+
const { messages } = useDomainKit();
|
|
642
|
+
return /* @__PURE__ */ jsx(Trigger, {
|
|
643
|
+
...props,
|
|
644
|
+
"data-domainkit-recipe": "connect",
|
|
645
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Mark, {
|
|
637
646
|
"aria-hidden": "true",
|
|
638
647
|
provider
|
|
639
|
-
}), messages.connectProvider(provider.name)]
|
|
648
|
+
}), messages.connectProvider(provider.name)] })
|
|
640
649
|
});
|
|
641
650
|
}
|
|
642
651
|
function OAuthAction({ controller, label, ...props }) {
|
|
643
652
|
return usePart("button", props, { authentication: "oauth" }, {
|
|
644
653
|
children: label,
|
|
645
654
|
"data-domainkit-part": "oauth-connect",
|
|
646
|
-
onClick: () =>
|
|
655
|
+
onClick: () => controller.connect(Transport.Method.OAuth()),
|
|
647
656
|
type: "button"
|
|
648
657
|
});
|
|
649
658
|
}
|
|
@@ -663,7 +672,10 @@ function TokenAction({ controller, method, ...props }) {
|
|
|
663
672
|
event.preventDefault();
|
|
664
673
|
if (token.length > 0) {
|
|
665
674
|
const populated = Object.fromEntries(Object.entries(parameters).filter(([, value]) => value.length > 0));
|
|
666
|
-
controller.connect(
|
|
675
|
+
controller.connect(Transport.Method.Token({
|
|
676
|
+
token,
|
|
677
|
+
...Object.keys(populated).length === 0 ? {} : { parameters: populated }
|
|
678
|
+
}));
|
|
667
679
|
}
|
|
668
680
|
};
|
|
669
681
|
const missingRequiredParameter = method.parameters?.some((parameter) => parameter.required === true && !parameters[parameter.key]);
|
|
@@ -705,7 +717,7 @@ function TokenAction({ controller, method, ...props }) {
|
|
|
705
717
|
onSubmit: submit
|
|
706
718
|
});
|
|
707
719
|
}
|
|
708
|
-
function Dialog$
|
|
720
|
+
function Dialog$2({ controller, snapshot }) {
|
|
709
721
|
const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();
|
|
710
722
|
return /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
711
723
|
container: portalContainer,
|
|
@@ -768,23 +780,23 @@ function Flow$2({ domain, ...props }) {
|
|
|
768
780
|
const controller = useController$2(domain);
|
|
769
781
|
const state = controller.state;
|
|
770
782
|
const snapshot = state._tag === "Disconnected" ? state : state._tag === "Submitting" || state._tag === "Redirecting" ? state.snapshot : void 0;
|
|
771
|
-
return /* @__PURE__ */ jsxs(Root$
|
|
783
|
+
return /* @__PURE__ */ jsxs(Root$3, {
|
|
772
784
|
...props,
|
|
773
785
|
status: state._tag,
|
|
774
786
|
children: [
|
|
775
787
|
/* @__PURE__ */ jsx(Status$2, { state }),
|
|
776
|
-
state._tag === "Failure" && state.retry !== "never" ? /* @__PURE__ */ jsx(RetryAction, {
|
|
788
|
+
state._tag === "Failure" && state.retry !== "never" ? /* @__PURE__ */ jsx(RetryAction$1, {
|
|
777
789
|
controller,
|
|
778
790
|
kind: state.retry === "after-user-action" ? "after-user-action" : "retry"
|
|
779
791
|
}) : null,
|
|
780
|
-
snapshot === void 0 ? null : /* @__PURE__ */ jsxs(Dialog.Root, { children: [/* @__PURE__ */ jsx(
|
|
792
|
+
snapshot === void 0 ? null : /* @__PURE__ */ jsxs(Dialog.Root, { children: [/* @__PURE__ */ jsx(ConnectTrigger, { provider: snapshot.provider }), /* @__PURE__ */ jsx(Dialog$2, {
|
|
781
793
|
controller,
|
|
782
794
|
snapshot
|
|
783
795
|
})] })
|
|
784
796
|
]
|
|
785
797
|
});
|
|
786
798
|
}
|
|
787
|
-
function RetryAction({ controller, kind = "retry", ...props }) {
|
|
799
|
+
function RetryAction$1({ controller, kind = "retry", ...props }) {
|
|
788
800
|
const { messages } = useDomainKit();
|
|
789
801
|
return usePart("button", props, { status: "Failure" }, {
|
|
790
802
|
children: kind === "after-user-action" ? messages.checkAgain : messages.retry,
|
|
@@ -793,28 +805,32 @@ function RetryAction({ controller, kind = "retry", ...props }) {
|
|
|
793
805
|
type: "button"
|
|
794
806
|
});
|
|
795
807
|
}
|
|
808
|
+
const DisconnectState = Data.taggedEnum();
|
|
796
809
|
function useDisconnect(connection) {
|
|
797
|
-
const {
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
810
|
+
const { runtime } = useDomainKit();
|
|
811
|
+
const controller = useMemo(() => {
|
|
812
|
+
const state = Atom.make(DisconnectState.Idle());
|
|
813
|
+
return {
|
|
814
|
+
disconnect: runtime.fn()((_, get) => {
|
|
815
|
+
get.set(state, DisconnectState.Disconnecting());
|
|
816
|
+
return Effect.flatMap(Transport.Service, (transport) => transport.connection.removeDomain({
|
|
804
817
|
connectionId: connection.connectionId,
|
|
805
818
|
domain: connection.domain,
|
|
806
819
|
preserveDns: true
|
|
807
|
-
}));
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
820
|
+
})).pipe(Effect.tap((result) => Effect.sync(() => get.set(state, result))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
|
|
821
|
+
}),
|
|
822
|
+
state
|
|
823
|
+
};
|
|
824
|
+
}, [
|
|
825
|
+
connection.connectionId,
|
|
826
|
+
connection.domain,
|
|
827
|
+
runtime
|
|
828
|
+
]);
|
|
829
|
+
const state = useAtomValue(controller.state);
|
|
830
|
+
const disconnect = useAtomSet(controller.disconnect);
|
|
831
|
+
return {
|
|
832
|
+
disconnect: () => disconnect(),
|
|
833
|
+
state
|
|
818
834
|
};
|
|
819
835
|
}
|
|
820
836
|
function DisconnectAction({ connection, ...props }) {
|
|
@@ -860,13 +876,16 @@ var records_exports = /* @__PURE__ */ __exportAll({
|
|
|
860
876
|
Head: () => Head,
|
|
861
877
|
Header: () => Header,
|
|
862
878
|
Priority: () => Priority,
|
|
863
|
-
Root: () => Root,
|
|
879
|
+
Root: () => Root$2,
|
|
864
880
|
Row: () => Row,
|
|
865
881
|
Status: () => Status$1,
|
|
866
882
|
Table: () => Table,
|
|
867
883
|
Value: () => Value,
|
|
868
884
|
ZoneFile: () => ZoneFile,
|
|
869
|
-
|
|
885
|
+
copyText: () => copyText,
|
|
886
|
+
downloadZoneFile: () => downloadZoneFile,
|
|
887
|
+
toZoneFile: () => toZoneFile,
|
|
888
|
+
useCopy: () => useCopy
|
|
870
889
|
});
|
|
871
890
|
const copyText = (value) => {
|
|
872
891
|
if (typeof navigator === "undefined" || navigator.clipboard === void 0) return Promise.resolve(false);
|
|
@@ -932,23 +951,31 @@ function leafPart(defaultTagName, part) {
|
|
|
932
951
|
return usePart(defaultTagName, props, {}, { "data-domainkit-part": part });
|
|
933
952
|
};
|
|
934
953
|
}
|
|
935
|
-
function
|
|
936
|
-
const icons = useIcons();
|
|
954
|
+
function useCopy(value, resetAfter = 2e3) {
|
|
937
955
|
const [copied, setCopied] = useState(false);
|
|
938
956
|
const reset = useRef(void 0);
|
|
939
957
|
useEffect(() => () => clearTimeout(reset.current), []);
|
|
958
|
+
return {
|
|
959
|
+
copied,
|
|
960
|
+
copy: () => {
|
|
961
|
+
copyText(value).then((ok) => {
|
|
962
|
+
if (!ok) return;
|
|
963
|
+
setCopied(true);
|
|
964
|
+
clearTimeout(reset.current);
|
|
965
|
+
reset.current = setTimeout(() => setCopied(false), resetAfter);
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
function CopyValue({ copiedIcon, copiedLabel = "Copied", copyIcon, copyLabel = "Copy", value, ...props }) {
|
|
971
|
+
const icons = useIcons();
|
|
972
|
+
const controller = useCopy(value);
|
|
973
|
+
const copied = controller.copied;
|
|
940
974
|
return usePart("span", props, { copied }, {
|
|
941
975
|
children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("code", { children: value }), /* @__PURE__ */ jsxs("button", {
|
|
942
976
|
"aria-label": `${copied ? copiedLabel : copyLabel} ${value}`,
|
|
943
977
|
"data-domainkit-part": "copy-action",
|
|
944
|
-
onClick:
|
|
945
|
-
copyText(value).then((ok) => {
|
|
946
|
-
if (!ok) return;
|
|
947
|
-
setCopied(true);
|
|
948
|
-
clearTimeout(reset.current);
|
|
949
|
-
reset.current = setTimeout(() => setCopied(false), 2e3);
|
|
950
|
-
});
|
|
951
|
-
},
|
|
978
|
+
onClick: controller.copy,
|
|
952
979
|
type: "button",
|
|
953
980
|
children: [/* @__PURE__ */ jsx("span", {
|
|
954
981
|
"aria-hidden": "true",
|
|
@@ -970,22 +997,13 @@ function CopyValue({ copiedIcon, copiedLabel = "Copied", copyIcon, copyLabel = "
|
|
|
970
997
|
}
|
|
971
998
|
function ZoneFile({ copiedIcon, copiedLabel = "Copied", copyIcon, copyLabel = "Copy zone", domain, downloadIcon, downloadLabel = "Download", records, ...props }) {
|
|
972
999
|
const icons = useIcons();
|
|
973
|
-
const
|
|
974
|
-
const
|
|
975
|
-
const zone = toZoneFile(records);
|
|
976
|
-
useEffect(() => () => clearTimeout(reset.current), []);
|
|
1000
|
+
const controller = useCopy(toZoneFile(records));
|
|
1001
|
+
const copied = controller.copied;
|
|
977
1002
|
return usePart("div", props, { count: records.length }, {
|
|
978
1003
|
children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
|
|
979
1004
|
"aria-label": copied ? copiedLabel : copyLabel,
|
|
980
1005
|
"data-domainkit-part": "zone-copy",
|
|
981
|
-
onClick:
|
|
982
|
-
copyText(zone).then((ok) => {
|
|
983
|
-
if (!ok) return;
|
|
984
|
-
setCopied(true);
|
|
985
|
-
clearTimeout(reset.current);
|
|
986
|
-
reset.current = setTimeout(() => setCopied(false), 2e3);
|
|
987
|
-
});
|
|
988
|
-
},
|
|
1006
|
+
onClick: controller.copy,
|
|
989
1007
|
type: "button",
|
|
990
1008
|
children: [/* @__PURE__ */ jsx("span", {
|
|
991
1009
|
"aria-hidden": "true",
|
|
@@ -994,7 +1012,7 @@ function ZoneFile({ copiedIcon, copiedLabel = "Copied", copyIcon, copyLabel = "C
|
|
|
994
1012
|
}), copied ? copiedLabel : copyLabel]
|
|
995
1013
|
}), /* @__PURE__ */ jsxs("button", {
|
|
996
1014
|
"data-domainkit-part": "zone-download",
|
|
997
|
-
onClick: () =>
|
|
1015
|
+
onClick: () => downloadZoneFile(domain, records),
|
|
998
1016
|
type: "button",
|
|
999
1017
|
children: [/* @__PURE__ */ jsx("span", {
|
|
1000
1018
|
"aria-hidden": "true",
|
|
@@ -1029,7 +1047,7 @@ const Value = leafPart("span", "record-value");
|
|
|
1029
1047
|
const CardHeader = leafPart("div", "record-card-head");
|
|
1030
1048
|
const CardTitle = leafPart("strong", "record-card-title");
|
|
1031
1049
|
const CardContent = leafPart("dl", "record-card-content");
|
|
1032
|
-
function Root({ count = 0, ...props }) {
|
|
1050
|
+
function Root$2({ count = 0, ...props }) {
|
|
1033
1051
|
return /* @__PURE__ */ jsx("div", {
|
|
1034
1052
|
"data-domainkit-part": "records-panel",
|
|
1035
1053
|
children: usePart("table", props, { count }, { "data-domainkit-part": "records-table" })
|
|
@@ -1052,7 +1070,7 @@ function Card({ copiedIcon, copyIcon, evidence, record, ...props }) {
|
|
|
1052
1070
|
}
|
|
1053
1071
|
function Table({ copiedIcon, copyIcon, evidence, records, ...props }) {
|
|
1054
1072
|
const status = evidence !== void 0;
|
|
1055
|
-
return /* @__PURE__ */ jsxs(Root, {
|
|
1073
|
+
return /* @__PURE__ */ jsxs(Root$2, {
|
|
1056
1074
|
count: records.length,
|
|
1057
1075
|
...props,
|
|
1058
1076
|
children: [/* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsxs(Row, { children: [
|
|
@@ -1093,237 +1111,251 @@ function Table({ copiedIcon, copyIcon, evidence, records, ...props }) {
|
|
|
1093
1111
|
});
|
|
1094
1112
|
}
|
|
1095
1113
|
const toZoneFile = (records) => `${records.map((record) => `${absoluteDomainName(record.name)} IN ${record.type} ${record.priority === void 0 ? "" : `${record.priority} `}${zoneValue(record)}`).join("\n")}\n`;
|
|
1114
|
+
const downloadZoneFile = (domain, records) => downloadText(`${domain}.txt`, toZoneFile(records));
|
|
1096
1115
|
//#endregion
|
|
1097
1116
|
//#region src/provisioning.tsx
|
|
1098
1117
|
var provisioning_exports = /* @__PURE__ */ __exportAll({
|
|
1118
|
+
Command: () => Command$1,
|
|
1119
|
+
Dialog: () => Dialog$1,
|
|
1099
1120
|
Flow: () => Flow$1,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
retry: "safe"
|
|
1121
|
+
Outcome: () => Outcome$1,
|
|
1122
|
+
RetryAction: () => RetryAction,
|
|
1123
|
+
Root: () => Root$1,
|
|
1124
|
+
State: () => State$1,
|
|
1125
|
+
useController: () => useController$1,
|
|
1126
|
+
useModel: () => useModel$1
|
|
1107
1127
|
});
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1128
|
+
const State$1 = Data.taggedEnum();
|
|
1129
|
+
const Command$1 = Data.taggedEnum();
|
|
1130
|
+
function useModel$1(connection, records, onApplied) {
|
|
1131
|
+
const { runtime } = useDomainKit();
|
|
1132
|
+
const recordKey = recordsIdentity(records);
|
|
1133
|
+
const onAppliedRef = useRef(onApplied);
|
|
1134
|
+
onAppliedRef.current = onApplied;
|
|
1135
|
+
return useMemo(() => {
|
|
1136
|
+
const state = Atom.make(State$1.Idle());
|
|
1137
|
+
return {
|
|
1138
|
+
command: runtime.fn()((command, get) => {
|
|
1139
|
+
if (command._tag === "Dismiss") {
|
|
1140
|
+
get.set(state, State$1.Idle());
|
|
1141
|
+
return Effect.void;
|
|
1142
|
+
}
|
|
1143
|
+
if (command._tag === "Plan") {
|
|
1144
|
+
get.set(state, State$1.Planning());
|
|
1145
|
+
return Effect.flatMap(Transport.Service, (transport) => transport.provisioning.plan({
|
|
1146
|
+
connectionId: connection.connectionId,
|
|
1147
|
+
domain: connection.domain,
|
|
1148
|
+
records
|
|
1149
|
+
})).pipe(Effect.tap((plan) => Effect.sync(() => get.set(state, State$1.Review({ plan })))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
|
|
1150
|
+
}
|
|
1151
|
+
const current = get(state);
|
|
1152
|
+
if (current._tag !== "Review" || current.plan.operations.some((operation) => operation._tag === "Conflict")) return Effect.void;
|
|
1153
|
+
const plan = current.plan;
|
|
1154
|
+
get.set(state, State$1.Applying({ plan }));
|
|
1155
|
+
return Effect.flatMap(Transport.Service, (transport) => transport.provisioning.apply({
|
|
1156
|
+
connectionId: connection.connectionId,
|
|
1157
|
+
domain: connection.domain,
|
|
1158
|
+
planDigest: plan.digest
|
|
1159
|
+
})).pipe(Effect.tap((result) => Effect.sync(() => {
|
|
1160
|
+
if (result._tag === "Applied") {
|
|
1161
|
+
get.set(state, State$1.Complete({ result }));
|
|
1162
|
+
onAppliedRef.current?.(result);
|
|
1163
|
+
} else if (result._tag === "Partial") {
|
|
1164
|
+
get.set(state, State$1.Partial({ result }));
|
|
1165
|
+
onAppliedRef.current?.(result);
|
|
1166
|
+
} else get.set(state, result);
|
|
1167
|
+
})), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
|
|
1168
|
+
}),
|
|
1169
|
+
state
|
|
1170
|
+
};
|
|
1127
1171
|
}, [
|
|
1128
1172
|
connection.connectionId,
|
|
1129
1173
|
connection.domain,
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
transport
|
|
1174
|
+
recordKey,
|
|
1175
|
+
runtime
|
|
1133
1176
|
]);
|
|
1177
|
+
}
|
|
1178
|
+
function useController$1(connection, records, onApplied) {
|
|
1179
|
+
const model = useModel$1(connection, records, onApplied);
|
|
1180
|
+
const state = useAtomValue(model.state);
|
|
1181
|
+
const execute = useAtomSet(model.command);
|
|
1134
1182
|
return {
|
|
1135
|
-
apply:
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
const request = requestState.begin({
|
|
1140
|
-
_tag: "Applying",
|
|
1141
|
-
plan: reviewedPlan
|
|
1142
|
-
});
|
|
1143
|
-
try {
|
|
1144
|
-
const result = await transport.provisioning.apply({
|
|
1145
|
-
connectionId: connection.connectionId,
|
|
1146
|
-
domain: connection.domain,
|
|
1147
|
-
planDigest: reviewedPlan.digest
|
|
1148
|
-
});
|
|
1149
|
-
if (result._tag === "Applied") {
|
|
1150
|
-
if (requestState.commit(request, {
|
|
1151
|
-
_tag: "Complete",
|
|
1152
|
-
result
|
|
1153
|
-
})) onApplied?.(result);
|
|
1154
|
-
} else if (result._tag === "Partial") {
|
|
1155
|
-
if (requestState.commit(request, {
|
|
1156
|
-
_tag: "Partial",
|
|
1157
|
-
result
|
|
1158
|
-
})) onApplied?.(result);
|
|
1159
|
-
} else requestState.commit(request, result);
|
|
1160
|
-
} catch (cause) {
|
|
1161
|
-
requestState.commit(request, failure(cause));
|
|
1162
|
-
}
|
|
1163
|
-
}, [
|
|
1164
|
-
connection.connectionId,
|
|
1165
|
-
connection.domain,
|
|
1166
|
-
onApplied,
|
|
1167
|
-
requestState,
|
|
1168
|
-
state,
|
|
1169
|
-
transport
|
|
1170
|
-
]),
|
|
1171
|
-
dismiss: () => requestState.reset({ _tag: "Idle" }),
|
|
1172
|
-
plan,
|
|
1173
|
-
retry: plan,
|
|
1183
|
+
apply: () => execute(Command$1.Apply()),
|
|
1184
|
+
dismiss: () => execute(Command$1.Dismiss()),
|
|
1185
|
+
plan: () => execute(Command$1.Plan()),
|
|
1186
|
+
retry: () => execute(Command$1.Plan()),
|
|
1174
1187
|
state
|
|
1175
1188
|
};
|
|
1176
1189
|
}
|
|
1177
|
-
function
|
|
1178
|
-
|
|
1190
|
+
function Root$1({ status, ...props }) {
|
|
1191
|
+
return usePart("div", props, { status }, {
|
|
1192
|
+
"data-domainkit-part": "provisioning-flow",
|
|
1193
|
+
"data-state": status
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
function Outcome$1({ state }) {
|
|
1197
|
+
const { messages } = useDomainKit();
|
|
1198
|
+
if (state._tag === "Complete") return /* @__PURE__ */ jsx("p", {
|
|
1199
|
+
"data-domainkit-part": "flow-outcome",
|
|
1200
|
+
"data-tone": "success",
|
|
1201
|
+
children: messages.recordsApplied
|
|
1202
|
+
});
|
|
1203
|
+
if (state._tag === "Partial" || state._tag === "Failure" || state._tag === "Stale") return /* @__PURE__ */ jsx("p", {
|
|
1204
|
+
"data-domainkit-part": "flow-outcome",
|
|
1205
|
+
"data-tone": "danger",
|
|
1206
|
+
role: "alert",
|
|
1207
|
+
children: state._tag === "Partial" ? messages.recordsPartiallyApplied : state.message
|
|
1208
|
+
});
|
|
1209
|
+
return null;
|
|
1210
|
+
}
|
|
1211
|
+
function Dialog$1({ controller }) {
|
|
1179
1212
|
const { colorScheme, messages, portalContainer, themeStyle } = useDomainKit();
|
|
1180
1213
|
const state = controller.state;
|
|
1181
1214
|
const plan = state._tag === "Review" || state._tag === "Applying" ? state.plan : void 0;
|
|
1182
|
-
return
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
"data-domainkit-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
children:
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
}),
|
|
1241
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1242
|
-
"data-domainkit-part": "dialog-footer",
|
|
1243
|
-
children: [/* @__PURE__ */ jsx(Dialog.Close, {
|
|
1244
|
-
"data-domainkit-part": "dialog-cancel",
|
|
1245
|
-
children: messages.cancel
|
|
1246
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1247
|
-
"data-domainkit-part": "plan-apply",
|
|
1248
|
-
disabled: state._tag === "Applying" || plan.operations.some((operation) => operation._tag === "Conflict"),
|
|
1249
|
-
onClick: () => void controller.apply(),
|
|
1250
|
-
type: "button",
|
|
1251
|
-
children: state._tag === "Applying" ? messages.applyingDns : messages.applyDns
|
|
1252
|
-
})]
|
|
1253
|
-
})
|
|
1254
|
-
]
|
|
1255
|
-
})]
|
|
1256
|
-
})]
|
|
1257
|
-
}),
|
|
1258
|
-
state._tag === "Failure" || state._tag === "Stale" || state._tag === "Partial" ? /* @__PURE__ */ jsx("button", {
|
|
1259
|
-
"data-domainkit-part": "provisioning-retry",
|
|
1260
|
-
onClick: () => void controller.retry(),
|
|
1261
|
-
type: "button",
|
|
1262
|
-
children: messages.retry
|
|
1263
|
-
}) : null
|
|
1264
|
-
] }),
|
|
1265
|
-
"data-domainkit-part": "provisioning-flow",
|
|
1266
|
-
"data-state": state._tag
|
|
1215
|
+
return /* @__PURE__ */ jsxs(Dialog.Root, {
|
|
1216
|
+
onOpenChange: (open) => {
|
|
1217
|
+
if (!open) controller.dismiss();
|
|
1218
|
+
},
|
|
1219
|
+
open: plan !== void 0,
|
|
1220
|
+
children: [/* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
1221
|
+
"data-domainkit-part": "plan-trigger",
|
|
1222
|
+
disabled: state._tag === "Planning" || state._tag === "Applying",
|
|
1223
|
+
onClick: () => controller.plan(),
|
|
1224
|
+
children: state._tag === "Planning" ? messages.planningDns : messages.reviewDns
|
|
1225
|
+
}), plan === void 0 ? null : /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
1226
|
+
container: portalContainer ?? void 0,
|
|
1227
|
+
children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { "data-domainkit-part": "dialog-backdrop" }), /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
1228
|
+
"data-color-scheme": colorScheme,
|
|
1229
|
+
"data-domainkit-part": "plan-dialog",
|
|
1230
|
+
"data-domainkit-root": "",
|
|
1231
|
+
style: themeStyle,
|
|
1232
|
+
children: [
|
|
1233
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1234
|
+
"data-domainkit-part": "dialog-header",
|
|
1235
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1236
|
+
"data-domainkit-part": "dialog-heading",
|
|
1237
|
+
children: [/* @__PURE__ */ jsx(Dialog.Title, {
|
|
1238
|
+
"data-domainkit-part": "dialog-title",
|
|
1239
|
+
children: messages.reviewDns
|
|
1240
|
+
}), /* @__PURE__ */ jsx(Dialog.Description, {
|
|
1241
|
+
"data-domainkit-part": "dialog-description",
|
|
1242
|
+
children: messages.planConsent
|
|
1243
|
+
})]
|
|
1244
|
+
}), /* @__PURE__ */ jsx(Dialog.Close, {
|
|
1245
|
+
"aria-label": messages.close,
|
|
1246
|
+
"data-domainkit-part": "dialog-close",
|
|
1247
|
+
children: "×"
|
|
1248
|
+
})]
|
|
1249
|
+
}),
|
|
1250
|
+
/* @__PURE__ */ jsx("div", {
|
|
1251
|
+
"data-domainkit-part": "dialog-body",
|
|
1252
|
+
children: /* @__PURE__ */ jsx(List, {
|
|
1253
|
+
lifecycle: "provisioning",
|
|
1254
|
+
operations: plan.operations
|
|
1255
|
+
})
|
|
1256
|
+
}),
|
|
1257
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1258
|
+
"data-domainkit-part": "dialog-footer",
|
|
1259
|
+
children: [/* @__PURE__ */ jsx(Dialog.Close, {
|
|
1260
|
+
"data-domainkit-part": "dialog-cancel",
|
|
1261
|
+
children: messages.cancel
|
|
1262
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1263
|
+
"data-domainkit-part": "plan-apply",
|
|
1264
|
+
disabled: state._tag === "Applying" || plan.operations.some((operation) => operation._tag === "Conflict"),
|
|
1265
|
+
onClick: () => controller.apply(),
|
|
1266
|
+
type: "button",
|
|
1267
|
+
children: state._tag === "Applying" ? messages.applyingDns : messages.applyDns
|
|
1268
|
+
})]
|
|
1269
|
+
})
|
|
1270
|
+
]
|
|
1271
|
+
})]
|
|
1272
|
+
})]
|
|
1267
1273
|
});
|
|
1268
1274
|
}
|
|
1269
|
-
function
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1275
|
+
function RetryAction({ controller }) {
|
|
1276
|
+
const { messages } = useDomainKit();
|
|
1277
|
+
const state = controller.state;
|
|
1278
|
+
if (state._tag !== "Failure" && state._tag !== "Stale" && state._tag !== "Partial") return null;
|
|
1279
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1280
|
+
"data-domainkit-part": "provisioning-retry",
|
|
1281
|
+
onClick: () => controller.retry(),
|
|
1282
|
+
type: "button",
|
|
1283
|
+
children: messages.retry
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
function Flow$1({ connection, onApplied, records, showRecords = true, ...props }) {
|
|
1287
|
+
const controller = useController$1(connection, records, onApplied);
|
|
1288
|
+
const state = controller.state;
|
|
1289
|
+
return /* @__PURE__ */ jsxs(Root$1, {
|
|
1290
|
+
status: state._tag,
|
|
1291
|
+
...props,
|
|
1292
|
+
children: [
|
|
1293
|
+
showRecords ? /* @__PURE__ */ jsx(Table, { records }) : null,
|
|
1294
|
+
/* @__PURE__ */ jsx(Outcome$1, { state }),
|
|
1295
|
+
/* @__PURE__ */ jsx(Dialog$1, { controller }),
|
|
1296
|
+
/* @__PURE__ */ jsx(RetryAction, { controller })
|
|
1297
|
+
]
|
|
1288
1298
|
});
|
|
1289
1299
|
}
|
|
1290
1300
|
//#endregion
|
|
1291
1301
|
//#region src/verification.tsx
|
|
1292
1302
|
var verification_exports = /* @__PURE__ */ __exportAll({
|
|
1303
|
+
Command: () => Command,
|
|
1304
|
+
Evidence: () => Evidence,
|
|
1305
|
+
ObserveAction: () => ObserveAction,
|
|
1306
|
+
Outcome: () => Outcome,
|
|
1307
|
+
Root: () => Root,
|
|
1308
|
+
State: () => State,
|
|
1293
1309
|
Status: () => Status,
|
|
1294
|
-
useController: () => useController
|
|
1310
|
+
useController: () => useController,
|
|
1311
|
+
useModel: () => useModel
|
|
1295
1312
|
});
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1313
|
+
const State = Data.taggedEnum();
|
|
1314
|
+
const Command = Data.taggedEnum();
|
|
1315
|
+
function useModel(config) {
|
|
1316
|
+
const { runtime } = useDomainKit();
|
|
1317
|
+
const provider = config.sources?.provider ?? config.connection !== void 0;
|
|
1318
|
+
const publicDns = config.sources?.publicDns ?? true;
|
|
1319
|
+
const recordKey = recordsIdentity(config.records);
|
|
1320
|
+
return useMemo(() => {
|
|
1321
|
+
const state = Atom.make(State.Idle());
|
|
1322
|
+
return {
|
|
1323
|
+
command: runtime.fn()((command, get) => {
|
|
1324
|
+
if (command._tag === "Reset") {
|
|
1325
|
+
get.set(state, State.Idle());
|
|
1326
|
+
return Effect.void;
|
|
1327
|
+
}
|
|
1328
|
+
get.set(state, State.Observing());
|
|
1329
|
+
return Effect.flatMap(Transport.Service, (transport) => transport.verification.observe({
|
|
1309
1330
|
...config.connection === void 0 ? {} : { connectionId: config.connection.connectionId },
|
|
1310
1331
|
domain: config.domain,
|
|
1311
1332
|
records: config.records,
|
|
1312
|
-
sources
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1333
|
+
sources: {
|
|
1334
|
+
provider,
|
|
1335
|
+
publicDns
|
|
1336
|
+
}
|
|
1337
|
+
})).pipe(Effect.tap((observation) => Effect.sync(() => get.set(state, observation))), Effect.catch((error) => Effect.sync(() => get.set(state, failureFromError(error)))), Effect.asVoid);
|
|
1338
|
+
}),
|
|
1339
|
+
state
|
|
1340
|
+
};
|
|
1341
|
+
}, [
|
|
1342
|
+
config.connection?.connectionId,
|
|
1343
|
+
config.domain,
|
|
1344
|
+
provider,
|
|
1345
|
+
publicDns,
|
|
1346
|
+
recordKey,
|
|
1347
|
+
runtime
|
|
1348
|
+
]);
|
|
1349
|
+
}
|
|
1350
|
+
function useController(config) {
|
|
1351
|
+
const model = useModel(config);
|
|
1352
|
+
const state = useAtomValue(model.state);
|
|
1353
|
+
const dispatch = useAtomSet(model.command);
|
|
1354
|
+
const observe = () => dispatch(Command.Observe());
|
|
1355
|
+
const reset = () => dispatch(Command.Reset());
|
|
1356
|
+
return {
|
|
1357
|
+
observe,
|
|
1358
|
+
reset,
|
|
1327
1359
|
state
|
|
1328
1360
|
};
|
|
1329
1361
|
}
|
|
@@ -1343,46 +1375,66 @@ const observationGroups = (observation) => [{
|
|
|
1343
1375
|
evidence: observation.publicDns,
|
|
1344
1376
|
label: "Public DNS"
|
|
1345
1377
|
}].filter((group) => group.evidence.length > 0);
|
|
1378
|
+
function Root({ status, ...props }) {
|
|
1379
|
+
return usePart("div", props, { status }, {
|
|
1380
|
+
"data-domainkit-part": "verification-status",
|
|
1381
|
+
"data-state": status
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
function Evidence({ observation }) {
|
|
1385
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1386
|
+
"data-domainkit-part": "observation-list",
|
|
1387
|
+
children: observationGroups(observation).map((group) => /* @__PURE__ */ jsxs("section", {
|
|
1388
|
+
"data-domainkit-part": "observation-group",
|
|
1389
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1390
|
+
"data-domainkit-part": "observation-source",
|
|
1391
|
+
children: group.label
|
|
1392
|
+
}), /* @__PURE__ */ jsx("ul", { children: group.evidence.map((evidence, index) => {
|
|
1393
|
+
const note = evidenceNote(evidence);
|
|
1394
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("div", {
|
|
1395
|
+
"data-domainkit-part": "observation-row",
|
|
1396
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1397
|
+
"data-domainkit-part": "observation-record",
|
|
1398
|
+
children: evidence.recordId
|
|
1399
|
+
}), /* @__PURE__ */ jsx(Status$1, { evidence })]
|
|
1400
|
+
}), note === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
1401
|
+
"data-domainkit-part": "observation-note",
|
|
1402
|
+
children: note
|
|
1403
|
+
})] }, `${evidence._tag}-${evidence.recordId}-${index}`);
|
|
1404
|
+
}) })]
|
|
1405
|
+
}, group.label))
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
function Outcome({ state }) {
|
|
1409
|
+
if (state._tag !== "Failure") return null;
|
|
1410
|
+
return /* @__PURE__ */ jsx("p", {
|
|
1411
|
+
"data-domainkit-part": "flow-outcome",
|
|
1412
|
+
"data-tone": "danger",
|
|
1413
|
+
role: "alert",
|
|
1414
|
+
children: state.message
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
function ObserveAction({ controller }) {
|
|
1418
|
+
const { messages } = useDomainKit();
|
|
1419
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1420
|
+
"data-domainkit-part": "observe-action",
|
|
1421
|
+
disabled: controller.state._tag === "Observing",
|
|
1422
|
+
onClick: () => controller.observe(),
|
|
1423
|
+
type: "button",
|
|
1424
|
+
children: controller.state._tag === "Observing" ? messages.checkingDns : messages.checkDns
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1346
1427
|
function Status({ config, ...props }) {
|
|
1347
1428
|
const controller = useController(config);
|
|
1348
|
-
const { messages } = useDomainKit();
|
|
1349
1429
|
const state = controller.state;
|
|
1350
|
-
return
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}), /* @__PURE__ */ jsx("ul", { children: group.evidence.map((evidence, index) => {
|
|
1359
|
-
const note = evidenceNote(evidence);
|
|
1360
|
-
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("div", {
|
|
1361
|
-
"data-domainkit-part": "observation-row",
|
|
1362
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1363
|
-
"data-domainkit-part": "observation-record",
|
|
1364
|
-
children: evidence.recordId
|
|
1365
|
-
}), /* @__PURE__ */ jsx(Status$1, { evidence })]
|
|
1366
|
-
}), note === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
1367
|
-
"data-domainkit-part": "observation-note",
|
|
1368
|
-
children: note
|
|
1369
|
-
})] }, `${evidence._tag}-${evidence.recordId}-${index}`);
|
|
1370
|
-
}) })]
|
|
1371
|
-
}, group.label))
|
|
1372
|
-
}) : state._tag === "Failure" ? /* @__PURE__ */ jsx("p", {
|
|
1373
|
-
"data-domainkit-part": "flow-outcome",
|
|
1374
|
-
"data-tone": "danger",
|
|
1375
|
-
role: "alert",
|
|
1376
|
-
children: state.message
|
|
1377
|
-
}) : null, /* @__PURE__ */ jsx("button", {
|
|
1378
|
-
"data-domainkit-part": "observe-action",
|
|
1379
|
-
disabled: state._tag === "Observing",
|
|
1380
|
-
onClick: () => void controller.observe(),
|
|
1381
|
-
type: "button",
|
|
1382
|
-
children: state._tag === "Observing" ? messages.checkingDns : messages.checkDns
|
|
1383
|
-
})] }),
|
|
1384
|
-
"data-domainkit-part": "verification-status",
|
|
1385
|
-
"data-state": state._tag
|
|
1430
|
+
return /* @__PURE__ */ jsxs(Root, {
|
|
1431
|
+
status: state._tag,
|
|
1432
|
+
...props,
|
|
1433
|
+
children: [
|
|
1434
|
+
state._tag === "Observation" ? /* @__PURE__ */ jsx(Evidence, { observation: state }) : null,
|
|
1435
|
+
/* @__PURE__ */ jsx(Outcome, { state }),
|
|
1436
|
+
/* @__PURE__ */ jsx(ObserveAction, { controller })
|
|
1437
|
+
]
|
|
1386
1438
|
});
|
|
1387
1439
|
}
|
|
1388
1440
|
//#endregion
|
|
@@ -1391,12 +1443,12 @@ var domain_exports = /* @__PURE__ */ __exportAll({ Flow: () => Flow });
|
|
|
1391
1443
|
function Flow({ domain, receiptId, records }) {
|
|
1392
1444
|
const connection = useController$2(domain);
|
|
1393
1445
|
const state = connection.state;
|
|
1394
|
-
return /* @__PURE__ */ jsxs(Root$
|
|
1446
|
+
return /* @__PURE__ */ jsxs(Root$3, {
|
|
1395
1447
|
status: state._tag,
|
|
1396
1448
|
children: [
|
|
1397
1449
|
state._tag === "Connected" ? null : /* @__PURE__ */ jsx(Status$2, { state }),
|
|
1398
|
-
state._tag === "Failure" && (state.retry === "safe" || state.retry === "unknown") ? /* @__PURE__ */ jsx(RetryAction, { controller: connection }) : null,
|
|
1399
|
-
state._tag === "Disconnected" ? /* @__PURE__ */ jsxs(Dialog.Root, { children: [/* @__PURE__ */ jsx(
|
|
1450
|
+
state._tag === "Failure" && (state.retry === "safe" || state.retry === "unknown") ? /* @__PURE__ */ jsx(RetryAction$1, { controller: connection }) : null,
|
|
1451
|
+
state._tag === "Disconnected" ? /* @__PURE__ */ jsxs(Dialog.Root, { children: [/* @__PURE__ */ jsx(ConnectTrigger, { provider: state.provider }), /* @__PURE__ */ jsx(Dialog$2, {
|
|
1400
1452
|
controller: connection,
|
|
1401
1453
|
snapshot: state
|
|
1402
1454
|
})] }) : null,
|
|
@@ -1497,8 +1549,7 @@ function makeFakeTransport(options) {
|
|
|
1497
1549
|
reuse: []
|
|
1498
1550
|
};
|
|
1499
1551
|
const inspections = Array.isArray(options.inspect) ? [...options.inspect] : [options.inspect];
|
|
1500
|
-
|
|
1501
|
-
calls,
|
|
1552
|
+
const transport = {
|
|
1502
1553
|
cleanup: {
|
|
1503
1554
|
apply: async (input) => {
|
|
1504
1555
|
calls.cleanupApply.push(input);
|
|
@@ -1530,7 +1581,14 @@ function makeFakeTransport(options) {
|
|
|
1530
1581
|
},
|
|
1531
1582
|
inspect: async (input) => {
|
|
1532
1583
|
calls.inspect.push(input);
|
|
1533
|
-
|
|
1584
|
+
const snapshot = inspections.shift() ?? inspections.at(-1) ?? options.inspect;
|
|
1585
|
+
if (Array.isArray(snapshot)) throw new Error("Fake inspection sequence is empty");
|
|
1586
|
+
if (snapshot._tag === "Failure") throw new Transport.Failure({
|
|
1587
|
+
message: snapshot.message,
|
|
1588
|
+
operation: snapshot.operation ?? "connection.inspect",
|
|
1589
|
+
retry: snapshot.retry
|
|
1590
|
+
});
|
|
1591
|
+
return snapshot;
|
|
1534
1592
|
},
|
|
1535
1593
|
reuse: async (input) => {
|
|
1536
1594
|
calls.reuse.push(input);
|
|
@@ -1590,11 +1648,9 @@ function makeFakeTransport(options) {
|
|
|
1590
1648
|
};
|
|
1591
1649
|
} }
|
|
1592
1650
|
};
|
|
1651
|
+
return Object.assign(Transport.layerFromAsync(transport), transport, { calls });
|
|
1593
1652
|
}
|
|
1594
1653
|
//#endregion
|
|
1595
|
-
|
|
1596
|
-
var transport_exports = /* @__PURE__ */ __exportAll({});
|
|
1597
|
-
//#endregion
|
|
1598
|
-
export { cleanup_exports as Cleanup, connection_exports as Connection, domain_exports as Domain, domain_kit_exports as DomainKit, messages_exports as Messages, provider_exports as Provider, provisioning_exports as Provisioning, records_exports as Records, testing_exports as Testing, theme_exports as Theme, transport_exports as Transport, verification_exports as Verification };
|
|
1654
|
+
export { cleanup_exports as Cleanup, connection_exports as Connection, domain_exports as Domain, domain_kit_exports as DomainKit, messages_exports as Messages, operations_exports as Operations, provider_exports as Provider, provisioning_exports as Provisioning, records_exports as Records, testing_exports as Testing, theme_exports as Theme, verification_exports as Verification };
|
|
1599
1655
|
|
|
1600
1656
|
//# sourceMappingURL=index.mjs.map
|