@blotch/angular-lynx 22.2.6 → 22.2.7

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,6 +1,6 @@
1
1
  import { n as GestureState, r as GestureType, t as FlingDirection } from "./blotch-angular-lynx-const-MkK6UdZ7.mjs";
2
2
  import * as i0 from "@angular/core";
3
- 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 { 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, reflectComponentType, signal, viewChild, ɵɵreplaceMetadata } from "@angular/core";
4
4
  import { ReplaySubject, Subject, firstValueFrom } from "rxjs";
5
5
  import { APP_BASE_HREF, IMAGE_CONFIG, Location, LocationStrategy, PlatformLocation, getLocaleId } from "@angular/common";
6
6
  import { NG_VALUE_ACCESSOR } from "@angular/forms";
@@ -58,6 +58,7 @@ const isUtf8Text = (contentType) => {
58
58
  const charset = /;\s*charset="?([^";]+)/.exec(type)?.[1];
59
59
  return TEXT_TYPE.test(type) && (charset === void 0 || /^utf-?8$/.test(charset));
60
60
  };
61
+ const canonicalName = (name) => name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("-");
61
62
  const decodeBody = (body) => {
62
63
  if (body === null) return void 0;
63
64
  if ("text" in body) return body.text;
@@ -74,15 +75,16 @@ const fetchForMainThread = async (id, request) => {
74
75
  const response = await fetchImpl(request.url, {
75
76
  ...request.options,
76
77
  method: request.method,
77
- headers: Object.fromEntries(request.headers),
78
+ headers: Object.fromEntries(request.headers.map(([name, value]) => [canonicalName(name), value])),
78
79
  body: decodeBody(request.body),
79
80
  signal: controller.signal
80
81
  });
81
82
  const headers = [];
82
83
  response.headers.forEach((value, name) => headers.push([name, value]));
83
84
  if (response.status === LYNX_FAILURE_STATUS && headers.length === 0) throw new TypeError(response.statusText || "Network request failed");
85
+ const contentType = headers.find(([name]) => name.toLowerCase() === "content-type")?.[1] ?? null;
84
86
  let body = null;
85
- 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())) };
87
+ if (!NULL_BODY_STATUSES.has(response.status)) body = isUtf8Text(contentType) ? { text: await response.text() } : { base64: bytesToBase64(new Uint8Array(await response.arrayBuffer())) };
86
88
  return {
87
89
  status: response.status,
88
90
  statusText: response.statusText,
@@ -239,6 +241,12 @@ const handlers = {
239
241
  if (typeof fn !== "function") throw new Error(`${kind === "native" ? "NativeModules" : "lynx.getJSModule"}: ${name}.${method} is not available`);
240
242
  return fn.apply(module, restoreFunctions(args));
241
243
  },
244
+ callNativeModuleAsync: (name, method, args) => new Promise((resolve) => {
245
+ const module = findModule("native", name);
246
+ const fn = module?.[method];
247
+ if (typeof fn !== "function") throw new Error(`NativeModules: ${name}.${method} is not available`);
248
+ fn.call(module, ...args, (result) => resolve(result));
249
+ }),
242
250
  registerJSModule: (name, module) => {
243
251
  lynxApi("registerModule")(name, restoreFunctions(module));
244
252
  },
@@ -5292,6 +5300,170 @@ i0.ɵɵngDeclareClassMetadata({
5292
5300
  args: [{ providedIn: "root" }]
5293
5301
  }]
5294
5302
  });
