@nuwatop/code-canvas-runtime 0.1.3 → 0.1.4
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 +58 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @nuwatop/code-canvas-runtime
|
|
2
|
+
|
|
3
|
+
Runtime utilities for **code-canvas** generated React applications. Re-exports [`@nuwatop/code-canvas-core`](https://www.npmjs.com/package/@nuwatop/code-canvas-core) and adds command watching, runtime rendering, and related helpers.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Peer dependencies: `react`, `react-dom`, `antd`, `zustand`, etc. (see `package.json` → `peerDependencies`).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @nuwatop/code-canvas-runtime
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Typical imports in generated app code (`Extend.ts` / pages):
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import {
|
|
19
|
+
createWatchCommands,
|
|
20
|
+
useAndStore,
|
|
21
|
+
useItemStore,
|
|
22
|
+
} from "@nuwatop/code-canvas-runtime";
|
|
23
|
+
|
|
24
|
+
const watchCommandsWithContext = createWatchCommands(() => ({
|
|
25
|
+
// command handlers keyed by action name
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
export function init(store?: unknown) {
|
|
29
|
+
if (store) {
|
|
30
|
+
watchCommandsWithContext(store as never, "your-session-id");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Other exports include `RuntimeRenderer`, `ComponentRegistry`, `initRuntime`, `UIUtils`, validation helpers, etc. — see `src/index.ts`.
|
|
36
|
+
|
|
37
|
+
## 发布到 npm(维护者)
|
|
38
|
+
|
|
39
|
+
在 **`runtime` 目录**下,先改好 `package.json` 里的 **`version`**(不能和已发布版本重复),登录 npm 官方源后执行:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm publish --access public
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- **`--access public`**:本包是 scoped 包(`@nuwatop/...`),公开到 npmjs 必须加这一项。
|
|
46
|
+
- **`prepublishOnly`** 已配置为自动 `npm run build`,一般无需先手动 `build`。
|
|
47
|
+
|
|
48
|
+
若本机默认 registry 是镜像(如 npmmirror,不能 `publish`),可:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm publish --access public --registry https://registry.npmjs.org/
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
或在 `runtime/.npmrc` 中指定 `registry=https://registry.npmjs.org/`(含 token 时不要提交到 Git)。
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|