vim-web 0.3.44-dev.10 → 0.3.44-dev.13

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.
@@ -7,8 +7,33 @@ export declare function useStateRef<T>(initialValue: T): {
7
7
  get(): T;
8
8
  set: (value: T) => void;
9
9
  confirm(): void;
10
- useRegister(on: (value: T) => (void | (() => void))): void;
10
+ useOnChange(on: (value: T) => (void | (() => void))): void;
11
11
  useMemo<TOut>(on: (value: T) => TOut, deps?: any[]): TOut;
12
12
  useValidate(on: (value: T) => T): void;
13
13
  useConfirm(on: (value: T) => T): void;
14
14
  };
15
+ export interface ActionRef {
16
+ call(): void;
17
+ set(func: () => void): void;
18
+ }
19
+ export declare function useActionRef(action: () => void): ActionRef;
20
+ export interface ArgActionRef<T> {
21
+ call(arg: T): void;
22
+ set(func: (arg: T) => void): void;
23
+ }
24
+ export declare function useArgActionRef<T>(action: (arg: T) => void): ArgActionRef<T>;
25
+ export interface FuncRef<T> {
26
+ call(): T;
27
+ set(func: () => T): void;
28
+ }
29
+ export declare function useFuncRef<T>(func: () => T): FuncRef<T>;
30
+ export interface AsyncFuncRef<T> {
31
+ call(): Promise<T>;
32
+ set(func: () => Promise<T>): void;
33
+ }
34
+ export declare function useAsyncFuncRef<T>(func: () => Promise<T>): AsyncFuncRef<T>;
35
+ export interface ArgFuncRef<TArg, TResult> {
36
+ call(arg: TArg): TResult;
37
+ set(func: (arg: TArg) => TResult): void;
38
+ }
39
+ export declare function useArgFuncRef<TArg, TResult>(func: (arg: TArg) => TResult): ArgFuncRef<TArg, TResult>;
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { ISignal } from 'ste-signals';
3
- import { StateRef } from '../helpers/reactUtils';
3
+ import { ArgActionRef, AsyncFuncRef, StateRef } from '../helpers/reactUtils';
4
4
  export type Offsets = {
5
5
  topOffset: string;
6
6
  sideOffset: string;
@@ -11,9 +11,9 @@ export interface SectionBoxRef {
11
11
  enable: StateRef<boolean>;
12
12
  visible: StateRef<boolean>;
13
13
  auto: StateRef<boolean>;
14
- sectionSelection: () => void;
15
- sectionReset: () => void;
16
- section: (box: THREE.Box3) => void;
14
+ sectionSelection: AsyncFuncRef<void>;
15
+ sectionReset: AsyncFuncRef<void>;
16
+ section: ArgActionRef<THREE.Box3>;
17
17
  showOffsetPanel: StateRef<boolean>;
18
18
  topOffset: StateRef<string>;
19
19
  sideOffset: StateRef<string>;
@@ -67845,7 +67845,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67845
67845
  enabled: () => section.enable.get(),
67846
67846
  isOn: () => hasSelection,
67847
67847
  style: (on) => buttonDisableStyle(on),
67848
- action: () => section.sectionSelection(),
67848
+ action: () => section.sectionSelection.call(),
67849
67849
  icon: sectionBoxShrink
67850
67850
  },
67851
67851
  {
@@ -67853,7 +67853,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67853
67853
  tip: "Reset Section",
67854
67854
  enabled: () => section.enable.get(),
67855
67855
  style: (on) => buttonDefaultStyle(on),
67856
- action: () => section.sectionReset(),
67856
+ action: () => section.sectionReset.call(),
67857
67857
  icon: sectionBoxReset
67858
67858
  },
67859
67859
  {
@@ -75835,7 +75835,7 @@ Averrage Date/Second ${avgDataRatePS} kb
75835
75835
  confirm() {
75836
75836
  set2(confirm.current(ref.current));
75837
75837
  },
75838
- useRegister(on) {
75838
+ useOnChange(on) {
75839
75839
  React2.useEffect(() => {
75840
75840
  return event.current.subscribe(on);
75841
75841
  }, []);
@@ -75855,6 +75855,28 @@ Averrage Date/Second ${avgDataRatePS} kb
75855
75855
  }
75856
75856
  };
75857
75857
  }
75858
+ function useArgActionRef(action) {
75859
+ const ref = React2.useRef(action);
75860
+ return {
75861
+ call(arg) {
75862
+ ref == null ? void 0 : ref.current(arg);
75863
+ },
75864
+ set(func) {
75865
+ ref.current = func;
75866
+ }
75867
+ };
75868
+ }
75869
+ function useFuncRef(func) {
75870
+ const ref = React2.useRef(func);
75871
+ return {
75872
+ call() {
75873
+ return ref == null ? void 0 : ref.current();
75874
+ },
75875
+ set(func2) {
75876
+ ref.current = func2;
75877
+ }
75878
+ };
75879
+ }
75858
75880
  function useSectionBox(adapter) {
75859
75881
  const enable = useStateRef(false);
75860
75882
  const visible2 = useStateRef(false);
@@ -75864,14 +75886,14 @@ Averrage Date/Second ${avgDataRatePS} kb
75864
75886
  const sideOffset = useStateRef("1");
75865
75887
  const bottomOffset = useStateRef("1");
75866
75888
  const boxRef = React2.useRef(adapter.getBox());
75867
- enable.useRegister((v) => {
75889
+ enable.useOnChange((v) => {
75868
75890
  visible2.set(v);
75869
75891
  auto.set(false);
75870
75892
  showOffsetPanel.set(false);
75871
75893
  topOffset.set("1");
75872
75894
  sideOffset.set("1");
75873
75895
  bottomOffset.set("1");
75874
- void sectionReset();
75896
+ void sectionReset.call();
75875
75897
  });
75876
75898
  topOffset.useValidate((v) => sanitize(v, false));
75877
75899
  sideOffset.useValidate((v) => sanitize(v, false));
@@ -75879,37 +75901,35 @@ Averrage Date/Second ${avgDataRatePS} kb
75879
75901
  topOffset.useConfirm((v) => sanitize(v, true));
75880
75902
  sideOffset.useConfirm((v) => sanitize(v, true));
75881
75903
  bottomOffset.useConfirm((v) => sanitize(v, true));
75882
- const offsetBox = React2.useMemo(
75883
- () => offsetsToBox3(topOffset.get(), sideOffset.get(), bottomOffset.get()),
75884
- [topOffset.get(), sideOffset.get(), bottomOffset.get()]
75885
- );
75886
- React2.useEffect(() => section(boxRef.current), [offsetBox]);
75887
- auto.useRegister((v) => {
75888
- if (v) sectionSelection();
75904
+ topOffset.useOnChange((v) => section.call(boxRef.current));
75905
+ sideOffset.useOnChange((v) => section.call(boxRef.current));
75906
+ bottomOffset.useOnChange((v) => section.call(boxRef.current));
75907
+ auto.useOnChange((v) => {
75908
+ if (v) sectionSelection.call();
75889
75909
  });
75890
75910
  React2.useEffect(() => {
75891
75911
  return adapter.onSelectionChanged.sub(() => {
75892
- if (auto.get()) sectionSelection();
75912
+ if (auto.get()) sectionSelection.call();
75893
75913
  });
75894
75914
  }, []);
75895
- visible2.useRegister((v) => adapter.setVisible(v));
75896
- const section = (baseBox) => {
75915
+ visible2.useOnChange((v) => adapter.setVisible(v));
75916
+ const section = useArgActionRef((baseBox) => {
75897
75917
  boxRef.current = baseBox;
75898
- const newBox = addBox(baseBox, offsetBox);
75918
+ const newBox = addBox(baseBox, offsetsToBox3(topOffset.get(), sideOffset.get(), bottomOffset.get()));
75899
75919
  adapter.fitBox(newBox);
75900
- };
75901
- const sectionSelection = async () => {
75920
+ });
75921
+ const sectionSelection = useFuncRef(async () => {
75902
75922
  try {
75903
75923
  const box = await adapter.getSelectionBox() ?? await adapter.getRendererBox();
75904
- section(box);
75924
+ section.call(box);
75905
75925
  } catch (e) {
75906
75926
  console.error(e);
75907
75927
  }
75908
- };
75909
- const sectionReset = async () => {
75928
+ });
75929
+ const sectionReset = useFuncRef(async () => {
75910
75930
  const box = await adapter.getRendererBox();
75911
- section(box);
75912
- };
75931
+ section.call(box);
75932
+ });
75913
75933
  return {
75914
75934
  enable,
75915
75935
  visible: visible2,