@vived/host 3.4.0 → 3.5.0
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/lib/Components/Dispatcher/UCs/DispatchThemeUC.d.ts +52 -1
- package/lib/Components/Dispatcher/UCs/DispatchThemeUC.js +7 -2
- package/lib/Components/ThemeColors/Adapter/index.d.ts +1 -0
- package/lib/Components/ThemeColors/Adapter/index.js +13 -0
- package/lib/Components/ThemeColors/Adapter/themeColorAdapter.d.ts +3 -0
- package/lib/Components/ThemeColors/Adapter/themeColorAdapter.js +23 -0
- package/lib/Components/ThemeColors/Controllers/getOnPrimaryColor.d.ts +3 -0
- package/lib/Components/ThemeColors/Controllers/getOnPrimaryColor.js +16 -0
- package/lib/Components/ThemeColors/Controllers/getOnSurfaceColor.d.ts +3 -0
- package/lib/Components/ThemeColors/Controllers/getOnSurfaceColor.js +16 -0
- package/lib/Components/ThemeColors/Controllers/getPrimaryColor.d.ts +3 -0
- package/lib/Components/ThemeColors/Controllers/getPrimaryColor.js +16 -0
- package/lib/Components/ThemeColors/Controllers/getSurfaceColor.d.ts +3 -0
- package/lib/Components/ThemeColors/Controllers/getSurfaceColor.js +16 -0
- package/lib/Components/ThemeColors/Controllers/getSurfaceContainerColor.d.ts +3 -0
- package/lib/Components/ThemeColors/Controllers/getSurfaceContainerColor.js +16 -0
- package/lib/Components/ThemeColors/Controllers/index.d.ts +5 -0
- package/lib/Components/ThemeColors/Controllers/index.js +17 -0
- package/lib/Components/ThemeColors/Data/index.d.ts +2 -0
- package/lib/Components/ThemeColors/Data/index.js +10 -0
- package/lib/Components/ThemeColors/Data/vivedDarkTheme.json +51 -0
- package/lib/Components/ThemeColors/Data/vivedLightTheme.json +51 -0
- package/lib/Components/ThemeColors/Entities/HostThemeEntity.d.ts +127 -0
- package/lib/Components/ThemeColors/Entities/HostThemeEntity.js +166 -0
- package/lib/Components/ThemeColors/Entities/index.d.ts +1 -0
- package/lib/Components/ThemeColors/Entities/index.js +13 -0
- package/lib/Components/ThemeColors/Mocks/MockThemeColorPM.d.ts +8 -0
- package/lib/Components/ThemeColors/Mocks/MockThemeColorPM.js +15 -0
- package/lib/Components/ThemeColors/Mocks/index.d.ts +1 -0
- package/lib/Components/ThemeColors/Mocks/index.js +13 -0
- package/lib/Components/ThemeColors/PM/ThemeColorsPM.d.ts +12 -0
- package/lib/Components/ThemeColors/PM/ThemeColorsPM.js +46 -0
- package/lib/Components/ThemeColors/PM/index.d.ts +1 -0
- package/lib/Components/ThemeColors/PM/index.js +13 -0
- package/lib/Components/ThemeColors/UCs/SetThemeUC.d.ts +10 -0
- package/lib/Components/ThemeColors/UCs/SetThemeUC.js +43 -0
- package/lib/Components/ThemeColors/UCs/index.d.ts +1 -0
- package/lib/Components/ThemeColors/UCs/index.js +13 -0
- package/lib/Components/ThemeColors/index.d.ts +7 -0
- package/lib/Components/ThemeColors/index.js +19 -0
- package/lib/Components/index.d.ts +1 -0
- package/lib/Components/index.js +1 -0
- package/lib/Entities/MemoizedColor.d.ts +9 -0
- package/lib/Entities/MemoizedColor.js +23 -0
- package/lib/Entities/index.d.ts +1 -0
- package/lib/Entities/index.js +1 -0
- package/lib/Utilities/addAlphaToHex.d.ts +1 -0
- package/lib/Utilities/addAlphaToHex.js +16 -0
- package/lib/Utilities/alphaToHex.d.ts +2 -0
- package/lib/Utilities/alphaToHex.js +21 -0
- package/lib/Utilities/index.d.ts +2 -0
- package/lib/Utilities/index.js +2 -0
- package/lib/ValueObjects/Color.d.ts +82 -0
- package/lib/ValueObjects/Color.js +858 -0
- package/lib/ValueObjects/index.d.ts +2 -1
- package/lib/ValueObjects/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultScheme = exports.makeHostThemeEntity = exports.HostThemeEntity = exports.ThemeColorType = void 0;
|
|
4
|
+
const Entities_1 = require("../../../Entities");
|
|
5
|
+
const HostAppObject_1 = require("../../../HostAppObject");
|
|
6
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
7
|
+
var ThemeColorType;
|
|
8
|
+
(function (ThemeColorType) {
|
|
9
|
+
ThemeColorType["primary"] = "primary";
|
|
10
|
+
ThemeColorType["onPrimary"] = "onPrimary";
|
|
11
|
+
ThemeColorType["primaryContainer"] = "primaryContainer";
|
|
12
|
+
ThemeColorType["onPrimaryContainer"] = "onPrimaryContainer";
|
|
13
|
+
ThemeColorType["primaryFixed"] = "primaryFixed";
|
|
14
|
+
ThemeColorType["onPrimaryFixed"] = "onPrimaryFixed";
|
|
15
|
+
ThemeColorType["primaryFixedDim"] = "primaryFixedDim";
|
|
16
|
+
ThemeColorType["onPrimaryFixedVariant"] = "onPrimaryFixedVariant";
|
|
17
|
+
ThemeColorType["secondary"] = "secondary";
|
|
18
|
+
ThemeColorType["onSecondary"] = "onSecondary";
|
|
19
|
+
ThemeColorType["secondaryContainer"] = "secondaryContainer";
|
|
20
|
+
ThemeColorType["onSecondaryContainer"] = "onSecondaryContainer";
|
|
21
|
+
ThemeColorType["secondaryFixed"] = "secondaryFixed";
|
|
22
|
+
ThemeColorType["onSecondaryFixed"] = "onSecondaryFixed";
|
|
23
|
+
ThemeColorType["secondaryFixedDim"] = "secondaryFixedDim";
|
|
24
|
+
ThemeColorType["onSecondaryFixedVariant"] = "onSecondaryFixedVariant";
|
|
25
|
+
ThemeColorType["tertiary"] = "tertiary";
|
|
26
|
+
ThemeColorType["onTertiary"] = "onTertiary";
|
|
27
|
+
ThemeColorType["tertiaryContainer"] = "tertiaryContainer";
|
|
28
|
+
ThemeColorType["onTertiaryContainer"] = "onTertiaryContainer";
|
|
29
|
+
ThemeColorType["tertiaryFixed"] = "tertiaryFixed";
|
|
30
|
+
ThemeColorType["onTertiaryFixed"] = "onTertiaryFixed";
|
|
31
|
+
ThemeColorType["tertiaryFixedDim"] = "tertiaryFixedDim";
|
|
32
|
+
ThemeColorType["onTertiaryFixedVariant"] = "onTertiaryFixedVariant";
|
|
33
|
+
ThemeColorType["error"] = "error";
|
|
34
|
+
ThemeColorType["onError"] = "onError";
|
|
35
|
+
ThemeColorType["errorContainer"] = "errorContainer";
|
|
36
|
+
ThemeColorType["onErrorContainer"] = "onErrorContainer";
|
|
37
|
+
ThemeColorType["outline"] = "outline";
|
|
38
|
+
ThemeColorType["background"] = "background";
|
|
39
|
+
ThemeColorType["onBackground"] = "onBackground";
|
|
40
|
+
ThemeColorType["surface"] = "surface";
|
|
41
|
+
ThemeColorType["onSurface"] = "onSurface";
|
|
42
|
+
ThemeColorType["surfaceVariant"] = "surfaceVariant";
|
|
43
|
+
ThemeColorType["onSurfaceVariant"] = "onSurfaceVariant";
|
|
44
|
+
ThemeColorType["inverseSurface"] = "inverseSurface";
|
|
45
|
+
ThemeColorType["inverseOnSurface"] = "inverseOnSurface";
|
|
46
|
+
ThemeColorType["inversePrimary"] = "inversePrimary";
|
|
47
|
+
ThemeColorType["shadow"] = "shadow";
|
|
48
|
+
ThemeColorType["surfaceTint"] = "surfaceTint";
|
|
49
|
+
ThemeColorType["outlineVariant"] = "outlineVariant";
|
|
50
|
+
ThemeColorType["scrim"] = "scrim";
|
|
51
|
+
ThemeColorType["surfaceContainerHighest"] = "surfaceContainerHighest";
|
|
52
|
+
ThemeColorType["surfaceContainerHigh"] = "surfaceContainerHigh";
|
|
53
|
+
ThemeColorType["surfaceContainer"] = "surfaceContainer";
|
|
54
|
+
ThemeColorType["surfaceContainerLow"] = "surfaceContainerLow";
|
|
55
|
+
ThemeColorType["surfaceContainerLowest"] = "surfaceContainerLowest";
|
|
56
|
+
ThemeColorType["surfaceBright"] = "surfaceBright";
|
|
57
|
+
ThemeColorType["surfaceDim"] = "surfaceDim";
|
|
58
|
+
})(ThemeColorType = exports.ThemeColorType || (exports.ThemeColorType = {}));
|
|
59
|
+
class HostThemeEntity extends HostAppObject_1.HostAppObjectEntity {
|
|
60
|
+
}
|
|
61
|
+
exports.HostThemeEntity = HostThemeEntity;
|
|
62
|
+
HostThemeEntity.type = "HostThemeEntity";
|
|
63
|
+
HostThemeEntity.get = (appObjects) => HostAppObject_1.getSingletonComponent(HostThemeEntity.type, appObjects);
|
|
64
|
+
function makeHostThemeEntity(appObject) {
|
|
65
|
+
return new HostThemeEntityImp(appObject);
|
|
66
|
+
}
|
|
67
|
+
exports.makeHostThemeEntity = makeHostThemeEntity;
|
|
68
|
+
class HostThemeEntityImp extends HostThemeEntity {
|
|
69
|
+
constructor(appObject) {
|
|
70
|
+
super(appObject, HostThemeEntity.type);
|
|
71
|
+
this.schemeLookup = new Map();
|
|
72
|
+
this.submitScheme = (name, scheme) => {
|
|
73
|
+
if (this.schemeLookup.has(name)) {
|
|
74
|
+
this.warn("Duplicate scheme name submitted. Overwriting");
|
|
75
|
+
}
|
|
76
|
+
this.schemeLookup.set(name, scheme);
|
|
77
|
+
if (!this.activeSchemeName) {
|
|
78
|
+
this.activeSchemeName = name;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this.memoizedActiveScheme = new Entities_1.MemoizedString("", this.notifyOnChange);
|
|
82
|
+
this.getColorForType = (type) => {
|
|
83
|
+
const scheme = this.schemeLookup.get(this.activeSchemeName);
|
|
84
|
+
if (!scheme) {
|
|
85
|
+
this.error("No active scheme");
|
|
86
|
+
return ValueObjects_1.Color.RGB(0, 0, 0);
|
|
87
|
+
}
|
|
88
|
+
const colorHex = scheme[type];
|
|
89
|
+
return ValueObjects_1.Color.Hex(colorHex);
|
|
90
|
+
};
|
|
91
|
+
this.appObjects.registerSingleton(this);
|
|
92
|
+
}
|
|
93
|
+
get activeScheme() {
|
|
94
|
+
var _a;
|
|
95
|
+
return (_a = this.schemeLookup.get(this.activeSchemeName)) !== null && _a !== void 0 ? _a : exports.defaultScheme;
|
|
96
|
+
}
|
|
97
|
+
getHexForType(type) {
|
|
98
|
+
const scheme = this.schemeLookup.get(this.activeSchemeName);
|
|
99
|
+
if (!scheme) {
|
|
100
|
+
this.error("No active scheme");
|
|
101
|
+
return "#000000";
|
|
102
|
+
}
|
|
103
|
+
return scheme[type];
|
|
104
|
+
}
|
|
105
|
+
get activeSchemeName() {
|
|
106
|
+
return this.memoizedActiveScheme.val;
|
|
107
|
+
}
|
|
108
|
+
set activeSchemeName(val) {
|
|
109
|
+
if (!this.schemeLookup.has(val)) {
|
|
110
|
+
this.warn(`Unknown theme schema: ${val}. Ignoring.`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.memoizedActiveScheme.val = val;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.defaultScheme = {
|
|
117
|
+
primary: "#7BD0FF",
|
|
118
|
+
onPrimary: "#003549",
|
|
119
|
+
primaryContainer: "#004C69",
|
|
120
|
+
onPrimaryContainer: "#C4E7FF",
|
|
121
|
+
primaryFixed: "#C4E7FF",
|
|
122
|
+
onPrimaryFixed: "#001E2C",
|
|
123
|
+
primaryFixedDim: "#7BD0FF",
|
|
124
|
+
onPrimaryFixedVariant: "#004C69",
|
|
125
|
+
secondary: "#B5C9D7",
|
|
126
|
+
onSecondary: "#20333E",
|
|
127
|
+
secondaryContainer: "#374955",
|
|
128
|
+
onSecondaryContainer: "#D1E5F4",
|
|
129
|
+
secondaryFixed: "#D1E5F4",
|
|
130
|
+
onSecondaryFixed: "#0A1E28",
|
|
131
|
+
secondaryFixedDim: "#B5C9D7",
|
|
132
|
+
onSecondaryFixedVariant: "#374955",
|
|
133
|
+
tertiary: "#CAC1E9",
|
|
134
|
+
onTertiary: "#322C4C",
|
|
135
|
+
tertiaryContainer: "#484264",
|
|
136
|
+
onTertiaryContainer: "#E6DEFF",
|
|
137
|
+
tertiaryFixed: "#E6DEFF",
|
|
138
|
+
onTertiaryFixed: "#1D1736",
|
|
139
|
+
tertiaryFixedDim: "#CAC1E9",
|
|
140
|
+
onTertiaryFixedVariant: "#484264",
|
|
141
|
+
error: "#FFB4AB",
|
|
142
|
+
onError: "#690005",
|
|
143
|
+
errorContainer: "#93000A",
|
|
144
|
+
onErrorContainer: "#FFDAD6",
|
|
145
|
+
outline: "#8B9297",
|
|
146
|
+
background: "#191C1E",
|
|
147
|
+
onBackground: "#E1E2E5",
|
|
148
|
+
surface: "#111416",
|
|
149
|
+
onSurface: "#C5C6C9",
|
|
150
|
+
surfaceVariant: "#41484D",
|
|
151
|
+
onSurfaceVariant: "#C0C7CD",
|
|
152
|
+
inverseSurface: "#E1E2E5",
|
|
153
|
+
inverseOnSurface: "#191C1E",
|
|
154
|
+
inversePrimary: "#00668A",
|
|
155
|
+
shadow: "#000000",
|
|
156
|
+
surfaceTint: "#7BD0FF",
|
|
157
|
+
outlineVariant: "#41484D",
|
|
158
|
+
scrim: "#000000",
|
|
159
|
+
surfaceContainerHighest: "#333537",
|
|
160
|
+
surfaceContainerHigh: "#282A2C",
|
|
161
|
+
surfaceContainer: "#1D2022",
|
|
162
|
+
surfaceContainerLow: "#191C1E",
|
|
163
|
+
surfaceContainerLowest: "#0C0F10",
|
|
164
|
+
surfaceBright: "#37393C",
|
|
165
|
+
surfaceDim: "#111416"
|
|
166
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HostThemeEntity";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./HostThemeEntity"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { HostAppObject, HostAppObjectRepo } from "../../../HostAppObject";
|
|
3
|
+
import { ThemeColorsPM } from "../PM";
|
|
4
|
+
export declare class MockThemeColorPM extends ThemeColorsPM {
|
|
5
|
+
vmsAreEqual: jest.Mock<any, any>;
|
|
6
|
+
constructor(appObject: HostAppObject);
|
|
7
|
+
}
|
|
8
|
+
export declare function makeMockThemeColorPM(appObjects: HostAppObjectRepo): MockThemeColorPM;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMockThemeColorPM = exports.MockThemeColorPM = void 0;
|
|
4
|
+
const PM_1 = require("../PM");
|
|
5
|
+
class MockThemeColorPM extends PM_1.ThemeColorsPM {
|
|
6
|
+
constructor(appObject) {
|
|
7
|
+
super(appObject, PM_1.ThemeColorsPM.type);
|
|
8
|
+
this.vmsAreEqual = jest.fn();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.MockThemeColorPM = MockThemeColorPM;
|
|
12
|
+
function makeMockThemeColorPM(appObjects) {
|
|
13
|
+
return new MockThemeColorPM(appObjects.getOrCreate("MockThemeColorPM"));
|
|
14
|
+
}
|
|
15
|
+
exports.makeMockThemeColorPM = makeMockThemeColorPM;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MockThemeColorPM";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./MockThemeColorPM"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HostAppObject, HostAppObjectPM, HostAppObjectRepo } from "../../../HostAppObject";
|
|
2
|
+
import { ColorScheme } from "../Entities/HostThemeEntity";
|
|
3
|
+
export interface ThemeColorsVM {
|
|
4
|
+
themeName: string;
|
|
5
|
+
scheme: ColorScheme;
|
|
6
|
+
}
|
|
7
|
+
export declare const defaultThemeColorsVM: ThemeColorsVM;
|
|
8
|
+
export declare abstract class ThemeColorsPM extends HostAppObjectPM<ThemeColorsVM> {
|
|
9
|
+
static readonly type = "ThemeColorsPM";
|
|
10
|
+
static get(appObjects: HostAppObjectRepo): ThemeColorsPM | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function makeThemeColorsPM(appObject: HostAppObject): ThemeColorsPM;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeThemeColorsPM = exports.ThemeColorsPM = exports.defaultThemeColorsVM = void 0;
|
|
4
|
+
const HostAppObject_1 = require("../../../HostAppObject");
|
|
5
|
+
const HostThemeEntity_1 = require("../Entities/HostThemeEntity");
|
|
6
|
+
exports.defaultThemeColorsVM = {
|
|
7
|
+
themeName: "",
|
|
8
|
+
scheme: HostThemeEntity_1.defaultScheme
|
|
9
|
+
};
|
|
10
|
+
class ThemeColorsPM extends HostAppObject_1.HostAppObjectPM {
|
|
11
|
+
static get(appObjects) {
|
|
12
|
+
return HostAppObject_1.getSingletonComponent(ThemeColorsPM.type, appObjects);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ThemeColorsPM = ThemeColorsPM;
|
|
16
|
+
ThemeColorsPM.type = "ThemeColorsPM";
|
|
17
|
+
function makeThemeColorsPM(appObject) {
|
|
18
|
+
return new ThemeColorsPMImp(appObject);
|
|
19
|
+
}
|
|
20
|
+
exports.makeThemeColorsPM = makeThemeColorsPM;
|
|
21
|
+
class ThemeColorsPMImp extends ThemeColorsPM {
|
|
22
|
+
constructor(appObject) {
|
|
23
|
+
super(appObject, ThemeColorsPM.type);
|
|
24
|
+
this.onThemeChange = () => {
|
|
25
|
+
if (!this.themeColors)
|
|
26
|
+
return;
|
|
27
|
+
this.doUpdateView({
|
|
28
|
+
themeName: this.themeColors.activeSchemeName,
|
|
29
|
+
scheme: this.themeColors.activeScheme
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
this.appObjects.registerSingleton(this);
|
|
33
|
+
this.themeColors = HostThemeEntity_1.HostThemeEntity.get(appObject.appObjectRepo);
|
|
34
|
+
if (!this.themeColors) {
|
|
35
|
+
this.error("Unable to find HostThemeEntity");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.themeColors.addChangeObserver(this.onThemeChange);
|
|
40
|
+
this.onThemeChange();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
vmsAreEqual(a, b) {
|
|
44
|
+
return a.themeName === b.themeName;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ThemeColorsPM";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./ThemeColorsPM"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HostAppObject, HostAppObjectRepo, HostAppObjectUC } from "../../../HostAppObject";
|
|
2
|
+
export declare abstract class SetThemeUC extends HostAppObjectUC {
|
|
3
|
+
static type: string;
|
|
4
|
+
abstract lightThemeName: string;
|
|
5
|
+
abstract darkThemeName: string;
|
|
6
|
+
abstract setThemeByName(name: string): void;
|
|
7
|
+
abstract tryDetectTheme(): void;
|
|
8
|
+
static get(appObjects: HostAppObjectRepo): SetThemeUC | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function makeSetThemeUC(appObject: HostAppObject): SetThemeUC;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSetThemeUC = exports.SetThemeUC = void 0;
|
|
4
|
+
const HostAppObject_1 = require("../../../HostAppObject");
|
|
5
|
+
const Entities_1 = require("../Entities");
|
|
6
|
+
class SetThemeUC extends HostAppObject_1.HostAppObjectUC {
|
|
7
|
+
static get(appObjects) {
|
|
8
|
+
return HostAppObject_1.getSingletonComponent(SetThemeUC.type, appObjects);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SetThemeUC = SetThemeUC;
|
|
12
|
+
SetThemeUC.type = "SetThemeUC";
|
|
13
|
+
function makeSetThemeUC(appObject) {
|
|
14
|
+
return new SetThemeUCImp(appObject);
|
|
15
|
+
}
|
|
16
|
+
exports.makeSetThemeUC = makeSetThemeUC;
|
|
17
|
+
class SetThemeUCImp extends SetThemeUC {
|
|
18
|
+
constructor(appObject) {
|
|
19
|
+
super(appObject, SetThemeUC.type);
|
|
20
|
+
this.lightThemeName = "light";
|
|
21
|
+
this.darkThemeName = "dark";
|
|
22
|
+
this.appObjects.registerSingleton(this);
|
|
23
|
+
}
|
|
24
|
+
get theme() {
|
|
25
|
+
return this.getCachedSingleton(Entities_1.HostThemeEntity.type);
|
|
26
|
+
}
|
|
27
|
+
setThemeByName(name) {
|
|
28
|
+
if (!this.theme)
|
|
29
|
+
return;
|
|
30
|
+
this.theme.activeSchemeName = name;
|
|
31
|
+
}
|
|
32
|
+
tryDetectTheme() {
|
|
33
|
+
if (!this.theme)
|
|
34
|
+
return;
|
|
35
|
+
const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
36
|
+
if (darkThemeMq.matches) {
|
|
37
|
+
this.theme.activeSchemeName = this.darkThemeName;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.theme.activeSchemeName = this.darkThemeName;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SetThemeUC";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./SetThemeUC"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Adapter"), exports);
|
|
14
|
+
__exportStar(require("./Controllers"), exports);
|
|
15
|
+
__exportStar(require("./Data"), exports);
|
|
16
|
+
__exportStar(require("./Entities"), exports);
|
|
17
|
+
__exportStar(require("./Mocks"), exports);
|
|
18
|
+
__exportStar(require("./PM"), exports);
|
|
19
|
+
__exportStar(require("./UCs"), exports);
|
package/lib/Components/index.js
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./Dispatcher"), exports);
|
|
|
18
18
|
__exportStar(require("./Handler"), exports);
|
|
19
19
|
__exportStar(require("./Logger"), exports);
|
|
20
20
|
__exportStar(require("./StateMachine"), exports);
|
|
21
|
+
__exportStar(require("./ThemeColors"), exports);
|
|
21
22
|
__exportStar(require("./VivedAPI"), exports);
|
|
22
23
|
__exportStar(require("./ZSpaceHost"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Color } from "../ValueObjects";
|
|
2
|
+
export declare class MemoizedColor {
|
|
3
|
+
private _val;
|
|
4
|
+
get val(): Color;
|
|
5
|
+
set val(v: Color);
|
|
6
|
+
setValQuietly(val: Color): void;
|
|
7
|
+
private onChangeCallback;
|
|
8
|
+
constructor(initialValue: Color, onChangeCallback: () => void);
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoizedColor = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
|
+
class MemoizedColor {
|
|
6
|
+
constructor(initialValue, onChangeCallback) {
|
|
7
|
+
this._val = initialValue;
|
|
8
|
+
this.onChangeCallback = onChangeCallback;
|
|
9
|
+
}
|
|
10
|
+
get val() {
|
|
11
|
+
return this._val;
|
|
12
|
+
}
|
|
13
|
+
set val(v) {
|
|
14
|
+
if (ValueObjects_1.Color.Equal(v, this._val))
|
|
15
|
+
return;
|
|
16
|
+
this._val = v;
|
|
17
|
+
this.onChangeCallback();
|
|
18
|
+
}
|
|
19
|
+
setValQuietly(val) {
|
|
20
|
+
this._val = val;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.MemoizedColor = MemoizedColor;
|
package/lib/Entities/index.d.ts
CHANGED
package/lib/Entities/index.js
CHANGED
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./Auth"), exports);
|
|
14
14
|
__exportStar(require("./ChallengeResults"), exports);
|
|
15
15
|
__exportStar(require("./MemoizedBoolean"), exports);
|
|
16
|
+
__exportStar(require("./MemoizedColor"), exports);
|
|
16
17
|
__exportStar(require("./MemoizedNumber"), exports);
|
|
17
18
|
__exportStar(require("./MemoizedString"), exports);
|
|
18
19
|
__exportStar(require("./ObservableEntity"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addAlphaToHex(hex: string, alpha: number): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addAlphaToHex = void 0;
|
|
4
|
+
const alphaToHex_1 = require("./alphaToHex");
|
|
5
|
+
function addAlphaToHex(hex, alpha) {
|
|
6
|
+
if (!/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(hex)) {
|
|
7
|
+
console.warn("[addAlphaToHex] Hex value is not valid.");
|
|
8
|
+
return "#000";
|
|
9
|
+
}
|
|
10
|
+
if (hex.length === 4) {
|
|
11
|
+
hex = "#" + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
|
|
12
|
+
}
|
|
13
|
+
const alphaHex = alphaToHex_1.alphaToHex(alpha);
|
|
14
|
+
return `${hex}${alphaHex}`;
|
|
15
|
+
}
|
|
16
|
+
exports.addAlphaToHex = addAlphaToHex;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.alphaToHex = exports.roundHalfToEven = void 0;
|
|
4
|
+
function roundHalfToEven(number) {
|
|
5
|
+
const roundedNumber = Math.round(number);
|
|
6
|
+
if (Math.abs(roundedNumber - number) === 0.5 && roundedNumber % 2 !== 0) {
|
|
7
|
+
return roundedNumber > number ? roundedNumber - 1 : roundedNumber + 1;
|
|
8
|
+
}
|
|
9
|
+
return roundedNumber;
|
|
10
|
+
}
|
|
11
|
+
exports.roundHalfToEven = roundHalfToEven;
|
|
12
|
+
function alphaToHex(alpha) {
|
|
13
|
+
if (alpha < 0 || alpha > 1) {
|
|
14
|
+
console.warn("[alphaToHex] Alpha value must be between 0 and 1.");
|
|
15
|
+
return "00";
|
|
16
|
+
}
|
|
17
|
+
const alpha255 = roundHalfToEven(alpha * 255);
|
|
18
|
+
const alphaHex = alpha255.toString(16).padStart(2, "0");
|
|
19
|
+
return alphaHex;
|
|
20
|
+
}
|
|
21
|
+
exports.alphaToHex = alphaToHex;
|
package/lib/Utilities/index.d.ts
CHANGED
package/lib/Utilities/index.js
CHANGED
|
@@ -10,5 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./addAlphaToHex"), exports);
|
|
14
|
+
__exportStar(require("./alphaToHex"), exports);
|
|
13
15
|
__exportStar(require("./downloadFile"), exports);
|
|
14
16
|
__exportStar(require("./generateUniqueID"), exports);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export declare type BasicColor = "";
|
|
2
|
+
export interface ColorDTO {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
a: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class Color {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Color from RGBA values
|
|
11
|
+
* @param r Red value, between 0-255
|
|
12
|
+
* @param g Green value, between 0-255
|
|
13
|
+
* @param b Blue value, between 0-255
|
|
14
|
+
* @param a Alpha value, between 0-255
|
|
15
|
+
* @returns The Color
|
|
16
|
+
*/
|
|
17
|
+
static RGBA(r: number, g: number, b: number, a: number): Color;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a Color from RGB values. Alpha is set to 255
|
|
20
|
+
* @param r Red value, between 0-255
|
|
21
|
+
* @param g Green value, between 0-255
|
|
22
|
+
* @param b Blue value, between 0-255
|
|
23
|
+
* @returns The Color
|
|
24
|
+
*/
|
|
25
|
+
static RGB(r: number, g: number, b: number): Color;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @returns Creates a Color from a DTO
|
|
29
|
+
* @param data Data Transfer Object
|
|
30
|
+
*/
|
|
31
|
+
static FromDTO(data: ColorDTO): Color;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a color from a Hex value
|
|
34
|
+
* @param hex The Hex string. Example '808080'
|
|
35
|
+
* @returns The Color
|
|
36
|
+
*/
|
|
37
|
+
static Hex(hex: string): Color;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a color from the X11 standard.
|
|
40
|
+
* @param name X11 name
|
|
41
|
+
* @returns The Color. If the color name is not found, it will return Black.
|
|
42
|
+
*/
|
|
43
|
+
static X11(name: string): Color;
|
|
44
|
+
/**
|
|
45
|
+
* Checks to see if Color A equals Color B
|
|
46
|
+
* @param a Color A
|
|
47
|
+
* @param b Color B
|
|
48
|
+
* @returns True if Color A === Color B
|
|
49
|
+
*/
|
|
50
|
+
static Equal(a: Color, b: Color): boolean;
|
|
51
|
+
readonly r: number;
|
|
52
|
+
readonly g: number;
|
|
53
|
+
readonly b: number;
|
|
54
|
+
readonly a: number;
|
|
55
|
+
/**
|
|
56
|
+
* Return the r value as a percent
|
|
57
|
+
*/
|
|
58
|
+
get rPercent(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Return the g value as a percent
|
|
61
|
+
*/
|
|
62
|
+
get gPercent(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Return the b value as a percent
|
|
65
|
+
*/
|
|
66
|
+
get bPercent(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Return the a value as a percent
|
|
69
|
+
*/
|
|
70
|
+
get aPercent(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the Color values as an array [r,g,b,a]
|
|
73
|
+
*/
|
|
74
|
+
get array(): [number, number, number, number];
|
|
75
|
+
/**
|
|
76
|
+
* Returns the Color values as a hex
|
|
77
|
+
*/
|
|
78
|
+
get hex(): string;
|
|
79
|
+
get dto(): ColorDTO;
|
|
80
|
+
private clampVal;
|
|
81
|
+
private constructor();
|
|
82
|
+
}
|