customforge 0.1.0-alpha.1 → 0.1.0-alpha.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/CHANGELOG.md +37 -11
- package/LICENSES/NunitoSans-OFL.txt +93 -0
- package/README.md +233 -62
- package/README.zh-CN.md +231 -60
- package/dist/NunitoSans-Variable.ttf +0 -0
- package/dist/ProductCustomizer-rMRyWe7L.js +1624 -0
- package/dist/ProductCustomizer-rMRyWe7L.js.map +1 -0
- package/dist/core/design.d.ts.map +1 -1
- package/dist/core/types.d.ts +35 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/customizer/ProductCustomizer.d.ts +78 -0
- package/dist/customizer/ProductCustomizer.d.ts.map +1 -1
- package/dist/editor/DesignEditor.d.ts +108 -6
- package/dist/editor/DesignEditor.d.ts.map +1 -1
- package/dist/editor/DesignHistory.d.ts +27 -0
- package/dist/editor/DesignHistory.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1108
- package/dist/index.js.map +1 -1
- package/dist/style.css +1319 -0
- package/dist/workbench/CustomForgeWorkbench.d.ts +128 -0
- package/dist/workbench/CustomForgeWorkbench.d.ts.map +1 -0
- package/dist/workbench/assets/catalog.d.ts +8 -0
- package/dist/workbench/assets/catalog.d.ts.map +1 -0
- package/dist/workbench/config.d.ts +55 -0
- package/dist/workbench/config.d.ts.map +1 -0
- package/dist/workbench/icons.d.ts +4 -0
- package/dist/workbench/icons.d.ts.map +1 -0
- package/dist/workbench/index.d.ts +25 -0
- package/dist/workbench/index.d.ts.map +1 -0
- package/dist/workbench/template.d.ts +3 -0
- package/dist/workbench/template.d.ts.map +1 -0
- package/dist/workbench/types.d.ts +294 -0
- package/dist/workbench/types.d.ts.map +1 -0
- package/dist/workbench.js +1920 -0
- package/dist/workbench.js.map +1 -0
- package/package.json +70 -71
package/CHANGELOG.md
CHANGED
|
@@ -2,17 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to CustomForge will be documented in this file
|
|
4
4
|
|
|
5
|
-
## [Unreleased]
|
|
6
|
-
|
|
7
|
-
## [0.1.0-alpha.
|
|
8
|
-
|
|
9
|
-
###
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0-alpha.2] - 2026-08-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Optional configurable Workbench UI exported from `customforge/workbench`
|
|
12
|
+
- Public object querying, selection, removal, naming, visibility, locking, and layer ordering APIs
|
|
13
|
+
- Object names, visibility, and locking state in backward-compatible Design JSON version 1 documents
|
|
14
|
+
- Undo and redo history with keyboard shortcuts and public history state APIs
|
|
15
|
+
- Text composition Dialog with replaceable typography presets
|
|
16
|
+
- Image Dialog with upload, configurable background, and decorative element catalogs
|
|
17
|
+
- Custom branding, labels, theme tokens, icon visibility, and semantic icon overrides
|
|
18
|
+
- Design background images that persist in Design JSON and remain locked at the bottom layer
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Built-in demo now consumes the same public Workbench available to package users
|
|
23
|
+
- Workbench presentation uses a quieter responsive studio layout with clearer control hierarchy
|
|
24
|
+
- Default controls now use softer neutral surfaces, light selection states, and restrained 7px radii
|
|
25
|
+
- Workbench now bundles the rounded Nunito Sans UI font with system font fallbacks
|
|
26
|
+
- Solid accent buttons now consistently use the configured high-contrast text color
|
|
27
|
+
- Layer selection and Dialog transitions now use subtle motion with reduced-motion support
|
|
28
|
+
- Nunito Sans is emitted as a cacheable font asset instead of being inlined into the stylesheet
|
|
29
|
+
- Package verification now parses actual ESM imports without matching examples inside bundled strings
|
|
30
|
+
- The bundled CustomForge logo is now the default Workbench brand mark
|
|
31
|
+
- Successful product changes reset design history while preserving current design objects
|
|
32
|
+
|
|
33
|
+
## [0.1.0-alpha.1] - 2026-08-27
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Fabric.js and Three.js are installed automatically as runtime dependencies
|
|
38
|
+
- Consumers no longer need to install Fabric.js and Three.js separately
|
|
39
|
+
- Library builds continue to keep both engines external
|
|
40
|
+
|
|
41
|
+
## [0.1.0-alpha.0] - 2026-08-27
|
|
16
42
|
|
|
17
43
|
### Added
|
|
18
44
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2016 The Nunito Sans Project Authors (https://github.com/Fonthausen/NunitoSans)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<p>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
</
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="./src/workbench/assets/CustomForgeLogo.png" alt="CustomForge Logo" width="136">
|
|
4
|
+
|
|
5
|
+
<h1>CustomForge</h1>
|
|
6
|
+
|
|
7
|
+
<hr>
|
|
8
|
+
|
|
9
|
+
<p><strong>Turn a 2D texture canvas into a live 3D product preview</strong></p>
|
|
10
|
+
|
|
11
|
+
<p>A lightweight, framework-agnostic toolkit for building browser-based product customization experiences with Fabric.js and Three.js</p>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<strong>English</strong>
|
|
15
|
+
<span> · </span>
|
|
16
|
+
<a href="./README.zh-CN.md">简体中文</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p>
|
|
20
|
+
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-strict-2563EB?style=flat-square&logo=typescript&logoColor=white&labelColor=1F2937">
|
|
21
|
+
<img alt="Vite" src="https://img.shields.io/badge/Vite-8-7C3AED?style=flat-square&logo=vite&logoColor=white&labelColor=1F2937">
|
|
22
|
+
<img alt="Three.js" src="https://img.shields.io/badge/Three.js-r185-27272A?style=flat-square&logo=threedotjs&logoColor=white&labelColor=1F2937">
|
|
23
|
+
<img alt="Fabric.js" src="https://img.shields.io/badge/Fabric.js-7-BE185D?style=flat-square&labelColor=1F2937">
|
|
24
|
+
<img alt="License" src="https://img.shields.io/badge/License-Apache%202.0-0F766E?style=flat-square&logo=apache&logoColor=white&labelColor=1F2937">
|
|
25
|
+
</p>
|
|
21
26
|
|
|
22
27
|
</div>
|
|
23
28
|
|
|
@@ -35,6 +40,10 @@ CustomForge connects a familiar 2D design surface to a UV-mapped 3D model:
|
|
|
35
40
|
- Rotate and zoom the 3D preview with OrbitControls
|
|
36
41
|
- Export the composed texture as a PNG
|
|
37
42
|
- Save and restore editable objects through versioned Design JSON
|
|
43
|
+
- Organize objects through names, visibility, locking, and layer order
|
|
44
|
+
- Undo and redo design changes through snapshot history
|
|
45
|
+
- Use configurable typography, background, and decorative asset Dialogs
|
|
46
|
+
- Adapt the default Workbench with branding, labels, theme tokens, and icons
|
|
38
47
|
|
|
39
48
|
The included workbench starts with a procedural cup, so the project works immediately without external assets
|
|
40
49
|
|
|
@@ -53,29 +62,29 @@ The built-in demo appears with a UV workspace on the left and a live 3D preview
|
|
|
53
62
|
|
|
54
63
|
## npm Alpha Package
|
|
55
64
|
|
|
56
|
-
CustomForge is available from the npm Registry under the `alpha` dist-tag and the API and Design JSON Schema may change between alpha versions
|
|
57
|
-
|
|
58
|
-
Install the current public alpha with:
|
|
59
|
-
|
|
60
|
-
```powershell
|
|
61
|
-
pnpm add customforge@alpha
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Fabric.js and Three.js are installed automatically as transitive dependencies
|
|
65
|
-
|
|
66
|
-
pnpm may report that the optional native `canvas` build script was ignored
|
|
67
|
-
|
|
68
|
-
CustomForge runs in the browser and does not use Node native canvas, so `pnpm approve-builds` is not required
|
|
69
|
-
|
|
70
|
-
Consumer projects can explicitly acknowledge this browser-only choice in `package.json`:
|
|
71
|
-
|
|
72
|
-
```json
|
|
73
|
-
{
|
|
74
|
-
"pnpm": {
|
|
75
|
-
"ignoredBuiltDependencies": ["canvas"]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
65
|
+
CustomForge is available from the npm Registry under the `alpha` dist-tag and the API and Design JSON Schema may change between alpha versions
|
|
66
|
+
|
|
67
|
+
Install the current public alpha with:
|
|
68
|
+
|
|
69
|
+
```powershell
|
|
70
|
+
pnpm add customforge@alpha
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Fabric.js and Three.js are installed automatically as transitive dependencies
|
|
74
|
+
|
|
75
|
+
pnpm may report that the optional native `canvas` build script was ignored
|
|
76
|
+
|
|
77
|
+
CustomForge runs in the browser and does not use Node native canvas, so `pnpm approve-builds` is not required
|
|
78
|
+
|
|
79
|
+
Consumer projects can explicitly acknowledge this browser-only choice in `package.json`:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"pnpm": {
|
|
84
|
+
"ignoredBuiltDependencies": ["canvas"]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
79
88
|
|
|
80
89
|
Package page: [npmjs.com/package/customforge](https://www.npmjs.com/package/customforge)
|
|
81
90
|
|
|
@@ -85,23 +94,23 @@ For repository-independent verification before publishing, build and create the
|
|
|
85
94
|
pnpm pack:local
|
|
86
95
|
```
|
|
87
96
|
|
|
88
|
-
The command builds JavaScript, TypeScript declarations, and
|
|
97
|
+
The command builds JavaScript, TypeScript declarations, and public styles, checks the npm file list, and creates:
|
|
89
98
|
|
|
90
99
|
```text
|
|
91
|
-
customforge-0.1.0-alpha.
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Install that local package in an independent Vite TypeScript project:
|
|
95
|
-
|
|
96
|
-
```powershell
|
|
97
|
-
pnpm add D:\projects\3DRendering\core_code\customforge-0.1.0-alpha.
|
|
98
|
-
```
|
|
100
|
+
customforge-0.1.0-alpha.2.tgz
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Install that local package in an independent Vite TypeScript project:
|
|
104
|
+
|
|
105
|
+
```powershell
|
|
106
|
+
pnpm add D:\projects\3DRendering\core_code\customforge-0.1.0-alpha.2.tgz
|
|
107
|
+
```
|
|
99
108
|
|
|
100
109
|
The checked-in `examples/npm-consumer` project imports CustomForge only through this `.tgz`. Run `pnpm install --ignore-workspace` in that directory so pnpm installs it independently from the parent workspace
|
|
101
110
|
|
|
102
111
|
## Load Your Product
|
|
103
112
|
|
|
104
|
-
Choose **Load
|
|
113
|
+
Choose **Load product** in the demo and provide:
|
|
105
114
|
|
|
106
115
|
| Field | Purpose |
|
|
107
116
|
| --- | --- |
|
|
@@ -171,6 +180,126 @@ window.addEventListener('beforeunload', () => customizer.destroy(), {
|
|
|
171
180
|
|
|
172
181
|
The public package uses the same root and style imports as the local `.tgz`; pin an exact alpha version when reproducible installs are required
|
|
173
182
|
|
|
183
|
+
## Ready-made Workbench
|
|
184
|
+
|
|
185
|
+
Use the optional Workbench entry when a complete default interface is preferable to building controls from scratch
|
|
186
|
+
|
|
187
|
+
The host element must have an explicit height so the design surface, layers, and 3D preview can measure their available space
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<div id="customforge-workbench" style="height: 720px"></div>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
import { createWorkbench } from 'customforge/workbench'
|
|
195
|
+
import 'customforge/style.css'
|
|
196
|
+
|
|
197
|
+
const workbench = await createWorkbench({
|
|
198
|
+
container: '#customforge-workbench',
|
|
199
|
+
product: {
|
|
200
|
+
modelUrl: 'https://example.com/product.glb',
|
|
201
|
+
surfaceMesh: 'PrintArea',
|
|
202
|
+
},
|
|
203
|
+
features: {
|
|
204
|
+
presetBackgrounds: true,
|
|
205
|
+
presetElements: true,
|
|
206
|
+
},
|
|
207
|
+
layout: {
|
|
208
|
+
header: true,
|
|
209
|
+
layers: true,
|
|
210
|
+
},
|
|
211
|
+
branding: {
|
|
212
|
+
logoUrl: '/brand/logo.png',
|
|
213
|
+
title: 'Studio',
|
|
214
|
+
subtitle: 'Product personalization',
|
|
215
|
+
},
|
|
216
|
+
labels: {
|
|
217
|
+
addText: 'Typography',
|
|
218
|
+
addImage: 'Artwork',
|
|
219
|
+
},
|
|
220
|
+
theme: {
|
|
221
|
+
accent: '#0057b8',
|
|
222
|
+
accentHover: '#003f87',
|
|
223
|
+
accentContrast: '#ffffff',
|
|
224
|
+
},
|
|
225
|
+
assets: {
|
|
226
|
+
backgrounds: [
|
|
227
|
+
{ id: 'floral', name: 'Floral', url: '/presets/floral.png' },
|
|
228
|
+
],
|
|
229
|
+
elements: [
|
|
230
|
+
{ id: 'flower', name: 'Flower', url: '/presets/flower.png' },
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The bundled CustomForge logo is used by default and can be replaced or hidden through `branding`
|
|
237
|
+
|
|
238
|
+
`labels` replaces visible Workbench copy, `theme` maps to scoped CSS variables, and `icons` can disable built-in icons or replace individual semantic icons with image URLs
|
|
239
|
+
|
|
240
|
+
The default UI font stack prefers the rounded `Nunito Sans` family and falls back to system sans-serif fonts
|
|
241
|
+
|
|
242
|
+
CustomForge bundles the font asset and does not fetch third-party font services at runtime
|
|
243
|
+
|
|
244
|
+
Text and image commands open focused Dialogs instead of immediately mutating the canvas
|
|
245
|
+
|
|
246
|
+
- The text Dialog includes an input, color control, and replaceable typography presets
|
|
247
|
+
- The image Dialog includes local upload, background presets, and decorative element presets
|
|
248
|
+
- A design background replaces the previous design background, fills the canvas, starts locked at the bottom layer, and persists in Design JSON
|
|
249
|
+
|
|
250
|
+
Feature and layout switches can also be changed after initialization
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
workbench.setFeature('addText', true)
|
|
254
|
+
workbench.setLayout('header', true)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
| Feature switch | Controls |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| `addText`, `addImage`, `deleteSelection` | Object Dialogs and deletion |
|
|
260
|
+
| `undoRedo` | Undo and redo buttons plus Workbench keyboard shortcuts |
|
|
261
|
+
| `saveDesign`, `loadDesign` | Design JSON actions |
|
|
262
|
+
| `loadRemoteProduct`, `exportTexture`, `resetView` | Product and output actions |
|
|
263
|
+
| `reorderObjects`, `toggleObjectVisibility`, `lockObjects`, `renameObjects` | Layer management |
|
|
264
|
+
| `presetBackgrounds`, `presetElements` | Image Dialog preset tabs |
|
|
265
|
+
|
|
266
|
+
| Layout switch | Region |
|
|
267
|
+
| --- | --- |
|
|
268
|
+
| `header` | Brand and global product actions |
|
|
269
|
+
| `editorHeader`, `viewerHeader` | Workspace panel headings |
|
|
270
|
+
| `toolbar` | Design tool controls |
|
|
271
|
+
| `layers` | Object layer panel |
|
|
272
|
+
| `status` | Runtime status and object count |
|
|
273
|
+
|
|
274
|
+
All feature and layout values default to `true`
|
|
275
|
+
|
|
276
|
+
Feature switches only control the built-in Workbench controls and do not remove methods from `workbench.customizer`
|
|
277
|
+
|
|
278
|
+
Theme values are intended for coherent product-level styling rather than per-button color configuration
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
const workbench = await createWorkbench({
|
|
282
|
+
container: '#customforge-workbench',
|
|
283
|
+
icons: {
|
|
284
|
+
enabled: true,
|
|
285
|
+
sources: {
|
|
286
|
+
addText: '/icons/typography.svg',
|
|
287
|
+
exportTexture: null,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
textPresets: [
|
|
291
|
+
{
|
|
292
|
+
id: 'brand-display',
|
|
293
|
+
name: 'Brand display',
|
|
294
|
+
fontFamily: 'Arial',
|
|
295
|
+
fontSize: 72,
|
|
296
|
+
width: 460,
|
|
297
|
+
color: '#17191c',
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
})
|
|
301
|
+
```
|
|
302
|
+
|
|
174
303
|
## Design JSON
|
|
175
304
|
|
|
176
305
|
`saveDesign()` returns a Library-owned, JSON-safe document instead of exposing Fabric.js serialization. `loadDesign()` validates unknown input and restores the editable object stack asynchronously:
|
|
@@ -185,32 +314,70 @@ if (savedDesign) {
|
|
|
185
314
|
}
|
|
186
315
|
```
|
|
187
316
|
|
|
188
|
-
The current Schema version is `1`. It stores the logical canvas size and the text and image objects in back-to-front render order, including stable object IDs and center-based transforms
|
|
317
|
+
The current Schema version is `1`. It stores the logical canvas size and the text and image objects in back-to-front render order, including stable object IDs, names, visibility, locking, image roles, and center-based transforms
|
|
189
318
|
|
|
190
319
|
Design JSON intentionally excludes the product model, target mesh, and base texture. A document can only be loaded into an editor with exactly the same logical width and height
|
|
191
320
|
|
|
321
|
+
An image with `role: 'background'` is a design object rather than the product base texture. Only one is allowed, it must be the first object, and older version 1 documents without `role` continue to load as ordinary image elements
|
|
322
|
+
|
|
192
323
|
Loading is transactional: the current design remains unchanged unless the document validates and every referenced image loads successfully. Blob URL images are converted to Data URLs when added; remote image URLs remain URLs and must continue to satisfy browser CORS requirements when restored
|
|
193
324
|
|
|
194
325
|
The Schema is still an alpha contract and may change in later alpha versions
|
|
195
326
|
|
|
327
|
+
## Undo and Redo
|
|
328
|
+
|
|
329
|
+
History is enabled in both the headless core and Workbench and defaults to 50 undo steps
|
|
330
|
+
|
|
331
|
+
Set `historyLimit` in `createCustomizer` or `createWorkbench` options to change the retained undo depth
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
if (customizer.canUndo()) {
|
|
335
|
+
await customizer.undo()
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
await customizer.redo()
|
|
339
|
+
customizer.clearHistory()
|
|
340
|
+
|
|
341
|
+
const stop = customizer.on('historychange', ({ canUndo, canRedo }) => {
|
|
342
|
+
console.log({ canUndo, canRedo })
|
|
343
|
+
})
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
History covers object creation, deletion, canvas transforms, text edits, layer order, names, visibility, locking, and Design JSON loading
|
|
347
|
+
|
|
348
|
+
Workbench also supports `Ctrl` or `Cmd` + `Z`, `Ctrl` or `Cmd` + `Shift` + `Z`, and `Ctrl` + `Y` while focus is outside form fields
|
|
349
|
+
|
|
350
|
+
Successful product replacement keeps the current design but starts a new history baseline
|
|
351
|
+
|
|
196
352
|
## Instance API
|
|
197
353
|
|
|
198
354
|
| Method | Description |
|
|
199
355
|
| --- | --- |
|
|
200
356
|
| `addText(options)` | Add and select editable text, constrained to the canvas |
|
|
201
|
-
| `addImage(options)` | Load and select an
|
|
357
|
+
| `addImage(options)` | Load and select an element or replace the design background |
|
|
358
|
+
| `getObjects()` | Return the current objects in back-to-front layer order |
|
|
359
|
+
| `getSelectedObjectIds()` | Return stable IDs for the current selection |
|
|
360
|
+
| `selectObject(id)` | Select a visible object by stable ID |
|
|
361
|
+
| `removeObject(id)` | Remove an object by stable ID |
|
|
362
|
+
| `moveObject(id, index)` | Move an object to a zero-based layer index |
|
|
363
|
+
| `renameObject(id, name)` | Change the object name shown in layer tools |
|
|
364
|
+
| `setObjectVisibility(id, visible)` | Include or exclude an object from rendering |
|
|
365
|
+
| `setObjectLocked(id, locked)` | Lock or unlock canvas transformations |
|
|
202
366
|
| `deleteSelected()` | Remove the active object or selection |
|
|
203
367
|
| `saveDesign()` | Return the current versioned Design JSON document |
|
|
204
368
|
| `loadDesign(value)` | Validate and transactionally restore Design JSON |
|
|
369
|
+
| `canUndo()`, `canRedo()` | Query the current history directions |
|
|
370
|
+
| `undo()`, `redo()` | Restore the previous or next design snapshot |
|
|
371
|
+
| `clearHistory()` | Make the current design the new history baseline |
|
|
205
372
|
| `loadProduct(product)` | Replace the model, base texture, and target mesh |
|
|
206
373
|
| `exportTexture(filename?)` | Download the composed texture as PNG |
|
|
207
374
|
| `resetView()` | Restore the default 3D camera position |
|
|
208
375
|
| `on(event, listener)` | Subscribe to instance events; returns an unsubscribe function |
|
|
209
376
|
| `destroy()` | Release DOM events, Fabric state, and WebGL resources |
|
|
210
377
|
|
|
211
|
-
Available events are `ready`, `change`, `selectionchange`, `status`, and `error`
|
|
378
|
+
Available events are `ready`, `change`, `selectionchange`, `historychange`, `status`, and `error`
|
|
212
379
|
|
|
213
|
-
The initial alpha stability boundary is limited to the methods above, `createCustomizer`, `ProductCustomizer`, and the configuration, event, and Design JSON types exported from
|
|
380
|
+
The initial alpha stability boundary is limited to the methods above, `createCustomizer`, `ProductCustomizer`, the `customforge/workbench` entry, and the configuration, event, Workbench, and Design JSON types exported from declared package entries
|
|
214
381
|
|
|
215
382
|
`ProductCustomizer` does not expose its Fabric.js editor or Three.js viewer instances; consumers interact through the facade API
|
|
216
383
|
|
|
@@ -239,7 +406,7 @@ ProductCustomizer
|
|
|
239
406
|
|
|
240
407
|
`ProductCustomizer` coordinates the modules while keeping Fabric.js and Three.js details behind a small instance API
|
|
241
408
|
|
|
242
|
-
The demo
|
|
409
|
+
The optional Workbench and demo use Vanilla TypeScript; the core does not depend on Vue, React, or another UI framework
|
|
243
410
|
|
|
244
411
|
## Model Contract
|
|
245
412
|
|
|
@@ -261,10 +428,11 @@ src/
|
|
|
261
428
|
|-- core/ Public types, configuration, and DOM helpers
|
|
262
429
|
|-- customizer/ Public instance orchestration
|
|
263
430
|
|-- demo/ Runnable workbench UI
|
|
264
|
-
|-- editor/ Fabric.js design surface
|
|
431
|
+
|-- editor/ Fabric.js design surface and snapshot history
|
|
265
432
|
|-- style.css Public Library style entry
|
|
266
|
-
|-- styles/
|
|
433
|
+
|-- styles/ Core and Workbench styles
|
|
267
434
|
|-- viewer/ Three.js product preview
|
|
435
|
+
|-- workbench/ Configurable UI, Dialogs, icons, and preset assets
|
|
268
436
|
`-- index.ts Framework-independent source entry
|
|
269
437
|
|
|
270
438
|
examples/
|
|
@@ -280,7 +448,7 @@ scripts/
|
|
|
280
448
|
pnpm check # TypeScript project check
|
|
281
449
|
pnpm test # Unit tests
|
|
282
450
|
pnpm build # Type-check and production build
|
|
283
|
-
pnpm build:lib # Build ESM, declarations, and
|
|
451
|
+
pnpm build:lib # Build core and Workbench ESM, declarations, and styles
|
|
284
452
|
pnpm verify:package # Check dist and the npm file list
|
|
285
453
|
pnpm pack:local # Build, verify, and create the local .tgz
|
|
286
454
|
pnpm release:check # Run checks, tests, package build, verification, and local pack
|
|
@@ -297,12 +465,13 @@ The current milestone intentionally focuses on one texture and one customizable
|
|
|
297
465
|
|
|
298
466
|
Public npm releases use the `alpha` dist-tag until the API and Design JSON contract are ready for a more stable channel
|
|
299
467
|
|
|
300
|
-
Multi-surface products,
|
|
468
|
+
Multi-surface products, advanced alignment tools, and framework adapters are not implemented yet
|
|
301
469
|
|
|
302
470
|
## Technology
|
|
303
471
|
|
|
304
472
|
- [Fabric.js](https://fabricjs.com/) for the 2D editing surface
|
|
305
473
|
- [Three.js](https://threejs.org/) for model loading and real-time 3D rendering
|
|
474
|
+
- [Lucide](https://lucide.dev/) for bundled Workbench controls
|
|
306
475
|
- [Vite](https://vite.dev/) for development and application builds
|
|
307
476
|
- [TypeScript](https://www.typescriptlang.org/) with strict checking enabled
|
|
308
477
|
|
|
@@ -313,3 +482,5 @@ CustomForge is licensed under the Apache License 2.0
|
|
|
313
482
|
See [LICENSE](./LICENSE) for the full license terms
|
|
314
483
|
|
|
315
484
|
Third-party dependencies and assets remain subject to their respective licenses
|
|
485
|
+
|
|
486
|
+
The bundled Nunito Sans font is licensed under the SIL Open Font License 1.1, available in [NunitoSans-OFL.txt](./LICENSES/NunitoSans-OFL.txt)
|