hyperframes 0.8.61 → 0.8.62

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 +1 @@
1
- import{g as P}from"./index-BK36b0XY.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-DLYk_vu_.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>HyperFrames Studio</title>
8
- <script type="module" crossorigin src="/assets/index-BK36b0XY.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-DLYk_vu_.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DS0kLbuM.css">
10
10
  </head>
11
11
  <body>
@@ -27708,6 +27708,9 @@ var logReload = makeStudioDebugLogger("reload");
27708
27708
 
27709
27709
  // src/player/hooks/useShadowPreviewReload.ts
27710
27710
  var SHADOW_READY_TIMEOUT_MS = 15e3;
27711
+ function isDocumentHidden() {
27712
+ return typeof document !== "undefined" && document.visibilityState === "hidden";
27713
+ }
27711
27714
  function useShadowPreviewReload({
27712
27715
  iframeRef,
27713
27716
  getAdapter,
@@ -27733,11 +27736,13 @@ function useShadowPreviewReload({
27733
27736
  const onReloadFailedRef = useRef51(onReloadFailed);
27734
27737
  onReloadFailedRef.current = onReloadFailed;
27735
27738
  const readyTimerRef = useRef51(void 0);
27739
+ const budgetGenRef = useRef51(null);
27736
27740
  const cancelPendingLoadRef = useRef51(() => {
27737
27741
  });
27738
27742
  const [previewSlots, setPreviewSlots] = useState33([{ gen: 0, role: "live" }]);
27739
27743
  const stopPendingShadow = useCallback36(() => {
27740
27744
  clearTimeout(readyTimerRef.current);
27745
+ budgetGenRef.current = null;
27741
27746
  cancelPendingLoadRef.current();
27742
27747
  pendingCommitRef.current = null;
27743
27748
  visuallyReadyGenRef.current = null;
@@ -27816,18 +27821,29 @@ function useShadowPreviewReload({
27816
27821
  const setShadowIframeNode = useCallback36((node) => {
27817
27822
  shadowIframeRef.current = node;
27818
27823
  }, []);
27824
+ const armReadyTimer = useCallback36(
27825
+ (gen) => {
27826
+ clearTimeout(readyTimerRef.current);
27827
+ if (isDocumentHidden()) return;
27828
+ readyTimerRef.current = setTimeout(
27829
+ () => failShadow(gen, "it took too long to load"),
27830
+ SHADOW_READY_TIMEOUT_MS
27831
+ );
27832
+ },
27833
+ [failShadow]
27834
+ );
27835
+ const armReadyTimerRef = useRef51(armReadyTimer);
27836
+ armReadyTimerRef.current = armReadyTimer;
27819
27837
  const beginShadowReload = useCallback36(
27820
27838
  (url) => {
27821
27839
  shadowGenRef.current += 1;
27822
27840
  const gen = shadowGenRef.current;
27823
27841
  stopPendingShadow();
27824
- readyTimerRef.current = setTimeout(
27825
- () => failShadow(gen, "it took too long to load"),
27826
- SHADOW_READY_TIMEOUT_MS
27827
- );
27842
+ budgetGenRef.current = gen;
27843
+ armReadyTimer(gen);
27828
27844
  setPreviewSlots((prev) => planShadowReload(prev, gen, url));
27829
27845
  },
27830
- [stopPendingShadow, failShadow]
27846
+ [stopPendingShadow, armReadyTimer]
27831
27847
  );
27832
27848
  const resetPreviewSlots = useCallback36(() => {
27833
27849
  shadowGenRef.current += 1;
@@ -27837,7 +27853,21 @@ function useShadowPreviewReload({
27837
27853
  pendingSeekRef.current = null;
27838
27854
  setPreviewSlots(planShadowDiscard);
27839
27855
  }, [stopPendingShadow, isRefreshingRef, pendingSeekRef]);
27840
- useMountEffect(() => stopPendingShadow);
27856
+ useMountEffect(() => {
27857
+ const onVisibilityChange = () => {
27858
+ if (isDocumentHidden()) {
27859
+ clearTimeout(readyTimerRef.current);
27860
+ return;
27861
+ }
27862
+ const gen = budgetGenRef.current;
27863
+ if (gen != null && gen === shadowGenRef.current) armReadyTimerRef.current(gen);
27864
+ };
27865
+ document.addEventListener("visibilitychange", onVisibilityChange);
27866
+ return () => {
27867
+ document.removeEventListener("visibilitychange", onVisibilityChange);
27868
+ stopPendingShadow();
27869
+ };
27870
+ });
27841
27871
  return {
27842
27872
  previewSlots,
27843
27873
  onShadowIframeLoad,