@celljs/ta-web 4.43.0 → 4.45.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 (213) hide show
  1. package/esm/browser/apps/app-window.js +2 -2
  2. package/esm/browser/assistant/assistant-chat-list.js +2 -1
  3. package/esm/browser/assistant/assistant-extension.js +16 -2
  4. package/esm/browser/assistant/assistant-protocol.d.ts +6 -0
  5. package/esm/browser/assistant/assistant-task-source.js +3 -0
  6. package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
  7. package/esm/browser/assistant/assistant-task-util.js +5 -0
  8. package/esm/browser/assistant/assistant.d.ts +3 -0
  9. package/esm/browser/assistant/assistant.js +26 -2
  10. package/esm/browser/components/app-shell-hooks.d.ts +2 -1
  11. package/esm/browser/components/app-shell-hooks.js +4 -3
  12. package/esm/browser/components/app-shell-state.js +2 -2
  13. package/esm/browser/components/chat-list-row.js +4 -4
  14. package/esm/browser/components/chat-list-util.d.ts +2 -2
  15. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  16. package/esm/browser/components/custom-host.d.ts +4 -1
  17. package/esm/browser/components/custom-host.js +8 -2
  18. package/esm/browser/components/earlier-messages.d.ts +4 -1
  19. package/esm/browser/components/earlier-messages.js +5 -2
  20. package/esm/browser/components/hearing-host.d.ts +2 -1
  21. package/esm/browser/components/hearing-host.js +10 -7
  22. package/esm/browser/components/host-view.d.ts +1 -1
  23. package/esm/browser/components/message-list.js +2 -1
  24. package/esm/browser/components/message-steps.js +8 -5
  25. package/esm/browser/components/settings-choices.d.ts +2 -1
  26. package/esm/browser/components/settings-choices.js +2 -1
  27. package/esm/browser/components/settings-parts.js +23 -3
  28. package/esm/browser/components/share-dialog.js +1 -1
  29. package/esm/browser/components/share-friends.d.ts +18 -2
  30. package/esm/browser/components/share-friends.js +62 -4
  31. package/esm/browser/components/share-sheet.d.ts +4 -3
  32. package/esm/browser/components/share-sheet.js +11 -3
  33. package/esm/browser/extension/web-api-chats.d.ts +23 -0
  34. package/esm/browser/extension/web-api-desktop.d.ts +14 -0
  35. package/esm/browser/extension/web-api-skins.d.ts +95 -0
  36. package/esm/browser/extension/web-api-skins.js +2 -0
  37. package/esm/browser/extension/web-api-spec.js +3 -0
  38. package/esm/browser/extension/web-extension-api.d.ts +11 -26
  39. package/esm/browser/extension/web-extension-context.js +4 -0
  40. package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
  41. package/esm/browser/extension/web-extension-protocol.js +1 -0
  42. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  43. package/esm/browser/extension/web-extension-run.js +3 -0
  44. package/esm/browser/extension/web-share-ui.js +6 -1
  45. package/esm/browser/i18n/en/assistant.d.ts +4 -0
  46. package/esm/browser/i18n/en/assistant.js +4 -0
  47. package/esm/browser/i18n/en/chat.d.ts +1 -0
  48. package/esm/browser/i18n/en/chat.js +1 -0
  49. package/esm/browser/i18n/en/common.d.ts +0 -3
  50. package/esm/browser/i18n/en/common.js +0 -3
  51. package/esm/browser/i18n/en/discover.d.ts +4 -1
  52. package/esm/browser/i18n/en/discover.js +4 -1
  53. package/esm/browser/i18n/en/service.js +1 -1
  54. package/esm/browser/i18n/en/settings.d.ts +8 -0
  55. package/esm/browser/i18n/en/settings.js +8 -0
  56. package/esm/browser/i18n/en/tools.d.ts +5 -0
  57. package/esm/browser/i18n/en/tools.js +5 -0
  58. package/esm/browser/i18n/ja/assistant.js +4 -0
  59. package/esm/browser/i18n/ja/chat.js +1 -0
  60. package/esm/browser/i18n/ja/common.js +0 -3
  61. package/esm/browser/i18n/ja/discover.js +4 -1
  62. package/esm/browser/i18n/ja/service.js +1 -1
  63. package/esm/browser/i18n/ja/settings.js +8 -0
  64. package/esm/browser/i18n/ja/tools.js +5 -0
  65. package/esm/browser/i18n/locales.d.ts +23 -5
  66. package/esm/browser/i18n/messages.d.ts +22 -4
  67. package/esm/browser/i18n/zh/assistant.js +4 -0
  68. package/esm/browser/i18n/zh/chat.js +1 -0
  69. package/esm/browser/i18n/zh/common.js +0 -3
  70. package/esm/browser/i18n/zh/discover.js +4 -1
  71. package/esm/browser/i18n/zh/service.js +1 -1
  72. package/esm/browser/i18n/zh/settings.js +8 -0
  73. package/esm/browser/i18n/zh/tools.js +5 -0
  74. package/esm/browser/i18n/zh-tw/assistant.js +4 -0
  75. package/esm/browser/i18n/zh-tw/chat.js +1 -0
  76. package/esm/browser/i18n/zh-tw/common.js +0 -3
  77. package/esm/browser/i18n/zh-tw/discover.js +4 -1
  78. package/esm/browser/i18n/zh-tw/service.js +1 -1
  79. package/esm/browser/i18n/zh-tw/settings.js +8 -0
  80. package/esm/browser/i18n/zh-tw/tools.js +5 -0
  81. package/esm/browser/links/clipboard-links.d.ts +4 -8
  82. package/esm/browser/links/clipboard-links.js +9 -51
  83. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  84. package/esm/browser/settings/settings-protocol.d.ts +24 -0
  85. package/esm/browser/settings/settings-protocol.js +9 -0
  86. package/esm/browser/settings/settings.d.ts +4 -1
  87. package/esm/browser/settings/settings.js +16 -3
  88. package/esm/browser/skin/skin-layer.d.ts +8 -0
  89. package/esm/browser/skin/skin-layer.js +118 -0
  90. package/esm/browser/skin/skin-util.d.ts +40 -0
  91. package/esm/browser/skin/skin-util.js +120 -0
  92. package/esm/browser/style/conversation.d.ts +1 -1
  93. package/esm/browser/style/conversation.js +3 -2
  94. package/esm/browser/style/skins.d.ts +9 -0
  95. package/esm/browser/style/skins.js +107 -0
  96. package/esm/browser/style/surfaces.d.ts +1 -1
  97. package/esm/browser/style/surfaces.js +8 -0
  98. package/esm/browser/style.js +2 -0
  99. package/esm/browser/util/desktop.d.ts +11 -1
  100. package/esm/browser/util/desktop.js +30 -0
  101. package/esm/browser/util/fresh-rows.d.ts +21 -0
  102. package/esm/browser/util/fresh-rows.js +36 -0
  103. package/esm/browser/util/process.d.ts +12 -22
  104. package/esm/browser/util/process.js +49 -39
  105. package/esm/browser/util/tool.js +15 -5
  106. package/esm/browser/util/voice.js +10 -2
  107. package/lib/browser/apps/app-window.js +2 -2
  108. package/lib/browser/assistant/assistant-chat-list.js +2 -1
  109. package/lib/browser/assistant/assistant-extension.js +15 -1
  110. package/lib/browser/assistant/assistant-protocol.d.ts +6 -0
  111. package/lib/browser/assistant/assistant-task-source.js +3 -0
  112. package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
  113. package/lib/browser/assistant/assistant-task-util.js +5 -0
  114. package/lib/browser/assistant/assistant.d.ts +3 -0
  115. package/lib/browser/assistant/assistant.js +26 -2
  116. package/lib/browser/components/app-shell-hooks.d.ts +2 -1
  117. package/lib/browser/components/app-shell-hooks.js +4 -3
  118. package/lib/browser/components/app-shell-state.js +2 -2
  119. package/lib/browser/components/chat-list-row.js +4 -4
  120. package/lib/browser/components/chat-list-util.d.ts +2 -2
  121. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  122. package/lib/browser/components/custom-host.d.ts +4 -1
  123. package/lib/browser/components/custom-host.js +8 -2
  124. package/lib/browser/components/earlier-messages.d.ts +4 -1
  125. package/lib/browser/components/earlier-messages.js +5 -2
  126. package/lib/browser/components/hearing-host.d.ts +2 -1
  127. package/lib/browser/components/hearing-host.js +9 -6
  128. package/lib/browser/components/host-view.d.ts +1 -1
  129. package/lib/browser/components/message-list.js +2 -1
  130. package/lib/browser/components/message-steps.js +8 -5
  131. package/lib/browser/components/settings-choices.d.ts +2 -1
  132. package/lib/browser/components/settings-choices.js +2 -1
  133. package/lib/browser/components/settings-parts.js +21 -1
  134. package/lib/browser/components/share-dialog.js +1 -1
  135. package/lib/browser/components/share-friends.d.ts +18 -2
  136. package/lib/browser/components/share-friends.js +65 -4
  137. package/lib/browser/components/share-sheet.d.ts +4 -3
  138. package/lib/browser/components/share-sheet.js +10 -2
  139. package/lib/browser/extension/web-api-chats.d.ts +23 -0
  140. package/lib/browser/extension/web-api-desktop.d.ts +14 -0
  141. package/lib/browser/extension/web-api-skins.d.ts +96 -0
  142. package/lib/browser/extension/web-api-skins.js +3 -0
  143. package/lib/browser/extension/web-api-spec.js +3 -0
  144. package/lib/browser/extension/web-extension-api.d.ts +11 -26
  145. package/lib/browser/extension/web-extension-context.js +4 -0
  146. package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
  147. package/lib/browser/extension/web-extension-protocol.js +1 -0
  148. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  149. package/lib/browser/extension/web-extension-run.js +3 -0
  150. package/lib/browser/extension/web-share-ui.js +6 -1
  151. package/lib/browser/i18n/en/assistant.d.ts +4 -0
  152. package/lib/browser/i18n/en/assistant.js +4 -0
  153. package/lib/browser/i18n/en/chat.d.ts +1 -0
  154. package/lib/browser/i18n/en/chat.js +1 -0
  155. package/lib/browser/i18n/en/common.d.ts +0 -3
  156. package/lib/browser/i18n/en/common.js +0 -3
  157. package/lib/browser/i18n/en/discover.d.ts +4 -1
  158. package/lib/browser/i18n/en/discover.js +4 -1
  159. package/lib/browser/i18n/en/service.js +1 -1
  160. package/lib/browser/i18n/en/settings.d.ts +8 -0
  161. package/lib/browser/i18n/en/settings.js +8 -0
  162. package/lib/browser/i18n/en/tools.d.ts +5 -0
  163. package/lib/browser/i18n/en/tools.js +5 -0
  164. package/lib/browser/i18n/ja/assistant.js +4 -0
  165. package/lib/browser/i18n/ja/chat.js +1 -0
  166. package/lib/browser/i18n/ja/common.js +0 -3
  167. package/lib/browser/i18n/ja/discover.js +4 -1
  168. package/lib/browser/i18n/ja/service.js +1 -1
  169. package/lib/browser/i18n/ja/settings.js +8 -0
  170. package/lib/browser/i18n/ja/tools.js +5 -0
  171. package/lib/browser/i18n/locales.d.ts +23 -5
  172. package/lib/browser/i18n/messages.d.ts +22 -4
  173. package/lib/browser/i18n/zh/assistant.js +4 -0
  174. package/lib/browser/i18n/zh/chat.js +1 -0
  175. package/lib/browser/i18n/zh/common.js +0 -3
  176. package/lib/browser/i18n/zh/discover.js +4 -1
  177. package/lib/browser/i18n/zh/service.js +1 -1
  178. package/lib/browser/i18n/zh/settings.js +8 -0
  179. package/lib/browser/i18n/zh/tools.js +5 -0
  180. package/lib/browser/i18n/zh-tw/assistant.js +4 -0
  181. package/lib/browser/i18n/zh-tw/chat.js +1 -0
  182. package/lib/browser/i18n/zh-tw/common.js +0 -3
  183. package/lib/browser/i18n/zh-tw/discover.js +4 -1
  184. package/lib/browser/i18n/zh-tw/service.js +1 -1
  185. package/lib/browser/i18n/zh-tw/settings.js +8 -0
  186. package/lib/browser/i18n/zh-tw/tools.js +5 -0
  187. package/lib/browser/links/clipboard-links.d.ts +4 -8
  188. package/lib/browser/links/clipboard-links.js +10 -52
  189. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  190. package/lib/browser/settings/settings-protocol.d.ts +24 -0
  191. package/lib/browser/settings/settings-protocol.js +10 -1
  192. package/lib/browser/settings/settings.d.ts +4 -1
  193. package/lib/browser/settings/settings.js +16 -3
  194. package/lib/browser/skin/skin-layer.d.ts +9 -0
  195. package/lib/browser/skin/skin-layer.js +154 -0
  196. package/lib/browser/skin/skin-util.d.ts +41 -0
  197. package/lib/browser/skin/skin-util.js +123 -0
  198. package/lib/browser/style/conversation.d.ts +1 -1
  199. package/lib/browser/style/conversation.js +3 -2
  200. package/lib/browser/style/skins.d.ts +10 -0
  201. package/lib/browser/style/skins.js +110 -0
  202. package/lib/browser/style/surfaces.d.ts +1 -1
  203. package/lib/browser/style/surfaces.js +8 -0
  204. package/lib/browser/style.js +2 -0
  205. package/lib/browser/util/desktop.d.ts +11 -1
  206. package/lib/browser/util/desktop.js +30 -0
  207. package/lib/browser/util/fresh-rows.d.ts +22 -0
  208. package/lib/browser/util/fresh-rows.js +40 -0
  209. package/lib/browser/util/process.d.ts +12 -22
  210. package/lib/browser/util/process.js +49 -40
  211. package/lib/browser/util/tool.js +15 -5
  212. package/lib/browser/util/voice.js +10 -2
  213. package/package.json +7 -7
