@wealthfolio/addon-dev-tools 3.6.0 → 3.6.2
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/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { AddonContext } from '@wealthfolio/addon-sdk';
|
|
3
|
-
import { Card, CardContent
|
|
1
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
2
|
+
import type { AddonContext, AddonEnableFunction } from '@wealthfolio/addon-sdk';
|
|
3
|
+
import { Card, CardContent } from '@wealthfolio/ui';
|
|
4
|
+
|
|
5
|
+
// The host owns a single React root per addon and mounts the route `component`
|
|
6
|
+
// itself (`createElement(Component, { location })`) with no access to the addon
|
|
7
|
+
// context. Capture it at enable time so the route wrapper can hand it down.
|
|
8
|
+
// (Do NOT call createRoot yourself — the host manages the lifecycle.)
|
|
9
|
+
let addonCtx: AddonContext | undefined;
|
|
4
10
|
|
|
5
11
|
function AddonExample({ ctx }: { ctx: AddonContext }) {
|
|
6
12
|
return (
|
|
@@ -17,35 +23,31 @@ function AddonExample({ ctx }: { ctx: AddonContext }) {
|
|
|
17
23
|
);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
// Route component. The sidebar entry + route are declared in manifest.json
|
|
27
|
+
// (`contributes.routes` + `contributes.links`), so the host renders navigation
|
|
28
|
+
// without booting the addon; this component only runs when the route is first
|
|
29
|
+
// visited. The QueryClientProvider shares one cache across route navigations.
|
|
30
|
+
const AddonRoute = () => (
|
|
31
|
+
<QueryClientProvider client={addonCtx!.api.query.getClient() as QueryClient}>
|
|
32
|
+
<AddonExample ctx={addonCtx!} />
|
|
33
|
+
</QueryClientProvider>
|
|
34
|
+
);
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
id: '{{addonId}}',
|
|
26
|
-
label: '{{addonName}}',
|
|
27
|
-
icon: 'blocks',
|
|
28
|
-
route: '/addon/{{addonId}}',
|
|
29
|
-
order: 100,
|
|
30
|
-
});
|
|
36
|
+
const enable: AddonEnableFunction = (ctx) => {
|
|
37
|
+
addonCtx = ctx;
|
|
31
38
|
|
|
32
|
-
//
|
|
39
|
+
// The route `id` MUST match `contributes.routes[].id` in manifest.json.
|
|
40
|
+
// The host derives this root path from the manifest addon id.
|
|
33
41
|
ctx.router.add({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
root.render(<AddonExample ctx={ctx} />);
|
|
38
|
-
},
|
|
42
|
+
id: '{{addonId}}',
|
|
43
|
+
path: '/addons/{{addonId}}',
|
|
44
|
+
component: AddonRoute,
|
|
39
45
|
});
|
|
40
46
|
|
|
41
|
-
//
|
|
47
|
+
// The host owns the React root, so there is nothing to unmount here.
|
|
42
48
|
ctx.onDisable(() => {
|
|
43
|
-
|
|
44
|
-
sidebarItem.remove();
|
|
45
|
-
root?.unmount();
|
|
46
|
-
root = null;
|
|
47
|
-
} catch (err) {
|
|
48
|
-
ctx.api.logger.error(`Failed to remove sidebar item: ${String(err)}`);
|
|
49
|
-
}
|
|
49
|
+
addonCtx = undefined;
|
|
50
50
|
});
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default enable;
|
|
@@ -5,12 +5,26 @@
|
|
|
5
5
|
"description": "{{description}}",
|
|
6
6
|
"author": "{{author}}",
|
|
7
7
|
"main": "dist/addon.js",
|
|
8
|
-
"sdkVersion": "3.6.
|
|
9
|
-
"minWealthfolioVersion": "3.6.
|
|
8
|
+
"sdkVersion": "3.6.2",
|
|
9
|
+
"minWealthfolioVersion": "3.6.2",
|
|
10
10
|
"enabled": true,
|
|
11
|
+
"contributes": {
|
|
12
|
+
"routes": [{ "id": "{{addonId}}" }],
|
|
13
|
+
"links": {
|
|
14
|
+
"sidebar": [
|
|
15
|
+
{
|
|
16
|
+
"id": "{{addonId}}",
|
|
17
|
+
"route": "{{addonId}}",
|
|
18
|
+
"label": "{{addonName}}",
|
|
19
|
+
"icon": "squares-four",
|
|
20
|
+
"order": 100
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
11
25
|
"hostDependencies": {
|
|
12
26
|
"@tanstack/react-query": "^5.90.0",
|
|
13
|
-
"@wealthfolio/addon-sdk": "^3.6.
|
|
27
|
+
"@wealthfolio/addon-sdk": "^3.6.2",
|
|
14
28
|
"@wealthfolio/ui": "^3.6.0",
|
|
15
29
|
"date-fns": "^4.1.0",
|
|
16
30
|
"lucide-react": "^0.561.0",
|
|
@@ -18,13 +32,7 @@
|
|
|
18
32
|
"react-dom": "^19.2.0",
|
|
19
33
|
"recharts": "^3.7.0"
|
|
20
34
|
},
|
|
21
|
-
"permissions": [
|
|
22
|
-
{
|
|
23
|
-
"category": "ui",
|
|
24
|
-
"functions": ["sidebar.addItem", "router.add"],
|
|
25
|
-
"purpose": "Add navigation items and pages"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
35
|
+
"permissions": [],
|
|
28
36
|
"keywords": ["wealthfolio", "addon"],
|
|
29
37
|
"license": "MIT"
|
|
30
38
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@tanstack/react-query": "^5.90.0",
|
|
21
|
-
"@wealthfolio/addon-sdk": "^3.6.
|
|
21
|
+
"@wealthfolio/addon-sdk": "^3.6.2",
|
|
22
22
|
"@wealthfolio/ui": "^3.6.0",
|
|
23
23
|
"date-fns": "^4.1.0",
|
|
24
24
|
"lucide-react": "^0.561.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@tanstack/react-query": "^5.90.20",
|
|
31
31
|
"@tailwindcss/vite": "^4.1.13",
|
|
32
32
|
"@wealthfolio/addon-dev-tools": "^3.6.0",
|
|
33
|
-
"@wealthfolio/addon-sdk": "^3.6.
|
|
33
|
+
"@wealthfolio/addon-sdk": "^3.6.2",
|
|
34
34
|
"@wealthfolio/ui": "^3.6.0",
|
|
35
35
|
"@types/node": "^20.0.0",
|
|
36
36
|
"@types/react": "^19.2.13",
|