@akinon/ui-shell-dev 1.6.28 → 1.7.0

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/index.html CHANGED
@@ -24,7 +24,7 @@
24
24
  box-sizing: border-box;
25
25
  }
26
26
  </style>
27
- <script type="module" crossorigin src="/assets/index-CKAduHRb.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-ZjGUam1u.js"></script>
28
28
  <link rel="stylesheet" crossorigin href="/assets/index-CqHg0o1i.css">
29
29
  </head>
30
30
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-shell-dev",
3
- "version": "1.6.28",
3
+ "version": "1.7.0",
4
4
  "private": false,
5
5
  "description": "Development shell application for Akinon UI Protocol plugins",
6
6
  "type": "module",
@@ -21,14 +21,14 @@
21
21
  "react-dom": "*",
22
22
  "react-router-dom": "^6.28.0",
23
23
  "vite": "*",
24
- "@akinon/app-shell": "1.5.8",
24
+ "@akinon/ui-react": "1.6.7",
25
25
  "@akinon/fonts-jost-variable": "2.1.8",
26
+ "@akinon/app-shell": "1.6.0",
26
27
  "@akinon/icons": "1.5.0",
27
- "@akinon/ui-react": "1.6.7",
28
- "@akinon/ui-utils": "1.3.1",
28
+ "@akinon/ui-hooks": "1.1.8",
29
29
  "@akinon/akidate": "1.2.7",
30
30
  "@akinon/akilocale": "1.2.8",
31
- "@akinon/ui-hooks": "1.1.8"
31
+ "@akinon/ui-utils": "1.3.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/cors": "^2.8.17",
package/src/providers.tsx CHANGED
@@ -1,6 +1,10 @@
1
1
  import { useTranslation } from '@akinon/akilocale/react';
2
2
  import type { ApplicationActions, RegisteredApp } from '@akinon/app-shell';
3
- import { AppShellProvider, type ShellNavigation } from '@akinon/app-shell';
3
+ import {
4
+ AppShellProvider,
5
+ type ShellNavigation,
6
+ type ShellNavigationPayload
7
+ } from '@akinon/app-shell';
4
8
  import { notification } from '@akinon/ui-react';
5
9
  import React from 'react';
6
10
  import { useNavigate, useSearchParams } from 'react-router-dom';
@@ -28,13 +32,43 @@ export const Providers: React.FC<ProvidersProps> = ({ config, children }) => {
28
32
  name: app.navTitle || app.name // Use navTitle if provided, otherwise use name
29
33
  }));
30
34
 
35
+ // One builder for every branch, so a same-tab navigation, a new-tab
36
+ // navigation and a resolved url can never point at different places.
37
+ const buildShellUri = ({ id, path, external }: ShellNavigationPayload) => {
38
+ const app = apps.find(app => app.id === id);
39
+ if (!app) return undefined;
40
+
41
+ return external ? path : `/external/${app.slug}${path || ''}`;
42
+ };
43
+
31
44
  const navigation: ShellNavigation = {
32
- navigate: ({ id, path, external }) => {
33
- const app = apps.find(app => app.id === id);
34
- if (!app) return;
45
+ navigate: payload => {
46
+ const uri = buildShellUri(payload);
47
+ if (uri === undefined) return;
48
+
49
+ if (payload.newTab) {
50
+ // Absolute, so the new tab never resolves against the iframe's own url.
51
+ const target = new URL(uri, window.location.origin);
52
+
53
+ // An external path arrives from the iframe untouched, so only a web url
54
+ // may reach window.open: a javascript: or data: url would run in the
55
+ // shell's context.
56
+ if (target.protocol !== 'http:' && target.protocol !== 'https:') return;
57
+
58
+ window.open(target.href, '_blank', 'noopener,noreferrer');
59
+ return;
60
+ }
35
61
 
36
- const uri = external ? path : `/external/${app.slug}${path || ''}`;
37
62
  navigate(uri);
63
+ },
64
+ resolveUrl: payload => {
65
+ const uri = buildShellUri(payload);
66
+ // An unknown app id has no url here, exactly as `navigate` has nowhere to
67
+ // go for one; returning nothing keeps the shell from emitting a base url
68
+ // that points at the shell root.
69
+ if (uri === undefined) return undefined;
70
+
71
+ return new URL(uri, window.location.origin).href;
38
72
  }
39
73
  };
40
74