@rise-x/apps-sdk 0.6.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.
Files changed (185) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +553 -0
  3. package/build/_internal.d.ts +2 -0
  4. package/build/_internal.js +23 -0
  5. package/build/accessors.d.ts +8 -0
  6. package/build/accessors.js +40 -0
  7. package/build/cli/index.d.ts +13 -0
  8. package/build/cli/index.js +54 -0
  9. package/build/cli/init.d.ts +6 -0
  10. package/build/cli/init.js +179 -0
  11. package/build/cli/templating.d.ts +2 -0
  12. package/build/cli/templating.js +84 -0
  13. package/build/connectors/agents.d.ts +85 -0
  14. package/build/connectors/agents.js +404 -0
  15. package/build/connectors/assets.d.ts +76 -0
  16. package/build/connectors/assets.js +204 -0
  17. package/build/connectors/deps.d.ts +4 -0
  18. package/build/connectors/deps.js +2 -0
  19. package/build/connectors/errors.d.ts +11 -0
  20. package/build/connectors/errors.js +67 -0
  21. package/build/connectors/flows.d.ts +37 -0
  22. package/build/connectors/flows.js +191 -0
  23. package/build/connectors/index.d.ts +8 -0
  24. package/build/connectors/index.js +50 -0
  25. package/build/connectors/sse.d.ts +12 -0
  26. package/build/connectors/sse.js +157 -0
  27. package/build/connectors/types.d.ts +285 -0
  28. package/build/connectors/types.js +419 -0
  29. package/build/connectors/work.d.ts +84 -0
  30. package/build/connectors/work.js +224 -0
  31. package/build/hooks.d.ts +4 -0
  32. package/build/hooks.js +28 -0
  33. package/build/index.d.ts +6 -0
  34. package/build/index.js +34 -0
  35. package/build/lifecycle.d.ts +23 -0
  36. package/build/lifecycle.js +6 -0
  37. package/build/mockShell.d.ts +10 -0
  38. package/build/mockShell.js +55 -0
  39. package/build/query/agents.d.ts +80 -0
  40. package/build/query/agents.js +143 -0
  41. package/build/query/assets.d.ts +73 -0
  42. package/build/query/assets.js +152 -0
  43. package/build/query/client.d.ts +5 -0
  44. package/build/query/client.js +68 -0
  45. package/build/query/context.d.ts +2 -0
  46. package/build/query/context.js +34 -0
  47. package/build/query/flows.d.ts +54 -0
  48. package/build/query/flows.js +81 -0
  49. package/build/query/index.d.ts +10 -0
  50. package/build/query/index.js +85 -0
  51. package/build/query/keys.d.ts +51 -0
  52. package/build/query/keys.js +79 -0
  53. package/build/query/layer.d.ts +175 -0
  54. package/build/query/layer.js +35 -0
  55. package/build/query/shared.d.ts +43 -0
  56. package/build/query/shared.js +116 -0
  57. package/build/query/work.d.ts +75 -0
  58. package/build/query/work.js +172 -0
  59. package/build/shell/index.d.ts +1 -0
  60. package/build/shell/index.js +6 -0
  61. package/build/shell/installShellBridge.d.ts +11 -0
  62. package/build/shell/installShellBridge.js +104 -0
  63. package/build/shellBridge.d.ts +36 -0
  64. package/build/shellBridge.js +10 -0
  65. package/build/topBar.d.ts +25 -0
  66. package/build/topBar.js +17 -0
  67. package/build/ui/components/ai.d.ts +49 -0
  68. package/build/ui/components/alert-dialog.d.ts +27 -0
  69. package/build/ui/components/alert.d.ts +14 -0
  70. package/build/ui/components/avatar.d.ts +17 -0
  71. package/build/ui/components/badge.d.ts +19 -0
  72. package/build/ui/components/button.d.ts +13 -0
  73. package/build/ui/components/calendar.d.ts +21 -0
  74. package/build/ui/components/card.d.ts +16 -0
  75. package/build/ui/components/chart.d.ts +124 -0
  76. package/build/ui/components/checkbox.d.ts +4 -0
  77. package/build/ui/components/data-table.d.ts +70 -0
  78. package/build/ui/components/dialog.d.ts +17 -0
  79. package/build/ui/components/dropdown-menu.d.ts +29 -0
  80. package/build/ui/components/empty-state.d.ts +7 -0
  81. package/build/ui/components/file-upload.d.ts +17 -0
  82. package/build/ui/components/input.d.ts +8 -0
  83. package/build/ui/components/label.d.ts +4 -0
  84. package/build/ui/components/list.d.ts +24 -0
  85. package/build/ui/components/map.d.ts +26 -0
  86. package/build/ui/components/message.d.ts +24 -0
  87. package/build/ui/components/nav.d.ts +12 -0
  88. package/build/ui/components/page-header.d.ts +27 -0
  89. package/build/ui/components/popover.d.ts +10 -0
  90. package/build/ui/components/progress.d.ts +4 -0
  91. package/build/ui/components/radio.d.ts +6 -0
  92. package/build/ui/components/resizable.d.ts +7 -0
  93. package/build/ui/components/scroll-area.d.ts +5 -0
  94. package/build/ui/components/segmented.d.ts +6 -0
  95. package/build/ui/components/select.d.ts +15 -0
  96. package/build/ui/components/separator.d.ts +4 -0
  97. package/build/ui/components/sheet.d.ts +14 -0
  98. package/build/ui/components/skeleton.d.ts +3 -0
  99. package/build/ui/components/slider.d.ts +15 -0
  100. package/build/ui/components/snackbar.d.ts +3 -0
  101. package/build/ui/components/sonner.d.ts +4 -0
  102. package/build/ui/components/spinner.d.ts +5 -0
  103. package/build/ui/components/statistic.d.ts +19 -0
  104. package/build/ui/components/stepper.d.ts +12 -0
  105. package/build/ui/components/switch.d.ts +6 -0
  106. package/build/ui/components/table.d.ts +24 -0
  107. package/build/ui/components/textarea.d.ts +3 -0
  108. package/build/ui/components/timeline.d.ts +15 -0
  109. package/build/ui/components/toggle-group.d.ts +10 -0
  110. package/build/ui/components/toggle.d.ts +9 -0
  111. package/build/ui/components/tooltip.d.ts +7 -0
  112. package/build/ui/index.d.ts +46 -0
  113. package/build/ui/index.js +8 -0
  114. package/build/ui/lib/utils.d.ts +2 -0
  115. package/build/ui/reference/README.md +11 -0
  116. package/build/ui/reference/components/ai.tsx +291 -0
  117. package/build/ui/reference/components/alert-dialog.tsx +208 -0
  118. package/build/ui/reference/components/alert.tsx +112 -0
  119. package/build/ui/reference/components/avatar.tsx +158 -0
  120. package/build/ui/reference/components/badge.tsx +160 -0
  121. package/build/ui/reference/components/button.tsx +100 -0
  122. package/build/ui/reference/components/calendar.tsx +119 -0
  123. package/build/ui/reference/components/card.tsx +144 -0
  124. package/build/ui/reference/components/chart.tsx +1394 -0
  125. package/build/ui/reference/components/checkbox.tsx +44 -0
  126. package/build/ui/reference/components/data-table.tsx +480 -0
  127. package/build/ui/reference/components/dialog.tsx +172 -0
  128. package/build/ui/reference/components/dropdown-menu.tsx +245 -0
  129. package/build/ui/reference/components/empty-state.tsx +63 -0
  130. package/build/ui/reference/components/file-upload.tsx +116 -0
  131. package/build/ui/reference/components/input.tsx +114 -0
  132. package/build/ui/reference/components/label.tsx +19 -0
  133. package/build/ui/reference/components/list.tsx +191 -0
  134. package/build/ui/reference/components/map.css +251 -0
  135. package/build/ui/reference/components/map.tsx +294 -0
  136. package/build/ui/reference/components/message.tsx +171 -0
  137. package/build/ui/reference/components/nav.tsx +113 -0
  138. package/build/ui/reference/components/page-header.tsx +213 -0
  139. package/build/ui/reference/components/popover.tsx +76 -0
  140. package/build/ui/reference/components/progress.tsx +31 -0
  141. package/build/ui/reference/components/radio.tsx +65 -0
  142. package/build/ui/reference/components/resizable.tsx +40 -0
  143. package/build/ui/reference/components/scroll-area.tsx +55 -0
  144. package/build/ui/reference/components/segmented.tsx +45 -0
  145. package/build/ui/reference/components/select.tsx +185 -0
  146. package/build/ui/reference/components/separator.tsx +26 -0
  147. package/build/ui/reference/components/sheet.tsx +173 -0
  148. package/build/ui/reference/components/skeleton.tsx +15 -0
  149. package/build/ui/reference/components/slider.tsx +161 -0
  150. package/build/ui/reference/components/snackbar.tsx +27 -0
  151. package/build/ui/reference/components/sonner.tsx +43 -0
  152. package/build/ui/reference/components/spinner.tsx +27 -0
  153. package/build/ui/reference/components/statistic.tsx +122 -0
  154. package/build/ui/reference/components/stepper.tsx +138 -0
  155. package/build/ui/reference/components/switch.tsx +47 -0
  156. package/build/ui/reference/components/table.tsx +233 -0
  157. package/build/ui/reference/components/textarea.tsx +28 -0
  158. package/build/ui/reference/components/timeline.tsx +94 -0
  159. package/build/ui/reference/components/toggle-group.tsx +86 -0
  160. package/build/ui/reference/components/toggle.tsx +46 -0
  161. package/build/ui/reference/components/tooltip.tsx +53 -0
  162. package/build/ui/reference/index.ts +49 -0
  163. package/build/ui/reference/lib/utils.ts +34 -0
  164. package/build/ui/standalone-stub.js +5 -0
  165. package/build/ui/standalone.js +135 -0
  166. package/build/ui/styles.css +3 -0
  167. package/connectors/package.json +8 -0
  168. package/package.json +114 -0
  169. package/query/package.json +8 -0
  170. package/shell/package.json +8 -0
  171. package/template/AGENTS.md +70 -0
  172. package/template/CLAUDE.md +4 -0
  173. package/template/README.md +102 -0
  174. package/template/_gitignore +6 -0
  175. package/template/commitlint.config.js +12 -0
  176. package/template/package.json +31 -0
  177. package/template/public/index.html +13 -0
  178. package/template/src/App.tsx +171 -0
  179. package/template/src/bootstrap.tsx +13 -0
  180. package/template/src/index.tsx +1 -0
  181. package/template/src/lifecycle.ts +20 -0
  182. package/template/tsconfig.json +31 -0
  183. package/template/webpack.config.js +112 -0
  184. package/template/webpack.local.config.js +68 -0
  185. package/ui/package.json +8 -0
