@absolutejs/absolute 0.20.0-beta.66 → 0.20.0-beta.67

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.
@@ -0,0 +1,246 @@
1
+ import { installDeviceAdapter } from '@absolutejs/devices';
2
+ import {
3
+ createAbsoluteHttpTransport,
4
+ installAbsoluteHttpTransport
5
+ } from '@absolutejs/http';
6
+ import {
7
+ createTestDeviceAdapter,
8
+ type TestDeviceController
9
+ } from '@absolutejs/devices/testing';
10
+
11
+ type PreviewMessage =
12
+ | { type: 'absolute-preview:back' }
13
+ | { type: 'absolute-preview:deep-link'; url: string }
14
+ | { type: 'absolute-preview:keyboard'; heightPx: number; visible: boolean }
15
+ | {
16
+ type: 'absolute-preview:lifecycle';
17
+ state: 'active' | 'background' | 'inactive';
18
+ }
19
+ | {
20
+ type: 'absolute-preview:network';
21
+ connected: boolean;
22
+ connectionType: 'cellular' | 'none' | 'unknown' | 'wifi';
23
+ }
24
+ | {
25
+ type: 'absolute-preview:permission';
26
+ capability: 'camera' | 'location' | 'notifications';
27
+ state: 'blocked' | 'denied' | 'granted' | 'prompt';
28
+ };
29
+
30
+ const isRecord = (value: unknown): value is Record<string, unknown> =>
31
+ typeof value === 'object' && value !== null;
32
+
33
+ const isPreviewMessage = (value: unknown): value is PreviewMessage => {
34
+ if (!isRecord(value) || typeof value.type !== 'string') return false;
35
+ if (value.type === 'absolute-preview:back') return true;
36
+ if (value.type === 'absolute-preview:deep-link')
37
+ return typeof value.url === 'string';
38
+ if (value.type === 'absolute-preview:keyboard')
39
+ return (
40
+ typeof value.heightPx === 'number' &&
41
+ Number.isFinite(value.heightPx) &&
42
+ typeof value.visible === 'boolean'
43
+ );
44
+ if (value.type === 'absolute-preview:lifecycle')
45
+ return ['active', 'background', 'inactive'].includes(
46
+ String(value.state)
47
+ );
48
+ if (value.type === 'absolute-preview:network')
49
+ return (
50
+ typeof value.connected === 'boolean' &&
51
+ ['cellular', 'none', 'unknown', 'wifi'].includes(
52
+ String(value.connectionType)
53
+ )
54
+ );
55
+ if (value.type === 'absolute-preview:permission')
56
+ return (
57
+ ['camera', 'location', 'notifications'].includes(
58
+ String(value.capability)
59
+ ) &&
60
+ ['blocked', 'denied', 'granted', 'prompt'].includes(
61
+ String(value.state)
62
+ )
63
+ );
64
+
65
+ return false;
66
+ };
67
+
68
+ const previewPlatform = () =>
69
+ new URLSearchParams(location.search).get('__absolute_preview_platform') ===
70
+ 'android'
71
+ ? 'android'
72
+ : 'ios';
73
+
74
+ const PREVIEW_STATE_KEY = Symbol.for('@absolutejs/mobile-preview/state');
75
+ type AbsoluteMobilePreviewState = { connected: boolean };
76
+ const isAbsoluteMobilePreviewState = (
77
+ value: unknown
78
+ ): value is AbsoluteMobilePreviewState =>
79
+ isRecord(value) && typeof value.connected === 'boolean';
80
+ const getPreviewState = () => {
81
+ const existing = Reflect.get(globalThis, PREVIEW_STATE_KEY);
82
+ if (isAbsoluteMobilePreviewState(existing)) return existing;
83
+ const created: AbsoluteMobilePreviewState = { connected: true };
84
+ Reflect.set(globalThis, PREVIEW_STATE_KEY, created);
85
+
86
+ return created;
87
+ };
88
+ const previewState = getPreviewState();
89
+ const browserFetch = globalThis.fetch;
90
+ const nativeFetch = browserFetch.bind(globalThis);
91
+ const isPreviewInfrastructureRequest = (url: URL) =>
92
+ url.origin === location.origin &&
93
+ (url.pathname.startsWith('/__absolute/') ||
94
+ url.pathname.startsWith('/@src/') ||
95
+ url.pathname === '/hmr-status');
96
+
97
+ const previewPreconnect = (
98
+ ...args: Parameters<typeof globalThis.fetch.preconnect>
99
+ ) => {
100
+ const preconnect = Reflect.get(browserFetch, 'preconnect');
101
+ if (typeof preconnect === 'function')
102
+ Reflect.apply(preconnect, browserFetch, args);
103
+ };
104
+
105
+ const previewFetch: typeof globalThis.fetch = Object.assign(
106
+ (
107
+ input: Parameters<typeof globalThis.fetch>[0],
108
+ init?: Parameters<typeof globalThis.fetch>[1]
109
+ ) => {
110
+ const requestUrl = new URL(
111
+ input instanceof Request ? input.url : String(input),
112
+ location.href
113
+ );
114
+ if (
115
+ !previewState.connected &&
116
+ !isPreviewInfrastructureRequest(requestUrl)
117
+ ) {
118
+ return Promise.reject(
119
+ new TypeError(
120
+ 'AbsoluteJS mobile preview is offline. Restore connectivity from the preview controls.'
121
+ )
122
+ );
123
+ }
124
+
125
+ return nativeFetch(input, init);
126
+ },
127
+ { preconnect: previewPreconnect }
128
+ );
129
+
130
+ const installPreviewFetch = () => {
131
+ globalThis.fetch = previewFetch;
132
+ };
133
+
134
+ let removePreviewHttpTransport: (() => void) | undefined;
135
+ const installPreviewHttpTransport = () => {
136
+ removePreviewHttpTransport?.();
137
+ removePreviewHttpTransport = installAbsoluteHttpTransport(
138
+ createAbsoluteHttpTransport({
139
+ fetch: previewFetch,
140
+ origin: location.origin,
141
+ runtime: 'web'
142
+ })
143
+ );
144
+ };
145
+
146
+ installPreviewFetch();
147
+
148
+ const postState = (
149
+ type: 'event' | 'ready',
150
+ detail: Record<string, unknown> = {}
151
+ ) => {
152
+ if (window.parent === window) return;
153
+ window.parent.postMessage(
154
+ {
155
+ ...detail,
156
+ platform: previewPlatform(),
157
+ type: `absolute-preview:${type}`
158
+ },
159
+ location.origin
160
+ );
161
+ };
162
+
163
+ const reportReady = () => {
164
+ const durationMs = Math.max(0, Math.round(performance.now()));
165
+ void nativeFetch('/__absolute/mobile-preview-telemetry', {
166
+ body: JSON.stringify({ durationMs, platform: previewPlatform() }),
167
+ headers: { 'content-type': 'application/json' },
168
+ keepalive: true,
169
+ method: 'POST'
170
+ }).catch(() => undefined);
171
+ };
172
+
173
+ const emitPermission = (
174
+ controller: TestDeviceController,
175
+ message: Extract<PreviewMessage, { type: 'absolute-preview:permission' }>
176
+ ) => {
177
+ const status = {
178
+ canRequest: message.state === 'prompt',
179
+ state: message.state
180
+ } as const;
181
+ if (message.capability === 'camera')
182
+ controller.cameraPermission.setStatus(status);
183
+ else if (message.capability === 'location')
184
+ controller.locationPermission.setStatus(status);
185
+ else controller.notificationPermission.setStatus(status);
186
+ };
187
+
188
+ const handlePreviewMessage = (
189
+ controller: TestDeviceController,
190
+ message: PreviewMessage
191
+ ) => {
192
+ if (message.type === 'absolute-preview:back') {
193
+ controller.emitBack({ canGoBack: history.length > 1 });
194
+ } else if (message.type === 'absolute-preview:deep-link') {
195
+ controller.emitLink(message.url);
196
+ } else if (message.type === 'absolute-preview:keyboard') {
197
+ controller.emitKeyboard({
198
+ heightPx: Math.max(0, Math.round(message.heightPx)),
199
+ visible: message.visible
200
+ });
201
+ } else if (message.type === 'absolute-preview:lifecycle') {
202
+ controller.emitLifecycle(message.state);
203
+ } else if (message.type === 'absolute-preview:network') {
204
+ previewState.connected = message.connected;
205
+ // Some framework runtimes replace window.fetch while bootstrapping.
206
+ // Reassert the raw-fetch simulation whenever connectivity changes;
207
+ // @absolutejs/http remains pinned to this provider independently.
208
+ installPreviewFetch();
209
+ installPreviewHttpTransport();
210
+ controller.emitNetwork({
211
+ connected: message.connected,
212
+ connectionType: message.connectionType
213
+ });
214
+ } else emitPermission(controller, message);
215
+ postState('event', { event: message.type });
216
+ };
217
+
218
+ export const installAbsoluteMobilePreview = () => {
219
+ if (Reflect.has(globalThis, '__ABS_MOBILE_PREVIEW__')) return;
220
+ const platform = previewPlatform();
221
+ const controller = createTestDeviceAdapter({
222
+ lifecycle: 'active',
223
+ network: { connected: true, connectionType: 'wifi' },
224
+ platform: {
225
+ formFactor: 'phone',
226
+ isNative: true,
227
+ os: platform,
228
+ runtime: 'capacitor',
229
+ safeAreaInsets:
230
+ platform === 'ios'
231
+ ? { bottom: 34, left: 0, right: 0, top: 59 }
232
+ : { bottom: 24, left: 0, right: 0, top: 24 }
233
+ }
234
+ });
235
+ installDeviceAdapter(controller.adapter);
236
+ installPreviewHttpTransport();
237
+ Reflect.set(globalThis, '__ABS_MOBILE_PREVIEW__', controller);
238
+ addEventListener('message', (event: MessageEvent<unknown>) => {
239
+ if (event.origin !== location.origin || event.source !== window.parent)
240
+ return;
241
+ if (!isPreviewMessage(event.data)) return;
242
+ handlePreviewMessage(controller, event.data);
243
+ });
244
+ postState('ready');
245
+ reportReady();
246
+ };
@@ -10,5 +10,7 @@ export declare const inlineLineMapComment: (sourcePath: string, sourceContent: s
10
10
  export declare const remapGeneratedLines: (mappings: string, lineRemap: number[]) => string;
11
11
  export declare const chainSourcemap: (outer: SourceMap, fetchInner: (sourcePath: string) => SourceMap | null) => SourceMap;
12
12
  export declare const chainBundleInlineSourcemap: (bundleFilePath: string) => void;
13
+ /** Chain every server bundle of a dev build (each bundle is independent). */
14
+ export declare const chainBundleInlineSourcemaps: (bundlePaths: string[]) => Promise<void>;
13
15
  export declare const chainExternalSourcemap: (mapFilePath: string) => void;
14
16
  export {};
@@ -0,0 +1,43 @@
1
+ import type { ParsedVueSpaRoute } from './parseVueSpaRoutes';
2
+ export type VueCompileCacheResult = {
3
+ clientPath: string;
4
+ serverPath: string;
5
+ cssPaths: string[];
6
+ cssCodes: string[];
7
+ tsHelperPaths: string[];
8
+ hmrId: string;
9
+ spaRoutes?: ParsedVueSpaRoute[];
10
+ };
11
+ export type VueCompileCacheEntry = {
12
+ key: string;
13
+ clientCode: string;
14
+ serverCode: string;
15
+ result: VueCompileCacheResult;
16
+ /** Absolute path → content hash of every file `compileScript` read
17
+ * while resolving imported types. Re-verified on read. */
18
+ typeDeps: Record<string, string>;
19
+ };
20
+ export declare const vueCompileCacheEnabled: () => boolean;
21
+ export declare const hashContent: (content: string) => string;
22
+ export declare const hashParts: (parts: readonly string[]) => string;
23
+ export declare const frameworkVersionForCache: () => string | null;
24
+ export declare const vueCompileCacheDir: (projectRoot?: string) => string;
25
+ /** Build the environment part of every key: anything that changes the
26
+ * compiler's output without changing the component's own source. */
27
+ export declare const vueCompileCacheFingerprint: (parts: {
28
+ compilerVersion: string | undefined;
29
+ stylePreprocessors: unknown;
30
+ vueRootDir: string;
31
+ outputDirs: {
32
+ client: string;
33
+ server: string;
34
+ css: string;
35
+ };
36
+ }) => string | null;
37
+ /** Read a cached compile for `sourceFilePath` if its key matches and every
38
+ * recorded type dependency is unchanged. Any I/O or shape problem is a
39
+ * miss — the cache can only ever make a build faster, never wrong. */
40
+ export declare const readVueCompileCacheEntry: (sourceFilePath: string, key: string, projectRoot?: string) => VueCompileCacheEntry | null;
41
+ /** Persist a compile. Written via a temp file + rename so a crash mid-write
42
+ * can never leave a torn entry for the next process to trust. */
43
+ export declare const writeVueCompileCacheEntry: (sourceFilePath: string, entry: VueCompileCacheEntry, projectRoot?: string) => void;
@@ -391,7 +391,7 @@ export declare const launchConfig: (args: string[], cwd?: string) => Promise<imp
391
391
  status?: number | keyof import("elysia").StatusMap;
392
392
  cookie?: Record<string, import("elysia").BaseCookie>;
393
393
  };
