@blotch/angular-lynx 22.2.2 → 22.2.4

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.
@@ -1,18 +1,482 @@
1
1
  import * as i0 from "@angular/core";
2
- import { ApplicationRef, Component, DOCUMENT, DestroyRef, Directive, ElementRef, EnvironmentInjector, ErrorHandler, Injectable, InjectionToken, LOCALE_ID, Renderer2, RendererFactory2, RendererStyleFlags2, TemplateRef, ViewContainerRef, ViewEncapsulation, computed, contentChild, createComponent, effect, forwardRef, inject, input, makeEnvironmentProviders, output, signal, viewChild } from "@angular/core";
2
+ import { ApplicationRef, Component, DOCUMENT, DestroyRef, Directive, ElementRef, EnvironmentInjector, ErrorHandler, Injectable, InjectionToken, Injector, LOCALE_ID, Renderer2, RendererFactory2, RendererStyleFlags2, TemplateRef, ViewContainerRef, ViewEncapsulation, computed, contentChild, createComponent, effect, forwardRef, inject, input, makeEnvironmentProviders, output, provideEnvironmentInitializer, signal, viewChild, ɵɵreplaceMetadata } from "@angular/core";
3
+ import { ReplaySubject, Subject, firstValueFrom } from "rxjs";
4
+ import { APP_BASE_HREF, IMAGE_CONFIG, Location, LocationStrategy, PlatformLocation, getLocaleId } from "@angular/common";
3
5
  import { NG_VALUE_ACCESSOR } from "@angular/forms";
4
- import { APP_BASE_HREF, IMAGE_CONFIG, LocationStrategy, PlatformLocation } from "@angular/common";
5
- import { RouteReuseStrategy, provideRouter as provideRouter$1, withRouterConfig } from "@angular/router";
6
+ import { RouterLinkActive, provideRouter as provideRouter$1, withRouterConfig } from "@angular/router";
6
7
  import { bootstrapApplication as bootstrapApplication$1 } from "@angular/platform-browser";
