@threekit-tools/treble 0.0.81 → 0.0.84

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 (110) hide show
  1. package/dist/Treble/Treble.d.ts +11 -5
  2. package/dist/Treble/Treble.js +41 -12
  3. package/dist/Treble/index.d.ts +2 -2
  4. package/dist/Treble/index.js +7 -3
  5. package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
  6. package/dist/Treble/snapshots.js +247 -0
  7. package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
  8. package/dist/Treble/wishlist.js +135 -0
  9. package/dist/api/catalog.js +6 -6
  10. package/dist/api/configurations.js +3 -3
  11. package/dist/api/datatables.js +5 -5
  12. package/dist/api/index.js +5 -1
  13. package/dist/api/orders.d.ts +5 -7
  14. package/dist/api/orders.js +12 -12
  15. package/dist/api/price.js +2 -2
  16. package/dist/api/products.js +2 -2
  17. package/dist/components/Accordion/index.js +6 -7
  18. package/dist/components/AttributeTitle/index.d.ts +0 -9
  19. package/dist/components/AttributeTitle/index.js +0 -9
  20. package/dist/components/AttributeValue/index.d.ts +0 -6
  21. package/dist/components/AttributeValue/index.js +2 -8
  22. package/dist/components/Button/index.d.ts +0 -27
  23. package/dist/components/Button/index.js +0 -27
  24. package/dist/components/Cards/index.d.ts +2 -55
  25. package/dist/components/Cards/index.js +3 -60
  26. package/dist/components/Drawer/index.js +7 -16
  27. package/dist/components/Dropdown/index.d.ts +2 -59
  28. package/dist/components/Dropdown/index.js +11 -72
  29. package/dist/components/FlatForm/index.d.ts +0 -21
  30. package/dist/components/FlatForm/index.js +10 -25
  31. package/dist/components/Modal/index.js +2 -15
  32. package/dist/components/Player/index.d.ts +1 -1
  33. package/dist/components/PortalToArOverlay/index.js +5 -1
  34. package/dist/components/PortalToElement/index.js +0 -8
  35. package/dist/components/ProductDescription/index.d.ts +0 -6
  36. package/dist/components/ProductDescription/index.js +0 -6
  37. package/dist/components/ProductName/index.d.ts +0 -9
  38. package/dist/components/ProductName/index.js +0 -9
  39. package/dist/components/Share/index.d.ts +0 -12
  40. package/dist/components/Share/index.js +2 -14
  41. package/dist/components/Snapshots/index.d.ts +0 -8
  42. package/dist/components/Snapshots/index.js +2 -10
  43. package/dist/components/Strips/index.d.ts +2 -55
  44. package/dist/components/Strips/index.js +3 -60
  45. package/dist/components/Swatch/index.d.ts +2 -64
  46. package/dist/components/Swatch/index.js +3 -69
  47. package/dist/components/Switch/index.d.ts +2 -34
  48. package/dist/components/Switch/index.js +2 -38
  49. package/dist/components/Tabs/index.js +5 -1
  50. package/dist/components/TextInput/index.d.ts +2 -1
  51. package/dist/components/TextInput/index.js +2 -3
  52. package/dist/components/ThreekitProvider/index.js +5 -1
  53. package/dist/components/Tiles/index.d.ts +2 -29
  54. package/dist/components/Tiles/index.js +3 -33
  55. package/dist/components/TilesGroup/index.d.ts +2 -26
  56. package/dist/components/TilesGroup/index.js +3 -30
  57. package/dist/components/TotalPrice/index.d.ts +0 -6
  58. package/dist/components/TotalPrice/index.js +0 -6
  59. package/dist/components/TrebleApp/index.js +5 -1
  60. package/dist/components/Upload/index.d.ts +2 -1
  61. package/dist/components/Upload/index.js +21 -17
  62. package/dist/components/UploadArea/index.d.ts +2 -1
  63. package/dist/components/UploadArea/index.js +18 -15
  64. package/dist/components/Wishlist/index.d.ts +0 -3
  65. package/dist/components/Wishlist/index.js +12 -10
  66. package/dist/components/Zoom/index.d.ts +0 -17
  67. package/dist/components/Zoom/index.js +5 -21
  68. package/dist/components/formComponents.d.ts +12 -0
  69. package/dist/components/formComponents.js +10 -8
  70. package/dist/components/message/index.d.ts +0 -9
  71. package/dist/components/message/index.js +4 -31
  72. package/dist/connection.js +2 -2
  73. package/dist/constants.d.ts +0 -49
  74. package/dist/constants.js +1 -59
  75. package/dist/hooks/useAttribute/index.d.ts +1 -1
  76. package/dist/hooks/useAttribute/index.js +6 -6
  77. package/dist/hooks/useConfigurationLoader/index.js +5 -5
  78. package/dist/hooks/useNestedConfigurator/index.js +2 -2
  79. package/dist/hooks/useShare/index.js +3 -3
  80. package/dist/hooks/useSingleAnimation/index.js +20 -25
  81. package/dist/http/datatables.js +0 -1
  82. package/dist/http/index.js +5 -1
  83. package/dist/http/orders.d.ts +6 -8
  84. package/dist/icons/Spinner.js +5 -1
  85. package/dist/icons/index.d.ts +0 -41
  86. package/dist/icons/index.js +0 -42
  87. package/dist/index.d.ts +42 -3
  88. package/dist/index.js +84 -26
  89. package/dist/store/attributes.d.ts +0 -12
  90. package/dist/store/attributes.js +2 -15
  91. package/dist/store/index.d.ts +1 -1
  92. package/dist/store/price.d.ts +0 -12
  93. package/dist/store/price.js +2 -16
  94. package/dist/store/product.d.ts +6 -21
  95. package/dist/store/product.js +26 -38
  96. package/dist/store/translations.d.ts +1 -13
  97. package/dist/store/translations.js +2 -12
  98. package/dist/store/treble.d.ts +1 -16
  99. package/dist/store/treble.js +31 -66
  100. package/dist/store/wishlist.d.ts +0 -12
  101. package/dist/store/wishlist.js +4 -17
  102. package/dist/types.d.ts +118 -65
  103. package/dist/types.js +54 -0
  104. package/dist/utils.d.ts +10 -10
  105. package/dist/utils.js +8 -16
  106. package/package.json +16 -4
  107. package/dist/Treble/Snapshots.js +0 -251
  108. package/dist/Treble/Wishlist.js +0 -136
  109. package/dist/hooks/useImageEditor/index.d.ts +0 -14
  110. package/dist/hooks/useImageEditor/index.js +0 -320
