@membranehq/sdk 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -20776,6 +20776,160 @@
20776
20776
  var urlJoinExports = requireUrlJoin();
20777
20777
  var urljoin = /*@__PURE__*/getDefaultExportFromCjs(urlJoinExports);
20778
20778
 
20779
+ const POPUP_ELEMENT_ID = '__integration-app-popup';
20780
+ const CONTAINER_ELEMENT_ID = '__integration-app-container';
20781
+ const CONTAINER_ELEMENT_CLASS = '__integration-app-container';
20782
+ const CONTAINER_ELEMENT_CLASS__LOADER = '__integration-app-container__loader';
20783
+ const BODY_CLASS = '__integration-app-open';
20784
+ const STYLES_ELEMENT_ID = '__integration-app-embed-styles';
20785
+ const TIMEOUT_MESSAGE_ELEMENT_ID = '__integration-app-timeout-message';
20786
+ const LOADER_SVG_ELEMENT_ID = '__integration-app-loader-svg';
20787
+ const SLOW_CONNECTION_TIMEOUT = 5000;
20788
+ const CONNECTION_FAILED_TIMEOUT = 30000;
20789
+ const HANDSHAKE_AFTER_LOAD_TIMEOUT = 3000;
20790
+ const IFRAME_SHOW_LOADER_MINIMAL_TIME = 500;
20791
+ const IFRAME_LAYOUT_SHIFT_TIME = 300;
20792
+
20793
+ function injectStyles(mountTargetSelector) {
20794
+ const hasCustomMountTarget = Boolean(mountTargetSelector && document.querySelector(mountTargetSelector));
20795
+ const styles = [
20796
+ `.${CONTAINER_ELEMENT_CLASS}:empty { display: none; }`,
20797
+ hasCustomMountTarget
20798
+ ? `.${CONTAINER_ELEMENT_CLASS} {
20799
+ inset: 0;
20800
+ background: rgba(0, 0, 0, 0);
20801
+ transition: background 0.2s ease-out;
20802
+ display: flex;
20803
+ justify-content: center;
20804
+ align-items: center;
20805
+ width: 100%;
20806
+ height: 100%;
20807
+ }`
20808
+ : `.${CONTAINER_ELEMENT_CLASS} {
20809
+ position: fixed;
20810
+ inset: 0;
20811
+ z-index: 2147483647;
20812
+ display: flex;
20813
+ justify-content: center;
20814
+ align-items: center;
20815
+ pointer-events: auto;
20816
+ background: rgba(0, 0, 0, 0);
20817
+ transition: background 0.2s ease-out;
20818
+ }`,
20819
+ `.${CONTAINER_ELEMENT_CLASS}.${CONTAINER_ELEMENT_CLASS__LOADER} {
20820
+ background: transparent;
20821
+ backdrop-filter: blur(8px);
20822
+ -webkit-backdrop-filter: blur(8px);
20823
+ }`,
20824
+ `.${CONTAINER_ELEMENT_CLASS} iframe {
20825
+ ${hasCustomMountTarget ? '' : 'position: absolute; inset: 0;'}
20826
+ width: 100%;
20827
+ height: 100%;
20828
+ border-width: 0;
20829
+ color-scheme: light;
20830
+ }`,
20831
+ `.${CONTAINER_ELEMENT_CLASS}.${CONTAINER_ELEMENT_CLASS__LOADER} iframe {
20832
+ visibility: hidden;
20833
+ }`,
20834
+ !hasCustomMountTarget ? `body.${BODY_CLASS} { overflow: hidden; }` : '',
20835
+ `#${LOADER_SVG_ELEMENT_ID} {
20836
+ position: absolute;
20837
+ top: 50%;
20838
+ left: 50%;
20839
+ transform: translate(-50%, -50%);
20840
+ width: 4rem;
20841
+ height: 4rem;
20842
+ color: black;
20843
+ }`,
20844
+ `#${TIMEOUT_MESSAGE_ELEMENT_ID} {
20845
+ position: absolute;
20846
+ top: calc(50% + 3rem);
20847
+ left: 50%;
20848
+ transform: translateX(-50%);
20849
+ display: flex;
20850
+ flex-direction: column;
20851
+ align-items: center;
20852
+ gap: 0.75rem;
20853
+ font-family: system-ui, -apple-system, sans-serif;
20854
+ }`,
20855
+ `#${TIMEOUT_MESSAGE_ELEMENT_ID} p {
20856
+ margin: 0;
20857
+ font-size: 0.875rem;
20858
+ font-weight: 500;
20859
+ color: #52525b;
20860
+ text-align: center;
20861
+ }`,
20862
+ `#${TIMEOUT_MESSAGE_ELEMENT_ID}.error p {
20863
+ color: #dc2626;
20864
+ }`,
20865
+ `#${TIMEOUT_MESSAGE_ELEMENT_ID} button {
20866
+ padding: 0.5rem 1rem;
20867
+ font-size: 0.875rem;
20868
+ font-weight: 500;
20869
+ color: white;
20870
+ background: #18181b;
20871
+ border: none;
20872
+ border-radius: 0.375rem;
20873
+ cursor: pointer;
20874
+ transition: background 0.15s;
20875
+ }`,
20876
+ `#${TIMEOUT_MESSAGE_ELEMENT_ID} button:hover {
20877
+ background: #27272a;
20878
+ }`,
20879
+ ];
20880
+ let styleElement = document.getElementById(STYLES_ELEMENT_ID);
20881
+ if (!styleElement) {
20882
+ styleElement = document.createElement('style');
20883
+ styleElement.id = STYLES_ELEMENT_ID;
20884
+ styleElement.type = 'text/css';
20885
+ document.head.appendChild(styleElement);
20886
+ }
20887
+ styleElement.textContent = styles.join('\n');
20888
+ }
20889
+ function removeInjectedStyles() {
20890
+ var _a;
20891
+ (_a = document.getElementById(STYLES_ELEMENT_ID)) === null || _a === void 0 ? void 0 : _a.remove();
20892
+ }
20893
+
20894
+ function getContainer() {
20895
+ return document.getElementById(CONTAINER_ELEMENT_ID);
20896
+ }
20897
+ function createContainer() {
20898
+ const container = document.createElement('div');
20899
+ container.id = CONTAINER_ELEMENT_ID;
20900
+ container.classList.add(CONTAINER_ELEMENT_CLASS);
20901
+ return container;
20902
+ }
20903
+ function appendToContainer(el) {
20904
+ var _a;
20905
+ (_a = getContainer()) === null || _a === void 0 ? void 0 : _a.appendChild(el);
20906
+ }
20907
+ function deleteContainer() {
20908
+ var _a;
20909
+ (_a = getContainer()) === null || _a === void 0 ? void 0 : _a.remove();
20910
+ removeInjectedStyles();
20911
+ }
20912
+ function handleIframeUnmount(iframe) {
20913
+ const observer = new MutationObserver((mutationsList) => {
20914
+ for (const mutation of mutationsList) {
20915
+ for (const removedNode of mutation.removedNodes) {
20916
+ if (removedNode instanceof HTMLElement && removedNode.id === POPUP_ELEMENT_ID) {
20917
+ observer.disconnect();
20918
+ deleteContainer();
20919
+ return;
20920
+ }
20921
+ }
20922
+ }
20923
+ });
20924
+ const parent = iframe.parentNode;
20925
+ if (parent) {
20926
+ observer.observe(parent, { childList: true });
20927
+ }
20928
+ else {
20929
+ console.warn(`iframe with ID "${POPUP_ELEMENT_ID}" has no parent node`);
20930
+ }
20931
+ }
20932
+
20779
20933
  var MessageType;
