@dingdao/psuip-generate-sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/index.js +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 @dingdao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# PSUIP Generate SDK
|
|
2
|
+
|
|
3
|
+
PSUIP(Particle Service UI Protocol)是一套用于描述企业级 UI 结构与内容的语义协议。本 SDK 将 PSUIP 文本转化为标准化「八要素」数据结构,可用于「八要素」渲染引擎用于渲染。
|
|
4
|
+
|
|
5
|
+
## 核心能力
|
|
6
|
+
|
|
7
|
+
- **语义解析**:将 PSUIP 文本解析为布局、文本、按钮、卡片、表格、标签、图标等 UI 元素。
|
|
8
|
+
- **设计令牌**:通过 `seed` 自定义主题,动态生成颜色、字体、尺寸等设计令牌。
|
|
9
|
+
- **可视化增强**:内置上千枚矢量图标、表格/图表渲染器以及按钮、卡片等组件生成器。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install psuip-generate-sdk
|
|
15
|
+
# 或
|
|
16
|
+
yarn add psuip-generate-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 快速上手
|
|
20
|
+
|
|
21
|
+
以下示例使用中立的内容片段,展示如何一次性获取标准八要素 JSON:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import PSUIPGenerator from "psuip-generate-sdk";
|
|
25
|
+
|
|
26
|
+
const eightElements = PSUIPGenerator({
|
|
27
|
+
psuip: `
|
|
28
|
+
<card>
|
|
29
|
+
### 智能协同平台
|
|
30
|
+
- ✅ 模块化业务组件
|
|
31
|
+
- ✅ 多终端一致体验
|
|
32
|
+
- ✅ 实时数据洞察
|
|
33
|
+
</card>
|
|
34
|
+
|
|
35
|
+
<layout:row>
|
|
36
|
+
我们提供端到端的数字化实施与 7x24 支持。
|
|
37
|
+
</layout:row>
|
|
38
|
+
`,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(eightElements); // 八要素对象
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### `PSUIPGenerator(options)`
|
|
47
|
+
|
|
48
|
+
| 参数 | 类型 | 说明 |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `psuip` | `string` | 必填,符合 PSUIP 语法的文本内容。 |
|
|
51
|
+
| `seed` | `object` | 选填,自定义品牌/主题种子,内部将衍生出颜色、尺寸、字体等设计令牌。 |
|
|
52
|
+
|
|
53
|
+
## 自定义主题(seed 示例)
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const customTheme = PSUIPGenerator({
|
|
57
|
+
psuip: `# Hello PSUIP`,
|
|
58
|
+
seed: {
|
|
59
|
+
shape: 5,
|
|
60
|
+
degree: 5,
|
|
61
|
+
font: 5,
|
|
62
|
+
material: 5,
|
|
63
|
+
color: '#0000FF'
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
传入 `seed` 后,SDK 会:
|
|
69
|
+
|
|
70
|
+
1. 通过 `calculateTokens` 生成设计令牌;
|
|
71
|
+
2. 注入动态 Token 系统解析 PSUIP;
|
|
72
|
+
|
|
73
|
+
## 构建与发布
|
|
74
|
+
|
|
75
|
+
- `npm run build`:使用 Rollup 产出 `dist/index.js`。
|
|
76
|
+
- `npm publish`:发布前会自动执行 `prepublishOnly` 完成构建。
|
|
77
|
+
|
|
78
|
+
## 许可证
|
|
79
|
+
|
|
80
|
+
MIT License © Dingdao
|