@celestia-island/hikari 0.55.72 → 0.55.73
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/package.json
CHANGED
|
@@ -73,12 +73,40 @@ describe("pre-paint theme loader mirrors the stock preset table", () => {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
it("keeps the stored-id default literal a declared, known id", () => {
|
|
76
|
-
|
|
76
|
+
// The chain is formatted across lines, so allow any whitespace between
|
|
77
|
+
// the operator and the literal.
|
|
78
|
+
const match = /__celestiaDefaultTheme\s*\|\|\s*"([A-Za-z0-9_-]+)"/.exec(source);
|
|
77
79
|
expect(match, "the stored-id chain ends in a literal id").toBeTruthy();
|
|
78
80
|
expect(declaredIds()).toContain(match![1]);
|
|
79
81
|
expect(Object.keys(themePresets)).toContain(match![1]);
|
|
80
82
|
});
|
|
81
83
|
|
|
84
|
+
it("consults the hikari engine keys ahead of the page default", () => {
|
|
85
|
+
// The running app persists its selection under these exact keys
|
|
86
|
+
// (useTheme.ts). Without them the loading screen repaints the default
|
|
87
|
+
// brand while the app restores another theme — the pre-paint and app
|
|
88
|
+
// halves would disagree on every non-default boot. The legacy per-app
|
|
89
|
+
// prefixed keys stay AHEAD of the engine keys for back-compat.
|
|
90
|
+
expect(source).toContain('localStorage.getItem("hikari-theme")');
|
|
91
|
+
expect(source).toContain('localStorage.getItem("hikari-theme-mode")');
|
|
92
|
+
// Order is asserted inside the tid chain itself — `window.__celestiaDefaultTheme`
|
|
93
|
+
// also appears earlier (the page-themes merge block), so a whole-file search
|
|
94
|
+
// would measure the wrong occurrence.
|
|
95
|
+
const chainStart = source.indexOf("var tid =");
|
|
96
|
+
const chainEnd = source.indexOf("var theme =", chainStart);
|
|
97
|
+
expect(chainStart, "the stored-id chain is still there").toBeGreaterThan(-1);
|
|
98
|
+
expect(chainEnd).toBeGreaterThan(chainStart);
|
|
99
|
+
const chain = source.slice(chainStart, chainEnd);
|
|
100
|
+
const prefixAt = chain.indexOf('storagePrefix() + "theme"');
|
|
101
|
+
const engineAt = chain.indexOf('localStorage.getItem("hikari-theme")');
|
|
102
|
+
const pageDefaultAt = chain.indexOf("window.__celestiaDefaultTheme");
|
|
103
|
+
expect(prefixAt, "the prefixed theme key is still read").toBeGreaterThan(-1);
|
|
104
|
+
expect(engineAt, "the engine theme key is read").toBeGreaterThan(-1);
|
|
105
|
+
expect(pageDefaultAt, "the page-declared default is still read").toBeGreaterThan(-1);
|
|
106
|
+
expect(engineAt, "prefixed key stays ahead of the engine key").toBeGreaterThan(prefixAt);
|
|
107
|
+
expect(engineAt, "engine key stays ahead of the page-declared default").toBeLessThan(pageDefaultAt);
|
|
108
|
+
});
|
|
109
|
+
|
|
82
110
|
it.each(["dark", "light"] as const)(
|
|
83
111
|
"mirrors every %s scheme's primary/bg/surface",
|
|
84
112
|
(mode) => {
|