@printine/designer 0.1.0
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 +146 -0
- package/dist/DesignerRuntimeContext.d.ts +3 -0
- package/dist/PrintineDesigner.d.ts +9 -0
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +82 -0
- package/dist/api/common-endpoints.d.ts +12 -0
- package/dist/api/design-endpoints.d.ts +18 -0
- package/dist/api/endpoints.d.ts +33 -0
- package/dist/api/endpoints.js +46 -0
- package/dist/api/files-endpoints.d.ts +1 -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 +21 -0
- package/dist/components/canvas-context-menu.d.ts +6 -0
- package/dist/components/color-picker/index.d.ts +10 -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 +4 -0
- package/dist/components/image-edit.d.ts +1 -0
- package/dist/components/layout/aside.d.ts +3 -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 +5 -0
- package/dist/components/loading.d.ts +3 -0
- package/dist/components/menus/ai.d.ts +5 -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 +7 -0
- package/dist/components/preview/graphic.d.ts +7 -0
- package/dist/components/preview/index.d.ts +18 -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 +18 -0
- package/dist/components/preview/real-time/index.d.ts +11 -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/store.d.ts +1 -0
- package/dist/components/toolbar.d.ts +2 -0
- package/dist/config-D2qm60gf.js +16 -0
- package/dist/contracts/api-design.d.ts +176 -0
- package/dist/contracts/design.d.ts +86 -0
- package/dist/design-7zRpRtv9.js +20331 -0
- package/dist/engine/canvas-designer.d.ts +101 -0
- package/dist/engine/canvas-designer.js +313 -0
- package/dist/engine/constants.d.ts +27 -0
- package/dist/engine/constants.js +148 -0
- package/dist/engine/editor.d.ts +186 -0
- package/dist/engine/editor.js +734 -0
- package/dist/engine/events.d.ts +34 -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 +24 -0
- package/dist/engine/managers/resize.js +63 -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 +26 -0
- package/dist/engine/managers/workspace.js +53 -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 +199 -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 +14 -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-oss-upload.d.ts +34 -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 +39 -0
- package/dist/index.js +127 -0
- package/dist/lib/analytics.d.ts +17 -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/renderer/ThreeDPreview.d.ts +14 -0
- package/dist/renderer/sticker.js +1731 -0
- package/dist/renderer/three-d-preview.js +32 -0
- package/dist/state/designer-store.d.ts +43 -0
- package/dist/state/designer-store.js +85 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +184 -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 +10 -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/render.worker.d.ts +1 -0
- package/package.json +201 -0
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @printine/designer
|
|
2
|
+
|
|
3
|
+
React online product designer for Printine-powered products. It provides the
|
|
4
|
+
editor UI, Fabric canvas, 2D/3D preview and public design-data integration;
|
|
5
|
+
the host application owns its own routing, authentication, uploads, user
|
|
6
|
+
assets, saved templates and final design persistence.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @printine/designer
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`react` and `react-dom` 18 or 19 are peer dependencies.
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
Render the component from a browser-only React component. For Next.js App
|
|
19
|
+
Router, place this in a Client Component (`'use client'`), or load it with
|
|
20
|
+
`next/dynamic({ ssr: false })`.
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
'use client';
|
|
24
|
+
|
|
25
|
+
import { PrintineDesigner, type DesignerSaveInput } from '@printine/designer';
|
|
26
|
+
import '@printine/designer/styles.css';
|
|
27
|
+
|
|
28
|
+
export function ProductDesigner() {
|
|
29
|
+
return (
|
|
30
|
+
<PrintineDesigner
|
|
31
|
+
productId="variant-id"
|
|
32
|
+
basePlateId="model-id"
|
|
33
|
+
locale="en-US"
|
|
34
|
+
adapters={{
|
|
35
|
+
uploadImage: async ({ file, purpose, metadata }) => {
|
|
36
|
+
// Return complete URLs, never
|
|
37
|
+
},
|
|
38
|
+
assets: {
|
|
39
|
+
list: async ({ page, pageSize }) => hostListAssets({ page, pageSize }),
|
|
40
|
+
remove: async ({ id }) => hostDeleteAsset({ id }),
|
|
41
|
+
},
|
|
42
|
+
templates: {
|
|
43
|
+
create: async ({ name, preview, content }) => hostCreateTemplate({ name, preview, content }),
|
|
44
|
+
list: async () => hostListTemplates(),
|
|
45
|
+
get: async ({ id }) => hostGetTemplate({ id }),
|
|
46
|
+
remove: async ({ id }) => hostDeleteTemplate({ id }),
|
|
47
|
+
},
|
|
48
|
+
}}
|
|
49
|
+
onSave={async (saveInput: DesignerSaveInput) => {
|
|
50
|
+
}}
|
|
51
|
+
onClose={() => router.back()}
|
|
52
|
+
onError={(error) => reportDesignerError(error)}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Integration model
|
|
59
|
+
|
|
60
|
+
By default, the package uses the Printine production API. To use a local,
|
|
61
|
+
testing or staging API, pass `apiBaseUrl` as a domain only;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
The following user-specific capabilities are always supplied by the host:
|
|
65
|
+
|
|
66
|
+
| Capability | Required adapter | Behaviour when omitted |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Image upload | `adapters.uploadImage` | Upload controls are hidden. |
|
|
69
|
+
| My images | `adapters.assets.list` | The image library is hidden. |
|
|
70
|
+
| Delete an image | `adapters.assets.remove` | The image delete button is hidden. |
|
|
71
|
+
| My designs | `adapters.templates` | “My designs” is hidden; public template categories remain available. Saving also requires `adapters.uploadImage`. |
|
|
72
|
+
| Save the final design | `onSave` | Done is hidden in the preview. |
|
|
73
|
+
|
|
74
|
+
### Uploads and assets
|
|
75
|
+
|
|
76
|
+
`uploadImage` receives a `purpose` of `'asset'`, `'design-data'` or
|
|
77
|
+
`'template-preview'` and returns `{ url, thumbnailUrl?, thumbnailScale? }`.
|
|
78
|
+
All returned values must be complete URLs.
|
|
79
|
+
|
|
80
|
+
For `purpose: 'asset'`, the host is responsible for its complete workflow:
|
|
81
|
+
uploading the original image, optionally creating a thumbnail, and creating the
|
|
82
|
+
host's asset record before resolving the promise. The package never calls a
|
|
83
|
+
`user-assets` endpoint.
|
|
84
|
+
|
|
85
|
+
### Saved templates
|
|
86
|
+
|
|
87
|
+
`adapters.templates` contains `create`, `list` and `get`; `remove` is optional.
|
|
88
|
+
The package uploads a template preview through `uploadImage` with
|
|
89
|
+
`purpose: 'template-preview'`, then passes the preview URL and template content
|
|
90
|
+
to `templates.create`.
|
|
91
|
+
|
|
92
|
+
### Saving
|
|
93
|
+
|
|
94
|
+
`onSave` receives the prepared existing save payload:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
type DesignerSaveInput = {
|
|
98
|
+
variant_id: string;
|
|
99
|
+
design_data: Record<string, unknown>;
|
|
100
|
+
background_customized?: unknown;
|
|
101
|
+
is_partially_customized?: 1;
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The callback owns its request, business-error handling, analytics and any route
|
|
106
|
+
change. When it rejects, the package only clears its own loading state and does
|
|
107
|
+
not show another error message.
|
|
108
|
+
|
|
109
|
+
## Styling
|
|
110
|
+
|
|
111
|
+
Import `@printine/designer/styles.css` once. The package ships its icons, empty
|
|
112
|
+
states and editor styles, so no host static files or Tailwind content scanning
|
|
113
|
+
are required.
|
|
114
|
+
|
|
115
|
+
Theme variables use the `--printine-` prefix and can be overridden globally:
|
|
116
|
+
|
|
117
|
+
```css
|
|
118
|
+
:root {
|
|
119
|
+
--printine-primary: #3540a5;
|
|
120
|
+
--printine-background: #f3f5f6;
|
|
121
|
+
--printine-foreground: #1c1c1e;
|
|
122
|
+
--printine-border: #e0e0e5;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Public exports
|
|
127
|
+
|
|
128
|
+
The main entry exports `PrintineDesigner` and the TypeScript contracts needed
|
|
129
|
+
for integration, including `PrintineDesignerProps`, `DesignerAdapters`,
|
|
130
|
+
`DesignerAsset`, `DesignerUserTemplate` and `DesignerSaveInput`.
|
|
131
|
+
|
|
132
|
+
`@printine/designer/full-designer` is available for advanced integrations that
|
|
133
|
+
already provide a `PrintineDesigner` runtime.
|
|
134
|
+
|
|
135
|
+
## Development and release checks
|
|
136
|
+
|
|
137
|
+
Run these commands from the package directory:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm run typecheck
|
|
141
|
+
npm run build
|
|
142
|
+
npm run test:api
|
|
143
|
+
npm run pack:check
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`npm publish` runs the build and API smoke test through `prepublishOnly`.
|
|
@@ -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-runtime").JSX.Element;
|
|
@@ -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,18 @@
|
|
|
1
|
+
import { API_URLS } from './endpoints';
|
|
2
|
+
/** Named endpoint helpers, mirroring the host module the editor UI imported. */
|
|
3
|
+
export declare const getFontList: () => Promise<import("./endpoints").ApiResponse<any>>;
|
|
4
|
+
export declare const getShapeList: (params: {
|
|
5
|
+
[x: string]: string | number | boolean | undefined;
|
|
6
|
+
}) => Promise<import("./endpoints").ApiResponse<any>>;
|
|
7
|
+
export declare const getTemplateList: (params: {
|
|
8
|
+
[x: string]: string | number | boolean | undefined;
|
|
9
|
+
}) => Promise<import("./endpoints").ApiResponse<any>>;
|
|
10
|
+
export declare const getColorsAll: () => Promise<import("./endpoints").ApiResponse<any>>;
|
|
11
|
+
export declare const getClipArtCategories: (params: {
|
|
12
|
+
[x: string]: string | number | boolean | undefined;
|
|
13
|
+
}) => Promise<import("./endpoints").ApiResponse<any>>;
|
|
14
|
+
export declare const getProduct: (id: string) => Promise<import("./endpoints").ApiResponse<import("..").Product>>;
|
|
15
|
+
export declare const getDesign: (id: string) => Promise<import("./endpoints").ApiResponse<import("..").BasePlate>>;
|
|
16
|
+
export declare const onRender: (data: Record<string, any>) => Promise<import("./endpoints").ApiResponse<any>>;
|
|
17
|
+
export declare const onGenerateImage: (data: Record<string, any>) => Promise<import("./endpoints").ApiResponse<any>>;
|
|
18
|
+
export { API_URLS };
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
type Params = Record<string, string | number | boolean | undefined>;
|
|
5
|
+
export declare const API_URLS: {
|
|
6
|
+
readonly RENDER: "products/render-design-data";
|
|
7
|
+
};
|
|
8
|
+
export declare const DesignApi: {
|
|
9
|
+
getFontList: () => Promise<ApiResponse<any>>;
|
|
10
|
+
getShapeList: (params: Params) => Promise<ApiResponse<any>>;
|
|
11
|
+
getTemplateList: (params: Params) => Promise<ApiResponse<any>>;
|
|
12
|
+
getColorsAll: () => Promise<ApiResponse<any>>;
|
|
13
|
+
getClipArtCategories: (params: Params) => Promise<ApiResponse<any>>;
|
|
14
|
+
getProduct: (id: string) => Promise<ApiResponse<Product>>;
|
|
15
|
+
getDesign: (id: string) => Promise<ApiResponse<BasePlate>>;
|
|
16
|
+
onRender: (data: Record<string, any>) => Promise<ApiResponse<any>>;
|
|
17
|
+
onGenerateImage: (data: Record<string, any>) => Promise<ApiResponse<any>>;
|
|
18
|
+
};
|
|
19
|
+
export declare const CommonApi: {
|
|
20
|
+
uploadImage: (formData: FormData) => Promise<ApiResponse<any>>;
|
|
21
|
+
getUploadKey: () => Promise<ApiResponse<{
|
|
22
|
+
base_path: string;
|
|
23
|
+
bucket: string;
|
|
24
|
+
region: string;
|
|
25
|
+
configs: {
|
|
26
|
+
AccessKeyId: string;
|
|
27
|
+
SecretAccessKey: string;
|
|
28
|
+
Expiration: string;
|
|
29
|
+
SessionToken: string;
|
|
30
|
+
};
|
|
31
|
+
}>>;
|
|
32
|
+
};
|
|
33
|
+
export type { ApiResponse };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
let o = null;
|
|
2
|
+
function l(e) {
|
|
3
|
+
o = e;
|
|
4
|
+
}
|
|
5
|
+
function i() {
|
|
6
|
+
if (!o)
|
|
7
|
+
throw new Error("[printine-designer] API client is not ready. Render <PrintineDesigner /> before calling the API.");
|
|
8
|
+
return o;
|
|
9
|
+
}
|
|
10
|
+
const t = (e, n) => i().get(e, n), s = (e, n) => i().post(e, n), r = (e, n) => i().postForm(e, n), a = {
|
|
11
|
+
// Legacy package-owned save path (kept for reference only):
|
|
12
|
+
// SAVE_DESIGN: 'products/design-save',
|
|
13
|
+
// Legacy package-owned user-template path (kept for reference only):
|
|
14
|
+
// USER_TEMPLATES: 'user-templates',
|
|
15
|
+
RENDER: "products/render-design-data"
|
|
16
|
+
// Legacy package-owned user-assets paths (kept for reference only):
|
|
17
|
+
// GET_USER_ASSETS: 'user-assets',
|
|
18
|
+
// DELETE_USER_ASSETS_BATCH: 'user-assets/batch-delete',
|
|
19
|
+
}, g = {
|
|
20
|
+
getFontList: () => t("parent-fonts/all"),
|
|
21
|
+
getShapeList: (e) => t("shapes", e),
|
|
22
|
+
getTemplateList: (e) => t("template-categories", e),
|
|
23
|
+
getColorsAll: () => t("colors/all"),
|
|
24
|
+
getClipArtCategories: (e) => t("clip-art-categories", e),
|
|
25
|
+
getProduct: (e) => t(`products/variant/${e}`),
|
|
26
|
+
getDesign: (e) => t(`base-plates/${e}`),
|
|
27
|
+
onRender: (e) => s(a.RENDER, e),
|
|
28
|
+
onGenerateImage: (e) => s("ai-images/generate", e)
|
|
29
|
+
// Legacy package-owned save method (kept for reference only). The package
|
|
30
|
+
// now delegates this to the host's `onSave` callback.
|
|
31
|
+
// saveDesign: (data: Record<string, any>) => post<any>(API_URLS.SAVE_DESIGN, data),
|
|
32
|
+
// Legacy package-owned user-template methods (kept for reference only):
|
|
33
|
+
// saveTemplate: (data: Record<string, any>) => post<any>(API_URLS.USER_TEMPLATES, data),
|
|
34
|
+
// getUserTemplates: () => get<any>(API_URLS.USER_TEMPLATES),
|
|
35
|
+
// getUserTemplteDetail: (id: string) => get<any>(`${API_URLS.USER_TEMPLATES}/${id}`),
|
|
36
|
+
// deleteUserTemplate: (id: string) => del<any>(`${API_URLS.USER_TEMPLATES}/${id}`),
|
|
37
|
+
}, p = {
|
|
38
|
+
uploadImage: (e) => r("uploads/image", e),
|
|
39
|
+
getUploadKey: () => s("uploads/get-temp-access")
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
a as API_URLS,
|
|
43
|
+
p as CommonApi,
|
|
44
|
+
g as DesignApi,
|
|
45
|
+
l as setDesignerApiClient
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SelectImageParams {
|
|
2
|
+
url: string;
|
|
3
|
+
thumbnailUrl?: string;
|
|
4
|
+
blobUrl?: string;
|
|
5
|
+
scale?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AssetsDialogProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onOpenChange: (open: boolean) => void;
|
|
10
|
+
onSelectImage: (image: SelectImageParams) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Package-owned replacement for the host's asset-library dialog.
|
|
15
|
+
*
|
|
16
|
+
* It deliberately starts with local file selection. Hosts that need a DAM can
|
|
17
|
+
* still add their own asset picker outside the package and insert a URL through
|
|
18
|
+
* the editor API; this prevents the reusable editor from importing a page-owned
|
|
19
|
+
* portfolio component.
|
|
20
|
+
*/
|
|
21
|
+
export default function AssetsDialog({ open, onOpenChange, onSelectImage, className }: AssetsDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface ColorPickerProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange?: (value: string, type: string) => void;
|
|
5
|
+
custom?: boolean;
|
|
6
|
+
unset?: boolean;
|
|
7
|
+
colors?: string[];
|
|
8
|
+
}
|
|
9
|
+
export default function ColorPicker({ value, onChange, custom, unset, colors, className, }: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
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 PersistImageFun } from '../hooks/use-oss-upload';
|
|
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: PersistImageFun;
|
|
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
|
+
}): import("react/jsx-runtime").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
|
+
/** Server-prefetched base plate; omit it to load by PrintineDesigner.basePlateId. */
|
|
6
|
+
basePlate?: BasePlate | null;
|
|
7
|
+
}
|
|
8
|
+
declare const Design: ({ semiDesignPermission, basePlate }: FullDesignerProps) => import("react/jsx-runtime").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-runtime").JSX.Element;
|
|
26
|
+
export default Fonts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ImageEdit(): import("react/jsx-runtime").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-runtime").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-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function BottomNav(): import("react/jsx-runtime").JSX.Element;
|