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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// src/appBundleManifest.ts
|
|
2
|
+
var MINDOODB_APP_BUNDLE_MANIFEST_FORMAT = "mindoodb.app.bundle";
|
|
3
|
+
var MINDOODB_APP_BUNDLE_MANIFEST_VERSION = 1;
|
|
4
|
+
var MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME = "haven-bundle.json";
|
|
5
|
+
var MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME = "haven-bundle.zip";
|
|
6
|
+
var SHA256_PATTERN = /^sha256-[0-9a-f]{64}$/;
|
|
7
|
+
function isMindooDBAppBundleHash(value) {
|
|
8
|
+
return typeof value === "string" && SHA256_PATTERN.test(value);
|
|
9
|
+
}
|
|
10
|
+
function hasUnsafePathSegments(path) {
|
|
11
|
+
return path.split("/").some((segment) => segment === ".." || segment === "." || segment.length === 0);
|
|
12
|
+
}
|
|
13
|
+
function normalizeMindooDBAppBundlePath(rawPath) {
|
|
14
|
+
if (typeof rawPath !== "string") {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const normalized = rawPath.replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
|
18
|
+
if (!normalized || hasUnsafePathSegments(normalized)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
function buildMindooDBAppBundleContentHashInput(files) {
|
|
24
|
+
return [...files].map((file) => `${file.path}\0${file.hash}`).sort().join("\n");
|
|
25
|
+
}
|
|
26
|
+
function isPlainObject(value) {
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
function validateSize(value) {
|
|
30
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
31
|
+
}
|
|
32
|
+
function validateMindooDBAppBundleManifest(raw) {
|
|
33
|
+
const errors = [];
|
|
34
|
+
if (!isPlainObject(raw)) {
|
|
35
|
+
return { manifest: null, errors: ["Bundle manifest must be a JSON object."] };
|
|
36
|
+
}
|
|
37
|
+
if (raw.format !== MINDOODB_APP_BUNDLE_MANIFEST_FORMAT) {
|
|
38
|
+
errors.push(
|
|
39
|
+
`Bundle manifest format must be "${MINDOODB_APP_BUNDLE_MANIFEST_FORMAT}", received ${JSON.stringify(raw.format)}.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if (raw.formatVersion !== MINDOODB_APP_BUNDLE_MANIFEST_VERSION) {
|
|
43
|
+
errors.push(
|
|
44
|
+
`Unsupported bundle manifest version ${JSON.stringify(raw.formatVersion)}, expected ${MINDOODB_APP_BUNDLE_MANIFEST_VERSION}.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (typeof raw.appId !== "string" || !raw.appId.trim()) {
|
|
48
|
+
errors.push("Bundle manifest is missing a non-empty appId.");
|
|
49
|
+
}
|
|
50
|
+
if (typeof raw.version !== "string" || !raw.version.trim()) {
|
|
51
|
+
errors.push("Bundle manifest is missing a non-empty version.");
|
|
52
|
+
}
|
|
53
|
+
if (!isMindooDBAppBundleHash(raw.contentHash)) {
|
|
54
|
+
errors.push("Bundle manifest contentHash must be a sha256-<hex> digest.");
|
|
55
|
+
}
|
|
56
|
+
if (typeof raw.generatedAt !== "string" || Number.isNaN(Date.parse(raw.generatedAt))) {
|
|
57
|
+
errors.push("Bundle manifest generatedAt must be an ISO timestamp.");
|
|
58
|
+
}
|
|
59
|
+
const archive = raw.archive;
|
|
60
|
+
if (!isPlainObject(archive)) {
|
|
61
|
+
errors.push("Bundle manifest is missing an archive descriptor.");
|
|
62
|
+
} else {
|
|
63
|
+
if (!normalizeMindooDBAppBundlePath(archive.path)) {
|
|
64
|
+
errors.push(`Bundle manifest archive path ${JSON.stringify(archive.path)} is not a safe relative path.`);
|
|
65
|
+
}
|
|
66
|
+
if (!isMindooDBAppBundleHash(archive.hash)) {
|
|
67
|
+
errors.push("Bundle manifest archive hash must be a sha256-<hex> digest.");
|
|
68
|
+
}
|
|
69
|
+
if (!validateSize(archive.size)) {
|
|
70
|
+
errors.push("Bundle manifest archive size must be a non-negative integer.");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const files = raw.files;
|
|
74
|
+
const normalizedFiles = [];
|
|
75
|
+
if (!Array.isArray(files) || files.length === 0) {
|
|
76
|
+
errors.push("Bundle manifest must list at least one file.");
|
|
77
|
+
} else {
|
|
78
|
+
const seen = /* @__PURE__ */ new Set();
|
|
79
|
+
files.forEach((file, index) => {
|
|
80
|
+
if (!isPlainObject(file)) {
|
|
81
|
+
errors.push(`Bundle manifest file #${index} must be an object.`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const path = normalizeMindooDBAppBundlePath(file.path);
|
|
85
|
+
if (!path) {
|
|
86
|
+
errors.push(`Bundle manifest file #${index} has an unsafe path ${JSON.stringify(file.path)}.`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (seen.has(path)) {
|
|
90
|
+
errors.push(`Bundle manifest lists "${path}" more than once.`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (!isMindooDBAppBundleHash(file.hash)) {
|
|
94
|
+
errors.push(`Bundle manifest file "${path}" must carry a sha256-<hex> digest.`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!validateSize(file.size)) {
|
|
98
|
+
errors.push(`Bundle manifest file "${path}" must carry a non-negative integer size.`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
seen.add(path);
|
|
102
|
+
normalizedFiles.push({ path, hash: file.hash, size: file.size });
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const entry = normalizeMindooDBAppBundlePath(raw.entry);
|
|
106
|
+
if (!entry) {
|
|
107
|
+
errors.push(`Bundle manifest entry ${JSON.stringify(raw.entry)} is not a safe relative path.`);
|
|
108
|
+
} else if (!entry.toLowerCase().endsWith(".html")) {
|
|
109
|
+
errors.push(`Bundle manifest entry "${entry}" must be an HTML file.`);
|
|
110
|
+
} else if (normalizedFiles.length && !normalizedFiles.some((file) => file.path === entry)) {
|
|
111
|
+
errors.push(`Bundle manifest entry "${entry}" is not part of the file list.`);
|
|
112
|
+
}
|
|
113
|
+
if (errors.length) {
|
|
114
|
+
return { manifest: null, errors };
|
|
115
|
+
}
|
|
116
|
+
const validated = raw;
|
|
117
|
+
return {
|
|
118
|
+
manifest: {
|
|
119
|
+
format: MINDOODB_APP_BUNDLE_MANIFEST_FORMAT,
|
|
120
|
+
formatVersion: MINDOODB_APP_BUNDLE_MANIFEST_VERSION,
|
|
121
|
+
appId: validated.appId.trim(),
|
|
122
|
+
version: validated.version.trim(),
|
|
123
|
+
entry,
|
|
124
|
+
archive: {
|
|
125
|
+
path: normalizeMindooDBAppBundlePath(archive.path),
|
|
126
|
+
hash: archive.hash,
|
|
127
|
+
size: archive.size
|
|
128
|
+
},
|
|
129
|
+
contentHash: validated.contentHash,
|
|
130
|
+
generatedAt: validated.generatedAt,
|
|
131
|
+
files: normalizedFiles
|
|
132
|
+
},
|
|
133
|
+
errors: []
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export {
|
|
138
|
+
MINDOODB_APP_BUNDLE_MANIFEST_FORMAT,
|
|
139
|
+
MINDOODB_APP_BUNDLE_MANIFEST_VERSION,
|
|
140
|
+
MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME,
|
|
141
|
+
MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME,
|
|
142
|
+
isMindooDBAppBundleHash,
|
|
143
|
+
normalizeMindooDBAppBundlePath,
|
|
144
|
+
buildMindooDBAppBundleContentHashInput,
|
|
145
|
+
validateMindooDBAppBundleManifest
|
|
146
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as
|
|
2
|
-
export {
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppHostingMode, c as MindooDBAppDatabase, d as MindooDBAppDocument, e as MindooDBAppRichTextSpan, f as MindooDBAppRichTextSnapshot } from './types-DxnCg5IW.js';
|
|
2
|
+
export { g as MINDOODB_APP_SEAL_SIGNING_DOMAIN, h as MindooDBAppAccessDecision, i as MindooDBAppAccessTier, j as MindooDBAppAttachmentApi, k as MindooDBAppAttachmentChunk, l as MindooDBAppAttachmentInfo, m as MindooDBAppAttachmentPreviewOptions, n as MindooDBAppAttachmentPreviewSession, o as MindooDBAppAutomergeChangesPatch, p as MindooDBAppAutomergeChangesSince, q as MindooDBAppAutomergeGetOptions, r as MindooDBAppAutomergePatchResult, s as MindooDBAppAutomergeSnapshot, t as MindooDBAppBridgeBeforeCloseAck, u as MindooDBAppBridgeBeforeCloseMessage, v as MindooDBAppBridgeConnectMessage, w as MindooDBAppBridgeConnectOptions, x as MindooDBAppBridgeConnectedMessage, y as MindooDBAppBridgeErrorPayload, z as MindooDBAppBridgeHandshakeErrorMessage, A as MindooDBAppBridgeLocaleChangedMessage, B as MindooDBAppBridgePortMessage, C as MindooDBAppBridgeQueryResultMessage, D as MindooDBAppBridgeRpcError, E as MindooDBAppBridgeRpcMessage, F as MindooDBAppBridgeRpcRequest, G as MindooDBAppBridgeRpcSuccess, H as MindooDBAppBridgeStreamAbortRequest, I as MindooDBAppBridgeStreamAck, J as MindooDBAppBridgeStreamCloseRequest, K as MindooDBAppBridgeStreamError, L as MindooDBAppBridgeStreamMessage, N as MindooDBAppBridgeStreamOpenResult, O as MindooDBAppBridgeStreamReadRequest, P as MindooDBAppBridgeStreamWriteRequest, Q as MindooDBAppBridgeThemeChangedMessage, R as MindooDBAppBridgeUiPreferencesChangedMessage, S as MindooDBAppBridgeViewChangedMessage, T as MindooDBAppBridgeViewportChangedMessage, U as MindooDBAppCapability, V as MindooDBAppConfiguredViewCategorizationStyle, W as MindooDBAppConfiguredViewColumn, X as MindooDBAppConfiguredViewColumnRole, Y as MindooDBAppConfiguredViewExpressionMode, Z as MindooDBAppConfiguredViewFieldExpression, _ as MindooDBAppConfiguredViewFilterDefinition, $ as MindooDBAppConfiguredViewFilterMode, a0 as MindooDBAppConfiguredViewFilterRule, a1 as MindooDBAppConfiguredViewFormulaExpression, a2 as MindooDBAppConfiguredViewFormulaFilterDefinition, a3 as MindooDBAppConfiguredViewPreviewMode, a4 as MindooDBAppConfiguredViewRuleFilterDefinition, a5 as MindooDBAppConfiguredViewRuleMatchMode, a6 as MindooDBAppConfiguredViewRuleOperator, a7 as MindooDBAppConfiguredViewValueExpression, a8 as MindooDBAppCreateDocumentInput, a9 as MindooDBAppCreateKeyInfo, aa as MindooDBAppCreateViewInput, ab as MindooDBAppCreateViewNavigatorInput, ac as MindooDBAppDatabaseInfo, ad as MindooDBAppDirectoryApi, ae as MindooDBAppDirectoryEntry, af as MindooDBAppDocumentApi, ag as MindooDBAppDocumentHeadCursorResult, ah as MindooDBAppDocumentHistoryEntry, ai as MindooDBAppDocumentListQuery, aj as MindooDBAppDocumentListResult, ak as MindooDBAppDocumentQuery, al as MindooDBAppDocumentRevisionId, am as MindooDBAppDocumentScanPreset, an as MindooDBAppDocumentSummary, ao as MindooDBAppEntryAttachmentRef, ap as MindooDBAppEntryProvenance, aq as MindooDBAppExtractDocumentTextInput, ar as MindooDBAppExtractDocumentTextResult, as as MindooDBAppExtractTextFormat, at as MindooDBAppExtractionSetup, au as MindooDBAppFulltextSetup, av as MindooDBAppHistoricalDocument, aw as MindooDBAppHistoryQuery, ax as MindooDBAppHostTheme, ay as MindooDBAppIdentityApi, az as MindooDBAppInaccessibleDocument, aA as MindooDBAppInaccessibleDocumentListQuery, aB as MindooDBAppInaccessibleDocumentListResult, aC as MindooDBAppJsonListDeletePatch, aD as MindooDBAppJsonListInsertPatch, aE as MindooDBAppJsonPatch, aF as MindooDBAppJsonSetPatch, aG as MindooDBAppJsonTextMarkPatch, aH as MindooDBAppJsonTextSplicePatch, aI as MindooDBAppJsonTextUnmarkPatch, aJ as MindooDBAppJsonUnsetPatch, aK as MindooDBAppLaunchContext, aL as MindooDBAppLiveQuerySubscription, aM as MindooDBAppMenuAnchor, aN as MindooDBAppMenuApi, aO as MindooDBAppMenuCommandItem, aP as MindooDBAppMenuDismissReason, aQ as MindooDBAppMenuDismissedResult, aR as MindooDBAppMenuItem, aS as MindooDBAppMenuKind, aT as MindooDBAppMenuPlacement, aU as MindooDBAppMenuPointAnchor, aV as MindooDBAppMenuRect, aW as MindooDBAppMenuRectAnchor, aX as MindooDBAppMenuSelectionResult, aY as MindooDBAppMenuSeparatorItem, aZ as MindooDBAppQueryCoverage, a_ as MindooDBAppQueryResult, a$ as MindooDBAppQueryRow, b0 as MindooDBAppQuerySortKey, b1 as MindooDBAppQueryTextClause, b2 as MindooDBAppReadableAttachmentStream, b3 as MindooDBAppRecipientOptions, b4 as MindooDBAppResolvedViewDefinition, b5 as MindooDBAppResolvedViewSource, b6 as MindooDBAppRevisionPhase, b7 as MindooDBAppRevisionVerification, b8 as MindooDBAppRichTextBlockSpan, b9 as MindooDBAppRichTextGetOptions, ba as MindooDBAppRichTextImmutableString, bb as MindooDBAppRichTextMarkRange, bc as MindooDBAppRichTextMaterializeValue, bd as MindooDBAppRichTextPatch, be as MindooDBAppRichTextScalar, bf as MindooDBAppRichTextSpliceStep, bg as MindooDBAppRichTextStep, bh as MindooDBAppRichTextStepPatch, bi as MindooDBAppRichTextTextSpan, bj as MindooDBAppRuntime, bk as MindooDBAppScanAttachmentOptions, bl as MindooDBAppScanAttachmentResult, bm as MindooDBAppScopedDocId, bn as MindooDBAppScopedDocumentSummary, bo as MindooDBAppSealIntent, bp as MindooDBAppSealedChannelOpenInput, bq as MindooDBAppSealedChannelOpenResult, br as MindooDBAppSealedChannelRequestInput, bs as MindooDBAppSession, bt as MindooDBAppShowMenuInput, bu as MindooDBAppShowMenuResult, bv as MindooDBAppSignPreview, bw as MindooDBAppSignPreviewScope, bx as MindooDBAppSignStatementInput, by as MindooDBAppSignStatementResult, bz as MindooDBAppStorageApi, bA as MindooDBAppTextEdit, bB as MindooDBAppTextPatch, bC as MindooDBAppThemeMode, bD as MindooDBAppTimestampApi, bE as MindooDBAppTimestampInput, bF as MindooDBAppTimestampProvider, bG as MindooDBAppTimestampResult, bH as MindooDBAppUiPreferences, bI as MindooDBAppUpdateDocumentInput, bJ as MindooDBAppViewCursorDocumentListResult, bK as MindooDBAppViewCursorResult, bL as MindooDBAppViewEntry, bM as MindooDBAppViewEntryKind, bN as MindooDBAppViewNavigator, bO as MindooDBAppViewNavigatorExpansionState, bP as MindooDBAppViewNavigatorOpenOptions, bQ as MindooDBAppViewNavigatorPageOptions, bR as MindooDBAppViewNavigatorPageResult, bS as MindooDBAppViewNavigatorRangeQuery, bT as MindooDBAppViewNavigatorSelectionState, bU as MindooDBAppViewUpdateStats, bV as MindooDBAppViewport, bW as MindooDBAppWritableAttachmentStream } from './types-DxnCg5IW.js';
|
|
3
|
+
export { M as MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME, a as MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME, b as MINDOODB_APP_BUNDLE_MANIFEST_FORMAT, c as MINDOODB_APP_BUNDLE_MANIFEST_VERSION, d as MindooDBAppBundleArchive, e as MindooDBAppBundleFileEntry, f as MindooDBAppBundleHash, g as MindooDBAppBundleManifest, h as MindooDBAppBundleManifestValidation, i as buildMindooDBAppBundleContentHashInput, j as isMindooDBAppBundleHash, n as normalizeMindooDBAppBundlePath, v as validateMindooDBAppBundleManifest } from './appBundleManifest-B0xfpaXG.js';
|
|
3
4
|
import { MindooDBAppBooleanExpression } from 'mindoodb-view-language';
|
|
4
5
|
export { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppFilterDefinition, MindooDBAppViewCategoryChildrenPageRequest, MindooDBAppViewColumn, MindooDBAppViewColumnRole, MindooDBAppViewDefinition, MindooDBAppViewExpansionState, MindooDBAppViewExpressionBase, MindooDBAppViewExpressionDatePart, MindooDBAppViewExpressionOperation, MindooDBAppViewFieldExpression, MindooDBAppViewIfExpression, MindooDBAppViewLetExpression, MindooDBAppViewLiteralExpression, MindooDBAppViewLookupByPath, MindooDBAppViewOperationExpression, MindooDBAppViewOriginExpression, MindooDBAppViewPageRequest, MindooDBAppViewPageResult, MindooDBAppViewRow, MindooDBAppViewSortDirection, MindooDBAppViewTotalMode, MindooDBAppViewValueExpressionRef, MindooDBAppViewVariableExpression, createViewLanguage } from 'mindoodb-view-language';
|
|
5
6
|
import { MindooDB, MindooQuerySortKey, MindooQueryOptions, MindooQueryResult } from 'mindoodb';
|
|
@@ -30,15 +31,102 @@ declare function abbreviateCanonicalName(value: string): string;
|
|
|
30
31
|
*/
|
|
31
32
|
declare function expandAbbreviatedName(value: string): string;
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Drops memoised sessions so the next `connect()` performs a fresh handshake.
|
|
36
|
+
*
|
|
37
|
+
* A real app never needs this: its document dies together with the host. Test harnesses
|
|
38
|
+
* do, because they stand up several hosts under the same launch id inside one JavaScript
|
|
39
|
+
* realm, and a cached session would still point at the previous host's port.
|
|
40
|
+
*
|
|
41
|
+
* @param launchId Release only this launch. Omit to release all of them.
|
|
42
|
+
*/
|
|
43
|
+
declare function releaseMindooDBAppBridgeSessions(launchId?: string): void;
|
|
33
44
|
/**
|
|
34
45
|
* Creates the browser-side bridge entry point used by MindooDB apps.
|
|
35
46
|
*
|
|
36
47
|
* The returned object performs the initial postMessage handshake with the
|
|
37
48
|
* Haven host and exposes a session with document, view, and attachment
|
|
38
49
|
* APIs over a dedicated `MessagePort`.
|
|
50
|
+
*
|
|
51
|
+
* `connect()` is memoised per launch id: repeated calls resolve to the same session, and
|
|
52
|
+
* concurrent calls share a single in-flight handshake. The entry is released when the
|
|
53
|
+
* session disconnects or the handshake fails, so a later `connect()` can retry.
|
|
39
54
|
*/
|
|
40
55
|
declare function createMindooDBAppBridge(): MindooDBAppBridge;
|
|
41
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Query parameter the host appends to the app URL so the app can tell how it is being
|
|
59
|
+
* delivered before any asynchronous work has happened.
|
|
60
|
+
*/
|
|
61
|
+
declare const MINDOODB_APP_HOSTING_QUERY_PARAM = "mindoodbAppHosting";
|
|
62
|
+
/**
|
|
63
|
+
* Reads the hosting mode synchronously from the current URL.
|
|
64
|
+
*
|
|
65
|
+
* Boot-time decisions — registering a service worker, installing the storage shim —
|
|
66
|
+
* happen long before the bridge handshake completes, so they cannot wait for
|
|
67
|
+
* {@link MindooDBAppSession.getLaunchContext}. Unknown or missing values resolve to
|
|
68
|
+
* `"external"`, which is the behaviour every app had before hosted bundles existed.
|
|
69
|
+
*
|
|
70
|
+
* @param search Optional query string, defaults to `window.location.search`.
|
|
71
|
+
*/
|
|
72
|
+
declare function readMindooDBAppHostingMode(search?: string): MindooDBAppHostingMode;
|
|
73
|
+
/**
|
|
74
|
+
* True when the app runs from a host-served bundle in an opaque origin.
|
|
75
|
+
*
|
|
76
|
+
* In that mode `localStorage`, `sessionStorage`, IndexedDB and
|
|
77
|
+
* `navigator.serviceWorker.register()` are unavailable — note that they *exist* on the
|
|
78
|
+
* global object and only throw when touched, so feature-detecting with `typeof` gives
|
|
79
|
+
* the wrong answer. Branch on this helper instead.
|
|
80
|
+
*/
|
|
81
|
+
declare function isHostedBundleRuntime(search?: string): boolean;
|
|
82
|
+
|
|
83
|
+
interface InstallHavenStorageShimOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Key prefixes whose values are written through to the host and restored on the next
|
|
86
|
+
* launch. Keys outside these prefixes stay in memory for the lifetime of the document.
|
|
87
|
+
*/
|
|
88
|
+
persistPrefixes?: string[];
|
|
89
|
+
/** Give up waiting for the host and boot with empty storage. Defaults to 2000 ms. */
|
|
90
|
+
timeoutMs?: number;
|
|
91
|
+
/** Debounce window for write-through. Defaults to 200 ms. */
|
|
92
|
+
coalesceMs?: number;
|
|
93
|
+
/** Total budget for persisted keys, matching the host. Defaults to 256 KiB. */
|
|
94
|
+
quotaBytes?: number;
|
|
95
|
+
/** Largest single persisted value, matching the host. Defaults to 64 KiB. */
|
|
96
|
+
maxValueBytes?: number;
|
|
97
|
+
/** Also replace `sessionStorage` with an in-memory shim. Defaults to `true`. */
|
|
98
|
+
shimSessionStorage?: boolean;
|
|
99
|
+
/** Overrides the hosting mode detected from the URL. Intended for tests. */
|
|
100
|
+
hosting?: MindooDBAppHostingMode;
|
|
101
|
+
/** Overrides the bridge used to reach the host. Intended for tests. */
|
|
102
|
+
bridge?: MindooDBAppBridge;
|
|
103
|
+
/** Forwarded to `bridge.connect()` when the URL carries no launch id. */
|
|
104
|
+
launchId?: string;
|
|
105
|
+
}
|
|
106
|
+
interface HavenStorageShimHandle {
|
|
107
|
+
/** False when the app is not running hosted; nothing was replaced in that case. */
|
|
108
|
+
installed: boolean;
|
|
109
|
+
/** True once storage was hydrated from the host. False after a boot timeout. */
|
|
110
|
+
connected: boolean;
|
|
111
|
+
/** Writes out everything still pending. Resolves once the host has acknowledged. */
|
|
112
|
+
flush(): Promise<void>;
|
|
113
|
+
/** Restores the original globals. Pending writes are flushed first. */
|
|
114
|
+
uninstall(): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Installs the storage shim when the app runs from a host-served bundle.
|
|
118
|
+
*
|
|
119
|
+
* Call this during boot, before any app module touches `localStorage`, and await it:
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* await installHavenStorageShim({ persistPrefixes: ["my-app-"] });
|
|
123
|
+
* await import("./main");
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* Outside hosted mode this is a no-op and the real `localStorage` stays in place.
|
|
127
|
+
*/
|
|
128
|
+
declare function installHavenStorageShim(options?: InstallHavenStorageShimOptions): Promise<HavenStorageShimHandle>;
|
|
129
|
+
|
|
42
130
|
interface CreateMindooDBRichTextHandleOptions {
|
|
43
131
|
database: MindooDBAppDatabase;
|
|
44
132
|
document: MindooDBAppDocument;
|
|
@@ -186,4 +274,4 @@ declare function createMindooDBTextBuffer(options: CreateMindooDBTextBufferOptio
|
|
|
186
274
|
*/
|
|
187
275
|
declare function queryDocuments(db: Pick<MindooDB, "query">, filter: MindooDBAppBooleanExpression | string, sortBy?: MindooQuerySortKey[], options?: MindooQueryOptions): Promise<MindooQueryResult>;
|
|
188
276
|
|
|
189
|
-
export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, MindooDBAppDatabase, MindooDBAppDocument, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, abbreviateCanonicalName, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName, queryDocuments };
|
|
277
|
+
export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, type HavenStorageShimHandle, type InstallHavenStorageShimOptions, MINDOODB_APP_HOSTING_QUERY_PARAM, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, MindooDBAppDatabase, MindooDBAppDocument, MindooDBAppHostingMode, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, abbreviateCanonicalName, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName, installHavenStorageShim, isHostedBundleRuntime, queryDocuments, readMindooDBAppHostingMode, releaseMindooDBAppBridgeSessions };
|