394
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 500 | 100 | 200 | 400 | 404 | 300 | 304 | 426 | 204 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 301 | 302 | 303 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
394
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 500 | 100 | 200 | 400 | 404 | 300 | 304 | 503 | 426 | 204 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 301 | 302 | 303 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 428 | 429 | 431 | 451 | 501 | 502 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
395
395
  readonly 100: "Continue";
396
396
  readonly 101: "Switching Protocols";
397
397
  readonly 102: "Processing";
@@ -0,0 +1,11 @@
1
+ /** Record which boot step is currently running so the early listener's
2
+ * "Building…" page can show it. Cheap enough to call from every step. */
3
+ export declare const getBootPhase: () => string | undefined;
4
+ export declare const setBootPhase: (phase: string) => void;
5
+ type DeferredBootTask = () => void | Promise<void>;
6
+ /** Run every task queued by `deferUntilServing`. Called by the
7
+ * `networking` plugin once the real server is bound, so the work runs
8
+ * after the port is serving real traffic instead of delaying it. */
9
+ export declare const deferUntilServing: (task: DeferredBootTask) => void;
10
+ export declare const runDeferredBootTasks: () => void;
11
+ export {};
@@ -0,0 +1,41 @@
1
+ import type { Server } from 'bun';
2
+ export declare const BOOT_STATUS_HEADER = "X-Absolute-Boot";
3
+ export type EarlyListenerOptions = {
4
+ host: string;
5
+ port: number;
6
+ tls?: {
7
+ cert: string;
8
+ key: string;
9
+ } | null;
10
+ };
11
+ export type EarlyListener = {
12
+ /** The placeholder server, or null while a bind retry is pending or
13
+ * after release. */
14
+ readonly server: Server<undefined> | null;
15
+ readonly startedAt: number;
16
+ readonly released: boolean;
17
+ release: () => void;
18
+ };
19
+ export declare const bootStatusSnapshot: (startedAt: number) => {
20
+ elapsedMs: number;
21
+ elapsedSeconds: number;
22
+ phase: string;
23
+ status: "building";
24
+ };
25
+ /** 503 response for one request while the boot build is still running.
26
+ * HTML for browsers (`Accept: text/html`), JSON for JSON clients, plain
27
+ * text otherwise; WebSocket upgrade attempts (the HMR client) get a plain
28
+ * 503 instead of an upgrade so they fail the handshake cleanly and fall
29
+ * back to their `/hmr-status` polling loop. */
30
+ export declare const buildingResponse: (request: Request, startedAt: number) => Response;
31
+ /** Defensive hand-off for entries that call `.listen()` without the
32
+ * `networking` plugin: any `Bun.serve` that targets the placeholder's
33
+ * port first releases it. Installed once per process by the bootstrap. */
34
+ export declare const installEarlyListenerServeGuard: (port: number) => void;
35
+ export declare const releaseEarlyListener: () => boolean;
36
+ /** Bind the placeholder. A failed bind (the previous child's socket is
37
+ * still draining, or the port genuinely conflicts) is retried in the
38
+ * background for a few seconds and then given up on silently — the real
39
+ * `.listen()` still reports the conflict the way it always did. Never
40
+ * throws: the placeholder is a nicety and must not break boot. */
41
+ export declare const startEarlyListener: (options: EarlyListenerOptions) => EarlyListener;
@@ -36,7 +36,7 @@ export declare const createAbsoluteMobilePreviewPlugin: (mobile: MobileConfig |
36
36
  status?: number | keyof import("elysia").StatusMap;
37
37
  cookie?: Record<string, import("elysia").BaseCookie>;
38
38
  };
