mesurer-solid 0.2.3-beta.6 → 0.2.3-beta.7

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/plugins.js CHANGED
@@ -2973,23 +2973,27 @@ var _o = /* @__PURE__ */ new WeakMap(), vo = (e) => {
2973
2973
  let n = vo(e);
2974
2974
  for (let e of t.listeners) e(n);
2975
2975
  }, bo = (e) => {
2976
- let t = _o.get(e);
2976
+ let t = _o.get(e.document);
2977
2977
  if (t) return t;
2978
- let n = e.history, r = n.pushState, i = n.replaceState, a = {
2978
+ let n = e.history, r = n.pushState, i = n.replaceState, a = e.removeEventListener.bind(e), o = {
2979
+ document: e.document,
2980
+ releaseNativeListeners: () => {
2981
+ a("popstate", o.handleNativeChange), a("hashchange", o.handleNativeChange);
2982
+ },
2979
2983
  listeners: /* @__PURE__ */ new Set(),
2980
2984
  pushState: r,
2981
2985
  replaceState: i,
2982
- handleNativeChange: () => yo(e, a)
2986
+ handleNativeChange: () => yo(e, o)
2983
2987
  };
2984
2988
  return n.pushState = function(...t) {
2985
2989
  let n = r.apply(this, t);
2986
- return yo(e, a), n;
2990
+ return yo(e, o), n;
2987
2991
  }, n.replaceState = function(...t) {
2988
2992
  let n = i.apply(this, t);
2989
- return yo(e, a), n;
2990
- }, e.addEventListener("popstate", a.handleNativeChange), e.addEventListener("hashchange", a.handleNativeChange), _o.set(e, a), a;
2993
+ return yo(e, o), n;
2994
+ }, e.addEventListener("popstate", o.handleNativeChange), e.addEventListener("hashchange", o.handleNativeChange), _o.set(e.document, o), o;
2991
2995
  }, xo = (e, t) => {
2992
- t.listeners.size > 0 || _o.get(e) !== t || (e.history.pushState = t.pushState, e.history.replaceState = t.replaceState, e.removeEventListener("popstate", t.handleNativeChange), e.removeEventListener("hashchange", t.handleNativeChange), _o.delete(e));
2996
+ t.listeners.size > 0 || _o.get(t.document) !== t || (t.document.defaultView === e && (e.history.pushState = t.pushState, e.history.replaceState = t.replaceState), t.releaseNativeListeners(), _o.delete(t.document));
2993
2997
  }, So = (e, t) => {
2994
2998
  let n = bo(e);
2995
2999
  n.listeners.add(t);
@@ -5827,7 +5831,7 @@ function cu(e) {
5827
5831
  t && (t.scroll.release(), t.releaseAnchor?.(), U.delete(e));
5828
5832
  }, pe = (t) => {
5829
5833
  let n = e.runtime.annotation(t);
5830
- return !n || n.anchor.kind !== "elements" ? null : n.resolvedTargets.find(({ element: e }) => e?.isConnected)?.element ?? null;
5834
+ return !n || n.anchor.kind !== "elements" || !e.runtime.annotationVisible(t) ? null : n.resolvedTargets.find(({ element: e }) => e?.isConnected && !Zs(e.ownerDocument))?.element ?? null;
5831
5835
  }, me = (e) => !!(ru(e) && G() && N && ce() && e.getRootNode() === N.getRootNode()), he = (e) => {
5832
5836
  let t = pe(e), n = U.get(e);
5833
5837
  if (!t) {
@@ -5875,6 +5879,10 @@ function cu(e) {
5875
5879
  V?.release(), V = null, B?.(), B = null, R = null, z = null;
5876
5880
  }, be = (e) => !!(ru(e) && G() && N && e !== O && ce() && e.getRootNode() === N.getRootNode()), xe = () => {
5877
5881
  let e = q();
5882
+ if (e && Zs(e.ownerDocument)) {
5883
+ ye();
5884
+ return;
5885
+ }
5878
5886
  O && e !== O && (O = null);
5879
5887
  let t = R, n = !!(e?.isConnected && be(e)), r = z === e;
5880
5888
  if (e === R && e?.isConnected && n === r) {
@@ -5929,24 +5937,24 @@ function cu(e) {
5929
5937
  });
5930
5938
  let Me = q();
5931
5939
  Se(Me);
5932
- let Ne = e.runtime.subscribe(() => {
5940
+ let Ne = e.runtime.subscribe(() => Qt(() => {
5933
5941
  let t = e.runtime.selectGestureActive();
5934
5942
  p() && t ? (k = !0, se()) : p() && A !== null && !ae(A, ie()) && (O = q(), k = !1, se());
5935
5943
  let r = q(), i = r !== Me;
5936
- i && (Me = r, Se(Me), k && (k = !1, O = r)), xe(), i && we(), n((e) => e + 1), ve();
5937
- });
5944
+ i && (Me = r, Se(Me), k && (k = !1, O = r)), xe(), (i || r && Zs(r.ownerDocument)) && we(), n((e) => e + 1), ve();
5945
+ }));
5938
5946
  xe(), W().queueMicrotask(ge), Sn(() => {
5939
5947
  H?.disconnect(), H = null, oe(), ee?.removeEventListener("resize", we), ee = null, je?.disconnect(), ye();
5940
5948
  for (let e of U.keys()) fe(e);
5941
5949
  Ne();
5942
5950
  });
5943
- let Pe = wr(() => (t(), e.runtime.currentSelection())), Fe = wr(() => (t(), e.runtime.annotations())), Ie = wr(() => {
5951
+ let Pe = wr(() => (t(), e.runtime.currentSelection())), Fe = wr(() => (t(), e.runtime.annotations().filter((t) => e.runtime.annotationVisible(t.id)))), Ie = wr(() => {
5944
5952
  let e = a();
5945
5953
  return e ? Fe().find((t) => t.id === e) ?? null : null;
5946
5954
  }), Le = wr(() => s() ?? l() ?? a()), Re = (e) => Fe().findIndex((t) => t.id === e) + 1, ze = wr(() => {
5947
5955
  t(), r();
5948
5956
  let n = Le();
5949
- if (!n) return [];
5957
+ if (!n || !e.runtime.annotationVisible(n)) return [];
5950
5958
  let i = e.runtime.annotation(n);
5951
5959
  if (!i) return [];
5952
5960
  if (i.anchor.kind === "region") return [{ ...i.anchor.rect }];
@@ -5987,7 +5995,7 @@ function cu(e) {
5987
5995
  }), Ke = () => {
5988
5996
  r();
5989
5997
  let e = Ge();
5990
- if (!e?.isConnected || Zs(e.ownerDocument)) return null;
5998
+ if (!e?.isConnected) return null;
5991
5999
  let t = ds(e), n = {
5992
6000
  left: t.left,
5993
6001
  top: t.top,
@@ -6195,7 +6203,7 @@ function cu(e) {
6195
6203
  }
6196
6204
  }
6197
6205
  }, ot = se, st = () => {
6198
- Be() && (e.runtime.currentSelection().elements.some((e) => Zs(e.ownerDocument)) || (k = !1, A = ie(), g(""), v(!1), b(null), w(null), o(null), m(!0), F = (e) => {
6206
+ Be() && (k = !1, A = ie(), g(""), v(!1), b(null), w(null), o(null), m(!0), F = (e) => {
6199
6207
  let t = le()?.querySelector("[data-mesurer-annotation-composer='true']"), n = W().Node;
6200
6208
  if (!(t && n && e.target instanceof n && t.contains(e.target))) {
6201
6209
  if (h().trim() && !y()) {
@@ -6204,24 +6212,18 @@ function cu(e) {
6204
6212
  }
6205
6213
  ct();
6206
6214
  }
6207
- }, W().document.addEventListener("pointerdown", F, !0), W().queueMicrotask(() => V?.sync())));
6215
+ }, W().document.addEventListener("pointerdown", F, !0), W().queueMicrotask(() => V?.sync()));
6208
6216
  }, ct = () => {
6209
6217
  let e = p();
6210
6218
  A !== null && !ae(A, ie()) ? (O = q(), k = !1, xe(), we()) : e && (k = !1), ot();
6211
6219
  }, lt = () => {
6212
6220
  p() && (k = !0, ot());
6213
6221
  }, ut = () => {
6214
- if (!(!h().trim() || x())) {
6215
- if (e.runtime.currentSelection().elements.some((e) => Zs(e.ownerDocument))) {
6216
- b("Context annotations are unavailable for Responsive preview targets.");
6217
- return;
6218
- }
6219
- try {
6220
- let t = e.runtime.addSelectionAnnotation(h());
6221
- k = !1, A = null, g(""), v(!1), b(null), m(!1), oe(), he(t.id), et(t.id), o(t.id), w(null), _e(t.id);
6222
- } catch (e) {
6223
- b(e instanceof Error ? e.message : String(e));
6224
- }
6222
+ if (!(!h().trim() || x())) try {
6223
+ let t = e.runtime.addSelectionAnnotation(h());
6224
+ k = !1, A = null, g(""), v(!1), b(null), m(!1), oe(), he(t.id), et(t.id), o(t.id), w(null), _e(t.id);
6225
+ } catch (e) {
6226
+ b(e instanceof Error ? e.message : String(e));
6225
6227
  }
6226
6228
  }, dt = {
6227
6229
  openNoteComposer: st,
@@ -9812,7 +9814,7 @@ var Lu = "mesurer.layout-guides", Ru = "layout-guides:v1", zu = "mesurer.layout-
9812
9814
  C = !0, b += 1, d.removeEventListener("pointerdown", z), d.removeEventListener("pointermove", B), d.removeEventListener("pointerup", V), d.removeEventListener("pointercancel", H), i.removeEventListener("keydown", ee, !0), y && i.clearTimeout(y), M.dispose(), k(), oo(i), a.finishCapture(), a.dispose(), o.dispose();
9813
9815
  });
9814
9816
  }
9815
- }), mp = "0.2.3-beta.6", hp = Uc, gp = Bc, _p = Vc, vp = Wc, yp = Hc, bp = () => ({
9817
+ }), mp = "0.2.3-beta.7", hp = Uc, gp = Bc, _p = Vc, vp = Wc, yp = Hc, bp = () => ({
9816
9818
  ...Il(),
9817
9819
  version: mp
9818
9820
  }), xp = bp, Sp = hp, Cp = gp, wp = _p, Tp = vp, Ep = yp, Dp = (e, t) => e.left <= t.left + t.width && e.left + e.width >= t.left && e.top <= t.top + t.height && e.top + e.height >= t.top, Op = (e) => {
@@ -9998,11 +10000,15 @@ var Bp = 10, Vp = (e) => ({
9998
10000
  function Wp(e) {
9999
10001
  let { runtime: t, ownerDocument: n, ownerWindow: r } = e, i = e.request ?? { scope: "workspace" }, a = t.snapshot();
10000
10002
  if (!a) throw Error("Mesurer workspace is not ready yet.");
10001
- let o = (e) => Vp(t.elementRect?.(e) ?? e.getBoundingClientRect()), s = [], c = [], l = { kind: "workspace" }, u = /* @__PURE__ */ new Map();
10003
+ let o = (e) => Vp(t.elementRect?.(e) ?? e.getBoundingClientRect()), s = [], c = [], l = { kind: "workspace" }, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f;
10002
10004
  if ("annotation" in i) {
10003
10005
  let e = t.annotation(i.annotation);
10004
10006
  if (!e) throw Error(`Mesurer annotation not found: ${i.annotation}`);
10005
- for (let t of e.resolvedTargets) t.element?.isConnected && u.set(t.element, t.target.id);
10007
+ e.anchor.kind === "elements" && (f = e.anchor.targets.find((e) => e.viewport)?.viewport);
10008
+ for (let t of e.resolvedTargets) t.element?.isConnected && (u.set(t.element, t.target.id), t.target.viewport && d.set(t.element, {
10009
+ viewport: { ...t.target.viewport },
10010
+ domPath: t.target.domPath?.map((e) => ({ ...e })) ?? []
10011
+ }));
10006
10012
  s = Hp(e.resolvedTargets.map((e) => e.element));
10007
10013
  let n = t.annotationRect(e.id);
10008
10014
  n && (c = [n]);
@@ -10023,7 +10029,7 @@ function Wp(e) {
10023
10029
  a.activeMeasurement?.elementRef,
10024
10030
  ...a.heldDistances.flatMap((e) => [e.elementRefA, e.elementRefB])
10025
10031
  ]);
10026
- let d = l.kind === "workspace" ? [] : c.length ? c : s.map(o), f = jp({
10032
+ let p = l.kind === "workspace" ? [] : c.length ? c : s.map(o), m = jp({
10027
10033
  workspace: {
10028
10034
  guides: a.guides,
10029
10035
  measurements: a.measurements,
@@ -10033,33 +10039,34 @@ function Wp(e) {
10033
10039
  scope: l.kind === "workspace" ? { kind: "workspace" } : {
10034
10040
  kind: "scoped",
10035
10041
  elements: s,
10036
- regions: d
10042
+ regions: p
10037
10043
  },
10038
10044
  guideTolerance: a.guideRelevanceTolerance ?? Bp
10039
- }), p = f.measurements, m = f.distances, h = f.guides, g = Hp([
10045
+ }), h = m.measurements, g = m.distances, _ = m.guides, v = Hp([
10040
10046
  ...s,
10041
- ...p.map((e) => e.elementRef),
10042
- ...m.flatMap((e) => [e.elementRefA, e.elementRefB])
10043
- ]), _ = /* @__PURE__ */ new Map(), v = new Set(u.values()), y = 1, b = () => {
10044
- let e = `target-${y++}`;
10045
- for (; v.has(e);) e = `target-${y++}`;
10046
- return v.add(e), e;
10047
- }, x = g.map((e) => {
10048
- let t = u.get(e) ?? b(), n = o(e), r = zp(e);
10049
- return _.set(e, t), {
10050
- ref: t,
10047
+ ...h.map((e) => e.elementRef),
10048
+ ...g.flatMap((e) => [e.elementRefA, e.elementRefB])
10049
+ ]), y = /* @__PURE__ */ new Map(), b = new Set(u.values()), x = 1, S = () => {
10050
+ let e = `target-${x++}`;
10051
+ for (; b.has(e);) e = `target-${x++}`;
10052
+ return b.add(e), e;
10053
+ }, C = v.map((e) => {
10054
+ let n = u.get(e) ?? S(), r = o(e), i = zp(e);
10055
+ return y.set(e, n), {
10056
+ ref: n,
10057
+ ...d.get(e) ?? t.targetScope?.(e),
10051
10058
  inspection: {
10052
- ...r,
10059
+ ...i,
10053
10060
  rect: {
10054
- ...n,
10055
- right: n.left + n.width,
10056
- bottom: n.top + n.height,
10057
- x: n.left,
10058
- y: n.top
10061
+ ...r,
10062
+ right: r.left + r.width,
10063
+ bottom: r.top + r.height,
10064
+ x: r.left,
10065
+ y: r.top
10059
10066
  }
10060
10067
  }
10061
10068
  };
10062
- }), S = p.map((e) => {
10069
+ }), w = h.map((e) => {
10063
10070
  let t = {
10064
10071
  id: e.id,
10065
10072
  rect: Vp(e.rect),
@@ -10067,19 +10074,18 @@ function Wp(e) {
10067
10074
  deltaY: e.deltaY
10068
10075
  };
10069
10076
  e.snapped !== void 0 && (t.snapped = e.snapped);
10070
- let n = e.elementRef ? _.get(e.elementRef) : void 0;
10077
+ let n = e.elementRef ? y.get(e.elementRef) : void 0;
10071
10078
  return n && (t.targetRef = n), t;
10072
- }), C = m.map((e) => {
10079
+ }), T = g.map((e) => {
10073
10080
  let t = {
10074
10081
  id: e.id,
10075
10082
  rectA: Vp(e.rectA),
10076
10083
  rectB: Vp(e.rectB),
10077
10084
  horizontal: e.horizontal ? { ...e.horizontal } : null,
10078
10085
  vertical: e.vertical ? { ...e.vertical } : null
10079
- }, n = e.elementRefA ? _.get(e.elementRefA) : void 0, r = e.elementRefB ? _.get(e.elementRefB) : void 0;
10086
+ }, n = e.elementRefA ? y.get(e.elementRefA) : void 0, r = e.elementRefB ? y.get(e.elementRefB) : void 0;
10080
10087
  return n && (t.targetARef = n), r && (t.targetBRef = r), t;
10081
- });
10082
- return {
10088
+ }), E = {
10083
10089
  schema: "mesurer.context/v1",
10084
10090
  id: Up(r),
10085
10091
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -10101,14 +10107,15 @@ function Wp(e) {
10101
10107
  rulersVisible: a.rulersVisible,
10102
10108
  xrayVisible: a.xrayVisible
10103
10109
  },
10104
- targets: x,
10110
+ targets: C,
10105
10111
  visualContext: {
10106
- guides: h,
10112
+ guides: _,
10107
10113
  layoutGuides: (e.layoutGuides ?? []).map((e) => ({ ...e })),
10108
- measurements: S,
10109
- distances: C
10114
+ measurements: w,
10115
+ distances: T
10110
10116
  }
10111
10117
  };
10118
+ return f ??= C.find((e) => e.viewport)?.viewport, f && (E.previewViewport = { ...f }), E;
10112
10119
  }
10113
10120
  var Gp = (e) => `${Math.round(e * 100) / 100}px`, Kp = (e) => `x=${Gp(e.left)} y=${Gp(e.top)} w=${Gp(e.width)} h=${Gp(e.height)}`;
10114
10121
  function qp(e) {
@@ -10122,7 +10129,7 @@ function qp(e) {
10122
10129
  t.push("", "Targets");
10123
10130
  for (let n of e.targets) {
10124
10131
  let e = n.inspection;
10125
- t.push(`[${n.ref}] ${e.selector}`, ` rect: ${Kp(e.rect)}`, ` margin: ${Gp(e.margin.top)} ${Gp(e.margin.right)} ${Gp(e.margin.bottom)} ${Gp(e.margin.left)}`, ` padding: ${Gp(e.padding.top)} ${Gp(e.padding.right)} ${Gp(e.padding.bottom)} ${Gp(e.padding.left)}`, ` layout: display=${e.layout.display}; position=${e.layout.position}; gap=${e.layout.gap}`, ` typography: ${e.typography.fontSize} / ${e.typography.lineHeight}; weight=${e.typography.fontWeight}; align=${e.typography.textAlign}`), e.text && t.push(` text: ${JSON.stringify(e.text)}`);
10132
+ n.viewport && t.push(`Preview: ${n.viewport.url}; ${n.viewport.width} × ${n.viewport.height} CSS px; id=${n.viewport.previewId}`), t.push(`[${n.ref}] ${e.selector}`, ` rect: ${Kp(e.rect)}`, ` margin: ${Gp(e.margin.top)} ${Gp(e.margin.right)} ${Gp(e.margin.bottom)} ${Gp(e.margin.left)}`, ` padding: ${Gp(e.padding.top)} ${Gp(e.padding.right)} ${Gp(e.padding.bottom)} ${Gp(e.padding.left)}`, ` layout: display=${e.layout.display}; position=${e.layout.position}; gap=${e.layout.gap}`, ` typography: ${e.typography.fontSize} / ${e.typography.lineHeight}; weight=${e.typography.fontWeight}; align=${e.typography.textAlign}`), e.text && t.push(` text: ${JSON.stringify(e.text)}`);
10126
10133
  }
10127
10134
  }
10128
10135
  if (e.visualContext.guides.length) {
@@ -10173,13 +10180,14 @@ function Jp(e) {
10173
10180
  }
10174
10181
  });
10175
10182
  }
10176
- return {
10183
+ let r = {
10177
10184
  schema: "mesurer.capture/v1",
10178
10185
  contextId: e.id,
10179
10186
  chrome: "hide",
10180
10187
  evidence: "show",
10181
10188
  captures: n
10182
10189
  };
10190
+ return e.previewViewport && (r.previewViewport = { ...e.previewViewport }), r;
10183
10191
  }
10184
10192
  var Yp = (e, t, n, r, i) => {
10185
10193
  !Number.isFinite(r) || !Number.isFinite(i) || Math.abs(r - i) < .01 || e.push({
@@ -10330,18 +10338,9 @@ var em = Lu, tm = Ru, nm = zu, rm = Bu, im = () => ({
10330
10338
  e.finishCapture(), await pm(t, n);
10331
10339
  }
10332
10340
  };
10333
- }, hm = (e) => {
10334
- let t = e.currentSelection();
10335
- return (t.elements.length > 0 || t.region !== null) && !t.elements.some((e) => {
10336
- let t = e.ownerDocument;
10337
- for (; t;) {
10338
- let e = t.defaultView?.frameElement ?? null;
10339
- if (!e) return !1;
10340
- if (e.hasAttribute("data-mesurer-responsive-frame")) return !0;
10341
- t = e.ownerDocument;
10342
- }
10343
- return !1;
10344
- });
10341
+ }, hm = (e, t) => {
10342
+ let n = e.currentSelection();
10343
+ return n.elements.length > 0 || n.region !== null && !t?.querySelector("[data-mesurer-responsive-stage]");
10345
10344
  };
10346
10345
  function gm(e = {}) {
10347
10346
  return {
@@ -10359,39 +10358,39 @@ function gm(e = {}) {
10359
10358
  persist: !0
10360
10359
  }), t.state.register({
10361
10360
  id: cm,
10362
- initial: { hasSelection: hm(r) }
10361
+ initial: { hasSelection: hm(r, n.rendererRoot) }
10363
10362
  });
10364
- let a = () => t.state.get("mesurer.context.settings")?.ui ?? !0, o = () => hm(r), s = (e) => {
10363
+ let a = () => t.state.get("mesurer.context.settings")?.ui ?? !0, o = () => hm(r, n.rendererRoot), s = (e) => {
10365
10364
  t.state.update(sm, (t) => ({
10366
10365
  ...t,
10367
10366
  ui: e
10368
10367
  }));
10369
- }, c = null, l = null, u = null, d = null, f = r.currentSelection(), p = {
10370
- elements: [...f.elements],
10371
- region: f.region ? { ...f.region } : null
10372
- }, m = (e, t) => e.elements.length !== t.elements.length || e.elements.some((e, n) => e !== t.elements[n]) ? !1 : e.region === t.region ? !0 : !e.region || !t.region ? !1 : e.region.left === t.region.left && e.region.top === t.region.top && e.region.width === t.region.width && e.region.height === t.region.height, h = r.subscribe(() => {
10373
- let e = r.currentSelection(), n = !m(p, e);
10374
- p = {
10368
+ }, c = null, l = null, u = null, d = null, [f, p] = Tr(!!n.rendererRoot?.querySelector("[data-mesurer-responsive-stage]")), m = null, h = r.currentSelection(), g = {
10369
+ elements: [...h.elements],
10370
+ region: h.region ? { ...h.region } : null
10371
+ }, _ = (e, t) => e.elements.length !== t.elements.length || e.elements.some((e, n) => e !== t.elements[n]) ? !1 : e.region === t.region ? !0 : !e.region || !t.region ? !1 : e.region.left === t.region.left && e.region.top === t.region.top && e.region.width === t.region.width && e.region.height === t.region.height, v = r.subscribe(() => {
10372
+ let e = r.currentSelection(), i = !_(g, e);
10373
+ g = {
10375
10374
  elements: [...e.elements],
10376
10375
  region: e.region ? { ...e.region } : null
10377
- }, r.selectGestureActive() ? c?.abandonNoteComposer() : n && c?.closeNoteComposer();
10378
- let i = hm(r);
10379
- i !== (t.state.get(cm)?.hasSelection ?? !1) && t.state.update(cm, () => ({ hasSelection: i }));
10376
+ }, r.selectGestureActive() ? c?.abandonNoteComposer() : i && c?.closeNoteComposer();
10377
+ let a = hm(r, n.rendererRoot);
10378
+ a !== (t.state.get(cm)?.hasSelection ?? !1) && t.state.update(cm, () => ({ hasSelection: a }));
10380
10379
  });
10381
10380
  t.command.register("context.copy", () => i.copyContext()), t.command.register("context.copy-selection", () => i.copyContext({ scope: "selection" }));
10382
- let g = () => {
10381
+ let y = () => {
10383
10382
  let e = u?.element;
10384
10383
  e && (n.rendererRoot?.hasAttribute(lm) ? e.setAttribute(lm, "true") : e.removeAttribute(lm));
10385
- }, _ = () => {
10384
+ }, b = () => {
10386
10385
  d?.disconnect(), d = null, c = null, l?.(), l = null, u?.dispose(), u = null;
10387
- }, v = () => {
10386
+ }, x = () => {
10388
10387
  if (u) return;
10389
- if (u = pu(n), u.element.dataset.mesurerLayer = "evidence", u.element.dataset.mesurerContextRoot = "true", n.rendererRoot) {
10390
- let e = new n.ownerWindow.MutationObserver(g);
10388
+ if (u = pu(n), m = u.element.parentNode, u.element.dataset.mesurerLayer = "evidence", u.element.dataset.mesurerContextRoot = "true", n.rendererRoot) {
10389
+ let e = new n.ownerWindow.MutationObserver(y);
10391
10390
  d = e, e.observe(n.rendererRoot, {
10392
10391
  attributes: !0,
10393
10392
  attributeFilter: [lm]
10394
- }), g();
10393
+ }), y();
10395
10394
  }
10396
10395
  let e = {
10397
10396
  runtime: r,
@@ -10399,16 +10398,25 @@ function gm(e = {}) {
10399
10398
  onController: (e) => {
10400
10399
  c = e;
10401
10400
  },
10402
- coordinateSpace: "document",
10401
+ get coordinateSpace() {
10402
+ return f() ? "viewport" : "document";
10403
+ },
10403
10404
  rendererRoot: n.rendererRoot
10404
10405
  };
10405
10406
  l = Ur(() => Or(lu, yr(e, { get ownerWindow() {
10406
10407
  return n.ownerWindow;
10407
- } })), u.element);
10408
- }, y = () => {
10409
- a() ? v() : _();
10408
+ } })), u.element), Qt(f) && n.rendererRoot && (n.rendererRoot.append(u.element), u.element.style.zIndex = "90");
10409
+ }, S = () => {
10410
+ a() ? x() : b();
10411
+ };
10412
+ S(), t.state.subscribe(S);
10413
+ let C = () => {
10414
+ let e = !!n.rendererRoot?.querySelector("[data-mesurer-responsive-stage]");
10415
+ if (e === Qt(f) || (p(e), !u)) return;
10416
+ let t = e ? n.rendererRoot : m;
10417
+ t && u.element.parentNode !== t && t.appendChild(u.element), u.element.style.zIndex = e ? "90" : "", Qt(() => c?.closeNoteComposer());
10410
10418
  };
10411
- y(), t.state.subscribe(y), t.command.register("context.add-note", () => {
10419
+ n.ownerWindow.addEventListener("mesurer:responsive-stage-change", C), t.command.register("context.add-note", () => {
10412
10420
  o() && c?.openNoteComposer();
10413
10421
  }), t.tool.register({
10414
10422
  id: "context.copy",
@@ -10452,7 +10460,7 @@ function gm(e = {}) {
10452
10460
  set: s
10453
10461
  }]
10454
10462
  }), t.lifecycle.onDispose(() => {
10455
- h(), _(), r.dispose();
10463
+ v(), n.ownerWindow.removeEventListener("mesurer:responsive-stage-change", C), b(), r.dispose();
10456
10464
  });
10457
10465
  }
10458
10466
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mesurer-solid",
3
- "version": "0.2.3-beta.6",
3
+ "version": "0.2.3-beta.7",
4
4
  "description": "Framework-agnostic UI measurement and inspection tools for browser apps and coding agents.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,7 @@ A meaningful Mesurer step must return evidence the agent actually uses.
15
15
 
16
16
  ## Know the available capabilities
17
17
 
18
- The base inspector has Select, X-ray, Color Picker, Rulers, Responsive, Typography, Guides, Distance, and Settings. Responsive opens one live iPhone 15 (393 × 852 CSS px) same-origin preview; while it is open, Select, measurements, X-ray, and Typography inspect accessible preview documents. Preview evidence is projected over the scaled iframe, and the root page and stage chrome are not inspection sources. Context annotations are unavailable for preview targets in this increment. The existing `window.__MESURER__` inspect/select methods continue targeting the root document. Preview loads rerun page JavaScript and side effects. Color Picker uses application-local host capture when available and otherwise uses a working browser `EyeDropper`; a successful sample copies the configured format to the clipboard.
18
+ The base inspector has Select, X-ray, Color Picker, Rulers, Responsive, Typography, Guides, Distance, and Settings. Responsive opens one live iPhone 15 (393 × 852 CSS px) same-origin preview; while it is open, Select, measurements, X-ray, and Typography inspect accessible preview documents. Preview evidence is projected over the scaled iframe, and the root page and stage chrome are not inspection sources. Context preview notes store exact URL/width/height/preview identity and render only over a matching preview in the root overlay. Removing or closing previews hides notes and releases watchers without deleting saved records; a uniquely matching recreated viewport can conservatively rebind. Context targets and capture plans include viewport metadata with root-projected geometry. The existing `window.__MESURER__` inspect/select methods continue targeting the root document. Preview loads rerun page JavaScript and side effects. Color Picker uses application-local host capture when available and otherwise uses a working browser `EyeDropper`; a successful sample copies the configured format to the clipboard.
19
19
 
20
20
  Optional first-party plugins add Context, Edit, Layout Guides, Screenshot, Recording, and Codex delivery. Rulers, ordinary Guides, and Layout Guides remain usable while Edit is active; X-ray, Color Picker, Typography, Screenshot, and Recording stay in the Select lane. Context carries annotations and structured evidence. Edit carries Before/Desired/Live movement intent through the existing Arrange compatibility APIs. Layout Guides carries page-scoped column/row/grid intent and exposes saved guides through Context with each guide's `visible` flag. Screenshot and Recording are human capture workflows; Recording exposes the typed `recording:v1` service when application code needs its lifecycle. Codex is an optional human queue transport, not the normal agent protocol.
21
21