vim-web 1.0.0-alpha.8 → 1.0.0-alpha.9

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/dist/vim-web.d.ts CHANGED
@@ -2310,10 +2310,6 @@ interface StateRef<T> {
2310
2310
  * @param value - The new state value.
2311
2311
  */
2312
2312
  set(value: T): void;
2313
- /**
2314
- * Confirms the current state (potentially applying a confirmation transformation).
2315
- */
2316
- confirm(): void;
2317
2313
  onChange: ISimpleEvent<T>;
2318
2314
  }
2319
2315
  /**
@@ -2599,7 +2595,7 @@ type PartialUltraSettings = RecursivePartial<UltraSettings>;
2599
2595
  /**
2600
2596
  * React UI feature toggles for the Ultra viewer, passed to `React.Ultra.createViewer(container, settings)`.
2601
2597
  * Controls which UI panels and toolbar buttons are shown.
2602
- * Access at runtime via `viewer.settings.update(s => { s.ui.panelControlBar = false })`.
2598
+ * Access at runtime via `viewer.ui.controlBar.set(false)`.
2603
2599
  *
2604
2600
  * @example
2605
2601
  * const viewer = await React.Ultra.createViewer(div, {
@@ -2656,7 +2652,7 @@ type PartialWebglSettings = RecursivePartial<WebglSettings>;
2656
2652
  /**
2657
2653
  * React UI feature toggles, passed to `React.Webgl.createViewer(container, settings)`.
2658
2654
  * Controls which UI panels and toolbar buttons are shown.
2659
- * Access at runtime via `viewer.settings.update(s => { s.ui.panelBimTree = false })`.
2655
+ * Access at runtime via `viewer.ui.bimTree.set(false)`.
2660
2656
  * Not to be confused with {@link ViewerSettings} (renderer config) or {@link VimSettings} (per-model transform).
2661
2657
  *
2662
2658
  * @example
@@ -3062,6 +3058,78 @@ type GenericPanelApi = {
3062
3058
  customize(fn: (entries: GenericEntryType[]) => GenericEntryType[]): void;
3063
3059
  };
3064
3060
 
3061
+ /**
3062
+ * Reactive UI visibility API for the WebGL viewer.
3063
+ * Each member is a `StateRef<boolean>` that can be read, written, and subscribed to.
3064
+ *
3065
+ * @example
3066
+ * viewer.ui.bimTree.set(false) // Hide BIM tree
3067
+ * viewer.ui.controlBar.get() // Read current state
3068
+ * viewer.ui.axes.onChange.subscribe(…) // Subscribe to changes
3069
+ */
3070
+ type WebglUiApi = {
3071
+ logo: StateRef<boolean>;
3072
+ controlBar: StateRef<boolean>;
3073
+ bimTree: StateRef<boolean>;
3074
+ bimInfo: StateRef<boolean>;
3075
+ axes: StateRef<boolean>;
3076
+ performance: StateRef<boolean>;
3077
+ axesOrthographic: StateRef<boolean>;
3078
+ axesHome: StateRef<boolean>;
3079
+ cursorOrbit: StateRef<boolean>;
3080
+ cursorLookAround: StateRef<boolean>;
3081
+ cursorPan: StateRef<boolean>;
3082
+ cursorZoom: StateRef<boolean>;
3083
+ cameraAuto: StateRef<boolean>;
3084
+ cameraFrameScene: StateRef<boolean>;
3085
+ cameraFrameSelection: StateRef<boolean>;
3086
+ sectioningEnable: StateRef<boolean>;
3087
+ sectioningFitToSelection: StateRef<boolean>;
3088
+ sectioningReset: StateRef<boolean>;
3089
+ sectioningShow: StateRef<boolean>;
3090
+ sectioningAuto: StateRef<boolean>;
3091
+ sectioningSettings: StateRef<boolean>;
3092
+ measureEnable: StateRef<boolean>;
3093
+ visibilityClearSelection: StateRef<boolean>;
3094
+ visibilityShowAll: StateRef<boolean>;
3095
+ visibilityToggle: StateRef<boolean>;
3096
+ visibilityIsolate: StateRef<boolean>;
3097
+ visibilityAutoIsolate: StateRef<boolean>;
3098
+ visibilitySettings: StateRef<boolean>;
3099
+ miscProjectInspector: StateRef<boolean>;
3100
+ miscSettings: StateRef<boolean>;
3101
+ miscHelp: StateRef<boolean>;
3102
+ miscMaximise: StateRef<boolean>;
3103
+ };
3104
+ /**
3105
+ * Reactive UI visibility API for the Ultra viewer.
3106
+ */
3107
+ type UltraUiApi = {
3108
+ logo: StateRef<boolean>;
3109
+ controlBar: StateRef<boolean>;
3110
+ cursorOrbit: StateRef<boolean>;
3111
+ cursorLookAround: StateRef<boolean>;
3112
+ cursorPan: StateRef<boolean>;
3113
+ cursorZoom: StateRef<boolean>;
3114
+ cameraAuto: StateRef<boolean>;
3115
+ cameraFrameScene: StateRef<boolean>;
3116
+ cameraFrameSelection: StateRef<boolean>;
3117
+ sectioningEnable: StateRef<boolean>;
3118
+ sectioningFitToSelection: StateRef<boolean>;
3119
+ sectioningReset: StateRef<boolean>;
3120
+ sectioningShow: StateRef<boolean>;
3121
+ sectioningAuto: StateRef<boolean>;
3122
+ sectioningSettings: StateRef<boolean>;
3123
+ visibilityClearSelection: StateRef<boolean>;
3124
+ visibilityShowAll: StateRef<boolean>;
3125
+ visibilityToggle: StateRef<boolean>;
3126
+ visibilityIsolate: StateRef<boolean>;
3127
+ visibilityAutoIsolate: StateRef<boolean>;
3128
+ visibilitySettings: StateRef<boolean>;
3129
+ miscSettings: StateRef<boolean>;
3130
+ miscHelp: StateRef<boolean>;
3131
+ };
3132
+
3065
3133
  /**
3066
3134
  * @module public-api
3067
3135
  */