39
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 500 | 100 | 200 | 400 | 404 | 300 | 304 | 426 | 204 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 301 | 302 | 303 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
39
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 500 | 100 | 200 | 400 | 404 | 300 | 304 | 503 | 426 | 204 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 301 | 302 | 303 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 428 | 429 | 431 | 451 | 501 | 502 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
40
40
  readonly 100: "Continue";
41
41
  readonly 101: "Switching Protocols";
42
42
  readonly 102: "Processing";
@@ -19,7 +19,7 @@ export declare const imageOptimizer: (config: ImageConfig | undefined, buildDir:
19
19
  status?: number | keyof import("elysia").StatusMap;
20
20
  cookie?: Record<string, import("elysia").BaseCookie>;
21
21
  };
22
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 500 | 100 | 200 | 400 | 404 | 300 | 304 | 426 | 204 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 301 | 302 | 303 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
22
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 500 | 100 | 200 | 400 | 404 | 300 | 304 | 503 | 426 | 204 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 301 | 302 | 303 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 428 | 429 | 431 | 451 | 501 | 502 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
23
23
  readonly 100: "Continue";
24
24
  readonly 101: "Switching Protocols";
25
25
  readonly 102: "Processing";
@@ -2,6 +2,10 @@ export type StartupTimingStep = {
2
2
  label: string;
3
3
  durationMs: number;
4
4
  };
