@lemoncat7/dsh-theme-xiaohei 0.4.6 → 0.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.
Files changed (232) hide show
  1. package/README.md +15 -9
  2. package/THIRD_PARTY_NOTICES.md +13 -1
  3. package/docs/dsh-021-compatibility.md +23 -0
  4. package/docs/releases/0.5.0.md +24 -0
  5. package/docs/rift-interaction.md +35 -0
  6. package/docs/rift-preview.md +39 -0
  7. package/lib/client.companion.js +3 -4
  8. package/lib/client.decorations.js +224 -51
  9. package/lib/client.js +532 -2405
  10. package/lib/index.d.ts +1 -2
  11. package/lib/index.js +393 -11
  12. package/lib/rift/boot.d.ts +6 -0
  13. package/package.json +29 -19
  14. package/lib/appearance.d.ts +0 -12
  15. package/lib/appearance.js +0 -42
  16. package/lib/blink.d.ts +0 -4
  17. package/lib/blink.js +0 -110
  18. package/lib/bloub-heixiu/ambient.d.ts +0 -3
  19. package/lib/bloub-heixiu/ambient.js +0 -12
  20. package/lib/bloub-heixiu/character.d.ts +0 -33
  21. package/lib/bloub-heixiu/character.js +0 -124
  22. package/lib/bloub-heixiu/effects.d.ts +0 -4
  23. package/lib/bloub-heixiu/effects.js +0 -91
  24. package/lib/bloub-heixiu/flight.d.ts +0 -15
  25. package/lib/bloub-heixiu/flight.js +0 -66
  26. package/lib/bloub-heixiu/follow.d.ts +0 -13
  27. package/lib/bloub-heixiu/follow.js +0 -23
  28. package/lib/bloub-heixiu/layout.d.ts +0 -34
  29. package/lib/bloub-heixiu/layout.js +0 -26
  30. package/lib/bloub-heixiu/renderer.d.ts +0 -16
  31. package/lib/bloub-heixiu/renderer.js +0 -94
  32. package/lib/bloub-heixiu/runtime.d.ts +0 -6
  33. package/lib/bloub-heixiu/runtime.js +0 -440
  34. package/lib/bloub-heixiu/signals.d.ts +0 -17
  35. package/lib/bloub-heixiu/signals.js +0 -55
  36. package/lib/bloub-heixiu/styles.d.ts +0 -2
  37. package/lib/bloub-heixiu/styles.js +0 -98
  38. package/lib/boot-appearance.d.ts +0 -10
  39. package/lib/boot-appearance.js +0 -47
  40. package/lib/boot-loader.d.ts +0 -5
  41. package/lib/boot-loader.js +0 -158
  42. package/lib/chrome/accessibility.d.ts +0 -3
  43. package/lib/chrome/accessibility.js +0 -69
  44. package/lib/chrome/blink.d.ts +0 -3
  45. package/lib/chrome/blink.js +0 -15
  46. package/lib/chrome/composer-avatar.d.ts +0 -10
  47. package/lib/chrome/composer-avatar.js +0 -599
  48. package/lib/chrome/composer-send-heixiu.d.ts +0 -3
  49. package/lib/chrome/composer-send-heixiu.js +0 -143
  50. package/lib/chrome/composer.d.ts +0 -3
  51. package/lib/chrome/composer.js +0 -135
  52. package/lib/chrome/controls.d.ts +0 -8
  53. package/lib/chrome/controls.js +0 -348
  54. package/lib/chrome/conversation-messages.d.ts +0 -3
  55. package/lib/chrome/conversation-messages.js +0 -329
  56. package/lib/chrome/conversation-submissions.d.ts +0 -3
  57. package/lib/chrome/conversation-submissions.js +0 -68
  58. package/lib/chrome/conversation.d.ts +0 -3
  59. package/lib/chrome/conversation.js +0 -67
  60. package/lib/chrome/frames.d.ts +0 -6
  61. package/lib/chrome/frames.js +0 -134
  62. package/lib/chrome/gaze.d.ts +0 -3
  63. package/lib/chrome/gaze.js +0 -103
  64. package/lib/chrome/identity.d.ts +0 -6
  65. package/lib/chrome/identity.js +0 -47
  66. package/lib/chrome/overlays.d.ts +0 -3
  67. package/lib/chrome/overlays.js +0 -104
  68. package/lib/chrome/portal.d.ts +0 -6
  69. package/lib/chrome/portal.js +0 -169
  70. package/lib/chrome/reactions.d.ts +0 -3
  71. package/lib/chrome/reactions.js +0 -85
  72. package/lib/chrome/sidebar.d.ts +0 -3
  73. package/lib/chrome/sidebar.js +0 -313
  74. package/lib/chrome/tokens.d.ts +0 -3
  75. package/lib/chrome/tokens.js +0 -224
  76. package/lib/chrome/workspace.d.ts +0 -3
  77. package/lib/chrome/workspace.js +0 -94
  78. package/lib/chrome.d.ts +0 -10
  79. package/lib/chrome.js +0 -46
  80. package/lib/client-entry.d.ts +0 -3
  81. package/lib/client-entry.js +0 -3
  82. package/lib/client.d.ts +0 -10
  83. package/lib/client.pose-chin-dark.js +0 -4
  84. package/lib/client.pose-chin-light.js +0 -4
  85. package/lib/client.pose-doze-dark.js +0 -4
  86. package/lib/client.pose-doze-light.js +0 -4
  87. package/lib/client.pose-halfpeek-dark.js +0 -4
  88. package/lib/client.pose-halfpeek-light.js +0 -4
  89. package/lib/client.pose-peek-dark.js +0 -4
  90. package/lib/client.pose-peek-light.js +0 -4
  91. package/lib/client.pose-seated-dark.js +0 -4
  92. package/lib/client.pose-seated-light.js +0 -4
  93. package/lib/client.rig-chin-dark.js +0 -4
  94. package/lib/client.rig-chin-light.js +0 -4
  95. package/lib/client.rig-halfpeek-dark.js +0 -4
  96. package/lib/client.rig-halfpeek-light.js +0 -4
  97. package/lib/client.rig-peek-dark.js +0 -4
  98. package/lib/client.rig-peek-light.js +0 -4
  99. package/lib/client.rig-seated-dark.js +0 -4
  100. package/lib/client.rig-seated-light.js +0 -4
  101. package/lib/companion-entry.d.ts +0 -3
  102. package/lib/companion-entry.js +0 -3
  103. package/lib/composer-avatar.d.ts +0 -18
  104. package/lib/composer-avatar.js +0 -441
  105. package/lib/composer-draft-preview.d.ts +0 -4
  106. package/lib/composer-draft-preview.js +0 -8
  107. package/lib/composer-send-heixiu.d.ts +0 -8
  108. package/lib/composer-send-heixiu.js +0 -133
  109. package/lib/current-session.d.ts +0 -6
  110. package/lib/current-session.js +0 -5
  111. package/lib/decorations-entry.d.ts +0 -3
  112. package/lib/decorations-entry.js +0 -18
  113. package/lib/deferred-companion.d.ts +0 -5
  114. package/lib/deferred-companion.js +0 -9
  115. package/lib/deferred-decorations.d.ts +0 -3
  116. package/lib/deferred-decorations.js +0 -51
  117. package/lib/gaze.d.ts +0 -4
  118. package/lib/gaze.js +0 -230
  119. package/lib/generated-backgrounds.d.ts +0 -14
  120. package/lib/generated-backgrounds.js +0 -14
  121. package/lib/generated-character-motion.d.ts +0 -4
  122. package/lib/generated-character-motion.js +0 -2
  123. package/lib/generated-identity.d.ts +0 -6
  124. package/lib/generated-identity.js +0 -6
  125. package/lib/generated-keyart.d.ts +0 -34
  126. package/lib/generated-keyart.js +0 -34
  127. package/lib/generated-loading-assets.d.ts +0 -4
  128. package/lib/generated-loading-assets.js +0 -4
  129. package/lib/heixiu-interactions.d.ts +0 -10
  130. package/lib/heixiu-interactions.js +0 -161
  131. package/lib/host-contract.d.ts +0 -9
  132. package/lib/host-contract.js +0 -13
  133. package/lib/host-dom.d.ts +0 -11
  134. package/lib/host-dom.js +0 -72
  135. package/lib/loading-heixiu.d.ts +0 -8
  136. package/lib/loading-heixiu.js +0 -287
  137. package/lib/metallic-brand-mark.d.ts +0 -10
  138. package/lib/metallic-brand-mark.js +0 -296
  139. package/lib/plugin.d.ts +0 -6
  140. package/lib/plugin.js +0 -60
  141. package/lib/portal.d.ts +0 -40
  142. package/lib/portal.js +0 -225
  143. package/lib/reactions.d.ts +0 -20
  144. package/lib/reactions.js +0 -380
  145. package/lib/scene/avatar-model.d.ts +0 -6
  146. package/lib/scene/avatar-model.js +0 -646
  147. package/lib/scene/avatar-motion.d.ts +0 -3
  148. package/lib/scene/avatar-motion.js +0 -799
  149. package/lib/scene/character-assets.d.ts +0 -13
  150. package/lib/scene/character-assets.js +0 -26
  151. package/lib/scene/character-expression.d.ts +0 -4
  152. package/lib/scene/character-expression.js +0 -15
  153. package/lib/scene/character-eye-material.d.ts +0 -13
  154. package/lib/scene/character-eye-material.js +0 -88
  155. package/lib/scene/character-eye-renderer.d.ts +0 -5
  156. package/lib/scene/character-eye-renderer.js +0 -80
  157. package/lib/scene/character-eye-rig.d.ts +0 -20
  158. package/lib/scene/character-eye-rig.js +0 -35
  159. package/lib/scene/character-gaze.d.ts +0 -16
  160. package/lib/scene/character-gaze.js +0 -36
  161. package/lib/scene/character-idle.d.ts +0 -17
  162. package/lib/scene/character-idle.js +0 -65
  163. package/lib/scene/character-layout.d.ts +0 -24
  164. package/lib/scene/character-layout.js +0 -51
  165. package/lib/scene/character-motion-clock.d.ts +0 -18
  166. package/lib/scene/character-motion-clock.js +0 -70
  167. package/lib/scene/character-motion-types.d.ts +0 -12
  168. package/lib/scene/character-motion-types.js +0 -2
  169. package/lib/scene/character-motion.d.ts +0 -6
  170. package/lib/scene/character-motion.js +0 -187
  171. package/lib/scene/character-poses.d.ts +0 -26
  172. package/lib/scene/character-poses.js +0 -11
  173. package/lib/scene/character-rig-renderer.d.ts +0 -5
  174. package/lib/scene/character-rig-renderer.js +0 -95
  175. package/lib/scene/character-rig.d.ts +0 -22
  176. package/lib/scene/character-rig.js +0 -61
  177. package/lib/scene/heixiu-feedback.d.ts +0 -3
  178. package/lib/scene/heixiu-feedback.js +0 -64
  179. package/lib/scene/heixiu-interactions.d.ts +0 -3
  180. package/lib/scene/heixiu-interactions.js +0 -92
  181. package/lib/scene/ids.d.ts +0 -5
  182. package/lib/scene/ids.js +0 -5
  183. package/lib/scene/pointer-bridge.d.ts +0 -21
  184. package/lib/scene/pointer-bridge.js +0 -155
  185. package/lib/scene/runtime.d.ts +0 -12
  186. package/lib/scene/runtime.js +0 -74
  187. package/lib/scene/state-transitions.d.ts +0 -3
  188. package/lib/scene/state-transitions.js +0 -37
  189. package/lib/scene/styles.d.ts +0 -5
  190. package/lib/scene/styles.js +0 -69
  191. package/lib/scene/sylva-performance.d.ts +0 -11
  192. package/lib/scene/sylva-performance.js +0 -58
  193. package/lib/scene/wallpaper-character-styles.d.ts +0 -3
  194. package/lib/scene/wallpaper-character-styles.js +0 -49
  195. package/lib/scene/wallpaper-character.d.ts +0 -5
  196. package/lib/scene/wallpaper-character.js +0 -222
  197. package/lib/scene.d.ts +0 -8
  198. package/lib/scene.js +0 -8
  199. package/lib/sidebar-glass.d.ts +0 -16
  200. package/lib/sidebar-glass.js +0 -168
  201. package/lib/sidebar-heixiu-escape.d.ts +0 -44
  202. package/lib/sidebar-heixiu-escape.js +0 -340
  203. package/lib/sidebar-heixiu-roaming.d.ts +0 -27
  204. package/lib/sidebar-heixiu-roaming.js +0 -310
  205. package/lib/sidebar-reveal.d.ts +0 -8
  206. package/lib/sidebar-reveal.js +0 -59
  207. package/lib/state.d.ts +0 -21
  208. package/lib/state.js +0 -123
  209. package/lib/theme.d.ts +0 -19
  210. package/lib/theme.js +0 -188
  211. package/lib/vendor/bloub/decor.d.ts +0 -114
  212. package/lib/vendor/bloub/decor.js +0 -198
  213. package/lib/vendor/bloub/engine.d.ts +0 -213
  214. package/lib/vendor/bloub/engine.js +0 -452
  215. package/lib/vendor/bloub/expressions.d.ts +0 -35
  216. package/lib/vendor/bloub/expressions.js +0 -143
  217. package/lib/vendor/bloub/eyefit.d.ts +0 -75
  218. package/lib/vendor/bloub/eyefit.js +0 -393
  219. package/lib/vendor/bloub/face.d.ts +0 -63
  220. package/lib/vendor/bloub/face.js +0 -106
  221. package/lib/vendor/bloub/math.d.ts +0 -22
  222. package/lib/vendor/bloub/math.js +0 -36
  223. package/lib/vendor/bloub/profiles.d.ts +0 -8
  224. package/lib/vendor/bloub/profiles.js +0 -20
  225. package/lib/vendor/bloub/repere.d.ts +0 -30
  226. package/lib/vendor/bloub/repere.js +0 -32
  227. package/lib/vendor/bloub/shape.d.ts +0 -80
  228. package/lib/vendor/bloub/shape.js +0 -268
  229. package/lib/vendor/bloub/skins.d.ts +0 -36
  230. package/lib/vendor/bloub/skins.js +0 -74
  231. package/lib/vendor/bloub/states.d.ts +0 -87
  232. package/lib/vendor/bloub/states.js +0 -468
