@forge/bridge 5.0.1-next.0 → 5.1.0-next.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/CHANGELOG.md +6 -0
- package/out/router/router.d.ts +3 -4
- package/out/router/router.d.ts.map +1 -1
- package/out/router/router.js +18 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/out/router/router.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { NavigationLocation } from './types';
|
|
2
|
-
declare type Navigate = (location: string | NavigationLocation) => Promise<void>;
|
|
3
2
|
export declare const router: {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
getUrl: (location: NavigationLocation) => Promise<URL | null>;
|
|
4
|
+
navigate: (location: string | NavigationLocation) => Promise<void>;
|
|
5
|
+
open: (location: string | NavigationLocation) => Promise<void>;
|
|
6
6
|
reload: () => Promise<void>;
|
|
7
7
|
};
|
|
8
|
-
export {};
|
|
9
8
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAoE7C,eAAO,MAAM,MAAM;uBA1Da,kBAAkB,KAAG,QAAQ,GAAG,GAAG,IAAI,CAAC;yBAuB5C,MAAM,GAAG,kBAAkB,KAAG,QAAQ,IAAI,CAAC;qBAiB/C,MAAM,GAAG,kBAAkB,KAAG,QAAQ,IAAI,CAAC;kBAgB/C,QAAQ,IAAI,CAAC;CAOhC,CAAC"}
|
package/out/router/router.js
CHANGED
|
@@ -3,7 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.router = void 0;
|
|
4
4
|
const bridge_1 = require("../bridge");
|
|
5
5
|
const callBridge = (0, bridge_1.getCallBridge)();
|
|
6
|
-
const
|
|
6
|
+
const getUrl = async (location) => {
|
|
7
|
+
if (!(location === null || location === void 0 ? void 0 : location.target)) {
|
|
8
|
+
throw new Error('target is required for getUrl');
|
|
9
|
+
}
|
|
10
|
+
const url = await callBridge('getUrl', location);
|
|
11
|
+
if (!url) {
|
|
12
|
+
throw new Error('Failed to get URL');
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return new URL(url);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw new Error(`Failed to parse URL: ${url} (${error})`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const navigate = (location) => {
|
|
7
22
|
if (typeof location === 'string') {
|
|
8
23
|
return callBridge('navigate', { url: location, type: 'same-tab' });
|
|
9
24
|
}
|
|
@@ -14,7 +29,7 @@ const navigate = async (location) => {
|
|
|
14
29
|
return callBridge('navigate', { ...location, type: 'same-tab' });
|
|
15
30
|
}
|
|
16
31
|
};
|
|
17
|
-
const open =
|
|
32
|
+
const open = (location) => {
|
|
18
33
|
if (typeof location === 'string') {
|
|
19
34
|
return callBridge('navigate', { url: location, type: 'new-tab' });
|
|
20
35
|
}
|
|
@@ -27,6 +42,7 @@ const open = async (location) => {
|
|
|
27
42
|
};
|
|
28
43
|
const reload = async () => callBridge('reload');
|
|
29
44
|
exports.router = {
|
|
45
|
+
getUrl,
|
|
30
46
|
navigate,
|
|
31
47
|
open,
|
|
32
48
|
reload
|