@@ -9,6 +9,13 @@ export type Language = TaLanguage;
9
9
  /** How diagrams of replies draw: in the colours of the page, as by hand, a colour to a node, or coming in and flowing. */
10
10
  export type DiagramStyle = 'clean' | 'sketch' | 'colour' | 'motion';
11
11
  export declare const DIAGRAM_STYLES: readonly DiagramStyle[];
12
+ /** How much of the picture of a skin the columns let through (WebSkinGlass). */
13
+ export type SkinGlass = 'clear' | 'soft' | 'focus';
14
+ export declare const SKIN_GLASSES: readonly SkinGlass[];
15
+ /** `Settings.skin` at first: the first skin there is, so that one the user installs shows. */
16
+ export declare const AUTO_SKIN = "auto";
17
+ /** `Settings.skin` of the user who wants none. */
18
+ export declare const NO_SKIN = "none";
12
19
  /** How large the text is, as the font size of WeChat: small, standard, large, extra large. */
13
20
  export type FontSize = 'small' | 'standard' | 'large' | 'xlarge';
14
21
  /** What each size multiplies the font sizes of the styles by (`--ta-font-scale`, see style/base.ts). */
@@ -55,6 +62,13 @@ export interface Settings {
55
62
  taskModel: string;
56
63
  reduceMotion: boolean;
57
64
  diagramStyle: DiagramStyle;
65
+ /**
66
+ * The skin Ta shows in (WebExtensionAPI.registerSkin, docs/design/ta-skins.md): `<extension id>/<skin id>`, NO_SKIN,
67
+ * or AUTO_SKIN for the first there is.
68
+ */
69
+ skin: string;
70
+ /** How clear the glass of a skin is. */
71
+ glass: SkinGlass;
58
72
  /** The names of the built-in web extensions turned off; the others are on. */
59
73
  builtinsOff: string[];
60
74
  /**
@@ -91,6 +105,8 @@ export interface SettingsState {
91
105
  chatFontScale: number;
92
106
  /** Also when the system asks for it. */
93
107
  reduceMotion: boolean;
108
+ /** The colour of the window, which a skin that shows gives it (ShownLook.color); else that of the theme. */
109
+ skinColor?: string;
94
110
  }
