@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.
Files changed (199) hide show
  1. package/README.md +146 -0
  2. package/dist/DesignerRuntimeContext.d.ts +3 -0
  3. package/dist/PrintineDesigner.d.ts +9 -0
  4. package/dist/api/client.d.ts +8 -0
  5. package/dist/api/client.js +82 -0
  6. package/dist/api/common-endpoints.d.ts +12 -0
  7. package/dist/api/design-endpoints.d.ts +18 -0
  8. package/dist/api/endpoints.d.ts +33 -0
  9. package/dist/api/endpoints.js +46 -0
  10. package/dist/api/files-endpoints.d.ts +1 -0
  11. package/dist/assets/icons/aspect_ratio.d.ts +3 -0
  12. package/dist/assets/icons/delete.d.ts +3 -0
  13. package/dist/assets/icons/fit_screen.d.ts +3 -0
  14. package/dist/assets/icons/index.d.ts +11 -0
  15. package/dist/assets/icons/loading_1.d.ts +3 -0
  16. package/dist/assets/icons/loading_2.d.ts +3 -0
  17. package/dist/assets/icons/loading_3.d.ts +3 -0
  18. package/dist/assets/icons/pan.d.ts +3 -0
  19. package/dist/assets/icons/setting.d.ts +3 -0
  20. package/dist/assets/icons/text_color.d.ts +3 -0
  21. package/dist/assets/icons/text_h.d.ts +3 -0
  22. package/dist/assets/icons/text_v.d.ts +3 -0
  23. package/dist/bundled-assets.d.ts +4 -0
  24. package/dist/components/add-design.d.ts +8 -0
  25. package/dist/components/assets-dialog.d.ts +21 -0
  26. package/dist/components/canvas-context-menu.d.ts +6 -0
  27. package/dist/components/color-picker/index.d.ts +10 -0
  28. package/dist/components/context.d.ts +24 -0
  29. package/dist/components/design.d.ts +9 -0
  30. package/dist/components/fonts.d.ts +26 -0
  31. package/dist/components/image-crop.d.ts +4 -0
  32. package/dist/components/image-edit.d.ts +1 -0
  33. package/dist/components/layout/aside.d.ts +3 -0
  34. package/dist/components/layout/bottom-nav/element-menu-sheet.d.ts +11 -0
  35. package/dist/components/layout/bottom-nav/element-sheet.d.ts +11 -0
  36. package/dist/components/layout/bottom-nav/index.d.ts +1 -0
  37. package/dist/components/layout/header.d.ts +5 -0
  38. package/dist/components/loading.d.ts +3 -0
  39. package/dist/components/menus/ai.d.ts +5 -0
  40. package/dist/components/menus/background.d.ts +6 -0
  41. package/dist/components/menus/clipart.d.ts +6 -0
  42. package/dist/components/menus/files.d.ts +7 -0
  43. package/dist/components/menus/image.d.ts +8 -0
  44. package/dist/components/menus/index.d.ts +13 -0
  45. package/dist/components/menus/layer.d.ts +5 -0
  46. package/dist/components/menus/product.d.ts +3 -0
  47. package/dist/components/menus/sca.d.ts +5 -0
  48. package/dist/components/menus/shapes.d.ts +6 -0
  49. package/dist/components/menus/templates.d.ts +6 -0
  50. package/dist/components/menus/text-effects.d.ts +5 -0
  51. package/dist/components/menus/text.d.ts +6 -0
  52. package/dist/components/placement-tab.d.ts +7 -0
  53. package/dist/components/preview/3d.d.ts +7 -0
  54. package/dist/components/preview/graphic.d.ts +7 -0
  55. package/dist/components/preview/index.d.ts +18 -0
  56. package/dist/components/preview/open.d.ts +7 -0
  57. package/dist/components/preview/real-time/3d.d.ts +12 -0
  58. package/dist/components/preview/real-time/graphic.d.ts +18 -0
  59. package/dist/components/preview/real-time/index.d.ts +11 -0
  60. package/dist/components/scale-tools.d.ts +7 -0
  61. package/dist/components/semi-deisgn-config.d.ts +13 -0
  62. package/dist/components/semi-design-link.d.ts +9 -0
  63. package/dist/components/store.d.ts +1 -0
  64. package/dist/components/toolbar.d.ts +2 -0
  65. package/dist/config-D2qm60gf.js +16 -0
  66. package/dist/contracts/api-design.d.ts +176 -0
  67. package/dist/contracts/design.d.ts +86 -0
  68. package/dist/design-7zRpRtv9.js +20331 -0
  69. package/dist/engine/canvas-designer.d.ts +101 -0
  70. package/dist/engine/canvas-designer.js +313 -0
  71. package/dist/engine/constants.d.ts +27 -0
  72. package/dist/engine/constants.js +148 -0
  73. package/dist/engine/editor.d.ts +186 -0
  74. package/dist/engine/editor.js +734 -0
  75. package/dist/engine/events.d.ts +34 -0
  76. package/dist/engine/events.js +7 -0
  77. package/dist/engine/extensions/curved-text.d.ts +59 -0
  78. package/dist/engine/fabric.d.ts +4 -0
  79. package/dist/engine/fabric.js +187 -0
  80. package/dist/engine/history.d.ts +27 -0
  81. package/dist/engine/history.js +56 -0
  82. package/dist/engine/managers/event.d.ts +101 -0
  83. package/dist/engine/managers/event.js +410 -0
  84. package/dist/engine/managers/resize.d.ts +24 -0
  85. package/dist/engine/managers/resize.js +63 -0
  86. package/dist/engine/managers/snapline.d.ts +70 -0
  87. package/dist/engine/managers/snapline.js +124 -0
  88. package/dist/engine/managers/workspace.d.ts +26 -0
  89. package/dist/engine/managers/workspace.js +53 -0
  90. package/dist/engine/processors/image.d.ts +88 -0
  91. package/dist/engine/processors/image.js +473 -0
  92. package/dist/engine/processors/template.d.ts +45 -0
  93. package/dist/engine/processors/template.js +314 -0
  94. package/dist/engine/processors/text.d.ts +74 -0
  95. package/dist/engine/processors/text.js +215 -0
  96. package/dist/engine/semi-export-editor.d.ts +199 -0
  97. package/dist/engine/types.d.ts +28 -0
  98. package/dist/engine/utils/common.d.ts +25 -0
  99. package/dist/engine/utils/common.js +68 -0
  100. package/dist/engine/utils/dialog.d.ts +25 -0
  101. package/dist/engine/utils/font.d.ts +5 -0
  102. package/dist/engine/utils/font.js +39 -0
  103. package/dist/engine/utils/image.d.ts +8 -0
  104. package/dist/engine/utils/image.js +50 -0
  105. package/dist/engine/utils/loading.d.ts +17 -0
  106. package/dist/engine/utils/loading.js +71 -0
  107. package/dist/engine/utils/measure.d.ts +6 -0
  108. package/dist/engine/utils/measure.js +6 -0
  109. package/dist/engine/utils/mockup.d.ts +59 -0
  110. package/dist/engine/utils/setting.d.ts +4 -0
  111. package/dist/engine/utils/setting.js +73 -0
  112. package/dist/fabric-types.d.ts +59 -0
  113. package/dist/full-designer.js +14 -0
  114. package/dist/hooks/pagination.d.ts +19 -0
  115. package/dist/hooks/use-adobe-express.d.ts +50 -0
  116. package/dist/hooks/use-before-unload.d.ts +1 -0
  117. package/dist/hooks/use-image-drop.d.ts +18 -0
  118. package/dist/hooks/use-oss-upload.d.ts +34 -0
  119. package/dist/hooks/use-screen.d.ts +1 -0
  120. package/dist/i18n/index.d.ts +12 -0
  121. package/dist/images/design/asset_empty.png +0 -0
  122. package/dist/images/design/design/background.svg +3 -0
  123. package/dist/images/design/design/color-picker.svg +15 -0
  124. package/dist/images/design/design/computer.svg +1 -0
  125. package/dist/images/design/design/copy.svg +1 -0
  126. package/dist/images/design/design/image.svg +10 -0
  127. package/dist/images/design/design/line.svg +1 -0
  128. package/dist/images/design/design/text.svg +1 -0
  129. package/dist/images/design/design/title.svg +1 -0
  130. package/dist/images/design/empty.png +0 -0
  131. package/dist/images/design/layer_empty.png +0 -0
  132. package/dist/images/design/menu/ai.svg +1 -0
  133. package/dist/images/design/menu/back.svg +4 -0
  134. package/dist/images/design/menu/background.svg +6 -0
  135. package/dist/images/design/menu/clipart.svg +6 -0
  136. package/dist/images/design/menu/file.svg +4 -0
  137. package/dist/images/design/menu/fill.svg +1 -0
  138. package/dist/images/design/menu/image.svg +7 -0
  139. package/dist/images/design/menu/layer.svg +6 -0
  140. package/dist/images/design/menu/product.svg +3 -0
  141. package/dist/images/design/menu/sca.svg +5 -0
  142. package/dist/images/design/menu/shapes.svg +5 -0
  143. package/dist/images/design/menu/templates.svg +6 -0
  144. package/dist/images/design/menu/text.svg +6 -0
  145. package/dist/images/design/menu/uploads.svg +7 -0
  146. package/dist/images/design/spinner.svg +3 -0
  147. package/dist/images/design/spinners.svg +17 -0
  148. package/dist/images/design/transparent_pattern.svg +5 -0
  149. package/dist/index.d.ts +39 -0
  150. package/dist/index.js +127 -0
  151. package/dist/lib/analytics.d.ts +17 -0
  152. package/dist/lib/cn.d.ts +3 -0
  153. package/dist/lib/common.d.ts +16 -0
  154. package/dist/lib/config.d.ts +14 -0
  155. package/dist/lib/navigation.d.ts +2 -0
  156. package/dist/renderer/ThreeDPreview.d.ts +14 -0
  157. package/dist/renderer/sticker.js +1731 -0
  158. package/dist/renderer/three-d-preview.js +32 -0
  159. package/dist/state/designer-store.d.ts +43 -0
  160. package/dist/state/designer-store.js +85 -0
  161. package/dist/style.css +1 -0
  162. package/dist/types.d.ts +184 -0
  163. package/dist/ui/accordion.d.ts +7 -0
  164. package/dist/ui/button-group.d.ts +11 -0
  165. package/dist/ui/button.d.ts +10 -0
  166. package/dist/ui/checkbox.d.ts +4 -0
  167. package/dist/ui/command.d.ts +18 -0
  168. package/dist/ui/confirm-dialog.d.ts +15 -0
  169. package/dist/ui/context-menu.d.ts +25 -0
  170. package/dist/ui/dialog.d.ts +15 -0
  171. package/dist/ui/drawer.d.ts +15 -0
  172. package/dist/ui/editable-combobox.d.ts +10 -0
  173. package/dist/ui/hint.d.ts +8 -0
  174. package/dist/ui/image.d.ts +24 -0
  175. package/dist/ui/input-group.d.ts +16 -0
  176. package/dist/ui/input-with-addon.d.ts +17 -0
  177. package/dist/ui/input.d.ts +3 -0
  178. package/dist/ui/label.d.ts +4 -0
  179. package/dist/ui/loading-button.d.ts +15 -0
  180. package/dist/ui/popover.d.ts +9 -0
  181. package/dist/ui/scroll-area.d.ts +5 -0
  182. package/dist/ui/select.d.ts +22 -0
  183. package/dist/ui/separator.d.ts +4 -0
  184. package/dist/ui/shared-loading-button.d.ts +20 -0
  185. package/dist/ui/simple-dialog.d.ts +19 -0
  186. package/dist/ui/simple-popover.d.ts +13 -0
  187. package/dist/ui/simple-select.d.ts +20 -0
  188. package/dist/ui/skeleton.d.ts +2 -0
  189. package/dist/ui/slider.d.ts +4 -0
  190. package/dist/ui/spinner-box.d.ts +12 -0
  191. package/dist/ui/spinner.d.ts +2 -0
  192. package/dist/ui/switch.d.ts +6 -0
  193. package/dist/ui/tab/index.d.ts +15 -0
  194. package/dist/ui/textarea.d.ts +3 -0
  195. package/dist/ui/tooltip.d.ts +7 -0
  196. package/dist/workers/image-resize.worker.d.ts +1 -0
  197. package/dist/workers/mockup.worker.d.ts +5 -0
  198. package/dist/workers/render.worker.d.ts +1 -0
  199. package/package.json +201 -0
