@threekit-tools/treble 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 (101) hide show
  1. package/dist/Treble/Treble.d.ts +9 -3
  2. package/dist/Treble/Treble.js +40 -11
  3. package/dist/Treble/index.d.ts +2 -2
  4. package/dist/Treble/index.js +2 -2
  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/orders.d.ts +5 -7
  13. package/dist/api/orders.js +12 -12
  14. package/dist/api/price.js +2 -2
  15. package/dist/api/products.js +2 -2
  16. package/dist/components/Accordion/index.js +1 -6
  17. package/dist/components/AttributeTitle/index.d.ts +0 -9
  18. package/dist/components/AttributeTitle/index.js +0 -9
  19. package/dist/components/AttributeValue/index.d.ts +0 -6
  20. package/dist/components/AttributeValue/index.js +2 -8
  21. package/dist/components/Button/index.d.ts +0 -27
  22. package/dist/components/Button/index.js +0 -27
  23. package/dist/components/Cards/index.d.ts +2 -55
  24. package/dist/components/Cards/index.js +3 -60
  25. package/dist/components/Drawer/index.js +0 -13
  26. package/dist/components/Dropdown/index.d.ts +2 -59
  27. package/dist/components/Dropdown/index.js +4 -69
  28. package/dist/components/FlatForm/index.d.ts +0 -21
  29. package/dist/components/FlatForm/index.js +5 -24
  30. package/dist/components/Modal/index.js +0 -13
  31. package/dist/components/Player/index.d.ts +1 -1
  32. package/dist/components/PortalToElement/index.js +0 -8
  33. package/dist/components/ProductDescription/index.d.ts +0 -6
  34. package/dist/components/ProductDescription/index.js +0 -6
  35. package/dist/components/ProductName/index.d.ts +0 -9
  36. package/dist/components/ProductName/index.js +0 -9
  37. package/dist/components/Share/index.d.ts +2 -12
  38. package/dist/components/Share/index.js +139 -21
  39. package/dist/components/Share/share.styles.d.ts +9 -0
  40. package/dist/components/Share/share.styles.js +23 -0
  41. package/dist/components/Snapshots/index.d.ts +0 -8
  42. package/dist/components/Snapshots/index.js +0 -8
  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/TextInput/index.d.ts +2 -1
  50. package/dist/components/TextInput/index.js +2 -3
  51. package/dist/components/Tiles/index.d.ts +2 -29
  52. package/dist/components/Tiles/index.js +3 -33
  53. package/dist/components/TilesGroup/index.d.ts +2 -26
  54. package/dist/components/TilesGroup/index.js +3 -30
  55. package/dist/components/TotalPrice/index.d.ts +0 -6
  56. package/dist/components/TotalPrice/index.js +0 -6
  57. package/dist/components/Upload/index.d.ts +2 -1
  58. package/dist/components/Upload/index.js +7 -8
  59. package/dist/components/UploadArea/index.d.ts +2 -1
  60. package/dist/components/UploadArea/index.js +6 -7
  61. package/dist/components/Wishlist/index.d.ts +1 -4
  62. package/dist/components/Wishlist/index.js +2 -5
  63. package/dist/components/Zoom/index.d.ts +1 -18
  64. package/dist/components/Zoom/index.js +0 -17
  65. package/dist/components/formComponents.d.ts +12 -0
  66. package/dist/components/formComponents.js +5 -7
  67. package/dist/components/message/index.d.ts +0 -9
  68. package/dist/components/message/index.js +0 -9
  69. package/dist/connection.js +2 -2
  70. package/dist/constants.d.ts +0 -49
  71. package/dist/constants.js +1 -59
  72. package/dist/hooks/useAttribute/index.js +6 -6
  73. package/dist/hooks/useConfigurationLoader/index.js +5 -5
  74. package/dist/hooks/useNestedConfigurator/index.js +2 -2
  75. package/dist/hooks/useShare/index.js +3 -3
  76. package/dist/hooks/useSingleAnimation/index.js +20 -25
  77. package/dist/http/datatables.js +0 -1
  78. package/dist/http/orders.d.ts +6 -8
  79. package/dist/icons/index.d.ts +0 -41
  80. package/dist/icons/index.js +0 -42
  81. package/dist/index.d.ts +42 -3
  82. package/dist/index.js +84 -30
  83. package/dist/store/attributes.d.ts +0 -12
  84. package/dist/store/attributes.js +2 -15
  85. package/dist/store/price.d.ts +0 -12
  86. package/dist/store/price.js +2 -16
  87. package/dist/store/product.d.ts +2 -17
  88. package/dist/store/product.js +26 -38
  89. package/dist/store/translations.d.ts +0 -12
  90. package/dist/store/translations.js +2 -12
  91. package/dist/store/treble.d.ts +0 -15
  92. package/dist/store/treble.js +31 -66
  93. package/dist/store/wishlist.d.ts +0 -12
  94. package/dist/store/wishlist.js +4 -17
  95. package/dist/types.d.ts +71 -58
  96. package/dist/types.js +54 -0
  97. package/dist/utils.d.ts +2 -2
  98. package/dist/utils.js +8 -16
  99. package/package.json +18 -4
  100. package/dist/Treble/Snapshots.js +0 -251
  101. package/dist/Treble/Wishlist.js +0 -136
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,6 @@ export interface ISnapshotConfig {
160
184
  height: number;
161
185
  };