7
- import { Subject, firstValueFrom } from "rxjs";
8
+ const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
9
+ const VALUES = new Map(Array.from(ALPHABET, (char, index) => [char, index]));
10
+ const SLICE$1 = 8192;
11
+ const bytesToBase64 = (bytes) => {
12
+ const codes = [];
13
+ let output = "";
14
+ for (let index = 0; index < bytes.length; index += 3) {
15
+ const a = bytes[index];
16
+ const b = bytes[index + 1];
17
+ const c = bytes[index + 2];
18
+ codes.push(ALPHABET.charCodeAt(a >> 2), ALPHABET.charCodeAt((a & 3) << 4 | (b ?? 0) >> 4), b === void 0 ? 61 : ALPHABET.charCodeAt((b & 15) << 2 | (c ?? 0) >> 6), c === void 0 ? 61 : ALPHABET.charCodeAt(c & 63));
19
+ if (codes.length >= SLICE$1) {
20
+ output += String.fromCharCode(...codes);
21
+ codes.length = 0;
22
+ }
23
+ }
24
+ return output + String.fromCharCode(...codes);
25
+ };
26
+ const base64ToBytes = (base64) => {
27
+ const values = [];
28
+ for (const char of base64) {
29
+ const value = VALUES.get(char);
30
+ if (value !== void 0) values.push(value);
31
+ }
32
+ const bytes = new Uint8Array(Math.floor(values.length * 3 / 4));
33
+ let byteIndex = 0;
34
+ for (let index = 0; index < values.length; index += 4) {
35
+ const a = values[index];
36
+ const b = values[index + 1] ?? 0;
37
+ const c = values[index + 2];
38
+ const d = values[index + 3];
39
+ bytes[byteIndex++] = a << 2 | b >> 4;
40
+ if (c !== void 0) bytes[byteIndex++] = (b & 15) << 4 | c >> 2;
41
+ if (d !== void 0) bytes[byteIndex++] = (c & 3) << 6 | d;
42
+ }
43
+ return bytes;
44
+ };
45
+ const LYNX_FAILURE_STATUS = 499;
46
+ const NULL_BODY_STATUSES = /* @__PURE__ */ new Set([
47
+ 101,
48
+ 103,
49
+ 204,
50
+ 205,
51
+ 304
52
+ ]);
53
+ const TEXT_TYPE = /^(text\/|application\/([\w.+-]*\+)?(json|xml|javascript|ecmascript|x-www-form-urlencoded|graphql)\b)/;
54
+ const isUtf8Text = (contentType) => {
55
+ if (!contentType) return false;
56
+ const type = contentType.toLowerCase();
57
+ const charset = /;\s*charset="?([^";]+)/.exec(type)?.[1];
58
+ return TEXT_TYPE.test(type) && (charset === void 0 || /^utf-?8$/.test(charset));
59
+ };
60
+ const decodeBody = (body) => {
61
+ if (body === null) return void 0;
62
+ if ("text" in body) return body.text;
63
+ return base64ToBytes(body.base64).buffer;
64
+ };
65
+ const backgroundFetch = () => typeof fetch === "function" ? fetch : void 0;
66
+ const controllers = /* @__PURE__ */ new Map();
67
+ const fetchForMainThread = async (id, request) => {
68
+ const fetchImpl = backgroundFetch();
69
+ if (!fetchImpl) throw new TypeError("fetch isn't available on the background thread in this environment");
70
+ const controller = new AbortController();
71
+ controllers.set(id, controller);
72
+ try {
73
+ const response = await fetchImpl(request.url, {
74
+ ...request.options,
75
+ method: request.method,
76
+ headers: Object.fromEntries(request.headers),
77
+ body: decodeBody(request.body),
78
+ signal: controller.signal
79
+ });
80
+ const headers = [];
81
+ response.headers.forEach((value, name) => headers.push([name, value]));
82
+ if (response.status === LYNX_FAILURE_STATUS && headers.length === 0) throw new TypeError(response.statusText || "Network request failed");
83
+ let body = null;
84
+ if (!NULL_BODY_STATUSES.has(response.status)) body = isUtf8Text(response.headers.get("content-type")) ? { text: await response.text() } : { base64: bytesToBase64(new Uint8Array(await response.arrayBuffer())) };
85
+ return {
86
+ status: response.status,
87
+ statusText: response.statusText,
88
+ url: response.url || request.url,
89
+ redirected: response.redirected === true,
90
+ headers,
91
+ body
92
+ };
93
+ } finally {
94
+ controllers.delete(id);
95
+ }
96
+ };
97
+ const abortFetchForMainThread = (id) => {
98
+ controllers.get(id)?.abort();
99
+ };
100
+ const CALL_EVENT = "AngularLynx.BackgroundCall";
101
+ const RESULT_EVENT = "AngularLynx.BackgroundCallResult";
102
+ const SESSION_STORAGE_EVENT = "AngularLynx.SessionStorageChange";
103
+ const CALLBACK_EVENT = "AngularLynx.Callback";
104
+ const isMainThread = () => typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__;
105
+ const lynxApi = (name) => {
106
+ const fn = typeof lynx !== "undefined" ? lynx[name] : void 0;
107
+ if (typeof fn !== "function") throw new Error(`lynx.${name} is not available in this environment`);
108
+ return fn.bind(lynx);
109
+ };
110
+ const relayedSubscriptions = /* @__PURE__ */ new Map();
111
+ const relayedFunctions = /* @__PURE__ */ new Map();
112
+ const relayedFunctionIds = /* @__PURE__ */ new WeakMap();
113
+ let nextFunctionId = 0;
114
+ const standIns = /* @__PURE__ */ new Map();
115
+ const isPlainObject = (value) => {
116
+ if (typeof value !== "object" || value === null) return false;
117
+ const proto = Object.getPrototypeOf(value);
118
+ return proto === Object.prototype || proto === null;
119
+ };
120
+ const isFunctionMarker = (value) => isPlainObject(value) && typeof value["__angularLynxCallback"] === "number";
121
+ const markFunction = (fn, owner) => {
122
+ let id = relayedFunctionIds.get(fn);
123
+ if (id === void 0) {
124
+ id = nextFunctionId++;
125
+ relayedFunctionIds.set(fn, id);
126
+ relayedFunctions.set(id, (...args) => fn.apply(owner, args));
127
+ }
128
+ return { __angularLynxCallback: id };
129
+ };
130
+ const relayFunctions = (value) => {
131
+ if (!isMainThread()) return value;
132
+ const relay = (item, owner) => {
133
+ if (typeof item === "function") return markFunction(item, owner);
134
+ if (Array.isArray(item)) return item.map((entry) => relay(entry));
135
+ if (isPlainObject(item)) {
136
+ const result = {};
137
+ for (const key of Object.keys(item)) result[key] = relay(item[key], item);
138
+ return result;
139
+ }
140
+ return item;
141
+ };
142
+ return relay(value);
143
+ };
144
+ const relayModuleObject = (module) => {
145
+ if (!isMainThread()) return module;
146
+ const result = {};
147
+ for (let source = module; source !== null && source !== Object.prototype; source = Object.getPrototypeOf(source)) for (const key of Object.getOwnPropertyNames(source)) {
148
+ if (key === "constructor" || key in result) continue;
149
+ const value = module[key];
150
+ result[key] = typeof value === "function" ? markFunction(value, module) : relayFunctions(value);
151
+ }
152
+ return result;
153
+ };
154
+ const restoreFunctions = (value) => {
155
+ if (isFunctionMarker(value)) {
156
+ const id = value.__angularLynxCallback;
157
+ let standIn = standIns.get(id);
158
+ if (!standIn) {
159
+ standIn = (...args) => {
160
+ try {
161
+ lynx.getCoreContext().dispatchEvent({
162
+ type: CALLBACK_EVENT,
163
+ data: JSON.stringify({
164
+ id,
165
+ args
166
+ })
167
+ });
168
+ } catch {}
169
+ };
170
+ standIns.set(id, standIn);
171
+ }
172
+ return standIn;
173
+ }
174
+ if (Array.isArray(value)) {
175
+ const items = value.map(restoreFunctions);
176
+ return items.some((item, i) => item !== value[i]) ? items : value;
177
+ }
178
+ if (isPlainObject(value)) {
179
+ let changed = false;
180
+ const result = {};
181
+ for (const key of Object.keys(value)) {
182
+ result[key] = restoreFunctions(value[key]);
183
+ changed ||= result[key] !== value[key];
184
+ }
185
+ return changed ? result : value;
186
+ }
187
+ return value;
188
+ };
189
+ const nativeBridge = () => {
190
+ const bridge = typeof NativeModules !== "undefined" && NativeModules != null ? NativeModules.bridge : void 0;
191
+ return typeof bridge?.call === "function" ? bridge : void 0;
192
+ };
193
+ const findModule = (kind, name) => {
194
+ if (kind === "native") return typeof NativeModules !== "undefined" && NativeModules != null ? NativeModules[name] : void 0;
195
+ return typeof lynx !== "undefined" && typeof lynx.getJSModule === "function" ? lynx.getJSModule(name) : void 0;
196
+ };
197
+ const handlers = {
198
+ accessibilityAnnounce: (content) => new Promise((resolve) => lynxApi("accessibilityAnnounce")({ content }, () => resolve())),
199
+ addFont: (fontFamily, src) => new Promise((resolve, reject) => lynxApi("addFont")({
200
+ "font-family": fontFamily,
201
+ src
202
+ }, (err) => err ? reject(err) : resolve())),
203
+ setObserverFrameRate: (options) => lynxApi("setObserverFrameRate")(options),
204
+ stopExposure: (options) => lynxApi("stopExposure")(options ?? {}),
205
+ resumeExposure: () => lynxApi("resumeExposure")(),
206
+ subscribeSessionStorage: (key, relayId) => {
207
+ const listenerId = lynxApi("subscribeSessionStorage")(key, (value) => lynx.getCoreContext().dispatchEvent({
208
+ type: SESSION_STORAGE_EVENT,
209
+ data: JSON.stringify({
210
+ relayId,
211
+ value
212
+ })
213
+ }));
214
+ relayedSubscriptions.set(relayId, {
215
+ key,
216
+ listenerId
217
+ });
218
+ },
219
+ unsubscribeSessionStorage: (relayId) => {
220
+ const subscription = relayedSubscriptions.get(relayId);
221
+ if (!subscription) return;
222
+ relayedSubscriptions.delete(relayId);
223
+ lynxApi("unsubscribeSessionStorage")(subscription.key, subscription.listenerId);
224
+ },
225
+ requestResourcePrefetch: (data) => new Promise((resolve) => lynxApi("requestResourcePrefetch")(data, resolve)),
226
+ cancelResourcePrefetch: (data) => new Promise((resolve) => lynxApi("cancelResourcePrefetch")(data, resolve)),
227
+ nativeBridgeCall: (name, params) => {
228
+ const bridge = nativeBridge();
229
+ if (!bridge) return Promise.resolve(void 0);
230
+ return new Promise((resolve) => bridge.call(name, params, (...args) => resolve(args[0])));
231
+ },
232
+ nativeBridgeOn: (name, callback) => {
233
+ nativeBridge()?.on(name, restoreFunctions(callback));
234
+ },
235
+ callModule: (kind, name, method, args) => {
236
+ const module = findModule(kind, name);
237
+ const fn = module?.[method];
238
+ if (typeof fn !== "function") throw new Error(`${kind === "native" ? "NativeModules" : "lynx.getJSModule"}: ${name}.${method} is not available`);
239
+ return fn.apply(module, restoreFunctions(args));
240
+ },
241
+ registerJSModule: (name, module) => {
242
+ lynxApi("registerModule")(name, restoreFunctions(module));
243
+ },
244
+ osVersion: () => typeof SystemInfo !== "undefined" ? SystemInfo.osVersion : void 0,
245
+ fetch: (id, request) => fetchForMainThread(id, request),
246
+ abortFetch: (id) => abortFetchForMainThread(id)
247
+ };
248
+ const pending = /* @__PURE__ */ new Map();
249
+ let nextCallId = 0;
250
+ const callOnBackground = (name, ...args) => {
251
+ if (!isMainThread()) try {
252
+ return Promise.resolve(handlers[name](...args));
253
+ } catch (error) {
254
+ return Promise.reject(error);
255
+ }
256
+ return new Promise((resolve, reject) => {
257
+ const id = nextCallId++;
258
+ pending.set(id, {
259
+ resolve,
260
+ reject
261
+ });
262
+ try {
263
+ lynx.getJSContext().dispatchEvent({
264
+ type: CALL_EVENT,
265
+ data: JSON.stringify({
266
+ id,
267
+ name,
268
+ args
269
+ })
270
+ });
271
+ } catch {
272
+ pending.delete(id);
273
+ reject(/* @__PURE__ */ new Error(`Can't reach the background thread to call lynx.${name} in this environment`));
274
+ }
275
+ });
276
+ };
277
+ const moduleProxies = /* @__PURE__ */ new Map();
278
+ const relayedModule = (kind, name) => {
279
+ const cacheKey = `${kind}:${name}`;
280
+ let proxy = moduleProxies.get(cacheKey);
281
+ if (!proxy) {
282
+ const methods = /* @__PURE__ */ new Map();
283
+ proxy = new Proxy({}, { get: (_target, method) => {
284
+ if (typeof method !== "string" || method === "then") return;
285
+ let call = methods.get(method);
286
+ if (!call) {
287
+ call = (...args) => callOnBackground("callModule", kind, name, method, relayFunctions(args));
288
+ methods.set(method, call);
289
+ }
290
+ return call;
291
+ } });
292
+ moduleProxies.set(cacheKey, proxy);
293
+ }
294
+ return proxy;
295
+ };
296
+ const sessionStorageListeners = /* @__PURE__ */ new Map();
297
+ let nextRelayId = 0;
298
+ const subscribeSessionStorageFromMainThread = (key, listener) => {
299
+ const relayId = nextRelayId++;
300
+ sessionStorageListeners.set(relayId, listener);
301
+ callOnBackground("subscribeSessionStorage", key, relayId).catch(() => {
302
+ sessionStorageListeners.delete(relayId);
303
+ });
304
+ return relayId;
305
+ };
306
+ const unsubscribeSessionStorageFromMainThread = (relayId) => {
307
+ if (!sessionStorageListeners.delete(relayId)) return;
308
+ callOnBackground("unsubscribeSessionStorage", relayId).catch(() => {});
309
+ };
310
+ const installRelay = () => {
311
+ if (typeof lynx === "undefined") return;
312
+ try {
313
+ if (isMainThread()) {
314
+ const context = lynx.getJSContext();
315
+ context.addEventListener(RESULT_EVENT, (event) => {
316
+ const { id, value, error } = JSON.parse(event.data);
317
+ const call = pending.get(id);
318
+ if (!call) return;
319
+ pending.delete(id);
320
+ if (error !== void 0) call.reject(new Error(error));
321
+ else call.resolve(value);
322
+ });
323
+ context.addEventListener(SESSION_STORAGE_EVENT, (event) => {
324
+ const { relayId, value } = JSON.parse(event.data);
325
+ sessionStorageListeners.get(relayId)?.(value);
326
+ });
327
+ context.addEventListener(CALLBACK_EVENT, (event) => {
328
+ const { id, args } = JSON.parse(event.data);
329
+ relayedFunctions.get(id)?.(...args);
330
+ });
331
+ return;
332
+ }
333
+ const context = lynx.getCoreContext();
334
+ context.addEventListener(CALL_EVENT, async (event) => {
335
+ const { id, name, args } = JSON.parse(event.data);
336
+ let reply;
337
+ try {
338
+ const handler = handlers[name];
339
+ if (!handler) throw new Error(`Unknown background call: ${name}`);
340
+ reply = {
341
+ id,
342
+ value: await handler(...args)
343
+ };
344
+ } catch (error) {
345
+ reply = {
346
+ id,
347
+ error: error instanceof Error ? error.message : String(error)
348
+ };
349
+ }
350
+ let data;
351
+ try {
352
+ data = JSON.stringify(reply);
353
+ } catch (error) {
354
+ data = JSON.stringify({
355
+ id,
356
+ error: `The result of ${name} can't be sent to the main thread: ${error.message}`
357
+ });
358
+ }
359
+ context.dispatchEvent({
360
+ type: RESULT_EVENT,
361
+ data
362
+ });
363
+ });
364
+ } catch {}
365
+ };
366
+ installRelay();
367
+ const ANIMATION_START = 0;
368
+ const ANIMATION_PLAY = 1;
369
+ const ANIMATION_PAUSE = 2;
370
+ const ANIMATION_CANCEL = 3;
371
+ var LynxAnimation = class LynxAnimation {
372
+ static #count = 0;
373
+ id;
374
+ #element;
375
+ #key;
376
+ #webAnimation;
377
+ constructor(element, keyframes, options) {
378
+ this.#element = element;
379
+ this.id = `__lynx-angular-animation-${LynxAnimation.#count++}`;
380
+ this.#key = __WEB__ ? this.id : options.name ?? this.id;
381
+ const wireOptions = { ...options };
382
+ if (options.iterations != null && !("iterationCount" in options)) wireOptions["iterationCount"] = options.iterations === Infinity ? "infinite" : options.iterations;
383
+ if (options.easing != null && !("timingFunction" in options)) wireOptions["timingFunction"] = options.easing;
384
+ if (options.fill != null && !("fillMode" in options)) wireOptions["fillMode"] = options.fill;
385
+ __ElementAnimate(this.#element, [
386
+ ANIMATION_START,
387
+ this.#key,
388
+ keyframes,
389
+ wireOptions
390
+ ]);
391
+ if (__WEB__) this.#webAnimation = this.#element.getAnimations?.().at(-1);
392
+ }
393
+ play() {
394
+ __ElementAnimate(this.#element, [ANIMATION_PLAY, this.#key]);
395
+ }
396
+ pause() {
397
+ __ElementAnimate(this.#element, [ANIMATION_PAUSE, this.#key]);
398
+ }
399
+ cancel() {
400
+ __ElementAnimate(this.#element, [ANIMATION_CANCEL, this.#key]);
401
+ this.#webAnimation?.cancel();
402
+ }
403
+ };
404
+ let willFlush = false;
405
+ const scheduleFlush = () => {
406
+ if (willFlush) return;
407
+ willFlush = true;
408
+ Promise.resolve().then(() => {
409
+ willFlush = false;
410
+ __FlushElementTree();
411
+ });
412
+ };
413
+ var MainThreadElement = class MainThreadElement {
414
+ #element;
415
+ constructor(element) {
416
+ this.#element = element;
417
+ }
418
+ setAttribute(name, value) {
419
+ __SetAttribute(this.#element, name, value);
420
+ scheduleFlush();
421
+ }
422
+ getAttribute(name) {
423
+ return __GetAttributeByName(this.#element, name);
424
+ }
425
+ getAttributeNames() {
426
+ return __GetAttributeNames(this.#element);
427
+ }
428
+ setStyleProperty(name, value) {
429
+ __AddInlineStyle(this.#element, name, value);
430
+ scheduleFlush();
431
+ }
432
+ setStyleProperties(styles) {
433
+ for (const key in styles) __AddInlineStyle(this.#element, key, styles[key]);
434
+ scheduleFlush();
435
+ }
436
+ querySelector(selector) {
437
+ const ref = __QuerySelector(this.#element, selector, {});
438
+ return ref ? new MainThreadElement(ref) : null;
439
+ }
440
+ querySelectorAll(selector) {
441
+ return __QuerySelectorAll(this.#element, selector, {}).map((el) => new MainThreadElement(el));
442
+ }
443
+ invoke(methodName, params) {
444
+ return new Promise((resolve, reject) => {
445
+ __InvokeUIMethod(this.#element, methodName, params ?? {}, (res) => {
446
+ if (res.code === 0) resolve(res.data);
447
+ else reject(/* @__PURE__ */ new Error("UI method invoke: " + JSON.stringify(res)));
448
+ });
449
+ scheduleFlush();
450
+ });
451
+ }
452
+ animate(keyframes, options) {
453
+ const normalizedOptions = typeof options === "number" ? { duration: options } : options ?? {};
454
+ return new LynxAnimation(this.#element, keyframes, normalizedOptions);
455
+ }
456
+ getBoundingClientRect(options) {
457
+ return this.invoke("boundingClientRect", options).then((rect) => {
458
+ const { left, top, right, bottom, width, height } = rect;
459
+ return {
460
+ left,
461
+ top,
462
+ right,
463
+ bottom,
464
+ width,
465
+ height
466
+ };
467
+ });
468
+ }
469
+ };
8
470
  var LynxAccessibility = class LynxAccessibility {
9
471
  announce(content) {
10
- if (typeof lynx === "undefined" || typeof lynx.accessibilityAnnounce !== "function") return Promise.reject(/* @__PURE__ */ new Error("lynx.accessibilityAnnounce is not available in this environment"));
11
- return new Promise((resolve) => {
12
- lynx.accessibilityAnnounce({ content }, () => resolve());
13
- });
472
+ return callOnBackground("accessibilityAnnounce", content);
14
473
  }
15
474
  requestFocus(selector) {
475
+ if (typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__) {
476
+ const element = new MainThreadElement(__GetPageElement()).querySelector(selector);
477
+ if (!element) return Promise.reject(/* @__PURE__ */ new Error(`requestAccessibilityFocus: no element matches ${selector}`));
478
+ return element.invoke("requestAccessibilityFocus").then(() => void 0);
479
+ }
16
480
  if (typeof lynx === "undefined" || !lynx.createSelectorQuery) return Promise.reject(/* @__PURE__ */ new Error("lynx.createSelectorQuery is not available in this environment"));
17
481
  return new Promise((resolve, reject) => {
18
482
  lynx.createSelectorQuery().select(selector).invoke({
@@ -49,38 +513,121 @@ i0.ɵɵngDeclareClassMetadata({
49
513
  args: [{ providedIn: "root" }]
50
514
  }]
51
515
  });
52
- const ANIMATION_START = 0;
53
- const ANIMATION_PLAY = 1;
54
- const ANIMATION_PAUSE = 2;
55
- const ANIMATION_CANCEL = 3;
56
- var LynxAnimation = class LynxAnimation {
57
- static #count = 0;
58
- id;
59
- #element;
60
- constructor(element, keyframes, options) {
61
- this.#element = element;
62
- this.id = `__lynx-angular-animation-${LynxAnimation.#count++}`;
63
- const wireOptions = { ...options };
64
- if (options.iterations != null && !("iterationCount" in options)) wireOptions["iterationCount"] = options.iterations === Infinity ? "infinite" : options.iterations;
65
- if (options.easing != null && !("timingFunction" in options)) wireOptions["timingFunction"] = options.easing;
66
- if (options.fill != null && !("fillMode" in options)) wireOptions["fillMode"] = options.fill;
67
- __ElementAnimate(this.#element, [
68
- ANIMATION_START,
69
- options.name ?? this.id,
70
- keyframes,
71
- wireOptions
72
- ]);
73
- }
74
- play() {
75
- __ElementAnimate(this.#element, [ANIMATION_PLAY, this.id]);
516
+ const initDataUpdates = new Subject();
517
+ const globalDataUpdates = new Subject();
518
+ const asRecord = (data) => typeof data === "object" && data !== null ? data : {};
519
+ const applyInitDataUpdate = (data, reset) => {
520
+ const host = lynx;
521
+ const next = {
522
+ ...reset ? {} : host.__initData,
523
+ ...asRecord(data)
524
+ };
525
+ host.__initData = next;
526
+ initDataUpdates.next(next);
527
+ return next;
528
+ };
529
+ const applyGlobalDataUpdate = (data) => {
530
+ const next = {
531
+ ...lynx.__globalProps,
532
+ ...asRecord(data)
533
+ };
534
+ lynx.__globalProps = next;
535
+ globalDataUpdates.next(next);
536
+ return next;
537
+ };
538
+ var LynxGlobalData = class LynxGlobalData {
539
+ globalData = signal(typeof lynx !== "undefined" && lynx.__globalProps || {}, ...ngDevMode ? [{ debugName: "globalData" }] : /* istanbul ignore next */ []);
540
+ constructor() {
541
+ const subscription = globalDataUpdates.subscribe((data) => this.globalData.set(data));
542
+ inject(DestroyRef).onDestroy(() => subscription.unsubscribe());
76
543
  }
77
- pause() {
78
- __ElementAnimate(this.#element, [ANIMATION_PAUSE, this.id]);
544
+ static ɵfac = i0.ɵɵngDeclareFactory({
545
+ minVersion: "12.0.0",
546
+ version: "22.2.1",
547
+ ngImport: i0,
548
+ type: LynxGlobalData,
549
+ deps: [],
550
+ target: i0.ɵɵFactoryTarget.Injectable
551
+ });
552
+ static ɵprov = i0.ɵɵngDeclareInjectable({
553
+ minVersion: "12.0.0",
554
+ version: "22.2.1",
555
+ ngImport: i0,
556
+ type: LynxGlobalData,
557
+ providedIn: "root"
558
+ });
559
+ };
560
+ i0.ɵɵngDeclareClassMetadata({
561
+ minVersion: "12.0.0",
562
+ version: "22.2.1",
563
+ ngImport: i0,
564
+ type: LynxGlobalData,
565
+ decorators: [{
566
+ type: Injectable,
567
+ args: [{ providedIn: "root" }]
568
+ }],
569
+ ctorParameters: () => []
570
+ });
571
+ const MEDIA_QUERIES = {
572
+ reduceMotion: "(prefers-reduced-motion: reduce)",
573
+ reduceTransparency: "(prefers-reduced-transparency: reduce)",
574
+ increaseContrast: "(prefers-contrast: more)"
575
+ };
576
+ const isOn = (data, setting) => data[setting] === true || data[setting] === "true";
577
+ const pageWindow = () => {
578
+ if (!__WEB__ || typeof __GetPageElement !== "function") return void 0;
579
+ return __GetPageElement()?.ownerDocument?.defaultView ?? void 0;
580
+ };
581
+ const watchMediaQueries = (destroyRef) => {
582
+ const win = pageWindow();
583
+ const signals = {};
584
+ for (const setting of Object.keys(MEDIA_QUERIES)) {
585
+ const query = typeof win?.matchMedia === "function" ? win.matchMedia(MEDIA_QUERIES[setting]) : void 0;
586
+ const matches = signal(query?.matches ?? false, ...ngDevMode ? [{ debugName: "matches" }] : /* istanbul ignore next */ []);
587
+ if (query) {
588
+ const update = () => matches.set(query.matches);
589
+ query.addEventListener("change", update);
590
+ destroyRef.onDestroy(() => query.removeEventListener("change", update));
591
+ }
592
+ signals[setting] = matches.asReadonly();
79
593
  }
80
- cancel() {
81
- __ElementAnimate(this.#element, [ANIMATION_CANCEL, this.id]);
594
+ return signals;
595
+ };
596
+ var LynxAccessibilitySettings = class LynxAccessibilitySettings {
597
+ #globalData = inject(LynxGlobalData);
598
+ #media = watchMediaQueries(inject(DestroyRef));
599
+ reduceMotion = this.#setting("reduceMotion");
600
+ reduceTransparency = this.#setting("reduceTransparency");
601
+ increaseContrast = this.#setting("increaseContrast");
602
+ #setting(setting) {
603
+ return computed(() => isOn(this.#globalData.globalData(), setting) || this.#media[setting]());
82
604
  }
605
+ static ɵfac = i0.ɵɵngDeclareFactory({
606
+ minVersion: "12.0.0",
607
+ version: "22.2.1",
608
+ ngImport: i0,
609
+ type: LynxAccessibilitySettings,
610
+ deps: [],
611
+ target: i0.ɵɵFactoryTarget.Injectable
612
+ });
613
+ static ɵprov = i0.ɵɵngDeclareInjectable({
614
+ minVersion: "12.0.0",
615
+ version: "22.2.1",
616
+ ngImport: i0,
617
+ type: LynxAccessibilitySettings,
618
+ providedIn: "root"
619
+ });
83
620
  };
621
+ i0.ɵɵngDeclareClassMetadata({
622
+ minVersion: "12.0.0",
623
+ version: "22.2.1",
624
+ ngImport: i0,
625
+ type: LynxAccessibilitySettings,
626
+ decorators: [{
627
+ type: Injectable,
628
+ args: [{ providedIn: "root" }]
629
+ }]
630
+ });
84
631
  var LynxPerformance = class LynxPerformance {
85
632
  #perf = this.#resolve();
86
633
  #resolve() {
@@ -142,6 +689,15 @@ const devStats = {
142
689
  this.lastCdDurationMs = 0;
143
690
  }
144
691
  };
692
+ const now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
693
+ const cdStartTimes = [];
694
+ const startCdTiming = () => {
695
+ cdStartTimes.push(now());
696
+ };
697
+ const endCdTiming = () => {
698
+ const start = cdStartTimes.pop();
699
+ if (start !== void 0) devStats.lastCdDurationMs = now() - start;
700
+ };
145
701
  var LynxDevTools = class LynxDevTools {
146
702
  #tick = signal(0, ...ngDevMode ? [{ debugName: "#tick" }] : /* istanbul ignore next */ []);
147
703
  stats = computed(() => {
@@ -206,48 +762,11 @@ const registerDataProcessors = (definition) => {
206
762
  }
207
763
  };
208
764
  };
209
- var LynxGlobalData = class LynxGlobalData {
210
- globalData = signal(typeof lynx !== "undefined" ? lynx.__globalProps : {}, ...ngDevMode ? [{ debugName: "globalData" }] : /* istanbul ignore next */ []);
211
- constructor() {
212
- if (typeof lynx === "undefined" || typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__ || typeof lynx.getJSModule !== "function") return;
213
- const emitter = lynx.getJSModule("GlobalEventEmitter");
214
- if (!emitter?.addListener) return;
215
- emitter.addListener("onGlobalPropsChanged", (...args) => this.globalData.set(args[0]));
216
- }
217
- static ɵfac = i0.ɵɵngDeclareFactory({
218
- minVersion: "12.0.0",
219
- version: "22.2.1",
220
- ngImport: i0,
221
- type: LynxGlobalData,
222
- deps: [],
223
- target: i0.ɵɵFactoryTarget.Injectable
224
- });
225
- static ɵprov = i0.ɵɵngDeclareInjectable({
226
- minVersion: "12.0.0",
227
- version: "22.2.1",
228
- ngImport: i0,
229
- type: LynxGlobalData,
230
- providedIn: "root"
231
- });
232
- };
233
- i0.ɵɵngDeclareClassMetadata({
234
- minVersion: "12.0.0",
235
- version: "22.2.1",
236
- ngImport: i0,
237
- type: LynxGlobalData,
238
- decorators: [{
239
- type: Injectable,
240
- args: [{ providedIn: "root" }]
241
- }],
242
- ctorParameters: () => []
243
- });
244
765
  var LynxInitData = class LynxInitData {
245
- initData = signal(typeof lynx !== "undefined" ? lynx.__initData : {}, ...ngDevMode ? [{ debugName: "initData" }] : /* istanbul ignore next */ []);
766
+ initData = signal(typeof lynx !== "undefined" && lynx.__initData || {}, ...ngDevMode ? [{ debugName: "initData" }] : /* istanbul ignore next */ []);
246
767
  constructor() {
247
- if (typeof lynx === "undefined" || typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__ || typeof lynx.getJSModule !== "function") return;
248
- const emitter = lynx.getJSModule("GlobalEventEmitter");
249
- if (!emitter?.addListener) return;
250
- emitter.addListener("onDataChanged", (...args) => this.initData.set(args[0]));
768
+ const subscription = initDataUpdates.subscribe((data) => this.initData.set(data));
769
+ inject(DestroyRef).onDestroy(() => subscription.unsubscribe());
251
770
  }
252
771
  static ɵfac = i0.ɵɵngDeclareFactory({
253
772
  minVersion: "12.0.0",
@@ -356,30 +875,57 @@ i0.ɵɵngDeclareClassMetadata({
356
875
  }],
357
876
  ctorParameters: () => []
358
877
  });
878
+ const globalExposureBatches = new Subject();
879
+ const FORWARD_EVENT = "AngularLynx.GlobalExposure";
880
+ const installGlobalExposureBridge = () => {
881
+ if (typeof lynx === "undefined") return;
882
+ try {
883
+ if (__MAIN_THREAD__) {
884
+ lynx.getJSContext?.()?.addEventListener(FORWARD_EVENT, (event) => globalExposureBatches.next(JSON.parse(event.data)));
885
+ return;
886
+ }
887
+ const emitter = lynx.getJSModule?.("GlobalEventEmitter");
888
+ if (!emitter?.addListener) return;
889
+ for (const type of ["exposure", "disexposure"]) emitter.addListener(type, (...args) => {
890
+ const batch = {
891
+ type,
892
+ events: args[0]
893
+ };
894
+ globalExposureBatches.next(batch);
895
+ lynx.getCoreContext?.()?.dispatchEvent({
896
+ type: FORWARD_EVENT,
897
+ data: JSON.stringify(batch)
898
+ });
899
+ });
900
+ } catch {}
901
+ };
902
+ installGlobalExposureBridge();
359
903
  var LynxGlobalExposure = class LynxGlobalExposure {
360
904
  exposures = signal([], ...ngDevMode ? [{ debugName: "exposures" }] : /* istanbul ignore next */ []);
361
905
  disexposures = signal([], ...ngDevMode ? [{ debugName: "disexposures" }] : /* istanbul ignore next */ []);
362
906
  active = signal(true, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
363
907
  constructor() {
364
- if (typeof lynx === "undefined" || typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__) return;
365
- const emitter = lynx.getJSModule("GlobalEventEmitter");
366
- if (!emitter?.addListener) return;
367
- emitter.addListener("exposure", (...args) => this.exposures.set(args[0]));
368
- emitter.addListener("disexposure", (...args) => this.disexposures.set(args[0]));
908
+ const subscription = globalExposureBatches.subscribe(({ type, events }) => (type === "exposure" ? this.exposures : this.disexposures).set(events));
909
+ inject(DestroyRef).onDestroy(() => subscription.unsubscribe());
369
910
  }
370
911
  stopExposure(options) {
371
912
  if (typeof lynx === "undefined") return;
372
- lynx.stopExposure(options);
913
+ if (typeof lynx.stopExposure === "function") lynx.stopExposure(options);
914
+ else this.#relay(callOnBackground("stopExposure", options));
373
915
  this.active.set(false);
374
916
  }
375
917
  resumeExposure() {
376
918
  if (typeof lynx === "undefined") return;
377
- lynx.resumeExposure();
919
+ if (typeof lynx.resumeExposure === "function") lynx.resumeExposure();
920
+ else this.#relay(callOnBackground("resumeExposure"));
378
921
  this.active.set(true);
379
922
  }
380
923
  setObserverFrameRate(options) {
381
- if (typeof lynx === "undefined") return;
382
- lynx.setObserverFrameRate(options);
924
+ if (typeof lynx === "undefined") return Promise.resolve();
925
+ return callOnBackground("setObserverFrameRate", options);
926
+ }
927
+ #relay(call) {
928
+ call.catch((error) => console.error(error));
383
929
  }
384
930
  static ɵfac = i0.ɵɵngDeclareFactory({
385
931
  minVersion: "12.0.0",
@@ -428,30 +974,23 @@ var LynxFont = class LynxFont {
428
974
  src,
429
975
  status: "loading"
430
976
  });
431
- const promise = new Promise((resolve, reject) => {
432
- lynx.addFont({
433
- "font-family": fontFamily,
434
- src
435
- }, (err) => {
436
- if (err) {
437
- this.#updateEntry(fontFamily, {
438
- fontFamily,
439
- src,
440
- status: "error",
441
- error: err
442
- });
443
- this.#pending.delete(fontFamily);
444
- reject(err);
445
- } else {
446
- this.#updateEntry(fontFamily, {
447
- fontFamily,
448
- src,
449
- status: "loaded"
450
- });
451
- this.#pending.delete(fontFamily);
452
- resolve();
453
- }
977
+ const promise = callOnBackground("addFont", fontFamily, src).then(() => {
978
+ this.#updateEntry(fontFamily, {
979
+ fontFamily,
980
+ src,
981
+ status: "loaded"
982
+ });
983
+ this.#pending.delete(fontFamily);
984
+ }, (err) => {
985
+ const error = err instanceof Error ? err : new Error(String(err));
986
+ this.#updateEntry(fontFamily, {
987
+ fontFamily,
988
+ src,
989
+ status: "error",
990
+ error
454
991
  });
992
+ this.#pending.delete(fontFamily);
993
+ throw error;
455
994
  });
456
995
  this.#pending.set(fontFamily, promise);
457
996
  return promise;
@@ -541,10 +1080,48 @@ const reportError = (source, cause) => {
541
1080
  _ReportError(error, { errorCode: 6 });
542
1081
  }
543
1082
  };
1083
+ const DATA_KEY = "angularLynx";
1084
+ const ɵhmrAccept = (hot, components, signature, code) => {
1085
+ hot.accept();
1086
+ if (!isMainThread()) return components;
1087
+ const previous = hot.data?.[DATA_KEY];
1088
+ let live = components;
1089
+ let invalidated = false;
1090
+ if (previous && !previous.invalidated) {
1091
+ if (previous.code !== code && previous.signature === signature && previous.components.length === components.length) try {
1092
+ previous.components.forEach((type, index) => replaceComponent(type, components[index]));
1093
+ live = previous.components;
1094
+ } catch (error) {
1095
+ console.error("[HMR] Could not update the component in place:", error);
1096
+ invalidated = true;
1097
+ }
1098
+ else invalidated = true;
1099
+ }
1100
+ hot.dispose((data) => {
1101
+ data[DATA_KEY] = {
1102
+ components: live,
1103
+ signature,
1104
+ code,
1105
+ invalidated
1106
+ };
1107
+ });
1108
+ if (invalidated) hot.invalidate();
1109
+ return live;
1110
+ };
1111
+ const replaceComponent = (current, next) => {
1112
+ const currentDef = current.ɵcmp;
1113
+ const nextDef = next.ɵcmp;
1114
+ currentDef.directiveDefs = nextDef.directiveDefs;
1115
+ currentDef.pipeDefs = nextDef.pipeDefs;
1116
+ ɵɵreplaceMetadata(current, (type) => {
1117
+ type.ɵcmp = next.ɵcmp;
1118
+ }, [], []);
1119
+ };
544
1120
  const extractAppLocale = (globalProps) => {
545
1121
  const value = globalProps?.["appLocale"];
546
1122
  return typeof value === "string" && value ? value : void 0;
547
1123
  };
1124
+ const getSourceLocale = () => typeof __LYNX_SOURCE_LOCALE__ !== "undefined" ? __LYNX_SOURCE_LOCALE__ : "en-US";
548
1125
  const getLynxAppLocale = () => {
549
1126
  if (typeof lynx === "undefined") return;
550
1127
  return extractAppLocale(lynx.__globalProps);
@@ -552,9 +1129,7 @@ const getLynxAppLocale = () => {
552
1129
  var LynxLocale = class LynxLocale {
553
1130
  #globalData = inject(LynxGlobalData);
554
1131
  locale = computed(() => {
555
- const value = extractAppLocale(this.#globalData.globalData());
556
- if (value) return value;
557
- return typeof __LYNX_SOURCE_LOCALE__ !== "undefined" ? __LYNX_SOURCE_LOCALE__ : "en-US";
1132
+ return extractAppLocale(this.#globalData.globalData()) ?? getSourceLocale();
558
1133
  }, ...ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []);
559
1134
  static ɵfac = i0.ɵɵngDeclareFactory({
560
1135
  minVersion: "12.0.0",
@@ -582,17 +1157,31 @@ i0.ɵɵngDeclareClassMetadata({
582
1157
  args: [{ providedIn: "root" }]
583
1158
  }]
584
1159
  });
1160
+ const hasLocaleData = (locale) => {
1161
+ try {
1162
+ getLocaleId(locale);
1163
+ return true;
1164
+ } catch {
1165
+ return false;
1166
+ }
1167
+ };
585
1168
  const provideLocale = () => {
586
1169
  return makeEnvironmentProviders([{
587
1170
  provide: LOCALE_ID,
588
- useFactory: () => inject(LynxLocale).locale()
1171
+ useFactory: () => {
1172
+ const locale = inject(LynxLocale).locale();
1173
+ const source = getSourceLocale();
1174
+ if (locale === source || hasLocaleData(locale)) return locale;
1175
+ console.warn(`provideLocale(): Angular has no locale data for "${locale}", so LOCALE_ID is "${source}". Register it with registerLocaleData() to format dates and numbers for it.`);
1176
+ return source;
1177
+ }
589
1178
  }]);
590
1179
  };
591
1180
  let nextGestureId = 1;
592
1181
  var BaseGesture = class {
593
1182
  id = nextGestureId++;
594
1183
  _callbacks = {};
595
- _config = {};
1184
+ _config = { enabled: true };
596
1185
  _waitFor = [];
597
1186
  _simultaneousWith = [];
598
1187
  _continueWith = [];
@@ -716,7 +1305,7 @@ const mapGestureEvent = (raw, name, origin) => {
716
1305
  absoluteY
717
1306
  };
718
1307
  if (origin) {
719
- if (name === "onBegin" || name === "onStart" || origin.x === null) {
1308
+ if (name === "onBegin" || origin.x === null) {
720
1309
  origin.x = absoluteX ?? 0;
721
1310
  origin.y = absoluteY ?? 0;
722
1311
  }
@@ -756,19 +1345,22 @@ var LynxGestureDetector = class LynxGestureDetector {
756
1345
  #el = inject(ElementRef).nativeElement;
757
1346
  #attachedIds = [];
758
1347
  lynxGesture;
1348
+ constructor() {
1349
+ const elementRef = this.#el.element;
1350
+ if (elementRef) __SetAttribute(elementRef, "flatten", false);
1351
+ }
759
1352
  ngOnChanges(_changes) {
760
1353
  this.#detachAll();
761
1354
  const gestures = this.#resolveGestures();
762
1355
  if (gestures.length === 0) return;
763
1356
  const elementRef = this.#el.element;
764
1357
  if (!elementRef) return;
765
- __SetAttribute(elementRef, "flatten", false);
766
1358
  for (const g of gestures) {
767
1359
  const stateManager = new GestureStateManager(elementRef, g.id);
768
1360
  const origin = createGestureOrigin();
769
1361
  const config = {
770
1362
  callbacks: buildGestureCallbacks(g, origin, stateManager),
771
- config: Object.keys(g._config).length > 0 ? g._config : void 0
1363
+ config: g._config
772
1364
  };
773
1365
  const relationMap = {
774
1366
  waitFor: g._waitFor.map((dep) => dep.id),
@@ -826,7 +1418,8 @@ i0.ɵɵngDeclareClassMetadata({
826
1418
  selector: "[lynxGesture]",
827
1419
  inputs: ["lynxGesture"]
828
1420
  }]
829
- }]
1421
+ }],
1422
+ ctorParameters: () => []
830
1423
  });
831
1424
  const buildGestureCallbacks = (gesture, origin, stateManager) => {
832
1425
  const wrap = (name, cb) => ({
@@ -834,7 +1427,11 @@ const buildGestureCallbacks = (gesture, origin, stateManager) => {
834
1427
  callback: { _fn: (event) => cb(mapGestureEvent(event, name, origin), stateManager) }
835
1428
  });
836
1429
  const userEnd = gesture._callbacks["onEnd"];
837
- if (!(gesture.type === GestureType.TAP || gesture.type === GestureType.LONGPRESS) || !userEnd) return Object.entries(gesture._callbacks).map(([name, cb]) => wrap(name, cb));
1430
+ if (!(gesture.type === GestureType.TAP || gesture.type === GestureType.LONGPRESS) || !userEnd) {
1431
+ const callbacks = Object.entries(gesture._callbacks).map(([name, cb]) => wrap(name, cb));
1432
+ if (gesture instanceof ContinuousGesture && !gesture._callbacks["onBegin"]) callbacks.push(wrap("onBegin", () => {}));
1433
+ return callbacks;
1434
+ }
838
1435
  const userStart = gesture._callbacks["onStart"];
839
1436
  const lifecycle = { started: false };
840
1437
  const callbacks = [{
@@ -934,6 +1531,15 @@ var TapGesture = class extends BaseGesture {
934
1531
  return this;
935
1532
  }
936
1533
  };
1534
+ function booleanInput(value) {
1535
+ return typeof value === "string" ? value !== "false" : value;
1536
+ }
1537
+ function panInterceptDirectionInput(value) {
1538
+ return typeof value === "string" ? Number(value) : value;
1539
+ }
1540
+ function panInterceptScopeInput(value) {
1541
+ return typeof value === "string" ? Number(value) : value;
1542
+ }
937
1543
  var LynxElementBase = class LynxElementBase {
938
1544
  #el = inject(ElementRef).nativeElement;
939
1545
  ngOnChanges(changes) {
@@ -947,7 +1553,7 @@ var LynxElementBase = class LynxElementBase {
947
1553
  name;
948
1554
  "accessibility-element";
949
1555
  "accessibility-label";
950
- "accessibility-trait";
1556
+ "accessibility-traits";
951
1557
  "accessibility-elements";
952
1558
  "accessibility-elements-hidden";
953
1559
  "accessibility-exclusive-focus";
@@ -959,6 +1565,11 @@ var LynxElementBase = class LynxElementBase {
959
1565
  "block-native-event";
960
1566
  "ignore-focus";
961
1567
  "ios-enable-simultaneous-touch";
1568
+ flatten;
1569
+ "pan-intercept-direction";
1570
+ "pan-intercept-scope";
1571
+ "consume-slide-event";
1572
+ "enable-touch-pseudo-propagation";
962
1573
  "exposure-id";
963
1574
  "exposure-scene";
964
1575
  "exposure-area";
@@ -970,6 +1581,7 @@ var LynxElementBase = class LynxElementBase {
970
1581
  "exposure-ui-margin-bottom";
971
1582
  "exposure-ui-margin-left";
972
1583
  "exposure-ui-margin-right";
1584
+ "enable-exposure-ui-margin";
973
1585
  static ɵfac = i0.ɵɵngDeclareFactory({
974
1586
  minVersion: "12.0.0",
975
1587
  version: "22.2.1",
@@ -979,27 +1591,86 @@ var LynxElementBase = class LynxElementBase {
979
1591
  target: i0.ɵɵFactoryTarget.Directive
980
1592
  });
981
1593
  static ɵdir = i0.ɵɵngDeclareDirective({
982
- minVersion: "14.0.0",
1594
+ minVersion: "16.1.0",
983
1595
  version: "22.2.1",
984
1596
  type: LynxElementBase,
985
1597
  isStandalone: true,
986
1598
  inputs: {
987
1599
  id: "id",
988
1600
  name: "name",
989
- "accessibility-element": "accessibility-element",
1601
+ "accessibility-element": [
1602
+ "accessibility-element",
1603
+ "accessibility-element",
1604
+ booleanInput
1605
+ ],
990
1606
  "accessibility-label": "accessibility-label",
991
- "accessibility-trait": "accessibility-trait",
1607
+ "accessibility-value": "accessibility-value",
1608
+ "accessibility-actions": "accessibility-actions",
1609
+ "accessibility-traits": "accessibility-traits",
992
1610
  "accessibility-elements": "accessibility-elements",
993
- "accessibility-elements-hidden": "accessibility-elements-hidden",
994
- "accessibility-exclusive-focus": "accessibility-exclusive-focus",
1611
+ "accessibility-elements-hidden": [
1612
+ "accessibility-elements-hidden",
1613
+ "accessibility-elements-hidden",
1614
+ booleanInput
1615
+ ],
1616
+ "accessibility-exclusive-focus": [
1617
+ "accessibility-exclusive-focus",
1618
+ "accessibility-exclusive-focus",
1619
+ booleanInput
1620
+ ],
995
1621
  "a11y-id": "a11y-id",
996
- "user-interaction-enabled": "user-interaction-enabled",
997
- "native-interaction-enabled": "native-interaction-enabled",
998
- "event-through": "event-through",
1622
+ "user-interaction-enabled": [
1623
+ "user-interaction-enabled",
1624
+ "user-interaction-enabled",
1625
+ booleanInput
1626
+ ],
1627
+ "native-interaction-enabled": [
1628
+ "native-interaction-enabled",
1629
+ "native-interaction-enabled",
1630
+ booleanInput
1631
+ ],
1632
+ "event-through": [
1633
+ "event-through",
1634
+ "event-through",
1635
+ booleanInput
1636
+ ],
999
1637
  "hit-slop": "hit-slop",
1000
- "block-native-event": "block-native-event",
1001
- "ignore-focus": "ignore-focus",
1002
- "ios-enable-simultaneous-touch": "ios-enable-simultaneous-touch",
1638
+ "block-native-event": [
1639
+ "block-native-event",
1640
+ "block-native-event",
1641
+ booleanInput
1642
+ ],
1643
+ "ignore-focus": [
1644
+ "ignore-focus",
1645
+ "ignore-focus",
1646
+ booleanInput
1647
+ ],
1648
+ "ios-enable-simultaneous-touch": [
1649
+ "ios-enable-simultaneous-touch",
1650
+ "ios-enable-simultaneous-touch",
1651
+ booleanInput
1652
+ ],
1653
+ flatten: [
1654
+ "flatten",
1655
+ "flatten",
1656
+ booleanInput
1657
+ ],
1658
+ "pan-intercept-direction": [
1659
+ "pan-intercept-direction",
1660
+ "pan-intercept-direction",
1661
+ panInterceptDirectionInput
1662
+ ],
1663
+ "pan-intercept-scope": [
1664
+ "pan-intercept-scope",
1665
+ "pan-intercept-scope",
1666
+ panInterceptScopeInput
1667
+ ],
1668
+ "consume-slide-event": "consume-slide-event",
1669
+ "enable-touch-pseudo-propagation": [
1670
+ "enable-touch-pseudo-propagation",
1671
+ "enable-touch-pseudo-propagation",
1672
+ booleanInput
1673
+ ],
1003
1674
  "exposure-id": "exposure-id",
1004
1675
  "exposure-scene": "exposure-scene",
1005
1676
  "exposure-area": "exposure-area",
@@ -1010,7 +1681,12 @@ var LynxElementBase = class LynxElementBase {
1010
1681
  "exposure-ui-margin-top": "exposure-ui-margin-top",
1011
1682
  "exposure-ui-margin-bottom": "exposure-ui-margin-bottom",
1012
1683
  "exposure-ui-margin-left": "exposure-ui-margin-left",
1013
- "exposure-ui-margin-right": "exposure-ui-margin-right"
1684
+ "exposure-ui-margin-right": "exposure-ui-margin-right",
1685
+ "enable-exposure-ui-margin": [
1686
+ "enable-exposure-ui-margin",
1687
+ "enable-exposure-ui-margin",
1688
+ booleanInput
1689
+ ]
1014
1690
  },
1015
1691
  usesOnChanges: true,
1016
1692
  ngImport: i0
@@ -1026,20 +1702,66 @@ i0.ɵɵngDeclareClassMetadata({
1026
1702
  args: [{ inputs: [
1027
1703
  "id",
1028
1704
  "name",
1029
- "accessibility-element",
1705
+ {
1706
+ name: "accessibility-element",
1707
+ transform: booleanInput
1708
+ },
1030
1709
  "accessibility-label",
1031
- "accessibility-trait",
1710
+ "accessibility-value",
1711
+ "accessibility-actions",
1712
+ "accessibility-traits",
1032
1713
  "accessibility-elements",
1033
- "accessibility-elements-hidden",
1034
- "accessibility-exclusive-focus",
1714
+ {
1715
+ name: "accessibility-elements-hidden",
1716
+ transform: booleanInput
1717
+ },
1718
+ {
1719
+ name: "accessibility-exclusive-focus",
1720
+ transform: booleanInput
1721
+ },
1035
1722
  "a11y-id",
1036
- "user-interaction-enabled",
1037
- "native-interaction-enabled",
1038
- "event-through",
1723
+ {
1724
+ name: "user-interaction-enabled",
1725
+ transform: booleanInput
1726
+ },
1727
+ {
1728
+ name: "native-interaction-enabled",
1729
+ transform: booleanInput
1730
+ },
1731
+ {
1732
+ name: "event-through",
1733
+ transform: booleanInput
1734
+ },
1039
1735
  "hit-slop",
1040
- "block-native-event",
1041
- "ignore-focus",
1042
- "ios-enable-simultaneous-touch",
1736
+ {
1737
+ name: "block-native-event",
1738
+ transform: booleanInput
1739
+ },
1740
+ {
1741
+ name: "ignore-focus",
1742
+ transform: booleanInput
1743
+ },
1744
+ {
1745
+ name: "ios-enable-simultaneous-touch",
1746
+ transform: booleanInput
1747
+ },
1748
+ {
1749
+ name: "flatten",
1750
+ transform: booleanInput
1751
+ },
1752
+ {
1753
+ name: "pan-intercept-direction",
1754
+ transform: panInterceptDirectionInput
1755
+ },
1756
+ {
1757
+ name: "pan-intercept-scope",
1758
+ transform: panInterceptScopeInput
1759
+ },
1760
+ "consume-slide-event",
1761
+ {
1762
+ name: "enable-touch-pseudo-propagation",
1763
+ transform: booleanInput
1764
+ },
1043
1765
  "exposure-id",
1044
1766
  "exposure-scene",
1045
1767
  "exposure-area",
@@ -1050,7 +1772,11 @@ i0.ɵɵngDeclareClassMetadata({
1050
1772
  "exposure-ui-margin-top",
1051
1773
  "exposure-ui-margin-bottom",
1052
1774
  "exposure-ui-margin-left",
1053
- "exposure-ui-margin-right"
1775
+ "exposure-ui-margin-right",
1776
+ {
1777
+ name: "enable-exposure-ui-margin",
1778
+ transform: booleanInput
1779
+ }
1054
1780
  ] }]
1055
1781
  }]
1056
1782
  });
@@ -1106,7 +1832,6 @@ i0.ɵɵngDeclareClassMetadata({
1106
1832
  type: Directive,
1107
1833
  args: [{
1108
1834
  selector: "blur-view",
1109
- standalone: true,
1110
1835
  inputs: [
1111
1836
  "blur-radius",
1112
1837
  "blur-sampling",
@@ -1149,10 +1874,7 @@ i0.ɵɵngDeclareClassMetadata({
1149
1874
  type: LynxCoverView,
1150
1875
  decorators: [{
1151
1876
  type: Directive,
1152
- args: [{
1153
- selector: "cover-view",
1154
- standalone: true
1155
- }]
1877
+ args: [{ selector: "cover-view" }]
1156
1878
  }]
1157
1879
  });
1158
1880
  var LynxInputValueAccessor = class LynxInputValueAccessor {
@@ -1167,7 +1889,7 @@ var LynxInputValueAccessor = class LynxInputValueAccessor {
1167
1889
  this.#onTouched();
1168
1890
  }
1169
1891
  writeValue(value) {
1170
- this.#el.nativeElement.invoke?.("setValue", { value: value ?? "" });
1892
+ this.#el.nativeElement.invoke("setValue", { value: value ?? "" });
1171
1893
  }
1172
1894
  registerOnChange(fn) {
1173
1895
  this.#onChange = fn;
@@ -1215,7 +1937,6 @@ i0.ɵɵngDeclareClassMetadata({
1215
1937
  type: Directive,
1216
1938
  args: [{
1217
1939
  selector: "input[formControlName],input[formControl],input[ngModel],input[formField]",
1218
- standalone: true,
1219
1940
  providers: [{
1220
1941
  provide: NG_VALUE_ACCESSOR,
1221
1942
  /* v8 ignore next -- Angular metadata: the forwardRef arrow is only invoked by Angular's directive DI resolution, which happens inside a full template render — the accessor's runtime behavior is covered by direct unit tests below. */
@@ -1241,7 +1962,7 @@ var LynxTextareaValueAccessor = class LynxTextareaValueAccessor {
1241
1962
  this.#onTouched();
1242
1963
  }
1243
1964
  writeValue(value) {
1244
- this.#el.nativeElement.invoke?.("setValue", { value: value ?? "" });
1965
+ this.#el.nativeElement.invoke("setValue", { value: value ?? "" });
1245
1966
  }
1246
1967
  registerOnChange(fn) {
1247
1968
  this.#onChange = fn;
@@ -1289,7 +2010,6 @@ i0.ɵɵngDeclareClassMetadata({
1289
2010
  type: Directive,
1290
2011
  args: [{
1291
2012
  selector: "textarea[formControlName],textarea[formControl],textarea[ngModel],textarea[formField]",
1292
- standalone: true,
1293
2013
  providers: [{
1294
2014
  provide: NG_VALUE_ACCESSOR,
1295
2015
  /* v8 ignore next -- Angular metadata: the forwardRef arrow is only invoked by Angular's directive DI resolution, which happens inside a full template render — the accessor's runtime behavior is covered by direct unit tests below. */
@@ -1350,7 +2070,6 @@ i0.ɵɵngDeclareClassMetadata({
1350
2070
  type: Directive,
1351
2071
  args: [{
1352
2072
  selector: "frame",
1353
- standalone: true,
1354
2073
  inputs: [
1355
2074
  "src",
1356
2075
  "data",
@@ -1422,7 +2141,6 @@ i0.ɵɵngDeclareClassMetadata({
1422
2141
  type: Directive,
1423
2142
  args: [{
1424
2143
  selector: "image",
1425
- standalone: true,
1426
2144
  inputs: [
1427
2145
  "src",
1428
2146
  "mode",
@@ -1446,7 +2164,7 @@ var LynxInput = class LynxInput extends LynxElementBase {
1446
2164
  #el = inject(ElementRef).nativeElement;
1447
2165
  ngOnChanges(changes) {
1448
2166
  if ("value" in changes) {
1449
- this.#el.invoke?.("setValue", { value: changes["value"].currentValue ?? "" });
2167
+ this.#el.invoke("setValue", { value: changes["value"].currentValue ?? "" });
1450
2168
  const { value: _ignored, ...rest } = changes;
1451
2169
  if (Object.keys(rest).length) super.ngOnChanges(rest);
1452
2170
  } else super.ngOnChanges(changes);
@@ -1507,7 +2225,6 @@ i0.ɵɵngDeclareClassMetadata({
1507
2225
  type: Directive,
1508
2226
  args: [{
1509
2227
  selector: "input",
1510
- standalone: true,
1511
2228
  inputs: [
1512
2229
  "type",
1513
2230
  "placeholder",
@@ -1530,7 +2247,7 @@ var LynxTextarea = class LynxTextarea extends LynxElementBase {
1530
2247
  #el = inject(ElementRef).nativeElement;
1531
2248
  ngOnChanges(changes) {
1532
2249
  if ("value" in changes) {
1533
- this.#el.invoke?.("setValue", { value: changes["value"].currentValue ?? "" });
2250
+ this.#el.invoke("setValue", { value: changes["value"].currentValue ?? "" });
1534
2251
  const { value: _ignored, ...rest } = changes;
1535
2252
  if (Object.keys(rest).length) super.ngOnChanges(rest);
1536
2253
  } else super.ngOnChanges(changes);
@@ -1599,7 +2316,6 @@ i0.ɵɵngDeclareClassMetadata({
1599
2316
  type: Directive,
1600
2317
  args: [{
1601
2318
  selector: "textarea",
1602
- standalone: true,
1603
2319
  inputs: [
1604
2320
  "type",
1605
2321
  "placeholder",
@@ -1641,8 +2357,6 @@ var LynxList = class LynxList extends LynxElementBase {
1641
2357
  "preload-buffer-count";
1642
2358
  "item-snap";
1643
2359
  "update-animation";
1644
- "list-main-axis-gap";
1645
- "list-cross-axis-gap";
1646
2360
  "enable-async-list";
1647
2361
  "enable-insert-platform-view-operation";
1648
2362
  "experimental-search-ref-anchor-strategy";
@@ -1680,8 +2394,6 @@ var LynxList = class LynxList extends LynxElementBase {
1680
2394
  "preload-buffer-count": "preload-buffer-count",
1681
2395
  "item-snap": "item-snap",
1682
2396
  "update-animation": "update-animation",
1683
- "list-main-axis-gap": "list-main-axis-gap",
1684
- "list-cross-axis-gap": "list-cross-axis-gap",
1685
2397
  "enable-async-list": "enable-async-list",
1686
2398
  "enable-insert-platform-view-operation": "enable-insert-platform-view-operation",
1687
2399
  "experimental-search-ref-anchor-strategy": "experimental-search-ref-anchor-strategy",
@@ -1700,7 +2412,6 @@ i0.ɵɵngDeclareClassMetadata({
1700
2412
  type: Directive,
1701
2413
  args: [{
1702
2414
  selector: "list",
1703
- standalone: true,
1704
2415
  inputs: [
1705
2416
  "list-type",
1706
2417
  "span-count",
@@ -1720,8 +2431,6 @@ i0.ɵɵngDeclareClassMetadata({
1720
2431
  "preload-buffer-count",
1721
2432
  "item-snap",
1722
2433
  "update-animation",
1723
- "list-main-axis-gap",
1724
- "list-cross-axis-gap",
1725
2434
  "enable-async-list",
1726
2435
  "enable-insert-platform-view-operation",
1727
2436
  "experimental-search-ref-anchor-strategy",
@@ -1738,7 +2447,6 @@ var LynxListItem = class LynxListItem extends LynxElementBase {
1738
2447
  recyclable;
1739
2448
  "reuse-identifier";
1740
2449
  "estimated-main-axis-size-px";
1741
- defer;
1742
2450
  static ɵfac = i0.ɵɵngDeclareFactory({
1743
2451
  minVersion: "12.0.0",
1744
2452
  version: "22.2.1",
@@ -1760,8 +2468,7 @@ var LynxListItem = class LynxListItem extends LynxElementBase {
1760
2468
  "sticky-bottom": "sticky-bottom",
1761
2469
  recyclable: "recyclable",
1762
2470
  "reuse-identifier": "reuse-identifier",
1763
- "estimated-main-axis-size-px": "estimated-main-axis-size-px",
1764
- defer: "defer"
2471
+ "estimated-main-axis-size-px": "estimated-main-axis-size-px"
1765
2472
  },
1766
2473
  usesInheritance: true,
1767
2474
  ngImport: i0
@@ -1776,7 +2483,6 @@ i0.ɵɵngDeclareClassMetadata({
1776
2483
  type: Directive,
1777
2484
  args: [{
1778
2485
  selector: "list-item",
1779
- standalone: true,
1780
2486
  inputs: [
1781
2487
  "item-key",
1782
2488
  "full-span",
@@ -1784,8 +2490,7 @@ i0.ɵɵngDeclareClassMetadata({
1784
2490
  "sticky-bottom",
1785
2491
  "recyclable",
1786
2492
  "reuse-identifier",
1787
- "estimated-main-axis-size-px",
1788
- "defer"
2493
+ "estimated-main-axis-size-px"
1789
2494
  ]
1790
2495
  }]
1791
2496
  }]
@@ -1816,10 +2521,7 @@ i0.ɵɵngDeclareClassMetadata({
1816
2521
  type: LynxBlock,
1817
2522
  decorators: [{
1818
2523
  type: Directive,
1819
- args: [{
1820
- selector: "block",
1821
- standalone: true
1822
- }]
2524
+ args: [{ selector: "block" }]
1823
2525
  }]
1824
2526
  });
1825
2527
  var LynxIf = class LynxIf extends LynxElementBase {
@@ -1848,10 +2550,7 @@ i0.ɵɵngDeclareClassMetadata({
1848
2550
  type: LynxIf,
1849
2551
  decorators: [{
1850
2552
  type: Directive,
1851
- args: [{
1852
- selector: "if",
1853
- standalone: true
1854
- }]
2553
+ args: [{ selector: "if" }]
1855
2554
  }]
1856
2555
  });
1857
2556
  var LynxFor = class LynxFor extends LynxElementBase {
@@ -1880,10 +2579,7 @@ i0.ɵɵngDeclareClassMetadata({
1880
2579
  type: LynxFor,
1881
2580
  decorators: [{
1882
2581
  type: Directive,
1883
- args: [{
1884
- selector: "for",
1885
- standalone: true
1886
- }]
2582
+ args: [{ selector: "for" }]
1887
2583
  }]
1888
2584
  });
1889
2585
  var LynxOverlay = class LynxOverlay extends LynxElementBase {
@@ -1928,7 +2624,6 @@ i0.ɵɵngDeclareClassMetadata({
1928
2624
  type: Directive,
1929
2625
  args: [{
1930
2626
  selector: "overlay",
1931
- standalone: true,
1932
2627
  inputs: [
1933
2628
  "visible",
1934
2629
  "level",
@@ -1970,7 +2665,6 @@ i0.ɵɵngDeclareClassMetadata({
1970
2665
  type: Directive,
1971
2666
  args: [{
1972
2667
  selector: "refresh",
1973
- standalone: true,
1974
2668
  inputs: ["enable-refresh"]
1975
2669
  }]
1976
2670
  }]
@@ -2001,10 +2695,7 @@ i0.ɵɵngDeclareClassMetadata({
2001
2695
  type: LynxRefreshHeader,
2002
2696
  decorators: [{
2003
2697
  type: Directive,
2004
- args: [{
2005
- selector: "refresh-header",
2006
- standalone: true
2007
- }]
2698
+ args: [{ selector: "refresh-header" }]
2008
2699
  }]
2009
2700
  });
2010
2701
  var LynxScrollCoordinator = class LynxScrollCoordinator extends LynxElementBase {
@@ -2057,7 +2748,6 @@ i0.ɵɵngDeclareClassMetadata({
2057
2748
  type: Directive,
2058
2749
  args: [{
2059
2750
  selector: "scroll-coordinator",
2060
- standalone: true,
2061
2751
  inputs: [
2062
2752
  "enable-scroll",
2063
2753
  "bounces",
@@ -2099,10 +2789,7 @@ i0.ɵɵngDeclareClassMetadata({
2099
2789
  type: LynxScrollCoordinatorHeader,
2100
2790
  decorators: [{
2101
2791
  type: Directive,
2102
- args: [{
2103
- selector: "scroll-coordinator-header",
2104
- standalone: true
2105
- }]
2792
+ args: [{ selector: "scroll-coordinator-header" }]
2106
2793
  }]
2107
2794
  });
2108
2795
  var LynxScrollCoordinatorToolbar = class LynxScrollCoordinatorToolbar extends LynxElementBase {
@@ -2131,10 +2818,7 @@ i0.ɵɵngDeclareClassMetadata({
2131
2818
  type: LynxScrollCoordinatorToolbar,
2132
2819
  decorators: [{
2133
2820
  type: Directive,
2134
- args: [{
2135
- selector: "scroll-coordinator-toolbar",
2136
- standalone: true
2137
- }]
2821
+ args: [{ selector: "scroll-coordinator-toolbar" }]
2138
2822
  }]
2139
2823
  });
2140
2824
  var LynxScrollCoordinatorSlot = class LynxScrollCoordinatorSlot extends LynxElementBase {
@@ -2163,10 +2847,7 @@ i0.ɵɵngDeclareClassMetadata({
2163
2847
  type: LynxScrollCoordinatorSlot,
2164
2848
  decorators: [{
2165
2849
  type: Directive,
2166
- args: [{
2167
- selector: "scroll-coordinator-slot",
2168
- standalone: true
2169
- }]
2850
+ args: [{ selector: "scroll-coordinator-slot" }]
2170
2851
  }]
2171
2852
  });
2172
2853
  var LynxScrollCoordinatorSlotDrag = class LynxScrollCoordinatorSlotDrag extends LynxElementBase {
@@ -2199,7 +2880,6 @@ i0.ɵɵngDeclareClassMetadata({
2199
2880
  type: Directive,
2200
2881
  args: [{
2201
2882
  selector: "scroll-coordinator-slot-drag",
2202
- standalone: true,
2203
2883
  inputs: ["enable-drag"]
2204
2884
  }]
2205
2885
  }]
@@ -2254,7 +2934,6 @@ i0.ɵɵngDeclareClassMetadata({
2254
2934
  type: Directive,
2255
2935
  args: [{
2256
2936
  selector: "scroll-view",
2257
- standalone: true,
2258
2937
  inputs: [
2259
2938
  "scroll-orientation",
2260
2939
  "enable-scroll",
@@ -2306,7 +2985,6 @@ i0.ɵɵngDeclareClassMetadata({
2306
2985
  type: Directive,
2307
2986
  args: [{
2308
2987
  selector: "svg",
2309
- standalone: true,
2310
2988
  inputs: [
2311
2989
  "src",
2312
2990
  "content",
@@ -2363,7 +3041,6 @@ i0.ɵɵngDeclareClassMetadata({
2363
3041
  type: Directive,
2364
3042
  args: [{
2365
3043
  selector: "text",
2366
- standalone: true,
2367
3044
  inputs: [
2368
3045
  "text-maxline",
2369
3046
  "text-single-line-vertical-align",
@@ -2404,10 +3081,7 @@ i0.ɵɵngDeclareClassMetadata({
2404
3081
  type: LynxInlineTruncation,
2405
3082
  decorators: [{
2406
3083
  type: Directive,
2407
- args: [{
2408
- selector: "inline-truncation",
2409
- standalone: true
2410
- }]
3084
+ args: [{ selector: "inline-truncation" }]
2411
3085
  }]
2412
3086
  });
2413
3087
  var LynxTitleBarView = class LynxTitleBarView extends LynxElementBase {
@@ -2440,7 +3114,6 @@ i0.ɵɵngDeclareClassMetadata({
2440
3114
  type: Directive,
2441
3115
  args: [{
2442
3116
  selector: "title-bar-view",
2443
- standalone: true,
2444
3117
  inputs: ["moveable"]
2445
3118
  }]
2446
3119
  }]
@@ -2491,7 +3164,6 @@ i0.ɵɵngDeclareClassMetadata({
2491
3164
  type: Directive,
2492
3165
  args: [{
2493
3166
  selector: "video",
2494
- standalone: true,
2495
3167
  inputs: [
2496
3168
  "src",
2497
3169
  "loop",
@@ -2506,11 +3178,6 @@ i0.ɵɵngDeclareClassMetadata({
2506
3178
  }]
2507
3179
  });
2508
3180
  var LynxView = class LynxView extends LynxElementBase {
2509
- flatten;
2510
- "pan-intercept-direction";
2511
- "pan-intercept-scope";
2512
- "consume-slide-event";
2513
- "enable-touch-pseudo-propagation";
2514
3181
  static ɵfac = i0.ɵɵngDeclareFactory({
2515
3182
  minVersion: "12.0.0",
2516
3183
  version: "22.2.1",
@@ -2525,13 +3192,6 @@ var LynxView = class LynxView extends LynxElementBase {
2525
3192
  type: LynxView,
2526
3193
  isStandalone: true,
2527
3194
  selector: "view",
2528
- inputs: {
2529
- flatten: "flatten",
2530
- "pan-intercept-direction": "pan-intercept-direction",
2531
- "pan-intercept-scope": "pan-intercept-scope",
2532
- "consume-slide-event": "consume-slide-event",
2533
- "enable-touch-pseudo-propagation": "enable-touch-pseudo-propagation"
2534
- },
2535
3195
  usesInheritance: true,
2536
3196
  ngImport: i0
2537
3197
  });
@@ -2543,17 +3203,7 @@ i0.ɵɵngDeclareClassMetadata({
2543
3203
  type: LynxView,
2544
3204
  decorators: [{
2545
3205
  type: Directive,
2546
- args: [{
2547
- selector: "view",
2548
- standalone: true,
2549
- inputs: [
2550
- "flatten",
2551
- "pan-intercept-direction",
2552
- "pan-intercept-scope",
2553
- "consume-slide-event",
2554
- "enable-touch-pseudo-propagation"
2555
- ]
2556
- }]
3206
+ args: [{ selector: "view" }]
2557
3207
  }]
2558
3208
  });
2559
3209
  var LynxViewPager = class LynxViewPager extends LynxElementBase {
@@ -2606,7 +3256,6 @@ i0.ɵɵngDeclareClassMetadata({
2606
3256
  type: Directive,
2607
3257
  args: [{
2608
3258
  selector: "viewpager",
2609
- standalone: true,
2610
3259
  inputs: [
2611
3260
  "initial-select-index",
2612
3261
  "enable-scroll",
@@ -2648,10 +3297,7 @@ i0.ɵɵngDeclareClassMetadata({
2648
3297
  type: LynxViewPagerItem,
2649
3298
  decorators: [{
2650
3299
  type: Directive,
2651
- args: [{
2652
- selector: "viewpager-item",
2653
- standalone: true
2654
- }]
3300
+ args: [{ selector: "viewpager-item" }]
2655
3301
  }]
2656
3302
  });
2657
3303
  var LynxWebView = class LynxWebView extends LynxElementBase {
@@ -2704,7 +3350,6 @@ i0.ɵɵngDeclareClassMetadata({
2704
3350
  type: Directive,
2705
3351
  args: [{
2706
3352
  selector: "webview",
2707
- standalone: true,
2708
3353
  inputs: [
2709
3354
  "src",
2710
3355
  "html",
@@ -2720,6 +3365,43 @@ i0.ɵɵngDeclareClassMetadata({
2720
3365
  }]
2721
3366
  }]
2722
3367
  });
3368
+ const ROUTER_LINK_ACTIVE_CHANGE = new InjectionToken("router-link-active-change");
3369
+ var LynxRouterLinkActive = class LynxRouterLinkActive {
3370
+ constructor() {
3371
+ const activeChange = inject(ROUTER_LINK_ACTIVE_CHANGE, { optional: true })?.();
3372
+ if (!activeChange) return;
3373
+ const element = inject(ElementRef).nativeElement;
3374
+ const subscription = activeChange.subscribe((active) => element.setAccessibilityTrait("selected", active));
3375
+ inject(DestroyRef).onDestroy(() => subscription.unsubscribe());
3376
+ }
3377
+ static ɵfac = i0.ɵɵngDeclareFactory({
3378
+ minVersion: "12.0.0",
3379
+ version: "22.2.1",
3380
+ ngImport: i0,
3381
+ type: LynxRouterLinkActive,
3382
+ deps: [],
3383
+ target: i0.ɵɵFactoryTarget.Directive
3384
+ });
3385
+ static ɵdir = i0.ɵɵngDeclareDirective({
3386
+ minVersion: "14.0.0",
3387
+ version: "22.2.1",
3388
+ type: LynxRouterLinkActive,
3389
+ isStandalone: true,
3390
+ selector: "[routerLinkActive]",
3391
+ ngImport: i0
3392
+ });
3393
+ };
3394
+ i0.ɵɵngDeclareClassMetadata({
3395
+ minVersion: "12.0.0",
3396
+ version: "22.2.1",
3397
+ ngImport: i0,
3398
+ type: LynxRouterLinkActive,
3399
+ decorators: [{
3400
+ type: Directive,
3401
+ args: [{ selector: "[routerLinkActive]" }]
3402
+ }],
3403
+ ctorParameters: () => []
3404
+ });
2723
3405
  const LYNX_ELEMENTS = [
2724
3406
  LynxView,
2725
3407
  LynxText,
@@ -2734,7 +3416,8 @@ const LYNX_ELEMENTS = [
2734
3416
  LynxFrame,
2735
3417
  LynxInput,
2736
3418
  LynxTextarea,
2737
- ...LYNX_FORM_ACCESSORS,
3419
+ LynxInputValueAccessor,
3420
+ LynxTextareaValueAccessor,
2738
3421
  LynxOverlay,
2739
3422
  LynxRefresh,
2740
3423
  LynxRefreshHeader,
@@ -2750,28 +3433,56 @@ const LYNX_ELEMENTS = [
2750
3433
  LynxVideo,
2751
3434
  LynxWebView,
2752
3435
  LynxCoverView,
2753
- LynxTitleBarView
3436
+ LynxTitleBarView,
3437
+ LynxRouterLinkActive
2754
3438
  ];
2755
- var LynxLogger = class LynxLogger {
2756
- #url = "";
2757
- #fetchFn;
2758
- constructor() {
2759
- if (!__DEV__) return;
2760
- this.#url = typeof __DEV_LOG_URL__ !== "undefined" ? __DEV_LOG_URL__ : "";
2761
- if (!this.#url) return;
2762
- try {
2763
- if (typeof fetch === "function") this.#fetchFn = fetch;
2764
- else if (typeof globalThis.fetch === "function") this.#fetchFn = globalThis.fetch;
2765
- } catch {}
2766
- if (!this.#fetchFn) return;
2767
- try {
2768
- if (typeof lynx !== "undefined" && typeof lynx.getCoreContext === "function") lynx.getCoreContext().addEventListener("__lynx_log__", (event) => {
2769
- try {
2770
- this.#postToServer(JSON.parse(event.data));
2771
- } catch {}
2772
- });
2773
- } catch {}
2774
- }
3439
+ const LOG_EVENT = "__lynx_log__";
3440
+ const logUrl = () => __DEV__ && typeof __DEV_LOG_URL__ !== "undefined" ? __DEV_LOG_URL__ : "";
3441
+ const resolveFetch = () => {
3442
+ try {
3443
+ if (typeof fetch === "function") return fetch;
3444
+ else if (typeof globalThis.fetch === "function") return globalThis.fetch;
3445
+ } catch {}
3446
+ };
3447
+ const toLogArg = (arg) => {
3448
+ if (arg instanceof Error) return {
3449
+ __type: "Error",
3450
+ name: arg.name,
3451
+ message: arg.message,
3452
+ stack: arg.stack
3453
+ };
3454
+ if (typeof arg === "object" && arg !== null) try {
3455
+ JSON.stringify(arg);
3456
+ return arg;
3457
+ } catch {}
3458
+ return String(arg);
3459
+ };
3460
+ const postToServer = (fetchFn, url, entry) => {
3461
+ try {
3462
+ fetchFn(url, {
3463
+ method: "POST",
3464
+ headers: { "Content-Type": "application/json" },
3465
+ body: JSON.stringify({ logs: [entry] })
3466
+ }).catch(() => {});
3467
+ } catch {}
3468
+ };
3469
+ const installLogRelay = () => {
3470
+ if (typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__) return;
3471
+ const url = logUrl();
3472
+ const fetchFn = resolveFetch();
3473
+ if (!url || !fetchFn) return;
3474
+ try {
3475
+ if (typeof lynx !== "undefined" && typeof lynx.getCoreContext === "function") lynx.getCoreContext().addEventListener(LOG_EVENT, (event) => {
3476
+ try {
3477
+ postToServer(fetchFn, url, JSON.parse(event.data));
3478
+ } catch {}
3479
+ });
3480
+ } catch {}
3481
+ };
3482
+ installLogRelay();
3483
+ var LynxLogger = class LynxLogger {
3484
+ #url = logUrl();
3485
+ #fetchFn = this.#url ? resolveFetch() : void 0;
2775
3486
  log(...args) {
2776
3487
  this.#send("log", args);
2777
3488
  }
@@ -2792,25 +3503,16 @@ var LynxLogger = class LynxLogger {
2792
3503
  const entry = {
2793
3504
  level,
2794
3505
  timestamp: Date.now(),
2795
- args: args.map(String)
3506
+ args: args.map(toLogArg)
2796
3507
  };
2797
- if (this.#fetchFn) this.#postToServer(entry);
3508
+ if (this.#fetchFn) postToServer(this.#fetchFn, this.#url, entry);
2798
3509
  else try {
2799
3510
  if (typeof lynx !== "undefined" && typeof lynx.getJSContext === "function") lynx.getJSContext().dispatchEvent({
2800
- type: "__lynx_log__",
3511
+ type: LOG_EVENT,
2801
3512
  data: JSON.stringify(entry)
2802
3513
  });
2803
3514
  } catch {}
2804
3515
  }
2805
- #postToServer(entry) {
2806
- try {
2807
- this.#fetchFn(this.#url, {
2808
- method: "POST",
2809
- headers: { "Content-Type": "application/json" },
2810
- body: JSON.stringify({ logs: [entry] })
2811
- }).catch(() => {});
2812
- } catch {}
2813
- }
2814
3516
  static ɵfac = i0.ɵɵngDeclareFactory({
2815
3517
  minVersion: "12.0.0",
2816
3518
  version: "22.2.1",
@@ -2835,39 +3537,35 @@ i0.ɵɵngDeclareClassMetadata({
2835
3537
  decorators: [{
2836
3538
  type: Injectable,
2837
3539
  args: [{ providedIn: "root" }]
2838
- }],
2839
- ctorParameters: () => []
3540
+ }]
2840
3541
  });
2841
3542
  var LynxNativeModule = class LynxNativeModule {
2842
3543
  #hasNativeModules() {
2843
- return typeof NativeModules !== "undefined" && NativeModules != null && typeof NativeModules.bridge?.call === "function";
3544
+ return typeof NativeModules !== "undefined" && NativeModules != null;
2844
3545
  }
2845
3546
  #hasLynx() {
2846
3547
  return typeof lynx !== "undefined" && typeof lynx.getJSModule === "function";
2847
3548
  }
2848
3549
  call(name, params = {}) {
2849
- if (!this.#hasNativeModules()) return Promise.resolve(void 0);
2850
- return new Promise((resolve) => {
2851
- NativeModules.bridge.call(name, params, (...args) => {
2852
- resolve(args[0]);
2853
- });
2854
- });
3550
+ if (isMainThread() && typeof lynx === "undefined") return Promise.resolve(void 0);
3551
+ return callOnBackground("nativeBridgeCall", name, params);
2855
3552
  }
2856
3553
  on(name, callback) {
2857
- if (!this.#hasNativeModules()) return;
2858
- NativeModules.bridge.on(name, callback);
3554
+ callOnBackground("nativeBridgeOn", name, relayFunctions(callback)).catch(() => {});
2859
3555
  }
2860
3556
  getNativeModule(name) {
2861
- if (typeof NativeModules === "undefined" || NativeModules == null) return;
3557
+ if (isMainThread()) return typeof lynx !== "undefined" ? relayedModule("native", name) : void 0;
3558
+ if (!this.#hasNativeModules()) return;
2862
3559
  return NativeModules[name];
2863
3560
  }
2864
3561
  getJSModule(name) {
3562
+ if (isMainThread()) return typeof lynx !== "undefined" ? relayedModule("js", name) : void 0;
2865
3563
  if (!this.#hasLynx()) return;
2866
3564
  return lynx.getJSModule(name);
2867
3565
  }
2868
3566
  registerJSModule(name, module) {
2869
- if (!this.#hasLynx()) return;
2870
- lynx.registerModule(name, module);
3567
+ if (typeof lynx === "undefined") return;
3568
+ callOnBackground("registerJSModule", name, relayModuleObject(module)).catch(() => {});
2871
3569
  }
2872
3570
  static ɵfac = i0.ɵɵngDeclareFactory({
2873
3571
  minVersion: "12.0.0",
@@ -2979,10 +3677,67 @@ i0.ɵɵngDeclareClassMetadata({
2979
3677
  args: [{ providedIn: "root" }]
2980
3678
  }]
2981
3679
  });
3680
+ const __workletMap = {};
3681
+ const __mainThreadRefMap = {};
3682
+ const __pendingResolvers = {};
3683
+ let __nextResolveId = 0;
3684
+ const nextResolveId = () => __nextResolveId++;
3685
+ const transform = (value, elements) => {
3686
+ if (typeof value !== "object" || value === null) return value;
3687
+ if (Array.isArray(value)) return value.map((item) => transform(item, elements));
3688
+ const obj = value;
3689
+ if (elements && "elementRefptr" in obj) return new MainThreadElement(obj["elementRefptr"]);
3690
+ if ("_wvid" in obj) return __mainThreadRefMap[obj["_wvid"]] ?? obj;
3691
+ const result = {};
3692
+ for (const key of Object.keys(obj)) result[key] = transform(obj[key], elements);
3693
+ return result;
3694
+ };
3695
+ const transformParams = (value) => transform(value, true);
3696
+ const restoreRefs = (value) => transform(value, false);
3697
+ const isThenable = (value) => typeof value?.then === "function";
3698
+ const errorText = (e) => e instanceof Error ? e.message : String(e);
3699
+ const answerCall = (resolveId, run, send) => {
3700
+ const reply = (result) => {
3701
+ let data;
3702
+ try {
3703
+ data = JSON.stringify({
3704
+ resolveId,
3705
+ ...result
3706
+ });
3707
+ } catch (e) {
3708
+ data = JSON.stringify({
3709
+ resolveId,
3710
+ error: `[angular-lynx] The return value can't be sent to the other thread: ${errorText(e)}`
3711
+ });
3712
+ }
3713
+ send(data);
3714
+ };
3715
+ let returnValue;
3716
+ try {
3717
+ returnValue = run();
3718
+ } catch (e) {
3719
+ reply({ error: errorText(e) });
3720
+ return;
3721
+ }
3722
+ if (isThenable(returnValue)) returnValue.then((value) => reply({ returnValue: value }), (e) => reply({ error: errorText(e) }));
3723
+ else reply({ returnValue });
3724
+ };
2982
3725
  let nextWorkletId = 0;
3726
+ const constructorDestroyRef = () => {
3727
+ try {
3728
+ return inject(DestroyRef);
3729
+ } catch {
3730
+ return null;
3731
+ }
3732
+ };
2983
3733
  const mainThreadFn = (fn) => {
2984
3734
  const id = "__angular_mts_" + nextWorkletId++;
2985
- if (__MAIN_THREAD__) globalThis.registerWorklet("main-thread", id, fn);
3735
+ if (__MAIN_THREAD__) {
3736
+ globalThis.registerWorklet("main-thread", id, fn);
3737
+ constructorDestroyRef()?.onDestroy(() => {
3738
+ delete __workletMap[id];
3739
+ });
3740
+ }
2986
3741
  return {
2987
3742
  _wkltId: id,
2988
3743
  _workletType: "main-thread",
@@ -2990,11 +3745,11 @@ const mainThreadFn = (fn) => {
2990
3745
  };
2991
3746
  };
2992
3747
  let nextBgWorkletId = 0;
2993
- const backgroundFn = (fn) => {
2994
- const id = "__angular_bg_" + nextBgWorkletId++;
2995
- if (!__MAIN_THREAD__) globalThis.registerWorklet("background", id, fn);
3748
+ const backgroundFn = (fn, id) => {
3749
+ const workletId = id ?? "__angular_bg_" + nextBgWorkletId++;
3750
+ if (!__MAIN_THREAD__) globalThis.registerWorklet("background", workletId, fn);
2996
3751
  return {
2997
- _wkltId: id,
3752
+ _wkltId: workletId,
2998
3753
  _workletType: "background",
2999
3754
  __isBackgroundFn: true
3000
3755
  };
@@ -3003,10 +3758,10 @@ let nextRefId = 0;
3003
3758
  var MainThreadRef = class {
3004
3759
  _wvid;
3005
3760
  #_value;
3006
- constructor(initValue) {
3007
- this._wvid = nextRefId++;
3761
+ constructor(initValue, id) {
3762
+ this._wvid = id ?? nextRefId++;
3008
3763
  this.#_value = initValue;
3009
- if (__MAIN_THREAD__) globalThis.__workletRefMap[this._wvid] = this;
3764
+ __mainThreadRefMap[this._wvid] = this;
3010
3765
  }
3011
3766
  get current() {
3012
3767
  return this.#_value;
@@ -3018,82 +3773,7 @@ var MainThreadRef = class {
3018
3773
  return { _wvid: this._wvid };
3019
3774
  }
3020
3775
  };
3021
- const createMainThreadRef = (initValue) => new MainThreadRef(initValue);
3022
- let willFlush = false;
3023
- const scheduleFlush = () => {
3024
- if (willFlush) return;
3025
- willFlush = true;
3026
- Promise.resolve().then(() => {
3027
- willFlush = false;
3028
- __FlushElementTree();
3029
- });
3030
- };
3031
- var MainThreadElement = class MainThreadElement {
3032
- #element;
3033
- constructor(element) {
3034
- this.#element = element;
3035
- }
3036
- setAttribute(name, value) {
3037
- __SetAttribute(this.#element, name, value);
3038
- scheduleFlush();
3039
- }
3040
- getAttribute(name) {
3041
- return __GetAttributeByName(this.#element, name);
3042
- }
3043
- getAttributeNames() {
3044
- return __GetAttributeNames(this.#element);
3045
- }
3046
- setStyleProperty(name, value) {
3047
- __AddInlineStyle(this.#element, name, value);
3048
- scheduleFlush();
3049
- }
3050
- setStyleProperties(styles) {
3051
- for (const key in styles) __AddInlineStyle(this.#element, key, styles[key]);
3052
- scheduleFlush();
3053
- }
3054
- querySelector(selector) {
3055
- const ref = __QuerySelector(this.#element, selector, {});
3056
- return ref ? new MainThreadElement(ref) : null;
3057
- }
3058
- querySelectorAll(selector) {
3059
- return __QuerySelectorAll(this.#element, selector, {}).map((el) => new MainThreadElement(el));
3060
- }
3061
- invoke(methodName, params) {
3062
- return new Promise((resolve, reject) => {
3063
- __InvokeUIMethod(this.#element, methodName, params ?? {}, (res) => {
3064
- if (res.code === 0) resolve(res.data);
3065
- else reject(/* @__PURE__ */ new Error("UI method invoke: " + JSON.stringify(res)));
3066
- });
3067
- scheduleFlush();
3068
- });
3069
- }
3070
- animate(keyframes, options) {
3071
- const normalizedOptions = typeof options === "number" ? { duration: options } : options ?? {};
3072
- return new LynxAnimation(this.#element, keyframes, normalizedOptions);
3073
- }
3074
- getBoundingClientRect() {
3075
- if (typeof __GetComputedStyleByKey !== "function") return {
3076
- left: 0,
3077
- top: 0,
3078
- right: 0,
3079
- bottom: 0,
3080
- width: 0,
3081
- height: 0
3082
- };
3083
- const width = parseFloat(__GetComputedStyleByKey(this.#element, "width")) || 0;
3084
- const height = parseFloat(__GetComputedStyleByKey(this.#element, "height")) || 0;
3085
- const left = parseFloat(__GetComputedStyleByKey(this.#element, "left")) || 0;
3086
- const top = parseFloat(__GetComputedStyleByKey(this.#element, "top")) || 0;
3087
- return {
3088
- left,
3089
- top,
3090
- right: left + width,
3091
- bottom: top + height,
3092
- width,
3093
- height
3094
- };
3095
- }
3096
- };
3776
+ const createMainThreadRef = (initValue, id) => new MainThreadRef(initValue, id);
3097
3777
  const INPUT_TO_EVENT = {
3098
3778
  mainThreadBindtap: ["bindEvent", "tap"],
3099
3779
  mainThreadCatchtap: ["catchEvent", "tap"],
@@ -3103,6 +3783,12 @@ const INPUT_TO_EVENT = {
3103
3783
  mainThreadCatchtouchmove: ["catchEvent", "touchmove"],
3104
3784
  mainThreadBindtouchend: ["bindEvent", "touchend"],
3105
3785
  mainThreadCatchtouchend: ["catchEvent", "touchend"],
3786
+ mainThreadBindmousedown: ["bindEvent", "mousedown"],
3787
+ mainThreadCatchmousedown: ["catchEvent", "mousedown"],
3788
+ mainThreadBindmousemove: ["bindEvent", "mousemove"],
3789
+ mainThreadCatchmousemove: ["catchEvent", "mousemove"],
3790
+ mainThreadBindmouseup: ["bindEvent", "mouseup"],
3791
+ mainThreadCatchmouseup: ["catchEvent", "mouseup"],
3106
3792
  mainThreadBindlongpress: ["bindEvent", "longpress"],
3107
3793
  mainThreadCatchlongpress: ["catchEvent", "longpress"],
3108
3794
  mainThreadBindscroll: ["bindEvent", "scroll"],
@@ -3113,9 +3799,14 @@ const INPUT_TO_EVENT = {
3113
3799
  mainThreadBindlayoutchange: ["bindEvent", "layoutchange"]
3114
3800
  };
3115
3801
  const isMainThreadHandle = (h) => !!h && "__isMainThreadFn" in h && !!h.__isMainThreadFn;
3802
+ let nextHandlerId = 0;
3803
+ const noHandler = () => ({
3804
+ type: "worklet",
3805
+ value: { _workletType: "main-thread" }
3806
+ });
3116
3807
  var LynxMainThreadEvent = class LynxMainThreadEvent {
3117
3808
  #el = inject(ElementRef).nativeElement;
3118
- #registeredEvents = [];
3809
+ #registrations = /* @__PURE__ */ new Map();
3119
3810
  mainThreadBindtap;
3120
3811
  mainThreadCatchtap;
3121
3812
  mainThreadBindtouchstart;
@@ -3124,6 +3815,12 @@ var LynxMainThreadEvent = class LynxMainThreadEvent {
3124
3815
  mainThreadCatchtouchmove;
3125
3816
  mainThreadBindtouchend;
3126
3817
  mainThreadCatchtouchend;
3818
+ mainThreadBindmousedown;
3819
+ mainThreadCatchmousedown;
3820
+ mainThreadBindmousemove;
3821
+ mainThreadCatchmousemove;
3822
+ mainThreadBindmouseup;
3823
+ mainThreadCatchmouseup;
3127
3824
  mainThreadBindlongpress;
3128
3825
  mainThreadCatchlongpress;
3129
3826
  mainThreadBindscroll;
@@ -3140,23 +3837,44 @@ var LynxMainThreadEvent = class LynxMainThreadEvent {
3140
3837
  if (!mapping) continue;
3141
3838
  const [eventType, eventName] = mapping;
3142
3839
  const handle = this[inputName];
3143
- if (isMainThreadHandle(handle)) {
3144
- __AddEvent(elementRef, eventType, eventName, {
3145
- type: "worklet",
3146
- value: {
3147
- _wkltId: handle._wkltId,
3148
- _workletType: "main-thread"
3149
- }
3150
- });
3151
- this.#registeredEvents.push([eventType, eventName]);
3840
+ this.#release(inputName);
3841
+ const registration = {
3842
+ eventType,
3843
+ eventName
3844
+ };
3845
+ let workletId;
3846
+ if (isMainThreadHandle(handle)) workletId = handle._wkltId;
3847
+ else if (typeof handle === "function") {
3848
+ workletId = "__angular_mts_handler_" + nextHandlerId++;
3849
+ registration.ownId = workletId;
3850
+ __workletMap[workletId] = handle;
3851
+ }
3852
+ if (workletId === void 0) {
3853
+ if (this.#registrations.delete(inputName)) __AddEvent(elementRef, eventType, eventName, noHandler());
3854
+ continue;
3152
3855
  }
3856
+ __AddEvent(elementRef, eventType, eventName, {
3857
+ type: "worklet",
3858
+ value: {
3859
+ _wkltId: workletId,
3860
+ _workletType: "main-thread"
3861
+ }
3862
+ });
3863
+ this.#registrations.set(inputName, registration);
3153
3864
  }
3154
3865
  }
3155
3866
  ngOnDestroy() {
3156
3867
  const elementRef = this.#el.element;
3157
3868
  if (!elementRef) return;
3158
- for (const [eventType, eventName] of this.#registeredEvents) __AddEvent(elementRef, eventType, eventName, void 0);
3159
- this.#registeredEvents = [];
3869
+ for (const [inputName, { eventType, eventName }] of this.#registrations) {
3870
+ __AddEvent(elementRef, eventType, eventName, noHandler());
3871
+ this.#release(inputName);
3872
+ }
3873
+ this.#registrations.clear();
3874
+ }
3875
+ #release(inputName) {
3876
+ const ownId = this.#registrations.get(inputName)?.ownId;
3877
+ if (ownId !== void 0) delete __workletMap[ownId];
3160
3878
  }
3161
3879
  static ɵfac = i0.ɵɵngDeclareFactory({
3162
3880
  minVersion: "12.0.0",
@@ -3171,7 +3889,7 @@ var LynxMainThreadEvent = class LynxMainThreadEvent {
3171
3889
  version: "22.2.1",
3172
3890
  type: LynxMainThreadEvent,
3173
3891
  isStandalone: true,
3174
- selector: "[mainThreadBindtap],[mainThreadCatchtap],[mainThreadBindtouchstart],[mainThreadCatchtouchstart],[mainThreadBindtouchmove],[mainThreadCatchtouchmove],[mainThreadBindtouchend],[mainThreadCatchtouchend],[mainThreadBindlongpress],[mainThreadCatchlongpress],[mainThreadBindscroll],[mainThreadCatchscroll],[mainThreadBindanimationstart],[mainThreadBindanimationend],[mainThreadBindtransitionend],[mainThreadBindlayoutchange]",
3892
+ selector: "[mainThreadBindtap],[mainThreadCatchtap],[mainThreadBindtouchstart],[mainThreadCatchtouchstart],[mainThreadBindtouchmove],[mainThreadCatchtouchmove],[mainThreadBindtouchend],[mainThreadCatchtouchend],[mainThreadBindmousedown],[mainThreadCatchmousedown],[mainThreadBindmousemove],[mainThreadCatchmousemove],[mainThreadBindmouseup],[mainThreadCatchmouseup],[mainThreadBindlongpress],[mainThreadCatchlongpress],[mainThreadBindscroll],[mainThreadCatchscroll],[mainThreadBindanimationstart],[mainThreadBindanimationend],[mainThreadBindtransitionend],[mainThreadBindlayoutchange]",
3175
3893
  inputs: {
3176
3894
  mainThreadBindtap: "mainThreadBindtap",
3177
3895
  mainThreadCatchtap: "mainThreadCatchtap",
@@ -3181,6 +3899,12 @@ var LynxMainThreadEvent = class LynxMainThreadEvent {
3181
3899
  mainThreadCatchtouchmove: "mainThreadCatchtouchmove",
3182
3900
  mainThreadBindtouchend: "mainThreadBindtouchend",
3183
3901
  mainThreadCatchtouchend: "mainThreadCatchtouchend",
3902
+ mainThreadBindmousedown: "mainThreadBindmousedown",
3903
+ mainThreadCatchmousedown: "mainThreadCatchmousedown",
3904
+ mainThreadBindmousemove: "mainThreadBindmousemove",
3905
+ mainThreadCatchmousemove: "mainThreadCatchmousemove",
3906
+ mainThreadBindmouseup: "mainThreadBindmouseup",
3907
+ mainThreadCatchmouseup: "mainThreadCatchmouseup",
3184
3908
  mainThreadBindlongpress: "mainThreadBindlongpress",
3185
3909
  mainThreadCatchlongpress: "mainThreadCatchlongpress",
3186
3910
  mainThreadBindscroll: "mainThreadBindscroll",
@@ -3202,8 +3926,7 @@ i0.ɵɵngDeclareClassMetadata({
3202
3926
  decorators: [{
3203
3927
  type: Directive,
3204
3928
  args: [{
3205
- selector: "[mainThreadBindtap],[mainThreadCatchtap],[mainThreadBindtouchstart],[mainThreadCatchtouchstart],[mainThreadBindtouchmove],[mainThreadCatchtouchmove],[mainThreadBindtouchend],[mainThreadCatchtouchend],[mainThreadBindlongpress],[mainThreadCatchlongpress],[mainThreadBindscroll],[mainThreadCatchscroll],[mainThreadBindanimationstart],[mainThreadBindanimationend],[mainThreadBindtransitionend],[mainThreadBindlayoutchange]",
3206
- standalone: true,
3929
+ selector: "[mainThreadBindtap],[mainThreadCatchtap],[mainThreadBindtouchstart],[mainThreadCatchtouchstart],[mainThreadBindtouchmove],[mainThreadCatchtouchmove],[mainThreadBindtouchend],[mainThreadCatchtouchend],[mainThreadBindmousedown],[mainThreadCatchmousedown],[mainThreadBindmousemove],[mainThreadCatchmousemove],[mainThreadBindmouseup],[mainThreadCatchmouseup],[mainThreadBindlongpress],[mainThreadCatchlongpress],[mainThreadBindscroll],[mainThreadCatchscroll],[mainThreadBindanimationstart],[mainThreadBindanimationend],[mainThreadBindtransitionend],[mainThreadBindlayoutchange]",
3207
3930
  inputs: [
3208
3931
  "mainThreadBindtap",
3209
3932
  "mainThreadCatchtap",
@@ -3213,6 +3936,12 @@ i0.ɵɵngDeclareClassMetadata({
3213
3936
  "mainThreadCatchtouchmove",
3214
3937
  "mainThreadBindtouchend",
3215
3938
  "mainThreadCatchtouchend",
3939
+ "mainThreadBindmousedown",
3940
+ "mainThreadCatchmousedown",
3941
+ "mainThreadBindmousemove",
3942
+ "mainThreadCatchmousemove",
3943
+ "mainThreadBindmouseup",
3944
+ "mainThreadCatchmouseup",
3216
3945
  "mainThreadBindlongpress",
3217
3946
  "mainThreadCatchlongpress",
3218
3947
  "mainThreadBindscroll",
@@ -3227,42 +3956,13 @@ i0.ɵɵngDeclareClassMetadata({
3227
3956
  });
3228
3957
  var LynxMainThread = class LynxMainThread {
3229
3958
  runOnMainThread(handle, ...args) {
3230
- if (__MAIN_THREAD__) {
3231
- const invokeDirect = globalThis.__lynxRunMainThreadWorklet;
3232
- if (!invokeDirect) return Promise.reject(/* @__PURE__ */ new Error("[angular-lynx] runOnMainThread() called on the main thread before the runtime worklet registry was initialized"));
3233
- try {
3234
- return Promise.resolve(invokeDirect(handle._wkltId, args));
3235
- } catch (e) {
3236
- return Promise.reject(e);
3237
- }
3238
- }
3239
- /* v8 ignore next 9 */
3240
- if (__DEV__) try {
3241
- JSON.stringify(args);
3242
- } catch {
3243
- throw new Error("[angular-lynx] MTS arguments must be JSON-serializable");
3959
+ const invokeDirect = globalThis.__lynxRunMainThreadWorklet;
3960
+ if (!invokeDirect) return Promise.reject(/* @__PURE__ */ new Error("[angular-lynx] runOnMainThread() called before the runtime worklet registry was initialized"));
3961
+ try {
3962
+ return Promise.resolve(invokeDirect(handle._wkltId, args));
3963
+ } catch (e) {
3964
+ return Promise.reject(e);
3244
3965
  }
3245
- const resolveId = globalThis.__lynxMtsNextResolveId();
3246
- const pendingResolvers = globalThis.__lynxMtsPendingResolvers;
3247
- return new Promise((resolve, reject) => {
3248
- pendingResolvers[resolveId] = {
3249
- resolve,
3250
- reject
3251
- };
3252
- try {
3253
- lynx.getCoreContext().dispatchEvent({
3254
- type: "Lynx.Worklet.runWorkletCtx",
3255
- data: JSON.stringify({
3256
- worklet: { _wkltId: handle._wkltId },
3257
- params: args,
3258
- resolveId
3259
- })
3260
- });
3261
- } catch (e) {
3262
- delete pendingResolvers[resolveId];
3263
- reject(e);
3264
- }
3265
- });
3266
3966
  }
3267
3967
  static ɵfac = i0.ɵɵngDeclareFactory({
3268
3968
  minVersion: "12.0.0",
@@ -3292,18 +3992,10 @@ i0.ɵɵngDeclareClassMetadata({
3292
3992
  });
3293
3993
  var LynxResourcePrefetch = class LynxResourcePrefetch {
3294
3994
  request(resources) {
3295
- if (typeof lynx === "undefined" || !lynx.requestResourcePrefetch) return Promise.reject(/* @__PURE__ */ new Error("lynx.requestResourcePrefetch is not available in this environment"));
3296
- const data = this.#toNativeData(resources);
3297
- return new Promise((resolve) => {
3298
- lynx.requestResourcePrefetch(data, resolve);
3299
- });
3995
+ return callOnBackground("requestResourcePrefetch", this.#toNativeData(resources));
3300
3996
  }
3301
3997
  cancel(resources) {
3302
- if (typeof lynx === "undefined" || !lynx.cancelResourcePrefetch) return Promise.reject(/* @__PURE__ */ new Error("lynx.cancelResourcePrefetch is not available in this environment"));
3303
- const data = this.#toNativeData(resources);
3304
- return new Promise((resolve) => {
3305
- lynx.cancelResourcePrefetch(data, resolve);
3306
- });
3998
+ return callOnBackground("cancelResourcePrefetch", this.#toNativeData(resources));
3307
3999
  }
3308
4000
  #toNativeData(resources) {
3309
4001
  return { data: resources.map((r) => {
@@ -3349,11 +4041,21 @@ i0.ɵɵngDeclareClassMetadata({
3349
4041
  args: [{ providedIn: "root" }]
3350
4042
  }]
3351
4043
  });
4044
+ const hostOsVersion = () => {
4045
+ const value = typeof lynx !== "undefined" ? lynx.__globalProps?.["osVersion"] : void 0;
4046
+ return typeof value === "string" && value !== "" ? value : void 0;
4047
+ };
3352
4048
  var LynxSystemInfo = class LynxSystemInfo {
3353
4049
  #info;
4050
+ #osVersion = signal(void 0, ...ngDevMode ? [{ debugName: "#osVersion" }] : /* istanbul ignore next */ []);
3354
4051
  constructor() {
3355
- if (typeof SystemInfo === "undefined") throw new Error("SystemInfo is not available in this environment");
3356
- this.#info = SystemInfo;
4052
+ const info = (typeof lynx !== "undefined" ? lynx.SystemInfo : void 0) ?? (typeof SystemInfo !== "undefined" ? SystemInfo : void 0);
4053
+ if (!info) throw new Error("SystemInfo is not available in this environment");
4054
+ this.#info = info;
4055
+ this.#osVersion.set(info.osVersion || hostOsVersion());
4056
+ if (this.#osVersion() === void 0 && isMainThread()) callOnBackground("osVersion").then((version) => {
4057
+ if (version) this.#osVersion.set(version);
4058
+ }, () => {});
3357
4059
  }
3358
4060
  get platform() {
3359
4061
  return this.#info.platform;
@@ -3362,7 +4064,7 @@ var LynxSystemInfo = class LynxSystemInfo {
3362
4064
  return this.#info.engineVersion;
3363
4065
  }
3364
4066
  get osVersion() {
3365
- return this.#info.osVersion;
4067
+ return this.#osVersion() ?? "";
3366
4068
  }
3367
4069
  get pixelWidth() {
3368
4070
  return this.#info.pixelWidth;
@@ -3418,10 +4120,10 @@ const SAFE_AREA_INSET_LEFT = "env(safe-area-inset-left)";
3418
4120
  const SAFE_AREA_INSET_RIGHT = "env(safe-area-inset-right)";
3419
4121
  var LynxSafeArea = class LynxSafeArea {
3420
4122
  #globalData = inject(LynxGlobalData);
3421
- #systemInfo = inject(LynxSystemInfo);
4123
+ #injector = inject(Injector);
3422
4124
  isNotchScreen = computed(() => !!this.#globalData.globalData()["isNotchScreen"], ...ngDevMode ? [{ debugName: "isNotchScreen" }] : /* istanbul ignore next */ []);
3423
4125
  get platform() {
3424
- return this.#systemInfo.platform;
4126
+ return this.#injector.get(LynxSystemInfo).platform;
3425
4127
  }
3426
4128
  static ɵfac = i0.ɵɵngDeclareFactory({
3427
4129
  minVersion: "12.0.0",
@@ -3453,11 +4155,18 @@ var LynxSessionStorage = class LynxSessionStorage {
3453
4155
  #store = /* @__PURE__ */ new Map();
3454
4156
  #listeners = /* @__PURE__ */ new Map();
3455
4157
  #nextId = 0;
4158
+ #relayIds = /* @__PURE__ */ new Map();
3456
4159
  #hasNativeSessionStorage() {
3457
- return typeof lynx !== "undefined" && typeof lynx.setSessionStorageItem === "function";
4160
+ return typeof lynx !== "undefined" && typeof lynx.setSessionStorageItem === "function" && !(typeof SystemInfo !== "undefined" && SystemInfo.platform === "web");
3458
4161
  }
3459
4162
  #hasNativeSubscription() {
3460
- return this.#hasNativeSessionStorage() && !(typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__);
4163
+ return this.#hasNativeSessionStorage() && !this.#isMainThread();
4164
+ }
4165
+ #isMainThread() {
4166
+ return typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__;
4167
+ }
4168
+ #unwrap(raw) {
4169
+ return raw != null && typeof raw === "object" && "__data" in raw && Object.keys(raw).length === 1 ? raw.__data : raw;
3461
4170
  }
3462
4171
  #notifyLocalListeners(key, value) {
3463
4172
  const keyListeners = this.#listeners.get(key);
@@ -3465,7 +4174,7 @@ var LynxSessionStorage = class LynxSessionStorage {
3465
4174
  }
3466
4175
  setItem(key, value) {
3467
4176
  if (this.#hasNativeSessionStorage()) {
3468
- if (typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__) {
4177
+ if (this.#isMainThread()) {
3469
4178
  const wrapped = typeof value === "object" && value !== null ? value : { __data: value };
3470
4179
  lynx.setSessionStorageItem(key, wrapped);
3471
4180
  this.#notifyLocalListeners(key, value);
@@ -3479,13 +4188,9 @@ var LynxSessionStorage = class LynxSessionStorage {
3479
4188
  }
3480
4189
  getItem(key) {
3481
4190
  if (this.#hasNativeSessionStorage()) {
3482
- if (typeof __MAIN_THREAD__ !== "undefined" && __MAIN_THREAD__) {
3483
- const raw = lynx.getSessionStorageItem(key);
3484
- const unwrapped = raw != null && typeof raw === "object" && "__data" in raw && Object.keys(raw).length === 1 ? raw.__data : raw;
3485
- return Promise.resolve(unwrapped);
3486
- }
4191
+ if (this.#isMainThread()) return Promise.resolve(this.#unwrap(lynx.getSessionStorageItem(key)));
3487
4192
  return new Promise((resolve) => {
3488
- lynx.getSessionStorageItem(key, (value) => resolve(value));
4193
+ lynx.getSessionStorageItem(key, (value) => resolve(this.#unwrap(value)));
3489
4194
  });
3490
4195
  }
3491
4196
  return Promise.resolve(this.#store.get(key));
@@ -3493,7 +4198,7 @@ var LynxSessionStorage = class LynxSessionStorage {
3493
4198
  subscribe(key, callback) {
3494
4199
  if (this.#hasNativeSubscription()) return {
3495
4200
  key,
3496
- listenerId: lynx.subscribeSessionStorage(key, callback)
4201
+ listenerId: lynx.subscribeSessionStorage(key, (value) => callback(this.#unwrap(value)))
3497
4202
  };
3498
4203
  const id = this.#nextId++;
3499
4204
  let keyListeners = this.#listeners.get(key);
@@ -3502,6 +4207,7 @@ var LynxSessionStorage = class LynxSessionStorage {
3502
4207
  this.#listeners.set(key, keyListeners);
3503
4208
  }
3504
4209
  keyListeners.set(id, callback);
4210
+ if (this.#isMainThread() && this.#hasNativeSessionStorage()) this.#relayIds.set(id, subscribeSessionStorageFromMainThread(key, (value) => callback(this.#unwrap(value))));
3505
4211
  return {
3506
4212
  key,
3507
4213
  listenerId: id
@@ -3513,6 +4219,11 @@ var LynxSessionStorage = class LynxSessionStorage {
3513
4219
  return;
3514
4220
  }
3515
4221
  this.#listeners.get(subscription.key)?.delete(subscription.listenerId);
4222
+ const relayId = this.#relayIds.get(subscription.listenerId);
4223
+ if (relayId !== void 0) {
4224
+ this.#relayIds.delete(subscription.listenerId);
4225
+ unsubscribeSessionStorageFromMainThread(relayId);
4226
+ }
3516
4227
  }
3517
4228
  watch(key, options) {
3518
4229
  const value = signal(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
@@ -3549,7 +4260,7 @@ i0.ɵɵngDeclareClassMetadata({
3549
4260
  });
3550
4261
  var LynxTextMeasure = class LynxTextMeasure {
3551
4262
  measure(text, options) {
3552
- if (typeof lynx === "undefined") throw new Error("lynx.getTextInfo is not available in this environment");
4263
+ if (typeof lynx === "undefined" || typeof lynx.getTextInfo !== "function") throw new Error("lynx.getTextInfo is not available in this environment");
3553
4264
  if (!text) return { width: 0 };
3554
4265
  return lynx.getTextInfo(text, options);
3555
4266
  }
@@ -3726,7 +4437,6 @@ i0.ɵɵngDeclareClassMetadata({
3726
4437
  type: Component,
3727
4438
  args: [{
3728
4439
  selector: "lynx-transition",
3729
- standalone: true,
3730
4440
  template: `@if (shouldRender()) {
3731
4441
  <ng-content />
3732
4442
  }`
@@ -4003,7 +4713,6 @@ i0.ɵɵngDeclareClassMetadata({
4003
4713
  type: Component,
4004
4714
  args: [{
4005
4715
  selector: "lynx-transition-group",
4006
- standalone: true,
4007
4716
  template: `<ng-template #anchor />`
4008
4717
  }]
4009
4718
  }],
@@ -4062,186 +4771,18 @@ i0.ɵɵngDeclareClassMetadata({
4062
4771
  }]
4063
4772
  }
4064
4773
  });
4065
- var NoopLynxAnimation = class NoopLynxAnimation {
4066
- static #count = 0;
4067
- id;
4068
- constructor() {
4069
- this.id = `__lynx-angular-noop-animation-${NoopLynxAnimation.#count++}`;
4070
- }
4071
- play() {}
4072
- pause() {}
4073
- cancel() {}
4074
- };
4075
- var LynxBackgroundElement = class {
4076
- isRootPageElement = false;
4077
- tagName = "";
4078
- #props = /* @__PURE__ */ new Map();
4079
- #styles = /* @__PURE__ */ new Map();
4080
- #classes = /* @__PURE__ */ new Set();
4081
- #events = /* @__PURE__ */ new Map();
4082
- #parent = null;
4083
- #firstChild = null;
4084
- #lastChild = null;
4085
- #previousSibling = null;
4086
- #nextSibling = null;
4087
- setProperty(name, value) {
4088
- this.#props.set(name, value);
4089
- }
4090
- setAttribute(name, value) {
4091
- this.#props.set(name, value);
4092
- }
4093
- getAttribute(name) {
4094
- return this.#props.get(name) ?? null;
4095
- }
4096
- removeAttribute(name) {
4097
- this.#props.delete(name);
4098
- }
4099
- setStyle(key, value) {
4100
- this.#styles.set(key, value);
4101
- }
4102
- removeStyle(key) {
4103
- this.#styles.delete(key);
4104
- }
4105
- setInlineStyles(inlineStyle) {
4106
- const styles = inlineStyle.split(";").map((s) => s.trim()).filter((s) => s.length > 0);
4107
- for (const s of styles) {
4108
- const [key, value] = s.split(":").map((s) => s.trim());
4109
- this.setStyle(key, value);
4110
- }
4111
- }
4112
- insertBefore(newChild, refChild) {
4113
- if (newChild.isRootPageElement) return;
4114
- if (refChild == null) {
4115
- this.appendChild(newChild);
4116
- return;
4117
- }
4118
- if (!refChild.#previousSibling) this.#firstChild = newChild;
4119
- else refChild.#previousSibling.#nextSibling = newChild;
4120
- newChild.#previousSibling = refChild.#previousSibling;
4121
- refChild.#previousSibling = newChild;
4122
- newChild.#nextSibling = refChild;
4123
- newChild.#parent = this;
4124
- }
4125
- appendChild(newChild) {
4126
- if (newChild.isRootPageElement) return;
4127
- if (!this.#firstChild) {
4128
- this.#firstChild = newChild;
4129
- this.#lastChild = newChild;
4130
- } else {
4131
- /* v8 ignore next 5 */
4132
- if (!this.#lastChild) throw new Error("Invariant violation: lastChild is null while firstChild is not null.");
4133
- this.#lastChild.#nextSibling = newChild;
4134
- newChild.#previousSibling = this.#lastChild;
4135
- this.#lastChild = newChild;
4136
- }
4137
- newChild.#parent = this;
4138
- }
4139
- addClass(name) {
4140
- this.#classes.add(name);
4141
- }
4142
- removeClass(name) {
4143
- this.#classes.delete(name);
4144
- }
4145
- remove() {
4146
- if (this.isRootPageElement) return;
4147
- if (!this.#parent) return;
4148
- if (this.#previousSibling) this.#previousSibling.#nextSibling = this.#nextSibling;
4149
- else this.#parent.#firstChild = this.#nextSibling;
4150
- if (this.#nextSibling) this.#nextSibling.#previousSibling = this.#previousSibling;
4151
- else this.#parent.#lastChild = this.#previousSibling;
4152
- this.#nextSibling = null;
4153
- this.#previousSibling = null;
4154
- this.#parent = null;
4155
- }
4156
- parentNode() {
4157
- return this.#parent;
4158
- }
4159
- nextSibling() {
4160
- return this.#nextSibling;
4161
- }
4162
- querySelector(selector) {
4163
- let child = this.#firstChild;
4164
- while (child) {
4165
- if (child.#matchesSelector(selector)) return child;
4166
- const found = child.querySelector(selector);
4167
- if (found) return found;
4168
- child = child.#nextSibling;
4169
- }
4170
- return null;
4171
- }
4172
- querySelectorAll(selector) {
4173
- const results = [];
4174
- this.#collectMatches(selector, results);
4175
- return results;
4176
- }
4177
- #collectMatches(selector, results) {
4178
- let child = this.#firstChild;
4179
- while (child) {
4180
- if (child.#matchesSelector(selector)) results.push(child);
4181
- child.#collectMatches(selector, results);
4182
- child = child.#nextSibling;
4183
- }
4184
- }
4185
- #matchesSelector(selector) {
4186
- let remaining = selector.trim();
4187
- if (/[\s>~+]/.test(remaining)) return false;
4188
- let tagName = null;
4189
- const classes = [];
4190
- const attrs = [];
4191
- const tagMatch = remaining.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);
4192
- if (tagMatch) {
4193
- tagName = tagMatch[1];
4194
- remaining = remaining.slice(tagMatch[0].length);
4195
- }
4196
- while (remaining.length > 0) {
4197
- const classMatch = remaining.match(/^\.([a-zA-Z0-9_-]+)/);
4198
- if (classMatch) {
4199
- classes.push(classMatch[1]);
4200
- remaining = remaining.slice(classMatch[0].length);
4201
- continue;
4202
- }
4203
- const idMatch = remaining.match(/^#([a-zA-Z0-9_-]+)/);
4204
- if (idMatch) {
4205
- attrs.push(["id", idMatch[1]]);
4206
- remaining = remaining.slice(idMatch[0].length);
4207
- continue;
4208
- }
4209
- const attrMatch = remaining.match(/^\[([a-zA-Z0-9_-]+)(?:=["']?([^"'\]]*)["']?)?\]/);
4210
- if (attrMatch) {
4211
- attrs.push([attrMatch[1], attrMatch[2] ?? null]);
4212
- remaining = remaining.slice(attrMatch[0].length);
4213
- continue;
4214
- }
4215
- return false;
4216
- }
4217
- if (!tagName && classes.length === 0 && attrs.length === 0) return false;
4218
- if (tagName && this.#props.get("tagName") !== tagName) return false;
4219
- for (const cls of classes) if (!this.#classes.has(cls)) return false;
4220
- for (const [attr, value] of attrs) {
4221
- const stored = this.#props.get(attr);
4222
- if (value === null) {
4223
- if (stored === void 0 || stored === null) return false;
4224
- } else if (String(stored) !== value) return false;
4225
- }
4226
- return true;
4227
- }
4228
- animate(_keyframes, _options) {
4229
- /* v8 ignore next 6 -- build-time __DEV__ define is false in vitest, so the guarded warn is dead code from the test bundle's point of view. */
4230
- if (__DEV__) console.warn("[angular-lynx] animate() called on background thread — animation will not play. Use a main-thread script for imperative animations.");
4231
- return new NoopLynxAnimation();
4232
- }
4233
- addEventListener(name, cb) {
4234
- this.#events.set(name, cb);
4235
- return () => {
4236
- this.#events.delete(name);
4237
- };
4238
- }
4239
- };
4240
4774
  const createBlockElement = (pageId) => {
4241
4775
  return __CreateWrapperElement(pageId);
4242
4776
  };
4777
+ const ANDROID_BLUR_CAPTURE_TARGET = "angular-lynx-page";
4778
+ const isAndroid = () => {
4779
+ return ((typeof lynx !== "undefined" ? lynx.SystemInfo : void 0) ?? (typeof SystemInfo !== "undefined" ? SystemInfo : void 0))?.platform === "Android";
4780
+ };
4243
4781
  const createBlurViewElement = (pageId) => {
4244
- return __CreateElement("blur-view", pageId);
4782
+ const element = __CreateElement("blur-view", pageId);
4783
+ if (!__WEB__ && isAndroid()) __SetAttribute(element, "android-capture-target", ANDROID_BLUR_CAPTURE_TARGET);
4784
+ if (__WEB__ && __MAIN_THREAD__) import("./blotch-angular-lynx-web-glass-ciDHw7Bw.mjs").then(({ attachWebGlass }) => attachWebGlass(element)).catch(() => {});
4785
+ return element;
4245
4786
  };
4246
4787
  const createCommentElement = (pageId) => {
4247
4788
  const element = __CreateView(pageId);
@@ -4265,22 +4806,13 @@ const createIfElement = (pageId) => {
4265
4806
  return __CreateElement("if", pageId);
4266
4807
  };
4267
4808
  const createImageElement = (pageId) => {
4268
- const element = __CreateImage(pageId);
4269
- __SetConfig(element, {
4270
- mode: "aspectFit",
4271
- fadeIn: true,
4272
- loadingPlaceholder: ""
4273
- });
4274
- return element;
4809
+ return __CreateImage(pageId);
4275
4810
  };
4276
4811
  const createInlineTruncationElement = (pageId) => {
4277
4812
  return __CreateElement("inline-truncation", pageId);
4278
4813
  };
4279
4814
  const createInputElement = (tag, pageId) => {
4280
- const element = __CreateElement(tag, pageId);
4281
- __AddInlineStyle(element, "height", tag === "textarea" ? "80px" : "40px");
4282
- __AddInlineStyle(element, "border", "1px solid");
4283
- return element;
4815
+ return __CreateElement(tag, pageId);
4284
4816
  };
4285
4817
  const createListItemElement = (pageId) => {
4286
4818
  return __CreateElement("list-item", pageId);
@@ -4374,11 +4906,51 @@ const createNativeRefByTag = (tag, pageId, text) => {
4374
4906
  default: return createDefaultElement(tag, pageId);
4375
4907
  }
4376
4908
  };
4909
+ const BLUR_BACKGROUND_VARIABLE = "--angular-lynx-blur-background";
4910
+ const BLUR_BACKGROUND_IMAGE_VARIABLE = "--angular-lynx-blur-background-image";
4911
+ const BLUR_BOX_SHADOW_VARIABLE = "--angular-lynx-blur-box-shadow";
4912
+ const BLUR_MATERIAL_ATTRIBUTES = /* @__PURE__ */ new Set([
4913
+ "blur-effect",
4914
+ "blur-radius",
4915
+ "glass-style",
4916
+ "glass-tint-color"
4917
+ ]);
4918
+ const MATERIAL_BACKGROUNDS = {
4919
+ light: "rgba(255, 255, 255, 0.3)",
4920
+ "extra-light": "rgba(255, 255, 255, 0.75)",
4921
+ dark: "rgba(0, 0, 0, 0.6)"
4922
+ };
4923
+ const GLASS_SHEEN = "rgba(255, 255, 255, 0.3)";
4924
+ const CLEAR_GLASS_SHEEN = "rgba(255, 255, 255, 0.1)";
4925
+ const GLASS_RIM = "inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.12)";
4926
+ const usesAndroidBlurMaterials = () => !__WEB__ && isAndroid();
4927
+ const declarations = (background, { image = "none", boxShadow = "none" } = {}) => `${BLUR_BACKGROUND_VARIABLE}: ${background}; ${BLUR_BACKGROUND_IMAGE_VARIABLE}: ${image}; ${BLUR_BOX_SHADOW_VARIABLE}: ${boxShadow}`;
4928
+ const androidBlurMaterialStyle = (attrs) => {
4929
+ const effect = attrs.get("blur-effect") ?? "light";
4930
+ if (effect === "glass") {
4931
+ const tint = attrs.get("glass-tint-color");
4932
+ return declarations(attrs.get("glass-style") === "clear" ? CLEAR_GLASS_SHEEN : GLASS_SHEEN, {
4933
+ image: typeof tint === "string" && tint !== "" && tint !== "transparent" ? `linear-gradient(${tint}, ${tint})` : "none",
4934
+ boxShadow: GLASS_RIM
4935
+ });
4936
+ }
4937
+ if (effect === "glass-container" || !parseFloat(String(attrs.get("blur-radius") ?? ""))) return declarations("transparent");
4938
+ return declarations(MATERIAL_BACKGROUNDS[String(effect)] ?? MATERIAL_BACKGROUNDS["light"]);
4939
+ };
4377
4940
  let __pageElementRef = null;
4378
4941
  const setPageElementRef = (ref) => {
4379
4942
  __pageElementRef = ref;
4380
4943
  };
4381
4944
  const getPageId = () => __pageElementRef ? __GetElementUniqueID(__pageElementRef) : 0;
4945
+ let handingOverPage = false;
4946
+ const handOverPageToNextApp = () => {
4947
+ handingOverPage = true;
4948
+ };
4949
+ const takePageHandOver = () => {
4950
+ const handing = handingOverPage;
4951
+ handingOverPage = false;
4952
+ return handing;
4953
+ };
4382
4954
  let firstRenderPending = true;
4383
4955
  const deferredCallbacks = [];
4384
4956
  const isFirstRenderPending = () => firstRenderPending;
@@ -4402,6 +4974,79 @@ const setInsideChangeDetection = (value) => {
4402
4974
  insideChangeDetection = value;
4403
4975
  };
4404
4976
  const isInsideChangeDetection = () => insideChangeDetection;
4977
+ const DASHARRAY_ATTRIBUTE = /(\s)stroke-dasharray\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
4978
+ const DASHARRAY_DECLARATION = /(^|[;"'\s])stroke-dasharray\s*:\s*([^;"']*);?/g;
4979
+ const DASH_LENGTH = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i;
4980
+ const normalizeDashArray = (value) => {
4981
+ const tokens = value.trim().split(/[\s,]+/).filter((token) => token.length > 0);
4982
+ if (tokens.length === 0 || !tokens.every((t) => DASH_LENGTH.test(t))) return null;
4983
+ return tokens.map((token) => token.replace(/px$/i, "")).join(" ");
4984
+ };
4985
+ const sanitizeSvgContent = (content) => {
4986
+ if (!content.includes("stroke-dasharray")) return content;
4987
+ return content.replace(DASHARRAY_ATTRIBUTE, (_match, space, double, single) => {
4988
+ const normalized = normalizeDashArray(double ?? single);
4989
+ return normalized === null ? "" : `${space}stroke-dasharray="${normalized}"`;
4990
+ }).replace(DASHARRAY_DECLARATION, (_match, before, value) => {
4991
+ const normalized = normalizeDashArray(value);
4992
+ return normalized === null ? before : `${before}stroke-dasharray:${normalized};`;
4993
+ });
4994
+ };
4995
+ const LONG_PRESS_SLOP = 10;
4996
+ const TAP_GRACE = 300;
4997
+ let tapsDropped = false;
4998
+ let longPresses = 0;
4999
+ const dropsTap = () => tapsDropped;
5000
+ const pointOf = (event) => {
5001
+ const { x = 0, y = 0 } = typeof event.detail === "object" && event.detail !== null ? event.detail : event;
5002
+ return {
5003
+ x,
5004
+ y
5005
+ };
5006
+ };
5007
+ var WebLongPress = class {
5008
+ #fire;
5009
+ #timer;
5010
+ #start = null;
5011
+ #fired = false;
5012
+ constructor(fire) {
5013
+ this.#fire = fire;
5014
+ }
5015
+ start = (event) => {
5016
+ if (event.button !== void 0 && event.button !== 0) return;
5017
+ this.#stop();
5018
+ this.#fired = false;
5019
+ const point = pointOf(event);
5020
+ this.#start = point;
5021
+ this.#timer = setTimeout(() => {
5022
+ this.#timer = void 0;
5023
+ this.#fired = true;
5024
+ longPresses++;
5025
+ tapsDropped = true;
5026
+ this.#fire(point);
5027
+ }, 500);
5028
+ };
5029
+ move = (event) => {
5030
+ if (!this.#start) return;
5031
+ const { x, y } = pointOf(event);
5032
+ if (Math.hypot(x - this.#start.x, y - this.#start.y) > LONG_PRESS_SLOP) this.#stop();
5033
+ };
5034
+ end = () => {
5035
+ this.#stop();
5036
+ this.#start = null;
5037
+ if (this.#fired) {
5038
+ this.#fired = false;
5039
+ const longPress = longPresses;
5040
+ setTimeout(() => {
5041
+ if (longPress === longPresses) tapsDropped = false;
5042
+ }, TAP_GRACE);
5043
+ }
5044
+ };
5045
+ #stop() {
5046
+ if (this.#timer !== void 0) clearTimeout(this.#timer);
5047
+ this.#timer = void 0;
5048
+ }
5049
+ };
4405
5050
  const EVENT_PREFIXES = [
4406
5051
  ["capture-bind", "capture-bindEvent"],
4407
5052
  ["capture-catch", "capture-catchEvent"],
@@ -4409,12 +5054,57 @@ const EVENT_PREFIXES = [
4409
5054
  ["catch", "catchEvent"],
4410
5055
  ["bind", "bindEvent"]
4411
5056
  ];
5057
+ const DOM_EVENT_ALIASES = /* @__PURE__ */ new Map([["click", "tap"]]);
4412
5058
  var _a;
5059
+ const nativeEventKey = (type, name) => type === "global-bindEvent" ? `global:${name}` : name;
5060
+ const combinedEventType = (listeners) => {
5061
+ if (listeners[0].eventType === "global-bindEvent") return "global-bindEvent";
5062
+ const capture = listeners.every((l) => l.eventType.startsWith("capture-"));
5063
+ const stops = listeners.some((l) => l.eventType.endsWith("catchEvent"));
5064
+ if (capture) return stops ? "capture-catchEvent" : "capture-bindEvent";
5065
+ return stops ? "catchEvent" : "bindEvent";
5066
+ };
5067
+ const parseEventName = (name) => {
5068
+ const alias = DOM_EVENT_ALIASES.get(name);
5069
+ if (alias) return {
5070
+ eventType: "bindEvent",
5071
+ eventName: alias
5072
+ };
5073
+ for (const [prefix, eventType] of EVENT_PREFIXES) if (name.startsWith(prefix)) return {
5074
+ eventType,
5075
+ eventName: name.slice(prefix.length)
5076
+ };
5077
+ };
5078
+ const withAddedTraits = (own, added) => {
5079
+ if (added.length === 0 || isAndroid()) return own;
5080
+ const traits = own == null ? [] : String(own).split(",").map((trait) => trait.trim()).filter((trait) => trait !== "" && trait !== "none");
5081
+ for (const trait of added) if (!traits.includes(trait)) traits.push(trait);
5082
+ return traits.join(",");
5083
+ };
4413
5084
  const wouldFormCycle = (parent, candidate) => {
4414
5085
  const candidateId = __GetElementUniqueID(candidate);
4415
5086
  for (let cur = parent; cur; cur = __GetParent(cur)) if (__GetElementUniqueID(cur) === candidateId) return true;
4416
5087
  return false;
4417
5088
  };
5089
+ const ancestry = (element) => {
5090
+ const path = [];
5091
+ for (let cur = element; cur; cur = __GetParent(cur)) path.push(cur);
5092
+ return path;
5093
+ };
5094
+ const flushesBefore = (first, second) => {
5095
+ const firstPath = ancestry(first);
5096
+ const secondPath = ancestry(second);
5097
+ const secondDepth = new Map(secondPath.map((element, depth) => [__GetElementUniqueID(element), depth]));
5098
+ for (let depth = 0; depth < firstPath.length; depth++) {
5099
+ const shared = secondDepth.get(__GetElementUniqueID(firstPath[depth]));
5100
+ if (shared === void 0) continue;
5101
+ if (depth === 0) return true;
5102
+ if (shared === 0) return false;
5103
+ const order = __GetChildren(firstPath[depth]).map((child) => __GetElementUniqueID(child));
5104
+ return order.indexOf(__GetElementUniqueID(firstPath[depth - 1])) < order.indexOf(__GetElementUniqueID(secondPath[shared - 1]));
5105
+ }
5106
+ return false;
5107
+ };
4418
5108
  const isTextish = (el) => el.tagName === "text" || el.tagName === "raw-text";
4419
5109
  var LynxElement = class {
4420
5110
  #nativeRef;
@@ -4426,14 +5116,20 @@ var LynxElement = class {
4426
5116
  _virtualParent = null;
4427
5117
  _virtualPrev = null;
4428
5118
  _virtualNext = null;
4429
- #activeAnimationIds = [];
5119
+ #activeAnimations = [];
4430
5120
  #attrs = /* @__PURE__ */ new Map();
4431
5121
  #id = null;
4432
5122
  #dataset = {};
4433
5123
  #classes = "";
5124
+ #scopeClasses = [];
4434
5125
  #inlineStyleWhole = null;
4435
5126
  #inlineStyleKeys = /* @__PURE__ */ new Map();
5127
+ #runtimeStyle = "";
5128
+ #ownTraits = null;
5129
+ #addedTraits = [];
4436
5130
  #listeners = [];
5131
+ #webLongPress = null;
5132
+ #nativeHandlers = /* @__PURE__ */ new Map();
4437
5133
  #text;
4438
5134
  #rawText;
4439
5135
  #children = [];
@@ -4468,8 +5164,9 @@ var LynxElement = class {
4468
5164
  }
4469
5165
  setAttribute(name, value) {
4470
5166
  if (name === "class") {
4471
- __SetClasses(this.element, value ?? "");
4472
- this.#classes = value ?? "";
5167
+ const classes = [.../* @__PURE__ */ new Set([...String(value ?? "").split(/\s+/).filter(Boolean), ...this.#scopeClasses])].join(" ");
5168
+ __SetClasses(this.element, classes);
5169
+ this.#classes = classes;
4473
5170
  } else if (name === "style") this.setInlineStyles(value);
4474
5171
  else if (name === "id") {
4475
5172
  __SetID(this.element, value);
@@ -4481,6 +5178,11 @@ var LynxElement = class {
4481
5178
  __SetDataset(this.element, data);
4482
5179
  this.#dataset[key] = value;
4483
5180
  } else {
5181
+ if (this.tagName === "svg" && name === "content" && typeof value === "string") value = sanitizeSvgContent(value);
5182
+ if (name === "accessibility-traits") {
5183
+ this.#ownTraits = value ?? null;
5184
+ value = withAddedTraits(this.#ownTraits, this.#addedTraits);
5185
+ }
4484
5186
  __SetAttribute(this.element, name, value);
4485
5187
  if (value == null) this.#attrs.delete(name);
4486
5188
  else this.#attrs.set(name, value);
@@ -4490,8 +5192,17 @@ var LynxElement = class {
4490
5192
  this.#rawText = text;
4491
5193
  _a.#enqueueTextNormalization(this);
4492
5194
  }
5195
+ if (this.tagName === "blur-view" && BLUR_MATERIAL_ATTRIBUTES.has(name)) this.updateBlurMaterial();
4493
5196
  }
4494
5197
  }
5198
+ updateBlurMaterial() {
5199
+ if (usesAndroidBlurMaterials()) this.#setRuntimeStyle(androidBlurMaterialStyle(this.#attrs));
5200
+ }
5201
+ setAccessibilityTrait(trait, on) {
5202
+ if (this.#addedTraits.includes(trait) === on) return;
5203
+ this.#addedTraits = on ? [...this.#addedTraits, trait] : this.#addedTraits.filter((added) => added !== trait);
5204
+ this.setAttribute("accessibility-traits", this.#ownTraits);
5205
+ }
4495
5206
  getAttribute(name) {
4496
5207
  return __GetAttributeByName(this.element, name);
4497
5208
  }
@@ -4507,12 +5218,23 @@ var LynxElement = class {
4507
5218
  this.#inlineStyleKeys.delete(key);
4508
5219
  }
4509
5220
  setInlineStyles(inlineStyle) {
4510
- __SetInlineStyles(this.element, inlineStyle);
5221
+ __SetInlineStyles(this.element, this.#withRuntimeStyle(inlineStyle));
4511
5222
  this.#inlineStyleWhole = inlineStyle;
4512
5223
  }
5224
+ #withRuntimeStyle(inlineStyle) {
5225
+ if (!this.#runtimeStyle) return inlineStyle;
5226
+ return inlineStyle ? `${this.#runtimeStyle}; ${inlineStyle}` : this.#runtimeStyle;
5227
+ }
5228
+ #setRuntimeStyle(style) {
5229
+ if (style === this.#runtimeStyle) return;
5230
+ this.#runtimeStyle = style;
5231
+ __SetInlineStyles(this.element, this.#withRuntimeStyle(this.#inlineStyleWhole));
5232
+ for (const [key, value] of this.#inlineStyleKeys) __AddInlineStyle(this.element, key, value);
5233
+ }
4513
5234
  insertBefore(newChild, refChild) {
4514
5235
  if (newChild.isRootPageElement) return;
4515
5236
  newChild.#cancelPendingRemoval();
5237
+ newChild.#removeIfMoveWouldBeLost(this);
4516
5238
  newChild.#recreateIfDead();
4517
5239
  if (refChild == null) this.appendChild(newChild);
4518
5240
  else {
@@ -4525,6 +5247,7 @@ var LynxElement = class {
4525
5247
  appendChild(newChild) {
4526
5248
  if (newChild.isRootPageElement) return;
4527
5249
  newChild.#cancelPendingRemoval();
5250
+ newChild.#removeIfMoveWouldBeLost(this);
4528
5251
  newChild.#recreateIfDead();
4529
5252
  if (wouldFormCycle(this.element, newChild.element)) return;
4530
5253
  __AppendElement(this.element, newChild.element);
@@ -4551,6 +5274,11 @@ var LynxElement = class {
4551
5274
  set.add(name);
4552
5275
  this.#classes = [...set].join(" ");
4553
5276
  }
5277
+ addScopeClass(name) {
5278
+ if (this.#scopeClasses.includes(name)) return;
5279
+ this.#scopeClasses.push(name);
5280
+ this.addClass(name);
5281
+ }
4554
5282
  removeClass(name) {
4555
5283
  const joined = __GetClasses(this.element).filter((c) => c !== name).join(" ");
4556
5284
  __SetClasses(this.element, joined);
@@ -4623,14 +5351,20 @@ var LynxElement = class {
4623
5351
  #cancelPendingRemoval() {
4624
5352
  _a.#pendingRemovals.delete(this);
4625
5353
  }
5354
+ #removeIfMoveWouldBeLost(newParent) {
5355
+ if (__WEB__ || this.#paintingDead || this._virtualParent) return;
5356
+ const oldParent = __GetParent(this.element);
5357
+ if (!oldParent || __GetElementUniqueID(oldParent) === __GetElementUniqueID(newParent.element)) return;
5358
+ if (flushesBefore(newParent.element, oldParent)) this.#doRemove();
5359
+ }
4626
5360
  #doRemove() {
4627
5361
  const parent = this.parentNode();
4628
5362
  if (!parent) return;
4629
- for (const id of this.#activeAnimationIds) __ElementAnimate(this.element, [3, id]);
4630
- if (this.#activeAnimationIds.length > 0) {
5363
+ for (const anim of this.#activeAnimations) anim.cancel();
5364
+ if (this.#activeAnimations.length > 0) {
4631
5365
  __AddInlineStyle(this.element, "opacity", null);
4632
5366
  __AddInlineStyle(this.element, "transform", null);
4633
- this.#activeAnimationIds.length = 0;
5367
+ this.#activeAnimations.length = 0;
4634
5368
  }
4635
5369
  __RemoveElement(parent.element, this.element);
4636
5370
  const jsParent = this.#jsParent;
@@ -4665,11 +5399,12 @@ var LynxElement = class {
4665
5399
  if (Object.keys(this.#dataset).length > 0) __SetDataset(fresh, this.#dataset);
4666
5400
  for (const [name, value] of this.#attrs) __SetAttribute(fresh, name, value);
4667
5401
  if (this.#classes) __SetClasses(fresh, this.#classes);
4668
- if (this.#inlineStyleWhole != null) __SetInlineStyles(fresh, this.#inlineStyleWhole);
5402
+ const inlineStyle = this.#withRuntimeStyle(this.#inlineStyleWhole);
5403
+ if (inlineStyle != null) __SetInlineStyles(fresh, inlineStyle);
4669
5404
  for (const [key, value] of this.#inlineStyleKeys) __AddInlineStyle(fresh, key, value);
4670
- for (const { eventType, eventName, listener } of this.#listeners) __AddEvent(fresh, eventType, eventName, {
5405
+ for (const { eventType, eventName, dispatch } of this.#nativeHandlers.values()) __AddEvent(fresh, eventType, eventName, {
4671
5406
  type: "worklet",
4672
- value: listener
5407
+ value: dispatch
4673
5408
  });
4674
5409
  for (const child of this.#children) {
4675
5410
  child.#recreateSubtree();
@@ -4703,44 +5438,91 @@ var LynxElement = class {
4703
5438
  animate(keyframes, options) {
4704
5439
  const normalizedOptions = typeof options === "number" ? { duration: options } : options ?? {};
4705
5440
  const anim = new LynxAnimation(this.element, keyframes, normalizedOptions);
4706
- this.#activeAnimationIds.push(anim.id);
5441
+ this.#activeAnimations.push(anim);
4707
5442
  return anim;
4708
5443
  }
4709
5444
  addEventListener(name, cb) {
4710
- let eventName = "";
4711
- let eventType;
4712
- for (const [prefix, type] of EVENT_PREFIXES) if (name.startsWith(prefix)) {
4713
- eventName = name.slice(prefix.length);
4714
- eventType = type;
4715
- break;
4716
- }
4717
- if (!eventType) return () => {};
4718
- const listener = (event) => {
4719
- if (event && typeof event === "object") {
4720
- if (typeof event.stopPropagation !== "function") event.stopPropagation = () => {};
4721
- if (typeof event.preventDefault !== "function") event.preventDefault = () => {};
4722
- if (typeof event.stopImmediatePropagation !== "function") event.stopImmediatePropagation = () => {};
4723
- }
4724
- const result = cb(event);
4725
- scheduleSettleFlush();
4726
- return result;
4727
- };
5445
+ const parsed = parseEventName(name);
5446
+ if (!parsed) return () => {};
5447
+ if (__WEB__ && parsed.eventName === "longpress") this.#listenForWebLongPress();
4728
5448
  const entry = {
5449
+ ...parsed,
5450
+ listener: cb
5451
+ };
5452
+ this.#listeners.push(entry);
5453
+ this.#syncNativeHandler(entry);
5454
+ return () => this.#removeListener(entry);
5455
+ }
5456
+ removeEventListener(name, cb) {
5457
+ const parsed = parseEventName(name);
5458
+ if (!parsed) return;
5459
+ const entry = this.#listeners.find((other) => other.listener === cb && other.eventType === parsed.eventType && other.eventName === parsed.eventName);
5460
+ if (entry) this.#removeListener(entry);
5461
+ }
5462
+ #listenForWebLongPress() {
5463
+ if (this.#webLongPress) return;
5464
+ const press = new WebLongPress((detail) => {
5465
+ const entry = this.#listeners.find((listener) => listener.eventName === "longpress");
5466
+ if (entry) this.#dispatch(entry, {
5467
+ type: "longpress",
5468
+ detail
5469
+ });
5470
+ });
5471
+ this.#webLongPress = press;
5472
+ this.addEventListener("bindtouchstart", press.start);
5473
+ this.addEventListener("bindmousedown", press.start);
5474
+ this.addEventListener("bindtouchmove", press.move);
5475
+ this.addEventListener("bindmousemove", press.move);
5476
+ for (const end of [
5477
+ "touchend",
5478
+ "touchcancel",
5479
+ "mouseup",
5480
+ "mouseleave"
5481
+ ]) this.addEventListener(`bind${end}`, press.end);
5482
+ }
5483
+ #removeListener(entry) {
5484
+ const i = this.#listeners.indexOf(entry);
5485
+ if (i < 0) return;
5486
+ this.#listeners.splice(i, 1);
5487
+ this.#syncNativeHandler(entry);
5488
+ }
5489
+ #listenersLike(entry) {
5490
+ const key = nativeEventKey(entry.eventType, entry.eventName);
5491
+ return this.#listeners.filter((other) => nativeEventKey(other.eventType, other.eventName) === key);
5492
+ }
5493
+ #syncNativeHandler(entry) {
5494
+ const key = nativeEventKey(entry.eventType, entry.eventName);
5495
+ const listeners = this.#listenersLike(entry);
5496
+ const current = this.#nativeHandlers.get(key);
5497
+ const eventType = listeners.length ? combinedEventType(listeners) : null;
5498
+ if (current?.eventType === eventType) return;
5499
+ if (current) {
5500
+ __AddEvent(this.element, current.eventType, entry.eventName, void 0);
5501
+ this.#nativeHandlers.delete(key);
5502
+ }
5503
+ if (!eventType) return;
5504
+ const handler = {
4729
5505
  eventType,
4730
- eventName,
4731
- listener
5506
+ eventName: entry.eventName,
5507
+ dispatch: current?.dispatch ?? ((event) => this.#dispatch(entry, event))
4732
5508
  };
4733
- this.#listeners.push(entry);
4734
- __AddEvent(this.element, eventType, eventName, {
5509
+ this.#nativeHandlers.set(key, handler);
5510
+ __AddEvent(this.element, eventType, entry.eventName, {
4735
5511
  type: "worklet",
4736
- value: listener
5512
+ value: handler.dispatch
4737
5513
  });
4738
- return () => {
4739
- const i = this.#listeners.indexOf(entry);
4740
- /* v8 ignore next */
4741
- if (i >= 0) this.#listeners.splice(i, 1);
4742
- __AddEvent(this.element, eventType, eventName, void 0);
4743
- };
5514
+ }
5515
+ #dispatch(entry, event) {
5516
+ if (event && typeof event === "object") {
5517
+ if (typeof event.stopPropagation !== "function") event.stopPropagation = () => {};
5518
+ if (typeof event.preventDefault !== "function") event.preventDefault = () => {};
5519
+ if (typeof event.stopImmediatePropagation !== "function") event.stopImmediatePropagation = () => {};
5520
+ }
5521
+ if (__WEB__ && entry.eventName === "tap" && dropsTap()) return void 0;
5522
+ let result;
5523
+ for (const other of this.#listenersLike(entry)) if (this.#listeners.includes(other)) result = other.listener(event);
5524
+ scheduleSettleFlush();
5525
+ return result;
4744
5526
  }
4745
5527
  };
4746
5528
  _a = LynxElement;
@@ -4893,42 +5675,6 @@ var LynxListElement = class extends LynxElement {
4893
5675
  __FlushElementTree(void 0, { triggerLayout: true });
4894
5676
  }
4895
5677
  };
4896
- var LynxBackgroundDocument = class {
4897
- #page = null;
4898
- constructor() {}
4899
- createRootElement() {
4900
- const page = new LynxBackgroundElement();
4901
- page.tagName = "page";
4902
- page.setAttribute("tagName", "page");
4903
- page.isRootPageElement = true;
4904
- this.#page = page;
4905
- return this.#page;
4906
- }
4907
- createElement(tag, value) {
4908
- if (tag === "page") return this.#page;
4909
- const element = new LynxBackgroundElement();
4910
- element.tagName = tag;
4911
- element.setAttribute("tagName", tag);
4912
- if (value) element.setAttribute("textContent", value);
4913
- return element;
4914
- }
4915
- createText(value) {
4916
- const element = new LynxBackgroundElement();
4917
- element.tagName = "text";
4918
- element.setAttribute("tagName", "text");
4919
- element.setAttribute("textContent", value);
4920
- return element;
4921
- }
4922
- createComment() {
4923
- const element = new LynxBackgroundElement();
4924
- element.tagName = "comment";
4925
- element.setAttribute("tagName", "comment");
4926
- return element;
4927
- }
4928
- appendChild(newChild) {
4929
- this.#page?.appendChild(newChild);
4930
- }
4931
- };
4932
5678
  const createListElement = (pageId) => {
4933
5679
  let listEl;
4934
5680
  const componentAtIndex = (listRef, listId, cellIndex, opId) => {
@@ -4985,16 +5731,23 @@ const createPageElement = (page, pageElementRequested) => {
4985
5731
  pageElementRequested: true
4986
5732
  };
4987
5733
  };
5734
+ const takeOverPage = () => {
5735
+ const page = __pageElementRef;
5736
+ if (!takePageHandOver() || !page) return null;
5737
+ for (const child of __GetChildren(page) ?? []) __RemoveElement(page, child);
5738
+ return page;
5739
+ };
4988
5740
  var LynxDocument = class {
4989
5741
  page;
4990
5742
  #pageId = 0;
4991
5743
  #pageElementRequested = false;
4992
5744
  constructor() {}
4993
5745
  createRootElement() {
4994
- const pageElement = __CreatePage("0", 0);
5746
+ const pageElement = takeOverPage() ?? __CreatePage("0", 0);
4995
5747
  this.page = new LynxElement(pageElement);
4996
5748
  this.page.tagName = "page";
4997
5749
  this.page.isRootPageElement = true;
5750
+ if (isAndroid()) __SetID(pageElement, ANDROID_BLUR_CAPTURE_TARGET);
4998
5751
  this.#pageId = __GetElementUniqueID(pageElement);
4999
5752
  setPageElementRef(pageElement);
5000
5753
  return this.page;
@@ -5012,6 +5765,7 @@ var LynxDocument = class {
5012
5765
  const el = new LynxElement(createNativeRefByTag(tag, this.#pageId, value));
5013
5766
  el.tagName = tag;
5014
5767
  if (tag === "raw-text") el.setInitialText(value ?? "");
5768
+ if (tag === "blur-view") el.updateBlurMaterial();
5015
5769
  return el;
5016
5770
  }
5017
5771
  createText(value) {
@@ -5164,14 +5918,24 @@ var LynxRenderer = class {
5164
5918
  }
5165
5919
  };
5166
5920
  var EmulatedLynxRenderer = class extends LynxRenderer {
5167
- #componentScopeId;
5921
+ #contentClass;
5922
+ #hostClass;
5168
5923
  constructor(document, componentId) {
5169
5924
  super(document);
5170
- this.#componentScopeId = componentId;
5925
+ this.#contentClass = `_ngcontent-${componentId}`;
5926
+ this.#hostClass = `_nghost-${componentId}`;
5927
+ }
5928
+ applyToHost(element) {
5929
+ element.addScopeClass(this.#hostClass);
5930
+ }
5931
+ createElement(name, namespace) {
5932
+ const element = super.createElement(name, namespace);
5933
+ element.addScopeClass(this.#contentClass);
5934
+ return element;
5171
5935
  }
5172
5936
  selectRootElement() {
5173
5937
  const el = super.selectRootElement();
5174
- el.addClass(`_nghost-${this.#componentScopeId}`);
5938
+ this.applyToHost(el);
5175
5939
  return el;
5176
5940
  }
5177
5941
  };
@@ -5179,13 +5943,9 @@ var LynxRendererFactory2 = class LynxRendererFactory2 {
5179
5943
  lynxDocument = inject(LYNX_DOCUMENT);
5180
5944
  #defaultRenderer = null;
5181
5945
  #emulatedRenderers = /* @__PURE__ */ new Map();
5182
- createRenderer(_hostElement, type) {
5183
- if (!type || type.encapsulation === ViewEncapsulation.None) {
5184
- if (!this.#defaultRenderer) this.#defaultRenderer = new LynxRenderer(this.lynxDocument);
5185
- return this.#defaultRenderer;
5186
- }
5187
- if (type.encapsulation === ViewEncapsulation.ShadowDom) {
5188
- console.warn("ViewEncapsulation.ShadowDom is not supported in Lynx. Falling back to no encapsulation.");
5946
+ createRenderer(hostElement, type) {
5947
+ if (!type || type.encapsulation !== ViewEncapsulation.Emulated) {
5948
+ if (type && type.encapsulation !== ViewEncapsulation.None) console.warn("ViewEncapsulation.ShadowDom is not supported in Lynx. Falling back to no encapsulation.");
5189
5949
  if (!this.#defaultRenderer) this.#defaultRenderer = new LynxRenderer(this.lynxDocument);
5190
5950
  return this.#defaultRenderer;
5191
5951
  }
@@ -5194,14 +5954,18 @@ var LynxRendererFactory2 = class LynxRendererFactory2 {
5194
5954
  renderer = new EmulatedLynxRenderer(this.lynxDocument, type.id);
5195
5955
  this.#emulatedRenderers.set(type.id, renderer);
5196
5956
  }
5957
+ if (hostElement) renderer.applyToHost(hostElement);
5197
5958
  return renderer;
5198
5959
  }
5199
5960
  begin() {
5200
5961
  setInsideChangeDetection(true);
5962
+ /* v8 ignore start */
5963
+ if (__PROFILE__) startCdTiming();
5964
+ /* v8 ignore stop */
5201
5965
  }
5202
5966
  end() {
5203
- setInsideChangeDetection(false);
5204
- if (__MAIN_THREAD__) {
5967
+ try {
5968
+ setInsideChangeDetection(false);
5205
5969
  /* v8 ignore start */
5206
5970
  if (__ENABLE_SSR__ && globalThis.__LYNX_IS_HYDRATING__) return;
5207
5971
  /* v8 ignore stop */
@@ -5215,6 +5979,9 @@ var LynxRendererFactory2 = class LynxRendererFactory2 {
5215
5979
  processPendingTextNormalization();
5216
5980
  if (!isFirstRenderPending()) __FlushElementTree();
5217
5981
  processPendingListUpdates();
5982
+ } finally {
5983
+ /* v8 ignore start */
5984
+ if (__PROFILE__) endCdTiming();
5218
5985
  }
5219
5986
  }
5220
5987
  static ɵfac = i0.ɵɵngDeclareFactory({
@@ -5244,12 +6011,9 @@ const provideRenderer = () => {
5244
6011
  {
5245
6012
  provide: LYNX_DOCUMENT,
5246
6013
  useFactory: () => {
5247
- if (__MAIN_THREAD__) {
5248
- /* v8 ignore next 6 */
5249
- if (__ENABLE_SSR__ && globalThis.__LYNX_IS_HYDRATING__) return new LynxHydrateDocument(globalThis.__LYNX_HYDRATE_PAGE__, globalThis.__LYNX_HYDRATE_QUEUE__);
5250
- return new LynxDocument();
5251
- }
5252
- return new LynxBackgroundDocument();
6014
+ /* v8 ignore next 6 */
6015
+ if (__ENABLE_SSR__ && globalThis.__LYNX_IS_HYDRATING__) return new LynxHydrateDocument(globalThis.__LYNX_HYDRATE_PAGE__, globalThis.__LYNX_HYDRATE_QUEUE__);
6016
+ return new LynxDocument();
5253
6017
  }
5254
6018
  },
5255
6019
  {
@@ -5278,6 +6042,12 @@ const provideRenderer = () => {
5278
6042
  }
5279
6043
  ]);
5280
6044
  };
6045
+ let carriedOver;
6046
+ let snapshotOf;
6047
+ const carryOverLocation = (injector) => {
6048
+ const strategy = injector?.get(LocationStrategy, null);
6049
+ if (strategy instanceof LynxLocationStrategy) carriedOver = snapshotOf(strategy);
6050
+ };
5281
6051
  var LynxLocationStrategy = class LynxLocationStrategy extends LocationStrategy {
5282
6052
  #path = "/";
5283
6053
  #baseHref = "/";
@@ -5287,6 +6057,24 @@ var LynxLocationStrategy = class LynxLocationStrategy extends LocationStrategy {
5287
6057
  }];
5288
6058
  #historyIndex = 0;
5289
6059
  #listeners = [];
6060
+ #canGoBack = signal(false, ...ngDevMode ? [{ debugName: "#canGoBack" }] : /* istanbul ignore next */ []);
6061
+ constructor() {
6062
+ super();
6063
+ if (carriedOver) {
6064
+ this.#history = carriedOver.history;
6065
+ this.#historyIndex = carriedOver.index;
6066
+ this.#path = this.#history[this.#historyIndex].url;
6067
+ this.#canGoBack.set(this.#historyIndex > 0);
6068
+ carriedOver = void 0;
6069
+ }
6070
+ }
6071
+ static {
6072
+ snapshotOf = (strategy) => ({
6073
+ history: strategy.#history.map((entry) => ({ ...entry })),
6074
+ index: strategy.#historyIndex
6075
+ });
6076
+ }
6077
+ canGoBack = this.#canGoBack.asReadonly();
5290
6078
  path() {
5291
6079
  return this.#path;
5292
6080
  }
@@ -5307,6 +6095,7 @@ var LynxLocationStrategy = class LynxLocationStrategy extends LocationStrategy {
5307
6095
  url: fullUrl
5308
6096
  });
5309
6097
  this.#historyIndex++;
6098
+ this.#canGoBack.set(true);
5310
6099
  this.#path = fullUrl;
5311
6100
  }
5312
6101
  replaceState(state, _title, url, queryParams) {
@@ -5327,6 +6116,7 @@ var LynxLocationStrategy = class LynxLocationStrategy extends LocationStrategy {
5327
6116
  const target = this.#historyIndex + relativePosition;
5328
6117
  if (target < 0 || target >= this.#history.length) return;
5329
6118
  this.#historyIndex = target;
6119
+ this.#canGoBack.set(target > 0);
5330
6120
  this.#path = this.#history[target].url;
5331
6121
  for (const fn of this.#listeners) fn({
5332
6122
  type: "popstate",
@@ -5344,7 +6134,7 @@ var LynxLocationStrategy = class LynxLocationStrategy extends LocationStrategy {
5344
6134
  version: "22.2.1",
5345
6135
  ngImport: i0,
5346
6136
  type: LynxLocationStrategy,
5347
- deps: null,
6137
+ deps: [],
5348
6138
  target: i0.ɵɵFactoryTarget.Injectable
5349
6139
  });
5350
6140
  static ɵprov = i0.ɵɵngDeclareInjectable({
@@ -5359,7 +6149,8 @@ i0.ɵɵngDeclareClassMetadata({
5359
6149
  version: "22.2.1",
5360
6150
  ngImport: i0,
5361
6151
  type: LynxLocationStrategy,
5362
- decorators: [{ type: Injectable }]
6152
+ decorators: [{ type: Injectable }],
6153
+ ctorParameters: () => []
5363
6154
  });
5364
6155
  var LynxPlatformLocation = class LynxPlatformLocation extends PlatformLocation {
5365
6156
  #history = [{
@@ -5520,6 +6311,51 @@ i0.ɵɵngDeclareClassMetadata({
5520
6311
  type: LynxRouteReuseStrategy,
5521
6312
  decorators: [{ type: Injectable }]
5522
6313
  });
6314
+ const SHELL_MODULE = "AngularLynxShell";
6315
+ const BACK_EVENT = "angularLynxBack";
6316
+ var LynxBackButton = class LynxBackButton {
6317
+ constructor() {
6318
+ const strategy = inject(LocationStrategy);
6319
+ if (!(strategy instanceof LynxLocationStrategy)) return;
6320
+ const location = inject(Location);
6321
+ const modules = inject(LynxNativeModule);
6322
+ const shell = modules.getNativeModule(SHELL_MODULE);
6323
+ let hasShell = true;
6324
+ effect(() => {
6325
+ const enabled = strategy.canGoBack();
6326
+ if (!hasShell) return;
6327
+ Promise.resolve().then(() => shell?.setBackHandlerEnabled(enabled)).catch(() => hasShell = false);
6328
+ });
6329
+ const emitter = modules.getJSModule("GlobalEventEmitter");
6330
+ Promise.resolve().then(() => emitter?.addListener(BACK_EVENT, () => location.back())).catch(() => {});
6331
+ }
6332
+ static ɵfac = i0.ɵɵngDeclareFactory({
6333
+ minVersion: "12.0.0",
6334
+ version: "22.2.1",
6335
+ ngImport: i0,
6336
+ type: LynxBackButton,
6337
+ deps: [],
6338
+ target: i0.ɵɵFactoryTarget.Injectable
6339
+ });
6340
+ static ɵprov = i0.ɵɵngDeclareInjectable({
6341
+ minVersion: "12.0.0",
6342
+ version: "22.2.1",
6343
+ ngImport: i0,
6344
+ type: LynxBackButton,
6345
+ providedIn: "root"
6346
+ });
6347
+ };
6348
+ i0.ɵɵngDeclareClassMetadata({
6349
+ minVersion: "12.0.0",
6350
+ version: "22.2.1",
6351
+ ngImport: i0,
6352
+ type: LynxBackButton,
6353
+ decorators: [{
6354
+ type: Injectable,
6355
+ args: [{ providedIn: "root" }]
6356
+ }],
6357
+ ctorParameters: () => []
6358
+ });
5523
6359
  const provideRouter = (routes, ...features) => {
5524
6360
  return makeEnvironmentProviders([
5525
6361
  {
@@ -5530,11 +6366,15 @@ const provideRouter = (routes, ...features) => {
5530
6366
  provide: LocationStrategy,
5531
6367
  useClass: LynxLocationStrategy
5532
6368
  },
6369
+ provideRouter$1(routes, withRouterConfig({ resolveNavigationPromiseOnError: true }), ...features),
6370
+ provideEnvironmentInitializer(() => inject(LynxBackButton)),
5533
6371
  {
5534
- provide: RouteReuseStrategy,
5535
- useClass: LynxRouteReuseStrategy
5536
- },
5537
- provideRouter$1(routes, withRouterConfig({ resolveNavigationPromiseOnError: true }), ...features)
6372
+ provide: ROUTER_LINK_ACTIVE_CHANGE,
6373
+ useValue: () => inject(RouterLinkActive, {
6374
+ self: true,
6375
+ optional: true
6376
+ })?.isActiveChange ?? null
6377
+ }
5538
6378
  ]);
5539
6379
  };
5540
6380
  globalThis.__lynxLastError = "";
@@ -5552,12 +6392,98 @@ if (typeof globalThis.onunhandledrejection !== "function") globalThis.onunhandle
5552
6392
  globalThis.__lynxLastError = `${e.name}: ${e.message}\n${e.stack ?? ""}`;
5553
6393
  reportToNative(e);
5554
6394
  };
5555
- const REPLACEMENT_CHARACTER = 65533;
6395
+ const CODES = {
6396
+ NotSupportedError: 9,
6397
+ InvalidStateError: 11,
6398
+ SyntaxError: 12,
6399
+ InvalidAccessError: 15,
6400
+ NetworkError: 19,
6401
+ AbortError: 20,
6402
+ TimeoutError: 23
6403
+ };
6404
+ var LynxDOMException = class extends Error {
6405
+ code;
6406
+ constructor(message = "", name = "Error") {
6407
+ super(message);
6408
+ this.name = name;
6409
+ this.code = CODES[name] ?? 0;
6410
+ }
6411
+ };
6412
+ const NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
6413
+ const normalizeValue = (value) => {
6414
+ const normalized = String(value).replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, "");
6415
+ if (/[\r\n]/.test(normalized) || normalized.includes("\0")) throw new TypeError(`Invalid header value: ${JSON.stringify(value)}`);
6416
+ return normalized;
6417
+ };
6418
+ const normalizeName = (name) => {
6419
+ const normalized = String(name);
6420
+ if (!NAME.test(normalized)) throw new TypeError(`Invalid header name: ${JSON.stringify(name)}`);
6421
+ return normalized.toLowerCase();
6422
+ };
6423
+ var LynxHeaders = class LynxHeaders {
6424
+ #list = [];
6425
+ constructor(init) {
6426
+ if (init == null) return;
6427
+ if (init instanceof LynxHeaders) this.#list = init.#list.map(([name, value]) => [name, value]);
6428
+ else if (typeof init[Symbol.iterator] === "function") for (const pair of init) {
6429
+ if (pair.length !== 2) throw new TypeError("Failed to construct 'Headers': Invalid value: each header must be a [name, value] pair");
6430
+ this.append(pair[0], pair[1]);
6431
+ }
6432
+ else for (const name of Object.keys(init)) this.append(name, init[name]);
6433
+ }
6434
+ append(name, value) {
6435
+ this.#list.push([normalizeName(name), normalizeValue(value)]);
6436
+ }
6437
+ delete(name) {
6438
+ const key = normalizeName(name);
6439
+ this.#list = this.#list.filter(([listed]) => listed !== key);
6440
+ }
6441
+ get(name) {
6442
+ const key = normalizeName(name);
6443
+ const values = this.#list.filter(([listed]) => listed === key).map(([, value]) => value);
6444
+ return values.length > 0 ? values.join(", ") : null;
6445
+ }
6446
+ getSetCookie() {
6447
+ return this.#list.filter(([name]) => name === "set-cookie").map(([, value]) => value);
6448
+ }
6449
+ has(name) {
6450
+ const key = normalizeName(name);
6451
+ return this.#list.some(([listed]) => listed === key);
6452
+ }
6453
+ set(name, value) {
6454
+ const key = normalizeName(name);
6455
+ const index = this.#list.findIndex(([listed]) => listed === key);
6456
+ if (index === -1) {
6457
+ this.append(key, value);
6458
+ return;
6459
+ }
6460
+ this.#list[index] = [key, normalizeValue(value)];
6461
+ this.#list = this.#list.filter(([listed], i) => listed !== key || i === index);
6462
+ }
6463
+ forEach(callback, thisArg) {
6464
+ for (const [name, value] of this.entries()) callback.call(thisArg, value, name, this);
6465
+ }
6466
+ *entries() {
6467
+ const names = [...new Set(this.#list.map(([name]) => name))].sort();
6468
+ for (const name of names) if (name === "set-cookie") for (const value of this.getSetCookie()) yield [name, value];
6469
+ else yield [name, this.get(name)];
6470
+ }
6471
+ *keys() {
6472
+ for (const [name] of this.entries()) yield name;
6473
+ }
6474
+ *values() {
6475
+ for (const [, value] of this.entries()) yield value;
6476
+ }
6477
+ [Symbol.iterator]() {
6478
+ return this.entries();
6479
+ }
6480
+ };
6481
+ const REPLACEMENT_CHARACTER$1 = 65533;
5556
6482
  const utf8Encode = (input) => {
5557
6483
  const bytes = [];
5558
6484
  for (const char of input) {
5559
6485
  let codePoint = char.codePointAt(0);
5560
- if (codePoint >= 55296 && codePoint <= 57343) codePoint = REPLACEMENT_CHARACTER;
6486
+ if (codePoint >= 55296 && codePoint <= 57343) codePoint = REPLACEMENT_CHARACTER$1;
5561
6487
  if (codePoint < 128) bytes.push(codePoint);
5562
6488
  else if (codePoint < 2048) bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
5563
6489
  else if (codePoint < 65536) bytes.push(224 | codePoint >> 12, 128 | codePoint >> 6 & 63, 128 | codePoint & 63);
@@ -5593,7 +6519,7 @@ const utf8Decode = (bytes) => {
5593
6519
  needed = 3;
5594
6520
  codePoint = lead & 7;
5595
6521
  } else {
5596
- output += String.fromCharCode(REPLACEMENT_CHARACTER);
6522
+ output += String.fromCharCode(REPLACEMENT_CHARACTER$1);
5597
6523
  index++;
5598
6524
  continue;
5599
6525
  }
@@ -5607,7 +6533,7 @@ const utf8Decode = (bytes) => {
5607
6533
  seen++;
5608
6534
  }
5609
6535
  if (seen < needed) {
5610
- output += String.fromCharCode(REPLACEMENT_CHARACTER);
6536
+ output += String.fromCharCode(REPLACEMENT_CHARACTER$1);
5611
6537
  index += 1 + seen;
5612
6538
  continue;
5613
6539
  }
@@ -5654,6 +6580,700 @@ const formUrlEncode = (input) => {
5654
6580
  else output += percentEncodeByte(byte);
5655
6581
  return output;
5656
6582
  };
6583
+ const UTF8_LABELS = /* @__PURE__ */ new Set([
6584
+ "unicode-1-1-utf-8",
6585
+ "unicode11utf8",
6586
+ "unicode20utf8",
6587
+ "utf-8",
6588
+ "utf8",
6589
+ "x-unicode20utf8"
6590
+ ]);
6591
+ const REPLACEMENT_CHARACTER = 65533;
6592
+ const BYTE_ORDER_MARK = 65279;
6593
+ const SLICE = 8192;
6594
+ const toBytes$1 = (input) => {
6595
+ if (input === void 0) return /* @__PURE__ */ new Uint8Array(0);
6596
+ if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
6597
+ if (input instanceof ArrayBuffer) return new Uint8Array(input);
6598
+ throw new TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'.");
6599
+ };
6600
+ const sequenceLength = (lead) => {
6601
+ if (lead >= 194 && lead <= 223) return 2;
6602
+ if (lead >= 224 && lead <= 239) return 3;
6603
+ if (lead >= 240 && lead <= 244) return 4;
6604
+ return 1;
6605
+ };
6606
+ const completeLength = (bytes) => {
6607
+ for (let back = 1; back <= 3 && back <= bytes.length; back++) {
6608
+ const byte = bytes[bytes.length - back];
6609
+ if ((byte & 192) !== 128) return sequenceLength(byte) > back ? bytes.length - back : bytes.length;
6610
+ }
6611
+ return bytes.length;
6612
+ };
6613
+ var LynxTextEncoder = class {
6614
+ encoding = "utf-8";
6615
+ encode(input = "") {
6616
+ return new Uint8Array(utf8Encode(String(input)));
6617
+ }
6618
+ encodeInto(source, destination) {
6619
+ let read = 0;
6620
+ let written = 0;
6621
+ for (const char of String(source)) {
6622
+ const bytes = utf8Encode(char);
6623
+ if (written + bytes.length > destination.length) break;
6624
+ destination.set(bytes, written);
6625
+ written += bytes.length;
6626
+ read += char.length;
6627
+ }
6628
+ return {
6629
+ read,
6630
+ written
6631
+ };
6632
+ }
6633
+ };
6634
+ var LynxTextDecoder = class {
6635
+ encoding = "utf-8";
6636
+ fatal;
6637
+ ignoreBOM;
6638
+ #pending = [];
6639
+ #started = false;
6640
+ constructor(label = "utf-8", options = {}) {
6641
+ if (!UTF8_LABELS.has(String(label).trim().toLowerCase())) throw new RangeError(`The encoding label provided ('${label}') is invalid or isn't supported on Lynx, which only decodes UTF-8.`);
6642
+ this.fatal = !!options.fatal;
6643
+ this.ignoreBOM = !!options.ignoreBOM;
6644
+ }
6645
+ decode(input, options = {}) {
6646
+ let bytes = toBytes$1(input);
6647
+ if (this.#pending.length > 0) bytes = [...this.#pending, ...Array.from(bytes)];
6648
+ const end = options.stream ? completeLength(bytes) : bytes.length;
6649
+ this.#pending = Array.from({ length: bytes.length - end }, (_, i) => Number(bytes[end + i]));
6650
+ let output = this.#decode(bytes, end);
6651
+ if (!this.ignoreBOM && !this.#started && output.charCodeAt(0) === BYTE_ORDER_MARK) output = output.slice(1);
6652
+ this.#started = options.stream ? this.#started || output !== "" : false;
6653
+ return output;
6654
+ }
6655
+ #decode(bytes, end) {
6656
+ let output = "";
6657
+ const codes = [];
6658
+ const invalid = () => {
6659
+ if (this.fatal) throw new TypeError("Failed to execute 'decode' on 'TextDecoder': The encoded data was not valid.");
6660
+ codes.push(REPLACEMENT_CHARACTER);
6661
+ };
6662
+ let index = 0;
6663
+ while (index < end) {
6664
+ const lead = bytes[index];
6665
+ if (lead < 128) {
6666
+ codes.push(lead);
6667
+ index++;
6668
+ } else {
6669
+ const needed = sequenceLength(lead) - 1;
6670
+ let lower = lead === 224 ? 160 : lead === 240 ? 144 : 128;
6671
+ let upper = lead === 237 ? 159 : lead === 244 ? 143 : 191;
6672
+ let codePoint = lead & 255 >> needed + 2;
6673
+ let seen = 0;
6674
+ while (seen < needed && index + 1 + seen < end) {
6675
+ const next = bytes[index + 1 + seen];
6676
+ if (next < lower || next > upper) break;
6677
+ lower = 128;
6678
+ upper = 191;
6679
+ codePoint = codePoint << 6 | next & 63;
6680
+ seen++;
6681
+ }
6682
+ if (needed === 0 || seen < needed) {
6683
+ invalid();
6684
+ index += 1 + seen;
6685
+ } else {
6686
+ if (codePoint > 65535) {
6687
+ codePoint -= 65536;
6688
+ codes.push(55296 | codePoint >> 10, 56320 | codePoint & 1023);
6689
+ } else codes.push(codePoint);
6690
+ index += 1 + needed;
6691
+ }
6692
+ }
6693
+ if (codes.length >= SLICE) {
6694
+ output += String.fromCharCode(...codes);
6695
+ codes.length = 0;
6696
+ }
6697
+ }
6698
+ return output + String.fromCharCode(...codes);
6699
+ }
6700
+ };
6701
+ const toBytes = (source) => typeof source === "string" ? new LynxTextEncoder().encode(source) : source ?? /* @__PURE__ */ new Uint8Array(0);
6702
+ const unsupportedBody = (kind) => /* @__PURE__ */ new TypeError(`${kind} request bodies aren't supported on Lynx. Send a string, URLSearchParams, an ArrayBuffer or a typed array.`);
6703
+ const extractBody = (body) => {
6704
+ if (body == null) return {
6705
+ source: null,
6706
+ type: null
6707
+ };
6708
+ if (typeof body === "string") return {
6709
+ source: body,
6710
+ type: "text/plain;charset=UTF-8"
6711
+ };
6712
+ if (body instanceof ArrayBuffer) return {
6713
+ source: new Uint8Array(body.slice(0)),
6714
+ type: null
6715
+ };
6716
+ if (ArrayBuffer.isView(body)) return {
6717
+ source: new Uint8Array(body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength)),
6718
+ type: null
6719
+ };
6720
+ if (typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams) return {
6721
+ source: body.toString(),
6722
+ type: "application/x-www-form-urlencoded;charset=UTF-8"
6723
+ };
6724
+ for (const kind of [
6725
+ "Blob",
6726
+ "FormData",
6727
+ "ReadableStream"
6728
+ ]) {
6729
+ const type = globalThis[kind];
6730
+ if (typeof type === "function" && body instanceof type) throw unsupportedBody(kind);
6731
+ }
6732
+ if (typeof body.getReader === "function") throw unsupportedBody("ReadableStream");
6733
+ return {
6734
+ source: String(body),
6735
+ type: "text/plain;charset=UTF-8"
6736
+ };
6737
+ };
6738
+ var LynxBodyStream = class {
6739
+ #chunk;
6740
+ #onRead;
6741
+ locked = false;
6742
+ constructor(chunk, onRead) {
6743
+ this.#chunk = chunk.length > 0 ? chunk : null;
6744
+ this.#onRead = onRead;
6745
+ }
6746
+ getReader() {
6747
+ if (this.locked) throw new TypeError("Failed to execute 'getReader' on 'ReadableStream': ReadableStreamDefaultReader constructor can only accept readable streams that are not yet locked to a reader");
6748
+ this.locked = true;
6749
+ this.#onRead();
6750
+ let released = false;
6751
+ return {
6752
+ read: async () => {
6753
+ if (released) throw new TypeError("This reader has been released");
6754
+ const chunk = this.#chunk;
6755
+ this.#chunk = null;
6756
+ return chunk ? {
6757
+ done: false,
6758
+ value: chunk
6759
+ } : {
6760
+ done: true,
6761
+ value: void 0
6762
+ };
6763
+ },
6764
+ cancel: async () => {
6765
+ this.#chunk = null;
6766
+ },
6767
+ releaseLock: () => {
6768
+ released = true;
6769
+ this.locked = false;
6770
+ },
6771
+ closed: Promise.resolve(void 0)
6772
+ };
6773
+ }
6774
+ async cancel() {
6775
+ this.#onRead();
6776
+ this.#chunk = null;
6777
+ }
6778
+ async *[Symbol.asyncIterator]() {
6779
+ const reader = this.getReader();
6780
+ for (;;) {
6781
+ const { done, value } = await reader.read();
6782
+ if (done) return;
6783
+ yield value;
6784
+ }
6785
+ }
6786
+ };
6787
+ var LynxBody = class {
6788
+ #source;
6789
+ #used = false;
6790
+ #stream;
6791
+ constructor(source) {
6792
+ this.#source = source;
6793
+ }
6794
+ get body() {
6795
+ if (this.#source === null) return null;
6796
+ this.#stream ??= new LynxBodyStream(toBytes(this.#source), () => {
6797
+ this.#used = true;
6798
+ });
6799
+ return this.#stream;
6800
+ }
6801
+ get bodyUsed() {
6802
+ return this.#used;
6803
+ }
6804
+ relayedBody() {
6805
+ const source = this.#source;
6806
+ if (source === null) return null;
6807
+ return typeof source === "string" ? { text: source } : { base64: bytesToBase64(source) };
6808
+ }
6809
+ cloneSource() {
6810
+ if (this.#used) throw new TypeError("Failed to execute 'clone': the body is already used");
6811
+ return this.#source;
6812
+ }
6813
+ async #consume() {
6814
+ if (this.#used) throw new TypeError("Failed to execute 'text' on 'Body': body stream already read");
6815
+ this.#used = true;
6816
+ return this.#source;
6817
+ }
6818
+ async text() {
6819
+ const source = await this.#consume();
6820
+ return typeof source === "string" ? source : new LynxTextDecoder().decode(toBytes(source));
6821
+ }
6822
+ async json() {
6823
+ return JSON.parse(await this.text());
6824
+ }
6825
+ async bytes() {
6826
+ return toBytes(await this.#consume());
6827
+ }
6828
+ async arrayBuffer() {
6829
+ const bytes = await this.bytes();
6830
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
6831
+ }
6832
+ async blob() {
6833
+ const BlobType = globalThis.Blob;
6834
+ if (typeof BlobType !== "function") throw new TypeError("Lynx has no Blob. Use arrayBuffer() instead.");
6835
+ return new BlobType([await this.arrayBuffer()], { type: this.headers.get("content-type") ?? "" });
6836
+ }
6837
+ async formData() {
6838
+ throw new TypeError("Lynx has no FormData. Use text() or json() instead.");
6839
+ }
6840
+ };
6841
+ const NORMALIZED_METHODS = /* @__PURE__ */ new Set([
6842
+ "DELETE",
6843
+ "GET",
6844
+ "HEAD",
6845
+ "OPTIONS",
6846
+ "POST",
6847
+ "PUT"
6848
+ ]);
6849
+ const parseUrl$1 = (input) => {
6850
+ try {
6851
+ return new URL(input).href;
6852
+ } catch {
6853
+ throw new TypeError(`Failed to parse URL from ${input}. Lynx has no page URL to resolve a relative URL against, so requests need an absolute URL.`);
6854
+ }
6855
+ };
6856
+ const DEFAULT_OPTIONS = {
6857
+ cache: "default",
6858
+ credentials: "same-origin",
6859
+ integrity: "",
6860
+ keepalive: false,
6861
+ mode: "cors",
6862
+ priority: "auto",
6863
+ redirect: "follow",
6864
+ referrer: "about:client",
6865
+ referrerPolicy: ""
6866
+ };
6867
+ const neverAborts = () => new AbortController().signal;
6868
+ var LynxRequest = class LynxRequest extends LynxBody {
6869
+ url;
6870
+ method;
6871
+ headers;
6872
+ signal;
6873
+ cache;
6874
+ credentials;
6875
+ integrity;
6876
+ keepalive;
6877
+ mode;
6878
+ priority;
6879
+ redirect;
6880
+ referrer;
6881
+ referrerPolicy;
6882
+ destination = "";
6883
+ constructor(input, init = {}) {
6884
+ const base = input instanceof LynxRequest ? input : void 0;
6885
+ const method = init.method ?? base?.method ?? "GET";
6886
+ const upper = method.toUpperCase();
6887
+ const normalizedMethod = NORMALIZED_METHODS.has(upper) ? upper : method;
6888
+ const { source, type } = init.body !== void 0 ? extractBody(init.body) : {
6889
+ source: base ? base.cloneSource() : null,
6890
+ type: null
6891
+ };
6892
+ if (source !== null && (upper === "GET" || upper === "HEAD")) throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
6893
+ super(source);
6894
+ this.url = base ? base.url : parseUrl$1(String(input));
6895
+ this.method = normalizedMethod;
6896
+ this.headers = new LynxHeaders(init.headers ?? base?.headers);
6897
+ if (type !== null && !this.headers.has("content-type")) this.headers.set("content-type", type);
6898
+ this.signal = init.signal ?? base?.signal ?? neverAborts();
6899
+ const options = base ?? DEFAULT_OPTIONS;
6900
+ this.cache = init.cache ?? options.cache;
6901
+ this.credentials = init.credentials ?? options.credentials;
6902
+ this.integrity = init.integrity ?? options.integrity;
6903
+ this.keepalive = init.keepalive ?? options.keepalive;
6904
+ this.mode = init.mode ?? options.mode;
6905
+ this.priority = init.priority ?? options.priority;
6906
+ this.redirect = init.redirect ?? options.redirect;
6907
+ this.referrer = init.referrer ?? options.referrer;
6908
+ this.referrerPolicy = init.referrerPolicy ?? options.referrerPolicy;
6909
+ }
6910
+ clone() {
6911
+ return new LynxRequest(this);
6912
+ }
6913
+ toRelayed() {
6914
+ return {
6915
+ url: this.url,
6916
+ method: this.method,
6917
+ headers: [...this.headers.entries()],
6918
+ body: this.relayedBody(),
6919
+ options: Object.fromEntries(Object.entries(DEFAULT_OPTIONS).filter(([name, value]) => this[name] !== value).map(([name]) => [name, this[name]]))
6920
+ };
6921
+ }
6922
+ };
6923
+ var ExtractedBody = class {
6924
+ source;
6925
+ constructor(source) {
6926
+ this.source = source;
6927
+ }
6928
+ };
6929
+ var LynxResponse = class LynxResponse extends LynxBody {
6930
+ status;
6931
+ statusText;
6932
+ headers;
6933
+ url;
6934
+ redirected;
6935
+ type;
6936
+ constructor(body, init = {}, details = {
6937
+ url: "",
6938
+ redirected: false,
6939
+ type: "default"
6940
+ }) {
6941
+ const status = init.status ?? 200;
6942
+ if (details.type === "default" && (!Number.isInteger(status) || status < 200 || status > 599)) throw new RangeError(`Failed to construct 'Response': The status provided (${status}) is outside the range [200, 599].`);
6943
+ const { source, type } = body instanceof ExtractedBody ? {
6944
+ source: body.source,
6945
+ type: null
6946
+ } : extractBody(body);
6947
+ super(source);
6948
+ this.status = status;
6949
+ this.statusText = init.statusText ?? "";
6950
+ this.headers = new LynxHeaders(init.headers);
6951
+ if (type !== null && !this.headers.has("content-type")) this.headers.set("content-type", type);
6952
+ this.url = details.url;
6953
+ this.redirected = details.redirected;
6954
+ this.type = details.type;
6955
+ }
6956
+ get ok() {
6957
+ return this.status >= 200 && this.status < 300;
6958
+ }
6959
+ clone() {
6960
+ return new LynxResponse(new ExtractedBody(this.cloneSource()), {
6961
+ status: this.status,
6962
+ statusText: this.statusText,
6963
+ headers: this.headers
6964
+ }, {
6965
+ url: this.url,
6966
+ redirected: this.redirected,
6967
+ type: this.type
6968
+ });
6969
+ }
6970
+ static error() {
6971
+ return new LynxResponse(null, { status: 0 }, {
6972
+ url: "",
6973
+ redirected: false,
6974
+ type: "error"
6975
+ });
6976
+ }
6977
+ static json(data, init = {}) {
6978
+ const response = new LynxResponse(new ExtractedBody(JSON.stringify(data)), init);
6979
+ if (!response.headers.has("content-type")) response.headers.set("content-type", "application/json");
6980
+ return response;
6981
+ }
6982
+ static redirect(url, status = 302) {
6983
+ if (![
6984
+ 301,
6985
+ 302,
6986
+ 303,
6987
+ 307,
6988
+ 308
6989
+ ].includes(status)) throw new RangeError(`Failed to execute 'redirect' on 'Response': Invalid status code ${status}`);
6990
+ return new LynxResponse(null, {
6991
+ status,
6992
+ headers: { location: parseUrl$1(url) }
6993
+ });
6994
+ }
6995
+ static fromRelayed(relayed) {
6996
+ const body = relayed.body;
6997
+ const source = body === null ? null : "text" in body ? body.text : base64ToBytes(body.base64);
6998
+ return new LynxResponse(new ExtractedBody(source), {
6999
+ status: relayed.status,
7000
+ statusText: relayed.statusText,
7001
+ headers: relayed.headers
7002
+ }, {
7003
+ url: relayed.url,
7004
+ redirected: relayed.redirected,
7005
+ type: "basic"
7006
+ });
7007
+ }
7008
+ };
7009
+ let nextFetchId = 0;
7010
+ const relayFetch = (input, init) => new Promise((resolve, reject) => {
7011
+ const request = new LynxRequest(input, init);
7012
+ const { signal } = request;
7013
+ if (signal.aborted) {
7014
+ reject(signal.reason);
7015
+ return;
7016
+ }
7017
+ const id = nextFetchId++;
7018
+ let settled = false;
7019
+ const onAbort = () => {
7020
+ settled = true;
7021
+ reject(signal.reason);
7022
+ callOnBackground("abortFetch", id).catch(() => {});
7023
+ };
7024
+ signal.addEventListener("abort", onAbort);
7025
+ const settle = (fn) => {
7026
+ signal.removeEventListener("abort", onAbort);
7027
+ if (settled) return;
7028
+ settled = true;
7029
+ fn();
7030
+ };
7031
+ callOnBackground("fetch", id, request.toRelayed()).then((relayed) => settle(() => resolve(LynxResponse.fromRelayed(relayed))), (error) => settle(() => reject(new TypeError(error.message))));
7032
+ });
7033
+ var XhrEventTarget = class {
7034
+ #listeners = /* @__PURE__ */ new Map();
7035
+ onloadstart = null;
7036
+ onprogress = null;
7037
+ onabort = null;
7038
+ onerror = null;
7039
+ onload = null;
7040
+ ontimeout = null;
7041
+ onloadend = null;
7042
+ addEventListener(type, listener) {
7043
+ if (!listener) return;
7044
+ let listeners = this.#listeners.get(type);
7045
+ if (!listeners) {
7046
+ listeners = /* @__PURE__ */ new Set();
7047
+ this.#listeners.set(type, listeners);
7048
+ }
7049
+ listeners.add(listener);
7050
+ }
7051
+ removeEventListener(type, listener) {
7052
+ if (listener) this.#listeners.get(type)?.delete(listener);
7053
+ }
7054
+ dispatchEvent(event) {
7055
+ const full = {
7056
+ lengthComputable: false,
7057
+ loaded: 0,
7058
+ total: 0,
7059
+ ...event,
7060
+ target: this,
7061
+ currentTarget: this
7062
+ };
7063
+ const handler = this[`on${event.type}`];
7064
+ if (typeof handler === "function") handler.call(this, full);
7065
+ for (const listener of Array.from(this.#listeners.get(event.type) ?? [])) listener.call(this, full);
7066
+ return true;
7067
+ }
7068
+ fire(type, loaded = 0, total = 0) {
7069
+ this.dispatchEvent({
7070
+ type,
7071
+ lengthComputable: total > 0,
7072
+ loaded,
7073
+ total
7074
+ });
7075
+ }
7076
+ };
7077
+ var XhrUpload = class extends XhrEventTarget {
7078
+ emit(type, loaded, total) {
7079
+ this.fire(type, loaded, total);
7080
+ }
7081
+ };
7082
+ const UNSENT = 0;
7083
+ const OPENED = 1;
7084
+ const HEADERS_RECEIVED = 2;
7085
+ const LOADING = 3;
7086
+ const DONE = 4;
7087
+ const bodySize = (body) => {
7088
+ if (typeof body === "string") return body.length;
7089
+ if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) return body.byteLength;
7090
+ return 0;
7091
+ };
7092
+ var LynxXMLHttpRequest = class extends XhrEventTarget {
7093
+ static UNSENT = UNSENT;
7094
+ static OPENED = OPENED;
7095
+ static HEADERS_RECEIVED = HEADERS_RECEIVED;
7096
+ static LOADING = LOADING;
7097
+ static DONE = DONE;
7098
+ UNSENT = UNSENT;
7099
+ OPENED = OPENED;
7100
+ HEADERS_RECEIVED = HEADERS_RECEIVED;
7101
+ LOADING = LOADING;
7102
+ DONE = DONE;
7103
+ upload = new XhrUpload();
7104
+ onreadystatechange = null;
7105
+ readyState = UNSENT;
7106
+ status = 0;
7107
+ statusText = "";
7108
+ responseURL = "";
7109
+ responseType = "";
7110
+ response = "";
7111
+ timeout = 0;
7112
+ withCredentials = false;
7113
+ #method = "GET";
7114
+ #url = "";
7115
+ #requestHeaders = new LynxHeaders();
7116
+ #responseHeaders = new LynxHeaders();
7117
+ #responseText = "";
7118
+ #controller;
7119
+ #generation = 0;
7120
+ #timer;
7121
+ #uploading = false;
7122
+ get responseText() {
7123
+ if (this.responseType !== "" && this.responseType !== "text") throw new LynxDOMException(`Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was '${this.responseType}').`, "InvalidStateError");
7124
+ return this.#responseText;
7125
+ }
7126
+ open(method, url, async = true) {
7127
+ if (!async) throw new LynxDOMException("Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests aren't supported on Lynx, where the request runs on another thread.", "InvalidAccessError");
7128
+ this.#cancel();
7129
+ this.#method = method;
7130
+ this.#url = String(url);
7131
+ this.#requestHeaders = new LynxHeaders();
7132
+ this.#reset();
7133
+ this.#setReadyState(OPENED);
7134
+ }
7135
+ setRequestHeader(name, value) {
7136
+ this.#assertOpened("setRequestHeader");
7137
+ this.#requestHeaders.append(name, value);
7138
+ }
7139
+ send(body = null) {
7140
+ this.#assertOpened("send");
7141
+ const generation = ++this.#generation;
7142
+ const controller = new AbortController();
7143
+ this.#controller = controller;
7144
+ const method = this.#method.toUpperCase();
7145
+ const sendsBody = method !== "GET" && method !== "HEAD" && body != null;
7146
+ const uploadSize = sendsBody ? bodySize(body) : 0;
7147
+ this.#uploading = sendsBody;
7148
+ this.fire("loadstart");
7149
+ if (sendsBody) this.upload.emit("loadstart", 0, uploadSize);
7150
+ if (this.timeout > 0) this.#timer = setTimeout(() => {
7151
+ if (generation !== this.#generation) return;
7152
+ this.#fail("timeout");
7153
+ }, this.timeout);
7154
+ const current = () => generation === this.#generation;
7155
+ Promise.resolve().then(() => globalThis.fetch(this.#url, {
7156
+ method: this.#method,
7157
+ headers: this.#requestHeaders,
7158
+ body: sendsBody ? body : void 0,
7159
+ credentials: this.withCredentials ? "include" : "same-origin",
7160
+ signal: controller.signal
7161
+ })).then(async (response) => {
7162
+ if (!current()) return;
7163
+ this.#uploadDone(uploadSize);
7164
+ this.status = response.status;
7165
+ this.statusText = response.statusText;
7166
+ this.responseURL = response.url;
7167
+ this.#responseHeaders = new LynxHeaders(response.headers);
7168
+ this.#setReadyState(HEADERS_RECEIVED);
7169
+ this.#setReadyState(LOADING);
7170
+ const size = await this.#readResponse(response);
7171
+ if (!current()) return;
7172
+ this.#finish();
7173
+ this.fire("progress", size, size);
7174
+ this.#setReadyState(DONE);
7175
+ this.fire("load", size, size);
7176
+ this.fire("loadend", size, size);
7177
+ }).catch(() => {
7178
+ if (current()) this.#fail("error");
7179
+ });
7180
+ }
7181
+ abort() {
7182
+ if (this.#controller && this.readyState !== DONE) this.#fail("abort");
7183
+ if (this.readyState === DONE) this.readyState = UNSENT;
7184
+ }
7185
+ getResponseHeader(name) {
7186
+ return this.readyState >= HEADERS_RECEIVED ? this.#responseHeaders.get(name) : null;
7187
+ }
7188
+ getAllResponseHeaders() {
7189
+ if (this.readyState < HEADERS_RECEIVED) return "";
7190
+ let headers = "";
7191
+ for (const [name, value] of this.#responseHeaders) headers += `${name}: ${value}\r\n`;
7192
+ return headers;
7193
+ }
7194
+ overrideMimeType(_mime) {}
7195
+ async #readResponse(response) {
7196
+ const type = this.responseType;
7197
+ if (type === "arraybuffer" || type === "blob") {
7198
+ const buffer = await response.arrayBuffer();
7199
+ const BlobType = globalThis.Blob;
7200
+ this.response = type === "arraybuffer" ? buffer : typeof BlobType === "function" ? new BlobType([buffer], { type: this.#responseHeaders.get("content-type") ?? "" }) : null;
7201
+ return buffer.byteLength;
7202
+ }
7203
+ const text = await response.text();
7204
+ if (type === "json") try {
7205
+ this.response = text === "" ? null : JSON.parse(text);
7206
+ } catch {
7207
+ this.response = null;
7208
+ }
7209
+ else if (type === "document") this.response = null;
7210
+ else {
7211
+ this.#responseText = text;
7212
+ this.response = text;
7213
+ }
7214
+ const length = Number(this.#responseHeaders.get("content-length"));
7215
+ return Number.isFinite(length) && length > 0 ? length : text.length;
7216
+ }
7217
+ #uploadDone(size) {
7218
+ if (!this.#uploading) return;
7219
+ this.#uploading = false;
7220
+ this.upload.emit("progress", size, size);
7221
+ this.upload.emit("load", size, size);
7222
+ this.upload.emit("loadend", size, size);
7223
+ }
7224
+ #fail(type) {
7225
+ this.#cancel();
7226
+ this.#reset();
7227
+ this.#setReadyState(DONE);
7228
+ if (this.#uploading) {
7229
+ this.#uploading = false;
7230
+ this.upload.emit(type);
7231
+ this.upload.emit("loadend");
7232
+ }
7233
+ this.fire(type);
7234
+ this.fire("loadend");
7235
+ }
7236
+ #cancel() {
7237
+ this.#generation++;
7238
+ this.#finish();
7239
+ this.#controller?.abort();
7240
+ this.#controller = void 0;
7241
+ }
7242
+ #finish() {
7243
+ if (this.#timer !== void 0) clearTimeout(this.#timer);
7244
+ this.#timer = void 0;
7245
+ }
7246
+ #reset() {
7247
+ this.status = 0;
7248
+ this.statusText = "";
7249
+ this.responseURL = "";
7250
+ this.response = this.responseType === "" || this.responseType === "text" ? "" : null;
7251
+ this.#responseText = "";
7252
+ this.#responseHeaders = new LynxHeaders();
7253
+ }
7254
+ #assertOpened(method) {
7255
+ if (this.readyState !== OPENED || this.#controller) throw new LynxDOMException(`Failed to execute '${method}' on 'XMLHttpRequest': The object's state must be OPENED.`, "InvalidStateError");
7256
+ }
7257
+ #setReadyState(state) {
7258
+ this.readyState = state;
7259
+ this.dispatchEvent({ type: "readystatechange" });
7260
+ }
7261
+ };
7262
+ const installNetworkGlobals = (target) => {
7263
+ const install = (name, value) => {
7264
+ if (typeof target[name] === "undefined") target[name] = value;
7265
+ };
7266
+ install("TextEncoder", LynxTextEncoder);
7267
+ install("TextDecoder", LynxTextDecoder);
7268
+ install("DOMException", LynxDOMException);
7269
+ if (typeof target["fetch"] === "undefined") {
7270
+ install("fetch", relayFetch);
7271
+ install("Headers", LynxHeaders);
7272
+ install("Request", LynxRequest);
7273
+ install("Response", LynxResponse);
7274
+ }
7275
+ install("XMLHttpRequest", LynxXMLHttpRequest);
7276
+ };
5657
7277
  const invalidUrl = () => /* @__PURE__ */ new TypeError("Invalid URL");
5658
7278
  const FORBIDDEN_HOST = /[\u0000\t\n\r #/:<>?@[\\\]^|]/;
5659
7279
  const FORBIDDEN_DOMAIN = /[\u0000-\u001f #%/:<>?@[\\\]^|\u007f]/;
@@ -6388,6 +8008,7 @@ if (typeof AbortController === "undefined") {
6388
8008
  };
6389
8009
  }
6390
8010
  installUrl(globalThis);
8011
+ if (isMainThread()) installNetworkGlobals(globalThis);
6391
8012
  if (typeof globalThis.queueMicrotask !== "function") {
6392
8013
  if (typeof lynx !== "undefined" && lynx.queueMicrotask) globalThis.queueMicrotask = lynx.queueMicrotask;
6393
8014
  else {
@@ -6548,27 +8169,41 @@ const ssrHydrate = (info) => {
6548
8169
  globalThis.__LYNX_HYDRATE_PAGE__ = nativePage;
6549
8170
  globalThis.__LYNX_HYDRATE_QUEUE__ = elementQueue;
6550
8171
  };
6551
- const __workletMap = {};
6552
- const __mainThreadRefMap = {};
6553
- const __pendingResolvers = {};
6554
- let __nextResolveId = 0;
6555
- const nextResolveId = () => __nextResolveId++;
6556
- const transformParams = (value) => {
6557
- if (typeof value !== "object" || value === null) return value;
6558
- if (Array.isArray(value)) return value.map(transformParams);
6559
- const obj = value;
6560
- if ("elementRefptr" in obj) return new MainThreadElement(obj["elementRefptr"]);
6561
- if ("_wvid" in obj) return __mainThreadRefMap[obj["_wvid"]] ?? obj;
6562
- const result = {};
6563
- for (const key of Object.keys(obj)) result[key] = transformParams(obj[key]);
6564
- return result;
8172
+ const callWorklet = (id, args, kind) => {
8173
+ const fn = __workletMap[id];
8174
+ if (!fn) throw new Error(`[angular-lynx] ${kind} not found: ${id}`);
8175
+ return fn(...args);
6565
8176
  };
6566
- const pageReady = new Subject();
6567
- globalThis.renderPage = () => {
8177
+ const pageReady = new ReplaySubject(1);
8178
+ globalThis.renderPage = (data) => {
8179
+ if (typeof lynx !== "undefined") lynx.__initData = data ?? {};
6568
8180
  pageReady.next();
6569
8181
  };
6570
- globalThis.updatePage = () => {};
6571
- globalThis.processData = () => {};
8182
+ globalThis.updatePage = (data, options) => {
8183
+ if (typeof lynx !== "undefined") applyInitDataUpdate(data, !!options?.resetPageData);
8184
+ };
8185
+ globalThis.updateGlobalProps = (data) => {
8186
+ if (typeof lynx !== "undefined") applyGlobalDataUpdate(data);
8187
+ };
8188
+ if (__MAIN_THREAD__ && typeof lynx !== "undefined" && typeof lynx.getEngine === "function") lynx.getEngine().addEventListener("__UpdateGlobalProps", (event) => applyGlobalDataUpdate(event.data?.[0]));
8189
+ globalThis.processData = (data) => data;
8190
+ if (!__MAIN_THREAD__ && typeof lynx !== "undefined" && typeof lynx.getApp === "function") {
8191
+ const app = lynx.getApp();
8192
+ const params = app._params;
8193
+ lynx.__initData = {
8194
+ ...params?.initData,
8195
+ ...params?.updateData
8196
+ };
8197
+ const emit = (eventName, args) => lynx.getJSModule?.("GlobalEventEmitter")?.emit?.(eventName, args);
8198
+ app.updateCardData = (data, options) => {
8199
+ const { __lynx_timing_flag: _timingFlag, ...patch } = data ?? {};
8200
+ applyInitDataUpdate(patch, options?.type === 1);
8201
+ emit("onDataChanged", [patch]);
8202
+ };
8203
+ app.updateGlobalProps = (data) => {
8204
+ emit("onGlobalPropsChanged", [applyGlobalDataUpdate(data)]);
8205
+ };
8206
+ }
6572
8207
  if (__ENABLE_SSR__) {
6573
8208
  globalThis.ssrEncode = ssrEncode;
6574
8209
  globalThis.ssrHydrate = ssrHydrate;
@@ -6588,36 +8223,15 @@ globalThis.runWorklet = (ctx, params) => {
6588
8223
  };
6589
8224
  if (__MAIN_THREAD__) {
6590
8225
  try {
6591
- if (typeof lynx !== "undefined" && lynx.getJSContext) {
6592
- lynx.getJSContext().addEventListener("Lynx.Worklet.runWorkletCtx", (event) => {
6593
- const { worklet, params, resolveId } = JSON.parse(event.data);
6594
- const fn = __workletMap[worklet._wkltId];
6595
- let returnValue;
6596
- let error;
6597
- try {
6598
- returnValue = fn?.(...params);
6599
- } catch (e) {
6600
- error = String(e);
6601
- }
6602
- lynx.getJSContext().dispatchEvent({
6603
- type: "Lynx.Worklet.FunctionCallRet",
6604
- data: JSON.stringify({
6605
- resolveId,
6606
- returnValue,
6607
- error
6608
- })
6609
- });
6610
- });
6611
- lynx.getJSContext().addEventListener("Lynx.Worklet.BgFunctionCallRet", (event) => {
6612
- const { resolveId, returnValue, error } = JSON.parse(event.data);
6613
- const resolver = __pendingResolvers[resolveId];
6614
- if (resolver) {
6615
- delete __pendingResolvers[resolveId];
6616
- if (error) resolver.reject(new Error(error));
6617
- else resolver.resolve(returnValue);
6618
- }
6619
- });
6620
- }
8226
+ if (typeof lynx !== "undefined" && lynx.getJSContext) lynx.getJSContext().addEventListener("Lynx.Worklet.BgFunctionCallRet", (event) => {
8227
+ const { resolveId, returnValue, error } = JSON.parse(event.data);
8228
+ const resolver = __pendingResolvers[resolveId];
8229
+ if (resolver) {
8230
+ delete __pendingResolvers[resolveId];
8231
+ if (error) resolver.reject(new Error(error));
8232
+ else resolver.resolve(returnValue);
8233
+ }
8234
+ });
6621
8235
  } catch {}
6622
8236
  globalThis.runOnBackground = (handle, ...args) => {
6623
8237
  const resolveId = nextResolveId();
@@ -6643,44 +8257,15 @@ if (__MAIN_THREAD__) {
6643
8257
  };
6644
8258
  }
6645
8259
  if (!__MAIN_THREAD__) try {
6646
- if (typeof lynx !== "undefined" && lynx.getCoreContext) {
6647
- lynx.getCoreContext().addEventListener("Lynx.Worklet.FunctionCallRet", (event) => {
6648
- const { resolveId, returnValue, error } = JSON.parse(event.data);
6649
- const resolver = __pendingResolvers[resolveId];
6650
- if (resolver) {
6651
- delete __pendingResolvers[resolveId];
6652
- if (error) resolver.reject(new Error(error));
6653
- else resolver.resolve(returnValue);
6654
- }
6655
- });
6656
- lynx.getCoreContext().addEventListener("Lynx.Worklet.runOnBackground", (event) => {
6657
- const { worklet, params, resolveId } = JSON.parse(event.data);
6658
- const fn = __workletMap[worklet._wkltId];
6659
- let returnValue;
6660
- let error;
6661
- try {
6662
- returnValue = fn?.(...params);
6663
- } catch (e) {
6664
- error = String(e);
6665
- }
6666
- lynx.getCoreContext().dispatchEvent({
6667
- type: "Lynx.Worklet.BgFunctionCallRet",
6668
- data: JSON.stringify({
6669
- resolveId,
6670
- returnValue,
6671
- error
6672
- })
6673
- });
6674
- });
6675
- }
8260
+ if (typeof lynx !== "undefined" && lynx.getCoreContext) lynx.getCoreContext().addEventListener("Lynx.Worklet.runOnBackground", (event) => {
8261
+ const { worklet, params, resolveId } = JSON.parse(event.data);
8262
+ answerCall(resolveId, () => callWorklet(worklet._wkltId, params.map(restoreRefs), "Background function"), (data) => lynx.getCoreContext().dispatchEvent({
8263
+ type: "Lynx.Worklet.BgFunctionCallRet",
8264
+ data
8265
+ }));
8266
+ });
6676
8267
  } catch {}
6677
- globalThis.__lynxMtsPendingResolvers = __pendingResolvers;
6678
- globalThis.__lynxMtsNextResolveId = nextResolveId;
6679
- globalThis.__lynxRunMainThreadWorklet = (wkltId, args) => {
6680
- const fn = __workletMap[wkltId];
6681
- if (!fn) throw new Error(`[angular-lynx] Main-thread worklet not found: ${wkltId}`);
6682
- return fn(...args);
6683
- };
8268
+ globalThis.__lynxRunMainThreadWorklet = (wkltId, args) => callWorklet(wkltId, args, "Main-thread worklet");
6684
8269
  const installLazyBundleLoader = () => {
6685
8270
  const host = lynx;
6686
8271
  host.loadLazyBundle = loadLazyBundleWithQueryComponent;
@@ -6746,15 +8331,25 @@ const makeSyncThen = (value) => (onFulfilled) => {
6746
8331
  if (next && typeof next.then === "function") return next;
6747
8332
  return syncResolved(next);
6748
8333
  };
8334
+ const ɵstartBackgroundThread = () => {
8335
+ installLazyBundleLoader();
8336
+ };
6749
8337
  const bootstrapApplication = async (rootComponent, options) => {
8338
+ if (!__MAIN_THREAD__) return new Promise(() => {});
6750
8339
  installLazyBundleLoader();
8340
+ const bootstrap = bootstrapOnMainThread(rootComponent, options);
8341
+ globalThis.__LYNX_ANGULAR_BOOTSTRAP__ = bootstrap;
8342
+ return bootstrap;
8343
+ };
8344
+ const bootstrapOnMainThread = async (rootComponent, options) => {
6751
8345
  const prev = globalThis.__LYNX_ANGULAR_APP_REF__;
6752
8346
  if (prev) {
8347
+ carryOverLocation(prev.injector);
8348
+ handOverPageToNextApp();
6753
8349
  prev.destroy();
6754
8350
  globalThis.__LYNX_ANGULAR_APP_REF__ = void 0;
6755
- for (const key of Object.keys(__workletMap)) delete __workletMap[key];
6756
8351
  }
6757
- if (__MAIN_THREAD__ && !prev) await firstValueFrom(pageReady);
8352
+ await firstValueFrom(pageReady);
6758
8353
  const appRef = await bootstrapApplication$1(rootComponent, options);
6759
8354
  markFirstRenderComplete();
6760
8355
  globalThis.__LYNX_ANGULAR_APP_REF__ = appRef;
@@ -6764,9 +8359,9 @@ const bootstrapApplication = async (rootComponent, options) => {
6764
8359
  globalThis.__LYNX_HYDRATE_PAGE__ = void 0;
6765
8360
  globalThis.__LYNX_HYDRATE_QUEUE__ = void 0;
6766
8361
  }
6767
- if (__WEB__ && __MAIN_THREAD__ && !wasHydrating) setTimeout(() => __FlushElementTree(), 0);
8362
+ if (__WEB__ && !wasHydrating) setTimeout(() => __FlushElementTree(), 0);
6768
8363
  return appRef;
6769
8364
  };
6770
- export { BaseGesture, ComposedGesture, ContinuousGesture, FlingDirection, FlingGesture, Gesture, GestureState, GestureStateManager, GestureType, LYNX_ELEMENTS, LYNX_FORM_ACCESSORS, LongPressGesture, LynxAccessibility, LynxAnimation, LynxBlock, LynxBlurView, LynxCoverView, LynxDevTools, LynxErrorHandler, LynxExposure, LynxFont, LynxFor, LynxFrame, LynxGestureDetector, LynxGlobalData, LynxGlobalExposure, LynxIf, LynxImage, LynxInitData, LynxInlineTruncation, LynxInput, LynxInputValueAccessor, LynxList, LynxListItem, LynxLocale, LynxLocationStrategy, LynxLogger, LynxMainThread, LynxMainThreadEvent, LynxNativeModule, LynxOverlay, LynxPerformance, LynxPlatformLocation, LynxPortal, LynxRefresh, LynxRefreshHeader, LynxResourcePrefetch, LynxRouteReuseStrategy, LynxSafeArea, LynxScrollCoordinator, LynxScrollCoordinatorHeader, LynxScrollCoordinatorSlot, LynxScrollCoordinatorSlotDrag, LynxScrollCoordinatorToolbar, LynxScrollView, LynxSessionStorage, LynxSvg, LynxSystemInfo, LynxText, LynxTextMeasure, LynxTextarea, LynxTextareaValueAccessor, LynxTheme, LynxTitleBarView, LynxTransition, LynxTransitionGroup, LynxVideo, LynxView, LynxViewPager, LynxViewPagerItem, LynxWebView, MainThreadElement, MainThreadRef, PanGesture, PinchGesture, PortalRef, RotationGesture, SAFE_AREA_INSET_BOTTOM, SAFE_AREA_INSET_LEFT, SAFE_AREA_INSET_RIGHT, SAFE_AREA_INSET_TOP, TapGesture, backgroundFn, bootstrapApplication, createMainThreadRef, getLynxAppLocale, loadLazyBundle, mainThreadFn, provideLocale, provideRenderer, provideRouter, registerDataProcessors };
8365
+ export { BaseGesture, ComposedGesture, ContinuousGesture, FlingDirection, FlingGesture, Gesture, GestureState, GestureStateManager, GestureType, LYNX_ELEMENTS, LYNX_FORM_ACCESSORS, LongPressGesture, LynxAccessibility, LynxAccessibilitySettings, LynxAnimation, LynxBlock, LynxBlurView, LynxCoverView, LynxDevTools, LynxErrorHandler, LynxExposure, LynxFont, LynxFor, LynxFrame, LynxGestureDetector, LynxGlobalData, LynxGlobalExposure, LynxIf, LynxImage, LynxInitData, LynxInlineTruncation, LynxInput, LynxInputValueAccessor, LynxList, LynxListItem, LynxLocale, LynxLocationStrategy, LynxLogger, LynxMainThread, LynxMainThreadEvent, LynxNativeModule, LynxOverlay, LynxPerformance, LynxPlatformLocation, LynxPortal, LynxRefresh, LynxRefreshHeader, LynxResourcePrefetch, LynxRouteReuseStrategy, LynxRouterLinkActive, LynxSafeArea, LynxScrollCoordinator, LynxScrollCoordinatorHeader, LynxScrollCoordinatorSlot, LynxScrollCoordinatorSlotDrag, LynxScrollCoordinatorToolbar, LynxScrollView, LynxSessionStorage, LynxSvg, LynxSystemInfo, LynxText, LynxTextMeasure, LynxTextarea, LynxTextareaValueAccessor, LynxTheme, LynxTitleBarView, LynxTransition, LynxTransitionGroup, LynxVideo, LynxView, LynxViewPager, LynxViewPagerItem, LynxWebView, MainThreadElement, MainThreadRef, PanGesture, PinchGesture, PortalRef, RotationGesture, SAFE_AREA_INSET_BOTTOM, SAFE_AREA_INSET_LEFT, SAFE_AREA_INSET_RIGHT, SAFE_AREA_INSET_TOP, TapGesture, backgroundFn, bootstrapApplication, createMainThreadRef, getLynxAppLocale, loadLazyBundle, mainThreadFn, provideLocale, provideRenderer, provideRouter, registerDataProcessors, ɵhmrAccept, ɵstartBackgroundThread };
6771
8366
 
6772
8367
  //# sourceMappingURL=blotch-angular-lynx.mjs.map