@buerli.io/core 0.0.35-beta.0 → 0.0.35-beta.4

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 (74) hide show
  1. package/build/{types/geometry → geometry}/ThreeGeometryCreator.d.ts +0 -0
  2. package/build/{esm/geometry → geometry}/ThreeGeometryCreator.js +17 -47
  3. package/build/{types/geometry → geometry}/index.d.ts +0 -0
  4. package/build/{esm/geometry → geometry}/index.js +0 -0
  5. package/build/index.d.ts +36 -0
  6. package/build/{esm/index.js → index.js} +0 -0
  7. package/build/{types/store → store}/index.d.ts +0 -0
  8. package/build/{esm/store → store}/index.js +2 -1
  9. package/build/{types/store → store}/states/buerli.d.ts +0 -0
  10. package/build/{cjs/store → store}/states/buerli.js +5 -9
  11. package/build/{types/store → store}/states/canvas.d.ts +0 -0
  12. package/build/{cjs/store → store}/states/canvas.js +2 -7
  13. package/build/{types/store → store}/states/drawing.d.ts +2 -0
  14. package/build/{esm/store → store}/states/drawing.js +4 -0
  15. package/build/{types/store → store}/states/geometry.d.ts +0 -0
  16. package/build/{cjs/store → store}/states/geometry.js +5 -29
  17. package/build/{types/store → store}/states/graphic.d.ts +0 -0
  18. package/build/{cjs/store → store}/states/graphic.js +2 -7
  19. package/build/{types/store → store}/states/message.d.ts +0 -0
  20. package/build/{esm/store → store}/states/message.js +2 -2
  21. package/build/{types/store → store}/states/plugin.d.ts +0 -0
  22. package/build/{cjs/store → store}/states/plugin.js +5 -11
  23. package/build/{types/store → store}/states/selection.d.ts +0 -0
  24. package/build/{cjs/store → store}/states/selection.js +14 -20
  25. package/build/{types/store → store}/states/structure.d.ts +0 -0
  26. package/build/{esm/store → store}/states/structure.js +4 -10
  27. package/build/{types/store → store}/store.d.ts +0 -0
  28. package/build/{esm/store → store}/store.js +0 -0
  29. package/build/{types/store → store}/subscribtion/selection.d.ts +0 -0
  30. package/build/{esm/store → store}/subscribtion/selection.js +2 -1
  31. package/build/{types/store → store}/subscribtion/subscribeToDrawing.d.ts +0 -0
  32. package/build/{esm/store → store}/subscribtion/subscribeToDrawing.js +0 -0
  33. package/build/types/{types/ErrorTypes.d.ts → ErrorTypes.d.ts} +0 -0
  34. package/build/{esm/types → types}/ErrorTypes.js +0 -0
  35. package/build/types/{types/IGraphicPackage.d.ts → IGraphicPackage.d.ts} +0 -0
  36. package/build/{esm/types → types}/IGraphicPackage.js +0 -0
  37. package/build/types/{types/IStructurePatch.d.ts → IStructurePatch.d.ts} +0 -0
  38. package/build/{esm/types → types}/IStructurePatch.js +0 -0
  39. package/build/types/{types/IStructureTree.d.ts → IStructureTree.d.ts} +0 -0
  40. package/build/{esm/types → types}/IStructureTree.js +0 -0
  41. package/build/types/index.d.ts +4 -36
  42. package/build/{esm/types → types}/index.js +0 -0
  43. package/build/{types/utils → utils}/Math.d.ts +0 -0
  44. package/build/{esm/utils → utils}/Math.js +0 -0
  45. package/build/{types/utils → utils}/Measure.d.ts +0 -0
  46. package/build/{esm/utils → utils}/Measure.js +1 -1
  47. package/build/{types/utils → utils}/Timing.d.ts +0 -0
  48. package/build/{esm/utils → utils}/Timing.js +1 -1
  49. package/package.json +6 -9
  50. package/build/cjs/geometry/ThreeGeometryCreator.js +0 -284
  51. package/build/cjs/geometry/index.js +0 -13
  52. package/build/cjs/index.js +0 -20
  53. package/build/cjs/store/index.js +0 -46
  54. package/build/cjs/store/states/drawing.js +0 -44
  55. package/build/cjs/store/states/message.js +0 -25
  56. package/build/cjs/store/states/structure.js +0 -203
  57. package/build/cjs/store/store.js +0 -14
  58. package/build/cjs/store/subscribtion/selection.js +0 -47
  59. package/build/cjs/store/subscribtion/subscribeToDrawing.js +0 -9
  60. package/build/cjs/types/ErrorTypes.js +0 -2
  61. package/build/cjs/types/IGraphicPackage.js +0 -24
  62. package/build/cjs/types/IStructurePatch.js +0 -2
  63. package/build/cjs/types/IStructureTree.js +0 -27
  64. package/build/cjs/types/index.js +0 -16
  65. package/build/cjs/utils/Math.js +0 -33
  66. package/build/cjs/utils/Measure.js +0 -576
  67. package/build/cjs/utils/Timing.js +0 -34
  68. package/build/esm/store/states/buerli.js +0 -116
  69. package/build/esm/store/states/canvas.js +0 -13
  70. package/build/esm/store/states/geometry.js +0 -98
  71. package/build/esm/store/states/graphic.js +0 -82
  72. package/build/esm/store/states/plugin.js +0 -152
  73. package/build/esm/store/states/selection.js +0 -269
  74. package/build/types/types/index.d.ts +0 -4
