@stacksjs/mobile 0.75.33 → 0.75.35
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.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appReview as
|
|
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.
|
|
5
|
+
"version": "0.75.35",
|
|
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.
|
|
38
|
+
"@stacksjs/build": "0.75.35",
|
|
39
39
|
"better-dx": "^0.2.24"
|
|
40
40
|
}
|
|
41
41
|
}
|