95
111
  /** What `keepAliveMinutes` may be. */
96
112
  export declare const KEEP_ALIVE_CHOICES: readonly number[];
@@ -115,9 +131,17 @@ export declare namespace SettingsUtil {
115
131
  function language(setting: LanguageSetting, browserLanguage: string): Language;
116
132
  }
117
133
  /** The settings of the web client: theme, language, font size, voice, motion. They apply as soon as they change. */
134
+ /** How a skin that shows wants the page (SkinLayer): its tone over the user's theme, and the window in its colour. */
135
+ export interface ShownLook {
136
+ theme: Theme;
137
+ /** Of the window and the bar of the browser (theme-color), opaque. */
138
+ color: string;
139
+ }
118
140
  export interface TaSettings {
119
141
  readonly state: SettingsState;
120
142
  update(change: Partial<Settings>): void;
121
143
  subscribe(listener: (state: SettingsState) => void): () => void;
144
+ /** The look of a skin, over the theme of the settings, until it is undefined again. */
145
+ show(look: ShownLook | undefined): void;
122
146
  }
123
147
  //# sourceMappingURL=settings-protocol.d.ts.map
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SettingsUtil = exports.DEFAULT_SETTINGS = exports.MAX_TASKS_CHOICES = exports.CHAT_ARCHIVE_CHOICES = exports.CHAT_FOLD_CHOICES = exports.KEEP_ALIVE_CHOICES = exports.HANDHELD_FONT_SCALE = exports.FONT_SCALES = exports.DIAGRAM_STYLES = exports.TaSettings = void 0;
3
+ exports.SettingsUtil = exports.DEFAULT_SETTINGS = exports.MAX_TASKS_CHOICES = exports.CHAT_ARCHIVE_CHOICES = exports.CHAT_FOLD_CHOICES = exports.KEEP_ALIVE_CHOICES = exports.HANDHELD_FONT_SCALE = exports.FONT_SCALES = exports.NO_SKIN = exports.AUTO_SKIN = exports.SKIN_GLASSES = exports.DIAGRAM_STYLES = exports.TaSettings = void 0;
4
4
  const ta_protocol_1 = require("@celljs/ta-protocol");
