@absolutejs/absolute 0.20.0-beta.134 → 0.20.0-beta.135

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.
@@ -476,7 +476,7 @@ const promiseRealpath = fs.promises.realpath.bind(fs.promises);
476
476
  fs.promises.realpath = async (value, options) => remap(await promiseRealpath(value, options));
477
477
  `,sLe=(v)=>`exp+${v.toLowerCase().replaceAll(/[^a-z0-9]+/gu,"-")}`,aLe=(v,P,M)=>`${sLe(v)}://expo-development-client/?url=${encodeURIComponent(`http://${P}:${M}`)}`,A1t=(v)=>{let P=Bun.spawnSync(v,{killSignal:"SIGKILL",stderr:"ignore",stdout:"pipe",timeout:30000});return{exitCode:P.exitCode,stdout:P.stdout.toString()}},a0e=(v,P)=>{let M=P(["wslpath","-w",v]);if(M.exitCode!==0||!M.stdout.trim())throw Error(`Could not translate WSL path for Windows: ${v}`);return M.stdout.trim()},P1t=(v,P)=>{let M=Bun.hash(tLe(v)).toString(iLe);return tLe(P,"..","..","ExpoBuilds",M.slice(0,T1t))},D1t=(v,P,M,z,ce)=>{let ve=z([v,"devices"]);if(ve.exitCode!==0)throw Error("Could not inspect devices after the Expo Android build.");let qe=ve.stdout.split(/\r?\n/u).flatMap((vr)=>{let Dr=/^(\S+)\s+device$/u.exec(vr.trim());return Dr?.[1]?[Dr[1]]:[]}),at=ce?qe.find((vr)=>vr===ce):qe.find((vr)=>vr.startsWith("emulator-"))??qe[0];if(!at)throw Error(ce?"The selected Expo Android device is not connected after build.":"Expo Android build completed but no ready device was found.");let yt=(vr,Dr)=>{if(z([v,"-s",at,...vr]).exitCode!==0)throw Error(Dr)};yt(["reverse",`tcp:${M}`,`tcp:${M}`],"Expo Android Metro forwarding failed."),yt(["shell","am","force-stop",P],"Expo Android development-client reset failed.");let cr=()=>yt(["shell","am","start","-a","android.intent.action.VIEW","-d",aLe(P,"localhost",M),P],"Expo Android development-client launch failed.");return cr(),yt(["shell","sleep","1"],"Expo Android development-client readiness pause failed."),cr(),at};var I1t=(v,P,M,z,ce,ve,qe,at="development",yt=[])=>{let cr=a0e(v,ce),vr=P1t(v,P),Dr=a0e(vr,ce),xe=a0e(P,ce),Hn=(el)=>Buffer.from(el,"utf8").toString("base64"),Nt=sLe(M),Ot=Hn(w1t),cs=`Local\\AbsoluteJS.Expo.${Bun.hash(vr).toString(iLe)}`,Di=at==="bundle"?[]:["$adb = Join-Path $androidHome 'platform-tools\\adb.exe'","$deviceDeadline = [DateTime]::UtcNow.AddSeconds(60)","do { $readyDevices = @(& $adb devices) | Where-Object { $_ -match '\\tdevice$' } | ForEach-Object { ($_ -split '\\s+')[0] }; if (-not $readyDevices) { Start-Sleep -Milliseconds 500 } } while (-not $readyDevices -and [DateTime]::UtcNow -lt $deviceDeadline)",...qe?[`$serial = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(qe)}'))`,"if ($readyDevices -notcontains $serial) { throw 'The selected Expo Android device is not connected after build.' }"]:["$serial = $readyDevices | Where-Object { $_ -like 'emulator-*' } | Select-Object -First 1","if (-not $serial) { $serial = $readyDevices | Select-Object -First 1 }"],"if (-not $serial) { throw 'Expo Android build completed but no ready device was found.' }",...at==="release"?["$apk = Join-Path $mappedProject 'android\\app\\build\\outputs\\apk\\release\\app-release.apk'","$installOutput = Join-Path $env:TEMP ('absolutejs-adb-install-' + [Guid]::NewGuid().ToString('N') + '.out')","$installError = $installOutput + '.err'","$install = Start-Process -FilePath $adb -ArgumentList @('-s', $serial, 'install', '-r', $apk) -NoNewWindow -PassThru -RedirectStandardOutput $installOutput -RedirectStandardError $installError","if (-not $install.WaitForExit(900000)) { $install.Kill(); throw 'Expo Android release installation timed out after 15 minutes.' }","$install.WaitForExit()","$installText = ((Get-Content $installOutput -Raw -ErrorAction SilentlyContinue) + (Get-Content $installError -Raw -ErrorAction SilentlyContinue))","if ($installText) { Write-Output $installText.Trim() }","Remove-Item $installOutput, $installError -Force -ErrorAction SilentlyContinue","if ($install.ExitCode -ne 0 -and $installText -notmatch '(?m)^Success\\r?$') { throw 'Expo Android release installation failed.' }",`$installedPackage = @(& $adb -s $serial shell pm path '${M}')`,"if ($LASTEXITCODE -ne 0 -or $installedPackage -notmatch '^package:') { throw 'Expo Android release package verification failed.' }"]:[],`& $adb -s $serial reverse 'tcp:${ve}' 'tcp:${ve}'`,"if ($LASTEXITCODE -ne 0) { throw 'Expo Android port forwarding failed.' }",`& $adb -s $serial shell am force-stop '${M}'`,"if ($LASTEXITCODE -ne 0) { throw 'Expo Android application reset failed.' }",...at==="development"?[`$developmentUrl = '${Nt}://expo-development-client/?url=' + [Uri]::EscapeDataString('http://localhost:${ve}')`,`& $adb -s $serial shell am start -a android.intent.action.VIEW -d $developmentUrl '${M}'`,"if ($LASTEXITCODE -ne 0) { throw 'Expo Android development-client launch failed.' }","Start-Sleep -Milliseconds 1000",`& $adb -s $serial shell am start -a android.intent.action.VIEW -d $developmentUrl '${M}'`,"if ($LASTEXITCODE -ne 0) { throw 'Expo Android development-client retry failed.' }"]:[`& $adb -s $serial shell monkey -p '${M}' -c android.intent.category.LAUNCHER 1 | Out-Null`,"if ($LASTEXITCODE -ne 0) { throw 'Expo Android release launch failed.' }"]],Us=["$mappedProject = Join-Path ($drive + '\\') (Split-Path -Leaf $directory)","Set-Location $mappedProject","$hook = Join-Path $mappedProject '.absolutejs-preserve-subst.cjs'",`[IO.File]::WriteAllText($hook, [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Ot}')))`,"$env:ABSOLUTE_EXPO_PHYSICAL_ROOT = $directory","$env:ABSOLUTE_EXPO_MAPPED_ROOT = $mappedProject","$env:ABSOLUTE_EXPO_APP_ROOT = $mappedProject",'$env:NODE_OPTIONS = "--require=$hook"',"$env:GRADLE_OPTS = (($env:GRADLE_OPTS + ' -Dorg.gradle.daemon=false').Trim())","$autolinkingCache = Join-Path $mappedProject 'android\\build\\generated\\autolinking'","if ([IO.Directory]::Exists($autolinkingCache)) { [IO.Directory]::Delete($autolinkingCache, $true) }","$reactGeneratedResources = Join-Path $mappedProject 'android\\app\\build\\generated\\res\\react'","if ([IO.Directory]::Exists($reactGeneratedResources)) { [IO.Directory]::Delete($reactGeneratedResources, $true) }",...at==="development"?["$expo = Join-Path $mappedProject 'node_modules\\.bin\\expo.exe'","& $expo @expoArguments","if ($LASTEXITCODE -ne 0) { throw 'Expo Android native build failed.' }"]:["$gradle = Join-Path $mappedProject 'android\\gradlew.bat'","$androidProject = Join-Path $mappedProject 'android'",at==="bundle"?"& $gradle --no-daemon --console=plain -p $androidProject @gradleArguments bundleRelease":"& $gradle --no-daemon --console=plain -p $androidProject assembleRelease","if ($LASTEXITCODE -ne 0) { throw 'Expo Android release compilation failed.' }"],...Di].join("; "),Ha=["$ErrorActionPreference = 'Stop'","$ProgressPreference = 'SilentlyContinue'",`$source = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(cr)}'))`,`$directory = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(Dr)}'))`,`$androidHome = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(xe)}'))`,`$mutexName = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(cs)}'))`,`$expoArguments = @([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(JSON.stringify(z))}')) | ConvertFrom-Json)`,`$gradleArguments = @([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(JSON.stringify(yt))}')) | ConvertFrom-Json)`,"$env:ANDROID_HOME = $androidHome","$env:ANDROID_SDK_ROOT = $androidHome",`$env:NODE_ENV = '${at==="development"?"development":"production"}'`,...qe||at==="bundle"?[]:["$env:ORG_GRADLE_PROJECT_reactNativeArchitectures = 'x86_64'"],"$mutex = [Threading.Mutex]::new($false, $mutexName)","$mutexAcquired = $false","try {","try { $mutexAcquired = $mutex.WaitOne([TimeSpan]::FromMinutes(30)) } catch [Threading.AbandonedMutexException] { $mutexAcquired = $true }","if (-not $mutexAcquired) { throw 'Timed out waiting for another AbsoluteJS Expo Android build to release the managed Windows mirror.' }","New-Item -ItemType Directory -Force -Path $directory | Out-Null",`& robocopy.exe $source $directory /MIR /XD node_modules .expo .git .gradle .cxx .kotlin build /XF bun.lock bun.lockb .absolutejs-preserve-subst.cjs .absolutejs-source-lock.sha256 ${s0e} /NFL /NDL /NJH /NJS /NP`,"$copyExit = $LASTEXITCODE","if ($copyExit -ge 8) { exit $copyExit }","Set-Location $directory",`$buildStamp = Join-Path $directory '${s0e}'`,"Set-Content $buildStamp ([DateTime]::UtcNow.ToString('o')) -NoNewline",`$staleBefore = [DateTime]::UtcNow.AddDays(-${k1t()})`,`Get-ChildItem -LiteralPath (Split-Path -Parent $directory) -Directory -ErrorAction SilentlyContinue | Where-Object { -not [String]::Equals($_.FullName, $directory, [StringComparison]::OrdinalIgnoreCase) -and (Test-Path (Join-Path $_.FullName '.absolutejs-expo-project')) } | ForEach-Object { $stamp = Join-Path $_.FullName '${s0e}'; $lastBuild = if (Test-Path $stamp) { (Get-Item $stamp).LastWriteTimeUtc } else { $_.LastWriteTimeUtc }; if ($lastBuild -lt $staleBefore) { Remove-Item -LiteralPath $_.FullName -Recurse -Force -ErrorAction SilentlyContinue } }`,"$sourceLock = @('bun.lock', 'bun.lockb') | ForEach-Object { Join-Path $source $_ } | Where-Object { Test-Path $_ } | Select-Object -First 1","$sourceLockHash = if ($sourceLock) { (Get-FileHash $sourceLock -Algorithm SHA256).Hash } else { 'none' }","$lockMarker = Join-Path $directory '.absolutejs-source-lock.sha256'","$priorLockHash = if (Test-Path $lockMarker) { (Get-Content $lockMarker -Raw).Trim() } else { '' }","if ($priorLockHash -ne $sourceLockHash) { Remove-Item (Join-Path $directory 'bun.lock'), (Join-Path $directory 'bun.lockb') -Force -ErrorAction SilentlyContinue; Set-Content $lockMarker $sourceLockHash -NoNewline }","$bun = (Get-Command bun.exe -ErrorAction Stop).Source","& $bun install","if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }","$mirrorRoot = Split-Path -Parent $directory","$staleDrives = @(& subst.exe) | ForEach-Object { if ($_ -match '^([A-Z]:)\\\\: => (.+)$' -and [String]::Equals($Matches[2].TrimEnd('\\'), $mirrorRoot.TrimEnd('\\'), [StringComparison]::OrdinalIgnoreCase)) { $Matches[1] } }","foreach ($staleDrive in $staleDrives) { & subst.exe $staleDrive /D | Out-Null }","$drive = @('Z:', 'Y:', 'X:', 'W:', 'V:', 'U:', 'T:') | Where-Object { -not (Test-Path ($_ + '\\')) } | Select-Object -First 1","if (-not $drive) { throw 'AbsoluteJS could not reserve a temporary drive letter for the Expo Android build.' }","& subst.exe $drive $mirrorRoot","if ($LASTEXITCODE -ne 0) { throw 'AbsoluteJS could not create the short Expo Android build path.' }",`try { ${Us} } finally { Set-Location ($env:SystemDrive + '\\'); & subst.exe $drive /D | Out-Null }`,"} finally {","if ($mutexAcquired) { $mutex.ReleaseMutex() }","$mutex.Dispose()","}","exit 0"].join("; ");return["powershell.exe","-NoProfile","-EncodedCommand",Buffer.from(Ha,"utf16le").toString("base64")]};var N1t=(v)=>({ABSOLUTE_EXPO_DEVELOPMENT:"1",NODE_ENV:"development",...v.certificateAuthorityPath?{ABSOLUTE_EXPO_DEVELOPMENT_CA_PATH:v.certificateAuthorityPath}:{},...v.androidOrigin?{EXPO_PUBLIC_ABSOLUTE_DEV_ANDROID_ORIGIN:v.androidOrigin}:{},...v.iosOrigin?{EXPO_PUBLIC_ABSOLUTE_DEV_IOS_ORIGIN:v.iosOrigin}:{},...v.metroHost?{REACT_NATIVE_PACKAGER_HOSTNAME:v.metroHost}:{}}),oY=async(v)=>{let P=nLe(v,"node_modules",".bin","expo");try{return await g1t(P),P}catch{throw TypeError("Expo dependencies are not installed in the generated shell. Run `absolute mobile init --yes`.")}},rLe=(v,P)=>{if(v.engine!=="expo")throw TypeError("The Expo development controller requires Expo.");if(P.platforms.length===0&&P.metro==="external")throw TypeError("External Expo execution requires a target platform.");if([P.androidOrigin,P.iosOrigin].some((at)=>at&&new URL(at).protocol==="https:")&&!P.certificateAuthorityPath)throw TypeError("Expo HTTPS development requires the AbsoluteJS development CA certificate.");let z=N1t(P),ce={args:["start","--dev-client","--host","localhost","--port",String(P.metroPort)],env:z,role:"metro"},ve=P.platforms.length===0?void 0:{args:["prebuild","--clean","--no-install","--platform",P.platforms.length===2?"all":P.platforms[0]??"all"],env:z,role:"native-prepare"},qe=P.platforms.map((at)=>{let yt=at==="android"?P.androidDevice:P.iosDevice;return{args:[`run:${at}`,"--no-bundler",...yt?["--device",yt]:[]],env:z,platform:at,role:"native-build"}});return{commands:[...ve?[ve]:[],...P.metro==="external"?[]:[ce],...qe],metroPort:P.metroPort,project:v.nativeProjectDirectory}},T7=()=>new DOMException("Expo development aborted.","AbortError"),aY=(v,P)=>{let M=(z)=>{if(!z)return;let ce="";z.on("data",(ve)=>{ce+=ve.toString("utf8");let qe=ce.indexOf(`