@@ -3151,6 +3219,16 @@ type WebglViewerApi = {
3151
3219
  * API to interact with the section box panel.
3152
3220
  */
3153
3221
  sectionBoxPanel: GenericPanelApi;
3222
+ /**
3223
+ * Reactive UI visibility controls. Each key from the settings `ui` block
3224
+ * is a `StateRef<boolean>` that can be read, written, and subscribed to.
3225
+ *
3226
+ * @example
3227
+ * viewer.ui.bimTree.set(false) // Hide BIM tree
3228
+ * viewer.ui.controlBar.get() // Read current state
3229
+ * viewer.ui.axes.onChange.subscribe(…) // Subscribe to changes
3230
+ */
3231
+ ui: WebglUiApi;
3154
3232
  /**
3155
3233
  * Cleans up and releases resources used by the viewer.
3156
3234
  */
@@ -3243,6 +3321,15 @@ type UltraViewerApi = {
3243
3321
  * API to interact with the section box panel.
3244
3322
  */
3245
3323
  sectionBoxPanel: GenericPanelApi;
3324
+ /**
3325
+ * Reactive UI visibility controls. Each key from the settings `ui` block
3326
+ * is a `StateRef<boolean>` that can be read, written, and subscribed to.
3327
+ *
3328
+ * @example
3329
+ * viewer.ui.logo.set(false) // Hide logo
3330
+ * viewer.ui.controlBar.get() // Read current state
3331
+ */
3332
+ ui: UltraUiApi;
3246
3333
  /**
3247
3334
  * Disposes of the viewer and its resources.
3248
3335
  */
@@ -3418,7 +3505,7 @@ type ViewerApi = WebglViewerApi | UltraViewerApi;
3418
3505
 
3419
3506
  declare namespace React {
3420
3507
  export { React_ContextMenu as ContextMenu, React_ControlBar as ControlBar, React_Errors as Errors, React_Icons as Icons, IsolationPanel, SectionBoxPanel, React_Settings as Settings, React_Ultra as Ultra, React_Webgl as Webgl, createContainer, createState };
3421
- export type { AugmentedElement, BimInfoPanelApi, Container, Data, DataCustomization, DataRender, Entry, FramingApi, FuncRef, GenericBoolEntry, GenericEntryType, GenericNumberEntry, GenericPanelApi, GenericTextEntry, Group, IsolationApi, LoadingBoxProps, MessageBoxProps, ModalApi, ModalProps, ProgressMode, Section, SectionBoxApi, StateRef, ViewerApi, VisibilityStatus };
3508
+ export type { AugmentedElement, BimInfoPanelApi, Container, Data, DataCustomization, DataRender, Entry, FramingApi, FuncRef, GenericBoolEntry, GenericEntryType, GenericNumberEntry, GenericPanelApi, GenericTextEntry, Group, IsolationApi, LoadingBoxProps, MessageBoxProps, ModalApi, ModalProps, ProgressMode, Section, SectionBoxApi, StateRef, UltraUiApi, ViewerApi, VisibilityStatus, WebglUiApi };
3422
3509
  }
3423
3510
 
3424
3511
  export { Core as Core, React as React };
@@ -74069,8 +74069,6 @@ Averrage Date/Second ${avgDataRatePS} kb
74069
74069
  this._value = value;
74070
74070
  this._onChange.dispatch(value);
74071
74071
  }
74072
- confirm() {
74073
- }
74074
74072
  get onChange() {
74075
74073
  return this._onChange.asEvent();
74076
74074
  }
@@ -74108,7 +74106,6 @@ Averrage Date/Second ${avgDataRatePS} kb
74108
74106
  }
