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