162
186
  }
163
- export declare type SNAPSHOT_FORMAT_TYPES = 'jpg' | 'png';
164
- /***************************************************
165
- * Tools
166
- **************************************************/
167
187
  export interface Node {
168
188
  name: string;
169
189
  nodeId: string;
@@ -211,9 +231,6 @@ export interface IThreekitTools {
211
231
  setTool: () => void;
212
232
  setTools: () => void;
213
233
  }
214
- /***************************************************
215
- * Threekit Api
216
- **************************************************/
217
234
  export interface IConfigurationChangeEvent {
218
235
  name: string;
219
236
  appliedConfiguration: Record<string, string>;
@@ -231,13 +248,13 @@ export interface IThreekitConfigurator {
231
248
  }
232
249
  export interface IThreekitScene {
233
250
  PHASES: {
234
- LOADED: 'loaded';
235
- PRELOADED: 'preloaded';
236
- RENDERED: 'rendered';
251
+ LOADED: SCENE_PHASES.LOADED;
252
+ PRELOADED: SCENE_PHASES.PRELOADED;
253
+ RENDERED: SCENE_PHASES.RENDERED;
237
254
  };
238
- get: (query: ISceneQuery | string) => ISceneResult;
239
- find: (query: ISceneQuery | string) => ISceneResult;
240
- set: (query: ISceneQuery | string, transform: ICoordinates) => 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;
241
258
  }
242
259
  export interface IThreekitCamera {
243
260
  frameBoundingSphere: () => void;
@@ -259,12 +276,13 @@ export interface IThreekitPlayer {
259
276
  on: (phase: SCENE_PHASES | string, callback: (args: any) => void) => void;
260
277
  getConfigurator: () => Promise<IThreekitConfigurator>;
261
278
  getStageConfigurator: () => Promise<IThreekitConfigurator>;
262
- enableApi: (api: PRIVATE_APIS) => any;
279
+ enableApi: <T extends PRIVATE_APIS>(api: T) => T extends PRIVATE_APIS.PLAYER ? IThreekitPrivatePlayer : any;
263
280
  snapshotAsync: (snapshotConfig: ISnapshotConfig) => Promise<string>;
264
281
  unload: () => Promise<string>;
265
282
  }
266
283
  export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
267
284
  getAppliedConfiguration: (attributeName: string) => string;
285
+ getFullConfiguration: () => IConfiguration;
268
286
  }
269
287
  export interface IThreekitPrivatePlayer {
270
288
  getConfigurator: () => IThreekitPrivateConfigurator;
@@ -272,6 +290,7 @@ export interface IThreekitPrivatePlayer {
272
290
  getFullConfiguration: () => IConfiguration;
273
291
  };
274
292
  calculateLogs: () => Promise<Record<string, any>>;
293
+ getAssetInstance: (query: ISceneQueryNode | string) => Promise<string>;
275
294
  }
276
295
  export interface ThreekitInitConfig {
277
296
  authToken: string;
@@ -305,9 +324,6 @@ export interface ThreekitInitConfig {
305
324
  help?: string;
306
325
  };
307
326
  }
308
- /***************************************************
309
- * Treble Declarations
310
- **************************************************/
311
327
  export interface IFrameworkConfig {
312
328
  productsCtx: __WebpackModuleApi.RequireContext;
313
329
  }
@@ -337,9 +353,6 @@ export interface ITrebleConfig {
337
353
  treble: IFrameworkConfig;
338
354
  player: IPlayerConfig;
339
355
  }
340
- /***************************************************
341
- * Global Declaration
342
- **************************************************/
343
356
  declare global {
344
357
  interface Window {
345
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 {
@@ -53,7 +53,7 @@ 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[];
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.82",
3
+ "version": "0.0.85",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -23,18 +23,28 @@
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",
46
+ "chokidar": "^3.5.3",
47
+ "live-server": "^1.2.2",
38
48
  "react-redux": "^7.2.6",
39
49
  "redux": "^4.1.2",
40
50
  "redux-logger": "^3.0.6",
@@ -61,14 +71,18 @@
61
71
  "babel-jest": "^27.5.1",
62
72
  "babel-loader": "^8.2.2",
63
73
  "chromatic": "^6.5.3",
74
+ "esbuild": "^0.14.48",
64
75
  "jest": "^27.5.1",
65
- "react": ">=17.0.2",
66
- "react-dom": ">=17.0.2",
76
+ "lint-staged": "^13.0.3",
67
77
  "rimraf": "^3.0.2",
68
78
  "serve": "^12.0.1",
69
79
  "themeprovider-storybook": "^1.8.0",
70
80
  "ts-jest": "^27.1.3",
71
81
  "typescript": ">=4.4.4"
72
82
  },
83
+ "peerDependencies": {
84
+ "react": ">=17.0.2",
85
+ "react-dom": ">=17.0.2"
86
+ },
73
87
  "gitHead": "2e16bcf98f81e16bb1768072fdb3968122e7966f"
74
88
  }