@virtualdisplay.io/client 3.6.0 → 4.0.0-alpha.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/CHANGELOG.md +46 -74
- package/LICENSE +1 -1
- package/README.md +278 -340
- package/dist/index.d.ts +151 -497
- package/dist/virtualdisplay.client.cjs.js +1 -7
- package/dist/virtualdisplay.client.cjs.js.map +1 -1
- package/dist/virtualdisplay.client.es.js +1 -7859
- package/dist/virtualdisplay.client.es.js.map +1 -1
- package/dist/virtualdisplay.client.umd.js +1 -7
- package/dist/virtualdisplay.client.umd.js.map +1 -1
- package/package.json +14 -98
- package/README.npm.md +0 -483
- package/node_modules/@virtualdisplay-io/logger/CHANGELOG.md +0 -82
- package/node_modules/@virtualdisplay-io/logger/LICENSE +0 -21
- package/node_modules/@virtualdisplay-io/logger/README.md +0 -314
- package/node_modules/@virtualdisplay-io/logger/dist/index.d.ts +0 -167
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js +0 -4
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js +0 -377
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/package.json +0 -79
package/package.json
CHANGED
|
@@ -1,57 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtualdisplay.io/client",
|
|
3
3
|
"description": "TypeScript-first 3D model integration library with iframe-based architecture",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-alpha.1",
|
|
5
5
|
"author": "Virtualdisplay <support@virtualdisplay.io>",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"last 2 Safari versions",
|
|
10
|
-
"last 2 Edge versions"
|
|
11
|
-
],
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/virtualdisplay-io/client/issues"
|
|
14
|
-
},
|
|
15
|
-
"bundledDependencies": [
|
|
16
|
-
"@virtualdisplay-io/logger"
|
|
17
|
-
],
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@virtualdisplay-io/logger": "1.2.0",
|
|
20
|
-
"ajv": "8.17.1"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@eslint/js": "^9.31.0",
|
|
24
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
25
|
-
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
26
|
-
"@semantic-release/exec": "7.1.0",
|
|
27
|
-
"@semantic-release/git": "^10.0.1",
|
|
28
|
-
"@semantic-release/github": "^11.0.3",
|
|
29
|
-
"@semantic-release/npm": "^12.0.2",
|
|
30
|
-
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
31
|
-
"@types/node": "^24.0.14",
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
33
|
-
"@typescript-eslint/parser": "^8.37.0",
|
|
34
|
-
"@virtualdisplay-io/shared-config": "^1.4.0",
|
|
35
|
-
"@vitest/coverage-v8": "^3.2.4",
|
|
36
|
-
"conventional-changelog-conventionalcommits": "9.0.0",
|
|
37
|
-
"eslint": "^9.31.0",
|
|
38
|
-
"eslint-plugin-import": "^2.32.0",
|
|
39
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
40
|
-
"eslint-plugin-prettier": "^5.5.1",
|
|
41
|
-
"eslint-plugin-unicorn": "^59.0.1",
|
|
42
|
-
"globals": "^16.3.0",
|
|
43
|
-
"jsdom": "^26.1.0",
|
|
44
|
-
"markdownlint-cli2": "^0.15.0",
|
|
45
|
-
"markdownlint-cli2-formatter-pretty": "^0.0.8",
|
|
46
|
-
"prettier": "^3.6.2",
|
|
47
|
-
"semantic-release": "^24.2.7",
|
|
48
|
-
"terser": "^5.43.1",
|
|
49
|
-
"typescript": "^5.8.3",
|
|
50
|
-
"vite": "^6.3.5",
|
|
51
|
-
"vite-bundle-visualizer": "^1.2.1",
|
|
52
|
-
"vite-plugin-dts": "^4.5.4",
|
|
53
|
-
"vitest": "^3.2.4"
|
|
54
|
-
},
|
|
6
|
+
"homepage": "https://virtualdisplay.io",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
55
9
|
"exports": {
|
|
56
10
|
".": {
|
|
57
11
|
"types": "./dist/index.d.ts",
|
|
@@ -59,14 +13,17 @@
|
|
|
59
13
|
"require": "./dist/virtualdisplay.client.cjs.js"
|
|
60
14
|
}
|
|
61
15
|
},
|
|
16
|
+
"main": "dist/virtualdisplay.client.cjs.js",
|
|
17
|
+
"module": "dist/virtualdisplay.client.es.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
62
19
|
"files": [
|
|
63
20
|
"dist",
|
|
64
|
-
"
|
|
65
|
-
"README.md",
|
|
66
|
-
"CHANGELOG.md",
|
|
67
|
-
"LICENSE"
|
|
21
|
+
"CHANGELOG.md"
|
|
68
22
|
],
|
|
69
|
-
"
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"registry": "https://registry.npmjs.org/",
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
70
27
|
"keywords": [
|
|
71
28
|
"3d",
|
|
72
29
|
"iframe",
|
|
@@ -74,46 +31,5 @@
|
|
|
74
31
|
"typescript",
|
|
75
32
|
"visualization",
|
|
76
33
|
"webgl"
|
|
77
|
-
]
|
|
78
|
-
|
|
79
|
-
"main": "dist/virtualdisplay.client.cjs.js",
|
|
80
|
-
"module": "dist/virtualdisplay.client.es.js",
|
|
81
|
-
"publishConfig": {
|
|
82
|
-
"registry": "https://registry.npmjs.org/",
|
|
83
|
-
"access": "public"
|
|
84
|
-
},
|
|
85
|
-
"repository": {
|
|
86
|
-
"type": "git",
|
|
87
|
-
"url": "git+https://github.com/virtualdisplay-io/client.git"
|
|
88
|
-
},
|
|
89
|
-
"scripts": {
|
|
90
|
-
"analyze": "vite-bundle-visualizer --template treemap --output stats.html --open false",
|
|
91
|
-
"build": "tsc -p tsconfig.build.json && vite build",
|
|
92
|
-
"coverage": "vitest run --coverage --reporter=verbose",
|
|
93
|
-
"coverage:feature": "vitest run test/feature --coverage --reporter=verbose",
|
|
94
|
-
"coverage:integration": "vitest run test/integration --coverage --reporter=verbose",
|
|
95
|
-
"coverage:unit": "vitest run test/unit --coverage --reporter=verbose",
|
|
96
|
-
"dev": "vite build --watch",
|
|
97
|
-
"format": "prettier --write .",
|
|
98
|
-
"format:check": "prettier --check .",
|
|
99
|
-
"lint": "pnpm run lint:eslint && pnpm run lint:md && pnpm run lint:types && pnpm run lint:format",
|
|
100
|
-
"lint:eslint": "eslint .",
|
|
101
|
-
"lint:eslint:fix": "eslint . --fix",
|
|
102
|
-
"lint:fix": "pnpm run lint:eslint:fix && pnpm run lint:md:fix && pnpm run lint:format:fix && npx fixpack",
|
|
103
|
-
"lint:format": "prettier --check .",
|
|
104
|
-
"lint:format:fix": "prettier --write .",
|
|
105
|
-
"lint:md": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.jsonc",
|
|
106
|
-
"lint:md:fix": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.jsonc --fix",
|
|
107
|
-
"lint:types": "tsc --noEmit",
|
|
108
|
-
"prepare": "node -e \"if (!process.env.CI) require('child_process').execSync('pnpm build', {stdio: 'inherit'})\"",
|
|
109
|
-
"release": "semantic-release",
|
|
110
|
-
"test": "vitest run",
|
|
111
|
-
"test:feature": "vitest run test/feature",
|
|
112
|
-
"test:integration": "vitest run test/integration",
|
|
113
|
-
"test:unit": "vitest run test/unit",
|
|
114
|
-
"test:watch": "vitest",
|
|
115
|
-
"type-check": "tsc --noEmit"
|
|
116
|
-
},
|
|
117
|
-
"type": "module",
|
|
118
|
-
"types": "dist/index.d.ts"
|
|
119
|
-
}
|
|
34
|
+
]
|
|
35
|
+
}
|
package/README.npm.md
DELETED
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
# Virtualdisplay client
|
|
2
|
-
|
|
3
|
-
TypeScript library for embedding interactive 3D product models in web
|
|
4
|
-
applications.
|
|
5
|
-
|
|
6
|
-
**Key features:**
|
|
7
|
-
|
|
8
|
-
- Simple attribute-based API for product configurators
|
|
9
|
-
- Fire-and-forget messaging with automatic state synchronization
|
|
10
|
-
- Zero external dependencies (all bundled)
|
|
11
|
-
- Works with any frontend framework or vanilla JavaScript
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @virtualdisplay.io/client
|
|
17
|
-
# or
|
|
18
|
-
pnpm add @virtualdisplay.io/client
|
|
19
|
-
# or
|
|
20
|
-
yarn add @virtualdisplay.io/client
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## What's new in v3.1
|
|
24
|
-
|
|
25
|
-
- Simplified message handling with unified event system
|
|
26
|
-
- JSON Schema validation using AJV
|
|
27
|
-
- Cleaner, more maintainable codebase
|
|
28
|
-
- Improved TypeScript types
|
|
29
|
-
- Better error messages with specific error codes
|
|
30
|
-
|
|
31
|
-
## Quick start
|
|
32
|
-
|
|
33
|
-
### Simple product (no options)
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { VirtualdisplayClient } from '@virtualdisplay.io/client';
|
|
37
|
-
|
|
38
|
-
// That's it! Your 3D model is now displayed
|
|
39
|
-
const client = new VirtualdisplayClient({
|
|
40
|
-
parent: '#product-container',
|
|
41
|
-
license: 'your-license-key',
|
|
42
|
-
model: 'statue-model',
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Configurable product (with options)
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import { VirtualdisplayClient } from '@virtualdisplay.io/client';
|
|
50
|
-
|
|
51
|
-
// Create client instance
|
|
52
|
-
const client = new VirtualdisplayClient({
|
|
53
|
-
parent: '#product-container',
|
|
54
|
-
license: 'your-license-key',
|
|
55
|
-
model: 'sneaker',
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Map product options to 3D parts
|
|
59
|
-
client.setMapping({
|
|
60
|
-
attributes: [
|
|
61
|
-
{
|
|
62
|
-
name: 'Color',
|
|
63
|
-
values: [
|
|
64
|
-
{ value: 'Red', nodeIds: ['laces_red', 'sole_red'], isSelected: true },
|
|
65
|
-
{ value: 'Blue', nodeIds: ['laces_blue', 'sole_blue'] },
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Control via product options
|
|
72
|
-
client.getAttribute('Color')?.select('Red');
|
|
73
|
-
|
|
74
|
-
// Or store the attribute for multiple operations
|
|
75
|
-
const sizeAttribute = client.getAttribute('Size');
|
|
76
|
-
if (sizeAttribute) {
|
|
77
|
-
sizeAttribute.select('Large');
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## How it works
|
|
82
|
-
|
|
83
|
-
The 3D server hosts the viewer in an iframe, keeping WebGL complexity isolated
|
|
84
|
-
from your application. The client library handles all communication via
|
|
85
|
-
postMessage and manages state locally using an attribute mapping system.
|
|
86
|
-
|
|
87
|
-
**Key principles:**
|
|
88
|
-
|
|
89
|
-
- **Iframe architecture**: 3D server loads the viewer independently
|
|
90
|
-
- **Fire-and-forget**: Send messages without waiting for confirmation
|
|
91
|
-
- **Attribute mapping**: Connect your product options to 3D model parts
|
|
92
|
-
- **State synchronization**: Client and 3D server stay in sync automatically
|
|
93
|
-
- **Domain-driven design**: Clean separation of concerns with simplified
|
|
94
|
-
architecture
|
|
95
|
-
- **Event-driven**: Loosely coupled components communicate via events
|
|
96
|
-
|
|
97
|
-
## Product options
|
|
98
|
-
|
|
99
|
-
### When do you need mapping
|
|
100
|
-
|
|
101
|
-
Before diving in, it's important to understand when you need attribute mapping:
|
|
102
|
-
|
|
103
|
-
**No mapping needed:**
|
|
104
|
-
|
|
105
|
-
- Static 3D models that always look the same
|
|
106
|
-
- Product showcases without options
|
|
107
|
-
- Architectural visualizations
|
|
108
|
-
- Art pieces or sculptures
|
|
109
|
-
- Single-configuration products
|
|
110
|
-
|
|
111
|
-
**Mapping required:**
|
|
112
|
-
|
|
113
|
-
- Products where users can change colors (different textures/materials per option)
|
|
114
|
-
- Products with size options (different 3D meshes per size)
|
|
115
|
-
- Modular products (parts that can be added/removed)
|
|
116
|
-
- Any product where different options show different 3D elements
|
|
117
|
-
|
|
118
|
-
### Attribute mapping
|
|
119
|
-
|
|
120
|
-
The mapping system bridges your business logic with the 3D visualization. It
|
|
121
|
-
serves multiple purposes:
|
|
122
|
-
|
|
123
|
-
**Why mapping is essential:**
|
|
124
|
-
|
|
125
|
-
- The 3D server is generic - it doesn't know your specific product options
|
|
126
|
-
- Your business rules (stock, pricing, combinations) change independently from
|
|
127
|
-
the 3D model
|
|
128
|
-
- You control exactly which parts of the model are shown for each option
|
|
129
|
-
- You can group multiple 3D nodes (meshes, materials) into logical product
|
|
130
|
-
choices
|
|
131
|
-
|
|
132
|
-
**How it works:** The mapping connects your product options to specific parts of
|
|
133
|
-
the 3D model:
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
client.setMapping({
|
|
137
|
-
attributes: [
|
|
138
|
-
{
|
|
139
|
-
name: 'Color',
|
|
140
|
-
values: [
|
|
141
|
-
{
|
|
142
|
-
value: 'Red',
|
|
143
|
-
nodeIds: ['mat_red_sole', 'mat_red_laces', 'mat_red_logo'],
|
|
144
|
-
isSelected: true,
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
value: 'Blue',
|
|
148
|
-
nodeIds: ['mat_blue_sole', 'mat_blue_laces', 'mat_blue_logo'],
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'Material',
|
|
154
|
-
values: [
|
|
155
|
-
{ value: 'Leather', nodeIds: ['material_leather_upper'] },
|
|
156
|
-
{
|
|
157
|
-
value: 'Canvas',
|
|
158
|
-
nodeIds: ['material_canvas_upper'],
|
|
159
|
-
isSelected: true,
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
});
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
**Structure explained:**
|
|
168
|
-
|
|
169
|
-
- `attribute` - A product feature like Color, Size, or Material
|
|
170
|
-
- `value` - A specific option like Red, Blue, Small, or Large
|
|
171
|
-
- `nodeIds` - The 3D model parts that represent this option
|
|
172
|
-
- `isSelected` - Whether this option is selected by default
|
|
173
|
-
|
|
174
|
-
**Example benefits:**
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
// Group related 3D parts into one logical choice
|
|
178
|
-
{
|
|
179
|
-
value: 'Red',
|
|
180
|
-
nodeIds: [
|
|
181
|
-
'mesh_sole_red', // Red sole mesh
|
|
182
|
-
'material_laces_red', // Red laces material
|
|
183
|
-
'texture_logo_red', // Red logo texture
|
|
184
|
-
'mesh_stitching_red' // Red stitching details
|
|
185
|
-
]
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// The server automatically handles showing Red parts
|
|
189
|
-
// and hiding Blue/Green parts when Red is selected
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
**Key advantages:**
|
|
193
|
-
|
|
194
|
-
- Full control over what's visible without modifying the 3D model
|
|
195
|
-
- Business logic stays in your application, not in the 3D server
|
|
196
|
-
- Easy to update when products or availability changes
|
|
197
|
-
- Group complex 3D structures into simple user choices
|
|
198
|
-
|
|
199
|
-
**Need help with mapping?**
|
|
200
|
-
|
|
201
|
-
- We help you connect your product catalog to your 3D models
|
|
202
|
-
- Visual mapping tool coming soon to simplify this process
|
|
203
|
-
- Contact <support@virtualdisplay.io> for mapping assistance
|
|
204
|
-
|
|
205
|
-
### Complete flow
|
|
206
|
-
|
|
207
|
-
Here's how the client, mapping system, and 3D server work together:
|
|
208
|
-
|
|
209
|
-
**Phase by phase breakdown:**
|
|
210
|
-
|
|
211
|
-
#### Phase 0: Initialization (always happens)
|
|
212
|
-
|
|
213
|
-
- Client creates iframe and loads 3D server
|
|
214
|
-
- Server initializes the 3D model with all nodes visible
|
|
215
|
-
- Server sends complete node state to client
|
|
216
|
-
- Client now knows about all available nodes in the model
|
|
217
|
-
|
|
218
|
-
**Note:** For simple models without options, this is all you need!
|
|
219
|
-
|
|
220
|
-
#### Phase 1: Configuration (only for configurable products)
|
|
221
|
-
|
|
222
|
-
- You call `setMapping()` with your product structure
|
|
223
|
-
- Client stores the attribute mapping locally
|
|
224
|
-
- Client sends mutations for all `isSelected: true` values
|
|
225
|
-
- Server applies these changes and hides non-selected options
|
|
226
|
-
- Server sends back confirmed state
|
|
227
|
-
- Local state updates based on server response
|
|
228
|
-
- onChange callbacks fire for initial UI synchronization
|
|
229
|
-
|
|
230
|
-
#### Phase 2: User interaction (only for configurable products)
|
|
231
|
-
|
|
232
|
-
- User selects a different option in your UI
|
|
233
|
-
- You call `getAttribute('Color').select('Blue')`
|
|
234
|
-
- Client sends mutation request to server
|
|
235
|
-
- Your code continues immediately (doesn't wait for server response)
|
|
236
|
-
- Server updates the 3D model
|
|
237
|
-
- Server sends back the confirmed state
|
|
238
|
-
- Local state updates based on server response
|
|
239
|
-
- onChange callbacks fire with the actual state
|
|
240
|
-
- UI stays perfectly synchronized with 3D model
|
|
241
|
-
|
|
242
|
-
**Important:** The pattern is identical for both initial mapping and user
|
|
243
|
-
interactions. In both cases:
|
|
244
|
-
|
|
245
|
-
1. Client sends mutations to server
|
|
246
|
-
2. Server applies changes to 3D model
|
|
247
|
-
3. Server sends back confirmed state
|
|
248
|
-
4. Client updates local state based on server response
|
|
249
|
-
5. onChange callbacks fire with the actual state
|
|
250
|
-
|
|
251
|
-
This ensures the server remains the single source of truth for all state
|
|
252
|
-
changes.
|
|
253
|
-
|
|
254
|
-
## Advanced usage
|
|
255
|
-
|
|
256
|
-
### Live state synchronization
|
|
257
|
-
|
|
258
|
-
Keep your UI in sync with the 3D server state using onChange callbacks:
|
|
259
|
-
|
|
260
|
-
```typescript
|
|
261
|
-
const colorAttribute = client.getAttribute('Color');
|
|
262
|
-
|
|
263
|
-
colorAttribute?.getValues().forEach((value) => {
|
|
264
|
-
value.onChange = () => {
|
|
265
|
-
// Update UI when state changes
|
|
266
|
-
updateButton(value.value, value.isSelected);
|
|
267
|
-
};
|
|
268
|
-
});
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Mapping validation
|
|
272
|
-
|
|
273
|
-
Validate your mapping configuration during development:
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
import { mappingSchema } from '@virtualdisplay.io/client';
|
|
277
|
-
import Ajv from 'ajv';
|
|
278
|
-
|
|
279
|
-
const validate = new Ajv().compile(mappingSchema);
|
|
280
|
-
if (!validate(myMapping)) {
|
|
281
|
-
console.error('Invalid mapping:', validate.errors);
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Real-world integration examples
|
|
286
|
-
|
|
287
|
-
### CMS integration
|
|
288
|
-
|
|
289
|
-
The Virtualdisplay client is CMS-agnostic. Store the mapping configuration in
|
|
290
|
-
your CMS alongside your product data:
|
|
291
|
-
|
|
292
|
-
```typescript
|
|
293
|
-
// Fetch product with 3D mapping from your CMS
|
|
294
|
-
const product = await fetch('/api/products/sneaker-pro').then((r) => r.json());
|
|
295
|
-
|
|
296
|
-
// Use the stored mapping directly
|
|
297
|
-
client.setMapping(product.server3dMapping);
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
**Best practices:**
|
|
301
|
-
|
|
302
|
-
- Store the complete mapping configuration with each product
|
|
303
|
-
- Update mappings when product options or availability changes
|
|
304
|
-
- Let your CMS handle filtering of unavailable combinations
|
|
305
|
-
- Version your mappings when 3D models are updated
|
|
306
|
-
|
|
307
|
-
## Example
|
|
308
|
-
|
|
309
|
-
See the [color configurator example](./examples/color-configurator/) for a
|
|
310
|
-
complete working implementation that demonstrates:
|
|
311
|
-
|
|
312
|
-
- Setting up the client
|
|
313
|
-
- Defining attribute mappings
|
|
314
|
-
- Binding UI controls to attributes
|
|
315
|
-
- Real-time state synchronization
|
|
316
|
-
|
|
317
|
-
## API reference
|
|
318
|
-
|
|
319
|
-
### ClientOptions
|
|
320
|
-
|
|
321
|
-
```typescript
|
|
322
|
-
interface ClientOptions {
|
|
323
|
-
parent: string | HTMLElement; // Container element or selector
|
|
324
|
-
license: string; // Your license key
|
|
325
|
-
model: string; // Model ID to load
|
|
326
|
-
debug?: boolean; // Enable debug logging (default: false)
|
|
327
|
-
language?: string; // Language for UI inside the iframe (default: 'nl', supported: 'nl', 'en', 'de')
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Methods
|
|
332
|
-
|
|
333
|
-
#### `setMapping(configuration: MappingConfiguration): void`
|
|
334
|
-
|
|
335
|
-
Configure attribute-to-node mapping for product variants. This is the primary
|
|
336
|
-
method for setting up your product configurator. Call this once with your
|
|
337
|
-
complete configuration - the client efficiently handles all updates.
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
client.setMapping({
|
|
341
|
-
attributes: [
|
|
342
|
-
{
|
|
343
|
-
name: 'Color',
|
|
344
|
-
values: [
|
|
345
|
-
{ value: 'Red', nodeIds: ['node1', 'node2'], isSelected: true },
|
|
346
|
-
{ value: 'Blue', nodeIds: ['node3', 'node4'] },
|
|
347
|
-
],
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
});
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
#### `getAttribute(name: string): AttributeSelector | undefined`
|
|
354
|
-
|
|
355
|
-
Get an attribute selector for changing values. Returns undefined if the
|
|
356
|
-
attribute doesn't exist.
|
|
357
|
-
|
|
358
|
-
```typescript
|
|
359
|
-
const colorAttr = client.getAttribute('Color');
|
|
360
|
-
if (colorAttr) {
|
|
361
|
-
colorAttr.select('Blue');
|
|
362
|
-
}
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
#### `destroy(): void`
|
|
366
|
-
|
|
367
|
-
Clean up and remove the client connection. Always call this when unmounting your
|
|
368
|
-
component.
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
// React example
|
|
372
|
-
useEffect(() => {
|
|
373
|
-
const client = new VirtualdisplayClient({ ... });
|
|
374
|
-
return () => client.destroy();
|
|
375
|
-
}, []);
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### Types
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
interface MappingConfiguration {
|
|
382
|
-
attributes: AttributeConfig[];
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
interface AttributeConfig {
|
|
386
|
-
name: string; // Attribute name (e.g., 'Color')
|
|
387
|
-
values: AttributeValueConfig[]; // Possible values
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
interface AttributeValueConfig {
|
|
391
|
-
value: string; // Value name (e.g., 'Red')
|
|
392
|
-
nodeIds: string[]; // 3D node IDs for this value
|
|
393
|
-
isSelected?: boolean; // Default selection state
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
class AttributeSelector {
|
|
397
|
-
// Properties
|
|
398
|
-
name: string; // Attribute name (getter)
|
|
399
|
-
currentValue: string | undefined; // Current selected value (getter)
|
|
400
|
-
availableValues: string[]; // All possible values (getter)
|
|
401
|
-
|
|
402
|
-
// Methods
|
|
403
|
-
select(value: string): AttributeSelector; // Select a value (chainable)
|
|
404
|
-
onChange(callback: () => void): AttributeSelector; // Register change callback (chainable)
|
|
405
|
-
getValues(): AttributeValue[]; // Get all AttributeValue objects
|
|
406
|
-
getValue(value: string): AttributeValue | undefined; // Get specific AttributeValue
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
class AttributeValue {
|
|
410
|
-
// Properties
|
|
411
|
-
value: string; // The value name (e.g., 'Red') - getter
|
|
412
|
-
nodeList: string[]; // Associated 3D node IDs - getter
|
|
413
|
-
isSelected: boolean; // Current selection state - getter
|
|
414
|
-
onChange?: () => void; // Callback when selection changes - property
|
|
415
|
-
}
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
#### NodeSelector
|
|
419
|
-
|
|
420
|
-
The client exports `NodeSelector` for direct node manipulation. This is intended
|
|
421
|
-
for specialized tools like mapping editors and inspectors, not for typical
|
|
422
|
-
product configurators. For product configurators, use the attribute-based API.
|
|
423
|
-
|
|
424
|
-
### Error handling
|
|
425
|
-
|
|
426
|
-
The client throws `VirtualdisplayError` for known error conditions:
|
|
427
|
-
|
|
428
|
-
```typescript
|
|
429
|
-
import {
|
|
430
|
-
VirtualdisplayClient,
|
|
431
|
-
VirtualdisplayError,
|
|
432
|
-
ERROR_CODES,
|
|
433
|
-
} from '@virtualdisplay.io/client';
|
|
434
|
-
|
|
435
|
-
try {
|
|
436
|
-
client.getAttribute('NonExistent').select('Value');
|
|
437
|
-
} catch (error) {
|
|
438
|
-
if (error instanceof VirtualdisplayError) {
|
|
439
|
-
switch (error.code) {
|
|
440
|
-
case ERROR_CODES.ATTRIBUTE_NOT_FOUND:
|
|
441
|
-
console.error('Attribute does not exist');
|
|
442
|
-
break;
|
|
443
|
-
case ERROR_CODES.NO_MAPPING:
|
|
444
|
-
console.error('Call setMapping() first');
|
|
445
|
-
break;
|
|
446
|
-
// Handle other error codes
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
**Error codes:**
|
|
453
|
-
|
|
454
|
-
- `NO_MAPPING` - No mapping configuration set
|
|
455
|
-
- `ATTRIBUTE_NOT_FOUND` - Requested attribute doesn't exist
|
|
456
|
-
- `VALUE_NOT_FOUND` - Requested value doesn't exist for attribute
|
|
457
|
-
- `INVALID_MAPPING` - Mapping configuration is invalid
|
|
458
|
-
- `PARENT_NOT_FOUND` - Parent element for iframe not found
|
|
459
|
-
|
|
460
|
-
## Contributing
|
|
461
|
-
|
|
462
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
|
|
463
|
-
|
|
464
|
-
## Troubleshooting
|
|
465
|
-
|
|
466
|
-
### Common issues
|
|
467
|
-
|
|
468
|
-
**Iframe not loading:**
|
|
469
|
-
|
|
470
|
-
- Check that the parent element exists in the DOM
|
|
471
|
-
- Verify your license key is valid
|
|
472
|
-
- Ensure the model ID matches your license
|
|
473
|
-
|
|
474
|
-
**Attributes not working:**
|
|
475
|
-
|
|
476
|
-
- Make sure you call `setMapping()` before using `getAttribute()`
|
|
477
|
-
- Verify attribute names match exactly (case-sensitive)
|
|
478
|
-
- Check that node IDs in your mapping exist in the 3D model
|
|
479
|
-
|
|
480
|
-
## Changelog
|
|
481
|
-
|
|
482
|
-
See the [GitHub releases](https://github.com/virtualdisplay-io/client/releases)
|
|
483
|
-
for release notes and version history.
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# [1.2.0](https://github.com/virtualdisplay-io/logger/compare/v1.1.2...v1.2.0) (2025-06-13)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* simplify logger API by removing environment detection ([#11](https://github.com/virtualdisplay-io/logger/issues/11)) ([8580f93](https://github.com/virtualdisplay-io/logger/commit/8580f93eb2b9eb7dd6fc6b4ae90b5512ac9b55bc))
|
|
7
|
-
|
|
8
|
-
## [1.1.2](https://github.com/virtualdisplay-io/logger/compare/v1.1.1...v1.1.2) (2025-06-08)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* resolve linting issues in console-transport ([#8](https://github.com/virtualdisplay-io/logger/issues/8)) ([10b8f1a](https://github.com/virtualdisplay-io/logger/commit/10b8f1adaf3ed04efb6c46ace9194f39c8d60b00))
|
|
14
|
-
|
|
15
|
-
## [1.1.1](https://github.com/virtualdisplay-io/logger/compare/v1.1.0...v1.1.1) (2025-06-08)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* remove hardcoded VirtualDisplay prefix from console transport ([f3734d5](https://github.com/virtualdisplay-io/logger/commit/f3734d5f3b66c9a1e190a13e7c91f9021543324c))
|
|
21
|
-
|
|
22
|
-
# [1.1.0](https://github.com/virtualdisplay-io/logger/compare/v1.0.1...v1.1.0) (2025-06-08)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* update semantic-release config to match client library ([ec76794](https://github.com/virtualdisplay-io/logger/commit/ec7679460926ec5423fad52a9859ef34d547a9ef))
|
|
28
|
-
|
|
29
|
-
## [1.0.1](https://github.com/virtualdisplay-io/logger/compare/v1.0.0...v1.0.1) (2025-06-08)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* ensure production build is created before release ([#7](https://github.com/virtualdisplay-io/logger/issues/7)) ([459af10](https://github.com/virtualdisplay-io/logger/commit/459af105c3e6e123b75f4cb96bbaa5c89722fdb8))
|
|
35
|
-
|
|
36
|
-
# 1.0.0 (2025-06-08)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Features
|
|
40
|
-
|
|
41
|
-
* initial Virtual Display Logger implementation ([dcbda81](https://github.com/virtualdisplay-io/logger/commit/dcbda81cf31a097eed8df61a6d5294a8b0d9f1c4))
|
|
42
|
-
|
|
43
|
-
# Changelog
|
|
44
|
-
|
|
45
|
-
All notable changes to this project will be documented in this file.
|
|
46
|
-
|
|
47
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
48
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
49
|
-
|
|
50
|
-
## [Unreleased]
|
|
51
|
-
|
|
52
|
-
### Added
|
|
53
|
-
- Initial release of @virtualdisplay-io/logger
|
|
54
|
-
- Core logging functionality with debug, info, warn, error levels
|
|
55
|
-
- Singleton pattern with Logger.getInstance()
|
|
56
|
-
- Child logger support with context inheritance
|
|
57
|
-
- Multiple transport system (Console, Memory)
|
|
58
|
-
- Formatter system (Context, JSON)
|
|
59
|
-
- Environment-aware logging
|
|
60
|
-
- Test environment auto-detection
|
|
61
|
-
- TypeScript support with full type definitions
|
|
62
|
-
- Comprehensive test suite with 100% coverage
|
|
63
|
-
- Zero dependencies
|
|
64
|
-
- Browser and Node.js compatibility
|
|
65
|
-
- Memory transport with querying and export capabilities
|
|
66
|
-
- Global muting functionality
|
|
67
|
-
- Configurable log levels and filtering
|
|
68
|
-
|
|
69
|
-
### Features
|
|
70
|
-
- **ConsoleTransport**: Console output with colors and timestamps
|
|
71
|
-
- **MemoryTransport**: In-memory log storage with search and export
|
|
72
|
-
- **ContextFormatter**: Appends context data to messages
|
|
73
|
-
- **JSONFormatter**: Full JSON serialization of log entries
|
|
74
|
-
- **Child Loggers**: Hierarchical logging with context merging
|
|
75
|
-
- **Smart Environment Detection**: Automatic test environment detection
|
|
76
|
-
- **Performance Optimized**: Zero runtime dependencies, efficient memory usage
|
|
77
|
-
- **Developer Experience**: Comprehensive TypeScript types, clear API
|
|
78
|
-
|
|
79
|
-
## [1.0.0] - 2025-01-XX
|
|
80
|
-
|
|
81
|
-
### Added
|
|
82
|
-
- Initial stable release
|