vim-web 0.3.44-dev.71 → 0.3.44-dev.73

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,5 +1,6 @@
1
1
  import { StateRef } from "../helpers/reactUtils";
2
2
  import { GenericEntryType } from "./genericField";
3
+ import { Customizer } from "../helpers/customizer";
3
4
  export interface GenericPanelProps {
4
5
  showPanel: StateRef<boolean>;
5
6
  header?: React.ReactNode;
@@ -7,9 +8,5 @@ export interface GenericPanelProps {
7
8
  onClose?: () => void;
8
9
  anchorElement: HTMLElement | null;
9
10
  }
10
- export declare const GenericPanel: import("react").ForwardRefExoticComponent<GenericPanelProps & import("react").RefAttributes<GenericPanelRef>>;
11
- export type GenericPanelRef = Customizer<GenericEntryType[]>;
12
- export interface Customizer<TData> {
13
- customize(fn: (entries: TData) => TData): any;
14
- }
15
- export declare function useCustomizer<TData>(baseEntries: TData, ref: React.Ref<Customizer<TData>>): TData;
11
+ export type GenericPanelHandle = Customizer<GenericEntryType[]>;
12
+ export declare const GenericPanel: import("react").ForwardRefExoticComponent<GenericPanelProps & import("react").RefAttributes<GenericPanelHandle>>;
@@ -0,0 +1,2 @@
1
+ export type * from './genericField';
2
+ export { type GenericPanelHandle } from './genericPanel';
@@ -0,0 +1,4 @@
1
+ export interface Customizer<TData> {
2
+ customize(fn: (entries: TData) => TData): any;
3
+ }
4
+ export declare function useCustomizer<TData>(baseEntries: TData, ref: React.Ref<Customizer<TData>>): TData;
@@ -34,6 +34,18 @@ export interface StateRef<T> {
34
34
  confirm(): void;
35
35
  onChange: ISimpleEvent<T>;
36
36
  }
37
+ /**
38
+ * A basic implementation of StateRef<T> without React.
39
+ */
40
+ export declare class MutableState<T> implements StateRef<T> {
41
+ private _value;
42
+ private _onChange;
43
+ constructor(initial: T);
44
+ get(): T;
45
+ set(value: T): void;
46
+ confirm(): void;
47
+ get onChange(): ISimpleEvent<T>;
48
+ }
37
49
  export interface StateRefresher {
38
50
  refresh: () => void;
39
51
  }
@@ -10,4 +10,5 @@ export * as Urls from './urls';
10
10
  export * from './container';
11
11
  export * from './panels';
12
12
  export * from './helpers';
13
+ export * from './generic';
13
14
  export type * from './state';
@@ -4,7 +4,7 @@
4
4
  import React from 'react';
5
5
  import { CameraRef } from '../state/cameraState';
6
6
  import { TreeActionRef } from '../bim/bimTree';
7
- import { ModalRef } from './modal';
7
+ import { ModalHandle } from './modal';
8
8
  import { IsolationRef } from '../state/sharedIsolation';
9
9
  import * as Core from '../../core-viewers';
10
10
  type ClickCallback = React.MouseEvent<HTMLDivElement, MouseEvent>;
@@ -76,7 +76,7 @@ export declare const VimContextMenuMemo: React.MemoExoticComponent<typeof Contex
76
76
  export declare function ContextMenu(props: {
77
77
  viewer: Core.Webgl.Viewer;
78
78
  camera: CameraRef;
79
- modal: ModalRef;
79
+ modal: ModalHandle;
80
80
  isolation: IsolationRef;
81
81
  selection: Core.Webgl.Element3D[];
82
82
  customization?: (e: ContextMenuElement[]) => ContextMenuElement[];
@@ -1,6 +1,5 @@
1
1
  export * as ContextMenu from './contextMenu';
2
2
  export type * from './axesPanel';
3
- export type * from '../generic/genericPanel';
4
3
  export type * from './help';
5
4
  export type * from './loadingBox';
6
5
  export type * from './logo';
@@ -1,5 +1,5 @@
1
1
  import { IsolationRef } from "../state/sharedIsolation";
2
- import { GenericPanelRef } from "../generic/genericPanel";
2
+ import { GenericPanelHandle } from "../generic/genericPanel";
3
3
  export declare const IsolationPanel: import("react").ForwardRefExoticComponent<{
4
4
  state: IsolationRef;
5
- } & import("react").RefAttributes<GenericPanelRef>>;
5
+ } & import("react").RefAttributes<GenericPanelHandle>>;
@@ -7,7 +7,7 @@ export type ModalPropsTyped = (MessageBoxPropsTyped | LoadingBoxPropsTyped | Hel
7
7
  canClose?: boolean;
8
8
  onClose?: () => void;
9
9
  };
10
- export type ModalRef = {
10
+ export type ModalHandle = {
11
11
  getActiveState(): ModalPropsTyped | undefined;
12
12
  loading(content: LoadingBoxProps | undefined): void;
13
13
  message(content: MessageBoxProps | undefined): void;
@@ -15,4 +15,4 @@ export type ModalRef = {
15
15
  };
16
16
  export declare const Modal: React.ForwardRefExoticComponent<{
17
17
  canFollowLinks: boolean;
18
- } & React.RefAttributes<ModalRef>>;
18
+ } & React.RefAttributes<ModalHandle>>;
@@ -1,5 +1,5 @@
1
1
  import { SectionBoxRef } from "../state/sectionBoxState";
2
- import { GenericPanelRef } from "../generic/genericPanel";
2
+ import { GenericPanelHandle } from "../generic/genericPanel";
3
3
  export declare const SectionBoxPanel: import("react").ForwardRefExoticComponent<{
4
4
  state: SectionBoxRef;
5
- } & import("react").RefAttributes<GenericPanelRef>>;
5
+ } & import("react").RefAttributes<GenericPanelHandle>>;
@@ -6,7 +6,7 @@ import { SideState } from './sideState';
6
6
  import * as Icons from '../icons';
7
7
  import { SectionBoxRef } from './sectionBoxState';
8
8
  import { getMeasureState } from './measureState';
9
- import { ModalRef } from '../panels/modal';
9
+ import { ModalHandle } from '../panels/modal';
10
10
  import { IsolationRef } from './sharedIsolation';
11
11
  import * as ControlBar from '../controlbar';
12
12
  /**
@@ -32,7 +32,7 @@ export declare function controlBarSelection(isolation: IsolationRef): ControlBar
32
32
  /**
33
33
  * Combines all control bar sections into one control bar.
34
34
  */
35
- export declare function useControlBar(viewer: Core.Webgl.Viewer, camera: CameraRef, modal: ModalRef, side: SideState, cursor: CursorManager, settings: Settings, section: SectionBoxRef, isolationRef: IsolationRef, customization: ControlBar.ControlBarCustomization | undefined): (ControlBar.IControlBarSection | {
35
+ export declare function useControlBar(viewer: Core.Webgl.Viewer, camera: CameraRef, modal: ModalHandle, side: SideState, cursor: CursorManager, settings: Settings, section: SectionBoxRef, isolationRef: IsolationRef, customization: ControlBar.ControlBarCustomization | undefined): (ControlBar.IControlBarSection | {
36
36
  id: string;
37
37
  enable: () => boolean;
38
38
  style: string;
@@ -1,5 +1,5 @@
1
- import { ModalRef } from "../panels/modal";
1
+ import { ModalHandle } from "../panels/modal";
2
2
  import * as Core from '../../core-viewers';
3
3
  import { RefObject } from "react";
4
- export declare function updateModal(modal: RefObject<ModalRef>, state: Core.Ultra.ClientState): void;
5
- export declare function updateProgress(request: Core.Ultra.ILoadRequest, modal: ModalRef): Promise<void>;
4
+ export declare function updateModal(modal: RefObject<ModalHandle>, state: Core.Ultra.ClientState): void;
5
+ export declare function updateProgress(request: Core.Ultra.ILoadRequest, modal: ModalHandle): Promise<void>;
@@ -1,9 +1,10 @@
1
1
  import * as Core from '../../core-viewers/ultra';
2
- import { ModalRef } from '../panels/modal';
2
+ import { ModalHandle } from '../panels/modal';
3
3
  import { CameraRef } from '../state/cameraState';
4
4
  import { SectionBoxRef } from '../state/sectionBoxState';
5
5
  import { IsolationRef } from '../state/sharedIsolation';
6
6
  import { ControlBarRef } from '../controlbar';
7
+ import { GenericPanelHandle } from '../generic/';
7
8
  export type ViewerRef = {
8
9
  /**
9
10
  * The Vim viewer instance associated with the viewer.
@@ -12,7 +13,7 @@ export type ViewerRef = {
12
13
  /**
13
14
  * API to manage the modal dialog.
14
15
  */
15
- modal: ModalRef;
16
+ modal: ModalHandle;
16
17
  /**
17
18
  * API to manage the section box.
18
19
  */
@@ -26,6 +27,14 @@ export type ViewerRef = {
26
27
  */
27
28
  camera: CameraRef;
28
29
  isolation: IsolationRef;
30
+ /**
31
+ * API to interact with the isolation panel.
32
+ */
33
+ isolationPanel: GenericPanelHandle;
34
+ /**
35
+ * API to interact with the isolation panel.
36
+ */
37
+ sectionBoxPanel: GenericPanelHandle;
29
38
  /**
30
39
  * Disposes of the viewer and its resources.
31
40
  */
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as Core from '../../core-viewers';
5
5
  import { LoadRequest } from '../helpers/loadRequest';
6
- import { ModalRef } from '../panels/modal';
6
+ import { ModalHandle } from '../panels/modal';
7
7
  type AddSettings = {
8
8
  /**
9
9
  * Controls whether to frame the camera on a vim everytime it is updated.
@@ -28,7 +28,7 @@ export type LoadingError = {
28
28
  export declare class ComponentLoader {
29
29
  private _viewer;
30
30
  private _modal;
31
- constructor(viewer: Core.Webgl.Viewer, modal: React.RefObject<ModalRef>);
31
+ constructor(viewer: Core.Webgl.Viewer, modal: React.RefObject<ModalHandle>);
32
32
  /**
33
33
  * Event emitter for progress updates.
34
34
  */
@@ -9,10 +9,10 @@ import { Container } from '../container';
9
9
  import { BimInfoPanelRef } from '../bim/bimInfoData';
10
10
  import { ControlBarRef } from '../controlbar';
11
11
  import { ComponentLoader } from './loading';
12
- import { ModalRef } from '../panels/modal';
12
+ import { ModalHandle } from '../panels/modal';
13
13
  import { SectionBoxRef } from '../state/sectionBoxState';
14
14
  import { IsolationRef } from '../state/sharedIsolation';
15
- import { GenericPanelRef } from '../panels';
15
+ import { GenericPanelHandle } from '../generic';
16
16
  /**
17
17
  * Settings API managing settings applied to the viewer.
18
18
  */
@@ -83,7 +83,7 @@ export type ViewerRef = {
83
83
  /**
84
84
  * Message API to interact with the loading box.
85
85
  */
86
- modal: ModalRef;
86
+ modal: ModalHandle;
87
87
  /**
88
88
  * Camera API to interact with the viewer camera at a higher level.
89
89
  */
@@ -92,8 +92,14 @@ export type ViewerRef = {
92
92
  * API To interact with the BIM info panel.
93
93
  */
94
94
  bimInfo: BimInfoPanelRef;
95
- isolationPanel: GenericPanelRef;
96
- sectionBoxPanel: GenericPanelRef;
95
+ /**
96
+ * API to interact with the isolation panel.
97
+ */
98
+ isolationPanel: GenericPanelHandle;
99
+ /**
100
+ * API to interact with the isolation panel.
101
+ */
102
+ sectionBoxPanel: GenericPanelHandle;
97
103
  /**
98
104
  * Cleans up and releases resources used by the viewer.
99
105
  */
@@ -74583,6 +74583,26 @@ Averrage Date/Second ${avgDataRatePS} kb
74583
74583
  })
74584
74584
  );
74585
74585
  }
74586
+ class MutableState {
74587
+ constructor(initial) {
74588
+ __publicField(this, "_value");
74589
+ __publicField(this, "_onChange", new distExports.SimpleEventDispatcher());
74590
+ this._value = initial;
74591
+ }
74592
+ get() {
74593
+ return this._value;
74594
+ }
74595
+ set(value) {
74596
+ if (value === this._value) return;
74597
+ this._value = value;
74598
+ this._onChange.dispatch(value);
74599
+ }
74600
+ confirm() {
74601
+ }
74602
+ get onChange() {
74603
+ return this._onChange.asEvent();
74604
+ }
74605
+ }
74586
74606
  function useRefresher() {
74587
74607
  const [refresh, setRefresh] = React2.useState(false);
74588
74608
  return {
@@ -74817,6 +74837,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74817
74837
  }
74818
74838
  const reactUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
74819
74839
  __proto__: null,
74840
+ MutableState,
74820
74841
  useActionRef,
74821
74842
  useArgActionRef,
74822
74843
  useArgFuncRef,
@@ -75720,6 +75741,24 @@ Averrage Date/Second ${avgDataRatePS} kb
75720
75741
  }
75721
75742
  );
75722
75743
  }
75744
+ function useCustomizer(baseEntries, ref) {
75745
+ const customization = React2.useRef();
75746
+ const [entries, setEntries] = React2.useState(baseEntries);
75747
+ const applyCustomization = () => {
75748
+ setEntries(customization.current ? customization.current(baseEntries) : baseEntries);
75749
+ };
75750
+ const setCustomization = (fn) => {
75751
+ customization.current = fn;
75752
+ applyCustomization();
75753
+ };
75754
+ React2.useEffect(() => {
75755
+ applyCustomization();
75756
+ }, [baseEntries]);
75757
+ React2.useImperativeHandle(ref, () => ({
75758
+ customize: setCustomization
75759
+ }));
75760
+ return entries;
75761
+ }
75723
75762
  const GenericPanel = React2.forwardRef((props, ref) => {
75724
75763
  const panelRef = React2.useRef(null);
75725
75764
  const panelPosition = useFloatingPanelPosition(
@@ -75758,24 +75797,6 @@ Averrage Date/Second ${avgDataRatePS} kb
75758
75797
  }
75759
75798
  ) });
75760
75799
  });
75761
- function useCustomizer(baseEntries, ref) {
75762
- const customization = React2.useRef();
75763
- const [entries, setEntries] = React2.useState(baseEntries);
75764
- const applyCustomization = () => {
75765
- setEntries(customization.current ? customization.current(baseEntries) : baseEntries);
75766
- };
75767
- const setCustomization = (fn) => {
75768
- customization.current = fn;
75769
- applyCustomization();
75770
- };
75771
- React2.useEffect(() => {
75772
- applyCustomization();
75773
- }, [baseEntries]);
75774
- React2.useImperativeHandle(ref, () => ({
75775
- customize: setCustomization
75776
- }));
75777
- return entries;
75778
- }
75779
75800
  const SectionBoxPanel = React2.forwardRef(
75780
75801
  (props, ref) => {
75781
75802
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -76136,8 +76157,8 @@ Averrage Date/Second ${avgDataRatePS} kb
76136
76157
  const settings2 = useSettings(props.viewer, props.settings ?? {});
76137
76158
  const modal = React2.useRef(null);
76138
76159
  const sectionBoxRef = useWebglSectionBox(props.viewer);
76139
- const isolationPanelRef = React2.useRef(null);
76140
- const sectionBoxPanelRef = React2.useRef(null);
76160
+ const isolationPanelHandle = React2.useRef(null);
76161
+ const sectionBoxPanelHandle = React2.useRef(null);
76141
76162
  const camera2 = useWebglCamera(props.viewer, sectionBoxRef);
76142
76163
  const cursor = React2.useMemo(() => new CursorManager(props.viewer), []);
76143
76164
  const loader = React2.useRef(new ComponentLoader(props.viewer, modal));
@@ -76174,10 +76195,10 @@ Averrage Date/Second ${avgDataRatePS} kb
76174
76195
  camera: camera2,
76175
76196
  settings: settings2,
76176
76197
  get isolationPanel() {
76177
- return isolationPanelRef.current;
76198
+ return isolationPanelHandle.current;
76178
76199
  },
76179
76200
  get sectionBoxPanel() {
76180
- return sectionBoxPanelRef.current;
76201
+ return sectionBoxPanelHandle.current;
76181
76202
  },
76182
76203
  get sectionBox() {
76183
76204
  return sectionBoxRef;
@@ -76246,8 +76267,8 @@ Averrage Date/Second ${avgDataRatePS} kb
76246
76267
  show: isTrue(settings2.value.ui.controlBar)
76247
76268
  }
76248
76269
  ),
76249
- /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel, { ref: sectionBoxPanelRef, state: sectionBoxRef }),
76250
- /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel, { ref: isolationPanelRef, state: isolationRef }),
76270
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel, { ref: sectionBoxPanelHandle, state: sectionBoxRef }),
76271
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel, { ref: isolationPanelHandle, state: isolationRef }),
76251
76272
  /* @__PURE__ */ jsxRuntimeExports.jsx(
76252
76273
  AxesPanelMemo,
76253
76274
  {
@@ -76525,9 +76546,11 @@ Averrage Date/Second ${avgDataRatePS} kb
76525
76546
  return promise;
76526
76547
  }
76527
76548
  function Viewer(props) {
76528
- const modal = React2.useRef(null);
76529
76549
  const sectionBox2 = useUltraSectionBox(props.core);
76530
76550
  const camera2 = useUltraCamera(props.core, sectionBox2);
76551
+ const isolationPanelHandle = React2.useRef(null);
76552
+ const sectionBoxPanelHandle = React2.useRef(null);
76553
+ const modalHandle = React2.useRef(null);
76531
76554
  const side = useSideState(true, 400);
76532
76555
  const [_, setSelectState] = React2.useState(0);
76533
76556
  const [controlBarCustom, setControlBarCustom] = React2.useState(() => (c) => c);
@@ -76535,24 +76558,30 @@ Averrage Date/Second ${avgDataRatePS} kb
76535
76558
  const controlBar = useUltraControlBar(props.core, sectionBox2, isolation, camera2, (_2) => _2);
76536
76559
  useViewerInput(props.core.inputs, camera2);
76537
76560
  React2.useEffect(() => {
76538
- props.core.onStateChanged.subscribe((state) => updateModal(modal, state));
76561
+ props.core.onStateChanged.subscribe((state) => updateModal(modalHandle, state));
76539
76562
  props.core.selection.onSelectionChanged.subscribe(() => {
76540
76563
  setSelectState((i2) => (i2 + 1) % 2);
76541
76564
  });
76542
76565
  props.onMount({
76543
76566
  core: props.core,
76544
76567
  get modal() {
76545
- return modal.current;
76568
+ return modalHandle.current;
76546
76569
  },
76547
76570
  isolation,
76548
76571
  sectionBox: sectionBox2,
76549
76572
  camera: camera2,
76573
+ get isolationPanel() {
76574
+ return isolationPanelHandle.current;
76575
+ },
76576
+ get sectionBoxPanel() {
76577
+ return sectionBoxPanelHandle.current;
76578
+ },
76550
76579
  dispose: () => {
76551
76580
  },
76552
76581
  controlBar: {
76553
76582
  customize: (v) => setControlBarCustom(() => v)
76554
76583
  },
76555
- load: patchLoad(props.core, modal)
76584
+ load: patchLoad(props.core, modalHandle)
76556
76585
  });
76557
76586
  }, []);
76558
76587
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
@@ -76567,11 +76596,11 @@ Averrage Date/Second ${avgDataRatePS} kb
76567
76596
  show: true
76568
76597
  }
76569
76598
  ),
76570
- /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel, { state: sectionBox2 }),
76571
- /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel, { state: isolation })
76599
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel, { ref: sectionBoxPanelHandle, state: sectionBox2 }),
76600
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel, { ref: isolationPanelHandle, state: isolation })
76572
76601
  ] });
76573
76602
  } }),
76574
- /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { ref: modal, canFollowLinks: true }),
76603
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { ref: modalHandle, canFollowLinks: true }),
76575
76604
  /* @__PURE__ */ jsxRuntimeExports.jsx(
76576
76605
  ReactTooltip,
76577
76606
  {