@pilotdev/pilot-web-2d 23.0.7-alpha.1

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.
Files changed (4) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +5 -0
  3. package/index.d.ts +476 -0
  4. package/package.json +17 -0
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Installation
2
+ > `npm install --save-dev @pilotdev/pilot-web-2d`
3
+
4
+ # Summary
5
+ This package contains type definitions for Ascon **PilotWeb2D** component (https://pilotcloud.ascon.net).
package/index.d.ts ADDED
@@ -0,0 +1,476 @@
1
+ declare namespace PilotWeb2D {
2
+ export class InitializerOptions {
3
+ libList?: string[];
4
+ language?: string;
5
+ }
6
+ class Global {
7
+ G: any;
8
+ RESOURCE_ROOT: string;
9
+ initializeResourceRoot(options: InitializerOptions): void;
10
+ getResourceUrl(resourceRelativePath: string): string;
11
+ }
12
+ export const global: Global;
13
+ export {};
14
+ export type StringMap = {
15
+ [key: string]: any;
16
+ };
17
+ export class Localization {
18
+ static initialize(options: any): Promise<void>;
19
+ static translate<T extends (string | StringMap) = string>(stringToTrans: string): T;
20
+ static setLanguage(language: string): Promise<void>;
21
+ static extendLocalization(locales: any): boolean;
22
+ }
23
+ export type InitializeSuccessCallback = () => void;
24
+ export function coreInitializer(options: InitializerOptions, callback: InitializeSuccessCallback): void;
25
+ export function coreShutdown(): void;
26
+ export interface IWindowStyle {
27
+ width: string;
28
+ height: string;
29
+ left: string;
30
+ right: string;
31
+ top: string;
32
+ }
33
+ export interface IWindowStateOptions {
34
+ saveKey: string;
35
+ restoreWindowSize: boolean;
36
+ }
37
+ export class WindowStater {
38
+ get windowStylesState(): IWindowStyle;
39
+ get windowOptionsState(): IWindowStateOptions;
40
+ restore(): void;
41
+ saveWindowState(): void;
42
+ }
43
+ export class Resizer {
44
+
45
+ constructor(resizableContainer: HTMLElement, containerToRestriction: HTMLElement, elementAnchor?: HTMLElement, windowStater?: WindowStater);
46
+ get windowState(): IWindowStyle | null;
47
+ }
48
+ export class Dragger {
49
+
50
+ constructor(allowedDraggableElement: HTMLElement, draggableContainer: HTMLElement, containerToRestriction: HTMLElement, windowStater?: WindowStater);
51
+ get windowState(): IWindowStyle | null;
52
+ }
53
+ export namespace Viewer3DIcons {
54
+ const VIEWER_SETTINGS_ICON: string;
55
+ const VIEWER_MODEL_BROWSER_ICON: string;
56
+ const VIEWER_FULL_SCREEN_ICON: string;
57
+ const VIEWER_COLLAPSE_ICON: string;
58
+ const VIEWER_ELEMENT_PROPERTIES_ICON: string;
59
+ const VIEWER_ADD_CLIPPING_PLANE_ICON: string;
60
+ const VIEWER_CLIPPING_FLIP_ICON: string;
61
+ const VIEWER_DELETE_CLIPPING_PLANE_ICON: string;
62
+ const VIEWER_CLIPPING_CUBE_ICON: string;
63
+ const VIEWER_ADD_REMARK_ICON: string;
64
+ const VIEWER_MEASUREMENT_EDGE_ICON: string;
65
+ const VIEWER_MEASUREMENT_PLANE_ICON: string;
66
+ const VIEWER_MEASUREMENT_DIMENSION_ICON: string;
67
+ }
68
+ export namespace ViewerGeneralIcons {
69
+ const CLOSE: string;
70
+ const STRETCH_WINDOW: string;
71
+ const EXPAND_TREE: string;
72
+ const COLLAPSE_TREE: string;
73
+ const ARROW_DROP_DOWN: string;
74
+ const ARROW_DROP_RIGHT: string;
75
+ const CIRCLE_ICON: string;
76
+ const SHOW: string;
77
+ const HIDE: string;
78
+ const TRASH: string;
79
+ const ARROW_DR: string;
80
+ }
81
+ export namespace Viewer2DIcons {
82
+ const REMARK_CIRCLE_ICON: string;
83
+ const ZOOM_IN: string;
84
+ const ZOOM_OUT: string;
85
+ }
86
+ export interface ISettings {
87
+ changeSetting<T>(name: string, value: T, notify?: boolean, providedData?: any): void;
88
+ getSettingValue<T>(name: string): T;
89
+ }
90
+ export enum BaseSettingsNames {
91
+ TOOLBAR = "toolbar",
92
+ TOOLBAR_POSITION = "toolbarPosition",
93
+ TOOLBAR_CONTENT_ALIGNMENT = "toolbarContent",
94
+ THEME = "theme"
95
+ }
96
+ export class SettingChangedEvent extends Event {
97
+ name: string;
98
+ oldValue: any;
99
+ newValue: any;
100
+ providedData: any;
101
+ }
102
+ export class LoadingSpinner {
103
+ addToDOM(container: HTMLElement): void;
104
+ removeFromDOM(container: HTMLElement): void;
105
+ }
106
+ export class CoreEventTypes {
107
+ static VIEWER_RESIZE_EVENT: string;
108
+ static VIEWER_MOUSE_DOWN_EVENT: string;
109
+ static VIEWER_MOUSE_MOVE_EVENT: string;
110
+ static VIEWER_MOUSE_UP_EVENT: string;
111
+ static VIEWER_MOUSE_LONG_TOUCH_EVENT: string;
112
+ static SETTING_CHANGED_EVENT: string;
113
+ static SETTING_RESET_EVENT: string;
114
+ static SETTING_LANGUAGE_CHANGED_EVENT: string;
115
+ static SETTING_THEME_CHANGED_EVENT: string;
116
+ }
117
+ export interface IControl {
118
+ container: HTMLElement;
119
+ getId(): string;
120
+ setToolTip(tooltipText: string): void;
121
+ setText(text: string): void;
122
+ }
123
+ export class Control implements IControl {
124
+ container: HTMLElement;
125
+
126
+ constructor(id: string);
127
+ addClass(cssClass: string): void;
128
+ removeClass(cssClass: string): void;
129
+ getId(): string;
130
+ setToolTip(tooltipText: string): void;
131
+ setText(text: string): void;
132
+ }
133
+ export enum ToolbarPosition {
134
+ TOP_FIXED = "ascn-toolbar-position-fixed-top",
135
+ TOP_FLUENT = "ascn-toolbar-position-top",
136
+ BOTTOM_FIXED = "ascn-toolbar-position-fixed-bottom",
137
+ BOTTOM_FLUENT = "ascn-toolbar-position-bottom"
138
+ }
139
+ export enum ToolbarContentAlignment {
140
+ CENTER = "ascn-toolbar-content-center",
141
+ START = "ascn-toolbar-content-start",
142
+ END = "ascn-toolbar-content-end"
143
+ }
144
+ export interface ToolbarStyle {
145
+ [BaseSettingsNames.TOOLBAR_POSITION]?: ToolbarPosition;
146
+ [BaseSettingsNames.TOOLBAR_CONTENT_ALIGNMENT]?: ToolbarContentAlignment;
147
+ }
148
+ export const defaultToolbarAppearance: ToolbarStyle;
149
+ export interface IMenu {
150
+ controls: IControl[];
151
+ addControl(control: IControl, index?: number): void;
152
+ removeControl(index: number): void;
153
+ }
154
+ interface IToolbarButton {
155
+ button: IControl;
156
+ index: number;
157
+ }
158
+ export class Toolbar extends Control implements IMenu {
159
+ readonly controls: IControl[];
160
+ addControl(control: IControl, index?: number): void;
161
+ removeControl(index: number): void;
162
+ getControls(): IToolbarButton[];
163
+ changeToolbarPosition(direction: ToolbarPosition): void;
164
+ changeToolbarContentAlignment(content: ToolbarContentAlignment): void;
165
+ }
166
+ export {};
167
+ export class ExtensionBase {
168
+ protected _viewer: ViewerBase;
169
+ protected _options: object;
170
+
171
+ constructor(viewer3D: ViewerBase, options?: object);
172
+ load(): boolean | Promise<boolean>;
173
+ unload(): boolean;
174
+ activate(): boolean;
175
+ deactivate(): boolean;
176
+ /**
177
+ * Gets the name of the extension.
178
+ * @returns {string} Returns the name of the extension.
179
+ */
180
+ getName(): string;
181
+ onMouseDown(event: MouseEvent): void;
182
+ onMouseMove(event: MouseEvent): void;
183
+ onMouseUp(event: MouseEvent): void;
184
+ onMouseLongTouch(event: MouseEvent): void;
185
+ onToolbarCreated(toolbar: Toolbar): void;
186
+ protected bindDomEvents(): void;
187
+ }
188
+ export class ExtensionManager {
189
+ registerExtensionType(extensionId: string, extension: typeof ExtensionBase): boolean;
190
+ unregisterExtensionType(extensionId: string): boolean;
191
+ getExtensionType(extensionId: string): typeof ExtensionBase;
192
+ }
193
+ export const theExtensionManager: ExtensionManager;
194
+ export class ExtensionLoader {
195
+ /**
196
+ * Loads the extension with the given id and options.
197
+ *
198
+ * @param {string} extensionId - The string id of the extension.
199
+ * @param {object} options - An optional dictionary of options.
200
+ *
201
+ * @returns {Promise<ExtensionBase>} - Resolves with the extension requested.
202
+ */
203
+ loadExtension(extensionId: string, options?: object): Promise<ExtensionBase>;
204
+ /**
205
+ * Unloads the extension with the given id.
206
+ *
207
+ * @param {string} extensionId - The string id of the extension.
208
+ * @returns {Promise<boolean>} - True if the extension was successfully unloaded.
209
+ */
210
+ unloadExtension(extensionId: string): Promise<boolean>;
211
+ /**
212
+ * Returns all loaded extensions.
213
+ * @returns {?string[]} - Ids of loaded extensions.
214
+ */
215
+ getExtensions(): string[];
216
+ /**
217
+ * Returns the loaded extension.
218
+ * @param {string} extensionId - The string id of the extension.
219
+ * @returns {?ExtensionBase} - Extension.
220
+ */
221
+ getExtension(extensionId: string): ExtensionBase;
222
+ }
223
+ export interface IEventsDispatcher {
224
+ addEventListener(event: string, listener: EventListener, options?: object): void;
225
+ removeEventListener(event: string, listener: EventListener): void;
226
+ hasEventListener(event: string, listener: EventListener): boolean;
227
+ dispatchEvent(event: string | Event): void;
228
+ dispatchEventAsync(event: string | Event): void;
229
+ clearListeners(): void;
230
+ }
231
+ export enum SettingsTheme {
232
+ LIGHT_THEME = "ascn-light",
233
+ DARK_THEME = "ascn-dark"
234
+ }
235
+ export const defaultThemeAppearance: string;
236
+ export type ViewerSettings = Record<string, any>;
237
+ export class ViewerConfiguration {
238
+ settingsPrefix: string;
239
+ appearance: ViewerSettings;
240
+ createConfiguration(configuration: ViewerSettings, origin: ViewerSettings): void;
241
+ mergeConfigurationAndSettings(configuration: ViewerSettings, settings: ISettings): void;
242
+ changeTheme(newTheme: string): void;
243
+ }
244
+ export type ErrorCallback = (message: string) => void;
245
+ export type SuccessCallback = (modelId: any) => void;
246
+ export enum DocumentType {
247
+ UNKNOWN = 0,
248
+ DOCUMENT_2D = 1,
249
+ DOCUMENT_3D = 2
250
+ }
251
+ export const defaultBaseSettings: ViewerConfiguration;
252
+ export abstract class ViewerBase {
253
+ protected _clientContainer: HTMLElement;
254
+ protected _loadingSpinner: LoadingSpinner;
255
+ protected _documentType: DocumentType;
256
+ protected _configuration: ViewerConfiguration;
257
+ readonly container: HTMLElement;
258
+ readonly extensionsLoader: ExtensionLoader;
259
+ abstract settings: ISettings;
260
+ abstract events: IEventsDispatcher;
261
+ get rootContainer(): HTMLElement;
262
+ getConfiguration(): ViewerConfiguration;
263
+ /**
264
+ *
265
+ * @returns
266
+ */
267
+ start(): Promise<number>;
268
+ /**
269
+ *
270
+ */
271
+ finish(): void;
272
+ onPostExtensionLoad(extension: ExtensionBase): void;
273
+ protected loadExtensions(): void;
274
+ protected setThemeFromSettings(): void;
275
+ }
276
+ export class EventsDispatcherCore implements IEventsDispatcher {
277
+ dispatchEventAsync(event: string | Event): void;
278
+ hasEventListener(type: string, listener: EventListener): boolean;
279
+ dispatchEvent(event: string | Event): void;
280
+ addEventListener(type: string, listener: EventListener, options?: object): void;
281
+ removeEventListener(type: string, listener: EventListener): void;
282
+ removeEvent(type: string): void;
283
+ clearListeners(): void;
284
+ }
285
+ export namespace ControlState {
286
+ enum State {
287
+ ACTIVE = 0,
288
+ INACTIVE = 1,
289
+ DISABLED = 2
290
+ }
291
+ }
292
+ export class Button extends Control {
293
+
294
+ constructor(id: string);
295
+ setIsChecked(value: boolean): void;
296
+ setState(state: ControlState.State): boolean;
297
+ setText(text: string): void;
298
+ getState(): ControlState.State;
299
+ setIcon(iconClassName: string): void;
300
+ setFromSvgTemlate(template: string): void;
301
+ /**
302
+ * Override this method to be notified when the user clicks on the button.
303
+ * @param {MouseEvent} event
304
+ */
305
+ onClick: (event: MouseEvent) => void;
306
+ /**
307
+ * Override this method to be notified when the mouse enters the button.
308
+ * @param {MouseEvent} event
309
+ */
310
+ onMouseOver: (event: MouseEvent) => void;
311
+ /**
312
+ * Override this method to be notified when the mouse leaves the button.
313
+ * @param {MouseEvent} event
314
+ */
315
+ onMouseOut: (event: MouseEvent) => void;
316
+ }
317
+ export namespace Button {
318
+ enum Event {
319
+ STATE_CHANGED = "Button.StateChanged",
320
+ CLICK = "click"
321
+ }
322
+ }
323
+ export class SubMenu implements IMenu {
324
+ readonly controls: IControl[];
325
+ set selectedIndex(value: number);
326
+ get selectedIndex(): number;
327
+ addControl(control: IControl, index?: number): void;
328
+ removeControl(index?: number): void;
329
+ clearList(): void;
330
+ changeControl(item: IControl, index: number): void;
331
+ getControlsCount(): number;
332
+ }
333
+ export class ComboButton extends Control {
334
+
335
+ constructor(id: string, selectedIndex?: number);
336
+ get subMenu(): SubMenu;
337
+ /**
338
+ * Override this method to be notified when the user clicks on the button.
339
+ * @param {MouseEvent} event
340
+ */
341
+ onClick: (event: PointerEvent) => void;
342
+ onOpen: () => void;
343
+ onClose: () => void;
344
+ setState(state: ControlState.State): boolean;
345
+ setText(text: string): void;
346
+ setFromSvgTemlate(template: string): void;
347
+ }
348
+ export class ViewerToolbar extends Toolbar {
349
+ }
350
+ interface ElementClass {
351
+ panelClassName?: string;
352
+ contentClassName?: string;
353
+ headerClassName?: string;
354
+ }
355
+ export class Dialog extends Control {
356
+ responseDialog: (state?: boolean) => void;
357
+
358
+ constructor(id: string, panelToAttach: HTMLElement);
359
+ get dialog(): HTMLElement;
360
+ get dialogContent(): HTMLElement;
361
+ get resizable(): boolean;
362
+ setDialogContent(value: HTMLElement): Dialog;
363
+ setHeader(value: HTMLElement): Dialog;
364
+ setCaption(value: string): Dialog;
365
+ setIcon(iconClassName: string): Dialog;
366
+ setFooter(value: HTMLElement): Dialog;
367
+ setDialogElementClassNames(value: ElementClass): Dialog;
368
+ setResizable(value: boolean): Dialog;
369
+ setWindowOptions(value: IWindowStateOptions): Dialog;
370
+ setDraggable(value: boolean): Dialog;
371
+ openDialog(): HTMLElement;
372
+ destroyDialog(): void;
373
+ isDialogShown(): boolean;
374
+ subscribe(fn: (state: boolean) => void): void;
375
+ }
376
+ export {};
377
+ export interface ISettingsStorage {
378
+ clear(): void;
379
+ getItem<T>(key: string): T | null;
380
+ removeItem(key: string): void;
381
+ setItem<T>(key: string, value: T): void;
382
+ getKeys(): string[];
383
+ }
384
+ export class SettingsStorageFactory {
385
+ getSettingsStorage(): ISettingsStorage;
386
+ }
387
+ export class LocalSettingsStorage implements ISettingsStorage {
388
+ clear(): void;
389
+ getItem<T>(key: string): T | null;
390
+ removeItem(key: string): void;
391
+ setItem<T>(key: string, value: T): void;
392
+ getKeys(): string[];
393
+ }
394
+ export class InMemorySettingsStorage implements ISettingsStorage {
395
+ clear(): void;
396
+ getItem<T>(key: string): T | null;
397
+ removeItem(key: string): void;
398
+ setItem<T>(key: string, value: T): void;
399
+ getKeys(): string[];
400
+ }
401
+ export abstract class SettingsBase implements ISettings {
402
+ protected _eventDispatcher: IEventsDispatcher;
403
+ protected _storage: ISettingsStorage;
404
+ changeSetting<T>(name: string, value: T, notify?: boolean, providedData?: any): void;
405
+ getSettingValue<T>(name: string): T;
406
+ protected abstract getKeyWithPrefix(key: string): string;
407
+ }
408
+ export interface IAnnotationLayer {
409
+ get pageDiv(): HTMLDivElement;
410
+ get div(): HTMLDivElement | null;
411
+ addOverlay(overlay: HTMLElement): void;
412
+ removeOverlay(overlay: HTMLElement): void;
413
+ getOverlays(): HTMLElement[];
414
+ }
415
+ export interface IPageUpdateParams {
416
+ scale?: number;
417
+ drawingDelay?: number;
418
+ }
419
+ export interface IDocumentPage {
420
+ get div(): HTMLDivElement;
421
+ get canvas(): HTMLCanvasElement | SVGSVGElement;
422
+ get pageNumber(): number;
423
+ get viewport(): DOMRect;
424
+ get annotationLayer(): IAnnotationLayer | null;
425
+ get height(): number;
426
+ get width(): number;
427
+ get scale(): number;
428
+ update(params?: IPageUpdateParams): void;
429
+ dispose(): any;
430
+ }
431
+ export interface IDocument {
432
+ loadDocumentAsync(arrayBuffer: ArrayBuffer): Promise<void>;
433
+ increaseScale(steps?: number, scaleFactor?: number): void;
434
+ decreaseScale(steps?: number, scaleFactor?: number): void;
435
+ fit(): void;
436
+ getPageAsync(pageNumber: number): Promise<IDocumentPage>;
437
+ getPageByTarget(element: HTMLElement): IDocumentPage | undefined;
438
+ dispose(): void;
439
+ }
440
+ export const ZOOM_IN_SCALE_FACTOR = 1.15;
441
+ export const ZOOM_OUT_SCALE_FACTOR = 0.85;
442
+ export const ZOOM_MAX_SCALE = 10;
443
+ export const ZOOM_MIN_SCALE = 4;
444
+ export class Viewer2DConfiguration extends ViewerConfiguration {
445
+
446
+ constructor(appearance?: ViewerSettings);
447
+ }
448
+ export let ViewerInstance: Viewer2D;
449
+ export class Viewer2D extends ViewerBase {
450
+ readonly settings: Readonly<ISettings>;
451
+ readonly events: Readonly<IEventsDispatcher>;
452
+ get document(): IDocument;
453
+ loadDocument(buffer: ArrayBuffer, options: object, onSuccessCallback: SuccessCallback, onErrorCallback: ErrorCallback): void;
454
+ unloadDocument(): void;
455
+ start(): Promise<number>;
456
+ finish(): void;
457
+ protected zoomIn(event: MouseEvent): void;
458
+ protected zoomOut(event: MouseEvent): void;
459
+ }
460
+ export class GuiViewer2D extends Viewer2D {
461
+ loadDocument(buffer: ArrayBuffer, options: object, onSuccessCallback: SuccessCallback, onErrorCallback: ErrorCallback): void;
462
+ getToolbar(): ViewerToolbar;
463
+ onPostExtensionLoad(extension: ExtensionBase): void;
464
+ protected getToolbarHeight(): number;
465
+ }
466
+ export class Extension extends ExtensionBase {
467
+ protected _viewer: Viewer2D;
468
+ }
469
+ export class Point2 {
470
+ x: number;
471
+ y: number;
472
+
473
+ constructor(x: number, y: number);
474
+ }
475
+
476
+ }
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@pilotdev/pilot-web-2d",
3
+ "version": "23.0.7-alpha.1",
4
+ "description": "TypeScript definitions for ASCON PilotWeb2D component",
5
+ "main": "",
6
+ "types": "index.d.ts",
7
+ "scripts": {},
8
+ "author": "JSC Ascon",
9
+ "license": "MIT",
10
+ "typeScriptVersion": "4.9.4",
11
+ "keywords": [
12
+ "pilotdev",
13
+ "PilotWeb3D",
14
+ "PilotWeb2D",
15
+ "Pilot-Cloud"
16
+ ]
17
+ }