@buerli.io/headless 1.0.1-beta.2 → 1.0.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/README.md +24 -24
- package/build/cjs/history.js +2308 -2308
- package/build/cjs/index.js +36 -36
- package/build/cjs/solid.js +479 -479
- package/build/cjs/utils/meshes.js +24 -24
- package/build/cjs/utils/selection.js +32 -32
- package/build/esm/history.js +2303 -2303
- package/build/esm/index.js +8 -8
- package/build/esm/solid.js +473 -473
- package/build/esm/utils/meshes.js +20 -20
- package/build/esm/utils/selection.js +25 -25
- package/build/types/history.d.ts +1852 -1852
- package/build/types/index.d.ts +29 -29
- package/build/types/solid.d.ts +524 -524
- package/build/types/utils/meshes.d.ts +14 -14
- package/build/types/utils/selection.d.ts +4 -4
- package/package.json +2 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get all meshes in a map, sorted by their color / opacity
|
|
3
|
-
* @param entity entity to look for the meshes
|
|
4
|
-
* @returns map (key = color/opacity as string, value = object containing the meshes, color and opacity)
|
|
5
|
-
*/
|
|
6
|
-
export const getDifferentColoredMeshesFromEntity = (entity) => {
|
|
7
|
-
const colorMeshesMap = {};
|
|
8
|
-
entity.meshes.forEach(mesh => {
|
|
9
|
-
const color = mesh.color ? mesh.color : entity.color;
|
|
10
|
-
const opacity = mesh.opacity ? mesh.opacity : entity.opacity;
|
|
11
|
-
const key = (color === null || color === void 0 ? void 0 : color.getHexString()) + (opacity === null || opacity === void 0 ? void 0 : opacity.toString());
|
|
12
|
-
if (colorMeshesMap[key]) {
|
|
13
|
-
colorMeshesMap[key].meshes.push(mesh);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
colorMeshesMap[key] = { meshes: [mesh], color, opacity };
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return colorMeshesMap;
|
|
20
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Get all meshes in a map, sorted by their color / opacity
|
|
3
|
+
* @param entity entity to look for the meshes
|
|
4
|
+
* @returns map (key = color/opacity as string, value = object containing the meshes, color and opacity)
|
|
5
|
+
*/
|
|
6
|
+
export const getDifferentColoredMeshesFromEntity = (entity) => {
|
|
7
|
+
const colorMeshesMap = {};
|
|
8
|
+
entity.meshes.forEach(mesh => {
|
|
9
|
+
const color = mesh.color ? mesh.color : entity.color;
|
|
10
|
+
const opacity = mesh.opacity ? mesh.opacity : entity.opacity;
|
|
11
|
+
const key = (color === null || color === void 0 ? void 0 : color.getHexString()) + (opacity === null || opacity === void 0 ? void 0 : opacity.toString());
|
|
12
|
+
if (colorMeshesMap[key]) {
|
|
13
|
+
colorMeshesMap[key].meshes.push(mesh);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
colorMeshesMap[key] = { meshes: [mesh], color, opacity };
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return colorMeshesMap;
|
|
20
|
+
};
|
|
@@ -1,25 +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
|
-
}
|
|
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
|
+
}
|