@effindomv2/fui-as 0.1.27 → 0.1.30
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/browser/src/common-harness/managed-harness-file-host.ts +123 -158
- package/browser/src/common-harness/managed-harness-file-types.ts +2 -37
- package/browser/src/common-harness/managed-harness.ts +4 -0
- package/browser/src/worker-bootstrap.ts +406 -0
- package/browser/src/worker-manager.ts +4 -0
- package/browser/src/worker-types.ts +18 -0
- package/package.json +3 -2
- package/src/Fui.ts +1 -0
- package/src/FuiWorker.ts +5 -1
- package/src/controls/Button.ts +39 -6
- package/src/controls/ButtonColors.ts +73 -0
- package/src/controls/Checkbox.ts +1 -0
- package/src/controls/LabeledControlColors.ts +36 -0
- package/src/controls/RadioButton.ts +1 -0
- package/src/controls/Switch.ts +1 -0
- package/src/controls/index.ts +1 -0
- package/src/controls/internal/ButtonPresenter.ts +3 -2
- package/src/controls/internal/CheckboxIndicatorPresenter.ts +10 -8
- package/src/controls/internal/PressableLabeledControl.ts +2 -1
- package/src/controls/internal/RadioIndicatorPresenter.ts +9 -5
- package/src/controls/internal/SwitchIndicatorPresenter.ts +16 -7
- package/src/core/File.ts +5 -2
- package/src/core/event_exports.ts +15 -1
- package/src/worker/ffi.ts +6 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export class ButtonColors {
|
|
2
|
+
private backgroundSet: bool = false;
|
|
3
|
+
private backgroundValue: u32 = 0;
|
|
4
|
+
|
|
5
|
+
private backgroundHoverSet: bool = false;
|
|
6
|
+
private backgroundHoverValue: u32 = 0;
|
|
7
|
+
|
|
8
|
+
private backgroundPressedSet: bool = false;
|
|
9
|
+
private backgroundPressedValue: u32 = 0;
|
|
10
|
+
|
|
11
|
+
private textPrimarySet: bool = false;
|
|
12
|
+
private textPrimaryValue: u32 = 0;
|
|
13
|
+
|
|
14
|
+
private textMutedSet: bool = false;
|
|
15
|
+
private textMutedValue: u32 = 0;
|
|
16
|
+
|
|
17
|
+
private borderSet: bool = false;
|
|
18
|
+
private borderValue: u32 = 0;
|
|
19
|
+
|
|
20
|
+
background(color: u32): this {
|
|
21
|
+
this.backgroundValue = color;
|
|
22
|
+
this.backgroundSet = true;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
backgroundHover(color: u32): this {
|
|
27
|
+
this.backgroundHoverValue = color;
|
|
28
|
+
this.backgroundHoverSet = true;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
backgroundPressed(color: u32): this {
|
|
33
|
+
this.backgroundPressedValue = color;
|
|
34
|
+
this.backgroundPressedSet = true;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
textPrimary(color: u32): this {
|
|
39
|
+
this.textPrimaryValue = color;
|
|
40
|
+
this.textPrimarySet = true;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
textMuted(color: u32): this {
|
|
45
|
+
this.textMutedValue = color;
|
|
46
|
+
this.textMutedSet = true;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
border(color: u32): this {
|
|
51
|
+
this.borderValue = color;
|
|
52
|
+
this.borderSet = true;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get hasBackground(): bool { return this.backgroundSet; }
|
|
57
|
+
get backgroundColor(): u32 { return this.backgroundValue; }
|
|
58
|
+
|
|
59
|
+
get hasBackgroundHover(): bool { return this.backgroundHoverSet; }
|
|
60
|
+
get backgroundHoverColor(): u32 { return this.backgroundHoverValue; }
|
|
61
|
+
|
|
62
|
+
get hasBackgroundPressed(): bool { return this.backgroundPressedSet; }
|
|
63
|
+
get backgroundPressedColor(): u32 { return this.backgroundPressedValue; }
|
|
64
|
+
|
|
65
|
+
get hasTextPrimary(): bool { return this.textPrimarySet; }
|
|
66
|
+
get textPrimaryColor(): u32 { return this.textPrimaryValue; }
|
|
67
|
+
|
|
68
|
+
get hasTextMuted(): bool { return this.textMutedSet; }
|
|
69
|
+
get textMutedColor(): u32 { return this.textMutedValue; }
|
|
70
|
+
|
|
71
|
+
get hasBorder(): bool { return this.borderSet; }
|
|
72
|
+
get borderColor(): u32 { return this.borderValue; }
|
|
73
|
+
}
|
package/src/controls/Checkbox.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
export class LabeledControlColors {
|
|
2
|
+
private backgroundSet: bool = false;
|
|
3
|
+
private backgroundValue: u32 = 0;
|
|
4
|
+
|
|
5
|
+
private borderSet: bool = false;
|
|
6
|
+
private borderValue: u32 = 0;
|
|
7
|
+
|
|
8
|
+
private accentSet: bool = false;
|
|
9
|
+
private accentValue: u32 = 0;
|
|
10
|
+
|
|
2
11
|
private textPrimarySet: bool = false;
|
|
3
12
|
private textPrimaryValue: u32 = 0;
|
|
4
13
|
|
|
5
14
|
private textMutedSet: bool = false;
|
|
6
15
|
private textMutedValue: u32 = 0;
|
|
7
16
|
|
|
17
|
+
background(color: u32): this {
|
|
18
|
+
this.backgroundValue = color;
|
|
19
|
+
this.backgroundSet = true;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
border(color: u32): this {
|
|
24
|
+
this.borderValue = color;
|
|
25
|
+
this.borderSet = true;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
accent(color: u32): this {
|
|
30
|
+
this.accentValue = color;
|
|
31
|
+
this.accentSet = true;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
8
35
|
textPrimary(color: u32): this {
|
|
9
36
|
this.textPrimaryValue = color;
|
|
10
37
|
this.textPrimarySet = true;
|
|
@@ -17,6 +44,15 @@ export class LabeledControlColors {
|
|
|
17
44
|
return this;
|
|
18
45
|
}
|
|
19
46
|
|
|
47
|
+
get hasBackground(): bool { return this.backgroundSet; }
|
|
48
|
+
get backgroundColor(): u32 { return this.backgroundValue; }
|
|
49
|
+
|
|
50
|
+
get hasBorder(): bool { return this.borderSet; }
|
|
51
|
+
get borderColor(): u32 { return this.borderValue; }
|
|
52
|
+
|
|
53
|
+
get hasAccent(): bool { return this.accentSet; }
|
|
54
|
+
get accentColor(): u32 { return this.accentValue; }
|
|
55
|
+
|
|
20
56
|
get hasTextPrimary(): bool { return this.textPrimarySet; }
|
|
21
57
|
get textPrimaryColor(): u32 { return this.textPrimaryValue; }
|
|
22
58
|
|
package/src/controls/Switch.ts
CHANGED
package/src/controls/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Button } from "./Button";
|
|
2
|
+
export { ButtonColors } from "./ButtonColors";
|
|
2
3
|
export { Checkbox } from "./Checkbox";
|
|
3
4
|
export { DropdownSizing, LabeledControlSizing, SliderSizing } from "./ControlSizing";
|
|
4
5
|
export { LabeledControlColors } from "./LabeledControlColors";
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { Theme } from "../../core/Theme";
|
|
8
8
|
import { FontStyle, FontWeight } from "../../core/Typography";
|
|
9
9
|
import { FlexBox, TextCore } from "../../nodes";
|
|
10
|
+
import { ButtonColors } from "../ButtonColors";
|
|
10
11
|
|
|
11
12
|
export class ButtonVisualState {
|
|
12
13
|
constructor(
|
|
@@ -42,7 +43,7 @@ export abstract class ButtonPresenter {
|
|
|
42
43
|
return changetype<FlexBox>(this.hostValue);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
abstract apply(theme: Theme, state: ButtonVisualState): void;
|
|
46
|
+
abstract apply(theme: Theme, state: ButtonVisualState, colors?: ButtonColors | null): void;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export abstract class ButtonTemplate {
|
|
@@ -60,7 +61,7 @@ class DefaultButtonPresenter extends ButtonPresenter {
|
|
|
60
61
|
super(contentRoot, labelNode);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
apply(theme: Theme, state: ButtonVisualState): void {
|
|
64
|
+
apply(theme: Theme, state: ButtonVisualState, _colors: ButtonColors | null = null): void {
|
|
64
65
|
const background = state.pressed
|
|
65
66
|
? theme.colors.accentPressed
|
|
66
67
|
: (state.hovered ? theme.colors.accentHovered : theme.colors.accent);
|
|
@@ -2,6 +2,7 @@ import { BorderStyle, SemanticCheckedState, Unit } from "../../core/ffi";
|
|
|
2
2
|
import { Theme } from "../../core/Theme";
|
|
3
3
|
import { FlexBox, Svg } from "../../nodes";
|
|
4
4
|
import { LabeledControlSizing } from "../ControlSizing";
|
|
5
|
+
import { LabeledControlColors } from "../LabeledControlColors";
|
|
5
6
|
import {
|
|
6
7
|
PressableIndicatorMetrics,
|
|
7
8
|
PressableIndicatorPresenter,
|
|
@@ -51,7 +52,7 @@ export abstract class CheckboxIndicatorPresenter extends PressableIndicatorPrese
|
|
|
51
52
|
super(root, metrics);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
abstract apply(theme: Theme, state: CheckboxIndicatorVisualState): void;
|
|
55
|
+
abstract apply(theme: Theme, state: CheckboxIndicatorVisualState, colors?: LabeledControlColors | null): void;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
export abstract class CheckboxIndicatorTemplate {
|
|
@@ -83,20 +84,21 @@ class DefaultCheckboxIndicatorPresenter extends CheckboxIndicatorPresenter {
|
|
|
83
84
|
root.child(markHost);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
apply(theme: Theme, state: CheckboxIndicatorVisualState): void {
|
|
87
|
-
let background = theme.colors.surface;
|
|
88
|
-
let borderColor = theme.colors.border;
|
|
87
|
+
apply(theme: Theme, state: CheckboxIndicatorVisualState, colors: LabeledControlColors | null = null): void {
|
|
88
|
+
let background = colors !== null && colors.hasBackground ? colors.backgroundColor : theme.colors.surface;
|
|
89
|
+
let borderColor = colors !== null && colors.hasBorder ? colors.borderColor : theme.colors.border;
|
|
89
90
|
const geometry = this.geometry;
|
|
90
91
|
let markVisible = false;
|
|
91
92
|
let markColor = theme.colors.textPrimary;
|
|
93
|
+
const accent = colors !== null && colors.hasAccent
|
|
94
|
+
? colors.accentColor
|
|
95
|
+
: (state.pressed ? theme.colors.accentPressed : (state.hovered ? theme.colors.accentHovered : theme.colors.accent));
|
|
92
96
|
if (state.checkedState == SemanticCheckedState.True || state.checkedState == SemanticCheckedState.Mixed) {
|
|
93
|
-
background =
|
|
94
|
-
? theme.colors.accentPressed
|
|
95
|
-
: (state.hovered ? theme.colors.accentHovered : theme.colors.accent);
|
|
97
|
+
background = accent;
|
|
96
98
|
borderColor = background;
|
|
97
99
|
markVisible = state.checkedState == SemanticCheckedState.True;
|
|
98
100
|
markColor = theme.colors.textOnAccent;
|
|
99
|
-
} else if (state.hovered) {
|
|
101
|
+
} else if (state.hovered && (colors === null || !colors.hasBackground)) {
|
|
100
102
|
background = theme.colors.background;
|
|
101
103
|
}
|
|
102
104
|
this.root.cornerRadius(geometry.cornerRadius);
|
|
@@ -32,7 +32,7 @@ export class PressableLabeledControl extends FlexBox {
|
|
|
32
32
|
private readonly disposables: Array<Disposable> = new Array<Disposable>();
|
|
33
33
|
private disposed: bool = false;
|
|
34
34
|
private labelFontSizeOverride: f32 = 0.0;
|
|
35
|
-
|
|
35
|
+
protected colorsValue: LabeledControlColors | null = null;
|
|
36
36
|
protected hoveredState: bool = false;
|
|
37
37
|
protected pressedState: bool = false;
|
|
38
38
|
protected focusedState: bool = false;
|
|
@@ -182,6 +182,7 @@ export class PressableLabeledControl extends FlexBox {
|
|
|
182
182
|
colors(colors: LabeledControlColors | null): this {
|
|
183
183
|
this.colorsValue = colors;
|
|
184
184
|
this.syncBaseTheme(activeTheme.value);
|
|
185
|
+
this.syncVisualState();
|
|
185
186
|
return this;
|
|
186
187
|
}
|
|
187
188
|
|
|
@@ -2,6 +2,7 @@ import { BorderStyle, Unit } from "../../core/ffi";
|
|
|
2
2
|
import { Theme } from "../../core/Theme";
|
|
3
3
|
import { FlexBox } from "../../nodes";
|
|
4
4
|
import { LabeledControlSizing } from "../ControlSizing";
|
|
5
|
+
import { LabeledControlColors } from "../LabeledControlColors";
|
|
5
6
|
import {
|
|
6
7
|
PressableIndicatorMetrics,
|
|
7
8
|
PressableIndicatorPresenter,
|
|
@@ -25,7 +26,7 @@ export abstract class RadioIndicatorPresenter extends PressableIndicatorPresente
|
|
|
25
26
|
super(root, metrics);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
abstract apply(theme: Theme, state: RadioIndicatorVisualState): void;
|
|
29
|
+
abstract apply(theme: Theme, state: RadioIndicatorVisualState, colors?: LabeledControlColors | null): void;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export abstract class RadioIndicatorTemplate {
|
|
@@ -88,14 +89,17 @@ class DefaultRadioIndicatorPresenter extends RadioIndicatorPresenter {
|
|
|
88
89
|
root.child(dotNode);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
apply(theme: Theme, state: RadioIndicatorVisualState): void {
|
|
92
|
+
apply(theme: Theme, state: RadioIndicatorVisualState, colors: LabeledControlColors | null = null): void {
|
|
92
93
|
const geometry = this.geometry;
|
|
94
|
+
const accent = colors !== null && colors.hasAccent
|
|
95
|
+
? colors.accentColor
|
|
96
|
+
: (state.pressed ? theme.colors.accentPressed : (state.hovered ? theme.colors.accentHovered : theme.colors.accent));
|
|
93
97
|
const outerColor = state.checked
|
|
94
|
-
?
|
|
95
|
-
: theme.colors.border;
|
|
98
|
+
? accent
|
|
99
|
+
: (colors !== null && colors.hasBorder ? colors.borderColor : theme.colors.border);
|
|
96
100
|
this.root.cornerRadius(geometry.indicatorSize * 0.5);
|
|
97
101
|
this.root.border(geometry.borderWidth, outerColor, BorderStyle.Solid);
|
|
98
|
-
this.root.bgColor(theme.colors.surface);
|
|
102
|
+
this.root.bgColor(colors !== null && colors.hasBackground ? colors.backgroundColor : theme.colors.surface);
|
|
99
103
|
this.dotNode
|
|
100
104
|
.cornerRadius(geometry.dotSize * 0.5)
|
|
101
105
|
.position(dotInset(geometry), dotInset(geometry))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BorderStyle, Unit } from "../../core/ffi";
|
|
2
2
|
import { Theme } from "../../core/Theme";
|
|
3
3
|
import { FlexBox } from "../../nodes";
|
|
4
|
+
import { LabeledControlColors } from "../LabeledControlColors";
|
|
4
5
|
import {
|
|
5
6
|
PressableIndicatorMetrics,
|
|
6
7
|
PressableIndicatorPresenter,
|
|
@@ -24,7 +25,7 @@ export abstract class SwitchIndicatorPresenter extends PressableIndicatorPresent
|
|
|
24
25
|
super(root, metrics);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
abstract apply(theme: Theme, state: SwitchIndicatorVisualState): void;
|
|
28
|
+
abstract apply(theme: Theme, state: SwitchIndicatorVisualState, colors?: LabeledControlColors | null): void;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export abstract class SwitchIndicatorTemplate {
|
|
@@ -49,17 +50,25 @@ class DefaultSwitchIndicatorPresenter extends SwitchIndicatorPresenter {
|
|
|
49
50
|
root.alignItems(1).child(thumbNode);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
apply(theme: Theme, state: SwitchIndicatorVisualState): void {
|
|
53
|
+
apply(theme: Theme, state: SwitchIndicatorVisualState, colors: LabeledControlColors | null = null): void {
|
|
54
|
+
const accent = colors !== null && colors.hasAccent
|
|
55
|
+
? colors.accentColor
|
|
56
|
+
: (state.pressed ? theme.colors.accentPressed : (state.hovered ? theme.colors.accentHovered : theme.colors.accent));
|
|
53
57
|
const trackColor = state.checked
|
|
54
|
-
?
|
|
55
|
-
: (
|
|
58
|
+
? accent
|
|
59
|
+
: (colors !== null && colors.hasBackground
|
|
60
|
+
? colors.backgroundColor
|
|
61
|
+
: (state.hovered ? theme.colors.background : theme.colors.surface));
|
|
62
|
+
const borderColor = colors !== null && colors.hasBorder
|
|
63
|
+
? colors.borderColor
|
|
64
|
+
: (state.checked ? trackColor : theme.colors.border);
|
|
56
65
|
this.root.cornerRadius(13.0);
|
|
57
|
-
this.root.border(1.0,
|
|
66
|
+
this.root.border(1.0, borderColor, BorderStyle.Solid);
|
|
58
67
|
this.root.bgColor(trackColor);
|
|
59
68
|
this.thumbNode.position(state.checked ? 21.0 : 3.0, 2.0);
|
|
60
69
|
this.thumbNode.cornerRadius(10.0);
|
|
61
|
-
this.thumbNode.bgColor(theme.colors.surface);
|
|
62
|
-
this.thumbNode.border(1.0,
|
|
70
|
+
this.thumbNode.bgColor(colors !== null && colors.hasBackground ? colors.backgroundColor : theme.colors.surface);
|
|
71
|
+
this.thumbNode.border(1.0, borderColor, BorderStyle.Solid);
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
|
package/src/core/File.ts
CHANGED
|
@@ -285,10 +285,12 @@ export class FileWorkerProcessProgress {
|
|
|
285
285
|
export class FileWorkerProcessResult {
|
|
286
286
|
readonly processedBytes: u64;
|
|
287
287
|
readonly outputFileName: string | null;
|
|
288
|
+
readonly workerResult: string | null;
|
|
288
289
|
|
|
289
|
-
constructor(processedBytes: u64, outputFileName: string | null) {
|
|
290
|
+
constructor(processedBytes: u64, outputFileName: string | null, workerResult: string | null = null) {
|
|
290
291
|
this.processedBytes = processedBytes;
|
|
291
292
|
this.outputFileName = outputFileName;
|
|
293
|
+
this.workerResult = workerResult;
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
296
|
|
|
@@ -961,12 +963,13 @@ export function handleFileWorkerProcessComplete(
|
|
|
961
963
|
requestId: u32,
|
|
962
964
|
processedBytes: u64,
|
|
963
965
|
outputFileName: string | null,
|
|
966
|
+
workerResult: string | null = null,
|
|
964
967
|
): void {
|
|
965
968
|
const request = pendingWorkerProcessRequests.has(requestId) ? unchecked(pendingWorkerProcessRequests.get(requestId)) : null;
|
|
966
969
|
if (request === null) {
|
|
967
970
|
return;
|
|
968
971
|
}
|
|
969
|
-
request.dispatchComplete(new FileWorkerProcessResult(processedBytes, outputFileName));
|
|
972
|
+
request.dispatchComplete(new FileWorkerProcessResult(processedBytes, outputFileName, workerResult));
|
|
970
973
|
}
|
|
971
974
|
|
|
972
975
|
export function handleFileWorkerProcessError(requestId: u32, status: u32, message: string | null = null): void {
|
|
@@ -371,11 +371,25 @@ export function __fui_on_file_worker_process_complete(
|
|
|
371
371
|
payloadPtr: usize,
|
|
372
372
|
payloadLen: u32,
|
|
373
373
|
): void {
|
|
374
|
-
const
|
|
374
|
+
const raw = readHostMessage(payloadPtr, payloadLen);
|
|
375
|
+
let outputFileName: string | null = null;
|
|
376
|
+
let workerResult: string | null = null;
|
|
377
|
+
if (raw !== null) {
|
|
378
|
+
const nullPos = raw.indexOf("\0");
|
|
379
|
+
if (nullPos >= 0) {
|
|
380
|
+
const before = raw.substring(0, nullPos);
|
|
381
|
+
const after = raw.substring(nullPos + 1);
|
|
382
|
+
outputFileName = before.length > 0 ? before : null;
|
|
383
|
+
workerResult = after.length > 0 ? after : null;
|
|
384
|
+
} else {
|
|
385
|
+
outputFileName = raw.length > 0 ? raw : null;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
375
388
|
handleFileWorkerProcessComplete(
|
|
376
389
|
requestId,
|
|
377
390
|
processedBytes,
|
|
378
391
|
outputFileName,
|
|
392
|
+
workerResult,
|
|
379
393
|
);
|
|
380
394
|
}
|
|
381
395
|
|
package/src/worker/ffi.ts
CHANGED
|
@@ -21,3 +21,9 @@ export declare function fui_worker_request_yield(): void;
|
|
|
21
21
|
|
|
22
22
|
@external("fui_worker_host", "fui_worker_request_yield_delay")
|
|
23
23
|
export declare function fui_worker_request_yield_delay(delayMs: i32): void;
|
|
24
|
+
|
|
25
|
+
@external("fui_worker_host", "fui_file_read_chunk")
|
|
26
|
+
export declare function fui_file_read_chunk(offsetLow: i32, offsetHigh: i32, length: i32): i32;
|
|
27
|
+
|
|
28
|
+
@external("fui_worker_host", "fui_file_worker_write_chunk")
|
|
29
|
+
export declare function fui_file_worker_write_chunk(ptr: usize, len: i32): void;
|