@absolutejs/absolute 0.20.0-beta.57 → 0.20.0-beta.59

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.
@@ -3229,6 +3229,7 @@ var writeAbsoluteCapacitorConfig = async (config, options) => {
3229
3229
 
3230
3230
  // src/mobile/androidEmulatorController.ts
3231
3231
  init_getDurationString();
3232
+ var ANDROID_CAPTURE_TIMEOUT_MS = 1e4;
3232
3233
  var HASH_RADIX = 16;
3233
3234
  var EXECUTABLE_MODE_MASK = 73;
3234
3235
  var NATIVE_PUBLIC_PATH_SEGMENTS = 5;
@@ -3268,7 +3269,8 @@ var captureCommand2 = (command, options = {}) => {
3268
3269
  cwd: options.cwd,
3269
3270
  env: options.env,
3270
3271
  stderr: "pipe",
3271
- stdout: "pipe"
3272
+ stdout: "pipe",
3273
+ timeout: ANDROID_CAPTURE_TIMEOUT_MS
3272
3274
  });
3273
3275
  return {
3274
3276
  exitCode: result.exitCode,
@@ -7398,7 +7400,11 @@ var createAbsoluteMobilePageRequest = (manifest, path, options = {}) => {
7398
7400
  headers.set(MOBILE_PAGE_REQUEST_HEADERS.pageId, page.pageId);
7399
7401
  headers.set(MOBILE_PAGE_REQUEST_HEADERS.protocol, String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION));
7400
7402
  headers.set(MOBILE_PAGE_REQUEST_HEADERS.runtime, manifest.runtime);
7401
- return new Request(url, { headers, method: "GET" });
7403
+ return new Request(url, {
7404
+ headers,
7405
+ method: "GET",
7406
+ ...options.signal ? { signal: options.signal } : {}
7407
+ });
7402
7408
  };
7403
7409
  var fetchAbsoluteMobilePage = async (manifest, path, options = {}) => {
7404
7410
  const request = createAbsoluteMobilePageRequest(manifest, path, options);
@@ -8610,6 +8616,11 @@ const bridgeBootstrap = (path: string, safeAreaInsets: { bottom: number; left: n
8610
8616
  send({ format: 3, kind: 'event', event: 'navigation', path });
8611
8617
  }
8612
8618
  };
8619
+ globalThis.__absoluteRequestBack = () => {
8620
+ const event = new CustomEvent('absolute:back-request', { cancelable: true });
8621
+ if (!dispatchEvent(event)) return;
8622
+ send({ format: 3, kind: 'event', event: 'back-unhandled', path: currentPath });
8623
+ };
8613
8624
  if (\${DEV_ORIGIN ? 'true' : 'false'}) {
8614
8625
  const publishPath = () => {
8615
8626
  const path = location.pathname + location.search + location.hash;
@@ -8718,12 +8729,12 @@ export function AbsoluteWebHost() {
8718
8729
  }, [safeAreaInsets.bottom, safeAreaInsets.left, safeAreaInsets.right, safeAreaInsets.top]);
8719
8730
  useEffect(() => {
8720
8731
  const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
8721
- if (!canGoBack) return false;
8722
- webView.current?.goBack();
8732
+ if (!indexUri) return false;
8733
+ webView.current?.injectJavaScript('globalThis.__absoluteRequestBack?.(); true;');
8723
8734
  return true;
8724
8735
  });
8725
8736
  return () => subscription.remove();
8726
- }, [canGoBack]);
8737
+ }, [indexUri]);
8727
8738
 
