@stacksjs/mobile 0.75.33 → 0.75.34

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{appReview as B,biometrics as _,camera as I,deepLinks as k,device as Y,haptics as K,health as j,keepAwake as q,lifecycle as G,liveActivities as W,location as z,network as J,notifications as Q,permissions as V,pushNotifications as X,secureStorage as Z,share as ee,watchConnectivity as te}from"craft-native/mobile";import{haptics as T}from"craft-native/mobile";function g(){if(typeof window>"u")return;return window}function y(e=g()){if(!e)return 0;if(typeof e.scrollY==="number")return e.scrollY;return e.document?.scrollingElement?.scrollTop??0}function Re(e,t=g()){if(!t)return()=>{};let r=!1,n=typeof requestAnimationFrame==="function"?requestAnimationFrame:(i)=>setTimeout(i,16),o=()=>{if(r)return;r=!0,n(()=>{r=!1,e(y(t))})};return e(y(t)),t.addEventListener("scroll",o,{passive:!0}),()=>t.removeEventListener("scroll",o)}function C(e,t){let r=Math.max(0,-e),n=e<=0?Math.max(0,t)*0.5:0;return Math.round(Math.max(r,n))}function Se(e){let t=e.host??g();if(!t)return()=>{};let r=e.threshold??72,n=null,o=!1,i=!1,a=(s)=>e.onPull?.(s,o),d=(s)=>{let f=s.touches?.[0];return f?f.clientY:null},u=(s)=>{if(i||y(t)>0)return;n=d(s),o=!1},l=(s)=>{if(n===null)return;let f=d(s);if(f===null)return;let p=C(y(t),f-n);if(!o&&p>=r)o=!0,Promise.resolve(T.impact("medium")).catch(()=>{});else if(o&&p<r*0.8)o=!1;a(p)},m=async()=>{if(n===null)return;if(n=null,!o){a(0);return}o=!1,i=!0,e.onPull?.(r,!1);try{await e.onRefresh()}finally{i=!1,a(0)}},c=()=>{if(n===null)return;n=null,o=!1,a(0)};return t.addEventListener("touchstart",u,{passive:!0}),t.addEventListener("touchmove",l,{passive:!0}),t.addEventListener("touchend",m),t.addEventListener("touchcancel",c),()=>{t.removeEventListener("touchstart",u),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",m),t.removeEventListener("touchcancel",c)}}function R(){if(typeof window>"u")return;return window}function N(e=R()){let t=e?.history?.state;return t!==null&&t!==void 0}function ke(e=R()){if(!N(e))return!1;return e.history.back(),!0}function F(e,t=D()){let r;try{r=new URL(e)}catch{return null}let n=`${r.search}${r.hash}`;if(r.protocol==="http:"||r.protocol==="https:"){if(!t||r.origin!==t)return null;return`${r.pathname||"/"}${n}`}return`${`/${[r.host,r.pathname.replace(/^\/+/,"")].filter(Boolean).join("/")}`}${n}`}function D(){if(typeof window>"u")return;return window.location?.origin}var A="stacks-mobile-deep-link";function Me(e,t){let r=(n)=>{let o=F(n);if(o)e(o)};return t.getInitialURL().then((n)=>{if(!n)return;try{if(sessionStorage.getItem(A)===n)return;sessionStorage.setItem(A,n)}catch{}r(n)}).catch(()=>{}),t.onLink((n,o)=>{if(o?.initial)return;r(n)})}var Ee=30;function O(e,t){let r=Math.PI/180,n=(t.latitude-e.latitude)*r,o=(t.longitude-e.longitude)*r,i=Math.sin(n/2)**2+Math.cos(e.latitude*r)*Math.cos(t.latitude*r)*Math.sin(o/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(i)))}function U(e,t=25){let r=new Set;return e.filter((n)=>Number.isFinite(n.latitude)&&Number.isFinite(n.longitude)&&Number.isFinite(n.timestamp)&&n.accuracy>=0&&n.accuracy<=t).sort((n,o)=>n.timestamp-o.timestamp).filter((n)=>{if(r.has(n.timestamp))return!1;return r.add(n.timestamp),!0})}function S(e,t={}){let r=U(e,t.maxAccuracyM??25),n=t.paceWindowS??30,o=[],i=0,a=0,d=null;for(let c of r){let s=o[o.length-1],f=d?(c.timestamp-d.timestamp)/1000:0;if(d=c,!s){o.push({fix:c,cumM:0});continue}if(f>30){o.push({fix:c,cumM:i});continue}let p=(c.timestamp-s.fix.timestamp)/1000,v=O(s.fix,c),H=Math.min(10,Math.max(3,s.fix.accuracy,c.accuracy));if(v<H)continue;if(i+=v,p>0&&v/p>=0.5)a+=p;o.push({fix:c,cumM:i})}let u=o[o.length-1],l=null,m=null;if(u){let c=u.fix.timestamp-n*1000,s=o.find((v)=>v.fix.timestamp>=c)??u,f=u.cumM-s.cumM,p=(u.fix.timestamp-s.fix.timestamp)/1000;if(f>=20&&p>0)m=f/p,l=p/(f/1000)}return{distanceM:i,movingS:a,paceSPerKm:l,averagePaceSPerKm:i>=50&&a>0?a/(i/1000):null,speedMps:m,accuracyM:r.length?r[r.length-1].accuracy:e.length?e[e.length-1].accuracy??null:null,fixes:r.length}}function He(e){if(!e||!Number.isFinite(e)||e>3600)return"–";let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Te(e){return e&&Number.isFinite(e)?(e*3.6).toFixed(1):"–"}var L={distanceM:0,movingS:0,paceSPerKm:null,averagePaceSPerKm:null,speedMps:null,accuracyM:null,fixes:0};function Ce(e){let t=e.location,r=e.intervalMs??3000,n=L,o=null,i=()=>typeof document<"u"&&document.visibilityState==="hidden";async function a(){let l=await t.readRecording();return n=S(l,e),e.onUpdate?.(n),n}function d(){u(),o=setInterval(()=>{if(!i())a().catch(()=>{})},r)}function u(){if(o)clearInterval(o);o=null}return{get stats(){return n},async start(){return await t.startRecording({enableHighAccuracy:!0,...e.locationOptions}),n=L,e.onUpdate?.(n),d(),n},async attach(){let l=await t.getRecordingState().catch(()=>null);if(!l?.active)return null;if(await a().catch(()=>{}),!l.paused)d();return l},async pause(){u(),await t.pauseRecording(),await a().catch(()=>{})},async resume(){await t.resumeRecording(),d()},async stop(){u();let m=(await t.stopRecording())?.locations??[];return n=S(m,e),e.onUpdate?.(n),m},refresh:a}}var ne=_,re=I,oe=Y,b=K,ie=G,ae=z,se=Q,ce=V,ue=Z,le=ee,fe=B;function M(e){if(typeof e==="string")return e.trim()||null;if(!e||typeof e!=="object")return null;let t=e.url;return typeof t==="string"&&t.trim()?t:null}var pe={async getInitialURL(){if(!await P())return null;return M(await k.getInitialURL?.())},onLink(e){let t=null,r=!1,n=()=>{if(r)return;t=k.onLink?.((o,i)=>{let a=M(o);if(a)e(a,{initial:i?.initial===!0})})??null};if(h()?.craft)n();else P().then(n);return()=>{r=!0,t?.()}}},de=q,me=J,ve=X,he=j,ye=W,be=te;function h(){if(typeof window>"u")return;return window}function w(){let e=h()?.craft;if(!e||typeof e!=="object")return null;if(!("platform"in e)||e.platform!=="ios"&&e.platform!=="android")return null;let t="capabilities"in e?e.capabilities:void 0,r=t&&typeof t==="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).filter(([,n])=>typeof n==="boolean")):{};return{platform:e.platform,capabilities:r}}function x(){return w()!==null}function E(){if(typeof window>"u")return!1;let e=window;if(e.CraftAndroid)return!0;let t=typeof navigator>"u"?"":navigator.userAgent;return Boolean(e.webkit?.messageHandlers?.craft)&&/iPhone|iPad|iPod/.test(t)}function we(e=2000){if(x()||E())return Promise.resolve(!0);let t=h(),r=t;if(!t||!(r?.craft||r?.webkit?.messageHandlers?.craft))return Promise.resolve(!1);return new Promise((n)=>{let o=()=>{clearTimeout(i),t.removeEventListener("craftReady",o),n(x())},i=setTimeout(o,e);t.addEventListener("craftReady",o,{once:!0})})}function P(e=15000){let t=h();if(t?.craft)return Promise.resolve(!0);let r=t;if(!t||!(E()||r?.webkit?.messageHandlers?.craft))return Promise.resolve(!1);return new Promise((n)=>{let o=()=>{clearTimeout(i),t.removeEventListener("craftReady",o),n(Boolean(t.craft))},i=setTimeout(o,e);t.addEventListener("craftReady",o)})}function ge(e){let t=h();if(!t)return()=>{};if(w()){let n=!1;return queueMicrotask(()=>{if(!n)e(new Event("craftReady"))}),()=>{n=!0}}let r=(n)=>{if(!w())return;t.removeEventListener("craftReady",r),e(n)};return t.addEventListener("craftReady",r),()=>t.removeEventListener("craftReady",r)}async function xe(e){await b.impact("light");try{let t=await e();return await b.notification("success"),t}catch(t){throw await b.notification("error"),t}}var De={get nativeBridge(){return w()},biometrics:ne,camera:re,device:oe,haptics:b,lifecycle:ie,location:ae,notifications:se,permissions:ce,secureStorage:ue,share:le,appReview:fe,deepLinks:pe,keepAwake:de,network:me,pushNotifications:ve,health:he,liveActivities:ye,watchConnectivity:be,isNativeMobile:x,whenNative:we,onReady:ge,withFeedback:xe};export{Ee as ROUTE_GAP_S,fe as appReview,ne as biometrics,re as camera,N as canGoBack,Ce as createRouteRecorder,F as deepLinkPath,pe as deepLinks,oe as device,O as fixDistance,Me as followDeepLinks,w as getNativeMobileBridge,ke as goBack,b as haptics,E as hasNativeMobileHost,he as health,x as isNativeMobile,de as keepAwake,ie as lifecycle,ye as liveActivities,ae as location,De as mobile,me as network,M as normalizeDeepLinkURL,se as notifications,Re as observePageScroll,Se as observePullToRefresh,ge as onMobileReady,He as paceLabel,y as pageScrollTop,ce as permissions,C as pullDistance,ve as pushNotifications,S as routeStats,ue as secureStorage,le as share,Te as speedLabel,U as usableFixes,be as watchConnectivity,P as whenBridgeReady,we as whenNativeMobile,xe as withNativeFeedback};
1
+ import{appReview as _,biometrics as I,camera as q,deepLinks as P,device as Y,haptics as K,health as j,keepAwake as G,lifecycle as W,liveActivities as z,location as J,network as Q,notifications as V,permissions as X,pushNotifications as Z,secureStorage as ee,share as te,watchConnectivity as ne}from"craft-native/mobile";import{haptics as C}from"craft-native/mobile";function A(){if(typeof window>"u")return;return window}function b(e=A()){if(!e)return 0;if(typeof e.scrollY==="number")return e.scrollY;return e.document?.scrollingElement?.scrollTop??0}function Se(e,t=A()){if(!t)return()=>{};let r=!1,n=typeof requestAnimationFrame==="function"?requestAnimationFrame:(i)=>setTimeout(i,16),o=()=>{if(r)return;r=!0,n(()=>{r=!1,e(b(t))})};return e(b(t)),t.addEventListener("scroll",o,{passive:!0}),()=>t.removeEventListener("scroll",o)}function N(e,t){let r=Math.max(0,-e),n=e<=0?Math.max(0,t)*0.5:0;return Math.round(Math.max(r,n))}function Le(e){let t=e.host??A();if(!t)return()=>{};let r=e.threshold??72,n=null,o=!1,i=!1,c=typeof requestAnimationFrame==="function"?requestAnimationFrame:(a)=>setTimeout(a,16),u=null,s=(a)=>{u=null,e.onPull?.(a,o)},f=(a)=>{let m=u!==null;if(u=a,m)return;c(()=>{if(u!==null)s(u)})},v=(a)=>{let m=a.touches?.[0];return m?m.clientY:null},l=(a)=>{if(i||b(t)>0)return;n=v(a),o=!1},p=(a)=>{if(n===null)return;let m=v(a);if(m===null)return;let x=N(b(t),m-n);if(!o&&x>=r)o=!0,Promise.resolve(C.impact("medium")).catch(()=>{});else if(o&&x<r*0.8)o=!1;f(x)},h=async()=>{if(n===null)return;if(n=null,!o){s(0);return}o=!1,i=!0,s(r);try{await e.onRefresh()}finally{i=!1,s(0)}},d=()=>{if(n===null)return;n=null,o=!1,s(0)};return t.addEventListener("touchstart",l,{passive:!0}),t.addEventListener("touchmove",p,{passive:!0}),t.addEventListener("touchend",h),t.addEventListener("touchcancel",d),()=>{u=null,t.removeEventListener("touchstart",l),t.removeEventListener("touchmove",p),t.removeEventListener("touchend",h),t.removeEventListener("touchcancel",d)}}function L(){if(typeof window>"u")return;return window}function F(e=L()){let t=e?.history?.state;return t!==null&&t!==void 0}function Me(e=L()){if(!F(e))return!1;return e.history.back(),!0}function D(e,t=O()){let r;try{r=new URL(e)}catch{return null}let n=`${r.search}${r.hash}`;if(r.protocol==="http:"||r.protocol==="https:"){if(!t||r.origin!==t)return null;return`${r.pathname||"/"}${n}`}return`${`/${[r.host,r.pathname.replace(/^\/+/,"")].filter(Boolean).join("/")}`}${n}`}function O(){if(typeof window>"u")return;return window.location?.origin}var S="stacks-mobile-deep-link";function Pe(e,t){let r=(n)=>{let o=D(n);if(o)e(o)};return t.getInitialURL().then((n)=>{if(!n)return;try{if(sessionStorage.getItem(S)===n)return;sessionStorage.setItem(S,n)}catch{}r(n)}).catch(()=>{}),t.onLink((n,o)=>{if(o?.initial)return;r(n)})}var He=30;function U(e,t){let r=Math.PI/180,n=(t.latitude-e.latitude)*r,o=(t.longitude-e.longitude)*r,i=Math.sin(n/2)**2+Math.cos(e.latitude*r)*Math.cos(t.latitude*r)*Math.sin(o/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(i)))}function B(e,t=25){let r=new Set;return e.filter((n)=>Number.isFinite(n.latitude)&&Number.isFinite(n.longitude)&&Number.isFinite(n.timestamp)&&n.accuracy>=0&&n.accuracy<=t).sort((n,o)=>n.timestamp-o.timestamp).filter((n)=>{if(r.has(n.timestamp))return!1;return r.add(n.timestamp),!0})}function k(e,t={}){let r=B(e,t.maxAccuracyM??25),n=t.paceWindowS??30,o=[],i=0,c=0,u=null;for(let l of r){let p=o[o.length-1],h=u?(l.timestamp-u.timestamp)/1000:0;if(u=l,!p){o.push({fix:l,cumM:0});continue}if(h>30){o.push({fix:l,cumM:i});continue}let d=(l.timestamp-p.fix.timestamp)/1000,a=U(p.fix,l),m=Math.min(10,Math.max(3,p.fix.accuracy,l.accuracy));if(a<m)continue;if(i+=a,d>0&&a/d>=0.5)c+=d;o.push({fix:l,cumM:i})}let s=o[o.length-1],f=null,v=null;if(s){let l=s.fix.timestamp-n*1000,p=o.find((a)=>a.fix.timestamp>=l)??s,h=s.cumM-p.cumM,d=(s.fix.timestamp-p.fix.timestamp)/1000;if(h>=20&&d>0)v=h/d,f=d/(h/1000)}return{distanceM:i,movingS:c,paceSPerKm:f,averagePaceSPerKm:i>=50&&c>0?c/(i/1000):null,speedMps:v,accuracyM:r.length?r[r.length-1].accuracy:e.length?e[e.length-1].accuracy??null:null,fixes:r.length}}function Te(e){if(!e||!Number.isFinite(e)||e>3600)return"–";let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Ce(e){return e&&Number.isFinite(e)?(e*3.6).toFixed(1):"–"}var M={distanceM:0,movingS:0,paceSPerKm:null,averagePaceSPerKm:null,speedMps:null,accuracyM:null,fixes:0};function Ne(e){let t=e.location,r=e.intervalMs??3000,n=M,o=null,i=()=>typeof document<"u"&&document.visibilityState==="hidden";async function c(){let f=await t.readRecording();return n=k(f,e),e.onUpdate?.(n),n}function u(){s(),o=setInterval(()=>{if(!i())c().catch(()=>{})},r)}function s(){if(o)clearInterval(o);o=null}return{get stats(){return n},async start(){return await t.startRecording({enableHighAccuracy:!0,...e.locationOptions}),n=M,e.onUpdate?.(n),u(),n},async attach(){let f=await t.getRecordingState().catch(()=>null);if(!f?.active)return null;if(await c().catch(()=>{}),!f.paused)u();return f},async pause(){s(),await t.pauseRecording(),await c().catch(()=>{})},async resume(){await t.resumeRecording(),u()},async stop(){s();let v=(await t.stopRecording())?.locations??[];return n=k(v,e),e.onUpdate?.(n),v},refresh:c}}var re=I,oe=q,ie=Y,w=K,ae=W,se=J,ce=V,ue=X,le=ee,fe=te,pe=_;function E(e){if(typeof e==="string")return e.trim()||null;if(!e||typeof e!=="object")return null;let t=e.url;return typeof t==="string"&&t.trim()?t:null}var de={async getInitialURL(){if(!await H())return null;return E(await P.getInitialURL?.())},onLink(e){let t=null,r=!1,n=()=>{if(r)return;t=P.onLink?.((o,i)=>{let c=E(o);if(c)e(c,{initial:i?.initial===!0})})??null};if(y()?.craft)n();else H().then(n);return()=>{r=!0,t?.()}}},me=G,ve=Q,he=Z,ye=j,be=z,we=ne;function y(){if(typeof window>"u")return;return window}function g(){let e=y()?.craft;if(!e||typeof e!=="object")return null;if(!("platform"in e)||e.platform!=="ios"&&e.platform!=="android")return null;let t="capabilities"in e?e.capabilities:void 0,r=t&&typeof t==="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).filter(([,n])=>typeof n==="boolean")):{};return{platform:e.platform,capabilities:r}}function R(){return g()!==null}function T(){if(typeof window>"u")return!1;let e=window;if(e.CraftAndroid)return!0;let t=typeof navigator>"u"?"":navigator.userAgent;return Boolean(e.webkit?.messageHandlers?.craft)&&/iPhone|iPad|iPod/.test(t)}function ge(e=2000){if(R()||T())return Promise.resolve(!0);let t=y(),r=t;if(!t||!(r?.craft||r?.webkit?.messageHandlers?.craft))return Promise.resolve(!1);return new Promise((n)=>{let o=()=>{clearTimeout(i),t.removeEventListener("craftReady",o),n(R())},i=setTimeout(o,e);t.addEventListener("craftReady",o,{once:!0})})}function H(e=15000){let t=y();if(t?.craft)return Promise.resolve(!0);let r=t;if(!t||!(T()||r?.webkit?.messageHandlers?.craft))return Promise.resolve(!1);return new Promise((n)=>{let o=()=>{clearTimeout(i),t.removeEventListener("craftReady",o),n(Boolean(t.craft))},i=setTimeout(o,e);t.addEventListener("craftReady",o)})}function xe(e){let t=y();if(!t)return()=>{};if(g()){let n=!1;return queueMicrotask(()=>{if(!n)e(new Event("craftReady"))}),()=>{n=!0}}let r=(n)=>{if(!g())return;t.removeEventListener("craftReady",r),e(n)};return t.addEventListener("craftReady",r),()=>t.removeEventListener("craftReady",r)}async function Ae(e){await w.impact("light");try{let t=await e();return await w.notification("success"),t}catch(t){throw await w.notification("error"),t}}var Oe={get nativeBridge(){return g()},biometrics:re,camera:oe,device:ie,haptics:w,lifecycle:ae,location:se,notifications:ce,permissions:ue,secureStorage:le,share:fe,appReview:pe,deepLinks:de,keepAwake:me,network:ve,pushNotifications:he,health:ye,liveActivities:be,watchConnectivity:we,isNativeMobile:R,whenNative:ge,onReady:xe,withFeedback:Ae};export{He as ROUTE_GAP_S,pe as appReview,re as biometrics,oe as camera,F as canGoBack,Ne as createRouteRecorder,D as deepLinkPath,de as deepLinks,ie as device,U as fixDistance,Pe as followDeepLinks,g as getNativeMobileBridge,Me as goBack,w as haptics,T as hasNativeMobileHost,ye as health,R as isNativeMobile,me as keepAwake,ae as lifecycle,be as liveActivities,se as location,Oe as mobile,ve as network,E as normalizeDeepLinkURL,ce as notifications,Se as observePageScroll,Le as observePullToRefresh,xe as onMobileReady,Te as paceLabel,b as pageScrollTop,ue as permissions,N as pullDistance,he as pushNotifications,k as routeStats,le as secureStorage,fe as share,Ce as speedLabel,B as usableFixes,we as watchConnectivity,H as whenBridgeReady,ge as whenNativeMobile,Ae as withNativeFeedback};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/mobile",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.33",
5
+ "version": "0.75.34",
6
6
  "description": "Craft-powered native mobile runtime for Stacks and STX applications",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "craft-native": ">=0.0.103"
36
36
  },
37
37
  "devDependencies": {
38
- "@stacksjs/build": "0.75.33",
38
+ "@stacksjs/build": "0.75.34",
39
39
  "better-dx": "^0.2.24"
40
40
  }
41
41
  }