@printine/pod-editor 0.0.0-stage → 0.1.15
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 +224 -2
- package/dist/DesignerRuntimeContext.d.ts +3 -0
- package/dist/PrintineDesigner.d.ts +9 -0
- package/dist/api/asset-client.d.ts +8 -0
- package/dist/api/asset-client.js +40 -0
- package/dist/api/asset-endpoints.d.ts +36 -0
- package/dist/assets/icons/aspect_ratio.d.ts +3 -0
- package/dist/assets/icons/delete.d.ts +3 -0
- package/dist/assets/icons/fit_screen.d.ts +3 -0
- package/dist/assets/icons/index.d.ts +11 -0
- package/dist/assets/icons/loading_1.d.ts +3 -0
- package/dist/assets/icons/loading_2.d.ts +3 -0
- package/dist/assets/icons/loading_3.d.ts +3 -0
- package/dist/assets/icons/pan.d.ts +3 -0
- package/dist/assets/icons/setting.d.ts +3 -0
- package/dist/assets/icons/text_color.d.ts +3 -0
- package/dist/assets/icons/text_h.d.ts +3 -0
- package/dist/assets/icons/text_v.d.ts +3 -0
- package/dist/bundled-assets.d.ts +4 -0
- package/dist/components/add-design.d.ts +8 -0
- package/dist/components/assets-dialog.d.ts +24 -0
- package/dist/components/canvas-context-menu.d.ts +6 -0
- package/dist/components/color-picker/index.d.ts +11 -0
- package/dist/components/context.d.ts +24 -0
- package/dist/components/design.d.ts +9 -0
- package/dist/components/fonts.d.ts +26 -0
- package/dist/components/image-crop.d.ts +5 -0
- package/dist/components/image-edit.d.ts +1 -0
- package/dist/components/layout/aside.d.ts +4 -0
- package/dist/components/layout/bottom-nav/element-menu-sheet.d.ts +11 -0
- package/dist/components/layout/bottom-nav/element-sheet.d.ts +11 -0
- package/dist/components/layout/bottom-nav/index.d.ts +1 -0
- package/dist/components/layout/header.d.ts +1 -0
- package/dist/components/loading.d.ts +3 -0
- package/dist/components/menus/background.d.ts +6 -0
- package/dist/components/menus/clipart.d.ts +6 -0
- package/dist/components/menus/files.d.ts +7 -0
- package/dist/components/menus/image.d.ts +8 -0
- package/dist/components/menus/index.d.ts +13 -0
- package/dist/components/menus/layer.d.ts +5 -0
- package/dist/components/menus/product.d.ts +3 -0
- package/dist/components/menus/sca.d.ts +5 -0
- package/dist/components/menus/shapes.d.ts +6 -0
- package/dist/components/menus/templates.d.ts +6 -0
- package/dist/components/menus/text-effects.d.ts +5 -0
- package/dist/components/menus/text.d.ts +6 -0
- package/dist/components/placement-tab.d.ts +7 -0
- package/dist/components/preview/3d.d.ts +8 -0
- package/dist/components/preview/graphic.d.ts +15 -0
- package/dist/components/preview/index.d.ts +20 -0
- package/dist/components/preview/open.d.ts +7 -0
- package/dist/components/preview/real-time/3d.d.ts +12 -0
- package/dist/components/preview/real-time/graphic.d.ts +31 -0
- package/dist/components/preview/real-time/index.d.ts +12 -0
- package/dist/components/scale-tools.d.ts +7 -0
- package/dist/components/semi-deisgn-config.d.ts +13 -0
- package/dist/components/semi-design-link.d.ts +9 -0
- package/dist/components/semi-interact-editor.d.ts +27 -0
- package/dist/components/semi-renderer.d.ts +74 -0
- package/dist/components/store.d.ts +1 -0
- package/dist/components/toolbar.d.ts +2 -0
- package/dist/components/upload-types.d.ts +20 -0
- package/dist/config-D2qm60gf.js +16 -0
- package/dist/contracts/api-design.d.ts +180 -0
- package/dist/contracts/design.d.ts +86 -0
- package/dist/design-CZvEVkwi.js +21443 -0
- package/dist/designer-store-Da9fICz8.js +153 -0
- package/dist/engine/canvas-designer.d.ts +101 -0
- package/dist/engine/canvas-designer.js +313 -0
- package/dist/engine/constants.d.ts +26 -0
- package/dist/engine/constants.js +147 -0
- package/dist/engine/editor.d.ts +199 -0
- package/dist/engine/editor.js +801 -0
- package/dist/engine/events.d.ts +35 -0
- package/dist/engine/events.js +7 -0
- package/dist/engine/extensions/curved-text.d.ts +59 -0
- package/dist/engine/fabric.d.ts +4 -0
- package/dist/engine/fabric.js +187 -0
- package/dist/engine/history.d.ts +27 -0
- package/dist/engine/history.js +56 -0
- package/dist/engine/managers/event.d.ts +101 -0
- package/dist/engine/managers/event.js +410 -0
- package/dist/engine/managers/resize.d.ts +26 -0
- package/dist/engine/managers/resize.js +64 -0
- package/dist/engine/managers/snapline.d.ts +70 -0
- package/dist/engine/managers/snapline.js +124 -0
- package/dist/engine/managers/workspace.d.ts +29 -0
- package/dist/engine/managers/workspace.js +75 -0
- package/dist/engine/processors/image.d.ts +88 -0
- package/dist/engine/processors/image.js +473 -0
- package/dist/engine/processors/template.d.ts +45 -0
- package/dist/engine/processors/template.js +314 -0
- package/dist/engine/processors/text.d.ts +74 -0
- package/dist/engine/processors/text.js +215 -0
- package/dist/engine/semi-export-editor.d.ts +215 -0
- package/dist/engine/types.d.ts +28 -0
- package/dist/engine/utils/common.d.ts +25 -0
- package/dist/engine/utils/common.js +68 -0
- package/dist/engine/utils/dialog.d.ts +25 -0
- package/dist/engine/utils/font.d.ts +5 -0
- package/dist/engine/utils/font.js +39 -0
- package/dist/engine/utils/image.d.ts +8 -0
- package/dist/engine/utils/image.js +50 -0
- package/dist/engine/utils/loading.d.ts +17 -0
- package/dist/engine/utils/loading.js +71 -0
- package/dist/engine/utils/measure.d.ts +6 -0
- package/dist/engine/utils/measure.js +6 -0
- package/dist/engine/utils/mockup.d.ts +59 -0
- package/dist/engine/utils/setting.d.ts +4 -0
- package/dist/engine/utils/setting.js +73 -0
- package/dist/fabric-types.d.ts +59 -0
- package/dist/full-designer.js +13 -0
- package/dist/hooks/pagination.d.ts +19 -0
- package/dist/hooks/use-adobe-express.d.ts +50 -0
- package/dist/hooks/use-before-unload.d.ts +1 -0
- package/dist/hooks/use-image-drop.d.ts +18 -0
- package/dist/hooks/use-preview-assets.d.ts +2 -0
- package/dist/hooks/use-screen.d.ts +1 -0
- package/dist/i18n/index.d.ts +12 -0
- package/dist/images/design/asset_empty.png +0 -0
- package/dist/images/design/design/background.svg +3 -0
- package/dist/images/design/design/color-picker.svg +15 -0
- package/dist/images/design/design/computer.svg +1 -0
- package/dist/images/design/design/copy.svg +1 -0
- package/dist/images/design/design/image.svg +10 -0
- package/dist/images/design/design/line.svg +1 -0
- package/dist/images/design/design/text.svg +1 -0
- package/dist/images/design/design/title.svg +1 -0
- package/dist/images/design/empty.png +0 -0
- package/dist/images/design/layer_empty.png +0 -0
- package/dist/images/design/menu/ai.svg +1 -0
- package/dist/images/design/menu/back.svg +4 -0
- package/dist/images/design/menu/background.svg +6 -0
- package/dist/images/design/menu/clipart.svg +6 -0
- package/dist/images/design/menu/file.svg +4 -0
- package/dist/images/design/menu/fill.svg +1 -0
- package/dist/images/design/menu/image.svg +7 -0
- package/dist/images/design/menu/layer.svg +6 -0
- package/dist/images/design/menu/product.svg +3 -0
- package/dist/images/design/menu/sca.svg +5 -0
- package/dist/images/design/menu/shapes.svg +5 -0
- package/dist/images/design/menu/templates.svg +6 -0
- package/dist/images/design/menu/text.svg +6 -0
- package/dist/images/design/menu/uploads.svg +7 -0
- package/dist/images/design/spinner.svg +3 -0
- package/dist/images/design/spinners.svg +17 -0
- package/dist/images/design/transparent_pattern.svg +5 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +156 -0
- package/dist/lib/analytics.d.ts +17 -0
- package/dist/lib/base-plate.d.ts +3 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/common.d.ts +16 -0
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/navigation.d.ts +2 -0
- package/dist/pixel-map-dSys7UAx.js +137 -0
- package/dist/renderer/ThreeDPreview.d.ts +14 -0
- package/dist/renderer/latest-task-queue.d.ts +17 -0
- package/dist/renderer/pixel-map.d.ts +37 -0
- package/dist/renderer/preview-asset-cache.d.ts +4 -0
- package/dist/renderer/render-layer-output.d.ts +5 -0
- package/dist/renderer/semi-resource-cache.d.ts +28 -0
- package/dist/renderer/sticker.d.ts +34 -0
- package/dist/renderer/sticker.js +1837 -0
- package/dist/renderer/three-d-preview.js +32 -0
- package/dist/semi-interact-editor-DfzphWy3.js +1409 -0
- package/dist/semi-renderer.d.ts +7 -0
- package/dist/semi-renderer.js +5 -0
- package/dist/state/designer-store.d.ts +43 -0
- package/dist/state/designer-store.js +8 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +279 -0
- package/dist/ui/accordion.d.ts +7 -0
- package/dist/ui/button-group.d.ts +11 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/checkbox.d.ts +4 -0
- package/dist/ui/command.d.ts +18 -0
- package/dist/ui/confirm-dialog.d.ts +15 -0
- package/dist/ui/context-menu.d.ts +25 -0
- package/dist/ui/dialog.d.ts +15 -0
- package/dist/ui/drawer.d.ts +15 -0
- package/dist/ui/editable-combobox.d.ts +11 -0
- package/dist/ui/hint.d.ts +8 -0
- package/dist/ui/image.d.ts +24 -0
- package/dist/ui/input-group.d.ts +16 -0
- package/dist/ui/input-with-addon.d.ts +17 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/label.d.ts +4 -0
- package/dist/ui/loading-button.d.ts +15 -0
- package/dist/ui/popover.d.ts +9 -0
- package/dist/ui/scroll-area.d.ts +5 -0
- package/dist/ui/select.d.ts +22 -0
- package/dist/ui/separator.d.ts +4 -0
- package/dist/ui/shared-loading-button.d.ts +20 -0
- package/dist/ui/simple-dialog.d.ts +19 -0
- package/dist/ui/simple-popover.d.ts +13 -0
- package/dist/ui/simple-select.d.ts +20 -0
- package/dist/ui/skeleton.d.ts +2 -0
- package/dist/ui/slider.d.ts +4 -0
- package/dist/ui/spinner-box.d.ts +12 -0
- package/dist/ui/spinner.d.ts +2 -0
- package/dist/ui/switch.d.ts +6 -0
- package/dist/ui/tab/index.d.ts +15 -0
- package/dist/ui/textarea.d.ts +3 -0
- package/dist/ui/tooltip.d.ts +7 -0
- package/dist/workers/image-resize.worker.d.ts +1 -0
- package/dist/workers/mockup.worker.d.ts +5 -0
- package/dist/workers/pixel-map.worker.d.ts +1 -0
- package/dist/workers/render-asset-cache.d.ts +18 -0
- package/dist/workers/render.worker.d.ts +1 -0
- package/docs/HOST_DATA_CONTRACT.md +434 -0
- package/docs/INTEGRATION_API.md +547 -0
- package/docs/SEMI_RENDERER.md +141 -0
- package/docs/auth-api.md +3 -0
- package/package.json +199 -4
package/README.md
CHANGED
|
@@ -1,3 +1,225 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @printine/pod-editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React online product designer for Printine-powered products. It provides the
|
|
4
|
+
editor UI, Fabric canvas, 2D/3D preview and design-data integration;
|
|
5
|
+
the host application owns its own routing, authentication, uploads, user
|
|
6
|
+
assets, saved templates and final design persistence.
|
|
7
|
+
|
|
8
|
+
For a complete React integration, including host upload/save implementations,
|
|
9
|
+
start with the [第三方接入文档(React)](https://printine.dev/docs).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @printine/pod-editor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`react` and `react-dom` 18 or 19 are peer dependencies.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
Render the component in the browser on a dedicated page. Replace the example
|
|
22
|
+
product ID with a valid variant ID and supply the complete host-loaded
|
|
23
|
+
`basePlate`. The base plate must contain at least one design area and accessible
|
|
24
|
+
SVG assets. Wait until the base plate is loaded before mounting the editor.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { PrintineDesigner, type BasePlate } from '@printine/pod-editor';
|
|
28
|
+
import '@printine/pod-editor/styles.css';
|
|
29
|
+
|
|
30
|
+
export function ProductDesigner({ basePlate }: { basePlate: BasePlate }) {
|
|
31
|
+
return (
|
|
32
|
+
<PrintineDesigner
|
|
33
|
+
productId="variant-id"
|
|
34
|
+
basePlate={basePlate}
|
|
35
|
+
productInfo={{ title: 'Classic T-shirt', price: 19.9, currency: 'USD' }}
|
|
36
|
+
locale="en-US"
|
|
37
|
+
onClose={() => window.history.back()}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This mounts the editor using the supplied base plate and the host's same-origin
|
|
44
|
+
asset proxy. Upload and Done controls appear only when the host
|
|
45
|
+
provides `adapters.uploadImage` and `onSave`, respectively.
|
|
46
|
+
|
|
47
|
+
For Next.js App Router, dynamically import the component with
|
|
48
|
+
`next/dynamic({ ssr: false })` inside a Client Component. A `'use client'`
|
|
49
|
+
directive alone does not disable server prerendering.
|
|
50
|
+
|
|
51
|
+
The full editor uses viewport-sized layouts and fixed toolbars. Mount one full
|
|
52
|
+
designer at a time: the current implementation uses shared state and
|
|
53
|
+
module-level API clients.
|
|
54
|
+
|
|
55
|
+
## Integration model
|
|
56
|
+
|
|
57
|
+
The host must supply `productId` and a complete `basePlate`. The editor never
|
|
58
|
+
fetches base-plate or product data. Product display information comes through
|
|
59
|
+
`productInfo`, and saved designs through `initialDesignData`. Keep the
|
|
60
|
+
`basePlate` object reference stable during editing; replace it when switching
|
|
61
|
+
to a different base plate.
|
|
62
|
+
|
|
63
|
+
Product details, uploads, saved designs and templates are host-owned.
|
|
64
|
+
|
|
65
|
+
Public editor assets default to the embedding page's own origin, through a merchant backend
|
|
66
|
+
proxy at `/api/v1/editor/*`. The merchant server holds its `assets:read` App Key;
|
|
67
|
+
the browser never receives it. To use a separate authorized resource origin,
|
|
68
|
+
pass domain-only overrides. The package adds the API paths itself:
|
|
69
|
+
|
|
70
|
+
| Prop | Default | SDK-owned path prefix |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| `assetBaseUrl` | Current page origin (`/`) | `/api/v1/editor/` |
|
|
73
|
+
|
|
74
|
+
`assetBaseUrl` is the merchant resource-service origin, not a CDN/static-image
|
|
75
|
+
prefix. The default `/` resolves to the current browser origin; SSR callers of
|
|
76
|
+
the low-level client must provide an absolute origin. Fonts, shapes and clipart
|
|
77
|
+
categories use `/api/v1/editor/*` without legacy aliases or redirects. Requests
|
|
78
|
+
use `credentials: 'same-origin'` and never send an App Key. The proxy must also
|
|
79
|
+
return browser-accessible merchant file URLs, preserving filename suffixes and
|
|
80
|
+
resource `v` references. Cross-origin overrides do not automatically send cookies
|
|
81
|
+
to the other origin. Use a same-origin proxy or supply custom `adapters.library`
|
|
82
|
+
loaders when your resource service needs different authentication. The package
|
|
83
|
+
has no top-level `token` or `appKey` prop.
|
|
84
|
+
|
|
85
|
+
Hosts may supply `adapters.library` for normalized fonts, shapes and clipart.
|
|
86
|
+
Preset colours are host-owned: provide `adapters.library.colors.list` to return
|
|
87
|
+
a `Promise<string[]>`. Without it, the preset palette is empty and no settings
|
|
88
|
+
API request occurs. This does not disable the normal custom colour picker.
|
|
89
|
+
|
|
90
|
+
The following user-specific capabilities are always supplied by the host:
|
|
91
|
+
|
|
92
|
+
| Capability | Host integration | Behaviour when omitted |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| Image upload | `adapters.uploadImage` | Upload controls are hidden. |
|
|
95
|
+
| My images | `adapters.assets.list` | The image library is hidden. |
|
|
96
|
+
| Delete an image | `adapters.assets.remove` | The image delete button is hidden. |
|
|
97
|
+
| My designs | `adapters.templates` | “My designs” is hidden. Saving templates also requires `adapters.uploadImage`. |
|
|
98
|
+
| Save the final design | `onSave` | Done is hidden in the preview. |
|
|
99
|
+
|
|
100
|
+
The public template catalog is currently disabled. User templates are provided
|
|
101
|
+
by `adapters.templates`.
|
|
102
|
+
|
|
103
|
+
### Uploads and assets
|
|
104
|
+
|
|
105
|
+
`uploadImage` receives a `purpose` of `'asset'`, `'design-data'` or
|
|
106
|
+
`'template-preview'` and returns a `DesignerImageUploadResult`:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import type { DesignerImageUploadResult } from '@printine/pod-editor';
|
|
110
|
+
|
|
111
|
+
const result: DesignerImageUploadResult = {
|
|
112
|
+
id: 'host-asset-id',
|
|
113
|
+
url: 'https://cdn.example.com/original/logo.png',
|
|
114
|
+
thumbnailUrl: 'https://cdn.example.com/thumb/logo.png',
|
|
115
|
+
canvasThumbnailUrl: 'https://cdn.example.com/canvas/logo.png',
|
|
116
|
+
thumbnailScale: 0.5,
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Only `url` is required. All URL fields must be complete browser-accessible
|
|
121
|
+
URLs. `thumbnailUrl` is used in lists; `canvasThumbnailUrl` is used on the
|
|
122
|
+
canvas, falling back to `thumbnailUrl`. `thumbnailScale` must match the actual
|
|
123
|
+
canvas thumbnail dimensions divided by the original dimensions.
|
|
124
|
+
|
|
125
|
+
For `purpose: 'asset'`, the host is responsible for its complete workflow:
|
|
126
|
+
uploading the original image, optionally creating a thumbnail, and creating the
|
|
127
|
+
host's asset record before resolving the promise. The package never calls a
|
|
128
|
+
`user-assets` endpoint. Optional `metadata` is supplied for `asset` uploads;
|
|
129
|
+
do not require it for the other purposes. Returning an asset `id` lets the editor
|
|
130
|
+
add the uploaded item to the current library without another list request.
|
|
131
|
+
|
|
132
|
+
### Saved templates
|
|
133
|
+
|
|
134
|
+
`adapters.templates` contains `create`, `list` and `get`; `remove` is optional.
|
|
135
|
+
The package uploads a template preview through `uploadImage` with
|
|
136
|
+
`purpose: 'template-preview'`, then passes the preview URL and template content
|
|
137
|
+
to `templates.create`.
|
|
138
|
+
|
|
139
|
+
### Saving
|
|
140
|
+
|
|
141
|
+
`onSave` receives the prepared design payload:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
type DesignerSaveInput = {
|
|
145
|
+
variant_id: string;
|
|
146
|
+
design_data: Record<string, unknown>;
|
|
147
|
+
previewBlob?: Blob;
|
|
148
|
+
background_customized?: unknown;
|
|
149
|
+
is_partially_customized?: 1;
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`previewBlob` is optional, is not guaranteed for every preview mode, and must be
|
|
154
|
+
uploaded separately from JSON when used. Keep the design JSON intact when
|
|
155
|
+
persisting it. If your endpoint needs `base_plate_id`, add it from the host page;
|
|
156
|
+
it is not included in `DesignerSaveInput`.
|
|
157
|
+
|
|
158
|
+
The callback owns its request, business-error handling, analytics and any route
|
|
159
|
+
change. Resolve only after a successful save; reject on HTTP or business
|
|
160
|
+
failure after displaying the host's error. The package clears its loading state
|
|
161
|
+
without repeating the error. A resolved callback emits `save-complete`; it does
|
|
162
|
+
not automatically navigate or add the design to a cart.
|
|
163
|
+
|
|
164
|
+
### Restoring a saved design
|
|
165
|
+
|
|
166
|
+
Pass the persisted `design_data` through `initialDesignData`, keyed by the base
|
|
167
|
+
plate's `areas[].name`. Restore semi-custom background settings separately
|
|
168
|
+
through `initialBackgroundCustomized`. Use `loading={true}` while fetching a
|
|
169
|
+
record, then initialize the editor with the loaded data. These are initial
|
|
170
|
+
values, not controlled canvas state; change the component `key` when switching
|
|
171
|
+
records or base plates.
|
|
172
|
+
|
|
173
|
+
### Preview rendering
|
|
174
|
+
|
|
175
|
+
Base-plate `renders` and `td_renders` configure live 2D and 3D previews. The
|
|
176
|
+
optional `onRenderPreview` callback handles the full-screen 2D path when no
|
|
177
|
+
usable live preview image exists. It receives the prepared render input and
|
|
178
|
+
must return `Promise<string[]>` containing full image URLs, without a backend
|
|
179
|
+
response wrapper. The package does not call a fixed server-rendering endpoint.
|
|
180
|
+
|
|
181
|
+
### Errors and events
|
|
182
|
+
|
|
183
|
+
`onError` reports editor initialization, preview and internal processing errors.
|
|
184
|
+
Host upload, asset, template and save request failures are handled by the host;
|
|
185
|
+
server-preview callback failures are reported through `onError`.
|
|
186
|
+
|
|
187
|
+
`onEvent` reports `ready`, `load-start`, `load-complete`, `save-start` and
|
|
188
|
+
`save-complete`. Mount/load events do not guarantee that every image or font
|
|
189
|
+
has finished loading. Keep callbacks and library loaders stable to avoid
|
|
190
|
+
restarting initialization effects. `onAnalytics` exposes the `preview_design`
|
|
191
|
+
event; the host owns save analytics.
|
|
192
|
+
|
|
193
|
+
## Styling
|
|
194
|
+
|
|
195
|
+
Import `@printine/pod-editor/styles.css` once. The package ships its icons, empty
|
|
196
|
+
states and editor styles, so no host static files or Tailwind content scanning
|
|
197
|
+
are required.
|
|
198
|
+
|
|
199
|
+
Theme variables use the `--printine-` prefix. Override them globally after the
|
|
200
|
+
package stylesheet so portal-based dialogs and menus inherit the same theme:
|
|
201
|
+
|
|
202
|
+
```css
|
|
203
|
+
:root {
|
|
204
|
+
--printine-primary: #3540a5;
|
|
205
|
+
--printine-background: #f3f5f6;
|
|
206
|
+
--printine-foreground: #1c1c1e;
|
|
207
|
+
--printine-border: #e0e0e5;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Built-in UI languages are English (`en`, `en-US`) and Spanish (`es`, `es-ES`).
|
|
212
|
+
Other locales fall back to English; use `messages` for host-supplied translations.
|
|
213
|
+
Images, fonts, SVGs, models and textures must remain accessible and allow the
|
|
214
|
+
browser to read them across origins when needed for rendering and export.
|
|
215
|
+
|
|
216
|
+
## Public exports
|
|
217
|
+
|
|
218
|
+
The main entry exports `PrintineDesigner` and the TypeScript contracts needed
|
|
219
|
+
for integration, including `PrintineDesignerProps`, `DesignerAdapters`,
|
|
220
|
+
`DesignerAsset`, `DesignerUserTemplate` and `DesignerSaveInput`.
|
|
221
|
+
|
|
222
|
+
`@printine/pod-editor/full-designer` is available for advanced integrations that
|
|
223
|
+
already provide a designer runtime and the required `basePlate` prop. The main entry also exports
|
|
224
|
+
`PrintineSemiRenderer` for standalone local preview rendering and
|
|
225
|
+
`PrintineSemiInteractEditor` for semi-custom editing.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PrintineDesignerProps } from './types';
|
|
2
|
+
import './styles.css';
|
|
3
|
+
/**
|
|
4
|
+
* Public full-screen mount point for the Printine online designer.
|
|
5
|
+
*
|
|
6
|
+
* It mounts the complete editor UI (Fabric canvas, tool panels, real-time
|
|
7
|
+
* 2D/3D previews and save flow) without coupling the host to Next.js.
|
|
8
|
+
*/
|
|
9
|
+
export declare function PrintineDesigner(props: PrintineDesignerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AssetCenterApiClient, AssetCenterApiClientOptions } from '../types';
|
|
2
|
+
/** Browser default: the embedding application's authenticated asset proxy. */
|
|
3
|
+
export declare const DEFAULT_PRINTINE_ASSET_BASE_URL = "/";
|
|
4
|
+
/**
|
|
5
|
+
* Read-only merchant editor-asset proxy client. No App Key or internal token
|
|
6
|
+
* reaches the browser.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAssetCenterApiClient(options: AssetCenterApiClientOptions): AssetCenterApiClient;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const c = "api/v1/editor/", a = /* @__PURE__ */ new Set(["fonts", "shapes", "clipart-categories", "cliparts"]), l = "/";
|
|
2
|
+
function u(e, t) {
|
|
3
|
+
if (!a.has(t))
|
|
4
|
+
throw new Error("Unsupported editor asset endpoint. Use the documented /api/v1/editor lists.");
|
|
5
|
+
const r = /^https?:\/\//i.test(e) ? new URL(e) : typeof window < "u" ? new URL(e, window.location.origin) : null;
|
|
6
|
+
if (!r)
|
|
7
|
+
throw new Error("An absolute assetBaseUrl domain is required for SSR.");
|
|
8
|
+
const n = new URL(c, r.origin);
|
|
9
|
+
return new URL(t, n);
|
|
10
|
+
}
|
|
11
|
+
function o(e, t) {
|
|
12
|
+
if (typeof e == "object" && e !== null && "error" in e) {
|
|
13
|
+
const r = e.error;
|
|
14
|
+
if (typeof r == "object" && r !== null && "message" in r) {
|
|
15
|
+
const n = r.message;
|
|
16
|
+
if (typeof n == "string" && n) return n;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return `Editor asset request failed (${t})`;
|
|
20
|
+
}
|
|
21
|
+
async function f(e) {
|
|
22
|
+
const t = await e.json().catch(() => null);
|
|
23
|
+
if (!e.ok) throw new Error(o(t, e.status));
|
|
24
|
+
if (!t || t.success !== !0) throw new Error(o(t, e.status));
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
function w(e) {
|
|
28
|
+
return {
|
|
29
|
+
async get(t, r) {
|
|
30
|
+
const n = u(e.assetBaseUrl, t);
|
|
31
|
+
for (const [i, s] of Object.entries(r ?? {}))
|
|
32
|
+
s !== void 0 && n.searchParams.set(i, String(s));
|
|
33
|
+
return f(await fetch(n, { credentials: "same-origin" }));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
l as DEFAULT_PRINTINE_ASSET_BASE_URL,
|
|
39
|
+
w as createAssetCenterApiClient
|
|
40
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Font } from '../contracts/design';
|
|
2
|
+
import type { AssetCenterApiClient } from '../types';
|
|
3
|
+
export interface AssetCenterShape {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
thumbnailUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AssetCenterClipArt {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
url: string;
|
|
13
|
+
thumbnailUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AssetCenterClipArtCategory {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
clip_arts: AssetCenterClipArt[];
|
|
19
|
+
showAll?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface AssetCenterPage<T> {
|
|
22
|
+
data: T[];
|
|
23
|
+
meta: {
|
|
24
|
+
current_page: number;
|
|
25
|
+
last_page: number;
|
|
26
|
+
total: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function setAssetCenterApiClient(next: AssetCenterApiClient | null): void;
|
|
30
|
+
/** Unified editor asset endpoints mapped to the editor's view models. */
|
|
31
|
+
export declare const AssetCenterApi: {
|
|
32
|
+
getFontList(): Promise<Font[]>;
|
|
33
|
+
getShapeList(params: Record<string, string | number | boolean | undefined>): Promise<AssetCenterPage<AssetCenterShape>>;
|
|
34
|
+
getClipArtCategories(): Promise<AssetCenterPage<AssetCenterClipArtCategory>>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { AspectRatioIcon } from './aspect_ratio';
|
|
2
|
+
export { FitScreenIcon } from './fit_screen';
|
|
3
|
+
export { PanIcon } from './pan';
|
|
4
|
+
export { SettingIcon } from './setting';
|
|
5
|
+
export { TextColorIcon } from './text_color';
|
|
6
|
+
export { TextHIcon } from './text_h';
|
|
7
|
+
export { TextVIcon } from './text_v';
|
|
8
|
+
export { Loading1Icon } from './loading_1';
|
|
9
|
+
export { Loading2Icon } from './loading_2';
|
|
10
|
+
export { Loading3Icon } from './loading_3';
|
|
11
|
+
export { DeleteIcon } from './delete';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TemplateData } from '../contracts/api-design';
|
|
2
|
+
type AddDesignProps = {
|
|
3
|
+
template: TemplateData | null;
|
|
4
|
+
show: boolean;
|
|
5
|
+
onChange: (value: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
export default function AddDesign({ template, ...props }: AddDesignProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SelectImageParams {
|
|
2
|
+
/** Original image URL retained for high-resolution rendering. */
|
|
3
|
+
url: string;
|
|
4
|
+
/** Host-provided small rendition, used only for option-list thumbnails. */
|
|
5
|
+
thumbnailUrl?: string;
|
|
6
|
+
/** Host-provided rendition intended for the editable canvas. */
|
|
7
|
+
canvasThumbnailUrl?: string;
|
|
8
|
+
blobUrl?: string;
|
|
9
|
+
scale?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface AssetsDialogProps {
|
|
12
|
+
open: boolean;
|
|
13
|
+
onOpenChange: (open: boolean) => void;
|
|
14
|
+
onSelectImage: (image: SelectImageParams) => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Package-owned replacement for the host's asset-library dialog.
|
|
19
|
+
*
|
|
20
|
+
* It deliberately exposes only the package-safe upload flow. A host can add a
|
|
21
|
+
* DAM outside the package when needed, without coupling this reusable dialog to
|
|
22
|
+
* a page-owned asset-library implementation.
|
|
23
|
+
*/
|
|
24
|
+
export default function AssetsDialog({ open, onOpenChange, onSelectImage, className }: AssetsDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ColorPickerProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
onChange?: (value: string, type: string) => void;
|
|
6
|
+
custom?: boolean;
|
|
7
|
+
unset?: boolean;
|
|
8
|
+
colors?: string[];
|
|
9
|
+
}
|
|
10
|
+
export default function ColorPicker({ value, onChange, custom, unset, colors, className, }: ColorPickerProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Editor from '../engine/editor';
|
|
2
|
+
import EventManager from '../engine/managers/event';
|
|
3
|
+
import { Product, BasePlate } from '../contracts/api-design';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import type { PersistImage } from './upload-types';
|
|
6
|
+
type DesignContextType = {
|
|
7
|
+
canvasEditor: React.RefObject<Editor | null>;
|
|
8
|
+
eventManager: React.RefObject<EventManager | null>;
|
|
9
|
+
productData: Product;
|
|
10
|
+
plateData: BasePlate;
|
|
11
|
+
currentViewName: string;
|
|
12
|
+
viewColors: Record<string, string>;
|
|
13
|
+
setViewColors: React.Dispatch<React.SetStateAction<Record<string, string>>>;
|
|
14
|
+
onPersistImage: PersistImage;
|
|
15
|
+
onChangeView: (placement: string) => Promise<void>;
|
|
16
|
+
setCanvasLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
|
+
};
|
|
18
|
+
export declare const DesignContext: React.Context<DesignContextType | null>;
|
|
19
|
+
export declare const useDesignContext: () => DesignContextType;
|
|
20
|
+
export declare function DesignProvider({ value, children }: {
|
|
21
|
+
value: DesignContextType;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BasePlate } from '../contracts/api-design';
|
|
2
|
+
export interface FullDesignerProps {
|
|
3
|
+
/** Enables the optional semi-customization menu supplied by the existing API. */
|
|
4
|
+
semiDesignPermission?: boolean;
|
|
5
|
+
/** Complete base plate supplied by the host. */
|
|
6
|
+
basePlate: BasePlate;
|
|
7
|
+
}
|
|
8
|
+
declare const Design: ({ semiDesignPermission, basePlate }: FullDesignerProps) => import("react").JSX.Element;
|
|
9
|
+
export default Design;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Font, FontFile } from '../contracts/design';
|
|
2
|
+
interface FontsProps {
|
|
3
|
+
type: 'ADD' | 'UPDATE' | 'CHECK';
|
|
4
|
+
onUpdate?: (data: {
|
|
5
|
+
fontFamily: string;
|
|
6
|
+
fontWeight: number;
|
|
7
|
+
fontStyle: string;
|
|
8
|
+
fontPath: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
onDone?: () => void;
|
|
11
|
+
checkedList?: Font[];
|
|
12
|
+
}
|
|
13
|
+
export type FontsRef = {
|
|
14
|
+
getCheckedFonts: () => Font[];
|
|
15
|
+
};
|
|
16
|
+
declare const Fonts: import("react").ForwardRefExoticComponent<FontsProps & import("react").RefAttributes<FontsRef>>;
|
|
17
|
+
export interface FontListProps {
|
|
18
|
+
type: 'ADD' | 'UPDATE' | 'CHECK';
|
|
19
|
+
onAddText?: (item: Font, font: FontFile) => void;
|
|
20
|
+
fontList: Font[];
|
|
21
|
+
onCheck?: (item: Font, file: FontFile) => void;
|
|
22
|
+
checkedFonts?: Font[];
|
|
23
|
+
showSearchBar?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function FontList({ fontList, type, onCheck, onAddText, checkedFonts, showSearchBar, }: FontListProps): import("react").JSX.Element;
|
|
26
|
+
export default Fonts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ImageEdit(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ElementType } from '../../../contracts/design';
|
|
2
|
+
/**
|
|
3
|
+
* 手机端元素菜单弹窗
|
|
4
|
+
*/
|
|
5
|
+
interface MenuPhoneProps {
|
|
6
|
+
show: boolean;
|
|
7
|
+
setShow: (show: boolean) => void;
|
|
8
|
+
onAddVariant: (type: ElementType) => void;
|
|
9
|
+
}
|
|
10
|
+
export default function ElementMenuSheet({ show, setShow, onAddVariant }: MenuPhoneProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ElementType } from '../../../contracts/design';
|
|
2
|
+
import { ExtraData } from '../../menus';
|
|
3
|
+
type ElementSheetProps = {
|
|
4
|
+
show: boolean;
|
|
5
|
+
contentType?: ElementType;
|
|
6
|
+
setShow: (show: boolean) => void;
|
|
7
|
+
onBack?: () => void;
|
|
8
|
+
extraData?: ExtraData;
|
|
9
|
+
};
|
|
10
|
+
export default function ElementSheet({ show, contentType, setShow, extraData, ...props }: ElementSheetProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function BottomNav(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Header(): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ElementType } from '../../contracts/design';
|
|
2
|
+
export interface ExtraData {
|
|
3
|
+
shape?: boolean;
|
|
4
|
+
image?: File;
|
|
5
|
+
hideBack?: boolean;
|
|
6
|
+
}
|
|
7
|
+
type MenuProps = {
|
|
8
|
+
type?: ElementType;
|
|
9
|
+
position?: 'sidebar' | 'sheet';
|
|
10
|
+
extraData?: ExtraData;
|
|
11
|
+
};
|
|
12
|
+
export default function Menu({ type, position }: MenuProps): import("react").JSX.Element;
|
|
13
|
+
export {};
|