@bimdata/viewer 2.0.0-beta.74 → 2.0.0-beta.76

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/index.d.ts CHANGED
@@ -5,18 +5,19 @@ declare module "@bimdata/viewer" {
5
5
  declare namespace BDV {
6
6
  interface Viewer {
7
7
  mount(container: HTMLElement | string, layout?: any): any;
8
+ destroy(): void;
8
9
  setAccessToken(token: string): void;
9
- setLocale(lang: ViewerLocales): void;
10
- registerPlugin(plugin: PluginConfig, cfg?: Object): void;
10
+ setLocale(lang: ViewerLocale): void;
11
+ registerPlugin(plugin: PluginDefinition, cfg?: Object): void;
11
12
  registerWindow(window: Object): void;
12
13
  unregisterWindow(name: string): void;
13
- loadModels(modelIds: number[]): StateModel[];
14
+ loadModels(modelIds: number[]): Promise<StateModel[]>;
14
15
 
15
16
  /** @deprecated use `loadModels` instead */
16
- loadIfcs(ifcIds: number[]): StateModel[];
17
+ loadIfcs(ifcIds: number[]): Promise<StateModel[]>;
17
18
  }
18
19
 
19
- enum ViewerLocales {
20
+ enum ViewerLocale {
20
21
  "de",
21
22
  "en",
22
23
  "es",
@@ -28,7 +29,7 @@ declare namespace BDV {
28
29
  ui?: ViewerConfigUI;
29
30
  api: ViewerConfigApi;
30
31
  plugins?: ViewerConfigPlugins;
31
- locale?: ViewerLocales;
32
+ locale?: ViewerLocale;
32
33
  }
33
34
 
34
35
  interface ViewerConfigUI {
@@ -57,23 +58,77 @@ declare namespace BDV {
57
58
  }
58
59
 
59
60
  interface ViewerConfigPlugins {
60
- // Conf
61
- addPlugins?: boolean;
62
- windowSelector?: boolean;
61
+ // --- General config ---
62
+ windowSelector?: boolean; // Enable/Disable window selector
63
63
 
64
- // IFC 3D Viewer
65
- viewer3d?:
64
+ // --- Native plugins config ---
65
+
66
+ alerts?: boolean;
67
+ bcf?:
66
68
  | boolean
67
69
  | {
68
- edges?: boolean;
69
- enableOffsets: boolean;
70
+ topicGuid?: string;
71
+ };
72
+ bcfManager?: boolean;
73
+ buildingMaker?: boolean;
74
+ dwg?:
75
+ | boolean
76
+ | {
77
+ help?: boolean;
78
+ modelLoader?: "hidden" | "disabled";
79
+ };
80
+ "dwg-layer"?: boolean;
81
+ dxf?:
82
+ | boolean
83
+ | {
84
+ help?: boolean;
85
+ modelLoader?: "hidden" | "disabled";
86
+ };
87
+ equipment2d?: boolean;
88
+ fullscreen?: boolean;
89
+ gauge2d?: boolean;
90
+ ged?: boolean;
91
+ header?: boolean;
92
+ measure2d?: boolean;
93
+ measure3d?: boolean;
94
+ navigationVersionsModel?: boolean;
95
+ pdf?: boolean;
96
+ pdfAnnotations?: boolean;
97
+ pdfExport?: boolean;
98
+ plan?:
99
+ | boolean
100
+ | {
101
+ help?: boolean;
102
+ modelLoader?: "hidden" | "disabled";
103
+ };
104
+ pointCloud?:
105
+ | boolean
106
+ | {
107
+ help?: boolean;
108
+ modelLoader?: "hidden" | "disabled";
70
109
  navCube?: boolean;
71
110
  pivotMarker?: boolean;
72
111
  };
112
+ pointCloudParameters?: boolean;
73
113
  projection?: boolean;
114
+ properties?:
115
+ | boolean
116
+ | {
117
+ editProperties?: boolean;
118
+ };
119
+ "right-angled"?: boolean;
74
120
  search?: boolean;
75
121
  section?: boolean;
122
+ smartview?: boolean;
76
123
  split?: boolean;
124
+ structure?:
125
+ | boolean
126
+ | {
127
+ merge?: boolean;
128
+ export?: boolean;
129
+ translateIfcEntities?: boolean;
130
+ customTranslations?: Object;
131
+ };
77
132
  "structure-properties"?:
78
133
  | boolean
79
134
  | {
@@ -83,63 +138,32 @@ declare namespace BDV {
83
138
  translateIfcEntities?: boolean;
84
139
  customTranslations?: Object;
85
140
  };
86
- "viewer3d-parameters"?: boolean;
87
-
88
- // IFC 2D Viewer
89
- viewer2d?: boolean;
90
- equipment2d?: boolean;
91
- gauge2d?: boolean;
92
141
  switch?: boolean;
142
+ synchronization?: boolean;
143
+ viewer2d?:
144
+ | boolean
145
+ | {
146
+ help?: boolean;
147
+ modelLoader?: "hidden" | "disabled";
148
+ };
93
149
  "viewer2d-background"?: boolean;
94
150
  "viewer2d-drawer"?: boolean;
95
151
  "viewer2d-parameters"?: boolean;
96
152
  "viewer2d-screenshot"?: boolean;
97
-
98
- // DWG / DXF Viewers
99
- dwg?: boolean;
100
- dxf?: boolean;
101
- "dwg-layer"?: boolean;
102
-
103
- // Plan / Meta-Building Viewer
104
- plan?: boolean;
105
- synchronization?: boolean;
106
-
107
- // Point Cloud Viewer
108
- pointCloud?:
153
+ viewer3d?:
109
154
  | boolean
110
155
  | {
156
+ edges?: boolean;
157
+ enableDynamicLOD?: boolean;
158
+ enableOffsets: boolean;
159
+ home?: boolean;
160
+ help?: boolean;
161
+ modelLoader?: "hidden" | "disabled";
111
162
  navCube?: boolean;
163
+ navigationVersionsModel?: boolean;
164
+ pivotMarker?: boolean;
112
165
  };
113
-
114
- // BCF
115
- bcf?:
116
- | boolean
117
- | {
118
- topicGuid?: string;
119
- };
120
- bcfManager?: boolean;
121
-
122
- // Misc
123
- alerts?: boolean;
124
- buildingMaker?: boolean;
125
- fullscreen?: boolean;
126
- ged?: boolean;
127
- header?: boolean;
128
- pdf?: boolean;
129
- properties?:
130
- | boolean
131
- | {
132
- editProperties?: boolean;
133
- };
134
- "storey-selector"?: boolean;
135
- structure?:
136
- | boolean
137
- | {
138
- merge?: boolean;
139
- export?: boolean;
140
- translateIfcEntities?: boolean;
141
- customTranslations?: Object;
142
- };
166
+ "viewer3d-parameters"?: boolean;
143
167
  "window-split"?: boolean;
144
168
  }
145
169
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bimdata/viewer",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.74",
4
+ "version": "2.0.0-beta.76",
5
5
  "description": "A customizable BIM viewer.",
6
6
  "keywords": [
7
7
  "bim",
@@ -1,17 +1,28 @@
1
1
  declare namespace BDV {
2
2
  interface $Viewer {
3
3
  cfg: ViewerConfig;
4
- i18n: any;
4
+ i18n: i18n;
5
5
  readonly api: Api;
6
6
  readonly state: State;
7
+ readonly pluginsCfg: ViewerConfigPlugins;
8
+ readonly registeredPlugins: string[];
9
+ readonly registeredWindows: string[];
7
10
 
8
- readonly pluginManager: PluginManager;
9
- readonly shortcutManager: ShortcutManager;
10
11
  readonly globalContext: GlobalContext;
11
12
  readonly localContext: LocalContext;
12
- getLocalContexts(window: string): LocalContext[];
13
-
14
- currentContext: any;
15
13
  contextMenu: ContextMenu;
14
+
15
+ readonly shortcutManager: ShortcutManager;
16
+
17
+ // ---
18
+
19
+ readonly _pluginManager: PluginManager;
20
+ readonly _windowManager: WindowManager;
21
+ }
22
+
23
+ interface i18n {
24
+ i18nVuePlugin: any;
25
+ registerTranslations(messages: Object): void;
26
+ changeLocale(locale: ViewerLocale): void;
16
27
  }
17
28
  }
package/types/api.d.ts CHANGED
@@ -1,17 +1,22 @@
1
1
  declare namespace BDV {
2
2
  interface Api {
3
- readonly permissions: Permissions;
4
3
  readonly apiClient: any;
5
4
  readonly apiUrl: string;
6
5
  readonly archiveUrl: string;
7
6
  readonly cloudId: number;
8
7
  readonly projectId: number;
8
+ readonly permissions: Permissions;
9
9
  accessToken: string;
10
10
 
11
11
  getModel(modelId: number): Promise<ApiModel>;
12
12
  getModelStructure(model: ApiModel): Promise<any>;
13
13
  getRawElements(modelId: number): Promise<any>;
14
14
  getStoreys(modelId: number): Promise<ApiStorey[]>;
15
+ createModel(docId: number): Promise<ApiModel>;
16
+ waitForModelProcess(model: ApiModel): Promise<ApiModel>;
17
+ createStoreyPlan(modelId: number, storeyUuid: string, docId: number): Promise<ApiPlan>;
18
+ deleteStoreyPlan(modelId: number, storeyUuid: string, planId: number): Promise<void>;
19
+ updatePlanPositioning(modelId: number, storeyUuid: string, planId: number, positioning: ApiPositionning): Promise<ApiPositionning>;
15
20
 
16
21
  // ---
17
22
 
@@ -38,12 +43,17 @@ declare namespace BDV {
38
43
  source: ModelSource;
39
44
  status: ModelStatus;
40
45
  archived: boolean;
41
- document: ApiDocument;
46
+ document?: ApiDocument;
42
47
  project_id: number;
43
48
  structure_file?: string;
44
49
  xkt_file?: string;
45
50
  gltf_file?: string;
46
51
  map_file?: string;
52
+
53
+ // Multi-page PDF
54
+ page_number?: number;
55
+ parent_id?: number;
56
+ children?: ApiModel[];
47
57
  }
48
58
 
49
59
  type ApiPlan = ApiModel;
@@ -54,12 +64,7 @@ declare namespace BDV {
54
64
  longname: string;
55
65
  type: string;
56
66
  object_type: string;
57
- model: StateModel;
58
- parent: StateObject;
59
67
  children: ApiObject[];
60
-
61
- /** @deprecated use `model` instead */
62
- ifc: StateModel;
63
68
  }
64
69
 
65
70
  interface ApiStorey {
package/types/events.d.ts CHANGED
@@ -2,6 +2,8 @@ type Events = {
2
2
  [eventName: string]: Object;
3
3
  };
4
4
 
5
+ type SubscriptionId = number;
6
+
5
7
  interface EventOptions {
6
8
  getLastEvent?: boolean;
7
9
  }
@@ -11,13 +13,13 @@ interface EventHandler<T extends Events> {
11
13
  eventName: N,
12
14
  callback: (arg: T[N]) => void,
13
15
  options?: EventOptions
14
- ): number;
16
+ ): SubscriptionId;
15
17
  once<N extends keyof T>(
16
18
  eventName: N,
17
19
  callback: (arg: T[N]) => void,
18
20
  options?: EventOptions
19
- ): number;
20
- off(subscriptionId: number): void;
21
+ ): SubscriptionId;
22
+ off(subId: SubscriptionId): void;
21
23
  emit<N extends keyof T>(eventName: N, payload: T[N]): void;
22
24
  clear(): void;
23
25
  }
@@ -1,42 +1,39 @@
1
1
  declare namespace BDV {
2
2
  interface GlobalContext {
3
- hub: EventHandler<LocalContextEvents & GlobalContextEvents>;
3
+ hub: EventHandler<GlobalContextEvents & LocalContextEvents>;
4
+ layout: any;
5
+ readonly el: HTMLElement;
6
+ readonly plugins: Map<string, PluginInstance[]>;
4
7
 
5
- areas: any;
6
- areasSettingsDisplayed: boolean;
7
- areasSwapEnabled: boolean;
8
- areasSettingsFullOption: boolean;
9
- bcfManagerDisplayed: boolean;
10
- mouseover: boolean;
11
-
12
- /** @deprecated */
13
- getPlugins(name: string): Plugin[];
14
- plugins: Map<string, Plugin>;
8
+ activeLocalContext?: LocalContext;
9
+ readonly localContexts: LocalContext[];
10
+ getLocalContexts(window: string): LocalContext[];
11
+ getViewers(): ModelViewerInstance[];
15
12
 
16
13
  // ---
17
14
 
18
- loading: boolean;
15
+ registerShortcut(shortcut: Shortcut, context: GlobalContext | LocalContext): boolean;
16
+ unregisterShortcut(name: string, context: GlobalContext | LocalContext): boolean;
17
+
18
+ readonly loading: boolean;
19
19
  loadingProcessStart(): void;
20
20
  loadingProcessEnd(): void;
21
-
22
- registerShortcut(shortcut: Shortcut, context: GlobalContext): boolean;
23
- unregisterShortcut(name: string, context: GlobalContext): boolean;
21
+ setSpinner(spinner: any): void;
24
22
 
25
23
  modals: {
26
- pushModal(component: Object, options?: { args: Object }): void;
24
+ pushModal(component: any, props?: any, options?: any): void;
27
25
  clearModal(): void;
28
26
  };
27
+
28
+ // ---
29
+
30
+ bcfManagerDisplayed: boolean; // TODO: should be moved elsewhere
31
+
32
+ /** @deprecated use `plugins` Map instead */
33
+ getPlugins(name: string): PluginInstance[];
29
34
  }
30
35
 
31
36
  type GlobalContextEvents = {
32
- "plan-model-loaded": {
33
- model: ApiModel;
34
- plugin: ViewerDwg.Plugin;
35
- };
36
- "plan-model-unloaded": {
37
- model: ApiModel;
38
- plugin: ViewerDwg.Plugin;
39
- };
40
37
  "window-open": Window;
41
38
  "window-close": Window;
42
39
  };
@@ -3,106 +3,160 @@ declare namespace BDV {
3
3
  hub: EventHandler<LocalContextEvents>;
4
4
 
5
5
  id: number;
6
- el: Element;
7
- width: number;
8
- height: number;
6
+ readonly el: Element;
7
+ readonly x: number;
8
+ readonly y: number;
9
+ readonly width: number;
10
+ readonly height: number;
9
11
  resolution: number;
10
12
 
11
13
  // Local state
12
- loadedModels: StateModel[];
13
- loadedModelIds: number[];
14
- loadingModelIds: number[];
15
- modelTypes: string[];
16
- multiModel: boolean;
14
+ readonly multiModel: boolean;
15
+ readonly modelTypes?: string[];
16
+ readonly loadedModels: StateModel[];
17
+ readonly loadedModelIds: number[];
18
+ readonly loadingModelIds: number[];
19
+ readonly currentStorey: StateStorey | null;
17
20
  loadModels(ids: number[]): Promise<boolean>;
18
21
  unloadModels(ids: number[]): boolean;
19
22
  toggleModel(id: number): Promise<boolean>;
23
+ selectStorey(storey: StateStorey): void;
24
+ showPlan(plan: StatePlan): void;
25
+ hidePlan(plan: StatePlan): void;
26
+ togglePlanVisibility(plan: StatePlan): void;
27
+ togglePlanEdition(plan: StatePlan): void;
28
+ createPlan(model: StateModel, storey: StateStorey, document: ApiDocument, positioning: StatePositionning): Promise<StatePlan>;
29
+ updatePlan(plan: StatePlan, positioning: StatePositionning): Promise<StatePlan>;
30
+ deletePlan(plan: StatePlan): Promise<void>;
31
+
32
+ // Viewer
33
+ readonly viewer: ModelViewerInstance | null;
34
+ readonly annotationMode: boolean;
35
+ getViewpoint: (options?: any) => any | Promise<any>;
36
+ setViewpoint: (viewpoint: any, options?: any) => void | Promise<void>;
37
+ startAnnotationMode: (callback: Function) => void;
38
+ stopAnnotationMode: () => void;
39
+ fitView: (options?: any) => void;
40
+ showUI: (options?: any) => void;
41
+ hideUI: (options?: { exceptions: string[] }) => Promise<void>;
20
42
 
21
43
  // Window
44
+ readonly window: Window;
22
45
  loadWindow(windowName: string): void;
23
- window: Window;
24
46
 
25
- // Plugin
26
- /** @deprecated */
27
- getPlugin(name: string): Plugin;
28
- plugins: Map<string, Plugin>;
47
+ // Plugins
48
+ readonly plugins: Map<string, PluginInstance>;
49
+ readonly _plugins: PluginInstance[];
50
+ setPlugins(names: string[]): void;
51
+
52
+ // Shortcuts
53
+ registerShortcut(shortcut: Shortcut): boolean;
54
+ unregisterShortcut(name: string): boolean;
29
55
 
30
- loading: boolean;
56
+ // Loading
57
+ readonly loading: boolean;
31
58
  loadingProcessStart(): void;
32
59
  loadingProcessEnd(): void;
33
60
 
34
- registerShortcut(shortcut: Shortcut, context: LocalContext): boolean;
35
- unregisterShortcut(name: string, context: LocalContext): boolean;
36
-
37
- modals: {
38
- pushModal(component: Object, options?: { args: Object }): void;
61
+ // Modals
62
+ readonly modals: {
63
+ pushModal(component: Object, props?: Object, options?: Object): void;
39
64
  clearModal(): void;
40
65
  };
66
+
67
+ // ---
68
+
69
+ /** @deprecated use `plugins` Map instead */
70
+ getPlugin(name: string): PluginInstance;
71
+ /** @deprecated use `loadingProcessStart` instead */
72
+ incrementSpinnerProcesses(): void;
73
+ /** @deprecated use `loadingProcessEnd` instead */
74
+ decrementSpinnerProcesses(): void;
41
75
  }
42
76
 
43
77
  type LocalContextEvents = {
78
+ "alert": { type: string; message: string };
79
+ "context-resize": { width: number; height: number };
80
+ "plugin-created": { name: string; plugin: PluginInstance; };
81
+ "plugin-destroyed": { name: string; plugin: PluginInstance; };
82
+ "plugin-menu-open": { name: string; plugin: PluginInstance; };
83
+ "plugin-menu-close": { name: string; plugin: PluginInstance; };
84
+
44
85
  "models-loaded": { models: StateModel[] };
45
86
  "models-unloaded": { models: StateModel[] };
46
87
  "models-loading": { ids: number[] };
88
+ "storey-selected": { storey: StateStorey };
89
+ "plan-shown": { plan: StatePlan };
90
+ "plan-hidden": { plan: StatePlan };
91
+ "plan-editing": { plan: StatePlan | null };
92
+ "plan-created": { plan: StatePlan };
93
+ "plan-updated": { plan: StatePlan };
94
+ "plan-deleted": { plan: StatePlan };
95
+
47
96
  "3d-model-loaded": {
48
97
  model: StateModel;
49
- plugin: ViewerIfc3D.Plugin;
98
+ plugin: ViewerIfc3D.Instance;
50
99
  /** @deprecated use `model` instead */
51
100
  ifc: StateModel;
52
101
  };
53
102
  "3d-model-unloaded": {
54
103
  model: StateModel;
55
- plugin: ViewerIfc3D.Plugin;
104
+ plugin: ViewerIfc3D.Instance;
56
105
  /** @deprecated use `model` instead */
57
106
  ifc: StateModel;
58
107
  };
59
108
  "2d-model-loaded": {
60
109
  model: StateModel;
61
- plugin: ViewerIfc2D.Plugin;
110
+ plugin: ViewerIfc2D.Instance;
62
111
  /** @deprecated use `model` instead */
63
112
  ifc: StateModel;
64
113
  };
65
114
  "2d-model-unloaded": {
66
115
  model: StateModel;
67
- plugin: ViewerIfc2D.Plugin;
116
+ plugin: ViewerIfc2D.Instance;
68
117
  /** @deprecated use `model` instead */
69
118
  ifc: StateModel;
70
119
  };
71
120
  "dwg-model-loaded": {
72
- dwg: Document;
121
+ type: "svg" | "binary";
122
+ dwg: Document | ArrayBuffer;
73
123
  model: StateModel;
74
- plugin: ViewerDwg.Plugin;
124
+ plugin: ViewerDwg.Instance;
75
125
  };
76
126
  "dwg-model-unloaded": {
77
- plugin: ViewerDwg.Plugin;
127
+ model: StateModel;
128
+ plugin: ViewerDwg.Instance;
78
129
  };
79
130
  "dxf-model-loaded": {
80
- dxf: Document;
131
+ type: "svg" | "binary";
132
+ dxf: Document | ArrayBuffer;
81
133
  model: StateModel;
82
- plugin: ViewerDwg.Plugin;
134
+ plugin: ViewerDwg.Instance;
83
135
  };
84
136
  "dxf-model-unloaded": {
85
- plugin: ViewerDwg.Plugin;
137
+ model: StateModel;
138
+ plugin: ViewerDwg.Instance;
86
139
  };
87
140
  "plan-model-loaded": {
88
- model: ApiModel;
89
- plugin: ViewerDwg.Plugin;
141
+ model: StateModel;
142
+ plugin: ViewerPlan.Instance;
90
143
  };
91
144
  "plan-model-unloaded": {
92
- model: ApiModel;
93
- plugin: ViewerDwg.Plugin;
145
+ model: StateModel;
146
+ plugin: ViewerPlan.Instance;
94
147
  };
95
- "plugin-created": {
96
- pluginName: string;
97
- plugin: Plugin;
148
+ "pointcloud-model-loaded": {
149
+ model: StateModel;
150
+ plugin: ViewerPointCloud.Instance;
98
151
  };
99
- "plugin-destroyed": {
100
- pluginName: string;
101
- plugin: Plugin;
152
+ "pointcloud-model-unloaded": {
153
+ model: StateModel;
154
+ plugin: ViewerPointCloud.Instance;
155
+ };
156
+
157
+ "pdf-page-changed": {
158
+ model: StateModel;
159
+ page: any;
102
160
  };
103
- "plugin-menu-open": Plugin;
104
- "plugin-menu-close": Plugin;
105
- "context-resize": { width: number; height: number };
106
- alert: { type: string; message: string };
107
161
  };
108
162
  }