package/dist/types.d.ts CHANGED
@@ -1,33 +1,67 @@
1
1
  /// <reference types="webpack-env" />
2
2
  import threekitAPI from './api';
3
3
  import Treble from './Treble';
4
- declare type SCENE_PHASES = 'LOADED' | 'PRELOADED' | 'RENDERED';
5
- declare type PRIVATE_APIS = 'scene' | 'player';
6
- export declare type DISPLAY_OPTIONS = 'webgl' | 'image';
7
- export declare type IAttributeTypes = 'String' | 'Asset' | 'Color' | 'Number' | 'Boolean';
8
- export declare type AssetType = 'upload' | 'item';
4
+ declare enum SCENE_PHASES {
5
+ LOADED = 0,
6
+ PRELOADED = 1,
7
+ RENDERED = 2
8
+ }
9
+ export declare enum PRIVATE_APIS {
10
+ SCENE = "scene",
11
+ PLAYER = "player"
12
+ }
13
+ export declare enum DISPLAY_OPTIONS {
14
+ WEBGL = "webgl",
15
+ IMAGE = "image"
16
+ }
17
+ export declare enum ATTRIBUTE_TYPES {
18
+ STRING = "String",
19
+ ASSET = "Asset",
20
+ COLOR = "Color",
21
+ NUMBER = "Number",
22
+ BOOLEAN = "Boolean"
23
+ }
24
+ export declare enum ASSET_TYPES {
25
+ UPLOAD = "upload",
26
+ ITEM = "item"
27
+ }
28
+ export declare enum PLUG_TYPES {
29
+ PROXY = "Proxy",
30
+ TRANSFORM = "Transform"
31
+ }
32
+ export declare enum TRANSFORM_PROPERTY_TYPES {
33
+ ROTATION = "rotation",
34
+ TRANSLATION = "translation",
35
+ SCALE = "scale"
36
+ }
37
+ export declare enum SNAPSHOT_FORMATS {
38
+ JPG = "jpg",
39
+ PNG = "png"
40
+ }
41
+ export declare enum SNAPSHOT_OUTPUTS {
42
+ URL = "url",
43
+ DOWNLOAD = "download",
44
+ DATA_URL = "dataUrl",
45
+ BLOB = "blob",
46
+ FILE = "file"
47
+ }
9
48
  export declare type IMetadata = Record<string, string | number | null>;
