npm package diff
Package: @forge/bridge
Versions: 5.0.1-next.0 - 5.1.0-next.1
File: package/out/router/router.js
Index: package/out/router/router.js
===================================================================
--- package/out/router/router.js
+++ package/out/router/router.js
@@ -2,9 +2,24 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.router = void 0;
const bridge_1 = require("../bridge");
const callBridge = (0, bridge_1.getCallBridge)();
-const navigate = async (location) => {
+const getUrl = async (location) => {
+ if (!(location === null || location === void 0 ? void 0 : location.target)) {
+ throw new Error('target is required for getUrl');
+ }
+ const url = await callBridge('getUrl', location);
+ if (!url) {
+ throw new Error('Failed to get URL');
+ }
+ try {
+ return new URL(url);
+ }
+ catch (error) {
+ throw new Error(`Failed to parse URL: ${url} (${error})`);
+ }
+};
+const navigate = (location) => {
if (typeof location === 'string') {
return callBridge('navigate', { url: location, type: 'same-tab' });
}
else {
@@ -13,9 +28,9 @@
}
return callBridge('navigate', { ...location, type: 'same-tab' });
}
};
-const open = async (location) => {
+const open = (location) => {
if (typeof location === 'string') {
return callBridge('navigate', { url: location, type: 'new-tab' });
}
else {
@@ -26,8 +41,9 @@
}
};
const reload = async () => callBridge('reload');
exports.router = {
+ getUrl,
navigate,
open,
reload
};