@powerhousedao/reactor-browser 6.2.2-dev.51 → 6.2.2-dev.53
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-BImio0aq.d.ts → attachment-service-BaLIapiL.d.ts} +82 -8
- package/dist/attachment-service-BaLIapiL.d.ts.map +1 -0
- package/dist/{document-operations-ZLuPOV3H.js → document-operations-VigJPOEe.js} +271 -107
- package/dist/document-operations-VigJPOEe.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/src/graphql-client/entry.d.ts +2 -2
- package/dist/src/graphql-client/entry.js +2 -2
- package/package.json +9 -9
- package/dist/attachment-service-BImio0aq.d.ts.map +0 -1
- package/dist/document-operations-ZLuPOV3H.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { t as makePHEventFunctions } from "./make-ph-event-functions-DBq3iWYn.js
|
|
|
3
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
4
|
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-BZabzj4l.js";
|
|
5
5
|
import { logger } from "document-model";
|
|
6
|
-
import { UnsupportedDocumentModelVersionError, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, documentModelDocumentType, generateId, hashDocumentStateForScope, replayDocumentVersioned, setName } from "@powerhousedao/shared/document-model";
|
|
6
|
+
import { UnsupportedDocumentModelVersionError, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, documentModelDocumentType, generateId, hashDocumentStateForScope, normalizeDocumentModelVersion, replayDocumentVersioned, setName } from "@powerhousedao/shared/document-model";
|
|
7
7
|
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
8
8
|
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
9
9
|
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -988,9 +988,13 @@ const MutateDocumentWithOperationsDocument = gql`
|
|
|
988
988
|
* `prevOpIndex` is the index of that last operation: revisions count
|
|
989
989
|
* operations and indices are zero based, so an empty scope stamps `-1`, which
|
|
990
990
|
* matches what the remote controller records.
|
|
991
|
+
*
|
|
992
|
+
* `revision` overrides the scope revision the index is derived from. Only a
|
|
993
|
+
* batch needs it - {@link prepareSignedActions} stamps action N at the revision
|
|
994
|
+
* the N actions before it will have produced, which the document itself does
|
|
995
|
+
* not know yet. `prevOpHash` always comes from the supplied document's state.
|
|
991
996
|
*/
|
|
992
|
-
function stampAction(action, document) {
|
|
993
|
-
const revision = document.header.revision[action.scope] ?? 0;
|
|
997
|
+
function stampAction(action, document, revision = document.header.revision[action.scope] ?? 0) {
|
|
994
998
|
return {
|
|
995
999
|
...action,
|
|
996
1000
|
context: {
|
|
@@ -1006,12 +1010,12 @@ function stampAction(action, document) {
|
|
|
1006
1010
|
* The signer reads `context.prevOpHash` off the action, so this must run after
|
|
1007
1011
|
* {@link stampAction}.
|
|
1008
1012
|
*/
|
|
1009
|
-
async function signStampedAction(action, signer) {
|
|
1013
|
+
async function signStampedAction(action, signer, signal) {
|
|
1010
1014
|
const actionSigner = action.context?.signer;
|
|
1011
1015
|
const user = actionSigner?.user ?? signer.user;
|
|
1012
1016
|
const app = actionSigner?.app ?? signer.app;
|
|
1013
1017
|
if (!user || !app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
1014
|
-
const signature = await signer.signAction(action);
|
|
1018
|
+
const signature = await signer.signAction(action, signal);
|
|
1015
1019
|
return {
|
|
1016
1020
|
...action,
|
|
1017
1021
|
context: {
|
|
@@ -1024,6 +1028,229 @@ async function signStampedAction(action, signer) {
|
|
|
1024
1028
|
}
|
|
1025
1029
|
};
|
|
1026
1030
|
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Actions a snapshot batch cannot predict the next state for.
|
|
1033
|
+
*
|
|
1034
|
+
* `UNDO`, `REDO` and `PRUNE` rewrite history the light read path never fetched
|
|
1035
|
+
* (and the reducer appends no operation for them); `NOOP` is only ever produced
|
|
1036
|
+
* by an undo chain; the document-scope actions run through the reactor's
|
|
1037
|
+
* document-action handler rather than a document-model reducer
|
|
1038
|
+
* (`DOCUMENT_SCOPE_ACTIONS` in packages/reactor/src/executor/util.ts) and
|
|
1039
|
+
* `UPGRADE_DOCUMENT` changes which reducer applies mid-batch.
|
|
1040
|
+
*/
|
|
1041
|
+
const unsupportedBatchActions = new Set([
|
|
1042
|
+
"UNDO",
|
|
1043
|
+
"REDO",
|
|
1044
|
+
"PRUNE",
|
|
1045
|
+
"NOOP",
|
|
1046
|
+
"CREATE_DOCUMENT",
|
|
1047
|
+
"DELETE_DOCUMENT",
|
|
1048
|
+
"UPGRADE_DOCUMENT",
|
|
1049
|
+
"ADD_RELATIONSHIP",
|
|
1050
|
+
"REMOVE_RELATIONSHIP",
|
|
1051
|
+
"UPDATE_RELATIONSHIP"
|
|
1052
|
+
]);
|
|
1053
|
+
/**
|
|
1054
|
+
* The base-reducer protocol version to predict with when the snapshot's header
|
|
1055
|
+
* carries none.
|
|
1056
|
+
*
|
|
1057
|
+
* `baseReducer` reads `baseReducerVersion(document.header)` for every action and
|
|
1058
|
+
* throws when the header has no `protocolVersions` - and a header built by
|
|
1059
|
+
* {@link phDocumentFromGetDocument} never has one, because the GraphQL
|
|
1060
|
+
* `PHDocument` type does not expose it. The version only selects between the v1
|
|
1061
|
+
* and v2 UNDO/NOOP branches, and every action reaching the prediction loop is an
|
|
1062
|
+
* ordinary append-only one, so it cannot change the predicted state here; it is
|
|
1063
|
+
* passed purely so the lookup does not throw.
|
|
1064
|
+
*/
|
|
1065
|
+
const predictionProtocolVersion = 2;
|
|
1066
|
+
/**
|
|
1067
|
+
* Stamps and signs a batch of actions against one document snapshot, so every
|
|
1068
|
+
* action carries the head its predecessor will leave behind.
|
|
1069
|
+
*
|
|
1070
|
+
* The server executes the array in order, each action against the state the one
|
|
1071
|
+
* before it produced. The snapshot the light client reads has correct state and
|
|
1072
|
+
* per-scope revisions but NO operation history (see `adapter.ts`), so the chain
|
|
1073
|
+
* is predicted here: reduce action N over the working document to get the state
|
|
1074
|
+
* action N+1 hashes, and carry a virtual revision alongside it. The revision has
|
|
1075
|
+
* to be tracked separately because the reducer derives operation indices from
|
|
1076
|
+
* the last stored operation, and with an empty history that counts from zero
|
|
1077
|
+
* rather than from the document's real revision.
|
|
1078
|
+
*
|
|
1079
|
+
* A single action needs no prediction and therefore no `module`, which keeps
|
|
1080
|
+
* today's callers working unchanged. Two or more require the document's exact
|
|
1081
|
+
* reducer, one shared scope (the reactor rejects mixed-scope jobs) and only
|
|
1082
|
+
* append-only actions. Anything else rejects: a batch that cannot be predicted
|
|
1083
|
+
* must fail before the mutation, never be downgraded to unsigned.
|
|
1084
|
+
*/
|
|
1085
|
+
async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
1086
|
+
if (actions.length === 0) return [];
|
|
1087
|
+
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, signal)];
|
|
1088
|
+
const scope = sharedScope(actions);
|
|
1089
|
+
assertSupportedBatch(actions);
|
|
1090
|
+
if (!module) throw new Error(`cannot sign ${actions.length} actions: no document model module for ${snapshot.header.documentType} was supplied, so the batch state cannot be predicted`);
|
|
1091
|
+
let working = {
|
|
1092
|
+
...snapshot,
|
|
1093
|
+
operations: {
|
|
1094
|
+
...snapshot.operations,
|
|
1095
|
+
[scope]: [...snapshot.operations[scope] ?? []]
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
let revision = snapshot.header.revision[scope] ?? 0;
|
|
1099
|
+
const signed = [];
|
|
1100
|
+
for (const [index, action] of actions.entries()) {
|
|
1101
|
+
throwIfAborted(signal, index);
|
|
1102
|
+
const signedAction = await signStampedAction(stampAction(action, working, revision), signer, signal);
|
|
1103
|
+
signed.push(signedAction);
|
|
1104
|
+
const before = scopeOperationCount(working, scope);
|
|
1105
|
+
let next;
|
|
1106
|
+
try {
|
|
1107
|
+
next = module.reducer(working, signedAction, void 0, { protocolVersion: working.header.protocolVersions?.["base-reducer"] ?? predictionProtocolVersion });
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
throw new Error(`cannot sign action ${index} (${action.type}): the ${snapshot.header.documentType} reducer rejected it, so the rest of the batch cannot be predicted`, { cause: error });
|
|
1110
|
+
}
|
|
1111
|
+
const after = scopeOperationCount(next, scope);
|
|
1112
|
+
if (after !== before + 1) throw new Error(`cannot sign action ${index} (${action.type}): the reducer appended ${after - before} operations to ${scope}, expected exactly 1`);
|
|
1113
|
+
working = next;
|
|
1114
|
+
revision += 1;
|
|
1115
|
+
}
|
|
1116
|
+
return signed;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* How many operations a scope holds.
|
|
1120
|
+
*
|
|
1121
|
+
* The index signature types the array as always present, but a module's reducer
|
|
1122
|
+
* is arbitrary code: one that hands back a document without the scope should
|
|
1123
|
+
* produce the actionable error above, not a `TypeError` on `.length`.
|
|
1124
|
+
*/
|
|
1125
|
+
function scopeOperationCount(document, scope) {
|
|
1126
|
+
return document.operations[scope]?.length ?? 0;
|
|
1127
|
+
}
|
|
1128
|
+
/** The one scope a reactor job may span (`getSharedActionScope`). */
|
|
1129
|
+
function sharedScope(actions) {
|
|
1130
|
+
const scope = actions[0].scope;
|
|
1131
|
+
const mixed = actions.find((action) => action.scope !== scope);
|
|
1132
|
+
if (mixed) throw new Error(`cannot sign a batch spanning scopes "${scope}" and "${mixed.scope}": every action in one request must share a scope`);
|
|
1133
|
+
return scope;
|
|
1134
|
+
}
|
|
1135
|
+
function assertSupportedBatch(actions) {
|
|
1136
|
+
const unsupported = actions.find((action) => unsupportedBatchActions.has(action.type));
|
|
1137
|
+
if (unsupported) throw new Error(`cannot sign a batch containing ${unsupported.type}: it needs operation history or an alternate executor path, so send it as a single action`);
|
|
1138
|
+
}
|
|
1139
|
+
function throwIfAborted(signal, index) {
|
|
1140
|
+
if (signal?.aborted) throw new Error(`signing aborted before action ${index}`, { cause: signal.reason });
|
|
1141
|
+
}
|
|
1142
|
+
//#endregion
|
|
1143
|
+
//#region src/graphql-client/static-package-manager.ts
|
|
1144
|
+
/**
|
|
1145
|
+
* A fixed set of packages presented through the `IPackageManager` interface,
|
|
1146
|
+
* so the package-derived hooks - `useDocumentModelModules`,
|
|
1147
|
+
* `useDocumentModelModuleById`, `useEditorModules`, `useVetraPackages` - work
|
|
1148
|
+
* below `GraphQLReactorProvider` exactly as they do below Connect.
|
|
1149
|
+
*
|
|
1150
|
+
* Connect's package manager installs, updates and removes packages at runtime.
|
|
1151
|
+
* A light app instead declares its packages once, as code it imports itself
|
|
1152
|
+
* (every generated package root exports `manifest`, `documentModels`, `editors`
|
|
1153
|
+
* and `upgradeManifests` by name), so every mutating member throws and
|
|
1154
|
+
* `subscribe` never emits. For hand-picked modules without package artifacts,
|
|
1155
|
+
* {@link packageFromDocumentModels} wraps them in one synthetic package.
|
|
1156
|
+
*/
|
|
1157
|
+
var StaticPackageManager = class {
|
|
1158
|
+
registryUrl = null;
|
|
1159
|
+
packages;
|
|
1160
|
+
constructor(packages) {
|
|
1161
|
+
this.packages = [...packages];
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Resolves a module by document type across all packages. Mirrors the
|
|
1165
|
+
* registry's semantics (`IDocumentModelRegistry.getModule`): the LATEST
|
|
1166
|
+
* version wins, with `version ?? 1` as each module's default.
|
|
1167
|
+
*/
|
|
1168
|
+
load(documentType) {
|
|
1169
|
+
const modules = this.packages.flatMap((pkg) => pkg.documentModels);
|
|
1170
|
+
try {
|
|
1171
|
+
return Promise.resolve(resolveDocumentModelModule(modules, documentType));
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
return Promise.reject(error);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
subscribe(_handler) {
|
|
1177
|
+
return () => {};
|
|
1178
|
+
}
|
|
1179
|
+
getPackageSource(_packageName) {
|
|
1180
|
+
return null;
|
|
1181
|
+
}
|
|
1182
|
+
getPackageVersion(_packageName) {}
|
|
1183
|
+
getRegistryPackages() {
|
|
1184
|
+
return [];
|
|
1185
|
+
}
|
|
1186
|
+
addPackage(_packageName) {
|
|
1187
|
+
throw staticPackageManagerError("addPackage");
|
|
1188
|
+
}
|
|
1189
|
+
addPackages(_packageNames) {
|
|
1190
|
+
throw staticPackageManagerError("addPackages");
|
|
1191
|
+
}
|
|
1192
|
+
removePackage(_name) {
|
|
1193
|
+
throw staticPackageManagerError("removePackage");
|
|
1194
|
+
}
|
|
1195
|
+
updateLocalPackage(_pkg, _version) {
|
|
1196
|
+
throw staticPackageManagerError("updateLocalPackage");
|
|
1197
|
+
}
|
|
1198
|
+
addLocalPackage(_name, _loadedPackage, _version) {
|
|
1199
|
+
throw staticPackageManagerError("addLocalPackage");
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
/**
|
|
1203
|
+
* Resolves one document-model module out of a flat module list, with the same
|
|
1204
|
+
* rule the reactor registry uses (`IDocumentModelRegistry.getModule`, at
|
|
1205
|
+
* packages/reactor/src/registry/implementation.ts): with a `version`, only an
|
|
1206
|
+
* EXACT `version ?? 1` match resolves; without one, the LATEST version wins.
|
|
1207
|
+
*
|
|
1208
|
+
* Signing an existing document needs the exact rule. A document carries the
|
|
1209
|
+
* model version it was written with in `state.document.version`, and its
|
|
1210
|
+
* reducer is the only one whose operations that document's history can accept -
|
|
1211
|
+
* so "latest" is correct only when no version is asked for.
|
|
1212
|
+
*
|
|
1213
|
+
* Pure and dependency-free on purpose: this is reachable from the browser
|
|
1214
|
+
* entry, so it must not pull the reactor registry in as a value.
|
|
1215
|
+
*/
|
|
1216
|
+
function resolveDocumentModelModule(modules, documentType, version) {
|
|
1217
|
+
let latestModule;
|
|
1218
|
+
let latestVersion = -1;
|
|
1219
|
+
for (const module of modules) {
|
|
1220
|
+
if (module.documentModel.global.id !== documentType) continue;
|
|
1221
|
+
const moduleVersion = module.version ?? 1;
|
|
1222
|
+
if (version !== void 0 && moduleVersion === version) return module;
|
|
1223
|
+
if (moduleVersion > latestVersion) {
|
|
1224
|
+
latestVersion = moduleVersion;
|
|
1225
|
+
latestModule = module;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
if (version === void 0 && latestModule) return latestModule;
|
|
1229
|
+
throw new Error(version === void 0 ? `Unknown document type: ${documentType}` : `Unknown document model version: ${documentType} v${version}` + (latestModule ? ` (available: ${availableVersions(modules, documentType).join(", ")})` : " (no module for this document type)"));
|
|
1230
|
+
}
|
|
1231
|
+
function availableVersions(modules, documentType) {
|
|
1232
|
+
return modules.filter((module) => module.documentModel.global.id === documentType).map((module) => module.version ?? 1).sort((a, b) => a - b);
|
|
1233
|
+
}
|
|
1234
|
+
function staticPackageManagerError(member) {
|
|
1235
|
+
return /* @__PURE__ */ new Error(`${member} is not supported: StaticPackageManager holds a fixed set of packages`);
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Wraps hand-picked modules in one synthetic `DocumentModelLib`, for apps that
|
|
1239
|
+
* assemble their model list from mixed sources instead of passing whole
|
|
1240
|
+
* packages. The manifest is fabricated - loose modules carry none - so prefer
|
|
1241
|
+
* the `packages` prop with the real package exports when you have them: a real
|
|
1242
|
+
* package also carries `editors`, which makes the editor hooks work.
|
|
1243
|
+
*/
|
|
1244
|
+
function packageFromDocumentModels(documentModels) {
|
|
1245
|
+
return {
|
|
1246
|
+
manifest: {
|
|
1247
|
+
name: "graphql-reactor-provider",
|
|
1248
|
+
description: "Document models passed to GraphQLReactorProvider"
|
|
1249
|
+
},
|
|
1250
|
+
documentModels,
|
|
1251
|
+
editors: []
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1027
1254
|
//#endregion
|
|
1028
1255
|
//#region src/graphql-client/subgraph.ts
|
|
1029
1256
|
/** What {@link describeGraphQLDocument} could not read off a document. */
|
|
@@ -1210,12 +1437,16 @@ var GraphQLReactorClient = class {
|
|
|
1210
1437
|
listeners = [];
|
|
1211
1438
|
tokenProvider;
|
|
1212
1439
|
subscriptionsUrl;
|
|
1440
|
+
documentModels;
|
|
1441
|
+
signer;
|
|
1213
1442
|
stopRealtime;
|
|
1214
1443
|
realtimeStarted = false;
|
|
1215
1444
|
realtimeGeneration = 0;
|
|
1216
1445
|
realtimeErrorLogged = false;
|
|
1217
1446
|
constructor(options) {
|
|
1218
1447
|
this.tokenProvider = options.tokenProvider ?? ambientRenownTokenProvider;
|
|
1448
|
+
this.documentModels = [...options.documentModels ?? []];
|
|
1449
|
+
this.signer = options.signer;
|
|
1219
1450
|
this.subscriptionsUrl = options.realtime === false ? void 0 : options.subscriptionsUrl ?? subscriptionsUrlFromGraphqlUrl(options.url);
|
|
1220
1451
|
const middleware = makeAuthMiddleware(this.tokenProvider);
|
|
1221
1452
|
this.sdk = options.graphqlClient ?? createClient$1(options.url, middleware);
|
|
@@ -1285,7 +1516,7 @@ var GraphQLReactorClient = class {
|
|
|
1285
1516
|
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
1286
1517
|
const variables = {
|
|
1287
1518
|
documentIdentifier,
|
|
1288
|
-
actions: await prepareActionsForPush(actions, document),
|
|
1519
|
+
actions: await prepareActionsForPush(actions, document, this.documentModels, this.signer, signal),
|
|
1289
1520
|
view: { branch },
|
|
1290
1521
|
sinceRevision: sinceRevisionForActions(document, actions),
|
|
1291
1522
|
scopes: scopesForActions(actions),
|
|
@@ -1583,18 +1814,33 @@ function propagationModeInput(propagate) {
|
|
|
1583
1814
|
/**
|
|
1584
1815
|
* Stamps and signs the actions about to be pushed.
|
|
1585
1816
|
*
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1817
|
+
* With no signer the actions go out exactly as given, batch or not - this
|
|
1818
|
+
* client does not require signatures. With one, every action is signed:
|
|
1819
|
+
* {@link prepareSignedActions} predicts the chain a batch will produce by
|
|
1820
|
+
* running the document's own reducer between signatures, which is why a batch
|
|
1821
|
+
* needs the module matching the document's type and exact version.
|
|
1822
|
+
*
|
|
1823
|
+
* A batch that cannot be predicted - no matching module, mixed scopes, an
|
|
1824
|
+
* action needing history - throws here, before the mutation. Sending it
|
|
1825
|
+
* unsigned instead would silently drop the signatures the caller asked for.
|
|
1589
1826
|
*/
|
|
1590
|
-
async function prepareActionsForPush(actions, document) {
|
|
1591
|
-
const signer = resolveAmbientSigner();
|
|
1827
|
+
async function prepareActionsForPush(actions, document, documentModels, explicitSigner, signal) {
|
|
1828
|
+
const signer = explicitSigner ?? resolveAmbientSigner();
|
|
1592
1829
|
if (!signer || actions.length === 0) return actions;
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1830
|
+
return prepareSignedActions(actions, document, signer, actions.length > 1 ? resolveDocumentModelModule(documentModels, document.header.documentType, documentModelVersion(document)) : void 0, signal);
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* The document-model version the document's actions must be reduced with.
|
|
1834
|
+
*
|
|
1835
|
+
* `state` arrives as JSON over GraphQL, so its `document` scope is only as
|
|
1836
|
+
* reliable as the server that sent it - one written before that scope existed
|
|
1837
|
+
* carries no version at all. `normalizeDocumentModelVersion` maps that, and 0,
|
|
1838
|
+
* to 1: the same rule `SimpleJobExecutor` applies before asking the registry
|
|
1839
|
+
* for a module, so client and server cannot resolve different reducers.
|
|
1840
|
+
*/
|
|
1841
|
+
function documentModelVersion(document) {
|
|
1842
|
+
const documentScope = document.state.document;
|
|
1843
|
+
return normalizeDocumentModelVersion(documentScope?.version);
|
|
1598
1844
|
}
|
|
1599
1845
|
/** Resolves the signer of the logged-in user, if there is one. */
|
|
1600
1846
|
function resolveAmbientSigner() {
|
|
@@ -2489,91 +2735,6 @@ function callEventHandlerRegisterFunctions(registerFunctions) {
|
|
|
2489
2735
|
forEachObj(registerFunctions, (fn) => fn());
|
|
2490
2736
|
}
|
|
2491
2737
|
//#endregion
|
|
2492
|
-
//#region src/graphql-client/static-package-manager.ts
|
|
2493
|
-
/**
|
|
2494
|
-
* A fixed set of packages presented through the `IPackageManager` interface,
|
|
2495
|
-
* so the package-derived hooks - `useDocumentModelModules`,
|
|
2496
|
-
* `useDocumentModelModuleById`, `useEditorModules`, `useVetraPackages` - work
|
|
2497
|
-
* below `GraphQLReactorProvider` exactly as they do below Connect.
|
|
2498
|
-
*
|
|
2499
|
-
* Connect's package manager installs, updates and removes packages at runtime.
|
|
2500
|
-
* A light app instead declares its packages once, as code it imports itself
|
|
2501
|
-
* (every generated package root exports `manifest`, `documentModels`, `editors`
|
|
2502
|
-
* and `upgradeManifests` by name), so every mutating member throws and
|
|
2503
|
-
* `subscribe` never emits. For hand-picked modules without package artifacts,
|
|
2504
|
-
* {@link packageFromDocumentModels} wraps them in one synthetic package.
|
|
2505
|
-
*/
|
|
2506
|
-
var StaticPackageManager = class {
|
|
2507
|
-
registryUrl = null;
|
|
2508
|
-
packages;
|
|
2509
|
-
constructor(packages) {
|
|
2510
|
-
this.packages = [...packages];
|
|
2511
|
-
}
|
|
2512
|
-
/**
|
|
2513
|
-
* Resolves a module by document type across all packages. Mirrors the
|
|
2514
|
-
* registry's semantics (`IDocumentModelRegistry.getModule`): the LATEST
|
|
2515
|
-
* version wins, with `version ?? 1` as each module's default.
|
|
2516
|
-
*/
|
|
2517
|
-
load(documentType) {
|
|
2518
|
-
let latestModule;
|
|
2519
|
-
let latestVersion = -1;
|
|
2520
|
-
for (const pkg of this.packages) for (const module of pkg.documentModels) {
|
|
2521
|
-
if (module.documentModel.global.id !== documentType) continue;
|
|
2522
|
-
const moduleVersion = module.version ?? 1;
|
|
2523
|
-
if (moduleVersion > latestVersion) {
|
|
2524
|
-
latestVersion = moduleVersion;
|
|
2525
|
-
latestModule = module;
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
return latestModule ? Promise.resolve(latestModule) : Promise.reject(/* @__PURE__ */ new Error(`Unknown document type: ${documentType}`));
|
|
2529
|
-
}
|
|
2530
|
-
subscribe(_handler) {
|
|
2531
|
-
return () => {};
|
|
2532
|
-
}
|
|
2533
|
-
getPackageSource(_packageName) {
|
|
2534
|
-
return null;
|
|
2535
|
-
}
|
|
2536
|
-
getPackageVersion(_packageName) {}
|
|
2537
|
-
getRegistryPackages() {
|
|
2538
|
-
return [];
|
|
2539
|
-
}
|
|
2540
|
-
addPackage(_packageName) {
|
|
2541
|
-
throw staticPackageManagerError("addPackage");
|
|
2542
|
-
}
|
|
2543
|
-
addPackages(_packageNames) {
|
|
2544
|
-
throw staticPackageManagerError("addPackages");
|
|
2545
|
-
}
|
|
2546
|
-
removePackage(_name) {
|
|
2547
|
-
throw staticPackageManagerError("removePackage");
|
|
2548
|
-
}
|
|
2549
|
-
updateLocalPackage(_pkg, _version) {
|
|
2550
|
-
throw staticPackageManagerError("updateLocalPackage");
|
|
2551
|
-
}
|
|
2552
|
-
addLocalPackage(_name, _loadedPackage, _version) {
|
|
2553
|
-
throw staticPackageManagerError("addLocalPackage");
|
|
2554
|
-
}
|
|
2555
|
-
};
|
|
2556
|
-
function staticPackageManagerError(member) {
|
|
2557
|
-
return /* @__PURE__ */ new Error(`${member} is not supported: StaticPackageManager holds a fixed set of packages`);
|
|
2558
|
-
}
|
|
2559
|
-
/**
|
|
2560
|
-
* Wraps hand-picked modules in one synthetic `DocumentModelLib`, for apps that
|
|
2561
|
-
* assemble their model list from mixed sources instead of passing whole
|
|
2562
|
-
* packages. The manifest is fabricated - loose modules carry none - so prefer
|
|
2563
|
-
* the `packages` prop with the real package exports when you have them: a real
|
|
2564
|
-
* package also carries `editors`, which makes the editor hooks work.
|
|
2565
|
-
*/
|
|
2566
|
-
function packageFromDocumentModels(documentModels) {
|
|
2567
|
-
return {
|
|
2568
|
-
manifest: {
|
|
2569
|
-
name: "graphql-reactor-provider",
|
|
2570
|
-
description: "Document models passed to GraphQLReactorProvider"
|
|
2571
|
-
},
|
|
2572
|
-
documentModels,
|
|
2573
|
-
editors: []
|
|
2574
|
-
};
|
|
2575
|
-
}
|
|
2576
|
-
//#endregion
|
|
2577
2738
|
//#region src/graphql-client/graphql-reactor-provider.tsx
|
|
2578
2739
|
/**
|
|
2579
2740
|
* Registers the `window.ph` event handlers once per page.
|
|
@@ -2596,9 +2757,11 @@ function ensurePHEventHandlers() {
|
|
|
2596
2757
|
*
|
|
2597
2758
|
* It fills the document slots, plus `window.ph.vetraPackageManager` when
|
|
2598
2759
|
* `documentModels` is given (a fixed {@link StaticPackageManager}, which makes
|
|
2599
|
-
* the document-model hooks work).
|
|
2600
|
-
*
|
|
2601
|
-
*
|
|
2760
|
+
* the document-model hooks work). The same modules go to the client itself, so
|
|
2761
|
+
* a dispatch of two or more actions is signed rather than refused.
|
|
2762
|
+
* `window.ph.reactorClientModule` always stays empty, so full-reactor surfaces
|
|
2763
|
+
* (drives, jobs, editor auto-discovery) find nothing - an app below this
|
|
2764
|
+
* provider renders components it imports itself.
|
|
2602
2765
|
*
|
|
2603
2766
|
* The client is built on the client only: on the server the slots stay empty
|
|
2604
2767
|
* and the hooks report their normal loading states. The props are read once,
|
|
@@ -2613,7 +2776,8 @@ function GraphQLReactorProvider({ url, tokenProvider, subscriptionsUrl, realtime
|
|
|
2613
2776
|
url,
|
|
2614
2777
|
tokenProvider,
|
|
2615
2778
|
subscriptionsUrl,
|
|
2616
|
-
realtime
|
|
2779
|
+
realtime,
|
|
2780
|
+
documentModels
|
|
2617
2781
|
}));
|
|
2618
2782
|
useEffect(() => {
|
|
2619
2783
|
if (!client) return;
|
|
@@ -2773,6 +2937,6 @@ function useDocumentOperations(documentId) {
|
|
|
2773
2937
|
};
|
|
2774
2938
|
}
|
|
2775
2939
|
//#endregion
|
|
2776
|
-
export {
|
|
2940
|
+
export { useGraphQLReactorClient as $, ReactorOperationFieldsFragmentDoc as $i, setIsDeletePublicDrivesEnabled as $n, useIsEditorReadModeEnabled as $r, addIsCloudDrivesEnabledEventHandler as $t, isFolderNodeKind as A, showPHModal as Aa, phDocumentEditorConfigSetters as Ai, addWarnOutdatedAppEventHandler as An, useBasePath as Ar, addFeaturesEventHandler as At, setReactorClientModule as B, makeAuthConnectionParams as Bi, setEnabledEditors as Bn, useIsAddLocalDrivesEnabled as Br, addDefaultDrivesUrlEventHandler as Bt, useSelectedNode as C, getUserPermissions as Ca, addAllowedDocumentTypesEventHandler as Ci, addSentryDsnEventHandler as Cn, setStudioMode as Cr, extractNodeIdFromSlug as Ct, useFolderNodesInSelectedDrive as D, setPHModal as Da, phAppConfigHooks as Di, addSwitchboardUrlEventHandler as Dn, setWarnOutdatedApp as Dr, makeDriveUrlComponent as Dt, useFileNodesInSelectedDrive as E, closePHModal as Ea, isExternalControlsEnabledEventFunctions as Ei, addStudioModeEventHandler as En, setVersionCheckInterval as Er, getPathWithoutBase as Et, showRevisionHistory as F, NoSelectedDocumentError as Fa, useIsDragAndDropEnabled as Fi, setBasePath as Fn, useEnabledEditors as Fr, useAttachmentService as Ft, useReactorClientModule as G, subgraphUrlFromGraphqlUrl as Gi, setIsAddLocalDrivesEnabled as Gn, useIsCloudDrivesEnabled as Gr, addGaTrackingIdEventHandler as Gt, useModelRegistry as H, subscriptionsUrlFromGraphqlUrl as Hi, setGaTrackingId as Hn, useIsAnalyticsDatabaseWorkerEnabled as Hr, addDrivesPreserveStrategyEventHandler as Ht, useRevisionHistoryVisible as I, UnsupportedDocumentTypeError as Ia, useIsExternalControlsEnabled as Ii, setCliVersion as In, useFileUploadOperationsChunkSize as Ir, addAllowListEventHandler as It, addPackageDiscoveryServiceEventHandler as J, resolveDocumentModelModule as Ji, setIsAnalyticsEnabled as Jn, useIsDeletePublicDrivesEnabled as Jr, addIsAddLocalDrivesEnabledEventHandler as Jt, useSync as K, StaticPackageManager as Ki, setIsAddPublicDrivesEnabled as Kn, useIsDeleteCloudDrivesEnabled as Kr, addIsAddCloudDrivesEnabledEventHandler as Kt, addReactorClientEventHandler as L, GraphQLReactorClient as Li, setDefaultDrivesUrl as Ln, useGaTrackingId as Lr, addAnalyticsDatabaseNameEventHandler as Lt, addRevisionHistoryVisibleEventHandler as M, DocumentModelNotFoundError as Ma, setIsDragAndDropEnabled as Mi, phGlobalConfigSetters as Mn, useDefaultDrivesUrl as Mr, useFeatures as Mt, hideRevisionHistory as N, DocumentNotFoundError as Na, setIsExternalControlsEnabled as Ni, setAllowList as Nn, useDisabledEditors as Nr, addAttachmentServiceEventHandler as Nt, useNodesInSelectedDrive as O, showCreateDocumentModal as Oa, phAppConfigSetters as Oi, addVersionCheckIntervalEventHandler as On, useAllowList as Or, makeNodeSlug as Ot, setRevisionHistoryVisible as P, DocumentTypeMismatchError as Pa, useAllowedDocumentTypes as Pi, setAnalyticsDatabaseName as Pn, useDrivesPreserveStrategy as Pr, setAttachmentService as Pt, setGraphQLReactorClient as Q, MutateDocumentWithOperationsDocument as Qi, setIsDeleteLocalDrivesEnabled as Qn, useIsEditorDebugModeEnabled as Qr, addIsAnalyticsExternalProcessorsEnabledEventHandler as Qt, addReactorClientModuleEventHandler as R, isGraphQLReactorClient as Ri, setDisabledEditors as Rn, useIsAddCloudDrivesEnabled as Rr, addBasePathEventHandler as Rt, useSelectedTimelineItem as S, upgradeDocument as Sa, useWarnOutdatedApp as Si, addRouterBasenameEventHandler as Sn, setSentryRelease as Sr, extractNodeIdFromPath as St, useDocumentsInSelectedDrive as T, addModalEventHandler as Ta, addIsExternalControlsEnabledEventHandler as Ti, addSentryReleaseEventHandler as Tn, setVersion as Tr, findUuid as Tt, usePGlite as U, SubgraphSdkRegistry as Ui, setIsAddCloudDrivesEnabled as Un, useIsAnalyticsEnabled as Ur, addEnabledEditorsEventHandler as Ut, useDatabase as V, startDocumentChangesSubscription as Vi, setFileUploadOperationsChunkSize as Vn, useIsAddPublicDrivesEnabled as Vr, addDisabledEditorsEventHandler as Vt, useReactorClient as W, describeGraphQLDocument as Wi, setIsAddDriveEnabled as Wn, useIsAnalyticsExternalProcessorsEnabled as Wr, addFileUploadOperationsChunkSizeEventHandler as Wt, usePackageDiscoveryService as X, signStampedAction as Xi, setIsCloudDrivesEnabled as Xn, useIsDocumentModelSelectionSettingsEnabled as Xr, addIsAnalyticsDatabaseWorkerEnabledEventHandler as Xt, setPackageDiscoveryService as Y, prepareSignedActions as Yi, setIsAnalyticsExternalProcessorsEnabled as Yn, useIsDiffAnalyticsEnabled as Yr, addIsAddPublicDrivesEnabledEventHandler as Yt, addGraphQLReactorClientEventHandler as Z, stampAction as Zi, setIsDeleteCloudDrivesEnabled as Zn, useIsDriveAnalyticsEnabled as Zr, addIsAnalyticsEnabledEventHandler as Zt, addSelectedTimelineRevisionEventHandler as _, exportFile as _a, useSentryRelease as _i, addRenownAdaptersEventHandler as _n, setRenownUrl as _r, useDrives as _t, ensurePHEventHandlers as a, ConflictError as aa, useIsRelationalProcessorsEnabled as ai, addIsDriveAnalyticsEnabledEventHandler as an, setIsExternalPackagesEnabled as ar, addSetSelectedDriveOnPopStateEventHandler as at, addSelectedTimelineItemEventHandler as b, renameDriveNode as ba, useVersion as bi, addRenownUrlEventHandler as bn, setSentryDsn as br, extractDriveIdFromSlug as bt, callEventHandlerRegisterFunctions as c, extractRevisionMap as ca, useLogLevel as ci, addIsExternalPackagesEnabledEventHandler as cn, setIsLocalDrivesEnabled as cr, useSelectedDrive as ct, setVetraPackageManager as d, addDocument as da, useRenownNetworkId as di, addIsLocalDrivesEnabledEventHandler as dn, setIsSentryTracingEnabled as dr, addResetSelectedNodeEventHandler as dt, ambientRenownTokenProvider as ea, useIsExternalPackagesEnabled as ei, addIsDeleteCloudDrivesEnabledEventHandler as en, setIsDiffAnalyticsEnabled as er, addDraggingNodeEventHandler as et, useVetraPackageManager as f, addFile as fa, useRenownUrl as fi, addIsPublicDrivesEnabledEventHandler as fn, setLocalDrivesEnabled as fr, addSelectedNodeIdEventHandler as ft, usePHToast as g, deleteNode as ga, useSentryEnv as gi, addLogLevelEventHandler as gn, setRenownNetworkId as gr, setDrives as gt, setPHToast as h, copyNode$1 as ha, useSentryDsn as hi, addLocalDrivesEnabledEventHandler as hn, setRenownChainId as hr, addDrivesEventHandler as ht, GraphQLReactorProvider as i, revisionMapFromRevisionsList as ia, useIsPublicDrivesEnabled as ii, addIsDocumentModelSelectionSettingsEnabledEventHandler as in, setIsEditorReadModeEnabled as ir, addSelectedDriveIdEventHandler as it, sortNodesByName as j, usePHModal as ja, setAllowedDocumentTypes as ji, phGlobalConfigHooks as jn, useCliVersion as jr, setFeatures as jt, isFileNodeKind as k, showDeleteNodeModal as ka, phDocumentEditorConfigHooks as ki, addVersionEventHandler as kn, useAnalyticsDatabaseName as kr, resolveUrlPathname as kt, commonGlobalEventHandlerFunctions as l, hasRevisionConflict as la, useRenownAdapters as li, addIsExternalProcessorsEnabledEventHandler as ln, setIsPublicDrivesEnabled as lr, useSelectedDriveId as lt, addToastEventHandler as m, addFolder$1 as ma, useRouterBasename as mi, addIsSentryTracingEnabledEventHandler as mn, setRenownAdapters as mr, setSelectedNode as mt, useDocumentModelModuleById as n, phDocumentFromGetDocument as na, useIsExternalRelationalProcessorsEnabled as ni, addIsDeletePublicDrivesEnabledEventHandler as nn, setIsDriveAnalyticsEnabled as nr, useDropNode as nt, useSwitchboardClient as o, buildPulledDocument as oa, useIsSentryTracingEnabled as oi, addIsEditorDebugModeEnabledEventHandler as on, setIsExternalProcessorsEnabled as or, setSelectedDrive as ot, useVetraPackages as p, addFileWithProgress as pa, useRequiresHardRefresh as pi, addIsRelationalProcessorsEnabledEventHandler as pn, setLogLevel as pr, addSetSelectedNodeOnPopStateEventHandler as pt, useSyncList as q, packageFromDocumentModels as qi, setIsAnalyticsDatabaseWorkerEnabled as qn, useIsDeleteLocalDrivesEnabled as qr, addIsAddDriveEnabledEventHandler as qt, useDocumentModelModules as r, phDocumentFromMutation as ra, useIsLocalDrivesEnabled as ri, addIsDiffAnalyticsEnabledEventHandler as rn, setIsEditorDebugModeEnabled as rr, useDropTarget as rt, addPHEventHandlers as s, convertRemoteOperations as sa, useLocalDrivesEnabled as si, addIsEditorReadModeEnabledEventHandler as sn, setIsExternalRelationalProcessorsEnabled as sr, setSelectedDriveId as st, useDocumentOperations as t, makeAuthMiddleware as ta, useIsExternalProcessorsEnabled as ti, addIsDeleteLocalDrivesEnabledEventHandler as tn, setIsDocumentModelSelectionSettingsEnabled as tr, useDragNode as tt, addVetraPackageManagerEventHandler as u, screamingSnakeToCamel as ua, useRenownChainId as ui, addIsExternalRelationalProcessorsEnabledEventHandler as un, setIsRelationalProcessorsEnabled as ur, useSelectedDriveSafe as ut, setSelectedTimelineRevision as v, loadFile as va, useStudioMode as vi, addRenownChainIdEventHandler as vn, setRequiresHardRefresh as vr, createUrlWithPreservedParams as vt, useDocumentTypesInSelectedDrive as w, isDocumentTypeSupported as wa, addIsDragAndDropEnabledEventHandler as wi, addSentryEnvEventHandler as wn, setSwitchboardUrl as wr, extractNodeSlugFromPath as wt, setSelectedTimelineItem as x, renameNode as xa, useVersionCheckInterval as xi, addRequiresHardRefreshEventHandler as xn, setSentryEnv as xr, extractDriveSlugFromPath as xt, useSelectedTimelineRevision as y, moveNode$1 as ya, useSwitchboardUrl as yi, addRenownNetworkIdEventHandler as yn, setRouterBasename as yr, extractDriveIdFromPath as yt, setReactorClient as z, viewFilterInputFromViewFilter as zi, setDrivesPreserveStrategy as zn, useIsAddDriveEnabled as zr, addCliVersionEventHandler as zt };
|
|
2777
2941
|
|
|
2778
|
-
//# sourceMappingURL=document-operations-
|
|
2942
|
+
//# sourceMappingURL=document-operations-VigJPOEe.js.map
|