5
5
  const navigation_1 = require("./navigation");
6
6
  exports.TaSettings = Symbol('TaSettings');
7
7
  exports.DIAGRAM_STYLES = ['clean', 'sketch', 'colour', 'motion'];
8
+ exports.SKIN_GLASSES = ['clear', 'soft', 'focus'];
9
+ /** `Settings.skin` at first: the first skin there is, so that one the user installs shows. */
10
+ exports.AUTO_SKIN = 'auto';
11
+ /** `Settings.skin` of the user who wants none. */
12
+ exports.NO_SKIN = 'none';
8
13
  /** What each size multiplies the font sizes of the styles by (`--ta-font-scale`, see style/base.ts). */
9
14
  exports.FONT_SCALES = { small: 0.9, standard: 1, large: 1.12, xlarge: 1.25 };
10
15
  /**
@@ -38,6 +43,8 @@ exports.DEFAULT_SETTINGS = {
38
43
  taskModel: '',
39
44
  reduceMotion: false,
40
45
  diagramStyle: 'clean',
46
+ skin: exports.AUTO_SKIN,
47
+ glass: 'soft',
41
48
  builtinsOff: [],
42
49
  trustedDomains: [],
43
50
  clipboardLinks: true,
@@ -88,6 +95,8 @@ var SettingsUtil;
88
95
  taskModel: modelRef(kept.taskModel),
89
96
  reduceMotion: kept.reduceMotion === true,
90
97
  diagramStyle: exports.DIAGRAM_STYLES.includes(kept.diagramStyle) ? kept.diagramStyle : exports.DEFAULT_SETTINGS.diagramStyle,
98
+ skin: typeof kept.skin === 'string' && kept.skin ? kept.skin : exports.AUTO_SKIN,
99
+ glass: exports.SKIN_GLASSES.includes(kept.glass) ? kept.glass : exports.DEFAULT_SETTINGS.glass,
91
100
  builtinsOff: strings(kept.builtinsOff),
92
101
  trustedDomains: strings(kept.trustedDomains),
93
102
  clipboardLinks: kept.clipboardLinks !== false,
@@ -1,7 +1,7 @@
1
1
  import { LocaleManager } from '@celljs/widget';
2
2
  import { TaState } from '../state/state-protocol';
3
3
  import { TaWorkbench } from '../workbench-protocol';
4
- import { type Settings, type SettingsState, TaSettings } from './settings-protocol';
4
+ import { type Settings, type SettingsState, type ShownLook, TaSettings } from './settings-protocol';
5
5
  /**
6
6
  * The colours of the conversation (--ta-main) and of the side columns (--ta-side), for the bar of the
7
7
  * browser and the title bar of the installed app.
@@ -21,6 +21,8 @@ export declare class TaSettingsImpl implements TaSettings {
21
21
  protected readonly persisted: TaState;
22
22
  protected readonly workbench: TaWorkbench;
23
23
  protected current: SettingsState;
24
+ /** That of a skin that shows (show). */
25
+ protected shownLook?: ShownLook;
24
26
  /** The settings kept for the computer signed in to; the page may show another look (shown). */
25
27
  protected kept: Settings;
26
28
  protected readonly listeners: Set<(state: SettingsState) => void>;
