zakeke-configurator-react 0.0.82 → 0.0.85

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 (3) hide show
  1. package/README.md +244 -0
  2. package/dist/index.js +9 -31
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,244 @@
1
+
2
+ # Zakeke Configurator for React
3
+
4
+
5
+
6
+ This library let you build a custom UI for the Zakeke 3D configurator tool.
7
+
8
+
9
+
10
+ ## How to install and run a basic example
11
+
12
+
13
+
14
+ git clone https://github.com/UpCommerce/zakeke-configurator-react-example.git
15
+ npm install
16
+ npm run start
17
+
18
+
19
+
20
+ After running the example you will see a blank page running on `localhost:3000` , that because Zakeke must have some parameters to know what product to load.
21
+
22
+ The parameters are automatically sent from the plugins with a postMessage but, for testing, we can pass them as query string in the URL.
23
+
24
+ The easiest way to have all the parameters is:
25
+
26
+
27
+
28
+ 1. Go in Zakeke configurator backoffice
29
+
30
+ 2. Add or edit a new product
31
+
32
+ 3. Go in the Shopping Preview page
33
+
34
+ 4. Right click on the page -> inspect element
35
+
36
+ 5. Find the zakeke `<iframe>` src attribute and copy all query string parameters
37
+
38
+ 6. Paste the parameters in the localhost page.
39
+
40
+ You should have something like:
41
+
42
+ http://localhost:3000?modelCode=XXX&culture=XX&token=XXXXXX....
43
+
44
+
45
+
46
+ With these parameter you should see the product loading in a basic UI interface.
47
+
48
+ You can start customizing it.
49
+
50
+
51
+
52
+ ## References
53
+
54
+ The library exposes 4 elements:
55
+
56
+
57
+
58
+ - a ZakekeEnvironment class that contains the state of the current scene
59
+
60
+ - a ZakekeProvider react component that should wrap your application
61
+
62
+ - a ZakekeViewer react component that will render the 3D scene
63
+
64
+ - a useZakeke effect to get the data and methods to execute
65
+
66
+
67
+
68
+ A basic Zakeke theme should be like:
69
+
70
+ const zakekeEnvironment = new ZakekeEnvironment();
71
+
72
+ <ZakekeProvider environment={zakekeEnvironment}>
73
+ <div>
74
+ <ZakekeViewer />
75
+ </div>
76
+ </ZakekeProvider>
77
+
78
+
79
+
80
+ ## Properties and methods
81
+
82
+ price: number;
83
+
84
+ culture: string;
85
+
86
+ currency: string;
87
+
88
+ isSceneLoading: boolean;
89
+
90
+ isAddToCartLoading: boolean;
91
+
92
+ isViewerReady: boolean;
93
+
94
+ fonts: FontFamily[];
95
+
96
+ groups: Group[];
97
+
98
+ templates: Template[];
99
+
100
+ currentTemplate: Template | null;
101
+
102
+ items: Item[];
103
+
104
+ productName: string;
105
+
106
+ productCode: string;
107
+
108
+ product: Product | null;
109
+
110
+ cameras: Camera[];
111
+
112
+
113
+
114
+ selectOption: (optionId: number) => void;
115
+
116
+ setTemplate: (templateId: number) => void;
117
+
118
+ isAreaVisible: (areaId: number) => boolean;
119
+
120
+
121
+
122
+ saveComposition: () => Promise<string>;
123
+
124
+ loadComposition: (id: string) => Promise<void>;
125
+
126
+ addToCart: (additionalProperties: Record<string, any>) => Promise<void>;
127
+
128
+
129
+
130
+ getPDF: () => Promise<string>;
131
+
132
+ getOnlineScreenshot: (width: number, height: number, backgroundColor?: string, padding?: number) => Promise<string>;
133
+
134
+
135
+
136
+ setCamera: (id: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
137
+
138
+ setCameraByName: (name: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
139
+
140
+ setCameraZoomEnabled: (enabled: boolean) => void;
141
+
142
+ resetCameraPivot: () => void;
143
+
144
+ setCameraPivot: (meshId: string) => void;
145
+
146
+
147
+
148
+ getImages: (categoryId: number) => Promise<Image[]>;
149
+
150
+ getMacroCategories: () => Promise<ImageMacroCategory[]>;
151
+
152
+ previewOnly__setItemImageFromBase64: (guid: string, base64: string) => void;
153
+
154
+
155
+
156
+ setItemImageFromFile: (guid: string, file: File) => Promise<void>;
157
+
158
+ addItemImage: (id: number, areaId: number) => Promise<void>;
159
+
160
+ createImage: (file: File, progress?: (percentage: number) => void) => Promise<Image>;
161
+
162
+ createImageFromUrl: (url: string) => Promise<Image>;
163
+
164
+ setItemImage: (guid: string, imageId: number) => Promise<void>;
165
+
166
+ setItemFontFamily: (guid: string, fontFamily: string) => void;
167
+
168
+ setItemColor: (guid: string, color: string) => void;
169
+
170
+ setItemBold: (guid: string, bold: boolean) => void;
171
+
172
+ setItemItalic: (guid: string, italic: boolean) => void;
173
+
174
+ setItemText: (guid: string, text: string) => void;
175
+
176
+ addItemText: (settings: { text: string, fontFamily: string }, areaId: number) => Promise<void>;
177
+
178
+ removeItem: (guid: string) => Promise<void>;
179
+
180
+
181
+
182
+ switchFullscreen: () => void;
183
+
184
+ isFullscreenMode: boolean;
185
+
186
+ zoomIn: () => void;
187
+
188
+ zoomOut: () => void;
189
+
190
+
191
+
192
+ updateView: (adjustCamera?: boolean) => void;
193
+
194
+ setHighlightSettings: (settings: { color: string, size: number }) => void;
195
+
196
+ hasExplodedMode: () => boolean;
197
+
198
+ isExplodedMode: boolean;
199
+
200
+ setExplodedMode: (exploded: boolean) => void;
201
+
202
+
203
+
204
+ // Scene manipulation
205
+
206
+ getMeshIDbyName: (name: string) => string | undefined | null,
207
+
208
+ hideMeshAndSaveState: (meshId: string) => void,
209
+
210
+ restoreMeshVisibility: (meshId: string) => void,
211
+
212
+ setMeshDesignVisibility: (meshId: string, visible: boolean) => void,
213
+
214
+
215
+
216
+ // Events
217
+
218
+ clearListeners: () => void;
219
+
220
+ addFocusAttributesListener: (listenerFunction: FocusAttributesEventListener) => void;
221
+
222
+ focusAttribute: (attributeId: number) => void;
223
+
224
+
225
+
226
+ // AR
227
+
228
+ getQrCodeArUrl: (device: 'iOS' | 'Android') => Promise<string>;
229
+
230
+ getMobileArUrl: (useCacheWithDesign?: boolean) => Promise<string | null>;
231
+
232
+ openArMobile: (url: string) => void;
233
+
234
+ isSceneArEnabled: () => boolean;
235
+
236
+
237
+
238
+ IS_ANDROID: boolean;
239
+
240
+ IS_IOS: boolean;
241
+
242
+
243
+
244
+ setBackgroundColor: (color: string, alpha: number) => void;
package/dist/index.js CHANGED
@@ -29866,24 +29866,6 @@ class SceneViewer {
29866
29866
  this._infoPointsManagerStyle = null;
29867
29867
  this._canShowInfoPoints = true;
29868
29868
  this._canShowInfoPointsContent = true;
29869
- this.setCameraLocked = (isBlocked) => {
29870
- if (this._zkScene && this._sceneHelper && this._scene) {
29871
- this._sceneHelper.setupCamera();
29872
- this._camera = this._scene.activeCamera;
29873
- if (this._camera) {
29874
- if (isBlocked) {
29875
- this._sceneHelper.setCameraLimitLowerRadius(true);
29876
- this._sceneHelper.setMinZoomPerc(1);
29877
- this._sceneHelper.setMaxZoomPerc(1);
29878
- }
29879
- else {
29880
- this._sceneHelper.setCameraLimitLowerRadius(false);
29881
- this._sceneHelper.setMinZoomPerc(1);
29882
- this._sceneHelper.setMaxZoomPerc(1.5);
29883
- }
29884
- }
29885
- }
29886
- };
29887
29869
  if (options != undefined) {
29888
29870
  if (typeof options == "boolean")
29889
29871
  this._configPreview = options;
@@ -49764,16 +49746,6 @@ class ZakekeEnvironment {
49764
49746
  if (this.viewer)
49765
49747
  this.viewer.clearListeners();
49766
49748
  };
49767
- this.setCameraLocked = (isBlocked) => {
49768
- return this.viewer.setCameraLocked(isBlocked);
49769
- };
49770
- this.isSceneTryOnEnabled = () => {
49771
- var _a;
49772
- if (this.viewer)
49773
- if (this.zkScene)
49774
- return (_a = this.zkScene.getTryOnEnabled()) !== null && _a !== void 0 ? _a : false;
49775
- return false;
49776
- };
49777
49749
  this.getTryOnUrl = () => {
49778
49750
  return new Promise(resolve => {
49779
49751
  if (this.zkScene && this.viewer) {
@@ -49784,7 +49756,7 @@ class ZakekeEnvironment {
49784
49756
  const attachmentPoint = 'noseBridge';
49785
49757
  // Salvo le mesh su IndexedDB
49786
49758
  this.viewer.saveVisibleMeshesOnDatabaseAsync(fileId).then(() => {
49787
- const url = Zakeke.config.baseUrl + "TryOn";
49759
+ const url = "https://zakekecdn.blob.core.windows.net/cdn/c/tryon/index.html";
49788
49760
  const link = new URL(url);
49789
49761
  let search = "id=" + fileId;
49790
49762
  search += '&rootUrl=' + encodeURIComponent(rootUrl);
@@ -49800,6 +49772,13 @@ class ZakekeEnvironment {
49800
49772
  }
49801
49773
  });
49802
49774
  };
49775
+ this.isSceneTryOnEnabled = () => {
49776
+ var _a;
49777
+ if (this.viewer)
49778
+ if (this.zkScene)
49779
+ return (_a = this.zkScene.getTryOnEnabled()) !== null && _a !== void 0 ? _a : false;
49780
+ return false;
49781
+ };
49803
49782
  }
49804
49783
  get internalProduct() {
49805
49784
  return this.zkProduct;
@@ -51326,8 +51305,7 @@ const createProviderValue = (state, dispatch) => {
51326
51305
  setBackgroundColor: state.environment.setBackgroundColor.bind(state.environment),
51327
51306
  // TRY ON
51328
51307
  getTryOnUrl: state.environment.getTryOnUrl.bind(state.environment),
51329
- isSceneTryOnEnabled: state.environment.isSceneTryOnEnabled.bind(state.environment),
51330
- setCameraLocked: state.environment.setCameraLocked.bind(state.environment)
51308
+ isSceneTryOnEnabled: state.environment.isSceneTryOnEnabled.bind(state.environment)
51331
51309
  };
51332
51310
  };
51333
51311
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zakeke-configurator-react",
3
- "version": "0.0.82",
3
+ "version": "0.0.85",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/declarations/composer/Module/src/index.d.ts",