74109
74107
  const event = React2.useRef(new distExports.SimpleEventDispatcher());
74110
74108
  const validate = React2.useRef((next, current) => next);
74111
- const confirm = React2.useRef((value) => value);
74112
74109
  const set2 = (value) => {
74113
74110
  const finalValue = validate.current(value, ref.current);
74114
74111
  if (finalValue === ref.current) return;
@@ -74126,12 +74123,6 @@ Averrage Date/Second ${avgDataRatePS} kb
74126
74123
  },
74127
74124
  set: set2,
74128
74125
  onChange: event.current.asEvent(),
74129
- /**
74130
- * Confirms the current state by applying the confirm function and updating the state.
74131
- */
74132
- confirm() {
74133
- set2(confirm.current(ref.current));
74134
- },
74135
74126
  /**
74136
74127
  * Registers a callback to be invoked when the state changes.
74137
74128
  * Accepts a sync function, a cleanup function, or a function returning a Promise<void> (which will be ignored).
@@ -74175,15 +74166,6 @@ Averrage Date/Second ${avgDataRatePS} kb
74175
74166
  React2.useEffect(() => {
74176
74167
  validate.current = on;
74177
74168
  }, []);
74178
- },
74179
- /**
74180
- * Sets a confirmation function to process the state value during confirmation.
74181
- * @param on - A function that confirms (and optionally transforms) the current state value.
74182
- */
74183
- useConfirm(on) {
74184
- React2.useEffect(() => {
74185
- confirm.current = on;
74186
- }, []);
74187
74169
  }
74188
74170
  };
74189
74171
  }
@@ -80035,8 +80017,7 @@ Averrage Date/Second ${avgDataRatePS} kb
80035
80017
  onChange: (e) => {
80036
80018
  refresher.refresh();
80037
80019
  props.state.set(e.target.value);
80038
- },
80039
- onBlur: () => props.state.confirm()
80020
+ }
80040
80021
  }
80041
80022
  );
80042
80023
  }
@@ -87180,7 +87161,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87180
87161
  },
87181
87162
  isolation: {
87182
87163
  autoIsolate: false,
87183
- showGhost: false,
87164
+ showGhost: true,
87184
87165
  transparency: true,
87185
87166
  showRooms: false
87186
87167
  },
@@ -87376,19 +87357,12 @@ Averrage Date/Second ${avgDataRatePS} kb
87376
87357
  }
87377
87358
  ];
87378
87359
  }