20780
20934
  (function (MessageType) {
20781
20935
  MessageType["Call"] = "call";
@@ -21306,87 +21460,260 @@
21306
21460
  };
21307
21461
  };
21308
21462
 
21309
- const POPUP_ELEMENT_ID = '__integration-app-popup';
21310
- const CONTAINER_ELEMENT_ID = '__integration-app-container';
21311
- const CONTAINER_ELEMENT_CLASS = '__integration-app-container';
21312
- const CONTAINER_ELEMENT_CLASS__LOADER = '__integration-app-container__loader';
21313
- const BODY_CLASS = '__integration-app-open';
21314
- const STYLES_ELEMENT_ID = '__integration-app-embed-styles';
21315
- let IFRAME_START_SHOW_LOADER_TIME = 0;
21316
- let IFRAME_SHOW_LOADER_TIMEOUT_ID;
21317
- const IFRAME_SHOW_LOADER_MINIMAL_TIME = 500;
21318
- const IFRAME_LAYOUT_SHIFT_TIME = 300;
21463
+ let loaderStartTime = 0;
21464
+ let loaderTimeoutId;
21465
+ function createLoaderSvg() {
21466
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
21467
+ svg.id = LOADER_SVG_ELEMENT_ID;
21468
+ svg.setAttribute('viewBox', '0 0 120 120');
21469
+ svg.setAttribute('fill', 'currentColor');
21470
+ svg.innerHTML = `
21471
+ <defs>
21472
+ <mask id="__membrane-mask-2">
21473
+ <rect x="0" y="0" width="120" height="120" fill="#fff" />
21474
+ <path
21475
+ d="M43.48 22.8008C43.48 21.8386 44.5223 21.2378 45.3549 21.72L89.7526 47.4331C90.2346 47.7123 90.5314 48.2271 90.5314 48.7841V120H88.6565H44.103C44.103 120 43.48 119.721 43.48 119.377V22.8008Z"
21476
+ fill="#000"
21477
+ >
21478
+ <animateTransform
21479
+ attributeName="transform"
21480
+ type="translate"
21481
+ values="0 0; 0 -12; 0 0"
21482
+ dur="1.1s"
21483
+ repeatCount="indefinite"
21484
+ calcMode="spline"
21485
+ keySplines="0.42 0 0.58 1; 0.42 0 0.58 1"
21486
+ begin="0.15s"
21487
+ />
21488
+ </path>
21489
+ </mask>
21490
+ <mask id="__membrane-mask-1">
21491
+ <rect x="0" y="0" width="120" height="120" fill="#fff" />
21492
+ <path
21493
+ d="M23.5 36.4509C23.5 35.4886 24.5423 34.8878 25.3749 35.3701L69.7726 61.0832C70.2546 61.3623 70.5514 61.8771 70.5514 62.4341L70.55 120H68.6764H37.5H23.5V36.4509Z"
21494
+ fill="#000"
21495
+ >
21496
+ <animateTransform
21497
+ attributeName="transform"
21498
+ type="translate"
21499
+ values="0 0; 0 -12; 0 0"
21500
+ dur="1.1s"
21501
+ repeatCount="indefinite"
21502
+ calcMode="spline"
21503
+ keySplines="0.42 0 0.58 1; 0.42 0 0.58 1"
21504
+ begin="0s"
21505
+ />
21506
+ </path>
21507
+ </mask>
21508
+ </defs>
21509
+ <g mask="url(#__membrane-mask-2)">
21510
+ <path
21511
+ d="M56.45 13.1708C56.45 12.2086 57.4923 11.6078 58.3249 12.09L102.723 37.8031C103.205 38.0823 103.501 38.5971 103.501 39.1541V90.5875C103.501 91.5497 102.459 92.1505 101.626 91.6683L57.073 65.865C56.6874 65.6417 56.45 65.2298 56.45 64.7842V13.1708Z"
21512
+ fill="currentColor"
21513
+ >
21514
+ <animateTransform
21515
+ attributeName="transform"
21516
+ type="translate"
21517
+ values="0 0; 0 -12; 0 0"
21518
+ dur="1.1s"
21519
+ repeatCount="indefinite"
21520
+ calcMode="spline"
21521
+ keySplines="0.42 0 0.58 1; 0.42 0 0.58 1"
21522
+ begin="0.3s"
21523
+ />
21524
+ </path>
21525
+ </g>
21526
+ <g mask="url(#__membrane-mask-1)">
21527
+ <path
21528
+ d="M36.48 26.8008C36.48 25.8386 37.5223 25.2378 38.3549 25.72L82.7526 51.4331C83.2346 51.7123 83.5314 52.2271 83.5314 52.7841V104.218C83.5314 105.18 82.4891 105.781 81.6565 105.298L37.103 79.495C36.7174 79.2717 36.48 78.8598 36.48 78.4142V26.8008Z"
21529
+ fill="currentColor"
21530
+ >
21531
+ <animateTransform
21532
+ attributeName="transform"
21533
+ type="translate"
21534
+ values="0 0; 0 -12; 0 0"
21535
+ dur="1.1s"
21536
+ repeatCount="indefinite"
21537
+ calcMode="spline"
21538
+ keySplines="0.42 0 0.58 1; 0.42 0 0.58 1"
21539
+ begin="0.15s"
21540
+ />
21541
+ </path>
21542
+ </g>
21543
+ <path
21544
+ d="M16.5 40.4509C16.5 39.4886 17.5423 38.8878 18.3749 39.3701L62.7726 65.0832C63.2546 65.3623 63.5514 65.8771 63.5514 66.4341V117.868C63.5514 118.83 62.5091 119.431 61.6764 118.948L17.123 93.145C16.7374 92.9217 16.5 92.5098 16.5 92.0642V40.4509Z"
21545
+ fill="currentColor"
21546
+ >
21547
+ <animateTransform
21548
+ attributeName="transform"
21549
+ type="translate"
21550
+ values="0 0; 0 -12; 0 0"
21551
+ dur="1.1s"
21552
+ repeatCount="indefinite"
21553
+ calcMode="spline"
21554
+ keySplines="0.42 0 0.58 1; 0.42 0 0.58 1"
21555
+ begin="0s"
21556
+ />
21557
+ </path>
21558
+ `;
21559
+ return svg;
21560
+ }
21319
21561
  function showIframeLoader() {
21320
21562
  const container = getContainer();
21321
21563
  container === null || container === void 0 ? void 0 : container.classList.add(CONTAINER_ELEMENT_CLASS__LOADER);
21322
- IFRAME_START_SHOW_LOADER_TIME = Date.now();
21564
+ if (container && !document.getElementById(LOADER_SVG_ELEMENT_ID)) {
21565
+ container.appendChild(createLoaderSvg());
21566
+ }
21567
+ loaderStartTime = Date.now();
21323
21568
  }
