@powerhousedao/reactor-browser 6.2.2-dev.76 → 6.2.2-dev.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{attachment-service-DTFJRf5j.d.ts → attachment-service-LwpgZ358.d.ts} +4 -4
- package/dist/{attachment-service-DTFJRf5j.d.ts.map → attachment-service-LwpgZ358.d.ts.map} +1 -1
- package/dist/{client-Zz_l9QzI.js → client-B8ezRmBB.js} +1 -1
- package/dist/{client-Zz_l9QzI.js.map → client-B8ezRmBB.js.map} +1 -1
- package/dist/{client-DjkEpwu_.d.ts → client-BIHN_UyR.d.ts} +2 -2
- package/dist/{client-DjkEpwu_.d.ts.map → client-BIHN_UyR.d.ts.map} +1 -1
- package/dist/{client-DB8gP4hz.js → client-D66jVnot.js} +1 -1
- package/dist/{client-DB8gP4hz.js.map → client-D66jVnot.js.map} +1 -1
- package/dist/document-model-modules-BB9s6a3m.js +377 -0
- package/dist/document-model-modules-BB9s6a3m.js.map +1 -0
- package/dist/{document-operations-DZ-oUHRy.js → document-operations-I1cGIcPg.js} +7 -377
- package/dist/document-operations-I1cGIcPg.js.map +1 -0
- package/dist/{global-pg5gy2eZ.d.ts → global-1rvI8VdA.d.ts} +4 -4
- package/dist/{global-pg5gy2eZ.d.ts.map → global-1rvI8VdA.d.ts.map} +1 -1
- package/dist/{index-BV00np9e.d.ts → index-BE3wBHLP.d.ts} +3 -3
- package/dist/index-BE3wBHLP.d.ts.map +1 -0
- package/dist/{index-CxxxP14A.d.ts → index-BIVDXw3K.d.ts} +2 -2
- package/dist/{index-CxxxP14A.d.ts.map → index-BIVDXw3K.d.ts.map} +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +11 -44
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-CaCFdEG4.d.ts → inspector-proxy-6h5VKAwt.d.ts} +1 -1
- package/dist/{inspector-proxy-CaCFdEG4.d.ts.map → inspector-proxy-6h5VKAwt.d.ts.map} +1 -1
- package/dist/{pglite-CntadC_p-BtEalg1H.d.ts → pglite-CntadC_p-9NDG14dS.d.ts} +1 -1
- package/dist/{pglite-CntadC_p-BtEalg1H.d.ts.map → pglite-CntadC_p-9NDG14dS.d.ts.map} +1 -1
- package/dist/{relational-C_0GdGVN.js → relational-D4sxGPz7.js} +1 -1
- package/dist/{relational-C_0GdGVN.js.map → relational-D4sxGPz7.js.map} +1 -1
- package/dist/{renown-6w_ImTvm.js → renown-BHxwP7xU.js} +1 -1
- package/dist/{renown-6w_ImTvm.js.map → renown-BHxwP7xU.js.map} +1 -1
- package/dist/{renown-DRnlawbP.js → renown-BIEv6bSI.js} +3 -3
- package/dist/renown-BIEv6bSI.js.map +1 -0
- package/dist/selected-document-CtRlEZyi.js +42 -0
- package/dist/selected-document-CtRlEZyi.js.map +1 -0
- package/dist/src/ai/index.d.ts +267 -0
- package/dist/src/ai/index.d.ts.map +1 -0
- package/dist/src/ai/index.js +951 -0
- package/dist/src/ai/index.js.map +1 -0
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +1 -1
- package/dist/src/graphql/client.d.ts +2 -2
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +3 -3
- package/dist/src/graphql-client/entry.js +2 -1
- package/dist/src/relational/index.d.ts +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +1 -1
- package/dist/src/renown/index.js +2 -2
- package/dist/src/rpc/index.d.ts +2 -2
- package/dist/src/rpc/index.js +1 -1
- package/dist/{store-DAJq6vSs.js → store-BJYcr_FL.js} +1 -1
- package/dist/{store-DAJq6vSs.js.map → store-BJYcr_FL.js.map} +1 -1
- package/dist/{types-wGaiXwjh.d.ts → types-6vDzbRRS.d.ts} +1 -1
- package/dist/{types-wGaiXwjh.d.ts.map → types-6vDzbRRS.d.ts.map} +1 -1
- package/dist/{types-4rfAFZQd.d.ts → types-Dcv1ZLoW.d.ts} +1 -1
- package/dist/{types-4rfAFZQd.d.ts.map → types-Dcv1ZLoW.d.ts.map} +1 -1
- package/package.json +19 -9
- package/dist/document-operations-DZ-oUHRy.js.map +0 -1
- package/dist/index-BV00np9e.d.ts.map +0 -1
- package/dist/renown-DRnlawbP.js.map +0 -1
|
@@ -1,50 +1,18 @@
|
|
|
1
|
-
import { S as uploadOperations,
|
|
1
|
+
import { S as uploadOperations, a as setDocumentCache, b as queueActions, g as DOCUMENT_CHANGE_TYPE, i as addDocumentCacheEventHandler, p as DocumentCache, x as queueOperations } from "./document-by-id-BSZqTN66.js";
|
|
2
|
+
import { C as addResetSelectedNodeEventHandler, D as addDrivesEventHandler, G as UnsupportedDocumentTypeError, H as DocumentModelNotFoundError, T as addSetSelectedNodeOnPopStateEventHandler, _ as addSetSelectedDriveOnPopStateEventHandler, g as addSelectedDriveIdEventHandler, i as setVetraPackageManager, r as addVetraPackageManagerEventHandler, w as addSelectedNodeIdEventHandler, x as useSelectedDriveId } from "./document-model-modules-BB9s6a3m.js";
|
|
2
3
|
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-
|
|
4
|
-
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-
|
|
4
|
+
import { a as PhDocumentFieldsFragmentDoc, n as DocumentChangeType, o as PropagationMode, r as DocumentChangesDocument, t as createClient$1 } from "./client-D66jVnot.js";
|
|
5
|
+
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-BHxwP7xU.js";
|
|
5
6
|
import { logger } from "document-model";
|
|
6
7
|
import { UnsupportedDocumentModelVersionError, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, deserializeSignature, documentModelDocumentType, generateId, hashDocumentStateForScope, normalizeDocumentModelVersion, replayDocumentVersioned, setName, setPreferredEditor, toTransportAction } from "@powerhousedao/shared/document-model";
|
|
7
8
|
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
8
9
|
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
9
|
-
import { useCallback, useEffect, useRef, useState
|
|
10
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
11
|
import { GraphQLClient } from "graphql-request";
|
|
11
12
|
import { gql } from "graphql-tag";
|
|
12
13
|
import { Kind, print } from "graphql";
|
|
13
14
|
import { createClient } from "graphql-ws/client";
|
|
14
|
-
import slug from "slug";
|
|
15
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 DocumentModelNotFoundError = class extends Error {
|
|
27
|
-
documentType;
|
|
28
|
-
name = "DocumentModelNotFoundError";
|
|
29
|
-
constructor(documentType) {
|
|
30
|
-
super(`Document model module for type ${documentType} not found`);
|
|
31
|
-
this.documentType = documentType;
|
|
32
|
-
}
|
|
33
|
-
static isError(error) {
|
|
34
|
-
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var DocumentTypeMismatchError = class extends Error {
|
|
38
|
-
constructor(documentId, expectedType, actualType) {
|
|
39
|
-
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var NoSelectedDocumentError = class extends Error {
|
|
43
|
-
constructor() {
|
|
44
|
-
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
16
|
//#region src/hooks/modals.ts
|
|
49
17
|
const modalEventFunctions = makePHEventFunctions("modal");
|
|
50
18
|
/** Returns the current modal */
|
|
@@ -2135,214 +2103,6 @@ const useFeatures = featuresEventFunctions.useValue;
|
|
|
2135
2103
|
const setFeatures = featuresEventFunctions.setValue;
|
|
2136
2104
|
const addFeaturesEventHandler = featuresEventFunctions.addEventHandler;
|
|
2137
2105
|
//#endregion
|
|
2138
|
-
//#region src/utils/url.ts
|
|
2139
|
-
function resolveUrlPathname(path) {
|
|
2140
|
-
return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
|
|
2141
|
-
}
|
|
2142
|
-
/** Returns the current path without the base path */
|
|
2143
|
-
function getPathWithoutBase(path) {
|
|
2144
|
-
const basePath = window.ph?.basePath ?? "/";
|
|
2145
|
-
return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
|
|
2146
|
-
}
|
|
2147
|
-
/** Makes a URL component for a drive. */
|
|
2148
|
-
function makeDriveUrlComponent(drive) {
|
|
2149
|
-
if (!drive) return "";
|
|
2150
|
-
return `/d/${slug(drive.header.slug)}`;
|
|
2151
|
-
}
|
|
2152
|
-
/** Makes a URL component for a node. */
|
|
2153
|
-
function makeNodeSlug(node) {
|
|
2154
|
-
if (!node) return "";
|
|
2155
|
-
const nodeName = node.name;
|
|
2156
|
-
if (!nodeName) return slug(node.id);
|
|
2157
|
-
return slug(`${nodeName}-${node.id}`);
|
|
2158
|
-
}
|
|
2159
|
-
/** Extracts the node slug from a path.
|
|
2160
|
-
*
|
|
2161
|
-
* The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
|
|
2162
|
-
*/
|
|
2163
|
-
function extractNodeSlugFromPath(path) {
|
|
2164
|
-
const currentPath = getPathWithoutBase(path);
|
|
2165
|
-
return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
|
|
2166
|
-
}
|
|
2167
|
-
/** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
|
|
2168
|
-
function findUuid(input) {
|
|
2169
|
-
if (!input) return void 0;
|
|
2170
|
-
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];
|
|
2171
|
-
}
|
|
2172
|
-
function extractNodeIdFromSlug(nodeSlug) {
|
|
2173
|
-
return findUuid(nodeSlug);
|
|
2174
|
-
}
|
|
2175
|
-
function extractNodeIdFromPath(path) {
|
|
2176
|
-
return extractNodeIdFromSlug(extractNodeSlugFromPath(path));
|
|
2177
|
-
}
|
|
2178
|
-
/** Extracts the drive slug from a path.
|
|
2179
|
-
* Used for extracting drive ids from drive slugs in the URL.
|
|
2180
|
-
* Expects the path to be in the format `/d/<drive-slug>`.
|
|
2181
|
-
*/
|
|
2182
|
-
function extractDriveSlugFromPath(path) {
|
|
2183
|
-
const currentPath = getPathWithoutBase(path);
|
|
2184
|
-
return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
|
|
2185
|
-
}
|
|
2186
|
-
function extractDriveIdFromSlug(driveSlug) {
|
|
2187
|
-
return findUuid(driveSlug);
|
|
2188
|
-
}
|
|
2189
|
-
function extractDriveIdFromPath(path) {
|
|
2190
|
-
return extractDriveIdFromSlug(extractDriveSlugFromPath(path));
|
|
2191
|
-
}
|
|
2192
|
-
/**
|
|
2193
|
-
* Creates a URL string with the given pathname while preserving existing query parameters.
|
|
2194
|
-
*/
|
|
2195
|
-
function createUrlWithPreservedParams(pathname) {
|
|
2196
|
-
const search = window.location.search;
|
|
2197
|
-
return search ? `${pathname}${search}` : pathname;
|
|
2198
|
-
}
|
|
2199
|
-
//#endregion
|
|
2200
|
-
//#region src/hooks/drives.ts
|
|
2201
|
-
const drivesEventFunctions = makePHEventFunctions("drives");
|
|
2202
|
-
/** Returns all of the drives in the reactor */
|
|
2203
|
-
const useDrives = drivesEventFunctions.useValue;
|
|
2204
|
-
/** Sets the drives in the reactor */
|
|
2205
|
-
const setDrives = drivesEventFunctions.setValue;
|
|
2206
|
-
/** Adds an event handler for the drives */
|
|
2207
|
-
const addDrivesEventHandler = drivesEventFunctions.addEventHandler;
|
|
2208
|
-
//#endregion
|
|
2209
|
-
//#region src/hooks/set-selected-node.ts
|
|
2210
|
-
const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
|
|
2211
|
-
const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
|
|
2212
|
-
const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
|
|
2213
|
-
const addSelectedNodeIdEventHandler = selectedNodeIdEventFunctions.addEventHandler;
|
|
2214
|
-
/** Sets the selected node (file or folder). */
|
|
2215
|
-
function setSelectedNode(nodeOrNodeSlug) {
|
|
2216
|
-
const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
|
|
2217
|
-
setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
|
|
2218
|
-
const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
|
|
2219
|
-
if (!driveSlugFromPath) return;
|
|
2220
|
-
if (!nodeSlug) {
|
|
2221
|
-
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
|
|
2222
|
-
if (pathname === window.location.pathname) return;
|
|
2223
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2224
|
-
return;
|
|
2225
|
-
}
|
|
2226
|
-
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
|
|
2227
|
-
if (pathname === window.location.pathname) return;
|
|
2228
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2229
|
-
}
|
|
2230
|
-
function addResetSelectedNodeEventHandler() {
|
|
2231
|
-
window.addEventListener("ph:selectedDriveIdUpdated", () => {
|
|
2232
|
-
setSelectedNodeId(void 0);
|
|
2233
|
-
});
|
|
2234
|
-
}
|
|
2235
|
-
function addSetSelectedNodeOnPopStateEventHandler() {
|
|
2236
|
-
window.addEventListener("popstate", () => {
|
|
2237
|
-
const pathname = window.location.pathname;
|
|
2238
|
-
const nodeSlug = extractNodeSlugFromPath(pathname);
|
|
2239
|
-
if (extractNodeIdFromSlug(nodeSlug) !== window.ph?.selectedNodeId) setSelectedNode(nodeSlug);
|
|
2240
|
-
});
|
|
2241
|
-
}
|
|
2242
|
-
//#endregion
|
|
2243
|
-
//#region src/hooks/selected-drive.ts
|
|
2244
|
-
const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
|
|
2245
|
-
/** Returns the selected drive id */
|
|
2246
|
-
const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
|
|
2247
|
-
/** Sets the selected drive id */
|
|
2248
|
-
const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
|
|
2249
|
-
/** Adds an event handler for the selected drive id */
|
|
2250
|
-
const addSelectedDriveIdEventHandler = selectedDriveIdEventFunctions.addEventHandler;
|
|
2251
|
-
/** Returns the selected drive */
|
|
2252
|
-
function useSelectedDrive() {
|
|
2253
|
-
const drive = useSelectedDriveSafe();
|
|
2254
|
-
if (!drive[0]) throw new Error("There is no drive selected. Did you mean to call 'useSelectedDriveSafe'?");
|
|
2255
|
-
return drive;
|
|
2256
|
-
}
|
|
2257
|
-
/** Returns the selected drive, or undefined if no drive is selected */
|
|
2258
|
-
function useSelectedDriveSafe() {
|
|
2259
|
-
const selectedDriveId = useSelectedDriveId();
|
|
2260
|
-
const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
|
|
2261
|
-
const [drive, dispatch] = useDispatch(selectedDrive);
|
|
2262
|
-
if (!selectedDrive) return [void 0, void 0];
|
|
2263
|
-
return [drive, dispatch];
|
|
2264
|
-
}
|
|
2265
|
-
function setSelectedDrive(driveOrDriveSlug) {
|
|
2266
|
-
const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
|
|
2267
|
-
const drives = window.ph?.drives;
|
|
2268
|
-
const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
|
|
2269
|
-
if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
|
|
2270
|
-
if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
|
|
2271
|
-
deferDriveSelection(driveSlug);
|
|
2272
|
-
return;
|
|
2273
|
-
}
|
|
2274
|
-
cancelPendingDriveSelection();
|
|
2275
|
-
setSelectedDriveId(driveId);
|
|
2276
|
-
if (!driveId) {
|
|
2277
|
-
const pathname = resolveUrlPathname("/");
|
|
2278
|
-
if (pathname === window.location.pathname) return;
|
|
2279
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2280
|
-
return;
|
|
2281
|
-
}
|
|
2282
|
-
const pathname = resolveUrlPathname(`/d/${driveSlug}`);
|
|
2283
|
-
if (pathname === window.location.pathname) return;
|
|
2284
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2285
|
-
}
|
|
2286
|
-
const DEFERRED_DRIVE_TICK_MS = 2e3;
|
|
2287
|
-
const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
|
|
2288
|
-
function isInitialSyncInFlight() {
|
|
2289
|
-
const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
|
|
2290
|
-
if (!remotes?.length) return false;
|
|
2291
|
-
return remotes.some((remote) => {
|
|
2292
|
-
try {
|
|
2293
|
-
const snapshot = remote.channel.getConnectionState();
|
|
2294
|
-
return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
|
|
2295
|
-
} catch {
|
|
2296
|
-
return false;
|
|
2297
|
-
}
|
|
2298
|
-
});
|
|
2299
|
-
}
|
|
2300
|
-
let pendingHandler;
|
|
2301
|
-
let pendingTimeout;
|
|
2302
|
-
function cancelPendingDriveSelection() {
|
|
2303
|
-
if (pendingHandler) {
|
|
2304
|
-
window.removeEventListener("ph:drivesUpdated", pendingHandler);
|
|
2305
|
-
pendingHandler = void 0;
|
|
2306
|
-
}
|
|
2307
|
-
if (pendingTimeout) {
|
|
2308
|
-
clearTimeout(pendingTimeout);
|
|
2309
|
-
pendingTimeout = void 0;
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
function deferDriveSelection(driveSlug) {
|
|
2313
|
-
cancelPendingDriveSelection();
|
|
2314
|
-
const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
|
|
2315
|
-
const handler = () => {
|
|
2316
|
-
if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
|
|
2317
|
-
cancelPendingDriveSelection();
|
|
2318
|
-
setSelectedDrive(driveSlug);
|
|
2319
|
-
setSelectedNode(nodeSlug);
|
|
2320
|
-
};
|
|
2321
|
-
pendingHandler = handler;
|
|
2322
|
-
window.addEventListener("ph:drivesUpdated", handler);
|
|
2323
|
-
const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
|
|
2324
|
-
const scheduleTick = () => {
|
|
2325
|
-
pendingTimeout = setTimeout(() => {
|
|
2326
|
-
if (Date.now() < deadline && isInitialSyncInFlight()) {
|
|
2327
|
-
scheduleTick();
|
|
2328
|
-
return;
|
|
2329
|
-
}
|
|
2330
|
-
cancelPendingDriveSelection();
|
|
2331
|
-
const pathname = resolveUrlPathname("/");
|
|
2332
|
-
if (pathname === window.location.pathname) return;
|
|
2333
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2334
|
-
}, DEFERRED_DRIVE_TICK_MS);
|
|
2335
|
-
};
|
|
2336
|
-
scheduleTick();
|
|
2337
|
-
}
|
|
2338
|
-
function addSetSelectedDriveOnPopStateEventHandler() {
|
|
2339
|
-
window.addEventListener("popstate", () => {
|
|
2340
|
-
const pathname = window.location.pathname;
|
|
2341
|
-
const driveId = extractDriveIdFromPath(pathname);
|
|
2342
|
-
if (driveId !== window.ph?.selectedDriveId) setSelectedDrive(driveId);
|
|
2343
|
-
});
|
|
2344
|
-
}
|
|
2345
|
-
//#endregion
|
|
2346
2106
|
//#region src/hooks/use-drop-target.ts
|
|
2347
2107
|
function useDropTarget() {
|
|
2348
2108
|
const [isDropTarget, setIsDropTarget] = useState(false);
|
|
@@ -2521,56 +2281,6 @@ function hideRevisionHistory() {
|
|
|
2521
2281
|
setRevisionHistoryVisible(false);
|
|
2522
2282
|
}
|
|
2523
2283
|
//#endregion
|
|
2524
|
-
//#region src/utils/nodes.ts
|
|
2525
|
-
/** Sorts nodes by name. */
|
|
2526
|
-
function sortNodesByName(nodes) {
|
|
2527
|
-
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
2528
|
-
}
|
|
2529
|
-
/** Returns whether a node is a file. */
|
|
2530
|
-
function isFileNodeKind(node) {
|
|
2531
|
-
if (!node) return false;
|
|
2532
|
-
return node.kind.toUpperCase() === "FILE";
|
|
2533
|
-
}
|
|
2534
|
-
/** Returns whether a node is a folder. */
|
|
2535
|
-
function isFolderNodeKind(node) {
|
|
2536
|
-
if (!node) return false;
|
|
2537
|
-
return node.kind.toUpperCase() === "FOLDER";
|
|
2538
|
-
}
|
|
2539
|
-
//#endregion
|
|
2540
|
-
//#region src/hooks/items-in-selected-drive.ts
|
|
2541
|
-
/** Returns the nodes in the selected drive. */
|
|
2542
|
-
function useNodesInSelectedDrive() {
|
|
2543
|
-
const [selectedDrive] = useSelectedDriveSafe();
|
|
2544
|
-
return selectedDrive?.state.global.nodes;
|
|
2545
|
-
}
|
|
2546
|
-
/** Returns the file nodes in the selected drive. */
|
|
2547
|
-
function useFileNodesInSelectedDrive() {
|
|
2548
|
-
return useNodesInSelectedDrive()?.filter((n) => isFileNodeKind(n));
|
|
2549
|
-
}
|
|
2550
|
-
/** Returns the folder nodes in the selected drive. */
|
|
2551
|
-
function useFolderNodesInSelectedDrive() {
|
|
2552
|
-
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
2553
|
-
}
|
|
2554
|
-
/** Returns the documents in the selected drive. */
|
|
2555
|
-
function useDocumentsInSelectedDrive() {
|
|
2556
|
-
const fileNodeIds = useFileNodesInSelectedDrive()?.map((node) => node.id);
|
|
2557
|
-
return useDocumentsByIds(fileNodeIds);
|
|
2558
|
-
}
|
|
2559
|
-
/** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */
|
|
2560
|
-
function useDocumentTypesInSelectedDrive() {
|
|
2561
|
-
return (useDocumentsInSelectedDrive()?.filter(isDocumentModelDocument))?.map((doc) => doc.state.global.id);
|
|
2562
|
-
}
|
|
2563
|
-
function isDocumentModelDocument(document) {
|
|
2564
|
-
return document.header.documentType === "powerhouse/document-model";
|
|
2565
|
-
}
|
|
2566
|
-
//#endregion
|
|
2567
|
-
//#region src/hooks/selected-node.ts
|
|
2568
|
-
/** Returns the selected node. */
|
|
2569
|
-
function useSelectedNode() {
|
|
2570
|
-
const selectedNodeId = useSelectedNodeId();
|
|
2571
|
-
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
2572
|
-
}
|
|
2573
|
-
//#endregion
|
|
2574
2284
|
//#region src/hooks/selected-timeline-item.ts
|
|
2575
2285
|
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
2576
2286
|
/** Returns the selected timeline item */
|
|
@@ -2598,54 +2308,6 @@ const setPHToast = toastEventFunctions.setValue;
|
|
|
2598
2308
|
/** Adds an event handler for the toast */
|
|
2599
2309
|
const addToastEventHandler = toastEventFunctions.addEventHandler;
|
|
2600
2310
|
//#endregion
|
|
2601
|
-
//#region src/hooks/vetra-packages.ts
|
|
2602
|
-
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
2603
|
-
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
2604
|
-
/** Returns all of the Vetra packages loaded by the Connect instance */
|
|
2605
|
-
const useVetraPackages = () => {
|
|
2606
|
-
const packageManager = useVetraPackageManager();
|
|
2607
|
-
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
|
|
2608
|
-
};
|
|
2609
|
-
/** Adds the Vetra package manager event handler */
|
|
2610
|
-
const addVetraPackageManagerEventHandler = vetraPackageManagerFunctions.addEventHandler;
|
|
2611
|
-
/** Sets the Vetra package manager and registers its packages */
|
|
2612
|
-
function setVetraPackageManager(packageManager) {
|
|
2613
|
-
vetraPackageManagerFunctions.setValue(packageManager);
|
|
2614
|
-
updateReactorClientDocumentModels(packageManager.packages);
|
|
2615
|
-
updateReactorClientUpgradeManifests(packageManager.packages);
|
|
2616
|
-
packageManager.subscribe(({ packages }) => {
|
|
2617
|
-
updateReactorClientDocumentModels(packages);
|
|
2618
|
-
updateReactorClientUpgradeManifests(packages);
|
|
2619
|
-
});
|
|
2620
|
-
}
|
|
2621
|
-
function updateReactorClientDocumentModels(packages) {
|
|
2622
|
-
const documentModelModules = packages.flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && (m.version ?? 1) === (module.version ?? 1)) === index);
|
|
2623
|
-
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2624
|
-
if (!registry || documentModelModules.length === 0) return;
|
|
2625
|
-
const results = registry.registerModules(...documentModelModules);
|
|
2626
|
-
const duplicateTypes = /* @__PURE__ */ new Set();
|
|
2627
|
-
for (const result of results) if (result.status === "error") if (isDuplicateModuleError(result.error)) duplicateTypes.add(result.item.documentModel.global.id);
|
|
2628
|
-
else console.error("Failed to register document model module:", result.error);
|
|
2629
|
-
if (duplicateTypes.size > 0) {
|
|
2630
|
-
registry.unregisterModules(...duplicateTypes);
|
|
2631
|
-
registry.registerModules(...documentModelModules.filter((module) => duplicateTypes.has(module.documentModel.global.id)));
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
function updateReactorClientUpgradeManifests(packages) {
|
|
2635
|
-
const upgradeManifests = packages.flatMap((pkg) => pkg.upgradeManifests).filter((u) => u !== void 0);
|
|
2636
|
-
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2637
|
-
if (!registry || upgradeManifests.length === 0) return;
|
|
2638
|
-
const results = registry.registerUpgradeManifests(...upgradeManifests);
|
|
2639
|
-
const duplicates = [];
|
|
2640
|
-
for (const result of results) if (result.status === "error") if (isDuplicateManifestError(result.error)) duplicates.push(result);
|
|
2641
|
-
else console.error("Failed to register upgrade manifest:", result.error);
|
|
2642
|
-
if (duplicates.length > 0) {
|
|
2643
|
-
const duplicateTypes = duplicates.map((r) => r.item.documentType).filter((t) => !!t);
|
|
2644
|
-
registry.unregisterUpgradeManifests(...duplicateTypes);
|
|
2645
|
-
registry.registerUpgradeManifests(...duplicates.map((r) => r.item));
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
//#endregion
|
|
2649
2311
|
//#region src/hooks/add-ph-event-handlers.ts
|
|
2650
2312
|
const commonGlobalEventHandlerFunctions = {
|
|
2651
2313
|
loading: addLoadingEventHandler,
|
|
@@ -2822,38 +2484,6 @@ function useSwitchboardClient() {
|
|
|
2822
2484
|
return isGraphQLReactorClient(client) ? client : void 0;
|
|
2823
2485
|
}
|
|
2824
2486
|
//#endregion
|
|
2825
|
-
//#region src/hooks/document-model-modules.ts
|
|
2826
|
-
function useDocumentModelModules() {
|
|
2827
|
-
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);
|
|
2828
|
-
}
|
|
2829
|
-
/**
|
|
2830
|
-
* Resolves a document model module by document type, mirroring the registry's
|
|
2831
|
-
* semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
|
|
2832
|
-
* LATEST version of the type wins (`version ?? 1` as each module's default),
|
|
2833
|
-
* with `version` given only an exact match is returned. The reactor resolves
|
|
2834
|
-
* modules the same way when a document is created, so metadata read through
|
|
2835
|
-
* this hook and the version a creation actually uses cannot disagree.
|
|
2836
|
-
*/
|
|
2837
|
-
function useDocumentModelModuleById(id, version) {
|
|
2838
|
-
const documentModelModules = useDocumentModelModules();
|
|
2839
|
-
if (!id || !documentModelModules) return void 0;
|
|
2840
|
-
let latestModule;
|
|
2841
|
-
let latestVersion = -1;
|
|
2842
|
-
for (const module of documentModelModules) {
|
|
2843
|
-
if (module.documentModel.global.id !== id) continue;
|
|
2844
|
-
const moduleVersion = module.version ?? 1;
|
|
2845
|
-
if (version !== void 0) {
|
|
2846
|
-
if (moduleVersion === version) return module;
|
|
2847
|
-
continue;
|
|
2848
|
-
}
|
|
2849
|
-
if (moduleVersion > latestVersion) {
|
|
2850
|
-
latestVersion = moduleVersion;
|
|
2851
|
-
latestModule = module;
|
|
2852
|
-
}
|
|
2853
|
-
}
|
|
2854
|
-
return latestModule;
|
|
2855
|
-
}
|
|
2856
|
-
//#endregion
|
|
2857
2487
|
//#region src/hooks/document-operations.ts
|
|
2858
2488
|
/**
|
|
2859
2489
|
* Hook to fetch document operations via the reactor client.
|
|
@@ -2938,6 +2568,6 @@ function useDocumentOperations(documentId) {
|
|
|
2938
2568
|
};
|
|
2939
2569
|
}
|
|
2940
2570
|
//#endregion
|
|
2941
|
-
export {
|
|
2571
|
+
export { addDefaultDrivesUrlEventHandler as $, useIsAddLocalDrivesEnabled as $n, makeAuthConnectionParams as $r, setEnabledEditors as $t, useReactorClientModule as A, loadFile as Ai, setRenownUrl as An, useSentryRelease as Ar, addRenownAdaptersEventHandler as At, useDragNode as B, setPHModal as Bi, setWarnOutdatedApp as Bn, phAppConfigHooks as Br, addSwitchboardUrlEventHandler as Bt, addReactorClientModuleEventHandler as C, screamingSnakeToCamel as Ci, setIsRelationalProcessorsEnabled as Cn, useRenownChainId as Cr, addIsExternalRelationalProcessorsEnabledEventHandler as Ct, useModelRegistry as D, copyNode$1 as Di, setRenownAdapters as Dn, useRouterBasename as Dr, addIsSentryTracingEnabledEventHandler as Dt, useDatabase as E, addFolder$1 as Ei, setLogLevel as En, useRequiresHardRefresh as Er, addIsRelationalProcessorsEnabledEventHandler as Et, usePackageDiscoveryService as F, upgradeDocument as Fi, setSentryRelease as Fn, useWarnOutdatedApp as Fr, addRouterBasenameEventHandler as Ft, useFeatures as G, useDefaultDrivesUrl as Gn, setIsDragAndDropEnabled as Gr, phGlobalConfigSetters as Gt, useDropTarget as H, showDeleteNodeModal as Hi, useAnalyticsDatabaseName as Hn, phDocumentEditorConfigHooks as Hr, addVersionEventHandler as Ht, addGraphQLReactorClientEventHandler as I, getUserPermissions as Ii, setStudioMode as In, addAllowedDocumentTypesEventHandler as Ir, addSentryDsnEventHandler as It, useAttachmentService as J, useEnabledEditors as Jn, useIsDragAndDropEnabled as Jr, setBasePath as Jt, addAttachmentServiceEventHandler as K, useDisabledEditors as Kn, setIsExternalControlsEnabled as Kr, setAllowList as Kt, setGraphQLReactorClient as L, isDocumentTypeSupported as Li, setSwitchboardUrl as Ln, addIsDragAndDropEnabledEventHandler as Lr, addSentryEnvEventHandler as Lt, useSyncList as M, renameDriveNode as Mi, setRouterBasename as Mn, useSwitchboardUrl as Mr, addRenownNetworkIdEventHandler as Mt, addPackageDiscoveryServiceEventHandler as N, renameNode as Ni, setSentryDsn as Nn, useVersion as Nr, addRenownUrlEventHandler as Nt, usePGlite as O, deleteNode as Oi, setRenownChainId as On, useSentryDsn as Or, addLocalDrivesEnabledEventHandler as Ot, setPackageDiscoveryService as P, setPreferredEditorOnNode as Pi, setSentryEnv as Pn, useVersionCheckInterval as Pr, addRequiresHardRefreshEventHandler as Pt, addCliVersionEventHandler as Q, useIsAddDriveEnabled as Qn, viewFilterInputFromViewFilter as Qr, setDrivesPreserveStrategy as Qt, useGraphQLReactorClient as R, addModalEventHandler as Ri, setVersion as Rn, addIsExternalControlsEnabledEventHandler as Rr, addSentryReleaseEventHandler as Rt, addReactorClientEventHandler as S, hasRevisionConflict as Si, setIsPublicDrivesEnabled as Sn, useRenownAdapters as Sr, addIsExternalProcessorsEnabledEventHandler as St, setReactorClientModule as T, addFileWithProgress as Ti, setLocalDrivesEnabled as Tn, useRenownUrl as Tr, addIsPublicDrivesEnabledEventHandler as Tt, addFeaturesEventHandler as U, showPHModal as Ui, useBasePath as Un, phDocumentEditorConfigSetters as Ur, addWarnOutdatedAppEventHandler as Ut, useDropNode as V, showCreateDocumentModal as Vi, useAllowList as Vn, phAppConfigSetters as Vr, addVersionCheckIntervalEventHandler as Vt, setFeatures as W, usePHModal as Wi, useCliVersion as Wn, setAllowedDocumentTypes as Wr, phGlobalConfigHooks as Wt, addAnalyticsDatabaseNameEventHandler as X, useGaTrackingId as Xn, GraphQLReactorClient as Xr, setDefaultDrivesUrl as Xt, addAllowListEventHandler as Y, useFileUploadOperationsChunkSize as Yn, useIsExternalControlsEnabled as Yr, setCliVersion as Yt, addBasePathEventHandler as Z, useIsAddCloudDrivesEnabled as Zn, isGraphQLReactorClient as Zr, setDisabledEditors as Zt, addRevisionHistoryVisibleEventHandler as _, revisionMapFromRevisionsList as _i, setIsEditorReadModeEnabled as _n, useIsPublicDrivesEnabled as _r, addIsDocumentModelSelectionSettingsEnabledEventHandler as _t, addPHEventHandlers as a, StaticPackageManager as ai, setIsAddPublicDrivesEnabled as an, useIsDeleteCloudDrivesEnabled as ar, addIsAddCloudDrivesEnabledEventHandler as at, showRevisionHistory as b, convertRemoteOperations as bi, setIsExternalRelationalProcessorsEnabled as bn, useLocalDrivesEnabled as br, addIsEditorReadModeEnabledEventHandler as bt, addToastEventHandler as c, prepareSignedActions as ci, setIsAnalyticsExternalProcessorsEnabled as cn, useIsDiffAnalyticsEnabled as cr, addIsAddPublicDrivesEnabledEventHandler as ct, addSelectedTimelineRevisionEventHandler as d, MutateDocumentWithOperationsDocument as di, setIsDeleteLocalDrivesEnabled as dn, useIsEditorDebugModeEnabled as dr, addIsAnalyticsExternalProcessorsEnabledEventHandler as dt, startDocumentChangesSubscription as ei, setFileUploadOperationsChunkSize as en, useIsAddPublicDrivesEnabled as er, addDisabledEditorsEventHandler as et, setSelectedTimelineRevision as f, ReactorOperationFieldsFragmentDoc as fi, setIsDeletePublicDrivesEnabled as fn, useIsEditorReadModeEnabled as fr, addIsCloudDrivesEnabledEventHandler as ft, useSelectedTimelineItem as g, phDocumentFromMutation as gi, setIsEditorDebugModeEnabled as gn, useIsLocalDrivesEnabled as gr, addIsDiffAnalyticsEnabledEventHandler as gt, setSelectedTimelineItem as h, phDocumentFromGetDocument as hi, setIsDriveAnalyticsEnabled as hn, useIsExternalRelationalProcessorsEnabled as hr, addIsDeletePublicDrivesEnabledEventHandler as ht, useSwitchboardClient as i, subgraphUrlFromGraphqlUrl as ii, setIsAddLocalDrivesEnabled as in, useIsCloudDrivesEnabled as ir, addGaTrackingIdEventHandler as it, useSync as j, moveNode$1 as ji, setRequiresHardRefresh as jn, useStudioMode as jr, addRenownChainIdEventHandler as jt, useReactorClient as k, exportFile as ki, setRenownNetworkId as kn, useSentryEnv as kr, addLogLevelEventHandler as kt, setPHToast as l, signStampedAction as li, setIsCloudDrivesEnabled as ln, useIsDocumentModelSelectionSettingsEnabled as lr, addIsAnalyticsDatabaseWorkerEnabledEventHandler as lt, addSelectedTimelineItemEventHandler as m, makeAuthMiddleware as mi, setIsDocumentModelSelectionSettingsEnabled as mn, useIsExternalProcessorsEnabled as mr, addIsDeleteLocalDrivesEnabledEventHandler as mt, GraphQLReactorProvider as n, SubgraphSdkRegistry as ni, setIsAddCloudDrivesEnabled as nn, useIsAnalyticsEnabled as nr, addEnabledEditorsEventHandler as nt, callEventHandlerRegisterFunctions as o, packageFromDocumentModels as oi, setIsAnalyticsDatabaseWorkerEnabled as on, useIsDeleteLocalDrivesEnabled as or, addIsAddDriveEnabledEventHandler as ot, useSelectedTimelineRevision as p, ambientRenownTokenProvider as pi, setIsDiffAnalyticsEnabled as pn, useIsExternalPackagesEnabled as pr, addIsDeleteCloudDrivesEnabledEventHandler as pt, setAttachmentService as q, useDrivesPreserveStrategy as qn, useAllowedDocumentTypes as qr, setAnalyticsDatabaseName as qt, ensurePHEventHandlers as r, describeGraphQLDocument as ri, setIsAddDriveEnabled as rn, useIsAnalyticsExternalProcessorsEnabled as rr, addFileUploadOperationsChunkSizeEventHandler as rt, commonGlobalEventHandlerFunctions as s, resolveDocumentModelModule as si, setIsAnalyticsEnabled as sn, useIsDeletePublicDrivesEnabled as sr, addIsAddLocalDrivesEnabledEventHandler as st, useDocumentOperations as t, subscriptionsUrlFromGraphqlUrl as ti, setGaTrackingId as tn, useIsAnalyticsDatabaseWorkerEnabled as tr, addDrivesPreserveStrategyEventHandler as tt, usePHToast as u, stampAction as ui, setIsDeleteCloudDrivesEnabled as un, useIsDriveAnalyticsEnabled as ur, addIsAnalyticsEnabledEventHandler as ut, hideRevisionHistory as v, ConflictError as vi, setIsExternalPackagesEnabled as vn, useIsRelationalProcessorsEnabled as vr, addIsDriveAnalyticsEnabledEventHandler as vt, setReactorClient as w, addDocument as wi, setIsSentryTracingEnabled as wn, useRenownNetworkId as wr, addIsLocalDrivesEnabledEventHandler as wt, useRevisionHistoryVisible as x, extractRevisionMap as xi, setIsLocalDrivesEnabled as xn, useLogLevel as xr, addIsExternalPackagesEnabledEventHandler as xt, setRevisionHistoryVisible as y, buildPulledDocument as yi, setIsExternalProcessorsEnabled as yn, useIsSentryTracingEnabled as yr, addIsEditorDebugModeEnabledEventHandler as yt, addDraggingNodeEventHandler as z, closePHModal as zi, setVersionCheckInterval as zn, isExternalControlsEnabledEventFunctions as zr, addStudioModeEventHandler as zt };
|
|
2942
2572
|
|
|
2943
|
-
//# sourceMappingURL=document-operations-
|
|
2573
|
+
//# sourceMappingURL=document-operations-I1cGIcPg.js.map
|