@@ -30,6 +32,7 @@ export declare class TaSettingsImpl implements TaSettings {
30
32
  protected init(): void;
31
33
  update(change: Partial<Settings>): void;
32
34
  subscribe(listener: (state: SettingsState) => void): () => void;
35
+ show(look: ShownLook | undefined): void;
33
36
  protected resolve(settings: Settings): SettingsState;
34
37
  /** Signed in, the settings kept for the computer; else those with the look the page had last. */
35
38
  protected shown(settings: Settings): Settings;
@@ -62,14 +62,25 @@ let TaSettingsImpl = class TaSettingsImpl {
62
62
  this.listeners.add(listener);
63
63
  return () => this.listeners.delete(listener);
64
64
  }
65
+ show(look) {
66
+ var _a, _b;
67
+ if ((look === null || look === void 0 ? void 0 : look.theme) === ((_a = this.shownLook) === null || _a === void 0 ? void 0 : _a.theme) && (look === null || look === void 0 ? void 0 : look.color) === ((_b = this.shownLook) === null || _b === void 0 ? void 0 : _b.color)) {
68
+ return;
69
+ }
70
+ this.shownLook = look;
71
+ this.apply(this.kept);
72
+ }
65
73
  resolve(settings) {
74
+ var _a;
75
+ var _b;
66
76
  return {
67
77
  settings,
68
- theme: settings_protocol_1.SettingsUtil.theme(settings.theme, this.dark.matches),
78
+ theme: (_b = (_a = this.shownLook) === null || _a === void 0 ? void 0 : _a.theme) !== null && _b !== void 0 ? _b : settings_protocol_1.SettingsUtil.theme(settings.theme, this.dark.matches),
69
79
  language: settings_protocol_1.SettingsUtil.language(settings.language, navigator.language),
70
80
  fontScale: settings_protocol_1.FONT_SCALES[settings.fontSize],
71
81
  chatFontScale: settings_protocol_1.FONT_SCALES[settings.chatFontSize],
72
82
  reduceMotion: settings.reduceMotion || this.calm.matches,
83
+ ...(this.shownLook ? { skinColor: this.shownLook.color } : {}),
73
84
  };
74
85
  }
75
86
  /** Signed in, the settings kept for the computer; else those with the look the page had last. */
@@ -77,6 +88,7 @@ let TaSettingsImpl = class TaSettingsImpl {
77
88
  return this.workbench.state.host === undefined ? { ...settings, ...this.persisted.get(settings_protocol_1.SettingsUtil.LOOK) } : settings;
78
89
  }
79
90
  apply(kept) {
91
+ var _a, _b;
80
92
  const state = this.resolve(this.shown(kept));
81
93
  this.kept = kept;
82
94
  this.current = state;
@@ -97,9 +109,10 @@ let TaSettingsImpl = class TaSettingsImpl {
97
109
  meta.name = 'theme-color';
98
110
  document.head.appendChild(meta);
99
111
  }
100
- meta.content = exports.THEME_COLORS[state.theme].main;
112
+ // Under a skin, the window is its colour: what shows for a moment where the page has not drawn is the picture's, never black.
113
+ meta.content = (_a = state.skinColor) !== null && _a !== void 0 ? _a : exports.THEME_COLORS[state.theme].main;
101
114
  // The bar of WeChat's mini program over the page: the colour at the top of the chats, its first page (--ta-side).
102
- mini_program_1.MiniProgram.paint(exports.THEME_COLORS[state.theme].side, state.theme === 'dark');
115
+ mini_program_1.MiniProgram.paint((_b = state.skinColor) !== null && _b !== void 0 ? _b : exports.THEME_COLORS[state.theme].side, state.theme === 'dark');
103
116
  // Even the current one: a language whose messages still load (Japanese, Traditional Chinese) is selected once
104
117
  // they are there, unless another is asked for meanwhile.
105
118
  void this.localeManager.get().then(locales => {
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * The skin the user picked (Settings.skin, docs/design/ta-skins.md), behind the page: its backdrop over the picture it
4
+ * kept, in the colour it gives, faded in once it draws; the page in its tone and its colours (style/skins.ts), the
5
+ * window in its colour (TaSettings.show). Another skin, or its extension loaded again, fades in over the one before,
6
+ * which goes once it is in: the window never shows blank between them.
7
+ */
8
+ export declare function SkinLayer(): React.JSX.Element | null;
9
+ //# sourceMappingURL=skin-layer.d.ts.map
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SkinLayer = SkinLayer;
37
+ const React = __importStar(require("react"));
38
+ const extension_view_1 = require("../extension/extension-view");
39
+ const hooks_1 = require("../hooks");
40
+ const settings_protocol_1 = require("../settings/settings-protocol");
41
+ const skin_util_1 = require("./skin-util");
42
+ /** A backdrop that never says it is ready is shown after this long. */
43
+ const READY_AT_LATEST_MS = 4000;
44
+ /** As the fade of .ta-skin-live: the backdrop before is let go once the new one is in. */
45
+ const FADE_MS = 1000;
46
+ let nextLayer = 0;
47
+ /** Normalizes any CSS colour to `#rrggbb` with a canvas of the page. */
48
+ function normalize(color) {
49
+ const context = document.createElement('canvas').getContext('2d');
50
+ if (!context) {
51
+ return undefined;
52
+ }
53
+ context.fillStyle = '#000';
54
+ context.fillStyle = color;
55
+ return String(context.fillStyle);
56
+ }
57
+ function usePrefersDark() {
58
+ return React.useSyncExternalStore(listener => {
59
+ const query = matchMedia('(prefers-color-scheme: dark)');
60
+ query.addEventListener('change', listener);
61
+ return () => query.removeEventListener('change', listener);
62
+ }, () => matchMedia('(prefers-color-scheme: dark)').matches);
63
+ }
64
+ /**
65
+ * The skin the user picked (Settings.skin, docs/design/ta-skins.md), behind the page: its backdrop over the picture it
66
+ * kept, in the colour it gives, faded in once it draws; the page in its tone and its colours (style/skins.ts), the
67
+ * window in its colour (TaSettings.show). Another skin, or its extension loaded again, fades in over the one before,
68
+ * which goes once it is in: the window never shows blank between them.
69
+ */
70
+ function SkinLayer() {
71
+ const [{ skins }] = (0, hooks_1.useWebExtensions)();
72
+ const [state, settings] = (0, hooks_1.useSettings)();
73
+ const [kept, keep] = (0, hooks_1.usePersisted)(skin_util_1.SkinUtil.PICTURE);
74
+ const prefersDark = usePrefersDark();
75
+ const entry = skin_util_1.SkinUtil.pick(skins, state.settings.skin);
76
+ const [asked, setAsked] = React.useState();
77
+ const tone = entry && skin_util_1.SkinUtil.tone((asked === null || asked === void 0 ? void 0 : asked.skin) === entry.id ? asked.tone : undefined, entry.skin, settings_protocol_1.SettingsUtil.theme(state.settings.theme, prefersDark));
78
+ const colors = entry && tone ? entry.skin.colors[tone] : undefined;
79
+ const skinId = entry === null || entry === void 0 ? void 0 : entry.id;
80
+ const [base, glassColor, ink, accent] = [colors === null || colors === void 0 ? void 0 : colors.base, colors === null || colors === void 0 ? void 0 : colors.glass, colors === null || colors === void 0 ? void 0 : colors.ink, colors === null || colors === void 0 ? void 0 : colors.accent];
81
+ const variables = React.useMemo(() => (base === undefined ? undefined : skin_util_1.SkinUtil.variables({ base, glass: glassColor, ink, accent }, normalize)), [base, glassColor, ink, accent]);
82
+ const glass = state.settings.glass;
83
+ const softens = !!(entry === null || entry === void 0 ? void 0 : entry.skin.softens);
84
+ React.useLayoutEffect(() => {
85
+ if (!skinId || !tone || !variables) {
86
+ return;
87
+ }
88
+ const root = document.documentElement;
89
+ root.setAttribute('data-ta-skin', skinId);
90
+ root.setAttribute('data-ta-glass', glass);
91
+ root.toggleAttribute('data-ta-skin-softens', softens);
92
+ for (const [name, value] of Object.entries(variables)) {
93
+ root.style.setProperty(name, value);
94
+ }
95
+ settings.show({ theme: tone, color: variables['--ta-skin-base'] });
96
+ return () => {
97
+ root.removeAttribute('data-ta-skin');
98
+ root.removeAttribute('data-ta-glass');
99
+ root.removeAttribute('data-ta-skin-softens');
100
+ for (const name of skin_util_1.SkinUtil.VARIABLES) {
101
+ root.style.removeProperty(name);
102
+ }
103
+ settings.show(undefined);
104
+ };
105
+ }, [skinId, tone, variables, glass, softens, settings]);
106
+ const [layers, setLayers] = React.useState([]);
107
+ React.useEffect(() => {
108
+ setLayers(current => {
109
+ if (!entry) {
110
+ return current.length ? [] : current;
111
+ }
112
+ const top = current.at(-1);
113
+ if (top && top.entry.id === entry.id && top.entry.skin.backdrop === entry.skin.backdrop) {
114
+ return top.entry === entry ? current : [...current.slice(0, -1), { ...top, entry }];
115
+ }
116
+ return [...current, { key: ++nextLayer, entry, ready: false }];
117
+ });
118
+ }, [entry]);
119
+ const top = layers.at(-1);
120
+ // The one before goes once the new one is in.
121
+ React.useEffect(() => {
122
+ if (!(top === null || top === void 0 ? void 0 : top.ready) || layers.length < 2) {
123
+ return;
124
+ }
125
+ const timer = setTimeout(() => setLayers(current => current.filter(layer => layer.key >= top.key)), FADE_MS);
126
+ return () => clearTimeout(timer);
127
+ }, [top, layers.length]);
128
+ const ready = React.useCallback((key) => setLayers(current => current.map(layer => (layer.key === key && !layer.ready ? { ...layer, ready: true } : layer))), []);
129
+ if (!entry || !tone || !layers.length) {
130
+ return null;
131
+ }
132
+ const picture = (kept === null || kept === void 0 ? void 0 : kept.skin) === entry.id ? kept.picture : undefined;
133
+ return (React.createElement("div", { className: "ta-skin", inert: true, "aria-hidden": "true", style: picture ? { backgroundImage: `url("${picture}")` } : undefined }, layers.map(layer => (React.createElement(SkinBackdrop, { key: layer.key, layer: layer, tone: tone, glass: glass, top: layer === top, onReady: ready, onTone: next => setAsked({ skin: layer.entry.id, tone: next }), onKeep: picture => skin_util_1.SkinUtil.keepable(picture) && keep({ skin: layer.entry.id, picture }) })))));
134
+ }
135
+ function SkinBackdrop({ layer, tone, glass, top, onReady, onTone, onKeep }) {
136
+ const calls = React.useRef({ top, onReady, onTone, onKeep });
137
+ calls.current = { top, onReady, onTone, onKeep };
138
+ const { key } = layer;
139
+ React.useEffect(() => {
140
+ const timer = setTimeout(() => calls.current.onReady(key), READY_AT_LATEST_MS);
141
+ return () => clearTimeout(timer);
142
+ }, [key]);
143
+ const own = React.useMemo(() => ({
144
+ setTone: next => calls.current.top && calls.current.onTone(next),
145
+ areas: () => skin_util_1.SkinUtil.areas(document),
146
+ ready: () => calls.current.onReady(key),
147
+ keep: picture => calls.current.onKeep(picture),
148
+ }), [key]);
149
+ const Backdrop = layer.entry.skin.backdrop;
150
+ return (React.createElement("div", { className: layer.ready ? 'ta-skin-live ta-skin-ready' : 'ta-skin-live' },
151
+ React.createElement(extension_view_1.ExtensionBoundary, { name: layer.entry.extension, extension: layer.entry.extension, resetKey: Backdrop, fallback: null },
152
+ React.createElement(Backdrop, { ...own, tone: tone, glass: glass }))));
153
+ }
154
+ //# sourceMappingURL=skin-layer.js.map
@@ -0,0 +1,41 @@
1
+ import type { WebSkin, WebSkinAreas, WebSkinColors, WebSkinEntry, WebSkinRect } from '../extension/web-extension-api';
2
+ import { type Theme } from '../settings/settings-protocol';
3
+ import type { StateSpec } from '../state/state-protocol';
4
+ /** The picture of the skin that showed last, on this device (WebSkinBackdropProps.keep). */
5
+ export interface KeptSkinPicture {
6
+ /** WebSkinEntry.id. */
7
+ skin: string;
8
+ /** A `data:` URL. */
9
+ picture: string;
10
+ }
11
+ /** What the page does with a skin (docs/design/ta-skins.md): which shows, in which tone, its colours, where it is read over. */
12
+ export declare namespace SkinUtil {
13
+ /** Where words are read over the picture: the conversation, the message box, the settings. */
14
+ const READ = ".ta-thread, .ta-console-box, .ta-settings-scroll";
15
+ /** Columns that cover it: the lists beside, the workbench, the navigation. */
16
+ const COVER = ".ta-chats, .ta-side-view, .ta-editors, .ta-rail, .ta-tabbar";
17
+ /** One picture for the device, of the skin that showed last: a skin chosen again shows its own once it keeps one. */
18
+ const PICTURE: StateSpec<KeptSkinPicture | undefined>;
19
+ /** The skin of `setting` (Settings.skin): none for NO_SKIN or one that is not there (its extension is not on this device), the first for AUTO_SKIN. */
20
+ function pick(skins: readonly WebSkinEntry[], setting: string): WebSkinEntry | undefined;
21
+ /** The tone the page shows in: the one its backdrop asked for, else its own, else the user's theme. */
22
+ function tone(asked: Theme | undefined, skin: WebSkin, theme: Theme): Theme;
23
+ /** A picture fit to keep: a picture, not too long. */
24
+ function keepable(picture: unknown): picture is string;
25
+ /** `#rrggbb` of `#rgb`, `#rrggbb` or `rgb(r, g, b)`; otherwise what `normalize` makes of it (a canvas of the page), else undefined. */
26
+ function hex(color: string | undefined, normalize?: (color: string) => string | undefined): string | undefined;
27
+ /** Whether words on `#rrggbb` should be dark. */
28
+ function light(hex: string): boolean;
29
+ /**
30
+ * The variables of the root for the colours of a tone (style/skins.ts makes the theme of them): those left out are
31
+ * not set, so that the style's own stand; the words on the accent dark or light as it is.
32
+ */
33
+ function variables(colors: WebSkinColors, normalize?: (color: string) => string | undefined): Record<string, string>;
34
+ /** Every variable `variables` may set, to take them off again. */
35
+ const VARIABLES: string[];
36
+ /** The rectangles of what `selector` finds that can be seen in the window. */
37
+ function rects(root: ParentNode, selector: string, width: number, height: number): WebSkinRect[];
38
+ /** Where words are read and where columns cover the picture, in the window now. */
39
+ function areas(document: Document): WebSkinAreas;
40
+ }
41
+ //# sourceMappingURL=skin-util.d.ts.map
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SkinUtil = void 0;
4
+ const settings_protocol_1 = require("../settings/settings-protocol");
5
+ /** The longest a picture kept may be, as text: a JPEG some 480 pixels wide is a tenth of it. */
6
+ const MAX_PICTURE = 400000;
7
+ /** What the page does with a skin (docs/design/ta-skins.md): which shows, in which tone, its colours, where it is read over. */
8
+ var SkinUtil;
9
+ (function (SkinUtil) {
10
+ /** Where words are read over the picture: the conversation, the message box, the settings. */
11
+ SkinUtil.READ = '.ta-thread, .ta-console-box, .ta-settings-scroll';
12
+ /** Columns that cover it: the lists beside, the workbench, the navigation. */
13
+ SkinUtil.COVER = '.ta-chats, .ta-side-view, .ta-editors, .ta-rail, .ta-tabbar';
14
+ /** One picture for the device, of the skin that showed last: a skin chosen again shows its own once it keeps one. */
15
+ SkinUtil.PICTURE = {
16
+ key: 'skin.picture',
17
+ tier: 'device',
18
+ initial: undefined,
19
+ parse: value => {
20
+ const kept = value;
21
+ return typeof (kept === null || kept === void 0 ? void 0 : kept.skin) === 'string' && typeof kept.picture === 'string' && kept.picture.startsWith('data:image/')
22
+ ? kept
23
+ : undefined;
24
+ },
25
+ };
26
+ /** The skin of `setting` (Settings.skin): none for NO_SKIN or one that is not there (its extension is not on this device), the first for AUTO_SKIN. */
27
+ function pick(skins, setting) {
28
+ if (setting === settings_protocol_1.NO_SKIN) {
29
+ return undefined;
30
+ }
31
+ return setting === settings_protocol_1.AUTO_SKIN ? skins[0] : skins.find(entry => entry.id === setting);
32
+ }
33
+ SkinUtil.pick = pick;
34
+ /** The tone the page shows in: the one its backdrop asked for, else its own, else the user's theme. */
35
+ function tone(asked, skin, theme) {
36
+ var _a;
37
+ return (_a = asked !== null && asked !== void 0 ? asked : skin.tone) !== null && _a !== void 0 ? _a : theme;
38
+ }
39
+ SkinUtil.tone = tone;
40
+ /** A picture fit to keep: a picture, not too long. */
41
+ function keepable(picture) {
42
+ return typeof picture === 'string' && picture.startsWith('data:image/') && picture.length <= MAX_PICTURE;
43
+ }
44
+ SkinUtil.keepable = keepable;
45
+ /** `#rrggbb` of `#rgb`, `#rrggbb` or `rgb(r, g, b)`; otherwise what `normalize` makes of it (a canvas of the page), else undefined. */
46
+ function hex(color, normalize) {
47
+ var _a;
48
+ const value = (_a = color === null || color === void 0 ? void 0 : color.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
49
+ const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(value);
50
+ if (short) {
51
+ return `#${short[1]}${short[1]}${short[2]}${short[2]}${short[3]}${short[3]}`;
52
+ }
53
+ if (/^#[0-9a-f]{6}$/.test(value)) {
54
+ return value;
55
+ }
56
+ const rgb = /^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*(?:[,/]\s*[\d.]+%?\s*)?\)$/.exec(value);
57
+ if (rgb) {
58
+ return `#${rgb
59
+ .slice(1, 4)
60
+ .map(part => Math.min(255, Number(part)).toString(16).padStart(2, '0'))
61
+ .join('')}`;
62
+ }
63
+ const made = value && (normalize === null || normalize === void 0 ? void 0 : normalize(value));
64
+ return made && /^#[0-9a-f]{6}$/.test(made) ? made : undefined;
65
+ }
66
+ SkinUtil.hex = hex;
67
+ /** Whether words on `#rrggbb` should be dark. */
68
+ function light(hex) {
69
+ const [r, g, b] = [1, 3, 5]
70
+ .map(at => Number.parseInt(hex.slice(at, at + 2), 16) / 255)
71
+ .map(c => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
72
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.4;
73
+ }
74
+ SkinUtil.light = light;
75
+ /**
76
+ * The variables of the root for the colours of a tone (style/skins.ts makes the theme of them): those left out are
77
+ * not set, so that the style's own stand; the words on the accent dark or light as it is.
78
+ */
79
+ function variables(colors, normalize) {
80
+ var _a;
81
+ const base = (_a = hex(colors.base, normalize)) !== null && _a !== void 0 ? _a : '#808080';
82
+ const out = { '--ta-skin-base': base };
83
+ const glass = hex(colors.glass, normalize);
84
+ const ink = hex(colors.ink, normalize);
85
+ const accent = hex(colors.accent, normalize);
86
+ if (glass) {
87
+ out['--ta-skin-glass'] = glass;
88
+ }
89
+ if (ink) {
90
+ out['--ta-skin-ink'] = ink;
91
+ }
92
+ if (accent) {
93
+ out['--ta-skin-accent'] = accent;
94
+ out['--ta-skin-on-accent'] = light(accent) ? '#1a1a1a' : '#ffffff';
95
+ }
96
+ return out;
97
+ }
98
+ SkinUtil.variables = variables;
99
+ /** Every variable `variables` may set, to take them off again. */
100
+ SkinUtil.VARIABLES = ['--ta-skin-base', '--ta-skin-glass', '--ta-skin-ink', '--ta-skin-accent', '--ta-skin-on-accent'];
101
+ /** The rectangles of what `selector` finds that can be seen in the window. */
102
+ function rects(root, selector, width, height) {
103
+ const out = [];
104
+ for (const element of root.querySelectorAll(selector)) {
105
+ const box = element.getBoundingClientRect();
106
+ if (box.width > 1 && box.height > 1 && box.right > 0 && box.bottom > 0 && box.left < width && box.top < height) {
107
+ out.push({ left: box.left, top: box.top, right: box.right, bottom: box.bottom });
108
+ }
109
+ }
110
+ return out;
111
+ }
112
+ SkinUtil.rects = rects;
113
+ /** Where words are read and where columns cover the picture, in the window now. */
114
+ function areas(document) {
115
+ var _a, _b;
116
+ const view = document.defaultView;
117
+ const width = (_a = view === null || view === void 0 ? void 0 : view.innerWidth) !== null && _a !== void 0 ? _a : 0;
118
+ const height = (_b = view === null || view === void 0 ? void 0 : view.innerHeight) !== null && _b !== void 0 ? _b : 0;
119
+ return { read: rects(document, SkinUtil.READ, width, height), cover: rects(document, SkinUtil.COVER, width, height) };
120
+ }
121
+ SkinUtil.areas = areas;
122
+ })(SkinUtil || (exports.SkinUtil = SkinUtil = {}));
123
+ //# sourceMappingURL=skin-util.js.map