@inweb/client 25.3.10 → 25.3.12

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.
@@ -72,7 +72,20 @@ export declare class Model {
72
72
  * @readonly
73
73
  */
74
74
  get name(): string;
75
+ /**
76
+ * Model owner type, matches the file extension this is model of the file, or `assembly` for
77
+ * assemblies.
78
+ *
79
+ * @readonly
80
+ */
81
+ get type(): string;
75
82
  get version(): string;
83
+ /**
84
+ * Returns model list with one item `self`.
85
+ *
86
+ * @async
87
+ */
88
+ getModels(): Promise<Model[]>;
76
89
  /**
77
90
  * Returns model viewpoint list.
78
91
  *
@@ -249,11 +249,11 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventM
249
249
  * - {@link GeometryErrorEvent | geometryerror}
250
250
  *
251
251
  * @async
252
- * @param model - Model instance to load. If a `File` instance with multiple models is
253
- * specified, the default model will be loaded. If there is no default model, first
254
- * availiable model will be loaded.
252
+ * @param file - File or Assembly or Model instance to load. If a `File` instance with
253
+ * multiple models is specified, the default model will be loaded. If there is no default
254
+ * model, first availiable model will be loaded.
255
255
  */
256
- open(model: Model | File | Assembly): Promise<this>;
256
+ open(file: File | Assembly | Model): Promise<this>;
257
257
  /**
258
258
  * Loads a VSF file into the viewer.
259
259
  *
@@ -234,8 +234,9 @@ export interface OpenEvent {
234
234
  */
235
235
  type: "open";
236
236
  /**
237
- * Model instance to open.
237
+ * File instance to open.
238
238
  */
239
+ file?: File | Assembly | Model;
239
240
  model?: File | Assembly | Model;
240
241
  /**
241
242
  * Buffer to open.
package/lib/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export { Project } from "./Api/Project";
16
16
  export { Role } from "./Api/Role";
17
17
  export { User } from "./Api/User";
18
18
  export { Viewer, Viewer as VisualizejsViewer } from "./Viewer/Viewer";
19
+ export { parseArgs, userFullName, userInitials, waitFor } from "./Api/impl/Utils";
19
20
  export * from "./Api/ClientEvents";
20
21
  export * from "./Viewer/Markup/IViewpoint";
21
22
  export * from "./Viewer/OptionsEvents";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/client",
3
- "version": "25.3.10",
3
+ "version": "25.3.12",
4
4
  "description": "Client.js is a library for implementing BIM Project management applications.",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/src/Api/Model.ts CHANGED
@@ -133,11 +133,30 @@ export class Model {
133
133
  return this.data.name;
134
134
  }
135
135
 
136
+ /**
137
+ * Model owner type, matches the file extension this is model of the file, or `assembly` for
138
+ * assemblies.
139
+ *
140
+ * @readonly
141
+ */
142
+ get type(): string {
143
+ return this.file.type;
144
+ }
145
+
136
146
  // Reserved for future use.
137
147
  get version(): string {
138
148
  return this.data.version;
139
149
  }
140
150
 
151
+ /**
152
+ * Returns model list with one item `self`.
153
+ *
154
+ * @async
155
+ */
156
+ getModels(): Promise<Model[]> {
157
+ return Promise.resolve([this]);
158
+ }
159
+
141
160
  /**
142
161
  * Returns model viewpoint list.
143
162
  *
@@ -836,35 +836,37 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
836
836
  * - {@link GeometryErrorEvent | geometryerror}
837
837
  *
838
838
  * @async
839
- * @param model - Model instance to load. If a `File` instance with multiple models is
840
- * specified, the default model will be loaded. If there is no default model, first
841
- * availiable model will be loaded.
839
+ * @param file - File or Assembly or Model instance to load. If a `File` instance with
840
+ * multiple models is specified, the default model will be loaded. If there is no default
841
+ * model, first availiable model will be loaded.
842
842
  */
843
- async open(model: Model | File | Assembly): Promise<this> {
843
+ async open(file: File | Assembly | Model): Promise<this> {
844
844
  if (!this.visualizeJs) return this;
845
845
 
846
846
  this.cancel();
847
847
  this.clear();
848
848
 
849
- this.emitEvent({ type: "open", model });
849
+ this.emitEvent({ type: "open", file, model: file });
850
850
 
851
- if (model instanceof File || model instanceof Assembly) {
852
- const models = (await model.getModels()) ?? [];
853
- model = models.find((model) => model.default) ?? models[0];
851
+ let model: Model;
852
+
853
+ if (file) {
854
+ const models = (await file.getModels()) || [];
855
+ model = models.find((model: Model) => model.default) || models[0];
854
856
  }
855
857
  if (!model) throw new Error("No default model found");
856
858
 
857
- await this.loadReferences(model);
858
-
859
859
  const overrideOptions = new Options();
860
860
  overrideOptions.data = this.options.data;
861
- if (model.file.type === ".rcs") {
861
+ if (file.type === ".rcs") {
862
862
  console.log("Partial load mode is forced for RCS file");
863
863
  overrideOptions.enablePartialMode = true;
864
864
  }
865
865
 
866
866
  const loaderFactory = new LoaderFactory();
867
867
  const loader = loaderFactory.create(this, model, overrideOptions.data);
868
+
869
+ await this.loadReferences(model);
868
870
  await loader.load();
869
871
 
870
872
  if (this.visualizeJs) {
@@ -265,7 +265,12 @@ export interface OpenEvent {
265
265
  type: "open";
266
266
 
267
267
  /**
268
- * Model instance to open.
268
+ * File instance to open.
269
+ */
270
+ file?: File | Assembly | Model;
271
+
272
+ /*
273
+ * Deprecated since `25.3`. Use `file` instead.
269
274
  */
270
275
  model?: File | Assembly | Model;
271
276
 
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ export { Project } from "./Api/Project";
39
39
  export { Role } from "./Api/Role";
40
40
  export { User } from "./Api/User";
41
41
  export { Viewer, Viewer as VisualizejsViewer } from "./Viewer/Viewer";
42
+ export { parseArgs, userFullName, userInitials, waitFor } from "./Api/impl/Utils";
42
43
 
43
44
  export * from "./Api/ClientEvents";
44
45
  export * from "./Viewer/Markup/IViewpoint";