@@ -1,51 +0,0 @@
1
- import { subscribeXiaoheiHostDom } from './host-dom.js';
2
- export function installDeferredDecorations(doc = typeof document === 'undefined' ? undefined : document, load = () => require.async('./client.decorations.js'), readySelector = '[data-slot="sidebar"]') {
3
- const win = doc?.defaultView;
4
- if (!doc || !win)
5
- return () => { };
6
- let disposed = false;
7
- let started = false;
8
- let timer;
9
- let idle;
10
- let cleanup;
11
- let unsubscribe = () => { };
12
- const run = () => {
13
- if (disposed)
14
- return;
15
- void load().then(module => {
16
- if (!disposed)
17
- cleanup = module.installDecorations(doc);
18
- }).catch(() => {
19
- // Decorative failure must never prevent reading or sending messages.
20
- if (!disposed)
21
- console.warn('[xiaohei] Decorative resources unavailable; refresh to retry.');
22
- });
23
- };
24
- const check = () => {
25
- if (disposed || started || !doc.querySelector(readySelector))
26
- return;
27
- started = true;
28
- unsubscribe();
29
- // Let the committed app paint before starting the independent resource request.
30
- timer = win.setTimeout(() => {
31
- if (disposed)
32
- return;
33
- if (typeof win.requestIdleCallback === 'function')
34
- idle = win.requestIdleCallback(run, { timeout: 1500 });
35
- else
36
- run();
37
- }, 100);
38
- };
39
- unsubscribe = subscribeXiaoheiHostDom(doc, check);
40
- check();
41
- return () => {
42
- disposed = true;
43
- unsubscribe();
44
- if (timer !== undefined)
45
- win.clearTimeout(timer);
46
- if (idle !== undefined)
47
- win.cancelIdleCallback(idle);
48
- cleanup?.();
49
- };
50
- }
51
- //# sourceMappingURL=deferred-decorations.js.map
package/lib/gaze.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const XIAOHEI_GAZE_STYLE_ID = "dsh-theme-xiaohei/gaze-style";
2
- /** Install a proximity gaze without keeping a permanent animation loop alive. */
3
- export declare function installXiaoheiGaze(doc?: Document | undefined): () => void;
4
- //# sourceMappingURL=gaze.d.ts.map
package/lib/gaze.js DELETED
@@ -1,230 +0,0 @@
1
- import { XIAOHEI_IDLE_EYE_BASE } from './generated-keyart.js';
2
- import { XIAOHEI_GAZE_CSS } from './chrome/gaze.js';
3
- import { subscribeXiaoheiHostDom } from './host-dom.js';
4
- import { XIAOHEI_PORTAL_ACTIVITY_EVENT, XIAOHEI_PORTAL_LAYER_ID, } from './portal.js';
5
- export const XIAOHEI_GAZE_STYLE_ID = 'dsh-theme-xiaohei/gaze-style';
6
- const POINTER_FULL_GAZE_RADIUS_PX = 360;
7
- const POINTER_GAZE_LIMIT_PX = 460;
8
- const PORTAL_FULL_GAZE_RADIUS_PX = 320;
9
- const PORTAL_GAZE_LIMIT_PX = 440;
10
- const EYE_CENTER_X = (69 + 109) / 2 / 256;
11
- const EYE_CENTER_Y = (105 + 108) / 2 / 256;
12
- const SETTLED_EPSILON = 0.015;
13
- /** Install a proximity gaze without keeping a permanent animation loop alive. */
14
- export function installXiaoheiGaze(doc = typeof document === 'undefined' ? undefined : document) {
15
- if (doc?.body === undefined || doc.defaultView === null)
16
- return () => { };
17
- const win = doc.defaultView;
18
- doc.getElementById(XIAOHEI_GAZE_STYLE_ID)?.remove();
19
- const style = doc.createElement('style');
20
- style.id = XIAOHEI_GAZE_STYLE_ID;
21
- style.textContent = XIAOHEI_GAZE_CSS;
22
- doc.head.append(style);
23
- const reducedMotion = win.matchMedia('(prefers-reduced-motion: reduce)');
24
- const coarsePointer = win.matchMedia('(hover: none) and (pointer: coarse)');
25
- let disposed = false;
26
- let pointer;
27
- let portalActive = false;
28
- let gaze;
29
- let mascot;
30
- let frameId = 0;
31
- let lastFrameTime = 0;
32
- let currentX = 0;
33
- let currentY = 0;
34
- const behaviorDisabled = () => reducedMotion.matches || coarsePointer.matches;
35
- const setMoving = (moving) => {
36
- if (gaze !== undefined)
37
- gaze.dataset.moving = String(moving);
38
- };
39
- const writeOffset = () => {
40
- if (gaze === undefined)
41
- return;
42
- gaze.style.setProperty('--xiaohei-gaze-x', `${currentX.toFixed(3)}px`);
43
- gaze.style.setProperty('--xiaohei-gaze-y', `${currentY.toFixed(3)}px`);
44
- };
45
- const wake = () => {
46
- if (disposed || doc.hidden || frameId !== 0 || gaze === undefined)
47
- return;
48
- setMoving(true);
49
- frameId = win.requestAnimationFrame(tick);
50
- };
51
- const tick = (time) => {
52
- frameId = 0;
53
- if (disposed || doc.hidden || gaze === undefined || mascot === undefined)
54
- return;
55
- const target = resolveGazeTarget(doc, mascot, pointer, portalActive, behaviorDisabled());
56
- const elapsed = lastFrameTime === 0 ? 16 : Math.min(48, Math.max(1, time - lastFrameTime));
57
- const easing = 1 - Math.exp(-elapsed / 82);
58
- currentX += (target.x - currentX) * easing;
59
- currentY += (target.y - currentY) * easing;
60
- lastFrameTime = time;
61
- if (Math.abs(target.x - currentX) < SETTLED_EPSILON)
62
- currentX = target.x;
63
- if (Math.abs(target.y - currentY) < SETTLED_EPSILON)
64
- currentY = target.y;
65
- writeOffset();
66
- const unsettled = currentX !== target.x || currentY !== target.y;
67
- if (portalActive || unsettled) {
68
- frameId = win.requestAnimationFrame(tick);
69
- return;
70
- }
71
- lastFrameTime = 0;
72
- setMoving(false);
73
- };
74
- const attach = () => {
75
- const nextMascot = doc.querySelector('.xiaohei-scene__mascot') ?? undefined;
76
- if (nextMascot === mascot && gaze?.isConnected === true)
77
- return;
78
- gaze?.remove();
79
- gaze = undefined;
80
- mascot = nextMascot;
81
- if (nextMascot === undefined)
82
- return;
83
- const viewport = nextMascot.querySelector('.xiaohei-scene__mascot-idle-viewport');
84
- if (viewport === null)
85
- return;
86
- gaze = createGazeLayer(doc);
87
- viewport.append(gaze);
88
- writeOffset();
89
- wake();
90
- };
91
- const onPointerMove = (event) => {
92
- if (event.pointerType === 'touch') {
93
- pointer = undefined;
94
- }
95
- else {
96
- pointer = { x: event.clientX, y: event.clientY };
97
- }
98
- wake();
99
- };
100
- const clearPointer = () => {
101
- pointer = undefined;
102
- wake();
103
- };
104
- const onPortalActivity = (event) => {
105
- portalActive = Boolean(event.detail?.active);
106
- wake();
107
- };
108
- const onPreferenceChange = () => wake();
109
- const onStateChange = () => wake();
110
- const onVisibilityChange = () => {
111
- if (doc.hidden) {
112
- if (frameId !== 0)
113
- win.cancelAnimationFrame(frameId);
114
- frameId = 0;
115
- lastFrameTime = 0;
116
- setMoving(false);
117
- }
118
- else
119
- wake();
120
- };
121
- const unsubscribeHostDom = subscribeXiaoheiHostDom(doc, attach);
122
- const stateObserver = new win.MutationObserver(onStateChange);
123
- stateObserver.observe(doc.documentElement, {
124
- attributes: true,
125
- attributeFilter: ['data-xiaohei-state'],
126
- });
127
- doc.addEventListener('pointermove', onPointerMove, { passive: true });
128
- doc.addEventListener('visibilitychange', onVisibilityChange);
129
- doc.addEventListener('pointerleave', clearPointer);
130
- doc.addEventListener(XIAOHEI_PORTAL_ACTIVITY_EVENT, onPortalActivity);
131
- win.addEventListener('blur', clearPointer);
132
- reducedMotion.addEventListener('change', onPreferenceChange);
133
- coarsePointer.addEventListener('change', onPreferenceChange);
134
- attach();
135
- return () => {
136
- disposed = true;
137
- if (frameId !== 0)
138
- win.cancelAnimationFrame(frameId);
139
- unsubscribeHostDom();
140
- stateObserver.disconnect();
141
- doc.removeEventListener('pointermove', onPointerMove);
142
- doc.removeEventListener('visibilitychange', onVisibilityChange);
143
- doc.removeEventListener('pointerleave', clearPointer);
144
- doc.removeEventListener(XIAOHEI_PORTAL_ACTIVITY_EVENT, onPortalActivity);
145
- win.removeEventListener('blur', clearPointer);
146
- reducedMotion.removeEventListener('change', onPreferenceChange);
147
- coarsePointer.removeEventListener('change', onPreferenceChange);
148
- gaze?.remove();
149
- style.remove();
150
- };
151
- }
152
- function createGazeLayer(doc) {
153
- const layer = doc.createElement('span');
154
- layer.className = 'xiaohei-gaze';
155
- layer.dataset.moving = 'false';
156
- const base = doc.createElement('img');
157
- base.className = 'xiaohei-gaze__base';
158
- base.alt = '';
159
- base.decoding = 'async';
160
- base.fetchPriority = 'low';
161
- base.src = XIAOHEI_IDLE_EYE_BASE;
162
- const leftPupil = doc.createElement('span');
163
- leftPupil.className = 'xiaohei-gaze__pupil xiaohei-gaze__pupil--left';
164
- const leftEye = doc.createElement('span');
165
- leftEye.className = 'xiaohei-gaze__eye xiaohei-gaze__eye--left';
166
- leftEye.append(leftPupil);
167
- const rightPupil = doc.createElement('span');
168
- rightPupil.className = 'xiaohei-gaze__pupil xiaohei-gaze__pupil--right';
169
- const rightEye = doc.createElement('span');
170
- rightEye.className = 'xiaohei-gaze__eye xiaohei-gaze__eye--right';
171
- rightEye.append(rightPupil);
172
- layer.append(base, leftEye, rightEye);
173
- return layer;
174
- }
175
- function resolveGazeTarget(doc, mascot, pointer, portalActive, disabled) {
176
- if (disabled || (doc.documentElement.getAttribute('data-xiaohei-state') ?? 'idle') !== 'idle') {
177
- return { x: 0, y: 0 };
178
- }
179
- const mascotRect = mascot.getBoundingClientRect();
180
- if (mascotRect.width <= 0 || mascotRect.height <= 0)
181
- return { x: 0, y: 0 };
182
- const eyeCenter = {
183
- x: mascotRect.left + mascotRect.width * EYE_CENTER_X,
184
- y: mascotRect.top + mascotRect.height * EYE_CENTER_Y,
185
- };
186
- const maximum = {
187
- x: clamp(5 * mascotRect.width / 256, 3.6, 5.2),
188
- y: clamp(3.2 * mascotRect.height / 256, 2.4, 3.35),
189
- };
190
- if (portalActive) {
191
- const portalLayer = doc.getElementById(XIAOHEI_PORTAL_LAYER_ID);
192
- const traveler = portalLayer?.querySelector('.xiaohei-portal__traveler');
193
- if (portalLayer?.dataset.running === 'true' && traveler !== null && traveler !== undefined) {
194
- const travelerRect = traveler.getBoundingClientRect();
195
- const portalTarget = {
196
- x: travelerRect.left + travelerRect.width / 2,
197
- y: travelerRect.top + travelerRect.height / 2,
198
- };
199
- const offset = offsetToward(eyeCenter, portalTarget, PORTAL_FULL_GAZE_RADIUS_PX, PORTAL_GAZE_LIMIT_PX, maximum);
200
- if (offset !== undefined)
201
- return offset;
202
- }
203
- }
204
- if (pointer !== undefined) {
205
- return offsetToward(eyeCenter, pointer, POINTER_FULL_GAZE_RADIUS_PX, POINTER_GAZE_LIMIT_PX, maximum) ?? { x: 0, y: 0 };
206
- }
207
- return { x: 0, y: 0 };
208
- }
209
- function offsetToward(origin, target, fullRadius, limitRadius, maximum) {
210
- const dx = target.x - origin.x;
211
- const dy = target.y - origin.y;
212
- const distance = Math.hypot(dx, dy);
213
- if (distance >= limitRadius)
214
- return undefined;
215
- if (distance < 0.001)
216
- return { x: 0, y: 0 };
217
- const fadeProgress = clamp((distance - fullRadius) / (limitRadius - fullRadius), 0, 1);
218
- const strength = 1 - smoothstep(fadeProgress);
219
- return {
220
- x: dx / distance * maximum.x * strength,
221
- y: dy / distance * maximum.y * strength,
222
- };
223
- }
224
- function smoothstep(value) {
225
- return value * value * (3 - 2 * value);
226
- }
227
- function clamp(value, minimum, maximum) {
228
- return Math.min(maximum, Math.max(minimum, value));
229
- }
230
- //# sourceMappingURL=gaze.js.map
@@ -1,14 +0,0 @@
1
- /** Generated by scripts/embed-assets.mjs for atmosphere and independent lossless character poses. */
2
- export declare const XIAOHEI_WALLPAPER_LIGHT: string;
3
- export declare const XIAOHEI_WALLPAPER_DARK: string;
4
- export declare const XIAOHEI_SEATED_LIGHT: string;
5
- export declare const XIAOHEI_SEATED_DARK: string;
6
- export declare const XIAOHEI_PEEK_LIGHT: string;
7
- export declare const XIAOHEI_PEEK_DARK: string;
8
- export declare const XIAOHEI_CHIN_LIGHT: string;
9
- export declare const XIAOHEI_CHIN_DARK: string;
10
- export declare const XIAOHEI_DOZE_LIGHT: string;
11
- export declare const XIAOHEI_DOZE_DARK: string;
12
- export declare const XIAOHEI_HALFPEEK_LIGHT: string;
13
- export declare const XIAOHEI_HALFPEEK_DARK: string;
14
- //# sourceMappingURL=generated-backgrounds.d.ts.map