@buerli.io/core 0.4.1 → 0.5.0-beta.2

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 (86) hide show
  1. package/build/cjs/geometry/ThreeGeometryCreator.js +321 -0
  2. package/build/cjs/geometry/index.js +17 -0
  3. package/build/cjs/graphic/filters.js +25 -0
  4. package/build/cjs/index.js +25 -0
  5. package/build/cjs/store/index.js +37 -0
  6. package/build/cjs/store/states/buerli.js +98 -0
  7. package/build/cjs/store/states/cad.js +35 -0
  8. package/build/cjs/store/states/drawing.js +47 -0
  9. package/build/cjs/store/states/geometry.js +139 -0
  10. package/build/cjs/store/states/graphic.js +115 -0
  11. package/build/cjs/store/states/interaction.js +55 -0
  12. package/build/cjs/store/states/message.js +25 -0
  13. package/build/cjs/store/states/plugin.js +115 -0
  14. package/build/cjs/store/states/selection.js +258 -0
  15. package/build/cjs/store/states/structure.js +239 -0
  16. package/build/cjs/store/store.js +9 -0
  17. package/build/cjs/store/subscribtion/selection.js +46 -0
  18. package/build/cjs/store/subscribtion/subscribeToDrawing.js +13 -0
  19. package/build/cjs/types/IGraphicPackage.js +49 -0
  20. package/build/cjs/types/IStructurePatch.js +2 -0
  21. package/build/cjs/types/IStructureTree.js +27 -0
  22. package/build/cjs/types/InteractionInfo.js +11 -0
  23. package/build/cjs/types/index.js +20 -0
  24. package/build/cjs/utils/Math.js +91 -0
  25. package/build/cjs/utils/Measure.js +560 -0
  26. package/build/cjs/utils/Timing.js +34 -0
  27. package/build/{geometry → esm/geometry}/ThreeGeometryCreator.js +0 -0
  28. package/build/{geometry → esm/geometry}/index.js +0 -0
  29. package/build/{graphic → esm/graphic}/filters.js +0 -0
  30. package/build/{index.js → esm/index.js} +0 -0
  31. package/build/{store → esm/store}/index.js +0 -0
  32. package/build/{store → esm/store}/states/buerli.js +2 -2
  33. package/build/{store → esm/store}/states/cad.js +0 -0
  34. package/build/{store → esm/store}/states/drawing.js +0 -0
  35. package/build/{store → esm/store}/states/geometry.js +0 -0
  36. package/build/{store → esm/store}/states/graphic.js +0 -0
  37. package/build/{store → esm/store}/states/interaction.js +0 -0
  38. package/build/{store → esm/store}/states/message.js +0 -0
  39. package/build/{store → esm/store}/states/plugin.js +0 -0
  40. package/build/{store → esm/store}/states/selection.js +0 -0
  41. package/build/{store → esm/store}/states/structure.js +0 -0
  42. package/build/esm/store/store.js +3 -0
  43. package/build/{store → esm/store}/subscribtion/selection.js +0 -0
  44. package/build/esm/store/subscribtion/subscribeToDrawing.js +9 -0
  45. package/build/{types → esm/types}/IGraphicPackage.js +0 -0
  46. package/build/{types → esm/types}/IStructurePatch.js +0 -0
  47. package/build/{types → esm/types}/IStructureTree.js +0 -0
  48. package/build/{types → esm/types}/InteractionInfo.js +0 -0
  49. package/build/{types → esm/types}/index.js +0 -0
  50. package/build/{utils → esm/utils}/Math.js +0 -0
  51. package/build/{utils → esm/utils}/Measure.js +0 -0
  52. package/build/{utils → esm/utils}/Timing.js +0 -0
  53. package/build/{geometry → types/geometry}/ThreeGeometryCreator.d.ts +0 -0
  54. package/build/{geometry → types/geometry}/index.d.ts +0 -0
  55. package/build/{graphic → types/graphic}/filters.d.ts +0 -0
  56. package/build/types/index.d.ts +37 -4
  57. package/build/{store → types/store}/index.d.ts +2 -2
  58. package/build/types/store/states/buerli.d.ts +41 -0
  59. package/build/{store → types/store}/states/cad.d.ts +4 -4
  60. package/build/{store → types/store}/states/drawing.d.ts +3 -3
  61. package/build/{store → types/store}/states/geometry.d.ts +7 -7
  62. package/build/{store → types/store}/states/graphic.d.ts +6 -6
  63. package/build/{store → types/store}/states/interaction.d.ts +4 -4
  64. package/build/{store → types/store}/states/message.d.ts +3 -3
  65. package/build/{store → types/store}/states/plugin.d.ts +5 -5
  66. package/build/{store → types/store}/states/selection.d.ts +13 -13
  67. package/build/{store → types/store}/states/structure.d.ts +4 -4
  68. package/build/types/store/store.d.ts +2 -0
  69. package/build/types/store/subscribtion/selection.d.ts +7 -0
  70. package/build/types/store/subscribtion/subscribeToDrawing.d.ts +4 -0
  71. package/build/types/{IGraphicPackage.d.ts → types/IGraphicPackage.d.ts} +0 -0
  72. package/build/types/{IStructurePatch.d.ts → types/IStructurePatch.d.ts} +0 -0
  73. package/build/types/{IStructureTree.d.ts → types/IStructureTree.d.ts} +0 -0
  74. package/build/types/{InteractionInfo.d.ts → types/InteractionInfo.d.ts} +0 -0
  75. package/build/types/types/index.d.ts +4 -0
  76. package/build/{utils → types/utils}/Math.d.ts +0 -0
  77. package/build/{utils → types/utils}/Measure.d.ts +0 -0
  78. package/build/{utils → types/utils}/Timing.d.ts +0 -0
  79. package/package.json +11 -11
  80. package/build/index.d.ts +0 -38
  81. package/build/store/states/buerli.d.ts +0 -50
  82. package/build/store/store.d.ts +0 -5
  83. package/build/store/store.js +0 -8
  84. package/build/store/subscribtion/selection.d.ts +0 -6
  85. package/build/store/subscribtion/subscribeToDrawing.d.ts +0 -3
  86. package/build/store/subscribtion/subscribeToDrawing.js +0 -4
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Timing = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const cache = {};
6
+ const start = (key = (0, uuid_1.v4)()) => {
7
+ cache[key] = { startTime: performance.now(), previousTime: performance.now() };
8
+ return key;
9
+ };
10
+ const measure = (key, mode = 'fromStart') => {
11
+ if (!cache[key])
12
+ return Number.NaN;
13
+ const curr = performance.now();
14
+ const prev = mode === 'fromPrevious' ? cache[key].previousTime : cache[key].startTime;
15
+ cache[key] = Object.assign(Object.assign({}, cache[key]), { previousTime: curr });
16
+ return curr - prev;
17
+ };
18
+ const stop = (key) => {
19
+ if (!cache[key])
20
+ return Number.NaN;
21
+ const curr = performance.now();
22
+ const prev = cache[key].startTime;
23
+ delete cache[key];
24
+ return curr - prev;
25
+ };
26
+ const dump = (key, message = '', mode = 'fromStart') => {
27
+ console.info(`${message ? message : key + ':'} ${measure(key, mode).toFixed(2)}ms`);
28
+ };
29
+ exports.Timing = {
30
+ start,
31
+ stop,
32
+ measure,
33
+ dump,
34
+ };
File without changes
File without changes
File without changes
File without changes
@@ -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 = (set, get, buerliApi) => ({
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)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ import vanillaCreate from 'zustand/vanilla';
2
+ import { createState } from './states/buerli';
3
+ export const api = vanillaCreate()(createState);
@@ -0,0 +1,9 @@
1
+ export function subscribeToDrawing(buerliApi, drawingId, sel, callback) {
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
+ });
8
+ return unsub;
9
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,37 @@
1
- export * from './IGraphicPackage';
2
- export * from './InteractionInfo';
3
- export * from './IStructurePatch';
4
- export * from './IStructureTree';
1
+ export * from './store';
2
+ export * from './geometry';
3
+ export * from './types';
4
+ export * from './utils/Math';
5
+ export * from './utils/Measure';
6
+ export * from './utils/Timing';
7
+ export * from './store/subscribtion/subscribeToDrawing';
8
+ export * from './graphic/filters';
9
+ /**
10
+ * Because babel typescript tools can not handle the type definitions
11
+ * in an other way, they have to be re-exported as you can see in this code region.
12
+ *
13
+ * Please have a look at https://github.com/awv-informatik/buerli/pull/129 for more information.
14
+ */
15
+ import { BuerliState as BS } from './store/states/buerli';
16
+ export declare type BuerliState = BS;
17
+ import { DrawingAPI as DrawingAPI1, DrawingID as DrawingID1, DrawingState as DrawingState1 } from './store/states/drawing';
18
+ export declare type DrawingID = DrawingID1;
19
+ export declare type DrawingState = DrawingState1;
20
+ export declare type DrawingAPI = DrawingAPI1;
21
+ import { GeometryConfig as GeometryConfig1, GeometryBounds as GeometryBounds1 } from './store/states/geometry';
22
+ export declare type GeometryConfig = GeometryConfig1;
23
+ export declare type GeometryBounds = GeometryBounds1;
24
+ import { Plugin as Plugin1, PluginDescription as PluginDescription1, PluginID as PluginID1, PluginState as PluginState1 } from './store/states/plugin';
25
+ export declare type Plugin = Plugin1;
26
+ export declare type PluginDescription<InternalState = any> = PluginDescription1<InternalState>;
27
+ export declare type PluginID = PluginID1;
28
+ export declare type PluginState<InternalState extends Record<any, any> = any> = PluginState1<InternalState>;
29
+ import { SeletedItemData, SelectedItem as SelectedItem1, SelectionFilter as SelectionFilter1, SelectionScope as SelectionScope1, Selector as Selector1, SelectorID as SelectorID1, CustomSelect as CustomSelect1 } from './store/states/selection';
30
+ export declare type SelectedItem<T extends SeletedItemData<any> = any> = SelectedItem1<T>;
31
+ export declare type SelectionFilter = SelectionFilter1;
32
+ export declare type SelectionScope = SelectionScope1;
33
+ export declare type Selector<T extends SeletedItemData<any> = any> = Selector1<T>;
34
+ export declare type SelectorID = SelectorID1;
35
+ export declare type CustomSelect = CustomSelect1;
36
+ import { Message as Message1 } from './store/states/message';
37
+ export declare type Message = Message1;
@@ -1,4 +1,4 @@
1
- import { BuerliOptions } from './states/buerli';
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<BuerliOptions>): void;
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';
@@ -0,0 +1,41 @@
1
+ import { StateCreator } from 'zustand';
2
+ import { DrawingID, DrawingState } from './drawing';
3
+ import { GeometryConfig } from './geometry';
4
+ import { MessageState } from './message';
5
+ import { PluginDef, PluginImpl } from './plugin';
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<{
15
+ initDone: boolean;
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
+ };
31
+ drawing: {
32
+ ids: DrawingID[];
33
+ refs: Record<DrawingID, DrawingState>;
34
+ active: DrawingID | null;
35
+ };
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>;
41
+ export {};
@@ -1,5 +1,5 @@
1
- import { GetState, SetState } from 'zustand';
2
- import { BuerliStoreApi } from '../../store/store';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
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
- } | undefined) => string;
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 { GetState, SetState } from 'zustand';
11
- import { BuerliStoreApi } from '../../store/store';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi, drawingNumber: number, name?: string) => DrawingState;
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 { GetState, SetState } from 'zustand';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
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[] | undefined) => ContainerGeometryT | undefined;
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 | undefined;
59
- containerId?: number | undefined;
60
- } | undefined) => GeometryElement[];
58
+ onlyOne?: boolean;
59
+ containerId?: ObjectID;
60
+ }) => GeometryElement[];
61
61
  };
