@roomle/embedding-lib 7.0.0 → 7.1.0-alpha.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.
@@ -1,13 +1,13 @@
1
- import { a as e, n as t, o as n } from "./utils-DfC2ZLUc.mjs";
2
- import { d as r } from "./drag-in-DXVxlotA.mjs";
3
- import { t as i } from "./drag-ghost-DbEzikW5.mjs";
4
- var a = (e, t = 0) => n(e) ? {
5
- clientX: e.touches[t].clientX,
6
- clientY: e.touches[t].clientY
1
+ import { a as e, c as t, n } from "./utils-Co3lE-Ji.mjs";
2
+ import { d as r } from "./drag-in-DDGopCLr.mjs";
3
+ import { t as i } from "./drag-ghost-Rbgko27K.mjs";
4
+ var a = (e, n = 0) => t(e) ? {
5
+ clientX: e.touches[n].clientX,
6
+ clientY: e.touches[n].clientY
7
7
  } : {
8
8
  clientX: e.clientX,
9
9
  clientY: e.clientY
10
- }, o = (e) => !e || !n(e) || e.touches.length > 0, s = class {
10
+ }, o = (e) => !e || !t(e) || e.touches.length > 0, s = class {
11
11
  _touchDragTimeOut;
12
12
  _onTouchDragStart;
13
13
  _payload = null;
@@ -19,7 +19,7 @@ var a = (e, t = 0) => n(e) ? {
19
19
  this._payload = e, this._onTouchDragStart = t, this._delay = typeof n.delay == "number" ? n.delay : 500, this._epsilon = typeof n.epsilon == "number" ? n.epsilon : 10;
20
20
  }
21
21
  onStart(e) {
22
- o(e) && (this._touchDragTimeOut ||= (this._firstTouch = a(e, n(e) ? e.touches.length - 1 : 0), setTimeout(() => {
22
+ o(e) && (this._touchDragTimeOut ||= (this._firstTouch = a(e, t(e) ? e.touches.length - 1 : 0), setTimeout(() => {
23
23
  this._clearTimeout(), this._lastTouch ||= a(e), this._checkXDistance(e)();
24
24
  }, this._delay)));
25
25
  }
@@ -70,12 +70,12 @@ var a = (e, t = 0) => n(e) ? {
70
70
  _reset() {
71
71
  this._startX = 0, this._startY = 0, this._lastX = 0, this._lastY = 0, this._isWaiting = !1;
72
72
  }
73
- }, u = "data-rml-old-draggable", d = (e, t) => {
74
- let r = n(e), i = {
73
+ }, u = "data-rml-old-draggable", d = (e, n) => {
74
+ let r = t(e), i = {
75
75
  delay: r ? 500 : 100,
76
76
  epsilon: r ? 10 : 15
77
77
  };
78
- if (!t || !(r || e instanceof MouseEvent)) return i;
78
+ if (!n || !(r || e instanceof MouseEvent)) return i;
79
79
  let { delayKey: a, epsilonKey: o } = r ? {
80
80
  delayKey: "touchDragDelay",
81
81
  epsilonKey: "touchDragEpsilon"
@@ -83,47 +83,65 @@ var a = (e, t = 0) => n(e) ? {
83
83
  delayKey: "customDragDelay",
84
84
  epsilonKey: "customDragEpsilon"
85
85
  };
86
- return typeof t[a] == "number" && (i.delay = t.touchDragDelay), typeof t[o] == "number" && (i.epsilon = t.touchDragEpsilon), i;
86
+ return typeof n[a] == "number" && (i.delay = n.touchDragDelay), typeof n[o] == "number" && (i.epsilon = n.touchDragEpsilon), i;
87
87
  }, f = class {
88
88
  _options = {};
89
89
  _instance;
90
90
  _mainDomElement;
91
91
  _viewName;
92
92
  _currentCustomDrag = null;
93
- _currentBb = null;
94
93
  _startTarget = null;
95
94
  _dragGhost = null;
96
95
  _onBeforeUpdateDrag = () => ({});
97
96
  isDragging = !1;
98
97
  _hasEnteredIframe = !1;
99
98
  _pendingDragIn = null;
100
- _canvasBb = null;
101
- _overlayBb = null;
99
+ _phase = { kind: "idle" };
102
100
  _dragGeneration = 0;
103
- _interactionContainerBb = null;
101
+ _parentWithDragLeave = null;
102
+ _parentDragLeave = () => {
103
+ this._phase.kind === "ready" && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
104
+ };
104
105
  constructor(e, t, n, r) {
105
- this._instance = e, this._options = n || {}, this._viewName = r, this._mainDomElement = t, this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
106
- this._instance.cancelDragIn();
107
- });
106
+ this._instance = e, this._options = n || {}, this._viewName = r, this._mainDomElement = t, this._parentWithDragLeave = this._mainDomElement.parentElement, this._parentWithDragLeave?.addEventListener("dragleave", this._parentDragLeave);
108
107
  }
109
108
  beforeUpdateGhost(e) {
110
109
  this._onBeforeUpdateDrag = e;
111
110
  }
112
111
  async _dragStart(e, t, n = "rml_id") {
113
112
  let r = ++this._dragGeneration;
114
- if (this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(u, this._startTarget.draggable.toString()), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", c), this._startTarget.addEventListener("dragstart", c)), this._startTarget) {
113
+ if (this._phase = { kind: "starting" }, this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(u, this._startTarget.draggable.toString()), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", c), this._startTarget.addEventListener("dragstart", c)), this._startTarget) {
115
114
  let e = this._startTarget.getBoundingClientRect(), t = this._startTarget.cloneNode(!0);
116
115
  t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, this._dragGhost = new i(t);
117
116
  } else this._dragGhost = new i();
118
- var a;
119
- this._currentBb = await this._instance.getBoundingClientRect((a = this._viewName, `[data-rml-custom-view="${a}"]`)), this._canvasBb = await this._instance.getBoundingClientRect("canvas"), this._overlayBb = (await this._instance.getDrawerBoundingClientRect()).final, this._interactionContainerBb = await this._instance.getBoundingClientRect(".interaction-container"), r === this._dragGeneration && (this._pendingDragIn = {
120
- id: e,
121
- type: n
122
- }, this._hasEnteredIframe = !1, this.isDragging = !0);
123
- }
124
- _dragUpdate(n) {
125
- document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(n);
126
- let { clientX: i, clientY: a } = t(n);
117
+ let a = await this._instance.getBoundingClientRect((o = this._viewName, `[data-rml-custom-view="${o}"]`));
118
+ var o;
119
+ let s = await this._instance.getBoundingClientRect("canvas"), l = (await this._instance.getDrawerBoundingClientRect()).final, d = await this._instance.getBoundingClientRect(".interaction-container");
120
+ if (r === this._dragGeneration) {
121
+ if (!a) {
122
+ this._phase = {
123
+ kind: "failed",
124
+ reason: `could not read the bounding rect of custom view "${this._viewName}"`
125
+ };
126
+ return;
127
+ }
128
+ this._phase = {
129
+ kind: "ready",
130
+ bounds: {
131
+ view: a,
132
+ canvas: s,
133
+ overlay: l,
134
+ interactionContainer: d
135
+ }
136
+ }, this._pendingDragIn = {
137
+ id: e,
138
+ type: n
139
+ }, this._hasEnteredIframe = !1, this.isDragging = !0;
140
+ }
141
+ }
142
+ _dragUpdate(t) {
143
+ document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(t);
144
+ let { clientX: i, clientY: a } = n(t);
127
145
  if (this._dragGhost) {
128
146
  let { width: e, height: t } = this._mainDomElement.getBoundingClientRect();
129
147
  this._dragGhost.updateDragGhost(i, a, { ghost: { visibleIn: {
@@ -133,10 +151,10 @@ var a = (e, t = 0) => n(e) ? {
133
151
  height: t
134
152
  } } });
135
153
  }
136
- if (!this._currentBb || !this.isDragging) return;
137
- let o = this._currentBb.x + i, s = this._currentBb.y + a, c = e(o, s, this._canvasBb, this._overlayBb, this._interactionContainerBb);
138
- if (c && !this._hasEnteredIframe && this._pendingDragIn && (this._instance.dragInObject(this._pendingDragIn.id, o, s, this._pendingDragIn.type), this._hasEnteredIframe = !0), !c && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1), !this._hasEnteredIframe) return;
139
- let { url: l, width: u, height: d } = ((e) => {
154
+ if (this._phase.kind !== "ready") return;
155
+ let { view: o, canvas: s, overlay: c, interactionContainer: l } = this._phase.bounds, u = o.x + i, d = o.y + a, f = e(u, d, s, c, l);
156
+ if (f && !this._hasEnteredIframe && this._pendingDragIn && (this._instance.dragInObject(this._pendingDragIn.id, u, d, this._pendingDragIn.type), this._hasEnteredIframe = !0), !f && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1), !this._hasEnteredIframe) return;
157
+ let { url: p, width: m, height: h } = ((e) => {
140
158
  let t = "", n = 112, i = 112;
141
159
  if (!e) return {
142
160
  url: r,
@@ -153,32 +171,32 @@ var a = (e, t = 0) => n(e) ? {
153
171
  width: n,
154
172
  height: i
155
173
  };
156
- })(this._startTarget), f = this._options || {}, p = {
174
+ })(this._startTarget), g = this._options || {}, _ = {
157
175
  ghost: {
158
176
  visibleIn: {
159
- x: this._currentBb.x - (f.dragInOverlapX || 0),
160
- y: this._currentBb.y + (f.dragInOverlapY || 0),
161
- width: this._currentBb.width + (f.dragInOverlapX || 0),
162
- height: this._currentBb.height + (f.dragInOverlapY || 0)
177
+ x: o.x - (g.dragInOverlapX || 0),
178
+ y: o.y + (g.dragInOverlapY || 0),
179
+ width: o.width + (g.dragInOverlapX || 0),
180
+ height: o.height + (g.dragInOverlapY || 0)
163
181
  },
164
- url: l,
165
- width: u,
166
- height: d
182
+ url: p,
183
+ width: m,
184
+ height: h
167
185
  },
168
186
  mode: "custom-view"
169
- }, { x: m, y: h, options: g } = this._onBeforeUpdateDrag(o, s, p), _ = typeof m == "number" ? m : o, v = typeof h == "number" ? h : s, y = g || p;
170
- this._instance.updateDrag(_, v, y);
187
+ }, { x: v, y, options: b } = this._onBeforeUpdateDrag(u, d, _), x = typeof v == "number" ? v : u, S = typeof y == "number" ? y : d, C = b || _;
188
+ this._instance.updateDrag(x, S, C);
171
189
  }
172
190
  _dragEnd() {
173
- this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._currentCustomDrag = null, this.isDragging = !1, this._currentBb = null, this._canvasBb = null, this._overlayBb = null, this._interactionContainerBb = null, this._resetStartTarget(), this._instance.enableEvents(), this._dragGhost &&= (this._dragGhost.removeDragGhost(), null), this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._hasEnteredIframe = !1, this._pendingDragIn = null;
191
+ this._dragGeneration++, this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._currentCustomDrag = null, this.isDragging = !1, this._phase = { kind: "idle" }, this._resetStartTarget(), this._instance.enableEvents(), this._dragGhost &&= (this._dragGhost.removeDragGhost(), null), this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._hasEnteredIframe = !1, this._pendingDragIn = null;
174
192
  }
175
- dragStart(e, t, r) {
176
- this._instance.disableEvents(), this._startTarget = t.target, this._currentCustomDrag = n(t) ? new s(void 0, { onTouchDragStart: (t, n) => {
193
+ dragStart(e, n, r) {
194
+ this._instance.disableEvents(), this._startTarget = n.target, this._currentCustomDrag = t(n) ? new s(void 0, { onTouchDragStart: (t, n) => {
177
195
  this._dragStart(e, n, r);
178
196
  } }, {
179
- ...d(t, this._options),
197
+ ...d(n, this._options),
180
198
  delay: 0
181
- }) : new l({ onCustomDragStart: (t) => this._dragStart(e, t, r) }, d(t, this._options)), this._currentCustomDrag.onStart(t);
199
+ }) : new l({ onCustomDragStart: (t) => this._dragStart(e, t, r) }, d(n, this._options)), this._currentCustomDrag.onStart(n);
182
200
  }
183
201
  dragEnd() {
184
202
  this._dragEnd();
@@ -195,12 +213,14 @@ var a = (e, t = 0) => n(e) ? {
195
213
  touchEnd() {
196
214
  this.dragEnd();
197
215
  }
198
- dispose() {}
216
+ dispose() {
217
+ this._parentWithDragLeave?.removeEventListener("dragleave", this._parentDragLeave), this._parentWithDragLeave = null;
218
+ }
199
219
  _resetStartTarget() {
200
220
  this._startTarget && (this._startTarget.style.pointerEvents = "", this._startTarget.style.userSelect = "", this._startTarget.draggable = this._startTarget.getAttribute(u) === "true", this._startTarget.removeAttribute(u), this._startTarget.removeEventListener("dragstart", c));
201
221
  }
202
222
  releaseInput(e) {
203
- this._dragGeneration++, this._dragEnd();
223
+ this._dragEnd();
204
224
  }
205
225
  };
206
226
  export { f as DragInFromCustomViewStrategy };
@@ -0,0 +1,123 @@
1
+ import { c as e, i as t, n, o as r, r as i, s as a } from "./utils-i2eOrtnv.mjs";
2
+ import { l as o, p as s, r as c } from "./drag-in-BCnrHxxt.mjs";
3
+ import { t as l } from "./drag-ghost-DqF-SGUQ.mjs";
4
+ //#region packages/embedding-lib/src/plugins/strategy/from-website.ts
5
+ var u = class {
6
+ _options = {};
7
+ _instance;
8
+ _mainDomElement;
9
+ _currentDrag = {};
10
+ _firefoxDragPosition = {
11
+ x: 0,
12
+ y: 0
13
+ };
14
+ _onBeforeUpdateDrag = () => ({});
15
+ isDragging = !1;
16
+ _hasEnteredIframe = !1;
17
+ _dragInObjectCalled = !1;
18
+ _pendingDragIn = null;
19
+ _phase = { kind: "idle" };
20
+ _dragGeneration = 0;
21
+ _currentTouch = null;
22
+ _parentWithDragLeave = null;
23
+ _firefoxFallback = (e) => {
24
+ if (!this._currentDrag.event) return;
25
+ e.preventDefault();
26
+ let t = e || window.event;
27
+ this._firefoxDragPosition.x = t.pageX || 0, this._firefoxDragPosition.y = t.pageY || 0;
28
+ };
29
+ _parentDragLeave = () => {
30
+ this._phase.kind !== "ready" || !this._hasEnteredIframe || (this._instance.cancelDragIn(), this._hasEnteredIframe = !1, this._dragInObjectCalled = !1);
31
+ };
32
+ constructor(e, t, n) {
33
+ this._instance = e, this._mainDomElement = t, this._options = n || {}, document.addEventListener("dragover", this._firefoxFallback), this._parentWithDragLeave = this._mainDomElement.parentElement, this._parentWithDragLeave?.addEventListener("dragleave", this._parentDragLeave);
34
+ }
35
+ beforeUpdateGhost(e) {
36
+ this._onBeforeUpdateDrag = e;
37
+ }
38
+ async dragStart(e, r, a = "rml_id") {
39
+ let u = ++this._dragGeneration, d = this._mainDomElement.parentNode;
40
+ if (i(d).position !== "relative") {
41
+ let e = "parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly";
42
+ this._phase = {
43
+ kind: "failed",
44
+ reason: e
45
+ }, console.warn(`Drag-in not started: ${e}`);
46
+ return;
47
+ }
48
+ this._mainDomElement.style.pointerEvents = "none";
49
+ let f = d.querySelector("." + s);
50
+ f || (f = document.createElement("div"), f.classList.add(s), d.appendChild(f)), f.classList.remove(c.DISPLAY_NONE), r.target.getAttribute("draggable") || console.warn("Draggable not detected correctly! Did you add draggable=\"true\" to the element? In Sarafi only 'draggable' is too less");
51
+ let p = d.querySelector("." + o);
52
+ this._currentDrag.event = r;
53
+ let m = r.target, h = m.cloneNode(!0), g = m.getBoundingClientRect();
54
+ h.style.width = `${g.width}px`, h.style.height = `${g.height}px`, this._currentDrag.ghost = new l(h), this._currentDrag.offset || (this._currentDrag.offset = {
55
+ x: 0,
56
+ y: 0
57
+ });
58
+ let { clientX: _, clientY: v } = n(r, this._firefoxDragPosition);
59
+ this._currentDrag.offset.x = _ - g.left, this._currentDrag.offset.y = v - g.top, r instanceof DragEvent && r.dataTransfer && r.dataTransfer.setDragImage && r.dataTransfer.setDragImage(p, 0, 0), t(d, this._currentDrag.event || r, this._firefoxDragPosition), this._pendingDragIn = {
60
+ id: e,
61
+ type: a
62
+ }, this._hasEnteredIframe = !1, this._dragInObjectCalled = !1, this.isDragging = !0, this._phase = { kind: "starting" };
63
+ let y = null;
64
+ try {
65
+ y = (await this._instance.getDrawerBoundingClientRect()).final;
66
+ } catch (e) {
67
+ console.warn("Could not read the interaction container rect, treating the whole iframe as canvas", e);
68
+ }
69
+ u === this._dragGeneration && (this._phase = {
70
+ kind: "ready",
71
+ bounds: { interactionContainer: y }
72
+ });
73
+ }
74
+ dragUpdate(i) {
75
+ let o = this._mainDomElement.parentNode, { x: s, y: c } = t(o, i, this._firefoxDragPosition);
76
+ if (s === 0 && c === 0) return;
77
+ let l = Math.max(1, s), u = Math.max(1, c);
78
+ if (l === 1 && u === 1) return;
79
+ let d = this._mainDomElement.getBoundingClientRect(), { clientX: f, clientY: p } = n(i, this._firefoxDragPosition), m = a(f, p, d), h = l, g = u;
80
+ if (e(i)) {
81
+ let e = this._options.settings?.fingerSize || 0;
82
+ h = Math.max(2, l + e), g = Math.max(2, u - e);
83
+ }
84
+ let { x: _, y: v, options: y } = this._onBeforeUpdateDrag(h, g, {}), b = y || {
85
+ settings: {},
86
+ ghost: {}
87
+ };
88
+ if (b.ghost ||= {}, b.ghost.visibleIn && b.ghost.hiddenIn || (b.ghost.hiddenIn = d), this._currentDrag.ghost && this._currentDrag.ghost.updateDragGhost(f, p, b), this._phase.kind !== "ready") return;
89
+ let { interactionContainer: x } = this._phase.bounds;
90
+ if (m && this._pendingDragIn) {
91
+ let e = r(f, p, d, x);
92
+ e && !this._hasEnteredIframe ? (this._dragInObjectCalled || (this._dragInObjectCalled = !0, this._instance.dragInObject(this._pendingDragIn.id, l, u, this._pendingDragIn.type)), this._hasEnteredIframe = !0) : !e && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1, this._dragInObjectCalled = !1);
93
+ } else !m && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1, this._dragInObjectCalled = !1);
94
+ if (!this._hasEnteredIframe) return;
95
+ let S = typeof _ == "number" ? _ : h, C = typeof v == "number" ? v : g;
96
+ this._instance.updateDrag(S, C, {});
97
+ }
98
+ dragEnd() {
99
+ this._dragGeneration++, this._mainDomElement.style.pointerEvents = "all";
100
+ let e = this._mainDomElement.parentNode;
101
+ this.isDragging = !1, this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = {
102
+ x: 0,
103
+ y: 0
104
+ }, this._hasEnteredIframe = !1, this._dragInObjectCalled = !1, this._pendingDragIn = null, this._phase = { kind: "idle" };
105
+ let t = e.querySelector("." + s);
106
+ t && t.classList.add(c.DISPLAY_NONE);
107
+ }
108
+ touchStart(e, t, n = "rml_id") {
109
+ t.preventDefault(), this.dragStart(e, t, n);
110
+ }
111
+ touchMove(e) {
112
+ this._currentTouch && this._currentTouch.onMove(e), this._currentDrag.event && this.dragUpdate(e);
113
+ }
114
+ touchEnd() {
115
+ this.dragEnd();
116
+ }
117
+ dispose() {
118
+ document.removeEventListener("dragover", this._firefoxFallback), this._parentWithDragLeave?.removeEventListener("dragleave", this._parentDragLeave), this._parentWithDragLeave = null;
119
+ }
120
+ releaseInput(e) {}
121
+ };
122
+ //#endregion
123
+ export { u as DragInFromWebsiteStrategy };
@@ -0,0 +1,118 @@
1
+ import { c as e, i as t, n, o as r, r as i, s as a } from "./utils-Co3lE-Ji.mjs";
2
+ import { l as o, p as s, r as c } from "./drag-in-DDGopCLr.mjs";
3
+ import { t as l } from "./drag-ghost-Rbgko27K.mjs";
4
+ var u = class {
5
+ _options = {};
6
+ _instance;
7
+ _mainDomElement;
8
+ _currentDrag = {};
9
+ _firefoxDragPosition = {
10
+ x: 0,
11
+ y: 0
12
+ };
13
+ _onBeforeUpdateDrag = () => ({});
14
+ isDragging = !1;
15
+ _hasEnteredIframe = !1;
16
+ _dragInObjectCalled = !1;
17
+ _pendingDragIn = null;
18
+ _phase = { kind: "idle" };
19
+ _dragGeneration = 0;
20
+ _currentTouch = null;
21
+ _parentWithDragLeave = null;
22
+ _firefoxFallback = (e) => {
23
+ if (!this._currentDrag.event) return;
24
+ e.preventDefault();
25
+ let t = e || window.event;
26
+ this._firefoxDragPosition.x = t.pageX || 0, this._firefoxDragPosition.y = t.pageY || 0;
27
+ };
28
+ _parentDragLeave = () => {
29
+ this._phase.kind === "ready" && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1, this._dragInObjectCalled = !1);
30
+ };
31
+ constructor(e, t, n) {
32
+ this._instance = e, this._mainDomElement = t, this._options = n || {}, document.addEventListener("dragover", this._firefoxFallback), this._parentWithDragLeave = this._mainDomElement.parentElement, this._parentWithDragLeave?.addEventListener("dragleave", this._parentDragLeave);
33
+ }
34
+ beforeUpdateGhost(e) {
35
+ this._onBeforeUpdateDrag = e;
36
+ }
37
+ async dragStart(e, r, a = "rml_id") {
38
+ let u = ++this._dragGeneration, d = this._mainDomElement.parentNode;
39
+ if (i(d).position !== "relative") {
40
+ this._phase = {
41
+ kind: "failed",
42
+ reason: "parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly"
43
+ };
44
+ return;
45
+ }
46
+ this._mainDomElement.style.pointerEvents = "none";
47
+ let f = d.querySelector("." + s);
48
+ f || (f = document.createElement("div"), f.classList.add(s), d.appendChild(f)), f.classList.remove(c.DISPLAY_NONE), r.target.getAttribute("draggable");
49
+ let p = d.querySelector("." + o);
50
+ this._currentDrag.event = r;
51
+ let m = r.target, h = m.cloneNode(!0), g = m.getBoundingClientRect();
52
+ h.style.width = `${g.width}px`, h.style.height = `${g.height}px`, this._currentDrag.ghost = new l(h), this._currentDrag.offset || (this._currentDrag.offset = {
53
+ x: 0,
54
+ y: 0
55
+ });
56
+ let { clientX: _, clientY: v } = n(r, this._firefoxDragPosition);
57
+ this._currentDrag.offset.x = _ - g.left, this._currentDrag.offset.y = v - g.top, r instanceof DragEvent && r.dataTransfer && r.dataTransfer.setDragImage && r.dataTransfer.setDragImage(p, 0, 0), t(d, this._currentDrag.event || r, this._firefoxDragPosition), this._pendingDragIn = {
58
+ id: e,
59
+ type: a
60
+ }, this._hasEnteredIframe = !1, this._dragInObjectCalled = !1, this.isDragging = !0, this._phase = { kind: "starting" };
61
+ let y = null;
62
+ try {
63
+ y = (await this._instance.getDrawerBoundingClientRect()).final;
64
+ } catch {}
65
+ u === this._dragGeneration && (this._phase = {
66
+ kind: "ready",
67
+ bounds: { interactionContainer: y }
68
+ });
69
+ }
70
+ dragUpdate(i) {
71
+ let o = this._mainDomElement.parentNode, { x: s, y: c } = t(o, i, this._firefoxDragPosition);
72
+ if (s === 0 && c === 0) return;
73
+ let l = Math.max(1, s), u = Math.max(1, c);
74
+ if (l === 1 && u === 1) return;
75
+ let d = this._mainDomElement.getBoundingClientRect(), { clientX: f, clientY: p } = n(i, this._firefoxDragPosition), m = a(f, p, d), h = l, g = u;
76
+ if (e(i)) {
77
+ let e = this._options.settings?.fingerSize || 0;
78
+ h = Math.max(2, l + e), g = Math.max(2, u - e);
79
+ }
80
+ let { x: _, y: v, options: y } = this._onBeforeUpdateDrag(h, g, {}), b = y || {
81
+ settings: {},
82
+ ghost: {}
83
+ };
84
+ if (b.ghost ||= {}, b.ghost.visibleIn && b.ghost.hiddenIn || (b.ghost.hiddenIn = d), this._currentDrag.ghost && this._currentDrag.ghost.updateDragGhost(f, p, b), this._phase.kind !== "ready") return;
85
+ let { interactionContainer: x } = this._phase.bounds;
86
+ if (m && this._pendingDragIn) {
87
+ let e = r(f, p, d, x);
88
+ e && !this._hasEnteredIframe ? (this._dragInObjectCalled || (this._dragInObjectCalled = !0, this._instance.dragInObject(this._pendingDragIn.id, l, u, this._pendingDragIn.type)), this._hasEnteredIframe = !0) : !e && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1, this._dragInObjectCalled = !1);
89
+ } else !m && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1, this._dragInObjectCalled = !1);
90
+ if (!this._hasEnteredIframe) return;
91
+ let S = typeof _ == "number" ? _ : h, C = typeof v == "number" ? v : g;
92
+ this._instance.updateDrag(S, C, {});
93
+ }
94
+ dragEnd() {
95
+ this._dragGeneration++, this._mainDomElement.style.pointerEvents = "all";
96
+ let e = this._mainDomElement.parentNode;
97
+ this.isDragging = !1, this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = {
98
+ x: 0,
99
+ y: 0
100
+ }, this._hasEnteredIframe = !1, this._dragInObjectCalled = !1, this._pendingDragIn = null, this._phase = { kind: "idle" };
101
+ let t = e.querySelector("." + s);
102
+ t && t.classList.add(c.DISPLAY_NONE);
103
+ }
104
+ touchStart(e, t, n = "rml_id") {
105
+ t.preventDefault(), this.dragStart(e, t, n);
106
+ }
107
+ touchMove(e) {
108
+ this._currentTouch && this._currentTouch.onMove(e), this._currentDrag.event && this.dragUpdate(e);
109
+ }
110
+ touchEnd() {
111
+ this.dragEnd();
112
+ }
113
+ dispose() {
114
+ document.removeEventListener("dragover", this._firefoxFallback), this._parentWithDragLeave?.removeEventListener("dragleave", this._parentDragLeave), this._parentWithDragLeave = null;
115
+ }
116
+ releaseInput(e) {}
117
+ };
118
+ export { u as DragInFromWebsiteStrategy };
package/hi.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./browser-C_Dfiou7.mjs";
2
- import { t } from "./utils-BnWKaFPc.mjs";
2
+ import { t } from "./utils-i2eOrtnv.mjs";
3
3
  var n = (e, t) => t === e.libraryId ? e : {
4
4
  ...e,
5
5
  libraryId: t
package/hi.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./browser-DRgK3Fk8.mjs";
2
- import { t } from "./utils-DfC2ZLUc.mjs";
2
+ import { t } from "./utils-Co3lE-Ji.mjs";
3
3
  var n = (e, t) => t === e.libraryId ? e : {
4
4
  ...e,
5
5
  libraryId: t
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomle/embedding-lib",
3
- "version": "7.0.0",
3
+ "version": "7.1.0-alpha.1",
4
4
  "description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
5
5
  "type": "module",
6
6
  "main": "./roomle-embedding-lib.js",
@@ -0,0 +1,25 @@
1
+ /**
2
+ * How far a drag-in strategy's `dragStart` has got.
3
+ *
4
+ * Both strategies ask Rubens for bounding rects over `MessageHandler` — an
5
+ * `await` — while `dragUpdate` keeps firing synchronously. In that window a drag
6
+ * is running but the strategy cannot yet tell whether the pointer is over the
7
+ * canvas, so changing the scene there is what caused RML-17511. The rects live
8
+ * inside `ready` rather than in nullable fields, so "not loaded yet" cannot be
9
+ * mistaken for "that element does not exist".
10
+ *
11
+ * `failed` is terminal: `dragUpdate` should keep ignoring events instead of
12
+ * looking like it is still loading. Details in
13
+ * `.agents/findings/homag-drag-in-inserts-object-twice.md`.
14
+ */
15
+ export type DragPhase<TBounds> = {
16
+ kind: 'idle';
17
+ } | {
18
+ kind: 'starting';
19
+ } | {
20
+ kind: 'ready';
21
+ bounds: TBounds;
22
+ } | {
23
+ kind: 'failed';
24
+ reason: string;
25
+ };
@@ -10,17 +10,18 @@ export declare class DragInFromCustomViewStrategy implements DragInStrategy {
10
10
  private _mainDomElement;
11
11
  private _viewName;
12
12
  private _currentCustomDrag;
13
- private _currentBb;
14
13
  private _startTarget;
15
14
  private _dragGhost;
16
15
  private _onBeforeUpdateDrag;
17
16
  isDragging: boolean;
18
17
  private _hasEnteredIframe;
19
18
  private _pendingDragIn;
20
- private _canvasBb;
21
- private _overlayBb;
19
+ private _phase;
22
20
  private _dragGeneration;
23
- private _interactionContainerBb;
21
+ /** Kept so `dispose()` can remove the listener again. */
22
+ private _parentWithDragLeave;
23
+ /** Same listener and same reasoning as `_parentDragLeave` in `from-website.ts`. */
24
+ private _parentDragLeave;
24
25
  constructor(instance: ExposedApi, mainDomElement: HTMLIFrameElement, options: DragInSettings, viewName: PossibleCustomViewsAndMain);
25
26
  beforeUpdateGhost(handler: OnBeforeUpdateDragGhost): void;
26
27
  _dragStart(id: RapiId, _event: MouseEvent | TouchEvent, type?: ID_TYPE): Promise<void>;
@@ -14,11 +14,24 @@ export declare class DragInFromWebsiteStrategy implements DragInStrategy {
14
14
  private _hasEnteredIframe;
15
15
  private _dragInObjectCalled;
16
16
  private _pendingDragIn;
17
- private _canvasBb;
18
- private _overlayBb;
19
- private _interactionContainerBb;
17
+ private _phase;
18
+ /**
19
+ * Bumped by `dragStart` and `dragEnd`, so a `dragStart` still awaiting its rect
20
+ * cannot arm the *next* drag with this drag's rects.
21
+ */
22
+ private _dragGeneration;
20
23
  private _currentTouch;
24
+ /** Kept so `dispose()` can remove the listener again. */
25
+ private _parentWithDragLeave;
21
26
  private _firefoxFallback;
27
+ /**
28
+ * Fires for every `dragleave` bubbling up through the iframe's parent, ours or
29
+ * not, so it needs the same guard `dragUpdate` has. Kept because `dragUpdate`
30
+ * bails once `getXY` reports 0,0, leaving this the only cancel for a drag that
31
+ * ends outside the iframe. Trade-off of the reset in
32
+ * `.agents/plans/drag-in-host-page-hardening.md`.
33
+ */
34
+ private _parentDragLeave;
22
35
  constructor(instance: ExposedApi, mainDomElement: HTMLIFrameElement, options: DragInOptions);
23
36
  beforeUpdateGhost(handler: OnBeforeUpdateDragGhost): void;
24
37
  dragStart(id: RapiId, event: DragEvent | TouchEvent, type?: ID_TYPE): Promise<void>;
@@ -16,4 +16,20 @@ export declare const extractClientXY: (event: MouseEvent | DragEvent | TouchEven
16
16
  clientY: number;
17
17
  };
18
18
  export declare const createGracefulProxy: <T extends object>(target: Partial<T>) => T;
19
- export declare const isOverVisibleCanvas: (clientX: number, clientY: number, canvasBb: Nullable<DOMRect>, overlayBb: Nullable<DOMRect>, interactionContainerBb: Nullable<DOMRect>, iframeBounds?: DOMRect) => boolean;
19
+ export declare const isPointInBounds: (clientX: number, clientY: number, bounds: {
20
+ left: number;
21
+ right: number;
22
+ top: number;
23
+ bottom: number;
24
+ }) => boolean;
25
+ export declare const isOverVisibleCanvasFromCustomView: (clientX: number, clientY: number, canvasBb: Nullable<DOMRect>, overlayBb: Nullable<DOMRect>, interactionContainerBb: Nullable<DOMRect>, iframeBounds?: DOMRect) => boolean;
26
+ /**
27
+ * Is the point over Rubens' visible 3D canvas? The host-page vantage point of
28
+ * `isOverVisibleCanvasFromCustomView` above: all it has is the iframe rect,
29
+ * standing in for the canvas, minus the interaction container.
30
+ *
31
+ * `interactionContainer` arrives in iframe-local coordinates and is offset here.
32
+ * `null` means there is none, so the whole iframe is canvas — pass it only once
33
+ * that is known, never while the rect is still loading (RML-17511).
34
+ */
35
+ export declare const isOverVisibleCanvasFromHostPage: (clientX: number, clientY: number, iframeBounds: DOMRect, interactionContainer: Nullable<DOMRect>) => boolean;
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./comlink-BipJ8Ikr.mjs";
2
2
  import { t } from "./browser-C_Dfiou7.mjs";
3
- import { t as n } from "./utils-BnWKaFPc.mjs";
3
+ import { t as n } from "./utils-i2eOrtnv.mjs";
4
4
  //#region packages/common/src/utils/message-handler.ts
5
5
  var r = class {
6
6
  _side;
@@ -139,7 +139,7 @@ var r = class {
139
139
  let e = d(f);
140
140
  e.locale ||= t(null, !0), e.id === "(idle)" && delete e.id;
141
141
  let n = o();
142
- return n && s(n) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = void 0, e.emails = !1, e;
142
+ return n && s(n) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = "https://rubens.alpha.roomle.com/api/v2", e.emails = !1, e;
143
143
  }, _ = "<CONF_ID>", v = "#CONFIGURATIONID#", y = (e) => {
144
144
  let t = e.featureFlags;
145
145
  if (!t || typeof t != "object" || Array.isArray(t)) return;
@@ -194,7 +194,7 @@ var r = class {
194
194
  setupPlugins(e, t, n = "website") {
195
195
  for (let r of e) typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(new Promise((e, r) => {
196
196
  try {
197
- import("./drag-in-B42WpY_e.mjs").then((e) => e.n).then(({ DragIn: i }) => {
197
+ import("./drag-in-BCnrHxxt.mjs").then((e) => e.n).then(({ DragIn: i }) => {
198
198
  let a = new i(this.ui, t, n, this.viewName);
199
199
  a.init().then(() => {
200
200
  this.plugins.dragIn = a, e();
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./comlink-Dds_bpug.mjs";
2
2
  import { t } from "./browser-DRgK3Fk8.mjs";
3
- import { t as n } from "./utils-DfC2ZLUc.mjs";
3
+ import { t as n } from "./utils-Co3lE-Ji.mjs";
4
4
  var r = class {
5
5
  _side;
6
6
  _incomingMessageBus = null;
@@ -134,7 +134,7 @@ var r = class {
134
134
  return n && ((e) => {
135
135
  let t = /* @__PURE__ */ new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);
136
136
  return !!(i.includes(e) || t.test(e) || e.endsWith("roomle.com") || e.endsWith("gitlab.io") || e.endsWith("gitlab.com"));
137
- })(n) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = void 0, e.emails = !1, e;
137
+ })(n) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = "https://rubens.alpha.roomle.com/api/v2", e.emails = !1, e;
138
138
  }, p = (e) => {
139
139
  e.featureFlags ||= {}, typeof e.featureFlags.realPartList != "boolean" && (e.featureFlags.realPartList = !0), typeof e.featureFlags.globalCallbacks != "boolean" && (e.featureFlags.globalCallbacks = !0), typeof e.featureFlags.mocAr != "boolean" && (e.featureFlags.mocAr = !1);
140
140
  }, m = () => /(android)/i.test(navigator.userAgent), h = class {
@@ -175,7 +175,7 @@ var r = class {
175
175
  setupPlugins(e, t, n = "website") {
176
176
  for (let r of e) typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(new Promise((e, r) => {
177
177
  try {
178
- import("./drag-in-DXVxlotA.mjs").then((e) => e.n).then(({ DragIn: i }) => {
178
+ import("./drag-in-DDGopCLr.mjs").then((e) => e.n).then(({ DragIn: i }) => {
179
179
  let a = new i(this.ui, t, n, this.viewName);
180
180
  a.init().then(() => {
181
181
  this.plugins.dragIn = a, e();
@@ -114,5 +114,10 @@ var e, t = class {
114
114
  top: i.y,
115
115
  bottom: i.y + i.height
116
116
  })), o && !s && !c;
117
- };
118
- export { u as a, a as i, o as n, n as o, r, c as t };
117
+ }, d = (e, t, n, r) => !(!l(e, t, n) || r && l(e, t, {
118
+ left: r.left + n.left,
119
+ right: r.right + n.left,
120
+ top: r.top + n.top,
121
+ bottom: r.bottom + n.top
122
+ }));
123
+ export { u as a, n as c, a as i, o as n, d as o, r, l as s, c as t };