vim-web 0.3.44-dev.12 → 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
|
-
|
|
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:
|
|
15
|
-
sectionReset:
|
|
16
|
-
section:
|
|
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>;
|
package/dist/vim-web.iife.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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,35 +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
|
-
topOffset.
|
|
75883
|
-
sideOffset.
|
|
75884
|
-
bottomOffset.
|
|
75885
|
-
auto.
|
|
75886
|
-
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();
|
|
75887
75909
|
});
|
|
75888
75910
|
React2.useEffect(() => {
|
|
75889
75911
|
return adapter.onSelectionChanged.sub(() => {
|
|
75890
|
-
if (auto.get()) sectionSelection();
|
|
75912
|
+
if (auto.get()) sectionSelection.call();
|
|
75891
75913
|
});
|
|
75892
75914
|
}, []);
|
|
75893
|
-
visible2.
|
|
75894
|
-
const section = (baseBox) => {
|
|
75915
|
+
visible2.useOnChange((v) => adapter.setVisible(v));
|
|
75916
|
+
const section = useArgActionRef((baseBox) => {
|
|
75895
75917
|
boxRef.current = baseBox;
|
|
75896
75918
|
const newBox = addBox(baseBox, offsetsToBox3(topOffset.get(), sideOffset.get(), bottomOffset.get()));
|
|
75897
75919
|
adapter.fitBox(newBox);
|
|
75898
|
-
};
|
|
75899
|
-
const sectionSelection = async () => {
|
|
75920
|
+
});
|
|
75921
|
+
const sectionSelection = useFuncRef(async () => {
|
|
75900
75922
|
try {
|
|
75901
75923
|
const box = await adapter.getSelectionBox() ?? await adapter.getRendererBox();
|
|
75902
|
-
section(box);
|
|
75924
|
+
section.call(box);
|
|
75903
75925
|
} catch (e) {
|
|
75904
75926
|
console.error(e);
|
|
75905
75927
|
}
|
|
75906
|
-
};
|
|
75907
|
-
const sectionReset = async () => {
|
|
75928
|
+
});
|
|
75929
|
+
const sectionReset = useFuncRef(async () => {
|
|
75908
75930
|
const box = await adapter.getRendererBox();
|
|
75909
|
-
section(box);
|
|
75910
|
-
};
|
|
75931
|
+
section.call(box);
|
|
75932
|
+
});
|
|
75911
75933
|
return {
|
|
75912
75934
|
enable,
|
|
75913
75935
|
visible: visible2,
|