@powerhousedao/reactor-browser 6.2.2-dev.4 → 6.2.2-dev.41
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 +283 -0
- package/dist/attachment-service-iRAJvtrC.d.ts +970 -0
- package/dist/attachment-service-iRAJvtrC.d.ts.map +1 -0
- package/dist/client-BaHKLGy5.d.ts +14 -0
- package/dist/client-BaHKLGy5.d.ts.map +1 -0
- package/dist/{client-u13cr-Vg.js → client-Zz_l9QzI.js} +30 -3
- package/dist/client-Zz_l9QzI.js.map +1 -0
- package/dist/{client-_Gh2Uf0E.js → client-s_ISz_Zs.js} +30 -4
- package/dist/client-s_ISz_Zs.js.map +1 -0
- package/dist/{document-by-id-dLYFX-xz.js → document-by-id-BPj6Gd7n.js} +48 -43
- package/dist/document-by-id-BPj6Gd7n.js.map +1 -0
- package/dist/document-operations-DvhxGXqI.js +2678 -0
- package/dist/document-operations-DvhxGXqI.js.map +1 -0
- package/dist/global-DscB9Uo3.d.ts +391 -0
- package/dist/global-DscB9Uo3.d.ts.map +1 -0
- package/dist/index-CxZDuIq9.d.ts +345 -0
- package/dist/index-CxZDuIq9.d.ts.map +1 -0
- package/dist/index-CxxxP14A.d.ts +144 -0
- package/dist/index-CxxxP14A.d.ts.map +1 -0
- package/dist/index.d.ts +107 -693
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -1627
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-CvQDDxmT.d.ts → inspector-proxy-CL1NSQyn.d.ts} +1 -1
- package/dist/{inspector-proxy-CvQDDxmT.d.ts.map → inspector-proxy-CL1NSQyn.d.ts.map} +1 -1
- package/dist/{make-ph-event-functions-BHoLPif5.js → make-ph-event-functions-DBq3iWYn.js} +1 -1
- package/dist/{make-ph-event-functions-BHoLPif5.js.map → make-ph-event-functions-DBq3iWYn.js.map} +1 -1
- package/dist/{index-DS4W07Y8.d.ts → pglite-CntadC_p-BtEalg1H.d.ts} +2 -142
- package/dist/pglite-CntadC_p-BtEalg1H.d.ts.map +1 -0
- package/dist/{relational-Dj06-YkI.js → relational-DJlbclWB.js} +1 -1
- package/dist/{relational-Dj06-YkI.js.map → relational-DJlbclWB.js.map} +1 -1
- package/dist/renown-BZabzj4l.js +68 -0
- package/dist/renown-BZabzj4l.js.map +1 -0
- package/dist/{renown-D-1c_Bvx.js → renown-C7a1ygsj.js} +471 -57
- package/dist/renown-C7a1ygsj.js.map +1 -0
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +2 -1
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/graphql/client.d.ts +3 -2
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +4 -0
- package/dist/src/graphql-client/entry.js +3 -0
- package/dist/src/relational/index.d.ts +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +2 -2
- package/dist/src/renown/index.js +3 -2
- package/dist/src/rpc/index.d.ts +2 -2
- package/dist/src/rpc/index.js +1 -1
- package/dist/store-DAJq6vSs.js +37 -0
- package/dist/store-DAJq6vSs.js.map +1 -0
- package/dist/{client-09xv0Dq6.d.ts → types-Bitg5Z5j.d.ts} +25 -13
- package/dist/types-Bitg5Z5j.d.ts.map +1 -0
- package/dist/{types-CPV0Cnsy.d.ts → types-wGaiXwjh.d.ts} +1 -1
- package/dist/{types-CPV0Cnsy.d.ts.map → types-wGaiXwjh.d.ts.map} +1 -1
- package/package.json +15 -9
- package/dist/client-09xv0Dq6.d.ts.map +0 -1
- package/dist/client-_Gh2Uf0E.js.map +0 -1
- package/dist/client-u13cr-Vg.js.map +0 -1
- package/dist/document-by-id-dLYFX-xz.js.map +0 -1
- package/dist/index-D3bV5rcl.d.ts +0 -216
- package/dist/index-D3bV5rcl.d.ts.map +0 -1
- package/dist/index-DS4W07Y8.d.ts.map +0 -1
- package/dist/renown-D-1c_Bvx.js.map +0 -1
|
@@ -0,0 +1,2678 @@
|
|
|
1
|
+
import { S as uploadOperations, _ as isDuplicateManifestError, a as setDocumentCache, b as queueActions, g as DOCUMENT_CHANGE_TYPE, i as addDocumentCacheEventHandler, n as useDocumentsByIds, p as DocumentCache, r as useDispatch, v as isDuplicateModuleError, x as queueOperations } from "./document-by-id-BPj6Gd7n.js";
|
|
2
|
+
import { t as makePHEventFunctions } from "./make-ph-event-functions-DBq3iWYn.js";
|
|
3
|
+
import { a as PhDocumentFieldsFragmentDoc, n as DocumentChangeType, o as PropagationMode, r as DocumentChangesDocument, t as createClient$1 } from "./client-s_ISz_Zs.js";
|
|
4
|
+
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-BZabzj4l.js";
|
|
5
|
+
import { logger } from "document-model";
|
|
6
|
+
import { assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, documentModelDocumentType, generateId, hashDocumentStateForScope, replayDocumentVersioned, setName } from "@powerhousedao/shared/document-model";
|
|
7
|
+
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
8
|
+
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
9
|
+
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
10
|
+
import { GraphQLClient } from "graphql-request";
|
|
11
|
+
import { gql } from "graphql-tag";
|
|
12
|
+
import { Kind, print } from "graphql";
|
|
13
|
+
import { createClient } from "graphql-ws/client";
|
|
14
|
+
import slug from "slug";
|
|
15
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
16
|
+
//#region src/errors.ts
|
|
17
|
+
var UnsupportedDocumentTypeError = class extends Error {
|
|
18
|
+
constructor(documentType) {
|
|
19
|
+
super(`Document type ${documentType} is not supported`);
|
|
20
|
+
this.name = "UnsupportedDocumentTypeError";
|
|
21
|
+
}
|
|
22
|
+
static isError(error) {
|
|
23
|
+
return Error.isError(error) && error.name === "UnsupportedDocumentTypeError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var DocumentNotFoundError = class extends Error {
|
|
27
|
+
constructor(documentId) {
|
|
28
|
+
super(`Document with id ${documentId} not found`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var DocumentModelNotFoundError = class extends Error {
|
|
32
|
+
documentType;
|
|
33
|
+
name = "DocumentModelNotFoundError";
|
|
34
|
+
constructor(documentType) {
|
|
35
|
+
super(`Document model module for type ${documentType} not found`);
|
|
36
|
+
this.documentType = documentType;
|
|
37
|
+
}
|
|
38
|
+
static isError(error) {
|
|
39
|
+
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var DocumentTypeMismatchError = class extends Error {
|
|
43
|
+
constructor(documentId, expectedType, actualType) {
|
|
44
|
+
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var NoSelectedDocumentError = class extends Error {
|
|
48
|
+
constructor() {
|
|
49
|
+
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/utils/documents.ts
|
|
54
|
+
function isDocumentTypeSupported(documentType, supportedDocuments) {
|
|
55
|
+
if (!supportedDocuments?.length) return true;
|
|
56
|
+
return supportedDocuments.some((pattern) => {
|
|
57
|
+
if (pattern.endsWith("/*")) {
|
|
58
|
+
const prefix = pattern.slice(0, -2);
|
|
59
|
+
return documentType.startsWith(prefix + "/");
|
|
60
|
+
}
|
|
61
|
+
if (pattern.endsWith("*") && !pattern.endsWith("/*")) {
|
|
62
|
+
const prefix = pattern.slice(0, -1);
|
|
63
|
+
return documentType.startsWith(prefix);
|
|
64
|
+
}
|
|
65
|
+
return pattern === documentType;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/utils/user.ts
|
|
70
|
+
function getUserPermissions() {
|
|
71
|
+
const user = window.ph?.renown?.user;
|
|
72
|
+
const allowList = window.ph?.allowList;
|
|
73
|
+
if (!allowList) return {
|
|
74
|
+
isAllowedToCreateDocuments: true,
|
|
75
|
+
isAllowedToEditDocuments: true
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
|
|
79
|
+
isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/actions/document.ts
|
|
84
|
+
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
85
|
+
async function isDocumentInLocation(document, driveId, parentFolder) {
|
|
86
|
+
const reactorClient = window.ph?.reactorClient;
|
|
87
|
+
if (!reactorClient) return { isDuplicate: false };
|
|
88
|
+
let drive;
|
|
89
|
+
try {
|
|
90
|
+
drive = await reactorClient.get(driveId);
|
|
91
|
+
} catch {
|
|
92
|
+
return { isDuplicate: false };
|
|
93
|
+
}
|
|
94
|
+
const nodeById = drive.state.global.nodes.find((node) => node.id === document.header.id);
|
|
95
|
+
if (nodeById && nodeById.parentFolder === (parentFolder ?? null)) return {
|
|
96
|
+
isDuplicate: true,
|
|
97
|
+
duplicateType: "id",
|
|
98
|
+
nodeId: nodeById.id
|
|
99
|
+
};
|
|
100
|
+
const nodeByNameAndType = drive.state.global.nodes.find((node) => isFileNode(node) && node.name === document.header.name && node.documentType === document.header.documentType && node.parentFolder === (parentFolder ?? null));
|
|
101
|
+
if (nodeByNameAndType) return {
|
|
102
|
+
isDuplicate: true,
|
|
103
|
+
duplicateType: "name",
|
|
104
|
+
nodeId: nodeByNameAndType.id
|
|
105
|
+
};
|
|
106
|
+
return { isDuplicate: false };
|
|
107
|
+
}
|
|
108
|
+
function getDocumentTypeIcon(document) {
|
|
109
|
+
switch (document.header.documentType) {
|
|
110
|
+
case "powerhouse/document-model": return "document-model";
|
|
111
|
+
case "powerhouse/app": return "app";
|
|
112
|
+
case "powerhouse/document-editor": return "editor";
|
|
113
|
+
case "powerhouse/subgraph": return "subgraph";
|
|
114
|
+
case "powerhouse/package": return "package";
|
|
115
|
+
case "powerhouse/processor": {
|
|
116
|
+
const processorType = document.state.global?.type;
|
|
117
|
+
if (processorType === "analytics") return "analytics-processor";
|
|
118
|
+
if (processorType === "relational") return "relational-processor";
|
|
119
|
+
if (processorType === "codegen") return "codegen-processor";
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
default: return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function downloadFile(document, fileName) {
|
|
126
|
+
try {
|
|
127
|
+
const data = await createZip(document);
|
|
128
|
+
const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
|
|
129
|
+
const link = window.document.createElement("a");
|
|
130
|
+
link.style.display = "none";
|
|
131
|
+
link.href = URL.createObjectURL(blob);
|
|
132
|
+
link.download = fileName;
|
|
133
|
+
window.document.body.appendChild(link);
|
|
134
|
+
link.click();
|
|
135
|
+
window.document.body.removeChild(link);
|
|
136
|
+
} catch (e) {
|
|
137
|
+
logger.error(e instanceof Error ? e.message : String(e));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function getDocumentExtension(document) {
|
|
141
|
+
const documentType = document.header.documentType;
|
|
142
|
+
let rawExtension;
|
|
143
|
+
if (documentType === documentModelDocumentType) rawExtension = document.state.global?.extension;
|
|
144
|
+
else {
|
|
145
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
146
|
+
if (reactorClient) {
|
|
147
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
148
|
+
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Fetches all operations for a document using cursor-based pagination.
|
|
155
|
+
* The reactor client handles multi-scope cursors transparently via
|
|
156
|
+
* composite cursors, so all scopes are fetched in a single paginated stream.
|
|
157
|
+
*/
|
|
158
|
+
async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
|
|
159
|
+
const scopes = Object.keys(document.state);
|
|
160
|
+
const operations = {};
|
|
161
|
+
for (const scope of scopes) operations[scope] = [];
|
|
162
|
+
let cursor = "";
|
|
163
|
+
do {
|
|
164
|
+
const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
|
|
165
|
+
cursor,
|
|
166
|
+
limit: pageSize
|
|
167
|
+
});
|
|
168
|
+
for (const op of page.results) {
|
|
169
|
+
const scope = op.action.scope ?? "global";
|
|
170
|
+
if (operations[scope]) operations[scope].push(op);
|
|
171
|
+
}
|
|
172
|
+
cursor = page.nextCursor ?? "";
|
|
173
|
+
} while (cursor);
|
|
174
|
+
return operations;
|
|
175
|
+
}
|
|
176
|
+
function extractInitialState(documentScopeOps) {
|
|
177
|
+
const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
|
|
178
|
+
if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
|
|
179
|
+
const input = upgradeOp.action.input;
|
|
180
|
+
const initialState = input.initialState ?? input.state;
|
|
181
|
+
if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
|
|
182
|
+
return initialState;
|
|
183
|
+
}
|
|
184
|
+
function filterDomainOperations(operations) {
|
|
185
|
+
return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
|
|
186
|
+
}
|
|
187
|
+
async function exportFile(document, suggestedName) {
|
|
188
|
+
const reactorClient = window.ph?.reactorClient;
|
|
189
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
190
|
+
const operations = await fetchDocumentOperations(reactorClient, document);
|
|
191
|
+
const initialState = extractInitialState(operations["document"] ?? []);
|
|
192
|
+
const documentWithOps = {
|
|
193
|
+
...document,
|
|
194
|
+
operations,
|
|
195
|
+
initialState
|
|
196
|
+
};
|
|
197
|
+
const extension = await getDocumentExtension(documentWithOps);
|
|
198
|
+
const baseName = suggestedName || documentWithOps.header.name || "Untitled";
|
|
199
|
+
const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
|
|
200
|
+
if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
|
|
201
|
+
try {
|
|
202
|
+
const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
|
|
203
|
+
await baseSaveToFileHandle(documentWithOps, fileHandle);
|
|
204
|
+
return fileHandle;
|
|
205
|
+
} catch (e) {
|
|
206
|
+
if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Loads a document file and replays it with version-aware reducers from the registry.
|
|
211
|
+
* Falls back to single-version legacy replay when no upgrade manifest is registered for
|
|
212
|
+
* the document type.
|
|
213
|
+
*/
|
|
214
|
+
async function loadFile(path) {
|
|
215
|
+
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
216
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
217
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
218
|
+
const documentType = baseDocument.header.documentType;
|
|
219
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
220
|
+
const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
|
|
221
|
+
if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
|
|
222
|
+
const reducers = {};
|
|
223
|
+
for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
|
|
224
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
225
|
+
let upgradeManifest;
|
|
226
|
+
if (registry) try {
|
|
227
|
+
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
228
|
+
} catch {}
|
|
229
|
+
return baseLoadFromInputVersioned(path, {
|
|
230
|
+
reducers,
|
|
231
|
+
upgradeManifest
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
|
|
235
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
236
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
237
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
238
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
239
|
+
const documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
240
|
+
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
241
|
+
newDocument.header.name = name;
|
|
242
|
+
if (preferredEditor) newDocument.header.meta = {
|
|
243
|
+
...newDocument.header.meta,
|
|
244
|
+
preferredEditor
|
|
245
|
+
};
|
|
246
|
+
let newDoc;
|
|
247
|
+
try {
|
|
248
|
+
newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
logger.error("Error adding document: @error", e);
|
|
251
|
+
throw new Error("There was an error adding document", { cause: e });
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
id: newDoc.header.id,
|
|
255
|
+
name: newDoc.header.name,
|
|
256
|
+
documentType,
|
|
257
|
+
parentFolder: parentFolder ?? null,
|
|
258
|
+
kind: "file"
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
async function addFile(file, driveId, name, parentFolder) {
|
|
262
|
+
logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
263
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
264
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
|
|
265
|
+
const document = await loadFile(file);
|
|
266
|
+
let duplicateId = false;
|
|
267
|
+
const reactorClient = window.ph?.reactorClient;
|
|
268
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
269
|
+
try {
|
|
270
|
+
await reactorClient.get(document.header.id);
|
|
271
|
+
duplicateId = true;
|
|
272
|
+
} catch {}
|
|
273
|
+
const documentId = duplicateId ? generateId() : document.header.id;
|
|
274
|
+
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
275
|
+
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
276
|
+
header.meta = document.header.meta;
|
|
277
|
+
header.name = name || document.header.name;
|
|
278
|
+
const initialDocument = {
|
|
279
|
+
...document,
|
|
280
|
+
header,
|
|
281
|
+
state: document.initialState,
|
|
282
|
+
operations: Object.keys(document.operations).reduce((acc, key) => {
|
|
283
|
+
acc[key] = [];
|
|
284
|
+
return acc;
|
|
285
|
+
}, {})
|
|
286
|
+
};
|
|
287
|
+
await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
|
|
288
|
+
await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations);
|
|
289
|
+
}
|
|
290
|
+
async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
291
|
+
logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
292
|
+
const reactor = window.ph?.reactorClientModule?.client;
|
|
293
|
+
if (!reactor) return;
|
|
294
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
295
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
|
|
296
|
+
try {
|
|
297
|
+
onProgress?.({
|
|
298
|
+
stage: "loading",
|
|
299
|
+
progress: 0
|
|
300
|
+
});
|
|
301
|
+
let document;
|
|
302
|
+
try {
|
|
303
|
+
document = await loadFile(file);
|
|
304
|
+
} catch (loadError) {
|
|
305
|
+
const discoveryService = window.ph?.packageDiscoveryService;
|
|
306
|
+
if (discoveryService && DocumentModelNotFoundError.isError(loadError)) {
|
|
307
|
+
retryAfterDiscovery(discoveryService, loadError.documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
throw loadError;
|
|
311
|
+
}
|
|
312
|
+
const duplicateCheck = await isDocumentInLocation(document, driveId, parentFolder);
|
|
313
|
+
if (duplicateCheck.isDuplicate && !resolveConflict) {
|
|
314
|
+
onProgress?.({
|
|
315
|
+
stage: "conflict",
|
|
316
|
+
progress: 0,
|
|
317
|
+
duplicateType: duplicateCheck.duplicateType
|
|
318
|
+
});
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const documentType = getDocumentTypeIcon(document);
|
|
322
|
+
if (documentType) onProgress?.({
|
|
323
|
+
stage: "loading",
|
|
324
|
+
progress: 10,
|
|
325
|
+
documentType
|
|
326
|
+
});
|
|
327
|
+
else onProgress?.({
|
|
328
|
+
stage: "loading",
|
|
329
|
+
progress: 10
|
|
330
|
+
});
|
|
331
|
+
if (!isDocumentTypeSupported(document.header.documentType, documentTypes)) {
|
|
332
|
+
onProgress?.({
|
|
333
|
+
stage: "unsupported-document-type",
|
|
334
|
+
progress: 100,
|
|
335
|
+
error: `Document type ${document.header.documentType} is not supported`
|
|
336
|
+
});
|
|
337
|
+
throw new UnsupportedDocumentTypeError(document.header.documentType);
|
|
338
|
+
}
|
|
339
|
+
await reactor.getDocumentModelModule(document.header.documentType);
|
|
340
|
+
onProgress?.({
|
|
341
|
+
stage: "initializing",
|
|
342
|
+
progress: 10
|
|
343
|
+
});
|
|
344
|
+
let duplicateId = false;
|
|
345
|
+
try {
|
|
346
|
+
await reactor.get(document.header.id);
|
|
347
|
+
duplicateId = true;
|
|
348
|
+
} catch {}
|
|
349
|
+
const documentId = duplicateId ? generateId() : document.header.id;
|
|
350
|
+
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
351
|
+
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
352
|
+
header.meta = document.header.meta;
|
|
353
|
+
header.name = name || document.header.name;
|
|
354
|
+
const initialDocument = {
|
|
355
|
+
...document,
|
|
356
|
+
header,
|
|
357
|
+
state: document.initialState,
|
|
358
|
+
operations: Object.keys(document.operations).reduce((acc, key) => {
|
|
359
|
+
acc[key] = [];
|
|
360
|
+
return acc;
|
|
361
|
+
}, {})
|
|
362
|
+
};
|
|
363
|
+
const fileNode = await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
|
|
364
|
+
if (!fileNode) throw new Error("There was an error adding file");
|
|
365
|
+
onProgress?.({
|
|
366
|
+
stage: "initializing",
|
|
367
|
+
progress: 20
|
|
368
|
+
});
|
|
369
|
+
await reactor.get(documentId);
|
|
370
|
+
console.log("Document created, starting upload of operations");
|
|
371
|
+
await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations, { onProgress: (uploadProgress) => {
|
|
372
|
+
if (uploadProgress.totalOperations && uploadProgress.uploadedOperations !== void 0) {
|
|
373
|
+
const uploadPercent = uploadProgress.totalOperations > 0 ? uploadProgress.uploadedOperations / uploadProgress.totalOperations : 0;
|
|
374
|
+
const overallProgress = 20 + Math.round(uploadPercent * 80);
|
|
375
|
+
onProgress?.({
|
|
376
|
+
stage: "uploading",
|
|
377
|
+
progress: overallProgress,
|
|
378
|
+
totalOperations: uploadProgress.totalOperations,
|
|
379
|
+
uploadedOperations: uploadProgress.uploadedOperations
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
} });
|
|
383
|
+
onProgress?.({
|
|
384
|
+
stage: "complete",
|
|
385
|
+
progress: 100,
|
|
386
|
+
fileNode
|
|
387
|
+
});
|
|
388
|
+
return fileNode;
|
|
389
|
+
} catch (error) {
|
|
390
|
+
if (!UnsupportedDocumentTypeError.isError(error)) {
|
|
391
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
392
|
+
onProgress?.({
|
|
393
|
+
stage: "failed",
|
|
394
|
+
progress: 100,
|
|
395
|
+
error: errorMessage
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
async function retryAfterDiscovery(discoveryService, documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
402
|
+
if (!discoveryService) return;
|
|
403
|
+
try {
|
|
404
|
+
await discoveryService.load(documentType);
|
|
405
|
+
} catch {
|
|
406
|
+
onProgress?.({
|
|
407
|
+
stage: "unsupported-document-type",
|
|
408
|
+
progress: 100,
|
|
409
|
+
error: `Document type ${documentType} is not supported`
|
|
410
|
+
});
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
await addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict);
|
|
414
|
+
}
|
|
415
|
+
async function addFolder$1(driveId, name, parentFolder) {
|
|
416
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
417
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
|
|
418
|
+
const reactorClient = window.ph?.reactorClient;
|
|
419
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
420
|
+
await reactorClient.get(driveId);
|
|
421
|
+
const folderId = generateId();
|
|
422
|
+
const node = (await reactorClient.execute(driveId, "main", [addFolder({
|
|
423
|
+
id: folderId,
|
|
424
|
+
name,
|
|
425
|
+
parentFolder
|
|
426
|
+
})])).state.global.nodes.find((node) => node.id === folderId);
|
|
427
|
+
if (!node || !isFolderNode(node)) throw new Error("There was an error adding folder");
|
|
428
|
+
return node;
|
|
429
|
+
}
|
|
430
|
+
async function deleteNode(driveId, nodeId) {
|
|
431
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
432
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to delete documents");
|
|
433
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
434
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
435
|
+
await reactorClient.drives.removeNode(driveId, nodeId);
|
|
436
|
+
}
|
|
437
|
+
async function renameNode(driveId, nodeId, name) {
|
|
438
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
439
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
440
|
+
const reactorClient = window.ph?.reactorClient;
|
|
441
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
442
|
+
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
443
|
+
const node = (await reactorClient.execute(driveId, "main", [updateNode({
|
|
444
|
+
id: nodeId,
|
|
445
|
+
name
|
|
446
|
+
})])).state.global.nodes.find((n) => n.id === nodeId);
|
|
447
|
+
if (!node) throw new Error("There was an error renaming node in the drive");
|
|
448
|
+
return node;
|
|
449
|
+
}
|
|
450
|
+
async function renameDriveNode(driveId, nodeId, name) {
|
|
451
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
452
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
453
|
+
const reactorClient = window.ph?.reactorClient;
|
|
454
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
455
|
+
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
456
|
+
await reactorClient.execute(driveId, "main", [updateNode({
|
|
457
|
+
id: nodeId,
|
|
458
|
+
name
|
|
459
|
+
})]);
|
|
460
|
+
return (await reactorClient.get(driveId)).state.global.nodes.find((n) => n.id === nodeId);
|
|
461
|
+
}
|
|
462
|
+
async function moveNodeById(args) {
|
|
463
|
+
const { driveId, srcId, targetId } = args;
|
|
464
|
+
if (!driveId || !srcId) return;
|
|
465
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
466
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
467
|
+
const reactorClient = window.ph?.reactorClient;
|
|
468
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
469
|
+
const targetParentFolder = conditional(targetId, [isNot(isDefined), constant(void 0)], [isStrictEqual(driveId), constant(void 0)], constant(targetId));
|
|
470
|
+
if (isStrictEqual(targetParentFolder, srcId)) return;
|
|
471
|
+
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
472
|
+
srcFolder: srcId,
|
|
473
|
+
targetParentFolder
|
|
474
|
+
})]);
|
|
475
|
+
}
|
|
476
|
+
async function moveNode$1(driveId, src, target) {
|
|
477
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
478
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
479
|
+
const reactorClient = window.ph?.reactorClient;
|
|
480
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
481
|
+
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
482
|
+
srcFolder: src.id,
|
|
483
|
+
targetParentFolder: target?.id
|
|
484
|
+
})]);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Duplicates a document under a new id using version-aware replay.
|
|
488
|
+
* Falls back gracefully when no upgrade manifest is registered for the document type.
|
|
489
|
+
*/
|
|
490
|
+
async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
491
|
+
const documentType = document.header.documentType;
|
|
492
|
+
const { results: allModules } = await reactor.getDocumentModelModules();
|
|
493
|
+
const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
|
|
494
|
+
const reducers = {};
|
|
495
|
+
for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
|
|
496
|
+
if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
|
|
497
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
498
|
+
let upgradeManifest;
|
|
499
|
+
if (registry) try {
|
|
500
|
+
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
501
|
+
} catch {}
|
|
502
|
+
const config = {
|
|
503
|
+
reducers,
|
|
504
|
+
upgradeManifest
|
|
505
|
+
};
|
|
506
|
+
const header = createPresignedHeader(newId, documentType);
|
|
507
|
+
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
508
|
+
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
509
|
+
return duplicated;
|
|
510
|
+
}
|
|
511
|
+
async function copyNode$1(driveId, src, target) {
|
|
512
|
+
const reactor = window.ph?.reactorClientModule?.client;
|
|
513
|
+
if (!reactor) return;
|
|
514
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
515
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
516
|
+
const drive = await reactor.get(driveId);
|
|
517
|
+
const copyNodesInput = generateNodesCopy({
|
|
518
|
+
srcId: src.id,
|
|
519
|
+
targetParentFolder: target?.id,
|
|
520
|
+
targetName: src.name
|
|
521
|
+
}, () => generateId(), drive.state.global.nodes);
|
|
522
|
+
const resolvedNamesMap = /* @__PURE__ */ new Map();
|
|
523
|
+
for (const copyNodeInput of copyNodesInput) {
|
|
524
|
+
const node = drive.state.global.nodes.find((n) => n.id === copyNodeInput.srcId);
|
|
525
|
+
if (node) {
|
|
526
|
+
const resolvedName = handleTargetNameCollisions({
|
|
527
|
+
nodes: drive.state.global.nodes,
|
|
528
|
+
srcName: copyNodeInput.targetName || node.name,
|
|
529
|
+
srcKind: isFileNode(node) ? "file" : "folder",
|
|
530
|
+
targetParentFolder: copyNodeInput.targetParentFolder || null
|
|
531
|
+
});
|
|
532
|
+
resolvedNamesMap.set(copyNodeInput.targetId, resolvedName);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const fileNodesToCopy = copyNodesInput.filter((copyNodeInput) => {
|
|
536
|
+
const node = drive.state.global.nodes.find((node) => node.id === copyNodeInput.srcId);
|
|
537
|
+
return node !== void 0 && isFileNode(node);
|
|
538
|
+
});
|
|
539
|
+
for (const fileNodeToCopy of fileNodesToCopy) try {
|
|
540
|
+
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
|
|
541
|
+
const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
|
|
542
|
+
if (resolvedName) duplicatedDocument.header.name = resolvedName;
|
|
543
|
+
await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
|
|
544
|
+
} catch (e) {
|
|
545
|
+
logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
|
|
546
|
+
}
|
|
547
|
+
return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/hooks/modals.ts
|
|
551
|
+
const modalEventFunctions = makePHEventFunctions("modal");
|
|
552
|
+
/** Returns the current modal */
|
|
553
|
+
const usePHModal = modalEventFunctions.useValue;
|
|
554
|
+
/** Sets the current modal */
|
|
555
|
+
const setPHModal = modalEventFunctions.setValue;
|
|
556
|
+
/** Adds an event handler for the modal */
|
|
557
|
+
const addModalEventHandler = modalEventFunctions.addEventHandler;
|
|
558
|
+
/** Shows a modal */
|
|
559
|
+
function showPHModal(modal) {
|
|
560
|
+
setPHModal(modal);
|
|
561
|
+
}
|
|
562
|
+
/** Closes the current modal */
|
|
563
|
+
function closePHModal() {
|
|
564
|
+
setPHModal(void 0);
|
|
565
|
+
}
|
|
566
|
+
/** Shows the create document modal */
|
|
567
|
+
function showCreateDocumentModal(documentType) {
|
|
568
|
+
setPHModal({
|
|
569
|
+
type: "createDocument",
|
|
570
|
+
documentType
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
/** Shows the delete node modal */
|
|
574
|
+
function showDeleteNodeModal(nodeOrId) {
|
|
575
|
+
setPHModal({
|
|
576
|
+
type: "deleteItem",
|
|
577
|
+
id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/remote-controller/utils.ts
|
|
582
|
+
/** Convert SCREAMING_SNAKE_CASE to camelCase (e.g. "SET_MODEL_NAME" → "setModelName"). */
|
|
583
|
+
function screamingSnakeToCamel(s) {
|
|
584
|
+
return s.toLowerCase().replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
585
|
+
}
|
|
586
|
+
/** Error thrown when a push conflict is detected with the "reject" strategy. */
|
|
587
|
+
var ConflictError = class extends Error {
|
|
588
|
+
constructor(conflict) {
|
|
589
|
+
super("Push conflict: remote has new operations since last pull");
|
|
590
|
+
this.conflict = conflict;
|
|
591
|
+
this.name = "ConflictError";
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
/** Convert a remote operation to the local Operation type. */
|
|
595
|
+
function remoteOperationToLocal(remote) {
|
|
596
|
+
return {
|
|
597
|
+
id: remote.id ?? "",
|
|
598
|
+
index: remote.index,
|
|
599
|
+
skip: remote.skip,
|
|
600
|
+
timestampUtcMs: remote.timestampUtcMs,
|
|
601
|
+
hash: remote.hash,
|
|
602
|
+
error: remote.error ?? void 0,
|
|
603
|
+
deniedReason: remote.deniedReason ?? void 0,
|
|
604
|
+
action: {
|
|
605
|
+
id: remote.action.id,
|
|
606
|
+
type: remote.action.type,
|
|
607
|
+
timestampUtcMs: remote.action.timestampUtcMs,
|
|
608
|
+
input: remote.action.input,
|
|
609
|
+
scope: remote.action.scope,
|
|
610
|
+
context: remote.action.context?.signer ? { signer: {
|
|
611
|
+
user: remote.action.context.signer.user ?? {
|
|
612
|
+
address: "",
|
|
613
|
+
networkId: "",
|
|
614
|
+
chainId: 0
|
|
615
|
+
},
|
|
616
|
+
app: remote.action.context.signer.app ?? {
|
|
617
|
+
name: "",
|
|
618
|
+
key: ""
|
|
619
|
+
},
|
|
620
|
+
signatures: remote.action.context.signer.signatures.map((s) => deserializeSignature(s))
|
|
621
|
+
} } : void 0
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Deserialize a signature string back to a 5-element tuple.
|
|
627
|
+
* The server serializes tuples via `tuple.join(", ")`.
|
|
628
|
+
*/
|
|
629
|
+
function deserializeSignature(s) {
|
|
630
|
+
const parts = s.split(", ");
|
|
631
|
+
return [
|
|
632
|
+
parts[0] ?? "",
|
|
633
|
+
parts[1] ?? "",
|
|
634
|
+
parts[2] ?? "",
|
|
635
|
+
parts[3] ?? "",
|
|
636
|
+
parts[4] ?? ""
|
|
637
|
+
];
|
|
638
|
+
}
|
|
639
|
+
/** Convert remote operations to local DocumentOperations format. */
|
|
640
|
+
function convertRemoteOperations(operationsByScope) {
|
|
641
|
+
const operations = {};
|
|
642
|
+
for (const [scope, remoteOps] of Object.entries(operationsByScope)) operations[scope] = remoteOps.map((op) => remoteOperationToLocal(op));
|
|
643
|
+
return operations;
|
|
644
|
+
}
|
|
645
|
+
/** Reconstruct a PHDocument from remote document data and operations. */
|
|
646
|
+
function buildPulledDocument(remoteDoc, operations, initialDoc, branch) {
|
|
647
|
+
return {
|
|
648
|
+
header: {
|
|
649
|
+
...initialDoc.header,
|
|
650
|
+
id: remoteDoc.id,
|
|
651
|
+
name: remoteDoc.name,
|
|
652
|
+
slug: remoteDoc.slug ?? "",
|
|
653
|
+
documentType: remoteDoc.documentType,
|
|
654
|
+
createdAtUtcIso: typeof remoteDoc.createdAtUtcIso === "string" ? remoteDoc.createdAtUtcIso : remoteDoc.createdAtUtcIso.toISOString(),
|
|
655
|
+
lastModifiedAtUtcIso: typeof remoteDoc.lastModifiedAtUtcIso === "string" ? remoteDoc.lastModifiedAtUtcIso : remoteDoc.lastModifiedAtUtcIso.toISOString(),
|
|
656
|
+
revision: Object.fromEntries(remoteDoc.revisionsList.map((r) => [r.scope, r.revision])),
|
|
657
|
+
branch
|
|
658
|
+
},
|
|
659
|
+
state: remoteDoc.state,
|
|
660
|
+
initialState: initialDoc.initialState,
|
|
661
|
+
operations,
|
|
662
|
+
clipboard: []
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
/** Extract revision map from a remote document's revisionsList. */
|
|
666
|
+
function extractRevisionMap(revisionsList) {
|
|
667
|
+
return Object.fromEntries(revisionsList.map((r) => [r.scope, r.revision]));
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Check if any scope in currentRevision is ahead of knownRevision.
|
|
671
|
+
* When `scopes` is provided, only those scopes are checked.
|
|
672
|
+
*/
|
|
673
|
+
function hasRevisionConflict(currentRevision, knownRevision, scopes) {
|
|
674
|
+
for (const scope in currentRevision) {
|
|
675
|
+
if (scopes && !scopes.has(scope)) continue;
|
|
676
|
+
if ((currentRevision[scope] ?? 0) > (knownRevision[scope] ?? 0)) return true;
|
|
677
|
+
}
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/graphql-client/adapter.ts
|
|
682
|
+
/**
|
|
683
|
+
* Converts a `GetDocument` result into a `PHDocument`.
|
|
684
|
+
*
|
|
685
|
+
* Unlike the legacy `src/graphql/adapters.ts` this preserves the per-scope
|
|
686
|
+
* revision map, which the write path needs to compute the `prevOpIndex` of a
|
|
687
|
+
* signed action. `sig` is filled with the empty shape used by
|
|
688
|
+
* `createPresignedHeader`: the creation signature is not fetchable over
|
|
689
|
+
* GraphQL and is not part of the operation signing payload.
|
|
690
|
+
*
|
|
691
|
+
* The read path never fetches operation history, so `operations` is a map of
|
|
692
|
+
* the document's known scopes to empty arrays.
|
|
693
|
+
*
|
|
694
|
+
* `branch` is the branch the document was read from. The GraphQL type does not
|
|
695
|
+
* carry it, so it has to be passed back in by the caller; it defaults to the
|
|
696
|
+
* server's own default branch.
|
|
697
|
+
*/
|
|
698
|
+
function phDocumentFromGetDocument(document, branch) {
|
|
699
|
+
const state = document.state;
|
|
700
|
+
return {
|
|
701
|
+
header: phDocumentHeaderFromGetDocument(document, branch),
|
|
702
|
+
state,
|
|
703
|
+
initialState: state,
|
|
704
|
+
operations: emptyOperationsForScopes(document.revisionsList),
|
|
705
|
+
clipboard: []
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Converts a mutation result into a `PHDocument`, carrying the operations the
|
|
710
|
+
* mutation produced.
|
|
711
|
+
*
|
|
712
|
+
* `dispatchActions` reads per-action failures out of `operations[scope]`, so
|
|
713
|
+
* unlike the read path this one must not return empty operation lists.
|
|
714
|
+
*/
|
|
715
|
+
function phDocumentFromMutation(document, operations, branch) {
|
|
716
|
+
const phDocument = phDocumentFromGetDocument(document, branch);
|
|
717
|
+
const operationsByScope = { ...phDocument.operations };
|
|
718
|
+
for (const remote of operations) {
|
|
719
|
+
const operation = remoteOperationToLocal(remote);
|
|
720
|
+
const scope = operation.action.scope;
|
|
721
|
+
const scopeOperations = operationsByScope[scope] ?? [];
|
|
722
|
+
scopeOperations.push(operation);
|
|
723
|
+
operationsByScope[scope] = scopeOperations;
|
|
724
|
+
}
|
|
725
|
+
phDocument.operations = operationsByScope;
|
|
726
|
+
return phDocument;
|
|
727
|
+
}
|
|
728
|
+
/** Turns a `revisionsList` selection into the header's per-scope revision map. */
|
|
729
|
+
function revisionMapFromRevisionsList(revisionsList) {
|
|
730
|
+
return Object.fromEntries(revisionsList.map((r) => [r.scope, r.revision]));
|
|
731
|
+
}
|
|
732
|
+
/** The branch the server reads and writes when none is asked for. */
|
|
733
|
+
const defaultBranch = "main";
|
|
734
|
+
function phDocumentHeaderFromGetDocument(document, branch) {
|
|
735
|
+
return {
|
|
736
|
+
id: document.id,
|
|
737
|
+
sig: {
|
|
738
|
+
publicKey: {},
|
|
739
|
+
nonce: ""
|
|
740
|
+
},
|
|
741
|
+
documentType: document.documentType,
|
|
742
|
+
createdAtUtcIso: isoStringFromDateTime(document.createdAtUtcIso),
|
|
743
|
+
slug: document.slug ?? "",
|
|
744
|
+
name: document.name,
|
|
745
|
+
branch: branch ?? defaultBranch,
|
|
746
|
+
revision: revisionMapFromRevisionsList(document.revisionsList),
|
|
747
|
+
lastModifiedAtUtcIso: isoStringFromDateTime(document.lastModifiedAtUtcIso)
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
function emptyOperationsForScopes(revisionsList) {
|
|
751
|
+
return Object.fromEntries(revisionsList.map((r) => [r.scope, []]));
|
|
752
|
+
}
|
|
753
|
+
/** The `DateTime` scalar deserializes as either an ISO string or a `Date`. */
|
|
754
|
+
function isoStringFromDateTime(value) {
|
|
755
|
+
return value instanceof Date ? value.toISOString() : value;
|
|
756
|
+
}
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region src/graphql-client/auth.ts
|
|
759
|
+
/** Lifetime requested for an ambient Renown token, in seconds. */
|
|
760
|
+
const ambientTokenExpiresInSeconds = 600;
|
|
761
|
+
/**
|
|
762
|
+
* The default token provider: the token of the currently logged-in Renown user.
|
|
763
|
+
*
|
|
764
|
+
* It is deliberately resolved from `window.ph` on every call rather than
|
|
765
|
+
* captured at construction time, so a client built before login starts sending
|
|
766
|
+
* the token as soon as there is one.
|
|
767
|
+
*
|
|
768
|
+
* The token is requested WITHOUT an `aud` claim - the Switchboard verifier
|
|
769
|
+
* rejects tokens that carry an audience.
|
|
770
|
+
*/
|
|
771
|
+
async function ambientRenownTokenProvider() {
|
|
772
|
+
if (typeof window === "undefined") return;
|
|
773
|
+
const renown = window.ph?.renown;
|
|
774
|
+
if (!renown?.user) return;
|
|
775
|
+
return renown.getBearerToken({ expiresIn: ambientTokenExpiresInSeconds });
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Builds the SDK middleware that authenticates every request.
|
|
779
|
+
*
|
|
780
|
+
* The token is resolved per request and never cached, so a login, a logout or
|
|
781
|
+
* an expiry between two calls is picked up by the next one. When no token is
|
|
782
|
+
* available the request goes out unauthenticated.
|
|
783
|
+
*/
|
|
784
|
+
function makeAuthMiddleware(tokenProvider) {
|
|
785
|
+
return async (action) => {
|
|
786
|
+
const token = await tokenProvider();
|
|
787
|
+
if (!token) return action();
|
|
788
|
+
return action({ authorization: `Bearer ${token}` });
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/graphql-client/operations.ts
|
|
793
|
+
/**
|
|
794
|
+
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
795
|
+
* the write path can reuse `remoteOperationToLocal` on the items it selects.
|
|
796
|
+
*/
|
|
797
|
+
const ReactorOperationFieldsFragmentDoc = gql`
|
|
798
|
+
fragment ReactorOperationFields on ReactorOperation {
|
|
799
|
+
index
|
|
800
|
+
timestampUtcMs
|
|
801
|
+
hash
|
|
802
|
+
skip
|
|
803
|
+
error
|
|
804
|
+
deniedReason
|
|
805
|
+
id
|
|
806
|
+
action {
|
|
807
|
+
id
|
|
808
|
+
type
|
|
809
|
+
timestampUtcMs
|
|
810
|
+
input
|
|
811
|
+
scope
|
|
812
|
+
context {
|
|
813
|
+
signer {
|
|
814
|
+
user {
|
|
815
|
+
address
|
|
816
|
+
networkId
|
|
817
|
+
chainId
|
|
818
|
+
}
|
|
819
|
+
app {
|
|
820
|
+
name
|
|
821
|
+
key
|
|
822
|
+
}
|
|
823
|
+
signatures
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
`;
|
|
829
|
+
/**
|
|
830
|
+
* `mutateDocument` plus the operations the mutation produced.
|
|
831
|
+
*
|
|
832
|
+
* The generated `MutateDocument` only selects the document fields, but
|
|
833
|
+
* `dispatchActions` reads per-action failures out of `result.operations[scope]`
|
|
834
|
+
* (`src/actions/dispatch.ts`), so the reducer-level errors would be lost.
|
|
835
|
+
*
|
|
836
|
+
* The operations filter keeps the extra selection to the operations this call
|
|
837
|
+
* could have appended rather than the whole history. All three of its fields
|
|
838
|
+
* matter:
|
|
839
|
+
* - `sinceRevision` is the lowest head revision across the targeted scopes, so
|
|
840
|
+
* it is only a safe window when the selection is scope-limited as well;
|
|
841
|
+
* - `scopes` limits the response to the scopes the pushed actions target,
|
|
842
|
+
* without it the server walks every scope of the document
|
|
843
|
+
* (`packages/reactor/src/core/reactor.ts` `getOperations`);
|
|
844
|
+
* - `branch` must match the branch the mutation writes to, otherwise the
|
|
845
|
+
* operations come from `main` (the server's default) while the actions were
|
|
846
|
+
* applied elsewhere.
|
|
847
|
+
*/
|
|
848
|
+
const MutateDocumentWithOperationsDocument = gql`
|
|
849
|
+
mutation MutateDocumentWithOperations(
|
|
850
|
+
$documentIdentifier: String!
|
|
851
|
+
$actions: [JSONObject!]!
|
|
852
|
+
$view: ViewFilterInput
|
|
853
|
+
$sinceRevision: Int
|
|
854
|
+
$scopes: [String!]
|
|
855
|
+
$branch: String
|
|
856
|
+
) {
|
|
857
|
+
mutateDocument(
|
|
858
|
+
documentIdentifier: $documentIdentifier
|
|
859
|
+
actions: $actions
|
|
860
|
+
view: $view
|
|
861
|
+
) {
|
|
862
|
+
...PHDocumentFields
|
|
863
|
+
operations(
|
|
864
|
+
filter: {
|
|
865
|
+
sinceRevision: $sinceRevision
|
|
866
|
+
scopes: $scopes
|
|
867
|
+
branch: $branch
|
|
868
|
+
}
|
|
869
|
+
) {
|
|
870
|
+
items {
|
|
871
|
+
...ReactorOperationFields
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
${PhDocumentFieldsFragmentDoc}
|
|
877
|
+
${ReactorOperationFieldsFragmentDoc}
|
|
878
|
+
`;
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/graphql-client/signing.ts
|
|
881
|
+
/**
|
|
882
|
+
* Stamps an action with the head of the scope it targets.
|
|
883
|
+
*
|
|
884
|
+
* `prevOpHash` is the hash of the scope state the action is meant to apply to;
|
|
885
|
+
* for a document at head that is the hash of the last operation in the scope,
|
|
886
|
+
* which the read path cannot fetch, so it is recomputed from the state.
|
|
887
|
+
* `prevOpIndex` is the index of that last operation: revisions count
|
|
888
|
+
* operations and indices are zero based, so an empty scope stamps `-1`, which
|
|
889
|
+
* matches what the remote controller records.
|
|
890
|
+
*/
|
|
891
|
+
function stampAction(action, document) {
|
|
892
|
+
const revision = document.header.revision[action.scope] ?? 0;
|
|
893
|
+
return {
|
|
894
|
+
...action,
|
|
895
|
+
context: {
|
|
896
|
+
...action.context,
|
|
897
|
+
prevOpHash: hashDocumentStateForScope(document, action.scope),
|
|
898
|
+
prevOpIndex: revision - 1
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Signs a stamped action, preserving any signatures it already carries.
|
|
904
|
+
*
|
|
905
|
+
* The signer reads `context.prevOpHash` off the action, so this must run after
|
|
906
|
+
* {@link stampAction}.
|
|
907
|
+
*/
|
|
908
|
+
async function signStampedAction(action, signer) {
|
|
909
|
+
const actionSigner = action.context?.signer;
|
|
910
|
+
const user = actionSigner?.user ?? signer.user;
|
|
911
|
+
const app = actionSigner?.app ?? signer.app;
|
|
912
|
+
if (!user || !app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
913
|
+
const signature = await signer.signAction(action);
|
|
914
|
+
return {
|
|
915
|
+
...action,
|
|
916
|
+
context: {
|
|
917
|
+
...action.context,
|
|
918
|
+
signer: {
|
|
919
|
+
user,
|
|
920
|
+
app,
|
|
921
|
+
signatures: [...actionSigner?.signatures ?? [], signature]
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
//#endregion
|
|
927
|
+
//#region src/graphql-client/subgraph.ts
|
|
928
|
+
/** What {@link describeGraphQLDocument} could not read off a document. */
|
|
929
|
+
const unnamedOperation = "AnonymousOperation";
|
|
930
|
+
const defaultOperationType = "query";
|
|
931
|
+
/**
|
|
932
|
+
* Derives a subgraph's endpoint from the Switchboard's GraphQL endpoint.
|
|
933
|
+
*
|
|
934
|
+
* Subgraphs are served next to the supergraph, at `<graphql base>/<name>`, so
|
|
935
|
+
* `http://localhost:4001/graphql` plus `statements` is
|
|
936
|
+
* `http://localhost:4001/graphql/statements`.
|
|
937
|
+
*/
|
|
938
|
+
function subgraphUrlFromGraphqlUrl(url, name) {
|
|
939
|
+
const trimmed = name.trim();
|
|
940
|
+
if (trimmed === "") throw new Error("a subgraph name is required");
|
|
941
|
+
return `${url.replace(/\/+$/, "")}/${trimmed}`;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Reads the operation name and type off a document, for the middleware.
|
|
945
|
+
*
|
|
946
|
+
* Nothing depends on getting this right - it is reported to the middleware, not
|
|
947
|
+
* sent to the server - so an unreadable document falls back to an anonymous
|
|
948
|
+
* query rather than throwing.
|
|
949
|
+
*/
|
|
950
|
+
function describeGraphQLDocument(document) {
|
|
951
|
+
if (typeof document !== "string") {
|
|
952
|
+
const operation = document.definitions.find((definition) => definition.kind === Kind.OPERATION_DEFINITION);
|
|
953
|
+
if (!operation || operation.kind !== Kind.OPERATION_DEFINITION) return {
|
|
954
|
+
operationName: unnamedOperation,
|
|
955
|
+
operationType: defaultOperationType
|
|
956
|
+
};
|
|
957
|
+
return {
|
|
958
|
+
operationName: operation.name?.value ?? unnamedOperation,
|
|
959
|
+
operationType: operation.operation
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
const match = /\b(query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]*)/.exec(document);
|
|
963
|
+
if (!match) return {
|
|
964
|
+
operationName: unnamedOperation,
|
|
965
|
+
operationType: /\bmutation\b/.test(document) ? "mutation" : defaultOperationType
|
|
966
|
+
};
|
|
967
|
+
return {
|
|
968
|
+
operationName: match[2],
|
|
969
|
+
operationType: match[1]
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Binds typed subgraph SDKs to one Switchboard's transport and auth.
|
|
974
|
+
*
|
|
975
|
+
* Every capability a Switchboard exposes lives behind the same base URL, so an
|
|
976
|
+
* app should not have to build a second client - with a second copy of the auth
|
|
977
|
+
* configuration - to reach a project's own subgraph. The registry derives the
|
|
978
|
+
* endpoint, reuses one transport per subgraph and hands the code generator's
|
|
979
|
+
* `getSdk` the very middleware the reactor operations already go through.
|
|
980
|
+
*
|
|
981
|
+
* Transport and typing only: subgraph results are not cached and produce no
|
|
982
|
+
* change events.
|
|
983
|
+
*/
|
|
984
|
+
var SubgraphSdkRegistry = class {
|
|
985
|
+
url;
|
|
986
|
+
middleware;
|
|
987
|
+
bindings = /* @__PURE__ */ new Map();
|
|
988
|
+
constructor(url, middleware) {
|
|
989
|
+
this.url = url;
|
|
990
|
+
this.middleware = middleware;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Returns the subgraph's SDK, building it on first use.
|
|
994
|
+
*
|
|
995
|
+
* The transport is kept per subgraph name, so repeated calls do not rebuild
|
|
996
|
+
* it. The SDK itself is only reused when the same factory is passed again -
|
|
997
|
+
* two different generated SDKs over one subgraph each get their own, rather
|
|
998
|
+
* than the second call being handed the first one's methods.
|
|
999
|
+
*/
|
|
1000
|
+
get(name, getSdk) {
|
|
1001
|
+
const binding = this.binding(name);
|
|
1002
|
+
if (binding.factory === getSdk) return binding.sdk;
|
|
1003
|
+
const sdk = getSdk(binding.transport, this.middleware);
|
|
1004
|
+
binding.factory = getSdk;
|
|
1005
|
+
binding.sdk = sdk;
|
|
1006
|
+
return sdk;
|
|
1007
|
+
}
|
|
1008
|
+
/** Returns the subgraph's endpoint, for diagnostics and tests. */
|
|
1009
|
+
urlFor(name) {
|
|
1010
|
+
return subgraphUrlFromGraphqlUrl(this.url, name);
|
|
1011
|
+
}
|
|
1012
|
+
binding(name) {
|
|
1013
|
+
const existing = this.bindings.get(name);
|
|
1014
|
+
if (existing) return existing;
|
|
1015
|
+
const binding = { transport: new GraphQLClient(this.urlFor(name)) };
|
|
1016
|
+
this.bindings.set(name, binding);
|
|
1017
|
+
return binding;
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/graphql-client/subscriptions.ts
|
|
1022
|
+
/**
|
|
1023
|
+
* Opens one `documentChanges` subscription and feeds every event to `onEvent`.
|
|
1024
|
+
*
|
|
1025
|
+
* The subscription is a firehose: no `search` argument, so the server sends
|
|
1026
|
+
* every change the connection is allowed to see and the caller filters. This is
|
|
1027
|
+
* the only module that knows about `graphql-ws`.
|
|
1028
|
+
*
|
|
1029
|
+
* Returns the stop function, which cancels the subscription and closes the
|
|
1030
|
+
* socket. It is safe to call more than once.
|
|
1031
|
+
*/
|
|
1032
|
+
function startDocumentChangesSubscription(options) {
|
|
1033
|
+
const client = createClient({
|
|
1034
|
+
url: options.wsUrl,
|
|
1035
|
+
connectionParams: options.connectionParams
|
|
1036
|
+
});
|
|
1037
|
+
const unsubscribe = client.subscribe({
|
|
1038
|
+
operationName: "DocumentChanges",
|
|
1039
|
+
query: print(DocumentChangesDocument)
|
|
1040
|
+
}, {
|
|
1041
|
+
next: (result) => {
|
|
1042
|
+
const event = result.data?.documentChanges;
|
|
1043
|
+
if (event) options.onEvent(event);
|
|
1044
|
+
},
|
|
1045
|
+
error: (error) => options.onError(error),
|
|
1046
|
+
complete: () => void 0
|
|
1047
|
+
});
|
|
1048
|
+
let stopped = false;
|
|
1049
|
+
return () => {
|
|
1050
|
+
if (stopped) return;
|
|
1051
|
+
stopped = true;
|
|
1052
|
+
unsubscribe();
|
|
1053
|
+
client.dispose();
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Derives the websocket endpoint from the GraphQL http endpoint.
|
|
1058
|
+
*
|
|
1059
|
+
* `http://host/graphql` becomes `ws://host/graphql/subscriptions`, which is
|
|
1060
|
+
* where the Switchboard mounts its websocket server (`packages/reactor-api`
|
|
1061
|
+
* `startServer`). A URL that already speaks `ws`/`wss` only gets the path.
|
|
1062
|
+
*/
|
|
1063
|
+
function subscriptionsUrlFromGraphqlUrl(url) {
|
|
1064
|
+
const trimmed = url.replace(/\/+$/, "");
|
|
1065
|
+
return `${trimmed.startsWith("https://") ? `wss://${trimmed.slice(8)}` : trimmed.startsWith("http://") ? `ws://${trimmed.slice(7)}` : trimmed}/subscriptions`;
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Turns a bearer token provider into `connectionParams`.
|
|
1069
|
+
*
|
|
1070
|
+
* The header key is the lowercase `authorization` the Switchboard's websocket
|
|
1071
|
+
* context factory reads. Without a token the payload is empty: an open
|
|
1072
|
+
* Switchboard serves anonymous subscribers.
|
|
1073
|
+
*/
|
|
1074
|
+
function makeAuthConnectionParams(tokenProvider) {
|
|
1075
|
+
return async () => {
|
|
1076
|
+
const token = await tokenProvider();
|
|
1077
|
+
if (!token) return {};
|
|
1078
|
+
return { authorization: `Bearer ${token}` };
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region src/graphql-client/graphql-reactor-client.ts
|
|
1083
|
+
/** Paging defaults, matching the reactor's own client. */
|
|
1084
|
+
const defaultPaging = {
|
|
1085
|
+
cursor: "0",
|
|
1086
|
+
limit: 100
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* The marker {@link isGraphQLReactorClient} looks for.
|
|
1090
|
+
*
|
|
1091
|
+
* A page can end up with two copies of this module - an app that bundles a
|
|
1092
|
+
* package carrying its own copy, or a dev server that hot-replaced it - and
|
|
1093
|
+
* then `instanceof` compares an instance against the other copy's class object
|
|
1094
|
+
* and answers `false`. A branded property survives both.
|
|
1095
|
+
*/
|
|
1096
|
+
const graphQLReactorClientBrand = "__powerhouseGraphQLReactorClient";
|
|
1097
|
+
/**
|
|
1098
|
+
* A light implementation of {@link IReactorBrowserClient} that talks plain
|
|
1099
|
+
* GraphQL to a Switchboard, with no reactor in the bundle.
|
|
1100
|
+
*
|
|
1101
|
+
* It fills the same `window.ph` slots the full in-browser reactor client fills,
|
|
1102
|
+
* so the reactor-browser hooks cannot tell the two apart.
|
|
1103
|
+
*/
|
|
1104
|
+
var GraphQLReactorClient = class {
|
|
1105
|
+
/** See {@link isGraphQLReactorClient}. */
|
|
1106
|
+
[graphQLReactorClientBrand] = true;
|
|
1107
|
+
sdk;
|
|
1108
|
+
subgraphs;
|
|
1109
|
+
listeners = [];
|
|
1110
|
+
tokenProvider;
|
|
1111
|
+
subscriptionsUrl;
|
|
1112
|
+
stopRealtime;
|
|
1113
|
+
realtimeStarted = false;
|
|
1114
|
+
realtimeGeneration = 0;
|
|
1115
|
+
realtimeErrorLogged = false;
|
|
1116
|
+
constructor(options) {
|
|
1117
|
+
this.tokenProvider = options.tokenProvider ?? ambientRenownTokenProvider;
|
|
1118
|
+
this.subscriptionsUrl = options.realtime === false ? void 0 : options.subscriptionsUrl ?? subscriptionsUrlFromGraphqlUrl(options.url);
|
|
1119
|
+
const middleware = makeAuthMiddleware(this.tokenProvider);
|
|
1120
|
+
this.sdk = options.graphqlClient ?? createClient$1(options.url, middleware);
|
|
1121
|
+
this.subgraphs = new SubgraphSdkRegistry(options.url, middleware);
|
|
1122
|
+
}
|
|
1123
|
+
async get(identifier, view, signal) {
|
|
1124
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1125
|
+
const document = (await this.sdk.GetDocument({
|
|
1126
|
+
identifier,
|
|
1127
|
+
view: viewInput
|
|
1128
|
+
}, void 0, signal)).document;
|
|
1129
|
+
if (!document) throw new Error(`Document not found: ${identifier}`);
|
|
1130
|
+
return phDocumentFromGetDocument(document.document, view?.branch);
|
|
1131
|
+
}
|
|
1132
|
+
async getOperations(documentIdentifier, view, filter, paging, signal) {
|
|
1133
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1134
|
+
const operationsFilter = {
|
|
1135
|
+
documentId: documentIdentifier,
|
|
1136
|
+
branch: viewInput?.branch,
|
|
1137
|
+
scopes: viewInput?.scopes,
|
|
1138
|
+
actionTypes: filter?.actionTypes,
|
|
1139
|
+
timestampFrom: filter?.timestampFrom,
|
|
1140
|
+
timestampTo: filter?.timestampTo,
|
|
1141
|
+
sinceRevision: filter?.sinceRevision
|
|
1142
|
+
};
|
|
1143
|
+
const page = (await this.sdk.GetDocumentOperations({
|
|
1144
|
+
filter: operationsFilter,
|
|
1145
|
+
paging: pagingInputFromPaging(paging)
|
|
1146
|
+
}, void 0, signal)).documentOperations;
|
|
1147
|
+
const nextCursor = page.hasNextPage ? page.cursor ?? void 0 : void 0;
|
|
1148
|
+
const effectivePaging = paging ?? defaultPaging;
|
|
1149
|
+
return {
|
|
1150
|
+
results: page.items.map((item) => remoteOperationToLocal(item)),
|
|
1151
|
+
options: effectivePaging,
|
|
1152
|
+
nextCursor,
|
|
1153
|
+
totalCount: page.totalCount,
|
|
1154
|
+
next: nextCursor ? () => this.getOperations(documentIdentifier, view, filter, {
|
|
1155
|
+
cursor: nextCursor,
|
|
1156
|
+
limit: effectivePaging.limit
|
|
1157
|
+
}, signal) : void 0
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
async create(document, parentIdentifier, signal) {
|
|
1161
|
+
const created = phDocumentFromGetDocument((await this.sdk.CreateDocument({
|
|
1162
|
+
document,
|
|
1163
|
+
parentIdentifier
|
|
1164
|
+
}, void 0, signal)).createDocument);
|
|
1165
|
+
this.emitChange({
|
|
1166
|
+
type: DOCUMENT_CHANGE_TYPE.Created,
|
|
1167
|
+
documents: [created]
|
|
1168
|
+
});
|
|
1169
|
+
return created;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Pushes actions to the Switchboard and returns the updated document.
|
|
1173
|
+
*
|
|
1174
|
+
* The document is fetched first: the response is the baseline for the
|
|
1175
|
+
* `sinceRevision` filter that narrows the returned operations to the ones
|
|
1176
|
+
* this call appended, and it carries the state hash a signed action is
|
|
1177
|
+
* stamped with.
|
|
1178
|
+
*
|
|
1179
|
+
* The emitted `Updated` event carries the document's id, never the
|
|
1180
|
+
* identifier this was called with: subscribers - including `DocumentCache` -
|
|
1181
|
+
* work in id space.
|
|
1182
|
+
*/
|
|
1183
|
+
async execute(documentIdentifier, branch, actions, signal) {
|
|
1184
|
+
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
1185
|
+
const variables = {
|
|
1186
|
+
documentIdentifier,
|
|
1187
|
+
actions: await prepareActionsForPush(actions, document),
|
|
1188
|
+
view: { branch },
|
|
1189
|
+
sinceRevision: sinceRevisionForActions(document, actions),
|
|
1190
|
+
scopes: scopesForActions(actions),
|
|
1191
|
+
branch
|
|
1192
|
+
};
|
|
1193
|
+
const mutated = (await this.sdk.RunDocument({
|
|
1194
|
+
operationName: "MutateDocumentWithOperations",
|
|
1195
|
+
operationType: "mutation",
|
|
1196
|
+
document: MutateDocumentWithOperationsDocument,
|
|
1197
|
+
variables,
|
|
1198
|
+
signal
|
|
1199
|
+
})).mutateDocument;
|
|
1200
|
+
const updated = phDocumentFromMutation(mutated, mutated.operations?.items ?? [], branch);
|
|
1201
|
+
this.emitChange({
|
|
1202
|
+
type: DOCUMENT_CHANGE_TYPE.Updated,
|
|
1203
|
+
documents: [updated]
|
|
1204
|
+
});
|
|
1205
|
+
return updated;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Deletes a document and announces it as a `Deleted` event.
|
|
1209
|
+
*
|
|
1210
|
+
* Pass a document id. The server resolves a slug just as happily, but
|
|
1211
|
+
* `deleteDocument` returns a boolean - there is no document left to read an
|
|
1212
|
+
* id off - so the identifier is announced verbatim on `context.childId`. A
|
|
1213
|
+
* subscriber keyed by id, `DocumentCache` included, therefore only reacts to
|
|
1214
|
+
* a delete by id.
|
|
1215
|
+
*/
|
|
1216
|
+
async deleteDocument(identifier, propagate, signal) {
|
|
1217
|
+
await this.sdk.DeleteDocument({
|
|
1218
|
+
identifier,
|
|
1219
|
+
propagate: propagationModeInput(propagate)
|
|
1220
|
+
}, void 0, signal);
|
|
1221
|
+
this.emitChange({
|
|
1222
|
+
type: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1223
|
+
documents: [],
|
|
1224
|
+
context: { childId: identifier }
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Registers a change subscriber and returns its unsubscribe function.
|
|
1229
|
+
*
|
|
1230
|
+
* Two things produce the events delivered here. Every successful `create`,
|
|
1231
|
+
* `execute` and `deleteDocument` emits one, which is what makes a
|
|
1232
|
+
* `DocumentCache` built on this client invalidate after a dispatch. And,
|
|
1233
|
+
* unless realtime is switched off, the first call to this method opens a
|
|
1234
|
+
* websocket to the Switchboard and every change it reports - from another
|
|
1235
|
+
* user, another tab or a server-side processor - is emitted too. A write of
|
|
1236
|
+
* this client's own is therefore announced twice, once locally and once by
|
|
1237
|
+
* the server; the cache refetches twice, which is harmless.
|
|
1238
|
+
*
|
|
1239
|
+
* A websocket that cannot be opened or is refused is logged once and then
|
|
1240
|
+
* ignored: realtime is an enhancement, never a dependency. The failed socket
|
|
1241
|
+
* is closed, so the next subscriber to arrive tries again.
|
|
1242
|
+
*
|
|
1243
|
+
* `view` is accepted for interface compatibility and ignored: the emitted
|
|
1244
|
+
* documents are whatever the write returned, so there is nothing to re-scope.
|
|
1245
|
+
*
|
|
1246
|
+
* Events live in id space: `search.ids` is matched against the resolved
|
|
1247
|
+
* document id, never against the identifier the write was issued with. The
|
|
1248
|
+
* one exception is `deleteDocument`, which has no document to resolve an id
|
|
1249
|
+
* from - see its own note. A `DocumentCache` on this client must therefore
|
|
1250
|
+
* be read by id: a slug-keyed entry is never invalidated.
|
|
1251
|
+
*/
|
|
1252
|
+
subscribe(search, callback, view) {
|
|
1253
|
+
const listener = {
|
|
1254
|
+
search,
|
|
1255
|
+
callback
|
|
1256
|
+
};
|
|
1257
|
+
this.listeners.push(listener);
|
|
1258
|
+
this.startRealtime();
|
|
1259
|
+
return () => {
|
|
1260
|
+
const index = this.listeners.indexOf(listener);
|
|
1261
|
+
if (index !== -1) this.listeners.splice(index, 1);
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Closes the realtime socket, if one was opened.
|
|
1266
|
+
*
|
|
1267
|
+
* Registered subscribers are left in place: they still receive the events
|
|
1268
|
+
* this client produces itself.
|
|
1269
|
+
*
|
|
1270
|
+
* Disposing is NOT final - a later `subscribe` opens a new socket. React
|
|
1271
|
+
* remounts a tree by running an effect's cleanup and then the effect again,
|
|
1272
|
+
* on the same client, and `StrictMode` does exactly that on every mount; a
|
|
1273
|
+
* terminal flag here would leave those pages without realtime for good, with
|
|
1274
|
+
* nothing logged.
|
|
1275
|
+
*/
|
|
1276
|
+
dispose() {
|
|
1277
|
+
this.teardownRealtime();
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Binds a project's generated SDK to this client's transport and auth.
|
|
1281
|
+
*
|
|
1282
|
+
* Subgraphs are served next to the reactor's own supergraph, so the endpoint
|
|
1283
|
+
* is derived from the client's `url` by appending the name, and the SDK is
|
|
1284
|
+
* handed the same auth middleware every reactor call goes through. An app
|
|
1285
|
+
* therefore configures one URL and one token provider, and reaches every
|
|
1286
|
+
* capability of its Switchboard through this one client.
|
|
1287
|
+
*
|
|
1288
|
+
* `getSdk` is the function a GraphQL code generator emits for the subgraph's
|
|
1289
|
+
* schema - see the README in this folder for the codegen recipe.
|
|
1290
|
+
*
|
|
1291
|
+
* Transport and typing only. Subgraph results are not cached, produce no
|
|
1292
|
+
* change events and never reach `useDocument`.
|
|
1293
|
+
*/
|
|
1294
|
+
subgraph(name, getSdk) {
|
|
1295
|
+
return this.subgraphs.get(name, getSdk);
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Runs a one-off GraphQL document against the Switchboard's own endpoint,
|
|
1299
|
+
* through the same transport and auth as everything else.
|
|
1300
|
+
*
|
|
1301
|
+
* The escape hatch for an operation not worth generating an SDK for. Pass a
|
|
1302
|
+
* document a code generator typed and the result type follows; pass a plain
|
|
1303
|
+
* `gql` document or a string and name the result type at the call site.
|
|
1304
|
+
*/
|
|
1305
|
+
async request(document, variables, options) {
|
|
1306
|
+
const described = describeGraphQLDocument(document);
|
|
1307
|
+
return this.sdk.RunDocument({
|
|
1308
|
+
operationName: options?.operationName ?? described.operationName,
|
|
1309
|
+
operationType: options?.operationType ?? described.operationType,
|
|
1310
|
+
document,
|
|
1311
|
+
variables,
|
|
1312
|
+
signal: options?.signal
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Opens the realtime socket on the first subscriber.
|
|
1317
|
+
*
|
|
1318
|
+
* The subscription is a firehose - no `search` argument - and this client
|
|
1319
|
+
* applies each subscriber's own filter on the way out, exactly as it does for
|
|
1320
|
+
* its own emissions.
|
|
1321
|
+
*/
|
|
1322
|
+
startRealtime() {
|
|
1323
|
+
if (!this.subscriptionsUrl || this.realtimeStarted) return;
|
|
1324
|
+
this.realtimeStarted = true;
|
|
1325
|
+
const generation = this.realtimeGeneration;
|
|
1326
|
+
const stop = startDocumentChangesSubscription({
|
|
1327
|
+
wsUrl: this.subscriptionsUrl,
|
|
1328
|
+
connectionParams: makeAuthConnectionParams(this.tokenProvider),
|
|
1329
|
+
onEvent: (event) => this.emitServerEvent(event),
|
|
1330
|
+
onError: (error) => this.handleRealtimeFailure(generation, error)
|
|
1331
|
+
});
|
|
1332
|
+
if (this.realtimeGeneration !== generation) {
|
|
1333
|
+
stop();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
this.stopRealtime = stop;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Gives up on a failed socket so that a later subscriber can try again.
|
|
1340
|
+
*
|
|
1341
|
+
* `graphql-ws` retries on its own and only reports here once it has given up,
|
|
1342
|
+
* or once the server refused the subscription outright - which is what an
|
|
1343
|
+
* auth-enabled Switchboard does to an anonymous subscriber. Keeping the dead
|
|
1344
|
+
* stop function would make every later `subscribe` a no-op, so realtime would
|
|
1345
|
+
* stay off for the life of the page even after the user signs in.
|
|
1346
|
+
*
|
|
1347
|
+
* The generation stamp discards a report from a socket that has already been
|
|
1348
|
+
* replaced or disposed.
|
|
1349
|
+
*/
|
|
1350
|
+
handleRealtimeFailure(generation, error) {
|
|
1351
|
+
if (generation !== this.realtimeGeneration) return;
|
|
1352
|
+
this.teardownRealtime();
|
|
1353
|
+
this.logRealtimeError(error);
|
|
1354
|
+
}
|
|
1355
|
+
/** Closes the socket and lets a later subscriber open a new one. */
|
|
1356
|
+
teardownRealtime() {
|
|
1357
|
+
this.realtimeGeneration += 1;
|
|
1358
|
+
this.realtimeStarted = false;
|
|
1359
|
+
this.stopRealtime?.();
|
|
1360
|
+
this.stopRealtime = void 0;
|
|
1361
|
+
}
|
|
1362
|
+
/** Maps a server event onto the client-side event and emits it. */
|
|
1363
|
+
emitServerEvent(event) {
|
|
1364
|
+
this.emitChange({
|
|
1365
|
+
type: documentChangeTypes[event.type],
|
|
1366
|
+
documents: event.documents.map((document) => phDocumentFromGetDocument(document)),
|
|
1367
|
+
context: event.context ? {
|
|
1368
|
+
parentId: event.context.parentId ?? void 0,
|
|
1369
|
+
childId: event.context.childId ?? void 0
|
|
1370
|
+
} : void 0
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Reports a broken realtime socket once per client, however many sockets it
|
|
1375
|
+
* goes through.
|
|
1376
|
+
*
|
|
1377
|
+
* `graphql-ws` retries on its own, and a Switchboard without a websocket
|
|
1378
|
+
* endpoint would otherwise fill the console for as long as the page is open.
|
|
1379
|
+
*/
|
|
1380
|
+
logRealtimeError(error) {
|
|
1381
|
+
if (this.realtimeErrorLogged) return;
|
|
1382
|
+
this.realtimeErrorLogged = true;
|
|
1383
|
+
logger.warn("GraphQLReactorClient: realtime document changes are unavailable, falling back to local change events", error);
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Delivers an event to every matching subscriber.
|
|
1387
|
+
*
|
|
1388
|
+
* A subscriber that throws is logged and skipped so one bad listener cannot
|
|
1389
|
+
* stop the others from being notified.
|
|
1390
|
+
*/
|
|
1391
|
+
emitChange(event) {
|
|
1392
|
+
for (const listener of [...this.listeners]) {
|
|
1393
|
+
if (!eventMatchesSearch(event, listener.search)) continue;
|
|
1394
|
+
try {
|
|
1395
|
+
listener.callback(event);
|
|
1396
|
+
} catch (error) {
|
|
1397
|
+
logger.error("GraphQLReactorClient: a document change subscriber threw", error);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
/**
|
|
1403
|
+
* Whether a value is a {@link GraphQLReactorClient}, including one built by
|
|
1404
|
+
* another copy of this module.
|
|
1405
|
+
*
|
|
1406
|
+
* Use this rather than `instanceof`: the brand it tests for is shared by every
|
|
1407
|
+
* copy of the class, so a client built by a hot-replaced module or by a package
|
|
1408
|
+
* that bundled its own copy is still recognised.
|
|
1409
|
+
*/
|
|
1410
|
+
function isGraphQLReactorClient(client) {
|
|
1411
|
+
return client?.[graphQLReactorClientBrand] === true;
|
|
1412
|
+
}
|
|
1413
|
+
/** The schema's change types, mapped onto the reactor's. */
|
|
1414
|
+
const documentChangeTypes = {
|
|
1415
|
+
[DocumentChangeType.Created]: DOCUMENT_CHANGE_TYPE.Created,
|
|
1416
|
+
[DocumentChangeType.Deleted]: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1417
|
+
[DocumentChangeType.Updated]: DOCUMENT_CHANGE_TYPE.Updated,
|
|
1418
|
+
[DocumentChangeType.ParentAdded]: DOCUMENT_CHANGE_TYPE.ParentAdded,
|
|
1419
|
+
[DocumentChangeType.ParentRemoved]: DOCUMENT_CHANGE_TYPE.ParentRemoved,
|
|
1420
|
+
[DocumentChangeType.ChildAdded]: DOCUMENT_CHANGE_TYPE.ChildAdded,
|
|
1421
|
+
[DocumentChangeType.ChildRemoved]: DOCUMENT_CHANGE_TYPE.ChildRemoved
|
|
1422
|
+
};
|
|
1423
|
+
/**
|
|
1424
|
+
* Decides whether an event reaches a subscriber.
|
|
1425
|
+
*
|
|
1426
|
+
* Every populated field of the search filter is an AND condition, matching the
|
|
1427
|
+
* reactor's own subscription manager - which also treats an empty array as a
|
|
1428
|
+
* filter that nothing satisfies. `parentId` is a drive concept and is ignored.
|
|
1429
|
+
*
|
|
1430
|
+
* A `Deleted` event carries no documents, so it is matched on its
|
|
1431
|
+
* `context.childId` for identifier filters and delivered unconditionally to
|
|
1432
|
+
* type and slug filters: there is no document left to check them against.
|
|
1433
|
+
*/
|
|
1434
|
+
function eventMatchesSearch(event, search) {
|
|
1435
|
+
const deleted = event.type === DOCUMENT_CHANGE_TYPE.Deleted;
|
|
1436
|
+
const { ids, slugs, type } = search;
|
|
1437
|
+
if (ids) {
|
|
1438
|
+
if (!(deleted ? [event.context?.childId] : event.documents.map((document) => document.header.id)).some((id) => id !== void 0 && ids.includes(id))) return false;
|
|
1439
|
+
}
|
|
1440
|
+
if (slugs && !deleted) {
|
|
1441
|
+
if (!event.documents.map((document) => document.header.slug).some((slug) => slugs.includes(slug))) return false;
|
|
1442
|
+
}
|
|
1443
|
+
if (type && !deleted) {
|
|
1444
|
+
if (!event.documents.map((document) => document.header.documentType).includes(type)) return false;
|
|
1445
|
+
}
|
|
1446
|
+
return true;
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Maps a reactor `ViewFilter` onto the GraphQL `ViewFilterInput`.
|
|
1450
|
+
*
|
|
1451
|
+
* Point-in-time reads are rejected: the Switchboard read API has no revision
|
|
1452
|
+
* argument, so silently returning the head state would be wrong.
|
|
1453
|
+
*/
|
|
1454
|
+
function viewFilterInputFromViewFilter(view) {
|
|
1455
|
+
if (!view) return;
|
|
1456
|
+
if (view.revision !== void 0) throw new Error("point-in-time views are not supported by GraphQLReactorClient");
|
|
1457
|
+
if (view.branch === void 0 && view.scopes === void 0) return;
|
|
1458
|
+
return {
|
|
1459
|
+
branch: view.branch,
|
|
1460
|
+
scopes: view.scopes
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
function pagingInputFromPaging(paging) {
|
|
1464
|
+
if (!paging) return;
|
|
1465
|
+
return {
|
|
1466
|
+
cursor: paging.cursor,
|
|
1467
|
+
limit: paging.limit
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* The reactor and the GraphQL schema disagree on the enum: the reactor's
|
|
1472
|
+
* `None` is the schema's `ORPHAN`. This is the inverse of the server's
|
|
1473
|
+
* `toReactorPropagationMode`.
|
|
1474
|
+
*/
|
|
1475
|
+
const propagationModeInputs = {
|
|
1476
|
+
cascade: PropagationMode.Cascade,
|
|
1477
|
+
none: PropagationMode.Orphan
|
|
1478
|
+
};
|
|
1479
|
+
function propagationModeInput(propagate) {
|
|
1480
|
+
return propagate === void 0 ? void 0 : propagationModeInputs[propagate];
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Stamps and signs the actions about to be pushed.
|
|
1484
|
+
*
|
|
1485
|
+
* Signing needs the state the action applies to, so only a single action can be
|
|
1486
|
+
* signed per call: the second action of a batch applies to a state this client
|
|
1487
|
+
* cannot compute without running the reducer. Batches are pushed unsigned.
|
|
1488
|
+
*/
|
|
1489
|
+
async function prepareActionsForPush(actions, document) {
|
|
1490
|
+
const signer = resolveAmbientSigner();
|
|
1491
|
+
if (!signer || actions.length === 0) return actions;
|
|
1492
|
+
if (actions.length > 1) {
|
|
1493
|
+
logger.warn("GraphQLReactorClient: pushing a multi-action batch unsigned, only single actions can be signed");
|
|
1494
|
+
return actions;
|
|
1495
|
+
}
|
|
1496
|
+
return [await signStampedAction(stampAction(actions[0], document), signer)];
|
|
1497
|
+
}
|
|
1498
|
+
/** Resolves the signer of the logged-in user, if there is one. */
|
|
1499
|
+
function resolveAmbientSigner() {
|
|
1500
|
+
if (typeof window === "undefined") return;
|
|
1501
|
+
const renown = window.ph?.renown;
|
|
1502
|
+
return renown?.user ? renown.signer : void 0;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* The revision the pushed operations start from: the lowest head revision
|
|
1506
|
+
* across the scopes the actions target.
|
|
1507
|
+
*
|
|
1508
|
+
* The baseline is only meaningful together with {@link scopesForActions}: a
|
|
1509
|
+
* batch that touches a scope at revision 1 and one at revision 5000 would
|
|
1510
|
+
* otherwise re-download the whole history of every scope of the document.
|
|
1511
|
+
*/
|
|
1512
|
+
function sinceRevisionForActions(document, actions) {
|
|
1513
|
+
const revisions = actions.map((action) => document.header.revision[action.scope] ?? 0);
|
|
1514
|
+
return revisions.length > 0 ? Math.min(...revisions) : 0;
|
|
1515
|
+
}
|
|
1516
|
+
/** The distinct scopes the pushed actions target, in first-seen order. */
|
|
1517
|
+
function scopesForActions(actions) {
|
|
1518
|
+
if (actions.length === 0) return;
|
|
1519
|
+
return [...new Set(actions.map((action) => action.scope))];
|
|
1520
|
+
}
|
|
1521
|
+
//#endregion
|
|
1522
|
+
//#region src/hooks/config/editor.ts
|
|
1523
|
+
const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
|
|
1524
|
+
/** Sets whether external controls are enabled for a given editor. */
|
|
1525
|
+
const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
|
|
1526
|
+
/** Gets whether external controls are enabled for a given editor. */
|
|
1527
|
+
const useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
|
|
1528
|
+
/** Adds an event handler for when the external controls enabled state changes. */
|
|
1529
|
+
const addIsExternalControlsEnabledEventHandler = isExternalControlsEnabledEventFunctions.addEventHandler;
|
|
1530
|
+
const isDragAndDropEnabledEventFunctions = makePHEventFunctions("isDragAndDropEnabled");
|
|
1531
|
+
/** Sets whether drag and drop is enabled for a given app. */
|
|
1532
|
+
const setIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.setValue;
|
|
1533
|
+
/** Gets whether drag and drop is enabled for a given app. */
|
|
1534
|
+
const useIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.useValue;
|
|
1535
|
+
/** Adds an event handler for when the drag and drop enabled state changes. */
|
|
1536
|
+
const addIsDragAndDropEnabledEventHandler = isDragAndDropEnabledEventFunctions.addEventHandler;
|
|
1537
|
+
const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocumentTypes");
|
|
1538
|
+
/** Sets the allowed document types for a given app. */
|
|
1539
|
+
const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
|
|
1540
|
+
/** Defines the document types a drive supports.
|
|
1541
|
+
*
|
|
1542
|
+
* Defaults to all of the document types registered in the reactor.
|
|
1543
|
+
*/
|
|
1544
|
+
function useAllowedDocumentTypes() {
|
|
1545
|
+
return allowedDocumentTypesEventFunctions.useValue();
|
|
1546
|
+
}
|
|
1547
|
+
/** Adds an event handler for when the allowed document types for a given app changes. */
|
|
1548
|
+
const addAllowedDocumentTypesEventHandler = allowedDocumentTypesEventFunctions.addEventHandler;
|
|
1549
|
+
const phAppConfigSetters = {
|
|
1550
|
+
allowedDocumentTypes: setAllowedDocumentTypes,
|
|
1551
|
+
isDragAndDropEnabled: setIsDragAndDropEnabled
|
|
1552
|
+
};
|
|
1553
|
+
const phDocumentEditorConfigSetters = { isExternalControlsEnabled: setIsExternalControlsEnabled };
|
|
1554
|
+
const phAppConfigHooks = {
|
|
1555
|
+
allowedDocumentTypes: useAllowedDocumentTypes,
|
|
1556
|
+
isDragAndDropEnabled: useIsDragAndDropEnabled
|
|
1557
|
+
};
|
|
1558
|
+
const phDocumentEditorConfigHooks = { isExternalControlsEnabled: useIsExternalControlsEnabled };
|
|
1559
|
+
//#endregion
|
|
1560
|
+
//#region src/hooks/config/connect.ts
|
|
1561
|
+
const { useValue: useRouterBasename, setValue: setRouterBasename, addEventHandler: addRouterBasenameEventHandler } = makePHEventFunctions("routerBasename");
|
|
1562
|
+
const { useValue: useVersion, setValue: setVersion, addEventHandler: addVersionEventHandler } = makePHEventFunctions("version");
|
|
1563
|
+
const { useValue: useRequiresHardRefresh, setValue: setRequiresHardRefresh, addEventHandler: addRequiresHardRefreshEventHandler } = makePHEventFunctions("requiresHardRefresh");
|
|
1564
|
+
const { useValue: useWarnOutdatedApp, setValue: setWarnOutdatedApp, addEventHandler: addWarnOutdatedAppEventHandler } = makePHEventFunctions("warnOutdatedApp");
|
|
1565
|
+
const { useValue: useStudioMode, setValue: setStudioMode, addEventHandler: addStudioModeEventHandler } = makePHEventFunctions("studioMode");
|
|
1566
|
+
const { useValue: useBasePath, setValue: setBasePath, addEventHandler: addBasePathEventHandler } = makePHEventFunctions("basePath");
|
|
1567
|
+
const { useValue: useVersionCheckInterval, setValue: setVersionCheckInterval, addEventHandler: addVersionCheckIntervalEventHandler } = makePHEventFunctions("versionCheckInterval");
|
|
1568
|
+
const { useValue: useCliVersion, setValue: setCliVersion, addEventHandler: addCliVersionEventHandler } = makePHEventFunctions("cliVersion");
|
|
1569
|
+
const { useValue: useFileUploadOperationsChunkSize, setValue: setFileUploadOperationsChunkSize, addEventHandler: addFileUploadOperationsChunkSizeEventHandler } = makePHEventFunctions("fileUploadOperationsChunkSize");
|
|
1570
|
+
const { useValue: useIsDocumentModelSelectionSettingsEnabled, setValue: setIsDocumentModelSelectionSettingsEnabled, addEventHandler: addIsDocumentModelSelectionSettingsEnabledEventHandler } = makePHEventFunctions("isDocumentModelSelectionSettingsEnabled");
|
|
1571
|
+
const { useValue: useGaTrackingId, setValue: setGaTrackingId, addEventHandler: addGaTrackingIdEventHandler } = makePHEventFunctions("gaTrackingId");
|
|
1572
|
+
const { useValue: useDefaultDrivesUrl, setValue: setDefaultDrivesUrl, addEventHandler: addDefaultDrivesUrlEventHandler } = makePHEventFunctions("defaultDrivesUrl");
|
|
1573
|
+
const { useValue: useDrivesPreserveStrategy, setValue: setDrivesPreserveStrategy, addEventHandler: addDrivesPreserveStrategyEventHandler } = makePHEventFunctions("drivesPreserveStrategy");
|
|
1574
|
+
const { useValue: useIsLocalDrivesEnabled, setValue: setIsLocalDrivesEnabled, addEventHandler: addIsLocalDrivesEnabledEventHandler } = makePHEventFunctions("isLocalDrivesEnabled");
|
|
1575
|
+
const { useValue: useIsAddDriveEnabled, setValue: setIsAddDriveEnabled, addEventHandler: addIsAddDriveEnabledEventHandler } = makePHEventFunctions("isAddDriveEnabled");
|
|
1576
|
+
const { useValue: useIsPublicDrivesEnabled, setValue: setIsPublicDrivesEnabled, addEventHandler: addIsPublicDrivesEnabledEventHandler } = makePHEventFunctions("isPublicDrivesEnabled");
|
|
1577
|
+
const { useValue: useIsAddPublicDrivesEnabled, setValue: setIsAddPublicDrivesEnabled, addEventHandler: addIsAddPublicDrivesEnabledEventHandler } = makePHEventFunctions("isAddPublicDrivesEnabled");
|
|
1578
|
+
const { useValue: useIsDeletePublicDrivesEnabled, setValue: setIsDeletePublicDrivesEnabled, addEventHandler: addIsDeletePublicDrivesEnabledEventHandler } = makePHEventFunctions("isDeletePublicDrivesEnabled");
|
|
1579
|
+
const { useValue: useIsCloudDrivesEnabled, setValue: setIsCloudDrivesEnabled, addEventHandler: addIsCloudDrivesEnabledEventHandler } = makePHEventFunctions("isCloudDrivesEnabled");
|
|
1580
|
+
const { useValue: useIsAddCloudDrivesEnabled, setValue: setIsAddCloudDrivesEnabled, addEventHandler: addIsAddCloudDrivesEnabledEventHandler } = makePHEventFunctions("isAddCloudDrivesEnabled");
|
|
1581
|
+
const { useValue: useIsDeleteCloudDrivesEnabled, setValue: setIsDeleteCloudDrivesEnabled, addEventHandler: addIsDeleteCloudDrivesEnabledEventHandler } = makePHEventFunctions("isDeleteCloudDrivesEnabled");
|
|
1582
|
+
const { useValue: useLocalDrivesEnabled, setValue: setLocalDrivesEnabled, addEventHandler: addLocalDrivesEnabledEventHandler } = makePHEventFunctions("isLocalDrivesEnabled");
|
|
1583
|
+
const { useValue: useIsAddLocalDrivesEnabled, setValue: setIsAddLocalDrivesEnabled, addEventHandler: addIsAddLocalDrivesEnabledEventHandler } = makePHEventFunctions("isAddLocalDrivesEnabled");
|
|
1584
|
+
const { useValue: useIsDeleteLocalDrivesEnabled, setValue: setIsDeleteLocalDrivesEnabled, addEventHandler: addIsDeleteLocalDrivesEnabledEventHandler } = makePHEventFunctions("isDeleteLocalDrivesEnabled");
|
|
1585
|
+
const { useValue: useIsEditorDebugModeEnabled, setValue: setIsEditorDebugModeEnabled, addEventHandler: addIsEditorDebugModeEnabledEventHandler } = makePHEventFunctions("isEditorDebugModeEnabled");
|
|
1586
|
+
const { useValue: useIsEditorReadModeEnabled, setValue: setIsEditorReadModeEnabled, addEventHandler: addIsEditorReadModeEnabledEventHandler } = makePHEventFunctions("isEditorReadModeEnabled");
|
|
1587
|
+
const { useValue: useIsAnalyticsDatabaseWorkerEnabled, setValue: setIsAnalyticsDatabaseWorkerEnabled, addEventHandler: addIsAnalyticsDatabaseWorkerEnabledEventHandler } = makePHEventFunctions("isAnalyticsDatabaseWorkerEnabled");
|
|
1588
|
+
const { useValue: useIsDiffAnalyticsEnabled, setValue: setIsDiffAnalyticsEnabled, addEventHandler: addIsDiffAnalyticsEnabledEventHandler } = makePHEventFunctions("isDiffAnalyticsEnabled");
|
|
1589
|
+
const { useValue: useIsDriveAnalyticsEnabled, setValue: setIsDriveAnalyticsEnabled, addEventHandler: addIsDriveAnalyticsEnabledEventHandler } = makePHEventFunctions("isDriveAnalyticsEnabled");
|
|
1590
|
+
const { useValue: useRenownUrl, setValue: setRenownUrl, addEventHandler: addRenownUrlEventHandler } = makePHEventFunctions("renownUrl");
|
|
1591
|
+
const { useValue: useRenownNetworkId, setValue: setRenownNetworkId, addEventHandler: addRenownNetworkIdEventHandler } = makePHEventFunctions("renownNetworkId");
|
|
1592
|
+
const { useValue: useRenownChainId, setValue: setRenownChainId, addEventHandler: addRenownChainIdEventHandler } = makePHEventFunctions("renownChainId");
|
|
1593
|
+
const { useValue: useSwitchboardUrl, setValue: setSwitchboardUrl, addEventHandler: addSwitchboardUrlEventHandler } = makePHEventFunctions("switchboardUrl");
|
|
1594
|
+
const { useValue: useRenownAdapters, setValue: setRenownAdapters, addEventHandler: addRenownAdaptersEventHandler } = makePHEventFunctions("renownAdapters");
|
|
1595
|
+
const { useValue: useSentryRelease, setValue: setSentryRelease, addEventHandler: addSentryReleaseEventHandler } = makePHEventFunctions("sentryRelease");
|
|
1596
|
+
const { useValue: useSentryDsn, setValue: setSentryDsn, addEventHandler: addSentryDsnEventHandler } = makePHEventFunctions("sentryDsn");
|
|
1597
|
+
const { useValue: useSentryEnv, setValue: setSentryEnv, addEventHandler: addSentryEnvEventHandler } = makePHEventFunctions("sentryEnv");
|
|
1598
|
+
const { useValue: useIsSentryTracingEnabled, setValue: setIsSentryTracingEnabled, addEventHandler: addIsSentryTracingEnabledEventHandler } = makePHEventFunctions("isSentryTracingEnabled");
|
|
1599
|
+
const { useValue: useIsExternalProcessorsEnabled, setValue: setIsExternalProcessorsEnabled, addEventHandler: addIsExternalProcessorsEnabledEventHandler } = makePHEventFunctions("isExternalProcessorsEnabled");
|
|
1600
|
+
const { useValue: useIsExternalPackagesEnabled, setValue: setIsExternalPackagesEnabled, addEventHandler: addIsExternalPackagesEnabledEventHandler } = makePHEventFunctions("isExternalPackagesEnabled");
|
|
1601
|
+
const enabledEditorsEventFunctions = makePHEventFunctions("enabledEditors");
|
|
1602
|
+
/** Sets the enabled editors for Connect. */
|
|
1603
|
+
const setEnabledEditors = enabledEditorsEventFunctions.setValue;
|
|
1604
|
+
/** Gets the enabled editors for Connect. */
|
|
1605
|
+
const useEnabledEditors = enabledEditorsEventFunctions.useValue;
|
|
1606
|
+
/** Adds an event handler for when the enabled editors for Connect changes. */
|
|
1607
|
+
const addEnabledEditorsEventHandler = enabledEditorsEventFunctions.addEventHandler;
|
|
1608
|
+
const disabledEditorsEventFunctions = makePHEventFunctions("disabledEditors");
|
|
1609
|
+
/** Sets the disabled editors for Connect. */
|
|
1610
|
+
const setDisabledEditors = disabledEditorsEventFunctions.setValue;
|
|
1611
|
+
/** Gets the disabled editors for Connect. */
|
|
1612
|
+
const useDisabledEditors = disabledEditorsEventFunctions.useValue;
|
|
1613
|
+
/** Adds an event handler for when the disabled editors for Connect changes. */
|
|
1614
|
+
const addDisabledEditorsEventHandler = disabledEditorsEventFunctions.addEventHandler;
|
|
1615
|
+
const isRelationalProcessorsEnabled = makePHEventFunctions("isRelationalProcessorsEnabled");
|
|
1616
|
+
/** Sets the isRelationalProcessorsEnabled for Connect. */
|
|
1617
|
+
const setIsRelationalProcessorsEnabled = isRelationalProcessorsEnabled.setValue;
|
|
1618
|
+
/** Gets the isRelationalProcessorsEnabled for Connect. */
|
|
1619
|
+
const useIsRelationalProcessorsEnabled = isRelationalProcessorsEnabled.useValue;
|
|
1620
|
+
/** Adds an event handler for when the isRelationalProcessorsEnabled for Connect changes. */
|
|
1621
|
+
const addIsRelationalProcessorsEnabledEventHandler = isRelationalProcessorsEnabled.addEventHandler;
|
|
1622
|
+
const isExternalRelationalProcessorsEnabled = makePHEventFunctions("isExternalRelationalProcessorsEnabled");
|
|
1623
|
+
/** Sets the isExternalRelationalProcessorsEnabled for Connect. */
|
|
1624
|
+
const setIsExternalRelationalProcessorsEnabled = isExternalRelationalProcessorsEnabled.setValue;
|
|
1625
|
+
/** Gets the isExternalRelationalProcessorsEnabled for Connect. */
|
|
1626
|
+
const useIsExternalRelationalProcessorsEnabled = isExternalRelationalProcessorsEnabled.useValue;
|
|
1627
|
+
/** Adds an event handler for when the isExternalRelationalProcessorsEnabled for Connect changes. */
|
|
1628
|
+
const addIsExternalRelationalProcessorsEnabledEventHandler = isExternalRelationalProcessorsEnabled.addEventHandler;
|
|
1629
|
+
const isAnalyticsEnabledEventFunctions = makePHEventFunctions("isAnalyticsEnabled");
|
|
1630
|
+
/** Sets the isAnalyticsEnabled for Connect. */
|
|
1631
|
+
const setIsAnalyticsEnabled = isAnalyticsEnabledEventFunctions.setValue;
|
|
1632
|
+
/** Gets the isAnalyticsEnabled for Connect. */
|
|
1633
|
+
const useIsAnalyticsEnabled = isAnalyticsEnabledEventFunctions.useValue;
|
|
1634
|
+
/** Adds an event handler for when the isAnalyticsEnabled for Connect changes. */
|
|
1635
|
+
const addIsAnalyticsEnabledEventHandler = isAnalyticsEnabledEventFunctions.addEventHandler;
|
|
1636
|
+
const isAnalyticsExternalProcessorsEnabled = makePHEventFunctions("isAnalyticsExternalProcessorsEnabled");
|
|
1637
|
+
/** Sets the isAnalyticsExternalProcessorsEnabled for Connect. */
|
|
1638
|
+
const setIsAnalyticsExternalProcessorsEnabled = isAnalyticsExternalProcessorsEnabled.setValue;
|
|
1639
|
+
/** Gets the isAnalyticsExternalProcessorsEnabled for Connect. */
|
|
1640
|
+
const useIsAnalyticsExternalProcessorsEnabled = isAnalyticsExternalProcessorsEnabled.useValue;
|
|
1641
|
+
/** Adds an event handler for when the isAnalyticsExternalProcessorsEnabled for Connect changes. */
|
|
1642
|
+
const addIsAnalyticsExternalProcessorsEnabledEventHandler = isAnalyticsExternalProcessorsEnabled.addEventHandler;
|
|
1643
|
+
const analyticsDatabaseNameEventFunctions = makePHEventFunctions("analyticsDatabaseName");
|
|
1644
|
+
/** Sets the analytics database name for Connect. */
|
|
1645
|
+
const setAnalyticsDatabaseName = analyticsDatabaseNameEventFunctions.setValue;
|
|
1646
|
+
/** Gets the analytics database name for Connect. */
|
|
1647
|
+
const useAnalyticsDatabaseName = analyticsDatabaseNameEventFunctions.useValue;
|
|
1648
|
+
/** Adds an event handler for when the analytics database name for Connect changes. */
|
|
1649
|
+
const addAnalyticsDatabaseNameEventHandler = analyticsDatabaseNameEventFunctions.addEventHandler;
|
|
1650
|
+
const logLevelEventFunctions = makePHEventFunctions("logLevel");
|
|
1651
|
+
/** Sets the log level for Connect. */
|
|
1652
|
+
const setLogLevel = logLevelEventFunctions.setValue;
|
|
1653
|
+
/** Gets the log level for Connect. */
|
|
1654
|
+
const useLogLevel = logLevelEventFunctions.useValue;
|
|
1655
|
+
/** Adds an event handler for when the log level for Connect changes. */
|
|
1656
|
+
const addLogLevelEventHandler = logLevelEventFunctions.addEventHandler;
|
|
1657
|
+
const allowListEventFunctions = makePHEventFunctions("allowList");
|
|
1658
|
+
/** Sets the allow list for Connect. */
|
|
1659
|
+
const setAllowList = allowListEventFunctions.setValue;
|
|
1660
|
+
/** Gets the allow list for Connect. */
|
|
1661
|
+
const useAllowList = allowListEventFunctions.useValue;
|
|
1662
|
+
/** Adds an event handler for when the allow list for Connect changes. */
|
|
1663
|
+
const addAllowListEventHandler = allowListEventFunctions.addEventHandler;
|
|
1664
|
+
const nonUserConfigSetters = {
|
|
1665
|
+
routerBasename: setRouterBasename,
|
|
1666
|
+
version: setVersion,
|
|
1667
|
+
requiresHardRefresh: setRequiresHardRefresh,
|
|
1668
|
+
warnOutdatedApp: setWarnOutdatedApp,
|
|
1669
|
+
studioMode: setStudioMode,
|
|
1670
|
+
basePath: setBasePath,
|
|
1671
|
+
versionCheckInterval: setVersionCheckInterval,
|
|
1672
|
+
cliVersion: setCliVersion,
|
|
1673
|
+
fileUploadOperationsChunkSize: setFileUploadOperationsChunkSize,
|
|
1674
|
+
isDocumentModelSelectionSettingsEnabled: setIsDocumentModelSelectionSettingsEnabled,
|
|
1675
|
+
gaTrackingId: setGaTrackingId,
|
|
1676
|
+
defaultDrivesUrl: setDefaultDrivesUrl,
|
|
1677
|
+
drivesPreserveStrategy: setDrivesPreserveStrategy,
|
|
1678
|
+
isLocalDrivesEnabled: setIsLocalDrivesEnabled,
|
|
1679
|
+
isAddDriveEnabled: setIsAddDriveEnabled,
|
|
1680
|
+
isPublicDrivesEnabled: setIsPublicDrivesEnabled,
|
|
1681
|
+
isAddPublicDrivesEnabled: setIsAddPublicDrivesEnabled,
|
|
1682
|
+
isDeletePublicDrivesEnabled: setIsDeletePublicDrivesEnabled,
|
|
1683
|
+
isCloudDrivesEnabled: setIsCloudDrivesEnabled,
|
|
1684
|
+
isAddCloudDrivesEnabled: setIsAddCloudDrivesEnabled,
|
|
1685
|
+
isDeleteCloudDrivesEnabled: setIsDeleteCloudDrivesEnabled,
|
|
1686
|
+
isAddLocalDrivesEnabled: setIsAddLocalDrivesEnabled,
|
|
1687
|
+
isDeleteLocalDrivesEnabled: setIsDeleteLocalDrivesEnabled,
|
|
1688
|
+
isEditorDebugModeEnabled: setIsEditorDebugModeEnabled,
|
|
1689
|
+
isEditorReadModeEnabled: setIsEditorReadModeEnabled,
|
|
1690
|
+
isRelationalProcessorsEnabled: setIsRelationalProcessorsEnabled,
|
|
1691
|
+
isExternalRelationalProcessorsEnabled: setIsExternalRelationalProcessorsEnabled,
|
|
1692
|
+
isAnalyticsEnabled: setIsAnalyticsEnabled,
|
|
1693
|
+
analyticsDatabaseName: setAnalyticsDatabaseName,
|
|
1694
|
+
isAnalyticsExternalProcessorsEnabled: setIsAnalyticsExternalProcessorsEnabled,
|
|
1695
|
+
isAnalyticsDatabaseWorkerEnabled: setIsAnalyticsDatabaseWorkerEnabled,
|
|
1696
|
+
isDiffAnalyticsEnabled: setIsDiffAnalyticsEnabled,
|
|
1697
|
+
isDriveAnalyticsEnabled: setIsDriveAnalyticsEnabled,
|
|
1698
|
+
renownUrl: setRenownUrl,
|
|
1699
|
+
renownNetworkId: setRenownNetworkId,
|
|
1700
|
+
renownChainId: setRenownChainId,
|
|
1701
|
+
switchboardUrl: setSwitchboardUrl,
|
|
1702
|
+
renownAdapters: setRenownAdapters,
|
|
1703
|
+
sentryRelease: setSentryRelease,
|
|
1704
|
+
sentryDsn: setSentryDsn,
|
|
1705
|
+
sentryEnv: setSentryEnv,
|
|
1706
|
+
isSentryTracingEnabled: setIsSentryTracingEnabled,
|
|
1707
|
+
isExternalProcessorsEnabled: setIsExternalProcessorsEnabled,
|
|
1708
|
+
isExternalPackagesEnabled: setIsExternalPackagesEnabled,
|
|
1709
|
+
allowList: setAllowList,
|
|
1710
|
+
logLevel: setLogLevel,
|
|
1711
|
+
disabledEditors: setDisabledEditors,
|
|
1712
|
+
enabledEditors: setEnabledEditors
|
|
1713
|
+
};
|
|
1714
|
+
const phGlobalConfigSetters = {
|
|
1715
|
+
...phAppConfigSetters,
|
|
1716
|
+
...phDocumentEditorConfigSetters,
|
|
1717
|
+
...nonUserConfigSetters
|
|
1718
|
+
};
|
|
1719
|
+
const nonUserConfigHooks = {
|
|
1720
|
+
routerBasename: useRouterBasename,
|
|
1721
|
+
version: useVersion,
|
|
1722
|
+
requiresHardRefresh: useRequiresHardRefresh,
|
|
1723
|
+
warnOutdatedApp: useWarnOutdatedApp,
|
|
1724
|
+
studioMode: useStudioMode,
|
|
1725
|
+
basePath: useBasePath,
|
|
1726
|
+
versionCheckInterval: useVersionCheckInterval,
|
|
1727
|
+
cliVersion: useCliVersion,
|
|
1728
|
+
fileUploadOperationsChunkSize: useFileUploadOperationsChunkSize,
|
|
1729
|
+
isDocumentModelSelectionSettingsEnabled: useIsDocumentModelSelectionSettingsEnabled,
|
|
1730
|
+
gaTrackingId: useGaTrackingId,
|
|
1731
|
+
defaultDrivesUrl: useDefaultDrivesUrl,
|
|
1732
|
+
drivesPreserveStrategy: useDrivesPreserveStrategy,
|
|
1733
|
+
isAddDriveEnabled: useIsAddDriveEnabled,
|
|
1734
|
+
isPublicDrivesEnabled: useIsPublicDrivesEnabled,
|
|
1735
|
+
isAddPublicDrivesEnabled: useIsAddPublicDrivesEnabled,
|
|
1736
|
+
isDeletePublicDrivesEnabled: useIsDeletePublicDrivesEnabled,
|
|
1737
|
+
isCloudDrivesEnabled: useIsCloudDrivesEnabled,
|
|
1738
|
+
isAddCloudDrivesEnabled: useIsAddCloudDrivesEnabled,
|
|
1739
|
+
isDeleteCloudDrivesEnabled: useIsDeleteCloudDrivesEnabled,
|
|
1740
|
+
isLocalDrivesEnabled: useIsLocalDrivesEnabled,
|
|
1741
|
+
isAddLocalDrivesEnabled: useIsAddLocalDrivesEnabled,
|
|
1742
|
+
isDeleteLocalDrivesEnabled: useIsDeleteLocalDrivesEnabled,
|
|
1743
|
+
isEditorDebugModeEnabled: useIsEditorDebugModeEnabled,
|
|
1744
|
+
isEditorReadModeEnabled: useIsEditorReadModeEnabled,
|
|
1745
|
+
isAnalyticsDatabaseWorkerEnabled: useIsAnalyticsDatabaseWorkerEnabled,
|
|
1746
|
+
isDiffAnalyticsEnabled: useIsDiffAnalyticsEnabled,
|
|
1747
|
+
isDriveAnalyticsEnabled: useIsDriveAnalyticsEnabled,
|
|
1748
|
+
renownUrl: useRenownUrl,
|
|
1749
|
+
renownNetworkId: useRenownNetworkId,
|
|
1750
|
+
renownChainId: useRenownChainId,
|
|
1751
|
+
switchboardUrl: useSwitchboardUrl,
|
|
1752
|
+
renownAdapters: useRenownAdapters,
|
|
1753
|
+
sentryRelease: useSentryRelease,
|
|
1754
|
+
sentryDsn: useSentryDsn,
|
|
1755
|
+
sentryEnv: useSentryEnv,
|
|
1756
|
+
isSentryTracingEnabled: useIsSentryTracingEnabled,
|
|
1757
|
+
isExternalProcessorsEnabled: useIsExternalProcessorsEnabled,
|
|
1758
|
+
isExternalPackagesEnabled: useIsExternalPackagesEnabled,
|
|
1759
|
+
allowList: useAllowList,
|
|
1760
|
+
isAnalyticsEnabled: useIsAnalyticsEnabled,
|
|
1761
|
+
isAnalyticsExternalProcessorsEnabled: useIsAnalyticsExternalProcessorsEnabled,
|
|
1762
|
+
isRelationalProcessorsEnabled: useIsRelationalProcessorsEnabled,
|
|
1763
|
+
isExternalRelationalProcessorsEnabled: useIsExternalRelationalProcessorsEnabled,
|
|
1764
|
+
analyticsDatabaseName: useAnalyticsDatabaseName,
|
|
1765
|
+
logLevel: useLogLevel,
|
|
1766
|
+
disabledEditors: useDisabledEditors,
|
|
1767
|
+
enabledEditors: useEnabledEditors
|
|
1768
|
+
};
|
|
1769
|
+
const phGlobalConfigHooks = {
|
|
1770
|
+
...phAppConfigHooks,
|
|
1771
|
+
...phDocumentEditorConfigHooks,
|
|
1772
|
+
...nonUserConfigHooks
|
|
1773
|
+
};
|
|
1774
|
+
//#endregion
|
|
1775
|
+
//#region src/hooks/attachment-service.ts
|
|
1776
|
+
const attachmentServiceEventFunctions = makePHEventFunctions("attachmentService");
|
|
1777
|
+
/** Returns the attachment service from window.ph */
|
|
1778
|
+
const useAttachmentService = attachmentServiceEventFunctions.useValue;
|
|
1779
|
+
/** Sets the attachment service on window.ph */
|
|
1780
|
+
const setAttachmentService = attachmentServiceEventFunctions.setValue;
|
|
1781
|
+
/** Registers the attachmentService window event handler */
|
|
1782
|
+
const addAttachmentServiceEventHandler = attachmentServiceEventFunctions.addEventHandler;
|
|
1783
|
+
//#endregion
|
|
1784
|
+
//#region src/hooks/features.ts
|
|
1785
|
+
const featuresEventFunctions = makePHEventFunctions("features");
|
|
1786
|
+
const useFeatures = featuresEventFunctions.useValue;
|
|
1787
|
+
const setFeatures = featuresEventFunctions.setValue;
|
|
1788
|
+
const addFeaturesEventHandler = featuresEventFunctions.addEventHandler;
|
|
1789
|
+
//#endregion
|
|
1790
|
+
//#region src/utils/url.ts
|
|
1791
|
+
function resolveUrlPathname(path) {
|
|
1792
|
+
return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
|
|
1793
|
+
}
|
|
1794
|
+
/** Returns the current path without the base path */
|
|
1795
|
+
function getPathWithoutBase(path) {
|
|
1796
|
+
const basePath = window.ph?.basePath ?? "/";
|
|
1797
|
+
return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
|
|
1798
|
+
}
|
|
1799
|
+
/** Makes a URL component for a drive. */
|
|
1800
|
+
function makeDriveUrlComponent(drive) {
|
|
1801
|
+
if (!drive) return "";
|
|
1802
|
+
return `/d/${slug(drive.header.slug)}`;
|
|
1803
|
+
}
|
|
1804
|
+
/** Makes a URL component for a node. */
|
|
1805
|
+
function makeNodeSlug(node) {
|
|
1806
|
+
if (!node) return "";
|
|
1807
|
+
const nodeName = node.name;
|
|
1808
|
+
if (!nodeName) return slug(node.id);
|
|
1809
|
+
return slug(`${nodeName}-${node.id}`);
|
|
1810
|
+
}
|
|
1811
|
+
/** Extracts the node slug from a path.
|
|
1812
|
+
*
|
|
1813
|
+
* The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
|
|
1814
|
+
*/
|
|
1815
|
+
function extractNodeSlugFromPath(path) {
|
|
1816
|
+
const currentPath = getPathWithoutBase(path);
|
|
1817
|
+
return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
|
|
1818
|
+
}
|
|
1819
|
+
/** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
|
|
1820
|
+
function findUuid(input) {
|
|
1821
|
+
if (!input) return void 0;
|
|
1822
|
+
return /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(input)?.[0];
|
|
1823
|
+
}
|
|
1824
|
+
function extractNodeIdFromSlug(nodeSlug) {
|
|
1825
|
+
return findUuid(nodeSlug);
|
|
1826
|
+
}
|
|
1827
|
+
function extractNodeIdFromPath(path) {
|
|
1828
|
+
return extractNodeIdFromSlug(extractNodeSlugFromPath(path));
|
|
1829
|
+
}
|
|
1830
|
+
/** Extracts the drive slug from a path.
|
|
1831
|
+
* Used for extracting drive ids from drive slugs in the URL.
|
|
1832
|
+
* Expects the path to be in the format `/d/<drive-slug>`.
|
|
1833
|
+
*/
|
|
1834
|
+
function extractDriveSlugFromPath(path) {
|
|
1835
|
+
const currentPath = getPathWithoutBase(path);
|
|
1836
|
+
return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
|
|
1837
|
+
}
|
|
1838
|
+
function extractDriveIdFromSlug(driveSlug) {
|
|
1839
|
+
return findUuid(driveSlug);
|
|
1840
|
+
}
|
|
1841
|
+
function extractDriveIdFromPath(path) {
|
|
1842
|
+
return extractDriveIdFromSlug(extractDriveSlugFromPath(path));
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Creates a URL string with the given pathname while preserving existing query parameters.
|
|
1846
|
+
*/
|
|
1847
|
+
function createUrlWithPreservedParams(pathname) {
|
|
1848
|
+
const search = window.location.search;
|
|
1849
|
+
return search ? `${pathname}${search}` : pathname;
|
|
1850
|
+
}
|
|
1851
|
+
//#endregion
|
|
1852
|
+
//#region src/hooks/drives.ts
|
|
1853
|
+
const drivesEventFunctions = makePHEventFunctions("drives");
|
|
1854
|
+
/** Returns all of the drives in the reactor */
|
|
1855
|
+
const useDrives = drivesEventFunctions.useValue;
|
|
1856
|
+
/** Sets the drives in the reactor */
|
|
1857
|
+
const setDrives = drivesEventFunctions.setValue;
|
|
1858
|
+
/** Adds an event handler for the drives */
|
|
1859
|
+
const addDrivesEventHandler = drivesEventFunctions.addEventHandler;
|
|
1860
|
+
//#endregion
|
|
1861
|
+
//#region src/hooks/set-selected-node.ts
|
|
1862
|
+
const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
|
|
1863
|
+
const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
|
|
1864
|
+
const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
|
|
1865
|
+
const addSelectedNodeIdEventHandler = selectedNodeIdEventFunctions.addEventHandler;
|
|
1866
|
+
/** Sets the selected node (file or folder). */
|
|
1867
|
+
function setSelectedNode(nodeOrNodeSlug) {
|
|
1868
|
+
const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
|
|
1869
|
+
setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
|
|
1870
|
+
const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
|
|
1871
|
+
if (!driveSlugFromPath) return;
|
|
1872
|
+
if (!nodeSlug) {
|
|
1873
|
+
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
|
|
1874
|
+
if (pathname === window.location.pathname) return;
|
|
1875
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
|
|
1879
|
+
if (pathname === window.location.pathname) return;
|
|
1880
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1881
|
+
}
|
|
1882
|
+
function addResetSelectedNodeEventHandler() {
|
|
1883
|
+
window.addEventListener("ph:selectedDriveIdUpdated", () => {
|
|
1884
|
+
setSelectedNodeId(void 0);
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
function addSetSelectedNodeOnPopStateEventHandler() {
|
|
1888
|
+
window.addEventListener("popstate", () => {
|
|
1889
|
+
const pathname = window.location.pathname;
|
|
1890
|
+
const nodeSlug = extractNodeSlugFromPath(pathname);
|
|
1891
|
+
if (extractNodeIdFromSlug(nodeSlug) !== window.ph?.selectedNodeId) setSelectedNode(nodeSlug);
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
//#endregion
|
|
1895
|
+
//#region src/hooks/selected-drive.ts
|
|
1896
|
+
const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
|
|
1897
|
+
/** Returns the selected drive id */
|
|
1898
|
+
const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
|
|
1899
|
+
/** Sets the selected drive id */
|
|
1900
|
+
const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
|
|
1901
|
+
/** Adds an event handler for the selected drive id */
|
|
1902
|
+
const addSelectedDriveIdEventHandler = selectedDriveIdEventFunctions.addEventHandler;
|
|
1903
|
+
/** Returns the selected drive */
|
|
1904
|
+
function useSelectedDrive() {
|
|
1905
|
+
const drive = useSelectedDriveSafe();
|
|
1906
|
+
if (!drive[0]) throw new Error("There is no drive selected. Did you mean to call 'useSelectedDriveSafe'?");
|
|
1907
|
+
return drive;
|
|
1908
|
+
}
|
|
1909
|
+
/** Returns the selected drive, or undefined if no drive is selected */
|
|
1910
|
+
function useSelectedDriveSafe() {
|
|
1911
|
+
const selectedDriveId = useSelectedDriveId();
|
|
1912
|
+
const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
|
|
1913
|
+
const [drive, dispatch] = useDispatch(selectedDrive);
|
|
1914
|
+
if (!selectedDrive) return [void 0, void 0];
|
|
1915
|
+
return [drive, dispatch];
|
|
1916
|
+
}
|
|
1917
|
+
function setSelectedDrive(driveOrDriveSlug) {
|
|
1918
|
+
const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
|
|
1919
|
+
const drives = window.ph?.drives;
|
|
1920
|
+
const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
|
|
1921
|
+
if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
|
|
1922
|
+
if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
|
|
1923
|
+
deferDriveSelection(driveSlug);
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
cancelPendingDriveSelection();
|
|
1927
|
+
setSelectedDriveId(driveId);
|
|
1928
|
+
if (!driveId) {
|
|
1929
|
+
const pathname = resolveUrlPathname("/");
|
|
1930
|
+
if (pathname === window.location.pathname) return;
|
|
1931
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1932
|
+
return;
|
|
1933
|
+
}
|
|
1934
|
+
const pathname = resolveUrlPathname(`/d/${driveSlug}`);
|
|
1935
|
+
if (pathname === window.location.pathname) return;
|
|
1936
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1937
|
+
}
|
|
1938
|
+
const DEFERRED_DRIVE_TICK_MS = 2e3;
|
|
1939
|
+
const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
|
|
1940
|
+
function isInitialSyncInFlight() {
|
|
1941
|
+
const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
|
|
1942
|
+
if (!remotes?.length) return false;
|
|
1943
|
+
return remotes.some((remote) => {
|
|
1944
|
+
try {
|
|
1945
|
+
const snapshot = remote.channel.getConnectionState();
|
|
1946
|
+
return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
|
|
1947
|
+
} catch {
|
|
1948
|
+
return false;
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
let pendingHandler;
|
|
1953
|
+
let pendingTimeout;
|
|
1954
|
+
function cancelPendingDriveSelection() {
|
|
1955
|
+
if (pendingHandler) {
|
|
1956
|
+
window.removeEventListener("ph:drivesUpdated", pendingHandler);
|
|
1957
|
+
pendingHandler = void 0;
|
|
1958
|
+
}
|
|
1959
|
+
if (pendingTimeout) {
|
|
1960
|
+
clearTimeout(pendingTimeout);
|
|
1961
|
+
pendingTimeout = void 0;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
function deferDriveSelection(driveSlug) {
|
|
1965
|
+
cancelPendingDriveSelection();
|
|
1966
|
+
const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
|
|
1967
|
+
const handler = () => {
|
|
1968
|
+
if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
|
|
1969
|
+
cancelPendingDriveSelection();
|
|
1970
|
+
setSelectedDrive(driveSlug);
|
|
1971
|
+
setSelectedNode(nodeSlug);
|
|
1972
|
+
};
|
|
1973
|
+
pendingHandler = handler;
|
|
1974
|
+
window.addEventListener("ph:drivesUpdated", handler);
|
|
1975
|
+
const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
|
|
1976
|
+
const scheduleTick = () => {
|
|
1977
|
+
pendingTimeout = setTimeout(() => {
|
|
1978
|
+
if (Date.now() < deadline && isInitialSyncInFlight()) {
|
|
1979
|
+
scheduleTick();
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
cancelPendingDriveSelection();
|
|
1983
|
+
const pathname = resolveUrlPathname("/");
|
|
1984
|
+
if (pathname === window.location.pathname) return;
|
|
1985
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1986
|
+
}, DEFERRED_DRIVE_TICK_MS);
|
|
1987
|
+
};
|
|
1988
|
+
scheduleTick();
|
|
1989
|
+
}
|
|
1990
|
+
function addSetSelectedDriveOnPopStateEventHandler() {
|
|
1991
|
+
window.addEventListener("popstate", () => {
|
|
1992
|
+
const pathname = window.location.pathname;
|
|
1993
|
+
const driveId = extractDriveIdFromPath(pathname);
|
|
1994
|
+
if (driveId !== window.ph?.selectedDriveId) setSelectedDrive(driveId);
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
//#endregion
|
|
1998
|
+
//#region src/hooks/use-drop-target.ts
|
|
1999
|
+
function useDropTarget() {
|
|
2000
|
+
const [isDropTarget, setIsDropTarget] = useState(false);
|
|
2001
|
+
const isDragAndDropEnabled = useIsDragAndDropEnabled();
|
|
2002
|
+
const targetSetter = funnel(() => setIsDropTarget(true), {
|
|
2003
|
+
triggerAt: "start",
|
|
2004
|
+
minQuietPeriodMs: 100
|
|
2005
|
+
});
|
|
2006
|
+
const targetUnsetter = funnel(() => setIsDropTarget(false), {
|
|
2007
|
+
triggerAt: "start",
|
|
2008
|
+
minQuietPeriodMs: 100
|
|
2009
|
+
});
|
|
2010
|
+
function setTarget() {
|
|
2011
|
+
if (!isDragAndDropEnabled) return;
|
|
2012
|
+
targetUnsetter.cancel();
|
|
2013
|
+
targetSetter.call();
|
|
2014
|
+
}
|
|
2015
|
+
function unsetTarget() {
|
|
2016
|
+
if (!isDragAndDropEnabled) return;
|
|
2017
|
+
targetSetter.cancel();
|
|
2018
|
+
targetUnsetter.call();
|
|
2019
|
+
}
|
|
2020
|
+
return {
|
|
2021
|
+
isDropTarget,
|
|
2022
|
+
setTarget,
|
|
2023
|
+
unsetTarget
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
//#endregion
|
|
2027
|
+
//#region src/hooks/node-drag-and-drop.ts
|
|
2028
|
+
const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
|
|
2029
|
+
const useDraggingNode = draggingNodeEventFunctions.useValue;
|
|
2030
|
+
const setDraggingNode = draggingNodeEventFunctions.setValue;
|
|
2031
|
+
const addDraggingNodeEventHandler = draggingNodeEventFunctions.addEventHandler;
|
|
2032
|
+
const draggingNodeSetter = funnel((node) => setDraggingNode(node), {
|
|
2033
|
+
reducer: (_, newNode) => newNode,
|
|
2034
|
+
triggerAt: "start",
|
|
2035
|
+
minQuietPeriodMs: 100
|
|
2036
|
+
});
|
|
2037
|
+
const draggingNodeUnsetter = funnel(() => setDraggingNode(void 0), {
|
|
2038
|
+
triggerAt: "start",
|
|
2039
|
+
minQuietPeriodMs: 100
|
|
2040
|
+
});
|
|
2041
|
+
function setDragging(node) {
|
|
2042
|
+
draggingNodeUnsetter.cancel();
|
|
2043
|
+
draggingNodeSetter.call(node);
|
|
2044
|
+
}
|
|
2045
|
+
function unsetDragging() {
|
|
2046
|
+
draggingNodeSetter.cancel();
|
|
2047
|
+
draggingNodeUnsetter.call();
|
|
2048
|
+
}
|
|
2049
|
+
const isNodeDrag = (params) => conditional(params, [({ srcId }) => isNot(isTruthy)(srcId), constant(false)], [({ driveId }) => isNot(isTruthy)(driveId), constant(false)], [({ driveId, srcId }) => isStrictEqual(driveId, srcId), constant(false)], constant(true));
|
|
2050
|
+
function useDragNode(args) {
|
|
2051
|
+
const { srcId, parentId } = args;
|
|
2052
|
+
const driveId = useSelectedDriveId();
|
|
2053
|
+
const draggingNodeId = useDraggingNode()?.srcId;
|
|
2054
|
+
const params = {
|
|
2055
|
+
driveId,
|
|
2056
|
+
srcId,
|
|
2057
|
+
parentId
|
|
2058
|
+
};
|
|
2059
|
+
const draggable = isNodeDrag(params);
|
|
2060
|
+
const isDragging = allPass({
|
|
2061
|
+
srcId,
|
|
2062
|
+
draggingNodeId
|
|
2063
|
+
}, [
|
|
2064
|
+
() => draggable,
|
|
2065
|
+
({ srcId }) => isString(srcId),
|
|
2066
|
+
({ draggingNodeId }) => isString(draggingNodeId),
|
|
2067
|
+
({ srcId, draggingNodeId }) => isStrictEqual(srcId, draggingNodeId)
|
|
2068
|
+
]);
|
|
2069
|
+
const onDragStart = () => {
|
|
2070
|
+
if (!draggable) return;
|
|
2071
|
+
setDragging(params);
|
|
2072
|
+
};
|
|
2073
|
+
const onDragEnd = () => {
|
|
2074
|
+
if (!draggable) return;
|
|
2075
|
+
unsetDragging();
|
|
2076
|
+
};
|
|
2077
|
+
return {
|
|
2078
|
+
isDragging,
|
|
2079
|
+
draggable,
|
|
2080
|
+
onDragStart,
|
|
2081
|
+
onDragEnd
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
const isNodeDrop = (params) => conditional(params, [({ srcId }) => isNot(isTruthy)(srcId), constant(false)], [({ driveId }) => isNot(isDefined)(driveId), constant(false)], [({ srcId, targetId }) => isStrictEqual(srcId, targetId), constant(false)], [({ driveId, parentId, targetId }) => isNot(isTruthy)(parentId) && isStrictEqual(targetId, driveId), constant(false)], [({ targetId, parentId }) => isStrictEqual(targetId, parentId), constant(false)], constant(true));
|
|
2085
|
+
function useDropNode(targetId) {
|
|
2086
|
+
const driveId = useSelectedDriveId();
|
|
2087
|
+
const { srcId, parentId } = useDraggingNode() ?? {};
|
|
2088
|
+
const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
|
|
2089
|
+
const params = {
|
|
2090
|
+
driveId,
|
|
2091
|
+
parentId,
|
|
2092
|
+
targetId,
|
|
2093
|
+
srcId
|
|
2094
|
+
};
|
|
2095
|
+
function handleNodeDrop(event, cb) {
|
|
2096
|
+
if (!isNodeDrop(params)) return;
|
|
2097
|
+
event.preventDefault();
|
|
2098
|
+
event.stopPropagation();
|
|
2099
|
+
cb?.();
|
|
2100
|
+
}
|
|
2101
|
+
const onDragEnter = (event) => handleNodeDrop(event);
|
|
2102
|
+
const onDragOver = (event) => handleNodeDrop(event, once(setTarget));
|
|
2103
|
+
const onDragLeave = (event) => handleNodeDrop(event, once(unsetTarget));
|
|
2104
|
+
const onDrop = (event) => handleNodeDrop(event, once(() => {
|
|
2105
|
+
unsetDragging();
|
|
2106
|
+
unsetTarget();
|
|
2107
|
+
moveNodeById(params).catch(console.error);
|
|
2108
|
+
}));
|
|
2109
|
+
return {
|
|
2110
|
+
isDropTarget,
|
|
2111
|
+
onDragEnter,
|
|
2112
|
+
onDragOver,
|
|
2113
|
+
onDragLeave,
|
|
2114
|
+
onDrop
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
//#endregion
|
|
2118
|
+
//#region src/hooks/graphql-reactor-client.ts
|
|
2119
|
+
const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
|
|
2120
|
+
const useGraphQLReactorClient = graphQLReactorClientEventFunctions.useValue;
|
|
2121
|
+
const setGraphQLReactorClient = graphQLReactorClientEventFunctions.setValue;
|
|
2122
|
+
const addGraphQLReactorClientEventHandler = graphQLReactorClientEventFunctions.addEventHandler;
|
|
2123
|
+
//#endregion
|
|
2124
|
+
//#region src/hooks/package-discovery.ts
|
|
2125
|
+
const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
|
|
2126
|
+
const usePackageDiscoveryService = packageDiscoveryFunctions.useValue;
|
|
2127
|
+
const setPackageDiscoveryService = packageDiscoveryFunctions.setValue;
|
|
2128
|
+
const addPackageDiscoveryServiceEventHandler = packageDiscoveryFunctions.addEventHandler;
|
|
2129
|
+
//#endregion
|
|
2130
|
+
//#region src/hooks/reactor.ts
|
|
2131
|
+
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
2132
|
+
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
2133
|
+
/** Returns the reactor client module (in-process or worker-backed) */
|
|
2134
|
+
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
2135
|
+
/** Sets the reactor client module */
|
|
2136
|
+
const setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
2137
|
+
/** Adds an event handler for the reactor client module */
|
|
2138
|
+
const addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
2139
|
+
/** Returns the reactor client */
|
|
2140
|
+
const useReactorClient = reactorClientEventFunctions.useValue;
|
|
2141
|
+
/** Sets the reactor client */
|
|
2142
|
+
const setReactorClient = reactorClientEventFunctions.setValue;
|
|
2143
|
+
/** Adds an event handler for the reactor client */
|
|
2144
|
+
const addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
2145
|
+
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
2146
|
+
const useSyncList = () => {
|
|
2147
|
+
return useSync()?.list() ?? [];
|
|
2148
|
+
};
|
|
2149
|
+
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
2150
|
+
const useDatabase = () => {
|
|
2151
|
+
const module = useReactorClientModule();
|
|
2152
|
+
return module?.kind === "browser" ? module.reactorModule?.database : void 0;
|
|
2153
|
+
};
|
|
2154
|
+
const usePGlite = () => {
|
|
2155
|
+
const module = useReactorClientModule();
|
|
2156
|
+
return module?.kind === "browser" ? module.reactorModule?.pg : void 0;
|
|
2157
|
+
};
|
|
2158
|
+
//#endregion
|
|
2159
|
+
//#region src/hooks/revision-history.ts
|
|
2160
|
+
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
2161
|
+
/** Returns whether revision history is visible */
|
|
2162
|
+
const useRevisionHistoryVisible = revisionHistoryEventFunctions.useValue;
|
|
2163
|
+
/** Sets revision history visibility */
|
|
2164
|
+
const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
|
|
2165
|
+
/** Adds event handler for revision history visibility */
|
|
2166
|
+
const addRevisionHistoryVisibleEventHandler = revisionHistoryEventFunctions.addEventHandler;
|
|
2167
|
+
/** Shows the revision history */
|
|
2168
|
+
function showRevisionHistory() {
|
|
2169
|
+
setRevisionHistoryVisible(true);
|
|
2170
|
+
}
|
|
2171
|
+
/** Hides the revision history */
|
|
2172
|
+
function hideRevisionHistory() {
|
|
2173
|
+
setRevisionHistoryVisible(false);
|
|
2174
|
+
}
|
|
2175
|
+
//#endregion
|
|
2176
|
+
//#region src/utils/nodes.ts
|
|
2177
|
+
/** Sorts nodes by name. */
|
|
2178
|
+
function sortNodesByName(nodes) {
|
|
2179
|
+
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
2180
|
+
}
|
|
2181
|
+
/** Returns whether a node is a file. */
|
|
2182
|
+
function isFileNodeKind(node) {
|
|
2183
|
+
if (!node) return false;
|
|
2184
|
+
return node.kind.toUpperCase() === "FILE";
|
|
2185
|
+
}
|
|
2186
|
+
/** Returns whether a node is a folder. */
|
|
2187
|
+
function isFolderNodeKind(node) {
|
|
2188
|
+
if (!node) return false;
|
|
2189
|
+
return node.kind.toUpperCase() === "FOLDER";
|
|
2190
|
+
}
|
|
2191
|
+
//#endregion
|
|
2192
|
+
//#region src/hooks/items-in-selected-drive.ts
|
|
2193
|
+
/** Returns the nodes in the selected drive. */
|
|
2194
|
+
function useNodesInSelectedDrive() {
|
|
2195
|
+
const [selectedDrive] = useSelectedDriveSafe();
|
|
2196
|
+
return selectedDrive?.state.global.nodes;
|
|
2197
|
+
}
|
|
2198
|
+
/** Returns the file nodes in the selected drive. */
|
|
2199
|
+
function useFileNodesInSelectedDrive() {
|
|
2200
|
+
return useNodesInSelectedDrive()?.filter((n) => isFileNodeKind(n));
|
|
2201
|
+
}
|
|
2202
|
+
/** Returns the folder nodes in the selected drive. */
|
|
2203
|
+
function useFolderNodesInSelectedDrive() {
|
|
2204
|
+
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
2205
|
+
}
|
|
2206
|
+
/** Returns the documents in the selected drive. */
|
|
2207
|
+
function useDocumentsInSelectedDrive() {
|
|
2208
|
+
const fileNodeIds = useFileNodesInSelectedDrive()?.map((node) => node.id);
|
|
2209
|
+
return useDocumentsByIds(fileNodeIds);
|
|
2210
|
+
}
|
|
2211
|
+
/** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */
|
|
2212
|
+
function useDocumentTypesInSelectedDrive() {
|
|
2213
|
+
return (useDocumentsInSelectedDrive()?.filter(isDocumentModelDocument))?.map((doc) => doc.state.global.id);
|
|
2214
|
+
}
|
|
2215
|
+
function isDocumentModelDocument(document) {
|
|
2216
|
+
return document.header.documentType === "powerhouse/document-model";
|
|
2217
|
+
}
|
|
2218
|
+
//#endregion
|
|
2219
|
+
//#region src/hooks/selected-node.ts
|
|
2220
|
+
/** Returns the selected node. */
|
|
2221
|
+
function useSelectedNode() {
|
|
2222
|
+
const selectedNodeId = useSelectedNodeId();
|
|
2223
|
+
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
2224
|
+
}
|
|
2225
|
+
//#endregion
|
|
2226
|
+
//#region src/hooks/selected-timeline-item.ts
|
|
2227
|
+
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
2228
|
+
/** Returns the selected timeline item */
|
|
2229
|
+
const useSelectedTimelineItem = selectedTimelineItemEventFunctions.useValue;
|
|
2230
|
+
/** Sets the selected timeline item */
|
|
2231
|
+
const setSelectedTimelineItem = selectedTimelineItemEventFunctions.setValue;
|
|
2232
|
+
/** Adds event handler for selected timeline item */
|
|
2233
|
+
const addSelectedTimelineItemEventHandler = selectedTimelineItemEventFunctions.addEventHandler;
|
|
2234
|
+
//#endregion
|
|
2235
|
+
//#region src/hooks/timeline-revision.ts
|
|
2236
|
+
const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
|
|
2237
|
+
/** Returns the selected timeline revision. */
|
|
2238
|
+
const useSelectedTimelineRevision = selectedTimelineRevisionEventFunctions.useValue;
|
|
2239
|
+
/** Sets the selected timeline revision. */
|
|
2240
|
+
const setSelectedTimelineRevision = selectedTimelineRevisionEventFunctions.setValue;
|
|
2241
|
+
/** Adds an event handler for the selected timeline revision. */
|
|
2242
|
+
const addSelectedTimelineRevisionEventHandler = selectedTimelineRevisionEventFunctions.addEventHandler;
|
|
2243
|
+
//#endregion
|
|
2244
|
+
//#region src/hooks/toast.ts
|
|
2245
|
+
const toastEventFunctions = makePHEventFunctions("toast");
|
|
2246
|
+
/** Returns the toast function */
|
|
2247
|
+
const usePHToast = toastEventFunctions.useValue;
|
|
2248
|
+
/** Sets the toast function */
|
|
2249
|
+
const setPHToast = toastEventFunctions.setValue;
|
|
2250
|
+
/** Adds an event handler for the toast */
|
|
2251
|
+
const addToastEventHandler = toastEventFunctions.addEventHandler;
|
|
2252
|
+
//#endregion
|
|
2253
|
+
//#region src/hooks/vetra-packages.ts
|
|
2254
|
+
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
2255
|
+
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
2256
|
+
/** Returns all of the Vetra packages loaded by the Connect instance */
|
|
2257
|
+
const useVetraPackages = () => {
|
|
2258
|
+
const packageManager = useVetraPackageManager();
|
|
2259
|
+
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
|
|
2260
|
+
};
|
|
2261
|
+
/** Adds the Vetra package manager event handler */
|
|
2262
|
+
const addVetraPackageManagerEventHandler = vetraPackageManagerFunctions.addEventHandler;
|
|
2263
|
+
/** Sets the Vetra package manager and registers its packages */
|
|
2264
|
+
function setVetraPackageManager(packageManager) {
|
|
2265
|
+
vetraPackageManagerFunctions.setValue(packageManager);
|
|
2266
|
+
updateReactorClientDocumentModels(packageManager.packages);
|
|
2267
|
+
updateReactorClientUpgradeManifests(packageManager.packages);
|
|
2268
|
+
packageManager.subscribe(({ packages }) => {
|
|
2269
|
+
updateReactorClientDocumentModels(packages);
|
|
2270
|
+
updateReactorClientUpgradeManifests(packages);
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
function updateReactorClientDocumentModels(packages) {
|
|
2274
|
+
const documentModelModules = packages.flatMap((pkg) => pkg.documentModels);
|
|
2275
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2276
|
+
if (!registry || documentModelModules.length === 0) return;
|
|
2277
|
+
const results = registry.registerModules(...documentModelModules);
|
|
2278
|
+
const duplicates = [];
|
|
2279
|
+
for (const result of results) if (result.status === "error") if (isDuplicateModuleError(result.error)) duplicates.push(result);
|
|
2280
|
+
else console.error("Failed to register document model module:", result.error);
|
|
2281
|
+
if (duplicates.length > 0) {
|
|
2282
|
+
const duplicateTypes = duplicates.map((r) => r.item.documentModel.global.id);
|
|
2283
|
+
registry.unregisterModules(...duplicateTypes);
|
|
2284
|
+
registry.registerModules(...duplicates.map((r) => r.item));
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
function updateReactorClientUpgradeManifests(packages) {
|
|
2288
|
+
const upgradeManifests = packages.flatMap((pkg) => pkg.upgradeManifests).filter((u) => u !== void 0);
|
|
2289
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2290
|
+
if (!registry || upgradeManifests.length === 0) return;
|
|
2291
|
+
const results = registry.registerUpgradeManifests(...upgradeManifests);
|
|
2292
|
+
const duplicates = [];
|
|
2293
|
+
for (const result of results) if (result.status === "error") if (isDuplicateManifestError(result.error)) duplicates.push(result);
|
|
2294
|
+
else console.error("Failed to register upgrade manifest:", result.error);
|
|
2295
|
+
if (duplicates.length > 0) {
|
|
2296
|
+
const duplicateTypes = duplicates.map((r) => r.item.documentType).filter((t) => !!t);
|
|
2297
|
+
registry.unregisterUpgradeManifests(...duplicateTypes);
|
|
2298
|
+
registry.registerUpgradeManifests(...duplicates.map((r) => r.item));
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
//#endregion
|
|
2302
|
+
//#region src/hooks/add-ph-event-handlers.ts
|
|
2303
|
+
const commonGlobalEventHandlerFunctions = {
|
|
2304
|
+
loading: addLoadingEventHandler,
|
|
2305
|
+
drives: addDrivesEventHandler,
|
|
2306
|
+
selectedDriveId: () => {
|
|
2307
|
+
addSelectedDriveIdEventHandler();
|
|
2308
|
+
addSetSelectedDriveOnPopStateEventHandler();
|
|
2309
|
+
addResetSelectedNodeEventHandler();
|
|
2310
|
+
},
|
|
2311
|
+
selectedNodeId: () => {
|
|
2312
|
+
addSelectedNodeIdEventHandler();
|
|
2313
|
+
addSetSelectedNodeOnPopStateEventHandler();
|
|
2314
|
+
},
|
|
2315
|
+
documentCache: addDocumentCacheEventHandler,
|
|
2316
|
+
reactorGraphQLClient: addGraphQLReactorClientEventHandler,
|
|
2317
|
+
draggingNode: addDraggingNodeEventHandler
|
|
2318
|
+
};
|
|
2319
|
+
const phGlobalEventHandlerRegisterFunctions = {
|
|
2320
|
+
...commonGlobalEventHandlerFunctions,
|
|
2321
|
+
reactorClientModule: addReactorClientModuleEventHandler,
|
|
2322
|
+
reactorClient: addReactorClientEventHandler,
|
|
2323
|
+
attachmentService: addAttachmentServiceEventHandler,
|
|
2324
|
+
features: addFeaturesEventHandler,
|
|
2325
|
+
modal: addModalEventHandler,
|
|
2326
|
+
renown: addRenownEventHandler,
|
|
2327
|
+
vetraPackageManager: addVetraPackageManagerEventHandler,
|
|
2328
|
+
packageDiscoveryService: addPackageDiscoveryServiceEventHandler,
|
|
2329
|
+
selectedTimelineRevision: addSelectedTimelineRevisionEventHandler,
|
|
2330
|
+
revisionHistoryVisible: addRevisionHistoryVisibleEventHandler,
|
|
2331
|
+
selectedTimelineItem: addSelectedTimelineItemEventHandler,
|
|
2332
|
+
routerBasename: addRouterBasenameEventHandler,
|
|
2333
|
+
version: addVersionEventHandler,
|
|
2334
|
+
logLevel: addLogLevelEventHandler,
|
|
2335
|
+
requiresHardRefresh: addRequiresHardRefreshEventHandler,
|
|
2336
|
+
warnOutdatedApp: addWarnOutdatedAppEventHandler,
|
|
2337
|
+
studioMode: addStudioModeEventHandler,
|
|
2338
|
+
basePath: addBasePathEventHandler,
|
|
2339
|
+
versionCheckInterval: addVersionCheckIntervalEventHandler,
|
|
2340
|
+
cliVersion: addCliVersionEventHandler,
|
|
2341
|
+
fileUploadOperationsChunkSize: addFileUploadOperationsChunkSizeEventHandler,
|
|
2342
|
+
isDocumentModelSelectionSettingsEnabled: addIsDocumentModelSelectionSettingsEnabledEventHandler,
|
|
2343
|
+
gaTrackingId: addGaTrackingIdEventHandler,
|
|
2344
|
+
allowList: addAllowListEventHandler,
|
|
2345
|
+
defaultDrivesUrl: addDefaultDrivesUrlEventHandler,
|
|
2346
|
+
drivesPreserveStrategy: addDrivesPreserveStrategyEventHandler,
|
|
2347
|
+
allowedDocumentTypes: addAllowedDocumentTypesEventHandler,
|
|
2348
|
+
enabledEditors: addEnabledEditorsEventHandler,
|
|
2349
|
+
disabledEditors: addDisabledEditorsEventHandler,
|
|
2350
|
+
isAddDriveEnabled: addIsAddDriveEnabledEventHandler,
|
|
2351
|
+
isLocalDrivesEnabled: addIsLocalDrivesEnabledEventHandler,
|
|
2352
|
+
isPublicDrivesEnabled: addIsPublicDrivesEnabledEventHandler,
|
|
2353
|
+
isAddPublicDrivesEnabled: addIsAddPublicDrivesEnabledEventHandler,
|
|
2354
|
+
isDeletePublicDrivesEnabled: addIsDeletePublicDrivesEnabledEventHandler,
|
|
2355
|
+
isCloudDrivesEnabled: addIsCloudDrivesEnabledEventHandler,
|
|
2356
|
+
isAddCloudDrivesEnabled: addIsAddCloudDrivesEnabledEventHandler,
|
|
2357
|
+
isDeleteCloudDrivesEnabled: addIsDeleteCloudDrivesEnabledEventHandler,
|
|
2358
|
+
isAddLocalDrivesEnabled: addIsAddLocalDrivesEnabledEventHandler,
|
|
2359
|
+
isDeleteLocalDrivesEnabled: addIsDeleteLocalDrivesEnabledEventHandler,
|
|
2360
|
+
isDragAndDropEnabled: addIsDragAndDropEnabledEventHandler,
|
|
2361
|
+
isExternalControlsEnabled: addIsExternalControlsEnabledEventHandler,
|
|
2362
|
+
isEditorDebugModeEnabled: addIsEditorDebugModeEnabledEventHandler,
|
|
2363
|
+
isEditorReadModeEnabled: addIsEditorReadModeEnabledEventHandler,
|
|
2364
|
+
isRelationalProcessorsEnabled: addIsRelationalProcessorsEnabledEventHandler,
|
|
2365
|
+
isExternalRelationalProcessorsEnabled: addIsExternalRelationalProcessorsEnabledEventHandler,
|
|
2366
|
+
isAnalyticsEnabled: addIsAnalyticsEnabledEventHandler,
|
|
2367
|
+
isAnalyticsExternalProcessorsEnabled: addIsAnalyticsExternalProcessorsEnabledEventHandler,
|
|
2368
|
+
analyticsDatabaseName: addAnalyticsDatabaseNameEventHandler,
|
|
2369
|
+
isAnalyticsDatabaseWorkerEnabled: addIsAnalyticsDatabaseWorkerEnabledEventHandler,
|
|
2370
|
+
isDiffAnalyticsEnabled: addIsDiffAnalyticsEnabledEventHandler,
|
|
2371
|
+
isDriveAnalyticsEnabled: addIsDriveAnalyticsEnabledEventHandler,
|
|
2372
|
+
renownUrl: addRenownUrlEventHandler,
|
|
2373
|
+
renownNetworkId: addRenownNetworkIdEventHandler,
|
|
2374
|
+
renownChainId: addRenownChainIdEventHandler,
|
|
2375
|
+
switchboardUrl: addSwitchboardUrlEventHandler,
|
|
2376
|
+
renownAdapters: addRenownAdaptersEventHandler,
|
|
2377
|
+
sentryRelease: addSentryReleaseEventHandler,
|
|
2378
|
+
sentryDsn: addSentryDsnEventHandler,
|
|
2379
|
+
sentryEnv: addSentryEnvEventHandler,
|
|
2380
|
+
isSentryTracingEnabled: addIsSentryTracingEnabledEventHandler,
|
|
2381
|
+
isExternalProcessorsEnabled: addIsExternalProcessorsEnabledEventHandler,
|
|
2382
|
+
isExternalPackagesEnabled: addIsExternalPackagesEnabledEventHandler,
|
|
2383
|
+
toast: addToastEventHandler
|
|
2384
|
+
};
|
|
2385
|
+
function addPHEventHandlers() {
|
|
2386
|
+
callEventHandlerRegisterFunctions(phGlobalEventHandlerRegisterFunctions);
|
|
2387
|
+
}
|
|
2388
|
+
function callEventHandlerRegisterFunctions(registerFunctions) {
|
|
2389
|
+
forEachObj(registerFunctions, (fn) => fn());
|
|
2390
|
+
}
|
|
2391
|
+
//#endregion
|
|
2392
|
+
//#region src/graphql-client/static-package-manager.ts
|
|
2393
|
+
/**
|
|
2394
|
+
* A fixed set of packages presented through the `IPackageManager` interface,
|
|
2395
|
+
* so the package-derived hooks - `useDocumentModelModules`,
|
|
2396
|
+
* `useDocumentModelModuleById`, `useEditorModules`, `useVetraPackages` - work
|
|
2397
|
+
* below `GraphQLReactorProvider` exactly as they do below Connect.
|
|
2398
|
+
*
|
|
2399
|
+
* Connect's package manager installs, updates and removes packages at runtime.
|
|
2400
|
+
* A light app instead declares its packages once, as code it imports itself
|
|
2401
|
+
* (every generated package root exports `manifest`, `documentModels`, `editors`
|
|
2402
|
+
* and `upgradeManifests` by name), so every mutating member throws and
|
|
2403
|
+
* `subscribe` never emits. For hand-picked modules without package artifacts,
|
|
2404
|
+
* {@link packageFromDocumentModels} wraps them in one synthetic package.
|
|
2405
|
+
*/
|
|
2406
|
+
var StaticPackageManager = class {
|
|
2407
|
+
registryUrl = null;
|
|
2408
|
+
packages;
|
|
2409
|
+
constructor(packages) {
|
|
2410
|
+
this.packages = [...packages];
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Resolves a module by document type across all packages. Mirrors the
|
|
2414
|
+
* registry's semantics (`IDocumentModelRegistry.getModule`): the LATEST
|
|
2415
|
+
* version wins, with `version ?? 1` as each module's default.
|
|
2416
|
+
*/
|
|
2417
|
+
load(documentType) {
|
|
2418
|
+
let latestModule;
|
|
2419
|
+
let latestVersion = -1;
|
|
2420
|
+
for (const pkg of this.packages) for (const module of pkg.documentModels) {
|
|
2421
|
+
if (module.documentModel.global.id !== documentType) continue;
|
|
2422
|
+
const moduleVersion = module.version ?? 1;
|
|
2423
|
+
if (moduleVersion > latestVersion) {
|
|
2424
|
+
latestVersion = moduleVersion;
|
|
2425
|
+
latestModule = module;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
return latestModule ? Promise.resolve(latestModule) : Promise.reject(/* @__PURE__ */ new Error(`Unknown document type: ${documentType}`));
|
|
2429
|
+
}
|
|
2430
|
+
subscribe(_handler) {
|
|
2431
|
+
return () => {};
|
|
2432
|
+
}
|
|
2433
|
+
getPackageSource(_packageName) {
|
|
2434
|
+
return null;
|
|
2435
|
+
}
|
|
2436
|
+
getPackageVersion(_packageName) {}
|
|
2437
|
+
getRegistryPackages() {
|
|
2438
|
+
return [];
|
|
2439
|
+
}
|
|
2440
|
+
addPackage(_packageName) {
|
|
2441
|
+
throw staticPackageManagerError("addPackage");
|
|
2442
|
+
}
|
|
2443
|
+
addPackages(_packageNames) {
|
|
2444
|
+
throw staticPackageManagerError("addPackages");
|
|
2445
|
+
}
|
|
2446
|
+
removePackage(_name) {
|
|
2447
|
+
throw staticPackageManagerError("removePackage");
|
|
2448
|
+
}
|
|
2449
|
+
updateLocalPackage(_pkg, _version) {
|
|
2450
|
+
throw staticPackageManagerError("updateLocalPackage");
|
|
2451
|
+
}
|
|
2452
|
+
addLocalPackage(_name, _loadedPackage, _version) {
|
|
2453
|
+
throw staticPackageManagerError("addLocalPackage");
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
function staticPackageManagerError(member) {
|
|
2457
|
+
return /* @__PURE__ */ new Error(`${member} is not supported: StaticPackageManager holds a fixed set of packages`);
|
|
2458
|
+
}
|
|
2459
|
+
/**
|
|
2460
|
+
* Wraps hand-picked modules in one synthetic `DocumentModelLib`, for apps that
|
|
2461
|
+
* assemble their model list from mixed sources instead of passing whole
|
|
2462
|
+
* packages. The manifest is fabricated - loose modules carry none - so prefer
|
|
2463
|
+
* the `packages` prop with the real package exports when you have them: a real
|
|
2464
|
+
* package also carries `editors`, which makes the editor hooks work.
|
|
2465
|
+
*/
|
|
2466
|
+
function packageFromDocumentModels(documentModels) {
|
|
2467
|
+
return {
|
|
2468
|
+
manifest: {
|
|
2469
|
+
name: "graphql-reactor-provider",
|
|
2470
|
+
description: "Document models passed to GraphQLReactorProvider"
|
|
2471
|
+
},
|
|
2472
|
+
documentModels,
|
|
2473
|
+
editors: []
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
//#endregion
|
|
2477
|
+
//#region src/graphql-client/graphql-reactor-provider.tsx
|
|
2478
|
+
/**
|
|
2479
|
+
* Registers the `window.ph` event handlers once per page.
|
|
2480
|
+
*
|
|
2481
|
+
* The `set*` helpers only dispatch CustomEvents - nothing writes `window.ph`
|
|
2482
|
+
* until `addPHEventHandlers` has registered the listeners that do. Registration
|
|
2483
|
+
* is guarded by a marker on `window` rather than a module-level flag so that a
|
|
2484
|
+
* hot module replacement, or two copies of this module, still register once.
|
|
2485
|
+
*/
|
|
2486
|
+
function ensurePHEventHandlers() {
|
|
2487
|
+
if (typeof window === "undefined" || window.__phEventHandlersRegistered) return;
|
|
2488
|
+
addPHEventHandlers();
|
|
2489
|
+
window.__phEventHandlersRegistered = true;
|
|
2490
|
+
}
|
|
2491
|
+
/**
|
|
2492
|
+
* Mounts a {@link GraphQLReactorClient} into the `window.ph` slots the
|
|
2493
|
+
* reactor-browser hooks read, so `useDocument`, `useDispatch` and
|
|
2494
|
+
* `useReactorClient` work below it against a Switchboard, with no reactor in
|
|
2495
|
+
* the bundle.
|
|
2496
|
+
*
|
|
2497
|
+
* It fills the document slots, plus `window.ph.vetraPackageManager` when
|
|
2498
|
+
* `documentModels` is given (a fixed {@link StaticPackageManager}, which makes
|
|
2499
|
+
* the document-model hooks work). `window.ph.reactorClientModule` always stays
|
|
2500
|
+
* empty, so full-reactor surfaces (drives, jobs, editor auto-discovery) find
|
|
2501
|
+
* nothing - an app below this provider renders components it imports itself.
|
|
2502
|
+
*
|
|
2503
|
+
* The client is built on the client only: on the server the slots stay empty
|
|
2504
|
+
* and the hooks report their normal loading states. The props are read once,
|
|
2505
|
+
* when the client is built - changing `url` afterwards does not rebuild it.
|
|
2506
|
+
*
|
|
2507
|
+
* The effect's cleanup disposes the cache and the client's socket, and the
|
|
2508
|
+
* effect rebuilds both if it runs again on the same client - which is what a
|
|
2509
|
+
* `StrictMode` mount does.
|
|
2510
|
+
*/
|
|
2511
|
+
function GraphQLReactorProvider({ url, tokenProvider, subscriptionsUrl, realtime, attachmentService, documentModels, children }) {
|
|
2512
|
+
const [client] = useState(() => typeof window === "undefined" ? void 0 : new GraphQLReactorClient({
|
|
2513
|
+
url,
|
|
2514
|
+
tokenProvider,
|
|
2515
|
+
subscriptionsUrl,
|
|
2516
|
+
realtime
|
|
2517
|
+
}));
|
|
2518
|
+
useEffect(() => {
|
|
2519
|
+
if (!client) return;
|
|
2520
|
+
ensurePHEventHandlers();
|
|
2521
|
+
setReactorClient(client);
|
|
2522
|
+
const documentCache = new DocumentCache(client);
|
|
2523
|
+
setDocumentCache(documentCache);
|
|
2524
|
+
return () => {
|
|
2525
|
+
documentCache.dispose();
|
|
2526
|
+
client.dispose();
|
|
2527
|
+
};
|
|
2528
|
+
}, [client]);
|
|
2529
|
+
useEffect(() => {
|
|
2530
|
+
if (!attachmentService) return;
|
|
2531
|
+
ensurePHEventHandlers();
|
|
2532
|
+
setAttachmentService(attachmentService);
|
|
2533
|
+
}, [attachmentService]);
|
|
2534
|
+
useEffect(() => {
|
|
2535
|
+
if (!documentModels || documentModels.length === 0) return;
|
|
2536
|
+
ensurePHEventHandlers();
|
|
2537
|
+
setVetraPackageManager(new StaticPackageManager([packageFromDocumentModels(documentModels)]));
|
|
2538
|
+
}, [documentModels]);
|
|
2539
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Returns the {@link GraphQLReactorClient} mounted by
|
|
2543
|
+
* {@link GraphQLReactorProvider}, or `undefined` when the slot holds something
|
|
2544
|
+
* else - the full in-browser reactor client, or nothing yet.
|
|
2545
|
+
*
|
|
2546
|
+
* `useReactorClient` is typed as the narrow `IReactorBrowserClient` subset both
|
|
2547
|
+
* implementations share. This is how a component reaches the light client's own
|
|
2548
|
+
* surface, i.e. `subgraph` and `request`.
|
|
2549
|
+
*
|
|
2550
|
+
* The narrowing is by brand, not by `instanceof`: a page can carry two copies
|
|
2551
|
+
* of this module - a bundled package with its own copy, or a hot-replaced one -
|
|
2552
|
+
* and `instanceof` would then answer `false` for a perfectly good client and
|
|
2553
|
+
* leave the component silently without one.
|
|
2554
|
+
*/
|
|
2555
|
+
function useSwitchboardClient() {
|
|
2556
|
+
const client = useReactorClient();
|
|
2557
|
+
return isGraphQLReactorClient(client) ? client : void 0;
|
|
2558
|
+
}
|
|
2559
|
+
//#endregion
|
|
2560
|
+
//#region src/hooks/document-model-modules.ts
|
|
2561
|
+
function useDocumentModelModules() {
|
|
2562
|
+
return useVetraPackages().flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
|
|
2563
|
+
}
|
|
2564
|
+
/**
|
|
2565
|
+
* Resolves a document model module by document type, mirroring the registry's
|
|
2566
|
+
* semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
|
|
2567
|
+
* LATEST version of the type wins (`version ?? 1` as each module's default),
|
|
2568
|
+
* with `version` given only an exact match is returned. The reactor resolves
|
|
2569
|
+
* modules the same way when a document is created, so metadata read through
|
|
2570
|
+
* this hook and the version a creation actually uses cannot disagree.
|
|
2571
|
+
*/
|
|
2572
|
+
function useDocumentModelModuleById(id, version) {
|
|
2573
|
+
const documentModelModules = useDocumentModelModules();
|
|
2574
|
+
if (!id || !documentModelModules) return void 0;
|
|
2575
|
+
let latestModule;
|
|
2576
|
+
let latestVersion = -1;
|
|
2577
|
+
for (const module of documentModelModules) {
|
|
2578
|
+
if (module.documentModel.global.id !== id) continue;
|
|
2579
|
+
const moduleVersion = module.version ?? 1;
|
|
2580
|
+
if (version !== void 0) {
|
|
2581
|
+
if (moduleVersion === version) return module;
|
|
2582
|
+
continue;
|
|
2583
|
+
}
|
|
2584
|
+
if (moduleVersion > latestVersion) {
|
|
2585
|
+
latestVersion = moduleVersion;
|
|
2586
|
+
latestModule = module;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
return latestModule;
|
|
2590
|
+
}
|
|
2591
|
+
//#endregion
|
|
2592
|
+
//#region src/hooks/document-operations.ts
|
|
2593
|
+
/**
|
|
2594
|
+
* Hook to fetch document operations via the reactor client.
|
|
2595
|
+
* Operations are no longer auto-populated on documents and must be fetched explicitly.
|
|
2596
|
+
*
|
|
2597
|
+
* @param documentId - The document ID to fetch operations for
|
|
2598
|
+
* @returns Object containing globalOperations, localOperations, isLoading, and error
|
|
2599
|
+
*/
|
|
2600
|
+
function useDocumentOperations(documentId) {
|
|
2601
|
+
const reactorClient = useReactorClient();
|
|
2602
|
+
const hasFetchedRef = useRef(false);
|
|
2603
|
+
const [state, setState] = useState(() => ({
|
|
2604
|
+
globalOperations: [],
|
|
2605
|
+
localOperations: [],
|
|
2606
|
+
isLoading: !!documentId,
|
|
2607
|
+
error: void 0
|
|
2608
|
+
}));
|
|
2609
|
+
const fetchOperations = useCallback(async (retryCount = 0) => {
|
|
2610
|
+
const MAX_RETRIES = 5;
|
|
2611
|
+
const RETRY_DELAY_MS = 500;
|
|
2612
|
+
if (!documentId || !reactorClient) {
|
|
2613
|
+
setState({
|
|
2614
|
+
globalOperations: [],
|
|
2615
|
+
localOperations: [],
|
|
2616
|
+
isLoading: false,
|
|
2617
|
+
error: void 0
|
|
2618
|
+
});
|
|
2619
|
+
return;
|
|
2620
|
+
}
|
|
2621
|
+
setState((prev) => ({
|
|
2622
|
+
...prev,
|
|
2623
|
+
isLoading: true,
|
|
2624
|
+
error: void 0
|
|
2625
|
+
}));
|
|
2626
|
+
let globalOps = [];
|
|
2627
|
+
let localOps = [];
|
|
2628
|
+
let fetchError;
|
|
2629
|
+
try {
|
|
2630
|
+
globalOps = (await reactorClient.getOperations(documentId, { scopes: ["global"] })).results;
|
|
2631
|
+
} catch (err) {
|
|
2632
|
+
fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2633
|
+
}
|
|
2634
|
+
if (!fetchError) try {
|
|
2635
|
+
localOps = (await reactorClient.getOperations(documentId, { scopes: ["local"] })).results;
|
|
2636
|
+
} catch (err) {
|
|
2637
|
+
fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2638
|
+
}
|
|
2639
|
+
if (!fetchError && globalOps.length === 0 && localOps.length === 0 && retryCount < MAX_RETRIES) {
|
|
2640
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
2641
|
+
return fetchOperations(retryCount + 1);
|
|
2642
|
+
}
|
|
2643
|
+
setState({
|
|
2644
|
+
globalOperations: globalOps,
|
|
2645
|
+
localOperations: localOps,
|
|
2646
|
+
isLoading: false,
|
|
2647
|
+
error: fetchError
|
|
2648
|
+
});
|
|
2649
|
+
hasFetchedRef.current = true;
|
|
2650
|
+
}, [documentId, reactorClient]);
|
|
2651
|
+
useEffect(() => {
|
|
2652
|
+
if (documentId && reactorClient) fetchOperations();
|
|
2653
|
+
else if (!documentId) {
|
|
2654
|
+
setState({
|
|
2655
|
+
globalOperations: [],
|
|
2656
|
+
localOperations: [],
|
|
2657
|
+
isLoading: false,
|
|
2658
|
+
error: void 0
|
|
2659
|
+
});
|
|
2660
|
+
hasFetchedRef.current = false;
|
|
2661
|
+
}
|
|
2662
|
+
}, [
|
|
2663
|
+
documentId,
|
|
2664
|
+
reactorClient,
|
|
2665
|
+
fetchOperations
|
|
2666
|
+
]);
|
|
2667
|
+
const refetch = useCallback(() => {
|
|
2668
|
+
fetchOperations(0);
|
|
2669
|
+
}, [fetchOperations]);
|
|
2670
|
+
return {
|
|
2671
|
+
...state,
|
|
2672
|
+
refetch
|
|
2673
|
+
};
|
|
2674
|
+
}
|
|
2675
|
+
//#endregion
|
|
2676
|
+
export { addGraphQLReactorClientEventHandler as $, makeAuthMiddleware as $i, setIsDeleteCloudDrivesEnabled as $n, useIsDriveAnalyticsEnabled as $r, addIsAnalyticsEnabledEventHandler as $t, useNodesInSelectedDrive as A, DocumentNotFoundError as Aa, phAppConfigSetters as Ai, addVersionCheckIntervalEventHandler as An, useAllowList as Ar, makeNodeSlug as At, addReactorClientModuleEventHandler as B, isGraphQLReactorClient as Bi, setDisabledEditors as Bn, useIsAddCloudDrivesEnabled as Br, addBasePathEventHandler as Bt, setSelectedTimelineItem as C, loadFile as Ca, useVersionCheckInterval as Ci, addRequiresHardRefreshEventHandler as Cn, setSentryEnv as Cr, extractDriveSlugFromPath as Ct, useDocumentsInSelectedDrive as D, getUserPermissions as Da, addIsExternalControlsEnabledEventHandler as Di, addSentryReleaseEventHandler as Dn, setVersion as Dr, findUuid as Dt, useDocumentTypesInSelectedDrive as E, renameNode as Ea, addIsDragAndDropEnabledEventHandler as Ei, addSentryEnvEventHandler as En, setSwitchboardUrl as Er, extractNodeSlugFromPath as Et, hideRevisionHistory as F, setIsExternalControlsEnabled as Fi, setAllowList as Fn, useDisabledEditors as Fr, addAttachmentServiceEventHandler as Ft, usePGlite as G, SubgraphSdkRegistry as Gi, setIsAddCloudDrivesEnabled as Gn, useIsAnalyticsEnabled as Gr, addEnabledEditorsEventHandler as Gt, setReactorClientModule as H, makeAuthConnectionParams as Hi, setEnabledEditors as Hn, useIsAddLocalDrivesEnabled as Hr, addDefaultDrivesUrlEventHandler as Ht, setRevisionHistoryVisible as I, useAllowedDocumentTypes as Ii, setAnalyticsDatabaseName as In, useDrivesPreserveStrategy as Ir, setAttachmentService as It, useSync as J, signStampedAction as Ji, setIsAddPublicDrivesEnabled as Jn, useIsDeleteCloudDrivesEnabled as Jr, addIsAddCloudDrivesEnabledEventHandler as Jt, useReactorClient as K, describeGraphQLDocument as Ki, setIsAddDriveEnabled as Kn, useIsAnalyticsExternalProcessorsEnabled as Kr, addFileUploadOperationsChunkSizeEventHandler as Kt, showRevisionHistory as L, useIsDragAndDropEnabled as Li, setBasePath as Ln, useEnabledEditors as Lr, useAttachmentService as Lt, isFolderNodeKind as M, NoSelectedDocumentError as Ma, phDocumentEditorConfigSetters as Mi, addWarnOutdatedAppEventHandler as Mn, useBasePath as Mr, addFeaturesEventHandler as Mt, sortNodesByName as N, UnsupportedDocumentTypeError as Na, setAllowedDocumentTypes as Ni, phGlobalConfigHooks as Nn, useCliVersion as Nr, setFeatures as Nt, useFileNodesInSelectedDrive as O, isDocumentTypeSupported as Oa, isExternalControlsEnabledEventFunctions as Oi, addStudioModeEventHandler as On, setVersionCheckInterval as Or, getPathWithoutBase as Ot, addRevisionHistoryVisibleEventHandler as P, setIsDragAndDropEnabled as Pi, phGlobalConfigSetters as Pn, useDefaultDrivesUrl as Pr, useFeatures as Pt, usePackageDiscoveryService as Q, ambientRenownTokenProvider as Qi, setIsCloudDrivesEnabled as Qn, useIsDocumentModelSelectionSettingsEnabled as Qr, addIsAnalyticsDatabaseWorkerEnabledEventHandler as Qt, useRevisionHistoryVisible as R, useIsExternalControlsEnabled as Ri, setCliVersion as Rn, useFileUploadOperationsChunkSize as Rr, addAllowListEventHandler as Rt, addSelectedTimelineItemEventHandler as S, exportFile as Sa, useVersion as Si, addRenownUrlEventHandler as Sn, setSentryDsn as Sr, extractDriveIdFromSlug as St, useSelectedNode as T, renameDriveNode as Ta, addAllowedDocumentTypesEventHandler as Ti, addSentryDsnEventHandler as Tn, setStudioMode as Tr, extractNodeIdFromSlug as Tt, useDatabase as U, startDocumentChangesSubscription as Ui, setFileUploadOperationsChunkSize as Un, useIsAddPublicDrivesEnabled as Ur, addDisabledEditorsEventHandler as Ut, setReactorClient as V, viewFilterInputFromViewFilter as Vi, setDrivesPreserveStrategy as Vn, useIsAddDriveEnabled as Vr, addCliVersionEventHandler as Vt, useModelRegistry as W, subscriptionsUrlFromGraphqlUrl as Wi, setGaTrackingId as Wn, useIsAnalyticsDatabaseWorkerEnabled as Wr, addDrivesPreserveStrategyEventHandler as Wt, addPackageDiscoveryServiceEventHandler as X, MutateDocumentWithOperationsDocument as Xi, setIsAnalyticsEnabled as Xn, useIsDeletePublicDrivesEnabled as Xr, addIsAddLocalDrivesEnabledEventHandler as Xt, useSyncList as Y, stampAction as Yi, setIsAnalyticsDatabaseWorkerEnabled as Yn, useIsDeleteLocalDrivesEnabled as Yr, addIsAddDriveEnabledEventHandler as Yt, setPackageDiscoveryService as Z, ReactorOperationFieldsFragmentDoc as Zi, setIsAnalyticsExternalProcessorsEnabled as Zn, useIsDiffAnalyticsEnabled as Zr, addIsAddPublicDrivesEnabledEventHandler as Zt, setPHToast as _, addFile as _a, useSentryDsn as _i, addLocalDrivesEnabledEventHandler as _n, setRenownChainId as _r, addDrivesEventHandler as _t, ensurePHEventHandlers as a, convertRemoteOperations as aa, useIsLocalDrivesEnabled as ai, addIsDiffAnalyticsEnabledEventHandler as an, setIsEditorDebugModeEnabled as ar, useDropTarget as at, setSelectedTimelineRevision as b, copyNode$1 as ba, useStudioMode as bi, addRenownChainIdEventHandler as bn, setRequiresHardRefresh as br, createUrlWithPreservedParams as bt, packageFromDocumentModels as c, screamingSnakeToCamel as ca, useIsSentryTracingEnabled as ci, addIsEditorDebugModeEnabledEventHandler as cn, setIsExternalProcessorsEnabled as cr, setSelectedDrive as ct, commonGlobalEventHandlerFunctions as d, setPHModal as da, useRenownAdapters as di, addIsExternalProcessorsEnabledEventHandler as dn, setIsPublicDrivesEnabled as dr, useSelectedDriveId as dt, phDocumentFromGetDocument as ea, useIsEditorDebugModeEnabled as ei, addIsAnalyticsExternalProcessorsEnabledEventHandler as en, setIsDeleteLocalDrivesEnabled as er, setGraphQLReactorClient as et, addVetraPackageManagerEventHandler as f, showCreateDocumentModal as fa, useRenownChainId as fi, addIsExternalRelationalProcessorsEnabledEventHandler as fn, setIsRelationalProcessorsEnabled as fr, useSelectedDriveSafe as ft, addToastEventHandler as g, addDocument as ga, useRouterBasename as gi, addIsSentryTracingEnabledEventHandler as gn, setRenownAdapters as gr, setSelectedNode as gt, useVetraPackages as h, usePHModal as ha, useRequiresHardRefresh as hi, addIsRelationalProcessorsEnabledEventHandler as hn, setLogLevel as hr, addSetSelectedNodeOnPopStateEventHandler as ht, GraphQLReactorProvider as i, buildPulledDocument as ia, useIsExternalRelationalProcessorsEnabled as ii, addIsDeletePublicDrivesEnabledEventHandler as in, setIsDriveAnalyticsEnabled as ir, useDropNode as it, isFileNodeKind as j, DocumentTypeMismatchError as ja, phDocumentEditorConfigHooks as ji, addVersionEventHandler as jn, useAnalyticsDatabaseName as jr, resolveUrlPathname as jt, useFolderNodesInSelectedDrive as k, DocumentModelNotFoundError as ka, phAppConfigHooks as ki, addSwitchboardUrlEventHandler as kn, setWarnOutdatedApp as kr, makeDriveUrlComponent as kt, addPHEventHandlers as l, addModalEventHandler as la, useLocalDrivesEnabled as li, addIsEditorReadModeEnabledEventHandler as ln, setIsExternalRelationalProcessorsEnabled as lr, setSelectedDriveId as lt, useVetraPackageManager as m, showPHModal as ma, useRenownUrl as mi, addIsPublicDrivesEnabledEventHandler as mn, setLocalDrivesEnabled as mr, addSelectedNodeIdEventHandler as mt, useDocumentModelModuleById as n, revisionMapFromRevisionsList as na, useIsExternalPackagesEnabled as ni, addIsDeleteCloudDrivesEnabledEventHandler as nn, setIsDiffAnalyticsEnabled as nr, addDraggingNodeEventHandler as nt, useSwitchboardClient as o, extractRevisionMap as oa, useIsPublicDrivesEnabled as oi, addIsDocumentModelSelectionSettingsEnabledEventHandler as on, setIsEditorReadModeEnabled as or, addSelectedDriveIdEventHandler as ot, setVetraPackageManager as p, showDeleteNodeModal as pa, useRenownNetworkId as pi, addIsLocalDrivesEnabledEventHandler as pn, setIsSentryTracingEnabled as pr, addResetSelectedNodeEventHandler as pt, useReactorClientModule as q, subgraphUrlFromGraphqlUrl as qi, setIsAddLocalDrivesEnabled as qn, useIsCloudDrivesEnabled as qr, addGaTrackingIdEventHandler as qt, useDocumentModelModules as r, ConflictError as ra, useIsExternalProcessorsEnabled as ri, addIsDeleteLocalDrivesEnabledEventHandler as rn, setIsDocumentModelSelectionSettingsEnabled as rr, useDragNode as rt, StaticPackageManager as s, hasRevisionConflict as sa, useIsRelationalProcessorsEnabled as si, addIsDriveAnalyticsEnabledEventHandler as sn, setIsExternalPackagesEnabled as sr, addSetSelectedDriveOnPopStateEventHandler as st, useDocumentOperations as t, phDocumentFromMutation as ta, useIsEditorReadModeEnabled as ti, addIsCloudDrivesEnabledEventHandler as tn, setIsDeletePublicDrivesEnabled as tr, useGraphQLReactorClient as tt, callEventHandlerRegisterFunctions as u, closePHModal as ua, useLogLevel as ui, addIsExternalPackagesEnabledEventHandler as un, setIsLocalDrivesEnabled as ur, useSelectedDrive as ut, usePHToast as v, addFileWithProgress as va, useSentryEnv as vi, addLogLevelEventHandler as vn, setRenownNetworkId as vr, setDrives as vt, useSelectedTimelineItem as w, moveNode$1 as wa, useWarnOutdatedApp as wi, addRouterBasenameEventHandler as wn, setSentryRelease as wr, extractNodeIdFromPath as wt, useSelectedTimelineRevision as x, deleteNode as xa, useSwitchboardUrl as xi, addRenownNetworkIdEventHandler as xn, setRouterBasename as xr, extractDriveIdFromPath as xt, addSelectedTimelineRevisionEventHandler as y, addFolder$1 as ya, useSentryRelease as yi, addRenownAdaptersEventHandler as yn, setRenownUrl as yr, useDrives as yt, addReactorClientEventHandler as z, GraphQLReactorClient as zi, setDefaultDrivesUrl as zn, useGaTrackingId as zr, addAnalyticsDatabaseNameEventHandler as zt };
|
|
2677
|
+
|
|
2678
|
+
//# sourceMappingURL=document-operations-DvhxGXqI.js.map
|