62
62
  export {};
@@ -1,20 +1,20 @@
1
- import { GetState, SetState } from 'zustand';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
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 | undefined;
16
- containerId?: number | undefined;
17
- } | undefined) => {
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 { GetState, SetState } from 'zustand';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
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 | undefined) => void;
33
+ select: (item: InteractionInfo, multi?: boolean) => void;
34
34
  };
@@ -1,4 +1,4 @@
1
- import { GetState, SetState } from 'zustand';
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: SetState<BuerliState>, get: GetState<BuerliState>, api: any) => MessageState;
26
- declare const messageApi: (set: SetState<BuerliState>, get: GetState<BuerliState>, api: any) => {
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 { GetState, PartialState, SetState } from 'zustand';
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: PartialState<InternalState>) => void;
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
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?: string | number | undefined, drawingId?: string | number | undefined, objectId?: number | undefined) => (deactivate?: boolean) => void;
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 { GetState, SetState } from 'zustand';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
44
- unselectAll(selectorId?: string | number | undefined): void;
45
- unselect(items: SelectedItem | SelectedItem[], selectorId?: string | number | undefined): void;
46
- select(items: SelectedItem | SelectedItem[], selectorId?: string | number | undefined): void;
47
- setHovered(item: SelectedItem | null, selectorId?: string | number | undefined): void;
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 | undefined, customUnSelect?: CustomSelect | undefined): () => void;
50
- areItemsSelected: (items: SelectedItem[], selectorId?: string | number | undefined) => boolean;
51
- isItemSelected: (item: SelectedItem, selectorId?: string | number | undefined) => boolean;
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 | undefined;
59
- } | undefined) => void;
60
- getGraphicItem: (productId: ObjectID, containerId: GraphicID, graphicId?: number | undefined) => SelectedItem<ProductElement> | null;
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 { GetState, SetState } from 'zustand';
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: SetState<DrawingState>, get: GetState<DrawingState>, buerliApi: BuerliStoreApi) => {
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
- } | undefined) => {
32
+ }) => {
33
33
  center: THREE.Vector3;
34
34
  radius: number;
35
35
  max: THREE.Vector3;
@@ -0,0 +1,2 @@
1
+ import { BuerliState } from './states/buerli';
2
+ export declare const api: import("zustand/vanilla").StoreApi<BuerliState>;
@@ -0,0 +1,7 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { DrawingID } from '../states/drawing';
3
+ import { SelectedItem, SelectorID } from '../states/selection';
4
+ import { BuerliState } from '../states/buerli';
5
+ export declare const unsubs: Record<string, () => void>;
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;
@@ -0,0 +1,4 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { DrawingID, DrawingState } from '../states/drawing';
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;
@@ -0,0 +1,4 @@
1
+ export * from './IGraphicPackage';
2
+ export * from './InteractionInfo';
3
+ export * from './IStructurePatch';
4
+ export * from './IStructureTree';
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "@buerli.io/core",
3
- "version": "0.4.1",
3
+ "version": "0.5.0-beta.2",
4
4
  "description": "buerli state management",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "license": "ISC",
7
7
  "repository": {},
8
- "main": "build/index.js",
9
- "module": "build/index.js",
10
- "types": "build/index.d.ts",
8
+ "main": "build/cjs/index.js",
9
+ "module": "build/esm/index.js",
10
+ "types": "build/types/index.d.ts",
11
11
  "sideEffects": false,
12
12
  "scripts": {
13
13
  "ver": "npm version",
14
- "prepack": "npm run clean && npm run build",
15
- "clean": "rimraf ./build && rimraf ./coverage && rimraf ./tsconfig.tsbuildinfo",
14
+ "prepack": "npm run clean && npm run build -- --sourceMap false && npm run build:cjs -- --sourceMap false",
15
+ "clean": "rimraf ./build* && rimraf ./coverage && rimraf tsconfig.tsbuildinfo",
16
16
  "build": "tsc -v && tsc",
17
- "build:dev": "tsc --sourceMap true --declarationMap true",
17
+ "build:cjs": "tsc --target es2017 --module commonjs --composite false --declaration false --declarationDir null --outDir ./build/cjs",
18
18
  "lint": "eslint \"./src/**/*.ts?(x)\"",
19
19
  "test": "jest",
20
20
  "coverage": "npm run clean && npm run build && npm run jestLite -- --coverage",
21
21
  "prettify": "prettier --write \"./{src,tests}/**/*.{js,jsx,ts,tsx,json}\""
22
22
  },
23
23
  "devDependencies": {
24
- "@types/three": "^0.137",
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.138",
33
- "typescript": "4.1.2"
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": "^3.5.7"
39
+ "zustand": "^4.1.4"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "three": ">=0.138"