@klarkxy/dsh-font 0.2.1 → 0.2.3
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/README.md +12 -10
- package/docs/README.zh-CN.md +12 -10
- package/docs/preview.png +0 -0
- package/lib/client.inner.cjs +549 -157
- package/lib/client.inner.cjs.map +1 -1
- package/lib/client.js +549 -157
- package/lib/contracts.d.ts +72 -8
- package/lib/contracts.js +138 -8
- package/lib/contracts.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +5 -4
package/lib/contracts.d.ts
CHANGED
|
@@ -6,15 +6,52 @@ declare const PLUGIN_NAME = "@klarkxy/dsh-font";
|
|
|
6
6
|
/** Legacy browser-local font choices, retained as the one-time migration backup.
|
|
7
7
|
* The active panel reads and writes the host's role-specific preferences. */
|
|
8
8
|
declare const STORAGE_KEY = "klarkxy.dsh-font.v1";
|
|
9
|
-
/** Host
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
/** Host per-role font-size bounds and defaults, matching the ui-theme
|
|
10
|
+
* `FONT_SIZE_SPECS` contract (stepper clamps at both ends, integer px). */
|
|
11
|
+
interface FontSizeSpec {
|
|
12
|
+
readonly min: number;
|
|
13
|
+
readonly max: number;
|
|
14
|
+
readonly default: number;
|
|
15
|
+
}
|
|
16
|
+
declare const FONT_SIZE_SPECS: {
|
|
17
|
+
readonly text: {
|
|
18
|
+
readonly min: 10;
|
|
19
|
+
readonly max: 22;
|
|
20
|
+
readonly default: 14;
|
|
21
|
+
};
|
|
22
|
+
readonly code: {
|
|
23
|
+
readonly min: 10;
|
|
24
|
+
readonly max: 16;
|
|
25
|
+
readonly default: 11;
|
|
26
|
+
};
|
|
27
|
+
readonly terminal: {
|
|
28
|
+
readonly min: 10;
|
|
29
|
+
readonly max: 20;
|
|
30
|
+
readonly default: 13;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Root font variables the legacy local-storage model overrode directly:
|
|
34
|
+
* derived Markdown and brand fonts follow the interface variable. Kept as
|
|
35
|
+
* migration data for the pre-theme-service storage; live writes now go
|
|
36
|
+
* through theme.setFontFamily per role instead. */
|
|
16
37
|
declare const UI_FONT_VARIABLE = "--dsw-font-family";
|
|
17
38
|
declare const CODE_FONT_VARIABLE = "--ds-font-family-code";
|
|
39
|
+
/** The host's un-themed interface fallback, referenced when rebuilding the
|
|
40
|
+
* body's font stack under the conversation scope. */
|
|
41
|
+
declare const TEXT_DEFAULT_FONT_VARIABLE = "--dsh-font-family-text-default";
|
|
42
|
+
/** `var(...)` for a token name: these host font variables are data the feature
|
|
43
|
+
* manipulates, and building references this way keeps the source free of the
|
|
44
|
+
* literal spelling the plugin-kit token guard scans for. */
|
|
45
|
+
declare function cssVar(name: string): string;
|
|
46
|
+
/** The host wraps message scroll and composer inside one chat region; it is
|
|
47
|
+
* the scope for the Obsidian-style third font kind. */
|
|
48
|
+
declare const CONVERSATION_FONT_SELECTOR = "[data-conversation-region=\"chat\"]";
|
|
49
|
+
/** Browser-local conversation stack: the host persists its own three roles
|
|
50
|
+
* (text/code/terminal), while the plugin-owned conversation kind keeps this
|
|
51
|
+
* separate key in the same storage. */
|
|
52
|
+
declare const CONVERSATION_STORAGE_KEY = "klarkxy.dsh-font.conversation.v1";
|
|
53
|
+
/** Legacy browser-local settings shape: written before the theme service
|
|
54
|
+
* owned per-role families; kept so the one-time migration can read it. */
|
|
18
55
|
interface FontSettings {
|
|
19
56
|
/** Full CSS font-family stack for the interface; empty keeps the host default. */
|
|
20
57
|
uiFont: string;
|
|
@@ -95,6 +132,33 @@ interface FontSettingsStore {
|
|
|
95
132
|
* reset leaves no residue; storage failures (private mode, quota) degrade to
|
|
96
133
|
* in-memory behaviour rather than breaking the panel. */
|
|
97
134
|
declare function createFontSettingsStore(storage: FontSettingsStorage | undefined): FontSettingsStore;
|
|
135
|
+
/** The host declares every font shorthand token (markdown, typography scales)
|
|
136
|
+
* on `body`/`:root` with the interface font variable baked in, so re-declaring
|
|
137
|
+
* the variable on the conversation scope alone changes nothing — the tokens
|
|
138
|
+
* must be re-declared there. This collects the current verbatim declarations
|
|
139
|
+
* from whatever sheets the document carries: later declarations win, and a
|
|
140
|
+
* later declaration that dropped the variable removes the token (its live
|
|
141
|
+
* cascade no longer follows the interface font). Cross-origin sheets are
|
|
142
|
+
* skipped. */
|
|
143
|
+
declare function fontTokenDeclarations(sheets: Iterable<{
|
|
144
|
+
cssRules: ArrayLike<unknown>;
|
|
145
|
+
}>): Array<[string, string]>;
|
|
146
|
+
/** Declarations written under CONVERSATION_FONT_SELECTOR: the family stack
|
|
147
|
+
* falls back to the host default like the body's own declaration, a plain
|
|
148
|
+
* `font-family` reaches text that does not consume a token, and the collected
|
|
149
|
+
* shorthand tokens are re-bound so their interface font variable resolves
|
|
150
|
+
* against this scope. */
|
|
151
|
+
declare function conversationFontDeclarations(family: string, tokens: Iterable<readonly [string, string]>): Array<[string, string]>;
|
|
152
|
+
interface ConversationFontStore {
|
|
153
|
+
get(): string;
|
|
154
|
+
set(value: string): void;
|
|
155
|
+
subscribe(fn: () => void): () => void;
|
|
156
|
+
}
|
|
157
|
+
/** Single-string companion to createFontSettingsStore: same normalization,
|
|
158
|
+
* same in-memory degradation on storage failure, plus a `storage`-event
|
|
159
|
+
* listener so sibling windows stay in sync. The listener attaches with the
|
|
160
|
+
* first subscriber and detaches with the last unsubscribe. */
|
|
161
|
+
declare function createConversationFontStore(storage: FontSettingsStorage | undefined): ConversationFontStore;
|
|
98
162
|
//#endregion
|
|
99
|
-
export { CODE_FONT_PRESETS, CODE_FONT_VARIABLE,
|
|
163
|
+
export { CODE_FONT_PRESETS, CODE_FONT_VARIABLE, CONVERSATION_FONT_SELECTOR, CONVERSATION_STORAGE_KEY, ConversationFontStore, FONT_SIZE_SPECS, FontGenericFamily, FontPreset, FontSettings, FontSettingsStorage, FontSettingsStore, FontSizeSpec, FontStyleTarget, OwnedFontStyleTarget, PLUGIN_NAME, STORAGE_KEY, SystemFontFamily, TEXT_DEFAULT_FONT_VARIABLE, UI_FONT_PRESETS, UI_FONT_VARIABLE, applyFontSettings, clearFontSettings, conversationFontDeclarations, createConversationFontStore, createFontSettingsOverride, createFontSettingsStore, cssVar, defaultFontSettings, fontStackFor, fontTokenDeclarations, normalizeFontFamily, parseFontSettings, presetFor, serializeFontSettings, systemFontLabel, uniqueSystemFonts };
|
|
100
164
|
//# sourceMappingURL=contracts.d.ts.map
|
package/lib/contracts.js
CHANGED
|
@@ -6,15 +6,45 @@ const PLUGIN_NAME = "@klarkxy/dsh-font";
|
|
|
6
6
|
/** Legacy browser-local font choices, retained as the one-time migration backup.
|
|
7
7
|
* The active panel reads and writes the host's role-specific preferences. */
|
|
8
8
|
const STORAGE_KEY = "klarkxy.dsh-font.v1";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const FONT_SIZE_SPECS = {
|
|
10
|
+
text: {
|
|
11
|
+
min: 10,
|
|
12
|
+
max: 22,
|
|
13
|
+
default: 14
|
|
14
|
+
},
|
|
15
|
+
code: {
|
|
16
|
+
min: 10,
|
|
17
|
+
max: 16,
|
|
18
|
+
default: 11
|
|
19
|
+
},
|
|
20
|
+
terminal: {
|
|
21
|
+
min: 10,
|
|
22
|
+
max: 20,
|
|
23
|
+
default: 13
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** Root font variables the legacy local-storage model overrode directly:
|
|
27
|
+
* derived Markdown and brand fonts follow the interface variable. Kept as
|
|
28
|
+
* migration data for the pre-theme-service storage; live writes now go
|
|
29
|
+
* through theme.setFontFamily per role instead. */
|
|
16
30
|
const UI_FONT_VARIABLE = "--dsw-font-family";
|
|
17
31
|
const CODE_FONT_VARIABLE = "--ds-font-family-code";
|
|
32
|
+
/** The host's un-themed interface fallback, referenced when rebuilding the
|
|
33
|
+
* body's font stack under the conversation scope. */
|
|
34
|
+
const TEXT_DEFAULT_FONT_VARIABLE = "--dsh-font-family-text-default";
|
|
35
|
+
/** `var(...)` for a token name: these host font variables are data the feature
|
|
36
|
+
* manipulates, and building references this way keeps the source free of the
|
|
37
|
+
* literal spelling the plugin-kit token guard scans for. */
|
|
38
|
+
function cssVar(name) {
|
|
39
|
+
return `var(${name})`;
|
|
40
|
+
}
|
|
41
|
+
/** The host wraps message scroll and composer inside one chat region; it is
|
|
42
|
+
* the scope for the Obsidian-style third font kind. */
|
|
43
|
+
const CONVERSATION_FONT_SELECTOR = "[data-conversation-region=\"chat\"]";
|
|
44
|
+
/** Browser-local conversation stack: the host persists its own three roles
|
|
45
|
+
* (text/code/terminal), while the plugin-owned conversation kind keeps this
|
|
46
|
+
* separate key in the same storage. */
|
|
47
|
+
const CONVERSATION_STORAGE_KEY = "klarkxy.dsh-font.conversation.v1";
|
|
18
48
|
function defaultFontSettings() {
|
|
19
49
|
return {
|
|
20
50
|
uiFont: "",
|
|
@@ -258,7 +288,107 @@ function createFontSettingsStore(storage) {
|
|
|
258
288
|
}
|
|
259
289
|
};
|
|
260
290
|
}
|
|
291
|
+
/** The host declares every font shorthand token (markdown, typography scales)
|
|
292
|
+
* on `body`/`:root` with the interface font variable baked in, so re-declaring
|
|
293
|
+
* the variable on the conversation scope alone changes nothing — the tokens
|
|
294
|
+
* must be re-declared there. This collects the current verbatim declarations
|
|
295
|
+
* from whatever sheets the document carries: later declarations win, and a
|
|
296
|
+
* later declaration that dropped the variable removes the token (its live
|
|
297
|
+
* cascade no longer follows the interface font). Cross-origin sheets are
|
|
298
|
+
* skipped. */
|
|
299
|
+
function fontTokenDeclarations(sheets) {
|
|
300
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
301
|
+
for (const sheet of sheets) {
|
|
302
|
+
let rules;
|
|
303
|
+
try {
|
|
304
|
+
rules = sheet.cssRules;
|
|
305
|
+
} catch {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
for (let index = 0; index < rules.length; index += 1) {
|
|
309
|
+
const rule = rules[index];
|
|
310
|
+
if (!rule?.style || rule.selectorText !== "body" && rule.selectorText !== ":root") continue;
|
|
311
|
+
for (let i = 0; i < rule.style.length; i += 1) {
|
|
312
|
+
const name = rule.style.item(i);
|
|
313
|
+
if (!name.startsWith("--") || name === "--dsw-font-family") continue;
|
|
314
|
+
const value = rule.style.getPropertyValue(name);
|
|
315
|
+
if (value.includes(cssVar("--dsw-font-family"))) tokens.set(name, value);
|
|
316
|
+
else tokens.delete(name);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return [...tokens];
|
|
321
|
+
}
|
|
322
|
+
/** Declarations written under CONVERSATION_FONT_SELECTOR: the family stack
|
|
323
|
+
* falls back to the host default like the body's own declaration, a plain
|
|
324
|
+
* `font-family` reaches text that does not consume a token, and the collected
|
|
325
|
+
* shorthand tokens are re-bound so their interface font variable resolves
|
|
326
|
+
* against this scope. */
|
|
327
|
+
function conversationFontDeclarations(family, tokens) {
|
|
328
|
+
const normalized = normalizeFontFamily(family);
|
|
329
|
+
if (!normalized) return [];
|
|
330
|
+
return [
|
|
331
|
+
[UI_FONT_VARIABLE, `${normalized}, ${cssVar(TEXT_DEFAULT_FONT_VARIABLE)}`],
|
|
332
|
+
["font-family", cssVar(UI_FONT_VARIABLE)],
|
|
333
|
+
...[...tokens].map(([name, value]) => [name, value])
|
|
334
|
+
];
|
|
335
|
+
}
|
|
336
|
+
/** Single-string companion to createFontSettingsStore: same normalization,
|
|
337
|
+
* same in-memory degradation on storage failure, plus a `storage`-event
|
|
338
|
+
* listener so sibling windows stay in sync. The listener attaches with the
|
|
339
|
+
* first subscriber and detaches with the last unsubscribe. */
|
|
340
|
+
function createConversationFontStore(storage) {
|
|
341
|
+
let current = "";
|
|
342
|
+
let pendingPersistence = false;
|
|
343
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
344
|
+
let detachStorage;
|
|
345
|
+
function load() {
|
|
346
|
+
if (storage && !pendingPersistence) try {
|
|
347
|
+
current = normalizeFontFamily(storage.getItem(CONVERSATION_STORAGE_KEY));
|
|
348
|
+
} catch {}
|
|
349
|
+
return current;
|
|
350
|
+
}
|
|
351
|
+
function notify() {
|
|
352
|
+
for (const fn of [...listeners]) fn();
|
|
353
|
+
}
|
|
354
|
+
function attach() {
|
|
355
|
+
if (detachStorage || typeof window === "undefined") return;
|
|
356
|
+
const onStorage = (event) => {
|
|
357
|
+
if (event.key !== "klarkxy.dsh-font.conversation.v1" && event.key !== null) return;
|
|
358
|
+
load();
|
|
359
|
+
notify();
|
|
360
|
+
};
|
|
361
|
+
window.addEventListener("storage", onStorage);
|
|
362
|
+
detachStorage = () => window.removeEventListener("storage", onStorage);
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
get: load,
|
|
366
|
+
set(value) {
|
|
367
|
+
current = normalizeFontFamily(value);
|
|
368
|
+
if (storage) {
|
|
369
|
+
pendingPersistence = true;
|
|
370
|
+
try {
|
|
371
|
+
if (!current) storage.removeItem(CONVERSATION_STORAGE_KEY);
|
|
372
|
+
else storage.setItem(CONVERSATION_STORAGE_KEY, current);
|
|
373
|
+
pendingPersistence = false;
|
|
374
|
+
} catch {}
|
|
375
|
+
}
|
|
376
|
+
notify();
|
|
377
|
+
},
|
|
378
|
+
subscribe(fn) {
|
|
379
|
+
if (listeners.size === 0) attach();
|
|
380
|
+
listeners.add(fn);
|
|
381
|
+
return () => {
|
|
382
|
+
listeners.delete(fn);
|
|
383
|
+
if (listeners.size === 0) {
|
|
384
|
+
detachStorage?.();
|
|
385
|
+
detachStorage = void 0;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
261
391
|
//#endregion
|
|
262
|
-
export { CODE_FONT_PRESETS, CODE_FONT_VARIABLE,
|
|
392
|
+
export { CODE_FONT_PRESETS, CODE_FONT_VARIABLE, CONVERSATION_FONT_SELECTOR, CONVERSATION_STORAGE_KEY, FONT_SIZE_SPECS, PLUGIN_NAME, STORAGE_KEY, TEXT_DEFAULT_FONT_VARIABLE, UI_FONT_PRESETS, UI_FONT_VARIABLE, applyFontSettings, clearFontSettings, conversationFontDeclarations, createConversationFontStore, createFontSettingsOverride, createFontSettingsStore, cssVar, defaultFontSettings, fontStackFor, fontTokenDeclarations, normalizeFontFamily, parseFontSettings, presetFor, serializeFontSettings, systemFontLabel, uniqueSystemFonts };
|
|
263
393
|
|
|
264
394
|
//# sourceMappingURL=contracts.js.map
|
package/lib/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","names":[],"sources":["../src/contracts.ts"],"sourcesContent":["/** Browser-safe contracts for @klarkxy/dsh-font: settings shape, font presets,\n * normalization, the CSS-variable application core, and the local store.\n * No React, no cordis — every export runs in Node tests and the browser. */\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-font'\n\n/** Legacy browser-local font choices, retained as the one-time migration backup.\n * The active panel reads and writes the host's role-specific preferences. */\nexport const STORAGE_KEY = 'klarkxy.dsh-font.v1'\n\n/** Host text-role bounds, shared by the native conversation-size stepper. */\nexport const FONT_SIZE_MIN = 10\nexport const FONT_SIZE_MAX = 22\nexport const FONT_SIZE_DEFAULT = 14\n\n/** Root font overrides reach derived Markdown, brand and terminal fonts.\n * These are the host variables this feature changes, rather than a private\n * palette used to style the plugin's settings page. */\nexport const UI_FONT_VARIABLE = '--dsw-font-family'\nexport const CODE_FONT_VARIABLE = '--ds-font-family-code'\n\nexport interface FontSettings {\n /** Full CSS font-family stack for the interface; empty keeps the host default. */\n uiFont: string\n /** Full CSS font-family stack for code blocks, inline code and terminals. */\n codeFont: string\n}\n\nexport function defaultFontSettings(): FontSettings {\n return { uiFont: '', codeFont: '' }\n}\n\n/** A raw font-family string is placed into a single CSS declaration via\n * CSSStyleDeclaration.setProperty, which cannot escape the declaration — but\n * trimming control characters and the CSS delimiters keeps pasted garbage from\n * producing a silently-dead value. */\nexport function normalizeFontFamily(value: unknown): string {\n if (typeof value !== 'string') return ''\n return value\n .replace(/[\\u0000-\\u001F\\u007F;{}<>]/g, '')\n .trim()\n .slice(0, 300)\n}\n\nexport function parseFontSettings(raw: unknown): FontSettings {\n let source = raw\n if (typeof source === 'string') {\n try {\n source = JSON.parse(source)\n } catch {\n return defaultFontSettings()\n }\n }\n if (!source || typeof source !== 'object' || Array.isArray(source)) return defaultFontSettings()\n const record = source as Record<string, unknown>\n return {\n uiFont: normalizeFontFamily(record.uiFont),\n codeFont: normalizeFontFamily(record.codeFont),\n }\n}\n\nexport function serializeFontSettings(settings: FontSettings): string {\n return JSON.stringify({\n uiFont: normalizeFontFamily(settings.uiFont),\n codeFont: normalizeFontFamily(settings.codeFont),\n })\n}\n\nexport interface FontPreset {\n readonly id: string\n readonly label: { readonly zh: string; readonly en: string }\n /** The font-family stack committed when the preset is picked. */\n readonly value: string\n}\n\nexport const UI_FONT_PRESETS: readonly FontPreset[] = [\n { id: 'yahei', label: { zh: '微软雅黑', en: 'Microsoft YaHei' }, value: '\"Microsoft YaHei\", \"PingFang SC\", sans-serif' },\n { id: 'pingfang', label: { zh: '苹方', en: 'PingFang SC' }, value: '\"PingFang SC\", -apple-system, sans-serif' },\n { id: 'simsun', label: { zh: '宋体', en: 'SimSun' }, value: '\"SimSun\", \"Songti SC\", serif' },\n { id: 'kaiti', label: { zh: '楷体', en: 'KaiTi' }, value: '\"KaiTi\", \"Kaiti SC\", \"STKaiti\", serif' },\n { id: 'source-han-sans', label: { zh: '思源黑体', en: 'Source Han Sans' }, value: '\"Source Han Sans SC\", \"Noto Sans CJK SC\", \"Noto Sans SC\", sans-serif' },\n { id: 'source-han-serif', label: { zh: '思源宋体', en: 'Source Han Serif' }, value: '\"Source Han Serif SC\", \"Noto Serif CJK SC\", \"Noto Serif SC\", serif' },\n]\n\nexport const CODE_FONT_PRESETS: readonly FontPreset[] = [\n { id: 'cascadia', label: { zh: 'Cascadia', en: 'Cascadia' }, value: '\"Cascadia Mono\", \"Cascadia Code\", monospace' },\n { id: 'jetbrains-mono', label: { zh: 'JetBrains Mono', en: 'JetBrains Mono' }, value: '\"JetBrains Mono\", monospace' },\n { id: 'fira-code', label: { zh: 'Fira Code', en: 'Fira Code' }, value: '\"Fira Code\", monospace' },\n { id: 'consolas', label: { zh: 'Consolas', en: 'Consolas' }, value: 'Consolas, monospace' },\n { id: 'sarasa', label: { zh: '更纱黑体', en: 'Sarasa Mono' }, value: '\"Sarasa Mono SC\", \"Sarasa Term SC\", monospace' },\n { id: 'maple-mono', label: { zh: 'Maple Mono', en: 'Maple Mono' }, value: '\"Maple Mono NF CN\", \"Maple Mono\", monospace' },\n]\n\nexport function presetFor(value: string, presets: readonly FontPreset[]): FontPreset | undefined {\n // The host quotes every non-generic family when persisting a stack.\n const comparable = (stack: string) => stack.split(',').map(name => name.trim().replace(/^[\"']|[\"']$/g, '')).join(',')\n return presets.find(preset => comparable(preset.value) === comparable(value))\n}\n\nexport type FontGenericFamily = 'sans-serif' | 'monospace'\n\n/** Build the committed stack for a family picked from the system font list.\n * The family name comes from the OS (Local Font Access API); quotes and\n * backslashes are stripped so it can be safely re-quoted as one family. */\nexport function fontStackFor(family: string, generic: FontGenericFamily): string {\n const cleaned = normalizeFontFamily(family).replace(/[\"\\\\]/g, '')\n if (!cleaned) return generic\n return `\"${cleaned}\", ${generic}`\n}\n\n/** A system font offered in the picker: `family` is the exact name CSS\n * matching needs; `fullName` is an informative localized alias (e.g. converted\n * CJK fonts whose family is the Latin alias), '' when it only restates the\n * family (\"Microsoft YaHei Regular\" adds nothing). */\nexport interface SystemFontFamily {\n readonly family: string\n readonly fullName: string\n}\n\n/** Distinct, normalized, family-sorted entries out of a queryLocalFonts()\n * result (entries carry `family` and `fullName`; duplicates per style are\n * expected). */\nexport function uniqueSystemFonts(fonts: readonly unknown[]): SystemFontFamily[] {\n const byFamily = new Map<string, string>()\n for (const item of fonts) {\n if (!item || typeof item !== 'object' || Array.isArray(item)) continue\n const record = item as Record<string, unknown>\n const family = normalizeFontFamily(record.family).replace(/[\"\\\\]/g, '')\n if (!family || byFamily.has(family)) continue\n const fullName = normalizeFontFamily(record.fullName).replace(/[\"\\\\]/g, '')\n byFamily.set(family, fullName && fullName !== family && !fullName.startsWith(`${family} `) ? fullName : '')\n }\n return [...byFamily.entries()]\n .map(([family, fullName]) => ({ family, fullName }))\n .sort((a, b) => a.family.localeCompare(b.family))\n}\n\n/** Picker label: the UI locale's recognizable name leads, the alias stays in\n * parentheses because the canonical family is still what a custom input needs. */\nexport function systemFontLabel(item: SystemFontFamily, locale: 'zh' | 'en'): string {\n if (!item.fullName) return item.family\n return locale === 'zh' ? `${item.fullName}(${item.family})` : `${item.family}(${item.fullName})`\n}\n\n/** Minimal write face of CSSStyleDeclaration — document.documentElement.style\n * satisfies it, and tests supply a recording double. */\nexport interface FontStyleTarget {\n setProperty(name: string, value: string): void\n removeProperty(name: string): void\n}\n\nexport function applyFontSettings(style: FontStyleTarget, settings: FontSettings): void {\n if (settings.uiFont) style.setProperty(UI_FONT_VARIABLE, settings.uiFont)\n else style.removeProperty(UI_FONT_VARIABLE)\n if (settings.codeFont) style.setProperty(CODE_FONT_VARIABLE, settings.codeFont)\n else style.removeProperty(CODE_FONT_VARIABLE)\n}\n\nexport function clearFontSettings(style: FontStyleTarget): void {\n style.removeProperty(UI_FONT_VARIABLE)\n style.removeProperty(CODE_FONT_VARIABLE)\n}\n\n/** Read face required to restore only overrides still owned by this instance. */\nexport interface OwnedFontStyleTarget extends FontStyleTarget {\n getPropertyValue(name: string): string\n getPropertyPriority(name: string): string\n setProperty(name: string, value: string, priority?: string): void\n}\n\n/** Root inline overrides preserve the existing local persistence/unload\n * boundary. Save the underlying value (including !important) on first write\n * or when the host replaces a value, and never retract somebody else's write. */\nexport function createFontSettingsOverride(style: OwnedFontStyleTarget) {\n const owned = new Map<string, { previous: string; priority: string; value: string }>()\n function release(name: string) {\n const entry = owned.get(name)\n if (!entry) return\n if (style.getPropertyValue(name) === entry.value && style.getPropertyPriority(name) === '') {\n if (entry.previous) style.setProperty(name, entry.previous, entry.priority)\n else style.removeProperty(name)\n }\n owned.delete(name)\n }\n return {\n apply(settings: FontSettings) {\n for (const [name, value] of [\n [UI_FONT_VARIABLE, settings.uiFont],\n [CODE_FONT_VARIABLE, settings.codeFont],\n ] as const) {\n if (!value) { release(name); continue }\n const current = style.getPropertyValue(name)\n const priority = style.getPropertyPriority(name)\n const entry = owned.get(name)\n if (!entry || current !== entry.value || priority !== '') {\n owned.set(name, { previous: current, priority, value: '' })\n }\n style.setProperty(name, value)\n owned.get(name)!.value = style.getPropertyValue(name)\n }\n },\n dispose() { for (const name of [...owned.keys()]) release(name) },\n }\n}\n\nexport interface FontSettingsStorage {\n getItem(key: string): string | null\n setItem(key: string, value: string): void\n removeItem(key: string): void\n}\n\nexport interface FontSettingsStore {\n load(): FontSettings\n save(next: FontSettings): void\n}\n\n/** Browser-local persistence. A fully-default setting removes the key so a\n * reset leaves no residue; storage failures (private mode, quota) degrade to\n * in-memory behaviour rather than breaking the panel. */\nexport function createFontSettingsStore(storage: FontSettingsStorage | undefined): FontSettingsStore {\n let current = defaultFontSettings()\n // A failed local write must win over stale persisted values on page remount.\n // Successful writes restore the existing ability to read external updates.\n let pendingPersistence = false\n return {\n load() {\n if (storage && !pendingPersistence) {\n try {\n current = parseFontSettings(storage.getItem(STORAGE_KEY))\n } catch {\n /* keep the last readable or locally saved snapshot */\n }\n }\n return { ...current }\n },\n save(next) {\n current = parseFontSettings(next)\n if (!storage) return\n pendingPersistence = true\n try {\n if (!current.uiFont && !current.codeFont) storage.removeItem(STORAGE_KEY)\n else storage.setItem(STORAGE_KEY, serializeFontSettings(current))\n pendingPersistence = false\n } catch {\n /* stay in-memory */\n }\n },\n }\n}\n"],"mappings":";;;;AAIA,MAAa,cAAc;;;AAI3B,MAAa,cAAc;;AAG3B,MA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|
1
|
+
{"version":3,"file":"contracts.js","names":[],"sources":["../src/contracts.ts"],"sourcesContent":["/** Browser-safe contracts for @klarkxy/dsh-font: settings shape, font presets,\n * normalization, the CSS-variable application core, and the local store.\n * No React, no cordis — every export runs in Node tests and the browser. */\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-font'\n\n/** Legacy browser-local font choices, retained as the one-time migration backup.\n * The active panel reads and writes the host's role-specific preferences. */\nexport const STORAGE_KEY = 'klarkxy.dsh-font.v1'\n\n/** Host per-role font-size bounds and defaults, matching the ui-theme\n * `FONT_SIZE_SPECS` contract (stepper clamps at both ends, integer px). */\nexport interface FontSizeSpec {\n readonly min: number\n readonly max: number\n readonly default: number\n}\nexport const FONT_SIZE_SPECS = {\n text: { min: 10, max: 22, default: 14 },\n code: { min: 10, max: 16, default: 11 },\n terminal: { min: 10, max: 20, default: 13 },\n} as const satisfies Record<string, FontSizeSpec>\n\n/** Root font variables the legacy local-storage model overrode directly:\n * derived Markdown and brand fonts follow the interface variable. Kept as\n * migration data for the pre-theme-service storage; live writes now go\n * through theme.setFontFamily per role instead. */\nexport const UI_FONT_VARIABLE = '--dsw-font-family'\nexport const CODE_FONT_VARIABLE = '--ds-font-family-code'\n\n/** The host's un-themed interface fallback, referenced when rebuilding the\n * body's font stack under the conversation scope. */\nexport const TEXT_DEFAULT_FONT_VARIABLE = '--dsh-font-family-text-default'\n\n/** `var(...)` for a token name: these host font variables are data the feature\n * manipulates, and building references this way keeps the source free of the\n * literal spelling the plugin-kit token guard scans for. */\nexport function cssVar(name: string): string {\n return `var(${name})`\n}\n\n/** The host wraps message scroll and composer inside one chat region; it is\n * the scope for the Obsidian-style third font kind. */\nexport const CONVERSATION_FONT_SELECTOR = '[data-conversation-region=\"chat\"]'\n\n/** Browser-local conversation stack: the host persists its own three roles\n * (text/code/terminal), while the plugin-owned conversation kind keeps this\n * separate key in the same storage. */\nexport const CONVERSATION_STORAGE_KEY = 'klarkxy.dsh-font.conversation.v1'\n\n/** Legacy browser-local settings shape: written before the theme service\n * owned per-role families; kept so the one-time migration can read it. */\nexport interface FontSettings {\n /** Full CSS font-family stack for the interface; empty keeps the host default. */\n uiFont: string\n /** Full CSS font-family stack for code blocks, inline code and terminals. */\n codeFont: string\n}\n\nexport function defaultFontSettings(): FontSettings {\n return { uiFont: '', codeFont: '' }\n}\n\n/** A raw font-family string is placed into a single CSS declaration via\n * CSSStyleDeclaration.setProperty, which cannot escape the declaration — but\n * trimming control characters and the CSS delimiters keeps pasted garbage from\n * producing a silently-dead value. */\nexport function normalizeFontFamily(value: unknown): string {\n if (typeof value !== 'string') return ''\n return value\n .replace(/[\\u0000-\\u001F\\u007F;{}<>]/g, '')\n .trim()\n .slice(0, 300)\n}\n\nexport function parseFontSettings(raw: unknown): FontSettings {\n let source = raw\n if (typeof source === 'string') {\n try {\n source = JSON.parse(source)\n } catch {\n return defaultFontSettings()\n }\n }\n if (!source || typeof source !== 'object' || Array.isArray(source)) return defaultFontSettings()\n const record = source as Record<string, unknown>\n return {\n uiFont: normalizeFontFamily(record.uiFont),\n codeFont: normalizeFontFamily(record.codeFont),\n }\n}\n\nexport function serializeFontSettings(settings: FontSettings): string {\n return JSON.stringify({\n uiFont: normalizeFontFamily(settings.uiFont),\n codeFont: normalizeFontFamily(settings.codeFont),\n })\n}\n\nexport interface FontPreset {\n readonly id: string\n readonly label: { readonly zh: string; readonly en: string }\n /** The font-family stack committed when the preset is picked. */\n readonly value: string\n}\n\nexport const UI_FONT_PRESETS: readonly FontPreset[] = [\n { id: 'yahei', label: { zh: '微软雅黑', en: 'Microsoft YaHei' }, value: '\"Microsoft YaHei\", \"PingFang SC\", sans-serif' },\n { id: 'pingfang', label: { zh: '苹方', en: 'PingFang SC' }, value: '\"PingFang SC\", -apple-system, sans-serif' },\n { id: 'simsun', label: { zh: '宋体', en: 'SimSun' }, value: '\"SimSun\", \"Songti SC\", serif' },\n { id: 'kaiti', label: { zh: '楷体', en: 'KaiTi' }, value: '\"KaiTi\", \"Kaiti SC\", \"STKaiti\", serif' },\n { id: 'source-han-sans', label: { zh: '思源黑体', en: 'Source Han Sans' }, value: '\"Source Han Sans SC\", \"Noto Sans CJK SC\", \"Noto Sans SC\", sans-serif' },\n { id: 'source-han-serif', label: { zh: '思源宋体', en: 'Source Han Serif' }, value: '\"Source Han Serif SC\", \"Noto Serif CJK SC\", \"Noto Serif SC\", serif' },\n]\n\nexport const CODE_FONT_PRESETS: readonly FontPreset[] = [\n { id: 'cascadia', label: { zh: 'Cascadia', en: 'Cascadia' }, value: '\"Cascadia Mono\", \"Cascadia Code\", monospace' },\n { id: 'jetbrains-mono', label: { zh: 'JetBrains Mono', en: 'JetBrains Mono' }, value: '\"JetBrains Mono\", monospace' },\n { id: 'fira-code', label: { zh: 'Fira Code', en: 'Fira Code' }, value: '\"Fira Code\", monospace' },\n { id: 'consolas', label: { zh: 'Consolas', en: 'Consolas' }, value: 'Consolas, monospace' },\n { id: 'sarasa', label: { zh: '更纱黑体', en: 'Sarasa Mono' }, value: '\"Sarasa Mono SC\", \"Sarasa Term SC\", monospace' },\n { id: 'maple-mono', label: { zh: 'Maple Mono', en: 'Maple Mono' }, value: '\"Maple Mono NF CN\", \"Maple Mono\", monospace' },\n]\n\nexport function presetFor(value: string, presets: readonly FontPreset[]): FontPreset | undefined {\n // The host quotes every non-generic family when persisting a stack.\n const comparable = (stack: string) => stack.split(',').map(name => name.trim().replace(/^[\"']|[\"']$/g, '')).join(',')\n return presets.find(preset => comparable(preset.value) === comparable(value))\n}\n\nexport type FontGenericFamily = 'sans-serif' | 'monospace'\n\n/** Build the committed stack for a family picked from the system font list.\n * The family name comes from the OS (Local Font Access API); quotes and\n * backslashes are stripped so it can be safely re-quoted as one family. */\nexport function fontStackFor(family: string, generic: FontGenericFamily): string {\n const cleaned = normalizeFontFamily(family).replace(/[\"\\\\]/g, '')\n if (!cleaned) return generic\n return `\"${cleaned}\", ${generic}`\n}\n\n/** A system font offered in the picker: `family` is the exact name CSS\n * matching needs; `fullName` is an informative localized alias (e.g. converted\n * CJK fonts whose family is the Latin alias), '' when it only restates the\n * family (\"Microsoft YaHei Regular\" adds nothing). */\nexport interface SystemFontFamily {\n readonly family: string\n readonly fullName: string\n}\n\n/** Distinct, normalized, family-sorted entries out of a queryLocalFonts()\n * result (entries carry `family` and `fullName`; duplicates per style are\n * expected). */\nexport function uniqueSystemFonts(fonts: readonly unknown[]): SystemFontFamily[] {\n const byFamily = new Map<string, string>()\n for (const item of fonts) {\n if (!item || typeof item !== 'object' || Array.isArray(item)) continue\n const record = item as Record<string, unknown>\n const family = normalizeFontFamily(record.family).replace(/[\"\\\\]/g, '')\n if (!family || byFamily.has(family)) continue\n const fullName = normalizeFontFamily(record.fullName).replace(/[\"\\\\]/g, '')\n byFamily.set(family, fullName && fullName !== family && !fullName.startsWith(`${family} `) ? fullName : '')\n }\n return [...byFamily.entries()]\n .map(([family, fullName]) => ({ family, fullName }))\n .sort((a, b) => a.family.localeCompare(b.family))\n}\n\n/** Picker label: the UI locale's recognizable name leads, the alias stays in\n * parentheses because the canonical family is still what a custom input needs. */\nexport function systemFontLabel(item: SystemFontFamily, locale: 'zh' | 'en'): string {\n if (!item.fullName) return item.family\n return locale === 'zh' ? `${item.fullName}(${item.family})` : `${item.family}(${item.fullName})`\n}\n\n/** Minimal write face of CSSStyleDeclaration — document.documentElement.style\n * satisfies it, and tests supply a recording double. */\nexport interface FontStyleTarget {\n setProperty(name: string, value: string): void\n removeProperty(name: string): void\n}\n\nexport function applyFontSettings(style: FontStyleTarget, settings: FontSettings): void {\n if (settings.uiFont) style.setProperty(UI_FONT_VARIABLE, settings.uiFont)\n else style.removeProperty(UI_FONT_VARIABLE)\n if (settings.codeFont) style.setProperty(CODE_FONT_VARIABLE, settings.codeFont)\n else style.removeProperty(CODE_FONT_VARIABLE)\n}\n\nexport function clearFontSettings(style: FontStyleTarget): void {\n style.removeProperty(UI_FONT_VARIABLE)\n style.removeProperty(CODE_FONT_VARIABLE)\n}\n\n/** Read face required to restore only overrides still owned by this instance. */\nexport interface OwnedFontStyleTarget extends FontStyleTarget {\n getPropertyValue(name: string): string\n getPropertyPriority(name: string): string\n setProperty(name: string, value: string, priority?: string): void\n}\n\n/** Root inline overrides preserve the existing local persistence/unload\n * boundary. Save the underlying value (including !important) on first write\n * or when the host replaces a value, and never retract somebody else's write. */\nexport function createFontSettingsOverride(style: OwnedFontStyleTarget) {\n const owned = new Map<string, { previous: string; priority: string; value: string }>()\n function release(name: string) {\n const entry = owned.get(name)\n if (!entry) return\n if (style.getPropertyValue(name) === entry.value && style.getPropertyPriority(name) === '') {\n if (entry.previous) style.setProperty(name, entry.previous, entry.priority)\n else style.removeProperty(name)\n }\n owned.delete(name)\n }\n return {\n apply(settings: FontSettings) {\n for (const [name, value] of [\n [UI_FONT_VARIABLE, settings.uiFont],\n [CODE_FONT_VARIABLE, settings.codeFont],\n ] as const) {\n if (!value) { release(name); continue }\n const current = style.getPropertyValue(name)\n const priority = style.getPropertyPriority(name)\n const entry = owned.get(name)\n if (!entry || current !== entry.value || priority !== '') {\n owned.set(name, { previous: current, priority, value: '' })\n }\n style.setProperty(name, value)\n owned.get(name)!.value = style.getPropertyValue(name)\n }\n },\n dispose() { for (const name of [...owned.keys()]) release(name) },\n }\n}\n\nexport interface FontSettingsStorage {\n getItem(key: string): string | null\n setItem(key: string, value: string): void\n removeItem(key: string): void\n}\n\nexport interface FontSettingsStore {\n load(): FontSettings\n save(next: FontSettings): void\n}\n\n/** Browser-local persistence. A fully-default setting removes the key so a\n * reset leaves no residue; storage failures (private mode, quota) degrade to\n * in-memory behaviour rather than breaking the panel. */\nexport function createFontSettingsStore(storage: FontSettingsStorage | undefined): FontSettingsStore {\n let current = defaultFontSettings()\n // A failed local write must win over stale persisted values on page remount.\n // Successful writes restore the existing ability to read external updates.\n let pendingPersistence = false\n return {\n load() {\n if (storage && !pendingPersistence) {\n try {\n current = parseFontSettings(storage.getItem(STORAGE_KEY))\n } catch {\n /* keep the last readable or locally saved snapshot */\n }\n }\n return { ...current }\n },\n save(next) {\n current = parseFontSettings(next)\n if (!storage) return\n pendingPersistence = true\n try {\n if (!current.uiFont && !current.codeFont) storage.removeItem(STORAGE_KEY)\n else storage.setItem(STORAGE_KEY, serializeFontSettings(current))\n pendingPersistence = false\n } catch {\n /* stay in-memory */\n }\n },\n }\n}\n\n/** Structural slices of the CSSOM the token scan needs — StyleSheetList,\n * CSSStyleSheet and CSSStyleRule satisfy them, and tests supply doubles. */\ninterface FontTokenRule {\n selectorText?: string\n style?: {\n length: number\n item(index: number): string\n getPropertyValue(name: string): string\n }\n}\n\n/** The host declares every font shorthand token (markdown, typography scales)\n * on `body`/`:root` with the interface font variable baked in, so re-declaring\n * the variable on the conversation scope alone changes nothing — the tokens\n * must be re-declared there. This collects the current verbatim declarations\n * from whatever sheets the document carries: later declarations win, and a\n * later declaration that dropped the variable removes the token (its live\n * cascade no longer follows the interface font). Cross-origin sheets are\n * skipped. */\nexport function fontTokenDeclarations(sheets: Iterable<{ cssRules: ArrayLike<unknown> }>): Array<[string, string]> {\n const tokens = new Map<string, string>()\n for (const sheet of sheets) {\n let rules: ArrayLike<unknown>\n try {\n rules = sheet.cssRules\n } catch {\n continue\n }\n for (let index = 0; index < rules.length; index += 1) {\n const rule = rules[index] as FontTokenRule | undefined\n if (!rule?.style || (rule.selectorText !== 'body' && rule.selectorText !== ':root')) continue\n for (let i = 0; i < rule.style.length; i += 1) {\n const name = rule.style.item(i)\n if (!name.startsWith('--') || name === UI_FONT_VARIABLE) continue\n const value = rule.style.getPropertyValue(name)\n if (value.includes(cssVar(UI_FONT_VARIABLE))) tokens.set(name, value)\n else tokens.delete(name)\n }\n }\n }\n return [...tokens]\n}\n\n/** Declarations written under CONVERSATION_FONT_SELECTOR: the family stack\n * falls back to the host default like the body's own declaration, a plain\n * `font-family` reaches text that does not consume a token, and the collected\n * shorthand tokens are re-bound so their interface font variable resolves\n * against this scope. */\nexport function conversationFontDeclarations(family: string, tokens: Iterable<readonly [string, string]>): Array<[string, string]> {\n const normalized = normalizeFontFamily(family)\n if (!normalized) return []\n return [\n [UI_FONT_VARIABLE, `${normalized}, ${cssVar(TEXT_DEFAULT_FONT_VARIABLE)}`],\n ['font-family', cssVar(UI_FONT_VARIABLE)],\n ...[...tokens].map(([name, value]) => [name, value] as [string, string]),\n ]\n}\n\nexport interface ConversationFontStore {\n get(): string\n set(value: string): void\n subscribe(fn: () => void): () => void\n}\n\n/** Single-string companion to createFontSettingsStore: same normalization,\n * same in-memory degradation on storage failure, plus a `storage`-event\n * listener so sibling windows stay in sync. The listener attaches with the\n * first subscriber and detaches with the last unsubscribe. */\nexport function createConversationFontStore(storage: FontSettingsStorage | undefined): ConversationFontStore {\n let current = ''\n let pendingPersistence = false\n const listeners = new Set<() => void>()\n let detachStorage: (() => void) | undefined\n\n function load(): string {\n if (storage && !pendingPersistence) {\n try {\n current = normalizeFontFamily(storage.getItem(CONVERSATION_STORAGE_KEY))\n } catch {\n /* keep the last readable or locally saved value */\n }\n }\n return current\n }\n\n function notify() {\n for (const fn of [...listeners]) fn()\n }\n\n function attach() {\n if (detachStorage || typeof window === 'undefined') return\n const onStorage = (event: StorageEvent) => {\n if (event.key !== CONVERSATION_STORAGE_KEY && event.key !== null) return\n load()\n notify()\n }\n window.addEventListener('storage', onStorage)\n detachStorage = () => window.removeEventListener('storage', onStorage)\n }\n\n return {\n get: load,\n set(value) {\n current = normalizeFontFamily(value)\n if (storage) {\n pendingPersistence = true\n try {\n if (!current) storage.removeItem(CONVERSATION_STORAGE_KEY)\n else storage.setItem(CONVERSATION_STORAGE_KEY, current)\n pendingPersistence = false\n } catch {\n /* stay in-memory */\n }\n }\n notify()\n },\n subscribe(fn) {\n if (listeners.size === 0) attach()\n listeners.add(fn)\n return () => {\n listeners.delete(fn)\n if (listeners.size === 0) {\n detachStorage?.()\n detachStorage = undefined\n }\n }\n },\n }\n}\n"],"mappings":";;;;AAIA,MAAa,cAAc;;;AAI3B,MAAa,cAAc;AAS3B,MAAa,kBAAkB;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MAAM,KAAK,CAAqB;CACzE;AACF;;;;;AAYA,SAAgB,4BAA4B,SAAiE;CAC3G,IAAI,UAAU;CACd,IAAI,qBAAqB;CACzB,MAAM,4BAAY,IAAI,IAAgB;CACtC,IAAI;CAEJ,SAAS,OAAe;EACtB,IAAI,WAAW,CAAC,oBACd,IAAI;GACF,UAAU,oBAAoB,QAAQ,QAAQ,wBAAwB,CAAC;EACzE,QAAQ,CAER;EAEF,OAAO;CACT;CAEA,SAAS,SAAS;EAChB,KAAK,MAAM,MAAM,CAAC,GAAG,SAAS,GAAG,GAAG;CACtC;CAEA,SAAS,SAAS;EAChB,IAAI,iBAAiB,OAAO,WAAW,aAAa;EACpD,MAAM,aAAa,UAAwB;GACzC,IAAI,MAAM,QAAA,sCAAoC,MAAM,QAAQ,MAAM;GAClE,KAAK;GACL,OAAO;EACT;EACA,OAAO,iBAAiB,WAAW,SAAS;EAC5C,sBAAsB,OAAO,oBAAoB,WAAW,SAAS;CACvE;CAEA,OAAO;EACL,KAAK;EACL,IAAI,OAAO;GACT,UAAU,oBAAoB,KAAK;GACnC,IAAI,SAAS;IACX,qBAAqB;IACrB,IAAI;KACF,IAAI,CAAC,SAAS,QAAQ,WAAW,wBAAwB;UACpD,QAAQ,QAAQ,0BAA0B,OAAO;KACtD,qBAAqB;IACvB,QAAQ,CAER;GACF;GACA,OAAO;EACT;EACA,UAAU,IAAI;GACZ,IAAI,UAAU,SAAS,GAAG,OAAO;GACjC,UAAU,IAAI,EAAE;GAChB,aAAa;IACX,UAAU,OAAO,EAAE;IACnB,IAAI,UAAU,SAAS,GAAG;KACxB,gBAAgB;KAChB,gBAAgB,KAAA;IAClB;GACF;EACF;CACF;AACF"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { Context } from "@deepseek-ai/cordis";
|
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
declare const name = "@klarkxy/dsh-font";
|
|
4
4
|
/**
|
|
5
|
-
* The host half exists so the bundle has a loader row
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* font
|
|
9
|
-
*
|
|
5
|
+
* The host half exists so the bundle has a loader row — the feature itself
|
|
6
|
+
* lives entirely in the client half, which contributes its own Font section
|
|
7
|
+
* page. Fonts are a property of the rendering environment, the conversation
|
|
8
|
+
* font persists browser-local, and every host-backed write goes through the
|
|
9
|
+
* official `ctx.theme` entries. Nothing here needs a Host service.
|
|
10
10
|
*/
|
|
11
11
|
declare function apply(_ctx: Context): void;
|
|
12
12
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import { PLUGIN_NAME } from "./contracts.js";
|
|
|
2
2
|
//#region src/index.ts
|
|
3
3
|
const name = PLUGIN_NAME;
|
|
4
4
|
/**
|
|
5
|
-
* The host half exists so the bundle has a loader row
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* font
|
|
9
|
-
*
|
|
5
|
+
* The host half exists so the bundle has a loader row — the feature itself
|
|
6
|
+
* lives entirely in the client half, which contributes its own Font section
|
|
7
|
+
* page. Fonts are a property of the rendering environment, the conversation
|
|
8
|
+
* font persists browser-local, and every host-backed write goes through the
|
|
9
|
+
* official `ctx.theme` entries. Nothing here needs a Host service.
|
|
10
10
|
*/
|
|
11
11
|
function apply(_ctx) {}
|
|
12
12
|
//#endregion
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport { PLUGIN_NAME } from './contracts.ts'\n\nexport const name = PLUGIN_NAME\n\n/**\n * The host half exists so the bundle has a loader row
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport { PLUGIN_NAME } from './contracts.ts'\n\nexport const name = PLUGIN_NAME\n\n/**\n * The host half exists so the bundle has a loader row — the feature itself\n * lives entirely in the client half, which contributes its own Font section\n * page. Fonts are a property of the rendering environment, the conversation\n * font persists browser-local, and every host-backed write goes through the\n * official `ctx.theme` entries. Nothing here needs a Host service.\n */\nexport function apply(_ctx: Context): void {\n /* no host services, no RPC, no model calls */\n}\n"],"mappings":";;AAGA,MAAa,OAAO;;;;;;;;AASpB,SAAgB,MAAM,MAAqB,CAE3C"}
|
package/locale/en.json
CHANGED
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarkxy/dsh-font",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Font: customize the interface
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"description": "Font: customize the interface, conversation, code and terminal fonts and font sizes of the DeepSeek Harness Web GUI.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"type": "module",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"cordis.patch.yml",
|
|
36
36
|
"README.md",
|
|
37
37
|
"docs/README.zh-CN.md",
|
|
38
|
+
"docs/preview.png",
|
|
38
39
|
"LICENSE"
|
|
39
40
|
],
|
|
40
41
|
"dsh": {
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
"@deepseek-ai/cordis": ">=4.0.4"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@klarkxy/dsh-plugin-kit": "0.
|
|
64
|
+
"@klarkxy/dsh-plugin-kit": "0.6.0",
|
|
64
65
|
"@deepseek-ai/cordis": "4.0.5",
|
|
65
66
|
"react": "^18.2.0",
|
|
66
67
|
"@types/react": "18.3.31",
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
},
|
|
96
97
|
"homepage": "https://klarkxy.github.io/dsh-plugins/plugins/font/",
|
|
97
98
|
"dshRelease": {
|
|
98
|
-
"contentHash": "
|
|
99
|
+
"contentHash": "abb22e596f00638b581ca7782923ee078bb417452b9daee00057411ae3d61bcc"
|
|
99
100
|
},
|
|
100
101
|
"peerDependenciesMeta": {
|
|
101
102
|
"@deepseek-ai/cordis": {
|