87379
- function makeInitialUiState(ui) {
87380
- return Object.fromEntries(
87381
- Object.entries(ui).map(([k, v]) => [k, isTrue(v)])
87382
- );
87383
- }
87384
- function tog(id2, label, key, src, uiState, setUiKey) {
87360
+ function tog(id2, label, key, src, refs) {
87385
87361
  if (src[key] === "AlwaysTrue" || src[key] === "AlwaysFalse") return [];
87386
- const state = createState(uiState[key]);
87387
- state.onChange.subscribe((v) => setUiKey(key, v));
87388
- return [{ type: "bool", id: id2, label, state }];
87362
+ return [{ type: "bool", id: id2, label, state: refs[key] }];
87389
87363
  }
87390
- function getWebglSettingsContent(viewer, isolation, uiState, setUiKey, srcUi) {
87391
- const t = (id2, label, key) => tog(id2, label, key, srcUi, uiState, setUiKey);
87364
+ function getWebglSettingsContent(viewer, isolation, refs, srcUi) {
87365
+ const t = (id2, label, key) => tog(id2, label, key, srcUi, refs);
87392
87366
  const scrollSpeedState = createState(viewer.inputs.scrollSpeed);
87393
87367
  scrollSpeedState.onChange.subscribe((v) => {
87394
87368
  viewer.inputs.scrollSpeed = v;
@@ -87449,6 +87423,110 @@ Averrage Date/Second ${avgDataRatePS} kb
87449
87423
  ...t(SettingsPanelKeys.ControlBarMiscShowMaximiseButtonToggle, "Maximise", "miscMaximise")
87450
87424
  ];
87451
87425
  }
87426
+ function useWebglUiState(initialSettings) {
87427
+ const { refs, values } = useUiRefs(initialSettings);
87428
+ const ui = React2.useMemo(() => ({
87429
+ // Panels
87430
+ logo: refs.panelLogo,
87431
+ controlBar: refs.panelControlBar,
87432
+ bimTree: refs.panelBimTree,
87433
+ bimInfo: refs.panelBimInfo,
87434
+ axes: refs.panelAxes,
87435
+ performance: refs.panelPerformance,
87436
+ // Axes panel
87437
+ axesOrthographic: refs.axesOrthographic,
87438
+ axesHome: refs.axesHome,
87439
+ // Cursors
87440
+ cursorOrbit: refs.cursorOrbit,
87441
+ cursorLookAround: refs.cursorLookAround,
87442
+ cursorPan: refs.cursorPan,
87443
+ cursorZoom: refs.cursorZoom,
87444
+ // Camera
87445
+ cameraAuto: refs.cameraAuto,
87446
+ cameraFrameScene: refs.cameraFrameScene,
87447
+ cameraFrameSelection: refs.cameraFrameSelection,
87448
+ // Section box
87449
+ sectioningEnable: refs.sectioningEnable,
87450
+ sectioningFitToSelection: refs.sectioningFitToSelection,
87451
+ sectioningReset: refs.sectioningReset,
87452
+ sectioningShow: refs.sectioningShow,
87453
+ sectioningAuto: refs.sectioningAuto,
87454
+ sectioningSettings: refs.sectioningSettings,
87455
+ // Measure
87456
+ measureEnable: refs.measureEnable,
87457
+ // Visibility
87458
+ visibilityClearSelection: refs.visibilityClearSelection,
87459
+ visibilityShowAll: refs.visibilityShowAll,
87460
+ visibilityToggle: refs.visibilityToggle,
87461
+ visibilityIsolate: refs.visibilityIsolate,
87462
+ visibilityAutoIsolate: refs.visibilityAutoIsolate,
87463
+ visibilitySettings: refs.visibilitySettings,
87464
+ // Misc
87465
+ miscProjectInspector: refs.miscProjectInspector,
87466
+ miscSettings: refs.miscSettings,
87467
+ miscHelp: refs.miscHelp,
87468
+ miscMaximise: refs.miscMaximise
87469
+ }), []);
87470
+ return { ui, refs, uiValues: values };
87471
+ }
87472
+ function useUltraUiState(initialSettings) {
87473
+ const { refs, values } = useUiRefs(initialSettings);
87474
+ const ui = React2.useMemo(() => ({
87475
+ // Panels
87476
+ logo: refs.panelLogo,
87477
+ controlBar: refs.panelControlBar,
87478
+ // Cursors
87479
+ cursorOrbit: refs.cursorOrbit,
87480
+ cursorLookAround: refs.cursorLookAround,
87481
+ cursorPan: refs.cursorPan,
87482
+ cursorZoom: refs.cursorZoom,
87483
+ // Camera
87484
+ cameraAuto: refs.cameraAuto,
87485
+ cameraFrameScene: refs.cameraFrameScene,
87486
+ cameraFrameSelection: refs.cameraFrameSelection,
87487
+ // Section box
87488
+ sectioningEnable: refs.sectioningEnable,
87489
+ sectioningFitToSelection: refs.sectioningFitToSelection,
87490
+ sectioningReset: refs.sectioningReset,
87491
+ sectioningShow: refs.sectioningShow,
87492
+ sectioningAuto: refs.sectioningAuto,
87493
+ sectioningSettings: refs.sectioningSettings,
87494
+ // Visibility
87495
+ visibilityClearSelection: refs.visibilityClearSelection,
87496
+ visibilityShowAll: refs.visibilityShowAll,
87497
+ visibilityToggle: refs.visibilityToggle,
87498
+ visibilityIsolate: refs.visibilityIsolate,
87499
+ visibilityAutoIsolate: refs.visibilityAutoIsolate,
87500
+ visibilitySettings: refs.visibilitySettings,
87501
+ // Misc
87502
+ miscSettings: refs.miscSettings,
87503
+ miscHelp: refs.miscHelp
87504
+ }), []);
87505
+ return { ui, refs, uiValues: values };
87506
+ }
87507
+ function useUiRefs(initialSettings) {
87508
+ const [values, setValues] = React2.useState(
87509
+ () => Object.fromEntries(
87510
+ Object.entries(initialSettings).map(([k, v]) => [k, isTrue(v)])
87511
+ )
87512
+ );
87513
+ const refs = React2.useMemo(() => {
87514
+ const result = {};
87515
+ for (const [key, initial] of Object.entries(initialSettings)) {
87516
+ result[key] = createState(isTrue(initial));
87517
+ }
87518
+ return result;
87519
+ }, []);
87520
+ React2.useEffect(() => {
87521
+ const unsubs = Object.keys(refs).map(
87522
+ (key) => refs[key].onChange.subscribe((v) => {
87523
+ setValues((prev) => ({ ...prev, [key]: v }));
87524
+ })
87525
+ );
87526
+ return () => unsubs.forEach((u) => u());
87527
+ }, []);
87528
+ return { refs, values };
87529
+ }
87452
87530
  function createWebglViewer(container, settings2 = {}, coreSettings = {}) {
87453
87531
  const cmpContainer = container instanceof HTMLElement ? createContainer(container) : container ?? createContainer();
87454
87532
  const viewer = createCoreWebglViewer(coreSettings);
@@ -87480,8 +87558,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87480
87558
  const WebglViewerComponent = React2.forwardRef((props, ref) => {
87481
87559
  const settings2 = createSettings(props.settings ?? {}, getDefaultSettings());
87482
87560
  const modal = React2.useRef(null);
87483
- const [uiState, setUiState] = React2.useState(() => makeInitialUiState(settings2.ui));
87484
- const setUiKey = (key, value) => setUiState((prev) => ({ ...prev, [key]: value }));
87561
+ const { ui: uiApi, refs: uiRefs, uiValues: uiState } = useWebglUiState(settings2.ui);
87485
87562
  const effectiveSettings = { ...settings2, ui: { ...settings2.ui, ...uiState } };
87486
87563
  React2.useEffect(() => {
87487
87564
  if (!settings2.capacity.canReadLocalStorage) disableLocalStorage();
@@ -87534,6 +87611,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87534
87611
  return modal.current;
87535
87612
  },
87536
87613
  bimInfo: bimInfoRef,
87614
+ ui: uiApi,
87537
87615
  dispose: () => {
87538
87616
  }
87539
87617
  }), []);
@@ -87563,7 +87641,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87563
87641
  SettingsPanel,
87564
87642
  {
87565
87643
  visible: side.getContent() === "settings",
87566
- content: getWebglSettingsContent(props.viewer, isolationRef, uiState, setUiKey, settings2.ui)
87644
+ content: getWebglSettingsContent(props.viewer, isolationRef, uiRefs, settings2.ui)
87567
87645
  }
87568
87646
  )
87569
87647
  ] });
