@absolutejs/absolute 0.20.0-beta.154 → 0.20.0-beta.156
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/CHANGELOG.md +12 -0
- package/changelog.json +20 -0
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/build.js +4 -2
- package/dist/build.js.map +4 -4
- package/dist/cli/{compile-0e7bd2db.js → compile-bky8k5we.js} +322 -116
- package/dist/cli/{dev-7ep6b81g.js → dev-dpb0bksv.js} +1 -1
- package/dist/cli/{expoProject-f3eb0040.js → expoProject-z1gxrw3s.js} +1 -1
- package/dist/cli/{index-f6mqr467.js → index-3n1vqn3y.js} +1 -1
- package/dist/cli/{index-039rh39e.js → index-bp60baze.js} +63 -1
- package/dist/cli/{index-50n5vfd1.js → index-cnchgvtx.js} +2 -2
- package/dist/cli/{index-snz4z0tq.js → index-x3a66ym4.js} +2 -2
- package/dist/cli/index.js +5 -5
- package/dist/cli/{mobile-8r10trsk.js → mobile-gtnrcfsf.js} +3 -3
- package/dist/cli/rewriteImports-z6629aww.js +46 -0
- package/dist/cli/{start-d1200qc3.js → start-3bbpy0md.js} +3 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +4 -4
- package/dist/mobile/index.js +3 -3
- package/dist/mobile/index.js.map +2 -2
- package/dist/mobile/remoteMacAgentEntry.js +1 -1
- package/dist/runtime/clientAssetArchive.js +215 -0
- package/dist/runtime/clientAssetArchive.js.map +10 -0
- package/dist/src/build/compiledClientGraph.d.ts +7 -0
- package/dist/src/mobile/nativePackages.d.ts +2 -2
- package/dist/src/runtime/clientAssetArchive.d.ts +5 -0
- package/package.json +3 -3
- package/dist/cli/rewriteImports-k6rjjmg1.js +0 -108
|
@@ -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
|
`,oLe=(v)=>`exp+${v.toLowerCase().replaceAll(/[^a-z0-9]+/gu,"-")}`,cLe=(v,P,M)=>`${oLe(v)}://expo-development-client/?url=${encodeURIComponent(`http://${P}:${M}`)}`,P1t=(v)=>{let P=Bun.spawnSync(v,{killSignal:"SIGKILL",stderr:"ignore",stdout:"pipe",timeout:30000});return{exitCode:P.exitCode,stdout:P.stdout.toString()}},c0e=(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()},D1t=(v,P)=>{let M=Bun.hash(nLe(v)).toString(aLe);return nLe(P,"..","..","ExpoBuilds",M.slice(0,x1t))},I1t=(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 $e=ve.stdout.split(/\r?\n/u).flatMap((yr)=>{let Dr=/^(\S+)\s+device$/u.exec(yr.trim());return Dr?.[1]?[Dr[1]]:[]}),at=ce?$e.find((yr)=>yr===ce):$e.find((yr)=>yr.startsWith("emulator-"))??$e[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 dt=(yr,Dr)=>{if(z([v,"-s",at,...yr]).exitCode!==0)throw Error(Dr)};dt(["reverse",`tcp:${M}`,`tcp:${M}`],"Expo Android Metro forwarding failed."),dt(["shell","am","force-stop",P],"Expo Android development-client reset failed.");let cr=()=>dt(["shell","am","start","-a","android.intent.action.VIEW","-d",cLe(P,"localhost",M),P],"Expo Android development-client launch failed.");return cr(),dt(["shell","sleep","1"],"Expo Android development-client readiness pause failed."),cr(),at};var N1t=(v,P,M,z,ce,ve,$e,at="development",dt=[])=>{let cr=c0e(v,ce),yr=D1t(v,P),Dr=c0e(yr,ce),xe=c0e(P,ce),Hn=(el)=>Buffer.from(el,"utf8").toString("base64"),Nt=oLe(M),Ot=Hn(A1t),os=`Local\\AbsoluteJS.Expo.${Bun.hash(yr).toString(aLe)}`,Pi=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)",...$e?[`$serial = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn($e)}'))`,"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.' }"],...Pi].join("; "),$a=["$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(os)}'))`,`$expoArguments = @([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(JSON.stringify(z))}')) | ConvertFrom-Json)`,`$gradleArguments = @([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Hn(JSON.stringify(dt))}')) | ConvertFrom-Json)`,"$env:ANDROID_HOME = $androidHome","$env:ANDROID_SDK_ROOT = $androidHome",`$env:NODE_ENV = '${at==="development"?"development":"production"}'`,...$e||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 ${o0e} /NFL /NDL /NJH /NJS /NP`,"$copyExit = $LASTEXITCODE","if ($copyExit -ge 8) { exit $copyExit }","Set-Location $directory",`$buildStamp = Join-Path $directory '${o0e}'`,"Set-Content $buildStamp ([DateTime]::UtcNow.ToString('o')) -NoNewline",`$staleBefore = [DateTime]::UtcNow.AddDays(-${C1t()})`,`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 '${o0e}'; $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($a,"utf16le").toString("base64")]};var O1t=(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}:{}}),lY=async(v)=>{let P=sLe(v,"node_modules",".bin","expo");try{return await h1t(P),P}catch{throw TypeError("Expo dependencies are not installed in the generated shell. Run `absolute mobile init --yes`.")}},iLe=(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=O1t(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"},$e=P.platforms.map((at)=>{let dt=at==="android"?P.androidDevice:P.iosDevice;return{args:[`run:${at}`,"--no-bundler",...dt?["--device",dt]:[]],env:z,platform:at,role:"native-build"}});return{commands:[...ve?[ve]:[],...P.metro==="external"?[]:[ce],...$e],metroPort:P.metroPort,project:v.nativeProjectDirectory}},x7=()=>new DOMException("Expo development aborted.","AbortError"),cY=(v,P)=>{let M=(z)=>{if(!z)return;let ce="";z.on("data",(ve)=>{ce+=ve.toString("utf8");let $e=ce.indexOf(`
|
|
478
478
|
`);while($e>=0)P(ce.slice(0,$e).replace(/\r$/u,"")),ce=ce.slice($e+1),$e=ce.indexOf(`
|
|
479
|
-
`)}),z.on("end",()=>{if(ce)P(ce)})};M(v.stdout),M(v.stderr)},KN=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,T1t))]),v.exitCode===null)v.kill("SIGKILL")},u0e=(v)=>new Promise((P)=>{if(v.exitCode!==null){P(v.exitCode);return}v.once("exit",(M)=>P(M??1))}),gB=async(v,P,M,z)=>{let ce=v(P,M,{cwd:z.cwd,env:z.env??process.env,stdio:["ignore","pipe","pipe"]});cY(ce,z.log);let ve=()=>void KN(ce);z.signal?.addEventListener("abort",ve,{once:!0});let $e=await u0e(ce);if(z.signal?.removeEventListener("abort",ve),z.signal?.aborted)throw x7();return $e};var lLe=async(v)=>{let P=iLe(v.config,v),M=v.executable??await lY(P.project),z=v.spawnProcess??g1t,ce=v.host??XN(),ve=v.capture??P1t,$e=v.log??(()=>{return}),at={},dt=null,cr=async()=>{let li=dt;dt=null,await li?.close()},yr=(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 x7();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"]});cY(Jc,($u)=>{if($u)$e(`[prebuild] ${$u}`)});let pn=()=>void KN(Jc);v.signal?.addEventListener("abort",pn,{once:!0});let vg=await u0e(Jc);if(v.signal?.removeEventListener("abort",pn),v.signal?.aborted)throw x7();if(vg!==0)throw Dr("failed"),Error(`Expo native preparation exited with status ${vg}.`);yr("preparing-native",performance.now()-Xl)};if(xe)await Ot(xe);let os=Hn!==void 0;if(os)Dr("starting-metro");let Pi=performance.now(),Us,$a=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."))},v1t);cY(li,(kr)=>{if(kr)$e(`[metro] ${kr}`);if(w1t(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 l0e(kr??1,vg))})}),ei=async()=>{if(!Hn)return;if(v.signal?.aborted)throw x7();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 l0e)||!li.conflict||el.length>=b1t)throw li;await KN(Us);let Jc=await(v.allocateMetroPort??E1t)(el);if(!Number.isSafeInteger(Jc)||Jc<1||Jc>S1t||el.includes(Jc))throw Error("Could not allocate a distinct replacement Metro port.",{cause:li});el.push(Jc),$a+=1,$e("Metro port was claimed during startup; retrying automatically on a new port."),P=iLe(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)KN(Us)};v.signal?.addEventListener("abort",ln,{once:!0});let u_=async(li)=>{if(v.signal?.aborted)throw x7();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"?N1t(P.project,v.androidRoot??sY(ce),v.config.appId,li.args,ve,P.metroPort,v.androidDevice):[M,...li.args];if(Xl==="android"&&ce==="wsl")$e("[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"]});cY(rS,(bg)=>{if(bg)$e(`[${Xl}] ${bg}`)});let Gc=()=>void KN(rS);v.signal?.addEventListener("abort",Gc,{once:!0});let Kf=await u0e(rS);if(v.signal?.removeEventListener("abort",Gc),v.signal?.aborted)throw x7();if(Kf!==0)throw Error(`Expo ${Xl} development build exited with status ${Kf}.`);if(Xl==="android"&&ce!=="wsl"){let bg=v.androidRoot??process.env.ANDROID_HOME??process.env.ANDROID_SDK_ROOT??sY(ce),$0=v.androidAdb??sLe(bg,"platform-tools",ce==="windows"?"adb.exe":"adb");I1t($0,v.config.appId,P.metroPort,ve,v.androidDevice),$e("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&&$e(`[ios-trust] ${Wi}`)},U2=await gB(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 gB(z,"xcrun",["simctl","terminate","booted",v.config.appId],$0);let uP=await gB(z,"xcrun",["simctl","launch","booted",v.config.appId],$0);if(uP!==0)throw Error(`Expo iOS Simulator relaunch exited with status ${uP}.`);$e("Installed the AbsoluteJS development CA into the Expo iOS Simulator and relaunched the app."),yr("enrolling-trust",performance.now()-bg)}if(Xl==="ios"&&!v.iosDevice){let bg={cwd:P.project,signal:v.signal,log:(U2)=>U2&&$e(`[ios-connect] ${U2}`)};await gB(z,"xcrun",["simctl","terminate","booted",v.config.appId],bg);let $0=await gB(z,"xcrun",["simctl","openurl","booted",cLe(v.config.appId,v.metroHost??"localhost",P.metroPort)],bg);if($0!==0)throw Error(`Expo iOS Simulator Metro connection exited with status ${$0}.`);$e("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();dt=await(v.startCaEnrollmentServer??aY)({certificateAuthorityPath:v.certificateAuthorityPath,displayHost:new URL(v.iosOrigin).hostname}),$e(`On the iOS device, open ${dt.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.`),yr("enrolling-trust",performance.now()-li)};try{if(await RT(),await ei(),os)yr("starting-metro",performance.now()-Pi,{...$a>0?{reason:"metro-port-conflict",retryCount:$a}:{}});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 KN(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 KN(Us);throw await cr(),Dr("failed"),li}};import{access as UTt,mkdir as q0e,mkdtemp as zTt,readdir as k9e,readFile as CB,rename as xY,rm as CY,writeFile as $0e}from"fs/promises";import{createHash as kB}from"crypto";import{basename as WTt,dirname as EB,join as Gl,relative as V0e,resolve as VTt,sep as qTt}from"path";var F1t="0.8.0",R1t="0.9.4",uY="0.7.1",_0e="0.0.12";var DEt=["@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@${uY}`,`@absolutejs/devices-capacitor@${F1t}`],IEt=[`@absolutejs/sync-capacitor@${R1t}`,"@capacitor-community/sqlite@8.1.1"];var NEt=[`@absolutejs/devices@${uY}`,`@absolutejs/devices-expo@${_0e}`];import{readFileSync as M1t}from"fs";import{join as L1t}from"path";var j1t="@absolutejs/auth",uLe="0.76.3",_Le="@absolutejs/auth-expo",fLe="0.0.6",pLe="2.31.0",dLe="@absolutejs/sync-expo",mLe="0.0.4";var B1t=["openid","profile"],J1t="@absolutejs/sync",gLe=(v)=>{try{return JSON.parse(M1t(L1t(v,"package.json"),"utf8"))}catch{return}},hLe=(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))},U1t=(v)=>{let P=v.deepLinkScheme??v.appId.toLowerCase();return{clientId:`absolutejs-native:${v.appId}`,issuer:v.productionOrigin,redirectUri:`${P}://auth/callback`,scopes:[...B1t]}};var f0e=(v)=>hLe(gLe(v),j1t),ZA=(v)=>hLe(gLe(v),J1t),_Y=(v,P)=>f0e(v)?U1t(P):void 0;import{readFileSync as $1t}from"fs";import{dirname as H1t,join as CLe,resolve as ELe}from"path";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 fY=(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),yLe=(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(yLe(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(yLe(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 TLe=(v,P={version:1})=>{let M=V1t(P).map((ve)=>{let $e=vLe(ve.version,ve);return{id:ve.id,...vLe(v[ve.id]??$e.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 vLe=(v,P={version:1})=>{fY(v,"Stored Sync schema version");let M=fY(P.version,"Target Sync schema version"),z=[...P.migrations??[]].sort((dt,cr)=>dt.toVersion-cr.toVersion),ce=new Set;for(let dt of z){if(fY(dt.toVersion,"Sync migration toVersion"),ce.has(dt.toVersion))throw new pE("INVALID_PLAN",`Sync migration ${dt.toVersion} is declared more than once`);ce.add(dt.toVersion)}let ve=z[0]?z[0].toVersion-1:M,$e=fY(P.minimumCompatibleVersion??ve,"Minimum compatible Sync schema version");if($e>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<$e)throw new pE("SCHEMA_TOO_OLD",`Stored Sync schema ${v} is older than the minimum compatible schema ${$e}`,{storedVersion:v,targetVersion:M});let at=[];for(let dt=v+1;dt<=M;dt++){let cr=z.find((yr)=>yr.toVersion===dt);if(cr===void 0)throw new pE("MIGRATION_MISSING",`Sync migration ${dt-1} -> ${dt} is missing`,{storedVersion:v,targetVersion:M});at.push(cr)}return{minimumCompatibleVersion:$e,steps:at,targetVersion:M}};var bLe=Symbol.for("@absolutejs/sync/client-runtime-transport"),SLe=globalThis,q1t=(v)=>typeof v==="object"&&v!==null&&Array.isArray(Reflect.get(v,"installations"))&&Array.isArray(Reflect.get(v,"clients")),LEt=(()=>{let v=SLe[bLe];if(q1t(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(SLe,bLe,{configurable:!1,enumerable:!1,value:P,writable:!1}),P})();var E7=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),p0e=(v)=>{try{let P=JSON.parse($1t(v,"utf8"));return E7(P)?P:void 0}catch{return}},xLe=(v)=>{let P=Reflect.get(v,"absolutejs");if(!E7(P))return;let M=Reflect.get(P,"sync");if(!E7(M))return;return Reflect.get(M,"localSchema")},G1t=(v,P)=>{let M=ELe(v);while(!0){let z=CLe(M,"node_modules",P,"package.json"),ce=p0e(z);if(ce&&Reflect.get(ce,"name")===P)return z;let ve=H1t(M);if(ve===M)return;M=ve}},bf=(v,P)=>TypeError(`Invalid AbsoluteJS Sync schema metadata for ${v}: ${P}`),C7=(v,P,M)=>{if(typeof v!=="number"||!Number.isSafeInteger(v)||v<1)throw bf(P,`${M} must be a positive safe integer.`);return v},k7=(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},QN=(v,P,M)=>{if(!E7(v))throw bf(P,M);return v},b1=(v,P)=>v[P],d0e=(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)=>d0e(z,P,M));if(E7(v))return Object.fromEntries(Object.entries(v).map(([z,ce])=>[z,d0e(ce,P,M)]));throw bf(P,`${M} must be JSON-safe.`)},X1t=(v,P,M)=>{let z=QN(v,P,`migration operation ${M} must be an object.`),ce=Reflect.get(z,"type"),ve=k7(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:k7(Reflect.get(z,"from"),P,`operation ${M}.from`),to:k7(Reflect.get(z,"to"),P,`operation ${M}.to`),type:ce};let $e=k7(Reflect.get(z,"field"),P,`operation ${M}.field`);if(ce==="remove-field")return{collection:ve,field:$e,type:ce};if(ce==="set-default")return{collection:ve,field:$e,type:ce,value:d0e(Reflect.get(z,"value"),P,`operation ${M}.value`)};throw bf(P,`operation ${M}.type is not supported.`)},K1t=(v,P,M)=>{let z=QN(v,P,`migration ${M} must be an object.`),ce=new Set(["operations","toVersion"]),ve=Object.keys(z).find((dt)=>!ce.has(dt));if(ve)throw bf(P,`migration ${M}.${ve} is not declarative metadata.`);let $e=Reflect.get(z,"operations");if($e!==void 0&&!Array.isArray($e))throw bf(P,`migration ${M}.operations must be an array.`);return{operations:(Array.isArray($e)?$e:[]).map((dt,cr)=>X1t(dt,P,cr)),toVersion:C7(Reflect.get(z,"toVersion"),P,`migration ${M}.toVersion`)}},Q1t=(v,P)=>{let M=QN(v,P,"localData must be an object."),z=new Set(["collections","maxBytesPerNamespace","mutations"]),ce=Object.keys(M).find((yr)=>!z.has(yr));if(ce)throw bf(P,`localData.${ce} is not supported.`);let ve=Reflect.get(M,"collections"),$e=Reflect.get(M,"mutations");if(ve!==void 0&&!Array.isArray(ve))throw bf(P,"localData.collections must be an array.");if($e!==void 0&&!Array.isArray($e))throw bf(P,"localData.mutations must be an array.");let at=Array.isArray(ve)?ve.map((yr,Dr)=>{let xe=QN(yr,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=k7(Reflect.get(xe,"match"),P,`localData.collections[${Dr}].match`),os=b1(xe,"persistence"),Pi=b1(xe,"sensitivity"),Us=b1(xe,"protection"),$a=b1(xe,"onProtectionUnavailable"),el=b1(xe,"evictionPriority"),of=b1(xe,"maxAgeMs");if(os!==void 0&&os!=="durable"&&os!=="memory-only")throw bf(P,`localData.collections[${Dr}].persistence is invalid.`);if(Pi!==void 0&&Pi!=="public"&&Pi!=="private"&&Pi!=="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($a!==void 0&&$a!=="error"&&$a!=="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,...Pi?{sensitivity:Pi}:{},...os?{persistence:os}:{},...Us?{protection:Us}:{},...$a?{onProtectionUnavailable:$a}:{},...el?{evictionPriority:el}:{},...of===void 0?{}:{maxAgeMs:C7(of,P,`localData.collections[${Dr}].maxAgeMs`)}}}):void 0,dt=Array.isArray($e)?$e.map((yr,Dr)=>{let xe=QN(yr,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"),os=b1(xe,"sensitivity"),Pi=b1(xe,"persistence"),Us=b1(xe,"onProtectionUnavailable"),$a=b1(xe,"conflict"),el;if($a!==void 0){let of=QN($a,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:C7(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(os!==void 0&&os!=="public"&&os!=="private"&&os!=="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(Pi!==void 0&&Pi!=="durable"&&Pi!=="memory-only")throw bf(P,`localData.mutations[${Dr}].persistence is invalid.`);return{match:k7(Reflect.get(xe,"match"),P,`localData.mutations[${Dr}].match`),...el?{conflict:el}:{},...os?{sensitivity:os}:{},...Us?{onProtectionUnavailable:Us}:{},...Pi?{persistence:Pi}:{},...Ot?{protection:Ot}:{}}}):void 0,cr=Reflect.get(M,"maxBytesPerNamespace");return{...at?{collections:at}:{},...dt?{mutations:dt}:{},...cr===void 0?{}:{maxBytesPerNamespace:C7(cr,P,"localData.maxBytesPerNamespace")}}},kLe=(v,P)=>{let M=QN(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=C7(Reflect.get(M,"version"),v,"version"),$e=Reflect.get(M,"minimumCompatibleVersion"),at=$e===void 0?Math.max(1,ve-2):C7($e,v,"minimumCompatibleVersion"),dt=Reflect.get(M,"migrations"),cr=Reflect.get(M,"localData");if(dt!==void 0&&!Array.isArray(dt))throw bf(v,"migrations must be an array.");let yr=Array.isArray(dt)?dt:void 0;return{id:v,...cr===void 0?{}:{localData:Q1t(cr,v)},minimumCompatibleVersion:at,...Array.isArray(yr)?{migrations:yr.map((Dr,xe)=>K1t(Dr,v,xe))}:{},version:ve}},Y1t=(v)=>[Reflect.get(v,"dependencies"),Reflect.get(v,"optionalDependencies"),Reflect.get(v,"devDependencies"),Reflect.get(v,"peerDependencies")].flatMap((P)=>E7(P)?Object.keys(P):[]).filter((P,M,z)=>z.indexOf(P)===M).sort(),w7=(v)=>{let P=CLe(ELe(v),"package.json"),M=p0e(P);if(!M)return{components:[{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}],sources:[]};let z=xLe(M),ce=[z===void 0?{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}:kLe("@absolutejs/app",z)],ve=[{id:"@absolutejs/app",manifestPath:P}];for(let $e of Y1t(M)){let at=G1t(v,$e);if(!at)continue;let dt=p0e(at);if(!dt)continue;let cr=xLe(dt);if(cr===void 0)continue;ce.push(kLe($e,cr)),ve.push({id:$e,manifestPath:at})}return ce.sort(($e,at)=>$e.id.localeCompare(at.id)),ve.sort(($e,at)=>$e.id.localeCompare(at.id)),TLe({},{components:ce}),{components:ce,sources:ve}};var W0=yvt(s9e());import{existsSync as PSt,readFileSync as M0e}from"fs";import{extname as DSt,join as L0e,relative as ISt,resolve as O7}from"path";import{fileURLToPath as NSt}from"url";var a9e="@absolutejs/devices",OSt=["keyboard","systemBars"],FSt={capacitor:"@absolutejs/devices-capacitor",expo:"@absolutejs/devices-expo"},RSt=new Bun.Glob("**/*.{js,jsx,ts,tsx,svelte,vue}"),MSt=new Set([".absolutejs",".git",".test-builds",".test-shards","build","dist","node_modules","test","tests"]),o9e=/^[A-Za-z_$][\w$]*$/u,LSt=(v)=>new RegExp(`^@absolutejs/devices-${v}/[a-z][a-z0-9-]*$`,"u"),jSt=(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,BSt=(v)=>v==="capacitor"?"Capacitor":"Expo",JSt=/^android\.permission\.[A-Z][A-Z0-9_]*$/u,USt=new Set(["camera","location-always","location-when-in-use","photo-library","photo-library-add"]),zSt={NSPrivacyAccessedAPICategoryFileTimestamp:new Set(["C617.1"])},yY=["NSPrivacyAccessedAPICategoryFileTimestamp"],L2=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),j0e=(v)=>{let P=JSON.parse(M0e(v,"utf8"));if(!L2(P))throw TypeError(`${v} must contain an object.`);return P},c9e=(v,P)=>{if(typeof v!=="string"||v.length===0)throw TypeError(`${P} must be a non-empty string.`);return v},WSt=(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"&&JSt.test(z)))throw TypeError(`${P}.permissions must contain Android permission names.`);return[...M]},VSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let M={};for(let z of yY){let ce=v[z];if(ce===void 0)continue;let ve=zSt[z];if(!Array.isArray(ce)||ce.length===0||!ce.every(($e)=>typeof $e==="string"&&ve.has($e)))throw TypeError(`${P} contains an unsupported API or reason.`);M[z]=[...ce]}if(Object.keys(v).some((z)=>!yY.some((ce)=>ce===z)))throw TypeError(`${P} contains an unsupported API or reason.`);return M},qSt=(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"&&USt.has(at))))throw TypeError(`${P}.usageDescriptions contains an unsupported purpose.`);let $e=VSt(M,`${P}.privacyAccessedApis`);return{...$e===void 0?{}:{privacyAccessedApis:$e},...z===!0?{pushNotifications:!0}:{},...ce===!0?{systemBars:!0}:{},...ve===void 0?{}:{usageDescriptions:[...ve]}}},$St=(v,P,M)=>{if(!o9e.test(v))throw TypeError("Device capability names must be identifiers.");if(!L2(P))throw TypeError(`Device capability ${v} must be an object.`);let z=c9e(P.factory,`${v}.factory`),ce=c9e(P.module,`${v}.module`);if(!o9e.test(z))throw TypeError(`${v}.factory must be a JavaScript identifier.`);if(!LSt(M).test(ce))throw TypeError(`${v}.module must be an official devices-${M} subpath.`);if(!Array.isArray(P.packages)||!P.packages.every((dt)=>typeof dt==="string"&&jSt(M).test(dt)))throw TypeError(`${v}.packages must contain exact official ${BSt(M)} package versions.`);let{plugins:ve}=P;if(ve!==void 0&&(!Array.isArray(ve)||!ve.every((dt)=>typeof dt==="string"&&/^expo-[a-z][a-z0-9-]*$/u.test(dt))))throw TypeError(`${v}.plugins must contain Expo config plugin names.`);let $e,{native:at}=P;if(at!==void 0){if(!L2(at))throw TypeError(`${v}.native must be an object.`);let{android:dt,ios:cr}=at,yr=WSt(dt,`${v}.native.android`),Dr=qSt(cr,`${v}.native.ios`);$e={...yr===void 0?{}:{android:{permissions:yr}},...Dr===void 0?{}:{ios:Dr}}}return{factory:z,module:ce,...$e===void 0?{}:{native:$e},...ve===void 0?{}:{plugins:[...ve]},packages:[...P.packages]}},e6=(v)=>{let P=v.capabilities.reduce((M,z)=>{for(let ce of yY){let ve=v.providers[z]?.native?.ios?.privacyAccessedApis?.[ce]??[];if(ve.length===0)continue;let $e=M[ce]??new Set;for(let at of ve)$e.add(at);M[ce]=$e}return M},{});return{androidPermissions:[...new Set(v.capabilities.flatMap((M)=>v.providers[M]?.native?.android?.permissions??[]))].sort(),iosPrivacyAccessedApis:yY.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()}},HSt=(v,P)=>{try{return NSt(import.meta.resolve(`${v}/package.json`))}catch{throw TypeError(`${v} is not installed. Run \`absolute mobile init\` to install the ${P==="expo"?"Expo":"Capacitor"} device adapters.`)}},l9e=(v,P="capacitor")=>{let M=FSt[P],z=L0e(O7(v),"node_modules",M,"package.json");try{M0e(z,"utf8")}catch{z=HSt(M,P)}let ce=j0e(z),{absolutejs:ve}=ce,$e=L2(ve)?ve.devices:void 0;if(!L2($e)||$e.format!==1||$e.provider!==P||!L2($e.capabilities))throw TypeError(`${M} does not publish supported capability metadata.`);let at=Object.entries($e.capabilities).map(([dt,cr])=>({name:dt,provider:$St(dt,cr,P)}));return Object.fromEntries(at.sort((dt,cr)=>dt.name.localeCompare(cr.name)).map(({name:dt,provider:cr})=>[dt,cr]))},GSt=(v)=>v.split("/").some((P)=>MSt.has(P)),XSt=(v,P)=>{let M=new Set,z=new Set,ce=(at)=>{if(W0.default.isImportDeclaration(at)&&W0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===a9e&&!at.importClause?.isTypeOnly){let dt=at.importClause?.namedBindings;if(dt&&W0.default.isNamedImports(dt)){for(let cr of dt.elements)if(!cr.isTypeOnly)M.add((cr.propertyName??cr.name).text)}if(dt&&W0.default.isNamespaceImport(dt))z.add(dt.name.text)}if(W0.default.isExportDeclaration(at)&&!at.isTypeOnly&&at.moduleSpecifier!==void 0&&W0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===a9e&&at.exportClause&&W0.default.isNamedExports(at.exportClause)){for(let dt of at.exportClause.elements)if(!dt.isTypeOnly)M.add((dt.propertyName??dt.name).text)}if(W0.default.isPropertyAccessExpression(at)&&W0.default.isIdentifier(at.expression)&&z.has(at.expression.text))M.add(at.name.text);W0.default.forEachChild(at,ce)},ve=DSt(P).toLowerCase(),$e=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,dt]of $e.entries())ce(W0.default.createSourceFile(`${P}#script-${at}`,dt,W0.default.ScriptTarget.Latest,!0,W0.default.ScriptKind.TSX));return M},u9e=(v,P)=>{let M=YSt(P,KSt(v)),z=P.requiredPackages.filter((ve)=>{let $e=ve.lastIndexOf("@"),at=ve.slice(0,$e);if(M.includes(ve))return!1;try{return j0e(L0e(O7(v),"node_modules",at,"package.json")).version!==ve.slice($e+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.`)},KSt=(v)=>{let P=j0e(L0e(O7(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},QSt=(v,P=l9e(v))=>{let M=O7(v);if(!PSt(M))return[];let z=new Set(Object.keys(P)),ce=new Set;for(let ve of RSt.scanSync({cwd:M})){let $e=ISt(M,O7(M,ve)).replaceAll("\\","/");if(GSt($e))continue;let at=M0e(O7(M,$e),"utf8");for(let dt of XSt(at,$e))if(z.has(dt))ce.add(dt)}return[...ce].sort()},YSt=(v,P)=>v.requiredPackages.filter((M)=>{let z=M.slice(0,M.lastIndexOf("@"));return!P.has(z)});var rP=(v,P="capacitor")=>{let M=l9e(v,P),z=QSt(v,M);for(let ve of OSt)if(M[ve]&&!z.includes(ve))z.push(ve);z.sort();let ce={};for(let ve of z){let $e=M[ve];if($e)ce[ve]=$e}return{capabilities:z,providers:ce,requiredPackages:[...new Set(z.flatMap((ve)=>ce[ve]?.packages??[]))].sort()}};import{createHash as eTt}from"crypto";var ZSt=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),B0e=(v)=>{if(Array.isArray(v))return v.map(B0e);if(!ZSt(v))return v;return Object.fromEntries(Object.keys(v).sort().map((P)=>[P,B0e(v[P])]))};var _9e=(v)=>JSON.stringify(B0e(v));var tTt=2,rTt=1,nTt=(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:rTt,shellAbi:tTt,syncSchema:v.syncSchema??null,updates:v.config.updates??null}),iTt=(v)=>eTt("sha256").update(_9e(v)).digest("hex"),vY=(v,P)=>{let M=_Y(P,v),z=M!==void 0&&ZA(P),ce=z?w7(P):void 0,ve=rP(P,v.engine),$e=nTt({...M?{auth:M}:{},config:v,deviceCapabilities:ve,...ce?{syncSchema:ce}:{}});return{auth:M,descriptor:$e,deviceCapabilities:ve,fingerprint:iTt($e),sync:z,syncSchema:ce}};import{join as t6}from"path";var TB=`// 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)},KN=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,T1t))]),v.exitCode===null)v.kill("SIGKILL")},u0e=(v)=>new Promise((P)=>{if(v.exitCode!==null){P(v.exitCode);return}v.once("exit",(M)=>P(M??1))}),gB=async(v,P,M,z)=>{let ce=v(P,M,{cwd:z.cwd,env:z.env??process.env,stdio:["ignore","pipe","pipe"]});cY(ce,z.log);let ve=()=>void KN(ce);z.signal?.addEventListener("abort",ve,{once:!0});let $e=await u0e(ce);if(z.signal?.removeEventListener("abort",ve),z.signal?.aborted)throw x7();return $e};var lLe=async(v)=>{let P=iLe(v.config,v),M=v.executable??await lY(P.project),z=v.spawnProcess??g1t,ce=v.host??XN(),ve=v.capture??P1t,$e=v.log??(()=>{return}),at={},dt=null,cr=async()=>{let li=dt;dt=null,await li?.close()},yr=(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 x7();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"]});cY(Jc,($u)=>{if($u)$e(`[prebuild] ${$u}`)});let pn=()=>void KN(Jc);v.signal?.addEventListener("abort",pn,{once:!0});let vg=await u0e(Jc);if(v.signal?.removeEventListener("abort",pn),v.signal?.aborted)throw x7();if(vg!==0)throw Dr("failed"),Error(`Expo native preparation exited with status ${vg}.`);yr("preparing-native",performance.now()-Xl)};if(xe)await Ot(xe);let os=Hn!==void 0;if(os)Dr("starting-metro");let Pi=performance.now(),Us,$a=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."))},v1t);cY(li,(kr)=>{if(kr)$e(`[metro] ${kr}`);if(w1t(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 l0e(kr??1,vg))})}),ei=async()=>{if(!Hn)return;if(v.signal?.aborted)throw x7();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 l0e)||!li.conflict||el.length>=b1t)throw li;await KN(Us);let Jc=await(v.allocateMetroPort??E1t)(el);if(!Number.isSafeInteger(Jc)||Jc<1||Jc>S1t||el.includes(Jc))throw Error("Could not allocate a distinct replacement Metro port.",{cause:li});el.push(Jc),$a+=1,$e("Metro port was claimed during startup; retrying automatically on a new port."),P=iLe(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)KN(Us)};v.signal?.addEventListener("abort",ln,{once:!0});let u_=async(li)=>{if(v.signal?.aborted)throw x7();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"?N1t(P.project,v.androidRoot??sY(ce),v.config.appId,li.args,ve,P.metroPort,v.androidDevice):[M,...li.args];if(Xl==="android"&&ce==="wsl")$e("[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"]});cY(rS,(bg)=>{if(bg)$e(`[${Xl}] ${bg}`)});let Gc=()=>void KN(rS);v.signal?.addEventListener("abort",Gc,{once:!0});let Kf=await u0e(rS);if(v.signal?.removeEventListener("abort",Gc),v.signal?.aborted)throw x7();if(Kf!==0)throw Error(`Expo ${Xl} development build exited with status ${Kf}.`);if(Xl==="android"&&ce!=="wsl"){let bg=v.androidRoot??process.env.ANDROID_HOME??process.env.ANDROID_SDK_ROOT??sY(ce),$0=v.androidAdb??sLe(bg,"platform-tools",ce==="windows"?"adb.exe":"adb");I1t($0,v.config.appId,P.metroPort,ve,v.androidDevice),$e("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&&$e(`[ios-trust] ${Wi}`)},U2=await gB(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 gB(z,"xcrun",["simctl","terminate","booted",v.config.appId],$0);let uP=await gB(z,"xcrun",["simctl","launch","booted",v.config.appId],$0);if(uP!==0)throw Error(`Expo iOS Simulator relaunch exited with status ${uP}.`);$e("Installed the AbsoluteJS development CA into the Expo iOS Simulator and relaunched the app."),yr("enrolling-trust",performance.now()-bg)}if(Xl==="ios"&&!v.iosDevice){let bg={cwd:P.project,signal:v.signal,log:(U2)=>U2&&$e(`[ios-connect] ${U2}`)};await gB(z,"xcrun",["simctl","terminate","booted",v.config.appId],bg);let $0=await gB(z,"xcrun",["simctl","openurl","booted",cLe(v.config.appId,v.metroHost??"localhost",P.metroPort)],bg);if($0!==0)throw Error(`Expo iOS Simulator Metro connection exited with status ${$0}.`);$e("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();dt=await(v.startCaEnrollmentServer??aY)({certificateAuthorityPath:v.certificateAuthorityPath,displayHost:new URL(v.iosOrigin).hostname}),$e(`On the iOS device, open ${dt.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.`),yr("enrolling-trust",performance.now()-li)};try{if(await RT(),await ei(),os)yr("starting-metro",performance.now()-Pi,{...$a>0?{reason:"metro-port-conflict",retryCount:$a}:{}});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 KN(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 KN(Us);throw await cr(),Dr("failed"),li}};import{access as UTt,mkdir as q0e,mkdtemp as zTt,readdir as k9e,readFile as CB,rename as xY,rm as CY,writeFile as $0e}from"fs/promises";import{createHash as kB}from"crypto";import{basename as WTt,dirname as EB,join as Gl,relative as V0e,resolve as VTt,sep as qTt}from"path";var F1t="0.8.1",R1t="0.9.5",uY="0.7.1",_0e="0.0.12";var DEt=["@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@${uY}`,`@absolutejs/devices-capacitor@${F1t}`],IEt=[`@absolutejs/sync-capacitor@${R1t}`,"@capacitor-community/sqlite@8.1.1"];var NEt=[`@absolutejs/devices@${uY}`,`@absolutejs/devices-expo@${_0e}`];import{readFileSync as M1t}from"fs";import{join as L1t}from"path";var j1t="@absolutejs/auth",uLe="0.76.3",_Le="@absolutejs/auth-expo",fLe="0.0.6",pLe="2.31.0",dLe="@absolutejs/sync-expo",mLe="0.0.4";var B1t=["openid","profile"],J1t="@absolutejs/sync",gLe=(v)=>{try{return JSON.parse(M1t(L1t(v,"package.json"),"utf8"))}catch{return}},hLe=(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))},U1t=(v)=>{let P=v.deepLinkScheme??v.appId.toLowerCase();return{clientId:`absolutejs-native:${v.appId}`,issuer:v.productionOrigin,redirectUri:`${P}://auth/callback`,scopes:[...B1t]}};var f0e=(v)=>hLe(gLe(v),j1t),ZA=(v)=>hLe(gLe(v),J1t),_Y=(v,P)=>f0e(v)?U1t(P):void 0;import{readFileSync as $1t}from"fs";import{dirname as H1t,join as CLe,resolve as ELe}from"path";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 fY=(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),yLe=(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(yLe(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(yLe(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 TLe=(v,P={version:1})=>{let M=V1t(P).map((ve)=>{let $e=vLe(ve.version,ve);return{id:ve.id,...vLe(v[ve.id]??$e.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 vLe=(v,P={version:1})=>{fY(v,"Stored Sync schema version");let M=fY(P.version,"Target Sync schema version"),z=[...P.migrations??[]].sort((dt,cr)=>dt.toVersion-cr.toVersion),ce=new Set;for(let dt of z){if(fY(dt.toVersion,"Sync migration toVersion"),ce.has(dt.toVersion))throw new pE("INVALID_PLAN",`Sync migration ${dt.toVersion} is declared more than once`);ce.add(dt.toVersion)}let ve=z[0]?z[0].toVersion-1:M,$e=fY(P.minimumCompatibleVersion??ve,"Minimum compatible Sync schema version");if($e>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<$e)throw new pE("SCHEMA_TOO_OLD",`Stored Sync schema ${v} is older than the minimum compatible schema ${$e}`,{storedVersion:v,targetVersion:M});let at=[];for(let dt=v+1;dt<=M;dt++){let cr=z.find((yr)=>yr.toVersion===dt);if(cr===void 0)throw new pE("MIGRATION_MISSING",`Sync migration ${dt-1} -> ${dt} is missing`,{storedVersion:v,targetVersion:M});at.push(cr)}return{minimumCompatibleVersion:$e,steps:at,targetVersion:M}};var bLe=Symbol.for("@absolutejs/sync/client-runtime-transport"),SLe=globalThis,q1t=(v)=>typeof v==="object"&&v!==null&&Array.isArray(Reflect.get(v,"installations"))&&Array.isArray(Reflect.get(v,"clients")),LEt=(()=>{let v=SLe[bLe];if(q1t(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(SLe,bLe,{configurable:!1,enumerable:!1,value:P,writable:!1}),P})();var E7=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),p0e=(v)=>{try{let P=JSON.parse($1t(v,"utf8"));return E7(P)?P:void 0}catch{return}},xLe=(v)=>{let P=Reflect.get(v,"absolutejs");if(!E7(P))return;let M=Reflect.get(P,"sync");if(!E7(M))return;return Reflect.get(M,"localSchema")},G1t=(v,P)=>{let M=ELe(v);while(!0){let z=CLe(M,"node_modules",P,"package.json"),ce=p0e(z);if(ce&&Reflect.get(ce,"name")===P)return z;let ve=H1t(M);if(ve===M)return;M=ve}},bf=(v,P)=>TypeError(`Invalid AbsoluteJS Sync schema metadata for ${v}: ${P}`),C7=(v,P,M)=>{if(typeof v!=="number"||!Number.isSafeInteger(v)||v<1)throw bf(P,`${M} must be a positive safe integer.`);return v},k7=(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},QN=(v,P,M)=>{if(!E7(v))throw bf(P,M);return v},b1=(v,P)=>v[P],d0e=(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)=>d0e(z,P,M));if(E7(v))return Object.fromEntries(Object.entries(v).map(([z,ce])=>[z,d0e(ce,P,M)]));throw bf(P,`${M} must be JSON-safe.`)},X1t=(v,P,M)=>{let z=QN(v,P,`migration operation ${M} must be an object.`),ce=Reflect.get(z,"type"),ve=k7(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:k7(Reflect.get(z,"from"),P,`operation ${M}.from`),to:k7(Reflect.get(z,"to"),P,`operation ${M}.to`),type:ce};let $e=k7(Reflect.get(z,"field"),P,`operation ${M}.field`);if(ce==="remove-field")return{collection:ve,field:$e,type:ce};if(ce==="set-default")return{collection:ve,field:$e,type:ce,value:d0e(Reflect.get(z,"value"),P,`operation ${M}.value`)};throw bf(P,`operation ${M}.type is not supported.`)},K1t=(v,P,M)=>{let z=QN(v,P,`migration ${M} must be an object.`),ce=new Set(["operations","toVersion"]),ve=Object.keys(z).find((dt)=>!ce.has(dt));if(ve)throw bf(P,`migration ${M}.${ve} is not declarative metadata.`);let $e=Reflect.get(z,"operations");if($e!==void 0&&!Array.isArray($e))throw bf(P,`migration ${M}.operations must be an array.`);return{operations:(Array.isArray($e)?$e:[]).map((dt,cr)=>X1t(dt,P,cr)),toVersion:C7(Reflect.get(z,"toVersion"),P,`migration ${M}.toVersion`)}},Q1t=(v,P)=>{let M=QN(v,P,"localData must be an object."),z=new Set(["collections","maxBytesPerNamespace","mutations"]),ce=Object.keys(M).find((yr)=>!z.has(yr));if(ce)throw bf(P,`localData.${ce} is not supported.`);let ve=Reflect.get(M,"collections"),$e=Reflect.get(M,"mutations");if(ve!==void 0&&!Array.isArray(ve))throw bf(P,"localData.collections must be an array.");if($e!==void 0&&!Array.isArray($e))throw bf(P,"localData.mutations must be an array.");let at=Array.isArray(ve)?ve.map((yr,Dr)=>{let xe=QN(yr,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=k7(Reflect.get(xe,"match"),P,`localData.collections[${Dr}].match`),os=b1(xe,"persistence"),Pi=b1(xe,"sensitivity"),Us=b1(xe,"protection"),$a=b1(xe,"onProtectionUnavailable"),el=b1(xe,"evictionPriority"),of=b1(xe,"maxAgeMs");if(os!==void 0&&os!=="durable"&&os!=="memory-only")throw bf(P,`localData.collections[${Dr}].persistence is invalid.`);if(Pi!==void 0&&Pi!=="public"&&Pi!=="private"&&Pi!=="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($a!==void 0&&$a!=="error"&&$a!=="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,...Pi?{sensitivity:Pi}:{},...os?{persistence:os}:{},...Us?{protection:Us}:{},...$a?{onProtectionUnavailable:$a}:{},...el?{evictionPriority:el}:{},...of===void 0?{}:{maxAgeMs:C7(of,P,`localData.collections[${Dr}].maxAgeMs`)}}}):void 0,dt=Array.isArray($e)?$e.map((yr,Dr)=>{let xe=QN(yr,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"),os=b1(xe,"sensitivity"),Pi=b1(xe,"persistence"),Us=b1(xe,"onProtectionUnavailable"),$a=b1(xe,"conflict"),el;if($a!==void 0){let of=QN($a,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:C7(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(os!==void 0&&os!=="public"&&os!=="private"&&os!=="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(Pi!==void 0&&Pi!=="durable"&&Pi!=="memory-only")throw bf(P,`localData.mutations[${Dr}].persistence is invalid.`);return{match:k7(Reflect.get(xe,"match"),P,`localData.mutations[${Dr}].match`),...el?{conflict:el}:{},...os?{sensitivity:os}:{},...Us?{onProtectionUnavailable:Us}:{},...Pi?{persistence:Pi}:{},...Ot?{protection:Ot}:{}}}):void 0,cr=Reflect.get(M,"maxBytesPerNamespace");return{...at?{collections:at}:{},...dt?{mutations:dt}:{},...cr===void 0?{}:{maxBytesPerNamespace:C7(cr,P,"localData.maxBytesPerNamespace")}}},kLe=(v,P)=>{let M=QN(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=C7(Reflect.get(M,"version"),v,"version"),$e=Reflect.get(M,"minimumCompatibleVersion"),at=$e===void 0?Math.max(1,ve-2):C7($e,v,"minimumCompatibleVersion"),dt=Reflect.get(M,"migrations"),cr=Reflect.get(M,"localData");if(dt!==void 0&&!Array.isArray(dt))throw bf(v,"migrations must be an array.");let yr=Array.isArray(dt)?dt:void 0;return{id:v,...cr===void 0?{}:{localData:Q1t(cr,v)},minimumCompatibleVersion:at,...Array.isArray(yr)?{migrations:yr.map((Dr,xe)=>K1t(Dr,v,xe))}:{},version:ve}},Y1t=(v)=>[Reflect.get(v,"dependencies"),Reflect.get(v,"optionalDependencies"),Reflect.get(v,"devDependencies"),Reflect.get(v,"peerDependencies")].flatMap((P)=>E7(P)?Object.keys(P):[]).filter((P,M,z)=>z.indexOf(P)===M).sort(),w7=(v)=>{let P=CLe(ELe(v),"package.json"),M=p0e(P);if(!M)return{components:[{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}],sources:[]};let z=xLe(M),ce=[z===void 0?{id:"@absolutejs/app",minimumCompatibleVersion:1,version:1}:kLe("@absolutejs/app",z)],ve=[{id:"@absolutejs/app",manifestPath:P}];for(let $e of Y1t(M)){let at=G1t(v,$e);if(!at)continue;let dt=p0e(at);if(!dt)continue;let cr=xLe(dt);if(cr===void 0)continue;ce.push(kLe($e,cr)),ve.push({id:$e,manifestPath:at})}return ce.sort(($e,at)=>$e.id.localeCompare(at.id)),ve.sort(($e,at)=>$e.id.localeCompare(at.id)),TLe({},{components:ce}),{components:ce,sources:ve}};var W0=yvt(s9e());import{existsSync as PSt,readFileSync as M0e}from"fs";import{extname as DSt,join as L0e,relative as ISt,resolve as O7}from"path";import{fileURLToPath as NSt}from"url";var a9e="@absolutejs/devices",OSt=["keyboard","systemBars"],FSt={capacitor:"@absolutejs/devices-capacitor",expo:"@absolutejs/devices-expo"},RSt=new Bun.Glob("**/*.{js,jsx,ts,tsx,svelte,vue}"),MSt=new Set([".absolutejs",".git",".test-builds",".test-shards","build","dist","node_modules","test","tests"]),o9e=/^[A-Za-z_$][\w$]*$/u,LSt=(v)=>new RegExp(`^@absolutejs/devices-${v}/[a-z][a-z0-9-]*$`,"u"),jSt=(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,BSt=(v)=>v==="capacitor"?"Capacitor":"Expo",JSt=/^android\.permission\.[A-Z][A-Z0-9_]*$/u,USt=new Set(["camera","location-always","location-when-in-use","photo-library","photo-library-add"]),zSt={NSPrivacyAccessedAPICategoryFileTimestamp:new Set(["C617.1"])},yY=["NSPrivacyAccessedAPICategoryFileTimestamp"],L2=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),j0e=(v)=>{let P=JSON.parse(M0e(v,"utf8"));if(!L2(P))throw TypeError(`${v} must contain an object.`);return P},c9e=(v,P)=>{if(typeof v!=="string"||v.length===0)throw TypeError(`${P} must be a non-empty string.`);return v},WSt=(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"&&JSt.test(z)))throw TypeError(`${P}.permissions must contain Android permission names.`);return[...M]},VSt=(v,P)=>{if(v===void 0)return;if(!L2(v))throw TypeError(`${P} must be an object.`);let M={};for(let z of yY){let ce=v[z];if(ce===void 0)continue;let ve=zSt[z];if(!Array.isArray(ce)||ce.length===0||!ce.every(($e)=>typeof $e==="string"&&ve.has($e)))throw TypeError(`${P} contains an unsupported API or reason.`);M[z]=[...ce]}if(Object.keys(v).some((z)=>!yY.some((ce)=>ce===z)))throw TypeError(`${P} contains an unsupported API or reason.`);return M},qSt=(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"&&USt.has(at))))throw TypeError(`${P}.usageDescriptions contains an unsupported purpose.`);let $e=VSt(M,`${P}.privacyAccessedApis`);return{...$e===void 0?{}:{privacyAccessedApis:$e},...z===!0?{pushNotifications:!0}:{},...ce===!0?{systemBars:!0}:{},...ve===void 0?{}:{usageDescriptions:[...ve]}}},$St=(v,P,M)=>{if(!o9e.test(v))throw TypeError("Device capability names must be identifiers.");if(!L2(P))throw TypeError(`Device capability ${v} must be an object.`);let z=c9e(P.factory,`${v}.factory`),ce=c9e(P.module,`${v}.module`);if(!o9e.test(z))throw TypeError(`${v}.factory must be a JavaScript identifier.`);if(!LSt(M).test(ce))throw TypeError(`${v}.module must be an official devices-${M} subpath.`);if(!Array.isArray(P.packages)||!P.packages.every((dt)=>typeof dt==="string"&&jSt(M).test(dt)))throw TypeError(`${v}.packages must contain exact official ${BSt(M)} package versions.`);let{plugins:ve}=P;if(ve!==void 0&&(!Array.isArray(ve)||!ve.every((dt)=>typeof dt==="string"&&/^expo-[a-z][a-z0-9-]*$/u.test(dt))))throw TypeError(`${v}.plugins must contain Expo config plugin names.`);let $e,{native:at}=P;if(at!==void 0){if(!L2(at))throw TypeError(`${v}.native must be an object.`);let{android:dt,ios:cr}=at,yr=WSt(dt,`${v}.native.android`),Dr=qSt(cr,`${v}.native.ios`);$e={...yr===void 0?{}:{android:{permissions:yr}},...Dr===void 0?{}:{ios:Dr}}}return{factory:z,module:ce,...$e===void 0?{}:{native:$e},...ve===void 0?{}:{plugins:[...ve]},packages:[...P.packages]}},e6=(v)=>{let P=v.capabilities.reduce((M,z)=>{for(let ce of yY){let ve=v.providers[z]?.native?.ios?.privacyAccessedApis?.[ce]??[];if(ve.length===0)continue;let $e=M[ce]??new Set;for(let at of ve)$e.add(at);M[ce]=$e}return M},{});return{androidPermissions:[...new Set(v.capabilities.flatMap((M)=>v.providers[M]?.native?.android?.permissions??[]))].sort(),iosPrivacyAccessedApis:yY.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()}},HSt=(v,P)=>{try{return NSt(import.meta.resolve(`${v}/package.json`))}catch{throw TypeError(`${v} is not installed. Run \`absolute mobile init\` to install the ${P==="expo"?"Expo":"Capacitor"} device adapters.`)}},l9e=(v,P="capacitor")=>{let M=FSt[P],z=L0e(O7(v),"node_modules",M,"package.json");try{M0e(z,"utf8")}catch{z=HSt(M,P)}let ce=j0e(z),{absolutejs:ve}=ce,$e=L2(ve)?ve.devices:void 0;if(!L2($e)||$e.format!==1||$e.provider!==P||!L2($e.capabilities))throw TypeError(`${M} does not publish supported capability metadata.`);let at=Object.entries($e.capabilities).map(([dt,cr])=>({name:dt,provider:$St(dt,cr,P)}));return Object.fromEntries(at.sort((dt,cr)=>dt.name.localeCompare(cr.name)).map(({name:dt,provider:cr})=>[dt,cr]))},GSt=(v)=>v.split("/").some((P)=>MSt.has(P)),XSt=(v,P)=>{let M=new Set,z=new Set,ce=(at)=>{if(W0.default.isImportDeclaration(at)&&W0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===a9e&&!at.importClause?.isTypeOnly){let dt=at.importClause?.namedBindings;if(dt&&W0.default.isNamedImports(dt)){for(let cr of dt.elements)if(!cr.isTypeOnly)M.add((cr.propertyName??cr.name).text)}if(dt&&W0.default.isNamespaceImport(dt))z.add(dt.name.text)}if(W0.default.isExportDeclaration(at)&&!at.isTypeOnly&&at.moduleSpecifier!==void 0&&W0.default.isStringLiteral(at.moduleSpecifier)&&at.moduleSpecifier.text===a9e&&at.exportClause&&W0.default.isNamedExports(at.exportClause)){for(let dt of at.exportClause.elements)if(!dt.isTypeOnly)M.add((dt.propertyName??dt.name).text)}if(W0.default.isPropertyAccessExpression(at)&&W0.default.isIdentifier(at.expression)&&z.has(at.expression.text))M.add(at.name.text);W0.default.forEachChild(at,ce)},ve=DSt(P).toLowerCase(),$e=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,dt]of $e.entries())ce(W0.default.createSourceFile(`${P}#script-${at}`,dt,W0.default.ScriptTarget.Latest,!0,W0.default.ScriptKind.TSX));return M},u9e=(v,P)=>{let M=YSt(P,KSt(v)),z=P.requiredPackages.filter((ve)=>{let $e=ve.lastIndexOf("@"),at=ve.slice(0,$e);if(M.includes(ve))return!1;try{return j0e(L0e(O7(v),"node_modules",at,"package.json")).version!==ve.slice($e+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.`)},KSt=(v)=>{let P=j0e(L0e(O7(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},QSt=(v,P=l9e(v))=>{let M=O7(v);if(!PSt(M))return[];let z=new Set(Object.keys(P)),ce=new Set;for(let ve of RSt.scanSync({cwd:M})){let $e=ISt(M,O7(M,ve)).replaceAll("\\","/");if(GSt($e))continue;let at=M0e(O7(M,$e),"utf8");for(let dt of XSt(at,$e))if(z.has(dt))ce.add(dt)}return[...ce].sort()},YSt=(v,P)=>v.requiredPackages.filter((M)=>{let z=M.slice(0,M.lastIndexOf("@"));return!P.has(z)});var rP=(v,P="capacitor")=>{let M=l9e(v,P),z=QSt(v,M);for(let ve of OSt)if(M[ve]&&!z.includes(ve))z.push(ve);z.sort();let ce={};for(let ve of z){let $e=M[ve];if($e)ce[ve]=$e}return{capabilities:z,providers:ce,requiredPackages:[...new Set(z.flatMap((ve)=>ce[ve]?.packages??[]))].sort()}};import{createHash as eTt}from"crypto";var ZSt=(v)=>typeof v==="object"&&v!==null&&!Array.isArray(v),B0e=(v)=>{if(Array.isArray(v))return v.map(B0e);if(!ZSt(v))return v;return Object.fromEntries(Object.keys(v).sort().map((P)=>[P,B0e(v[P])]))};var _9e=(v)=>JSON.stringify(B0e(v));var tTt=2,rTt=1,nTt=(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:rTt,shellAbi:tTt,syncSchema:v.syncSchema??null,updates:v.config.updates??null}),iTt=(v)=>eTt("sha256").update(_9e(v)).digest("hex"),vY=(v,P)=>{let M=_Y(P,v),z=M!==void 0&&ZA(P),ce=z?w7(P):void 0,ve=rP(P,v.engine),$e=nTt({...M?{auth:M}:{},config:v,deviceCapabilities:ve,...ce?{syncSchema:ce}:{}});return{auth:M,descriptor:$e,deviceCapabilities:ve,fingerprint:iTt($e),sync:z,syncSchema:ce}};import{join as t6}from"path";var TB=`// Generated by AbsoluteJS. Edit absolute.config.ts, then run absolute mobile sync.
|
|
480
480
|
`,sTt=`<!-- Generated by AbsoluteJS. Edit absolute.config.ts, then run absolute mobile sync. -->
|
|
481
481
|
`,aTt=`${JSON.stringify({android:{modules:["expo.modules.absolutemobileobservability.AbsoluteMobileObservabilityModule"]},apple:{modules:["AbsoluteMobileObservabilityModule"]},platforms:["apple","android"]},null,2)}
|
|
482
482
|
`,oTt=`${TB}Pod::Spec.new do |s|
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/runtime/clientAssetArchive.ts
|
|
3
|
+
import {
|
|
4
|
+
mkdir,
|
|
5
|
+
readdir,
|
|
6
|
+
readFile,
|
|
7
|
+
rename,
|
|
8
|
+
rm,
|
|
9
|
+
stat,
|
|
10
|
+
writeFile
|
|
11
|
+
} from "fs/promises";
|
|
12
|
+
import { dirname, join, resolve } from "path";
|
|
13
|
+
import { randomUUID } from "crypto";
|
|
14
|
+
var PREFIX = "/_absolute/assets/";
|
|
15
|
+
var GRAPH_ID = /^[a-f0-9]{64}$/;
|
|
16
|
+
var MAX_GRAPHS = 3;
|
|
17
|
+
var MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
18
|
+
var MAX_BYTES = 512 * 1024 * 1024;
|
|
19
|
+
var safePath = (path) => path.length > 0 && !path.includes("\\") && !path.includes("\x00") && path.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
20
|
+
var sequentially = (items, action) => items.reduce((pending, value) => pending.then(() => action(value)), Promise.resolve());
|
|
21
|
+
var readManifest = async (directory) => {
|
|
22
|
+
try {
|
|
23
|
+
const value = JSON.parse(await readFile(join(directory, "graph.json"), "utf8"));
|
|
24
|
+
if (!value || typeof value !== "object")
|
|
25
|
+
return;
|
|
26
|
+
const createdAt = Reflect.get(value, "createdAt");
|
|
27
|
+
const bytes = Reflect.get(value, "bytes");
|
|
28
|
+
const paths = Reflect.get(value, "paths");
|
|
29
|
+
const retiredAt = Reflect.get(value, "retiredAt");
|
|
30
|
+
if (retiredAt !== undefined && (typeof retiredAt !== "number" || !Number.isFinite(retiredAt)))
|
|
31
|
+
return;
|
|
32
|
+
if (typeof createdAt !== "number" || !Number.isFinite(createdAt) || typeof bytes !== "number" || !Number.isSafeInteger(bytes) || bytes < 0 || !Array.isArray(paths) || !paths.every((path) => typeof path === "string" && safePath(path)))
|
|
33
|
+
return;
|
|
34
|
+
const manifest = {
|
|
35
|
+
bytes,
|
|
36
|
+
createdAt,
|
|
37
|
+
paths,
|
|
38
|
+
...typeof retiredAt === "number" ? { retiredAt } : {}
|
|
39
|
+
};
|
|
40
|
+
return manifest;
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var commitGraph = async (temporary, destination) => {
|
|
46
|
+
try {
|
|
47
|
+
await rename(temporary, destination);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (!await readManifest(destination))
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var sourceFile = (source) => typeof source === "string" ? Bun.file(source) : source;
|
|
54
|
+
var graphBytes = (entries) => entries.reduce((bytes, [, source]) => bytes + sourceFile(source).size, 0);
|
|
55
|
+
var publishGraph = async (directory, id, entries, now) => {
|
|
56
|
+
const destination = join(directory, id);
|
|
57
|
+
if (await readManifest(destination))
|
|
58
|
+
return;
|
|
59
|
+
const bytes = graphBytes(entries);
|
|
60
|
+
if (bytes > MAX_BYTES)
|
|
61
|
+
throw new Error("Client asset graph exceeds archive byte limit");
|
|
62
|
+
const temporary = join(directory, `.pending-${randomUUID()}`);
|
|
63
|
+
const manifest = {
|
|
64
|
+
bytes,
|
|
65
|
+
createdAt: now,
|
|
66
|
+
paths: entries.map(([path]) => path)
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
await sequentially(entries, async ([path, source]) => {
|
|
70
|
+
const target = join(temporary, "files", path);
|
|
71
|
+
await mkdir(dirname(target), { recursive: true });
|
|
72
|
+
await Bun.write(target, sourceFile(source));
|
|
73
|
+
});
|
|
74
|
+
await writeFile(join(temporary, "graph.json"), JSON.stringify(manifest));
|
|
75
|
+
await commitGraph(temporary, destination);
|
|
76
|
+
} finally {
|
|
77
|
+
await rm(temporary, { force: true, recursive: true });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var cleanAbandonedStage = async (path, now) => {
|
|
81
|
+
if (now - (await stat(path)).mtimeMs <= MAX_AGE_MS)
|
|
82
|
+
return;
|
|
83
|
+
await rm(path, { force: true, recursive: true });
|
|
84
|
+
};
|
|
85
|
+
var listGraphs = async (directory, now) => {
|
|
86
|
+
const graphs = [];
|
|
87
|
+
await sequentially(await readdir(directory, { withFileTypes: true }), async (entry) => {
|
|
88
|
+
if (!entry.isDirectory())
|
|
89
|
+
return;
|
|
90
|
+
const path = join(directory, entry.name);
|
|
91
|
+
if (/^\.pending-[a-f0-9-]+$/.test(entry.name)) {
|
|
92
|
+
await cleanAbandonedStage(path, now);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!GRAPH_ID.test(entry.name))
|
|
96
|
+
return;
|
|
97
|
+
const manifest = await readManifest(path);
|
|
98
|
+
if (manifest)
|
|
99
|
+
graphs.push({ id: entry.name, manifest });
|
|
100
|
+
});
|
|
101
|
+
return graphs;
|
|
102
|
+
};
|
|
103
|
+
var atomicArchiveJson = async (directory, target, value) => {
|
|
104
|
+
const temporary = join(directory, `.pending-${randomUUID()}`);
|
|
105
|
+
await mkdir(temporary);
|
|
106
|
+
try {
|
|
107
|
+
const source = join(temporary, "data.json");
|
|
108
|
+
await writeFile(source, JSON.stringify(value));
|
|
109
|
+
await rename(source, target);
|
|
110
|
+
} finally {
|
|
111
|
+
await rm(temporary, { force: true, recursive: true });
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var readActiveGraphs = async (directory) => {
|
|
115
|
+
try {
|
|
116
|
+
const value = JSON.parse(await readFile(join(directory, "active.json"), "utf8"));
|
|
117
|
+
return Array.isArray(value) ? value.filter((id) => typeof id === "string" && GRAPH_ID.test(id)) : [];
|
|
118
|
+
} catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var recordActivation = async (directory, current, now) => {
|
|
123
|
+
const previous = await readActiveGraphs(directory);
|
|
124
|
+
await sequentially(previous.filter((id) => !current.has(id)), async (id) => {
|
|
125
|
+
const path = join(directory, id);
|
|
126
|
+
const manifest = await readManifest(path);
|
|
127
|
+
if (!manifest || manifest.retiredAt !== undefined)
|
|
128
|
+
return;
|
|
129
|
+
await atomicArchiveJson(directory, join(path, "graph.json"), {
|
|
130
|
+
...manifest,
|
|
131
|
+
retiredAt: now
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
await sequentially([...current], async (id) => {
|
|
135
|
+
const path = join(directory, id);
|
|
136
|
+
const manifest = await readManifest(path);
|
|
137
|
+
if (!manifest || manifest.retiredAt === undefined)
|
|
138
|
+
return;
|
|
139
|
+
const active = {
|
|
140
|
+
bytes: manifest.bytes,
|
|
141
|
+
createdAt: manifest.createdAt,
|
|
142
|
+
paths: manifest.paths
|
|
143
|
+
};
|
|
144
|
+
await atomicArchiveJson(directory, join(path, "graph.json"), active);
|
|
145
|
+
});
|
|
146
|
+
await atomicArchiveJson(directory, join(directory, "active.json"), [
|
|
147
|
+
...current
|
|
148
|
+
]);
|
|
149
|
+
};
|
|
150
|
+
var retentionTime = (graph) => graph.manifest.retiredAt ?? graph.manifest.createdAt;
|
|
151
|
+
var collectGraphs = (assets) => {
|
|
152
|
+
const groups = new Map;
|
|
153
|
+
for (const [url, file] of Object.entries(assets)) {
|
|
154
|
+
if (!url.startsWith(PREFIX))
|
|
155
|
+
continue;
|
|
156
|
+
const [id, ...parts] = url.slice(PREFIX.length).split("/");
|
|
157
|
+
const path = parts.join("/");
|
|
158
|
+
if (!id || !GRAPH_ID.test(id) || !safePath(path))
|
|
159
|
+
continue;
|
|
160
|
+
const group = groups.get(id) ?? [];
|
|
161
|
+
group.push([path, file]);
|
|
162
|
+
groups.set(id, group);
|
|
163
|
+
}
|
|
164
|
+
return groups;
|
|
165
|
+
};
|
|
166
|
+
var findRetainedAsset = async (directory, retained, pathname) => {
|
|
167
|
+
if (!pathname.startsWith(PREFIX))
|
|
168
|
+
return;
|
|
169
|
+
const [id, ...parts] = pathname.slice(PREFIX.length).split("/");
|
|
170
|
+
const path = parts.join("/");
|
|
171
|
+
if (!id || !safePath(path) || !retained.get(id)?.has(path))
|
|
172
|
+
return;
|
|
173
|
+
const file = join(directory, id, "files", path);
|
|
174
|
+
try {
|
|
175
|
+
if (!(await stat(file)).isFile())
|
|
176
|
+
return;
|
|
177
|
+
} catch {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
return Bun.file(file);
|
|
181
|
+
};
|
|
182
|
+
var createClientAssetArchive = async (assets, directory = resolve(process.env.ABSOLUTE_ASSET_ARCHIVE_DIR || ".absolutejs/client-assets"), now = Date.now()) => {
|
|
183
|
+
const groups = collectGraphs(assets);
|
|
184
|
+
const currentBytes = [...groups.values()].reduce((bytes, entries) => bytes + graphBytes(entries), 0);
|
|
185
|
+
if (currentBytes > MAX_BYTES || groups.size > MAX_GRAPHS)
|
|
186
|
+
throw new Error("Current client graphs exceed archive limits");
|
|
187
|
+
await mkdir(directory, { recursive: true });
|
|
188
|
+
await sequentially([...groups], ([id, entries]) => publishGraph(directory, id, entries, now));
|
|
189
|
+
await recordActivation(directory, new Set(groups.keys()), now);
|
|
190
|
+
const graphs = await listGraphs(directory, now);
|
|
191
|
+
graphs.sort((a, b) => Number(groups.has(b.id)) - Number(groups.has(a.id)) || retentionTime(b) - retentionTime(a));
|
|
192
|
+
let bytes = 0;
|
|
193
|
+
let count = 0;
|
|
194
|
+
const retained = new Map;
|
|
195
|
+
await sequentially(graphs, async (graph) => {
|
|
196
|
+
const expired = now - retentionTime(graph) > MAX_AGE_MS;
|
|
197
|
+
if (!groups.has(graph.id) && (expired || count >= MAX_GRAPHS || bytes + graph.manifest.bytes > MAX_BYTES)) {
|
|
198
|
+
await rm(join(directory, graph.id), {
|
|
199
|
+
force: true,
|
|
200
|
+
recursive: true
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
count++;
|
|
205
|
+
bytes += graph.manifest.bytes;
|
|
206
|
+
retained.set(graph.id, new Set(graph.manifest.paths));
|
|
207
|
+
});
|
|
208
|
+
return (pathname) => findRetainedAsset(directory, retained, pathname);
|
|
209
|
+
};
|
|
210
|
+
export {
|
|
211
|
+
createClientAssetArchive
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
//# debugId=7C1C3482FC40FA1B64756E2164756E21
|
|
215
|
+
//# sourceMappingURL=clientAssetArchive.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runtime/clientAssetArchive.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n\tmkdir,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, join, resolve } from 'node:path';\nimport { randomUUID } from 'node:crypto';\n\nconst PREFIX = '/_absolute/assets/';\nconst GRAPH_ID = /^[a-f0-9]{64}$/;\nconst MAX_GRAPHS = 3;\nconst MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;\nconst MAX_BYTES = 512 * 1024 * 1024;\n\ntype GraphManifest = {\n\tbytes: number;\n\tcreatedAt: number;\n\tpaths: string[];\n\tretiredAt?: number;\n};\ntype StoredGraph = { id: string; manifest: GraphManifest };\ntype AssetEntry = [string, string | Blob];\nconst safePath = (path: string) =>\n\tpath.length > 0 &&\n\t!path.includes('\\\\') &&\n\t!path.includes('\\0') &&\n\tpath\n\t\t.split('/')\n\t\t.every((part) => part.length > 0 && part !== '.' && part !== '..');\nconst sequentially = <Value>(\n\titems: Value[],\n\taction: (value: Value) => Promise<void>\n) =>\n\titems.reduce<Promise<void>>(\n\t\t(pending, value) => pending.then(() => action(value)),\n\t\tPromise.resolve()\n\t);\n\nconst readManifest = async (directory: string) => {\n\ttry {\n\t\tconst value: unknown = JSON.parse(\n\t\t\tawait readFile(join(directory, 'graph.json'), 'utf8')\n\t\t);\n\t\tif (!value || typeof value !== 'object') return undefined;\n\t\tconst createdAt: unknown = Reflect.get(value, 'createdAt');\n\t\tconst bytes: unknown = Reflect.get(value, 'bytes');\n\t\tconst paths: unknown = Reflect.get(value, 'paths');\n\t\tconst retiredAt: unknown = Reflect.get(value, 'retiredAt');\n\t\tif (\n\t\t\tretiredAt !== undefined &&\n\t\t\t(typeof retiredAt !== 'number' || !Number.isFinite(retiredAt))\n\t\t)\n\t\t\treturn undefined;\n\t\tif (\n\t\t\ttypeof createdAt !== 'number' ||\n\t\t\t!Number.isFinite(createdAt) ||\n\t\t\ttypeof bytes !== 'number' ||\n\t\t\t!Number.isSafeInteger(bytes) ||\n\t\t\tbytes < 0 ||\n\t\t\t!Array.isArray(paths) ||\n\t\t\t!paths.every(\n\t\t\t\t(path): path is string =>\n\t\t\t\t\ttypeof path === 'string' && safePath(path)\n\t\t\t)\n\t\t)\n\t\t\treturn undefined;\n\t\tconst manifest: GraphManifest = {\n\t\t\tbytes,\n\t\t\tcreatedAt,\n\t\t\tpaths,\n\t\t\t...(typeof retiredAt === 'number' ? { retiredAt } : {})\n\t\t};\n\n\t\treturn manifest;\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nconst commitGraph = async (temporary: string, destination: string) => {\n\ttry {\n\t\tawait rename(temporary, destination);\n\t} catch (error) {\n\t\tif (!(await readManifest(destination))) throw error;\n\t}\n};\n\nconst sourceFile = (source: string | Blob) =>\n\ttypeof source === 'string' ? Bun.file(source) : source;\nconst graphBytes = (entries: AssetEntry[]) =>\n\tentries.reduce((bytes, [, source]) => bytes + sourceFile(source).size, 0);\nconst publishGraph = async (\n\tdirectory: string,\n\tid: string,\n\tentries: AssetEntry[],\n\tnow: number\n) => {\n\tconst destination = join(directory, id);\n\tif (await readManifest(destination)) return;\n\tconst bytes = graphBytes(entries);\n\tif (bytes > MAX_BYTES)\n\t\tthrow new Error('Client asset graph exceeds archive byte limit');\n\tconst temporary = join(directory, `.pending-${randomUUID()}`);\n\tconst manifest: GraphManifest = {\n\t\tbytes,\n\t\tcreatedAt: now,\n\t\tpaths: entries.map(([path]) => path)\n\t};\n\ttry {\n\t\tawait sequentially(entries, async ([path, source]) => {\n\t\t\tconst target = join(temporary, 'files', path);\n\t\t\tawait mkdir(dirname(target), { recursive: true });\n\t\t\tawait Bun.write(target, sourceFile(source));\n\t\t});\n\t\tawait writeFile(\n\t\t\tjoin(temporary, 'graph.json'),\n\t\t\tJSON.stringify(manifest)\n\t\t);\n\t\tawait commitGraph(temporary, destination);\n\t} finally {\n\t\tawait rm(temporary, { force: true, recursive: true });\n\t}\n};\n\nconst cleanAbandonedStage = async (path: string, now: number) => {\n\tif (now - (await stat(path)).mtimeMs <= MAX_AGE_MS) return;\n\tawait rm(path, { force: true, recursive: true });\n};\n\nconst listGraphs = async (directory: string, now: number) => {\n\tconst graphs: StoredGraph[] = [];\n\tawait sequentially(\n\t\tawait readdir(directory, { withFileTypes: true }),\n\t\tasync (entry) => {\n\t\t\tif (!entry.isDirectory()) return;\n\t\t\tconst path = join(directory, entry.name);\n\t\t\tif (/^\\.pending-[a-f0-9-]+$/.test(entry.name)) {\n\t\t\t\tawait cleanAbandonedStage(path, now);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!GRAPH_ID.test(entry.name)) return;\n\t\t\tconst manifest = await readManifest(path);\n\t\t\tif (manifest) graphs.push({ id: entry.name, manifest });\n\t\t}\n\t);\n\n\treturn graphs;\n};\n\nconst atomicArchiveJson = async (\n\tdirectory: string,\n\ttarget: string,\n\tvalue: unknown\n) => {\n\tconst temporary = join(directory, `.pending-${randomUUID()}`);\n\tawait mkdir(temporary);\n\ttry {\n\t\tconst source = join(temporary, 'data.json');\n\t\tawait writeFile(source, JSON.stringify(value));\n\t\tawait rename(source, target);\n\t} finally {\n\t\tawait rm(temporary, { force: true, recursive: true });\n\t}\n};\n\nconst readActiveGraphs = async (directory: string) => {\n\ttry {\n\t\tconst value: unknown = JSON.parse(\n\t\t\tawait readFile(join(directory, 'active.json'), 'utf8')\n\t\t);\n\n\t\treturn Array.isArray(value)\n\t\t\t? value.filter(\n\t\t\t\t\t(id): id is string =>\n\t\t\t\t\t\ttypeof id === 'string' && GRAPH_ID.test(id)\n\t\t\t\t)\n\t\t\t: [];\n\t} catch {\n\t\treturn [];\n\t}\n};\n\nconst recordActivation = async (\n\tdirectory: string,\n\tcurrent: Set<string>,\n\tnow: number\n) => {\n\tconst previous = await readActiveGraphs(directory);\n\tawait sequentially(\n\t\tprevious.filter((id) => !current.has(id)),\n\t\tasync (id) => {\n\t\t\tconst path = join(directory, id);\n\t\t\tconst manifest = await readManifest(path);\n\t\t\tif (!manifest || manifest.retiredAt !== undefined) return;\n\t\t\tawait atomicArchiveJson(directory, join(path, 'graph.json'), {\n\t\t\t\t...manifest,\n\t\t\t\tretiredAt: now\n\t\t\t});\n\t\t}\n\t);\n\tawait sequentially([...current], async (id) => {\n\t\tconst path = join(directory, id);\n\t\tconst manifest = await readManifest(path);\n\t\tif (!manifest || manifest.retiredAt === undefined) return;\n\t\tconst active: GraphManifest = {\n\t\t\tbytes: manifest.bytes,\n\t\t\tcreatedAt: manifest.createdAt,\n\t\t\tpaths: manifest.paths\n\t\t};\n\t\tawait atomicArchiveJson(directory, join(path, 'graph.json'), active);\n\t});\n\tawait atomicArchiveJson(directory, join(directory, 'active.json'), [\n\t\t...current\n\t]);\n};\n\nconst retentionTime = (graph: StoredGraph) =>\n\tgraph.manifest.retiredAt ?? graph.manifest.createdAt;\n\nconst collectGraphs = (assets: Record<string, string | Blob>) => {\n\tconst groups = new Map<string, AssetEntry[]>();\n\tfor (const [url, file] of Object.entries(assets)) {\n\t\tif (!url.startsWith(PREFIX)) continue;\n\t\tconst [id, ...parts] = url.slice(PREFIX.length).split('/');\n\t\tconst path = parts.join('/');\n\t\tif (!id || !GRAPH_ID.test(id) || !safePath(path)) continue;\n\t\tconst group = groups.get(id) ?? [];\n\t\tgroup.push([path, file]);\n\t\tgroups.set(id, group);\n\t}\n\n\treturn groups;\n};\n\nconst findRetainedAsset = async (\n\tdirectory: string,\n\tretained: Map<string, Set<string>>,\n\tpathname: string\n) => {\n\tif (!pathname.startsWith(PREFIX)) return undefined;\n\tconst [id, ...parts] = pathname.slice(PREFIX.length).split('/');\n\tconst path = parts.join('/');\n\tif (!id || !safePath(path) || !retained.get(id)?.has(path))\n\t\treturn undefined;\n\tconst file = join(directory, id, 'files', path);\n\ttry {\n\t\tif (!(await stat(file)).isFile()) return undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\treturn Bun.file(file);\n};\n\n/** Persist only explicitly namespaced browser assets in a directory shared by\n * releases. Atomic publication preserves previous graphs on failure; sequential\n * writes bound memory. Current assets are always served from the executable.\n */\nexport const createClientAssetArchive = async (\n\tassets: Record<string, string | Blob>,\n\tdirectory = resolve(\n\t\tprocess.env.ABSOLUTE_ASSET_ARCHIVE_DIR || '.absolutejs/client-assets'\n\t),\n\tnow = Date.now()\n) => {\n\tconst groups = collectGraphs(assets);\n\tconst currentBytes = [...groups.values()].reduce(\n\t\t(bytes, entries) => bytes + graphBytes(entries),\n\t\t0\n\t);\n\tif (currentBytes > MAX_BYTES || groups.size > MAX_GRAPHS)\n\t\tthrow new Error('Current client graphs exceed archive limits');\n\tawait mkdir(directory, { recursive: true });\n\tawait sequentially([...groups], ([id, entries]) =>\n\t\tpublishGraph(directory, id, entries, now)\n\t);\n\tawait recordActivation(directory, new Set(groups.keys()), now);\n\tconst graphs = await listGraphs(directory, now);\n\tgraphs.sort(\n\t\t(a, b) =>\n\t\t\tNumber(groups.has(b.id)) - Number(groups.has(a.id)) ||\n\t\t\tretentionTime(b) - retentionTime(a)\n\t);\n\tlet bytes = 0;\n\tlet count = 0;\n\tconst retained = new Map<string, Set<string>>();\n\tawait sequentially(graphs, async (graph) => {\n\t\tconst expired = now - retentionTime(graph) > MAX_AGE_MS;\n\t\tif (\n\t\t\t!groups.has(graph.id) &&\n\t\t\t(expired ||\n\t\t\t\tcount >= MAX_GRAPHS ||\n\t\t\t\tbytes + graph.manifest.bytes > MAX_BYTES)\n\t\t) {\n\t\t\tawait rm(join(directory, graph.id), {\n\t\t\t\tforce: true,\n\t\t\t\trecursive: true\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\t\tcount++;\n\t\tbytes += graph.manifest.bytes;\n\t\tretained.set(graph.id, new Set(graph.manifest.paths));\n\t});\n\n\treturn (pathname: string) =>\n\t\tfindRetainedAsset(directory, retained, pathname);\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "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",
|
|
8
|
+
"debugId": "7C1C3482FC40FA1B64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CLIENT_GRAPH_PREFIX = "/_absolute/assets/";
|
|
2
|
+
export declare const isClientGraphAsset: (path: string) => boolean;
|
|
3
|
+
/** Namespace the complete browser graph, including stable vendor filenames.
|
|
4
|
+
* Relative imports stay within the graph. Original URLs remain current-release
|
|
5
|
+
* aliases; application strings, API paths and SW registration scopes stay intact.
|
|
6
|
+
*/
|
|
7
|
+
export declare const prepareCompiledClientGraph: (directory: string, serverBundle: string, publicDirectory?: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const ABSOLUTE_CAPACITOR_DEVICES_VERSION = "0.8.
|
|
2
|
-
export declare const ABSOLUTE_CAPACITOR_SYNC_VERSION = "0.9.
|
|
1
|
+
export declare const ABSOLUTE_CAPACITOR_DEVICES_VERSION = "0.8.1";
|
|
2
|
+
export declare const ABSOLUTE_CAPACITOR_SYNC_VERSION = "0.9.5";
|
|
3
3
|
export declare const ABSOLUTE_DEVICES_VERSION = "0.7.1";
|
|
4
4
|
export declare const ABSOLUTE_EXPO_DEVICES_VERSION = "0.0.12";
|
|
5
5
|
export declare const ABSOLUTE_NATIVE_EXACT_PACKAGES: Set<string>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Persist only explicitly namespaced browser assets in a directory shared by
|
|
2
|
+
* releases. Atomic publication preserves previous graphs on failure; sequential
|
|
3
|
+
* writes bound memory. Current assets are always served from the executable.
|
|
4
|
+
*/
|
|
5
|
+
export declare const createClientAssetArchive: (assets: Record<string, string | Blob>, directory?: string, now?: number) => Promise<(pathname: string) => Promise<Bun.BunFile | undefined>>;
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@absolutejs/bvm": "^0.1.1",
|
|
13
13
|
"@absolutejs/deploy": "0.27.0",
|
|
14
14
|
"@absolutejs/devices": "0.7.1",
|
|
15
|
-
"@absolutejs/devices-capacitor": "0.8.
|
|
15
|
+
"@absolutejs/devices-capacitor": "0.8.1",
|
|
16
16
|
"@absolutejs/http": "0.0.1",
|
|
17
17
|
"@absolutejs/pwa": "0.16.3",
|
|
18
18
|
"@capacitor/browser": "8.0.4",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@absolutejs/manifest": "0.9.0",
|
|
40
40
|
"@absolutejs/scoped-state": "0.2.2",
|
|
41
41
|
"@absolutejs/sync": "3.0.0",
|
|
42
|
-
"@absolutejs/sync-capacitor": "0.9.
|
|
42
|
+
"@absolutejs/sync-capacitor": "0.9.5",
|
|
43
43
|
"@absolutejs/sync-expo": "0.0.5",
|
|
44
44
|
"@angular/animations": "21.2.6",
|
|
45
45
|
"@angular/cdk": "21.2.6",
|
|
@@ -563,7 +563,7 @@
|
|
|
563
563
|
]
|
|
564
564
|
}
|
|
565
565
|
},
|
|
566
|
-
"version": "0.20.0-beta.
|
|
566
|
+
"version": "0.20.0-beta.156",
|
|
567
567
|
"workspaces": [
|
|
568
568
|
"tests/fixtures/*",
|
|
569
569
|
"tests/fixtures/_packages/*"
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
SENTINEL,
|
|
4
|
-
maskLiterals
|
|
5
|
-
} from "./index-039rh39e.js";
|
|
6
|
-
|
|
7
|
-
// src/build/specifierRewriter.ts
|
|
8
|
-
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9
|
-
var PLACEHOLDER = `${SENTINEL}\\d+${SENTINEL}`;
|
|
10
|
-
var GAP = `(?:\\s|${PLACEHOLDER}|/\\*${PLACEHOLDER}\\*/|//${PLACEHOLDER})*`;
|
|
11
|
-
var QUOTE = `["']`;
|
|
12
|
-
var ADJACENT_PREFIXES = [`from\\s*${QUOTE}`, `import\\s*${QUOTE}`];
|
|
13
|
-
var ADJACENT_DYNAMIC_PREFIX = `import\\s*\\(\\s*${QUOTE}`;
|
|
14
|
-
var ADJACENT_DYNAMIC_SUFFIX = `${QUOTE}\\s*\\)`;
|
|
15
|
-
var SWEEP_PREFIXES = [
|
|
16
|
-
`\\bfrom${GAP}${QUOTE}`,
|
|
17
|
-
`\\bimport${GAP}${QUOTE}`,
|
|
18
|
-
`\\b(?:import|require)${GAP}\\(${GAP}${QUOTE}`
|
|
19
|
-
];
|
|
20
|
-
var rewriterCache = new Map;
|
|
21
|
-
var cacheKey = (vendorPaths) => Object.entries(vendorPaths).sort(([left], [right]) => left.localeCompare(right)).map(([specifier, webPath]) => `${specifier}\x00${webPath}\x00`).join("");
|
|
22
|
-
var compileRegex = (prefixes, alternation, withAdjacentDynamic) => {
|
|
23
|
-
const plain = `(${prefixes.join("|")})(${alternation})(${QUOTE})`;
|
|
24
|
-
if (!withAdjacentDynamic)
|
|
25
|
-
return new RegExp(plain, "g");
|
|
26
|
-
const dynamic = `(${ADJACENT_DYNAMIC_PREFIX})(${alternation})(${ADJACENT_DYNAMIC_SUFFIX})`;
|
|
27
|
-
return new RegExp(`${plain}|${dynamic}`, "g");
|
|
28
|
-
};
|
|
29
|
-
var compileSpecifierRewriter = (vendorPaths) => {
|
|
30
|
-
const key = cacheKey(vendorPaths);
|
|
31
|
-
const cached = rewriterCache.get(key);
|
|
32
|
-
if (cached)
|
|
33
|
-
return cached;
|
|
34
|
-
const replacements = Object.entries(vendorPaths).sort(([specA], [specB]) => specB.length - specA.length);
|
|
35
|
-
const alternation = replacements.map(([specifier]) => escapeRegex(specifier)).join("|");
|
|
36
|
-
const rewriter = {
|
|
37
|
-
lookup: new Map(replacements),
|
|
38
|
-
mainRegex: compileRegex(ADJACENT_PREFIXES, alternation, true),
|
|
39
|
-
quotedSpecifiers: replacements.flatMap(([specifier]) => [
|
|
40
|
-
`"${specifier}`,
|
|
41
|
-
`'${specifier}`
|
|
42
|
-
]),
|
|
43
|
-
sweepRegex: compileRegex(SWEEP_PREFIXES, alternation, false),
|
|
44
|
-
unionRegex: compileRegex([...ADJACENT_PREFIXES, ...SWEEP_PREFIXES], alternation, true)
|
|
45
|
-
};
|
|
46
|
-
rewriterCache.set(key, rewriter);
|
|
47
|
-
return rewriter;
|
|
48
|
-
};
|
|
49
|
-
var hasSpecifierCandidate = (content, rewriter) => rewriter.quotedSpecifiers.some((quoted) => content.includes(quoted));
|
|
50
|
-
var asGroup = (value) => typeof value === "string" ? value : undefined;
|
|
51
|
-
var replaceSpecifier = (lookup) => (match, ...groups) => {
|
|
52
|
-
const [prefixA, specA, suffixA, prefixB, specB, suffixB] = groups;
|
|
53
|
-
const prefix = asGroup(prefixA) ?? asGroup(prefixB);
|
|
54
|
-
const specifier = asGroup(specA) ?? asGroup(specB);
|
|
55
|
-
const suffix = asGroup(suffixA) ?? asGroup(suffixB);
|
|
56
|
-
if (prefix === undefined || specifier === undefined || suffix === undefined)
|
|
57
|
-
return match;
|
|
58
|
-
const webPath = lookup.get(specifier);
|
|
59
|
-
return webPath === undefined ? match : `${prefix}${webPath}${suffix}`;
|
|
60
|
-
};
|
|
61
|
-
var rewriteContentSpecifiers = (content, rewriter, options) => {
|
|
62
|
-
if (!hasSpecifierCandidate(content, rewriter))
|
|
63
|
-
return content;
|
|
64
|
-
const { masked, restore } = maskLiterals(content);
|
|
65
|
-
return restore(rewriteSpecifiers(masked, rewriter, options));
|
|
66
|
-
};
|
|
67
|
-
var rewriteSpecifiers = (masked, rewriter, options) => masked.replace(options.sweep ? rewriter.unionRegex : rewriter.mainRegex, replaceSpecifier(rewriter.lookup));
|
|
68
|
-
|
|
69
|
-
// src/build/rewriteImportsPlugin.ts
|
|
70
|
-
var rewriteImportsInContent = (content, vendorPaths) => {
|
|
71
|
-
if (Object.keys(vendorPaths).length === 0)
|
|
72
|
-
return content;
|
|
73
|
-
return rewriteContentSpecifiers(content, compileSpecifierRewriter(vendorPaths), { sweep: false });
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// src/build/rewriteImports.ts
|
|
77
|
-
var rewriteImports = async (outputPaths, vendorPaths) => {
|
|
78
|
-
const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
|
|
79
|
-
if (jsFiles.length === 0)
|
|
80
|
-
return;
|
|
81
|
-
if (Object.keys(vendorPaths).length === 0)
|
|
82
|
-
return;
|
|
83
|
-
await Promise.all(jsFiles.map(async (filePath) => {
|
|
84
|
-
let original;
|
|
85
|
-
try {
|
|
86
|
-
original = await Bun.file(filePath).text();
|
|
87
|
-
} catch (err) {
|
|
88
|
-
const code = err.code;
|
|
89
|
-
if (code === "ENOENT")
|
|
90
|
-
return;
|
|
91
|
-
throw err;
|
|
92
|
-
}
|
|
93
|
-
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
94
|
-
if (rewritten === original)
|
|
95
|
-
return;
|
|
96
|
-
try {
|
|
97
|
-
await Bun.write(filePath, rewritten);
|
|
98
|
-
} catch (err) {
|
|
99
|
-
const code = err.code;
|
|
100
|
-
if (code === "ENOENT")
|
|
101
|
-
return;
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
}));
|
|
105
|
-
};
|
|
106
|
-
export {
|
|
107
|
-
rewriteImports
|
|
108
|
-
};
|