@lingxia/bridge 0.9.0 → 0.11.1

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.
package/dist/es5/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export { LingXiaBridge, channel, initBridge, invoke, notify, stream, } from './bridge';
9
9
  export { isNativeError } from './invocation';
10
+ export { getDisplayLanguage } from './runtime-env';
10
11
  export { renderErrorUI, hasError, getErrorInfo } from './error';
11
12
  export { boot, bootWhenReady } from './boot';
12
13
  import { bootWhenReady } from './boot';
@@ -1,4 +1,12 @@
1
+ var _a;
1
2
  export var BRIDGE_CONFIG = (typeof window !== 'undefined' && window.__LX_BRIDGE_CFG) || {};
3
+ var displayLanguage = ((_a = BRIDGE_CONFIG.displayLanguage) === null || _a === void 0 ? void 0 : _a.trim()) || 'en-US';
4
+ if (typeof document !== 'undefined' && document.documentElement) {
5
+ document.documentElement.lang = displayLanguage;
6
+ }
7
+ export function getDisplayLanguage() {
8
+ return displayLanguage;
9
+ }
2
10
  export function getPlatformOS() {
3
11
  return BRIDGE_CONFIG.os || 'unknown';
4
12
  }
@@ -14,8 +22,29 @@ export function isAndroid() {
14
22
  export function isMacOS() {
15
23
  return BRIDGE_CONFIG.os === 'macOS';
16
24
  }
25
+ export function isWindows() {
26
+ return BRIDGE_CONFIG.os === 'Windows';
27
+ }
17
28
  export function isDesktop() {
18
- return isMacOS();
29
+ return isMacOS() || isWindows();
30
+ }
31
+ // iOS and macOS share the WKWebView transport, so features scoped to it (e.g.
32
+ // the streaming downstream) key off this rather than the two OS checks.
33
+ export function isApple() {
34
+ return isIOS() || isMacOS();
35
+ }
36
+ // True when attached to a `lingxia dev` session (the host sets `dev` in
37
+ // `__LX_BRIDGE_CFG`). Used to surface the bridge's own protocol/lifecycle trace
38
+ // only during development.
39
+ export function isDevSession() {
40
+ return BRIDGE_CONFIG.dev === true;
41
+ }
42
+ // True when running inside the LingXia Runner (the `lingxia dev` device
43
+ // simulator), which the host marks in `__LX_BRIDGE_CFG`. Unlike a real host
44
+ // app in dev mode, the Runner lacks host-declared surfaces such as the
45
+ // terminal — apps read this to hide those affordances.
46
+ export function isRunner() {
47
+ return BRIDGE_CONFIG.runner === true;
19
48
  }
20
49
  export function getCommunicationMethod() {
21
50
  var _a, _b;
@@ -23,6 +52,8 @@ export function getCommunicationMethod() {
23
52
  return 'webkit';
24
53
  if (BRIDGE_CONFIG.os === 'Harmony')
25
54
  return 'messageport';
55
+ if (BRIDGE_CONFIG.os === 'Windows')
56
+ return 'webmessage';
26
57
  if (BRIDGE_CONFIG.os === 'Android') {
27
58
  if ((_b = (_a = window.LingXiaProxy) === null || _a === void 0 ? void 0 : _a.supportsMessagePort) === null || _b === void 0 ? void 0 : _b.call(_a))
28
59
  return 'messageport';
@@ -1,9 +1,9 @@
1
- import { getPlatformOS } from '../runtime-env';
1
+ import { isDesktop } from '../runtime-env';
2
2
  var ANIMATION_MS = 300;
3
3
  var STYLE_ID = 'lx-action-sheet-style';
4
4
  var activeSheet = null;
5
5
  function isDesktopMode() {
6
- return getPlatformOS() === 'macOS';
6
+ return isDesktop();
7
7
  }
8
8
  function ensureActionSheetStyle() {
9
9
  if (document.getElementById(STYLE_ID))
package/dist/index.d.ts CHANGED
@@ -8,5 +8,6 @@
8
8
  export type { BridgeConfig, CallOptions, ChannelCloseEvent, ChannelOptions, ChannelOpenOptions, BridgeErrorCode, ChannelEventName, DataSubscriber, ErrorInfo, LingXiaBridgeInterface, LxChannel, LxBridgeError, LxMethod, LxMethodParams, LxMethodResult, LxMethodStreamData, LxStream, NativeComponentMessage, NativeChannel, NativeError, NativeStream, NotifyOptions, InvokeOptions, StateInfo, StreamCallOptions, StreamOptions, StreamEventName, } from './types';
9
9
  export { LingXiaBridge, channel, initBridge, invoke, notify, stream, } from './bridge';
10
10
  export { isNativeError } from './invocation';
11
+ export { getDisplayLanguage } from './runtime-env';
11
12
  export { renderErrorUI, hasError, getErrorInfo } from './error';
12
13
  export { boot, bootWhenReady } from './boot';
@@ -1,11 +1,16 @@
1
1
  import type { BridgeConfig } from './types';
2
- export type CommunicationMethod = 'messageport' | 'jsinterface' | 'webkit' | 'unknown';
2
+ export type CommunicationMethod = 'messageport' | 'jsinterface' | 'webmessage' | 'webkit' | 'unknown';
3
3
  export type PlatformOS = NonNullable<BridgeConfig['os']> | 'unknown';
4
4
  export declare const BRIDGE_CONFIG: BridgeConfig;
5
+ export declare function getDisplayLanguage(): string;
5
6
  export declare function getPlatformOS(): PlatformOS;
6
7
  export declare function isHarmony(): boolean;
7
8
  export declare function isIOS(): boolean;
8
9
  export declare function isAndroid(): boolean;
9
10
  export declare function isMacOS(): boolean;
11
+ export declare function isWindows(): boolean;
10
12
  export declare function isDesktop(): boolean;
13
+ export declare function isApple(): boolean;
14
+ export declare function isDevSession(): boolean;
15
+ export declare function isRunner(): boolean;
11
16
  export declare function getCommunicationMethod(): CommunicationMethod;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  export interface BridgeConfig {
2
- os?: 'Harmony' | 'iOS' | 'Android' | 'macOS';
2
+ os?: 'Harmony' | 'iOS' | 'Android' | 'macOS' | 'Windows';
3
+ /** Effective host display language; distinct from the raw system locale. */
4
+ displayLanguage?: string;
3
5
  nonce?: string;
4
6
  appleDownstreamURL?: string;
7
+ dev?: boolean;
8
+ runner?: boolean;
5
9
  }
6
10
  export interface RuntimeConfig {
7
11
  error?: ErrorInfo;
@@ -159,7 +163,10 @@ export interface LingXiaBridgeInterface {
159
163
  isIOS(): boolean;
160
164
  isAndroid(): boolean;
161
165
  isMacOS(): boolean;
166
+ isWindows(): boolean;
162
167
  isDesktop(): boolean;
168
+ isApple(): boolean;
169
+ isRunner(): boolean;
163
170
  getOS(): string;
164
171
  };
165
172
  dom: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxia/bridge",
3
- "version": "0.9.0",
3
+ "version": "0.11.1",
4
4
  "private": false,
5
5
  "description": "LingXia Web Runtime - Bridge, boot, and error handling for WebView",
6
6
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "build:modules:es5": "tsc -p tsconfig.modules.legacy.json",
41
41
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
42
42
  "dev": "rolldown -c -w",
43
- "clean": "rm -rf dist",
43
+ "clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
44
44
  "prepublishOnly": "npm run build"
45
45
  },
46
46
  "devDependencies": {