realibox-ui-sdk 0.0.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/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # realibox-ui-sdk
2
+
3
+ `realibox-ui-sdk` 用于在网页中嵌入 `product-3d-viewer` 组件。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install realibox-ui-sdk
9
+ ```
10
+
11
+
12
+
13
+ ```bash
14
+ pnpm add realibox-ui-sdk
15
+ ```
16
+
17
+ ## 使用流程
18
+
19
+ 接入分为两步:
20
+
21
+ 1. 调用 `initSDK` 完成初始化
22
+ 2. 在页面中使用 `<product-3d-viewer>` 组件
23
+
24
+ ## 初始化
25
+
26
+ 使用组件前必须先执行 `initSDK`。
27
+
28
+ ```ts
29
+ import { initSDK } from "realibox-ui-sdk";
30
+
31
+ initSDK({
32
+ key: "your-key",
33
+ mode: "development",
34
+ });
35
+ ```
36
+
37
+ ### `initSDK` 参数说明
38
+
39
+ | 参数名 | 类型 | 是否必填 | 说明 |
40
+ | ------ | ------------------------------- | -------- | --------------------------------------------------------------------- |
41
+ | `key` | `string` | 是 | SDK 授权密钥。不能为空。 |
42
+ | `mode` | `"development" \| "production"` | 是 | SDK 运行环境。`development` 使用测试环境,`production` 使用正式环境。 |
43
+
44
+ ## 组件
45
+
46
+ 组件名:`product-3d-viewer`
47
+
48
+ ### 组件参数说明
49
+
50
+ 不同接入方式下,项目 ID 的参数名不同:
51
+
52
+ | 接入方式 | 参数名 | 类型 | 是否必填 | 说明 |
53
+ | --------------------- | ------------ | -------- | -------- | ---------- |
54
+ | React | `projectId` | `string` | 是 | 3D 项目 ID |
55
+ | Vue | `projectId` | `string` | 是 | 3D 项目 ID |
56
+ | HTML / CDN / 其他框架 | `project-id` | `string` | 是 | 3D 项目 ID |
57
+
58
+ ## 示例
59
+
60
+ ### HTML
61
+
62
+ ```html
63
+ <script type="module">
64
+ import { initSDK } from "realibox-ui-sdk";
65
+
66
+ initSDK({
67
+ key: "your-key",
68
+ mode: "development",
69
+ });
70
+ </script>
71
+
72
+ <product-3d-viewer project-id="your-project-id"></product-3d-viewer>
73
+ ```
74
+
75
+ ### React
76
+
77
+ ```tsx
78
+ import { initSDK } from "realibox-ui-sdk";
79
+
80
+ initSDK({
81
+ key: "your-key",
82
+ mode: "development",
83
+ });
84
+
85
+ export default function App() {
86
+ return <product-3d-viewer projectId="your-project-id" />;
87
+ }
88
+ ```
89
+
90
+ ### Vue
91
+
92
+ Vue 使用 Web Components 时,需要先将 `product-3d-viewer` 声明为自定义元素。
93
+
94
+ `vite.config.js`
95
+
96
+ ```js
97
+ import vue from "@vitejs/plugin-vue";
98
+ import { defineConfig } from "vite";
99
+
100
+ export default defineConfig({
101
+ plugins: [
102
+ vue({
103
+ template: {
104
+ compilerOptions: {
105
+ isCustomElement: (tag) => tag === "product-3d-viewer",
106
+ },
107
+ },
108
+ }),
109
+ ],
110
+ });
111
+ ```
112
+
113
+ `src/vite-env.d.ts`
114
+
115
+ ```ts
116
+ /// <reference types="vite/client" />
117
+
118
+ import type {} from "realibox-ui-sdk/vue";
119
+ ```
120
+
121
+ `tsconfig.json`
122
+
123
+ ```json
124
+ {
125
+ "compilerOptions": {
126
+ "target": "ES2022",
127
+ "module": "ESNext",
128
+ "moduleResolution": "Bundler",
129
+ "strict": true,
130
+ "jsx": "preserve",
131
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
132
+ "skipLibCheck": true,
133
+ "types": ["vite/client"]
134
+ },
135
+ "vueCompilerOptions": {
136
+ "strictTemplates": true
137
+ },
138
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"]
139
+ }
140
+ ```
141
+
142
+ `App.vue`
143
+
144
+ ```vue
145
+ <script setup lang="ts">
146
+ import { initSDK } from "realibox-ui-sdk";
147
+
148
+ initSDK({
149
+ key: "your-key",
150
+ mode: "development",
151
+ });
152
+ </script>
153
+
154
+ <template>
155
+ <product-3d-viewer projectId="your-project-id" />
156
+ </template>
157
+ ```
158
+
159
+ ### CDN
160
+
161
+ ```html
162
+ <script src="https://cdn.jsdelivr.net/npm/realibox-ui-sdk@0.0.2/dist/realibox-ui-sdk.umd.js"></script>
163
+ <script>
164
+ window.RealiboxUISDK.initSDK({
165
+ key: "your-key",
166
+ mode: "development",
167
+ });
168
+ </script>
169
+
170
+ <product-3d-viewer project-id="your-project-id"></product-3d-viewer>
171
+ ```
@@ -0,0 +1,85 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "README.md",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "dist/components/product-3d-viewer.js",
8
+ "declarations": [
9
+ {
10
+ "kind": "class",
11
+ "name": "Product3dViewer",
12
+ "tagName": "product-3d-viewer",
13
+ "attributes": [
14
+ {
15
+ "name": "project-id",
16
+ "type": {
17
+ "text": "string"
18
+ },
19
+ "fieldName": "projectId"
20
+ },
21
+ {
22
+ "name": "placeholder",
23
+ "type": {
24
+ "text": "string | undefined"
25
+ },
26
+ "fieldName": "placeholder"
27
+ },
28
+ {
29
+ "name": "size",
30
+ "type": {
31
+ "text": "\"sm\" | \"md\" | \"lg\" | \"none\" | undefined"
32
+ },
33
+ "fieldName": "size"
34
+ },
35
+ {
36
+ "name": "show-top-header",
37
+ "type": {
38
+ "text": "boolean | undefined"
39
+ },
40
+ "fieldName": "showTopHeader"
41
+ },
42
+ {
43
+ "name": "part-selection",
44
+ "type": {
45
+ "text": "boolean | undefined"
46
+ },
47
+ "fieldName": "partSelection"
48
+ },
49
+ {
50
+ "name": "camera-focus",
51
+ "type": {
52
+ "text": "boolean | undefined"
53
+ },
54
+ "fieldName": "cameraFocus"
55
+ },
56
+ {
57
+ "name": "design",
58
+ "type": {
59
+ "text": "boolean | undefined"
60
+ },
61
+ "fieldName": "design"
62
+ },
63
+ {
64
+ "name": "outline-render",
65
+ "type": {
66
+ "text": "boolean | undefined"
67
+ },
68
+ "fieldName": "outlineRender"
69
+ }
70
+ ]
71
+ }
72
+ ],
73
+ "exports": [
74
+ {
75
+ "kind": "custom-element-definition",
76
+ "name": "product-3d-viewer",
77
+ "declaration": {
78
+ "name": "Product3dViewer",
79
+ "module": "dist/components/product-3d-viewer.js"
80
+ }
81
+ }
82
+ ]
83
+ }
84
+ ]
85
+ }
@@ -0,0 +1 @@
1
+ export * from './product';
@@ -0,0 +1,4 @@
1
+ import { ProductSearchRequest, ProductSearchResponse } from './types/product-search.type';
2
+ export type { AttributeFilter, ProductSearchRequest } from './types/product-search.type';
3
+ export type { AssetSimple, AttributeValueItem, BaseDataPagination, ProductAttributeGroupItem, ProductAttributeItem, ProductSearchItem, ProductSearchResponse, } from './types/product-search.type';
4
+ export declare const postSearchProductsApi: (body: ProductSearchRequest) => Promise<ProductSearchResponse>;
@@ -0,0 +1,84 @@
1
+ export interface AttributeFilter {
2
+ attribute_code: string;
3
+ operator: string;
4
+ value: unknown;
5
+ [property: string]: unknown;
6
+ }
7
+ export interface ProductSearchRequest {
8
+ category_ids?: string[];
9
+ filters?: AttributeFilter[];
10
+ has_3d?: boolean;
11
+ keyword?: string;
12
+ limit?: number;
13
+ org_id?: string;
14
+ recommend_types?: string[];
15
+ share_code?: string;
16
+ skip?: number;
17
+ sort_by?: string;
18
+ sort_order?: string;
19
+ status?: number;
20
+ [property: string]: unknown;
21
+ }
22
+ export interface AssetSimple {
23
+ asset_type: string;
24
+ content?: string;
25
+ media_type: string;
26
+ sort_order?: number;
27
+ url?: string;
28
+ uuid: string;
29
+ [property: string]: unknown;
30
+ }
31
+ export interface AttributeValueItem {
32
+ label?: string;
33
+ spec_row_index: number;
34
+ value?: unknown;
35
+ [property: string]: unknown;
36
+ }
37
+ export interface ProductAttributeItem {
38
+ code: string;
39
+ field_type: string;
40
+ name: string;
41
+ unit?: string;
42
+ values?: AttributeValueItem[];
43
+ [property: string]: unknown;
44
+ }
45
+ export interface ProductAttributeGroupItem {
46
+ attributes?: ProductAttributeItem[];
47
+ code: string;
48
+ is_spec_group?: boolean;
49
+ name: string;
50
+ [property: string]: unknown;
51
+ }
52
+ export interface ProductSearchItem {
53
+ assets?: AssetSimple[];
54
+ attribute_groups?: ProductAttributeGroupItem[];
55
+ category_ids?: string[];
56
+ code?: string;
57
+ cover_image?: string;
58
+ create_time: number;
59
+ is_collected?: boolean;
60
+ name: string;
61
+ project_id?: string;
62
+ project_type: string;
63
+ recommend_type: string;
64
+ status: number;
65
+ uuid: string;
66
+ [property: string]: unknown;
67
+ }
68
+ export interface BaseDataPagination {
69
+ limit: number;
70
+ offset: number;
71
+ total: number;
72
+ [property: string]: unknown;
73
+ }
74
+ export interface ProductSearchResponse {
75
+ code: number;
76
+ info: Record<string, unknown>;
77
+ list: {
78
+ data: ProductSearchItem[];
79
+ pagination: boolean | BaseDataPagination;
80
+ [property: string]: unknown;
81
+ };
82
+ message?: unknown;
83
+ [property: string]: unknown;
84
+ }