@thatopen/components 2.1.26 → 2.2.0-alpha.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.
@@ -0,0 +1,86 @@
1
+ import { Component, Configurable, Disposable, Event, World, DataMap } from "../../core/Types";
2
+ import { BCFTopic, BCFTopicsConfig, Topic } from "./src";
3
+ import { Viewpoint } from "../../core/Viewpoints";
4
+ export declare class BCFTopics extends Component implements Disposable, Configurable<BCFTopicsConfig> {
5
+ static uuid: "de977976-e4f6-4e4f-a01a-204727839802";
6
+ enabled: boolean;
7
+ private _xmlParser;
8
+ config: Required<BCFTopicsConfig>;
9
+ readonly list: DataMap<string, Topic>;
10
+ readonly onSetup: Event<unknown>;
11
+ isSetup: boolean;
12
+ setup(config?: Partial<BCFTopicsConfig>): void;
13
+ readonly onBCFImported: Event<Topic[]>;
14
+ /**
15
+ * Creates a new BCFTopic instance and adds it to the list.
16
+ *
17
+ * @param data - Optional partial BCFTopic object to initialize the new topic with.
18
+ * If not provided, default values will be used.
19
+ * @returns The newly created BCFTopic instance.
20
+ */
21
+ create(data?: Partial<BCFTopic>): Topic;
22
+ readonly onDisposed: Event<unknown>;
23
+ dispose(): void;
24
+ /**
25
+ * Retrieves the unique set of topic types used across all topics.
26
+ *
27
+ * @returns A Set containing the unique topic types.
28
+ */
29
+ get usedTypes(): Set<string>;
30
+ /**
31
+ * Retrieves the unique set of topic statuses used across all topics.
32
+ *
33
+ * @returns A Set containing the unique topic statuses.
34
+ */
35
+ get usedStatuses(): Set<string>;
36
+ /**
37
+ * Retrieves the unique set of topic priorities used across all topics.
38
+ *
39
+ * @returns A Set containing the unique topic priorities.
40
+ * Note: This method filters out any null or undefined priorities.
41
+ */
42
+ get usedPriorities(): Set<string | undefined>;
43
+ /**
44
+ * Retrieves the unique set of topic stages used across all topics.
45
+ *
46
+ * @returns A Set containing the unique topic stages.
47
+ * Note: This method filters out any null or undefined stages.
48
+ */
49
+ get usedStages(): Set<string | undefined>;
50
+ /**
51
+ * Retrieves the unique set of users associated with topics.
52
+ *
53
+ * @returns A Set containing the unique users.
54
+ * Note: This method collects users from the creation author, assigned to, modified author, and comment authors.
55
+ */
56
+ get usedUsers(): Set<string>;
57
+ /**
58
+ * Retrieves the unique set of labels used across all topics.
59
+ *
60
+ * @returns A Set containing the unique labels.
61
+ */
62
+ get usedLabels(): Set<string>;
63
+ /**
64
+ * Updates the set of extensions (types, statuses, priorities, labels, stages, users) based on the current topics.
65
+ * This method iterates through each topic in the list and adds its properties to the corresponding sets in the config.
66
+ */
67
+ updateExtensions(): void;
68
+ /**
69
+ * Exports the given topics to a BCF (Building Collaboration Format) zip file.
70
+ *
71
+ * @param topics - The topics to export. Defaults to all topics in the list.
72
+ * @returns A promise that resolves to a Blob containing the exported BCF zip file.
73
+ */
74
+ export(topics?: Iterable<Topic>): Promise<Blob>;
75
+ private serializeExtensions;
76
+ private processMarkupComment;
77
+ private getMarkupComments;
78
+ private getMarkupLabels;
79
+ private getMarkupViewpoints;
80
+ private getMarkupRelatedTopics;
81
+ load(world: World, data: Uint8Array): Promise<{
82
+ viewpoints: Viewpoint[];
83
+ topics: Topic[];
84
+ }>;
85
+ }
86
+ export * from "./src";
@@ -0,0 +1,33 @@
1
+ import { Viewpoint } from "../../../core/Viewpoints";
2
+ import { Components } from "../../../core/Components";
3
+ /**
4
+ * Represents a comment in a BCF Topic.
5
+ */
6
+ export declare class Comment {
7
+ date: Date;
8
+ author: string;
9
+ guid: string;
10
+ viewpoint?: Viewpoint;
11
+ modifiedAuthor?: string;
12
+ modifiedDate?: Date;
13
+ private _components;
14
+ private _comment;
15
+ /**
16
+ * Sets the comment text and updates the modified date and author.
17
+ * The author will be the one defined in BCFTopics.config.author
18
+ * @param value - The new comment text.
19
+ */
20
+ set comment(value: string);
21
+ /**
22
+ * Gets the comment text.
23
+ * @returns The comment text.
24
+ */
25
+ get comment(): string;
26
+ /**
27
+ * Constructs a new BCF Topic Comment instance.
28
+ * @param components - The Components instance.
29
+ * @param text - The initial comment text.
30
+ */
31
+ constructor(components: Components, text: string);
32
+ serialize(): string;
33
+ }
@@ -0,0 +1,129 @@
1
+ import { Components } from "../../../core/Components";
2
+ import { Viewpoint } from "../../../core/Viewpoints";
3
+ import { Comment } from "./Comment";
4
+ import { BCFTopic } from "./types";
5
+ import { DataSet } from "../../../core/Types";
6
+ export declare class Topic implements BCFTopic {
7
+ /**
8
+ * Default values for a BCF Topic, excluding `guid`, `creationDate`, and `creationAuthor`.
9
+ */
10
+ static default: Omit<BCFTopic, "guid" | "creationDate" | "creationAuthor">;
11
+ /**
12
+ * A unique identifier for the topic.
13
+ *
14
+ * @remarks
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
+ */
23
+ guid: string;
24
+ title: string;
25
+ creationDate: Date;
26
+ creationAuthor: string;
27
+ readonly comments: DataSet<Comment>;
28
+ readonly viewpoints: DataSet<Viewpoint>;
29
+ readonly relatedTopics: DataSet<Topic>;
30
+ customData: Record<string, any>;
31
+ description?: string;
32
+ serverAssignedId?: string;
33
+ dueDate?: Date;
34
+ modifiedAuthor?: string;
35
+ modifiedDate?: Date;
36
+ index?: number;
37
+ private _type;
38
+ set type(value: string);
39
+ get type(): string;
40
+ private _status;
41
+ set status(value: string);
42
+ get status(): string;
43
+ private _priority?;
44
+ set priority(value: string | undefined);
45
+ get priority(): string | undefined;
46
+ private _stage?;
47
+ set stage(value: string | undefined);
48
+ get stage(): string | undefined;
49
+ private _assignedTo?;
50
+ set assignedTo(value: string | undefined);
51
+ get assignedTo(): string | undefined;
52
+ private _labels;
53
+ set labels(value: Set<string>);
54
+ get labels(): Set<string>;
55
+ private _components;
56
+ private get _managerVersion();
57
+ /**
58
+ * Initializes a new instance of the `Topic` class representing a BCF (BIM Collaboration Format) topic.
59
+ * It provides methods and properties to manage and serialize BCF topics.
60
+ *
61
+ * @remarks
62
+ * The default creationUser is the one set in BCFTopics.config.author
63
+ * It should not be created manually. Better use BCFTopics.create().
64
+ *
65
+ * @param components - The `Components` instance that provides access to other components and services.
66
+ */
67
+ constructor(components: Components);
68
+ /**
69
+ * Sets properties of the BCF Topic based on the provided data.
70
+ *
71
+ * @remarks
72
+ * This method iterates over the provided `data` object and updates the corresponding properties of the BCF Topic.
73
+ * It skips the `guid` property as it should not be modified.
74
+ *
75
+ * @param data - An object containing the properties to be updated.
76
+ * @returns The topic
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const topic = new Topic(components);
81
+ * topic.set({
82
+ * title: "New BCF Topic Title",
83
+ * description: "This is a new description.",
84
+ * status: "Resolved",
85
+ * });
86
+ * ```
87
+ */
88
+ set(data: Partial<BCFTopic>): this;
89
+ /**
90
+ * Creates a new comment associated with the current topic.
91
+ *
92
+ * @param text - The text content of the comment.
93
+ * @param viewpoint - (Optional) The viewpoint associated with the comment.
94
+ *
95
+ * @returns The newly created comment.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const viewpoint = viewpoints.create(world); // Created with an instance of Viewpoints
100
+ * const topic = topics.create(); // Created with an instance of BCFTopics
101
+ * topic.viewpoints.add(viewpoint);
102
+ * const comment = topic.createComment("This is a new comment", viewpoint);
103
+ * ```
104
+ */
105
+ createComment(text: string, viewpoint?: Viewpoint): Comment;
106
+ private createLabelTags;
107
+ private createCommentTags;
108
+ private createViewpointTags;
109
+ private createRelatedTopicTags;
110
+ /**
111
+ * Serializes the BCF Topic instance into an XML string representation based on the official schema.
112
+ *
113
+ * @remarks
114
+ * This method constructs an XML string based on the properties of the BCF Topic instance.
115
+ * It includes the topic's guid, type, status, creation date, creation author, priority, index,
116
+ * modified date, modified author, due date, assigned to, description, stage, labels, related topics,
117
+ * comments, and viewpoints.
118
+ *
119
+ * @returns A string representing the XML serialization of the BCF Topic.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const topic = bcfTopics.create(); // Created with an instance of BCFTopics
124
+ * const xml = topic.serialize();
125
+ * console.log(xml);
126
+ * ```
127
+ */
128
+ serialize(): string;
129
+ }
@@ -0,0 +1,10 @@
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];
@@ -0,0 +1,20 @@
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 {};
@@ -0,0 +1,12 @@
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];
@@ -0,0 +1,37 @@
1
+ import * as BUI from "@thatopen/ui";
2
+ import { Components } 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
+ export interface TopicPanelUI {
31
+ components: Components;
32
+ topic?: Topic;
33
+ styles?: Partial<DataStyles>;
34
+ onUpdateInformation?: (topic: Topic) => void | Promise<void>;
35
+ }
36
+ export declare const topicPanelTemplate: (state: TopicPanelUI) => BUI.TemplateResult<1>;
37
+ export {};
@@ -0,0 +1,12 @@
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];
@@ -0,0 +1,37 @@
1
+ import * as BUI from "@thatopen/ui";
2
+ import { Components } 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
+ export interface BCFTopicsUI {
31
+ components: Components;
32
+ topics?: Iterable<Topic>;
33
+ styles?: Partial<DataStyles>;
34
+ onTopicEnter?: (topic: Topic) => void | Promise<void>;
35
+ }
36
+ export declare const bcfTopicsListTemplate: (state: BCFTopicsUI) => BUI.TemplateResult<1>;
37
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from "./Topic";
2
+ export * from "./types";
3
+ export * from "./Comment";
4
+ export * from "./TopicForm";
5
+ export * from "./TopicPanel";
6
+ export * from "./TopicsList";
@@ -0,0 +1,35 @@
1
+ export type BCFVersion = "2.1" | "3";
2
+ export interface BCFTopic {
3
+ guid: string;
4
+ serverAssignedId?: string;
5
+ type: string;
6
+ status: string;
7
+ title: string;
8
+ priority?: string;
9
+ index?: number;
10
+ labels: Set<string>;
11
+ creationDate: Date;
12
+ creationAuthor: string;
13
+ modifiedDate?: Date;
14
+ modifiedAuthor?: string;
15
+ dueDate?: Date;
16
+ assignedTo?: string;
17
+ description?: string;
18
+ stage?: string;
19
+ }
20
+ export interface BCFTopicsConfig {
21
+ version: BCFVersion;
22
+ author: string;
23
+ types: Set<string>;
24
+ statuses: Set<string>;
25
+ priorities: Set<string>;
26
+ labels: Set<string>;
27
+ stages: Set<string>;
28
+ users: Set<string>;
29
+ includeSelectionTag: boolean;
30
+ updateExtensionsOnImport: boolean;
31
+ strict: boolean;
32
+ includeAllExtensionsOnExport: boolean;
33
+ fallbackVersionOnImport: BCFVersion | null;
34
+ ignoreIncompleteTopicsOnImport: boolean;
35
+ }
@@ -0,0 +1 @@
1
+ export * from "./BCFTopics";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@thatopen/components",
3
3
  "description": "Collection of core functionalities to author BIM apps.",
4
- "version": "2.1.26",
4
+ "version": "2.2.0-alpha.0",
5
5
  "author": "That Open Company",
6
6
  "contributors": [
7
7
  "Antonio Gonzalez Viegas (https://github.com/agviegas)",
@@ -46,6 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "camera-controls": "2.7.3",
49
+ "fast-xml-parser": "latest",
50
+ "jszip": "latest",
49
51
  "three-mesh-bvh": "0.7.0"
50
52
  },
51
53
  "peerDependencies": {
@@ -53,4 +55,4 @@
53
55
  "three": "^0.160.1",
54
56
  "web-ifc": "0.0.57"
55
57
  }
56
- }
58
+ }