10
- /***************************************************
11
- * Scene
12
- **************************************************/
13
- export interface ISceneQuery {
49
+ export interface ISceneQueryShared {
14
50
  all?: boolean;
15
51
  id?: string;
16
52
  name?: string | RegExp;
17
53
  type?: string | Array<string>;
18
54
  names?: Array<RegExp>;
19
55
  properties?: any;
20
- property?: string;
21
56
  child?: string;
22
57
  parent?: boolean;
23
58
  includeParent?: boolean;
24
- from?: string | ISceneQuery;
59
+ from?: string | ISceneQueryShared | ISceneQueryNode;
25
60
  hasPlug?: string;
26
61
  operator?: any;
27
62
  operatorIndex?: number;
28
63
  evalNode?: boolean;
29
64
  evalPlug?: string;
30
- plug?: string;
31
65
  shallow?: boolean;
32
66
  skipModels?: boolean;
33
67
  configurator?: boolean;
@@ -36,14 +70,20 @@ export interface ISceneQuery {
36
70
  tags?: Array<RegExp>;
37
71
  hierarchial?: boolean;
38
72
  }
73
+ export interface ISceneQueryNode extends ISceneQueryShared {
74
+ plug?: PLUG_TYPES.PROXY;
75
+ property?: 'asset';
76
+ }
77
+ export interface ISceneQueryTransform extends ISceneQueryShared {
78
+ plug: PLUG_TYPES.TRANSFORM;
79
+ property: TRANSFORM_PROPERTY_TYPES;
80
+ }
81
+ export declare type ISceneQuery = ISceneQueryNode | ISceneQueryTransform | string;
39
82
  export interface ISceneResult {
40
83
  id: string;
41
84
  name: string;
42
85
  configurator: IThreekitPrivateConfigurator;
43
86
  }
44
- /***************************************************
45
- * Configuration
46
- **************************************************/
47
87
  export interface IConfigurationAsset {
48
88
  assetId: string;
49
89
  configuration?: string;
@@ -57,22 +97,16 @@ export interface IConfigurationColor {
57
97
  export declare type IConfigurationAttribute = IConfigurationAsset | IConfigurationColor | string | number | boolean | undefined;
58
98
  export declare type IConfiguration = Record<string, IConfigurationAttribute>;
59
99
  export declare type ISetConfiguration = Record<string, IConfigurationAttribute>;
60
- /***************************************************
61
- * ATTRIBUTES
62
- *
63
- * This section covers both getAttributes() and getDisplayAttributes()
64
- **************************************************/
65
100
  interface IDisplayAttributeConfig {
66
101
  includeHidden?: boolean;
67
102
  }
68
- interface IAttributeBase<T extends IAttributeTypes, V extends IConfigurationAttribute> {
103
+ interface IAttributeBase<T extends ATTRIBUTE_TYPES, V extends IConfigurationAttribute> {
69
104
  type: T;
70
105
  id: string;
71
106
  name: string;
72
107
  value: V;
73
108
  label: string;
74
109
  }
75
- /****** ASSET TYPE ATTRIBUTE *******/
76
110
  export interface IConfigurationAssetValue {
77
111
  assetId: string;
78
112
  name: string;
@@ -90,8 +124,8 @@ export interface IHydratedAttributeAssetValue extends IDisplayAttributeAssetValu
90
124
  handleSelect: () => Promise<void>;
91
125
  selected: boolean;
92
126
  }
93
- export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigurationAsset> {
94
- assetType: AssetType;
127
+ export interface IAttributeAssetBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.ASSET, IConfigurationAsset> {
128
+ assetType: ASSET_TYPES;
95
129
  blacklist: [];
96
130
  defaultValue: IConfigurationAsset;
97
131
  hiddenValues?: Array<string>;
@@ -101,7 +135,6 @@ export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigu
101
135
  export declare type IDisplayAttributeAsset = IAttributeAssetBase<IDisplayAttributeAssetValue>;
102
136
  export declare type IHydratedAttributeAsset = IAttributeAssetBase<IHydratedAttributeAssetValue>;
103
137
  export declare type IAttributeAsset = IAttributeAssetBase<IConfigurationAssetValue>;
104
- /****** String TYPE ATTRIBUTE *******/
105
138
  export interface IDisplayAttributeStringValue {
106
139
  label: string;
107
140
  value: string;
@@ -110,7 +143,7 @@ export interface IHydratedAttributeStringValue extends IDisplayAttributeStringVa
110
143
  handleSelect: () => Promise<void>;
111
144
  selected: boolean;
112
145
  }
113
- export interface IAttributeStringBase<V> extends IAttributeBase<'String', string> {
146
+ export interface IAttributeStringBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.STRING, string> {
114
147
  blacklist: [];
115
148
  defaultValue: string;
116
149
  hiddenValues?: Array<string>;
@@ -120,31 +153,22 @@ export interface IAttributeStringBase<V> extends IAttributeBase<'String', string
120
153
  export declare type IDisplayAttributeString = IAttributeStringBase<IDisplayAttributeStringValue>;
121
154
  export declare type IHydratedAttributeString = IAttributeStringBase<IHydratedAttributeStringValue>;
122
155
  export declare type IAttributeString = IAttributeStringBase<string>;
123
- /****** STRING TYPE ATTRIBUTE *******/
124
- export interface IAttributeColor extends IAttributeBase<'Color', IConfigurationColor> {
156
+ export interface IAttributeColor extends IAttributeBase<ATTRIBUTE_TYPES.COLOR, IConfigurationColor> {
125
157
  defaultValue: IConfigurationColor;
126
158
  }
127
- /****** NUMBER TYPE ATTRIBUTE *******/
128
- export interface IAttributeNumber extends IAttributeBase<'Number', number> {
159
+ export interface IAttributeNumber extends IAttributeBase<ATTRIBUTE_TYPES.NUMBER, number> {
129
160
  defaultValue: number;
130
161
  lockToStep: boolean;
131
162
  max?: number;
132
163
  min?: number;
133
164
  step: number;
134
165
  }
135
- /****** NUMBER TYPE ATTRIBUTE *******/
136
- export interface IAttributeBoolean extends IAttributeBase<'Boolean', boolean> {
166
+ export interface IAttributeBoolean extends IAttributeBase<ATTRIBUTE_TYPES.BOOLEAN, boolean> {
137
167
  defaultValue: boolean;
138
168
  }
139
- /****** getAttributes() *******/
140
169
  export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber | IAttributeBoolean;
141
- /****** getDisplayAttributes() *******/
142
170
  export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
143
- /****** Treble Hydrated Values *******/
144
171
  export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
145
- /***************************************************
146
- * Camera
147
- **************************************************/
148
172
  export interface ICoordinates {
149
173
  x: number;
150
174
  y: number;
@@ -160,10 +184,53 @@ export interface ISnapshotConfig {
160
184
  height: number;
161
185
  };
162
186
  }
163
- export declare type SNAPSHOT_FORMAT_TYPES = 'jpg' | 'png';
164
- /***************************************************
165
- * Threekit Api
166
- **************************************************/
187
+ export interface Node {
188
+ name: string;
189
+ nodeId: string;
190
+ type: string;
191
+ }
192
+ export interface HitNode {
193
+ distance: number;
194
+ intersection: ICoordinates;
195
+ nodeId: string;
196
+ hierarchy: Array<Node>;
197
+ }
198
+ export interface PlayerToolEvent {
199
+ altKey: boolean;
200
+ clientX: number;
201
+ clientY: number;
202
+ deltaX: number;
203
+ deltaY: number;
204
+ ctrlKey: boolean;
205
+ isTouch: boolean;
206
+ metaKey: boolean;
207
+ shiftKey: boolean;
208
+ which: number;
209
+ originalEvent: MouseEvent;
210
+ rect: DOMRect;
211
+ hitNodes: Array<HitNode>;
212
+ }
213
+ export interface CustomPlayerTool {
214
+ key: string;
215
+ label: string;
216
+ active: boolean;
217
+ enabled: boolean;
218
+ handlers: {
219
+ click?: (event: PlayerToolEvent) => void | Promise<void>;
220
+ mousedown?: (event: PlayerToolEvent) => void | Promise<void>;
221
+ mouseup?: (event: PlayerToolEvent) => void | Promise<void>;
222
+ };
223
+ }
224
+ export interface IThreekitTools {
225
+ addTool: (tool: string | CustomPlayerTool) => void;
226
+ addTools: (tools: Array<string | CustomPlayerTool>) => void;
227
+ removeTool: (tool: string) => void;
228
+ removeTools: (tools: Array<string>) => void;
229
+ setPrimary: (tool: string) => void;
230
+ getPrimaryTool: () => string;
231
+ setTool: () => void;
232
+ setTools: () => void;
233
+ }
167
234
  export interface IConfigurationChangeEvent {
168
235
  name: string;
169
236
  appliedConfiguration: Record<string, string>;
@@ -181,23 +248,13 @@ export interface IThreekitConfigurator {
181
248
  }
182
249
  export interface IThreekitScene {
183
250
  PHASES: {
184
- LOADED: 'loaded';
185
- PRELOADED: 'preloaded';
186
- RENDERED: 'rendered';
251
+ LOADED: SCENE_PHASES.LOADED;
252
+ PRELOADED: SCENE_PHASES.PRELOADED;
253
+ RENDERED: SCENE_PHASES.RENDERED;
187
254
  };
188
- get: (query: ISceneQuery | string) => ISceneResult;
189
- find: (query: ISceneQuery | string) => ISceneResult;
190
- set: (query: ISceneQuery | string, transform: ICoordinates) => void;
191
- }
192
- export interface IThreekitTools {
193
- addTool: (tool: string) => void;
194
- addTools: (tools: string[]) => void;
195
- removeTool: (tool: string) => void;
196
- removeTools: (tools: string[]) => void;
197
- setPrimary: (tool: string) => void;
198
- getPrimaryTool: () => string;
199
- setTool: () => void;
200
- setTools: () => void;
255
+ get: <T extends ISceneQuery>(query: T) => T extends ISceneQueryTransform ? ICoordinates : ISceneResult;
256
+ find: (query: ISceneQuery) => string;
257
+ set: (query: ISceneQueryTransform, transform: ICoordinates) => void;
201
258
  }
202
259
  export interface IThreekitCamera {
203
260
  frameBoundingSphere: () => void;
@@ -219,12 +276,13 @@ export interface IThreekitPlayer {
219
276
  on: (phase: SCENE_PHASES | string, callback: (args: any) => void) => void;
220
277
  getConfigurator: () => Promise<IThreekitConfigurator>;
221
278
  getStageConfigurator: () => Promise<IThreekitConfigurator>;
222
- enableApi: (api: PRIVATE_APIS) => any;
279
+ enableApi: <T extends PRIVATE_APIS>(api: T) => T extends PRIVATE_APIS.PLAYER ? IThreekitPrivatePlayer : any;
223
280
  snapshotAsync: (snapshotConfig: ISnapshotConfig) => Promise<string>;
224
281
  unload: () => Promise<string>;
225
282
  }
226
283
  export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
227
284
  getAppliedConfiguration: (attributeName: string) => string;
285
+ getFullConfiguration: () => IConfiguration;
228
286
  }
229
287
  export interface IThreekitPrivatePlayer {
230
288
  getConfigurator: () => IThreekitPrivateConfigurator;
@@ -232,6 +290,7 @@ export interface IThreekitPrivatePlayer {
232
290
  getFullConfiguration: () => IConfiguration;
233
291
  };
234
292
  calculateLogs: () => Promise<Record<string, any>>;
293
+ getAssetInstance: (query: ISceneQueryNode | string) => Promise<string>;
235
294
  }
236
295
  export interface ThreekitInitConfig {
237
296
  authToken: string;
@@ -265,9 +324,6 @@ export interface ThreekitInitConfig {
265
324
  help?: string;
266
325
  };
267
326
  }
268
- /***************************************************
269
- * Treble Declarations
270
- **************************************************/
271
327
  export interface IFrameworkConfig {
272
328
  productsCtx: __WebpackModuleApi.RequireContext;
273
329
  }
@@ -297,9 +353,6 @@ export interface ITrebleConfig {
297
353
  treble: IFrameworkConfig;
298
354
  player: IPlayerConfig;
299
355
  }
300
- /***************************************************
301
- * Global Declaration
302
- **************************************************/
303
356
  declare global {
304
357
  interface Window {
305
358
  threekitPlayer: (arg0: ThreekitInitConfig) => Promise<IThreekitPlayer>;
package/dist/types.js CHANGED
@@ -1,2 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.TRANSFORM_PROPERTY_TYPES = exports.PLUG_TYPES = exports.ASSET_TYPES = exports.ATTRIBUTE_TYPES = exports.DISPLAY_OPTIONS = exports.PRIVATE_APIS = void 0;
4
+ var SCENE_PHASES;
5
+ (function (SCENE_PHASES) {
6
+ SCENE_PHASES[SCENE_PHASES["LOADED"] = 0] = "LOADED";
7
+ SCENE_PHASES[SCENE_PHASES["PRELOADED"] = 1] = "PRELOADED";
8
+ SCENE_PHASES[SCENE_PHASES["RENDERED"] = 2] = "RENDERED";
9
+ })(SCENE_PHASES || (SCENE_PHASES = {}));
10
+ var PRIVATE_APIS;
11
+ (function (PRIVATE_APIS) {
12
+ PRIVATE_APIS["SCENE"] = "scene";
13
+ PRIVATE_APIS["PLAYER"] = "player";
14
+ })(PRIVATE_APIS = exports.PRIVATE_APIS || (exports.PRIVATE_APIS = {}));
15
+ var DISPLAY_OPTIONS;
16
+ (function (DISPLAY_OPTIONS) {
17
+ DISPLAY_OPTIONS["WEBGL"] = "webgl";
18
+ DISPLAY_OPTIONS["IMAGE"] = "image";
19
+ })(DISPLAY_OPTIONS = exports.DISPLAY_OPTIONS || (exports.DISPLAY_OPTIONS = {}));
20
+ var ATTRIBUTE_TYPES;
21
+ (function (ATTRIBUTE_TYPES) {
22
+ ATTRIBUTE_TYPES["STRING"] = "String";
23
+ ATTRIBUTE_TYPES["ASSET"] = "Asset";
24
+ ATTRIBUTE_TYPES["COLOR"] = "Color";
25
+ ATTRIBUTE_TYPES["NUMBER"] = "Number";
26
+ ATTRIBUTE_TYPES["BOOLEAN"] = "Boolean";
27
+ })(ATTRIBUTE_TYPES = exports.ATTRIBUTE_TYPES || (exports.ATTRIBUTE_TYPES = {}));
28
+ var ASSET_TYPES;
29
+ (function (ASSET_TYPES) {
30
+ ASSET_TYPES["UPLOAD"] = "upload";
31
+ ASSET_TYPES["ITEM"] = "item";
32
+ })(ASSET_TYPES = exports.ASSET_TYPES || (exports.ASSET_TYPES = {}));
33
+ var PLUG_TYPES;
34
+ (function (PLUG_TYPES) {
35
+ PLUG_TYPES["PROXY"] = "Proxy";
36
+ PLUG_TYPES["TRANSFORM"] = "Transform";
37
+ })(PLUG_TYPES = exports.PLUG_TYPES || (exports.PLUG_TYPES = {}));
38
+ var TRANSFORM_PROPERTY_TYPES;
39
+ (function (TRANSFORM_PROPERTY_TYPES) {
40
+ TRANSFORM_PROPERTY_TYPES["ROTATION"] = "rotation";
41
+ TRANSFORM_PROPERTY_TYPES["TRANSLATION"] = "translation";
42
+ TRANSFORM_PROPERTY_TYPES["SCALE"] = "scale";
43
+ })(TRANSFORM_PROPERTY_TYPES = exports.TRANSFORM_PROPERTY_TYPES || (exports.TRANSFORM_PROPERTY_TYPES = {}));
44
+ var SNAPSHOT_FORMATS;
45
+ (function (SNAPSHOT_FORMATS) {
46
+ SNAPSHOT_FORMATS["JPG"] = "jpg";
47
+ SNAPSHOT_FORMATS["PNG"] = "png";
48
+ })(SNAPSHOT_FORMATS = exports.SNAPSHOT_FORMATS || (exports.SNAPSHOT_FORMATS = {}));
49
+ var SNAPSHOT_OUTPUTS;
50
+ (function (SNAPSHOT_OUTPUTS) {
51
+ SNAPSHOT_OUTPUTS["URL"] = "url";
52
+ SNAPSHOT_OUTPUTS["DOWNLOAD"] = "download";
53
+ SNAPSHOT_OUTPUTS["DATA_URL"] = "dataUrl";
54
+ SNAPSHOT_OUTPUTS["BLOB"] = "blob";
55
+ SNAPSHOT_OUTPUTS["FILE"] = "file";
56
+ })(SNAPSHOT_OUTPUTS = exports.SNAPSHOT_OUTPUTS || (exports.SNAPSHOT_OUTPUTS = {}));
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute, ISetConfiguration, IHydratedAttribute } from './types';
2
- import { ITrebleConfig, IAttributeTypes } from './types';
2
+ import { ITrebleConfig, ATTRIBUTE_TYPES } from './types';
3
3
  import { RawAttributeValue } from './hooks/useAttribute';
4
4
  import { ITranslationMap } from './api/products';
5
5
  interface ICameraPosition {
@@ -15,13 +15,13 @@ interface IAttributeComponentProps {
15
15
  interface IAttributesComponentProps {
16
16
  [attributeName: string]: undefined | false | IAttributeComponentProps;
17
17
  }
18
- export declare const generateClassName: (baseClass: string) => (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
19
- export declare const generateInputClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
20
- export declare const generateWidgetClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
21
- export declare const generateLayoutClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
22
- export declare const generateToolClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
23
- export declare const generateDisplayClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
24
- export declare const generateFormClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
18
+ export declare const generateClassName: (baseClass: string) => (component: string, customClassName?: string, title?: string) => string;
19
+ export declare const generateInputClassName: (component: string, customClassName?: string, title?: string) => string;
20
+ export declare const generateWidgetClassName: (component: string, customClassName?: string, title?: string) => string;
21
+ export declare const generateLayoutClassName: (component: string, customClassName?: string, title?: string) => string;
22
+ export declare const generateToolClassName: (component: string, customClassName?: string, title?: string) => string;
23
+ export declare const generateDisplayClassName: (component: string, customClassName?: string, title?: string) => string;
24
+ export declare const generateFormClassName: (component: string, customClassName?: string, title?: string) => string;
25
25
  export declare const isIOS: () => RegExpMatchArray | null;
26
26
  export declare const isJsonString: (str: string) => boolean;
27
27
  export declare const objectToQueryStr: (obj: Record<string, any>) => string;
@@ -53,11 +53,11 @@ export declare const hydrateAttribute: (data: [
53
53
  undefined | ITranslationMap,
54
54
  undefined | string
55
55
  ], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>) => Record<string, IHydratedAttribute>;
56
- export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: IAttributeTypes) => string | number | boolean | File | IConfigurationColor | {
56
+ export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: ATTRIBUTE_TYPES) => string | number | boolean | File | IConfigurationColor | {
57
57
  assetId: RawAttributeValue;
58
58
  } | undefined;
59
59
  export declare const filterFormAttributes: (attributes: Record<string, IThreekitDisplayAttribute>, attributeComponentProps: IAttributesComponentProps, includeReservedAttributes: boolean) => IThreekitDisplayAttribute[];
60
- export declare const isUuid: (str?: string | undefined) => boolean;
60
+ export declare const isUuid: (str?: string) => boolean;
61
61
  export declare const runDebugger: () => Promise<void>;
62
62
  export declare const loadTrebleConfig: () => Partial<ITrebleConfig>;
63
63
  export {};
package/dist/utils.js CHANGED
@@ -47,6 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.loadTrebleConfig = exports.runDebugger = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.isIOS = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
49
49
  var constants_1 = require("./constants");
50
+ var types_1 = require("./types");
50
51
  var generateClassName = function (baseClass) {
51
52
  return function (component, customClassName, title) {
52
53
  var result = "".concat(baseClass, "-").concat(component);
@@ -143,35 +144,26 @@ var shallowCompare = function (value1, value2) {
143
144
  };
144
145
  exports.shallowCompare = shallowCompare;
145
146
  var deepCompare = function (item1, item2) {
146
- // Are the items the same type
147
147
  if (typeof item1 !== typeof item2)
148
148
  return false;
149
- // If that type is Array we deepCompare each item
150
- // against its counter part
151
- // The same arrays in different orders will fail this check
152
149
  else if (Array.isArray(item1)) {
153
150
  if (item1.length !== item2.length)
154
151
  return false;
155
152
  for (var i = 0; i < item1.length; i++)
156
153
  if (!(0, exports.deepCompare)(item1[i], item2[i]))
157
154
  return false;
158
- // If they're objects...
159
155
  }
160
156
  else if (isObject(item1)) {
161
157
  var keys1 = Object.keys(item1);
162
158
  var keys2 = Object.keys(item2);
163
- // We makre sure they have the same keys...
164
159
  if (keys1.length !== keys2.length) {
165
160
  return false;
166
161
  }
167
- // and then deep compare each value
168
162
  for (var _i = 0, keys1_2 = keys1; _i < keys1_2.length; _i++) {
169
163
  var key = keys1_2[_i];
170
164
  if (!(0, exports.deepCompare)(item1[key], item2[key]))
171
165
  return false;
172
166
  }
173
- // This leaves us with literals that can be
174
- // compared directly
175
167
  }
176
168
  else if (item1 !== item2)
177
169
  return false;
@@ -280,7 +272,7 @@ var downloadSnapshot = function (snapshot, filename) { return __awaiter(void 0,
280
272
  link.addEventListener('click', clickHandler);
281
273
  document.body.appendChild(link);
282
274
  link.click();
283
- return [2 /*return*/];
275
+ return [2];
284
276
  });
285
277
  }); };
286
278
  exports.downloadSnapshot = downloadSnapshot;
@@ -365,12 +357,12 @@ var hydrateAttribute = function (data, optionSelectionHandler) {
365
357
  exports.hydrateAttribute = hydrateAttribute;
366
358
  var selectionToConfiguration = function (value, attributeType) {
367
359
  switch (attributeType) {
368
- case constants_1.ATTRIBUTE_TYPES.number:
369
- case constants_1.ATTRIBUTE_TYPES.string:
360
+ case types_1.ATTRIBUTE_TYPES.NUMBER:
361
+ case types_1.ATTRIBUTE_TYPES.STRING:
370
362
  return value;
371
- case constants_1.ATTRIBUTE_TYPES.asset:
363
+ case types_1.ATTRIBUTE_TYPES.ASSET:
372
364
  return { assetId: value };
373
- case constants_1.ATTRIBUTE_TYPES.color:
365
+ case types_1.ATTRIBUTE_TYPES.COLOR:
374
366
  return (0, exports.deflateRgb)(value);
375
367
  default:
376
368
  return value;
@@ -409,12 +401,12 @@ var runDebugger = function () { return __awaiter(void 0, void 0, void 0, functio
409
401
  var logs;
410
402
  return __generator(this, function (_a) {
411
403
  switch (_a.label) {
412
- case 0: return [4 /*yield*/, window.threekit.treble._player.calculateLogs()];
404
+ case 0: return [4, window.threekit.treble._player.calculateLogs()];
413
405
  case 1:
414
406
  logs = _a.sent();
415
407
  if (logs.length)
416
408
  console.log("Threekit Debugger: \n", logs);
417
- return [2 /*return*/];
409
+ return [2];
418
410
  }
419
411
  });
420
412
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.81",
3
+ "version": "0.0.84",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -23,15 +23,23 @@
23
23
  },
24
24
  "scripts": {
25
25
  "start": "tsc --watch",
26
- "build": "tsc",
26
+ "build": "npm run clean && tsc",
27
27
  "clean": "rimraf dist",
28
+ "esbuild": "npm run clean && node build.js && tsc --emitDeclarationOnly --outDir dist",
28
29
  "storybook": "start-storybook -p 6006",
29
30
  "build-storybook": "build-storybook -o build",
30
31
  "lint": "eslint ./src",
32
+ "lint-staged": "lint-staged",
31
33
  "check-format": "prettier -c ./src",
32
34
  "format": "prettier --write ./src",
33
35
  "test": "jest"
34
36
  },
37
+ "lint-staged": {
38
+ "./src/**/*.{css,less,scss,html,json,jsx,js,tsx,ts}": [
39
+ "prettier --write ./src"
40
+ ],
41
+ "./src": "eslint ./src --fix"
42
+ },
35
43
  "dependencies": {
36
44
  "@reduxjs/toolkit": "^1.6.2",
37
45
  "axios": "^0.22.0",
@@ -61,14 +69,18 @@
61
69
  "babel-jest": "^27.5.1",
62
70
  "babel-loader": "^8.2.2",
63
71
  "chromatic": "^6.5.3",
72
+ "esbuild": "^0.14.48",
64
73
  "jest": "^27.5.1",
65
- "react": ">=17.0.2",
66
- "react-dom": ">=17.0.2",
74
+ "lint-staged": "^13.0.3",
67
75
  "rimraf": "^3.0.2",
68
76
  "serve": "^12.0.1",
69
77
  "themeprovider-storybook": "^1.8.0",
70
78
  "ts-jest": "^27.1.3",
71
79
  "typescript": ">=4.4.4"
72
80
  },
81
+ "peerDependencies": {
82
+ "react": ">=17.0.2",
83
+ "react-dom": ">=17.0.2"
84
+ },
73
85
  "gitHead": "2e16bcf98f81e16bb1768072fdb3968122e7966f"
74
86
  }