21324
21569
  function hideIframeLoader(waitLayoutShift = IFRAME_LAYOUT_SHIFT_TIME) {
21325
- if (IFRAME_SHOW_LOADER_TIMEOUT_ID) {
21326
- clearTimeout(IFRAME_SHOW_LOADER_TIMEOUT_ID);
21570
+ if (loaderTimeoutId) {
21571
+ clearTimeout(loaderTimeoutId);
21327
21572
  }
21328
- const delta = Date.now() - IFRAME_START_SHOW_LOADER_TIME;
21573
+ const delta = Date.now() - loaderStartTime;
21329
21574
  if (delta >= IFRAME_SHOW_LOADER_MINIMAL_TIME) {
21330
21575
  setTimeout(() => {
21576
+ var _a;
21331
21577
  const container = getContainer();
21332
21578
  container === null || container === void 0 ? void 0 : container.classList.remove(CONTAINER_ELEMENT_CLASS__LOADER);
21333
- IFRAME_START_SHOW_LOADER_TIME = 0;
21579
+ (_a = document.getElementById(LOADER_SVG_ELEMENT_ID)) === null || _a === void 0 ? void 0 : _a.remove();
21580
+ loaderStartTime = 0;
21334
21581
  }, waitLayoutShift);
21335
- return;
21336
21582
  }
21337
21583
  else {
21338
- const waitLayoutShift = delta >= IFRAME_LAYOUT_SHIFT_TIME ? 0 : IFRAME_LAYOUT_SHIFT_TIME - delta;
21584
+ const adjustedWait = delta >= IFRAME_LAYOUT_SHIFT_TIME ? 0 : IFRAME_LAYOUT_SHIFT_TIME - delta;
21339
21585
  const timeoutTime = IFRAME_SHOW_LOADER_MINIMAL_TIME - delta;
21340
- IFRAME_SHOW_LOADER_TIMEOUT_ID = setTimeout(() => {
21341
- hideIframeLoader(waitLayoutShift);
21586
+ loaderTimeoutId = setTimeout(() => {
21587
+ hideIframeLoader(adjustedWait);
21342
21588
  }, timeoutTime);
21589
+ }
21590
+ }
21591
+
21592
+ function removeTimeoutMessage() {
21593
+ var _a;
21594
+ (_a = document.getElementById(TIMEOUT_MESSAGE_ELEMENT_ID)) === null || _a === void 0 ? void 0 : _a.remove();
21595
+ }
21596
+ function showTimeoutMessage(message, onClose, isError = false) {
21597
+ removeTimeoutMessage();
21598
+ const container = getContainer();
21599
+ if (!container)
21343
21600
  return;
21601
+ const messageEl = document.createElement('div');
21602
+ messageEl.id = TIMEOUT_MESSAGE_ELEMENT_ID;
21603
+ if (isError) {
21604
+ messageEl.classList.add('error');
21605
+ }
21606
+ const textEl = document.createElement('p');
21607
+ textEl.textContent = message;
21608
+ messageEl.appendChild(textEl);
21609
+ const button = document.createElement('button');
21610
+ button.textContent = 'Close';
21611
+ button.addEventListener('click', onClose);
21612
+ messageEl.appendChild(button);
21613
+ container.appendChild(messageEl);
21614
+ }
21615
+
21616
+ function setupIframeConnection({ iframe, callbacks, childOrigin, onComplete, close }) {
21617
+ let slowTimeoutId = null;
21618
+ let failedTimeoutId = null;
21619
+ let handshakeTimeoutId = null;
21620
+ let handshakeReceived = false;
21621
+ function clearTimeouts() {
21622
+ if (slowTimeoutId)
21623
+ clearTimeout(slowTimeoutId);
21624
+ if (failedTimeoutId)
21625
+ clearTimeout(failedTimeoutId);
21626
+ if (handshakeTimeoutId)
21627
+ clearTimeout(handshakeTimeoutId);
21628
+ slowTimeoutId = null;
21629
+ failedTimeoutId = null;
21630
+ handshakeTimeoutId = null;
21631
+ removeTimeoutMessage();
21632
+ }
21633
+ function complete(callback) {
21634
+ clearTimeouts();
21635
+ close(callback);
21636
+ onComplete();
21637
+ }
21638
+ function handleError() {
21639
+ clearTimeouts();
21640
+ showTimeoutMessage('Unable to connect', () => complete(callbacks.onClose), true);
21641
+ }
21642
+ iframe.onerror = handleError;
21643
+ iframe.onload = () => {
21644
+ if (!handshakeReceived) {
21645
+ handshakeTimeoutId = setTimeout(() => {
21646
+ if (!handshakeReceived)
21647
+ handleError();
21648
+ }, HANDSHAKE_AFTER_LOAD_TIMEOUT);
21649
+ }
21650
+ };
21651
+ slowTimeoutId = setTimeout(() => {
21652
+ showTimeoutMessage('Taking longer than expected', () => complete(callbacks.onClose));
21653
+ }, SLOW_CONNECTION_TIMEOUT);
21654
+ failedTimeoutId = setTimeout(() => {
21655
+ showTimeoutMessage('Unable to connect', () => complete(callbacks.onClose), true);
21656
+ }, CONNECTION_FAILED_TIMEOUT);
21657
+ const connection = connectToChild({
21658
+ iframe,
21659
+ ...(childOrigin && { childOrigin }),
21660
+ methods: {
21661
+ ...callbacks,
21662
+ handshake: (...args) => {
21663
+ var _a;
21664
+ handshakeReceived = true;
21665
+ clearTimeouts();
21666
+ hideIframeLoader();
21667
+ (_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.handshake) === null || _a === void 0 ? void 0 : _a.call(callbacks, ...args);
21668
+ },
21669
+ close: () => complete(callbacks.onClose),
21670
+ },
21671
+ });
21672
+ connection.promise.catch(handleError);
21673
+ }
21674
+
21675
+ function init(mountTargetSelector) {
21676
+ var _a;
21677
+ injectStyles(mountTargetSelector);
21678
+ if (getContainer())
21679
+ return;
21680
+ const container = createContainer();
21681
+ if (mountTargetSelector && document.querySelector(mountTargetSelector)) {
21682
+ (_a = document.querySelector(mountTargetSelector)) === null || _a === void 0 ? void 0 : _a.appendChild(container);
21683
+ }
21684
+ else {
21685
+ document.body.appendChild(container);
21686
+ }
21687
+ }
21688
+ function close(callback) {
21689
+ document.body.classList.remove(BODY_CLASS);
21690
+ if (getContainer()) {
21691
+ deleteContainer();
21692
+ callback === null || callback === void 0 ? void 0 : callback();
21344
21693
  }
21345
21694
  }
21346
21695
  async function openIframe(uri, callbacks = {}, { mountTargetSelector } = {}) {
21347
21696
  close();
21348
21697
  init(mountTargetSelector);
21349
21698
  return new Promise((resolve) => {
21350
- function complete(callback) {
21351
- close(callback);
21352
- resolve();
21353
- }
21354
21699
  function doOpen() {
21355
- const iframe = document.createElement('iframe');
21356
- iframe.src = uri;
21357
- iframe.id = POPUP_ELEMENT_ID;
21358
- iframe.onload = () => {
21359
- hideIframeLoader();
21360
- };
21361
- if (!!getContainer()) {
21362
- document.body.classList.add(BODY_CLASS);
21363
- showIframeLoader();
21364
- appendToContainer(iframe);
21365
- handleIframeUnmount(iframe);
21366
- connectToChild({
21367
- iframe,
21368
- methods: {
21369
- ...callbacks,
21370
- handshake: (...args) => {
21371
- var _a;
21372
- hideIframeLoader();
21373
- (_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.handshake) === null || _a === void 0 ? void 0 : _a.call(callbacks, ...args);
21374
- },
21375
- close: () => complete(callbacks.onClose),
21376
- },
21377
- });
21378
- }
21379
- else {
21700
+ if (!getContainer()) {
21380
21701
  throw Error('Membrane container element not found. Was it manually removed?');
21381
21702
  }
21703
+ const iframe = document.createElement('iframe');
21704
+ iframe.id = POPUP_ELEMENT_ID;
21705
+ iframe.src = uri;
21706
+ document.body.classList.add(BODY_CLASS);
21707
+ showIframeLoader();
21708
+ appendToContainer(iframe);
21709
+ handleIframeUnmount(iframe);
21710
+ setupIframeConnection({ iframe, callbacks, onComplete: resolve, close });
21382
21711
  }
21383
21712
  if (document.readyState === 'complete' || document.readyState === 'interactive') {
21384
21713
  doOpen();
21385
21714
  }
21386
21715
  else {
21387
- document.addEventListener('DOMContentLoaded', () => {
21388
- doOpen();
21389
- });
21716
+ document.addEventListener('DOMContentLoaded', doOpen);
21390
21717
  }
21391
21718
  });
21392
21719
  }
@@ -21394,18 +21721,14 @@
21394
21721
  close();
21395
21722
  init(mountTargetSelector);
21396
21723
  return new Promise((resolve) => {
21397
- function complete(callback) {
21398
- close(callback);
21399
- resolve();
21400
- }
21401
21724
  function doOpen() {
21725
+ if (!getContainer()) {
21726
+ throw Error('Membrane container element not found. Was it manually removed?');
21727
+ }
21402
21728
  const iframeName = `${POPUP_ELEMENT_ID}-${Date.now()}`;
21403
21729
  const iframe = document.createElement('iframe');
21404
21730
  iframe.id = POPUP_ELEMENT_ID;
21405
21731
  iframe.name = iframeName;
21406
- iframe.onload = () => {
21407
- hideIframeLoader();
21408
- };
21409
21732
  const form = document.createElement('form');
21410
21733
  form.method = 'POST';
21411
21734
  form.action = url;
@@ -21420,186 +21743,24 @@
21420
21743
  form.appendChild(input);
21421
21744
  }
21422
21745
  }
21423
- if (!!getContainer()) {
21424
- document.body.classList.add(BODY_CLASS);
21425
- showIframeLoader();
21426
- appendToContainer(iframe);
21427
- handleIframeUnmount(iframe);
21428
- document.body.appendChild(form);
21429
- form.submit();
21430
- form.remove();
21431
- const childOrigin = new URL(url).origin;
21432
- connectToChild({
21433
- iframe,
21434
- childOrigin,
21435
- methods: {
21436
- ...callbacks,
21437
- handshake: (...args) => {
21438
- var _a;
21439
- hideIframeLoader();
21440
- (_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.handshake) === null || _a === void 0 ? void 0 : _a.call(callbacks, ...args);
21441
- },
21442
- close: () => complete(callbacks.onClose),
21443
- },
21444
- });
21445
- }
21446
- else {
21447
- throw Error('Membrane container element not found. Was it manually removed?');
21448
- }
21746
+ document.body.classList.add(BODY_CLASS);
21747
+ showIframeLoader();
21748
+ appendToContainer(iframe);
21749
+ handleIframeUnmount(iframe);
21750
+ document.body.appendChild(form);
21751
+ form.submit();
21752
+ form.remove();
21753
+ const childOrigin = new URL(url).origin;
21754
+ setupIframeConnection({ iframe, callbacks, childOrigin, onComplete: resolve, close });
21449
21755
  }
21450
21756
  if (document.readyState === 'complete' || document.readyState === 'interactive') {
21451
21757
  doOpen();
21452
21758
  }
21453
21759
  else {
21454
- document.addEventListener('DOMContentLoaded', () => {
21455
- doOpen();
21456
- });
21760
+ document.addEventListener('DOMContentLoaded', doOpen);
21457
21761
  }
21458
21762
  });
21459
21763
  }
21460
- function close(callback) {
21461
- document.body.classList.remove(BODY_CLASS);
21462
- if (!!getContainer()) {
21463
- deleteContainer();
21464
- if (callback) {
21465
- callback();
21466
- }
21467
- }
21468
- }
21469
- function init(mountTargetSelector) {
21470
- var _a;
21471
- injectStyles(mountTargetSelector);
21472
- if (!!getContainer()) {
21473
- return;
21474
- }
21475
- const container = createContainer();
21476
- if (mountTargetSelector && document.querySelector(mountTargetSelector)) {
21477
- (_a = document.querySelector(mountTargetSelector)) === null || _a === void 0 ? void 0 : _a.appendChild(container);
21478
- }
21479
- else {
21480
- document.body.appendChild(container);
21481
- }
21482
- }
21483
- function injectStyles(mountTargetSelector) {
21484
- const hasCustomMountTarget = Boolean(mountTargetSelector && document.querySelector(mountTargetSelector));
21485
- const styles = [
21486
- `.${CONTAINER_ELEMENT_CLASS}:empty {
21487
- display: none;
21488
- }`,
21489
- hasCustomMountTarget
21490
- ? `.${CONTAINER_ELEMENT_CLASS} {
21491
- inset: 0;
21492
- background: rgba(0, 0, 0, 0);
21493
- transition: background 0.2s ease-out;
21494
- display: flex;
21495
- justify-content: center;
21496
- align-items: center;
21497
- width: 100%;
21498
- height: 100%;
21499
- }`
21500
- : `.${CONTAINER_ELEMENT_CLASS} {
21501
- position: fixed;
21502
- inset: 0;
21503
- z-index: 2147483647;
21504
- display: flex;
21505
- justify-content: center;
21506
- align-items: center;
21507
- pointer-events: auto;
21508
- background: rgba(0, 0, 0, 0);
21509
- transition: background 0.2s ease-out;
21510
- }`,
21511
- `.${CONTAINER_ELEMENT_CLASS}.${CONTAINER_ELEMENT_CLASS__LOADER} {
21512
- background: transparent;
21513
- backdrop-filter: blur(8px);
21514
- -webkit-backdrop-filter: blur(8px);
21515
- }`,
21516
- `.${CONTAINER_ELEMENT_CLASS}.${CONTAINER_ELEMENT_CLASS__LOADER}::before {
21517
- ${hasCustomMountTarget ? 'position: absolute;' : ''}
21518
- content: "";
21519
- width: 6rem;
21520
- height: 6rem;
21521
- padding: 1rem;
21522
- border-radius: 1rem;
21523
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120' fill='black' %3E%3Cpath d='M56.45 13.17c0-.96 1.04-1.56 1.88-1.08l44.4 25.71c.47.28.77.8.77 1.35V90.6c0 .96-1.04 1.56-1.87 1.08l-11.1-6.43V48.78c0-.55-.3-1.07-.78-1.35l-33.3-19.28z' /%3E%3Cpath d='M36.48 26.8c0-.96 1.04-1.56 1.87-1.08l44.4 25.71c.48.28.78.8.78 1.35v51.44c0 .96-1.04 1.56-1.87 1.08l-11.11-6.43V62.43c0-.55-.3-1.07-.78-1.35L36.48 41.8z' /%3E%3Cpath d='M16.5 40.45c0-.96 1.04-1.56 1.87-1.08l44.4 25.71c.48.28.78.8.78 1.35v51.44c0 .96-1.04 1.56-1.87 1.08l-44.56-25.8a1.3 1.3 0 0 1-.62-1.09z' /%3E%3C/svg%3E");
21524
- background-size: 4rem 4rem;
21525
- background-repeat: no-repeat;
21526
- background-position: center;
21527
- }`,
21528
- `.${CONTAINER_ELEMENT_CLASS} iframe {
21529
- ${hasCustomMountTarget ? '' : 'position: absolute;'}
21530
- width: 100%;
21531
- height: 100%;
21532
- border-width: 0;
21533
-
21534
- /* fix transparent bg, because iframe document has light scheme */
21535
- color-scheme: light;
21536
- }`,
21537
- `.${CONTAINER_ELEMENT_CLASS}.${CONTAINER_ELEMENT_CLASS__LOADER} iframe {
21538
- visibility: hidden;
21539
- }`,
21540
- !hasCustomMountTarget
21541
- ? `body.${BODY_CLASS} {
21542
- overflow: hidden;
21543
- }`
21544
- : '',
21545
- ];
21546
- let styleElement = document.getElementById(STYLES_ELEMENT_ID);
21547
- if (!styleElement) {
21548
- styleElement = document.createElement('style');
21549
- styleElement.id = STYLES_ELEMENT_ID;
21550
- styleElement.type = 'text/css';
21551
- document.head.appendChild(styleElement);
21552
- }
21553
- styleElement.textContent = styles.join('\n');
21554
- }
21555
- function removeInjectedStyles() {
21556
- const stylesElement = document.getElementById(STYLES_ELEMENT_ID);
21557
- if (stylesElement) {
21558
- stylesElement.remove();
21559
- }
21560
- }
21561
- function createContainer() {
21562
- const container = document.createElement('div');
21563
- container.id = CONTAINER_ELEMENT_ID;
21564
- container.classList.add(CONTAINER_ELEMENT_CLASS);
21565
- return container;
21566
- }
21567
- function getContainer() {
21568
- return document.getElementById(CONTAINER_ELEMENT_ID);
21569
- }
21570
- function appendToContainer(el) {
21571
- const container = getContainer();
21572
- container === null || container === void 0 ? void 0 : container.appendChild(el);
21573
- }
21574
- function deleteContainer() {
21575
- const container = getContainer();
21576
- if (container) {
21577
- container.remove();
21578
- }
21579
- removeInjectedStyles();
21580
- }
21581
- function handleIframeUnmount(iframe) {
21582
- const observer = new MutationObserver((mutationsList) => {
21583
- for (const mutation of mutationsList) {
21584
- for (const removedNode of mutation.removedNodes) {
21585
- if (removedNode instanceof HTMLElement && removedNode.id === POPUP_ELEMENT_ID) {
21586
- observer.disconnect();
21587
- deleteContainer();
21588
- return;
21589
- }
21590
- }
21591
- }
21592
- });
21593
- const parent = iframe.parentNode;
21594
- if (parent) {
21595
- observer.observe(parent, {
21596
- childList: true,
21597
- });
21598
- }
21599
- else {
21600
- console.warn(`iframe with ID "${POPUP_ELEMENT_ID}" has no parent node`);
21601
- }
21602
- }
21603
21764
 
21604
21765
  class DataSourcesAccessor extends ElementListAccessor {
21605
21766
  constructor(client) {
@@ -22791,9 +22952,10 @@
22791
22952
  }
22792
22953
  });
22793
22954
  }
22794
- async function detectConnectionType({ client, authOptionKey, connectorId, integrationKey, integrationId, connectorParameters, }) {
22955
+ async function detectConnectionType({ client, authOptionKey, connectorId, connectionId, integrationKey, integrationId, connectorParameters, }) {
22795
22956
  const connectionOptions = await client.post('/connection-options', {
22796
22957
  connectorId,
22958
+ connectionId,
22797
22959
  integrationId,
22798
22960
  integrationKey,
22799
22961
  connectorParameters,
@@ -24411,6 +24573,7 @@
24411
24573
  integrationId: string$1().optional(),
24412
24574
  integrationKey: string$1().optional(),
24413
24575
  connectorId: string$1().optional(),
24576
+ connectionId: string$1().optional(),
24414
24577
  connectorParameters: any().optional(),
24415
24578
  connectorVersion: string$1().optional(),
24416
24579
  });