@buerli.io/headless 0.2.1 → 0.3.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/build/history.d.ts +217 -77
- package/build/history.js +445 -351
- package/build/index.d.ts +1 -2
- package/build/solid.js +3 -1
- package/build/utils/selection.d.ts +4 -0
- package/build/utils/selection.js +25 -0
- package/package.json +3 -2
package/build/index.d.ts
CHANGED
|
@@ -7,12 +7,11 @@ export { solid, history, createPolyline };
|
|
|
7
7
|
*
|
|
8
8
|
* Please have a look at https://github.com/awv-informatik/buerli/pull/129 for more information.
|
|
9
9
|
*/
|
|
10
|
-
import { ApiHistory as ApiHistory1, ConstraintType as ConstraintType1, Transform as Transform1, DimensionType as DimensionType1
|
|
10
|
+
import { ApiHistory as ApiHistory1, ConstraintType as ConstraintType1, Transform as Transform1, DimensionType as DimensionType1 } from './history';
|
|
11
11
|
export declare type ApiHistory = ApiHistory1;
|
|
12
12
|
export declare type ConstraintType = ConstraintType1;
|
|
13
13
|
export declare type Transform = Transform1;
|
|
14
14
|
export declare type DimensionType = DimensionType1;
|
|
15
|
-
export declare type OrientationTypes = OrientationTypes1;
|
|
16
15
|
import { ApiNoHistory as ApiNoHistory1, FilletPoint as FilletPoint1, Polyline as Polyline1 } from './solid';
|
|
17
16
|
export declare type ApiNoHistory = ApiNoHistory1;
|
|
18
17
|
export declare type Polyline = Polyline1;
|
package/build/solid.js
CHANGED
|
@@ -182,7 +182,9 @@ export default class CAD {
|
|
|
182
182
|
this.queue = Promise.resolve(0);
|
|
183
183
|
}
|
|
184
184
|
resolve(callback, ...args) {
|
|
185
|
-
return (this.queue = this.queue.then(() => Promise.all(args).then(callback))
|
|
185
|
+
return (this.queue = this.queue.then(() => Promise.all(args).then(callback)).catch(e => {
|
|
186
|
+
// catch is necessary to avoid error promises in the queue
|
|
187
|
+
}));
|
|
186
188
|
}
|
|
187
189
|
init(callback) {
|
|
188
190
|
const promise = new Promise(async (resolve, reject) => {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SelectedItem } from '@buerli.io/core';
|
|
2
|
+
declare type CustomSelect<T> = (resolve: (result: T) => Promise<T>, newItems: SelectedItem[], diff: SelectedItem[]) => void;
|
|
3
|
+
export declare function waitForSelect<T>(length: number, filter: any, onChange: CustomSelect<T>): Promise<number[]>;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { api, getDrawing } from '@buerli.io/core';
|
|
2
|
+
import { v4 } from 'uuid';
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import createPromise from 'flat-promise';
|
|
6
|
+
export async function waitForSelect(length, filter, onChange) {
|
|
7
|
+
const id = v4();
|
|
8
|
+
const activeDrawingId = api.getState().drawing.active;
|
|
9
|
+
const selApi = activeDrawingId && getDrawing(activeDrawingId).api.selection;
|
|
10
|
+
// Set up selection API
|
|
11
|
+
const { promise, resolve } = createPromise();
|
|
12
|
+
const change = (selId, items, diff) => {
|
|
13
|
+
selApi && selApi.setItems(selId, items);
|
|
14
|
+
if (onChange)
|
|
15
|
+
onChange(resolve, items, diff);
|
|
16
|
+
};
|
|
17
|
+
const unsub = selApi && selApi.createSelector(id, filter, false, [], length, change, change);
|
|
18
|
+
// Wait for user interaction
|
|
19
|
+
selApi && selApi.activateSelector(id);
|
|
20
|
+
const result = await promise;
|
|
21
|
+
// Unsubscribe from all selections
|
|
22
|
+
unsub && unsub();
|
|
23
|
+
selApi && selApi.activateSelector(null);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/headless",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A non-manifold CAD workflow for the web",
|
|
5
5
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"three": ">=0.138"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@buerli.io/classcad": "0.
|
|
32
|
+
"@buerli.io/classcad": "0.3.0",
|
|
33
|
+
"flat-promise": "^1.0.3"
|
|
33
34
|
}
|
|
34
35
|
}
|