@thatopen/components 2.2.0-alpha.1 → 2.2.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.
@@ -1,10 +1,11 @@
1
+ import { XMLParser } from "fast-xml-parser";
1
2
  import { Component, Configurable, Disposable, Event, World, DataMap } from "../../core/Types";
2
3
  import { BCFTopic, BCFTopicsConfig, Topic } from "./src";
3
4
  import { Viewpoint } from "../../core/Viewpoints";
4
5
  export declare class BCFTopics extends Component implements Disposable, Configurable<BCFTopicsConfig> {
5
6
  static uuid: "de977976-e4f6-4e4f-a01a-204727839802";
6
7
  enabled: boolean;
7
- private _xmlParser;
8
+ static xmlParser: XMLParser;
8
9
  config: Required<BCFTopicsConfig>;
9
10
  readonly list: DataMap<string, Topic>;
10
11
  readonly onSetup: Event<unknown>;
@@ -20,6 +21,13 @@ export declare class BCFTopics extends Component implements Disposable, Configur
20
21
  */
21
22
  create(data?: Partial<BCFTopic>): Topic;
22
23
  readonly onDisposed: Event<unknown>;
24
+ /**
25
+ * Disposes of the BCFTopics component and triggers the onDisposed event.
26
+ *
27
+ * @remarks
28
+ * This method clears the list of topics and triggers the onDisposed event.
29
+ * It also resets the onDisposed event listener.
30
+ */
23
31
  dispose(): void;
24
32
  /**
25
33
  * Retrieves the unique set of topic types used across all topics.
@@ -84,7 +92,17 @@ export declare class BCFTopics extends Component implements Disposable, Configur
84
92
  private getMarkupLabels;
85
93
  private getMarkupViewpoints;
86
94
  private getMarkupRelatedTopics;
87
- load(world: World, data: Uint8Array): Promise<{
95
+ /**
96
+ * Loads BCF (Building Collaboration Format) data into the engine.
97
+ *
98
+ * @param world - The default world where the viewpoints are going to be created.
99
+ * @param data - The BCF data to load.
100
+ *
101
+ * @returns A promise that resolves to an object containing the created viewpoints and topics.
102
+ *
103
+ * @throws An error if the BCF version is not supported.
104
+ */
105
+ load(data: Uint8Array, world: World): Promise<{
88
106
  viewpoints: Viewpoint[];
89
107
  topics: Topic[];
90
108
  }>;
@@ -31,5 +31,10 @@ export declare class Comment {
31
31
  * @param text - The initial comment text.
32
32
  */
33
33
  constructor(components: Components, text: string);
34
+ /**
35
+ * Serializes the Comment instance into a BCF compliant XML string.
36
+ *
37
+ * @returns A string representing the Comment in BCFv2 XML format.
38
+ */
34
39
  serialize(): string;
35
40
  }
@@ -13,12 +13,6 @@ export declare class Topic implements BCFTopic {
13
13
  *
14
14
  * @remarks
15
15
  * The `guid` is automatically generated upon topic creation and by no means it should change.
16
- *
17
- * @example
18
- * ```typescript
19
- * const topic = new Topic(components);
20
- * console.log(topic.guid); // Output: "123e4567-e89b-12d3-a456-426614174000"
21
- * ```
22
16
  */
23
17
  guid: string;
24
18
  title: string;
@@ -0,0 +1,2 @@
1
+ import { BCFTopics } from "../..";
2
+ export declare const extensionsImporter: (manager: BCFTopics, extensionsXML: string) => void;
@@ -0,0 +1 @@
1
+ export * from "./extensions";
@@ -1,7 +1,4 @@
1
1
  export * from "./Topic";
2
2
  export * from "./types";
3
3
  export * from "./Comment";
4
- export * from "./TopicForm";
5
- export * from "./TopicPanel";
6
- export * from "./TopicsList";
7
- export * from "./ViewpointsList";
4
+ export * from "./importers";
@@ -17,19 +17,75 @@ export interface BCFTopic {
17
17
  description?: string;
18
18
  stage?: string;
19
19
  }
20
+ /**
21
+ * Configuration settings for managing BCF topics.
22
+ * This interface defines the properties and their meanings used to control the behavior of exporting and importing BCF topics.
23
+ */
20
24
  export interface BCFTopicsConfig {
25
+ /**
26
+ * The BCF version used during export.
27
+ */
21
28
  version: BCFVersion;
29
+ /**
30
+ * The email of the user creating topics using this component.
31
+ */
22
32
  author: string;
33
+ /**
34
+ * The set of allowed topic types. This is exported inside the
35
+ * [bcf.extensions](https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#bcf-file-structure).
36
+ */
23
37
  types: Set<string>;
38
+ /**
39
+ * The set of allowed topic statuses. This is exported inside the
40
+ * [bcf.extensions](https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#bcf-file-structure).
41
+ */
24
42
  statuses: Set<string>;
43
+ /**
44
+ * The set of allowed topic priorities. This is exported inside the
45
+ * [bcf.extensions](https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#bcf-file-structure).
46
+ */
25
47
  priorities: Set<string>;
48
+ /**
49
+ * The set of allowed topic labels. This is exported inside the
50
+ * [bcf.extensions](https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#bcf-file-structure).
51
+ */
26
52
  labels: Set<string>;
53
+ /**
54
+ * The set of allowed topic stages. This is exported inside the
55
+ * [bcf.extensions](https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#bcf-file-structure).
56
+ */
27
57
  stages: Set<string>;
58
+ /**
59
+ * The set of allowed topic users. This is exported inside the
60
+ * [bcf.extensions](https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#bcf-file-structure).
61
+ */
28
62
  users: Set<string>;
63
+ /**
64
+ * Whether or not to include the AuthoringSoftwareId in the viewpoint components during export.
65
+ */
29
66
  includeSelectionTag: boolean;
67
+ /**
68
+ * Updates the types, statuses, users, etc., after importing an external BCF.
69
+ */
30
70
  updateExtensionsOnImport: boolean;
71
+ /**
72
+ * Only allow to use the extensions (types, statuses, etc.) defined in the config when setting the corresponding data in a topic.
73
+ */
31
74
  strict: boolean;
75
+ /**
76
+ * If true, export the extensions (types, status, etc.) based on topics data. This doesn't update the extensions in the config.
77
+ * If false, only export the extensions defined in each collection of possibilities set in the config.
78
+ * In all cases, all the values from each collection of extensions defined in the config are going to be exported.
79
+ */
32
80
  includeAllExtensionsOnExport: boolean;
81
+ /**
82
+ * Version to be used when importing if no bcf.version file is present in the incoming data.
83
+ * When null, the importer will throw an error if the version is missing or is not supported.
84
+ */
33
85
  fallbackVersionOnImport: BCFVersion | null;
86
+ /**
87
+ * If true, do not import a topic with missing information (guid, type, status, title, creationDate or creationAuthor).
88
+ * If false, use default values for missing data.
89
+ */
34
90
  ignoreIncompleteTopicsOnImport: boolean;
35
91
  }
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
- {
2
- "name": "@thatopen/components",
3
- "description": "Collection of core functionalities to author BIM apps.",
4
- "version": "2.2.0-alpha.1",
5
- "author": "That Open Company",
6
- "contributors": [
7
- "Antonio Gonzalez Viegas (https://github.com/agviegas)",
8
- "Juan Hoyos (https://github.com/HoyosJuan)",
9
- "Harry Collin (https://github.com/harrycollin)"
10
- ],
11
- "license": "MIT",
12
- "homepage": "https://github.com/ThatOpen/engine_components/tree/main/packages/components#readme",
13
- "bugs": {
14
- "url": "https://github.com/ThatOpen/engine_components/issues"
15
- },
16
- "type": "module",
17
- "main": "dist/index.cjs",
18
- "module": "dist/index.mjs",
19
- "types": "dist/index.d.ts",
20
- "files": [
21
- "dist"
22
- ],
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/ThatOpen/engine_components/tree/main/packages/components.git"
26
- },
27
- "packageManager": "yarn@3.2.1",
28
- "scripts": {
29
- "dev": "vite --host",
30
- "test": "jest",
31
- "build": "tsc --p ./tsconfig-build.json && vite build",
32
- "prepublishOnly": "node ./resources/updateComponentsVersion.mjs && yarn build",
33
- "publish-repo": "npm publish",
34
- "publish-alpha": "npm publish --tag alpha"
35
- },
36
- "publishConfig": {
37
- "access": "public"
38
- },
39
- "devDependencies": {
40
- "@thatopen/fragments": "~2.1.0",
41
- "@thatopen/ui": "~2.1.0",
42
- "@types/three": "0.160.0",
43
- "stats.js": "^0.17.0",
44
- "three": "^0.160.1",
45
- "web-ifc": "0.0.57"
46
- },
47
- "dependencies": {
48
- "camera-controls": "2.7.3",
49
- "fast-xml-parser": "latest",
50
- "jszip": "latest",
51
- "three-mesh-bvh": "0.7.0"
52
- },
53
- "peerDependencies": {
54
- "@thatopen/fragments": "~2.1.0",
55
- "three": "^0.160.1",
56
- "web-ifc": "0.0.57"
57
- }
58
- }
1
+ {
2
+ "name": "@thatopen/components",
3
+ "description": "Collection of core functionalities to author BIM apps.",
4
+ "version": "2.2.0",
5
+ "author": "That Open Company",
6
+ "contributors": [
7
+ "Antonio Gonzalez Viegas (https://github.com/agviegas)",
8
+ "Juan Hoyos (https://github.com/HoyosJuan)",
9
+ "Harry Collin (https://github.com/harrycollin)"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://github.com/ThatOpen/engine_components/tree/main/packages/components#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/ThatOpen/engine_components/issues"
15
+ },
16
+ "type": "module",
17
+ "main": "dist/index.cjs",
18
+ "module": "dist/index.mjs",
19
+ "types": "dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/ThatOpen/engine_components/tree/main/packages/components.git"
26
+ },
27
+ "packageManager": "yarn@3.2.1",
28
+ "scripts": {
29
+ "dev": "vite --host",
30
+ "test": "jest",
31
+ "build": "tsc --p ./tsconfig-build.json && vite build",
32
+ "prepublishOnly": "node ./resources/updateComponentsVersion.mjs && yarn build",
33
+ "publish-repo": "npm publish",
34
+ "publish-alpha": "npm publish --tag alpha"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "devDependencies": {
40
+ "@thatopen/fragments": "~2.2.0",
41
+ "@thatopen/ui": "~2.1.0",
42
+ "@types/three": "0.160.0",
43
+ "stats.js": "^0.17.0",
44
+ "three": "^0.160.1",
45
+ "web-ifc": "0.0.57"
46
+ },
47
+ "dependencies": {
48
+ "camera-controls": "2.7.3",
49
+ "fast-xml-parser": "4.4.1",
50
+ "jszip": "3.10.1",
51
+ "three-mesh-bvh": "0.7.0"
52
+ },
53
+ "peerDependencies": {
54
+ "@thatopen/fragments": "~2.2.0",
55
+ "three": "^0.160.1",
56
+ "web-ifc": "0.0.57"
57
+ }
58
+ }
@@ -1,12 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { TopicCommentsUI } from "./src/template";
3
- /**
4
- * Creates a Topic Comments List component with the given UI state.
5
- *
6
- * @param state - The initial state of the Topic Comments List component.
7
- * @param autoUpdate - A flag indicating whether the component should automatically update based on events happening in the BCFTopic component.
8
- * Default value is `true`.
9
- *
10
- * @returns A tuple containing the created Topic Comments List component and a function to update it.
11
- */
12
- export declare const topicComments: (state: TopicCommentsUI, autoUpdate?: boolean) => [element: BUI.Table, update: (state?: Partial<TopicCommentsUI> | undefined) => TopicCommentsUI, currentState: () => TopicCommentsUI];
@@ -1,20 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { Topic } from "../../Topic";
3
- import { Viewpoint } from "../../../../../core";
4
- interface UserStyles {
5
- [email: string]: {
6
- name: string;
7
- picture?: string;
8
- };
9
- }
10
- interface TopicCommentsActions {
11
- delete: boolean;
12
- }
13
- export interface TopicCommentsUI {
14
- topic: Topic;
15
- viewpoint?: Viewpoint;
16
- styles?: UserStyles;
17
- actions?: Partial<TopicCommentsActions>;
18
- }
19
- export declare const topicCommentsTemplate: (state: TopicCommentsUI) => BUI.TemplateResult<1>;
20
- export {};
@@ -1,10 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { TopicFormUI } from "./src/template";
3
- /**
4
- * Creates a Topic Form component with the given UI state.
5
- *
6
- * @param state - The initial state of the Topic Form component.
7
- *
8
- * @returns A tuple containing the created Topic Form component and a function to update it.
9
- */
10
- export declare const topicForm: (state: TopicFormUI) => [element: BUI.Table, update: (state?: Partial<TopicFormUI> | undefined) => TopicFormUI, currentState: () => TopicFormUI];
@@ -1,20 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { Topic } from "../../Topic";
3
- import { Components } from "../../../../../core";
4
- interface DataStyles {
5
- users: {
6
- [email: string]: {
7
- name: string;
8
- picture?: string;
9
- };
10
- };
11
- }
12
- export interface TopicFormUI {
13
- components: Components;
14
- topic?: Topic;
15
- onSubmit?: (topic: Topic) => void | Promise<void>;
16
- onCancel?: () => void | Promise<void>;
17
- styles?: Partial<DataStyles>;
18
- }
19
- export declare const topicFormTemplate: (state: TopicFormUI) => BUI.TemplateResult<1>;
20
- export {};
@@ -1,12 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { TopicPanelUI } from "./src/template";
3
- /**
4
- * Creates a Topic Panel component with the given UI state.
5
- *
6
- * @param state - The initial state of the Topic Panel component.
7
- * @param autoUpdate - A flag indicating whether the component should automatically update based on events happening in the BCFTopic component.
8
- * Default value is `true`.
9
- *
10
- * @returns A tuple containing the created Topic Panel component and a function to update it.
11
- */
12
- export declare const topicPanel: (state: TopicPanelUI, autoUpdate?: boolean) => [element: BUI.Table, update: (state?: Partial<TopicPanelUI> | undefined) => TopicPanelUI, currentState: () => TopicPanelUI];
@@ -1,46 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { Components, World } from "../../../../../core";
3
- import { Topic } from "../../Topic";
4
- interface DataStyles {
5
- priorities: {
6
- [name: string]: {
7
- icon?: string;
8
- style?: Record<string, string>;
9
- };
10
- };
11
- statuses: {
12
- [name: string]: {
13
- icon?: string;
14
- style?: Record<string, string>;
15
- };
16
- };
17
- types: {
18
- [name: string]: {
19
- icon?: string;
20
- style?: Record<string, string>;
21
- };
22
- };
23
- users: {
24
- [email: string]: {
25
- name: string;
26
- picture?: string;
27
- };
28
- };
29
- }
30
- interface TopicPanelActions {
31
- update: boolean;
32
- addComments: boolean;
33
- addViewpoints: boolean;
34
- linkViewpoints: boolean;
35
- linkTopics: boolean;
36
- }
37
- export interface TopicPanelUI {
38
- components: Components;
39
- topic?: Topic;
40
- styles?: Partial<DataStyles>;
41
- onUpdateInformation?: (topic: Topic) => void | Promise<void>;
42
- actions?: Partial<TopicPanelActions>;
43
- world?: World;
44
- }
45
- export declare const topicPanelTemplate: (state: TopicPanelUI) => BUI.TemplateResult<1>;
46
- export {};
@@ -1,12 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { BCFTopicsUI } from "./src/template";
3
- /**
4
- * Creates a BCF Topics List component with the given UI state.
5
- *
6
- * @param state - The initial state of the BCF Topics List component.
7
- * @param autoUpdate - A flag indicating whether the component should automatically update based on events happening in the BCFTopic component.
8
- * Default value is `true`.
9
- *
10
- * @returns A tuple containing the created BCF Topics List component and a function to update it.
11
- */
12
- export declare const bcfTopicsList: (state: BCFTopicsUI, autoUpdate?: boolean) => [element: BUI.Table, update: (state?: Partial<BCFTopicsUI> | undefined) => BCFTopicsUI, currentState: () => BCFTopicsUI];
@@ -1,29 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { Components } from "../../../../../core";
3
- import { Topic } from "../../Topic";
4
- interface DataStyles {
5
- [name: string]: {
6
- icon?: string;
7
- style?: Record<string, string>;
8
- };
9
- }
10
- interface UserStyles {
11
- [email: string]: {
12
- name: string;
13
- picture?: string;
14
- };
15
- }
16
- interface TopicDataStyles {
17
- priorities?: DataStyles;
18
- statuses?: DataStyles;
19
- types?: DataStyles;
20
- users?: UserStyles;
21
- }
22
- export interface BCFTopicsUI {
23
- components: Components;
24
- topics?: Iterable<Topic>;
25
- dataStyles?: TopicDataStyles;
26
- onTopicEnter?: (topic: Topic) => void | Promise<void>;
27
- }
28
- export declare const bcfTopicsListTemplate: (state: BCFTopicsUI) => BUI.TemplateResult<1>;
29
- export {};
@@ -1,12 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { ViewpointsUI } from "./src/template";
3
- /**
4
- * Creates a Viewpoints component with the given UI state.
5
- *
6
- * @param state - The initial state of the Viewpoints component.
7
- * @param autoUpdate - A flag indicating whether the component should automatically update based on events happening in the BCFTopic component.
8
- * Default value is `true`.
9
- *
10
- * @returns A tuple containing the created Viewpoints component and a function to update it.
11
- */
12
- export declare const viewpointsList: (state: ViewpointsUI, autoUpdate?: boolean) => [element: BUI.Table, update: (state?: Partial<ViewpointsUI> | undefined) => ViewpointsUI, currentState: () => ViewpointsUI];
@@ -1,19 +0,0 @@
1
- import * as BUI from "@thatopen/ui";
2
- import { Components, Viewpoint } from "../../../../../core";
3
- import { Topic } from "../../Topic";
4
- interface ViewpointUIActions {
5
- selectComponents: boolean;
6
- colorizeComponent: boolean;
7
- resetColors: boolean;
8
- updateCamera: boolean;
9
- delete: boolean;
10
- unlink: boolean;
11
- }
12
- export interface ViewpointsUI {
13
- components: Components;
14
- topic?: Topic;
15
- actions?: Partial<ViewpointUIActions>;
16
- onViewpointEnter?: (viewpoint: Viewpoint) => void | Promise<void>;
17
- }
18
- export declare const viewpointsListTemplate: (state: ViewpointsUI) => BUI.TemplateResult<1>;
19
- export {};