478
478
  `);while(qe>=0)P(ce.slice(0,qe).replace(/\r$/u,"")),ce=ce.slice(qe+1),qe=ce.indexOf(`
479
- `)}),z.on("end",()=>{if(ce)P(ce)})};M(v.stdout),M(v.stderr)},QN=async(v)=>{if(v.exitCode!==null||v.killed)return;if(v.kill("SIGTERM"),await Promise.race([new Promise((P)=>v.once("exit",()=>P())),new Promise((P)=>setTimeout(P,S1t))]),v.exitCode===null)v.kill("SIGKILL")},c0e=(v)=>new Promise((P)=>{if(v.exitCode!==null){P(v.exitCode);return}v.once("exit",(M)=>P(M??1))}),dB=async(v,P,M,z)=>{let ce=v(P,M,{cwd:z.cwd,env:z.env??process.env,stdio:["ignore","pipe","pipe"]});aY(ce,z.log);let ve=()=>void QN(ce);z.signal?.addEventListener("abort",ve,{once:!0});let qe=await c0e(ce);if(z.signal?.removeEventListener("abort",ve),z.signal?.aborted)throw T7();return qe};var oLe=async(v)=>{let P=rLe(v.config,v),M=v.executable??await oY(P.project),z=v.spawnProcess??m1t,ce=v.host??XN(),ve=v.capture??A1t,qe=v.log??(()=>{return}),at={},yt=null,cr=async()=>{let li=yt;yt=null,await li?.close()},vr=(li,Xl,Jc={})=>{at[li]=(at[li]??0)+Xl,v.onPhaseTiming?.({durationMs:Xl,phase:li,...Jc})},Dr=(li)=>{v.onStateChange?.(li)};if(v.signal?.aborted)throw T7();let xe=P.commands.find((li)=>li.role==="native-prepare"),Hn=P.commands.find((li)=>li.role==="metro"),Nt=P.commands.filter((li)=>li.role==="native-build"),Ot=async(li)=>{Dr("preparing-native");let Xl=performance.now(),Jc=z(M,li.args,{cwd:P.project,env:{...process.env,...li.env},stdio:["ignore","pipe","pipe"]});aY(Jc,($u)=>{if($u)qe(`[prebuild] ${$u}`)});let pn=()=>void QN(Jc);v.signal?.addEventListener("abort",pn,{once:!0});let vg=await c0e(Jc);if(v.signal?.removeEventListener("abort",pn),v.signal?.aborted)throw T7();if(vg!==0)throw Dr("failed"),Error(`Expo native preparation exited with status ${vg}.`);vr("preparing-native",performance.now()-Xl)};if(xe)await Ot(xe);let cs=Hn!==void 0;if(cs)Dr("starting-metro");let Di=performance.now(),Us,Ha=0,el=[P.metroPort],of=(li)=>new Promise((Xl,Jc)=>{let pn=!1,vg=!1,$u=setTimeout(()=>{Jc(Error("Expo Metro did not become ready within 120 seconds."))},y1t);aY(li,(kr)=>{if(kr)qe(`[metro] ${kr}`);if(E1t(kr))vg=!0;if(!pn&&/(?:Waiting on|Metro waiting on|Dev server ready)/iu.test(kr))pn=!0,clearTimeout($u),Xl()}),li.once("exit",(kr)=>{if(pn)return;clearTimeout($u),Jc(new o0e(kr??1,vg))})}),ei=async()=>{if(!Hn)return;if(v.signal?.aborted)throw T7();Us=z(M,Hn.args,{cwd:P.project,env:{...process.env,...Hn.env},stdio:["ignore","pipe","pipe"]});try{await of(Us)}catch(li){if(!(li instanceof o0e)||!li.conflict||el.length>=v1t)throw li;await QN(Us);let Jc=await(v.allocateMetroPort??C1t)(el);if(!Number.isSafeInteger(Jc)||Jc<1||Jc>b1t||el.includes(Jc))throw Error("Could not allocate a distinct replacement Metro port.",{cause:li});el.push(Jc),Ha+=1,qe("Metro port was claimed during startup; retrying automatically on a new port."),P=rLe(v.config,{...v,metroPort:Jc}),Hn=P.commands.find((pn)=>pn.role==="metro"),Nt=P.commands.filter((pn)=>pn.role==="native-build"),await ei()}},ln=()=>{if(Us)QN(Us)};v.signal?.addEventListener("abort",ln,{once:!0});let u_=async(li)=>{if(v.signal?.aborted)throw T7();let{platform:Xl}=li;if(!Xl)throw TypeError("Expo native build command is missing a platform.");let Jc=Xl==="android"?"building-android":"building-ios";Dr(Jc);let pn=performance.now(),vg=Xl==="android"&&ce==="wsl"?I1t(P.project,v.androidRoot??nY(ce),v.config.appId,li.args,ve,P.metroPort,v.androidDevice):[M,...li.args];if(Xl==="android"&&ce==="wsl")qe("[android] Mirroring native inputs to the Windows host for accelerated Expo build and launch.");let[$u,...kr]=vg;if(!$u)throw Error("Expo native build command is empty.");let rS=z($u,kr,{cwd:P.project,env:{...process.env,...li.env},stdio:["ignore","pipe","pipe"]});aY(rS,(bg)=>{if(bg)qe(`[${Xl}] ${bg}`)});let Gc=()=>void QN(rS);v.signal?.addEventListener("abort",Gc,{once:!0});let Xf=await c0e(rS);if(v.signal?.removeEventListener("abort",Gc),v.signal?.aborted)throw T7();if(Xf!==0)throw Error(`Expo ${Xl} development build exited with status ${Xf}.`);if(Xl==="android"&&ce!=="wsl"){let bg=v.androidRoot??process.env.ANDROID_HOME??process.env.ANDROID_SDK_ROOT??nY(ce),$0=v.androidAdb??nLe(bg,"platform-tools",ce==="windows"?"adb.exe":"adb");D1t($0,v.config.appId,P.metroPort,ve,v.androidDevice),qe("Connected the Expo Android development client to Metro.")}if(Xl==="ios"&&v.certificateAuthorityPath&&v.iosOrigin&&new URL(v.iosOrigin).protocol==="https:"&&!v.iosDevice){Dr("enrolling-trust");let bg=performance.now(),$0={cwd:P.project,signal:v.signal,log:(Wi)=>Wi&&qe(`[ios-trust] ${Wi}`)},U2=await dB(z,"xcrun",["simctl","keychain","booted","add-root-cert",v.certificateAuthorityPath],$0);if(U2!==0)throw Error(`Expo iOS Simulator development CA trust exited with status ${U2}.`);await dB(z,"xcrun",["simctl","terminate","booted",v.config.appId],$0);let uP=await dB(z,"xcrun",["simctl","launch","booted",v.config.appId],$0);if(uP!==0)throw Error(`Expo iOS Simulator relaunch exited with status ${uP}.`);qe("Installed the AbsoluteJS development CA into the Expo iOS Simulator and relaunched the app."),vr("enrolling-trust",performance.now()-bg)}if(Xl==="ios"&&!v.iosDevice){let bg={cwd:P.project,signal:v.signal,log:(U2)=>U2&&qe(`[ios-connect] ${U2}`)};await dB(z,"xcrun",["simctl","terminate","booted",v.config.appId],bg);let $0=await dB(z,"xcrun",["simctl","openurl","booted",aLe(v.config.appId,v.metroHost??"localhost",P.metroPort)],bg);if($0!==0)throw Error(`Expo iOS Simulator Metro connection exited with status ${$0}.`);qe("Connected the Expo iOS Simulator development client to Metro.")}let Ea=performance.now()-pn;at[Jc]=Ea,v.onPhaseTiming?.({durationMs:Ea,phase:Jc})},So=async(li)=>{let[Xl,...Jc]=li;if(!Xl)return;await u_(Xl),await So(Jc)},RT=async()=>{if(!v.iosDevice||!v.certificateAuthorityPath||!v.iosOrigin||new URL(v.iosOrigin).protocol!=="https:")return;Dr("enrolling-trust");let li=performance.now();yt=await(v.startCaEnrollmentServer??iY)({certificateAuthorityPath:v.certificateAuthorityPath,displayHost:new URL(v.iosOrigin).hostname}),qe(`On the iOS device, open ${yt.url}, install the AbsoluteJS development CA profile, then enable it under Settings > General > About > Certificate Trust Settings. This public CA endpoint exists only for this dev session.`),vr("enrolling-trust",performance.now()-li)};try{if(await RT(),await ei(),cs)vr("starting-metro",performance.now()-Di,{...Ha>0?{reason:"metro-port-conflict",retryCount:Ha}:{}});await So(Nt),Dr("ready");let li=!1,Xl=Promise.resolve(),Jc={metroPort:P.metroPort,platforms:v.platforms,timings:at,close:async()=>{if(li)return;if(li=!0,v.signal?.removeEventListener("abort",ln),await Xl,Us)await QN(Us);await cr(),Dr("closed")},rebuild:()=>{let pn=Xl.then(async()=>{if(li)throw Error("The Expo development session is closed.");if(xe)await Ot(xe);return await So(Nt),Dr("ready"),Jc});return Xl=pn.then(()=>{return},()=>{return}),pn}};return Jc}catch(li){if(v.signal?.removeEventListener("abort",ln),Us)await QN(Us);throw await cr(),Dr("failed"),li}};import{access as BTt,mkdir as W0e,mkdtemp as JTt,readdir as x9e,readFile as xB,rename as bY,rm as TY,writeFile as V0e}from"fs/promises";import{createHash as TB}from"crypto";import{basename as UTt,dirname as kB,join as Gl,relative as z0e,resolve as zTt,sep as WTt}from"path";var O1t="0.8.0",F1t="0.9.3",l0e="0.7.0",cLe="0.0.11";var EEt=["@capacitor/core@8.5.0","@capacitor/app@8.1.1","@capacitor/browser@8.0.4","@capacitor/network@8.0.1","@capacitor/preferences@8.0.1","@capacitor/cli@8.5.0","@capacitor/android@8.5.0","@capacitor/ios@8.5.0",`@absolutejs/devices@${l0e}`,`@absolutejs/devices-capacitor@${O1t}`],wEt=[`@absolutejs/sync-capacitor@${F1t}`,"@capacitor-community/sqlite@8.1.1"];import{readFileSync as R1t}from"fs";import{join as M1t}from"path";var L1t="@absolutejs/auth",lLe="0.76.3",uLe="@absolutejs/auth-expo",_Le="0.0.6",fLe="2.31.0",pLe="@absolutejs/sync-expo",dLe="0.0.4";var j1t=["openid","profile"],B1t="@absolutejs/sync",mLe=(v)=>{try{return JSON.parse(R1t(M1t(v,"package.json"),"utf8"))}catch{return}},gLe=(v,P)=>{if(typeof v!=="object"||v===null)return!1;return[Reflect.get(v,"dependencies"),Reflect.get(v,"devDependencies"),Reflect.get(v,"optionalDependencies"),Reflect.get(v,"peerDependencies")].some((M)=>typeof M==="object"&&M!==null&&Object.hasOwn(M,P))},J1t=(v)=>{let P=v.deepLinkScheme??v.appId.toLowerCase();return{clientId:`absolutejs-native:${v.appId}`,issuer:v.productionOrigin,redirectUri:`${P}://auth/callback`,scopes:[...j1t]}};var u0e=(v)=>gLe(mLe(v),L1t),ZA=(v)=>gLe(mLe(v),B1t),cY=(v,P)=>u0e(v)?J1t(P):void 0;import{readFileSync as q1t}from"fs";import{dirname as $1t,join as kLe,resolve as CLe}from"path";var hLe=Symbol.for("@absolutejs/sync/client-runtime-transport"),yLe=globalThis,U1t=(v)=>typeof v==="object"&&v!==null&&Array.isArray(Reflect.get(v,"installations"))&&Array.isArray(Reflect.get(v,"clients")),NEt=(()=>{let v=yLe[hLe];if(U1t(v))return v;if(typeof v==="object"&&v!==null&&Array.isArray(Reflect.get(v,"installations")))return Reflect.set(v,"clients",[]),v;let P={clients:[],installations:[]};return Object.defineProperty(yLe,hLe,{configurable:!1,enumerable:!1,value:P,writable:!1}),P})();class NT extends Error{code;constructor(v,P){super(P);this.name="SyncLocalDataPolicyError",this.code=v}}class pE extends Error{code;storedVersion;targetVersion;constructor(v,P,M={}){super(P);this.name="SyncLocalStoreSchemaError",this.code=v,this.storedVersion=M.storedVersion,this.targetVersion=M.targetVersion}}var lY=(v,P)=>{if(!Number.isSafeInteger(v)||v<1)throw new pE("INVALID_PLAN",`${P} must be a positive safe integer`);return v},z1t=(v)=>("components"in v),vLe=(v,P)=>{if(v.length===0||v.trim()!==v||/^\*+$/.test(v)||v.includes("**"))throw new NT("INVALID_POLICY",`${P}.match must be an exact name or a non-empty glob without adjacent wildcards.`)},W1t=(v,P="localData")=>{if(v.maxBytesPerNamespace!==void 0&&(!Number.isSafeInteger(v.maxBytesPerNamespace)||v.maxBytesPerNamespace<1))throw new NT("INVALID_POLICY",`${P}.maxBytesPerNamespace must be a positive safe integer.`);for(let[M,z]of(v.collections??[]).entries()){if(vLe(z.match,`${P}.collections[${M}]`),z.maxAgeMs!==void 0&&(!Number.isSafeInteger(z.maxAgeMs)||z.maxAgeMs<1))throw new NT("INVALID_POLICY",`${P}.collections[${M}].maxAgeMs must be a positive safe integer.`);if(z.persistence==="memory-only"&&z.protection==="required")throw new NT("INVALID_POLICY",`${P}.collections[${M}] cannot require at-rest protection when it is memory-only.`);if(z.sensitivity!==void 0&&z.sensitivity!=="public"&&z.protection!=="required"&&z.persistence!=="memory-only")throw new NT("INVALID_POLICY",`${P}.collections[${M}] declares ${z.sensitivity} data without required protection or memory-only persistence.`)}for(let[M,z]of(v.mutations??[]).entries()){if(vLe(z.match,`${P}.mutations[${M}]`),z.conflict!==void 0&&z.conflict.strategy!=="client-wins"&&z.conflict.strategy!=="manual"&&z.conflict.strategy!=="server-wins")throw new NT("INVALID_POLICY",`${P}.mutations[${M}].conflict.strategy is invalid.`);if(z.conflict?.maxAttempts!==void 0&&(!Number.isSafeInteger(z.conflict.maxAttempts)||z.conflict.maxAttempts<1))throw new NT("INVALID_POLICY",`${P}.mutations[${M}].conflict.maxAttempts must be a positive safe integer.`);if(z.conflict?.maxAttempts!==void 0&&z.conflict.strategy!=="client-wins")throw new NT("INVALID_POLICY",`${P}.mutations[${M}].conflict.maxAttempts is only valid for client-wins.`);if(z.persistence==="memory-only"&&z.protection==="required")throw new NT("INVALID_POLICY",`${P}.mutations[${M}] cannot require at-rest protection when it is memory-only.`);if(z.sensitivity!==void 0&&z.sensitivity!=="public"&&z.protection!=="required"&&z.persistence!=="memory-only")throw new NT("INVALID_POLICY",`${P}.mutations[${M}] declares ${z.sensitivity} arguments without required protection.`)}return v};var V1t=(v={version:1})=>{let P=z1t(v)?[...v.components]:[{...v,id:"@absolutejs/app"}],M=new Set;for(let z of P){if(typeof z.id!=="string"||z.id.trim()!==z.id||z.id.length===0)throw new pE("INVALID_PLAN","Sync schema component id must be non-empty and trimmed");if(M.has(z.id))throw new pE("INVALID_PLAN",`Sync schema component "${z.id}" is declared more than once`);if(M.add(z.id),z.localData)W1t(z.localData,`${z.id}.localData`)}return P.sort((z,ce)=>z.id.localeCompare(ce.id))};var SLe=(v,P={version:1})=>{let M=V1t(P).map((ve)=>{let qe=bLe(ve.version,ve);return{id:ve.id,...bLe(v[ve.id]??qe.minimumCompatibleVersion,ve)}}),z=new Set(M.map((ve)=>ve.id)),ce=Object.keys(v).filter((ve)=>!z.has(ve)).sort();return{components:M,orphanedComponents:ce}};var bLe=(v,P={version:1})=>{lY(v,"Stored Sync schema version");let M=lY(P.version,"Target Sync schema version"),z=[...P.migrations??[]].sort((yt,cr)=>yt.toVersion-cr.toVersion),ce=new Set;for(let yt of z){if(lY(yt.toVersion,"Sync migration toVersion"),ce.has(yt.toVersion))throw new pE("INVALID_PLAN",`Sync migration ${yt.toVersion} is declared more than once`);ce.add(yt.toVersion)}let ve=z[0]?z[0].toVersion-1:M,qe=lY(P.minimumCompatibleVersion??ve,"Minimum compatible Sync schema version");if(qe>M)throw new pE("INVALID_PLAN","Minimum compatible Sync schema version cannot exceed its target");if(v>M)throw new pE("SCHEMA_TOO_NEW",`Stored Sync schema ${v} is newer than this runtime's schema ${M}`,{storedVersion:v,targetVersion:M});if(v<qe)throw new pE("SCHEMA_TOO_OLD",`Stored Sync schema ${v} is older than the minimum compatible schema ${qe}`,{storedVersion:v,targetVersion:M});let at=[];for(let yt=v+1;yt<=M;yt++){let cr=z.find((vr)=>vr.toVersion===yt);if(cr===void 0)throw new pE("MIGRATION_MISSING",`Sync migration ${yt-1} -> ${yt} is missing`,{storedVersion:v,targetVersion:M});at.push(cr)}return{minimumCompatibleVersion:qe,steps:at,targetVersion:M}};var C7=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),_0e=(v)=>{try{let P=JSON.parse(q1t(v,"utf8"));return C7(P)?P:void 0}catch{return}},TLe=(v)=>{let P=Reflect.get(v,"absolutejs");if(!C7(P))return;let M=Reflect.get(P,"sync");if(!C7(M))return;return Reflect.get(M,"localSchema")},H1t=(v,P)=>{let M=CLe(v);while(!0){let z=kLe(M,"node_modules",P,"package.json"),ce=_0e(z);if(ce&&Reflect.get(ce,"name")===P)return z;let ve=$1t(M);if(ve===M)return;M=ve}},bf=(v,P)=>TypeError(`Invalid AbsoluteJS Sync schema metadata for ${v}: ${P}`),k7=(v,P,M)=>{if(typeof v!=="number"||!Number.isSafeInteger(v)||v<1)throw bf(P,`${M} must be a positive safe integer.`);return v},x7=(v,P,M)=>{if(typeof v!=="string"||v.trim()!==v||v.length===0)throw bf(P,`${M} must be a non-empty trimmed string.`);return v},KN=(v,P,M)=>{if(!C7(v))throw bf(P,M);return v},b1=(v,P)=>v[P],f0e=(v,P,M)=>{if(v===null||typeof v==="string"||typeof v==="boolean")return v;if(typeof v==="number"&&Number.isFinite(v))return v;if(Array.isArray(v))return v.map((z)=>f0e(z,P,M));if(C7(v))return Object.fromEntries(Object.entries(v).map(([z,ce])=>[z,f0e(ce,P,M)]));throw bf(P,`${M} must be JSON-safe.`)},G1t=(v,P,M)=>{let z=KN(v,P,`migration operation ${M} must be an object.`),ce=Reflect.get(z,"type"),ve=x7(Reflect.get(z,"collection"),P,`operation ${M}.collection`);if(ce==="delete-collection")return{collection:ve,type:ce};if(ce==="rename-field")return{collection:ve,from:x7(Reflect.get(z,"from"),P,`operation ${M}.from`),to:x7(Reflect.get(z,"to"),P,`operation ${M}.to`),type:ce};let qe=x7(Reflect.get(z,"field"),P,`operation ${M}.field`);if(ce==="remove-field")return{collection:ve,field:qe,type:ce};if(ce==="set-default")return{collection:ve,field:qe,type:ce,value:f0e(Reflect.get(z,"value"),P,`operation ${M}.value`)};throw bf(P,`operation ${M}.type is not supported.`)},X1t=(v,P,M)=>{let z=KN(v,P,`migration ${M} must be an object.`),ce=new Set(["operations","toVersion"]),ve=Object.keys(z).find((yt)=>!ce.has(yt));if(ve)throw bf(P,`migration ${M}.${ve} is not declarative metadata.`);let qe=Reflect.get(z,"operations");if(qe!==void 0&&!Array.isArray(qe))throw bf(P,`migration ${M}.operations must be an array.`);return{operations:(Array.isArray(qe)?qe:[]).map((yt,cr)=>G1t(yt,P,cr)),toVersion:k7(Reflect.get(z,"toVersion"),P,`migration ${M}.toVersion`)}},Q1t=(v,P)=>{let M=KN(v,P,"localData must be an object."),z=new Set(["collections","maxBytesPerNamespace","mutations"]),ce=Object.keys(M).find((vr)=>!z.has(vr));if(ce)throw bf(P,`localData.${ce} is not supported.`);let ve=Reflect.get(M,"collections"),qe=Reflect.get(M,"mutations");if(ve!==void 0&&!Array.isArray(ve))throw bf(P,"localData.collections must be an array.");if(qe!==void 0&&!Array.isArray(qe))throw bf(P,"localData.mutations must be an array.");let at=Array.isArray(ve)?ve.map((vr,Dr)=>{let xe=KN(vr,P,`localData.collections[${Dr}] must be an object.`),Hn=new Set(["evictionPriority","match","maxAgeMs","onProtectionUnavailable","persistence","protection","sensitivity"]),Nt=Object.keys(xe).find((ei)=>!Hn.has(ei));if(Nt)throw bf(P,`localData.collections[${Dr}].${Nt} is not supported.`);let Ot=x7(Reflect.get(xe,"match"),P,`localData.collections[${Dr}].match`),cs=b1(xe,"persistence"),Di=b1(xe,"sensitivity"),Us=b1(xe,"protection"),Ha=b1(xe,"onProtectionUnavailable"),el=b1(xe,"evictionPriority"),of=b1(xe,"maxAgeMs");if(cs!==void 0&&cs!=="durable"&&cs!=="memory-only")throw bf(P,`localData.collections[${Dr}].persistence is invalid.`);if(Di!==void 0&&Di!=="public"&&Di!=="private"&&Di!=="secret")throw bf(P,`localData.collections[${Dr}].sensitivity is invalid.`);if(Us!==void 0&&Us!=="none"&&Us!=="required")throw bf(P,`localData.collections[${Dr}].protection is invalid.`);if(Ha!==void 0&&Ha!=="error"&&Ha!=="memory-only")throw bf(P,`localData.collections[${Dr}].onProtectionUnavailable is invalid.`);if(el!==void 0&&el!=="critical"&&el!=="normal"&&el!=="disposable")throw bf(P,`localData.collections[${Dr}].evictionPriority is invalid.`);return{match:Ot,...Di?{sensitivity:Di}:{},...cs?{persistence:cs}:{},...Us?{protection:Us}:{},...Ha?{onProtectionUnavailable:Ha}:{},...el?{evictionPriority:el}:{},...of===void 0?{}:{maxAgeMs:k7(of,P,`localData.collections[${Dr}].maxAgeMs`)}}}):void 0,yt=Array.isArray(qe)?qe.map((vr,Dr)=>{let xe=KN(vr,P,`localData.mutations[${Dr}] must be an object.`),Hn=new Set(["conflict","match","onProtectionUnavailable","persistence","protection","sensitivity"]),Nt=Object.keys(xe).find((of)=>!Hn.has(of));if(Nt)throw bf(P,`localData.mutations[${Dr}].${Nt} is not supported.`);let Ot=b1(xe,"protection"),cs=b1(xe,"sensitivity"),Di=b1(xe,"persistence"),Us=b1(xe,"onProtectionUnavailable"),Ha=b1(xe,"conflict"),el;if(Ha!==void 0){let of=KN(Ha,P,`localData.mutations[${Dr}].conflict must be an object.`),ei=Object.keys(of).find((So)=>So!=="maxAttempts"&&So!=="strategy");if(ei)throw bf(P,`localData.mutations[${Dr}].conflict.${ei} is not supported.`);let ln=b1(of,"strategy");if(ln!=="client-wins"&&ln!=="manual"&&ln!=="server-wins")throw bf(P,`localData.mutations[${Dr}].conflict.strategy is invalid.`);let u_=b1(of,"maxAttempts");if(u_!==void 0&&ln!=="client-wins")throw bf(P,`localData.mutations[${Dr}].conflict.maxAttempts requires client-wins.`);el={strategy:ln,...u_===void 0?{}:{maxAttempts:k7(u_,P,`localData.mutations[${Dr}].conflict.maxAttempts`)}}}if(Ot!==void 0&&Ot!=="none"&&Ot!=="required")throw bf(P,`localData.mutations[${Dr}].protection is invalid.`);if(cs!==void 0&&cs!=="public"&&cs!=="private"&&cs!=="secret")throw bf(P,`localData.mutations[${Dr}].sensitivity is invalid.`);if(Us!==void 0&&Us!=="error"&&Us!=="memory-only")throw bf(P,`localData.mutations[${Dr}].onProtectionUnavailable is invalid.`);if(Di!==void 0&&Di!=="durable"&&Di!=="memory-only")throw bf(P,`localData.mutations[${Dr}].persistence is invalid.`);return{match:x7(Reflect.get(xe,"match"),P,`localData.mutations[${Dr}].match`),...el?{conflict:el}:{},...cs?{sensitivity:cs}:{},...Us?{onProtectionUnavailable:Us}:{},...Di?{persistence:Di}:{},...Ot?{protection:Ot}:{}}}):void 0,cr=Reflect.get(M,"maxBytesPerNamespace");return{...at?{collections:at}:{},...yt?{mutations:yt}:{},...cr===void 0?{}:{maxBytesPerNamespace:k7(cr,P,"localData.maxBytesPerNamespace")}}},xLe=(v,P)=>{let M=KN(P,v,"localSchema must be an object."),z=new Set(["localData","migrations","minimumCompatibleVersion","version"]),ce=Object.keys(M).find((Dr)=>!z.has(Dr));if(ce)throw bf(v,`${ce} is not supported.`);let ve=k7(Reflect.get(M,"version"),v,"version"),qe=Reflect.get(M,"minimumCompatibleVersion"),at=qe===void 0?Math.max(1,ve-2):k7(qe,v,"minimumCompatibleVersion"),yt=Reflect.get(M,"migrations"),cr=Reflect.get(M,"localData");if(yt!==void 0&&!Array.isArray(yt))throw bf(v,"migrations must be an array.");let vr=Array.isArray(yt)?yt:void 0;return{id:v,...cr===void 0?{}:{localData:Q1t(cr,v)},minimumCompatibleVersion:at,...Array.isArray(vr)?{migrations:vr.map((Dr,xe)=>X1t(Dr,v,xe))}:{},version:ve}},K1t=(v)=>[Reflect.get(v,"dependencies"),Reflect.get(v,"optionalDependencies"),Reflect.get(v,"devDependencies"),Reflect.get(v,"peerDependencies")].flatMap((P)=>C7(P)?Object.keys(P):[]).filter((P,M,z)=>z.indexOf(P)===M).sort(),E7=(v)=>{let P=kLe(CLe(v),"package.json"),M=_0e(P);if(!M)return{components:[{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}],sources:[]};let z=TLe(M),ce=[z===void 0?{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}:xLe("@absolutejs/app",z)],ve=[{id:"@absolutejs/app",manifestPath:P}];for(let qe of K1t(M)){let at=H1t(v,qe);if(!at)continue;let yt=_0e(at);if(!yt)continue;let cr=TLe(yt);if(cr===void 0)continue;ce.push(xLe(qe,cr)),ve.push({id:qe,manifestPath:at})}return ce.sort((qe,at)=>qe.id.localeCompare(at.id)),ve.sort((qe,at)=>qe.id.localeCompare(at.id)),SLe({},{components:ce}),{components:ce,sources:ve}};var V0=hvt(i9e());import{existsSync as ASt,readFileSync as F0e}from"fs";import{extname as PSt,join as R0e,relative as DSt,resolve as N7}from"path";import{fileURLToPath as ISt}from"url";var s9e="@absolutejs/devices",NSt=["keyboard","systemBars"],OSt={capacitor:"@absolutejs/devices-capacitor",expo:"@absolutejs/devices-expo"},FSt=new Bun.Glob("**/*.{js,jsx,ts,tsx,svelte,vue}"),RSt=new Set([".absolutejs",".git",".test-builds",".test-shards","build","dist","node_modules","test","tests"]),a9e=/^[A-Za-z_$][\w$]*$/u,MSt=(v)=>new RegExp(`^@absolutejs/devices-${v}/[a-z][a-z0-9-]*$`,"u"),LSt=(v)=>v==="capacitor"?/^@capacitor\/[a-z][a-z0-9-]*@\d+\.\d+\.\d+$/u:/^(?:expo-[a-z][a-z0-9-]*|@react-native-[a-z0-9-]+\/[a-z][a-z0-9-]*)@\d+\.\d+\.\d+$/u,jSt=(v)=>v==="capacitor"?"Capacitor":"Expo",BSt=/^android\.permission\.[A-Z][A-Z0-9_]*$/u,JSt=new Set(["camera","location-always","location-when-in-use","photo-library","photo-library-add"]),USt={NSPrivacyAccessedAPICategoryFileTimestamp:new Set(["C617.1"])},mY=["NSPrivacyAccessedAPICategoryFileTimestamp"],L2=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),M0e=(v)=>{let P=JSON.parse(F0e(v,"utf8"));if(!L2(P))throw TypeError(`${v} must contain an object.`);return P},o9e=(v,P)=>{if(typeof v!=="string"||v.length===0)throw TypeError(`${P} must be a non-empty string.`);return v},zSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let{permissions:M}=v;if(!Array.isArray(M)||!M.every((z)=>typeof z==="string"&&BSt.test(z)))throw TypeError(`${P}.permissions must contain Android permission names.`);return[...M]},WSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let M={};for(let z of mY){let ce=v[z];if(ce===void 0)continue;let ve=USt[z];if(!Array.isArray(ce)||ce.length===0||!ce.every((qe)=>typeof qe==="string"&&ve.has(qe)))throw TypeError(`${P} contains an unsupported API or reason.`);M[z]=[...ce]}if(Object.keys(v).some((z)=>!mY.some((ce)=>ce===z)))throw TypeError(`${P} contains an unsupported API or reason.`);return M},VSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let{privacyAccessedApis:M,pushNotifications:z,systemBars:ce,usageDescriptions:ve}=v;if(z!==void 0&&z!==!0)throw TypeError(`${P}.pushNotifications must be true.`);if(ce!==void 0&&ce!==!0)throw TypeError(`${P}.systemBars must be true.`);if(ve!==void 0&&(!Array.isArray(ve)||!ve.every((at)=>typeof at==="string"&&JSt.has(at))))throw TypeError(`${P}.usageDescriptions contains an unsupported purpose.`);let qe=WSt(M,`${P}.privacyAccessedApis`);return{...qe===void 0?{}:{privacyAccessedApis:qe},...z===!0?{pushNotifications:!0}:{},...ce===!0?{systemBars:!0}:{},...ve===void 0?{}:{usageDescriptions:[...ve]}}},qSt=(v,P,M)=>{if(!a9e.test(v))throw TypeError("Device capability names must be identifiers.");if(!L2(P))throw TypeError(`Device capability ${v} must be an object.`);let z=o9e(P.factory,`${v}.factory`),ce=o9e(P.module,`${v}.module`);if(!a9e.test(z))throw TypeError(`${v}.factory must be a JavaScript identifier.`);if(!MSt(M).test(ce))throw TypeError(`${v}.module must be an official devices-${M} subpath.`);if(!Array.isArray(P.packages)||!P.packages.every((yt)=>typeof yt==="string"&&LSt(M).test(yt)))throw TypeError(`${v}.packages must contain exact official ${jSt(M)} package versions.`);let{plugins:ve}=P;if(ve!==void 0&&(!Array.isArray(ve)||!ve.every((yt)=>typeof yt==="string"&&/^expo-[a-z][a-z0-9-]*$/u.test(yt))))throw TypeError(`${v}.plugins must contain Expo config plugin names.`);let qe,{native:at}=P;if(at!==void 0){if(!L2(at))throw TypeError(`${v}.native must be an object.`);let{android:yt,ios:cr}=at,vr=zSt(yt,`${v}.native.android`),Dr=VSt(cr,`${v}.native.ios`);qe={...vr===void 0?{}:{android:{permissions:vr}},...Dr===void 0?{}:{ios:Dr}}}return{factory:z,module:ce,...qe===void 0?{}:{native:qe},...ve===void 0?{}:{plugins:[...ve]},packages:[...P.packages]}},e6=(v)=>{let P=v.capabilities.reduce((M,z)=>{for(let ce of mY){let ve=v.providers[z]?.native?.ios?.privacyAccessedApis?.[ce]??[];if(ve.length===0)continue;let qe=M[ce]??new Set;for(let at of ve)qe.add(at);M[ce]=qe}return M},{});return{androidPermissions:[...new Set(v.capabilities.flatMap((M)=>v.providers[M]?.native?.android?.permissions??[]))].sort(),iosPrivacyAccessedApis:mY.flatMap((M)=>{let z=P[M];return z?[{api:M,reasons:[...z].sort()}]:[]}),iosPushNotifications:v.capabilities.some((M)=>v.providers[M]?.native?.ios?.pushNotifications===!0),iosSystemBars:v.capabilities.some((M)=>v.providers[M]?.native?.ios?.systemBars===!0),iosUsageDescriptions:[...new Set(v.capabilities.flatMap((M)=>v.providers[M]?.native?.ios?.usageDescriptions??[]))].sort()}},c9e=(v,P="capacitor")=>{let M=OSt[P],z=R0e(N7(v),"node_modules",M,"package.json");try{F0e(z,"utf8")}catch{z=ISt(import.meta.resolve(`${M}/package.json`))}let ce=M0e(z),{absolutejs:ve}=ce,qe=L2(ve)?ve.devices:void 0;if(!L2(qe)||qe.format!==1||qe.provider!==P||!L2(qe.capabilities))throw TypeError(`${M} does not publish supported capability metadata.`);let at=Object.entries(qe.capabilities).map(([yt,cr])=>({name:yt,provider:qSt(yt,cr,P)}));return Object.fromEntries(at.sort((yt,cr)=>yt.name.localeCompare(cr.name)).map(({name:yt,provider:cr})=>[yt,cr]))},$St=(v)=>v.split("/").some((P)=>RSt.has(P)),HSt=(v,P)=>{let M=new Set,z=new Set,ce=(at)=>{if(V0.default.isImportDeclaration(at)&&V0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===s9e&&!at.importClause?.isTypeOnly){let yt=at.importClause?.namedBindings;if(yt&&V0.default.isNamedImports(yt)){for(let cr of yt.elements)if(!cr.isTypeOnly)M.add((cr.propertyName??cr.name).text)}if(yt&&V0.default.isNamespaceImport(yt))z.add(yt.name.text)}if(V0.default.isExportDeclaration(at)&&!at.isTypeOnly&&at.moduleSpecifier!==void 0&&V0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===s9e&&at.exportClause&&V0.default.isNamedExports(at.exportClause)){for(let yt of at.exportClause.elements)if(!yt.isTypeOnly)M.add((yt.propertyName??yt.name).text)}if(V0.default.isPropertyAccessExpression(at)&&V0.default.isIdentifier(at.expression)&&z.has(at.expression.text))M.add(at.name.text);V0.default.forEachChild(at,ce)},ve=PSt(P).toLowerCase(),qe=ve===".svelte"||ve===".vue"?[...v.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/giu)].map((at)=>at[1]).filter((at)=>at!==void 0):[v];for(let[at,yt]of qe.entries())ce(V0.default.createSourceFile(`${P}#script-${at}`,yt,V0.default.ScriptTarget.Latest,!0,V0.default.ScriptKind.TSX));return M},l9e=(v,P)=>{let M=QSt(P,GSt(v)),z=P.requiredPackages.filter((ve)=>{let qe=ve.lastIndexOf("@"),at=ve.slice(0,qe);if(M.includes(ve))return!1;try{return M0e(R0e(N7(v),"node_modules",at,"package.json")).version!==ve.slice(qe+1)}catch{return!0}}),ce=[...M,...z];if(ce.length>0)throw TypeError(`Device capabilities ${P.capabilities.join(", ")} require ${ce.join(", ")}. Run absolute mobile sync and approve the detected capability plugins.`)},GSt=(v)=>{let P=M0e(R0e(N7(v),"package.json")),M=new Set;for(let z of["dependencies","devDependencies"]){let ce=P[z];if(L2(ce))for(let ve of Object.keys(ce))M.add(ve)}return M},XSt=(v,P=c9e(v))=>{let M=N7(v);if(!ASt(M))return[];let z=new Set(Object.keys(P)),ce=new Set;for(let ve of FSt.scanSync({cwd:M})){let qe=DSt(M,N7(M,ve)).replaceAll("\\","/");if($St(qe))continue;let at=F0e(N7(M,qe),"utf8");for(let yt of HSt(at,qe))if(z.has(yt))ce.add(yt)}return[...ce].sort()},QSt=(v,P)=>v.requiredPackages.filter((M)=>{let z=M.slice(0,M.lastIndexOf("@"));return!P.has(z)});var rP=(v,P="capacitor")=>{let M=c9e(v,P),z=XSt(v,M);for(let ve of NSt)if(M[ve]&&!z.includes(ve))z.push(ve);z.sort();let ce={};for(let ve of z){let qe=M[ve];if(qe)ce[ve]=qe}return{capabilities:z,providers:ce,requiredPackages:[...new Set(z.flatMap((ve)=>ce[ve]?.packages??[]))].sort()}};import{createHash as YSt}from"crypto";var KSt=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),L0e=(v)=>{if(Array.isArray(v))return v.map(L0e);if(!KSt(v))return v;return Object.fromEntries(Object.keys(v).sort().map((P)=>[P,L0e(v[P])]))};var u9e=(v)=>JSON.stringify(L0e(v));var ZSt=2,eTt=1,tTt=(v)=>({appId:v.config.appId,auth:v.auth??null,deepLinks:{hosts:v.config.deepLinkHosts,...v.config.deepLinkScheme?{scheme:v.config.deepLinkScheme}:{}},deviceCapabilities:v.deviceCapabilities,engine:v.config.engine,...v.config.engine==="expo"?{expoEmbeddedAssetsAbi:1}:{},format:eTt,shellAbi:ZSt,syncSchema:v.syncSchema??null,updates:v.config.updates??null}),rTt=(v)=>YSt("sha256").update(u9e(v)).digest("hex"),gY=(v,P)=>{let M=cY(P,v),z=M!==void 0&&ZA(P),ce=z?E7(P):void 0,ve=rP(P,v.engine),qe=tTt({...M?{auth:M}:{},config:v,deviceCapabilities:ve,...ce?{syncSchema:ce}:{}});return{auth:M,descriptor:qe,deviceCapabilities:ve,fingerprint:rTt(qe),sync:z,syncSchema:ce}};import{join as t6}from"path";var bB=`// Generated by AbsoluteJS. Edit absolute.config.ts, then run absolute mobile sync.
479
+ `)}),z.on("end",()=>{if(ce)P(ce)})};M(v.stdout),M(v.stderr)},QN=async(v)=>{if(v.exitCode!==null||v.killed)return;if(v.kill("SIGTERM"),await Promise.race([new Promise((P)=>v.once("exit",()=>P())),new Promise((P)=>setTimeout(P,S1t))]),v.exitCode===null)v.kill("SIGKILL")},c0e=(v)=>new Promise((P)=>{if(v.exitCode!==null){P(v.exitCode);return}v.once("exit",(M)=>P(M??1))}),dB=async(v,P,M,z)=>{let ce=v(P,M,{cwd:z.cwd,env:z.env??process.env,stdio:["ignore","pipe","pipe"]});aY(ce,z.log);let ve=()=>void QN(ce);z.signal?.addEventListener("abort",ve,{once:!0});let qe=await c0e(ce);if(z.signal?.removeEventListener("abort",ve),z.signal?.aborted)throw T7();return qe};var oLe=async(v)=>{let P=rLe(v.config,v),M=v.executable??await oY(P.project),z=v.spawnProcess??m1t,ce=v.host??XN(),ve=v.capture??A1t,qe=v.log??(()=>{return}),at={},yt=null,cr=async()=>{let li=yt;yt=null,await li?.close()},vr=(li,Xl,Jc={})=>{at[li]=(at[li]??0)+Xl,v.onPhaseTiming?.({durationMs:Xl,phase:li,...Jc})},Dr=(li)=>{v.onStateChange?.(li)};if(v.signal?.aborted)throw T7();let xe=P.commands.find((li)=>li.role==="native-prepare"),Hn=P.commands.find((li)=>li.role==="metro"),Nt=P.commands.filter((li)=>li.role==="native-build"),Ot=async(li)=>{Dr("preparing-native");let Xl=performance.now(),Jc=z(M,li.args,{cwd:P.project,env:{...process.env,...li.env},stdio:["ignore","pipe","pipe"]});aY(Jc,($u)=>{if($u)qe(`[prebuild] ${$u}`)});let pn=()=>void QN(Jc);v.signal?.addEventListener("abort",pn,{once:!0});let vg=await c0e(Jc);if(v.signal?.removeEventListener("abort",pn),v.signal?.aborted)throw T7();if(vg!==0)throw Dr("failed"),Error(`Expo native preparation exited with status ${vg}.`);vr("preparing-native",performance.now()-Xl)};if(xe)await Ot(xe);let cs=Hn!==void 0;if(cs)Dr("starting-metro");let Di=performance.now(),Us,Ha=0,el=[P.metroPort],of=(li)=>new Promise((Xl,Jc)=>{let pn=!1,vg=!1,$u=setTimeout(()=>{Jc(Error("Expo Metro did not become ready within 120 seconds."))},y1t);aY(li,(kr)=>{if(kr)qe(`[metro] ${kr}`);if(E1t(kr))vg=!0;if(!pn&&/(?:Waiting on|Metro waiting on|Dev server ready)/iu.test(kr))pn=!0,clearTimeout($u),Xl()}),li.once("exit",(kr)=>{if(pn)return;clearTimeout($u),Jc(new o0e(kr??1,vg))})}),ei=async()=>{if(!Hn)return;if(v.signal?.aborted)throw T7();Us=z(M,Hn.args,{cwd:P.project,env:{...process.env,...Hn.env},stdio:["ignore","pipe","pipe"]});try{await of(Us)}catch(li){if(!(li instanceof o0e)||!li.conflict||el.length>=v1t)throw li;await QN(Us);let Jc=await(v.allocateMetroPort??C1t)(el);if(!Number.isSafeInteger(Jc)||Jc<1||Jc>b1t||el.includes(Jc))throw Error("Could not allocate a distinct replacement Metro port.",{cause:li});el.push(Jc),Ha+=1,qe("Metro port was claimed during startup; retrying automatically on a new port."),P=rLe(v.config,{...v,metroPort:Jc}),Hn=P.commands.find((pn)=>pn.role==="metro"),Nt=P.commands.filter((pn)=>pn.role==="native-build"),await ei()}},ln=()=>{if(Us)QN(Us)};v.signal?.addEventListener("abort",ln,{once:!0});let u_=async(li)=>{if(v.signal?.aborted)throw T7();let{platform:Xl}=li;if(!Xl)throw TypeError("Expo native build command is missing a platform.");let Jc=Xl==="android"?"building-android":"building-ios";Dr(Jc);let pn=performance.now(),vg=Xl==="android"&&ce==="wsl"?I1t(P.project,v.androidRoot??nY(ce),v.config.appId,li.args,ve,P.metroPort,v.androidDevice):[M,...li.args];if(Xl==="android"&&ce==="wsl")qe("[android] Mirroring native inputs to the Windows host for accelerated Expo build and launch.");let[$u,...kr]=vg;if(!$u)throw Error("Expo native build command is empty.");let rS=z($u,kr,{cwd:P.project,env:{...process.env,...li.env},stdio:["ignore","pipe","pipe"]});aY(rS,(bg)=>{if(bg)qe(`[${Xl}] ${bg}`)});let Gc=()=>void QN(rS);v.signal?.addEventListener("abort",Gc,{once:!0});let Xf=await c0e(rS);if(v.signal?.removeEventListener("abort",Gc),v.signal?.aborted)throw T7();if(Xf!==0)throw Error(`Expo ${Xl} development build exited with status ${Xf}.`);if(Xl==="android"&&ce!=="wsl"){let bg=v.androidRoot??process.env.ANDROID_HOME??process.env.ANDROID_SDK_ROOT??nY(ce),$0=v.androidAdb??nLe(bg,"platform-tools",ce==="windows"?"adb.exe":"adb");D1t($0,v.config.appId,P.metroPort,ve,v.androidDevice),qe("Connected the Expo Android development client to Metro.")}if(Xl==="ios"&&v.certificateAuthorityPath&&v.iosOrigin&&new URL(v.iosOrigin).protocol==="https:"&&!v.iosDevice){Dr("enrolling-trust");let bg=performance.now(),$0={cwd:P.project,signal:v.signal,log:(Wi)=>Wi&&qe(`[ios-trust] ${Wi}`)},U2=await dB(z,"xcrun",["simctl","keychain","booted","add-root-cert",v.certificateAuthorityPath],$0);if(U2!==0)throw Error(`Expo iOS Simulator development CA trust exited with status ${U2}.`);await dB(z,"xcrun",["simctl","terminate","booted",v.config.appId],$0);let uP=await dB(z,"xcrun",["simctl","launch","booted",v.config.appId],$0);if(uP!==0)throw Error(`Expo iOS Simulator relaunch exited with status ${uP}.`);qe("Installed the AbsoluteJS development CA into the Expo iOS Simulator and relaunched the app."),vr("enrolling-trust",performance.now()-bg)}if(Xl==="ios"&&!v.iosDevice){let bg={cwd:P.project,signal:v.signal,log:(U2)=>U2&&qe(`[ios-connect] ${U2}`)};await dB(z,"xcrun",["simctl","terminate","booted",v.config.appId],bg);let $0=await dB(z,"xcrun",["simctl","openurl","booted",aLe(v.config.appId,v.metroHost??"localhost",P.metroPort)],bg);if($0!==0)throw Error(`Expo iOS Simulator Metro connection exited with status ${$0}.`);qe("Connected the Expo iOS Simulator development client to Metro.")}let Ea=performance.now()-pn;at[Jc]=Ea,v.onPhaseTiming?.({durationMs:Ea,phase:Jc})},So=async(li)=>{let[Xl,...Jc]=li;if(!Xl)return;await u_(Xl),await So(Jc)},RT=async()=>{if(!v.iosDevice||!v.certificateAuthorityPath||!v.iosOrigin||new URL(v.iosOrigin).protocol!=="https:")return;Dr("enrolling-trust");let li=performance.now();yt=await(v.startCaEnrollmentServer??iY)({certificateAuthorityPath:v.certificateAuthorityPath,displayHost:new URL(v.iosOrigin).hostname}),qe(`On the iOS device, open ${yt.url}, install the AbsoluteJS development CA profile, then enable it under Settings > General > About > Certificate Trust Settings. This public CA endpoint exists only for this dev session.`),vr("enrolling-trust",performance.now()-li)};try{if(await RT(),await ei(),cs)vr("starting-metro",performance.now()-Di,{...Ha>0?{reason:"metro-port-conflict",retryCount:Ha}:{}});await So(Nt),Dr("ready");let li=!1,Xl=Promise.resolve(),Jc={metroPort:P.metroPort,platforms:v.platforms,timings:at,close:async()=>{if(li)return;if(li=!0,v.signal?.removeEventListener("abort",ln),await Xl,Us)await QN(Us);await cr(),Dr("closed")},rebuild:()=>{let pn=Xl.then(async()=>{if(li)throw Error("The Expo development session is closed.");if(xe)await Ot(xe);return await So(Nt),Dr("ready"),Jc});return Xl=pn.then(()=>{return},()=>{return}),pn}};return Jc}catch(li){if(v.signal?.removeEventListener("abort",ln),Us)await QN(Us);throw await cr(),Dr("failed"),li}};import{access as BTt,mkdir as W0e,mkdtemp as JTt,readdir as x9e,readFile as xB,rename as bY,rm as TY,writeFile as V0e}from"fs/promises";import{createHash as TB}from"crypto";import{basename as UTt,dirname as kB,join as Gl,relative as z0e,resolve as zTt,sep as WTt}from"path";var O1t="0.8.0",F1t="0.9.3",l0e="0.7.1",cLe="0.0.12";var EEt=["@capacitor/core@8.5.0","@capacitor/app@8.1.1","@capacitor/browser@8.0.4","@capacitor/network@8.0.1","@capacitor/preferences@8.0.1","@capacitor/cli@8.5.0","@capacitor/android@8.5.0","@capacitor/ios@8.5.0",`@absolutejs/devices@${l0e}`,`@absolutejs/devices-capacitor@${O1t}`],wEt=[`@absolutejs/sync-capacitor@${F1t}`,"@capacitor-community/sqlite@8.1.1"];import{readFileSync as R1t}from"fs";import{join as M1t}from"path";var L1t="@absolutejs/auth",lLe="0.76.3",uLe="@absolutejs/auth-expo",_Le="0.0.6",fLe="2.31.0",pLe="@absolutejs/sync-expo",dLe="0.0.4";var j1t=["openid","profile"],B1t="@absolutejs/sync",mLe=(v)=>{try{return JSON.parse(R1t(M1t(v,"package.json"),"utf8"))}catch{return}},gLe=(v,P)=>{if(typeof v!=="object"||v===null)return!1;return[Reflect.get(v,"dependencies"),Reflect.get(v,"devDependencies"),Reflect.get(v,"optionalDependencies"),Reflect.get(v,"peerDependencies")].some((M)=>typeof M==="object"&&M!==null&&Object.hasOwn(M,P))},J1t=(v)=>{let P=v.deepLinkScheme??v.appId.toLowerCase();return{clientId:`absolutejs-native:${v.appId}`,issuer:v.productionOrigin,redirectUri:`${P}://auth/callback`,scopes:[...j1t]}};var u0e=(v)=>gLe(mLe(v),L1t),ZA=(v)=>gLe(mLe(v),B1t),cY=(v,P)=>u0e(v)?J1t(P):void 0;import{readFileSync as q1t}from"fs";import{dirname as $1t,join as kLe,resolve as CLe}from"path";var hLe=Symbol.for("@absolutejs/sync/client-runtime-transport"),yLe=globalThis,U1t=(v)=>typeof v==="object"&&v!==null&&Array.isArray(Reflect.get(v,"installations"))&&Array.isArray(Reflect.get(v,"clients")),NEt=(()=>{let v=yLe[hLe];if(U1t(v))return v;if(typeof v==="object"&&v!==null&&Array.isArray(Reflect.get(v,"installations")))return Reflect.set(v,"clients",[]),v;let P={clients:[],installations:[]};return Object.defineProperty(yLe,hLe,{configurable:!1,enumerable:!1,value:P,writable:!1}),P})();class NT extends Error{code;constructor(v,P){super(P);this.name="SyncLocalDataPolicyError",this.code=v}}class pE extends Error{code;storedVersion;targetVersion;constructor(v,P,M={}){super(P);this.name="SyncLocalStoreSchemaError",this.code=v,this.storedVersion=M.storedVersion,this.targetVersion=M.targetVersion}}var lY=(v,P)=>{if(!Number.isSafeInteger(v)||v<1)throw new pE("INVALID_PLAN",`${P} must be a positive safe integer`);return v},z1t=(v)=>("components"in v),vLe=(v,P)=>{if(v.length===0||v.trim()!==v||/^\*+$/.test(v)||v.includes("**"))throw new NT("INVALID_POLICY",`${P}.match must be an exact name or a non-empty glob without adjacent wildcards.`)},W1t=(v,P="localData")=>{if(v.maxBytesPerNamespace!==void 0&&(!Number.isSafeInteger(v.maxBytesPerNamespace)||v.maxBytesPerNamespace<1))throw new NT("INVALID_POLICY",`${P}.maxBytesPerNamespace must be a positive safe integer.`);for(let[M,z]of(v.collections??[]).entries()){if(vLe(z.match,`${P}.collections[${M}]`),z.maxAgeMs!==void 0&&(!Number.isSafeInteger(z.maxAgeMs)||z.maxAgeMs<1))throw new NT("INVALID_POLICY",`${P}.collections[${M}].maxAgeMs must be a positive safe integer.`);if(z.persistence==="memory-only"&&z.protection==="required")throw new NT("INVALID_POLICY",`${P}.collections[${M}] cannot require at-rest protection when it is memory-only.`);if(z.sensitivity!==void 0&&z.sensitivity!=="public"&&z.protection!=="required"&&z.persistence!=="memory-only")throw new NT("INVALID_POLICY",`${P}.collections[${M}] declares ${z.sensitivity} data without required protection or memory-only persistence.`)}for(let[M,z]of(v.mutations??[]).entries()){if(vLe(z.match,`${P}.mutations[${M}]`),z.conflict!==void 0&&z.conflict.strategy!=="client-wins"&&z.conflict.strategy!=="manual"&&z.conflict.strategy!=="server-wins")throw new NT("INVALID_POLICY",`${P}.mutations[${M}].conflict.strategy is invalid.`);if(z.conflict?.maxAttempts!==void 0&&(!Number.isSafeInteger(z.conflict.maxAttempts)||z.conflict.maxAttempts<1))throw new NT("INVALID_POLICY",`${P}.mutations[${M}].conflict.maxAttempts must be a positive safe integer.`);if(z.conflict?.maxAttempts!==void 0&&z.conflict.strategy!=="client-wins")throw new NT("INVALID_POLICY",`${P}.mutations[${M}].conflict.maxAttempts is only valid for client-wins.`);if(z.persistence==="memory-only"&&z.protection==="required")throw new NT("INVALID_POLICY",`${P}.mutations[${M}] cannot require at-rest protection when it is memory-only.`);if(z.sensitivity!==void 0&&z.sensitivity!=="public"&&z.protection!=="required"&&z.persistence!=="memory-only")throw new NT("INVALID_POLICY",`${P}.mutations[${M}] declares ${z.sensitivity} arguments without required protection.`)}return v};var V1t=(v={version:1})=>{let P=z1t(v)?[...v.components]:[{...v,id:"@absolutejs/app"}],M=new Set;for(let z of P){if(typeof z.id!=="string"||z.id.trim()!==z.id||z.id.length===0)throw new pE("INVALID_PLAN","Sync schema component id must be non-empty and trimmed");if(M.has(z.id))throw new pE("INVALID_PLAN",`Sync schema component "${z.id}" is declared more than once`);if(M.add(z.id),z.localData)W1t(z.localData,`${z.id}.localData`)}return P.sort((z,ce)=>z.id.localeCompare(ce.id))};var SLe=(v,P={version:1})=>{let M=V1t(P).map((ve)=>{let qe=bLe(ve.version,ve);return{id:ve.id,...bLe(v[ve.id]??qe.minimumCompatibleVersion,ve)}}),z=new Set(M.map((ve)=>ve.id)),ce=Object.keys(v).filter((ve)=>!z.has(ve)).sort();return{components:M,orphanedComponents:ce}};var bLe=(v,P={version:1})=>{lY(v,"Stored Sync schema version");let M=lY(P.version,"Target Sync schema version"),z=[...P.migrations??[]].sort((yt,cr)=>yt.toVersion-cr.toVersion),ce=new Set;for(let yt of z){if(lY(yt.toVersion,"Sync migration toVersion"),ce.has(yt.toVersion))throw new pE("INVALID_PLAN",`Sync migration ${yt.toVersion} is declared more than once`);ce.add(yt.toVersion)}let ve=z[0]?z[0].toVersion-1:M,qe=lY(P.minimumCompatibleVersion??ve,"Minimum compatible Sync schema version");if(qe>M)throw new pE("INVALID_PLAN","Minimum compatible Sync schema version cannot exceed its target");if(v>M)throw new pE("SCHEMA_TOO_NEW",`Stored Sync schema ${v} is newer than this runtime's schema ${M}`,{storedVersion:v,targetVersion:M});if(v<qe)throw new pE("SCHEMA_TOO_OLD",`Stored Sync schema ${v} is older than the minimum compatible schema ${qe}`,{storedVersion:v,targetVersion:M});let at=[];for(let yt=v+1;yt<=M;yt++){let cr=z.find((vr)=>vr.toVersion===yt);if(cr===void 0)throw new pE("MIGRATION_MISSING",`Sync migration ${yt-1} -> ${yt} is missing`,{storedVersion:v,targetVersion:M});at.push(cr)}return{minimumCompatibleVersion:qe,steps:at,targetVersion:M}};var C7=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),_0e=(v)=>{try{let P=JSON.parse(q1t(v,"utf8"));return C7(P)?P:void 0}catch{return}},TLe=(v)=>{let P=Reflect.get(v,"absolutejs");if(!C7(P))return;let M=Reflect.get(P,"sync");if(!C7(M))return;return Reflect.get(M,"localSchema")},H1t=(v,P)=>{let M=CLe(v);while(!0){let z=kLe(M,"node_modules",P,"package.json"),ce=_0e(z);if(ce&&Reflect.get(ce,"name")===P)return z;let ve=$1t(M);if(ve===M)return;M=ve}},bf=(v,P)=>TypeError(`Invalid AbsoluteJS Sync schema metadata for ${v}: ${P}`),k7=(v,P,M)=>{if(typeof v!=="number"||!Number.isSafeInteger(v)||v<1)throw bf(P,`${M} must be a positive safe integer.`);return v},x7=(v,P,M)=>{if(typeof v!=="string"||v.trim()!==v||v.length===0)throw bf(P,`${M} must be a non-empty trimmed string.`);return v},KN=(v,P,M)=>{if(!C7(v))throw bf(P,M);return v},b1=(v,P)=>v[P],f0e=(v,P,M)=>{if(v===null||typeof v==="string"||typeof v==="boolean")return v;if(typeof v==="number"&&Number.isFinite(v))return v;if(Array.isArray(v))return v.map((z)=>f0e(z,P,M));if(C7(v))return Object.fromEntries(Object.entries(v).map(([z,ce])=>[z,f0e(ce,P,M)]));throw bf(P,`${M} must be JSON-safe.`)},G1t=(v,P,M)=>{let z=KN(v,P,`migration operation ${M} must be an object.`),ce=Reflect.get(z,"type"),ve=x7(Reflect.get(z,"collection"),P,`operation ${M}.collection`);if(ce==="delete-collection")return{collection:ve,type:ce};if(ce==="rename-field")return{collection:ve,from:x7(Reflect.get(z,"from"),P,`operation ${M}.from`),to:x7(Reflect.get(z,"to"),P,`operation ${M}.to`),type:ce};let qe=x7(Reflect.get(z,"field"),P,`operation ${M}.field`);if(ce==="remove-field")return{collection:ve,field:qe,type:ce};if(ce==="set-default")return{collection:ve,field:qe,type:ce,value:f0e(Reflect.get(z,"value"),P,`operation ${M}.value`)};throw bf(P,`operation ${M}.type is not supported.`)},X1t=(v,P,M)=>{let z=KN(v,P,`migration ${M} must be an object.`),ce=new Set(["operations","toVersion"]),ve=Object.keys(z).find((yt)=>!ce.has(yt));if(ve)throw bf(P,`migration ${M}.${ve} is not declarative metadata.`);let qe=Reflect.get(z,"operations");if(qe!==void 0&&!Array.isArray(qe))throw bf(P,`migration ${M}.operations must be an array.`);return{operations:(Array.isArray(qe)?qe:[]).map((yt,cr)=>G1t(yt,P,cr)),toVersion:k7(Reflect.get(z,"toVersion"),P,`migration ${M}.toVersion`)}},Q1t=(v,P)=>{let M=KN(v,P,"localData must be an object."),z=new Set(["collections","maxBytesPerNamespace","mutations"]),ce=Object.keys(M).find((vr)=>!z.has(vr));if(ce)throw bf(P,`localData.${ce} is not supported.`);let ve=Reflect.get(M,"collections"),qe=Reflect.get(M,"mutations");if(ve!==void 0&&!Array.isArray(ve))throw bf(P,"localData.collections must be an array.");if(qe!==void 0&&!Array.isArray(qe))throw bf(P,"localData.mutations must be an array.");let at=Array.isArray(ve)?ve.map((vr,Dr)=>{let xe=KN(vr,P,`localData.collections[${Dr}] must be an object.`),Hn=new Set(["evictionPriority","match","maxAgeMs","onProtectionUnavailable","persistence","protection","sensitivity"]),Nt=Object.keys(xe).find((ei)=>!Hn.has(ei));if(Nt)throw bf(P,`localData.collections[${Dr}].${Nt} is not supported.`);let Ot=x7(Reflect.get(xe,"match"),P,`localData.collections[${Dr}].match`),cs=b1(xe,"persistence"),Di=b1(xe,"sensitivity"),Us=b1(xe,"protection"),Ha=b1(xe,"onProtectionUnavailable"),el=b1(xe,"evictionPriority"),of=b1(xe,"maxAgeMs");if(cs!==void 0&&cs!=="durable"&&cs!=="memory-only")throw bf(P,`localData.collections[${Dr}].persistence is invalid.`);if(Di!==void 0&&Di!=="public"&&Di!=="private"&&Di!=="secret")throw bf(P,`localData.collections[${Dr}].sensitivity is invalid.`);if(Us!==void 0&&Us!=="none"&&Us!=="required")throw bf(P,`localData.collections[${Dr}].protection is invalid.`);if(Ha!==void 0&&Ha!=="error"&&Ha!=="memory-only")throw bf(P,`localData.collections[${Dr}].onProtectionUnavailable is invalid.`);if(el!==void 0&&el!=="critical"&&el!=="normal"&&el!=="disposable")throw bf(P,`localData.collections[${Dr}].evictionPriority is invalid.`);return{match:Ot,...Di?{sensitivity:Di}:{},...cs?{persistence:cs}:{},...Us?{protection:Us}:{},...Ha?{onProtectionUnavailable:Ha}:{},...el?{evictionPriority:el}:{},...of===void 0?{}:{maxAgeMs:k7(of,P,`localData.collections[${Dr}].maxAgeMs`)}}}):void 0,yt=Array.isArray(qe)?qe.map((vr,Dr)=>{let xe=KN(vr,P,`localData.mutations[${Dr}] must be an object.`),Hn=new Set(["conflict","match","onProtectionUnavailable","persistence","protection","sensitivity"]),Nt=Object.keys(xe).find((of)=>!Hn.has(of));if(Nt)throw bf(P,`localData.mutations[${Dr}].${Nt} is not supported.`);let Ot=b1(xe,"protection"),cs=b1(xe,"sensitivity"),Di=b1(xe,"persistence"),Us=b1(xe,"onProtectionUnavailable"),Ha=b1(xe,"conflict"),el;if(Ha!==void 0){let of=KN(Ha,P,`localData.mutations[${Dr}].conflict must be an object.`),ei=Object.keys(of).find((So)=>So!=="maxAttempts"&&So!=="strategy");if(ei)throw bf(P,`localData.mutations[${Dr}].conflict.${ei} is not supported.`);let ln=b1(of,"strategy");if(ln!=="client-wins"&&ln!=="manual"&&ln!=="server-wins")throw bf(P,`localData.mutations[${Dr}].conflict.strategy is invalid.`);let u_=b1(of,"maxAttempts");if(u_!==void 0&&ln!=="client-wins")throw bf(P,`localData.mutations[${Dr}].conflict.maxAttempts requires client-wins.`);el={strategy:ln,...u_===void 0?{}:{maxAttempts:k7(u_,P,`localData.mutations[${Dr}].conflict.maxAttempts`)}}}if(Ot!==void 0&&Ot!=="none"&&Ot!=="required")throw bf(P,`localData.mutations[${Dr}].protection is invalid.`);if(cs!==void 0&&cs!=="public"&&cs!=="private"&&cs!=="secret")throw bf(P,`localData.mutations[${Dr}].sensitivity is invalid.`);if(Us!==void 0&&Us!=="error"&&Us!=="memory-only")throw bf(P,`localData.mutations[${Dr}].onProtectionUnavailable is invalid.`);if(Di!==void 0&&Di!=="durable"&&Di!=="memory-only")throw bf(P,`localData.mutations[${Dr}].persistence is invalid.`);return{match:x7(Reflect.get(xe,"match"),P,`localData.mutations[${Dr}].match`),...el?{conflict:el}:{},...cs?{sensitivity:cs}:{},...Us?{onProtectionUnavailable:Us}:{},...Di?{persistence:Di}:{},...Ot?{protection:Ot}:{}}}):void 0,cr=Reflect.get(M,"maxBytesPerNamespace");return{...at?{collections:at}:{},...yt?{mutations:yt}:{},...cr===void 0?{}:{maxBytesPerNamespace:k7(cr,P,"localData.maxBytesPerNamespace")}}},xLe=(v,P)=>{let M=KN(P,v,"localSchema must be an object."),z=new Set(["localData","migrations","minimumCompatibleVersion","version"]),ce=Object.keys(M).find((Dr)=>!z.has(Dr));if(ce)throw bf(v,`${ce} is not supported.`);let ve=k7(Reflect.get(M,"version"),v,"version"),qe=Reflect.get(M,"minimumCompatibleVersion"),at=qe===void 0?Math.max(1,ve-2):k7(qe,v,"minimumCompatibleVersion"),yt=Reflect.get(M,"migrations"),cr=Reflect.get(M,"localData");if(yt!==void 0&&!Array.isArray(yt))throw bf(v,"migrations must be an array.");let vr=Array.isArray(yt)?yt:void 0;return{id:v,...cr===void 0?{}:{localData:Q1t(cr,v)},minimumCompatibleVersion:at,...Array.isArray(vr)?{migrations:vr.map((Dr,xe)=>X1t(Dr,v,xe))}:{},version:ve}},K1t=(v)=>[Reflect.get(v,"dependencies"),Reflect.get(v,"optionalDependencies"),Reflect.get(v,"devDependencies"),Reflect.get(v,"peerDependencies")].flatMap((P)=>C7(P)?Object.keys(P):[]).filter((P,M,z)=>z.indexOf(P)===M).sort(),E7=(v)=>{let P=kLe(CLe(v),"package.json"),M=_0e(P);if(!M)return{components:[{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}],sources:[]};let z=TLe(M),ce=[z===void 0?{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}:xLe("@absolutejs/app",z)],ve=[{id:"@absolutejs/app",manifestPath:P}];for(let qe of K1t(M)){let at=H1t(v,qe);if(!at)continue;let yt=_0e(at);if(!yt)continue;let cr=TLe(yt);if(cr===void 0)continue;ce.push(xLe(qe,cr)),ve.push({id:qe,manifestPath:at})}return ce.sort((qe,at)=>qe.id.localeCompare(at.id)),ve.sort((qe,at)=>qe.id.localeCompare(at.id)),SLe({},{components:ce}),{components:ce,sources:ve}};var V0=hvt(i9e());import{existsSync as ASt,readFileSync as F0e}from"fs";import{extname as PSt,join as R0e,relative as DSt,resolve as N7}from"path";import{fileURLToPath as ISt}from"url";var s9e="@absolutejs/devices",NSt=["keyboard","systemBars"],OSt={capacitor:"@absolutejs/devices-capacitor",expo:"@absolutejs/devices-expo"},FSt=new Bun.Glob("**/*.{js,jsx,ts,tsx,svelte,vue}"),RSt=new Set([".absolutejs",".git",".test-builds",".test-shards","build","dist","node_modules","test","tests"]),a9e=/^[A-Za-z_$][\w$]*$/u,MSt=(v)=>new RegExp(`^@absolutejs/devices-${v}/[a-z][a-z0-9-]*$`,"u"),LSt=(v)=>v==="capacitor"?/^@capacitor\/[a-z][a-z0-9-]*@\d+\.\d+\.\d+$/u:/^(?:expo-[a-z][a-z0-9-]*|@react-native-[a-z0-9-]+\/[a-z][a-z0-9-]*)@\d+\.\d+\.\d+$/u,jSt=(v)=>v==="capacitor"?"Capacitor":"Expo",BSt=/^android\.permission\.[A-Z][A-Z0-9_]*$/u,JSt=new Set(["camera","location-always","location-when-in-use","photo-library","photo-library-add"]),USt={NSPrivacyAccessedAPICategoryFileTimestamp:new Set(["C617.1"])},mY=["NSPrivacyAccessedAPICategoryFileTimestamp"],L2=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),M0e=(v)=>{let P=JSON.parse(F0e(v,"utf8"));if(!L2(P))throw TypeError(`${v} must contain an object.`);return P},o9e=(v,P)=>{if(typeof v!=="string"||v.length===0)throw TypeError(`${P} must be a non-empty string.`);return v},zSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let{permissions:M}=v;if(!Array.isArray(M)||!M.every((z)=>typeof z==="string"&&BSt.test(z)))throw TypeError(`${P}.permissions must contain Android permission names.`);return[...M]},WSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let M={};for(let z of mY){let ce=v[z];if(ce===void 0)continue;let ve=USt[z];if(!Array.isArray(ce)||ce.length===0||!ce.every((qe)=>typeof qe==="string"&&ve.has(qe)))throw TypeError(`${P} contains an unsupported API or reason.`);M[z]=[...ce]}if(Object.keys(v).some((z)=>!mY.some((ce)=>ce===z)))throw TypeError(`${P} contains an unsupported API or reason.`);return M},VSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let{privacyAccessedApis:M,pushNotifications:z,systemBars:ce,usageDescriptions:ve}=v;if(z!==void 0&&z!==!0)throw TypeError(`${P}.pushNotifications must be true.`);if(ce!==void 0&&ce!==!0)throw TypeError(`${P}.systemBars must be true.`);if(ve!==void 0&&(!Array.isArray(ve)||!ve.every((at)=>typeof at==="string"&&JSt.has(at))))throw TypeError(`${P}.usageDescriptions contains an unsupported purpose.`);let qe=WSt(M,`${P}.privacyAccessedApis`);return{...qe===void 0?{}:{privacyAccessedApis:qe},...z===!0?{pushNotifications:!0}:{},...ce===!0?{systemBars:!0}:{},...ve===void 0?{}:{usageDescriptions:[...ve]}}},qSt=(v,P,M)=>{if(!a9e.test(v))throw TypeError("Device capability names must be identifiers.");if(!L2(P))throw TypeError(`Device capability ${v} must be an object.`);let z=o9e(P.factory,`${v}.factory`),ce=o9e(P.module,`${v}.module`);if(!a9e.test(z))throw TypeError(`${v}.factory must be a JavaScript identifier.`);if(!MSt(M).test(ce))throw TypeError(`${v}.module must be an official devices-${M} subpath.`);if(!Array.isArray(P.packages)||!P.packages.every((yt)=>typeof yt==="string"&&LSt(M).test(yt)))throw TypeError(`${v}.packages must contain exact official ${jSt(M)} package versions.`);let{plugins:ve}=P;if(ve!==void 0&&(!Array.isArray(ve)||!ve.every((yt)=>typeof yt==="string"&&/^expo-[a-z][a-z0-9-]*$/u.test(yt))))throw TypeError(`${v}.plugins must contain Expo config plugin names.`);let qe,{native:at}=P;if(at!==void 0){if(!L2(at))throw TypeError(`${v}.native must be an object.`);let{android:yt,ios:cr}=at,vr=zSt(yt,`${v}.native.android`),Dr=VSt(cr,`${v}.native.ios`);qe={...vr===void 0?{}:{android:{permissions:vr}},...Dr===void 0?{}:{ios:Dr}}}return{factory:z,module:ce,...qe===void 0?{}:{native:qe},...ve===void 0?{}:{plugins:[...ve]},packages:[...P.packages]}},e6=(v)=>{let P=v.capabilities.reduce((M,z)=>{for(let ce of mY){let ve=v.providers[z]?.native?.ios?.privacyAccessedApis?.[ce]??[];if(ve.length===0)continue;let qe=M[ce]??new Set;for(let at of ve)qe.add(at);M[ce]=qe}return M},{});return{androidPermissions:[...new Set(v.capabilities.flatMap((M)=>v.providers[M]?.native?.android?.permissions??[]))].sort(),iosPrivacyAccessedApis:mY.flatMap((M)=>{let z=P[M];return z?[{api:M,reasons:[...z].sort()}]:[]}),iosPushNotifications:v.capabilities.some((M)=>v.providers[M]?.native?.ios?.pushNotifications===!0),iosSystemBars:v.capabilities.some((M)=>v.providers[M]?.native?.ios?.systemBars===!0),iosUsageDescriptions:[...new Set(v.capabilities.flatMap((M)=>v.providers[M]?.native?.ios?.usageDescriptions??[]))].sort()}},c9e=(v,P="capacitor")=>{let M=OSt[P],z=R0e(N7(v),"node_modules",M,"package.json");try{F0e(z,"utf8")}catch{z=ISt(import.meta.resolve(`${M}/package.json`))}let ce=M0e(z),{absolutejs:ve}=ce,qe=L2(ve)?ve.devices:void 0;if(!L2(qe)||qe.format!==1||qe.provider!==P||!L2(qe.capabilities))throw TypeError(`${M} does not publish supported capability metadata.`);let at=Object.entries(qe.capabilities).map(([yt,cr])=>({name:yt,provider:qSt(yt,cr,P)}));return Object.fromEntries(at.sort((yt,cr)=>yt.name.localeCompare(cr.name)).map(({name:yt,provider:cr})=>[yt,cr]))},$St=(v)=>v.split("/").some((P)=>RSt.has(P)),HSt=(v,P)=>{let M=new Set,z=new Set,ce=(at)=>{if(V0.default.isImportDeclaration(at)&&V0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===s9e&&!at.importClause?.isTypeOnly){let yt=at.importClause?.namedBindings;if(yt&&V0.default.isNamedImports(yt)){for(let cr of yt.elements)if(!cr.isTypeOnly)M.add((cr.propertyName??cr.name).text)}if(yt&&V0.default.isNamespaceImport(yt))z.add(yt.name.text)}if(V0.default.isExportDeclaration(at)&&!at.isTypeOnly&&at.moduleSpecifier!==void 0&&V0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===s9e&&at.exportClause&&V0.default.isNamedExports(at.exportClause)){for(let yt of at.exportClause.elements)if(!yt.isTypeOnly)M.add((yt.propertyName??yt.name).text)}if(V0.default.isPropertyAccessExpression(at)&&V0.default.isIdentifier(at.expression)&&z.has(at.expression.text))M.add(at.name.text);V0.default.forEachChild(at,ce)},ve=PSt(P).toLowerCase(),qe=ve===".svelte"||ve===".vue"?[...v.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/giu)].map((at)=>at[1]).filter((at)=>at!==void 0):[v];for(let[at,yt]of qe.entries())ce(V0.default.createSourceFile(`${P}#script-${at}`,yt,V0.default.ScriptTarget.Latest,!0,V0.default.ScriptKind.TSX));return M},l9e=(v,P)=>{let M=QSt(P,GSt(v)),z=P.requiredPackages.filter((ve)=>{let qe=ve.lastIndexOf("@"),at=ve.slice(0,qe);if(M.includes(ve))return!1;try{return M0e(R0e(N7(v),"node_modules",at,"package.json")).version!==ve.slice(qe+1)}catch{return!0}}),ce=[...M,...z];if(ce.length>0)throw TypeError(`Device capabilities ${P.capabilities.join(", ")} require ${ce.join(", ")}. Run absolute mobile sync and approve the detected capability plugins.`)},GSt=(v)=>{let P=M0e(R0e(N7(v),"package.json")),M=new Set;for(let z of["dependencies","devDependencies"]){let ce=P[z];if(L2(ce))for(let ve of Object.keys(ce))M.add(ve)}return M},XSt=(v,P=c9e(v))=>{let M=N7(v);if(!ASt(M))return[];let z=new Set(Object.keys(P)),ce=new Set;for(let ve of FSt.scanSync({cwd:M})){let qe=DSt(M,N7(M,ve)).replaceAll("\\","/");if($St(qe))continue;let at=F0e(N7(M,qe),"utf8");for(let yt of HSt(at,qe))if(z.has(yt))ce.add(yt)}return[...ce].sort()},QSt=(v,P)=>v.requiredPackages.filter((M)=>{let z=M.slice(0,M.lastIndexOf("@"));return!P.has(z)});var rP=(v,P="capacitor")=>{let M=c9e(v,P),z=XSt(v,M);for(let ve of NSt)if(M[ve]&&!z.includes(ve))z.push(ve);z.sort();let ce={};for(let ve of z){let qe=M[ve];if(qe)ce[ve]=qe}return{capabilities:z,providers:ce,requiredPackages:[...new Set(z.flatMap((ve)=>ce[ve]?.packages??[]))].sort()}};import{createHash as YSt}from"crypto";var KSt=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),L0e=(v)=>{if(Array.isArray(v))return v.map(L0e);if(!KSt(v))return v;return Object.fromEntries(Object.keys(v).sort().map((P)=>[P,L0e(v[P])]))};var u9e=(v)=>JSON.stringify(L0e(v));var ZSt=2,eTt=1,tTt=(v)=>({appId:v.config.appId,auth:v.auth??null,deepLinks:{hosts:v.config.deepLinkHosts,...v.config.deepLinkScheme?{scheme:v.config.deepLinkScheme}:{}},deviceCapabilities:v.deviceCapabilities,engine:v.config.engine,...v.config.engine==="expo"?{expoEmbeddedAssetsAbi:1}:{},format:eTt,shellAbi:ZSt,syncSchema:v.syncSchema??null,updates:v.config.updates??null}),rTt=(v)=>YSt("sha256").update(u9e(v)).digest("hex"),gY=(v,P)=>{let M=cY(P,v),z=M!==void 0&&ZA(P),ce=z?E7(P):void 0,ve=rP(P,v.engine),qe=tTt({...M?{auth:M}:{},config:v,deviceCapabilities:ve,...ce?{syncSchema:ce}:{}});return{auth:M,descriptor:qe,deviceCapabilities:ve,fingerprint:rTt(qe),sync:z,syncSchema:ce}};import{join as t6}from"path";var bB=`// Generated by AbsoluteJS. Edit absolute.config.ts, then run absolute mobile sync.
480
480
  `,nTt=`<!-- Generated by AbsoluteJS. Edit absolute.config.ts, then run absolute mobile sync. -->
