@buerli.io/headless 1.0.1 → 1.1.0-beta.8

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.
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDifferentColoredMeshesFromEntity = void 0;
4
- /**
5
- * Get all meshes in a map, sorted by their color / opacity
6
- * @param entity entity to look for the meshes
7
- * @returns map (key = color/opacity as string, value = object containing the meshes, color and opacity)
8
- */
9
- const getDifferentColoredMeshesFromEntity = (entity) => {
10
- const colorMeshesMap = {};
11
- entity.meshes.forEach(mesh => {
12
- const color = mesh.color ? mesh.color : entity.color;
13
- const opacity = mesh.opacity ? mesh.opacity : entity.opacity;
14
- const key = (color === null || color === void 0 ? void 0 : color.getHexString()) + (opacity === null || opacity === void 0 ? void 0 : opacity.toString());
15
- if (colorMeshesMap[key]) {
16
- colorMeshesMap[key].meshes.push(mesh);
17
- }
18
- else {
19
- colorMeshesMap[key] = { meshes: [mesh], color, opacity };
20
- }
21
- });
22
- return colorMeshesMap;
23
- };
24
- exports.getDifferentColoredMeshesFromEntity = getDifferentColoredMeshesFromEntity;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDifferentColoredMeshesFromEntity = void 0;
4
+ /**
5
+ * Get all meshes in a map, sorted by their color / opacity
6
+ * @param entity entity to look for the meshes
7
+ * @returns map (key = color/opacity as string, value = object containing the meshes, color and opacity)
8
+ */
9
+ const getDifferentColoredMeshesFromEntity = (entity) => {
10
+ const colorMeshesMap = {};
11
+ entity.meshes.forEach(mesh => {
12
+ const color = mesh.color ? mesh.color : entity.color;
13
+ const opacity = mesh.opacity ? mesh.opacity : entity.opacity;
14
+ const key = (color === null || color === void 0 ? void 0 : color.getHexString()) + (opacity === null || opacity === void 0 ? void 0 : opacity.toString());
15
+ if (colorMeshesMap[key]) {
16
+ colorMeshesMap[key].meshes.push(mesh);
17
+ }
18
+ else {
19
+ colorMeshesMap[key] = { meshes: [mesh], color, opacity };
20
+ }
21
+ });
22
+ return colorMeshesMap;
23
+ };
24
+ exports.getDifferentColoredMeshesFromEntity = getDifferentColoredMeshesFromEntity;
@@ -1,32 +1,32 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.waitForSelect = void 0;
7
- const core_1 = require("@buerli.io/core");
8
- const uuid_1 = require("uuid");
9
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
- // @ts-ignore
11
- const flat_promise_1 = __importDefault(require("flat-promise"));
12
- async function waitForSelect(length, filter, onChange) {
13
- const id = (0, uuid_1.v4)();
14
- const activeDrawingId = core_1.api.getState().drawing.active;
15
- const selApi = activeDrawingId && (0, core_1.getDrawing)(activeDrawingId).api.selection;
16
- // Set up selection API
17
- const { promise, resolve } = (0, flat_promise_1.default)();
18
- const change = (selId, items, diff) => {
19
- selApi && selApi.setItems(selId, items);
20
- if (onChange)
21
- onChange(resolve, items, diff);
22
- };
23
- const unsub = selApi && selApi.createSelector(id, filter, false, [], length, change, change);
24
- // Wait for user interaction
25
- selApi && selApi.activateSelector(id);
26
- const result = await promise;
27
- // Unsubscribe from all selections
28
- unsub && unsub();
29
- selApi && selApi.activateSelector(null);
30
- return result;
31
- }
32
- exports.waitForSelect = waitForSelect;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.waitForSelect = void 0;
7
+ const core_1 = require("@buerli.io/core");
8
+ const uuid_1 = require("uuid");
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @ts-ignore
11
+ const flat_promise_1 = __importDefault(require("flat-promise"));
12
+ async function waitForSelect(length, filter, onChange) {
13
+ const id = (0, uuid_1.v4)();
14
+ const activeDrawingId = core_1.api.getState().drawing.active;
15
+ const selApi = activeDrawingId && (0, core_1.getDrawing)(activeDrawingId).api.selection;
16
+ // Set up selection API
17
+ const { promise, resolve } = (0, flat_promise_1.default)();
18
+ const change = (selId, items, diff) => {
19
+ selApi && selApi.setItems(selId, items);
20
+ if (onChange)
21
+ onChange(resolve, items, diff);
22
+ };
23
+ const unsub = selApi && selApi.createSelector(id, filter, false, [], length, change, change);
24
+ // Wait for user interaction
25
+ selApi && selApi.activateSelector(id);
26
+ const result = await promise;
27
+ // Unsubscribe from all selections
28
+ unsub && unsub();
29
+ selApi && selApi.activateSelector(null);
30
+ return result;
31
+ }
32
+ exports.waitForSelect = waitForSelect;