@buerli.io/core 0.4.1 → 0.5.0-beta.1
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/build/index.d.ts +1 -2
- package/build/store/index.d.ts +2 -2
- package/build/store/states/buerli.d.ts +30 -39
- package/build/store/states/buerli.js +2 -2
- package/build/store/states/cad.d.ts +4 -4
- package/build/store/states/drawing.d.ts +3 -3
- package/build/store/states/geometry.d.ts +7 -7
- package/build/store/states/graphic.d.ts +6 -6
- package/build/store/states/interaction.d.ts +4 -4
- package/build/store/states/message.d.ts +3 -3
- package/build/store/states/plugin.d.ts +5 -5
- package/build/store/states/selection.d.ts +13 -13
- package/build/store/states/structure.d.ts +4 -4
- package/build/store/store.d.ts +1 -4
- package/build/store/store.js +1 -6
- package/build/store/subscribtion/selection.d.ts +5 -4
- package/build/store/subscribtion/subscribeToDrawing.d.ts +3 -2
- package/build/store/subscribtion/subscribeToDrawing.js +6 -1
- package/package.json +5 -5
package/build/index.d.ts
CHANGED
|
@@ -12,9 +12,8 @@ export * from './graphic/filters';
|
|
|
12
12
|
*
|
|
13
13
|
* Please have a look at https://github.com/awv-informatik/buerli/pull/129 for more information.
|
|
14
14
|
*/
|
|
15
|
-
import { BuerliState as BS
|
|
15
|
+
import { BuerliState as BS } from './store/states/buerli';
|
|
16
16
|
export declare type BuerliState = BS;
|
|
17
|
-
export declare type BuerliOptions = BO;
|
|
18
17
|
import { DrawingAPI as DrawingAPI1, DrawingID as DrawingID1, DrawingState as DrawingState1 } from './store/states/drawing';
|
|
19
18
|
export declare type DrawingID = DrawingID1;
|
|
20
19
|
export declare type DrawingState = DrawingState1;
|
package/build/store/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuerliState } from './states/buerli';
|
|
2
2
|
import { DrawingID, DrawingState } from './states/drawing';
|
|
3
3
|
import { Message, MessageID } from './states/message';
|
|
4
4
|
import { PluginID, PluginState } from './states/plugin';
|
|
@@ -7,7 +7,7 @@ declare function getDrawing(id: DrawingID): DrawingState;
|
|
|
7
7
|
* @returns PluginState or undefined if either drawing or plugin don't exist
|
|
8
8
|
*/
|
|
9
9
|
declare function getPlugin(drawingId: DrawingID, pluginId: PluginID): PluginState;
|
|
10
|
-
declare function init(options?: Partial<
|
|
10
|
+
declare function init(options?: Partial<BuerliState['options']>): void;
|
|
11
11
|
declare function showMessage(message: Message): MessageID;
|
|
12
12
|
declare function updateMessage(id: MessageID, message: Message): void;
|
|
13
13
|
export { BuerliMessageScope } from './states/message';
|
|
@@ -1,50 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
1
|
+
import { StateCreator } from 'zustand';
|
|
3
2
|
import { DrawingID, DrawingState } from './drawing';
|
|
4
3
|
import { GeometryConfig } from './geometry';
|
|
5
4
|
import { MessageState } from './message';
|
|
6
5
|
import { PluginDef, PluginImpl } from './plugin';
|
|
7
|
-
declare type
|
|
6
|
+
declare type GeneralApi = {
|
|
7
|
+
init(options?: Partial<BuerliState['options']>): void;
|
|
8
|
+
};
|
|
9
|
+
declare type DrawingManagementApi = {
|
|
10
|
+
createDrawing(name?: string): Promise<DrawingState>;
|
|
11
|
+
removeDrawing(id: DrawingID): void;
|
|
12
|
+
setActiveDrawing(id: DrawingID | null): void;
|
|
13
|
+
};
|
|
14
|
+
export declare type BuerliState = Readonly<{
|
|
8
15
|
initDone: boolean;
|
|
9
|
-
options:
|
|
16
|
+
options: {
|
|
17
|
+
elements: any;
|
|
18
|
+
plugins: Record<string, PluginImpl>;
|
|
19
|
+
globalPlugins: PluginDef[];
|
|
20
|
+
theme: {
|
|
21
|
+
primary: string;
|
|
22
|
+
secondary: string;
|
|
23
|
+
dark: string;
|
|
24
|
+
highlightedGeom: string;
|
|
25
|
+
hoveredGeom: string;
|
|
26
|
+
};
|
|
27
|
+
config: {
|
|
28
|
+
geometry: GeometryConfig;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
10
31
|
drawing: {
|
|
11
32
|
ids: DrawingID[];
|
|
12
33
|
refs: Record<DrawingID, DrawingState>;
|
|
13
34
|
active: DrawingID | null;
|
|
14
35
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
theme: {
|
|
21
|
-
primary: string;
|
|
22
|
-
secondary: string;
|
|
23
|
-
dark: string;
|
|
24
|
-
highlightedGeom: string;
|
|
25
|
-
hoveredGeom: string;
|
|
26
|
-
};
|
|
27
|
-
config: {
|
|
28
|
-
geometry: GeometryConfig;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
declare type StateApi = ReturnType<typeof generalApi> & ReturnType<typeof drawingManagementApi>;
|
|
32
|
-
export declare type BuerliState = Readonly<StateData> & Readonly<{
|
|
33
|
-
api: StateApi;
|
|
34
|
-
}>;
|
|
35
|
-
export declare const createState: (set: SetState<BuerliState>, get: GetState<BuerliState>, buerliApi: BuerliStoreApi) => BuerliState;
|
|
36
|
-
declare const generalApi: (set: SetState<BuerliState>, get: GetState<BuerliState>, buerliApi: BuerliStoreApi) => {
|
|
37
|
-
/**
|
|
38
|
-
* This api method initializes state. Considering user can accidentally ommit some important like elements,
|
|
39
|
-
* there is a warning disaplying for these cases.
|
|
40
|
-
*
|
|
41
|
-
* @param options - options which will be set into state.options
|
|
42
|
-
*/
|
|
43
|
-
init(options?: Partial<BuerliOptions> | undefined): void;
|
|
44
|
-
};
|
|
45
|
-
declare const drawingManagementApi: (set: SetState<BuerliState>, get: GetState<BuerliState>, buerliApi: BuerliStoreApi) => {
|
|
46
|
-
createDrawing(name?: string | undefined): Promise<DrawingState>;
|
|
47
|
-
removeDrawing(id: DrawingID): void;
|
|
48
|
-
setActiveDrawing(id: DrawingID | null): void;
|
|
49
|
-
};
|
|
36
|
+
api: GeneralApi & DrawingManagementApi;
|
|
37
|
+
}> & Readonly<MessageState>;
|
|
38
|
+
export declare const createState: StateCreator<BuerliState, [], [], BuerliState>;
|
|
39
|
+
export declare const generalApi: StateCreator<BuerliState, [], [], GeneralApi>;
|
|
40
|
+
export declare const drawingManagementApi: StateCreator<BuerliState, [], [], DrawingManagementApi>;
|
|
50
41
|
export {};
|
|
@@ -20,7 +20,7 @@ export const createState = (set, get, buerliApi) => (Object.assign({ initDone: f
|
|
|
20
20
|
refs: {},
|
|
21
21
|
active: null,
|
|
22
22
|
}, api: Object.assign(Object.assign({}, generalApi(set, get, buerliApi)), drawingManagementApi(set, get, buerliApi)) }, getInitialMessageState(set, get, buerliApi)));
|
|
23
|
-
const generalApi =
|
|
23
|
+
export const generalApi = set => ({
|
|
24
24
|
// TODO: rename init to setOptions and remove initDone if everything is ok
|
|
25
25
|
/**
|
|
26
26
|
* This api method initializes state. Considering user can accidentally ommit some important like elements,
|
|
@@ -32,7 +32,7 @@ const generalApi = (set, get, buerliApi) => ({
|
|
|
32
32
|
set(state => ({ options: Object.assign(Object.assign({}, state.options), options), initDone: true }));
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
-
const drawingManagementApi = (set, get, buerliApi) => ({
|
|
35
|
+
export const drawingManagementApi = (set, get, buerliApi) => ({
|
|
36
36
|
async createDrawing(name) {
|
|
37
37
|
const { initDone, drawing } = get();
|
|
38
38
|
if (!initDone)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
2
|
+
import { BuerliState } from './buerli';
|
|
3
3
|
import { DrawingState } from './drawing';
|
|
4
4
|
declare type States = {
|
|
5
5
|
current: number;
|
|
@@ -22,7 +22,7 @@ export declare type CadData = {
|
|
|
22
22
|
};
|
|
23
23
|
export declare type CadApi = ReturnType<typeof cadApi>;
|
|
24
24
|
export declare const cadData: () => CadData;
|
|
25
|
-
export declare const cadApi: (set:
|
|
25
|
+
export declare const cadApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
26
26
|
setStates: (current: number, stack: string[], captionMap: Record<string, {
|
|
27
27
|
stateName: string;
|
|
28
28
|
caption: string;
|
|
@@ -33,7 +33,7 @@ export declare const cadApi: (set: SetState<DrawingState>, get: GetState<Drawing
|
|
|
33
33
|
}>) => void;
|
|
34
34
|
addPending: (name: string, options?: {
|
|
35
35
|
args?: any;
|
|
36
|
-
}
|
|
36
|
+
}) => string;
|
|
37
37
|
removePending: (id: string) => void;
|
|
38
38
|
setConnected: (connected: boolean) => void;
|
|
39
39
|
};
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @image /doc/assets/core/drawing.png
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { StoreApi } from 'zustand';
|
|
11
|
+
import { BuerliState } from './buerli';
|
|
12
12
|
import { CadApi, CadData } from './cad';
|
|
13
13
|
import { GeometryApi, GeometryData } from './geometry';
|
|
14
14
|
import { GraphicApi, GraphicData } from './graphic';
|
|
@@ -40,5 +40,5 @@ declare type StateData = {
|
|
|
40
40
|
export declare type DrawingState = Readonly<StateData> & Readonly<{
|
|
41
41
|
api: DrawingAPI;
|
|
42
42
|
}>;
|
|
43
|
-
export declare const createDrawingState: (set:
|
|
43
|
+
export declare const createDrawingState: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>, drawingNumber: number, name?: string) => DrawingState;
|
|
44
44
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import { StoreApi } from 'zustand';
|
|
3
3
|
import { ContainerGeometryT, GeometryElement } from '../../geometry/ThreeGeometryCreator';
|
|
4
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
5
4
|
import { GraphicID } from '../../types/IGraphicPackage';
|
|
6
5
|
import { ObjectID } from '../../types/IStructureTree';
|
|
6
|
+
import { BuerliState } from './buerli';
|
|
7
7
|
import { DrawingState } from './drawing';
|
|
8
8
|
export declare type GeometryBounds = {
|
|
9
9
|
center: THREE.Vector3;
|
|
@@ -43,20 +43,20 @@ export declare type GeometryData = {
|
|
|
43
43
|
};
|
|
44
44
|
export declare type GeometryApi = ReturnType<typeof geometryApi>;
|
|
45
45
|
export declare const geometryData: () => GeometryData;
|
|
46
|
-
export declare const geometryApi: (set:
|
|
46
|
+
export declare const geometryApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
47
47
|
/**
|
|
48
48
|
* Updates the @see geometry.bounds depending on all products of the model.
|
|
49
49
|
* The update will only happen, if at least one solid of one product is available.
|
|
50
50
|
*/
|
|
51
51
|
updateBounds: () => void;
|
|
52
|
-
createGeometryIfNotCached: (containerId: number, color?: number[]
|
|
52
|
+
createGeometryIfNotCached: (containerId: number, color?: number[]) => ContainerGeometryT | undefined;
|
|
53
53
|
setColor: (containerId: GraphicID, r: number, g: number, b: number) => void;
|
|
54
54
|
setOpacity: (containerId: GraphicID, opacity: number) => void;
|
|
55
55
|
setConfig: (objId: ObjectID | GraphicID, config: Partial<GeometryConfig> | null) => void;
|
|
56
56
|
findDecorated: () => GeometryElement[];
|
|
57
57
|
filter: (cb: (elem: GeometryElement) => boolean, options?: {
|
|
58
|
-
onlyOne?: boolean
|
|
59
|
-
containerId?:
|
|
60
|
-
}
|
|
58
|
+
onlyOne?: boolean;
|
|
59
|
+
containerId?: ObjectID;
|
|
60
|
+
}) => GeometryElement[];
|
|
61
61
|
};
|
|
62
62
|
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
3
2
|
import { IGraphicContainer, IGraphicElement, IGraphicPackage } from '../../types/IGraphicPackage';
|
|
4
3
|
import { ObjectID } from '../../types/IStructureTree';
|
|
4
|
+
import { BuerliState } from './buerli';
|
|
5
5
|
import { DrawingState } from './drawing';
|
|
6
6
|
export declare type GraphicData = {
|
|
7
7
|
containers: Record<number, IGraphicContainer>;
|
|
8
8
|
};
|
|
9
9
|
export declare type GraphicApi = ReturnType<typeof graphicApi>;
|
|
10
10
|
export declare const graphicData: () => GraphicData;
|
|
11
|
-
export declare const graphicApi: (set:
|
|
11
|
+
export declare const graphicApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
12
12
|
addPackages: (packages: IGraphicPackage[]) => void;
|
|
13
13
|
cleanupGraphicRecords: () => void;
|
|
14
14
|
filter: (cb: (elem: IGraphicElement) => boolean, options?: {
|
|
15
|
-
onlyOne?: boolean
|
|
16
|
-
containerId?:
|
|
17
|
-
}
|
|
15
|
+
onlyOne?: boolean;
|
|
16
|
+
containerId?: ObjectID;
|
|
17
|
+
}) => {
|
|
18
18
|
elem: IGraphicElement;
|
|
19
19
|
containerId: ObjectID;
|
|
20
20
|
solidId: ObjectID;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
3
2
|
import { InteractionInfo } from '../../types';
|
|
3
|
+
import { BuerliState } from './buerli';
|
|
4
4
|
import { DrawingState } from './drawing';
|
|
5
5
|
export declare type InteractionData = {
|
|
6
6
|
hovered?: InteractionInfo | null;
|
|
@@ -8,7 +8,7 @@ export declare type InteractionData = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare type InteractionApi = ReturnType<typeof interactionApi>;
|
|
10
10
|
export declare const interactionData: () => InteractionData;
|
|
11
|
-
export declare const interactionApi: (set:
|
|
11
|
+
export declare const interactionApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
12
12
|
/**
|
|
13
13
|
* Sets the hovered item in the store to the given item.
|
|
14
14
|
*
|
|
@@ -30,5 +30,5 @@ export declare const interactionApi: (set: SetState<DrawingState>, get: GetState
|
|
|
30
30
|
* @param item The item to select.
|
|
31
31
|
* @param multi Do multi select.
|
|
32
32
|
*/
|
|
33
|
-
select: (item: InteractionInfo, multi?: boolean
|
|
33
|
+
select: (item: InteractionInfo, multi?: boolean) => void;
|
|
34
34
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
2
2
|
import { BuerliState } from './buerli';
|
|
3
3
|
import { DrawingID } from './drawing';
|
|
4
4
|
export declare type MessageScope = string | number;
|
|
@@ -22,8 +22,8 @@ export declare type MessageState = {
|
|
|
22
22
|
api: ReturnType<typeof messageApi>;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
export declare const getInitialMessageState: (set:
|
|
26
|
-
declare const messageApi: (set:
|
|
25
|
+
export declare const getInitialMessageState: (set: StoreApi<BuerliState>['setState'], get: StoreApi<BuerliState>['getState'], api: StoreApi<BuerliState>) => MessageState;
|
|
26
|
+
declare const messageApi: (set: StoreApi<BuerliState>['setState'], get: StoreApi<BuerliState>['getState'], api: StoreApi<BuerliState>) => {
|
|
27
27
|
show(message: Message): MessageID;
|
|
28
28
|
update(id: MessageID, message: Message): void;
|
|
29
29
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
2
2
|
import { ObjectID } from '../../types';
|
|
3
|
+
import { BuerliState } from './buerli';
|
|
3
4
|
import { DrawingID, DrawingState } from './drawing';
|
|
4
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
5
5
|
export declare type PluginDescription<InternalState = any> = {
|
|
6
6
|
name: string;
|
|
7
7
|
version: string;
|
|
@@ -18,7 +18,7 @@ declare type StateData<InternalState extends Record<any, any>> = PluginDescripti
|
|
|
18
18
|
drawingId?: DrawingID;
|
|
19
19
|
objectId?: ObjectID;
|
|
20
20
|
state: InternalState;
|
|
21
|
-
set: (sel:
|
|
21
|
+
set: (sel: Partial<InternalState> | ((state: InternalState) => Partial<InternalState>)) => void;
|
|
22
22
|
};
|
|
23
23
|
export declare type Plugin = {
|
|
24
24
|
Root?: ((options?: any) => any) | null;
|
|
@@ -43,11 +43,11 @@ export declare type PluginData = {
|
|
|
43
43
|
};
|
|
44
44
|
export declare type PluginApi = ReturnType<typeof pluginApi>;
|
|
45
45
|
export declare const pluginData: () => PluginData;
|
|
46
|
-
export declare const pluginApi: (set:
|
|
46
|
+
export declare const pluginApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
47
47
|
setActiveFeature: (id: ObjectID | null) => void;
|
|
48
48
|
setVisiblePlugin: (id: PluginID, visible: boolean) => void;
|
|
49
49
|
setActiveGlobal: (id: PluginID, active: boolean) => void;
|
|
50
|
-
createPlugin: (def: PluginDef, defaultId?:
|
|
50
|
+
createPlugin: (def: PluginDef, defaultId?: ObjectID | string, drawingId?: DrawingID, objectId?: ObjectID) => (deactivate?: boolean) => void;
|
|
51
51
|
};
|
|
52
52
|
export declare function isPromisePlugin(def: PluginDef): def is Promise<Plugin>;
|
|
53
53
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
3
2
|
import { GraphicID } from '../../types/IGraphicPackage';
|
|
4
3
|
import { ObjectID } from '../../types/IStructureTree';
|
|
5
4
|
import { GeometryElement, ProductElement } from './../../geometry/ThreeGeometryCreator';
|
|
5
|
+
import { BuerliState } from './buerli';
|
|
6
6
|
import { DrawingState } from './drawing';
|
|
7
7
|
export declare const BuerliScope = "ClassCAD";
|
|
8
8
|
export declare type SelectorID = string | number;
|
|
@@ -40,23 +40,23 @@ export declare type SelectionData = {
|
|
|
40
40
|
};
|
|
41
41
|
export declare type SelectionApi = ReturnType<typeof selectionApi>;
|
|
42
42
|
export declare const selectionData: () => SelectionData;
|
|
43
|
-
export declare const selectionApi: (set:
|
|
44
|
-
unselectAll(selectorId?:
|
|
45
|
-
unselect(items: SelectedItem | SelectedItem[], selectorId?:
|
|
46
|
-
select(items: SelectedItem | SelectedItem[], selectorId?:
|
|
47
|
-
setHovered(item: SelectedItem | null, selectorId?:
|
|
43
|
+
export declare const selectionApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
44
|
+
unselectAll(selectorId?: SelectorID): void;
|
|
45
|
+
unselect(items: SelectedItem | SelectedItem[], selectorId?: SelectorID): void;
|
|
46
|
+
select(items: SelectedItem | SelectedItem[], selectorId?: SelectorID): void;
|
|
47
|
+
setHovered(item: SelectedItem | null, selectorId?: SelectorID): void;
|
|
48
48
|
activateSelector(selectorId: SelectorID | null): void;
|
|
49
|
-
createSelector(selectorId: SelectorID, filter: SelectionFilter, activate?: boolean, initialItems?: SelectedItem[], maxLen?: number, customSelect?: CustomSelect
|
|
50
|
-
areItemsSelected: (items: SelectedItem[], selectorId?:
|
|
51
|
-
isItemSelected: (item: SelectedItem, selectorId?:
|
|
49
|
+
createSelector(selectorId: SelectorID, filter: SelectionFilter, activate?: boolean, initialItems?: SelectedItem[], maxLen?: number, customSelect?: CustomSelect, customUnSelect?: CustomSelect): () => void;
|
|
50
|
+
areItemsSelected: (items: SelectedItem[], selectorId?: SelectorID) => boolean;
|
|
51
|
+
isItemSelected: (item: SelectedItem, selectorId?: SelectorID) => boolean;
|
|
52
52
|
setItems(id: SelectorID, items: SelectedItem[]): void;
|
|
53
53
|
selectGraphic: (selectorId: SelectorID, items: {
|
|
54
54
|
productId: ObjectID;
|
|
55
55
|
containerId: GraphicID;
|
|
56
56
|
graphicId?: GraphicID;
|
|
57
57
|
}[], options?: {
|
|
58
|
-
unselectExisting?: boolean
|
|
59
|
-
}
|
|
60
|
-
getGraphicItem: (productId: ObjectID, containerId: GraphicID, graphicId?:
|
|
58
|
+
unselectExisting?: boolean;
|
|
59
|
+
}) => void;
|
|
60
|
+
getGraphicItem: (productId: ObjectID, containerId: GraphicID, graphicId?: GraphicID) => SelectedItem<ProductElement> | null;
|
|
61
61
|
};
|
|
62
62
|
export declare const createGraphicItem: (productId: ObjectID, el: GeometryElement) => SelectedItem<ProductElement>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
3
|
-
import { BuerliStoreApi } from '../../store/store';
|
|
2
|
+
import { StoreApi } from 'zustand';
|
|
4
3
|
import { GraphicID, IStructureObject, IStructurePatch, IStructureProtocol, IStructureTree, ObjectID } from '../../types';
|
|
4
|
+
import { BuerliState } from './buerli';
|
|
5
5
|
import { DrawingState } from './drawing';
|
|
6
6
|
export declare type StructureData = IStructureProtocol & {
|
|
7
7
|
products: ObjectID[];
|
|
@@ -9,7 +9,7 @@ export declare type StructureData = IStructureProtocol & {
|
|
|
9
9
|
};
|
|
10
10
|
export declare type StructureApi = ReturnType<typeof structureApi>;
|
|
11
11
|
export declare const structureData: () => StructureData;
|
|
12
|
-
export declare const structureApi: (set:
|
|
12
|
+
export declare const structureApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
|
|
13
13
|
get: () => StructureData;
|
|
14
14
|
set: (structure: IStructureProtocol) => void;
|
|
15
15
|
applyPatches: (patches: IStructurePatch[]) => void;
|
|
@@ -29,7 +29,7 @@ export declare const structureApi: (set: SetState<DrawingState>, get: GetState<D
|
|
|
29
29
|
calculateProductBounds: (productId: ObjectID, base?: {
|
|
30
30
|
min: THREE.Vector3;
|
|
31
31
|
max: THREE.Vector3;
|
|
32
|
-
}
|
|
32
|
+
}) => {
|
|
33
33
|
center: THREE.Vector3;
|
|
34
34
|
radius: number;
|
|
35
35
|
max: THREE.Vector3;
|
package/build/store/store.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { StoreApi } from 'zustand/vanilla';
|
|
2
1
|
import { BuerliState } from './states/buerli';
|
|
3
|
-
declare
|
|
4
|
-
declare const api: StoreApi<BuerliState>;
|
|
5
|
-
export { api, BuerliStoreApi };
|
|
2
|
+
export declare const api: import("zustand/vanilla").StoreApi<BuerliState>;
|
package/build/store/store.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import vanillaCreate from 'zustand/vanilla';
|
|
2
2
|
import { createState } from './states/buerli';
|
|
3
|
-
const
|
|
4
|
-
const wnd = typeof window !== 'undefined' ? window : null;
|
|
5
|
-
const middleware = wnd ? wnd.BUERLI_MIDDLEWARE || (wnd.BUERLI_MIDDLEWARE = []) : [];
|
|
6
|
-
const buerliStore = middleware.reduceRight((acc, cur) => cur(acc), store);
|
|
7
|
-
const api = vanillaCreate(buerliStore);
|
|
8
|
-
export { api };
|
|
3
|
+
export const api = vanillaCreate()(createState);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
2
|
+
import { DrawingID } from '../states/drawing';
|
|
3
3
|
import { SelectedItem, SelectorID } from '../states/selection';
|
|
4
|
+
import { BuerliState } from '../states/buerli';
|
|
4
5
|
export declare const unsubs: Record<string, () => void>;
|
|
5
|
-
export declare function subscribeItems(buerliApi:
|
|
6
|
-
export declare function unsubscribeItems(buerliApi:
|
|
6
|
+
export declare function subscribeItems(buerliApi: StoreApi<BuerliState>, drawingId: DrawingID, selectorId: SelectorID, items?: SelectedItem[]): void;
|
|
7
|
+
export declare function unsubscribeItems(buerliApi: StoreApi<BuerliState>, drawingId: DrawingID, selectorId: SelectorID, items?: SelectedItem[]): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
1
2
|
import { DrawingID, DrawingState } from '../states/drawing';
|
|
2
|
-
import {
|
|
3
|
-
export declare function subscribeToDrawing(buerliApi:
|
|
3
|
+
import { BuerliState } from '../states/buerli';
|
|
4
|
+
export declare function subscribeToDrawing<T = any>(buerliApi: StoreApi<BuerliState>, drawingId: DrawingID, sel: (d: DrawingState) => T, callback: (arg: T) => void): () => void;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export function subscribeToDrawing(buerliApi, drawingId, sel, callback) {
|
|
2
|
-
const unsub = buerliApi.subscribe(
|
|
2
|
+
const unsub = buerliApi.subscribe((state, prev) => {
|
|
3
|
+
const curDrawing = state.drawing.refs[drawingId] && sel(state.drawing.refs[drawingId]);
|
|
4
|
+
const prevDrawing = prev.drawing.refs[drawingId] && sel(prev.drawing.refs[drawingId]);
|
|
5
|
+
if (curDrawing !== prevDrawing)
|
|
6
|
+
callback(curDrawing);
|
|
7
|
+
});
|
|
3
8
|
return unsub;
|
|
4
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.1",
|
|
4
4
|
"description": "buerli state management",
|
|
5
5
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"prettify": "prettier --write \"./{src,tests}/**/*.{js,jsx,ts,tsx,json}\""
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/three": "^0.
|
|
24
|
+
"@types/three": "^0.143",
|
|
25
25
|
"@babel/preset-env": "^7.10.4",
|
|
26
26
|
"@babel/preset-typescript": "^7.10.4",
|
|
27
27
|
"babel-jest": "^26.1.0",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
30
30
|
"jest": "^26.1.0",
|
|
31
31
|
"rimraf": "^2.6.3",
|
|
32
|
-
"three": "^0.
|
|
33
|
-
"typescript": "4.
|
|
32
|
+
"three": "^0.143",
|
|
33
|
+
"typescript": "4.8.4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"fast-json-patch": "^3.1.1",
|
|
37
37
|
"jsonpatch": "^3.1.0",
|
|
38
38
|
"uuid": "^3.3.2",
|
|
39
|
-
"zustand": "^
|
|
39
|
+
"zustand": "^4.1.4"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"three": ">=0.138"
|