@buerli.io/core 0.13.0 → 0.13.1-beta.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 (81) hide show
  1. package/CHANGELOG.md +7 -7
  2. package/README.md +12 -12
  3. package/build/cjs/geometry/ThreeGeometryCreator.js +320 -320
  4. package/build/cjs/geometry/index.js +17 -17
  5. package/build/cjs/graphic/filters.js +25 -25
  6. package/build/cjs/index.js +25 -25
  7. package/build/cjs/store/index.js +37 -37
  8. package/build/cjs/store/states/buerli.js +98 -98
  9. package/build/cjs/store/states/cad.js +47 -47
  10. package/build/cjs/store/states/drawing.js +49 -49
  11. package/build/cjs/store/states/geometry.js +157 -157
  12. package/build/cjs/store/states/graphic.js +112 -112
  13. package/build/cjs/store/states/interaction.js +55 -55
  14. package/build/cjs/store/states/message.js +25 -25
  15. package/build/cjs/store/states/plugin.js +115 -115
  16. package/build/cjs/store/states/selection.js +267 -267
  17. package/build/cjs/store/states/structure.js +250 -250
  18. package/build/cjs/store/store.js +9 -9
  19. package/build/cjs/store/subscribtion/selection.js +49 -49
  20. package/build/cjs/store/subscribtion/subscribeToDrawing.js +13 -13
  21. package/build/cjs/types/IGraphicPackage.js +46 -46
  22. package/build/cjs/types/IStructurePatch.js +2 -2
  23. package/build/cjs/types/IStructureTree.js +28 -28
  24. package/build/cjs/types/InteractionInfo.js +11 -11
  25. package/build/cjs/types/index.js +20 -20
  26. package/build/cjs/utils/Math.js +91 -91
  27. package/build/cjs/utils/Measure.js +576 -576
  28. package/build/cjs/utils/Timing.js +34 -34
  29. package/build/esm/geometry/ThreeGeometryCreator.js +291 -291
  30. package/build/esm/geometry/index.js +1 -1
  31. package/build/esm/graphic/filters.js +12 -12
  32. package/build/esm/index.js +9 -9
  33. package/build/esm/store/index.js +26 -26
  34. package/build/esm/store/states/buerli.js +92 -92
  35. package/build/esm/store/states/cad.js +42 -42
  36. package/build/esm/store/states/drawing.js +45 -45
  37. package/build/esm/store/states/geometry.js +129 -129
  38. package/build/esm/store/states/graphic.js +107 -107
  39. package/build/esm/store/states/interaction.js +50 -50
  40. package/build/esm/store/states/message.js +21 -21
  41. package/build/esm/store/states/plugin.js +109 -109
  42. package/build/esm/store/states/selection.js +261 -261
  43. package/build/esm/store/states/structure.js +219 -219
  44. package/build/esm/store/store.js +3 -3
  45. package/build/esm/store/subscribtion/selection.js +44 -44
  46. package/build/esm/store/subscribtion/subscribeToDrawing.js +9 -9
  47. package/build/esm/types/IGraphicPackage.js +43 -43
  48. package/build/esm/types/IStructurePatch.js +1 -1
  49. package/build/esm/types/IStructureTree.js +24 -24
  50. package/build/esm/types/InteractionInfo.js +6 -6
  51. package/build/esm/types/index.js +4 -4
  52. package/build/esm/utils/Math.js +65 -65
  53. package/build/esm/utils/Measure.js +550 -550
  54. package/build/esm/utils/Timing.js +31 -31
  55. package/build/types/geometry/ThreeGeometryCreator.d.ts +256 -256
  56. package/build/types/geometry/index.d.ts +1 -1
  57. package/build/types/graphic/filters.d.ts +11 -11
  58. package/build/types/index.d.ts +37 -37
  59. package/build/types/store/index.d.ts +16 -16
  60. package/build/types/store/states/buerli.d.ts +41 -41
  61. package/build/types/store/states/cad.d.ts +53 -53
  62. package/build/types/store/states/drawing.d.ts +45 -45
  63. package/build/types/store/states/geometry.d.ts +65 -65
  64. package/build/types/store/states/graphic.d.ts +22 -22
  65. package/build/types/store/states/interaction.d.ts +34 -34
  66. package/build/types/store/states/message.d.ts +30 -30
  67. package/build/types/store/states/plugin.d.ts +53 -53
  68. package/build/types/store/states/selection.d.ts +62 -62
  69. package/build/types/store/states/structure.d.ts +47 -47
  70. package/build/types/store/store.d.ts +2 -2
  71. package/build/types/store/subscribtion/selection.d.ts +7 -7
  72. package/build/types/store/subscribtion/subscribeToDrawing.d.ts +4 -4
  73. package/build/types/types/IGraphicPackage.d.ts +160 -160
  74. package/build/types/types/IStructurePatch.d.ts +6 -6
  75. package/build/types/types/IStructureTree.d.ts +80 -80
  76. package/build/types/types/InteractionInfo.d.ts +43 -43
  77. package/build/types/types/index.d.ts +4 -4
  78. package/build/types/utils/Math.d.ts +21 -21
  79. package/build/types/utils/Measure.d.ts +64 -64
  80. package/build/types/utils/Timing.d.ts +8 -8
  81. package/package.json +44 -44