@@ -87970,6 +88048,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87970
88048
  }
87971
88049
  const UltraViewerComponent = React2.forwardRef((props, ref) => {
87972
88050
  const settings2 = createSettings(props.settings ?? {}, getDefaultUltraSettings());
88051
+ const { ui: uiApi, uiValues: uiState } = useUltraUiState(settings2.ui);
87973
88052
  const sectionBoxRef = useUltraSectionBox(props.core, settings2.sectionBox);
87974
88053
  const framing = useUltraFraming(props.core, sectionBoxRef, settings2.camera.autoCamera);
87975
88054
  const isolationPanelHandle = React2.useRef(null);
@@ -88009,6 +88088,7 @@ Averrage Date/Second ${avgDataRatePS} kb
88009
88088
  },
88010
88089
  dispose: () => {
88011
88090
  },
88091
+ ui: uiApi,
88012
88092
  controlBar: controlBarApi,
88013
88093
  load: patchLoad(props.core, modalHandle),
88014
88094
  unload: (vim) => props.core.unload(vim)
@@ -88040,13 +88120,13 @@ Averrage Date/Second ${avgDataRatePS} kb
88040
88120
  ),
88041
88121
  /* @__PURE__ */ jsxRuntimeExports.jsx(RestOfScreen, { side, content: () => {
88042
88122
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
88043
- whenTrue(settings2.ui.panelLogo, /* @__PURE__ */ jsxRuntimeExports.jsx(LogoMemo, {})),
88123
+ uiState.panelLogo && /* @__PURE__ */ jsxRuntimeExports.jsx(LogoMemo, {}),
88044
88124
  /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { canvas: props.core.viewport.canvas }),
88045
88125
  /* @__PURE__ */ jsxRuntimeExports.jsx(
88046
88126
  ControlBar,
88047
88127
  {
88048
88128
  content: controlBar,
88049
- show: isTrue(settings2.ui.panelControlBar)
88129
+ show: uiState.panelControlBar
88050
88130
  }
88051
88131
  ),
88052
88132
  /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBoxRef }),