@absolutejs/absolute 0.20.0-beta.96 → 0.20.0-beta.98

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.
@@ -28301,7 +28301,10 @@ var androidManifest2 = `${XML_HEADER2}<manifest xmlns:android="http://schemas.an
28301
28301
  `;
28302
28302
  var androidModule2 = `${HEADER2}package expo.modules.absoluteactivityresultrecovery
28303
28303
 
28304
+ import android.app.Activity
28305
+ import android.content.Context
28304
28306
  import android.content.Intent
28307
+ import android.provider.MediaStore
28305
28308
  import android.util.Log
28306
28309
  import expo.modules.kotlin.modules.Module
28307
28310
  import expo.modules.kotlin.modules.ModuleDefinition
@@ -28317,16 +28320,58 @@ object AbsoluteActivityResultRecoveryState {
28317
28320
  var applicationRuntimeReady = false
28318
28321
 
28319
28322
  private val pendingActivityResults = ArrayDeque<AbsolutePendingActivityResult>()
28323
+ private var pendingCancellations = 0
28324
+
28325
+ private const val preferencesName = "absolutejs.activity-result-recovery"
28326
+ private const val pickerRequestCodeKey = "picker-request-code"
28327
+
28328
+ @Synchronized
28329
+ fun registerPickerRequest(context: Context, requestCode: Int, intent: Intent) {
28330
+ val action = intent.action
28331
+ val isPicker = action == MediaStore.ACTION_IMAGE_CAPTURE ||
28332
+ action == MediaStore.ACTION_VIDEO_CAPTURE ||
28333
+ action == MediaStore.ACTION_PICK_IMAGES ||
28334
+ action == Intent.ACTION_PICK ||
28335
+ action == Intent.ACTION_GET_CONTENT ||
28336
+ action == Intent.ACTION_OPEN_DOCUMENT ||
28337
+ action?.endsWith(".PICK") == true ||
28338
+ intent.type?.startsWith("image/") == true ||
28339
+ intent.hasExtra(MediaStore.EXTRA_OUTPUT)
28340
+ if (!isPicker) return
28341
+ context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE)
28342
+ .edit()
28343
+ .putInt(pickerRequestCodeKey, requestCode)
28344
+ .apply()
28345
+ }
28320
28346
 
28321
28347
  @Synchronized
28322
- fun enqueueActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
28348
+ fun consumePickerCancellation(context: Context, requestCode: Int, resultCode: Int): Boolean {
28349
+ val preferences = context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE)
28350
+ val pickerRequestCode = preferences.getInt(pickerRequestCodeKey, Int.MIN_VALUE)
28351
+ if (pickerRequestCode != requestCode) return false
28352
+ preferences.edit().remove(pickerRequestCodeKey).apply()
28353
+ return resultCode == Activity.RESULT_CANCELED
28354
+ }
28355
+
28356
+ @Synchronized
28357
+ fun enqueueActivityResult(requestCode: Int, resultCode: Int, data: Intent?, pickerCancelled: Boolean) {
28323
28358
  if (pendingActivityResults.size == 8) pendingActivityResults.removeFirst()
28324
28359
  pendingActivityResults.addLast(
28325
28360
  AbsolutePendingActivityResult(requestCode, resultCode, data?.let(::Intent))
28326
28361
  )
28362
+ if (pickerCancelled && pendingCancellations < 8) {
28363
+ pendingCancellations += 1
28364
+ }
28327
28365
  Log.d("AbsoluteJS", "Queued early Android activity result; pending=" + pendingActivityResults.size)
28328
28366
  }
28329
28367
 
28368
+ @Synchronized
28369
+ fun takePendingCancellation(): Boolean {
28370
+ if (pendingCancellations == 0) return false
28371
+ pendingCancellations -= 1
28372
+ return true
28373
+ }
28374
+
28330
28375
  @Synchronized
28331
28376
  fun hasPendingActivityResults() = pendingActivityResults.isNotEmpty()
28332
28377
 
@@ -28347,6 +28392,10 @@ class AbsoluteActivityResultRecoveryModule : Module() {
28347
28392
  AbsoluteActivityResultRecoveryState.applicationRuntimeReady = true
28348
28393
  Log.d("AbsoluteJS", "Expo application runtime ready for Android activity results")
28349
28394
  }
28395
+
28396
+ Function("takePendingCancellation") {
28397
+ AbsoluteActivityResultRecoveryState.takePendingCancellation()
28398
+ }
28350
28399
  }
28351
28400
  }
28352
28401
  `;
@@ -28354,6 +28403,7 @@ var runtime = `${HEADER2}import { requireNativeModule } from 'expo-modules-core'
28354
28403
 
28355
28404
  type AbsoluteActivityResultRecoveryNative = {
28356
28405
  markApplicationRuntimeReady(): void;
28406
+ takePendingCancellation(): boolean;
28357
28407
  };
28358
28408
 
28359
28409
  const native = requireNativeModule<AbsoluteActivityResultRecoveryNative>(
@@ -28362,6 +28412,9 @@ const native = requireNativeModule<AbsoluteActivityResultRecoveryNative>(
28362
28412
 
28363
28413
  export const markAbsoluteApplicationRuntimeReady = () =>
28364
28414
  native.markApplicationRuntimeReady();
28415
+
28416
+ export const takeAbsoluteActivityResultCancellation = () =>
28417
+ native.takePendingCancellation();
28365
28418
  `;
28366
28419
  var absoluteExpoActivityResultRecoveryFiles = (project) => new Map([
28367
28420
  [
@@ -28474,7 +28527,7 @@ var packageDependencies = (plan) => Object.fromEntries(plan.requiredPackages.map
28474
28527
  var expoPackage = (auth, sync, devices, updates) => ({
28475
28528
  dependencies: {
28476
28529
  "@absolutejs/devices": "0.7.0",
28477
- "@absolutejs/devices-expo": "0.0.9",
28530
+ "@absolutejs/devices-expo": "0.0.11",
28478
28531
  ...auth ? {
28479
28532
  "@absolutejs/auth": ABSOLUTE_EXPO_AUTH_CORE_VERSION,
28480
28533
  [ABSOLUTE_EXPO_AUTH_PACKAGE]: ABSOLUTE_EXPO_AUTH_VERSION
@@ -28720,6 +28773,7 @@ const withAbsoluteActivityResultRecovery = config => withMainActivity(config, va
28720
28773
  'import android.os.Bundle',
28721
28774
  'import android.os.Handler',
28722
28775
  'import android.os.Looper',
28776
+ 'import android.util.Log',
28723
28777
  'import expo.modules.absoluteactivityresultrecovery.AbsoluteActivityResultRecoveryState'
28724
28778
  ].join('\\n'));
28725
28779
  source = source.replace(CLASS_ANCHOR, \`\${CLASS_ANCHOR}
@@ -28741,12 +28795,19 @@ const withAbsoluteActivityResultRecovery = config => withMainActivity(config, va
28741
28795
  }
28742
28796
  }
28743
28797
 
28798
+ @Suppress("DEPRECATION")
28799
+ override fun startActivityForResult(intent: Intent, requestCode: Int, options: Bundle?) {
28800
+ AbsoluteActivityResultRecoveryState.registerPickerRequest(applicationContext, requestCode, intent)
28801
+ super.startActivityForResult(intent, requestCode, options)
28802
+ }
28803
+
28744
28804
  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
28805
+ val pickerCancelled = AbsoluteActivityResultRecoveryState.consumePickerCancellation(applicationContext, requestCode, resultCode)
28745
28806
  if (AbsoluteActivityResultRecoveryState.applicationRuntimeReady) {
28746
28807
  super.onActivityResult(requestCode, resultCode, data)
28747
28808
  return
28748
28809
  }
28749
- AbsoluteActivityResultRecoveryState.enqueueActivityResult(requestCode, resultCode, data)
28810
+ AbsoluteActivityResultRecoveryState.enqueueActivityResult(requestCode, resultCode, data, pickerCancelled)
28750
28811
  absoluteActivityResultHandler.removeCallbacks(absoluteReplayActivityResults)
28751
28812
  absoluteActivityResultHandler.postDelayed(absoluteReplayActivityResults, 250)
28752
28813
  }
@@ -28762,7 +28823,9 @@ const withAbsoluteActivityResultRecovery = config => withMainActivity(config, va
28762
28823
 
28763
28824
  override fun onDestroy() {
28764
28825
  absoluteActivityResultHandler.removeCallbacks(absoluteReplayActivityResults)
28826
+ AbsoluteActivityResultRecoveryState.applicationRuntimeReady = false
28765
28827
  super.onDestroy()
28828
+ Log.d("AbsoluteJS", "Expo activity-result recovery activity destroyed")
28766
28829
  }
28767
28830
  \`);
28768
28831
  value.modResults.contents = source;
@@ -28986,6 +29049,7 @@ const absoluteExpoPushOptions = {
28986
29049
  };` : "";
28987
29050
  return `${EXPO_GENERATED_HEADER}import { installDeviceAdapter } from '@absolutejs/devices/runtime';
28988
29051
  import { createExpoDeviceAdapter } from '@absolutejs/devices-expo';
29052
+ import { takeAbsoluteActivityResultCancellation } from './AbsoluteActivityResultRecovery';
28989
29053
  ${push ? "import { absoluteExpoAuth } from './AbsoluteAuth';" : ""}
28990
29054
  ${imports.join(`
28991
29055
  `)}
@@ -28995,6 +29059,7 @@ ${pushSource}
28995
29059
  export const absoluteExpoDeviceCapabilities = ${JSON.stringify(plan.capabilities)} as const;
28996
29060
  export const absoluteExpoDevices = createExpoDeviceAdapter({
28997
29061
  storagePrefix: ${JSON.stringify(`absolutejs.${config.appId}.`)},
29062
+ takeActivityResultCancellation: takeAbsoluteActivityResultCancellation,
28998
29063
  ${entries}
28999
29064
  });
29000
29065
  installDeviceAdapter(absoluteExpoDevices);
@@ -31271,6 +31336,97 @@ var startAbsoluteExpoDevSession = async (options) => {
31271
31336
  throw error;
31272
31337
  }
31273
31338
  };
31339
+ // src/mobile/expoAndroidQuality.ts
31340
+ var KIB_PER_MIB = 1024;
31341
+ var XML_BOUND_BOTTOM_INDEX = 4;
31342
+ var XML_BOUND_LEFT_INDEX = 1;
31343
+ var XML_BOUND_RIGHT_INDEX = 3;
31344
+ var XML_BOUND_TOP_INDEX = 2;
31345
+ var DEFAULT_ABSOLUTE_EXPO_ANDROID_QUALITY_BUDGETS = {
31346
+ bridgeP95Ms: 500,
31347
+ coldLaunchMs: 25000,
31348
+ hmrP95Ms: 1e4,
31349
+ maxMemoryGrowthMiB: 160,
31350
+ maxTotalPssMiB: 700,
31351
+ minTouchTargetDp: 44,
31352
+ warmLaunchMs: 5000
31353
+ };
31354
+ var requiredInteger = (source, name) => {
31355
+ const match = new RegExp(`^${name}:\\s*(\\d+)$`, "mu").exec(source);
31356
+ const value = Number(match?.[1]);
31357
+ if (!Number.isSafeInteger(value))
31358
+ throw new TypeError(`Android launch output is missing ${name}.`);
31359
+ return value;
31360
+ };
31361
+ var optionalInteger = (source, name) => {
31362
+ const match = new RegExp(`^${name}:\\s*(\\d+)$`, "mu").exec(source);
31363
+ if (!match)
31364
+ return;
31365
+ const value = Number(match[1]);
31366
+ if (!Number.isSafeInteger(value))
31367
+ throw new TypeError(`Android launch output has invalid ${name}.`);
31368
+ return value;
31369
+ };
31370
+ var parseAbsoluteExpoAndroidLaunchTiming = (source) => ({
31371
+ launchState: /^LaunchState:\s*(\S+)$/mu.exec(source)?.[1],
31372
+ thisTimeMs: optionalInteger(source, "ThisTime"),
31373
+ totalTimeMs: requiredInteger(source, "TotalTime"),
31374
+ waitTimeMs: requiredInteger(source, "WaitTime")
31375
+ });
31376
+ var parseAbsoluteExpoAndroidMemory = (source) => {
31377
+ const summary = /^\s*TOTAL PSS:\s*(\d+)/mu.exec(source)?.[1];
31378
+ const table = /^\s*TOTAL\s+(\d+)\s+/mu.exec(source)?.[1];
31379
+ const totalPssKiB = Number(summary ?? table);
31380
+ if (!Number.isSafeInteger(totalPssKiB) || totalPssKiB < 0)
31381
+ throw new TypeError("Android meminfo output is missing total PSS.");
31382
+ return { totalPssKiB };
31383
+ };
31384
+ var decodeXml = (value) => value.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
31385
+ var nodeAttributes = (source) => Object.fromEntries([...source.matchAll(/([\w:-]+)="([^"]*)"/gu)].map(([, name = "", value = ""]) => [name, decodeXml(value)]));
31386
+ var nodeBounds = (source) => {
31387
+ const match = /^\[(\d+),(\d+)\]\[(\d+),(\d+)\]$/u.exec(source);
31388
+ if (!match)
31389
+ return { bottom: 0, left: 0, right: 0, top: 0 };
31390
+ return {
31391
+ bottom: Number(match[XML_BOUND_BOTTOM_INDEX]),
31392
+ left: Number(match[XML_BOUND_LEFT_INDEX]),
31393
+ right: Number(match[XML_BOUND_RIGHT_INDEX]),
31394
+ top: Number(match[XML_BOUND_TOP_INDEX])
31395
+ };
31396
+ };
31397
+ var absoluteAndroidNodeLabel = (node) => node.contentDescription.trim() || node.text.trim();
31398
+ var absoluteAndroidTouchTargetDp = (node, density) => {
31399
+ if (!Number.isFinite(density) || density <= 0)
31400
+ throw new TypeError("Android display density must be positive.");
31401
+ return {
31402
+ height: (node.bounds.bottom - node.bounds.top) / density,
31403
+ width: (node.bounds.right - node.bounds.left) / density
31404
+ };
31405
+ };
31406
+ var absolutePercentile = (values, ratio) => {
31407
+ if (values.length === 0)
31408
+ throw new TypeError("A percentile requires at least one measurement.");
31409
+ if (!Number.isFinite(ratio) || ratio < 0 || ratio > 1)
31410
+ throw new TypeError("A percentile ratio must be between zero and one.");
31411
+ const ordered = [...values].sort((left, right) => left - right);
31412
+ const index = Math.ceil(ratio * ordered.length) - 1;
31413
+ return ordered[Math.max(0, index)] ?? 0;
31414
+ };
31415
+ var absolutePssMiB = (memory) => memory.totalPssKiB / KIB_PER_MIB;
31416
+ var parseAbsoluteAndroidAccessibilityHierarchy = (source) => [...source.matchAll(/<node\s+([^>]*?)\/?>(?:<\/node>)?/gu)].map(([, raw = ""]) => {
31417
+ const attributes = nodeAttributes(raw);
31418
+ return {
31419
+ bounds: nodeBounds(attributes.bounds ?? ""),
31420
+ className: attributes.class ?? "",
31421
+ clickable: attributes.clickable === "true",
31422
+ contentDescription: attributes["content-desc"] ?? "",
31423
+ enabled: attributes.enabled === "true",
31424
+ packageName: attributes.package ?? "",
31425
+ resourceId: attributes["resource-id"] ?? "",
31426
+ text: attributes.text ?? "",
31427
+ visible: attributes["visible-to-user"] !== "false"
31428
+ };
31429
+ });
31274
31430
  // src/mobile/expoNativeWatcher.ts
31275
31431
  import { watch as watch2 } from "fs";
31276
31432
  import { access as access12, readdir as readdir5, readFile as readFile16 } from "fs/promises";
@@ -40729,8 +40885,11 @@ export {
40729
40885
  ANDROID_ASSOCIATION_PATH,
40730
40886
  APPLE_ASSOCIATION_PATH,
40731
40887
  AbsoluteMobilePageProtocolError,
40888
+ DEFAULT_ABSOLUTE_EXPO_ANDROID_QUALITY_BUDGETS,
40732
40889
  DEFAULT_MOBILE_UPDATE_REGISTRY_MODULE,
40733
40890
  MOBILE_PAGE_REQUEST_HEADERS,
40891
+ absoluteAndroidNodeLabel,
40892
+ absoluteAndroidTouchTargetDp,
40734
40893
  absoluteDeviceNativeRequirements,
40735
40894
  absoluteExpoExecutable,
40736
40895
  absoluteExpoNativeObservabilityFiles,
@@ -40738,6 +40897,8 @@ export {
40738
40897
  absoluteIosDeviceAcceptanceCommands,
40739
40898
  absoluteMobilePreviewDocument,
40740
40899
  absoluteMobileUpdateSigningPayload,
40900
+ absolutePercentile,
40901
+ absolutePssMiB,
40741
40902
  absoluteRemoteMacSshBase,
40742
40903
  absoluteRemoteProjectSyncCommands,
40743
40904
  absoluteRemoteReleaseInputSyncCommands,
@@ -40853,7 +41014,10 @@ export {
40853
41014
  normalizeAbsoluteMobileUpdatePath,
40854
41015
  openAbsoluteMobileSheet,
40855
41016
  pairAbsoluteRemoteMac,
41017
+ parseAbsoluteAndroidAccessibilityHierarchy,
40856
41018
  parseAbsoluteAndroidInstalledApp,
41019
+ parseAbsoluteExpoAndroidLaunchTiming,
41020
+ parseAbsoluteExpoAndroidMemory,
40857
41021
  parseAbsoluteExpoBridgeMessage,
40858
41022
  parseAbsoluteExpoUpdateDescriptor,
40859
41023
  parseAbsoluteIosHmrLog,
@@ -40931,5 +41095,5 @@ export {
40931
41095
  writeAbsoluteMobileUpdateRegistry
40932
41096
  };
40933
41097
 
40934
- //# debugId=60D5DDBF8A7817D064756E2164756E21
41098
+ //# debugId=35DF25B2FF31C85164756E2164756E21
40935
41099
  //# sourceMappingURL=index.js.map