@@ -1,109 +1,109 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- export const pluginData = () => ({
3
- feature: [],
4
- global: [],
5
- refs: {},
6
- active: {
7
- feature: null,
8
- global: [],
9
- },
10
- visible: [],
11
- });
12
- export const pluginApi = (set, get, buerliApi) => ({
13
- setActiveFeature: (id) => {
14
- set(state => {
15
- let plugins = state.plugin.refs;
16
- const oldPlugin = state.plugin.active.feature !== null && state.plugin.refs[state.plugin.active.feature];
17
- if (oldPlugin && state.plugin.active.feature !== id && !oldPlugin.persistent && id !== null) {
18
- // Reset plugin-state when the plugin is re-activated, not persistent and has not been active all along
19
- const initState = oldPlugin.initialState || {};
20
- plugins = Object.assign(Object.assign({}, plugins), { [oldPlugin.id]: Object.assign(Object.assign({}, oldPlugin), { state: typeof initState === 'function' ? initState(get().id, id) : initState }) });
21
- }
22
- return {
23
- plugin: Object.assign(Object.assign({}, state.plugin), { active: Object.assign(Object.assign({}, state.plugin.active), { feature: id }), refs: plugins }),
24
- selection: Object.assign(Object.assign({}, state.selection), { active: null }),
25
- };
26
- });
27
- },
28
- setVisiblePlugin: (id, visible) => {
29
- set(currentState => {
30
- const filtered = currentState.plugin.visible.filter(p => p !== id);
31
- if (visible)
32
- filtered.push(id);
33
- return {
34
- plugin: Object.assign(Object.assign({}, currentState.plugin), { visible: filtered }),
35
- };
36
- });
37
- },
38
- setActiveGlobal: (id, active) => {
39
- set(currentState => {
40
- if (currentState.plugin.global.indexOf(id) === -1) {
41
- console.warn('Given plugin id does not exist.');
42
- return currentState;
43
- }
44
- const filtered = currentState.plugin.active.global.filter(p => p !== id);
45
- if (active)
46
- filtered.push(id);
47
- return {
48
- plugin: Object.assign(Object.assign({}, currentState.plugin), { active: Object.assign(Object.assign({}, currentState.plugin.active), { global: filtered }) }),
49
- };
50
- });
51
- },
52
- // TODO remove defaultId and useEmbeddedPlugin ?
53
- createPlugin: (def, defaultId, drawingId, objectId) => {
54
- const id = defaultId !== void 0 ? defaultId : uuidv4();
55
- function init(definition) {
56
- const { description, Root = null, View = null } = definition;
57
- const initialState = description.initialState || {};
58
- const localState = typeof initialState === 'function' ? initialState(drawingId, objectId) : initialState;
59
- set(currentState => {
60
- const newPlugin = Object.assign(Object.assign({ id }, description), { drawingId,
61
- objectId, state: localState, Root,
62
- View, set: (sel) => {
63
- // set function can be called when drawing doesn't exist anymore, in this case nothing should be done.
64
- if (get() === undefined)
65
- return;
66
- set(state => {
67
- const newState = typeof sel === 'function' ? sel(state.plugin.refs[id].state) : sel;
68
- return {
69
- plugin: Object.assign(Object.assign({}, state.plugin), { refs: Object.assign(Object.assign({}, state.plugin.refs), { [id]: Object.assign(Object.assign({}, state.plugin.refs[id]), { state: Object.assign(Object.assign({}, state.plugin.refs[id].state), newState) }) }) }),
70
- };
71
- });
72
- } });
73
- return {
74
- plugin: Object.assign(Object.assign({}, currentState.plugin), { feature: description.global
75
- ? currentState.plugin.feature
76
- : [...currentState.plugin.feature, id], global: description.global ? [...currentState.plugin.global, id] : currentState.plugin.global, refs: Object.assign(Object.assign({}, currentState.plugin.refs), { [id]: Object.assign(Object.assign({}, currentState.plugin.refs[id]), newPlugin) }) }),
77
- };
78
- });
79
- }
80
- // Initialize plugin definition, which may be a promise or an object
81
- if (isPromisePlugin(def)) {
82
- // The definition is async, so we create a plugin slot right away and complete it later
83
- init({
84
- description: { author: '', name: '', persistent: false, global: false, version: '' },
85
- Root: null,
86
- View: null,
87
- });
88
- def.then(init).catch();
89
- }
90
- else
91
- init(def);
92
- // Return unsubscribe
93
- return (deactivate = true) => {
94
- // Use 'get' to check if the drawing still exists
95
- get &&
96
- get() &&
97
- set(state => {
98
- const newPlugins = Object.assign({}, state.plugin.refs);
99
- delete newPlugins[id];
100
- return {
101
- plugin: Object.assign(Object.assign({}, state.plugin), { active: Object.assign(Object.assign({}, state.plugin.active), { feature: deactivate ? null : state.plugin.active.feature }), feature: state.plugin.feature.filter(pluginId => pluginId !== id), global: state.plugin.global.filter(pluginId => pluginId !== id), refs: newPlugins }),
102
- };
103
- });
104
- };
105
- },
106
- });
107
- export function isPromisePlugin(def) {
108
- return def.then !== undefined;
109
- }
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ export const pluginData = () => ({
3
+ feature: [],
4
+ global: [],
5
+ refs: {},
6
+ active: {
7
+ feature: null,
8
+ global: [],
9
+ },
10
+ visible: [],
11
+ });
12
+ export const pluginApi = (set, get, buerliApi) => ({
13
+ setActiveFeature: (id) => {
14
+ set(state => {
15
+ let plugins = state.plugin.refs;
16
+ const oldPlugin = state.plugin.active.feature !== null && state.plugin.refs[state.plugin.active.feature];
17
+ if (oldPlugin && state.plugin.active.feature !== id && !oldPlugin.persistent && id !== null) {
18
+ // Reset plugin-state when the plugin is re-activated, not persistent and has not been active all along
19
+ const initState = oldPlugin.initialState || {};
20
+ plugins = Object.assign(Object.assign({}, plugins), { [oldPlugin.id]: Object.assign(Object.assign({}, oldPlugin), { state: typeof initState === 'function' ? initState(get().id, id) : initState }) });
21
+ }
22
+ return {
23
+ plugin: Object.assign(Object.assign({}, state.plugin), { active: Object.assign(Object.assign({}, state.plugin.active), { feature: id }), refs: plugins }),
24
+ selection: Object.assign(Object.assign({}, state.selection), { active: null }),
25
+ };
26
+ });
27
+ },
28
+ setVisiblePlugin: (id, visible) => {
29
+ set(currentState => {
30
+ const filtered = currentState.plugin.visible.filter(p => p !== id);
31
+ if (visible)
32
+ filtered.push(id);
33
+ return {
34
+ plugin: Object.assign(Object.assign({}, currentState.plugin), { visible: filtered }),
35
+ };
36
+ });
37
+ },
38
+ setActiveGlobal: (id, active) => {
39
+ set(currentState => {
40
+ if (currentState.plugin.global.indexOf(id) === -1) {
41
+ console.warn('Given plugin id does not exist.');
42
+ return currentState;
43
+ }
44
+ const filtered = currentState.plugin.active.global.filter(p => p !== id);
45
+ if (active)
46
+ filtered.push(id);
47
+ return {
48
+ plugin: Object.assign(Object.assign({}, currentState.plugin), { active: Object.assign(Object.assign({}, currentState.plugin.active), { global: filtered }) }),
49
+ };
50
+ });
51
+ },
52
+ // TODO remove defaultId and useEmbeddedPlugin ?
53
+ createPlugin: (def, defaultId, drawingId, objectId) => {
54
+ const id = defaultId !== void 0 ? defaultId : uuidv4();
55
+ function init(definition) {
56
+ const { description, Root = null, View = null } = definition;
57
+ const initialState = description.initialState || {};
58
+ const localState = typeof initialState === 'function' ? initialState(drawingId, objectId) : initialState;
59
+ set(currentState => {
60
+ const newPlugin = Object.assign(Object.assign({ id }, description), { drawingId,
61
+ objectId, state: localState, Root,
62
+ View, set: (sel) => {
63
+ // set function can be called when drawing doesn't exist anymore, in this case nothing should be done.
64
+ if (get() === undefined)
65
+ return;
66
+ set(state => {
67
+ const newState = typeof sel === 'function' ? sel(state.plugin.refs[id].state) : sel;
68
+ return {
69
+ plugin: Object.assign(Object.assign({}, state.plugin), { refs: Object.assign(Object.assign({}, state.plugin.refs), { [id]: Object.assign(Object.assign({}, state.plugin.refs[id]), { state: Object.assign(Object.assign({}, state.plugin.refs[id].state), newState) }) }) }),
70
+ };
71
+ });
72
+ } });
73
+ return {
74
+ plugin: Object.assign(Object.assign({}, currentState.plugin), { feature: description.global
75
+ ? currentState.plugin.feature
76
+ : [...currentState.plugin.feature, id], global: description.global ? [...currentState.plugin.global, id] : currentState.plugin.global, refs: Object.assign(Object.assign({}, currentState.plugin.refs), { [id]: Object.assign(Object.assign({}, currentState.plugin.refs[id]), newPlugin) }) }),
77
+ };
78
+ });
79
+ }
80
+ // Initialize plugin definition, which may be a promise or an object
81
+ if (isPromisePlugin(def)) {
82
+ // The definition is async, so we create a plugin slot right away and complete it later
83
+ init({
84
+ description: { author: '', name: '', persistent: false, global: false, version: '' },
85
+ Root: null,
86
+ View: null,
87
+ });
88
+ def.then(init).catch();
89
+ }
90
+ else
91
+ init(def);
92
+ // Return unsubscribe
93
+ return (deactivate = true) => {
94
+ // Use 'get' to check if the drawing still exists
95
+ get &&
96
+ get() &&
97
+ set(state => {
98
+ const newPlugins = Object.assign({}, state.plugin.refs);
99
+ delete newPlugins[id];
100
+ return {
101
+ plugin: Object.assign(Object.assign({}, state.plugin), { active: Object.assign(Object.assign({}, state.plugin.active), { feature: deactivate ? null : state.plugin.active.feature }), feature: state.plugin.feature.filter(pluginId => pluginId !== id), global: state.plugin.global.filter(pluginId => pluginId !== id), refs: newPlugins }),
102
+ };
103
+ });
104
+ };
105
+ },
106
+ });
107
+ export function isPromisePlugin(def) {
108
+ return def.then !== undefined;
109
+ }