481
481
  `,iTt=`${JSON.stringify({android:{modules:["expo.modules.absolutemobileobservability.AbsoluteMobileObservabilityModule"]},apple:{modules:["AbsoluteMobileObservabilityModule"]},platforms:["apple","android"]},null,2)}
482
482
  `,sTt=`${bB}Pod::Spec.new do |s|
@@ -1,7 +1,7 @@
1
1
  export declare const ABSOLUTE_CAPACITOR_DEVICES_VERSION = "0.8.0";
2
2
  export declare const ABSOLUTE_CAPACITOR_SYNC_VERSION = "0.9.3";
3
- export declare const ABSOLUTE_DEVICES_VERSION = "0.7.0";
4
- export declare const ABSOLUTE_EXPO_DEVICES_VERSION = "0.0.11";
3
+ export declare const ABSOLUTE_DEVICES_VERSION = "0.7.1";
4
+ export declare const ABSOLUTE_EXPO_DEVICES_VERSION = "0.0.12";
5
5
  export declare const ABSOLUTE_NATIVE_EXACT_PACKAGES: Set<string>;
6
6
  export declare const CAPACITOR_PACKAGE_SPECS: string[];
7
7
  export declare const CAPACITOR_SYNC_PACKAGE_SPECS: string[];
package/package.json CHANGED
@@ -11,9 +11,9 @@
11
11
  "@absolutejs/beacon": ">=0.7.0-beta.4 <0.8.0",
12
12
  "@absolutejs/bvm": "^0.1.1",
13
13
  "@absolutejs/deploy": "0.27.0",
14
- "@absolutejs/devices": "0.7.0",
14
+ "@absolutejs/devices": "0.7.1",
15
15
  "@absolutejs/devices-capacitor": "0.8.0",
16
- "@absolutejs/devices-expo": "0.0.11",
16
+ "@absolutejs/devices-expo": "0.0.12",
17
17
  "@absolutejs/http": "0.0.1",
18
18
  "@absolutejs/pwa": "0.14.0",
19
19
  "@capacitor/browser": "8.0.4",
@@ -555,7 +555,7 @@
555
555
  ]
556
556
  }
557
557
  },
558
- "version": "0.20.0-beta.134",
558
+ "version": "0.20.0-beta.135",
559
559
  "workspaces": [
560
560
  "tests/fixtures/*",
561
561
  "tests/fixtures/_packages/*"