@@ -0,0 +1,102 @@
1
+ # __APP_PKG_NAME__
2
+
3
+ Rise-X federated app scaffolded from `@rise-x/apps-sdk`.
4
+
5
+ ## Purpose & agent guide
6
+
7
+ - **`APP.md`** — what this app is for: the problem it solves, the
8
+ personas, and their user journeys. Read it for context before making
9
+ changes; update it whenever behaviour or a journey changes.
10
+ - **`AGENTS.md`** — guide for AI agents: the app's architecture inside the
11
+ Rise host, stack, commands, and the `APP.md` discipline. (`CLAUDE.md` is a
12
+ one-line `@AGENTS.md` import so Claude Code picks it up — edit `AGENTS.md`,
13
+ not `CLAUDE.md`.)
14
+
15
+ ## Layout
16
+
17
+ - **MF scope**: `__APP_SCOPE__` (hyphens replaced by underscores; derived from `package.json` name).
18
+ - **Exposed modules**: `./App` → `src/App.tsx` and `./lifecycle` → `src/lifecycle.ts`.
19
+ - **Shared singletons**: `react`, `react-dom` (managed by the shell at runtime).
20
+ - **Canonical layout**: `src/App.tsx` ships the Rise-X app chrome — left-rail nav on the page background, PageHeader + content screens, no user/account UI (the host owns identity). Extend it; don't flatten it.
21
+
22
+ ## Run standalone
23
+
24
+ ```bash
25
+ pnpm start # standalone dev server on port __APP_PORT__
26
+ ```
27
+
28
+ Uses `webpack.local.config.js`: bundles React directly (no Module Federation) and installs `createMockShell()` via `src/bootstrap.tsx` so shell hooks resolve against the mock. The design system renders for real here too — `@rise-x/ui` is aliased to the SDK's compiled standalone bundle (self-contained, CSS injected); `getShellApi` / `getShellApiV4` still throw with no host behind them — run `pnpm start:federated` alongside a host for backend access.
29
+
30
+ ## Build for the shell
31
+
32
+ ```bash
33
+ pnpm build # federated production bundle (dist/remoteEntry.js)
34
+ pnpm start:federated # federated dev server — only meaningful when consumed
35
+ # by the shell (alongside tools/apps-dev-server)
36
+ ```
37
+
38
+ `pnpm build` publishes `dist/remoteEntry.js` + chunks. The shell loads this bundle via Module Federation.
39
+
40
+ ## SDK cheatsheet
41
+
42
+ ```ts
43
+ import {
44
+ useShellUser,
45
+ useShellEnvironment,
46
+ useShellNavigate,
47
+ getShellApi,
48
+ getShellApiV4,
49
+ } from '@rise-x/apps-sdk';
50
+
51
+ // Typed API wrappers (event handlers, lifecycle hooks, non-React code):
52
+ import { flows, work, assets, agents } from '@rise-x/apps-sdk/connectors';
53
+
54
+ // Cached react-query hooks for component data (what App.tsx uses):
55
+ import { useFlows, useWorkRows, useSubmitWork } from '@rise-x/apps-sdk/query';
56
+ ```
57
+
58
+ The query hooks need **no provider**: inside the shell they use the per-app
59
+ `QueryClient` the shell mounts around this app; standalone they fall back to
60
+ the SDK's own client. Keep `@tanstack/react-query` in `webpack.config.js`'s
61
+ `shared` block (already configured) so the shell-managed client can reach the
62
+ app.
63
+
64
+ ## UI components
65
+
66
+ ```tsx
67
+ import { Button, Input, Dialog, cn } from '@rise-x/apps-sdk/ui';
68
+ ```
69
+
70
+ The Rise-X design system. Typings come from the SDK. Federated, the runtime
71
+ is the host's copy, delivered via the Module Federation share scope
72
+ (`@rise-x/ui` in `webpack.config.js` `shared`, already wired) — the Diana
73
+ host provides it. Standalone (`pnpm start`), `webpack.local.config.js`
74
+ aliases `@rise-x/ui` to the SDK's compiled bundle instead — a self-contained
75
+ snapshot with its own CSS injected, so components render for real without a
76
+ host. It's a snapshot, not the source of truth: verify in a host (or
77
+ deployed) before release.
78
+
79
+ ## Lifecycle hooks
80
+
81
+ `src/lifecycle.ts` exports optional `onInstall`, `onUpdate`, `onUninstall` hooks. The shell loads this module via MF and invokes them:
82
+
83
+ - **`onInstall`** — first time this device sees the app in the registry.
84
+ - **`onUpdate(ctx, { from, to })`** — when `manifest.version` changes between shell mounts.
85
+ - **`onUninstall`** — eagerly when removed via the admin UI, or lazily when the reconciler detects the app is gone from the registry (e.g. removed on another device).
86
+
87
+ Each hook is best-effort — errors are logged, 10s timeout per invocation. Hooks you don't export are skipped silently.
88
+
89
+ ## Storage
90
+
91
+ BYO — install `localforage` (or whatever you prefer) as a direct dep. Drop your data in `onUninstall`:
92
+
93
+ ```ts
94
+ import localforage from 'localforage';
95
+ import type { UninstallHook } from '@rise-x/apps-sdk';
96
+
97
+ export const onUninstall: UninstallHook = async ({ manifest }) => {
98
+ await localforage.dropInstance({ name: `diana-app-${manifest.id}` });
99
+ };
100
+ ```
101
+
102
+ See `@rise-x/apps-sdk` README for the full API.
@@ -0,0 +1,6 @@
1
+ node_modules/
2
+ dist/
3
+ dist-local/
4
+ .yalc/
5
+ yalc.lock
6
+ *.log
@@ -0,0 +1,12 @@
1
+ // Conventional-commit rules for this app, derived from the rise-x-app repo
2
+ // config (minus its internal ticket-footer requirement). Verify the last
3
+ // commit with `npx commitlint --last`.
4
+ module.exports = {
5
+ extends: ["@commitlint/config-conventional"],
6
+ helpUrl: "https://www.conventionalcommits.org/en/v1.0.0",
7
+ rules: {
8
+ "body-max-line-length": [2, "always", 200],
9
+ "footer-max-line-length": [2, "always", 200],
10
+ "header-max-length": [2, "always", 200],
11
+ },
12
+ };
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "__APP_PKG_NAME__",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "scripts": {
6
+ "build": "webpack --mode=production",
7
+ "start": "webpack serve --config webpack.local.config.js --mode=development",
8
+ "start:federated": "webpack serve --mode=development"
9
+ },
10
+ "dependencies": {
11
+ "@rise-x/apps-sdk": "__SDK_VERSION__",
12
+ "@tanstack/react-query": "^5.59.20",
13
+ "lucide-react": "^1.25.0"
14
+ },
15
+ "devDependencies": {
16
+ "@commitlint/cli": "^21.2.1",
17
+ "@commitlint/config-conventional": "^21.2.0",
18
+ "@types/react": "^18.2.0",
19
+ "@types/react-dom": "^18.2.0",
20
+ "axios": "^1.7.7",
21
+ "html-webpack-plugin": "^5.5.3",
22
+ "react": "^18.2.0",
23
+ "react-dom": "^18.2.0",
24
+ "react-router-dom": "^6.19.0",
25
+ "ts-loader": "^9.5.1",
26
+ "typescript": "^5.3.0",
27
+ "webpack": "^5.90.0",
28
+ "webpack-cli": "^5.1.4",
29
+ "webpack-dev-server": "^4.15.1"
30
+ }
31
+ }
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>__APP_SLUG__ (standalone)</title>
7
+ <!-- No base styles here — the standalone bundle of the design system
8
+ injects the compiled theme plus the host baseline (font, colors). -->
9
+ </head>
10
+ <body>
11
+ <div id="standalone-root"></div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,171 @@
1
+ import { useState } from "react";
2
+ import {
3
+ Download,
4
+ FileText,
5
+ Home,
6
+ Package,
7
+ Plus,
8
+ Settings,
9
+ Users,
10
+ } from "lucide-react";
11
+ import {
12
+ Badge,
13
+ Button,
14
+ Nav,
15
+ NavItem,
16
+ NavSection,
17
+ PageHeader,
18
+ PageHeaderActions,
19
+ PageHeaderRow,
20
+ PageHeaderSubtitle,
21
+ PageHeaderTitle,
22
+ } from "@rise-x/apps-sdk/ui";
23
+
24
+ /*
25
+ * CANONICAL APP LAYOUT — keep this composition as the app grows:
26
+ *
27
+ * · The HOST renders the top bar above the app (navigation, user menu,
28
+ * ecosystem switcher). Never render a top bar and NEVER any user/account
29
+ * UI in the app — no avatar, no user name, no sign-out.
30
+ * · App navigation is a LEFT RAIL built from the Nav primitives, sitting
31
+ * directly on the page background — never wrapped in a Card or Panel.
32
+ * Cards are for content, not chrome.
33
+ * · No app logo or name in the rail — the host already identifies the app;
34
+ * the rail starts directly with Nav.
35
+ * · A screen is a PageHeader (title / subtitle / actions) + content below.
36
+ * Content is a set of plain tiles (bg-card + shadow-card), not Card
37
+ * components — see LShell in
38
+ * Shell/src/components/__demo__/design/layout.tsx.
39
+ * Give empty, loading and error states the same care as the happy path.
40
+ *
41
+ * Data access: hooks from '@rise-x/apps-sdk/query' in components, connectors
42
+ * from '@rise-x/apps-sdk/connectors' in handlers — see README.md.
43
+ */
44
+
45
+ const SCREENS = [
46
+ { id: "home", label: "Home" },
47
+ { id: "records", label: "Records" },
48
+ { id: "packages", label: "Packages" },
49
+ { id: "people", label: "People" },
50
+ { id: "settings", label: "Settings" },
51
+ ] as const;
52
+
53
+ export default function App() {
54
+ return <Shell />;
55
+ }
56
+
57
+ function Shell() {
58
+ const [screen, setScreen] = useState<string>("home");
59
+ const current = SCREENS.find((s) => s.id === screen) ?? SCREENS[0];
60
+
61
+ return (
62
+ // The host paints the page background and owns page height — the app
63
+ // fills its outlet. NOTE: the host ships only the utility classes used
64
+ // inside the design system itself; app-specific values (like the rail
65
+ // width below) go in inline styles or your own CSS.
66
+ <div className="flex text-foreground">
67
+ {/* Left rail: a borderless list on the page background — NOT a Card. */}
68
+ <aside className="flex shrink-0 flex-col p-3" style={{ width: 180 }}>
69
+ <Nav>
70
+ <NavItem
71
+ current={screen === "home"}
72
+ onClick={() => setScreen("home")}
73
+ >
74
+ <Home />
75
+ Home
76
+ </NavItem>
77
+ <NavItem
78
+ current={screen === "records"}
79
+ onClick={() => setScreen("records")}
80
+ >
81
+ <FileText />
82
+ Records
83
+ <Badge variant="count">12</Badge>
84
+ </NavItem>
85
+ <NavItem
86
+ current={screen === "packages"}
87
+ onClick={() => setScreen("packages")}
88
+ >
89
+ <Package />
90
+ Packages
91
+ </NavItem>
92
+ <NavItem
93
+ current={screen === "people"}
94
+ onClick={() => setScreen("people")}
95
+ >
96
+ <Users />
97
+ People
98
+ </NavItem>
99
+ <NavSection>Workspace</NavSection>
100
+ <NavItem
101
+ current={screen === "settings"}
102
+ onClick={() => setScreen("settings")}
103
+ >
104
+ <Settings />
105
+ Settings
106
+ </NavItem>
107
+ </Nav>
108
+ {/* Nothing below the nav — the host top bar owns user identity. */}
109
+ </aside>
110
+
111
+ <main className="min-w-0 flex-1 p-6">
112
+ <PageHeader variant="bare">
113
+ <PageHeaderRow>
114
+ <div>
115
+ <PageHeaderTitle>{current.label}</PageHeaderTitle>
116
+ <PageHeaderSubtitle>
117
+ What this screen is for, in one line.
118
+ </PageHeaderSubtitle>
119
+ </div>
120
+ <PageHeaderActions>
121
+ <Button variant="outline" size="sm">
122
+ <Download />
123
+ Export
124
+ </Button>
125
+ <Button size="sm">
126
+ <Plus />
127
+ New record
128
+ </Button>
129
+ </PageHeaderActions>
130
+ </PageHeaderRow>
131
+ </PageHeader>
132
+
133
+ {/* Stat tiles: plain divs (bg-card + shadow-card), not Card — see the
134
+ CANONICAL APP LAYOUT comment above. `sm:grid-cols-3` isn't in the
135
+ host's compiled CSS, so the column count is an inline style. */}
136
+ <div
137
+ className="grid gap-3"
138
+ style={{
139
+ gridTemplateColumns: "repeat(auto-fit, minmax(160px, 1fr))",
140
+ }}
141
+ >
142
+ {[
143
+ ["Records", "1,284"],
144
+ ["Open", "104"],
145
+ ["Resolved", "1,180"],
146
+ ].map(([label, value]) => (
147
+ <div key={label} className="rounded-xl bg-card p-3.5 shadow-card">
148
+ <div className="text-xs text-muted-foreground">{label}</div>
149
+ <div className="mt-0.5 text-[22px] font-semibold tracking-[-0.02em] tabular-nums">
150
+ {value}
151
+ </div>
152
+ </div>
153
+ ))}
154
+ </div>
155
+
156
+ {/* `min-h-[104px]` isn't in the host's compiled CSS either — same
157
+ inline-style treatment. */}
158
+ <div
159
+ className="mt-3 rounded-xl bg-card p-3.5 shadow-card"
160
+ style={{ minHeight: 104 }}
161
+ >
162
+ <div className="text-ui font-medium">Results</div>
163
+ <div className="mt-1 text-xs text-muted-foreground">
164
+ Tables, cards and charts are each their own tile. Replace these
165
+ stubs with your app.
166
+ </div>
167
+ </div>
168
+ </main>
169
+ </div>
170
+ );
171
+ }
@@ -0,0 +1,13 @@
1
+ import { createRoot } from 'react-dom/client';
2
+ import { createMockShell } from '@rise-x/apps-sdk';
3
+ import App from './App';
4
+
5
+ // Standalone entry — only used when running the app on its own port for dev.
6
+ // When hosted inside the Rise-X shell, App is loaded via Module Federation instead.
7
+ const root = document.getElementById('standalone-root');
8
+ if (root) {
9
+ if (!window.__DIANA_SHELL__) {
10
+ window.__DIANA_SHELL__ = createMockShell();
11
+ }
12
+ createRoot(root).render(<App />);
13
+ }
@@ -0,0 +1 @@
1
+ import('./bootstrap');
@@ -0,0 +1,20 @@
1
+ import type { InstallHook, UninstallHook, UpdateHook } from '@rise-x/apps-sdk';
2
+
3
+ // Lifecycle hooks are optional — export only the ones you need. The shell
4
+ // loads this module via Module Federation and invokes each hook best-effort
5
+ // (errors are logged, not thrown; 10s timeout per hook).
6
+
7
+ export const onInstall: InstallHook = async ({ manifest }) => {
8
+ console.info(`[__APP_SLUG__] onInstall for ${manifest.id}@${manifest.version}`);
9
+ };
10
+
11
+ export const onUpdate: UpdateHook = async ({ manifest }, { from, to }) => {
12
+ console.info(`[__APP_SLUG__] onUpdate ${from} -> ${to} for ${manifest.id}`);
13
+ };
14
+
15
+ // Drop any local data your app owns. Example:
16
+ // import localforage from 'localforage';
17
+ // await localforage.dropInstance({ name: `diana-app-${manifest.id}` });
18
+ export const onUninstall: UninstallHook = async ({ manifest }) => {
19
+ console.info(`[__APP_SLUG__] onUninstall for ${manifest.id}`);
20
+ };
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "jsx": "react-jsx",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "resolveJsonModule": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "isolatedModules": true,
14
+ "lib": ["DOM", "DOM.Iterable", "ES2020"],
15
+ "baseUrl": ".",
16
+ // TS tries each paths entry in order and keeps the first that resolves.
17
+ // A partner app (own flat install) has its own node_modules/@types/react
18
+ // and matches entry #1. An in-repo app (pnpm hoisted workspace) has no
19
+ // app-level @types/react — icon/UI deps nest their own @types/react@19
20
+ // copies, but nothing hoists them to the app — so entry #1 fails to
21
+ // resolve and TS falls through to entry #2, the workspace root's
22
+ // @types/react. Without this fallback, in-repo apps silently pick up one
23
+ // of those nested @types/react@19 copies instead of the root's, and
24
+ // design-system components typed against React 18 collapse to `{}`.
25
+ "paths": {
26
+ "react": ["./node_modules/@types/react", "../../node_modules/@types/react"],
27
+ "react-dom": ["./node_modules/@types/react-dom", "../../node_modules/@types/react-dom"]
28
+ }
29
+ },
30
+ "include": ["src"]
31
+ }
@@ -0,0 +1,112 @@
1
+ const path = require("path");
2
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
3
+ const { ModuleFederationPlugin } = require("webpack").container;
4
+ const pkg = require("./package.json");
5
+
6
+ // Conventions:
7
+ // package.json name → "@rise-x-apps/<slug>"
8
+ // remote scope → "app_<slug_with_underscores>"
9
+ // exposed module → "./App" → src/App.tsx
10
+ const slug = pkg.name.replace(/^@rise-x-apps\//, "");
11
+ const scope = "app_" + slug.replace(/-/g, "_");
12
+
13
+ module.exports = (_env, argv) => {
14
+ const isProd = argv.mode === "production";
15
+
16
+ return {
17
+ entry: "./src/index.tsx",
18
+ mode: argv.mode || "development",
19
+ devtool: isProd ? "source-map" : "eval-source-map",
20
+ output: {
21
+ path: path.resolve(__dirname, "dist"),
22
+ // 'auto' lets webpack derive the chunk base URL from document.currentScript.src
23
+ // at runtime — required so the same bundle works in dev and when the shell loads
24
+ // remoteEntry.js from the CDN under /apps/<id>/<ver>/.
25
+ publicPath: "auto",
26
+ filename: "[name].[contenthash].js",
27
+ chunkFilename: "[name].[contenthash].js",
28
+ uniqueName: scope,
29
+ clean: true,
30
+ },
31
+ resolve: {
32
+ extensions: [".tsx", ".ts", ".js", ".jsx"],
33
+ },
34
+ module: {
35
+ rules: [
36
+ {
37
+ test: /\.(ts|tsx)$/,
38
+ exclude: /node_modules/,
39
+ use: "ts-loader",
40
+ },
41
+ ],
42
+ },
43
+ plugins: [
44
+ new ModuleFederationPlugin({
45
+ name: scope,
46
+ filename: "remoteEntry.js",
47
+ exposes: {
48
+ "./App": "./src/App",
49
+ "./lifecycle": "./src/lifecycle",
50
+ },
51
+ shared: {
52
+ // import: false — the app consumes React (and its JSX runtimes) from the shell
53
+ // only and never bundles a fallback. Prevents duplicate-React-instance bugs and
54
+ // the sync-require failure inside React 18's bundled jsx-runtime. For standalone
55
+ // local dev (no shell), use `pnpm start` which runs webpack.local.config.js.
56
+ // The dual range mirrors the SDK's peer range: hosts provide React 18
57
+ // or 19 depending on their generation, and the same bundle must load
58
+ // on both — author to the React 18-compatible API surface (AGENTS.md).
59
+ react: {
60
+ singleton: true,
61
+ requiredVersion: "^18.0.0 || ^19.0.0",
62
+ import: false,
63
+ },
64
+ "react-dom": {
65
+ singleton: true,
66
+ requiredVersion: "^18.0.0 || ^19.0.0",
67
+ import: false,
68
+ },
69
+ "react/jsx-runtime": {
70
+ singleton: true,
71
+ requiredVersion: "^18.0.0 || ^19.0.0",
72
+ import: false,
73
+ },
74
+ "react/jsx-dev-runtime": {
75
+ singleton: true,
76
+ requiredVersion: "^18.0.0 || ^19.0.0",
77
+ import: false,
78
+ },
79
+ // Rise-X design system, imported via `@rise-x/apps-sdk/ui`. The
80
+ // host (the Diana app) provides the only copy — and the Tailwind
81
+ // CSS that styles it — through the share scope; never bundle a
82
+ // fallback.
83
+ "@rise-x/ui": {
84
+ singleton: true,
85
+ requiredVersion: false,
86
+ import: false,
87
+ },
88
+ // Unlike react, keep the bundled fallback (no `import: false`): the
89
+ // app loads through an async MF boundary so there is no eager
90
+ // sync-require hazard, and the fallback keeps the app working on
91
+ // hosts that don't share react-query. When the shell does share it,
92
+ // `singleton: true` wins with the shell's copy — which is what lets
93
+ // the shell-managed per-app QueryClient reach the SDK's query hooks
94
+ // through React context.
95
+ "@tanstack/react-query": {
96
+ singleton: true,
97
+ requiredVersion: "^5.0.0",
98
+ },
99
+ },
100
+ }),
101
+ new HtmlWebpackPlugin({
102
+ template: path.resolve(__dirname, "public/index.html"),
103
+ }),
104
+ ],
105
+ devServer: {
106
+ port: __APP_PORT__,
107
+ hot: true,
108
+ historyApiFallback: true,
109
+ headers: { "Access-Control-Allow-Origin": "*" },
110
+ },
111
+ };
112
+ };
@@ -0,0 +1,68 @@
1
+ const path = require("path");
2
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
3
+
4
+ // Standalone dev config — bundles React directly so the app boots on its own
5
+ // port without the Rise-X shell. src/bootstrap.tsx installs createMockShell()
6
+ // on window.__DIANA_SHELL__, so shell hooks (useShellUser, useShellEnvironment)
7
+ // resolve against the mock. For the federated build loaded by the shell via
8
+ // Module Federation, see webpack.config.js.
9
+ module.exports = (_env, argv) => {
10
+ const isProd = argv.mode === "production";
11
+
12
+ return {
13
+ entry: "./src/index.tsx",
14
+ mode: argv.mode || "development",
15
+ devtool: isProd ? "source-map" : "eval-source-map",
16
+ output: {
17
+ path: path.resolve(__dirname, "dist-local"),
18
+ publicPath: "/",
19
+ filename: "[name].[contenthash].js",
20
+ chunkFilename: "[name].[contenthash].js",
21
+ clean: true,
22
+ },
23
+ resolve: {
24
+ extensions: [".tsx", ".ts", ".js", ".jsx"],
25
+ alias: {
26
+ // No shell → no share scope. Standalone builds bundle the SDK's own
27
+ // compiled copy of the design system instead (CSS self-injected,
28
+ // Inter included) — the federated build still gets the host's copy
29
+ // via the share scope (see webpack.config.js).
30
+ "@rise-x/ui": require.resolve("@rise-x/apps-sdk/ui/standalone"),
31
+
32
+ // Same single-physical-React pin the hosts use via Module Federation
33
+ // `shared` — but standalone dev has no share scope, so icon/UI deps
34
+ // that nest their own React (e.g. lucide-react, radix-ui on React 19
35
+ // in a pnpm hoisted workspace) would otherwise feed React-19 elements
36
+ // to this app's React-18 renderer, which rejects them outright.
37
+ // require.resolve walks up from this app's own node_modules, so it
38
+ // finds the app's own React — the workspace root in-repo, the app's
39
+ // local install for partner projects — and the alias forces every
40
+ // `react`/`react-dom` request in the compilation onto that one copy,
41
+ // including requests nested under those deps. Subpath requests
42
+ // (e.g. react/jsx-runtime) resolve through the same alias.
43
+ react: path.dirname(require.resolve("react/package.json")),
44
+ "react-dom": path.dirname(require.resolve("react-dom/package.json")),
45
+ },
46
+ },
47
+ module: {
48
+ rules: [
49
+ {
50
+ test: /\.(ts|tsx)$/,
51
+ exclude: /node_modules/,
52
+ use: "ts-loader",
53
+ },
54
+ ],
55
+ },
56
+ plugins: [
57
+ new HtmlWebpackPlugin({
58
+ template: path.resolve(__dirname, "public/index.html"),
59
+ }),
60
+ ],
61
+ devServer: {
62
+ port: __APP_PORT__,
63
+ hot: true,
64
+ historyApiFallback: true,
65
+ open: true,
66
+ },
67
+ };
68
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@rise-x/apps-sdk/ui",
3
+ "description": "Legacy-resolution stub for the ui subpath. See parent package.json `exports` for the canonical wiring.",
4
+ "main": "../build/ui/index.js",
5
+ "module": "../build/ui/index.js",
6
+ "types": "../build/ui/index.d.ts",
7
+ "private": true
8
+ }