@kieransimkin/dancemoves 3.1.16 → 3.1.18

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/lib/index.cjs CHANGED
@@ -2331,7 +2331,10 @@ function install2(__dmScope) {
2331
2331
  function tick(now) {
2332
2332
  if (!running)
2333
2333
  return;
2334
- if (document2.hidden || state.reduced.matches || state.forced.matches) {
2334
+ var preferenceBlocked = state.reduced.matches || state.forced.matches;
2335
+ if (preferenceBlocked !== preferenceLimited)
2336
+ preference();
2337
+ if (document2.hidden || preferenceBlocked) {
2335
2338
  resetWindow(now);
2336
2339
  frame = window2.requestAnimationFrame(tick);
2337
2340
  return;
@@ -3221,6 +3224,7 @@ function install5(__dmScope) {
3221
3224
  if (!Core || !harnessMode && (!Core.isMobileDevice(window) || !Core.sensorSupported(window)))
3222
3225
  return;
3223
3226
  const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
3227
+ const forcedColours = window.matchMedia("(forced-colors: active)");
3224
3228
  const perceptualAxis = (value) => {
3225
3229
  const bounded = Core.clamp(value, -1, 1);
3226
3230
  return Math.sign(bounded) * Math.sqrt(Math.abs(bounded));
@@ -3549,6 +3553,10 @@ function install5(__dmScope) {
3549
3553
  let destroyed = false;
3550
3554
  let controlFeedback = null;
3551
3555
  const phonePreference = Core.createOrientationPreference(window);
3556
+ const subscribers = /* @__PURE__ */ new Set();
3557
+ let suspended = false;
3558
+ const qualityLimited = () => ["minimal", "static"].includes(adapter.root.dataset.danceMovesQuality) || adapter.root.dataset.danceMovesPerformance === "minimal" || document.body?.dataset?.epkAdaptiveTier === "static";
3559
+ const notify = (reason) => subscribers.forEach((callback) => callback({ ...latest, reason }));
3552
3560
  __dmScope.dataset(adapter.root, "ksOrientation", "supported");
3553
3561
  __dmScope.dataset(adapter.root, "ksOrientationAdapter", config.adapter || "detected");
3554
3562
  __dmScope.dataset(adapter.root, "ksOrientationWindow", String(windowMilliseconds));
@@ -3580,6 +3588,7 @@ function install5(__dmScope) {
3580
3588
  removeControl();
3581
3589
  }
3582
3590
  adapter.apply(x, y);
3591
+ notify("phone");
3583
3592
  window.EPKEffectHarnessProbe?.noteCommit?.(detail.sampleAge);
3584
3593
  }
3585
3594
  });
@@ -3603,9 +3612,10 @@ function install5(__dmScope) {
3603
3612
  active = false;
3604
3613
  __dmScope.dataset(adapter.root, "ksOrientation", "supported");
3605
3614
  adapter.reset();
3615
+ notify("reset");
3606
3616
  };
3607
3617
  const onOrientation = (event) => {
3608
- if (reducedMotion.matches)
3618
+ if (reducedMotion.matches || forcedColours.matches || suspended || qualityLimited())
3609
3619
  return;
3610
3620
  if (!Core.hasMotionData(event)) {
3611
3621
  window.EPKEffectHarnessProbe?.noteRejected?.();
@@ -3614,7 +3624,7 @@ function install5(__dmScope) {
3614
3624
  scheduler.receive(event, Core.screenAngle(window), window.performance.now());
3615
3625
  };
3616
3626
  const startListening = () => {
3617
- if (listening || reducedMotion.matches || document.hidden || destroyed)
3627
+ if (listening || reducedMotion.matches || forcedColours.matches || suspended || qualityLimited() || document.hidden || destroyed)
3618
3628
  return;
3619
3629
  listening = true;
3620
3630
  __dmScope.listen(window, "deviceorientation", onOrientation, { passive: true });
@@ -3633,7 +3643,7 @@ function install5(__dmScope) {
3633
3643
  reset();
3634
3644
  };
3635
3645
  const makePermissionControl = () => {
3636
- if (control || destroyed)
3646
+ if (control || destroyed || active)
3637
3647
  return;
3638
3648
  control = document.createElement("button");
3639
3649
  control.type = "button";
@@ -3652,7 +3662,7 @@ function install5(__dmScope) {
3652
3662
  button.disabled = true;
3653
3663
  button.textContent = "Checking motion\u2026";
3654
3664
  try {
3655
- const result = await window.DeviceOrientationEvent.requestPermission();
3665
+ const result = Core.permissionRequired(window) ? await window.DeviceOrientationEvent.requestPermission() : "granted";
3656
3666
  if (destroyed || control !== button)
3657
3667
  return;
3658
3668
  if (result !== "granted") {
@@ -3691,7 +3701,7 @@ function install5(__dmScope) {
3691
3701
  stopListening();
3692
3702
  };
3693
3703
  const pageShown = () => {
3694
- if (destroyed || reducedMotion.matches)
3704
+ if (destroyed || reducedMotion.matches || forcedColours.matches || suspended || qualityLimited())
3695
3705
  return;
3696
3706
  if (harnessMode)
3697
3707
  startListening();
@@ -3699,8 +3709,11 @@ function install5(__dmScope) {
3699
3709
  makePermissionControl();
3700
3710
  if (phonePreference.read() === "enabled")
3701
3711
  startListening();
3702
- } else if (phonePreference.read() !== "disabled")
3703
- startListening();
3712
+ } else {
3713
+ makePermissionControl();
3714
+ if (phonePreference.read() !== "disabled")
3715
+ startListening();
3716
+ }
3704
3717
  };
3705
3718
  __dmScope.listen(window, "orientationchange", recalibrate, { passive: true });
3706
3719
  if (window.screen && window.screen.orientation && typeof window.screen.orientation.addEventListener === "function") {
@@ -3710,7 +3723,7 @@ function install5(__dmScope) {
3710
3723
  __dmScope.listen(window, "pagehide", pageHidden);
3711
3724
  __dmScope.listen(window, "pageshow", pageShown);
3712
3725
  const preferenceChanged = () => {
3713
- if (reducedMotion.matches) {
3726
+ if (reducedMotion.matches || forcedColours.matches || suspended || qualityLimited()) {
3714
3727
  controlFeedback?.clear();
3715
3728
  stopListening();
3716
3729
  removeControl();
@@ -3722,6 +3735,10 @@ function install5(__dmScope) {
3722
3735
  __dmScope.listen(reducedMotion, "change", preferenceChanged);
3723
3736
  else
3724
3737
  __dmScope.addMediaListener(reducedMotion, preferenceChanged);
3738
+ if (typeof forcedColours.addEventListener === "function")
3739
+ __dmScope.listen(forcedColours, "change", preferenceChanged);
3740
+ else if (typeof forcedColours.addListener === "function")
3741
+ __dmScope.addMediaListener(forcedColours, preferenceChanged);
3725
3742
  const teardown = () => {
3726
3743
  if (destroyed)
3727
3744
  return;
@@ -3735,6 +3752,8 @@ function install5(__dmScope) {
3735
3752
  latest = { x: 0, y: 0 };
3736
3753
  active = false;
3737
3754
  adapter.reset();
3755
+ notify("teardown");
3756
+ subscribers.clear();
3738
3757
  controlFeedback?.destroy();
3739
3758
  removeControl();
3740
3759
  __dmScope.unlisten(window, "orientationchange", recalibrate);
@@ -3748,6 +3767,10 @@ function install5(__dmScope) {
3748
3767
  __dmScope.unlisten(reducedMotion, "change", preferenceChanged);
3749
3768
  else if (typeof reducedMotion.removeListener === "function")
3750
3769
  __dmScope.removeMediaListener(reducedMotion, preferenceChanged);
3770
+ if (typeof forcedColours.removeEventListener === "function")
3771
+ __dmScope.unlisten(forcedColours, "change", preferenceChanged);
3772
+ else if (typeof forcedColours.removeListener === "function")
3773
+ __dmScope.removeMediaListener(forcedColours, preferenceChanged);
3751
3774
  observer?.disconnect();
3752
3775
  observer = null;
3753
3776
  if (window.__ksEpkOrientationRuntime?.teardown === teardown)
@@ -3760,15 +3783,34 @@ function install5(__dmScope) {
3760
3783
  destroyed,
3761
3784
  latest: { ...latest },
3762
3785
  reducedMotion: reducedMotion.matches,
3786
+ forcedColors: forcedColours.matches,
3787
+ suspended,
3763
3788
  documentHidden: document.hidden
3764
3789
  });
3765
- window.__ksEpkOrientationRuntime = Object.freeze({ reset, teardown, snapshot });
3790
+ window.__ksEpkOrientationRuntime = Object.freeze({
3791
+ reset,
3792
+ teardown,
3793
+ snapshot,
3794
+ subscribe(callback) {
3795
+ if (typeof callback !== "function")
3796
+ throw new TypeError("Orientation callback required");
3797
+ subscribers.add(callback);
3798
+ callback({ ...latest, reason: active ? "phone" : "reset" });
3799
+ return () => subscribers.delete(callback);
3800
+ },
3801
+ suspend(value) {
3802
+ suspended = value === true;
3803
+ preferenceChanged();
3804
+ }
3805
+ });
3766
3806
  if (typeof window.MutationObserver === "function" && document.documentElement) {
3767
- observer = new window.MutationObserver(() => {
3807
+ observer = new window.MutationObserver((records) => {
3768
3808
  if (adapter.root.isConnected === false)
3769
3809
  teardown();
3810
+ else if (records?.some((record) => record.type === "attributes"))
3811
+ preferenceChanged();
3770
3812
  });
3771
- observer.observe(document.documentElement, { childList: true, subtree: true });
3813
+ observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-dance-moves-quality", "data-dance-moves-performance", "data-epk-adaptive-tier"] });
3772
3814
  }
3773
3815
  pageShown();
3774
3816
  }
@@ -5528,7 +5570,7 @@ function createOrientationController(scope, { render, windowMilliseconds = 2e3,
5528
5570
  for (const [name, value] of Object.entries({ windowMilliseconds, minimumSpanDegrees, smoothingTimeConstantMilliseconds })) if (!Number.isFinite(value) || value <= 0) throw new RangeError(name);
5529
5571
  const w = scope.window, core = w.KSEpkOrientationCore;
5530
5572
  const preference = core.createOrientationPreference(w);
5531
- let enabled = core.sensorSupported(w) && preference.read() === "enabled", listening = false, destroyed = false, pending = false;
5573
+ let enabled = core.sensorSupported(w) && preference.read() === "enabled", listening = false, destroyed = false, pending = false, active = true, pageHidden = false;
5532
5574
  const reduced = w.matchMedia("(prefers-reduced-motion: reduce)"), forced = w.matchMedia("(forced-colors: active)");
5533
5575
  const scheduler = core.createLatestSampleRafScheduler({
5534
5576
  requestFrame: w.requestAnimationFrame,
@@ -5546,27 +5588,49 @@ function createOrientationController(scope, { render, windowMilliseconds = 2e3,
5546
5588
  if (!destroyed) render({ x: 0, y: 0, reason: "reset" });
5547
5589
  };
5548
5590
  const reconcile = () => {
5549
- const active = enabled && !destroyed && !scope.disposed && !scope.document.hidden && !reduced.matches && !forced.matches;
5550
- if (active && !listening) {
5591
+ const allowed = active && enabled && !destroyed && !scope.disposed && !pageHidden && !scope.document.hidden && !reduced.matches && !forced.matches;
5592
+ if (allowed && !listening) {
5551
5593
  scope.listen(w, "deviceorientation", receive, { passive: true });
5552
5594
  listening = true;
5553
5595
  }
5554
- if (!active && listening) {
5596
+ if (!allowed && listening) {
5555
5597
  scope.unlisten(w, "deviceorientation", receive);
5556
5598
  listening = false;
5557
5599
  reset();
5558
5600
  }
5559
5601
  };
5602
+ const hide = () => {
5603
+ pageHidden = true;
5604
+ reconcile();
5605
+ };
5606
+ const show = () => {
5607
+ pageHidden = false;
5608
+ reset();
5609
+ reconcile();
5610
+ };
5560
5611
  const disposers = [
5561
5612
  () => scope.unlisten(scope.document, "visibilitychange", reconcile),
5562
5613
  () => scope.unlisten(reduced, "change", reconcile),
5563
5614
  () => scope.unlisten(forced, "change", reconcile),
5564
- () => scope.unlisten(w, "orientationchange", reset)
5615
+ () => scope.unlisten(w, "orientationchange", reset),
5616
+ () => scope.unlisten(w.screen?.orientation, "change", reset),
5617
+ () => scope.unlisten(w, "pagehide", hide),
5618
+ () => scope.unlisten(w, "pageshow", show)
5565
5619
  ];
5566
5620
  scope.listen(scope.document, "visibilitychange", reconcile);
5567
5621
  scope.listen(reduced, "change", reconcile);
5568
5622
  scope.listen(forced, "change", reconcile);
5569
5623
  scope.listen(w, "orientationchange", reset);
5624
+ scope.listen(w.screen?.orientation, "change", reset);
5625
+ scope.listen(w, "pagehide", hide);
5626
+ scope.listen(w, "pageshow", show);
5627
+ let observer;
5628
+ if (w.MutationObserver) {
5629
+ observer = new w.MutationObserver(() => {
5630
+ if (w.DanceMoves?.root?.isConnected === false) destroy();
5631
+ });
5632
+ observer.observe(w.DanceMoves?.root?.ownerDocument.documentElement || scope.document.documentElement, { childList: true, subtree: true });
5633
+ }
5570
5634
  function destroy() {
5571
5635
  if (destroyed) return;
5572
5636
  enabled = false;
@@ -5574,6 +5638,7 @@ function createOrientationController(scope, { render, windowMilliseconds = 2e3,
5574
5638
  destroyed = true;
5575
5639
  pending = false;
5576
5640
  scheduler.teardown();
5641
+ observer?.disconnect();
5577
5642
  disposers.forEach((fn) => fn());
5578
5643
  removeDispose();
5579
5644
  }
@@ -5586,6 +5651,7 @@ function createOrientationController(scope, { render, windowMilliseconds = 2e3,
5586
5651
  if (!core.sensorSupported(w)) throw new Error("Device orientation is unavailable in this browser or insecure context");
5587
5652
  pending = true;
5588
5653
  try {
5654
+ if (!active || pageHidden || scope.document.hidden || reduced.matches || forced.matches) throw new Error("Phone motion is currently paused");
5589
5655
  if (core.permissionRequired(w) && await w.DeviceOrientationEvent.requestPermission() !== "granted") {
5590
5656
  if (!destroyed && !scope.disposed) {
5591
5657
  preference.write(false);
@@ -5608,12 +5674,175 @@ function createOrientationController(scope, { render, windowMilliseconds = 2e3,
5608
5674
  enabled = false;
5609
5675
  reconcile();
5610
5676
  },
5677
+ setActive(value) {
5678
+ active = value === true;
5679
+ reconcile();
5680
+ },
5611
5681
  reset,
5612
5682
  destroy,
5613
- snapshot: () => ({ enabled, listening, destroyed, pending, reducedMotion: reduced.matches, forcedColors: forced.matches, framePending: scheduler.pending() })
5683
+ snapshot: () => ({ enabled, listening, destroyed, pending, active, pageHidden, reducedMotion: reduced.matches, forcedColors: forced.matches, framePending: scheduler.pending() })
5614
5684
  });
5615
5685
  }
5616
5686
 
5687
+ // .build/modules/phone-motion.mjs
5688
+ var connections = /* @__PURE__ */ new WeakMap();
5689
+ function connectPhoneMotion(scope, { render = () => {
5690
+ }, pointers = [], enabled = () => true, controlParent = scope.document.body, watchAttributes = ["class"], windowMilliseconds = 1e4 } = {}) {
5691
+ if (scope.disposed) throw new Error("DanceMoves mount is destroyed");
5692
+ if (connections.has(scope)) throw new Error("Phone motion is already connected on this mount");
5693
+ if (typeof render !== "function" || typeof enabled !== "function") throw new TypeError("Phone motion callbacks must be functions");
5694
+ if (!Array.isArray(pointers) || !Array.isArray(watchAttributes)) throw new TypeError("Phone motion lists must be arrays");
5695
+ const w = scope.window, core = w.KSEpkOrientationCore;
5696
+ let destroyed = false, sensorActive = false, pageHidden = false, button = null, timer = 0, pending = false, observer = null, source = null, unsubscribe = null;
5697
+ const reduced = w.matchMedia("(prefers-reduced-motion: reduce)"), forced = w.matchMedia("(forced-colors: active)");
5698
+ const eligible = () => core.isMobileDevice(w) && core.sensorSupported(w);
5699
+ if (!eligible()) {
5700
+ const dispose = () => {
5701
+ destroyed = true;
5702
+ connections.delete(scope);
5703
+ };
5704
+ scope.onDispose(dispose);
5705
+ const unavailable2 = Object.freeze({ enable: async () => false, reconcile: () => {
5706
+ }, destroy: dispose, snapshot: () => ({ eligible: false, allowed: false, sensorActive: false, destroyed: destroyed || scope.disposed, source: "unavailable", orientation: null }) });
5707
+ connections.set(scope, unavailable2);
5708
+ return unavailable2;
5709
+ }
5710
+ const allowed = () => eligible() && !destroyed && !scope.disposed && !pageHidden && !scope.document.hidden && !reduced.matches && !forced.matches && enabled();
5711
+ function apply(point) {
5712
+ const live = allowed() && point.reason !== "reset" && point.reason !== "teardown";
5713
+ const x = live ? core.clamp(point.x, -1, 1) : 0, y = live ? core.clamp(point.y, -1, 1) : 0;
5714
+ for (const id of pointers) {
5715
+ const pointer = w.DanceMovesEffects.get(id);
5716
+ if (pointer) {
5717
+ live ? pointer.set(x, y, "phone") : pointer.reset("phone-reset");
5718
+ }
5719
+ }
5720
+ render({ x, y, reason: live ? "phone" : "reset" });
5721
+ if (live) {
5722
+ sensorActive = true;
5723
+ removeButton();
5724
+ } else sensorActive = false;
5725
+ }
5726
+ function removeButton() {
5727
+ if (timer) w.clearTimeout(timer);
5728
+ timer = 0;
5729
+ if (button) {
5730
+ scope.unlisten(button, "click", enable);
5731
+ button.remove();
5732
+ button = null;
5733
+ }
5734
+ }
5735
+ function unavailable() {
5736
+ timer = 0;
5737
+ if (!button || sensorActive) return;
5738
+ button.disabled = false;
5739
+ button.textContent = core.permissionRequired(w) ? "Use phone motion" : "Phone motion unavailable";
5740
+ }
5741
+ function makeButton() {
5742
+ if (button || !allowed() || source?.subscribe) return;
5743
+ button = scope.document.createElement("button");
5744
+ button.type = "button";
5745
+ button.className = "ks-epk-orientation-control";
5746
+ button.textContent = "Use phone motion";
5747
+ button.setAttribute("aria-live", "polite");
5748
+ scope.listen(button, "click", enable);
5749
+ controlParent.append(button);
5750
+ }
5751
+ async function enable() {
5752
+ if (!allowed() || pending || !source) return false;
5753
+ pending = true;
5754
+ makeButton();
5755
+ if (button) {
5756
+ button.disabled = true;
5757
+ button.textContent = "Checking motion\u2026";
5758
+ }
5759
+ try {
5760
+ await source.enable();
5761
+ if (destroyed) return false;
5762
+ if (button) {
5763
+ button.textContent = "Move phone to enable\u2026";
5764
+ button.disabled = false;
5765
+ }
5766
+ if (timer) w.clearTimeout(timer);
5767
+ timer = w.setTimeout(unavailable, 3500);
5768
+ return true;
5769
+ } catch (error) {
5770
+ if (button) {
5771
+ button.disabled = false;
5772
+ button.textContent = /denied/i.test(error.message) ? "Phone motion blocked" : "Use phone motion";
5773
+ }
5774
+ return false;
5775
+ } finally {
5776
+ pending = false;
5777
+ }
5778
+ }
5779
+ function reconcile() {
5780
+ if (destroyed) return;
5781
+ if (source?.subscribe) {
5782
+ source.suspend?.(!allowed());
5783
+ if (!allowed()) apply({ x: 0, y: 0, reason: "reset" });
5784
+ return;
5785
+ }
5786
+ source?.setActive(allowed());
5787
+ if (!allowed()) {
5788
+ removeButton();
5789
+ apply({ x: 0, y: 0, reason: "reset" });
5790
+ return;
5791
+ }
5792
+ if (!sensorActive) makeButton();
5793
+ const state = source?.snapshot();
5794
+ if (state?.listening && !timer && !sensorActive) timer = w.setTimeout(unavailable, 3500);
5795
+ if (source && !core.permissionRequired(w) && core.createOrientationPreference(w).read() !== "disabled" && !state.enabled) void enable();
5796
+ }
5797
+ const hide = () => {
5798
+ pageHidden = true;
5799
+ reconcile();
5800
+ };
5801
+ const show = () => {
5802
+ pageHidden = false;
5803
+ reconcile();
5804
+ };
5805
+ const signals = [[scope.document, "visibilitychange", reconcile], [reduced, "change", reconcile], [forced, "change", reconcile], [w, "pagehide", hide], [w, "pageshow", show]];
5806
+ signals.forEach(([target, type, handler]) => scope.listen(target, type, handler));
5807
+ if (eligible()) {
5808
+ const existing = w.DanceMoves?.getOrientation?.();
5809
+ if (existing?.subscribe) {
5810
+ source = existing;
5811
+ unsubscribe = existing.subscribe(apply);
5812
+ } else source = createOrientationController(scope, { render: apply, windowMilliseconds });
5813
+ }
5814
+ if (w.MutationObserver) {
5815
+ const root = w.DanceMoves.root, document = root.ownerDocument;
5816
+ observer = new w.MutationObserver((records) => {
5817
+ if (root.isConnected === false) {
5818
+ destroy();
5819
+ return;
5820
+ }
5821
+ if (records.some((r) => r.type === "attributes")) reconcile();
5822
+ });
5823
+ observer.observe(root, { attributes: true, attributeFilter: watchAttributes, childList: true, subtree: true });
5824
+ if (document.body !== root) observer.observe(document.body, { attributes: true, attributeFilter: watchAttributes });
5825
+ if (document.documentElement !== root) observer.observe(document.documentElement, { childList: true, subtree: true });
5826
+ }
5827
+ function destroy() {
5828
+ if (destroyed) return;
5829
+ removeButton();
5830
+ apply({ x: 0, y: 0, reason: "teardown" });
5831
+ destroyed = true;
5832
+ unsubscribe?.();
5833
+ if (!source?.subscribe) source?.destroy();
5834
+ observer?.disconnect();
5835
+ signals.forEach(([target, type, handler]) => scope.unlisten(target, type, handler));
5836
+ removeDispose();
5837
+ connections.delete(scope);
5838
+ }
5839
+ const removeDispose = scope.onDispose(destroy);
5840
+ reconcile();
5841
+ const connection = Object.freeze({ enable, reconcile, destroy, snapshot: () => ({ eligible: eligible(), allowed: allowed(), sensorActive, destroyed, pending, source: source?.subscribe ? "existing" : "generic", orientation: source?.snapshot() || null }) });
5842
+ connections.set(scope, connection);
5843
+ return connection;
5844
+ }
5845
+
5617
5846
  // .build/modules/recorder.mjs
5618
5847
  function createMotionRecorder(scope, { durationMilliseconds = 3e4, maxSamples = 500 } = {}) {
5619
5848
  if (scope.disposed) throw new Error("DanceMoves mount is destroyed");
@@ -5721,7 +5950,7 @@ function createMotionRecorder(scope, { durationMilliseconds = 3e4, maxSamples =
5721
5950
  }
5722
5951
 
5723
5952
  // .build/modules/version.mjs
5724
- var VERSION = "3.1.16";
5953
+ var VERSION = "3.1.18";
5725
5954
 
5726
5955
  // .build/modules/index.mjs
5727
5956
  var mounted = /* @__PURE__ */ new WeakMap();
@@ -5780,6 +6009,7 @@ function createDanceMoves(options = {}) {
5780
6009
  createRecorder: (settings) => createMotionRecorder(scope, settings),
5781
6010
  createOrientation: (settings) => createOrientationController(scope, settings),
5782
6011
  destroy,
6012
+ connectPhoneMotion: (settings) => connectPhoneMotion(scope, settings),
5783
6013
  resources: () => scope.snapshot(),
5784
6014
  on(type, callback) {
5785
6015
  scope.listen(scope.document, type, callback);
package/lib/index.d.ts CHANGED
@@ -40,7 +40,9 @@ export interface Effects {
40
40
  get(id:string):Controller|null;snapshot():Record<string,unknown>[];teardown(id:string):void;teardownAll():void;
41
41
  }
42
42
  export interface EffectOptions {id?:string;root?:Element|string;[key:string]:unknown}
43
- export interface OrientationController {enable():Promise<boolean>;disable():void;reset():void;destroy():void;snapshot():Record<string,unknown>}
43
+ export interface OrientationController {enable():Promise<boolean>;disable():void;setActive(value:boolean):void;reset():void;destroy():void;snapshot():Record<string,unknown>}
44
+ export interface PhoneMotionConnection {enable():Promise<boolean>;reconcile():void;destroy():void;snapshot():Record<string,unknown>}
45
+ export interface PhoneMotionOptions {render?:(point:Offset & {reason:string})=>void;pointers?:string[];enabled?:()=>boolean;controlParent?:HTMLElement;watchAttributes?:string[];windowMilliseconds?:number}
44
46
  export interface Recorder {start():Promise<MotionCapture>;stop(reason?:string):MotionCapture;snapshot():Record<string,unknown>;upload(endpoint:string,options?:{headers?:Record<string,string>;signal?:AbortSignal}):Promise<Record<string,unknown>>}
45
47
  export interface MotionCapture {schema:'ks-epk-motion-recording/v1';samples:Array<{milliseconds:number;beta:number;gamma:number;alpha?:number|null;[key:string]:unknown}>;[key:string]:unknown}
46
48
  export interface DanceMoves {
@@ -66,6 +68,7 @@ export interface DanceMoves {
66
68
  orientationCore:Record<string,(...args:any[])=>any>;
67
69
  getOrientation():(Controller & {reset():void})|null;getClay():(Controller & Record<string,any>)|null;getPaperPlanes():Controller|null;
68
70
  createOrientation(options:{render:(point:Offset & Record<string,unknown>)=>void;windowMilliseconds?:number;minimumSpanDegrees?:number;smoothingTimeConstantMilliseconds?:number}):OrientationController;
71
+ connectPhoneMotion(options?:PhoneMotionOptions):PhoneMotionConnection;
69
72
  createRecorder(options?:{durationMilliseconds?:number;maxSamples?:number}):Recorder;
70
73
  on(type:string,callback:EventListener):Remove;resources():{id:string;disposed:boolean;listeners:number;timers:number;frames:number;observers:number;created:number};destroy():void;
71
74
  }