mindoodb-app-sdk 0.0.60 → 0.0.61

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 CHANGED
@@ -435,18 +435,29 @@ const embed = await session.embeds.open({
435
435
  componentKey: sheet.key,
436
436
  databaseId: "crm",
437
437
  docId: doc.id,
438
- rect: panel.getBoundingClientRect(), // in this app's viewport
438
+ container: panel, // a positioned element; the component fills it
439
439
  });
440
- new ResizeObserver(() => void embed.setRect(panel.getBoundingClientRect())).observe(panel);
441
440
  const closed = await embed.closed; // { reason: "completed" | "cancelled" | "closed" | "error", result? }
442
441
  ```
443
442
 
444
- Haven lays the component's frame over the rectangle, above the host's frame, so the
445
- host cannot draw on top of it; hide it with `embed.setVisible(false)` while a dialog of
446
- the host should be visible. The first time a host embeds a component, Haven asks the user.
443
+ The SDK puts a frame into `container`, so the component is part of the host's page: it
444
+ scrolls, clips and resizes with it, and the host's menus and dialogs cover it like any
445
+ other element. The frame holds a page from Haven's origin that loads the component and
446
+ hands its connection to Haven, so the host cannot reach into the component or its data
447
+ channel. Haven tells the SDK where the container is (for the component's own menus);
448
+ the SDK follows the container's size and position by itself.
449
+
450
+ Havens that predate this lay the component over the container instead, above the host's
451
+ frame (`embed.placement === "overlay"`). The host then cannot draw on top of it: hide it
452
+ with `embed.setVisible(false)` while a menu or dialog of the host should be visible.
453
+ Without a `container`, pass `rect` (in this app's viewport) and keep it current with
454
+ `embed.setRect` to get that overlay explicitly.
455
+
456
+ The first time a host embeds a component, Haven asks the user.
447
457
  In tests, `createMockMindooDBAppSession({ components })` records embeds
448
458
  (`listEmbeds`, `closeEmbed`), and the `/__haven-test/` page draws a stand-in with
449
- Done/Cancel buttons.
459
+ Done/Cancel buttons over the container. `createFakeBridgeHost({ embedFrameUrl })`
460
+ answers like a current Haven, so the SDK frames that URL in the container.
450
461
 
451
462
  ### Databases and capabilities
452
463
 
@@ -1350,26 +1350,92 @@ function toRect(rect) {
1350
1350
  height: Math.max(0, Number(rect.height) || 0)
1351
1351
  };
1352
1352
  }
1353
+ function containerRect(container) {
1354
+ const bounds = container.getBoundingClientRect();
1355
+ return toRect({ left: bounds.left, top: bounds.top, width: bounds.width, height: bounds.height });
1356
+ }
1357
+ var ContainerTracker = class {
1358
+ constructor(container, report) {
1359
+ this.container = container;
1360
+ this.report = report;
1361
+ this.observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(this.schedule);
1362
+ this.observer?.observe(container);
1363
+ window.addEventListener("resize", this.schedule);
1364
+ window.addEventListener("scroll", this.schedule, true);
1365
+ }
1366
+ container;
1367
+ report;
1368
+ frameRequest = null;
1369
+ observer;
1370
+ schedule = () => {
1371
+ if (this.frameRequest !== null) {
1372
+ return;
1373
+ }
1374
+ this.frameRequest = window.requestAnimationFrame(() => {
1375
+ this.frameRequest = null;
1376
+ this.report(containerRect(this.container));
1377
+ });
1378
+ };
1379
+ dispose() {
1380
+ this.observer?.disconnect();
1381
+ window.removeEventListener("resize", this.schedule);
1382
+ window.removeEventListener("scroll", this.schedule, true);
1383
+ if (this.frameRequest !== null) {
1384
+ window.cancelAnimationFrame(this.frameRequest);
1385
+ }
1386
+ }
1387
+ };
1388
+ function createComponentFrame(container, url, allow) {
1389
+ const frame = container.ownerDocument.createElement("iframe");
1390
+ frame.src = url;
1391
+ if (allow) {
1392
+ frame.setAttribute("allow", allow);
1393
+ }
1394
+ frame.setAttribute("referrerpolicy", "strict-origin-when-cross-origin");
1395
+ frame.dataset.mindoodbEmbed = "";
1396
+ Object.assign(frame.style, {
1397
+ position: "absolute",
1398
+ inset: "0",
1399
+ width: "100%",
1400
+ height: "100%",
1401
+ border: "0",
1402
+ display: "block"
1403
+ });
1404
+ container.appendChild(frame);
1405
+ return frame;
1406
+ }
1353
1407
  var MindooDBAppEmbedImpl = class {
1354
- constructor(rpc, embedId, componentKey, databaseId, docId) {
1408
+ constructor(rpc, embedId, componentKey, databaseId, docId, frame, container) {
1355
1409
  this.rpc = rpc;
1356
1410
  this.embedId = embedId;
1357
1411
  this.componentKey = componentKey;
1358
1412
  this.databaseId = databaseId;
1359
1413
  this.docId = docId;
1414
+ this.frame = frame;
1360
1415
  this.closed = new Promise((resolve) => {
1361
1416
  this.resolveClosed = resolve;
1362
1417
  });
1418
+ if (container) {
1419
+ this.tracker = new ContainerTracker(container, (rect) => {
1420
+ void this.setRect(rect).catch(() => {
1421
+ });
1422
+ });
1423
+ }
1363
1424
  }
1364
1425
  rpc;
1365
1426
  embedId;
1366
1427
  componentKey;
1367
1428
  databaseId;
1368
1429
  docId;
1430
+ frame;
1369
1431
  closed;
1370
1432
  resolveClosed;
1371
1433
  closedEvent = null;
1372
1434
  listeners = /* @__PURE__ */ new Set();
1435
+ tracker = null;
1436
+ get placement() {
1437
+ return this.frame ? "frame" : "overlay";
1438
+ }
1373
1439
  async setRect(rect) {
1374
1440
  if (this.closedEvent) {
1375
1441
  return;
@@ -1380,6 +1446,10 @@ var MindooDBAppEmbedImpl = class {
1380
1446
  if (this.closedEvent) {
1381
1447
  return;
1382
1448
  }
1449
+ if (this.frame) {
1450
+ this.frame.style.visibility = visible ? "" : "hidden";
1451
+ return;
1452
+ }
1383
1453
  await this.rpc.call("embeds.setVisible", { embedId: this.embedId, visible: visible === true });
1384
1454
  }
1385
1455
  async close() {
@@ -1405,6 +1475,9 @@ var MindooDBAppEmbedImpl = class {
1405
1475
  return;
1406
1476
  }
1407
1477
  this.closedEvent = event;
1478
+ this.tracker?.dispose();
1479
+ this.tracker = null;
1480
+ this.frame?.remove();
1408
1481
  this.resolveClosed(event);
1409
1482
  this.listeners.forEach((listener) => {
1410
1483
  try {
@@ -1442,15 +1515,22 @@ var MindooDBAppEmbedsClient = class {
1442
1515
  };
1443
1516
  this.embeds = {
1444
1517
  open: async (input) => {
1518
+ const { container, rect, ...rest } = input;
1519
+ const initialRect = container ? containerRect(container) : toRect(rect ?? { left: 0, top: 0, width: 0, height: 0 });
1445
1520
  const response = await this.rpc.call("embeds.open", {
1446
- input: { ...input, rect: toRect(input.rect) }
1521
+ // `frame`: Haven hands back a page for the container instead of laying
1522
+ // the component over this app. Havens that do not know it ignore it.
1523
+ input: { ...rest, rect: initialRect, ...container ? { placement: "frame" } : {} }
1447
1524
  });
1525
+ const frame = container && response.frame?.url ? createComponentFrame(container, response.frame.url, response.frame.allow) : null;
1448
1526
  const embed = new MindooDBAppEmbedImpl(
1449
1527
  this.rpc,
1450
1528
  response.embedId,
1451
1529
  input.componentKey,
1452
1530
  input.databaseId,
1453
- input.docId
1531
+ input.docId,
1532
+ frame,
1533
+ container
1454
1534
  );
1455
1535
  const early = this.early.get(embed.embedId);
1456
1536
  if (early) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppDragBindSourceOptions, b as MindooDBAppDragStartInput, c as MindooDBAppDragStartResult, d as MindooDBAppDragPreview, e as MindooDBAppBridge, f as MindooDBAppAgentToolErrorCode, g as MindooDBAppHostShortcutBinding, h as MindooDBAppHostShortcutAction, i as MindooDBAppHostingMode, j as MindooDBAppDefinition, k as MindooDBAppDatabase, l as MindooDBAppDocument, m as MindooDBAppRichTextSpan, n as MindooDBAppRichTextSnapshot, o as MindooDBAppCreateDocumentInput } from './types-D0Bsbd1G.js';
2
- export { p as MINDOODB_APP_ACCEPTS_MAX, q as MINDOODB_APP_COMPONENTS_MAX, r as MINDOODB_APP_DEFINITION_FILE_NAME, s as MINDOODB_APP_DEFINITION_FORMAT, t as MINDOODB_APP_DEFINITION_PERMISSIONS, u as MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS, v as MINDOODB_APP_DEFINITION_VERSION, w as MINDOODB_APP_LISTING_DESCRIPTION_MAX, x as MINDOODB_APP_LISTING_MAX_SCREENSHOTS, y as MINDOODB_APP_LISTING_SUMMARY_MAX, z as MINDOODB_APP_SEAL_SIGNING_DOMAIN, A as MINDOODB_APP_WELL_KNOWN_DRAG_TYPES, B as MindooDBAppAcceptSpec, C as MindooDBAppAccessDecision, D as MindooDBAppAccessTier, E as MindooDBAppAgentApi, F as MindooDBAppAgentRegistration, G as MindooDBAppAgentTool, H as MindooDBAppAgentToolAnnotations, I as MindooDBAppAgentToolDescriptor, J as MindooDBAppAttachmentApi, K as MindooDBAppAttachmentChunk, L as MindooDBAppAttachmentInfo, N as MindooDBAppAttachmentPreviewOptions, O as MindooDBAppAttachmentPreviewSession, P as MindooDBAppAutomergeChangesPatch, Q as MindooDBAppAutomergeChangesSince, R as MindooDBAppAutomergeGetOptions, S as MindooDBAppAutomergePatchResult, T as MindooDBAppAutomergeSnapshot, U as MindooDBAppBridgeAgentInvokeMessage, V as MindooDBAppBridgeAgentResultMessage, W as MindooDBAppBridgeBeforeCloseAck, X as MindooDBAppBridgeBeforeCloseMessage, Y as MindooDBAppBridgeConnectMessage, Z as MindooDBAppBridgeConnectOptions, _ as MindooDBAppBridgeConnectedMessage, $ as MindooDBAppBridgeDragDropMessage, a0 as MindooDBAppBridgeDragLeaveMessage, a1 as MindooDBAppBridgeDragOverMessage, a2 as MindooDBAppBridgeEmbedEventMessage, a3 as MindooDBAppBridgeErrorPayload, a4 as MindooDBAppBridgeHandshakeErrorMessage, a5 as MindooDBAppBridgeHostFocusChangedMessage, a6 as MindooDBAppBridgeIncomingContentMessage, a7 as MindooDBAppBridgeLocaleChangedMessage, a8 as MindooDBAppBridgePortMessage, a9 as MindooDBAppBridgeQueryResultMessage, aa as MindooDBAppBridgeRpcError, ab as MindooDBAppBridgeRpcMessage, ac as MindooDBAppBridgeRpcRequest, ad as MindooDBAppBridgeRpcSuccess, ae as MindooDBAppBridgeShortcutInvokedMessage, af as MindooDBAppBridgeShortcutsChangedMessage, ag as MindooDBAppBridgeStreamAbortRequest, ah as MindooDBAppBridgeStreamAck, ai as MindooDBAppBridgeStreamCloseRequest, aj as MindooDBAppBridgeStreamError, ak as MindooDBAppBridgeStreamMessage, al as MindooDBAppBridgeStreamOpenResult, am as MindooDBAppBridgeStreamReadRequest, an as MindooDBAppBridgeStreamWriteRequest, ao as MindooDBAppBridgeThemeChangedMessage, ap as MindooDBAppBridgeUiPreferencesChangedMessage, aq as MindooDBAppBridgeViewChangedMessage, ar as MindooDBAppBridgeViewportChangedMessage, as as MindooDBAppBridgeWorkspaceFocusRequestedMessage, at as MindooDBAppBrowserFeatures, au as MindooDBAppCapability, av as MindooDBAppComponentChildren, aw as MindooDBAppComponentFieldValue, ax as MindooDBAppComponentInfo, ay as MindooDBAppComponentIntent, az as MindooDBAppComponentQuery, aA as MindooDBAppComponentSpec, aB as MindooDBAppComponentsApi, aC as MindooDBAppConfiguredViewCategorizationStyle, aD as MindooDBAppConfiguredViewColumn, aE as MindooDBAppConfiguredViewColumnRole, aF as MindooDBAppConfiguredViewExpressionMode, aG as MindooDBAppConfiguredViewFieldExpression, aH as MindooDBAppConfiguredViewFilterDefinition, aI as MindooDBAppConfiguredViewFilterMode, aJ as MindooDBAppConfiguredViewFilterRule, aK as MindooDBAppConfiguredViewFormulaExpression, aL as MindooDBAppConfiguredViewFormulaFilterDefinition, aM as MindooDBAppConfiguredViewPreviewMode, aN as MindooDBAppConfiguredViewRuleFilterDefinition, aO as MindooDBAppConfiguredViewRuleMatchMode, aP as MindooDBAppConfiguredViewRuleOperator, aQ as MindooDBAppConfiguredViewValueExpression, aR as MindooDBAppCreateKeyInfo, aS as MindooDBAppCreateViewInput, aT as MindooDBAppCreateViewNavigatorInput, aU as MindooDBAppDatabaseInfo, aV as MindooDBAppDefinitionDatabase, aW as MindooDBAppDefinitionListing, aX as MindooDBAppDefinitionPermission, aY as MindooDBAppDefinitionRegistrationPermission, aZ as MindooDBAppDefinitionScreenshot, a_ as MindooDBAppDefinitionValidation, a$ as MindooDBAppDirectoryApi, b0 as MindooDBAppDirectoryEntry, b1 as MindooDBAppDocumentApi, b2 as MindooDBAppDocumentHeadCursorResult, b3 as MindooDBAppDocumentHistoryEntry, b4 as MindooDBAppDocumentListQuery, b5 as MindooDBAppDocumentListResult, b6 as MindooDBAppDocumentQuery, b7 as MindooDBAppDocumentRevisionId, b8 as MindooDBAppDocumentScanPreset, b9 as MindooDBAppDocumentSummary, ba as MindooDBAppDragApi, bb as MindooDBAppDragCancelReason, bc as MindooDBAppDragDropEvent, bd as MindooDBAppDragEffect, be as MindooDBAppDragHoverResult, bf as MindooDBAppDragOffer, bg as MindooDBAppDragOverEvent, bh as MindooDBAppDragPointer, bi as MindooDBAppDragProfile, bj as MindooDBAppEmbed, bk as MindooDBAppEmbedCloseReason, bl as MindooDBAppEmbedClosedEvent, bm as MindooDBAppEmbedContext, bn as MindooDBAppEmbedOpenInput, bo as MindooDBAppEmbedRect, bp as MindooDBAppEmbeddingApi, bq as MindooDBAppEmbedsApi, br as MindooDBAppEntryAttachmentRef, bs as MindooDBAppEntryProvenance, bt as MindooDBAppExtractDocumentTextInput, bu as MindooDBAppExtractDocumentTextResult, bv as MindooDBAppExtractTextFormat, bw as MindooDBAppExtractionSetup, bx as MindooDBAppFulltextSetup, by as MindooDBAppHistoricalDocument, bz as MindooDBAppHistoryQuery, bA as MindooDBAppHostTheme, bB as MindooDBAppIdentityApi, bC as MindooDBAppInaccessibleDocument, bD as MindooDBAppInaccessibleDocumentListQuery, bE as MindooDBAppInaccessibleDocumentListResult, bF as MindooDBAppIncomingContent, bG as MindooDBAppIncomingContentHandler, bH as MindooDBAppIncomingContentInfo, bI as MindooDBAppIncomingItem, bJ as MindooDBAppIncomingItemInfo, bK as MindooDBAppIncomingResult, bL as MindooDBAppIncomingSource, bM as MindooDBAppJsonCounterIncrementPatch, bN as MindooDBAppJsonListDeletePatch, bO as MindooDBAppJsonListInsertPatch, bP as MindooDBAppJsonPatch, bQ as MindooDBAppJsonSetPatch, bR as MindooDBAppJsonTextMarkPatch, bS as MindooDBAppJsonTextSplicePatch, bT as MindooDBAppJsonTextUnmarkPatch, bU as MindooDBAppJsonUnsetPatch, bV as MindooDBAppLaunchContext, bW as MindooDBAppListUsersOptions, bX as MindooDBAppListUsersPage, bY as MindooDBAppLiveQuerySubscription, bZ as MindooDBAppLocalizedText, b_ as MindooDBAppMenuAnchor, b$ as MindooDBAppMenuApi, c0 as MindooDBAppMenuCommandItem, c1 as MindooDBAppMenuDismissReason, c2 as MindooDBAppMenuDismissedResult, c3 as MindooDBAppMenuItem, c4 as MindooDBAppMenuKind, c5 as MindooDBAppMenuPlacement, c6 as MindooDBAppMenuPointAnchor, c7 as MindooDBAppMenuRect, c8 as MindooDBAppMenuRectAnchor, c9 as MindooDBAppMenuSelectionResult, ca as MindooDBAppMenuSeparatorItem, cb as MindooDBAppNotificationSeverity, cc as MindooDBAppNotifyInput, cd as MindooDBAppNotifyResult, ce as MindooDBAppProposeAppInput, cf as MindooDBAppProposeAppResult, cg as MindooDBAppQueryCoverage, ch as MindooDBAppQueryInclude, ci as MindooDBAppQueryIncludeCardinality, cj as MindooDBAppQueryIncludeSlots, ck as MindooDBAppQueryResult, cl as MindooDBAppQueryRow, cm as MindooDBAppQuerySortKey, cn as MindooDBAppQueryTextClause, co as MindooDBAppReadableAttachmentStream, cp as MindooDBAppRecipientOptions, cq as MindooDBAppResolvedViewDefinition, cr as MindooDBAppResolvedViewSource, cs as MindooDBAppRevisionPhase, ct as MindooDBAppRevisionVerification, cu as MindooDBAppRichTextBlockSpan, cv as MindooDBAppRichTextGetOptions, cw as MindooDBAppRichTextImmutableString, cx as MindooDBAppRichTextMarkRange, cy as MindooDBAppRichTextMaterializeValue, cz as MindooDBAppRichTextPatch, cA as MindooDBAppRichTextScalar, cB as MindooDBAppRichTextSpliceStep, cC as MindooDBAppRichTextStep, cD as MindooDBAppRichTextStepPatch, cE as MindooDBAppRichTextTextSpan, cF as MindooDBAppRuntime, cG as MindooDBAppScanAttachmentOptions, cH as MindooDBAppScanAttachmentResult, cI as MindooDBAppScopedDocId, cJ as MindooDBAppScopedDocumentSummary, cK as MindooDBAppSealIntent, cL as MindooDBAppSealedChannelOpenInput, cM as MindooDBAppSealedChannelOpenResult, cN as MindooDBAppSealedChannelRequestInput, cO as MindooDBAppSession, cP as MindooDBAppShowMenuInput, cQ as MindooDBAppShowMenuResult, cR as MindooDBAppSignPreview, cS as MindooDBAppSignPreviewScope, cT as MindooDBAppSignStatementInput, cU as MindooDBAppSignStatementResult, cV as MindooDBAppStorageApi, cW as MindooDBAppSummarySetup, cX as MindooDBAppTextCursorOptions, cY as MindooDBAppTextCursorPosition, cZ as MindooDBAppTextCursorPositionsResult, c_ as MindooDBAppTextCursorsResult, c$ as MindooDBAppTextEdit, d0 as MindooDBAppTextPatch, d1 as MindooDBAppThemeMode, d2 as MindooDBAppTimestampApi, d3 as MindooDBAppTimestampInput, d4 as MindooDBAppTimestampProvider, d5 as MindooDBAppTimestampResult, d6 as MindooDBAppUiPreferences, d7 as MindooDBAppUpdateDocumentInput, d8 as MindooDBAppViewCursorDocumentListResult, d9 as MindooDBAppViewCursorResult, da as MindooDBAppViewEntry, db as MindooDBAppViewEntryKind, dc as MindooDBAppViewNavigator, dd as MindooDBAppViewNavigatorExpansionState, de as MindooDBAppViewNavigatorOpenOptions, df as MindooDBAppViewNavigatorPageOptions, dg as MindooDBAppViewNavigatorPageResult, dh as MindooDBAppViewNavigatorRangeQuery, di as MindooDBAppViewNavigatorSelectionState, dj as MindooDBAppViewUpdateStats, dk as MindooDBAppViewport, dl as MindooDBAppWellKnownDragType, dm as MindooDBAppWritableAttachmentStream, dn as mindooDBAppAcceptMatchesType, dp as mindooDBAppComponentFieldsMatch, dq as resolveMindooDBAppDefinitionUrl, dr as resolveMindooDBAppListingAssetUrl, ds as resolveMindooDBAppLocalizedText, dt as validateMindooDBAppAccepts, du as validateMindooDBAppComponents, dv as validateMindooDBAppDefinition } from './types-D0Bsbd1G.js';
1
+ import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppDragBindSourceOptions, b as MindooDBAppDragStartInput, c as MindooDBAppDragStartResult, d as MindooDBAppDragPreview, e as MindooDBAppBridge, f as MindooDBAppAgentToolErrorCode, g as MindooDBAppHostShortcutBinding, h as MindooDBAppHostShortcutAction, i as MindooDBAppHostingMode, j as MindooDBAppDefinition, k as MindooDBAppDatabase, l as MindooDBAppDocument, m as MindooDBAppRichTextSpan, n as MindooDBAppRichTextSnapshot, o as MindooDBAppCreateDocumentInput } from './types-BKN_Zh_l.js';
2
+ export { p as MINDOODB_APP_ACCEPTS_MAX, q as MINDOODB_APP_COMPONENTS_MAX, r as MINDOODB_APP_DEFINITION_FILE_NAME, s as MINDOODB_APP_DEFINITION_FORMAT, t as MINDOODB_APP_DEFINITION_PERMISSIONS, u as MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS, v as MINDOODB_APP_DEFINITION_VERSION, w as MINDOODB_APP_LISTING_DESCRIPTION_MAX, x as MINDOODB_APP_LISTING_MAX_SCREENSHOTS, y as MINDOODB_APP_LISTING_SUMMARY_MAX, z as MINDOODB_APP_SEAL_SIGNING_DOMAIN, A as MINDOODB_APP_WELL_KNOWN_DRAG_TYPES, B as MindooDBAppAcceptSpec, C as MindooDBAppAccessDecision, D as MindooDBAppAccessTier, E as MindooDBAppAgentApi, F as MindooDBAppAgentRegistration, G as MindooDBAppAgentTool, H as MindooDBAppAgentToolAnnotations, I as MindooDBAppAgentToolDescriptor, J as MindooDBAppAttachmentApi, K as MindooDBAppAttachmentChunk, L as MindooDBAppAttachmentInfo, N as MindooDBAppAttachmentPreviewOptions, O as MindooDBAppAttachmentPreviewSession, P as MindooDBAppAutomergeChangesPatch, Q as MindooDBAppAutomergeChangesSince, R as MindooDBAppAutomergeGetOptions, S as MindooDBAppAutomergePatchResult, T as MindooDBAppAutomergeSnapshot, U as MindooDBAppBridgeAgentInvokeMessage, V as MindooDBAppBridgeAgentResultMessage, W as MindooDBAppBridgeBeforeCloseAck, X as MindooDBAppBridgeBeforeCloseMessage, Y as MindooDBAppBridgeConnectMessage, Z as MindooDBAppBridgeConnectOptions, _ as MindooDBAppBridgeConnectedMessage, $ as MindooDBAppBridgeDragDropMessage, a0 as MindooDBAppBridgeDragLeaveMessage, a1 as MindooDBAppBridgeDragOverMessage, a2 as MindooDBAppBridgeEmbedEventMessage, a3 as MindooDBAppBridgeErrorPayload, a4 as MindooDBAppBridgeHandshakeErrorMessage, a5 as MindooDBAppBridgeHostFocusChangedMessage, a6 as MindooDBAppBridgeIncomingContentMessage, a7 as MindooDBAppBridgeLocaleChangedMessage, a8 as MindooDBAppBridgePortMessage, a9 as MindooDBAppBridgeQueryResultMessage, aa as MindooDBAppBridgeRpcError, ab as MindooDBAppBridgeRpcMessage, ac as MindooDBAppBridgeRpcRequest, ad as MindooDBAppBridgeRpcSuccess, ae as MindooDBAppBridgeShortcutInvokedMessage, af as MindooDBAppBridgeShortcutsChangedMessage, ag as MindooDBAppBridgeStreamAbortRequest, ah as MindooDBAppBridgeStreamAck, ai as MindooDBAppBridgeStreamCloseRequest, aj as MindooDBAppBridgeStreamError, ak as MindooDBAppBridgeStreamMessage, al as MindooDBAppBridgeStreamOpenResult, am as MindooDBAppBridgeStreamReadRequest, an as MindooDBAppBridgeStreamWriteRequest, ao as MindooDBAppBridgeThemeChangedMessage, ap as MindooDBAppBridgeUiPreferencesChangedMessage, aq as MindooDBAppBridgeViewChangedMessage, ar as MindooDBAppBridgeViewportChangedMessage, as as MindooDBAppBridgeWorkspaceFocusRequestedMessage, at as MindooDBAppBrowserFeatures, au as MindooDBAppCapability, av as MindooDBAppComponentChildren, aw as MindooDBAppComponentFieldValue, ax as MindooDBAppComponentInfo, ay as MindooDBAppComponentIntent, az as MindooDBAppComponentQuery, aA as MindooDBAppComponentSpec, aB as MindooDBAppComponentsApi, aC as MindooDBAppConfiguredViewCategorizationStyle, aD as MindooDBAppConfiguredViewColumn, aE as MindooDBAppConfiguredViewColumnRole, aF as MindooDBAppConfiguredViewExpressionMode, aG as MindooDBAppConfiguredViewFieldExpression, aH as MindooDBAppConfiguredViewFilterDefinition, aI as MindooDBAppConfiguredViewFilterMode, aJ as MindooDBAppConfiguredViewFilterRule, aK as MindooDBAppConfiguredViewFormulaExpression, aL as MindooDBAppConfiguredViewFormulaFilterDefinition, aM as MindooDBAppConfiguredViewPreviewMode, aN as MindooDBAppConfiguredViewRuleFilterDefinition, aO as MindooDBAppConfiguredViewRuleMatchMode, aP as MindooDBAppConfiguredViewRuleOperator, aQ as MindooDBAppConfiguredViewValueExpression, aR as MindooDBAppCreateKeyInfo, aS as MindooDBAppCreateViewInput, aT as MindooDBAppCreateViewNavigatorInput, aU as MindooDBAppDatabaseInfo, aV as MindooDBAppDefinitionDatabase, aW as MindooDBAppDefinitionListing, aX as MindooDBAppDefinitionPermission, aY as MindooDBAppDefinitionRegistrationPermission, aZ as MindooDBAppDefinitionScreenshot, a_ as MindooDBAppDefinitionValidation, a$ as MindooDBAppDirectoryApi, b0 as MindooDBAppDirectoryEntry, b1 as MindooDBAppDocumentApi, b2 as MindooDBAppDocumentHeadCursorResult, b3 as MindooDBAppDocumentHistoryEntry, b4 as MindooDBAppDocumentListQuery, b5 as MindooDBAppDocumentListResult, b6 as MindooDBAppDocumentQuery, b7 as MindooDBAppDocumentRevisionId, b8 as MindooDBAppDocumentScanPreset, b9 as MindooDBAppDocumentSummary, ba as MindooDBAppDragApi, bb as MindooDBAppDragCancelReason, bc as MindooDBAppDragDropEvent, bd as MindooDBAppDragEffect, be as MindooDBAppDragHoverResult, bf as MindooDBAppDragOffer, bg as MindooDBAppDragOverEvent, bh as MindooDBAppDragPointer, bi as MindooDBAppDragProfile, bj as MindooDBAppEmbed, bk as MindooDBAppEmbedCloseReason, bl as MindooDBAppEmbedClosedEvent, bm as MindooDBAppEmbedContext, bn as MindooDBAppEmbedOpenInput, bo as MindooDBAppEmbedRect, bp as MindooDBAppEmbeddingApi, bq as MindooDBAppEmbedsApi, br as MindooDBAppEntryAttachmentRef, bs as MindooDBAppEntryProvenance, bt as MindooDBAppExtractDocumentTextInput, bu as MindooDBAppExtractDocumentTextResult, bv as MindooDBAppExtractTextFormat, bw as MindooDBAppExtractionSetup, bx as MindooDBAppFulltextSetup, by as MindooDBAppHistoricalDocument, bz as MindooDBAppHistoryQuery, bA as MindooDBAppHostTheme, bB as MindooDBAppIdentityApi, bC as MindooDBAppInaccessibleDocument, bD as MindooDBAppInaccessibleDocumentListQuery, bE as MindooDBAppInaccessibleDocumentListResult, bF as MindooDBAppIncomingContent, bG as MindooDBAppIncomingContentHandler, bH as MindooDBAppIncomingContentInfo, bI as MindooDBAppIncomingItem, bJ as MindooDBAppIncomingItemInfo, bK as MindooDBAppIncomingResult, bL as MindooDBAppIncomingSource, bM as MindooDBAppJsonCounterIncrementPatch, bN as MindooDBAppJsonListDeletePatch, bO as MindooDBAppJsonListInsertPatch, bP as MindooDBAppJsonPatch, bQ as MindooDBAppJsonSetPatch, bR as MindooDBAppJsonTextMarkPatch, bS as MindooDBAppJsonTextSplicePatch, bT as MindooDBAppJsonTextUnmarkPatch, bU as MindooDBAppJsonUnsetPatch, bV as MindooDBAppLaunchContext, bW as MindooDBAppListUsersOptions, bX as MindooDBAppListUsersPage, bY as MindooDBAppLiveQuerySubscription, bZ as MindooDBAppLocalizedText, b_ as MindooDBAppMenuAnchor, b$ as MindooDBAppMenuApi, c0 as MindooDBAppMenuCommandItem, c1 as MindooDBAppMenuDismissReason, c2 as MindooDBAppMenuDismissedResult, c3 as MindooDBAppMenuItem, c4 as MindooDBAppMenuKind, c5 as MindooDBAppMenuPlacement, c6 as MindooDBAppMenuPointAnchor, c7 as MindooDBAppMenuRect, c8 as MindooDBAppMenuRectAnchor, c9 as MindooDBAppMenuSelectionResult, ca as MindooDBAppMenuSeparatorItem, cb as MindooDBAppNotificationSeverity, cc as MindooDBAppNotifyInput, cd as MindooDBAppNotifyResult, ce as MindooDBAppProposeAppInput, cf as MindooDBAppProposeAppResult, cg as MindooDBAppQueryCoverage, ch as MindooDBAppQueryInclude, ci as MindooDBAppQueryIncludeCardinality, cj as MindooDBAppQueryIncludeSlots, ck as MindooDBAppQueryResult, cl as MindooDBAppQueryRow, cm as MindooDBAppQuerySortKey, cn as MindooDBAppQueryTextClause, co as MindooDBAppReadableAttachmentStream, cp as MindooDBAppRecipientOptions, cq as MindooDBAppResolvedViewDefinition, cr as MindooDBAppResolvedViewSource, cs as MindooDBAppRevisionPhase, ct as MindooDBAppRevisionVerification, cu as MindooDBAppRichTextBlockSpan, cv as MindooDBAppRichTextGetOptions, cw as MindooDBAppRichTextImmutableString, cx as MindooDBAppRichTextMarkRange, cy as MindooDBAppRichTextMaterializeValue, cz as MindooDBAppRichTextPatch, cA as MindooDBAppRichTextScalar, cB as MindooDBAppRichTextSpliceStep, cC as MindooDBAppRichTextStep, cD as MindooDBAppRichTextStepPatch, cE as MindooDBAppRichTextTextSpan, cF as MindooDBAppRuntime, cG as MindooDBAppScanAttachmentOptions, cH as MindooDBAppScanAttachmentResult, cI as MindooDBAppScopedDocId, cJ as MindooDBAppScopedDocumentSummary, cK as MindooDBAppSealIntent, cL as MindooDBAppSealedChannelOpenInput, cM as MindooDBAppSealedChannelOpenResult, cN as MindooDBAppSealedChannelRequestInput, cO as MindooDBAppSession, cP as MindooDBAppShowMenuInput, cQ as MindooDBAppShowMenuResult, cR as MindooDBAppSignPreview, cS as MindooDBAppSignPreviewScope, cT as MindooDBAppSignStatementInput, cU as MindooDBAppSignStatementResult, cV as MindooDBAppStorageApi, cW as MindooDBAppSummarySetup, cX as MindooDBAppTextCursorOptions, cY as MindooDBAppTextCursorPosition, cZ as MindooDBAppTextCursorPositionsResult, c_ as MindooDBAppTextCursorsResult, c$ as MindooDBAppTextEdit, d0 as MindooDBAppTextPatch, d1 as MindooDBAppThemeMode, d2 as MindooDBAppTimestampApi, d3 as MindooDBAppTimestampInput, d4 as MindooDBAppTimestampProvider, d5 as MindooDBAppTimestampResult, d6 as MindooDBAppUiPreferences, d7 as MindooDBAppUpdateDocumentInput, d8 as MindooDBAppViewCursorDocumentListResult, d9 as MindooDBAppViewCursorResult, da as MindooDBAppViewEntry, db as MindooDBAppViewEntryKind, dc as MindooDBAppViewNavigator, dd as MindooDBAppViewNavigatorExpansionState, de as MindooDBAppViewNavigatorOpenOptions, df as MindooDBAppViewNavigatorPageOptions, dg as MindooDBAppViewNavigatorPageResult, dh as MindooDBAppViewNavigatorRangeQuery, di as MindooDBAppViewNavigatorSelectionState, dj as MindooDBAppViewUpdateStats, dk as MindooDBAppViewport, dl as MindooDBAppWellKnownDragType, dm as MindooDBAppWritableAttachmentStream, dn as mindooDBAppAcceptMatchesType, dp as mindooDBAppComponentFieldsMatch, dq as resolveMindooDBAppDefinitionUrl, dr as resolveMindooDBAppListingAssetUrl, ds as resolveMindooDBAppLocalizedText, dt as validateMindooDBAppAccepts, du as validateMindooDBAppComponents, dv as validateMindooDBAppDefinition } from './types-BKN_Zh_l.js';
3
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';
4
4
  import { MindooDBAppBooleanExpression } from 'mindoodb-view-language';
5
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';
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  validateMindooDBAppAccepts,
48
48
  validateMindooDBAppComponents,
49
49
  validateMindooDBAppDefinition
50
- } from "./chunk-HJUDYIPR.js";
50
+ } from "./chunk-U4NXI7EH.js";
51
51
  import {
52
52
  MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME,
53
53
  MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME,
@@ -1,4 +1,4 @@
1
- import { ax as MindooDBAppComponentInfo, bo as MindooDBAppEmbedRect, aT as MindooDBAppCreateViewNavigatorInput, dc as MindooDBAppViewNavigator, ac as MindooDBAppBridgeRpcRequest, bA as MindooDBAppHostTheme, au as MindooDBAppCapability, j as MindooDBAppDefinition, J as MindooDBAppAttachmentApi, e as MindooDBAppBridge, cO as MindooDBAppSession, ce as MindooDBAppProposeAppInput, dk as MindooDBAppViewport, d6 as MindooDBAppUiPreferences, ck as MindooDBAppQueryResult, dj as MindooDBAppViewUpdateStats, a8 as MindooDBAppBridgePortMessage, aU as MindooDBAppDatabaseInfo, bk as MindooDBAppEmbedCloseReason, a3 as MindooDBAppBridgeErrorPayload, bV as MindooDBAppLaunchContext, b1 as MindooDBAppDocumentApi, de as MindooDBAppViewNavigatorOpenOptions, bB as MindooDBAppIdentityApi, d2 as MindooDBAppTimestampApi, a$ as MindooDBAppDirectoryApi, l as MindooDBAppDocument, bx as MindooDBAppFulltextSetup, bw as MindooDBAppExtractionSetup, cW as MindooDBAppSummarySetup, cf as MindooDBAppProposeAppResult, bL as MindooDBAppIncomingSource, c as MindooDBAppDragStartResult, bi as MindooDBAppDragProfile, bK as MindooDBAppIncomingResult } from '../types-D0Bsbd1G.js';
1
+ import { ax as MindooDBAppComponentInfo, bo as MindooDBAppEmbedRect, aT as MindooDBAppCreateViewNavigatorInput, dc as MindooDBAppViewNavigator, ac as MindooDBAppBridgeRpcRequest, bA as MindooDBAppHostTheme, au as MindooDBAppCapability, j as MindooDBAppDefinition, J as MindooDBAppAttachmentApi, e as MindooDBAppBridge, cO as MindooDBAppSession, ce as MindooDBAppProposeAppInput, dk as MindooDBAppViewport, d6 as MindooDBAppUiPreferences, ck as MindooDBAppQueryResult, dj as MindooDBAppViewUpdateStats, a8 as MindooDBAppBridgePortMessage, aU as MindooDBAppDatabaseInfo, bk as MindooDBAppEmbedCloseReason, a3 as MindooDBAppBridgeErrorPayload, bV as MindooDBAppLaunchContext, b1 as MindooDBAppDocumentApi, de as MindooDBAppViewNavigatorOpenOptions, bB as MindooDBAppIdentityApi, d2 as MindooDBAppTimestampApi, a$ as MindooDBAppDirectoryApi, l as MindooDBAppDocument, bx as MindooDBAppFulltextSetup, bw as MindooDBAppExtractionSetup, cW as MindooDBAppSummarySetup, cf as MindooDBAppProposeAppResult, bL as MindooDBAppIncomingSource, c as MindooDBAppDragStartResult, bi as MindooDBAppDragProfile, bK as MindooDBAppIncomingResult } from '../types-BKN_Zh_l.js';
2
2
  import * as mindoodb from 'mindoodb';
3
3
  import 'mindoodb-view-language';
4
4
 
@@ -342,6 +342,12 @@ interface CreateMockMindooDBAppSessionOptions {
342
342
  components?: MindooDBAppComponentInfo[];
343
343
  /** Called whenever the app opens, moves or closes an embed. */
344
344
  onEmbedChange?: (embeds: readonly MockEmbedState[]) => void;
345
+ /**
346
+ * Answer `embeds.open` with a `container` like a current Haven: with this page
347
+ * for the SDK to frame (e.g. `about:blank`). Without it the host behaves like an
348
+ * older Haven and the component is laid over the container.
349
+ */
350
+ embedFrameUrl?: string;
345
351
  }
346
352
  /**
347
353
  * Test usernames in Haven's canonical form: `CN=Test User 001/O=Test`, …
@@ -4,7 +4,7 @@ import {
4
4
  mindooDBAppComponentFieldsMatch,
5
5
  pageUsers,
6
6
  releaseMindooDBAppBridgeSessions
7
- } from "../chunk-HJUDYIPR.js";
7
+ } from "../chunk-U4NXI7EH.js";
8
8
 
9
9
  // src/testing/index.ts
10
10
  import * as Automerge from "@automerge/automerge";
@@ -468,6 +468,13 @@ function createMockEmbedHost(options, getDatabase) {
468
468
  function notifyChange() {
469
469
  options.onEmbedChange?.([...embeds.values()].map((entry) => ({ ...entry, rect: { ...entry.rect } })));
470
470
  }
471
+ function mockRect(input) {
472
+ if (input.rect) {
473
+ return { ...input.rect };
474
+ }
475
+ const bounds = input.container?.getBoundingClientRect();
476
+ return { left: bounds?.left ?? 0, top: bounds?.top ?? 0, width: bounds?.width ?? 0, height: bounds?.height ?? 0 };
477
+ }
471
478
  async function openEmbed(input) {
472
479
  const component = components.find((entry) => entry.key === input.componentKey);
473
480
  if (!component) {
@@ -492,7 +499,7 @@ function createMockEmbedHost(options, getDatabase) {
492
499
  databaseId: input.databaseId,
493
500
  docId: input.docId,
494
501
  intent,
495
- rect: { ...input.rect },
502
+ rect: mockRect(input),
496
503
  visible: input.visible !== false
497
504
  });
498
505
  notifyChange();
@@ -526,6 +533,8 @@ function createMockEmbedHost(options, getDatabase) {
526
533
  componentKey;
527
534
  databaseId;
528
535
  docId;
536
+ placement = "overlay";
537
+ frame = null;
529
538
  closed;
530
539
  resolve;
531
540
  listeners = /* @__PURE__ */ new Set();
@@ -4302,8 +4311,11 @@ function createFakeBridgeHost(options = {}) {
4302
4311
  params.query ?? void 0
4303
4312
  )
4304
4313
  };
4305
- case "embeds.open":
4306
- return { embedId: await state.embedHost.openEmbed(params.input) };
4314
+ case "embeds.open": {
4315
+ const input = params.input;
4316
+ const embedId = await state.embedHost.openEmbed(input);
4317
+ return input.placement === "frame" && options.embedFrameUrl ? { embedId, frame: { url: options.embedFrameUrl } } : { embedId };
4318
+ }
4307
4319
  case "embeds.setRect":
4308
4320
  state.embedHost.setRect(String(params.embedId), params.rect);
4309
4321
  return { ok: true };
@@ -1621,8 +1621,23 @@ interface MindooDBAppEmbedOpenInput {
1621
1621
  docId: string;
1622
1622
  /** Default `edit`. `view` gives the component read access only. */
1623
1623
  intent?: "edit" | "view";
1624
- /** Where the component appears, in this app's viewport. */
1625
- rect: MindooDBAppEmbedRect;
1624
+ /**
1625
+ * The element to show the component in (recommended). The SDK puts a frame into
1626
+ * it that fills it (`position: absolute; inset: 0`, so give the element a
1627
+ * position), and the component then belongs to this app's page: it scrolls,
1628
+ * clips and stacks with it, and this app's menus and dialogs cover it as usual.
1629
+ * The frame holds a page of Haven's that loads the component, so this app never
1630
+ * reaches into the component or its connection.
1631
+ *
1632
+ * Havens that predate this lay the component over the element instead; the SDK
1633
+ * then keeps the rectangle in step with the element itself.
1634
+ */
1635
+ container?: HTMLElement;
1636
+ /**
1637
+ * Without `container`: where Haven lays the component over this app, in this
1638
+ * app's viewport. Keep it current with `setRect`.
1639
+ */
1640
+ rect?: MindooDBAppEmbedRect;
1626
1641
  /** Default true. */
1627
1642
  visible?: boolean;
1628
1643
  }
@@ -1642,7 +1657,19 @@ interface MindooDBAppEmbed {
1642
1657
  readonly componentKey: string;
1643
1658
  readonly databaseId: string;
1644
1659
  readonly docId: string;
1645
- /** Move or resize; coordinates are in this app's viewport. */
1660
+ /**
1661
+ * `frame`: the component is a frame in `container` and stacks like any element
1662
+ * of this page. `overlay`: Haven lays it over this page, above everything in it,
1663
+ * so hide it (`setVisible(false)`) while a menu or dialog of this app would
1664
+ * overlap it.
1665
+ */
1666
+ readonly placement: "frame" | "overlay";
1667
+ /** The component's frame in `container` (`frame` placement), else null. */
1668
+ readonly frame: HTMLIFrameElement | null;
1669
+ /**
1670
+ * Move or resize; coordinates are in this app's viewport. Not needed with a
1671
+ * `container`, whose rectangle the SDK follows itself.
1672
+ */
1646
1673
  setRect(rect: MindooDBAppEmbedRect): Promise<void>;
1647
1674
  /** Hide without closing, e.g. while a dialog of the host covers it. */
1648
1675
  setVisible(visible: boolean): Promise<void>;
@@ -1660,7 +1687,7 @@ interface MindooDBAppComponentsApi {
1660
1687
  /** Show another app's component inside this app. */
1661
1688
  interface MindooDBAppEmbedsApi {
1662
1689
  /**
1663
- * Shows the component over `rect`. Haven copies the root document and its
1690
+ * Shows the component in `container` (or over `rect`). Haven copies the root document and its
1664
1691
  * children into a sandbox, runs the component against it and writes the changes
1665
1692
  * back to `databaseId`, which this app must be allowed to read and (for `edit`)
1666
1693
  * update. The first time, Haven asks the user to allow the pairing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindoodb-app-sdk",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "engines": {
5
5
  "node": ">=22.13.0"
6
6
  },