@@ -1,269 +0,0 @@
1
- import { subscribeItems, unsubscribeItems } from '../subscribtion/selection';
2
- ////////////////////////////////////////////////////
3
- // CONSTANTS
4
- ////////////////////////////////////////////////////
5
- export const BuerliScope = 'ClassCAD';
6
- export const selectionData = () => ({
7
- refs: {},
8
- active: null,
9
- });
10
- export const selectionApi = (set, get) => ({
11
- unselectAll() {
12
- const drawingId = get().id;
13
- const activeSelector = get().selection.active;
14
- if (activeSelector) {
15
- const unselItems = get().selection.refs[activeSelector].items;
16
- unsubscribeItems(drawingId, activeSelector, unselItems);
17
- set(state => {
18
- const selector = state.selection.refs[activeSelector];
19
- return {
20
- selection: {
21
- ...state.selection,
22
- refs: { ...state.selection.refs, [activeSelector]: { ...selector, items: [] } },
23
- },
24
- };
25
- });
26
- }
27
- },
28
- unselect(...unselItems) {
29
- const { selection, id: drawingId } = get();
30
- const activeSelectorId = selection.active;
31
- if (activeSelectorId) {
32
- // Remove unselItems from selector's items
33
- const selector = selection.refs[activeSelectorId];
34
- const newItems = selector.items.filter(item => unselItems.find(uItem => uItem.id === item.id) === undefined);
35
- unsubscribeItems(drawingId, activeSelectorId, unselItems);
36
- if (selector.customUnSelect) {
37
- // Find recently unselected items
38
- const diff = selector.items.filter(item1 => {
39
- return newItems.find(item2 => item2.id === item1.id) === undefined;
40
- });
41
- selector.customUnSelect(activeSelectorId, newItems, diff);
42
- }
43
- else {
44
- set(state => {
45
- return {
46
- selection: {
47
- ...state.selection,
48
- refs: {
49
- ...state.selection.refs,
50
- [activeSelectorId]: {
51
- ...state.selection.refs[activeSelectorId],
52
- items: newItems,
53
- },
54
- },
55
- },
56
- };
57
- });
58
- }
59
- this.setHovered(null, activeSelectorId);
60
- }
61
- },
62
- select(...newItems) {
63
- const { selection, api, id: drawingId } = get();
64
- const activeSelectorId = selection.active;
65
- const { isItemSelected } = api.selection;
66
- if (activeSelectorId) {
67
- const selector = selection.refs[activeSelectorId];
68
- const curItems = selector.items;
69
- // Remove duplicates
70
- let filteredItems = newItems.filter((item1, idx) => newItems.findIndex(item2 => item2.id === item1.id) === idx);
71
- // Remove already selected items and duplicates
72
- filteredItems = filteredItems.filter(item => !isItemSelected(item, activeSelectorId));
73
- let unsubItems = [];
74
- let result = [...curItems, ...filteredItems];
75
- if (selector.maxLen > 0) {
76
- if (filteredItems.length === selector.maxLen) {
77
- result = [...filteredItems];
78
- unsubItems = [...curItems];
79
- }
80
- else if (filteredItems.length > selector.maxLen) {
81
- const extraItems = filteredItems.length - selector.maxLen;
82
- // If filteredItems has bigger length then selector.maxLen, remove last few items from filteredItems.
83
- result = filteredItems.slice(0, -extraItems);
84
- unsubItems = [...curItems];
85
- }
86
- else if (filteredItems.length + curItems.length >= selector.maxLen) {
87
- const extraItems = filteredItems.length + curItems.length - selector.maxLen;
88
- const allItems = [...curItems, ...filteredItems];
89
- // If filteredItems.len + curItems.len > selector.maxLen, remove first few items from union of curItems and filteredItems.
90
- result = allItems.slice(extraItems);
91
- unsubItems = allItems.slice(0, extraItems);
92
- }
93
- }
94
- if (selector.customSelect !== undefined) {
95
- // Find items which weren't selected before.
96
- const diff = result.filter(item1 => {
97
- return selector.items.find(item2 => item2.id === item1.id) === undefined;
98
- });
99
- selector.customSelect(activeSelectorId, result, diff);
100
- }
101
- else {
102
- // subscribe items which will be selected
103
- subscribeItems(drawingId, activeSelectorId, result);
104
- // unsubscribe items which will be unselected
105
- unsubscribeItems(drawingId, activeSelectorId, unsubItems);
106
- set(state => {
107
- return {
108
- selection: {
109
- ...state.selection,
110
- refs: { ...state.selection.refs, [activeSelectorId]: { ...selector, items: result } },
111
- },
112
- };
113
- });
114
- }
115
- this.setHovered(null, activeSelectorId);
116
- }
117
- },
118
- setHovered(item, selectorId) {
119
- const { selection } = get();
120
- if (selection.active === null && selectorId === undefined)
121
- return;
122
- const selId = selection.active || selectorId;
123
- set(state => ({
124
- selection: {
125
- ...state.selection,
126
- refs: {
127
- ...state.selection.refs,
128
- [selId]: {
129
- ...state.selection.refs[selId],
130
- hoveredItem: item,
131
- },
132
- },
133
- },
134
- }));
135
- },
136
- activateSelector(selectorId) {
137
- set(state => {
138
- const refs = state.selection.refs;
139
- const curSelectorId = state.selection.active;
140
- if (curSelectorId) {
141
- // Reset hoveredItem
142
- refs[curSelectorId] = {
143
- ...refs[curSelectorId],
144
- hoveredItem: null,
145
- };
146
- }
147
- return {
148
- selection: {
149
- ...state.selection,
150
- active: state.selection.active === selectorId ? null : selectorId,
151
- refs: {
152
- ...refs,
153
- },
154
- },
155
- };
156
- });
157
- },
158
- createSelector(selectorId, filter, activate = false, initialItems = [], maxLen = -1, customSelect, customUnSelect) {
159
- if (maxLen > 0 && initialItems.length > maxLen)
160
- console.error('Number initialItems should be less or equal to selector.maxLen');
161
- set(state => ({
162
- selection: {
163
- ...state.selection,
164
- active: activate ? selectorId : state.selection.active,
165
- refs: {
166
- ...state.selection.refs,
167
- [selectorId]: {
168
- items: maxLen > 0 && initialItems.length > maxLen ? [] : initialItems,
169
- hoveredItem: null,
170
- isSelectable: filter,
171
- maxLen,
172
- customSelect,
173
- customUnSelect,
174
- },
175
- },
176
- },
177
- }));
178
- return () => {
179
- if (get && get()) {
180
- const drawingId = get().id;
181
- unsubscribeItems(drawingId, selectorId);
182
- set(state => {
183
- const refs = state.selection.refs;
184
- delete refs[selectorId];
185
- return {
186
- selection: {
187
- ...state.selection,
188
- active: state.selection.active === selectorId ? null : state.selection.active,
189
- refs,
190
- },
191
- };
192
- });
193
- }
194
- };
195
- },
196
- areItemsSelected: (items, selectorId) => {
197
- const { selection } = get();
198
- if (selection.active === null && selectorId === undefined)
199
- return false;
200
- const selId = selection.active || selectorId;
201
- const selector = selection.refs[selId];
202
- let res = true;
203
- items.forEach(item => {
204
- const itemSelected = Boolean(selector.items.find(i => areItemsEqual(i, item)));
205
- if (!itemSelected) {
206
- res = false;
207
- }
208
- });
209
- return res;
210
- },
211
- isItemSelected: (item, selectorId) => {
212
- const { selection } = get();
213
- if (selection.active === null && selectorId === undefined)
214
- return false;
215
- const selId = selection.active || selectorId;
216
- const selector = selection.refs[selId];
217
- return Boolean(selector.items.find(i => areItemsEqual(i, item)));
218
- },
219
- setItems(id, items) {
220
- const { selection, id: drawingId } = get();
221
- const curItems = selection.refs[id]?.items || [];
222
- unsubscribeItems(drawingId, id, curItems);
223
- subscribeItems(drawingId, id, items);
224
- set(state => {
225
- const selector = state.selection.refs[id];
226
- return {
227
- selection: { ...state.selection, refs: { ...state.selection.refs, [id]: { ...selector, items } } },
228
- };
229
- });
230
- },
231
- getGraphicItem: (productId, containerId, graphicId) => {
232
- const { cache } = get().geometry;
233
- const container = cache[containerId];
234
- if (container) {
235
- if (graphicId === undefined) {
236
- const ids = Object.getOwnPropertyNames(container.map);
237
- graphicId = ids.length > 0 ? Number(ids[0]) : undefined;
238
- }
239
- if (graphicId !== undefined) {
240
- const geomElem = container.map[graphicId];
241
- if (geomElem) {
242
- return createGraphicItem(productId, geomElem);
243
- }
244
- }
245
- }
246
- return null;
247
- },
248
- });
249
- ////////////////////////////////////////////////////
250
- //#region GLOBAL FUNCTIONS
251
- const areItemsEqual = (a, b) => a.id === b.id && a.scope === b.scope;
252
- const createGraphicIdent = (productId, graphicId, type) => {
253
- return {
254
- id: `${productId}|${graphicId}|${type}`,
255
- scope: BuerliScope,
256
- label: (type[0] + type[1]).toUpperCase(),
257
- };
258
- };
259
- export const createGraphicItem = (productId, el) => {
260
- return {
261
- ...createGraphicIdent(productId, el.graphicId, el.type),
262
- data: {
263
- ...el,
264
- productId,
265
- },
266
- };
267
- };
268
- //#endregion GLOBAL FUNCTIONS
269
- ////////////////////////////////////////////////////
@@ -1,4 +0,0 @@
1
- export * from './ErrorTypes';
2
- export * from './IGraphicPackage';
3
- export * from './IStructurePatch';
4
- export * from './IStructureTree';