@wvb/bridge 0.1.0-next.e459de3 → 0.1.0-next.f941058
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/CHANGELOG.md +3 -2
- package/dist/{index-B2ggQzrN.d.cts → index-eeBgJJSy.d.cts} +37 -1
- package/dist/{index-B2ggQzrN.d.ts → index-eeBgJJSy.d.ts} +37 -1
- package/dist/index.cjs +69 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +66 -8
- package/dist/{platform-mock-Dh3dBF3P.js → platform-mock-Bvaw9qjP.js} +6 -6
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/{platform-mock-BmiQzf2l.cjs → platform-mock-DrAsRJ91.cjs} +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## bridge v0.1.0-next.
|
|
3
|
+
## bridge v0.1.0-next.f941058
|
|
4
4
|
|
|
5
|
-
This release includes packages: [`@wvb/bridge`](https://www.npmjs.com/package/@wvb/bridge/v/0.1.0-next.
|
|
5
|
+
This release includes packages: [`@wvb/bridge`](https://www.npmjs.com/package/@wvb/bridge/v/0.1.0-next.f941058)
|
|
6
6
|
|
|
7
|
+
- feat(bridge,electron,tauri): remove legacy invokes to unify in `@wvb/bridge` and add `BridgeError` (#178) (f3735bb)
|
|
7
8
|
- feat(bridge): impl universal bridge (#171) (e4cfd0d)
|
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
//#region src/error.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Bridge error data that respond from native.
|
|
4
|
+
*/
|
|
5
|
+
interface BridgeErrorData {
|
|
6
|
+
code?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
declare const BridgeErrorCode: {
|
|
10
|
+
/** `params` was missing or had the wrong shape/type. */readonly InvalidParams: "invalid_params"; /** A `remote.*` command was invoked but no remote is configured. */
|
|
11
|
+
readonly RemoteNotInitialized: "remote_not_initialized"; /** An `updater.*` command was invoked but no updater is configured. */
|
|
12
|
+
readonly UpdaterNotInitialized: "updater_not_initialized"; /** No handler is registered for the requested command name. */
|
|
13
|
+
readonly HandlerNotFound: "handler_not_found"; /** The handler returned a value that is not JSON-encodable. */
|
|
14
|
+
readonly UnencodableResult: "unencodable_result";
|
|
15
|
+
};
|
|
16
|
+
type BridgeErrorCode = (typeof BridgeErrorCode)[keyof typeof BridgeErrorCode];
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown by `@wvb/bridge` when an `invoke()` command rejects, regardless of
|
|
19
|
+
* platform.
|
|
20
|
+
*/
|
|
21
|
+
declare class BridgeError extends Error {
|
|
22
|
+
override readonly name = "BridgeError";
|
|
23
|
+
readonly code?: string;
|
|
24
|
+
static of(code: BridgeErrorCode | string, message?: string): BridgeError;
|
|
25
|
+
static from(value: unknown): BridgeError;
|
|
26
|
+
constructor(data: BridgeErrorData);
|
|
27
|
+
}
|
|
28
|
+
declare function isBridgeError(e: unknown): e is BridgeError;
|
|
29
|
+
declare function isBridgeErrorData(value: unknown): value is BridgeErrorData;
|
|
30
|
+
//#endregion
|
|
1
31
|
//#region src/invoke.d.ts
|
|
2
32
|
interface InvokeParams {
|
|
3
33
|
[key: string | number]: any;
|
|
4
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Invokes a native bridge command and resolves its result.
|
|
37
|
+
* Before using the bridge, make sure native supports webview-bundle.
|
|
38
|
+
*
|
|
39
|
+
* Throws a {@link BridgeError} on failure.
|
|
40
|
+
*/
|
|
5
41
|
declare function invoke<T = unknown>(name: string, params?: InvokeParams): Promise<T>;
|
|
6
42
|
//#endregion
|
|
7
43
|
//#region src/platform.d.ts
|
|
@@ -159,4 +195,4 @@ interface UpdaterApi {
|
|
|
159
195
|
}
|
|
160
196
|
declare const updater: UpdaterApi;
|
|
161
197
|
//#endregion
|
|
162
|
-
export { InvokeParams as _, BundleSourceType as a, ListBundleManifestItem as c, ListRemoteBundleInfo as d, RemoteApi as f, platform as g, PlatformType as h, BundleManifestMetadata as i, SourceApi as l, remote as m, UpdaterApi as n, BundleSourceVersion as o, RemoteBundleInfo as p, updater as r, ListBundleItem as s, BundleUpdateInfo as t, source as u, invoke as v };
|
|
198
|
+
export { isBridgeErrorData as C, isBridgeError as S, InvokeParams as _, BundleSourceType as a, BridgeErrorCode as b, ListBundleManifestItem as c, ListRemoteBundleInfo as d, RemoteApi as f, platform as g, PlatformType as h, BundleManifestMetadata as i, SourceApi as l, remote as m, UpdaterApi as n, BundleSourceVersion as o, RemoteBundleInfo as p, updater as r, ListBundleItem as s, BundleUpdateInfo as t, source as u, invoke as v, BridgeErrorData as x, BridgeError as y };
|
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
//#region src/error.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Bridge error data that respond from native.
|
|
4
|
+
*/
|
|
5
|
+
interface BridgeErrorData {
|
|
6
|
+
code?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
declare const BridgeErrorCode: {
|
|
10
|
+
/** `params` was missing or had the wrong shape/type. */readonly InvalidParams: "invalid_params"; /** A `remote.*` command was invoked but no remote is configured. */
|
|
11
|
+
readonly RemoteNotInitialized: "remote_not_initialized"; /** An `updater.*` command was invoked but no updater is configured. */
|
|
12
|
+
readonly UpdaterNotInitialized: "updater_not_initialized"; /** No handler is registered for the requested command name. */
|
|
13
|
+
readonly HandlerNotFound: "handler_not_found"; /** The handler returned a value that is not JSON-encodable. */
|
|
14
|
+
readonly UnencodableResult: "unencodable_result";
|
|
15
|
+
};
|
|
16
|
+
type BridgeErrorCode = (typeof BridgeErrorCode)[keyof typeof BridgeErrorCode];
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown by `@wvb/bridge` when an `invoke()` command rejects, regardless of
|
|
19
|
+
* platform.
|
|
20
|
+
*/
|
|
21
|
+
declare class BridgeError extends Error {
|
|
22
|
+
override readonly name = "BridgeError";
|
|
23
|
+
readonly code?: string;
|
|
24
|
+
static of(code: BridgeErrorCode | string, message?: string): BridgeError;
|
|
25
|
+
static from(value: unknown): BridgeError;
|
|
26
|
+
constructor(data: BridgeErrorData);
|
|
27
|
+
}
|
|
28
|
+
declare function isBridgeError(e: unknown): e is BridgeError;
|
|
29
|
+
declare function isBridgeErrorData(value: unknown): value is BridgeErrorData;
|
|
30
|
+
//#endregion
|
|
1
31
|
//#region src/invoke.d.ts
|
|
2
32
|
interface InvokeParams {
|
|
3
33
|
[key: string | number]: any;
|
|
4
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Invokes a native bridge command and resolves its result.
|
|
37
|
+
* Before using the bridge, make sure native supports webview-bundle.
|
|
38
|
+
*
|
|
39
|
+
* Throws a {@link BridgeError} on failure.
|
|
40
|
+
*/
|
|
5
41
|
declare function invoke<T = unknown>(name: string, params?: InvokeParams): Promise<T>;
|
|
6
42
|
//#endregion
|
|
7
43
|
//#region src/platform.d.ts
|
|
@@ -159,4 +195,4 @@ interface UpdaterApi {
|
|
|
159
195
|
}
|
|
160
196
|
declare const updater: UpdaterApi;
|
|
161
197
|
//#endregion
|
|
162
|
-
export { InvokeParams as _, BundleSourceType as a, ListBundleManifestItem as c, ListRemoteBundleInfo as d, RemoteApi as f, platform as g, PlatformType as h, BundleManifestMetadata as i, SourceApi as l, remote as m, UpdaterApi as n, BundleSourceVersion as o, RemoteBundleInfo as p, updater as r, ListBundleItem as s, BundleUpdateInfo as t, source as u, invoke as v };
|
|
198
|
+
export { isBridgeErrorData as C, isBridgeError as S, InvokeParams as _, BundleSourceType as a, BridgeErrorCode as b, ListBundleManifestItem as c, ListRemoteBundleInfo as d, RemoteApi as f, platform as g, PlatformType as h, BundleManifestMetadata as i, SourceApi as l, remote as m, UpdaterApi as n, BundleSourceVersion as o, RemoteBundleInfo as p, updater as r, ListBundleItem as s, BundleUpdateInfo as t, source as u, invoke as v, BridgeErrorData as x, BridgeError as y };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_platform_mock = require("./platform-mock-
|
|
2
|
+
const require_platform_mock = require("./platform-mock-DrAsRJ91.cjs");
|
|
3
3
|
let _tauri_apps_api_core = require("@tauri-apps/api/core");
|
|
4
|
+
//#region src/error.ts
|
|
5
|
+
const BridgeErrorCode = {
|
|
6
|
+
/** `params` was missing or had the wrong shape/type. */
|
|
7
|
+
InvalidParams: "invalid_params",
|
|
8
|
+
/** A `remote.*` command was invoked but no remote is configured. */
|
|
9
|
+
RemoteNotInitialized: "remote_not_initialized",
|
|
10
|
+
/** An `updater.*` command was invoked but no updater is configured. */
|
|
11
|
+
UpdaterNotInitialized: "updater_not_initialized",
|
|
12
|
+
/** No handler is registered for the requested command name. */
|
|
13
|
+
HandlerNotFound: "handler_not_found",
|
|
14
|
+
/** The handler returned a value that is not JSON-encodable. */
|
|
15
|
+
UnencodableResult: "unencodable_result"
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown by `@wvb/bridge` when an `invoke()` command rejects, regardless of
|
|
19
|
+
* platform.
|
|
20
|
+
*/
|
|
21
|
+
var BridgeError = class BridgeError extends Error {
|
|
22
|
+
static of(code, message = "") {
|
|
23
|
+
return new BridgeError({
|
|
24
|
+
code,
|
|
25
|
+
message
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
static from(value) {
|
|
29
|
+
if (value instanceof BridgeError) return value;
|
|
30
|
+
if (isBridgeErrorData(value)) return new BridgeError(value);
|
|
31
|
+
if (value instanceof Error) return new BridgeError({ message: value.message });
|
|
32
|
+
if (typeof value === "string") return new BridgeError({ message: value });
|
|
33
|
+
return new BridgeError({ message: "unknown bridge error" });
|
|
34
|
+
}
|
|
35
|
+
constructor(data) {
|
|
36
|
+
super(data.message);
|
|
37
|
+
require_platform_mock._defineProperty(this, "name", "BridgeError");
|
|
38
|
+
require_platform_mock._defineProperty(this, "code", void 0);
|
|
39
|
+
this.code = data.code;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
function isBridgeError(e) {
|
|
43
|
+
return e != null && typeof e === "object" && "name" in e && e.name === "BridgeError";
|
|
44
|
+
}
|
|
45
|
+
function isBridgeErrorData(value) {
|
|
46
|
+
if (typeof value !== "object" || value === null) return false;
|
|
47
|
+
const data = value;
|
|
48
|
+
return typeof data.message === "string" && (data.code === void 0 || typeof data.code === "string");
|
|
49
|
+
}
|
|
50
|
+
function unknownPlatform() {
|
|
51
|
+
throw new Error("Unknown platform. Make sure native webview supports webview-bundle.");
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
4
54
|
//#region src/callback.ts
|
|
5
55
|
var CallbackBag = class {
|
|
6
56
|
constructor() {
|
|
@@ -43,11 +93,6 @@ function generateId() {
|
|
|
43
93
|
return id;
|
|
44
94
|
}
|
|
45
95
|
//#endregion
|
|
46
|
-
//#region src/error.ts
|
|
47
|
-
function unknownPlatform() {
|
|
48
|
-
throw new Error("Unknown platform. Make sure native webview supports webview-bundle.");
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
96
|
//#region src/platform.ts
|
|
52
97
|
function isElectron() {
|
|
53
98
|
return require_platform_mock.getWindow()?.wvbElectron != null;
|
|
@@ -90,7 +135,20 @@ function snakeCase(str) {
|
|
|
90
135
|
}
|
|
91
136
|
//#endregion
|
|
92
137
|
//#region src/invoke.ts
|
|
93
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Invokes a native bridge command and resolves its result.
|
|
140
|
+
* Before using the bridge, make sure native supports webview-bundle.
|
|
141
|
+
*
|
|
142
|
+
* Throws a {@link BridgeError} on failure.
|
|
143
|
+
*/
|
|
144
|
+
async function invoke(name, params) {
|
|
145
|
+
try {
|
|
146
|
+
return await invokeInner(name, params);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw BridgeError.from(error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function invokeInner(name, params) {
|
|
94
152
|
const mock = require_platform_mock.getWindow()[require_platform_mock.INVOKE_MOCK_KEY];
|
|
95
153
|
if (mock != null) return mock(name, params);
|
|
96
154
|
switch (platform.type) {
|
|
@@ -271,7 +329,11 @@ const updater = {
|
|
|
271
329
|
install
|
|
272
330
|
};
|
|
273
331
|
//#endregion
|
|
332
|
+
exports.BridgeError = BridgeError;
|
|
333
|
+
exports.BridgeErrorCode = BridgeErrorCode;
|
|
274
334
|
exports.invoke = invoke;
|
|
335
|
+
exports.isBridgeError = isBridgeError;
|
|
336
|
+
exports.isBridgeErrorData = isBridgeErrorData;
|
|
275
337
|
exports.platform = platform;
|
|
276
338
|
exports.remote = remote;
|
|
277
339
|
exports.source = source;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as InvokeParams, a as BundleSourceType, c as ListBundleManifestItem, d as ListRemoteBundleInfo, f as RemoteApi, g as platform, h as PlatformType, i as BundleManifestMetadata, l as SourceApi, m as remote, n as UpdaterApi, o as BundleSourceVersion, p as RemoteBundleInfo, r as updater, s as ListBundleItem, t as BundleUpdateInfo, u as source, v as invoke } from "./index-
|
|
2
|
-
export { type BundleManifestMetadata, type BundleSourceType, type BundleSourceVersion, type BundleUpdateInfo, type InvokeParams, type ListBundleItem, type ListBundleManifestItem, type ListRemoteBundleInfo, type PlatformType, type RemoteApi, type RemoteBundleInfo, type SourceApi, type UpdaterApi, invoke, platform, remote, source, updater };
|
|
1
|
+
import { C as isBridgeErrorData, S as isBridgeError, _ as InvokeParams, a as BundleSourceType, b as BridgeErrorCode, c as ListBundleManifestItem, d as ListRemoteBundleInfo, f as RemoteApi, g as platform, h as PlatformType, i as BundleManifestMetadata, l as SourceApi, m as remote, n as UpdaterApi, o as BundleSourceVersion, p as RemoteBundleInfo, r as updater, s as ListBundleItem, t as BundleUpdateInfo, u as source, v as invoke, x as BridgeErrorData, y as BridgeError } from "./index-eeBgJJSy.cjs";
|
|
2
|
+
export { BridgeError, BridgeErrorCode, type BridgeErrorData, type BundleManifestMetadata, type BundleSourceType, type BundleSourceVersion, type BundleUpdateInfo, type InvokeParams, type ListBundleItem, type ListBundleManifestItem, type ListRemoteBundleInfo, type PlatformType, type RemoteApi, type RemoteBundleInfo, type SourceApi, type UpdaterApi, invoke, isBridgeError, isBridgeErrorData, platform, remote, source, updater };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as InvokeParams, a as BundleSourceType, c as ListBundleManifestItem, d as ListRemoteBundleInfo, f as RemoteApi, g as platform, h as PlatformType, i as BundleManifestMetadata, l as SourceApi, m as remote, n as UpdaterApi, o as BundleSourceVersion, p as RemoteBundleInfo, r as updater, s as ListBundleItem, t as BundleUpdateInfo, u as source, v as invoke } from "./index-
|
|
2
|
-
export { type BundleManifestMetadata, type BundleSourceType, type BundleSourceVersion, type BundleUpdateInfo, type InvokeParams, type ListBundleItem, type ListBundleManifestItem, type ListRemoteBundleInfo, type PlatformType, type RemoteApi, type RemoteBundleInfo, type SourceApi, type UpdaterApi, invoke, platform, remote, source, updater };
|
|
1
|
+
import { C as isBridgeErrorData, S as isBridgeError, _ as InvokeParams, a as BundleSourceType, b as BridgeErrorCode, c as ListBundleManifestItem, d as ListRemoteBundleInfo, f as RemoteApi, g as platform, h as PlatformType, i as BundleManifestMetadata, l as SourceApi, m as remote, n as UpdaterApi, o as BundleSourceVersion, p as RemoteBundleInfo, r as updater, s as ListBundleItem, t as BundleUpdateInfo, u as source, v as invoke, x as BridgeErrorData, y as BridgeError } from "./index-eeBgJJSy.js";
|
|
2
|
+
export { BridgeError, BridgeErrorCode, type BridgeErrorData, type BundleManifestMetadata, type BundleSourceType, type BundleSourceVersion, type BundleUpdateInfo, type InvokeParams, type ListBundleItem, type ListBundleManifestItem, type ListRemoteBundleInfo, type PlatformType, type RemoteApi, type RemoteBundleInfo, type SourceApi, type UpdaterApi, invoke, isBridgeError, isBridgeErrorData, platform, remote, source, updater };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
|
-
import { i as
|
|
1
|
+
import { i as _defineProperty, n as INVOKE_MOCK_KEY, r as getWindow, t as PLATFORM_MOCK_KEY } from "./platform-mock-Bvaw9qjP.js";
|
|
2
2
|
import { invoke as invoke$1, isTauri } from "@tauri-apps/api/core";
|
|
3
|
+
//#region src/error.ts
|
|
4
|
+
const BridgeErrorCode = {
|
|
5
|
+
/** `params` was missing or had the wrong shape/type. */
|
|
6
|
+
InvalidParams: "invalid_params",
|
|
7
|
+
/** A `remote.*` command was invoked but no remote is configured. */
|
|
8
|
+
RemoteNotInitialized: "remote_not_initialized",
|
|
9
|
+
/** An `updater.*` command was invoked but no updater is configured. */
|
|
10
|
+
UpdaterNotInitialized: "updater_not_initialized",
|
|
11
|
+
/** No handler is registered for the requested command name. */
|
|
12
|
+
HandlerNotFound: "handler_not_found",
|
|
13
|
+
/** The handler returned a value that is not JSON-encodable. */
|
|
14
|
+
UnencodableResult: "unencodable_result"
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown by `@wvb/bridge` when an `invoke()` command rejects, regardless of
|
|
18
|
+
* platform.
|
|
19
|
+
*/
|
|
20
|
+
var BridgeError = class BridgeError extends Error {
|
|
21
|
+
static of(code, message = "") {
|
|
22
|
+
return new BridgeError({
|
|
23
|
+
code,
|
|
24
|
+
message
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
static from(value) {
|
|
28
|
+
if (value instanceof BridgeError) return value;
|
|
29
|
+
if (isBridgeErrorData(value)) return new BridgeError(value);
|
|
30
|
+
if (value instanceof Error) return new BridgeError({ message: value.message });
|
|
31
|
+
if (typeof value === "string") return new BridgeError({ message: value });
|
|
32
|
+
return new BridgeError({ message: "unknown bridge error" });
|
|
33
|
+
}
|
|
34
|
+
constructor(data) {
|
|
35
|
+
super(data.message);
|
|
36
|
+
_defineProperty(this, "name", "BridgeError");
|
|
37
|
+
_defineProperty(this, "code", void 0);
|
|
38
|
+
this.code = data.code;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function isBridgeError(e) {
|
|
42
|
+
return e != null && typeof e === "object" && "name" in e && e.name === "BridgeError";
|
|
43
|
+
}
|
|
44
|
+
function isBridgeErrorData(value) {
|
|
45
|
+
if (typeof value !== "object" || value === null) return false;
|
|
46
|
+
const data = value;
|
|
47
|
+
return typeof data.message === "string" && (data.code === void 0 || typeof data.code === "string");
|
|
48
|
+
}
|
|
49
|
+
function unknownPlatform() {
|
|
50
|
+
throw new Error("Unknown platform. Make sure native webview supports webview-bundle.");
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
3
53
|
//#region src/callback.ts
|
|
4
54
|
var CallbackBag = class {
|
|
5
55
|
constructor() {
|
|
@@ -42,11 +92,6 @@ function generateId() {
|
|
|
42
92
|
return id;
|
|
43
93
|
}
|
|
44
94
|
//#endregion
|
|
45
|
-
//#region src/error.ts
|
|
46
|
-
function unknownPlatform() {
|
|
47
|
-
throw new Error("Unknown platform. Make sure native webview supports webview-bundle.");
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
95
|
//#region src/platform.ts
|
|
51
96
|
function isElectron() {
|
|
52
97
|
return getWindow()?.wvbElectron != null;
|
|
@@ -89,7 +134,20 @@ function snakeCase(str) {
|
|
|
89
134
|
}
|
|
90
135
|
//#endregion
|
|
91
136
|
//#region src/invoke.ts
|
|
92
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Invokes a native bridge command and resolves its result.
|
|
139
|
+
* Before using the bridge, make sure native supports webview-bundle.
|
|
140
|
+
*
|
|
141
|
+
* Throws a {@link BridgeError} on failure.
|
|
142
|
+
*/
|
|
143
|
+
async function invoke(name, params) {
|
|
144
|
+
try {
|
|
145
|
+
return await invokeInner(name, params);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
throw BridgeError.from(error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function invokeInner(name, params) {
|
|
93
151
|
const mock = getWindow()[INVOKE_MOCK_KEY];
|
|
94
152
|
if (mock != null) return mock(name, params);
|
|
95
153
|
switch (platform.type) {
|
|
@@ -270,4 +328,4 @@ const updater = {
|
|
|
270
328
|
install
|
|
271
329
|
};
|
|
272
330
|
//#endregion
|
|
273
|
-
export { invoke, platform, remote, source, updater };
|
|
331
|
+
export { BridgeError, BridgeErrorCode, invoke, isBridgeError, isBridgeErrorData, platform, remote, source, updater };
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
//#region src/window.ts
|
|
2
|
-
function getWindow() {
|
|
3
|
-
return globalThis || window;
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
1
|
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
7
2
|
function _typeof(o) {
|
|
8
3
|
"@babel/helpers - typeof";
|
|
@@ -41,10 +36,15 @@ function _defineProperty(e, r, t) {
|
|
|
41
36
|
}) : e[r] = t, e;
|
|
42
37
|
}
|
|
43
38
|
//#endregion
|
|
39
|
+
//#region src/window.ts
|
|
40
|
+
function getWindow() {
|
|
41
|
+
return globalThis || window;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
44
|
//#region src/invoke-mock.ts
|
|
45
45
|
const INVOKE_MOCK_KEY = "__wvb_invoke_mock__";
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/platform-mock.ts
|
|
48
48
|
const PLATFORM_MOCK_KEY = "__wvb_platform_mock__";
|
|
49
49
|
//#endregion
|
|
50
|
-
export {
|
|
50
|
+
export { _defineProperty as i, INVOKE_MOCK_KEY as n, getWindow as r, PLATFORM_MOCK_KEY as t };
|
package/dist/testing/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_platform_mock = require("../platform-mock-
|
|
2
|
+
const require_platform_mock = require("../platform-mock-DrAsRJ91.cjs");
|
|
3
3
|
//#region src/testing/mock.ts
|
|
4
4
|
const store = /* @__PURE__ */ new Map();
|
|
5
5
|
function ensureMocked() {
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as RemoteApi, h as PlatformType, l as SourceApi, n as UpdaterApi } from "../index-
|
|
1
|
+
import { f as RemoteApi, h as PlatformType, l as SourceApi, n as UpdaterApi } from "../index-eeBgJJSy.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/testing/mock.d.ts
|
|
4
4
|
interface MockInvoke extends Disposable {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as RemoteApi, h as PlatformType, l as SourceApi, n as UpdaterApi } from "../index-
|
|
1
|
+
import { f as RemoteApi, h as PlatformType, l as SourceApi, n as UpdaterApi } from "../index-eeBgJJSy.js";
|
|
2
2
|
|
|
3
3
|
//#region src/testing/mock.d.ts
|
|
4
4
|
interface MockInvoke extends Disposable {
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as
|
|
1
|
+
import { i as _defineProperty, n as INVOKE_MOCK_KEY, r as getWindow, t as PLATFORM_MOCK_KEY } from "../platform-mock-Bvaw9qjP.js";
|
|
2
2
|
//#region src/testing/mock.ts
|
|
3
3
|
const store = /* @__PURE__ */ new Map();
|
|
4
4
|
function ensureMocked() {
|
package/package.json
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
//#region src/window.ts
|
|
2
|
-
function getWindow() {
|
|
3
|
-
return globalThis || window;
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
1
|
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
7
2
|
function _typeof(o) {
|
|
8
3
|
"@babel/helpers - typeof";
|
|
@@ -41,6 +36,11 @@ function _defineProperty(e, r, t) {
|
|
|
41
36
|
}) : e[r] = t, e;
|
|
42
37
|
}
|
|
43
38
|
//#endregion
|
|
39
|
+
//#region src/window.ts
|
|
40
|
+
function getWindow() {
|
|
41
|
+
return globalThis || window;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
44
|
//#region src/invoke-mock.ts
|
|
45
45
|
const INVOKE_MOCK_KEY = "__wvb_invoke_mock__";
|
|
46
46
|
//#endregion
|