@printine/pod-editor 0.0.0-stage → 0.1.14

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.
Files changed (222) hide show
  1. package/README.md +242 -2
  2. package/dist/DesignerRuntimeContext.d.ts +3 -0
  3. package/dist/PrintineDesigner.d.ts +9 -0
  4. package/dist/api/asset-client.d.ts +8 -0
  5. package/dist/api/asset-client.js +40 -0
  6. package/dist/api/asset-endpoints.d.ts +36 -0
  7. package/dist/api/client.d.ts +8 -0
  8. package/dist/api/client.js +82 -0
  9. package/dist/api/common-endpoints.d.ts +12 -0
  10. package/dist/api/design-endpoints.d.ts +4 -0
  11. package/dist/api/endpoints.d.ts +23 -0
  12. package/dist/api/endpoints.js +33 -0
  13. package/dist/api/files-endpoints.d.ts +1 -0
  14. package/dist/assets/icons/aspect_ratio.d.ts +3 -0
  15. package/dist/assets/icons/delete.d.ts +3 -0
  16. package/dist/assets/icons/fit_screen.d.ts +3 -0
  17. package/dist/assets/icons/index.d.ts +11 -0
  18. package/dist/assets/icons/loading_1.d.ts +3 -0
  19. package/dist/assets/icons/loading_2.d.ts +3 -0
  20. package/dist/assets/icons/loading_3.d.ts +3 -0
  21. package/dist/assets/icons/pan.d.ts +3 -0
  22. package/dist/assets/icons/setting.d.ts +3 -0
  23. package/dist/assets/icons/text_color.d.ts +3 -0
  24. package/dist/assets/icons/text_h.d.ts +3 -0
  25. package/dist/assets/icons/text_v.d.ts +3 -0
  26. package/dist/bundled-assets.d.ts +4 -0
  27. package/dist/components/add-design.d.ts +8 -0
  28. package/dist/components/assets-dialog.d.ts +24 -0
  29. package/dist/components/canvas-context-menu.d.ts +6 -0
  30. package/dist/components/color-picker/index.d.ts +11 -0
  31. package/dist/components/context.d.ts +24 -0
  32. package/dist/components/design.d.ts +9 -0
  33. package/dist/components/fonts.d.ts +26 -0
  34. package/dist/components/image-crop.d.ts +5 -0
  35. package/dist/components/image-edit.d.ts +1 -0
  36. package/dist/components/layout/aside.d.ts +4 -0
  37. package/dist/components/layout/bottom-nav/element-menu-sheet.d.ts +11 -0
  38. package/dist/components/layout/bottom-nav/element-sheet.d.ts +11 -0
  39. package/dist/components/layout/bottom-nav/index.d.ts +1 -0
  40. package/dist/components/layout/header.d.ts +1 -0
  41. package/dist/components/loading.d.ts +3 -0
  42. package/dist/components/menus/ai.d.ts +5 -0
  43. package/dist/components/menus/background.d.ts +6 -0
  44. package/dist/components/menus/clipart.d.ts +6 -0
  45. package/dist/components/menus/files.d.ts +7 -0
  46. package/dist/components/menus/image.d.ts +8 -0
  47. package/dist/components/menus/index.d.ts +13 -0
  48. package/dist/components/menus/layer.d.ts +5 -0
  49. package/dist/components/menus/product.d.ts +3 -0
  50. package/dist/components/menus/sca.d.ts +5 -0
  51. package/dist/components/menus/shapes.d.ts +6 -0
  52. package/dist/components/menus/templates.d.ts +6 -0
  53. package/dist/components/menus/text-effects.d.ts +5 -0
  54. package/dist/components/menus/text.d.ts +6 -0
  55. package/dist/components/placement-tab.d.ts +7 -0
  56. package/dist/components/preview/3d.d.ts +8 -0
  57. package/dist/components/preview/graphic.d.ts +15 -0
  58. package/dist/components/preview/index.d.ts +20 -0
  59. package/dist/components/preview/open.d.ts +7 -0
  60. package/dist/components/preview/real-time/3d.d.ts +12 -0
  61. package/dist/components/preview/real-time/graphic.d.ts +31 -0
  62. package/dist/components/preview/real-time/index.d.ts +12 -0
  63. package/dist/components/scale-tools.d.ts +7 -0
  64. package/dist/components/semi-deisgn-config.d.ts +13 -0
  65. package/dist/components/semi-design-link.d.ts +9 -0
  66. package/dist/components/semi-interact-editor.d.ts +27 -0
  67. package/dist/components/semi-renderer.d.ts +74 -0
  68. package/dist/components/store.d.ts +1 -0
  69. package/dist/components/toolbar.d.ts +2 -0
  70. package/dist/config-D2qm60gf.js +16 -0
  71. package/dist/contracts/api-design.d.ts +180 -0
  72. package/dist/contracts/design.d.ts +86 -0
  73. package/dist/design-C_TmcalT.js +21449 -0
  74. package/dist/designer-store-Da9fICz8.js +153 -0
  75. package/dist/engine/canvas-designer.d.ts +101 -0
  76. package/dist/engine/canvas-designer.js +313 -0
  77. package/dist/engine/constants.d.ts +26 -0
  78. package/dist/engine/constants.js +147 -0
  79. package/dist/engine/editor.d.ts +199 -0
  80. package/dist/engine/editor.js +801 -0
  81. package/dist/engine/events.d.ts +35 -0
  82. package/dist/engine/events.js +7 -0
  83. package/dist/engine/extensions/curved-text.d.ts +59 -0
  84. package/dist/engine/fabric.d.ts +4 -0
  85. package/dist/engine/fabric.js +187 -0
  86. package/dist/engine/history.d.ts +27 -0
  87. package/dist/engine/history.js +56 -0
  88. package/dist/engine/managers/event.d.ts +101 -0
  89. package/dist/engine/managers/event.js +410 -0
  90. package/dist/engine/managers/resize.d.ts +26 -0
  91. package/dist/engine/managers/resize.js +64 -0
  92. package/dist/engine/managers/snapline.d.ts +70 -0
  93. package/dist/engine/managers/snapline.js +124 -0
  94. package/dist/engine/managers/workspace.d.ts +29 -0
  95. package/dist/engine/managers/workspace.js +75 -0
  96. package/dist/engine/processors/image.d.ts +88 -0
  97. package/dist/engine/processors/image.js +473 -0
  98. package/dist/engine/processors/template.d.ts +45 -0
  99. package/dist/engine/processors/template.js +314 -0
  100. package/dist/engine/processors/text.d.ts +74 -0
  101. package/dist/engine/processors/text.js +215 -0
  102. package/dist/engine/semi-export-editor.d.ts +215 -0
  103. package/dist/engine/types.d.ts +28 -0
  104. package/dist/engine/utils/common.d.ts +25 -0
  105. package/dist/engine/utils/common.js +68 -0
  106. package/dist/engine/utils/dialog.d.ts +25 -0
  107. package/dist/engine/utils/font.d.ts +5 -0
  108. package/dist/engine/utils/font.js +39 -0
  109. package/dist/engine/utils/image.d.ts +8 -0
  110. package/dist/engine/utils/image.js +50 -0
  111. package/dist/engine/utils/loading.d.ts +17 -0
  112. package/dist/engine/utils/loading.js +71 -0
  113. package/dist/engine/utils/measure.d.ts +6 -0
  114. package/dist/engine/utils/measure.js +6 -0
  115. package/dist/engine/utils/mockup.d.ts +59 -0
  116. package/dist/engine/utils/setting.d.ts +4 -0
  117. package/dist/engine/utils/setting.js +73 -0
  118. package/dist/fabric-types.d.ts +59 -0
  119. package/dist/full-designer.js +14 -0
  120. package/dist/hooks/pagination.d.ts +19 -0
  121. package/dist/hooks/use-adobe-express.d.ts +50 -0
  122. package/dist/hooks/use-before-unload.d.ts +1 -0
  123. package/dist/hooks/use-image-drop.d.ts +18 -0
  124. package/dist/hooks/use-oss-upload.d.ts +36 -0
  125. package/dist/hooks/use-preview-assets.d.ts +2 -0
  126. package/dist/hooks/use-screen.d.ts +1 -0
  127. package/dist/i18n/index.d.ts +12 -0
  128. package/dist/images/design/asset_empty.png +0 -0
  129. package/dist/images/design/design/background.svg +3 -0
  130. package/dist/images/design/design/color-picker.svg +15 -0
  131. package/dist/images/design/design/computer.svg +1 -0
  132. package/dist/images/design/design/copy.svg +1 -0
  133. package/dist/images/design/design/image.svg +10 -0
  134. package/dist/images/design/design/line.svg +1 -0
  135. package/dist/images/design/design/text.svg +1 -0
  136. package/dist/images/design/design/title.svg +1 -0
  137. package/dist/images/design/empty.png +0 -0
  138. package/dist/images/design/layer_empty.png +0 -0
  139. package/dist/images/design/menu/ai.svg +1 -0
  140. package/dist/images/design/menu/back.svg +4 -0
  141. package/dist/images/design/menu/background.svg +6 -0
  142. package/dist/images/design/menu/clipart.svg +6 -0
  143. package/dist/images/design/menu/file.svg +4 -0
  144. package/dist/images/design/menu/fill.svg +1 -0
  145. package/dist/images/design/menu/image.svg +7 -0
  146. package/dist/images/design/menu/layer.svg +6 -0
  147. package/dist/images/design/menu/product.svg +3 -0
  148. package/dist/images/design/menu/sca.svg +5 -0
  149. package/dist/images/design/menu/shapes.svg +5 -0
  150. package/dist/images/design/menu/templates.svg +6 -0
  151. package/dist/images/design/menu/text.svg +6 -0
  152. package/dist/images/design/menu/uploads.svg +7 -0
  153. package/dist/images/design/spinner.svg +3 -0
  154. package/dist/images/design/spinners.svg +17 -0
  155. package/dist/images/design/transparent_pattern.svg +5 -0
  156. package/dist/index.d.ts +51 -0
  157. package/dist/index.js +168 -0
  158. package/dist/lib/analytics.d.ts +17 -0
  159. package/dist/lib/cn.d.ts +3 -0
  160. package/dist/lib/common.d.ts +16 -0
  161. package/dist/lib/config.d.ts +14 -0
  162. package/dist/lib/navigation.d.ts +2 -0
  163. package/dist/pixel-map-dSys7UAx.js +137 -0
  164. package/dist/renderer/ThreeDPreview.d.ts +14 -0
  165. package/dist/renderer/latest-task-queue.d.ts +17 -0
  166. package/dist/renderer/pixel-map.d.ts +37 -0
  167. package/dist/renderer/preview-asset-cache.d.ts +4 -0
  168. package/dist/renderer/render-layer-output.d.ts +5 -0
  169. package/dist/renderer/semi-resource-cache.d.ts +28 -0
  170. package/dist/renderer/sticker.d.ts +34 -0
  171. package/dist/renderer/sticker.js +1837 -0
  172. package/dist/renderer/three-d-preview.js +32 -0
  173. package/dist/semi-interact-editor-DfzphWy3.js +1409 -0
  174. package/dist/semi-renderer.d.ts +7 -0
  175. package/dist/semi-renderer.js +5 -0
  176. package/dist/state/designer-store.d.ts +43 -0
  177. package/dist/state/designer-store.js +8 -0
  178. package/dist/style.css +1 -0
  179. package/dist/types.d.ts +305 -0
  180. package/dist/ui/accordion.d.ts +7 -0
  181. package/dist/ui/button-group.d.ts +11 -0
  182. package/dist/ui/button.d.ts +10 -0
  183. package/dist/ui/checkbox.d.ts +4 -0
  184. package/dist/ui/command.d.ts +18 -0
  185. package/dist/ui/confirm-dialog.d.ts +15 -0
  186. package/dist/ui/context-menu.d.ts +25 -0
  187. package/dist/ui/dialog.d.ts +15 -0
  188. package/dist/ui/drawer.d.ts +15 -0
  189. package/dist/ui/editable-combobox.d.ts +11 -0
  190. package/dist/ui/hint.d.ts +8 -0
  191. package/dist/ui/image.d.ts +24 -0
  192. package/dist/ui/input-group.d.ts +16 -0
  193. package/dist/ui/input-with-addon.d.ts +17 -0
  194. package/dist/ui/input.d.ts +3 -0
  195. package/dist/ui/label.d.ts +4 -0
  196. package/dist/ui/loading-button.d.ts +15 -0
  197. package/dist/ui/popover.d.ts +9 -0
  198. package/dist/ui/scroll-area.d.ts +5 -0
  199. package/dist/ui/select.d.ts +22 -0
  200. package/dist/ui/separator.d.ts +4 -0
  201. package/dist/ui/shared-loading-button.d.ts +20 -0
  202. package/dist/ui/simple-dialog.d.ts +19 -0
  203. package/dist/ui/simple-popover.d.ts +13 -0
  204. package/dist/ui/simple-select.d.ts +20 -0
  205. package/dist/ui/skeleton.d.ts +2 -0
  206. package/dist/ui/slider.d.ts +4 -0
  207. package/dist/ui/spinner-box.d.ts +12 -0
  208. package/dist/ui/spinner.d.ts +2 -0
  209. package/dist/ui/switch.d.ts +6 -0
  210. package/dist/ui/tab/index.d.ts +15 -0
  211. package/dist/ui/textarea.d.ts +3 -0
  212. package/dist/ui/tooltip.d.ts +7 -0
  213. package/dist/workers/image-resize.worker.d.ts +1 -0
  214. package/dist/workers/mockup.worker.d.ts +5 -0
  215. package/dist/workers/pixel-map.worker.d.ts +1 -0
  216. package/dist/workers/render-asset-cache.d.ts +18 -0
  217. package/dist/workers/render.worker.d.ts +1 -0
  218. package/docs/HOST_DATA_CONTRACT.md +426 -0
  219. package/docs/INTEGRATION_API.md +549 -0
  220. package/docs/SEMI_RENDERER.md +141 -0
  221. package/docs/auth-api.md +3 -0
  222. package/package.json +208 -4