5
+ /** `ABSOLUTE_DEV_PROFILE=1` is the one-stop profiling switch: it turns on
6
+ * these per-step startup timings AND the per-phase build trace
7
+ * (`ABSOLUTE_BUILD_TRACE`, written to `<buildDir>/.absolute-trace/`). */
8
+ export declare const devProfileEnabled: boolean;
5
9
  export declare const startupTimingsEnabled: boolean;
6
10
  export declare const formatStartupTimingBlock: (title: string, steps: StartupTimingStep[]) => string;
7
11
  export declare const logStartupTimingBlock: (title: string, steps: StartupTimingStep[]) => void;
@@ -46,6 +46,21 @@ declare global {
46
46
  * detect this and call `.reload({ fetch })` on the existing server
47
47
  * instead of re-binding the port. Stays unset outside dev. */
48
48
  var __absoluteBunServer: import('bun').Server | null | undefined;
49
+ /** "Building…" placeholder bound by the dev bootstrap before the entry
50
+ * is imported; released by `networking` right before the real listen.
51
+ * See `src/dev/earlyListener.ts`. */
52
+ var __absoluteEarlyListener:
53
+ | import('../src/dev/earlyListener').EarlyListener
54
+ | undefined;
55
+ var __absoluteEarlyListenerServeGuard: boolean | undefined;
56
+ /** Label of the boot step currently running (shown on the placeholder
57
+ * page). See `src/dev/bootLifecycle.ts`. */
58
+ var __absoluteBootPhase: string | undefined;
59
+ /** Boot work deferred until the server is serving real traffic. */
60
+ var __absoluteDeferredBootTasks:
61
+ | Array<() => void | Promise<void>>
62
+ | undefined;
63
+ var __absoluteDeferredBootTasksRan: boolean | undefined;
49
64
 
50
65
  /** Dev-only request inspector ring buffer, filled by the global
51
66
  * request/afterResponse hooks in `requestInspector` and served at
package/package.json CHANGED
@@ -296,12 +296,12 @@
296
296
  "main": "./dist/index.js",
297
297
  "name": "@absolutejs/absolute",
298
298
  "optionalDependencies": {
299
- "@absolutejs/native-darwin-arm64": "0.20.0-beta.66",
300
- "@absolutejs/native-darwin-x64": "0.20.0-beta.66",
301
- "@absolutejs/native-linux-arm64": "0.20.0-beta.66",
302
- "@absolutejs/native-linux-x64": "0.20.0-beta.66",
303
- "@absolutejs/native-windows-arm64": "0.20.0-beta.66",
304
- "@absolutejs/native-windows-x64": "0.20.0-beta.66"
299
+ "@absolutejs/native-darwin-arm64": "0.20.0-beta.67",
300
+ "@absolutejs/native-darwin-x64": "0.20.0-beta.67",
301
+ "@absolutejs/native-linux-arm64": "0.20.0-beta.67",
302
+ "@absolutejs/native-linux-x64": "0.20.0-beta.67",
303
+ "@absolutejs/native-windows-arm64": "0.20.0-beta.67",
304
+ "@absolutejs/native-windows-x64": "0.20.0-beta.67"
305
305
  },
306
306
  "overrides": {
307
307
  "@sinclair/typebox": "0.34.52",
@@ -519,7 +519,7 @@
519
519
  ]
520
520
  }
521
521
  },
522
- "version": "0.20.0-beta.66",
522
+ "version": "0.20.0-beta.67",
523
523
  "workspaces": [
524
524
  "tests/fixtures/*",
525
525
  "tests/fixtures/_packages/*"