@rise-x/apps-sdk 0.8.0 → 0.9.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/README.md +104 -1
- package/build/rsbuild/index.d.ts +31 -0
- package/build/rsbuild/index.js +204 -0
- package/build/ui/components/app-frame.d.ts +13 -0
- package/build/ui/components/nav.d.ts +2 -1
- package/build/ui/index.d.ts +1 -0
- package/build/ui/reference/components/ai.tsx +3 -1
- package/build/ui/reference/components/alert-dialog.tsx +9 -15
- package/build/ui/reference/components/app-frame.tsx +71 -0
- package/build/ui/reference/components/button.tsx +4 -2
- package/build/ui/reference/components/combobox.tsx +6 -1
- package/build/ui/reference/components/dialog.tsx +1 -1
- package/build/ui/reference/components/dropdown-menu.tsx +1 -1
- package/build/ui/reference/components/message.tsx +12 -6
- package/build/ui/reference/components/nav.tsx +8 -3
- package/build/ui/reference/components/sheet.tsx +1 -1
- package/build/ui/reference/index.ts +1 -0
- package/build/ui/standalone.js +51 -51
- package/build/ui/styles.css +1 -1
- package/package.json +22 -2
- package/rsbuild/package.json +8 -0
- package/template/AGENTS.md +15 -7
- package/template/src/App.tsx +18 -11
package/README.md
CHANGED
|
@@ -65,6 +65,36 @@ re-exported for apps:
|
|
|
65
65
|
import { Button, Dialog, DialogContent, Input, cn } from '@rise-x/apps-sdk/ui';
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
#### App layout (`AppFrame` / `AppRail` / `AppContent`)
|
|
69
|
+
|
|
70
|
+
The root layout contract, scaffolded into every new app:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<AppFrame>
|
|
74
|
+
<AppRail>{/* Nav / NavItem rail */}</AppRail>
|
|
75
|
+
<AppContent>{/* screens; the app's ONE scroll container */}</AppContent>
|
|
76
|
+
</AppFrame>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The next-gen shell hands the app a full-height region that extends under its
|
|
80
|
+
floating top bar and publishes the bar's height as `--topbar-h` on the
|
|
81
|
+
document. `AppRail` stays fixed on the left and starts below the bar;
|
|
82
|
+
`AppContent` owns the scroll and slides content **behind** the bar's blur.
|
|
83
|
+
Both pad with `var(--topbar-h, 0px)`, so in hosts without a floating bar
|
|
84
|
+
(the classic shell, standalone dev) the frame degrades to a plain
|
|
85
|
+
rail-plus-content layout. Never hardcode a bar height and never add a second
|
|
86
|
+
page-level scroller.
|
|
87
|
+
|
|
88
|
+
The frame is responsive by default: below the `md` breakpoint it stacks —
|
|
89
|
+
`AppRail` renders as a horizontal, scrollable nav strip under the top bar
|
|
90
|
+
(`NavSection` headers hide) and `AppContent` scrolls beneath it. Don't write
|
|
91
|
+
your own breakpoints around the frame; compose inside it.
|
|
92
|
+
|
|
93
|
+
Rendering an `AppFrame` anywhere in the app is the signal that the app owns
|
|
94
|
+
its layout: the next-gen shell detects it and hands over the full-bleed
|
|
95
|
+
region. Apps without one are compensated — the host pads and scrolls the
|
|
96
|
+
region itself — so pre-frame bundles keep working, minus the fixed rail.
|
|
97
|
+
|
|
68
98
|
How it works: the SDK ships the **typings**; the **runtime** is the shell's own
|
|
69
99
|
copy of `@rise-x/ui`, delivered through the Module Federation share scope —
|
|
70
100
|
exactly how apps already consume React. That is deliberate: the components are
|
|
@@ -703,6 +733,79 @@ per-app `QueryClient` (built with `createAppQueryClient` from
|
|
|
703
733
|
`@rise-x/apps-sdk/query`), which is what the SDK's query hooks pick up
|
|
704
734
|
through context in federated apps.
|
|
705
735
|
|
|
736
|
+
## Build config (`@rise-x/apps-sdk/rsbuild`)
|
|
737
|
+
|
|
738
|
+
Apps build with [Rsbuild](https://rsbuild.dev), and the Module Federation
|
|
739
|
+
contract with the shell lives in this preset rather than in each app's config.
|
|
740
|
+
|
|
741
|
+
```ts
|
|
742
|
+
// rsbuild.config.ts
|
|
743
|
+
import { defineConfig } from '@rsbuild/core';
|
|
744
|
+
import { defineAppConfig } from '@rise-x/apps-sdk/rsbuild';
|
|
745
|
+
import pkg from './package.json';
|
|
746
|
+
|
|
747
|
+
export default defineConfig(({ envMode }) =>
|
|
748
|
+
defineAppConfig({ pkg, port: 5102, standalone: envMode === 'standalone' }),
|
|
749
|
+
);
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
```bash
|
|
753
|
+
pnpm rsbuild build # federated bundle -> dist/
|
|
754
|
+
pnpm rsbuild dev # federated, served for a host to load
|
|
755
|
+
pnpm rsbuild dev --env-mode standalone # standalone, no shell -> dist-local/
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
Requires `@rsbuild/core` and `@rsbuild/plugin-react` in the app (they are
|
|
759
|
+
optional peers here, so hosts that never import this subpath get no unmet-peer
|
|
760
|
+
noise).
|
|
761
|
+
|
|
762
|
+
| Option | Required | Purpose |
|
|
763
|
+
|---|---|---|
|
|
764
|
+
| `pkg` | yes | the app's `package.json`. `name` derives the MF scope (`@rise-x-apps/vendor-hub` → `app_vendor_hub`); `version` is baked as `__APP_VERSION__` |
|
|
765
|
+
| `port` | yes | dev-server port. Must be unique across apps |
|
|
766
|
+
| `standalone` | no | no shell, no MF, React bundled in |
|
|
767
|
+
| `exposes` | no | extra MF exposes, merged over `./App` + `./lifecycle` |
|
|
768
|
+
|
|
769
|
+
`__APP_VERSION__` is a `define`, so TypeScript needs to be told it exists. Add
|
|
770
|
+
`declare const __APP_VERSION__: string;` to the app if you read it.
|
|
771
|
+
|
|
772
|
+
What the federated branch sets, and why it matters:
|
|
773
|
+
|
|
774
|
+
- **`ModuleFederationPluginV1`**, never the enhanced plugin — V1 emits the
|
|
775
|
+
container shape (`window[scope].init/get`) that both hosts' runtime loaders
|
|
776
|
+
speak.
|
|
777
|
+
- **`output.uniqueName = scope`** via `tools.rspack`. Rsbuild has no
|
|
778
|
+
`output.uniqueName` of its own, and it names the chunk-loading global — left
|
|
779
|
+
at the default it collides with the host's.
|
|
780
|
+
- **React, its JSX runtimes and `@rise-x/ui` are consume-only**
|
|
781
|
+
(`import: false`): the host provides the single copy. `@tanstack/react-query`
|
|
782
|
+
deliberately keeps its bundled fallback, so an app still works on a host that
|
|
783
|
+
does not share it.
|
|
784
|
+
- **React is shared as `^18.0.0 || ^19.0.0`**, because the two hosts are on
|
|
785
|
+
different majors (ClientApp 18, Shell 19) and one bundle must load on both.
|
|
786
|
+
That is a build-level permission, not a licence to use React 19 APIs — write
|
|
787
|
+
app code against the **React 18-compatible API surface**, since ClientApp is
|
|
788
|
+
still the production host.
|
|
789
|
+
- **Flat `dist/`** — `remoteEntry.js` beside its chunks, because
|
|
790
|
+
`tools/apps-dev-server` probes `dist/remoteEntry.js` and the deploy zips the
|
|
791
|
+
*contents* of `dist/`.
|
|
792
|
+
- **`assetPrefix: 'auto'` on both `output` and `dev`** so one bundle works on
|
|
793
|
+
the dev port and when the shell loads `remoteEntry.js` from the CDN. Rsbuild
|
|
794
|
+
splits what webpack had as a single `output.publicPath`, and the dev half
|
|
795
|
+
defaults to `/` — a remote served by `rsbuild dev` would otherwise resolve
|
|
796
|
+
its async chunks against the *host's* origin.
|
|
797
|
+
- **Production source maps**, which Rsbuild otherwise defaults off.
|
|
798
|
+
|
|
799
|
+
The preset's own `standalone` specs resolve `@rise-x/apps-sdk/ui/standalone`,
|
|
800
|
+
so run `pnpm build` in this package before `pnpm test` on a clean checkout (CI
|
|
801
|
+
already builds first).
|
|
802
|
+
|
|
803
|
+
Set `APP_SCOPE` to override the derived scope. That is only for registering two
|
|
804
|
+
builds of one app side by side (an old and a redesigned version, to compare
|
|
805
|
+
them) — two registrations may not share a scope, because the shell caches
|
|
806
|
+
loaded remotes by URL and the second `remoteEntry.js` would overwrite the
|
|
807
|
+
first's global. Leave it unset for normal releases.
|
|
808
|
+
|
|
706
809
|
## Local development against the SDK
|
|
707
810
|
|
|
708
811
|
In-repo consumers (ClientApp, apps/\*) declare `"@rise-x/apps-sdk": "workspace:*"`,
|
|
@@ -722,7 +825,7 @@ pnpm add @rise-x/apps-sdk
|
|
|
722
825
|
|
|
723
826
|
## Publishing
|
|
724
827
|
|
|
725
|
-
Publishes to the public npm registry (`registry.npmjs.org`) under the `rise-x` org, per `publishConfig` in `package.json`.
|
|
828
|
+
Publishes to the public npm registry (`registry.npmjs.org`) under the `rise-x` org, per `publishConfig` in `package.json`. Releases are manual: run the **Publish @rise-x/apps-sdk** workflow (`.github/workflows/publish-apps-sdk.yml`) via workflow dispatch, from `main` or a `release/*` branch — it publishes the version in `package.json`, and fails if that version is already on the registry.
|
|
726
829
|
|
|
727
830
|
To publish manually you need an npmjs account with publish rights in the `rise-x` org (`npm login`), then:
|
|
728
831
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
+
export interface AppPackageJson {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DefineAppConfigOptions {
|
|
7
|
+
/** The app's own package.json. `name` derives the Module Federation scope. */
|
|
8
|
+
pkg: AppPackageJson;
|
|
9
|
+
/**
|
|
10
|
+
* Dev-server port. Must be unique across apps — two apps on one port cannot
|
|
11
|
+
* be served side by side during development.
|
|
12
|
+
*/
|
|
13
|
+
port: number;
|
|
14
|
+
/**
|
|
15
|
+
* Standalone dev: no shell, no Module Federation, React bundled in.
|
|
16
|
+
* Drive it with `rsbuild dev --env-mode standalone`.
|
|
17
|
+
*
|
|
18
|
+
* Do NOT use `--env-mode local`: Rsbuild rejects that value outright,
|
|
19
|
+
* because `.env.local` is reserved as a temporary local file. The mode
|
|
20
|
+
* name is refused whether or not such a file exists.
|
|
21
|
+
*/
|
|
22
|
+
standalone?: boolean;
|
|
23
|
+
/** Extra Module Federation exposes, merged over `./App` + `./lifecycle`. */
|
|
24
|
+
exposes?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Derive an app's Module Federation scope from its package name:
|
|
28
|
+
* `@rise-x-apps/vendor-hub` -> `app_vendor_hub`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function deriveAppScope(packageName: string): string;
|
|
31
|
+
export declare function defineAppConfig({ pkg, port, standalone, exposes, }: DefineAppConfigOptions): RsbuildConfig;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveAppScope = deriveAppScope;
|
|
4
|
+
exports.defineAppConfig = defineAppConfig;
|
|
5
|
+
const node_module_1 = require("node:module");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const plugin_react_1 = require("@rsbuild/plugin-react");
|
|
8
|
+
const plugin_type_check_1 = require("@rsbuild/plugin-type-check");
|
|
9
|
+
const lifecycle_1 = require("../lifecycle");
|
|
10
|
+
// The shell validates an app's scope against this, and `uniqueName` (the
|
|
11
|
+
// chunk-loading global) is the same string — so an invalid scope fails at
|
|
12
|
+
// runtime in ways that are hard to trace. Fail at config time instead.
|
|
13
|
+
const SCOPE_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
14
|
+
// React and its JSX runtimes are CONSUMED from the shell and never bundled.
|
|
15
|
+
// `import: false` prevents the duplicate-React-instance failure where Module
|
|
16
|
+
// Federation's singleton dedup picks the higher version after the host has
|
|
17
|
+
// already bound its react-dom to a lower one. The jsx-runtime entries are
|
|
18
|
+
// required because React 18's automatic JSX transform emits
|
|
19
|
+
// `import 'react/jsx-runtime'`; unshared, the bundled runtime would
|
|
20
|
+
// sync-require('react') and fail. A config with these shares only runs inside
|
|
21
|
+
// a host — standalone dev takes the `standalone` branch below, which bundles
|
|
22
|
+
// React itself.
|
|
23
|
+
//
|
|
24
|
+
// The version range must cover BOTH hosts: ClientApp resolves React 18, Shell
|
|
25
|
+
// resolves 19. Most apps' webpack configs carry a literal '^18.0.0', which Shell
|
|
26
|
+
// does not satisfy — it logs one warning per shared entry on every app load, and
|
|
27
|
+
// it states a constraint the apps do not actually have. Both hosts DERIVE the
|
|
28
|
+
// version they provide from the resolved package precisely so it cannot rot
|
|
29
|
+
// (see ClientApp/webpack.config.js).
|
|
30
|
+
//
|
|
31
|
+
// The range matches this package's own `react` peer range, and
|
|
32
|
+
// apps/medication-identifier already ships it in production. Be precise about
|
|
33
|
+
// what it does: with `singleton` and no `strictVersion` it does NOT reject a
|
|
34
|
+
// host on another React major — the host's copy is consumed either way. The
|
|
35
|
+
// range documents intent and silences the warning. Anyone adding
|
|
36
|
+
// `strictVersion` later is changing that, deliberately.
|
|
37
|
+
//
|
|
38
|
+
// Accepting both majors is a build-level permission, not a licence to use
|
|
39
|
+
// React 19 APIs. ClientApp is still the production host on React 18, so app
|
|
40
|
+
// code must stay on the React 18-compatible API surface (see AGENTS.md).
|
|
41
|
+
const CONSUMED_REACT_SHARE = {
|
|
42
|
+
singleton: true,
|
|
43
|
+
requiredVersion: '^18.0.0 || ^19.0.0',
|
|
44
|
+
import: false,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Derive an app's Module Federation scope from its package name:
|
|
48
|
+
* `@rise-x-apps/vendor-hub` -> `app_vendor_hub`.
|
|
49
|
+
*/
|
|
50
|
+
function deriveAppScope(packageName) {
|
|
51
|
+
const slug = packageName.replace(/^@[^/]+\//, '');
|
|
52
|
+
const scope = `app_${slug.replace(/-/g, '_')}`;
|
|
53
|
+
if (!SCOPE_PATTERN.test(scope)) {
|
|
54
|
+
throw new Error(`[apps-sdk] Cannot derive a valid Module Federation scope from package name "${packageName}" ` +
|
|
55
|
+
`(got "${scope}", which must match ${SCOPE_PATTERN}). Rename the package, or set APP_SCOPE.`);
|
|
56
|
+
}
|
|
57
|
+
return scope;
|
|
58
|
+
}
|
|
59
|
+
function defineAppConfig({ pkg, port, standalone = false, exposes, }) {
|
|
60
|
+
// APP_SCOPE overrides the derived scope, for the case where an app must be
|
|
61
|
+
// registered ALONGSIDE another build of itself (e.g. an old and a redesigned
|
|
62
|
+
// version, side by side, to compare them). Two registrations may not share a
|
|
63
|
+
// scope: the shell resolves the container from `window[manifest.scope]` and
|
|
64
|
+
// caches loaded scripts by URL, so once the second remoteEntry.js has
|
|
65
|
+
// overwritten the global, the first registration re-uses the cached script
|
|
66
|
+
// promise and serves the SECOND app's container for both. Leave it unset for
|
|
67
|
+
// normal releases — the derived value is the app's identity.
|
|
68
|
+
const override = process.env.APP_SCOPE;
|
|
69
|
+
if (override && !SCOPE_PATTERN.test(override)) {
|
|
70
|
+
throw new Error(`[apps-sdk] APP_SCOPE="${override}" is not a valid Module Federation scope ` +
|
|
71
|
+
`(it must match ${SCOPE_PATTERN}).`);
|
|
72
|
+
}
|
|
73
|
+
const scope = override || deriveAppScope(pkg.name);
|
|
74
|
+
const base = {
|
|
75
|
+
// pluginTypeCheck is NOT optional polish. The webpack configs this preset
|
|
76
|
+
// replaces used ts-loader, which type-checked on every build, and that pass
|
|
77
|
+
// was each app's ONLY type gate: no workflow runs an app's `tsc` — the PR
|
|
78
|
+
// check builds ClientApp and Shell only, build-workspace-packages
|
|
79
|
+
// deliberately excludes apps/, and the pre-commit hook covers Shell,
|
|
80
|
+
// packages/ui and ClientApp. Rsbuild transpiles with SWC, which strips
|
|
81
|
+
// types without checking them, so without this `pnpm build` would happily
|
|
82
|
+
// produce a deploy artifact from code that does not compile.
|
|
83
|
+
plugins: [(0, plugin_react_1.pluginReact)(), (0, plugin_type_check_1.pluginTypeCheck)()],
|
|
84
|
+
source: {
|
|
85
|
+
entry: { index: './src/index.tsx' },
|
|
86
|
+
define: {
|
|
87
|
+
__APP_VERSION__: JSON.stringify(pkg.version ?? '0.0.0'),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
html: { template: './public/index.html' },
|
|
91
|
+
server: {
|
|
92
|
+
port,
|
|
93
|
+
historyApiFallback: true,
|
|
94
|
+
// `public/` holds only the HTML template, which `html.template` already
|
|
95
|
+
// consumes. Left enabled, Rsbuild would also copy it to the dist root and
|
|
96
|
+
// clobber the generated index.html.
|
|
97
|
+
publicDir: false,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
if (standalone) {
|
|
101
|
+
// Resolve React from the APP, not from the SDK — apps live at varying
|
|
102
|
+
// depths and pnpm hoists unpredictably.
|
|
103
|
+
const appRequire = (0, node_module_1.createRequire)((0, node_path_1.join)(process.cwd(), 'package.json'));
|
|
104
|
+
return {
|
|
105
|
+
...base,
|
|
106
|
+
output: {
|
|
107
|
+
distPath: { root: 'dist-local' },
|
|
108
|
+
assetPrefix: '/',
|
|
109
|
+
},
|
|
110
|
+
resolve: {
|
|
111
|
+
alias: {
|
|
112
|
+
// No shell means no share scope, so bundle the SDK's own compiled
|
|
113
|
+
// snapshot of the design system (CSS self-injected, Inter included).
|
|
114
|
+
// The federated build still gets the host's copy via the share scope.
|
|
115
|
+
'@rise-x/ui': require.resolve('@rise-x/apps-sdk/ui/standalone'),
|
|
116
|
+
// ONE React copy in the bundle. The workspace hoists react@18 to the
|
|
117
|
+
// root, but lucide-react, radix-ui and sonner all peer on React 19 and
|
|
118
|
+
// pnpm nests react@19 under each of them. The federated build is
|
|
119
|
+
// immune — Module Federation's `shared` rewires every `react` request
|
|
120
|
+
// in the compilation, including those inside node_modules. Standalone
|
|
121
|
+
// dev has no share scope, so without these aliases lucide's icons are
|
|
122
|
+
// built by React 19's createElement and the app's React 18 renderer
|
|
123
|
+
// rejects them outright ("Objects are not valid as a React child").
|
|
124
|
+
react: (0, node_path_1.dirname)(appRequire.resolve('react/package.json')),
|
|
125
|
+
'react-dom': (0, node_path_1.dirname)(appRequire.resolve('react-dom/package.json')),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...base,
|
|
132
|
+
output: {
|
|
133
|
+
// Flat dist: remoteEntry.js plus its sibling chunks at the archive root.
|
|
134
|
+
// tools/apps-dev-server probes `dist/remoteEntry.js`, and the deploy zips
|
|
135
|
+
// the CONTENTS of dist/ with remoteEntry.js at the top level.
|
|
136
|
+
distPath: { root: 'dist', js: '', jsAsync: '', css: '', cssAsync: '' },
|
|
137
|
+
// 'auto' derives the chunk base URL from document.currentScript.src at
|
|
138
|
+
// runtime, so one bundle works both in dev and when the shell loads
|
|
139
|
+
// remoteEntry.js from the CDN under /apps/<id>/<version>/.
|
|
140
|
+
assetPrefix: 'auto',
|
|
141
|
+
},
|
|
142
|
+
// `output.assetPrefix` above is the PRODUCTION value only — the dev server
|
|
143
|
+
// reads `dev.assetPrefix`, which otherwise defaults to `/`. Without this,
|
|
144
|
+
// a remote served by `rsbuild dev` resolves its async chunks against the
|
|
145
|
+
// HOST's origin and 404s, because webpack's single `output.publicPath`
|
|
146
|
+
// covered both modes and Rsbuild's does not.
|
|
147
|
+
dev: { assetPrefix: 'auto' },
|
|
148
|
+
server: {
|
|
149
|
+
...base.server,
|
|
150
|
+
// The shell's dev server fetches remoteEntry.js cross-origin.
|
|
151
|
+
headers: { 'Access-Control-Allow-Origin': '*' },
|
|
152
|
+
},
|
|
153
|
+
tools: {
|
|
154
|
+
rspack: (config, { rspack, appendPlugins, isProd }) => {
|
|
155
|
+
// Rsbuild defaults production source maps OFF; the webpack configs this
|
|
156
|
+
// replaces shipped them, and without them a deployed app is unreadable
|
|
157
|
+
// in a devtools stack trace. Set here rather than via
|
|
158
|
+
// `output.sourceMap`, which is mode-agnostic and would also downgrade
|
|
159
|
+
// dev rebuilds to the slowest option.
|
|
160
|
+
if (isProd) {
|
|
161
|
+
config.devtool = 'source-map';
|
|
162
|
+
}
|
|
163
|
+
// Rsbuild has no `output.uniqueName`, and it is load-bearing: it names
|
|
164
|
+
// the chunk-loading global, which must not collide with the host's.
|
|
165
|
+
config.output.uniqueName = scope;
|
|
166
|
+
appendPlugins(
|
|
167
|
+
// V1 = the webpack-aligned Module Federation implementation. It emits
|
|
168
|
+
// the container shape (`window[scope].init/get`) that BOTH hosts'
|
|
169
|
+
// runtime loaders speak. Never the enhanced plugin.
|
|
170
|
+
new rspack.container.ModuleFederationPluginV1({
|
|
171
|
+
name: scope,
|
|
172
|
+
filename: 'remoteEntry.js',
|
|
173
|
+
exposes: {
|
|
174
|
+
'./App': './src/App',
|
|
175
|
+
[lifecycle_1.LIFECYCLE_MODULE_NAME]: './src/lifecycle',
|
|
176
|
+
...exposes,
|
|
177
|
+
},
|
|
178
|
+
shared: {
|
|
179
|
+
react: CONSUMED_REACT_SHARE,
|
|
180
|
+
'react-dom': CONSUMED_REACT_SHARE,
|
|
181
|
+
'react/jsx-runtime': CONSUMED_REACT_SHARE,
|
|
182
|
+
'react/jsx-dev-runtime': CONSUMED_REACT_SHARE,
|
|
183
|
+
// The design system, imported via `@rise-x/apps-sdk/ui`. The host
|
|
184
|
+
// provides the only copy — and the compiled Tailwind CSS that
|
|
185
|
+
// styles it — so never bundle a fallback.
|
|
186
|
+
'@rise-x/ui': {
|
|
187
|
+
singleton: true,
|
|
188
|
+
requiredVersion: false,
|
|
189
|
+
import: false,
|
|
190
|
+
},
|
|
191
|
+
// Unlike react, KEEP the bundled fallback: the app loads through
|
|
192
|
+
// an async MF boundary so there is no eager sync-require hazard,
|
|
193
|
+
// and the fallback keeps the app working on hosts that do not
|
|
194
|
+
// share react-query.
|
|
195
|
+
'@tanstack/react-query': {
|
|
196
|
+
singleton: true,
|
|
197
|
+
requiredVersion: '^5.0.0',
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
}));
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare function AppFrame({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
3
|
+
/** Fixed left rail from md up (180px, the Nav convention; override via
|
|
4
|
+
* className) — long rails scroll themselves, the page never scrolls them
|
|
5
|
+
* away. Below md it renders as a horizontal nav strip under the top bar. */
|
|
6
|
+
declare function AppRail({ className, ...props }: React.ComponentProps<'aside'>): React.JSX.Element;
|
|
7
|
+
/** The scrolling content column. From md up it spans under the shell top bar —
|
|
8
|
+
* the top padding keeps resting content below it, so only scrolled content
|
|
9
|
+
* passes behind. Below md the rail strip clears the bar and the column
|
|
10
|
+
* scrolls beneath it with plain padding; a rail-less frame (AppContent as
|
|
11
|
+
* the frame's first child) pads itself below the bar instead. */
|
|
12
|
+
declare function AppContent({ className, ...props }: React.ComponentProps<'main'>): React.JSX.Element;
|
|
13
|
+
export { AppFrame, AppRail, AppContent };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
declare function Nav({ className, ...props }: React.ComponentProps<'nav'>): React.JSX.Element;
|
|
3
|
-
declare function NavItem({ className, current, ...props }: React.ComponentProps<'button'> & {
|
|
3
|
+
declare function NavItem({ className, current, asChild, ...props }: React.ComponentProps<'button'> & {
|
|
4
4
|
current?: boolean;
|
|
5
|
+
asChild?: boolean;
|
|
5
6
|
}): React.JSX.Element;
|
|
6
7
|
declare function NavSection({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
7
8
|
declare function Panel({ className, ...props }: React.ComponentProps<'aside'>): React.JSX.Element;
|
package/build/ui/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './components/accordion';
|
|
|
2
2
|
export * from './components/ai';
|
|
3
3
|
export * from './components/alert';
|
|
4
4
|
export * from './components/alert-dialog';
|
|
5
|
+
export * from './components/app-frame';
|
|
5
6
|
export * from './components/aspect-ratio';
|
|
6
7
|
export * from './components/avatar';
|
|
7
8
|
export * from './components/badge';
|
|
@@ -72,7 +72,9 @@ function AiWorking({ className, children, ...props }: React.ComponentProps<'span
|
|
|
72
72
|
<span
|
|
73
73
|
data-slot="ai-working"
|
|
74
74
|
className={cn(
|
|
75
|
-
|
|
75
|
+
// gap-1.5 is the icon-to-text step used by AiNote / AiExplainSummary;
|
|
76
|
+
// the dots keep their own tighter gap-1 below.
|
|
77
|
+
'inline-flex items-center gap-1.5 rounded-full bg-ai/9 px-[11px] py-2 text-ui text-ai-text',
|
|
76
78
|
className,
|
|
77
79
|
)}
|
|
78
80
|
{...props}
|
|
@@ -45,7 +45,7 @@ const AlertDialogOverlay = React.forwardRef<
|
|
|
45
45
|
ref={ref}
|
|
46
46
|
data-slot="alert-dialog-overlay"
|
|
47
47
|
className={cn(
|
|
48
|
-
'fixed inset-0 z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
48
|
+
'fixed inset-0 z-50 bg-black/30 duration-100 dark:bg-black/60 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
49
49
|
className,
|
|
50
50
|
)}
|
|
51
51
|
{...props}
|
|
@@ -169,13 +169,12 @@ const AlertDialogAction = React.forwardRef<
|
|
|
169
169
|
Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>
|
|
170
170
|
>(function AlertDialogAction({ className, variant = 'default', size = 'default', ...props }, ref) {
|
|
171
171
|
return (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/>
|
|
172
|
+
// className goes to the Button, not to the slotted child: Radix's Slot
|
|
173
|
+
// CONCATENATES classNames instead of merging them, so a caller's override on
|
|
174
|
+
// the child would tie with the variant's own class and lose or win purely on
|
|
175
|
+
// stylesheet order. Routed here, it goes through Button's cn() and wins.
|
|
176
|
+
<Button variant={variant} size={size} className={className} asChild>
|
|
177
|
+
<AlertDialogPrimitive.Action ref={ref} data-slot="alert-dialog-action" {...props} />
|
|
179
178
|
</Button>
|
|
180
179
|
);
|
|
181
180
|
});
|
|
@@ -186,13 +185,8 @@ const AlertDialogCancel = React.forwardRef<
|
|
|
186
185
|
Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>
|
|
187
186
|
>(function AlertDialogCancel({ className, variant = 'outline', size = 'default', ...props }, ref) {
|
|
188
187
|
return (
|
|
189
|
-
<Button variant={variant} size={size} asChild>
|
|
190
|
-
<AlertDialogPrimitive.Cancel
|
|
191
|
-
ref={ref}
|
|
192
|
-
data-slot="alert-dialog-cancel"
|
|
193
|
-
className={cn(className)}
|
|
194
|
-
{...props}
|
|
195
|
-
/>
|
|
188
|
+
<Button variant={variant} size={size} className={className} asChild>
|
|
189
|
+
<AlertDialogPrimitive.Cancel ref={ref} data-slot="alert-dialog-cancel" {...props} />
|
|
196
190
|
</Button>
|
|
197
191
|
);
|
|
198
192
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* THE APP LAYOUT CONTRACT for federated apps.
|
|
7
|
+
*
|
|
8
|
+
* The next-gen shell hands an app a full-bleed region that extends UNDER its
|
|
9
|
+
* floating top bar and publishes the bar's height as `--topbar-h` on the
|
|
10
|
+
* document. These three primitives split that region the way the shell's own
|
|
11
|
+
* surfaces do: a rail that starts below the bar and never scrolls away, and a
|
|
12
|
+
* content column whose scroller spans the full height so content slides in
|
|
13
|
+
* BEHIND the bar's progressive blur instead of being clipped at its edge.
|
|
14
|
+
*
|
|
15
|
+
* RESPONSIVE STANDARD: below md the frame stacks — the rail becomes a
|
|
16
|
+
* horizontal, scrollable nav strip under the top bar (Nav rows flip to a row,
|
|
17
|
+
* NavSection headers hide) and the content column scrolls beneath it. Apps
|
|
18
|
+
* get a sane phone/tablet layout without writing their own breakpoints.
|
|
19
|
+
*
|
|
20
|
+
* In hosts that don't publish the variable (the classic ClientApp shell,
|
|
21
|
+
* standalone dev) every offset falls back to 0px and the frame degrades to a
|
|
22
|
+
* plain rail-plus-content flex layout in normal flow.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function AppFrame({ className, ...props }: React.ComponentProps<'div'>) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
data-slot="app-frame"
|
|
29
|
+
className={cn('flex h-full min-h-0 flex-col text-foreground md:flex-row', className)}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Fixed left rail from md up (180px, the Nav convention; override via
|
|
36
|
+
* className) — long rails scroll themselves, the page never scrolls them
|
|
37
|
+
* away. Below md it renders as a horizontal nav strip under the top bar. */
|
|
38
|
+
function AppRail({ className, ...props }: React.ComponentProps<'aside'>) {
|
|
39
|
+
return (
|
|
40
|
+
<aside
|
|
41
|
+
data-slot="app-rail"
|
|
42
|
+
className={cn(
|
|
43
|
+
'flex w-full shrink-0 flex-row items-center gap-1 overflow-x-auto px-3 pt-[calc(var(--topbar-h,0px)_+_8px)] pb-1',
|
|
44
|
+
'max-md:[&_[data-slot=nav]]:flex-row max-md:[&_[data-slot=nav]]:items-center max-md:[&_[data-slot=nav-item]]:w-auto max-md:[&_[data-slot=nav-item]]:shrink-0 max-md:[&_[data-slot=nav-section]]:hidden',
|
|
45
|
+
'md:w-[180px] md:flex-col md:items-stretch md:gap-0 md:overflow-x-visible md:overflow-y-auto md:p-3 md:pt-[calc(var(--topbar-h,0px)_+_12px)]',
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The scrolling content column. From md up it spans under the shell top bar —
|
|
54
|
+
* the top padding keeps resting content below it, so only scrolled content
|
|
55
|
+
* passes behind. Below md the rail strip clears the bar and the column
|
|
56
|
+
* scrolls beneath it with plain padding; a rail-less frame (AppContent as
|
|
57
|
+
* the frame's first child) pads itself below the bar instead. */
|
|
58
|
+
function AppContent({ className, ...props }: React.ComponentProps<'main'>) {
|
|
59
|
+
return (
|
|
60
|
+
<main
|
|
61
|
+
data-slot="app-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
'min-w-0 flex-1 overflow-y-auto p-4 max-md:first:pt-[calc(var(--topbar-h,0px)_+_16px)] md:p-6 md:pt-[calc(var(--topbar-h,0px)_+_24px)]',
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { AppFrame, AppRail, AppContent };
|
|
@@ -52,8 +52,10 @@ const buttonVariants = cva(
|
|
|
52
52
|
* upload glyph still describes the control after a file is chosen. */
|
|
53
53
|
dashed:
|
|
54
54
|
'border-dashed border-border-strong text-muted-foreground hover:bg-fill-1 hover:text-foreground aria-pressed:border-solid aria-pressed:border-transparent aria-pressed:bg-fill-2 aria-pressed:text-foreground aria-pressed:hover:bg-fill-3 aria-pressed:[&>svg:first-child]:hidden data-filled:border-solid data-filled:border-transparent data-filled:bg-fill-2 data-filled:text-foreground data-filled:hover:bg-fill-3',
|
|
55
|
-
/* Rise-X wireframe pill —
|
|
56
|
-
|
|
55
|
+
/* Rise-X wireframe pill — frosted-glass surface, soft shadow, fully
|
|
56
|
+
* rounded. Translucent + backdrop blur so scrolled content shows
|
|
57
|
+
* through without hurting label contrast. */
|
|
58
|
+
pill: 'rounded-full border-border/60 bg-card/70 text-card-foreground shadow-pill backdrop-blur-xl backdrop-saturate-150 hover:shadow-card aria-expanded:shadow-card',
|
|
57
59
|
},
|
|
58
60
|
size: {
|
|
59
61
|
default:
|
|
@@ -115,7 +115,12 @@ const Combobox = React.forwardRef<
|
|
|
115
115
|
{options.map((option) => (
|
|
116
116
|
<CommandItem
|
|
117
117
|
key={option.value}
|
|
118
|
-
value
|
|
118
|
+
// value is cmdk's IDENTITY, so it has to be the option's own
|
|
119
|
+
// value — two options sharing a label would otherwise collapse
|
|
120
|
+
// into one selectable row. Search text goes in keywords, which
|
|
121
|
+
// cmdk scores alongside the value.
|
|
122
|
+
value={option.value}
|
|
123
|
+
keywords={option.keywords ? [option.label, option.keywords] : [option.label]}
|
|
119
124
|
disabled={option.disabled}
|
|
120
125
|
onSelect={() => {
|
|
121
126
|
onValueChange?.(option.value);
|
|
@@ -51,7 +51,7 @@ const DialogOverlay = React.forwardRef<
|
|
|
51
51
|
ref={ref}
|
|
52
52
|
data-slot="dialog-overlay"
|
|
53
53
|
className={cn(
|
|
54
|
-
'fixed inset-0 isolate z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
54
|
+
'fixed inset-0 isolate z-50 bg-black/30 duration-100 dark:bg-black/60 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
55
55
|
className,
|
|
56
56
|
)}
|
|
57
57
|
{...props}
|
|
@@ -150,7 +150,7 @@ function DropdownMenuLabel({
|
|
|
150
150
|
<DropdownMenuPrimitive.Label
|
|
151
151
|
data-slot="dropdown-menu-label"
|
|
152
152
|
data-inset={inset}
|
|
153
|
-
className={cn('px-
|
|
153
|
+
className={cn('px-2 py-2.5 text-xs text-muted-foreground data-inset:pl-9.5', className)}
|
|
154
154
|
{...props}
|
|
155
155
|
/>
|
|
156
156
|
);
|
|
@@ -12,11 +12,12 @@ import { FileCard } from '@rise-x/ui/components/file-upload';
|
|
|
12
12
|
* past the footer instead.
|
|
13
13
|
*
|
|
14
14
|
* THE ASYMMETRY IS THE POINT. A user turn is a bubble — short, quotable, and it
|
|
15
|
-
* needs to be visibly *theirs
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* needs to be visibly *theirs*; it stops at 80% of the column so even a long
|
|
16
|
+
* paste still reads as a bubble against the edge. An assistant turn is NOT: AI
|
|
17
|
+
* answers run long, and a tinted block the height of the viewport is a wall. So
|
|
18
|
+
* `variant="ai"` strips the bubble entirely — no background, no border, no
|
|
19
|
+
* padding — and caps the measure at 68ch so it reads as prose. Colour on an AI
|
|
20
|
+
* turn marks *activity* (see ai.tsx), never the finished answer.
|
|
20
21
|
*/
|
|
21
22
|
function MessageGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
22
23
|
return (
|
|
@@ -110,7 +111,12 @@ function MessageBubble({
|
|
|
110
111
|
className={cn(
|
|
111
112
|
'w-fit max-w-full text-ui leading-[1.55]',
|
|
112
113
|
variant === 'default' && 'rounded-xl bg-fill-1 px-3 py-[9px]',
|
|
113
|
-
variant === 'user' &&
|
|
114
|
+
variant === 'user' &&
|
|
115
|
+
// The raised surface, not --primary: a host that brands --primary pins
|
|
116
|
+
// one colour across both themes, and a mid-grey brand left the bubble
|
|
117
|
+
// almost invisible on a dark page. Card inverts with the theme, so the
|
|
118
|
+
// bubble reads as a pill lifted off the canvas in both.
|
|
119
|
+
'max-w-[80%] rounded-xl border border-border/60 bg-card px-3 py-[9px] text-card-foreground shadow-pill',
|
|
114
120
|
// no bubble at all — see the note at the top of this file
|
|
115
121
|
variant === 'ai' && 'max-w-[68ch] border-0 bg-transparent px-0 pt-px pb-0',
|
|
116
122
|
className,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Slot } from 'radix-ui';
|
|
2
3
|
|
|
3
4
|
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
5
|
|
|
@@ -19,11 +20,15 @@ function Nav({ className, ...props }: React.ComponentProps<'nav'>) {
|
|
|
19
20
|
function NavItem({
|
|
20
21
|
className,
|
|
21
22
|
current,
|
|
23
|
+
asChild = false,
|
|
22
24
|
...props
|
|
23
|
-
}: React.ComponentProps<'button'> & { current?: boolean }) {
|
|
25
|
+
}: React.ComponentProps<'button'> & { current?: boolean; asChild?: boolean }) {
|
|
26
|
+
// asChild renders the item styling onto a link (router <Link>, <a>) so
|
|
27
|
+
// navigation stays cmd/middle-clickable; the default stays a real button.
|
|
28
|
+
const Comp = asChild ? Slot.Root : 'button';
|
|
24
29
|
return (
|
|
25
|
-
<
|
|
26
|
-
type=
|
|
30
|
+
<Comp
|
|
31
|
+
type={asChild ? undefined : 'button'}
|
|
27
32
|
data-slot="nav-item"
|
|
28
33
|
aria-current={current ? 'page' : undefined}
|
|
29
34
|
className={cn(
|
|
@@ -59,7 +59,7 @@ const SheetOverlay = React.forwardRef<
|
|
|
59
59
|
ref={ref}
|
|
60
60
|
data-slot="sheet-overlay"
|
|
61
61
|
className={cn(
|
|
62
|
-
'fixed inset-0 z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
62
|
+
'fixed inset-0 z-50 bg-black/30 duration-100 dark:bg-black/60 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
63
63
|
className,
|
|
64
64
|
)}
|
|
65
65
|
{...props}
|