package/README.md CHANGED
@@ -1,3 +1,243 @@
1
- # Temporary Holding Version
1
+ # @printine/pod-editor
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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)](./docs/INTEGRATION_API.md).
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
+ ## Migrating from @printine/designer
20
+
21
+ Replace the dependency with `@printine/pod-editor` and update all import paths,
22
+ including subpaths such as `/styles.css`, `/full-designer` and `/semi-renderer`.
23
+ The `PrintineDesigner` component, exported APIs and CSS selectors are unchanged.
24
+ Existing projects can keep using the previously published `@printine/designer`
25
+ package until they migrate.
26
+
27
+ ## Quick start
28
+
29
+ Render the component in the browser on a dedicated page. Replace the example
30
+ IDs with a valid product variant ID and its matching base-plate ID. The
31
+ base plate must contain at least one design area and accessible SVG assets.
32
+
33
+ ```tsx
34
+ import { PrintineDesigner } from '@printine/pod-editor';
35
+ import '@printine/pod-editor/styles.css';
36
+
37
+ export function ProductDesigner() {
38
+ return (
39
+ <PrintineDesigner
40
+ productId="variant-id"
41
+ basePlateId="model-id"
42
+ productInfo={{ title: 'Classic T-shirt', price: 19.9, currency: 'USD' }}
43
+ locale="en-US"
44
+ onClose={() => window.history.back()}
45
+ />
46
+ );
47
+ }
48
+ ```
49
+
50
+ This mounts the editor using the default base-plate service and the host's
51
+ same-origin asset proxy. Upload and Done controls appear only when the host
52
+ provides `adapters.uploadImage` and `onSave`, respectively. See the
53
+ [complete upload/save example](./docs/INTEGRATION_API.md#32-带上传与保存的完整示例)
54
+ to connect those capabilities to your backend.
55
+
56
+ For Next.js App Router, dynamically import the component with
57
+ `next/dynamic({ ssr: false })` inside a Client Component. A `'use client'`
58
+ directive alone does not disable server prerendering. See the
59
+ [SSR integration example](./docs/INTEGRATION_API.md#33-使用-ssr-框架).
60
+
61
+ The full editor uses viewport-sized layouts and fixed toolbars. Mount one full
62
+ designer at a time: the current implementation uses shared state and
63
+ module-level API clients.
64
+
65
+ ## Integration model
66
+
67
+ The Printine API defaults to the production origin. The full designer loads
68
+ base-plate data from it; product display information comes from the host
69
+ through `productInfo`, and saved designs through `initialDesignData`. It does
70
+ not automatically fetch product details. Pass a complete `basePlate` to skip
71
+ the initial base-plate request; `productId` and `basePlateId` remain required.
72
+
73
+ Public editor assets default to the embedding page's own origin, through a merchant backend
74
+ proxy at `/api/v1/editor/*`. The merchant server holds its `assets:read` App Key;
75
+ the browser never receives it. To use a separate authorized resource origin,
76
+ pass domain-only overrides. The package adds the API paths itself:
77
+
78
+ | Prop | Default | SDK-owned path prefix |
79
+ | --- | --- | --- |
80
+ | `apiBaseUrl` | `https://shop-api.printine.com` | `/api/client/` |
81
+ | `assetBaseUrl` | Current page origin (`/`) | `/api/v1/editor/` |
82
+
83
+ `assetBaseUrl` is the merchant resource-service origin, not a CDN/static-image
84
+ prefix. The default `/` resolves to the current browser origin; SSR callers of
85
+ the low-level client must provide an absolute origin. Fonts, shapes and clipart
86
+ categories use `/api/v1/editor/*` without legacy aliases or redirects. Requests
87
+ use `credentials: 'same-origin'` and never send an App Key or use the product
88
+ API's 445 guest-token retry. The proxy must also return browser-accessible
89
+ merchant file URLs, preserving filename suffixes and resource `v` references.
90
+ Cross-origin overrides do not automatically send cookies to the other origin.
91
+ Use a same-origin proxy or supply custom `adapters.library` loaders when your
92
+ resource service needs different authentication. The package has no top-level
93
+ `token` or `appKey` prop. Printine API responses with business code `445` trigger
94
+ one guest-token recovery and retry; this does not apply to asset requests.
95
+
96
+ Hosts may supply `adapters.library` for normalized fonts, shapes and clipart.
97
+ Preset colours are host-owned: provide `adapters.library.colors.list` to return
98
+ a `Promise<string[]>`. Without it, the preset palette is empty and no settings
99
+ API request occurs. This does not disable the normal custom colour picker.
100
+
101
+ The following user-specific capabilities are always supplied by the host:
102
+
103
+ | Capability | Host integration | Behaviour when omitted |
104
+ | --- | --- | --- |
105
+ | Image upload | `adapters.uploadImage` | Upload controls are hidden. |
106
+ | My images | `adapters.assets.list` | The image library is hidden. |
107
+ | Delete an image | `adapters.assets.remove` | The image delete button is hidden. |
108
+ | My designs | `adapters.templates` | “My designs” is hidden. Saving templates also requires `adapters.uploadImage`. |
109
+ | Save the final design | `onSave` | Done is hidden in the preview. |
110
+
111
+ The public template catalog is currently disabled. User templates are provided
112
+ by `adapters.templates`.
113
+
114
+ ### Uploads and assets
115
+
116
+ `uploadImage` receives a `purpose` of `'asset'`, `'design-data'` or
117
+ `'template-preview'` and returns a `DesignerImageUploadResult`:
118
+
119
+ ```ts
120
+ import type { DesignerImageUploadResult } from '@printine/pod-editor';
121
+
122
+ const result: DesignerImageUploadResult = {
123
+ id: 'host-asset-id',
124
+ url: 'https://cdn.example.com/original/logo.png',
125
+ thumbnailUrl: 'https://cdn.example.com/thumb/logo.png',
126
+ canvasThumbnailUrl: 'https://cdn.example.com/canvas/logo.png',
127
+ thumbnailScale: 0.5,
128
+ };
129
+ ```
130
+
131
+ Only `url` is required. All URL fields must be complete browser-accessible
132
+ URLs. `thumbnailUrl` is used in lists; `canvasThumbnailUrl` is used on the
133
+ canvas, falling back to `thumbnailUrl`. `thumbnailScale` must match the actual
134
+ canvas thumbnail dimensions divided by the original dimensions.
135
+
136
+ For `purpose: 'asset'`, the host is responsible for its complete workflow:
137
+ uploading the original image, optionally creating a thumbnail, and creating the
138
+ host's asset record before resolving the promise. The package never calls a
139
+ `user-assets` endpoint. Optional `metadata` is supplied for `asset` uploads;
140
+ do not require it for the other purposes. Returning an asset `id` lets the editor
141
+ add the uploaded item to the current library without another list request.
142
+
143
+ ### Saved templates
144
+
145
+ `adapters.templates` contains `create`, `list` and `get`; `remove` is optional.
146
+ The package uploads a template preview through `uploadImage` with
147
+ `purpose: 'template-preview'`, then passes the preview URL and template content
148
+ to `templates.create`.
149
+
150
+ ### Saving
151
+
152
+ `onSave` receives the prepared design payload:
153
+
154
+ ```ts
155
+ type DesignerSaveInput = {
156
+ variant_id: string;
157
+ design_data: Record<string, unknown>;
158
+ previewBlob?: Blob;
159
+ background_customized?: unknown;
160
+ is_partially_customized?: 1;
161
+ };
162
+ ```
163
+
164
+ `previewBlob` is optional, is not guaranteed for every preview mode, and must be
165
+ uploaded separately from JSON when used. Keep the design JSON intact when
166
+ persisting it. If your endpoint needs `base_plate_id`, add it from the host page;
167
+ it is not included in `DesignerSaveInput`.
168
+
169
+ The callback owns its request, business-error handling, analytics and any route
170
+ change. Resolve only after a successful save; reject on HTTP or business
171
+ failure after displaying the host's error. The package clears its loading state
172
+ without repeating the error. A resolved callback emits `save-complete`; it does
173
+ not automatically navigate or add the design to a cart.
174
+
175
+ ### Restoring a saved design
176
+
177
+ Pass the persisted `design_data` through `initialDesignData`, keyed by the base
178
+ plate's `areas[].name`. Restore semi-custom background settings separately
179
+ through `initialBackgroundCustomized`. Use `loading={true}` while fetching a
180
+ record, then initialize the editor with the loaded data. These are initial
181
+ values, not controlled canvas state; change the component `key` when switching
182
+ records or base plates. See the [restore example](./docs/INTEGRATION_API.md#62-恢复编辑).
183
+
184
+ ### Preview rendering
185
+
186
+ Base-plate `renders` and `td_renders` configure live 2D and 3D previews. The
187
+ optional `onRenderPreview` callback handles the full-screen 2D path when no
188
+ usable live preview image exists. It receives the prepared render input and
189
+ must return `Promise<string[]>` containing full image URLs, without a backend
190
+ response wrapper. The package does not call a fixed server-rendering endpoint.
191
+
192
+ ### Errors and events
193
+
194
+ `onError` reports editor initialization, preview and internal processing errors.
195
+ Host upload, asset, template and save request failures are handled by the host;
196
+ server-preview callback failures are reported through `onError`.
197
+
198
+ `onEvent` reports `ready`, `load-start`, `load-complete`, `save-start` and
199
+ `save-complete`. Mount/load events do not guarantee that every image or font
200
+ has finished loading. Keep callbacks and library loaders stable to avoid
201
+ restarting initialization effects. `onAnalytics` exposes the `preview_design`
202
+ event; the host owns save analytics.
203
+
204
+ ## Styling
205
+
206
+ Import `@printine/pod-editor/styles.css` once. The package ships its icons, empty
207
+ states and editor styles, so no host static files or Tailwind content scanning
208
+ are required.
209
+
210
+ Theme variables use the `--printine-` prefix. Override them globally after the
211
+ package stylesheet so portal-based dialogs and menus inherit the same theme:
212
+
213
+ ```css
214
+ :root {
215
+ --printine-primary: #3540a5;
216
+ --printine-background: #f3f5f6;
217
+ --printine-foreground: #1c1c1e;
218
+ --printine-border: #e0e0e5;
219
+ }
220
+ ```
221
+
222
+ Built-in UI languages are English (`en`, `en-US`) and Spanish (`es`, `es-ES`).
223
+ Other locales fall back to English; use `messages` for host-supplied translations.
224
+ Images, fonts, SVGs, models and textures must remain accessible and allow the
225
+ browser to read them across origins when needed for rendering and export.
226
+
227
+ ## Public exports
228
+
229
+ The main entry exports `PrintineDesigner` and the TypeScript contracts needed
230
+ for integration, including `PrintineDesignerProps`, `DesignerAdapters`,
231
+ `DesignerAsset`, `DesignerUserTemplate` and `DesignerSaveInput`.
232
+
233
+ `@printine/pod-editor/full-designer` is available for advanced integrations that
234
+ already provide a designer runtime. The main entry also exports
235
+ `PrintineSemiRenderer` for standalone local preview rendering and
236
+ `PrintineSemiInteractEditor` for semi-custom editing. See the
237
+ [semi-custom renderer documentation](./docs/SEMI_RENDERER.md) for usage.
238
+
239
+ ## Documentation
240
+
241
+ - [第三方接入文档(React)](./docs/INTEGRATION_API.md): installation, complete React example, properties, upload/save/restore flows, asset proxy, events and troubleshooting.
242
+ - [Host data contract](./docs/HOST_DATA_CONTRACT.md): host product display data, design restoration, base-plate data, merchant asset proxy and optional palette.
243
+ - [Semi-custom renderer](./docs/SEMI_RENDERER.md): standalone rendering, resource preloading, incremental updates and interactive editing.
@@ -0,0 +1,3 @@
1
+ import type { DesignerRuntime } from './types';
2
+ export declare const DesignerRuntimeProvider: import("react").Provider<DesignerRuntime | null>;
3
+ export declare function useDesignerRuntime(): DesignerRuntime;
@@ -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. It does not use the product API's guest-token/445 retry.
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,8 @@
1
+ import type { DesignerApiClient, DesignerApiClientOptions } from '../types';
2
+ /** Production API used by the complete <PrintineDesigner /> entry point. */
3
+ export declare const DEFAULT_PRINTINE_API_BASE_URL = "https://shop-api.printine.com";
4
+ /**
5
+ * API client for the existing Printine endpoints. It deliberately owns no host
6
+ * state and receives only the API location from the embedding site.
7
+ */
8
+ export declare function createDesignerApiClient(options: DesignerApiClientOptions): DesignerApiClient;
@@ -0,0 +1,82 @@
1
+ const h = "api/client/", g = "https://shop-api.printine.com";
2
+ function l(e, t) {
3
+ const s = /^https?:\/\//i.test(e) ? new URL(e) : typeof window < "u" ? new URL(e, window.location.origin) : null;
4
+ if (!s)
5
+ throw new Error("An absolute apiBaseUrl domain is required for SSR.");
6
+ const o = new URL(h, s.origin);
7
+ return new URL(t.replace(/^\//, ""), o);
8
+ }
9
+ async function f(e, t = !1, s) {
10
+ const o = new Headers();
11
+ return t && o.set("Content-Type", "application/json"), e.locale && o.set("Accept-Language", e.locale), s && o.set("X-Guest-Token", s), o;
12
+ }
13
+ async function p(e) {
14
+ return (await e.clone().json().catch(() => null))?.code === 445;
15
+ }
16
+ async function w(e) {
17
+ const t = await e.json().catch(() => null);
18
+ if (!e.ok)
19
+ throw new Error(t?.message || `Designer API request failed (${e.status})`);
20
+ if (!t) throw new Error("Designer API returned an empty or invalid JSON response");
21
+ if (t.ret === !1 || t.ret === 0)
22
+ throw new Error(t.message || t.msg || "Designer API request was rejected");
23
+ return t;
24
+ }
25
+ function A(e) {
26
+ let t, s = null;
27
+ const o = async () => t || s || (s = (async () => {
28
+ const n = new Headers();
29
+ e.locale && n.set("Accept-Language", e.locale);
30
+ const a = await (await fetch(l(e.apiBaseUrl, "get-guest-token"), { headers: n })).json().catch(() => null), c = a?.ret !== !1 && a?.ret !== 0 && typeof a?.data?.token == "string" ? a.data.token : void 0;
31
+ return t = c, c;
32
+ })().finally(() => {
33
+ s = null;
34
+ }), s), u = async (n) => {
35
+ let r = await n(t);
36
+ if (await p(r)) {
37
+ const a = await o();
38
+ a && (r = await n(a));
39
+ }
40
+ return r;
41
+ }, d = async (n, r, a) => {
42
+ const c = await u(
43
+ async (i) => fetch(l(e.apiBaseUrl, r), {
44
+ method: n,
45
+ headers: await f(e, !0, i),
46
+ body: a === void 0 ? void 0 : JSON.stringify(a)
47
+ })
48
+ );
49
+ return w(c);
50
+ };
51
+ return {
52
+ async get(n, r) {
53
+ const a = l(e.apiBaseUrl, n);
54
+ for (const [i, y] of Object.entries(r ?? {}))
55
+ y !== void 0 && a.searchParams.set(i, String(y));
56
+ const c = await u(
57
+ async (i) => fetch(a, { headers: await f(e, !1, i) })
58
+ );
59
+ return w(c);
60
+ },
61
+ async post(n, r) {
62
+ return d("POST", n, r);
63
+ },
64
+ async delete(n, r) {
65
+ return d("DELETE", n, r);
66
+ },
67
+ async postForm(n, r) {
68
+ const a = await u(
69
+ async (c) => fetch(l(e.apiBaseUrl, n), {
70
+ method: "POST",
71
+ headers: await f(e, !1, c),
72
+ body: r
73
+ })
74
+ );
75
+ return w(a);
76
+ }
77
+ };
78
+ }
79
+ export {
80
+ g as DEFAULT_PRINTINE_API_BASE_URL,
81
+ A as createDesignerApiClient
82
+ };
@@ -0,0 +1,12 @@
1
+ export declare const uploadImage: (formData: FormData) => Promise<import("./endpoints").ApiResponse<any>>;
2
+ export declare const getUploadKey: () => Promise<import("./endpoints").ApiResponse<{
3
+ base_path: string;
4
+ bucket: string;
5
+ region: string;
6
+ configs: {
7
+ AccessKeyId: string;
8
+ SecretAccessKey: string;
9
+ Expiration: string;
10
+ SessionToken: string;
11
+ };
12
+ }>>;
@@ -0,0 +1,4 @@
1
+ /** Named endpoint helpers, mirroring the host module the editor UI imported. */
2
+ export declare const getProduct: (id: string) => Promise<import("./endpoints").ApiResponse<import("..").Product>>;
3
+ export declare const getDesign: (id: string) => Promise<import("./endpoints").ApiResponse<import("..").BasePlate>>;
4
+ export declare const onGenerateImage: (data: Record<string, any>) => Promise<import("./endpoints").ApiResponse<any>>;
@@ -0,0 +1,23 @@
1
+ import type { BasePlate, Product } from '../contracts/api-design';
2
+ import type { ApiResponse, DesignerApiClient } from '../types';
3
+ export declare function setDesignerApiClient(next: DesignerApiClient | null): void;
4
+ export declare const DesignApi: {
5
+ getProduct: (id: string) => Promise<ApiResponse<Product>>;
6
+ getDesign: (id: string) => Promise<ApiResponse<BasePlate>>;
7
+ onGenerateImage: (data: Record<string, any>) => Promise<ApiResponse<any>>;
8
+ };
9
+ export declare const CommonApi: {
10
+ uploadImage: (formData: FormData) => Promise<ApiResponse<any>>;
11
+ getUploadKey: () => Promise<ApiResponse<{
12
+ base_path: string;
13
+ bucket: string;
14
+ region: string;
15
+ configs: {
16
+ AccessKeyId: string;
17
+ SecretAccessKey: string;
18
+ Expiration: string;
19
+ SessionToken: string;
20
+ };
21
+ }>>;
22
+ };
23
+ export type { ApiResponse };
@@ -0,0 +1,33 @@
1
+ let n = null;
2
+ function a(e) {
3
+ n = e;
4
+ }
5
+ function i() {
6
+ if (!n)
7
+ throw new Error("[printine-designer] API client is not ready. Render <PrintineDesigner /> before calling the API.");
8
+ return n;
9
+ }
10
+ const o = (e, t) => i().get(e, t), r = (e, t) => i().post(e, t), s = (e, t) => i().postForm(e, t), g = {
11
+ // Public template catalog is temporarily disabled. Template persistence and
12
+ // listing are provided by the host through `adapters.templates` instead.
13
+ // getTemplateList: (params: Params) => get<any>('template-categories', params),
14
+ getProduct: (e) => o(`products/variant/${e}`),
15
+ getDesign: (e) => o(`base-plates/${e}`),
16
+ onGenerateImage: (e) => r("ai-images/generate", e)
17
+ // Legacy package-owned save method (kept for reference only). The package
18
+ // now delegates this to the host's `onSave` callback.
19
+ // saveDesign: (data: Record<string, any>) => post<any>(API_URLS.SAVE_DESIGN, data),
20
+ // Legacy package-owned user-template methods (kept for reference only):
21
+ // saveTemplate: (data: Record<string, any>) => post<any>(API_URLS.USER_TEMPLATES, data),
22
+ // getUserTemplates: () => get<any>(API_URLS.USER_TEMPLATES),
23
+ // getUserTemplteDetail: (id: string) => get<any>(`${API_URLS.USER_TEMPLATES}/${id}`),
24
+ // deleteUserTemplate: (id: string) => del<any>(`${API_URLS.USER_TEMPLATES}/${id}`),
25
+ }, p = {
26
+ uploadImage: (e) => s("uploads/image", e),
27
+ getUploadKey: () => r("uploads/get-temp-access")
28
+ };
29
+ export {
30
+ p as CommonApi,
31
+ g as DesignApi,
32
+ a as setDesignerApiClient
33
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function AspectRatioIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default AspectRatioIcon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function DeleteIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default DeleteIcon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function FitScreenIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default FitScreenIcon;
@@ -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,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function Loading1Icon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default Loading1Icon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function Loading2Icon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default Loading2Icon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function Loading3Icon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default Loading3Icon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function PanIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default PanIcon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function SettingIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default SettingIcon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function TextColorIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default TextColorIcon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function TextHIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default TextHIcon;
@@ -0,0 +1,3 @@
1
+ import type { SVGProps } from 'react';
2
+ export declare function TextVIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
3
+ export default TextVIcon;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The editor's UI icons and placeholders are embedded in the package output.
3
+ */
4
+ export declare const bundledDesignerAssets: Record<string, string>;
@@ -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,6 @@
1
+ type CanvasContextMenuProps = {
2
+ children: React.ReactNode;
3
+ canvasIsEmpty: boolean;
4
+ };
5
+ export default function CanvasContextMenu({ children, canvasIsEmpty }: CanvasContextMenuProps): import("react").JSX.Element;
6
+ export {};
@@ -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 {};