dsh-arknights-theme 1.0.2 → 1.0.4

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/index.js CHANGED
@@ -41,6 +41,11 @@ const MIME = new Map([
41
41
  ['.webp', 'image/webp'],
42
42
  ['.svg', 'image/svg+xml'],
43
43
  ['.json', 'application/json; charset=utf-8'],
44
+ /* Without this entry the stylesheet went out as `application/octet-stream`, and a browser silently
45
+ * discards a `<link rel="stylesheet">` whose MIME is not `text/css` — so the whole skin was inert
46
+ * while the file itself was fine and returned 200. Locally the client half masked it by injecting
47
+ * the same CSS from the bundle; a from-scratch install has no such fallback. Reported in issue #1. */
48
+ ['.css', 'text/css; charset=utf-8'],
44
49
  ['.jpg', 'image/jpeg'],
45
50
  ['.jpeg', 'image/jpeg'],
46
51
  ['.png', 'image/png'],
@@ -80,20 +85,37 @@ export function apply(ctx) {
80
85
  * * the attribute is set by a blocking inline script, so every rule in the
81
86
  * stylesheet — all of which are scoped to it — is live from the first frame,
82
87
  * and the stylesheet stays inert in a DSH that is not running this skin.
88
+ *
89
+ * **The mechanism changed in 1.0.3 because `tapIndex` is not enough any more.** DSH now has a
90
+ * structured injection table (`webserver/index-inject`): rows are JSON data, and they feed two
91
+ * renderers — the served index, and the boot payload a static/desktop deployment ships to a
92
+ * page-side interpreter. `tapIndex` only exists in the first: it is a string transform applied to
93
+ * a served index body, so on a build that serves a static index it never runs. That is exactly the
94
+ * report in issue #1 — the asset route registered, the skin attribute read back `null`, and the
95
+ * page fell through to the stylesheet-less fallback colour. Emitting rows instead makes the same
96
+ * injection land in both deployments; the client half also sets the attribute as a last resort, so
97
+ * a third mechanism appearing later cannot silently take the skin down again.
83
98
  */
84
99
  ctx.effect(() => {
85
- const disposeTap = ctx.webServer.tapIndex((html) => {
86
- if (html.includes('data-amiya-skin=')) return html
87
- const head =
88
- '<link rel="stylesheet" href="' +
89
- ROUTE +
90
- '/assets/skin.css" data-amiya-skin="1">' +
91
- '<script data-amiya-skin="1">document.documentElement.setAttribute("data-amiya-skin","1")</script>'
92
- return html.includes('</head>')
93
- ? html.replace('</head>', head + '</head>')
94
- : head + html
95
- })
96
- return disposeTap
100
+ const listener = (table) => {
101
+ table.push(
102
+ {
103
+ kind: 'html',
104
+ placement: 'head',
105
+ html:
106
+ '<link rel="stylesheet" href="' +
107
+ ROUTE +
108
+ '/assets/skin.css" data-amiya-skin="1">',
109
+ },
110
+ {
111
+ kind: 'script',
112
+ placement: 'head',
113
+ text: 'document.documentElement.setAttribute("data-amiya-skin","1")',
114
+ },
115
+ )
116
+ }
117
+ ctx.on('webserver/index-inject', listener)
118
+ return () => ctx.off('webserver/index-inject', listener)
97
119
  }, 'amiya-wallpaper: index injection')
98
120
 
99
121
  ctx.effect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-arknights-theme",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "为《明日方舟》玩家在 DSH Web 上构建沉浸感:12 张整屏壁纸(按画面自适应的边缘虚化)、按每张图解算的玻璃与文字色、罗德岛图标体系,以及签字式的授权与选择交互。 / Building immersion for Arknights players on the DSH Web GUI: twelve full-screen wallpapers with per-image edge blur, glass and ink solved from each picture, Rhodes Island iconography, and sign-off style approval and choice interactions.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",