8728
8739
  const respond = (message: Record<string, unknown>) => {
8729
8740
  const source = JSON.stringify(message).replaceAll('\\u2028', '\\\\u2028').replaceAll('\\u2029', '\\\\u2029');
@@ -8763,6 +8774,11 @@ export function AbsoluteWebHost() {
8763
8774
  else activeWebPath.current = message.path;
8764
8775
  return;
8765
8776
  }
8777
+ if (message.kind === 'event' && message.event === 'back-unhandled') {
8778
+ if (canGoBack) webView.current?.goBack();
8779
+ else BackHandler.exitApp();
8780
+ return;
8781
+ }
8766
8782
  if (message.kind !== 'request' || typeof message.id !== 'string' || message.path !== activeWebPath.current) return;
8767
8783
  try {
8768
8784
  if (typeof message.params !== 'object' || message.params === null || Array.isArray(message.params)) throw new Error('Expo bridge method params are invalid.');
@@ -12107,6 +12123,263 @@ var http = createAbsoluteHttpClient();
12107
12123
 
12108
12124
  // src/mobile/shellHttp.ts
12109
12125
  var installAbsoluteMobileShellHttp = (origin, fetch2 = globalThis.fetch) => installAbsoluteHttpTransport(createAbsoluteHttpTransport({ fetch: fetch2, origin, runtime: "native" }));
12126
+ // src/mobile/uiPrimitives.ts
12127
+ var STYLE_ID2 = "absolute-mobile-ui-primitives";
12128
+ var NAVIGATION_EVENT = "absolute:navigation-change";
12129
+ var SHEET_EVENT = "absolute:sheet-change";
12130
+ var BACK_EVENT = "absolute:back-request";
12131
+ var ACTIVE_SHEET_SELECTOR = "dialog[data-absolute-sheet][open]";
12132
+ var TAB_LINK_SELECTOR = "[data-absolute-tab-bar] a[href]";
12133
+ var UI_STYLE = `
12134
+ [data-absolute-app-shell] {
12135
+ display: grid;
12136
+ grid-template-rows: auto minmax(0, 1fr) auto;
12137
+ box-sizing: border-box;
12138
+ min-height: var(--absolute-available-height, 100dvh);
12139
+ padding-inline: var(--absolute-safe-area-inset-left, 0px) var(--absolute-safe-area-inset-right, 0px);
12140
+ }
12141
+ [data-absolute-app-header] {
12142
+ padding-top: var(--absolute-safe-area-inset-top, 0px);
12143
+ }
12144
+ [data-absolute-app-main], [data-absolute-navigation-stack] {
12145
+ min-width: 0;
12146
+ min-height: 0;
12147
+ }
12148
+ [data-absolute-app-main] {
12149
+ overflow: auto;
12150
+ overscroll-behavior-y: contain;
12151
+ }
12152
+ [data-absolute-navigation-stack] {
12153
+ view-transition-name: absolute-mobile-stack;
12154
+ }
12155
+ [data-absolute-tab-bar] {
12156
+ display: flex;
12157
+ align-items: stretch;
12158
+ justify-content: space-around;
12159
+ box-sizing: border-box;
12160
+ padding-bottom: var(--absolute-safe-area-inset-bottom, 0px);
12161
+ background: Canvas;
12162
+ color: CanvasText;
12163
+ }
12164
+ [data-absolute-tab-bar] > a {
12165
+ display: grid;
12166
+ flex: 1 1 0;
12167
+ min-width: 0;
12168
+ min-height: 2.75rem;
12169
+ place-items: center;
12170
+ padding: 0.375rem 0.5rem;
12171
+ color: inherit;
12172
+ text-align: center;
12173
+ text-decoration: none;
12174
+ touch-action: manipulation;
12175
+ }
12176
+ [data-absolute-tab-bar] > a[aria-current="page"] {
12177
+ font-weight: 700;
12178
+ }
12179
+ dialog[data-absolute-sheet] {
12180
+ box-sizing: border-box;
12181
+ width: min(100%, var(--absolute-sheet-max-width, 42rem));
12182
+ max-height: min(90dvh, var(--absolute-available-height, 90dvh));
12183
+ margin: auto auto 0;
12184
+ padding: 1rem max(1rem, var(--absolute-safe-area-inset-right, 0px)) max(1rem, var(--absolute-safe-area-inset-bottom, 0px)) max(1rem, var(--absolute-safe-area-inset-left, 0px));
12185
+ overflow: auto;
12186
+ border: 1px solid color-mix(in srgb, CanvasText 18%, transparent);
12187
+ border-radius: 1rem 1rem 0 0;
12188
+ background: Canvas;
12189
+ color: CanvasText;
12190
+ box-shadow: 0 -0.5rem 2rem color-mix(in srgb, CanvasText 18%, transparent);
12191
+ }
12192
+ dialog[data-absolute-sheet]::backdrop {
12193
+ background: color-mix(in srgb, CanvasText 38%, transparent);
12194
+ }
12195
+ @keyframes absolute-mobile-forward-old { to { opacity: 0; transform: translateX(-12%); } }
12196
+ @keyframes absolute-mobile-forward-new { from { opacity: 0; transform: translateX(12%); } }
12197
+ @keyframes absolute-mobile-back-old { to { opacity: 0; transform: translateX(12%); } }
12198
+ @keyframes absolute-mobile-back-new { from { opacity: 0; transform: translateX(-12%); } }
12199
+ html[data-absolute-navigation-direction="forward"]::view-transition-old(absolute-mobile-stack) { animation: 180ms ease both absolute-mobile-forward-old; }
12200
+ html[data-absolute-navigation-direction="forward"]::view-transition-new(absolute-mobile-stack) { animation: 180ms ease both absolute-mobile-forward-new; }
12201
+ html[data-absolute-navigation-direction="back"]::view-transition-old(absolute-mobile-stack) { animation: 180ms ease both absolute-mobile-back-old; }
12202
+ html[data-absolute-navigation-direction="back"]::view-transition-new(absolute-mobile-stack) { animation: 180ms ease both absolute-mobile-back-new; }
12203
+ html[data-absolute-reduced-motion="reduce"]::view-transition-old(absolute-mobile-stack),
12204
+ html[data-absolute-reduced-motion="reduce"]::view-transition-new(absolute-mobile-stack) { animation: none; }
12205
+ `;
12206
+ var currentPath = () => `${location.pathname}${location.search}${location.hash}`;
12207
+ var ensureStyle2 = () => {
12208
+ let style = document.getElementById(STYLE_ID2);
12209
+ if (!(style instanceof HTMLStyleElement)) {
12210
+ style = document.createElement("style");
12211
+ style.id = STYLE_ID2;
12212
+ style.textContent = UI_STYLE;
12213
+ document.head.append(style);
12214
+ }
12215
+ };
12216
+ var sheetById = (id) => {
12217
+ const target = document.getElementById(id);
12218
+ return target instanceof HTMLDialogElement && target.dataset.absoluteSheet !== undefined ? target : undefined;
12219
+ };
12220
+ var dispatchSheet = (sheet, open) => dispatchEvent(new CustomEvent(SHEET_EVENT, {
12221
+ detail: { id: sheet.id, open }
12222
+ }));
12223
+ var focusSheet = (sheet) => {
12224
+ const target = sheet.querySelector('[autofocus], button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
12225
+ (target ?? sheet).focus();
12226
+ };
12227
+ var sheetOpeners = new WeakMap;
12228
+ var closeAbsoluteMobileSheet = (target) => {
12229
+ const sheet = typeof target === "string" ? sheetById(target) : target;
12230
+ if (!sheet || !sheet.open)
12231
+ return false;
12232
+ if (typeof sheet.close === "function")
12233
+ sheet.close();
12234
+ else
12235
+ sheet.removeAttribute("open");
12236
+ sheet.removeAttribute("aria-modal");
12237
+ sheetOpeners.get(sheet)?.focus();
12238
+ sheetOpeners.delete(sheet);
12239
+ dispatchSheet(sheet, false);
12240
+ return true;
12241
+ };
12242
+ var openAbsoluteMobileSheet = (target, opener) => {
12243
+ const sheet = typeof target === "string" ? sheetById(target) : target;
12244
+ if (!sheet || sheet.dataset.absoluteSheet === undefined)
12245
+ return false;
12246
+ const active = document.querySelector(ACTIVE_SHEET_SELECTOR);
12247
+ if (active && active !== sheet)
12248
+ closeAbsoluteMobileSheet(active);
12249
+ if (opener)
12250
+ sheetOpeners.set(sheet, opener);
12251
+ if (!sheet.open) {
12252
+ if (typeof sheet.showModal === "function")
12253
+ sheet.showModal();
12254
+ else
12255
+ sheet.setAttribute("open", "");
12256
+ }
12257
+ sheet.setAttribute("aria-modal", "true");
12258
+ focusSheet(sheet);
12259
+ dispatchSheet(sheet, true);
12260
+ return true;
12261
+ };
12262
+ var readAbsoluteMobileLinkIntent = (anchor) => {
12263
+ const mode = anchor.dataset.absoluteLink;
12264
+ if (mode === "back")
12265
+ return { kind: "back" };
12266
+ if (mode === "external")
12267
+ return { kind: "external" };
12268
+ return { kind: "navigate", replace: mode === "replace" };
12269
+ };
12270
+ var requestAbsoluteMobileBack = () => {
12271
+ const event = new CustomEvent(BACK_EVENT, { cancelable: true });
12272
+ return !dispatchEvent(event);
12273
+ };
12274
+ var normalizePathname = (value) => {
12275
+ try {
12276
+ return new URL(value, location.href).pathname.replace(/\/$/u, "") || "/";
12277
+ } catch {
12278
+ return;
12279
+ }
12280
+ };
12281
+ var syncTabLinks = (path) => {
12282
+ const activePath = normalizePathname(path);
12283
+ if (!activePath)
12284
+ return;
12285
+ document.querySelectorAll(TAB_LINK_SELECTOR).forEach((anchor) => {
12286
+ const candidate = normalizePathname(anchor.href);
12287
+ const prefix = anchor.dataset.absoluteTabMatch === "prefix";
12288
+ const active = candidate !== undefined && (prefix ? activePath === candidate || candidate !== "/" && activePath.startsWith(`${candidate}/`) : activePath === candidate);
12289
+ if (active)
12290
+ anchor.setAttribute("aria-current", "page");
12291
+ else
12292
+ anchor.removeAttribute("aria-current");
12293
+ });
12294
+ };
12295
+ var installAbsoluteMobileUiPrimitives = () => {
12296
+ let disposed = false;
12297
+ let scheduled = false;
12298
+ let path = currentPath();
12299
+ const refreshDocument = (nextPath = path) => {
12300
+ if (disposed || !document.head || !document.body)
12301
+ return;
12302
+ path = nextPath;
12303
+ ensureStyle2();
12304
+ syncTabLinks(path);
12305
+ };
12306
+ const scheduleRefresh = () => {
12307
+ if (scheduled || disposed)
12308
+ return;
12309
+ scheduled = true;
12310
+ queueMicrotask(() => {
12311
+ scheduled = false;
12312
+ refreshDocument();
12313
+ });
12314
+ };
12315
+ const handleClick = (event) => {
12316
+ if (!(event.target instanceof Element))
12317
+ return;
12318
+ const opener = event.target.closest("[data-absolute-sheet-open]");
12319
+ if (opener?.dataset.absoluteSheetOpen) {
12320
+ if (openAbsoluteMobileSheet(opener.dataset.absoluteSheetOpen, opener))
12321
+ event.preventDefault();
12322
+ return;
12323
+ }
12324
+ const closer = event.target.closest("[data-absolute-sheet-close]");
12325
+ const sheet = closer?.closest("dialog[data-absolute-sheet]");
12326
+ if (sheet && closeAbsoluteMobileSheet(sheet)) {
12327
+ event.preventDefault();
12328
+ return;
12329
+ }
12330
+ if (event.target instanceof HTMLDialogElement && event.target.dataset.absoluteSheet !== undefined) {
12331
+ const rect = event.target.getBoundingClientRect();
12332
+ const outside = event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom;
12333
+ if (outside && closeAbsoluteMobileSheet(event.target))
12334
+ event.preventDefault();
12335
+ }
12336
+ };
12337
+ const handleCancel = (event) => {
12338
+ if (!(event.target instanceof HTMLDialogElement))
12339
+ return;
12340
+ if (event.target.dataset.absoluteSheet === undefined)
12341
+ return;
12342
+ event.preventDefault();
12343
+ closeAbsoluteMobileSheet(event.target);
12344
+ };
12345
+ const handleBack = (event) => {
12346
+ const active = document.querySelector(ACTIVE_SHEET_SELECTOR);
12347
+ if (!active)
12348
+ return;
12349
+ event.preventDefault();
12350
+ closeAbsoluteMobileSheet(active);
12351
+ };
12352
+ const observer = new MutationObserver(scheduleRefresh);
12353
+ observer.observe(document.documentElement, {
12354
+ childList: true,
12355
+ subtree: true
12356
+ });
12357
+ addEventListener("click", handleClick);
12358
+ addEventListener("cancel", handleCancel, true);
12359
+ addEventListener(BACK_EVENT, handleBack);
12360
+ refreshDocument();
12361
+ return {
12362
+ refreshDocument,
12363
+ requestBack: requestAbsoluteMobileBack,
12364
+ dispose: () => {
12365
+ if (disposed)
12366
+ return;
12367
+ disposed = true;
12368
+ observer.disconnect();
12369
+ removeEventListener("click", handleClick);
12370
+ removeEventListener("cancel", handleCancel, true);
12371
+ removeEventListener(BACK_EVENT, handleBack);
12372
+ },
12373
+ navigate: (detail) => {
12374
+ path = detail.to;
12375
+ document.documentElement.dataset.absoluteNavigationDirection = detail.direction;
12376
+ refreshDocument(path);
12377
+ dispatchEvent(new CustomEvent(NAVIGATION_EVENT, {
12378
+ detail
12379
+ }));
12380
+ }
12381
+ };
12382
+ };
12110
12383
  export {
12111
12384
  ABSOLUTE_ANDROID_RELEASE_FORMAT,
12112
12385
  ABSOLUTE_AUTH_PACKAGE,
@@ -12164,6 +12437,7 @@ export {
12164
12437
  captureAbsoluteRemoteMacCommand,
12165
12438
  carryForwardAbsoluteMobileCompatibilityReleases,
12166
12439
  cleanAbsoluteRemoteMacWorkspace,
12440
+ closeAbsoluteMobileSheet,
12167
12441
  createAbsoluteExpoBridgeError,
12168
12442
  createAbsoluteExpoBridgeResponse,
12169
12443
  createAbsoluteIosNativeWatcher,
@@ -12206,6 +12480,7 @@ export {
12206
12480
  installAbsoluteMobileAuthEnvironment,
12207
12481
  installAbsoluteMobileShellHttp,
12208
12482
  installAbsoluteMobileSyncRemediation,
12483
+ installAbsoluteMobileUiPrimitives,
12209
12484
  installAbsoluteRemoteMacAgent,
12210
12485
  isAbsoluteIosNativeRootInput,
12211
12486
  listAbsoluteRemoteMacProfiles,
@@ -12222,6 +12497,7 @@ export {
12222
12497
  normalizeAbsoluteIosDeviceHost,
12223
12498
  normalizeAbsoluteIosDeviceIdentifier,
12224
12499
  normalizeAbsoluteMobileConfig,
12500
+ openAbsoluteMobileSheet,
12225
12501
  pairAbsoluteRemoteMac,
12226
12502
  parseAbsoluteAndroidInstalledApp,
12227
12503
  parseAbsoluteExpoBridgeMessage,
@@ -12243,10 +12519,12 @@ export {
12243
12519
  projectUsesAbsoluteSync,
12244
12520
  publishAbsoluteAndroidRelease,
12245
12521
  publishAbsoluteIosRelease,
12522
+ readAbsoluteMobileLinkIntent,
12246
12523
  readAbsoluteMobileMaterializedReleases,
12247
12524
  redactAbsoluteIosLog,
12248
12525
  removeAbsoluteRemoteMacProfile,
12249
12526
  repairAbsoluteIosDevSession,
12527
+ requestAbsoluteMobileBack,
12250
12528
  requireAbsoluteIosReleaseMetadata,
12251
12529
  resolveAbsoluteDeviceCapabilityPlan,
12252
12530
  resolveAbsoluteIosXcodeProject,
@@ -12279,5 +12557,5 @@ export {
12279
12557
  writeAbsoluteMobileGithubWorkflow
12280
12558
  };
12281
12559
 
12282
- //# debugId=15034BCB4D45F19A64756E2164756E21
12560
+ //# debugId=AC4084DD1C6BCD7664756E2164756E21
12283
12561
  //# sourceMappingURL=index.js.map