mindoodb-app-sdk 0.0.40 → 0.0.42
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 +94 -3
- package/TESTING.md +1 -1
- package/dist/appBundleManifest-B0xfpaXG.d.ts +62 -0
- package/dist/chunk-6433L6TE.js +1303 -0
- package/dist/chunk-LT4FK6LU.js +146 -0
- package/dist/index.d.ts +91 -3
- package/dist/index.js +280 -1170
- package/dist/testing/index.d.ts +11 -1
- package/dist/testing/index.js +112 -13
- package/dist/{types-DlZpHkfb.d.ts → types-DxnCg5IW.d.ts} +106 -2
- package/dist/vite/index.d.ts +46 -0
- package/dist/vite/index.js +291 -0
- package/package.json +7 -2
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ab as MindooDBAppCreateViewNavigatorInput, bN as MindooDBAppViewNavigator, aK as MindooDBAppLaunchContext, ac as MindooDBAppDatabaseInfo, af as MindooDBAppDocumentApi, bP as MindooDBAppViewNavigatorOpenOptions, j as MindooDBAppAttachmentApi, ay as MindooDBAppIdentityApi, bD as MindooDBAppTimestampApi, ad as MindooDBAppDirectoryApi, d as MindooDBAppDocument, au as MindooDBAppFulltextSetup, at as MindooDBAppExtractionSetup, a as MindooDBAppBridge, bs as MindooDBAppSession, F as MindooDBAppBridgeRpcRequest, ax as MindooDBAppHostTheme, bV as MindooDBAppViewport, bH as MindooDBAppUiPreferences, a_ as MindooDBAppQueryResult, bU as MindooDBAppViewUpdateStats, B as MindooDBAppBridgePortMessage } from '../types-DxnCg5IW.js';
|
|
2
2
|
import * as mindoodb from 'mindoodb';
|
|
3
3
|
import 'mindoodb-view-language';
|
|
4
4
|
|
|
@@ -42,6 +42,7 @@ interface MockSeedDocument {
|
|
|
42
42
|
isDeleted?: boolean;
|
|
43
43
|
/** When true the doc is hidden from `list`/`get` and returned by `listInaccessible`. */
|
|
44
44
|
inaccessible?: boolean;
|
|
45
|
+
/** Key the doc is encrypted with — reported by `get` and by `listInaccessible`. */
|
|
45
46
|
decryptionKeyId?: string;
|
|
46
47
|
authorLabel?: string;
|
|
47
48
|
heads?: string[];
|
|
@@ -97,6 +98,8 @@ interface CreateMockMindooDBAppSessionOptions {
|
|
|
97
98
|
databases?: MockMindooDBAppDatabaseDefinition[];
|
|
98
99
|
onDisconnect?: () => MaybePromise<void>;
|
|
99
100
|
sealedChannel?: MockSealedChannelOptions;
|
|
101
|
+
/** Initial contents of `session.storage`. */
|
|
102
|
+
storage?: Record<string, string>;
|
|
100
103
|
}
|
|
101
104
|
interface MockMindooDBAppSessionController {
|
|
102
105
|
bridge: MindooDBAppBridge;
|
|
@@ -110,6 +113,8 @@ interface MockMindooDBAppSessionController {
|
|
|
110
113
|
emitViewportChange(viewport: MindooDBAppViewport): void;
|
|
111
114
|
emitUiPreferencesChange(uiPreferences: MindooDBAppUiPreferences): void;
|
|
112
115
|
emitLocaleChange(locale: string): void;
|
|
116
|
+
/** Runs the app's `onBeforeClose` listeners, as the host does before a teardown. */
|
|
117
|
+
emitBeforeClose(): Promise<void>;
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
declare function createMockMindooDBAppSession(options?: CreateMockMindooDBAppSessionOptions): MockMindooDBAppSessionController;
|
|
@@ -143,6 +148,11 @@ interface FakeBridgeHostController {
|
|
|
143
148
|
emitQueryResult(subscriptionId: string, result: MindooDBAppQueryResult): void;
|
|
144
149
|
/** Push a navigator view-changed event to connected apps. */
|
|
145
150
|
emitViewChanged(navigatorId: string, stats: MindooDBAppViewUpdateStats): void;
|
|
151
|
+
/**
|
|
152
|
+
* Ask connected apps to flush before teardown, as the Haven host does. Resolves `true`
|
|
153
|
+
* when every port acknowledged and `false` when the grace period ran out.
|
|
154
|
+
*/
|
|
155
|
+
requestBeforeClose(timeoutMs?: number): Promise<boolean>;
|
|
146
156
|
postPortMessage(message: MindooDBAppBridgePortMessage, transfer?: Transferable[]): void;
|
|
147
157
|
setRequestHandler(method: string, handler: FakeBridgeRequestHandler): void;
|
|
148
158
|
clearRequestHandler(method: string): void;
|
package/dist/testing/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
releaseMindooDBAppBridgeSessions
|
|
3
|
+
} from "../chunk-6433L6TE.js";
|
|
4
|
+
|
|
1
5
|
// src/testing/index.ts
|
|
2
6
|
import * as Automerge from "@automerge/automerge";
|
|
3
7
|
import {
|
|
@@ -762,6 +766,7 @@ function createDefaultLaunchContext(patch) {
|
|
|
762
766
|
appVersion: "1.0.0",
|
|
763
767
|
launchId: "test-launch",
|
|
764
768
|
runtime: "iframe",
|
|
769
|
+
hosting: "external",
|
|
765
770
|
theme: {
|
|
766
771
|
mode: "dark",
|
|
767
772
|
preset: "mindoo"
|
|
@@ -823,6 +828,12 @@ function createDefaultWritableAttachmentStream() {
|
|
|
823
828
|
}
|
|
824
829
|
};
|
|
825
830
|
}
|
|
831
|
+
function mockDecryptionKeyId(document) {
|
|
832
|
+
if (!document.decryptionKeyId || document.data._encryptFor) {
|
|
833
|
+
return {};
|
|
834
|
+
}
|
|
835
|
+
return { decryptionKeyId: document.decryptionKeyId };
|
|
836
|
+
}
|
|
826
837
|
function loadMockAutomergeDocument(document) {
|
|
827
838
|
if (document.automergeBinary) {
|
|
828
839
|
return Automerge.load(document.automergeBinary);
|
|
@@ -1282,7 +1293,8 @@ function createDatabaseHandle(definition) {
|
|
|
1282
1293
|
data: structuredClone(updated.data),
|
|
1283
1294
|
attachments: updated.attachments ? structuredClone(updated.attachments) : [],
|
|
1284
1295
|
isDeleted: false,
|
|
1285
|
-
automergeBinary: void 0
|
|
1296
|
+
automergeBinary: void 0,
|
|
1297
|
+
decryptionKeyId: existing.decryptionKeyId
|
|
1286
1298
|
});
|
|
1287
1299
|
notifyLiveQueries();
|
|
1288
1300
|
return updated;
|
|
@@ -1386,7 +1398,8 @@ function createDatabaseHandle(definition) {
|
|
|
1386
1398
|
data: structuredClone(document.data),
|
|
1387
1399
|
heads: document.heads ? [...document.heads] : void 0,
|
|
1388
1400
|
attachments: document.attachments ? structuredClone(document.attachments) : [],
|
|
1389
|
-
updatedAt: document.updatedAt
|
|
1401
|
+
updatedAt: document.updatedAt,
|
|
1402
|
+
...mockDecryptionKeyId(document)
|
|
1390
1403
|
};
|
|
1391
1404
|
},
|
|
1392
1405
|
async getRichText(docId, path, _options) {
|
|
@@ -1441,7 +1454,8 @@ function createDatabaseHandle(definition) {
|
|
|
1441
1454
|
data: structuredClone(document.data),
|
|
1442
1455
|
heads: mergedHeads,
|
|
1443
1456
|
attachments: document.attachments ? structuredClone(document.attachments) : [],
|
|
1444
|
-
updatedAt: document.updatedAt
|
|
1457
|
+
updatedAt: document.updatedAt,
|
|
1458
|
+
...mockDecryptionKeyId(document)
|
|
1445
1459
|
},
|
|
1446
1460
|
heads: mergedHeads,
|
|
1447
1461
|
changesSince
|
|
@@ -1469,7 +1483,8 @@ function createDatabaseHandle(definition) {
|
|
|
1469
1483
|
data: structuredClone(existing.data),
|
|
1470
1484
|
heads: existing.heads ? [...existing.heads] : void 0,
|
|
1471
1485
|
attachments: existing.attachments ? structuredClone(existing.attachments) : [],
|
|
1472
|
-
updatedAt: existing.updatedAt
|
|
1486
|
+
updatedAt: existing.updatedAt,
|
|
1487
|
+
...mockDecryptionKeyId(existing)
|
|
1473
1488
|
};
|
|
1474
1489
|
}
|
|
1475
1490
|
}
|
|
@@ -1499,15 +1514,18 @@ function createDatabaseHandle(definition) {
|
|
|
1499
1514
|
attachments: [],
|
|
1500
1515
|
updatedAt: createdAt
|
|
1501
1516
|
};
|
|
1502
|
-
|
|
1517
|
+
const stored = {
|
|
1503
1518
|
...created,
|
|
1504
1519
|
data: structuredClone(created.data),
|
|
1505
1520
|
attachments: [],
|
|
1506
|
-
isDeleted: false
|
|
1507
|
-
|
|
1521
|
+
isDeleted: false,
|
|
1522
|
+
decryptionKeyId: input.decryptionKeyId ?? "default"
|
|
1523
|
+
};
|
|
1524
|
+
storedDocuments.set(created.id, stored);
|
|
1508
1525
|
notifyLiveQueries();
|
|
1509
1526
|
return {
|
|
1510
|
-
...created
|
|
1527
|
+
...created,
|
|
1528
|
+
...mockDecryptionKeyId(stored)
|
|
1511
1529
|
};
|
|
1512
1530
|
},
|
|
1513
1531
|
async createMany(inputs) {
|
|
@@ -1528,15 +1546,17 @@ function createDatabaseHandle(definition) {
|
|
|
1528
1546
|
attachments: existing?.attachments ? structuredClone(existing.attachments) : [],
|
|
1529
1547
|
updatedAt
|
|
1530
1548
|
};
|
|
1531
|
-
|
|
1549
|
+
const stored = {
|
|
1532
1550
|
...updated,
|
|
1533
1551
|
data: structuredClone(updated.data),
|
|
1534
1552
|
attachments: updated.attachments ? structuredClone(updated.attachments) : [],
|
|
1535
1553
|
isDeleted: false,
|
|
1536
|
-
automergeBinary: void 0
|
|
1537
|
-
|
|
1554
|
+
automergeBinary: void 0,
|
|
1555
|
+
decryptionKeyId: existing?.decryptionKeyId ?? "default"
|
|
1556
|
+
};
|
|
1557
|
+
storedDocuments.set(docId, stored);
|
|
1538
1558
|
notifyLiveQueries();
|
|
1539
|
-
return updated;
|
|
1559
|
+
return { ...updated, ...mockDecryptionKeyId(stored) };
|
|
1540
1560
|
},
|
|
1541
1561
|
async addRecipients(docId, recipients) {
|
|
1542
1562
|
const existing = storedDocuments.get(docId);
|
|
@@ -1831,6 +1851,7 @@ function createMockSessionState(options = {}) {
|
|
|
1831
1851
|
const viewportListeners = /* @__PURE__ */ new Set();
|
|
1832
1852
|
const uiPreferencesListeners = /* @__PURE__ */ new Set();
|
|
1833
1853
|
const localeListeners = /* @__PURE__ */ new Set();
|
|
1854
|
+
const beforeCloseListeners = /* @__PURE__ */ new Set();
|
|
1834
1855
|
const databaseHandles = /* @__PURE__ */ new Map();
|
|
1835
1856
|
const databaseViewDocumentLists = /* @__PURE__ */ new Map();
|
|
1836
1857
|
const databaseViewApis = /* @__PURE__ */ new Map();
|
|
@@ -1838,6 +1859,7 @@ function createMockSessionState(options = {}) {
|
|
|
1838
1859
|
let activeMenuResolve = null;
|
|
1839
1860
|
let databaseInfos = [];
|
|
1840
1861
|
const openSealedChannels = /* @__PURE__ */ new Map();
|
|
1862
|
+
const appStorage = new Map(Object.entries(options.storage ?? {}));
|
|
1841
1863
|
const requireCapability = (databaseId, capability) => {
|
|
1842
1864
|
const info = databaseInfos.find((entry) => entry.id === databaseId);
|
|
1843
1865
|
if (!info) {
|
|
@@ -2001,6 +2023,39 @@ function createMockSessionState(options = {}) {
|
|
|
2001
2023
|
return view;
|
|
2002
2024
|
},
|
|
2003
2025
|
menus,
|
|
2026
|
+
storage: {
|
|
2027
|
+
async snapshot(snapshotOptions) {
|
|
2028
|
+
const prefixes = snapshotOptions?.prefixes;
|
|
2029
|
+
const result = {};
|
|
2030
|
+
appStorage.forEach((value, key) => {
|
|
2031
|
+
if (!prefixes?.length || prefixes.some((prefix) => key.startsWith(prefix))) {
|
|
2032
|
+
result[key] = value;
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
return result;
|
|
2036
|
+
},
|
|
2037
|
+
async get(key) {
|
|
2038
|
+
return appStorage.get(key) ?? null;
|
|
2039
|
+
},
|
|
2040
|
+
async set(key, value) {
|
|
2041
|
+
appStorage.set(key, value);
|
|
2042
|
+
},
|
|
2043
|
+
async remove(key) {
|
|
2044
|
+
appStorage.delete(key);
|
|
2045
|
+
},
|
|
2046
|
+
async keys(keysOptions) {
|
|
2047
|
+
const prefix = keysOptions?.prefix;
|
|
2048
|
+
return [...appStorage.keys()].filter((key) => !prefix || key.startsWith(prefix)).sort();
|
|
2049
|
+
},
|
|
2050
|
+
async clear(clearOptions) {
|
|
2051
|
+
const prefix = clearOptions?.prefix;
|
|
2052
|
+
if (!prefix) {
|
|
2053
|
+
appStorage.clear();
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
[...appStorage.keys()].filter((key) => key.startsWith(prefix)).forEach((key) => appStorage.delete(key));
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2004
2059
|
onThemeChange(listener) {
|
|
2005
2060
|
themeListeners.add(listener);
|
|
2006
2061
|
return () => {
|
|
@@ -2025,6 +2080,12 @@ function createMockSessionState(options = {}) {
|
|
|
2025
2080
|
localeListeners.delete(listener);
|
|
2026
2081
|
};
|
|
2027
2082
|
},
|
|
2083
|
+
onBeforeClose(listener) {
|
|
2084
|
+
beforeCloseListeners.add(listener);
|
|
2085
|
+
return () => {
|
|
2086
|
+
beforeCloseListeners.delete(listener);
|
|
2087
|
+
};
|
|
2088
|
+
},
|
|
2028
2089
|
async disconnect() {
|
|
2029
2090
|
await options.onDisconnect?.();
|
|
2030
2091
|
}
|
|
@@ -2082,6 +2143,9 @@ function createMockSessionState(options = {}) {
|
|
|
2082
2143
|
emitLocaleChange(locale) {
|
|
2083
2144
|
launchContext = mergeLaunchContext(launchContext, { locale });
|
|
2084
2145
|
localeListeners.forEach((listener) => listener(launchContext.locale));
|
|
2146
|
+
},
|
|
2147
|
+
async emitBeforeClose() {
|
|
2148
|
+
await Promise.all([...beforeCloseListeners].map(async (listener) => listener()));
|
|
2085
2149
|
}
|
|
2086
2150
|
};
|
|
2087
2151
|
}
|
|
@@ -2098,7 +2162,8 @@ function createMockMindooDBAppSession(options = {}) {
|
|
|
2098
2162
|
emitThemeChange: state.emitThemeChange,
|
|
2099
2163
|
emitViewportChange: state.emitViewportChange,
|
|
2100
2164
|
emitUiPreferencesChange: state.emitUiPreferencesChange,
|
|
2101
|
-
emitLocaleChange: state.emitLocaleChange
|
|
2165
|
+
emitLocaleChange: state.emitLocaleChange,
|
|
2166
|
+
emitBeforeClose: state.emitBeforeClose
|
|
2102
2167
|
};
|
|
2103
2168
|
}
|
|
2104
2169
|
function createMockMindooDBAppBridge(options = {}) {
|
|
@@ -2111,6 +2176,8 @@ function createFakeBridgeHost(options = {}) {
|
|
|
2111
2176
|
);
|
|
2112
2177
|
const requests = [];
|
|
2113
2178
|
const connectedPorts = /* @__PURE__ */ new Set();
|
|
2179
|
+
const beforeCloseWaiters = /* @__PURE__ */ new Map();
|
|
2180
|
+
let beforeCloseCounter = 0;
|
|
2114
2181
|
const viewSessions = /* @__PURE__ */ new Map();
|
|
2115
2182
|
const readStreams = /* @__PURE__ */ new Map();
|
|
2116
2183
|
const writeStreams = /* @__PURE__ */ new Map();
|
|
@@ -2162,6 +2229,7 @@ function createFakeBridgeHost(options = {}) {
|
|
|
2162
2229
|
port.close();
|
|
2163
2230
|
});
|
|
2164
2231
|
connectedPorts.clear();
|
|
2232
|
+
releaseMindooDBAppBridgeSessions(state.getLaunchContext().launchId);
|
|
2165
2233
|
if (previousWindowDescriptor) {
|
|
2166
2234
|
Object.defineProperty(globalThis, "window", previousWindowDescriptor);
|
|
2167
2235
|
} else if (previousWindowValue !== void 0) {
|
|
@@ -2179,6 +2247,7 @@ function createFakeBridgeHost(options = {}) {
|
|
|
2179
2247
|
if (installed) {
|
|
2180
2248
|
return;
|
|
2181
2249
|
}
|
|
2250
|
+
releaseMindooDBAppBridgeSessions(state.getLaunchContext().launchId);
|
|
2182
2251
|
previousWindowDescriptor = Object.getOwnPropertyDescriptor(
|
|
2183
2252
|
globalThis,
|
|
2184
2253
|
"window"
|
|
@@ -2740,6 +2809,10 @@ function createFakeBridgeHost(options = {}) {
|
|
|
2740
2809
|
if (!message || message.protocol !== PROTOCOL) {
|
|
2741
2810
|
return;
|
|
2742
2811
|
}
|
|
2812
|
+
if (message.kind === "before-close-ack") {
|
|
2813
|
+
beforeCloseWaiters.get(message.closeId)?.();
|
|
2814
|
+
return;
|
|
2815
|
+
}
|
|
2743
2816
|
if (message.kind === "request") {
|
|
2744
2817
|
requests.push(message);
|
|
2745
2818
|
try {
|
|
@@ -2865,6 +2938,32 @@ function createFakeBridgeHost(options = {}) {
|
|
|
2865
2938
|
};
|
|
2866
2939
|
connectedPorts.forEach((port) => port.postMessage(payload));
|
|
2867
2940
|
},
|
|
2941
|
+
async requestBeforeClose(timeoutMs = 500) {
|
|
2942
|
+
if (!connectedPorts.size) {
|
|
2943
|
+
return true;
|
|
2944
|
+
}
|
|
2945
|
+
beforeCloseCounter += 1;
|
|
2946
|
+
const closeId = `close-${beforeCloseCounter}`;
|
|
2947
|
+
let pending = connectedPorts.size;
|
|
2948
|
+
const acknowledged = await new Promise((resolve) => {
|
|
2949
|
+
const timer = setTimeout(() => resolve(false), timeoutMs);
|
|
2950
|
+
beforeCloseWaiters.set(closeId, () => {
|
|
2951
|
+
pending -= 1;
|
|
2952
|
+
if (pending <= 0) {
|
|
2953
|
+
clearTimeout(timer);
|
|
2954
|
+
resolve(true);
|
|
2955
|
+
}
|
|
2956
|
+
});
|
|
2957
|
+
const payload = {
|
|
2958
|
+
protocol: PROTOCOL,
|
|
2959
|
+
kind: "before-close",
|
|
2960
|
+
closeId
|
|
2961
|
+
};
|
|
2962
|
+
connectedPorts.forEach((port) => port.postMessage(payload));
|
|
2963
|
+
});
|
|
2964
|
+
beforeCloseWaiters.delete(closeId);
|
|
2965
|
+
return acknowledged;
|
|
2966
|
+
},
|
|
2868
2967
|
postPortMessage(message, transfer = []) {
|
|
2869
2968
|
connectedPorts.forEach((port) => port.postMessage(message, transfer));
|
|
2870
2969
|
},
|
|
@@ -2,6 +2,16 @@ import { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppViewSor
|
|
|
2
2
|
|
|
3
3
|
/** Launch target used by the Haven when opening an app. */
|
|
4
4
|
type MindooDBAppRuntime = "iframe" | "window";
|
|
5
|
+
/**
|
|
6
|
+
* How the host delivers the app's assets.
|
|
7
|
+
*
|
|
8
|
+
* - `"external"` — loaded from the app's own origin. Normal web platform behaviour.
|
|
9
|
+
* - `"hosted"` — the host serves the app's build from its own cache into a sandboxed
|
|
10
|
+
* iframe without `allow-same-origin`. The document then lives in an opaque origin,
|
|
11
|
+
* where `localStorage`, `sessionStorage`, IndexedDB and service worker registration
|
|
12
|
+
* are unavailable and throw on access.
|
|
13
|
+
*/
|
|
14
|
+
type MindooDBAppHostingMode = "external" | "hosted";
|
|
5
15
|
/** Theme mode currently active in the Haven host UI. */
|
|
6
16
|
type MindooDBAppThemeMode = "light" | "dark";
|
|
7
17
|
/** Host theme snapshot exposed to running apps. */
|
|
@@ -110,6 +120,15 @@ interface MindooDBAppLaunchContext {
|
|
|
110
120
|
appVersion?: string;
|
|
111
121
|
launchId: string;
|
|
112
122
|
runtime: MindooDBAppRuntime;
|
|
123
|
+
/**
|
|
124
|
+
* How the host delivers this app. `"hosted"` means the host serves the app's own
|
|
125
|
+
* build from its cache under an opaque origin: `localStorage`/`sessionStorage` throw
|
|
126
|
+
* on access and the app must not register a service worker of its own. `"external"`
|
|
127
|
+
* means the app was loaded from its own origin with the usual web platform storage.
|
|
128
|
+
*
|
|
129
|
+
* Available synchronously before the bridge connects via {@link isHostedBundleRuntime}.
|
|
130
|
+
*/
|
|
131
|
+
hosting: MindooDBAppHostingMode;
|
|
113
132
|
theme: MindooDBAppHostTheme;
|
|
114
133
|
viewport: MindooDBAppViewport | null;
|
|
115
134
|
uiPreferences: MindooDBAppUiPreferences;
|
|
@@ -194,6 +213,13 @@ interface MindooDBAppDocument {
|
|
|
194
213
|
attachments?: MindooDBAppAttachmentInfo[];
|
|
195
214
|
createdAt?: string;
|
|
196
215
|
updatedAt?: string;
|
|
216
|
+
/**
|
|
217
|
+
* Named shared key the document's payload is encrypted with — the key another
|
|
218
|
+
* user needs access to before they can open it. Absent for person-encrypted
|
|
219
|
+
* documents (`recipients`), where there is no shareable named key, and on
|
|
220
|
+
* hosts predating this field.
|
|
221
|
+
*/
|
|
222
|
+
decryptionKeyId?: string;
|
|
197
223
|
}
|
|
198
224
|
/** Opaque persisted id for a document revision in the MindooDB DAG. */
|
|
199
225
|
type MindooDBAppDocumentRevisionId = string;
|
|
@@ -208,6 +234,12 @@ interface MindooDBAppDocumentHistoryEntry {
|
|
|
208
234
|
isDeleted: boolean;
|
|
209
235
|
isCurrent: boolean;
|
|
210
236
|
summary?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Named shared key this revision was written with, so a key change along the
|
|
239
|
+
* timeline stays visible. Absent for person-encrypted revisions and on hosts
|
|
240
|
+
* predating this field. See {@link MindooDBAppDocument.decryptionKeyId}.
|
|
241
|
+
*/
|
|
242
|
+
decryptionKeyId?: string;
|
|
211
243
|
/**
|
|
212
244
|
* The revisions this one was written on top of — the edges of the signed
|
|
213
245
|
* change graph, in the same id space as {@link revisionId}. More than one id
|
|
@@ -895,8 +927,30 @@ interface MindooDBAppBridgeViewChangedMessage {
|
|
|
895
927
|
navigatorId: string;
|
|
896
928
|
stats: MindooDBAppViewUpdateStats;
|
|
897
929
|
}
|
|
930
|
+
/**
|
|
931
|
+
* Host-pushed event announcing that this launch is about to be torn down.
|
|
932
|
+
*
|
|
933
|
+
* Removing an iframe from the DOM discards messages its port has not delivered yet, and
|
|
934
|
+
* `pagehide` does not reliably fire for frames — so an app with queued asynchronous writes
|
|
935
|
+
* would lose them. The host therefore asks first and waits, briefly, for
|
|
936
|
+
* {@link MindooDBAppBridgeBeforeCloseAck}.
|
|
937
|
+
*
|
|
938
|
+
* The host proceeds after a short timeout regardless, so an app that does not answer is
|
|
939
|
+
* not able to block the close.
|
|
940
|
+
*/
|
|
941
|
+
interface MindooDBAppBridgeBeforeCloseMessage {
|
|
942
|
+
protocol: "mindoodb-app-bridge";
|
|
943
|
+
kind: "before-close";
|
|
944
|
+
closeId: string;
|
|
945
|
+
}
|
|
946
|
+
/** App acknowledgement that it has finished flushing and is ready to be torn down. */
|
|
947
|
+
interface MindooDBAppBridgeBeforeCloseAck {
|
|
948
|
+
protocol: "mindoodb-app-bridge";
|
|
949
|
+
kind: "before-close-ack";
|
|
950
|
+
closeId: string;
|
|
951
|
+
}
|
|
898
952
|
/** Any message that can travel across the dedicated bridge MessagePort. */
|
|
899
|
-
type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage | MindooDBAppBridgeUiPreferencesChangedMessage | MindooDBAppBridgeLocaleChangedMessage | MindooDBAppBridgeQueryResultMessage | MindooDBAppBridgeViewChangedMessage;
|
|
953
|
+
type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage | MindooDBAppBridgeUiPreferencesChangedMessage | MindooDBAppBridgeLocaleChangedMessage | MindooDBAppBridgeQueryResultMessage | MindooDBAppBridgeViewChangedMessage | MindooDBAppBridgeBeforeCloseMessage | MindooDBAppBridgeBeforeCloseAck;
|
|
900
954
|
/** Placement hint for a host-rendered overlay menu. */
|
|
901
955
|
type MindooDBAppMenuPlacement = "auto" | "bottom-start" | "bottom-end" | "top-start" | "top-end" | "right-start" | "left-start";
|
|
902
956
|
/** Semantic hint allowing Haven to tune menu behavior or styling. */
|
|
@@ -2003,6 +2057,40 @@ interface MindooDBAppSealedChannelRequestInput {
|
|
|
2003
2057
|
/** JSON-serialisable body. Sealed by the host before it leaves the device. */
|
|
2004
2058
|
payload: unknown;
|
|
2005
2059
|
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Small key/value store the host keeps on the app's behalf.
|
|
2062
|
+
*
|
|
2063
|
+
* Scoped to the app *registration*, so two registrations of the same app do not see each
|
|
2064
|
+
* other's keys, and the data survives a bundle update. Values are strings; the host
|
|
2065
|
+
* enforces a per-value and a total byte budget and rejects writes beyond it with a
|
|
2066
|
+
* `quota-exceeded` bridge error.
|
|
2067
|
+
*
|
|
2068
|
+
* This exists because a hosted app runs in an opaque origin where `localStorage` is not
|
|
2069
|
+
* available. It is meant for preferences and similar small state — documents belong in a
|
|
2070
|
+
* database, not here.
|
|
2071
|
+
*/
|
|
2072
|
+
interface MindooDBAppStorageApi {
|
|
2073
|
+
/**
|
|
2074
|
+
* Read many keys in one round trip. Without `prefixes` it returns everything the app
|
|
2075
|
+
* has stored.
|
|
2076
|
+
*
|
|
2077
|
+
* Apps that replace synchronous `localStorage` access need the whole working set up
|
|
2078
|
+
* front, and doing that as one call instead of N keeps it to a single boot round trip.
|
|
2079
|
+
*/
|
|
2080
|
+
snapshot(options?: {
|
|
2081
|
+
prefixes?: string[];
|
|
2082
|
+
}): Promise<Record<string, string>>;
|
|
2083
|
+
get(key: string): Promise<string | null>;
|
|
2084
|
+
set(key: string, value: string): Promise<void>;
|
|
2085
|
+
remove(key: string): Promise<void>;
|
|
2086
|
+
keys(options?: {
|
|
2087
|
+
prefix?: string;
|
|
2088
|
+
}): Promise<string[]>;
|
|
2089
|
+
/** Remove every key, or only those starting with `prefix`. */
|
|
2090
|
+
clear(options?: {
|
|
2091
|
+
prefix?: string;
|
|
2092
|
+
}): Promise<void>;
|
|
2093
|
+
}
|
|
2006
2094
|
/** Connected session between the running app and the Haven host. */
|
|
2007
2095
|
interface MindooDBAppSession {
|
|
2008
2096
|
/**
|
|
@@ -2074,6 +2162,11 @@ interface MindooDBAppSession {
|
|
|
2074
2162
|
*/
|
|
2075
2163
|
openViewNavigator(viewId: string, options?: MindooDBAppViewNavigatorOpenOptions): Promise<MindooDBAppViewNavigator>;
|
|
2076
2164
|
menus: MindooDBAppMenuApi;
|
|
2165
|
+
/**
|
|
2166
|
+
* Host-backed key/value storage for this app registration. Usable in both hosting
|
|
2167
|
+
* modes; required in `"hosted"` mode, where `localStorage` throws.
|
|
2168
|
+
*/
|
|
2169
|
+
storage: MindooDBAppStorageApi;
|
|
2077
2170
|
/**
|
|
2078
2171
|
* Subscribe to host-pushed theme changes (light/dark mode and preset).
|
|
2079
2172
|
* The initial theme is in `launchContext.theme`. Returns an unsubscribe
|
|
@@ -2097,6 +2190,17 @@ interface MindooDBAppSession {
|
|
|
2097
2190
|
* new BCP-47 language tag (e.g. `"de"`). Returns an unsubscribe function.
|
|
2098
2191
|
*/
|
|
2099
2192
|
onLocaleChange(listener: (locale: string) => void): () => void;
|
|
2193
|
+
/**
|
|
2194
|
+
* Run work before the host tears this launch down, e.g. flushing buffered writes.
|
|
2195
|
+
*
|
|
2196
|
+
* The host waits for all registered listeners to settle, but only for a short grace
|
|
2197
|
+
* period — return quickly and do not start new work here. A rejected listener is logged
|
|
2198
|
+
* and does not stop the teardown. Returns an unsubscribe function.
|
|
2199
|
+
*
|
|
2200
|
+
* This does not fire when the browser tab itself goes away; a crash or a killed tab can
|
|
2201
|
+
* still lose whatever was buffered.
|
|
2202
|
+
*/
|
|
2203
|
+
onBeforeClose(listener: () => void | Promise<void>): () => void;
|
|
2100
2204
|
/**
|
|
2101
2205
|
* Tear down the session: close the bridge port and release all host-side
|
|
2102
2206
|
* resources of this launch (navigators, live queries, streams). The
|
|
@@ -2115,4 +2219,4 @@ interface MindooDBAppBridge {
|
|
|
2115
2219
|
connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
|
|
2116
2220
|
}
|
|
2117
2221
|
|
|
2118
|
-
export { type
|
|
2222
|
+
export { type MindooDBAppConfiguredViewFilterMode as $, type MindooDBAppBridgeLocaleChangedMessage as A, type MindooDBAppBridgePortMessage as B, type MindooDBAppBridgeQueryResultMessage as C, type MindooDBAppBridgeRpcError as D, type MindooDBAppBridgeRpcMessage as E, type MindooDBAppBridgeRpcRequest as F, type MindooDBAppBridgeRpcSuccess as G, type MindooDBAppBridgeStreamAbortRequest as H, type MindooDBAppBridgeStreamAck as I, type MindooDBAppBridgeStreamCloseRequest as J, type MindooDBAppBridgeStreamError as K, type MindooDBAppBridgeStreamMessage as L, type MindooDBAppAttachmentPreviewMode as M, type MindooDBAppBridgeStreamOpenResult as N, type MindooDBAppBridgeStreamReadRequest as O, type MindooDBAppBridgeStreamWriteRequest as P, type MindooDBAppBridgeThemeChangedMessage as Q, type MindooDBAppBridgeUiPreferencesChangedMessage as R, type MindooDBAppBridgeViewChangedMessage as S, type MindooDBAppBridgeViewportChangedMessage as T, type MindooDBAppCapability as U, type MindooDBAppConfiguredViewCategorizationStyle as V, type MindooDBAppConfiguredViewColumn as W, type MindooDBAppConfiguredViewColumnRole as X, type MindooDBAppConfiguredViewExpressionMode as Y, type MindooDBAppConfiguredViewFieldExpression as Z, type MindooDBAppConfiguredViewFilterDefinition as _, type MindooDBAppBridge as a, type MindooDBAppQueryRow as a$, type MindooDBAppConfiguredViewFilterRule as a0, type MindooDBAppConfiguredViewFormulaExpression as a1, type MindooDBAppConfiguredViewFormulaFilterDefinition as a2, type MindooDBAppConfiguredViewPreviewMode as a3, type MindooDBAppConfiguredViewRuleFilterDefinition as a4, type MindooDBAppConfiguredViewRuleMatchMode as a5, type MindooDBAppConfiguredViewRuleOperator as a6, type MindooDBAppConfiguredViewValueExpression as a7, type MindooDBAppCreateDocumentInput as a8, type MindooDBAppCreateKeyInfo as a9, type MindooDBAppInaccessibleDocumentListQuery as aA, type MindooDBAppInaccessibleDocumentListResult as aB, type MindooDBAppJsonListDeletePatch as aC, type MindooDBAppJsonListInsertPatch as aD, type MindooDBAppJsonPatch as aE, type MindooDBAppJsonSetPatch as aF, type MindooDBAppJsonTextMarkPatch as aG, type MindooDBAppJsonTextSplicePatch as aH, type MindooDBAppJsonTextUnmarkPatch as aI, type MindooDBAppJsonUnsetPatch as aJ, type MindooDBAppLaunchContext as aK, type MindooDBAppLiveQuerySubscription as aL, type MindooDBAppMenuAnchor as aM, type MindooDBAppMenuApi as aN, type MindooDBAppMenuCommandItem as aO, type MindooDBAppMenuDismissReason as aP, type MindooDBAppMenuDismissedResult as aQ, type MindooDBAppMenuItem as aR, type MindooDBAppMenuKind as aS, type MindooDBAppMenuPlacement as aT, type MindooDBAppMenuPointAnchor as aU, type MindooDBAppMenuRect as aV, type MindooDBAppMenuRectAnchor as aW, type MindooDBAppMenuSelectionResult as aX, type MindooDBAppMenuSeparatorItem as aY, type MindooDBAppQueryCoverage as aZ, type MindooDBAppQueryResult as a_, type MindooDBAppCreateViewInput as aa, type MindooDBAppCreateViewNavigatorInput as ab, type MindooDBAppDatabaseInfo as ac, type MindooDBAppDirectoryApi as ad, type MindooDBAppDirectoryEntry as ae, type MindooDBAppDocumentApi as af, type MindooDBAppDocumentHeadCursorResult as ag, type MindooDBAppDocumentHistoryEntry as ah, type MindooDBAppDocumentListQuery as ai, type MindooDBAppDocumentListResult as aj, type MindooDBAppDocumentQuery as ak, type MindooDBAppDocumentRevisionId as al, type MindooDBAppDocumentScanPreset as am, type MindooDBAppDocumentSummary as an, type MindooDBAppEntryAttachmentRef as ao, type MindooDBAppEntryProvenance as ap, type MindooDBAppExtractDocumentTextInput as aq, type MindooDBAppExtractDocumentTextResult as ar, type MindooDBAppExtractTextFormat as as, type MindooDBAppExtractionSetup as at, type MindooDBAppFulltextSetup as au, type MindooDBAppHistoricalDocument as av, type MindooDBAppHistoryQuery as aw, type MindooDBAppHostTheme as ax, type MindooDBAppIdentityApi as ay, type MindooDBAppInaccessibleDocument as az, type MindooDBAppHostingMode as b, type MindooDBAppQuerySortKey as b0, type MindooDBAppQueryTextClause as b1, type MindooDBAppReadableAttachmentStream as b2, type MindooDBAppRecipientOptions as b3, type MindooDBAppResolvedViewDefinition as b4, type MindooDBAppResolvedViewSource as b5, type MindooDBAppRevisionPhase as b6, type MindooDBAppRevisionVerification as b7, type MindooDBAppRichTextBlockSpan as b8, type MindooDBAppRichTextGetOptions as b9, type MindooDBAppTextEdit as bA, type MindooDBAppTextPatch as bB, type MindooDBAppThemeMode as bC, type MindooDBAppTimestampApi as bD, type MindooDBAppTimestampInput as bE, type MindooDBAppTimestampProvider as bF, type MindooDBAppTimestampResult as bG, type MindooDBAppUiPreferences as bH, type MindooDBAppUpdateDocumentInput as bI, type MindooDBAppViewCursorDocumentListResult as bJ, type MindooDBAppViewCursorResult as bK, type MindooDBAppViewEntry as bL, type MindooDBAppViewEntryKind as bM, type MindooDBAppViewNavigator as bN, type MindooDBAppViewNavigatorExpansionState as bO, type MindooDBAppViewNavigatorOpenOptions as bP, type MindooDBAppViewNavigatorPageOptions as bQ, type MindooDBAppViewNavigatorPageResult as bR, type MindooDBAppViewNavigatorRangeQuery as bS, type MindooDBAppViewNavigatorSelectionState as bT, type MindooDBAppViewUpdateStats as bU, type MindooDBAppViewport as bV, type MindooDBAppWritableAttachmentStream as bW, type MindooDBAppRichTextImmutableString as ba, type MindooDBAppRichTextMarkRange as bb, type MindooDBAppRichTextMaterializeValue as bc, type MindooDBAppRichTextPatch as bd, type MindooDBAppRichTextScalar as be, type MindooDBAppRichTextSpliceStep as bf, type MindooDBAppRichTextStep as bg, type MindooDBAppRichTextStepPatch as bh, type MindooDBAppRichTextTextSpan as bi, type MindooDBAppRuntime as bj, type MindooDBAppScanAttachmentOptions as bk, type MindooDBAppScanAttachmentResult as bl, type MindooDBAppScopedDocId as bm, type MindooDBAppScopedDocumentSummary as bn, type MindooDBAppSealIntent as bo, type MindooDBAppSealedChannelOpenInput as bp, type MindooDBAppSealedChannelOpenResult as bq, type MindooDBAppSealedChannelRequestInput as br, type MindooDBAppSession as bs, type MindooDBAppShowMenuInput as bt, type MindooDBAppShowMenuResult as bu, type MindooDBAppSignPreview as bv, type MindooDBAppSignPreviewScope as bw, type MindooDBAppSignStatementInput as bx, type MindooDBAppSignStatementResult as by, type MindooDBAppStorageApi as bz, type MindooDBAppDatabase as c, type MindooDBAppDocument as d, type MindooDBAppRichTextSpan as e, type MindooDBAppRichTextSnapshot as f, MINDOODB_APP_SEAL_SIGNING_DOMAIN as g, type MindooDBAppAccessDecision as h, type MindooDBAppAccessTier as i, type MindooDBAppAttachmentApi as j, type MindooDBAppAttachmentChunk as k, type MindooDBAppAttachmentInfo as l, type MindooDBAppAttachmentPreviewOptions as m, type MindooDBAppAttachmentPreviewSession as n, type MindooDBAppAutomergeChangesPatch as o, type MindooDBAppAutomergeChangesSince as p, type MindooDBAppAutomergeGetOptions as q, type MindooDBAppAutomergePatchResult as r, type MindooDBAppAutomergeSnapshot as s, type MindooDBAppBridgeBeforeCloseAck as t, type MindooDBAppBridgeBeforeCloseMessage as u, type MindooDBAppBridgeConnectMessage as v, type MindooDBAppBridgeConnectOptions as w, type MindooDBAppBridgeConnectedMessage as x, type MindooDBAppBridgeErrorPayload as y, type MindooDBAppBridgeHandshakeErrorMessage as z };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export { g as MindooDBAppBundleManifest } from '../appBundleManifest-B0xfpaXG.js';
|
|
2
|
+
|
|
3
|
+
interface HavenBundleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Stable application identifier written to the manifest. Defaults to the `name` field
|
|
6
|
+
* of the project's package.json.
|
|
7
|
+
*/
|
|
8
|
+
appId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Human-readable version. Defaults to the `version` field of the project's
|
|
11
|
+
* package.json. Informational only — the host keys updates off the content hash.
|
|
12
|
+
*/
|
|
13
|
+
version?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Entry HTML file relative to the build output directory. Auto-detected when omitted:
|
|
16
|
+
* root `index.html`, else a nested `index.html`, else the first HTML file.
|
|
17
|
+
*/
|
|
18
|
+
entry?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Additional exclusion predicate, evaluated with the bundle-relative POSIX path. Return
|
|
21
|
+
* `true` to keep the file out of the bundle.
|
|
22
|
+
*/
|
|
23
|
+
exclude?: (relativePath: string) => boolean;
|
|
24
|
+
/** Skip `.map` files. Defaults to `true` — source maps only bloat the download. */
|
|
25
|
+
excludeSourcemaps?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface ResolvedViteConfig {
|
|
28
|
+
root: string;
|
|
29
|
+
build: {
|
|
30
|
+
outDir: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Structural subset of Vite's `Plugin`, so the SDK does not need to depend on Vite. */
|
|
34
|
+
interface HavenBundleVitePlugin {
|
|
35
|
+
name: string;
|
|
36
|
+
apply: "build";
|
|
37
|
+
configResolved: (config: ResolvedViteConfig) => void;
|
|
38
|
+
closeBundle: () => Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Emits `haven-bundle.json` and `haven-bundle.zip` next to the build output so a MindooDB
|
|
42
|
+
* host can install and update the app from a URL.
|
|
43
|
+
*/
|
|
44
|
+
declare function havenBundle(options?: HavenBundleOptions): HavenBundleVitePlugin;
|
|
45
|
+
|
|
46
|
+
export { type HavenBundleOptions, type HavenBundleVitePlugin, havenBundle };
|