@limrun/ui 0.4.2 → 0.4.3

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/index.css CHANGED
@@ -1 +1 @@
1
- .rc-container{position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;isolation:isolate;touch-action:none;width:100%;height:100%}.rc-phone-frame{position:relative;z-index:30;display:block;pointer-events:none;-webkit-user-select:none;user-select:none;width:auto;height:auto;max-width:100%;max-height:100%}.rc-video{position:absolute;z-index:20;outline:none;pointer-events:none;cursor:none;background-color:#000;object-fit:contain;object-position:center center;inset:50% auto auto 50%;transform:translate(-50%,-50%)}.rc-video-frameless{position:relative;top:auto;left:auto;transform:none;max-width:100%;max-height:100%}.rc-video-loading{aspect-ratio:9 / 19.5}
1
+ .rc-container{position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;isolation:isolate;touch-action:none;width:100%;height:100%}.rc-phone-frame{position:relative;z-index:30;display:block;pointer-events:none;-webkit-user-select:none;user-select:none;width:auto;height:auto;max-width:100%;max-height:100%}.rc-phone-frame-ios{z-index:10}.rc-video{position:absolute;z-index:20;outline:none;pointer-events:none;cursor:none;background-color:#000;object-fit:contain;object-position:center center;inset:50% auto auto 50%;transform:translate(-50%,-50%)}.rc-video-frameless{position:relative;top:auto;left:auto;transform:none;max-width:100%;max-height:100%}.rc-video-loading{aspect-ratio:9 / 19.5}
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { jsxs as KA, jsx as iA } from "react/jsx-runtime";
2
- import { forwardRef as wA, useRef as h, useState as _, useMemo as IA, useEffect as nA, useImperativeHandle as aA } from "react";
3
- import './index.css';function sA(C) {
1
+ import { jsxs as KA, jsx as nA } from "react/jsx-runtime";
2
+ import { forwardRef as wA, useRef as h, useState as _, useMemo as zA, useEffect as sA, useImperativeHandle as aA } from "react";
3
+ import './index.css';function tA(C) {
4
4
  var s, D, B = "";
5
5
  if (typeof C == "string" || typeof C == "number") B += C;
6
6
  else if (typeof C == "object") if (Array.isArray(C)) {
7
7
  var d = C.length;
8
- for (s = 0; s < d; s++) C[s] && (D = sA(C[s])) && (B && (B += " "), B += D);
8
+ for (s = 0; s < d; s++) C[s] && (D = tA(C[s])) && (B && (B += " "), B += D);
9
9
  } else for (D in C) C[D] && (B && (B += " "), B += D);
10
10
  return B;
11
11
  }
12
- function zA() {
13
- for (var C, s, D = 0, B = "", d = arguments.length; D < d; D++) (C = arguments[D]) && (s = sA(C)) && (B && (B += " "), B += s);
12
+ function $() {
13
+ for (var C, s, D = 0, B = "", d = arguments.length; D < d; D++) (C = arguments[D]) && (s = tA(C)) && (B && (B += " "), B += s);
14
14
  return B;
15
15
  }
16
- const $ = {
16
+ const AA = {
17
17
  INJECT_KEYCODE: 0,
18
18
  INJECT_TOUCH_EVENT: 2,
19
19
  SET_CLIPBOARD: 9
@@ -149,7 +149,7 @@ const $ = {
149
149
  KEYCODE_NUMPAD_COMMA: 159,
150
150
  KEYCODE_NUMPAD_ENTER: 160,
151
151
  KEYCODE_NUMPAD_EQUALS: 161
152
- }, tA = {
152
+ }, rA = {
153
153
  KeyA: A.KEYCODE_A,
154
154
  KeyB: A.KEYCODE_B,
155
155
  KeyC: A.KEYCODE_C,
@@ -259,17 +259,17 @@ const $ = {
259
259
  function uA(C, s, D, B, d, m, z = 1, r = 0, l = 0) {
260
260
  const W = new ArrayBuffer(32), K = new DataView(W);
261
261
  let Q = 0;
262
- return K.setUint8(Q, $.INJECT_TOUCH_EVENT), Q += 1, K.setUint8(Q, C), Q += 1, K.setBigInt64(Q, BigInt(s)), Q += 8, K.setInt32(Q, Math.round(d), !0), Q += 4, K.setInt32(Q, Math.round(m), !0), Q += 4, K.setUint16(Q, D, !0), Q += 2, K.setUint16(Q, B, !0), Q += 2, K.setInt16(Q, Math.round(z * 65535), !0), Q += 2, K.setInt32(Q, r, !0), Q += 4, K.setInt32(Q, l, !0), W;
262
+ return K.setUint8(Q, AA.INJECT_TOUCH_EVENT), Q += 1, K.setUint8(Q, C), Q += 1, K.setBigInt64(Q, BigInt(s)), Q += 8, K.setInt32(Q, Math.round(d), !0), Q += 4, K.setInt32(Q, Math.round(m), !0), Q += 4, K.setUint16(Q, D, !0), Q += 2, K.setUint16(Q, B, !0), Q += 2, K.setInt16(Q, Math.round(z * 65535), !0), Q += 2, K.setInt32(Q, r, !0), Q += 4, K.setInt32(Q, l, !0), W;
263
263
  }
264
264
  function jA(C, s = !0) {
265
265
  const B = new TextEncoder().encode(C), d = new ArrayBuffer(14 + B.length), m = new DataView(d);
266
266
  let z = 0;
267
- return m.setUint8(z, $.SET_CLIPBOARD), z += 1, m.setBigInt64(z, BigInt(0), !1), z += 8, m.setUint8(z, s ? 1 : 0), z += 1, m.setUint32(z, B.length, !1), z += 4, new Uint8Array(d, z).set(B), d;
267
+ return m.setUint8(z, AA.SET_CLIPBOARD), z += 1, m.setBigInt64(z, BigInt(0), !1), z += 8, m.setUint8(z, s ? 1 : 0), z += 1, m.setUint32(z, B.length, !1), z += 4, new Uint8Array(d, z).set(B), d;
268
268
  }
269
269
  function P(C, s, D = 0, B = 0) {
270
270
  const d = new ArrayBuffer(14), m = new DataView(d);
271
271
  let z = 0;
272
- return m.setUint8(z, $.INJECT_KEYCODE), z += 1, m.setUint8(z, C), z += 1, m.setInt32(z, s, !0), z += 4, m.setInt32(z, D, !0), z += 4, m.setInt32(z, B, !0), d;
272
+ return m.setUint8(z, AA.INJECT_KEYCODE), z += 1, m.setUint8(z, C), z += 1, m.setInt32(z, s, !0), z += 4, m.setInt32(z, D, !0), z += 4, m.setInt32(z, B, !0), d;
273
273
  }
274
274
  const w = (...C) => {
275
275
  window.debugRemoteControl && console.log(...C);
@@ -306,7 +306,7 @@ const w = (...C) => {
306
306
  }
307
307
  };
308
308
  function SA(C) {
309
- const s = C.code, D = tA[s];
309
+ const s = C.code, D = rA[s];
310
310
  if (!D)
311
311
  return O(`Unknown event.code: ${s}, key: ${C.key}`), null;
312
312
  let B = A.META_NONE;
@@ -316,10 +316,10 @@ function SA(C) {
316
316
  }
317
317
  const lA = wA(
318
318
  ({ className: C, url: s, token: D, sessionId: B, openUrl: d, showFrame: m = !0 }, z) => {
319
- const r = h(null), l = h(null), [W, K] = _(!1), [Q, rA] = _(!1), [QA, AA] = _({}), i = h(null), Y = h(null), o = h(null), v = h(void 0), j = h(/* @__PURE__ */ new Map()), f = h(/* @__PURE__ */ new Map()), a = h(/* @__PURE__ */ new Map()), U = IA(
319
+ const r = h(null), l = h(null), [W, K] = _(!1), [Q, QA] = _(!1), [cA, eA] = _({}), i = h(null), Y = h(null), o = h(null), v = h(void 0), j = h(/* @__PURE__ */ new Map()), f = h(/* @__PURE__ */ new Map()), a = h(/* @__PURE__ */ new Map()), U = zA(
320
320
  () => B || Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
321
321
  [B]
322
- ), cA = IA(() => fA(s), [s]), R = vA[cA], Z = (e) => {
322
+ ), EA = zA(() => fA(s), [s]), R = vA[EA], Z = (e) => {
323
323
  w(e);
324
324
  }, S = (e) => {
325
325
  !o.current || o.current.readyState !== "open" || o.current.send(e);
@@ -336,7 +336,7 @@ const lA = wA(
336
336
  let b = 0, q = 0;
337
337
  V && (b = Math.max(0, Math.min(E, J / T * E)), q = Math.max(0, Math.min(M, L / y * M)));
338
338
  let H = null, u = null, OA = 1;
339
- const CA = N.BUTTON_PRIMARY;
339
+ const iA = N.BUTTON_PRIMARY;
340
340
  switch (x) {
341
341
  case "down":
342
342
  V ? (H = N.ACTION_DOWN, u = { x: b, y: q }, a.current.set(I, u), I === -1 && r.current?.focus()) : a.current.delete(I);
@@ -350,7 +350,7 @@ const lA = wA(
350
350
  break;
351
351
  }
352
352
  if (H !== null && u !== null) {
353
- const BA = uA(
353
+ const IA = uA(
354
354
  H,
355
355
  I,
356
356
  E,
@@ -358,10 +358,10 @@ const lA = wA(
358
358
  u.x,
359
359
  u.y,
360
360
  OA,
361
- CA,
362
- CA
361
+ iA,
362
+ iA
363
363
  );
364
- BA && S(BA);
364
+ IA && S(IA);
365
365
  } else (x === "up" || x === "cancel") && a.current.delete(I);
366
366
  };
367
367
  if ("touches" in e) {
@@ -405,7 +405,7 @@ const lA = wA(
405
405
  }
406
406
  t && F(-1, e.clientX, e.clientY, t);
407
407
  }
408
- }, eA = (e) => {
408
+ }, MA = (e) => {
409
409
  if (e.preventDefault(), e.stopPropagation(), w("Keyboard event:", {
410
410
  type: e.type,
411
411
  key: e.key,
@@ -478,12 +478,12 @@ const lA = wA(
478
478
  sessionId: U
479
479
  })
480
480
  );
481
- }, EA = () => {
481
+ }, gA = () => {
482
482
  v.current && window.clearInterval(v.current), v.current = window.setInterval(DA, 1e4);
483
- }, MA = () => {
483
+ }, CA = () => {
484
484
  v.current && (window.clearInterval(v.current), v.current = void 0);
485
- }, gA = () => {
486
- document.hidden ? MA() : EA();
485
+ }, BA = () => {
486
+ document.hidden ? CA() : gA();
487
487
  }, YA = async () => {
488
488
  try {
489
489
  i.current = new WebSocket(`${s}?token=${D}`), i.current.onerror = (E) => {
@@ -657,23 +657,23 @@ const lA = wA(
657
657
  }, ZA = () => {
658
658
  i.current && (i.current.close(), i.current = null), Y.current && (Y.current.close(), Y.current = null), r.current && (r.current.srcObject = null), o.current && (o.current.close(), o.current = null), Z("Stopped");
659
659
  };
660
- nA(() => (K(!1), YA(), document.hidden || EA(), document.addEventListener("visibilitychange", gA), () => {
661
- MA(), ZA(), document.removeEventListener("visibilitychange", gA);
662
- }), [s, D, B]), nA(() => {
660
+ sA(() => (K(!1), YA(), document.hidden || gA(), document.addEventListener("visibilitychange", BA), () => {
661
+ CA(), ZA(), document.removeEventListener("visibilitychange", BA);
662
+ }), [s, D, B]), sA(() => {
663
663
  const e = r.current, n = l.current;
664
664
  if (!e) return;
665
665
  if (!m || !n) {
666
- AA({});
666
+ eA({});
667
667
  return;
668
668
  }
669
669
  const g = () => {
670
670
  const M = n.clientWidth, F = n.clientHeight;
671
671
  if (M === 0 || F === 0) return;
672
672
  const I = e.videoWidth > e.videoHeight;
673
- rA(I);
673
+ QA(I);
674
674
  const t = I ? R.videoPosition.landscape : R.videoPosition.portrait;
675
675
  let c = {};
676
- t.heightMultiplier ? (c.height = `${F * t.heightMultiplier}px`, c.width = "auto") : t.widthMultiplier && (c.width = `${M * t.widthMultiplier}px`, c.height = "auto"), c.borderRadius = `${I ? F * R.videoBorderRadiusMultiplier : M * R.videoBorderRadiusMultiplier}px`, AA(c);
676
+ t.heightMultiplier ? (c.height = `${F * t.heightMultiplier}px`, c.width = "auto") : t.widthMultiplier && (c.width = `${M * t.widthMultiplier}px`, c.height = "auto"), c.borderRadius = `${I ? F * R.videoBorderRadiusMultiplier : M * R.videoBorderRadiusMultiplier}px`, eA(c);
677
677
  }, E = new ResizeObserver(() => {
678
678
  g();
679
679
  });
@@ -714,7 +714,7 @@ const lA = wA(
714
714
  O("Data channel not ready for imperative key command:", o.current?.readyState);
715
715
  return;
716
716
  }
717
- const n = tA[e.code];
717
+ const n = rA[e.code];
718
718
  if (!n) {
719
719
  O(`Unknown event.code for imperative command: ${e.code}`);
720
720
  return;
@@ -756,7 +756,7 @@ const lA = wA(
756
756
  })), /* @__PURE__ */ KA(
757
757
  "div",
758
758
  {
759
- className: zA(
759
+ className: $(
760
760
  "rc-container",
761
761
  C
762
762
  ),
@@ -770,27 +770,27 @@ const lA = wA(
770
770
  onTouchEnd: k,
771
771
  onTouchCancel: k,
772
772
  children: [
773
- m && /* @__PURE__ */ iA(
773
+ m && /* @__PURE__ */ nA(
774
774
  "img",
775
775
  {
776
776
  ref: l,
777
777
  src: Q ? R.frame.imageLandscape : R.frame.image,
778
778
  alt: "",
779
- className: "rc-phone-frame",
779
+ className: EA === "ios" ? $("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
780
780
  draggable: !1
781
781
  }
782
782
  ),
783
- /* @__PURE__ */ iA(
783
+ /* @__PURE__ */ nA(
784
784
  "video",
785
785
  {
786
786
  ref: r,
787
- className: zA(
787
+ className: $(
788
788
  "rc-video",
789
789
  !m && "rc-video-frameless",
790
790
  !W && "rc-video-loading"
791
791
  ),
792
792
  style: {
793
- ...QA,
793
+ ...cA,
794
794
  ...R.loadingLogo ? {
795
795
  backgroundImage: `url("${R.loadingLogo}")`,
796
796
  backgroundRepeat: "no-repeat",
@@ -802,8 +802,8 @@ const lA = wA(
802
802
  playsInline: !0,
803
803
  muted: !0,
804
804
  tabIndex: 0,
805
- onKeyDown: eA,
806
- onKeyUp: eA,
805
+ onKeyDown: MA,
806
+ onKeyUp: MA,
807
807
  onClick: mA,
808
808
  onLoadedMetadata: () => K(!0),
809
809
  onFocus: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limrun/ui",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,6 +23,10 @@
23
23
  max-height: 100%;
24
24
  }
25
25
 
26
+ .rc-phone-frame-ios {
27
+ z-index: 10;
28
+ }
29
+
26
30
  .rc-video {
27
31
  position: absolute;
28
32
  z-index: 20;
@@ -1013,7 +1013,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
1013
1013
  ref={frameRef}
1014
1014
  src={isLandscape ? config.frame.imageLandscape : config.frame.image}
1015
1015
  alt=""
1016
- className={'rc-phone-frame'}
1016
+ className={platform === 'ios' ? clsx('rc-phone-frame', 'rc-phone-frame-ios') : 'rc-phone-frame'}
1017
1017
  draggable={false}
1018
1018
  />
1019
1019
  )}