5303
+ var NoModuleError = class extends Error {};
5304
+ const nativeStore = (module) => {
5305
+ const call = async (method, args) => {
5306
+ let result;
5307
+ try {
5308
+ result = await callOnBackground("callNativeModuleAsync", module, method, args);
5309
+ } catch (error) {
5310
+ throw new NoModuleError(error.message);
5311
+ }
5312
+ if (result?.error !== void 0) throw new Error(result.error);
5313
+ return result?.value ?? null;
5314
+ };
5315
+ return {
5316
+ getItem: (key) => call("getItem", [key]),
5317
+ setItem: async (key, value) => {
5318
+ await call("setItem", [key, value]);
5319
+ },
5320
+ removeItem: async (key) => {
5321
+ await call("removeItem", [key]);
5322
+ },
5323
+ clear: async () => {
5324
+ await call("clear", []);
5325
+ }
5326
+ };
5327
+ };
5328
+ const browserStore = (storage, prefix) => ({
5329
+ getItem: async (key) => storage.getItem(prefix + key),
5330
+ setItem: async (key, value) => storage.setItem(prefix + key, value),
5331
+ removeItem: async (key) => storage.removeItem(prefix + key),
5332
+ clear: async () => {
5333
+ const keys = [];
5334
+ for (let i = 0; i < storage.length; i++) {
5335
+ const key = storage.key(i);
5336
+ if (key?.startsWith(prefix)) keys.push(key);
5337
+ }
5338
+ for (const key of keys) storage.removeItem(key);
5339
+ }
5340
+ });
5341
+ const memoryStore = () => {
5342
+ const values = /* @__PURE__ */ new Map();
5343
+ return {
5344
+ getItem: async (key) => values.get(key) ?? null,
5345
+ setItem: async (key, value) => {
5346
+ values.set(key, value);
5347
+ },
5348
+ removeItem: async (key) => {
5349
+ values.delete(key);
5350
+ },
5351
+ clear: async () => values.clear()
5352
+ };
5353
+ };
5354
+ const browserStorage = () => {
5355
+ if (typeof SystemInfo === "undefined" || SystemInfo.platform !== "web") return;
5356
+ try {
5357
+ return globalThis.localStorage;
5358
+ } catch {
5359
+ return;
5360
+ }
5361
+ };
5362
+ const decode = (raw) => {
5363
+ try {
5364
+ return JSON.parse(raw);
5365
+ } catch {
5366
+ return raw;
5367
+ }
5368
+ };
5369
+ var PersistentStorage = class {
5370
+ #native;
5371
+ #webPrefix;
5372
+ #memory = memoryStore();
5373
+ #hasModule = true;
5374
+ constructor(module, webPrefix) {
5375
+ this.#native = nativeStore(module);
5376
+ this.#webPrefix = webPrefix;
5377
+ }
5378
+ async getItem(key) {
5379
+ const raw = await this.#run((store) => store.getItem(key));
5380
+ return raw === null ? null : decode(raw);
5381
+ }
5382
+ async setItem(key, value) {
5383
+ const raw = JSON.stringify(value);
5384
+ if (raw === void 0) throw new TypeError(`Can't store a ${typeof value} under "${key}": values are stored as JSON.`);
5385
+ await this.#run((store) => store.setItem(key, raw));
5386
+ }
5387
+ async removeItem(key) {
5388
+ await this.#run((store) => store.removeItem(key));
5389
+ }
5390
+ async clear() {
5391
+ await this.#run((store) => store.clear());
5392
+ }
5393
+ async #run(operation) {
5394
+ const web = browserStorage();
5395
+ if (web) return operation(browserStore(web, this.#webPrefix));
5396
+ if (this.#hasModule) try {
5397
+ return await operation(this.#native);
5398
+ } catch (error) {
5399
+ if (!(error instanceof NoModuleError)) throw error;
5400
+ this.#hasModule = false;
5401
+ }
5402
+ return operation(this.#memory);
5403
+ }
5404
+ };
5405
+ var LynxLocalStorage = class LynxLocalStorage extends PersistentStorage {
5406
+ constructor() {
5407
+ super("AngularLynxLocalStorage", "angular-lynx:");
5408
+ }
5409
+ static ɵfac = i0.ɵɵngDeclareFactory({
5410
+ minVersion: "12.0.0",
5411
+ version: "22.2.1",
5412
+ ngImport: i0,
5413
+ type: LynxLocalStorage,
5414
+ deps: [],
5415
+ target: i0.ɵɵFactoryTarget.Injectable
5416
+ });
5417
+ static ɵprov = i0.ɵɵngDeclareInjectable({
5418
+ minVersion: "12.0.0",
5419
+ version: "22.2.1",
5420
+ ngImport: i0,
5421
+ type: LynxLocalStorage,
5422
+ providedIn: "root"
5423
+ });
5424
+ };
5425
+ i0.ɵɵngDeclareClassMetadata({
5426
+ minVersion: "12.0.0",
5427
+ version: "22.2.1",
5428
+ ngImport: i0,
5429
+ type: LynxLocalStorage,
5430
+ decorators: [{
5431
+ type: Injectable,
5432
+ args: [{ providedIn: "root" }]
5433
+ }],
5434
+ ctorParameters: () => []
5435
+ });
5436
+ var LynxSecureStorage = class LynxSecureStorage extends PersistentStorage {
5437
+ constructor() {
5438
+ super("AngularLynxSecureStorage", "angular-lynx-secure:");
5439
+ }
5440
+ static ɵfac = i0.ɵɵngDeclareFactory({
5441
+ minVersion: "12.0.0",
5442
+ version: "22.2.1",
5443
+ ngImport: i0,
5444
+ type: LynxSecureStorage,
5445
+ deps: [],
5446
+ target: i0.ɵɵFactoryTarget.Injectable
5447
+ });
5448
+ static ɵprov = i0.ɵɵngDeclareInjectable({
5449
+ minVersion: "12.0.0",
5450
+ version: "22.2.1",
5451
+ ngImport: i0,
5452
+ type: LynxSecureStorage,
5453
+ providedIn: "root"
5454
+ });
5455
+ };
5456
+ i0.ɵɵngDeclareClassMetadata({
5457
+ minVersion: "12.0.0",
5458
+ version: "22.2.1",
5459
+ ngImport: i0,
5460
+ type: LynxSecureStorage,
5461
+ decorators: [{
5462
+ type: Injectable,
5463
+ args: [{ providedIn: "root" }]
5464
+ }],
5465
+ ctorParameters: () => []
5466
+ });
5295
5467
  var LynxTextMeasure = class LynxTextMeasure {
5296
5468
  measure(text, options) {
5297
5469
  if (typeof lynx === "undefined" || typeof lynx.getTextInfo !== "function") throw new Error("lynx.getTextInfo is not available in this environment");
@@ -5923,6 +6095,14 @@ i0.ɵɵngDeclareClassMetadata({
5923
6095
  args: [{ providedIn: "root" }]
5924
6096
  }]
5925
6097
  });
6098
+ const hostElements = /* @__PURE__ */ new Map();
6099
+ const ELEMENT_SELECTOR = /^[a-z][\w-]*$/i;
6100
+ const registerHostElement = (component, element) => {
6101
+ const tags = (reflectComponentType(component)?.selector ?? "").split(",").map((part) => part.trim()).filter((part) => ELEMENT_SELECTOR.test(part));
6102
+ if (tags.length === 0) throw new Error(`registerHostElement: ${component.name} isn't a component with an element selector, such as 'app-title'.`);
6103
+ for (const tag of tags) hostElements.set(tag, element);
6104
+ };
6105
+ const hostElementOf = (tag) => hostElements.get(tag) ?? tag;
5926
6106
  const createListElement = (pageId) => {
5927
6107
  let listEl;
5928
6108
  const componentAtIndex = (listRef, listId, cellIndex, opId) => {
@@ -6000,7 +6180,8 @@ var LynxDocument = class {
6000
6180
  setPageElementRef(pageElement);
6001
6181
  return this.page;
6002
6182
  }
6003
- createElement(tag, value) {
6183
+ createElement(name, value) {
6184
+ const tag = hostElementOf(name);
6004
6185
  /* v8 ignore next */
6005
6186
  if (__PROFILE__) devStats.elementCreated++;
6006
6187
  scheduleSettleFlush();
@@ -6070,7 +6251,7 @@ var LynxHydrateDocument = class {
6070
6251
  if (!this.#isHydrating()) return this.#getFallback().createElement(tag, value);
6071
6252
  if (tag === "page") return this.#page;
6072
6253
  const el = this.#nextElement();
6073
- el.tagName = tag;
6254
+ el.tagName = hostElementOf(tag);
6074
6255
  return el;
6075
6256
  }
6076
6257
  createText(value) {
@@ -8611,6 +8792,6 @@ const bootstrapOnMainThread = async (rootComponent, options) => {
8611
8792
  if (__WEB__ && !wasHydrating) setTimeout(() => __FlushElementTree(), 0);
8612
8793
  return appRef;
8613
8794
  };
8614
- export { BaseGesture, ComposedGesture, ContinuousGesture, DYNAMIC_COLOR_ROLES, FlingDirection, FlingGesture, Gesture, GestureState, GestureStateManager, GestureType, LYNX_ELEMENTS, LYNX_FORM_ACCESSORS, LongPressGesture, LynxAccessibility, LynxAccessibilitySettings, LynxAccessibilityTraits, 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, LynxWebAuthSession, LynxWebView, MainThreadElement, MainThreadRef, PanGesture, PinchGesture, PortalRef, RotationGesture, SAFE_AREA_INSET_BOTTOM, SAFE_AREA_INSET_LEFT, SAFE_AREA_INSET_RIGHT, SAFE_AREA_INSET_TOP, TapGesture, WebAuthSessionError, backgroundFn, bootstrapApplication, createMainThreadRef, getLynxAppLocale, loadLazyBundle, mainThreadFn, provideLocale, provideRenderer, provideRouter, registerDataProcessors, ɵhmrAccept, ɵstartBackgroundThread };
8795
+ export { BaseGesture, ComposedGesture, ContinuousGesture, DYNAMIC_COLOR_ROLES, FlingDirection, FlingGesture, Gesture, GestureState, GestureStateManager, GestureType, LYNX_ELEMENTS, LYNX_FORM_ACCESSORS, LongPressGesture, LynxAccessibility, LynxAccessibilitySettings, LynxAccessibilityTraits, LynxAnimation, LynxBlock, LynxBlurView, LynxCoverView, LynxDevTools, LynxErrorHandler, LynxExposure, LynxFont, LynxFor, LynxFrame, LynxGestureDetector, LynxGlobalData, LynxGlobalExposure, LynxIf, LynxImage, LynxInitData, LynxInlineTruncation, LynxInput, LynxInputValueAccessor, LynxList, LynxListItem, LynxLocalStorage, LynxLocale, LynxLocationStrategy, LynxLogger, LynxMainThread, LynxMainThreadEvent, LynxNativeModule, LynxOverlay, LynxPerformance, LynxPlatformLocation, LynxPortal, LynxRefresh, LynxRefreshHeader, LynxResourcePrefetch, LynxRouteReuseStrategy, LynxRouterLinkActive, LynxSafeArea, LynxScrollCoordinator, LynxScrollCoordinatorHeader, LynxScrollCoordinatorSlot, LynxScrollCoordinatorSlotDrag, LynxScrollCoordinatorToolbar, LynxScrollView, LynxSecureStorage, LynxSessionStorage, LynxSvg, LynxSystemInfo, LynxText, LynxTextMeasure, LynxTextarea, LynxTextareaValueAccessor, LynxTheme, LynxTitleBarView, LynxTransition, LynxTransitionGroup, LynxVideo, LynxView, LynxViewPager, LynxViewPagerItem, LynxWebAuthSession, LynxWebView, MainThreadElement, MainThreadRef, PanGesture, PinchGesture, PortalRef, RotationGesture, SAFE_AREA_INSET_BOTTOM, SAFE_AREA_INSET_LEFT, SAFE_AREA_INSET_RIGHT, SAFE_AREA_INSET_TOP, TapGesture, WebAuthSessionError, backgroundFn, bootstrapApplication, createMainThreadRef, getLynxAppLocale, loadLazyBundle, mainThreadFn, provideLocale, provideRenderer, provideRouter, registerDataProcessors, registerHostElement, ɵhmrAccept, ɵstartBackgroundThread };
8615
8796
 
8616
8797
  //# sourceMappingURL=blotch-angular-lynx.mjs.map