@buerli.io/core 0.13.1-beta.9 → 1.0.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 (75) hide show
  1. package/README.md +19 -12
  2. package/build/cjs/geometry/ThreeGeometryCreator.js +320 -320
  3. package/build/cjs/geometry/index.js +17 -17
  4. package/build/cjs/graphic/filters.js +25 -25
  5. package/build/cjs/index.js +26 -26
  6. package/build/cjs/re-export.js +29 -29
  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 +115 -115
  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/InteractionInfo.js +11 -11
  22. package/build/cjs/types/index.js +34 -34
  23. package/build/cjs/utils/Math.js +91 -91
  24. package/build/cjs/utils/Measure.js +576 -576
  25. package/build/cjs/utils/Timing.js +34 -34
  26. package/build/esm/geometry/ThreeGeometryCreator.js +291 -291
  27. package/build/esm/geometry/index.js +1 -1
  28. package/build/esm/graphic/filters.js +12 -12
  29. package/build/esm/index.js +10 -10
  30. package/build/esm/re-export.js +23 -23
  31. package/build/esm/store/index.js +26 -26
  32. package/build/esm/store/states/buerli.js +92 -92
  33. package/build/esm/store/states/cad.js +42 -42
  34. package/build/esm/store/states/drawing.js +45 -45
  35. package/build/esm/store/states/geometry.js +129 -129
  36. package/build/esm/store/states/graphic.js +110 -110
  37. package/build/esm/store/states/interaction.js +50 -50
  38. package/build/esm/store/states/message.js +21 -21
  39. package/build/esm/store/states/plugin.js +109 -109
  40. package/build/esm/store/states/selection.js +261 -261
  41. package/build/esm/store/states/structure.js +219 -219
  42. package/build/esm/store/store.js +3 -3
  43. package/build/esm/store/subscribtion/selection.js +44 -44
  44. package/build/esm/store/subscribtion/subscribeToDrawing.js +9 -9
  45. package/build/esm/types/InteractionInfo.js +6 -6
  46. package/build/esm/types/index.js +16 -16
  47. package/build/esm/utils/Math.js +65 -65
  48. package/build/esm/utils/Measure.js +550 -550
  49. package/build/esm/utils/Timing.js +31 -31
  50. package/build/types/geometry/ThreeGeometryCreator.d.ts +256 -256
  51. package/build/types/geometry/index.d.ts +1 -1
  52. package/build/types/graphic/filters.d.ts +11 -11
  53. package/build/types/index.d.ts +38 -38
  54. package/build/types/re-export.d.ts +70 -70
  55. package/build/types/store/index.d.ts +16 -16
  56. package/build/types/store/states/buerli.d.ts +41 -41
  57. package/build/types/store/states/cad.d.ts +56 -53
  58. package/build/types/store/states/drawing.d.ts +45 -45
  59. package/build/types/store/states/geometry.d.ts +64 -64
  60. package/build/types/store/states/graphic.d.ts +21 -21
  61. package/build/types/store/states/interaction.d.ts +34 -34
  62. package/build/types/store/states/message.d.ts +30 -30
  63. package/build/types/store/states/plugin.d.ts +53 -53
  64. package/build/types/store/states/selection.d.ts +69 -69
  65. package/build/types/store/states/structure.d.ts +47 -47
  66. package/build/types/store/store.d.ts +2 -2
  67. package/build/types/store/subscribtion/selection.d.ts +7 -7
  68. package/build/types/store/subscribtion/subscribeToDrawing.d.ts +4 -4
  69. package/build/types/types/InteractionInfo.d.ts +42 -42
  70. package/build/types/types/index.d.ts +7 -7
  71. package/build/types/utils/Math.d.ts +21 -21
  72. package/build/types/utils/Measure.d.ts +64 -64
  73. package/build/types/utils/Timing.d.ts +8 -8
  74. package/package.json +45 -45
  75. package/CHANGELOG.md +0 -7
@@ -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
+ }