package/dist/index.js ADDED
@@ -0,0 +1,127 @@
1
+ import { AdvancedIText as z } from "./engine/fabric.js";
2
+ import { s as g, D as _, a as A, C as L } from "./design-7zRpRtv9.js";
3
+ import { u as k } from "./design-7zRpRtv9.js";
4
+ import { jsx as o, jsxs as P } from "react/jsx-runtime";
5
+ import { useMemo as C, useEffect as s } from "react";
6
+ import { DEFAULT_PRINTINE_API_BASE_URL as S, createDesignerApiClient as F } from "./api/client.js";
7
+ import { setDesignerApiClient as f } from "./api/endpoints.js";
8
+ import { CommonApi as G, DesignApi as W } from "./api/endpoints.js";
9
+ import { d as U, s as b } from "./config-D2qm60gf.js";
10
+ import { CanvasDesigner as V, renderPlacementPreviews as X } from "./engine/canvas-designer.js";
11
+ import { Editor as $ } from "./engine/editor.js";
12
+ import { HistoryManager as J } from "./engine/history.js";
13
+ import { ALIGN_TYPES as ee, DEFAULT_FILL_COLOR_LIST as re, DEFAULT_FONT_SIZE as oe, ELEMENT_TITLE_MAP as te, FONT_WEIGHT as ae, LAYER_BLACK_LIST as ne } from "./engine/constants.js";
14
+ import { createEventBus as ie, designerEventBus as me } from "./engine/events.js";
15
+ import { SnaplineManager as pe } from "./engine/managers/snapline.js";
16
+ import { ResizeManager as fe } from "./engine/managers/resize.js";
17
+ import { WorkspaceManager as de } from "./engine/managers/workspace.js";
18
+ import { EventManager as ue } from "./engine/managers/event.js";
19
+ import { ImageProcessor as De } from "./engine/processors/image.js";
20
+ import { TextProcessor as Ie } from "./engine/processors/text.js";
21
+ import { TemplateProcessor as _e } from "./engine/processors/template.js";
22
+ import { useDesignerStore as Le } from "./state/designer-store.js";
23
+ import { blobToDataURL as Ce, blobUrlToFile as Se, cloneObject as Fe, dataUrlToFile as Ue, directionOffsetToXY as be, generateThumbImage as Re, getCanvasSize as Be, resizeBase64Image as Ne, toHorizontalRaw as he, toVerticalStack as Me, urlToBlob as Oe, urlToDataURL as ye, xyToDirectionOffset as He } from "./engine/utils/common.js";
24
+ import { loadImage as ze, loadOverlaySvgImage as Ye, loadSvgImage as ke } from "./engine/utils/image.js";
25
+ import { fontCache as Ge, loadFontFile as We, loadFontface as Ke } from "./engine/utils/font.js";
26
+ import { DEFAULT_DPI as Xe, inchToPixel as Ze, isSvg as $e } from "./engine/utils/measure.js";
27
+ import { Loading as Je } from "./engine/utils/loading.js";
28
+ import { getImageControls as er, setDefaultControls as rr } from "./engine/utils/setting.js";
29
+ import { fabric as tr } from "fabric";
30
+ function y(e) {
31
+ const {
32
+ productId: r,
33
+ apiBaseUrl: i = S,
34
+ locale: t,
35
+ imageBaseUrl: m,
36
+ threeDEnvironmentUrl: c,
37
+ basePlateId: d,
38
+ basePlate: x,
39
+ initialDesignData: u,
40
+ adapters: a,
41
+ // Legacy top-level prop (kept for reference; uploads now come from adapters):
42
+ // uploadImage,
43
+ semiDesignPermission: T,
44
+ messages: D,
45
+ className: E,
46
+ children: I,
47
+ onClose: v,
48
+ onEvent: l,
49
+ onAnalytics: p
50
+ } = e, n = C(
51
+ () => F({ apiBaseUrl: i, locale: t }),
52
+ [i, t]
53
+ );
54
+ return s(() => {
55
+ l?.({ name: "ready", productId: r });
56
+ }, [l, r]), s(() => (f(n), () => f(null)), [n]), s(() => (g(p ?? null), () => g(null)), [p]), b({
57
+ ...m !== void 0 ? { imageBaseUrl: m } : {}
58
+ }), /* @__PURE__ */ o(_, { value: { productId: r, basePlateId: d, initialDesignData: u, uploadImage: a?.uploadImage, assets: a?.assets, templates: a?.templates, locale: t, threeDEnvironmentUrl: c, messages: D, onClose: v, onSave: e.onSave, onError: e.onError, onEvent: e.onEvent, api: n }, children: /* @__PURE__ */ P(
59
+ "section",
60
+ {
61
+ className: ["printine-designer", E].filter(Boolean).join(" "),
62
+ "data-product-id": r,
63
+ style: { "--printine-designer-transparent-pattern": `url("${U("/images/design/transparent_pattern.svg")}")` },
64
+ children: [
65
+ /* @__PURE__ */ o("main", { className: "printine-designer__content", children: I ?? /* @__PURE__ */ o(A, { basePlate: x, semiDesignPermission: T }) }),
66
+ /* @__PURE__ */ o(L, {})
67
+ ]
68
+ }
69
+ ) });
70
+ }
71
+ export {
72
+ ee as ALIGN_TYPES,
73
+ z as AdvancedIText,
74
+ V as CanvasDesigner,
75
+ G as CommonApi,
76
+ Xe as DEFAULT_DPI,
77
+ re as DEFAULT_FILL_COLOR_LIST,
78
+ oe as DEFAULT_FONT_SIZE,
79
+ W as DesignApi,
80
+ _ as DesignerRuntimeProvider,
81
+ te as ELEMENT_TITLE_MAP,
82
+ $ as Editor,
83
+ ue as EventManager,
84
+ ae as FONT_WEIGHT,
85
+ A as FullDesigner,
86
+ J as HistoryManager,
87
+ De as ImageProcessor,
88
+ ne as LAYER_BLACK_LIST,
89
+ Je as Loading,
90
+ y as PrintineDesigner,
91
+ fe as ResizeManager,
92
+ pe as SnaplineManager,
93
+ _e as TemplateProcessor,
94
+ Ie as TextProcessor,
95
+ de as WorkspaceManager,
96
+ Ce as blobToDataURL,
97
+ Se as blobUrlToFile,
98
+ Fe as cloneObject,
99
+ F as createDesignerApiClient,
100
+ ie as createEventBus,
101
+ Ue as dataUrlToFile,
102
+ me as designerEventBus,
103
+ be as directionOffsetToXY,
104
+ tr as fabric,
105
+ Ge as fontCache,
106
+ Re as generateThumbImage,
107
+ Be as getCanvasSize,
108
+ er as getImageControls,
109
+ Ze as inchToPixel,
110
+ $e as isSvg,
111
+ We as loadFontFile,
112
+ Ke as loadFontface,
113
+ ze as loadImage,
114
+ Ye as loadOverlaySvgImage,
115
+ ke as loadSvgImage,
116
+ X as renderPlacementPreviews,
117
+ Ne as resizeBase64Image,
118
+ rr as setDefaultControls,
119
+ f as setDesignerApiClient,
120
+ he as toHorizontalRaw,
121
+ Me as toVerticalStack,
122
+ Oe as urlToBlob,
123
+ ye as urlToDataURL,
124
+ k as useDesignerRuntime,
125
+ Le as useDesignerStore,
126
+ He as xyToDirectionOffset
127
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Analytics indirection.
3
+ *
4
+ * The package never talks to gtag, Meta or Reddit pixels directly. It emits
5
+ * named editor events and the host decides whether to forward them anywhere.
6
+ */
7
+ export type DesignerAnalyticsEvent = 'preview_design';
8
+ export type DesignerAnalyticsHandler = (event: DesignerAnalyticsEvent, payload: Record<string, unknown>) => void;
9
+ /** Registered by `PrintineDesigner`; unset on unmount. */
10
+ export declare function setAnalyticsHandler(next: DesignerAnalyticsHandler | null): void;
11
+ export declare const DesignerAnalytics: {
12
+ previewDesign: (productId?: string | number, modelId?: string | number) => void;
13
+ };
14
+ /** Compatibility alias for the migrated components. */
15
+ export declare const GtagEvents: {
16
+ previewDesign: (productId?: string | number, modelId?: string | number) => void;
17
+ };
@@ -0,0 +1,3 @@
1
+ import { type ClassValue } from 'clsx';
2
+ /** Tailwind-aware class merge used by every packaged editor component. */
3
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,16 @@
1
+ /** Converts a `#rgb`/`#rrggbb` string to its RGB channels. */
2
+ export declare const hexToRgb: (hex: string) => {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ };
7
+ export declare const roundToDecimals: (num: number, decimals?: number) => number;
8
+ /**
9
+ * Appends the OSS resize query used for thumbnails. SVG and video assets are
10
+ * returned untouched because the OSS pipeline cannot resize them.
11
+ */
12
+ export declare const getScaleImage: (url: string, params: string) => string;
13
+ /** Prefixes an OSS object key with the configured image base URL. */
14
+ export declare const getFullImageUrl: (path: string) => string;
15
+ /** True when a hex colour resolves to pure white. */
16
+ export declare const isWhite: (code: string) => boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Runtime configuration shared by non-React modules.
3
+ *
4
+ * The host app previously read build-time environment variables. The package
5
+ * takes configuration as props instead, so it carries no host-environment coupling.
6
+ */
7
+ export interface DesignerConfig {
8
+ /** Prefix prepended to OSS object keys returned by the upload endpoints. */
9
+ imageBaseUrl: string;
10
+ }
11
+ export declare const designerConfig: DesignerConfig;
12
+ export declare function setDesignerConfig(next: Partial<DesignerConfig>): void;
13
+ /** Resolves an editor asset embedded in the package output. */
14
+ export declare function designerAssetUrl(path: string): string;
@@ -0,0 +1,2 @@
1
+ /** Lets the host close the editor without exposing its router to the package. */
2
+ export declare function useDesignerClose(): () => void;
@@ -0,0 +1,14 @@
1
+ import type { TDRender } from '../contracts/api-design';
2
+ export interface ThreeDPreviewProps {
3
+ model: TDRender;
4
+ /** Preview images keyed by placement name and/or base plate area id. */
5
+ textures: Record<string, string | ImageBitmap>;
6
+ environmentUrl?: string;
7
+ className?: string;
8
+ onError?: (error: unknown) => void;
9
+ }
10
+ /**
11
+ * Lazy 3D renderer. It stays out of the main designer entry until a host opens
12
+ * a 3D preview, keeping Pixi/Babylon out of the canvas editor's initial load.
13
+ */
14
+ export declare function ThreeDPreview({ model, textures, environmentUrl, className, onError }: ThreeDPreviewProps): import("react/jsx-runtime").JSX.Element;