@tangle-network/agent-app 0.60.250 → 0.60.252
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/dist/DesignCanvas-L6J72JQ2.js +15 -0
- package/dist/DesignCanvasEditor-QFQD63MR.js +18 -0
- package/dist/agent-enrollment/drizzle.js +3 -3
- package/dist/agent-enrollment/index.js +3 -3
- package/dist/app-auth/drizzle.d.ts +475 -0
- package/dist/app-auth/drizzle.js +86 -0
- package/dist/app-auth/drizzle.js.map +1 -0
- package/dist/app-auth/index.js +5 -3
- package/dist/app-auth/index.js.map +1 -1
- package/dist/app-oauth/drizzle.d.ts +2080 -0
- package/dist/app-oauth/drizzle.js +161 -0
- package/dist/app-oauth/drizzle.js.map +1 -0
- package/dist/app-oauth/index.d.ts +4 -0
- package/dist/app-oauth/index.js +8 -222
- package/dist/app-oauth/index.js.map +1 -1
- package/dist/app-oauth/issuer.d.ts +133 -0
- package/dist/app-oauth/issuer.js +247 -0
- package/dist/app-oauth/issuer.js.map +1 -0
- package/dist/assistant/index.js +13 -13
- package/dist/chat-react/index.js +4 -4
- package/dist/chat-routes/index.js +37 -67
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/promote-file-part.d.ts +2 -3
- package/dist/chat-store/index.js +4 -4
- package/dist/{chunk-MY3EJJ6Y.js → chunk-4FEH6266.js} +2 -2
- package/dist/{chunk-5Y7Z5G3Y.js → chunk-4GCPADYG.js} +20 -336
- package/dist/chunk-4GCPADYG.js.map +1 -0
- package/dist/{chunk-X556WVBG.js → chunk-4ZSLX3LY.js} +2 -2
- package/dist/chunk-57XPEL7X.js +26 -0
- package/dist/chunk-57XPEL7X.js.map +1 -0
- package/dist/chunk-6Z7TZVKZ.js +26 -0
- package/dist/chunk-6Z7TZVKZ.js.map +1 -0
- package/dist/{chunk-7KKOFMLD.js → chunk-AWIQQEFP.js} +1 -1
- package/dist/chunk-AWIQQEFP.js.map +1 -0
- package/dist/{chunk-VBKP2NLI.js → chunk-BTKI4XMM.js} +2 -2
- package/dist/{chunk-63QAQP7I.js → chunk-CNBVWPQC.js} +7 -7
- package/dist/{chunk-FENBDSIW.js → chunk-CQGEGPY7.js} +75 -3
- package/dist/chunk-CQGEGPY7.js.map +1 -0
- package/dist/chunk-CTREXL3O.js +335 -0
- package/dist/chunk-CTREXL3O.js.map +1 -0
- package/dist/chunk-DLWO3J7D.js +238 -0
- package/dist/chunk-DLWO3J7D.js.map +1 -0
- package/dist/{chunk-LWSJK546.js → chunk-DSMGS4IV.js} +5 -5
- package/dist/{chunk-LWSJK546.js.map → chunk-DSMGS4IV.js.map} +1 -1
- package/dist/{chunk-A3KPDLSF.js → chunk-EFPIHR6F.js} +18 -18
- package/dist/chunk-FRAICFTZ.js +191 -0
- package/dist/chunk-FRAICFTZ.js.map +1 -0
- package/dist/chunk-GS7VWV26.js +61 -0
- package/dist/chunk-GS7VWV26.js.map +1 -0
- package/dist/{chunk-NMSAZFRL.js → chunk-H5GQMLHA.js} +2 -2
- package/dist/{chunk-OQE6WMDP.js → chunk-HN6MZ2XL.js} +5 -5
- package/dist/chunk-HY57QRRW.js +11 -0
- package/dist/chunk-HY57QRRW.js.map +1 -0
- package/dist/{chunk-TCGZFSN5.js → chunk-KH4QSBNI.js} +2 -2
- package/dist/{chunk-JH3CKHF4.js → chunk-KJODHPWM.js} +8 -8
- package/dist/chunk-LSBI5MWS.js +66 -0
- package/dist/chunk-LSBI5MWS.js.map +1 -0
- package/dist/chunk-MDRH3SDA.js +106 -0
- package/dist/chunk-MDRH3SDA.js.map +1 -0
- package/dist/{chunk-VBWYH7UZ.js → chunk-NHYRIM4I.js} +3 -3
- package/dist/{chunk-BYP54FMI.js → chunk-O2RCDK5D.js} +30 -15
- package/dist/{chunk-BYP54FMI.js.map → chunk-O2RCDK5D.js.map} +1 -1
- package/dist/{chunk-EWOJATDS.js → chunk-PDD5A43Y.js} +3 -3
- package/dist/{chunk-23JUSUUB.js → chunk-RZLCBWGG.js} +2 -2
- package/dist/chunk-SFZELD6V.js +52 -0
- package/dist/chunk-SFZELD6V.js.map +1 -0
- package/dist/{chunk-Y4W6GK5X.js → chunk-UGFCLD32.js} +2 -2
- package/dist/{chunk-ZGUXI5SI.js → chunk-VUBJZEZB.js} +2 -2
- package/dist/{chunk-LQYIBL3G.js → chunk-WL7PZK7Q.js} +71 -1
- package/dist/chunk-WL7PZK7Q.js.map +1 -0
- package/dist/{chunk-7HZCFG2A.js → chunk-WP2GYFZ4.js} +38 -1
- package/dist/chunk-WP2GYFZ4.js.map +1 -0
- package/dist/{chunk-JK7R7BZQ.js → chunk-ZWJ3SZ2G.js} +2 -2
- package/dist/crypto/digest.d.ts +2 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.js +6 -2
- package/dist/design-canvas/index.js +5 -3
- package/dist/design-canvas/index.js.map +1 -1
- package/dist/design-canvas-react/engine.js +7 -5
- package/dist/design-canvas-react/index.js +14 -12
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/eval/index.d.ts +4 -0
- package/dist/eval/index.js +125 -0
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/persona-driver.d.ts +37 -0
- package/dist/eval/research-plan.d.ts +25 -0
- package/dist/eval/research-plan.js +55 -0
- package/dist/eval/research-plan.js.map +1 -0
- package/dist/eval/scorecard.d.ts +38 -0
- package/dist/forms/blank.d.ts +2 -2
- package/dist/forms/index.js +4 -5
- package/dist/forms/index.js.map +1 -1
- package/dist/hosted-agent/application.js +2 -2
- package/dist/interactions/index.js +3 -3
- package/dist/knowledge/prelaunch-audit.d.ts +17 -0
- package/dist/knowledge/prelaunch-audit.js +67 -0
- package/dist/knowledge/prelaunch-audit.js.map +1 -0
- package/dist/media/drizzle.d.ts +207 -0
- package/dist/media/drizzle.js +26 -0
- package/dist/media/drizzle.js.map +1 -0
- package/dist/media/generate-request.d.ts +53 -0
- package/dist/media/generation-record.d.ts +68 -0
- package/dist/media/index.d.ts +13 -0
- package/dist/media/index.js +653 -0
- package/dist/media/index.js.map +1 -0
- package/dist/media/model-catalog.d.ts +109 -0
- package/dist/media/router-client.d.ts +40 -0
- package/dist/media/router-generation.d.ts +44 -0
- package/dist/media/speech-script.d.ts +20 -0
- package/dist/openui/index.js +1 -1
- package/dist/operator/index.js +4 -5
- package/dist/operator/index.js.map +1 -1
- package/dist/plans/decision.d.ts +48 -0
- package/dist/plans/drizzle.d.ts +25 -0
- package/dist/plans/drizzle.js +97 -0
- package/dist/plans/drizzle.js.map +1 -0
- package/dist/plans/index.d.ts +1 -1
- package/dist/plans/index.js +11 -3
- package/dist/platform/billing-config.d.ts +22 -0
- package/dist/platform/billing-config.js +36 -0
- package/dist/platform/billing-config.js.map +1 -0
- package/dist/platform/index.js +13 -11
- package/dist/platform/index.js.map +1 -1
- package/dist/preset-cloudflare/index.js +2 -1
- package/dist/preset-cloudflare/index.js.map +1 -1
- package/dist/profile/index.js +4 -5
- package/dist/profile/index.js.map +1 -1
- package/dist/public-consultation/index.d.ts +1 -1
- package/dist/public-consultation/index.js +13 -11
- package/dist/public-consultation/index.js.map +1 -1
- package/dist/runtime/telemetry-cap.d.ts +24 -0
- package/dist/runtime/telemetry-cap.js +36 -0
- package/dist/runtime/telemetry-cap.js.map +1 -0
- package/dist/sandbox/index.js +12 -9
- package/dist/sequences/index.js +4 -2
- package/dist/sequences/index.js.map +1 -1
- package/dist/skills-placement/box.d.ts +50 -0
- package/dist/skills-placement/box.js +204 -0
- package/dist/skills-placement/box.js.map +1 -0
- package/dist/skills-placement/index.js +8 -96
- package/dist/skills-placement/index.js.map +1 -1
- package/dist/spend/budget.d.ts +13 -0
- package/dist/spend/drizzle.d.ts +55 -0
- package/dist/spend/drizzle.js +131 -0
- package/dist/spend/drizzle.js.map +1 -0
- package/dist/spend/index.d.ts +2 -1
- package/dist/spend/index.js +77 -58
- package/dist/spend/index.js.map +1 -1
- package/dist/spend/platform-settlements.d.ts +46 -0
- package/dist/stream/index.js +19 -19
- package/dist/studio/generated-media/index.d.ts +6 -0
- package/dist/studio/generated-media/index.js +590 -0
- package/dist/studio/generated-media/index.js.map +1 -0
- package/dist/studio/generated-media/output.d.ts +27 -0
- package/dist/studio/generated-media/store.d.ts +175 -0
- package/dist/studio-react/download-generations.d.ts +7 -0
- package/dist/studio-react/index.d.ts +1 -0
- package/dist/studio-react/index.js +85 -0
- package/dist/studio-react/index.js.map +1 -1
- package/dist/studio-react/use-studio-route.d.ts +44 -0
- package/dist/teams/invitations-api.d.ts +4 -0
- package/dist/teams/invitations-api.js +44 -32
- package/dist/teams/invitations-api.js.map +1 -1
- package/dist/theme/dom.d.ts +22 -0
- package/dist/theme/dom.js +18 -0
- package/dist/theme/dom.js.map +1 -0
- package/dist/vault/collaboration.d.ts +83 -0
- package/dist/vault/collaboration.js +215 -0
- package/dist/vault/collaboration.js.map +1 -0
- package/dist/vault/server.js +6 -53
- package/dist/vault/server.js.map +1 -1
- package/dist/vault/store/coordinator.d.ts +64 -0
- package/dist/vault/store/index.d.ts +12 -0
- package/dist/vault/store/index.js +1202 -0
- package/dist/vault/store/index.js.map +1 -0
- package/dist/vault/store/paths.d.ts +65 -0
- package/dist/vault/store/revisions.d.ts +211 -0
- package/dist/vault/store/sandbox-sync.d.ts +74 -0
- package/dist/vault/store/store.d.ts +161 -0
- package/dist/vault/store/tree.d.ts +11 -0
- package/dist/web/entry-server.d.ts +7 -0
- package/dist/web/entry-server.js +29 -0
- package/dist/web/entry-server.js.map +1 -0
- package/dist/web/fetch-guard.d.ts +6 -0
- package/dist/web/index.d.ts +3 -0
- package/dist/web/index.js +20 -4
- package/dist/web/mime.d.ts +16 -0
- package/dist/web/rate-limit.d.ts +25 -0
- package/dist/web/timeout.d.ts +9 -0
- package/dist/web-react/agent-profile-editor.js +3 -3
- package/dist/web-react/api-access-panel.d.ts +4 -2
- package/dist/web-react/document.d.ts +41 -0
- package/dist/web-react/document.js +103 -0
- package/dist/web-react/document.js.map +1 -0
- package/dist/web-react/index.js +31 -31
- package/dist/workspace-react/index.js +5 -5
- package/package.json +95 -4
- package/dist/DesignCanvas-OW3W2QXW.js +0 -13
- package/dist/DesignCanvasEditor-TCHZF25W.js +0 -16
- package/dist/chunk-5Y7Z5G3Y.js.map +0 -1
- package/dist/chunk-7HZCFG2A.js.map +0 -1
- package/dist/chunk-7KKOFMLD.js.map +0 -1
- package/dist/chunk-FENBDSIW.js.map +0 -1
- package/dist/chunk-LQYIBL3G.js.map +0 -1
- /package/dist/{DesignCanvas-OW3W2QXW.js.map → DesignCanvas-L6J72JQ2.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-TCHZF25W.js.map → DesignCanvasEditor-QFQD63MR.js.map} +0 -0
- /package/dist/{chunk-MY3EJJ6Y.js.map → chunk-4FEH6266.js.map} +0 -0
- /package/dist/{chunk-X556WVBG.js.map → chunk-4ZSLX3LY.js.map} +0 -0
- /package/dist/{chunk-VBKP2NLI.js.map → chunk-BTKI4XMM.js.map} +0 -0
- /package/dist/{chunk-63QAQP7I.js.map → chunk-CNBVWPQC.js.map} +0 -0
- /package/dist/{chunk-A3KPDLSF.js.map → chunk-EFPIHR6F.js.map} +0 -0
- /package/dist/{chunk-NMSAZFRL.js.map → chunk-H5GQMLHA.js.map} +0 -0
- /package/dist/{chunk-OQE6WMDP.js.map → chunk-HN6MZ2XL.js.map} +0 -0
- /package/dist/{chunk-TCGZFSN5.js.map → chunk-KH4QSBNI.js.map} +0 -0
- /package/dist/{chunk-JH3CKHF4.js.map → chunk-KJODHPWM.js.map} +0 -0
- /package/dist/{chunk-VBWYH7UZ.js.map → chunk-NHYRIM4I.js.map} +0 -0
- /package/dist/{chunk-EWOJATDS.js.map → chunk-PDD5A43Y.js.map} +0 -0
- /package/dist/{chunk-23JUSUUB.js.map → chunk-RZLCBWGG.js.map} +0 -0
- /package/dist/{chunk-Y4W6GK5X.js.map → chunk-UGFCLD32.js.map} +0 -0
- /package/dist/{chunk-ZGUXI5SI.js.map → chunk-VUBJZEZB.js.map} +0 -0
- /package/dist/{chunk-JK7R7BZQ.js.map → chunk-ZWJ3SZ2G.js.map} +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { KVStore } from '../../store';
|
|
2
|
+
import { VaultPathError } from './paths';
|
|
3
|
+
import { type VaultHeadState, type VaultMutationPolicy, type VaultMutationRequest, type VaultMutationResult, type VaultRevisionMetadata, type VaultWriter } from './revisions';
|
|
4
|
+
import { type VaultNode } from './tree';
|
|
5
|
+
/** The Durable Object namespace surface the store calls; Cloudflare's binding satisfies it. */
|
|
6
|
+
export interface VaultCoordinatorNamespace {
|
|
7
|
+
idFromName(name: string): unknown;
|
|
8
|
+
get(id: any): {
|
|
9
|
+
fetch(input: string, init?: RequestInit): Promise<Response>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** A coordinator's structured error, as its JSON body carries it. */
|
|
13
|
+
export interface VaultCoordinatorErrorDetail {
|
|
14
|
+
code?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
retryable?: boolean;
|
|
17
|
+
workspaceId?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
expectedRevision?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class VaultFileNotFoundError extends VaultPathError {
|
|
22
|
+
readonly code = "vault.file_not_found";
|
|
23
|
+
constructor(filePath: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class VaultConflictError extends Error {
|
|
26
|
+
readonly code = "vault.conflict";
|
|
27
|
+
readonly conflicts: Extract<VaultMutationResult, {
|
|
28
|
+
status: 'conflict';
|
|
29
|
+
}>['conflicts'];
|
|
30
|
+
constructor(result: Extract<VaultMutationResult, {
|
|
31
|
+
status: 'conflict';
|
|
32
|
+
}>);
|
|
33
|
+
}
|
|
34
|
+
/** Frontmatter parse result: a parse failure keeps the raw text and its error. */
|
|
35
|
+
export type VaultFrontmatterParse = {
|
|
36
|
+
succeeded: true;
|
|
37
|
+
frontmatter: Record<string, unknown>;
|
|
38
|
+
body: string;
|
|
39
|
+
} | {
|
|
40
|
+
succeeded: false;
|
|
41
|
+
raw: string;
|
|
42
|
+
error: {
|
|
43
|
+
code: string;
|
|
44
|
+
message: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/** How a product stores frontmatter and body in one Vault file. */
|
|
48
|
+
export interface VaultFrontmatterCodec {
|
|
49
|
+
parse(raw: string): VaultFrontmatterParse;
|
|
50
|
+
serialize(frontmatter: Record<string, unknown>, body: string): string;
|
|
51
|
+
}
|
|
52
|
+
/** A text file as the store reads or wrote it. */
|
|
53
|
+
export interface VaultStoredFile {
|
|
54
|
+
path: string;
|
|
55
|
+
content: string;
|
|
56
|
+
frontmatter: Record<string, unknown>;
|
|
57
|
+
body: string;
|
|
58
|
+
parseError?: {
|
|
59
|
+
code: string;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
/** The `mime` frontmatter field, when the file records one. */
|
|
63
|
+
mimeType?: string;
|
|
64
|
+
revision: string;
|
|
65
|
+
contentHash: string;
|
|
66
|
+
}
|
|
67
|
+
export interface VaultMutationOptions {
|
|
68
|
+
expectedRevision?: string | null;
|
|
69
|
+
operationId?: string;
|
|
70
|
+
writer?: VaultWriter;
|
|
71
|
+
}
|
|
72
|
+
export interface VaultHeadListEntry {
|
|
73
|
+
path: string;
|
|
74
|
+
revision: string | null;
|
|
75
|
+
contentHash: string | null;
|
|
76
|
+
deleted: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface VaultHeadListPage {
|
|
79
|
+
entries: VaultHeadListEntry[];
|
|
80
|
+
complete: boolean;
|
|
81
|
+
cursor: string | null;
|
|
82
|
+
}
|
|
83
|
+
/** Saved versions of one file a history listing returns at most. */
|
|
84
|
+
export declare const VAULT_HISTORY_MAX_REVISIONS = 20;
|
|
85
|
+
/** One committed version of a file, as the Vault History lists it. */
|
|
86
|
+
export interface VaultFileRevision {
|
|
87
|
+
revision: string;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
writer: VaultWriter;
|
|
90
|
+
/** True for the version the head holds now. */
|
|
91
|
+
current: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface VaultRevisionsPage {
|
|
94
|
+
revisions: VaultRevisionMetadata[];
|
|
95
|
+
complete: boolean;
|
|
96
|
+
/** False when a listed key carried no readable metadata or an uncommitted batch. */
|
|
97
|
+
metadataComplete: boolean;
|
|
98
|
+
cursor: string | null;
|
|
99
|
+
}
|
|
100
|
+
export interface VaultStoreConfig {
|
|
101
|
+
/** How a file's frontmatter and body are stored. */
|
|
102
|
+
codec: VaultFrontmatterCodec;
|
|
103
|
+
/** Headers for each coordinator request (JSON content type plus any channel auth). */
|
|
104
|
+
coordinatorHeaders?: (workspaceId: string) => Promise<Record<string, string>>;
|
|
105
|
+
/** A product error a coordinator response carries, typed; null when it is not one. */
|
|
106
|
+
decodeCoordinatorError?: (detail: VaultCoordinatorErrorDetail, fallback: string) => Error | null;
|
|
107
|
+
/** Writer rules every mutation applies; the coordinator must apply the same ones. */
|
|
108
|
+
mutationPolicy?: VaultMutationPolicy;
|
|
109
|
+
/** Runs inside the local mutation queue before a write without a coordinator; throw to refuse it. */
|
|
110
|
+
beforeLocalMutation?: (kv: KVStore, request: VaultMutationRequest) => Promise<void>;
|
|
111
|
+
/** Runs before a file delete commits, for product records tied to the path. */
|
|
112
|
+
beforeDelete?: (workspaceId: string, filePath: string) => Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
/** The store's head-list query: a page of heads, optionally under a path prefix. */
|
|
115
|
+
export interface VaultHeadListOptions {
|
|
116
|
+
cursor?: string;
|
|
117
|
+
limit?: number;
|
|
118
|
+
prefix?: string;
|
|
119
|
+
}
|
|
120
|
+
/** Create a Vault store bound per request with `setVaultKV` and `setVaultCoordinator`. */
|
|
121
|
+
export declare function createVaultStore<Namespace extends VaultCoordinatorNamespace = VaultCoordinatorNamespace>(config: VaultStoreConfig): {
|
|
122
|
+
setVaultKV: (next: KVStore) => void;
|
|
123
|
+
getVaultKV: () => KVStore;
|
|
124
|
+
setVaultCoordinator: (next: Namespace | null) => void;
|
|
125
|
+
getVaultCoordinator: () => Namespace | null;
|
|
126
|
+
postVaultCoordinator: (namespace: Namespace, workspaceId: string, route: string, body: unknown) => Promise<Response>;
|
|
127
|
+
throwVaultCoordinatorError: (response: Response, fallback: string) => Promise<never>;
|
|
128
|
+
enqueueLocalVaultMutation: <T>(workspaceId: string, run: () => Promise<T>) => Promise<T>;
|
|
129
|
+
commitVaultMutation: (request: VaultMutationRequest) => Promise<VaultMutationResult>;
|
|
130
|
+
readVaultFileState: (workspaceId: string, filePath: string) => Promise<VaultHeadState>;
|
|
131
|
+
getVaultRoot: (workspaceId: string) => string;
|
|
132
|
+
writeVaultFile: (workspaceId: string, filePath: string, content: {
|
|
133
|
+
frontmatter: Record<string, unknown>;
|
|
134
|
+
body: string;
|
|
135
|
+
}, options?: VaultMutationOptions) => Promise<VaultStoredFile>;
|
|
136
|
+
writeVaultRawFile: (workspaceId: string, filePath: string, content: string, options?: VaultMutationOptions) => Promise<VaultStoredFile>;
|
|
137
|
+
readVaultFile: (workspaceId: string, filePath: string) => Promise<VaultStoredFile>;
|
|
138
|
+
deleteVaultFile: (workspaceId: string, filePath: string, options?: VaultMutationOptions) => Promise<void>;
|
|
139
|
+
listVaultHeadPage: (workspaceId: string, options?: VaultHeadListOptions) => Promise<VaultHeadListPage>;
|
|
140
|
+
listVaultFilePaths: (workspaceId: string) => Promise<string[]>;
|
|
141
|
+
listVaultTree: (workspaceId: string) => Promise<VaultNode[]>;
|
|
142
|
+
findVaultRevisionWithContent: (workspaceId: string, path: string, headRevision: string, contentHash: string, options?: {
|
|
143
|
+
matchesContent?: ((content: string) => Promise<boolean>) | undefined;
|
|
144
|
+
}) => Promise<string | null>;
|
|
145
|
+
listVaultFileRevisions: (workspaceId: string, path: string, limit?: number) => Promise<VaultFileRevision[]>;
|
|
146
|
+
listCommittedVaultRevisionsPage: (workspaceId: string, options: {
|
|
147
|
+
cursor?: string;
|
|
148
|
+
limit?: number;
|
|
149
|
+
includePath: (path: string) => boolean;
|
|
150
|
+
}) => Promise<VaultRevisionsPage>;
|
|
151
|
+
readVaultRevisionMetadata: (workspaceId: string, path: string, revision: string) => Promise<VaultRevisionMetadata | null>;
|
|
152
|
+
readVaultFileRevision: (workspaceId: string, path: string, revision: string, options?: {
|
|
153
|
+
maxBytes?: number;
|
|
154
|
+
}) => Promise<string | null>;
|
|
155
|
+
eraseVaultConflictRecords: (workspaceId: string, conflicts: readonly {
|
|
156
|
+
path: string;
|
|
157
|
+
conflictRevision: string;
|
|
158
|
+
}[]) => Promise<void>;
|
|
159
|
+
purgeHiddenVaultFiles: (workspaceId: string) => Promise<number>;
|
|
160
|
+
};
|
|
161
|
+
export type VaultStore<Namespace extends VaultCoordinatorNamespace = VaultCoordinatorNamespace> = ReturnType<typeof createVaultStore<Namespace>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** One node of the Vault file tree the store lists. */
|
|
2
|
+
export interface VaultNode {
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
type: 'file' | 'directory';
|
|
6
|
+
children?: VaultNode[];
|
|
7
|
+
}
|
|
8
|
+
/** Nest flat file paths into a tree: directories first, then names in locale order. */
|
|
9
|
+
export declare function buildTreeFromPaths(paths: string[]): VaultNode[];
|
|
10
|
+
/** Flatten a `VaultNode` tree back to its file paths, dropping directories. */
|
|
11
|
+
export declare function flattenVaultTreePaths(nodes: VaultNode[]): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EntryContext } from 'react-router';
|
|
2
|
+
/**
|
|
3
|
+
* A React Router `entry.server` request handler for edge runtimes: streams the
|
|
4
|
+
* router, waits for the shell, and answers 500 when rendering errors. A
|
|
5
|
+
* product re-exports it as its default export.
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleRouterRequest(request: Request, responseStatusCode: number, responseHeaders: Headers, routerContext: EntryContext): Promise<Response>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/web/entry-server.tsx
|
|
2
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
3
|
+
import { ServerRouter } from "react-router";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
async function handleRouterRequest(request, responseStatusCode, responseHeaders, routerContext) {
|
|
6
|
+
let shellRendered = false;
|
|
7
|
+
const body = await renderToReadableStream(
|
|
8
|
+
/* @__PURE__ */ jsx(ServerRouter, { context: routerContext, url: request.url }),
|
|
9
|
+
{
|
|
10
|
+
onError(error) {
|
|
11
|
+
responseStatusCode = 500;
|
|
12
|
+
if (shellRendered) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
shellRendered = true;
|
|
19
|
+
await body.allReady;
|
|
20
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
21
|
+
return new Response(body, {
|
|
22
|
+
headers: responseHeaders,
|
|
23
|
+
status: responseStatusCode
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
handleRouterRequest
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=entry-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/web/entry-server.tsx"],"sourcesContent":["import { renderToReadableStream } from 'react-dom/server'\nimport type { EntryContext } from 'react-router'\nimport { ServerRouter } from 'react-router'\n\n/**\n * A React Router `entry.server` request handler for edge runtimes: streams the\n * router, waits for the shell, and answers 500 when rendering errors. A\n * product re-exports it as its default export.\n */\nexport async function handleRouterRequest(\n request: Request,\n responseStatusCode: number,\n responseHeaders: Headers,\n routerContext: EntryContext,\n) {\n let shellRendered = false\n const body = await renderToReadableStream(\n <ServerRouter context={routerContext} url={request.url} />,\n {\n onError(error: unknown) {\n responseStatusCode = 500\n if (shellRendered) {\n console.error(error)\n }\n },\n },\n )\n shellRendered = true\n\n await body.allReady\n\n responseHeaders.set('Content-Type', 'text/html')\n return new Response(body, {\n headers: responseHeaders,\n status: responseStatusCode,\n })\n}\n"],"mappings":";AAAA,SAAS,8BAA8B;AAEvC,SAAS,oBAAoB;AAezB;AARJ,eAAsB,oBACpB,SACA,oBACA,iBACA,eACA;AACA,MAAI,gBAAgB;AACpB,QAAM,OAAO,MAAM;AAAA,IACjB,oBAAC,gBAAa,SAAS,eAAe,KAAK,QAAQ,KAAK;AAAA,IACxD;AAAA,MACE,QAAQ,OAAgB;AACtB,6BAAqB;AACrB,YAAI,eAAe;AACjB,kBAAQ,MAAM,KAAK;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,kBAAgB;AAEhB,QAAM,KAAK;AAEX,kBAAgB,IAAI,gBAAgB,WAAW;AAC/C,SAAO,IAAI,SAAS,MAAM;AAAA,IACxB,SAAS;AAAA,IACT,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side fetch target guard: refuse hosts that resolve to this machine or a
|
|
3
|
+
* private network, so a user- or model-supplied URL cannot reach internal
|
|
4
|
+
* services. URL canonicalization covers alternate IPv4 spellings. No imports.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isBlockedFetchHostname(hostname: string): boolean;
|
package/dist/web/index.d.ts
CHANGED
package/dist/web/index.js
CHANGED
|
@@ -2,8 +2,11 @@ import {
|
|
|
2
2
|
acquisitionFromRequest,
|
|
3
3
|
firstTouchAcquisitionCookie,
|
|
4
4
|
groupConversationMessages,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
isEditableMime,
|
|
6
|
+
readFirstTouchAcquisition,
|
|
7
|
+
sniffMime,
|
|
8
|
+
sniffMimeFromName
|
|
9
|
+
} from "../chunk-CQGEGPY7.js";
|
|
7
10
|
import {
|
|
8
11
|
createApiKeyFetch
|
|
9
12
|
} from "../chunk-RN4WPTBH.js";
|
|
@@ -17,6 +20,7 @@ import {
|
|
|
17
20
|
checkFreeRouteLimit,
|
|
18
21
|
checkRateLimit,
|
|
19
22
|
clearCookieHeader,
|
|
23
|
+
createRateLimiterBinding,
|
|
20
24
|
extractRequestContext,
|
|
21
25
|
freeRouteLimitResponse,
|
|
22
26
|
parseJsonObjectBody,
|
|
@@ -24,10 +28,16 @@ import {
|
|
|
24
28
|
requireString,
|
|
25
29
|
serializeCookie,
|
|
26
30
|
withFreeRouteLimit
|
|
27
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-WP2GYFZ4.js";
|
|
28
32
|
import {
|
|
29
33
|
isWorkspaceFileExportable
|
|
30
34
|
} from "../chunk-TXD5HXLE.js";
|
|
35
|
+
import {
|
|
36
|
+
withTimeout
|
|
37
|
+
} from "../chunk-6Z7TZVKZ.js";
|
|
38
|
+
import {
|
|
39
|
+
isBlockedFetchHostname
|
|
40
|
+
} from "../chunk-57XPEL7X.js";
|
|
31
41
|
export {
|
|
32
42
|
FREE_ROUTE_BUDGETS,
|
|
33
43
|
FreeRouteLimitError,
|
|
@@ -40,16 +50,22 @@ export {
|
|
|
40
50
|
checkRateLimit,
|
|
41
51
|
clearCookieHeader,
|
|
42
52
|
createApiKeyFetch,
|
|
53
|
+
createRateLimiterBinding,
|
|
43
54
|
extractRequestContext,
|
|
44
55
|
firstTouchAcquisitionCookie,
|
|
45
56
|
freeRouteLimitResponse,
|
|
46
57
|
groupConversationMessages,
|
|
58
|
+
isBlockedFetchHostname,
|
|
59
|
+
isEditableMime,
|
|
47
60
|
isWorkspaceFileExportable,
|
|
48
61
|
parseJsonObjectBody,
|
|
49
62
|
readCookieValue,
|
|
50
63
|
readFirstTouchAcquisition,
|
|
51
64
|
requireString,
|
|
52
65
|
serializeCookie,
|
|
53
|
-
|
|
66
|
+
sniffMime,
|
|
67
|
+
sniffMimeFromName,
|
|
68
|
+
withFreeRouteLimit,
|
|
69
|
+
withTimeout
|
|
54
70
|
};
|
|
55
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filename extension → media type. Browser-safe; no imports.
|
|
3
|
+
*
|
|
4
|
+
* `sniffMimeFromName` is the generic last-resort typing for uploads and
|
|
5
|
+
* promoted agent files. `sniffMime` adds the code, MDX and spreadsheet types a
|
|
6
|
+
* file preview picks its renderer from (rendered markdown, line-numbered code,
|
|
7
|
+
* image, video, tabular CSV, embedded PDF, monospace text fallback). An unknown
|
|
8
|
+
* extension falls to `text/plain`; it is never a rejection.
|
|
9
|
+
*/
|
|
10
|
+
/** Generic extension → mime for uploads and promoted files. */
|
|
11
|
+
export declare function sniffMimeFromName(filename: string): string;
|
|
12
|
+
/** Extension → mime for choosing a file preview renderer. A product's own
|
|
13
|
+
* file types (e.g. `{ fountain: 'text/plain' }`) go in `extraExtensions`. */
|
|
14
|
+
export declare function sniffMime(filename: string, extraExtensions?: Readonly<Record<string, string>>): string;
|
|
15
|
+
/** The vault editor surface is Markdown-only. */
|
|
16
|
+
export declare function isEditableMime(mime: string): boolean;
|
package/dist/web/rate-limit.d.ts
CHANGED
|
@@ -36,3 +36,28 @@ export interface RateLimitOptions {
|
|
|
36
36
|
* the count and bypass the limiter. A bare `JSON.parse` here would throw and
|
|
37
37
|
* abort the request handler, silently disabling the limit (fail-open). */
|
|
38
38
|
export declare function checkRateLimit(kv: KvLike, key: string, limit: number, windowSeconds: number, options?: RateLimitOptions): Promise<RateLimitResult>;
|
|
39
|
+
/** Timing of one limiter decision, for a product that logs it. */
|
|
40
|
+
export interface RateLimitTiming {
|
|
41
|
+
readMs: number;
|
|
42
|
+
/** Present once the counter write settled. */
|
|
43
|
+
writeMs?: number;
|
|
44
|
+
/** Present on the decision event. */
|
|
45
|
+
decisionMs?: number;
|
|
46
|
+
allowed?: boolean;
|
|
47
|
+
deferred: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface RateLimiterBindingOptions {
|
|
50
|
+
/** Called when the counter write settles and when the decision is made. */
|
|
51
|
+
onTiming?: (event: 'counter' | 'decision', timing: RateLimitTiming) => void;
|
|
52
|
+
/** Called when a deferred counter write fails; the decision already stood. */
|
|
53
|
+
onPersistError?: (error: unknown) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A product's limiter bound once to its KV namespace at worker start:
|
|
57
|
+
* `setKV(env.RATE_LIMIT_KV)`, then `check(key, limit, windowSeconds)` anywhere.
|
|
58
|
+
* Pass `waitUntil` to defer the counter write past the response.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createRateLimiterBinding(options?: RateLimiterBindingOptions): {
|
|
61
|
+
setKV: (kv: KvLike) => void;
|
|
62
|
+
check: (key: string, limit: number, windowSeconds: number, waitUntil?: (persist: Promise<void>) => void) => Promise<RateLimitResult>;
|
|
63
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Race an async operation against a timeout. The operation receives an
|
|
3
|
+
* AbortSignal that fires when the timeout elapses, so a hung request is
|
|
4
|
+
* aborted and rejected with `message` instead of hanging forever. The timer is
|
|
5
|
+
* cleared the moment the operation settles, so wrapping a streaming `fetch`
|
|
6
|
+
* (which resolves at response headers) guards only the connect/first-byte
|
|
7
|
+
* phase and never truncates a long-lived response body. Browser-safe.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withTimeout<T>(operation: (signal: AbortSignal) => Promise<T>, timeoutMs: number, message: string): Promise<T>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_PROFILE_EDITOR_SECTIONS,
|
|
3
3
|
AgentProfileEditor
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-HN6MZ2XL.js";
|
|
5
5
|
import "../chunk-G4F2NWZH.js";
|
|
6
6
|
import "../chunk-FUZETA6Z.js";
|
|
7
7
|
import "../chunk-R4X5474U.js";
|
|
8
8
|
import "../chunk-RASGKEAL.js";
|
|
9
|
-
import "../chunk-FPNZMIAW.js";
|
|
10
9
|
import "../chunk-B7CL7ENS.js";
|
|
11
|
-
import "../chunk-PV33JZKV.js";
|
|
12
10
|
import "../chunk-AMUXRAUO.js";
|
|
11
|
+
import "../chunk-FPNZMIAW.js";
|
|
12
|
+
import "../chunk-PV33JZKV.js";
|
|
13
13
|
export {
|
|
14
14
|
AGENT_PROFILE_EDITOR_SECTIONS,
|
|
15
15
|
AgentProfileEditor
|
|
@@ -39,7 +39,8 @@ export interface ApiAccessPanelProps {
|
|
|
39
39
|
plural: string;
|
|
40
40
|
};
|
|
41
41
|
/** `workspaceIds` is empty for a key that reaches every workspace. */
|
|
42
|
-
|
|
42
|
+
/** Defaults to `POST /api/keys`, the route the shared key handlers serve. */
|
|
43
|
+
onCreate?: (input: {
|
|
43
44
|
name: string;
|
|
44
45
|
scopes: string[];
|
|
45
46
|
expiresAt: string;
|
|
@@ -48,7 +49,8 @@ export interface ApiAccessPanelProps {
|
|
|
48
49
|
id: string;
|
|
49
50
|
key: string;
|
|
50
51
|
}>;
|
|
51
|
-
|
|
52
|
+
/** Defaults to `DELETE /api/keys/:id`. */
|
|
53
|
+
onRevoke?: (id: string) => Promise<void>;
|
|
52
54
|
onChanged: () => void;
|
|
53
55
|
}
|
|
54
56
|
export declare function ApiAccessPanel({ keys, access, defaultScopes, baseUrl, accountHref, description, limitsDescription, expiryDays, defaultExpiryDays, workspaces, workspaceNoun, onCreate, onRevoke, onChanged }: ApiAccessPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type LinksFunction } from 'react-router';
|
|
3
|
+
/**
|
|
4
|
+
* The shared `useTheme` hook toggles only `.dark` on <html>. This mirrors every
|
|
5
|
+
* such flip onto the `.light` class and the color-scheme/theme-color metas, and
|
|
6
|
+
* tracks OS appearance changes while the preference is System.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ThemeClassSync(): null;
|
|
9
|
+
export interface AppDocumentProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** Theme the server renders before the bootstrap script runs. */
|
|
12
|
+
defaultTheme: 'light' | 'dark';
|
|
13
|
+
bodyClassName?: string;
|
|
14
|
+
/** Extra attributes on <html>, such as `data-density`. */
|
|
15
|
+
htmlAttributes?: HTMLAttributes<HTMLHtmlElement> & Record<`data-${string}`, string>;
|
|
16
|
+
/** Rendered first in the body, after the theme script (a skip link). */
|
|
17
|
+
before?: ReactNode;
|
|
18
|
+
/** Rendered after the route content (a toaster). */
|
|
19
|
+
after?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/** The root route's `Layout`: document shell, theme bootstrap, scroll restoration and scripts. */
|
|
22
|
+
export declare function AppDocument({ children, defaultTheme, bodyClassName, htmlAttributes, before, after }: AppDocumentProps): import("react").JSX.Element;
|
|
23
|
+
/** A data-URI SVG favicon whose strokes follow the Brand foreground in light and dark. `shapes` is the SVG `<path>` markup. */
|
|
24
|
+
export declare function svgFaviconHref(shapes: string): string;
|
|
25
|
+
/** The root route's `links`: favicon, the app stylesheet, Inter, and any extra font stylesheets. */
|
|
26
|
+
export declare function appDocumentLinks(options: {
|
|
27
|
+
stylesheet: string;
|
|
28
|
+
favicon: string;
|
|
29
|
+
extraStylesheets?: readonly string[];
|
|
30
|
+
}): ReturnType<LinksFunction>;
|
|
31
|
+
/** The message and, outside a route response, the stack a root error screen shows. */
|
|
32
|
+
export declare function describeRouteError(error: unknown): {
|
|
33
|
+
message: string;
|
|
34
|
+
stack?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Wrap `window.fetch` for the page's lifetime so `onResponse` sees every
|
|
38
|
+
* response. Read a body from `response.clone()`; the caller still gets the
|
|
39
|
+
* original untouched. Install from an effect and call the result to restore.
|
|
40
|
+
*/
|
|
41
|
+
export declare function installFetchResponseObserver(onResponse: (response: Response, args: Parameters<typeof fetch>) => void | Promise<void>): () => void;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DARK_THEME_COLOR,
|
|
3
|
+
LIGHT_THEME_COLOR,
|
|
4
|
+
THEME_BOOTSTRAP_SCRIPT,
|
|
5
|
+
applyThemeDom,
|
|
6
|
+
shouldFollowSystemTheme
|
|
7
|
+
} from "../chunk-SFZELD6V.js";
|
|
8
|
+
import {
|
|
9
|
+
darkTheme,
|
|
10
|
+
lightTheme,
|
|
11
|
+
themeColor
|
|
12
|
+
} from "../chunk-UTF7H6BK.js";
|
|
13
|
+
|
|
14
|
+
// src/web-react/document.tsx
|
|
15
|
+
import { useEffect } from "react";
|
|
16
|
+
import { Links, Meta, Scripts, ScrollRestoration, isRouteErrorResponse } from "react-router";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
function ThemeClassSync() {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const root = document.documentElement;
|
|
21
|
+
const sync = () => {
|
|
22
|
+
applyThemeDom(root.classList.contains("dark"));
|
|
23
|
+
};
|
|
24
|
+
const syncSystemTheme = () => {
|
|
25
|
+
if (!shouldFollowSystemTheme()) return;
|
|
26
|
+
applyThemeDom(window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
27
|
+
};
|
|
28
|
+
sync();
|
|
29
|
+
const observer = new MutationObserver(sync);
|
|
30
|
+
observer.observe(root, { attributes: true, attributeFilter: ["class"] });
|
|
31
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
32
|
+
media.addEventListener("change", syncSystemTheme);
|
|
33
|
+
return () => {
|
|
34
|
+
observer.disconnect();
|
|
35
|
+
media.removeEventListener("change", syncSystemTheme);
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function AppDocument({ children, defaultTheme, bodyClassName, htmlAttributes, before, after }) {
|
|
41
|
+
return /* @__PURE__ */ jsxs("html", { lang: "en", suppressHydrationWarning: true, className: defaultTheme, "data-sandbox-ui": true, ...htmlAttributes, children: [
|
|
42
|
+
/* @__PURE__ */ jsxs("head", { children: [
|
|
43
|
+
/* @__PURE__ */ jsx("meta", { charSet: "utf-8" }),
|
|
44
|
+
/* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }),
|
|
45
|
+
/* @__PURE__ */ jsx("meta", { name: "theme-color", content: defaultTheme === "dark" ? DARK_THEME_COLOR : LIGHT_THEME_COLOR }),
|
|
46
|
+
/* @__PURE__ */ jsx("meta", { name: "color-scheme", content: defaultTheme }),
|
|
47
|
+
/* @__PURE__ */ jsx(Meta, {}),
|
|
48
|
+
/* @__PURE__ */ jsx(Links, {})
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ jsxs("body", { className: bodyClassName, children: [
|
|
51
|
+
/* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: THEME_BOOTSTRAP_SCRIPT } }),
|
|
52
|
+
before,
|
|
53
|
+
/* @__PURE__ */ jsx(ThemeClassSync, {}),
|
|
54
|
+
children,
|
|
55
|
+
after,
|
|
56
|
+
/* @__PURE__ */ jsx(ScrollRestoration, {}),
|
|
57
|
+
/* @__PURE__ */ jsx(Scripts, {})
|
|
58
|
+
] })
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
function svgFaviconHref(shapes) {
|
|
62
|
+
return "data:image/svg+xml;utf8," + encodeURIComponent(
|
|
63
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><style>path{stroke:${themeColor(lightTheme.foreground)}}@media (prefers-color-scheme: dark){path{stroke:${themeColor(darkTheme.foreground)}}}</style>` + shapes + "</svg>"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function appDocumentLinks(options) {
|
|
67
|
+
return [
|
|
68
|
+
{ rel: "icon", href: options.favicon, type: "image/svg+xml" },
|
|
69
|
+
{ rel: "stylesheet", href: options.stylesheet },
|
|
70
|
+
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
|
|
71
|
+
{ rel: "dns-prefetch", href: "https://fonts.googleapis.com" },
|
|
72
|
+
{ rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" },
|
|
73
|
+
{ rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" },
|
|
74
|
+
...(options.extraStylesheets ?? []).map((href) => ({ rel: "stylesheet", href }))
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function describeRouteError(error) {
|
|
78
|
+
if (isRouteErrorResponse(error)) {
|
|
79
|
+
return { message: error.status === 404 ? "Page not found" : error.statusText || "An unexpected error occurred" };
|
|
80
|
+
}
|
|
81
|
+
if (error instanceof Error) return { message: error.message, stack: error.stack };
|
|
82
|
+
return { message: "An unexpected error occurred" };
|
|
83
|
+
}
|
|
84
|
+
function installFetchResponseObserver(onResponse) {
|
|
85
|
+
const original = window.fetch;
|
|
86
|
+
window.fetch = async (...args) => {
|
|
87
|
+
const response = await original(...args);
|
|
88
|
+
await onResponse(response, args);
|
|
89
|
+
return response;
|
|
90
|
+
};
|
|
91
|
+
return () => {
|
|
92
|
+
window.fetch = original;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
AppDocument,
|
|
97
|
+
ThemeClassSync,
|
|
98
|
+
appDocumentLinks,
|
|
99
|
+
describeRouteError,
|
|
100
|
+
installFetchResponseObserver,
|
|
101
|
+
svgFaviconHref
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/web-react/document.tsx"],"sourcesContent":["import { useEffect, type HTMLAttributes, type ReactNode } from 'react'\nimport { Links, Meta, Scripts, ScrollRestoration, isRouteErrorResponse, type LinksFunction } from 'react-router'\nimport {\n applyThemeDom,\n DARK_THEME_COLOR,\n LIGHT_THEME_COLOR,\n shouldFollowSystemTheme,\n THEME_BOOTSTRAP_SCRIPT,\n} from '../theme/dom'\nimport { darkTheme, lightTheme, themeColor } from '../theme/theme'\n\n/**\n * The shared `useTheme` hook toggles only `.dark` on <html>. This mirrors every\n * such flip onto the `.light` class and the color-scheme/theme-color metas, and\n * tracks OS appearance changes while the preference is System.\n */\nexport function ThemeClassSync() {\n useEffect(() => {\n const root = document.documentElement\n const sync = () => {\n applyThemeDom(root.classList.contains('dark'))\n }\n const syncSystemTheme = () => {\n if (!shouldFollowSystemTheme()) return\n applyThemeDom(window.matchMedia('(prefers-color-scheme: dark)').matches)\n }\n sync()\n const observer = new MutationObserver(sync)\n observer.observe(root, { attributes: true, attributeFilter: ['class'] })\n const media = window.matchMedia('(prefers-color-scheme: dark)')\n media.addEventListener('change', syncSystemTheme)\n return () => {\n observer.disconnect()\n media.removeEventListener('change', syncSystemTheme)\n }\n }, [])\n return null\n}\n\nexport interface AppDocumentProps {\n children: ReactNode\n /** Theme the server renders before the bootstrap script runs. */\n defaultTheme: 'light' | 'dark'\n bodyClassName?: string\n /** Extra attributes on <html>, such as `data-density`. */\n htmlAttributes?: HTMLAttributes<HTMLHtmlElement> & Record<`data-${string}`, string>\n /** Rendered first in the body, after the theme script (a skip link). */\n before?: ReactNode\n /** Rendered after the route content (a toaster). */\n after?: ReactNode\n}\n\n/** The root route's `Layout`: document shell, theme bootstrap, scroll restoration and scripts. */\nexport function AppDocument({ children, defaultTheme, bodyClassName, htmlAttributes, before, after }: AppDocumentProps) {\n return (\n <html lang=\"en\" suppressHydrationWarning className={defaultTheme} data-sandbox-ui {...htmlAttributes}>\n <head>\n <meta charSet=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta name=\"theme-color\" content={defaultTheme === 'dark' ? DARK_THEME_COLOR : LIGHT_THEME_COLOR} />\n <meta name=\"color-scheme\" content={defaultTheme} />\n <Meta />\n <Links />\n </head>\n <body className={bodyClassName}>\n <script dangerouslySetInnerHTML={{ __html: THEME_BOOTSTRAP_SCRIPT }} />\n {before}\n <ThemeClassSync />\n {children}\n {after}\n <ScrollRestoration />\n <Scripts />\n </body>\n </html>\n )\n}\n\n/** A data-URI SVG favicon whose strokes follow the Brand foreground in light and dark. `shapes` is the SVG `<path>` markup. */\nexport function svgFaviconHref(shapes: string): string {\n return 'data:image/svg+xml;utf8,' + encodeURIComponent(\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">'\n + `<style>path{stroke:${themeColor(lightTheme.foreground)}}@media (prefers-color-scheme: dark){path{stroke:${themeColor(darkTheme.foreground)}}}</style>`\n + shapes\n + '</svg>',\n )\n}\n\n/** The root route's `links`: favicon, the app stylesheet, Inter, and any extra font stylesheets. */\nexport function appDocumentLinks(options: { stylesheet: string; favicon: string; extraStylesheets?: readonly string[] }): ReturnType<LinksFunction> {\n return [\n { rel: 'icon', href: options.favicon, type: 'image/svg+xml' },\n { rel: 'stylesheet', href: options.stylesheet },\n { rel: 'preconnect', href: 'https://fonts.googleapis.com' },\n { rel: 'dns-prefetch', href: 'https://fonts.googleapis.com' },\n { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossOrigin: 'anonymous' },\n { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap' },\n ...(options.extraStylesheets ?? []).map((href) => ({ rel: 'stylesheet', href })),\n ]\n}\n\n/** The message and, outside a route response, the stack a root error screen shows. */\nexport function describeRouteError(error: unknown): { message: string; stack?: string } {\n if (isRouteErrorResponse(error)) {\n return { message: error.status === 404 ? 'Page not found' : error.statusText || 'An unexpected error occurred' }\n }\n if (error instanceof Error) return { message: error.message, stack: error.stack }\n return { message: 'An unexpected error occurred' }\n}\n\n/**\n * Wrap `window.fetch` for the page's lifetime so `onResponse` sees every\n * response. Read a body from `response.clone()`; the caller still gets the\n * original untouched. Install from an effect and call the result to restore.\n */\nexport function installFetchResponseObserver(onResponse: (response: Response, args: Parameters<typeof fetch>) => void | Promise<void>): () => void {\n const original = window.fetch\n window.fetch = async (...args) => {\n const response = await original(...args)\n await onResponse(response, args)\n return response\n }\n return () => {\n window.fetch = original\n }\n}\n"],"mappings":"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","names":[]}
|