dsh-cool-theme 0.3.1 → 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 (66) hide show
  1. package/README.md +9 -10
  2. package/README.zh.md +9 -10
  3. package/lib/client.js +2694 -215
  4. package/lib/index.js +304 -6
  5. package/lib/types/client/components.d.ts +43 -3
  6. package/lib/types/client/components.d.ts.map +1 -1
  7. package/lib/types/client/custom.d.ts +124 -0
  8. package/lib/types/client/custom.d.ts.map +1 -0
  9. package/lib/types/client/locales.d.ts +102 -0
  10. package/lib/types/client/locales.d.ts.map +1 -1
  11. package/lib/types/client/presets/aura.d.ts +26 -0
  12. package/lib/types/client/presets/aura.d.ts.map +1 -0
  13. package/lib/types/client/presets/catppuccin-frappe.d.ts +26 -0
  14. package/lib/types/client/presets/catppuccin-frappe.d.ts.map +1 -0
  15. package/lib/types/client/presets/catppuccin-macchiato.d.ts +26 -0
  16. package/lib/types/client/presets/catppuccin-macchiato.d.ts.map +1 -0
  17. package/lib/types/client/presets/cobalt2.d.ts +26 -0
  18. package/lib/types/client/presets/cobalt2.d.ts.map +1 -0
  19. package/lib/types/client/presets/cursor.d.ts +26 -0
  20. package/lib/types/client/presets/cursor.d.ts.map +1 -0
  21. package/lib/types/client/presets/everforest.d.ts +26 -0
  22. package/lib/types/client/presets/everforest.d.ts.map +1 -0
  23. package/lib/types/client/presets/flexoki.d.ts +26 -0
  24. package/lib/types/client/presets/flexoki.d.ts.map +1 -0
  25. package/lib/types/client/presets/kanagawa.d.ts +26 -0
  26. package/lib/types/client/presets/kanagawa.d.ts.map +1 -0
  27. package/lib/types/client/presets/lucent-orng.d.ts +26 -0
  28. package/lib/types/client/presets/lucent-orng.d.ts.map +1 -0
  29. package/lib/types/client/presets/material.d.ts +26 -0
  30. package/lib/types/client/presets/material.d.ts.map +1 -0
  31. package/lib/types/client/presets/matrix.d.ts +26 -0
  32. package/lib/types/client/presets/matrix.d.ts.map +1 -0
  33. package/lib/types/client/presets/mercury.d.ts +26 -0
  34. package/lib/types/client/presets/mercury.d.ts.map +1 -0
  35. package/lib/types/client/presets/nightowl.d.ts +26 -0
  36. package/lib/types/client/presets/nightowl.d.ts.map +1 -0
  37. package/lib/types/client/presets/opencode.d.ts +26 -0
  38. package/lib/types/client/presets/opencode.d.ts.map +1 -0
  39. package/lib/types/client/presets/orng.d.ts +26 -0
  40. package/lib/types/client/presets/orng.d.ts.map +1 -0
  41. package/lib/types/client/presets/osaka-jade.d.ts +26 -0
  42. package/lib/types/client/presets/osaka-jade.d.ts.map +1 -0
  43. package/lib/types/client/presets/palenight.d.ts +26 -0
  44. package/lib/types/client/presets/palenight.d.ts.map +1 -0
  45. package/lib/types/client/presets/synthwave84.d.ts +26 -0
  46. package/lib/types/client/presets/synthwave84.d.ts.map +1 -0
  47. package/lib/types/client/presets/system.d.ts +26 -0
  48. package/lib/types/client/presets/system.d.ts.map +1 -0
  49. package/lib/types/client/presets/vercel.d.ts +26 -0
  50. package/lib/types/client/presets/vercel.d.ts.map +1 -0
  51. package/lib/types/client/presets/vesper.d.ts +26 -0
  52. package/lib/types/client/presets/vesper.d.ts.map +1 -0
  53. package/lib/types/client/presets.d.ts +537 -0
  54. package/lib/types/client/presets.d.ts.map +1 -1
  55. package/lib/types/client/theme-files.d.ts +37 -0
  56. package/lib/types/client/theme-files.d.ts.map +1 -0
  57. package/lib/types/client/theme.d.ts.map +1 -1
  58. package/lib/types/client/tokens.d.ts +16 -3
  59. package/lib/types/client/tokens.d.ts.map +1 -1
  60. package/lib/types/contract.d.ts +43 -0
  61. package/lib/types/contract.d.ts.map +1 -1
  62. package/lib/types/host/index.d.ts +6 -3
  63. package/lib/types/host/index.d.ts.map +1 -1
  64. package/lib/types/host/theme-files.d.ts +38 -0
  65. package/lib/types/host/theme-files.d.ts.map +1 -0
  66. package/package.json +1 -1
@@ -1,8 +1,21 @@
1
- import { type PresetId } from './presets.js';
1
+ import { type PresetId, type PresetDef } from './presets.js';
2
2
  export declare function buildBaseCss(): string;
3
- export declare function buildOverrides(id: PresetId): Record<string, {
3
+ /**
4
+ * Accepts either a preset id or an already-built `PresetDef` (what a custom
5
+ * theme produces). Both go through the identical merge, so a custom theme is
6
+ * not a special case anywhere downstream.
7
+ */
8
+ export declare function resolvePreset(src: PresetId | PresetDef): {
9
+ light: {
10
+ [x: string]: string;
11
+ };
12
+ dark: {
13
+ [x: string]: string;
14
+ };
15
+ } | null;
16
+ export declare function buildOverrides(src: PresetId | PresetDef): Record<string, {
4
17
  light: string;
5
18
  dark: string;
6
19
  }>;
7
- export declare function buildFullCssFallback(id: PresetId): string;
20
+ export declare function buildFullCssFallback(src: PresetId | PresetDef): string;
8
21
  //# sourceMappingURL=tokens.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/client/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIrD,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAcD,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAI5F;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAQzD"}
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/client/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAItF,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS;;;;;;;SAatD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAIzG;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAItE"}
@@ -3,4 +3,47 @@
3
3
  */
4
4
  export declare const THEME_STORAGE_KEY = "cool-theme-preset";
5
5
  export declare const THEME_STORAGE_KEY_LEGACY = "cooltea-theme-preset";
6
+ export declare const CUSTOM_PRESET_ID = "custom";
7
+ export declare const CUSTOM_THEME_STORAGE_KEY = "cool-theme-custom";
8
+ export declare const CUSTOM_LIST_STORAGE_KEY = "cool-theme-custom-list";
9
+ export declare const CUSTOM_ACTIVE_STORAGE_KEY = "cool-theme-custom-active";
10
+ export declare const CUSTOM_MIGRATED_STORAGE_KEY = "cool-theme-custom-migrated";
11
+ /**
12
+ * Documents are one directory each — `<root>/<id>/theme.json` — so a theme can
13
+ * later carry media beside its seeds without changing this contract.
14
+ */
15
+ export declare const THEME_FILE_VERSION = 1;
16
+ /** Media kind carried with a theme; the seed payload itself is `theme`. */
17
+ export type ThemeAssetKind = 'image' | 'video';
18
+ /** One media file stored under the theme's `assets/` directory. */
19
+ export type ThemeAsset = {
20
+ /** File name inside `assets/`; unique within the theme. */
21
+ name: string;
22
+ kind: ThemeAssetKind;
23
+ /** Content type the Host serves it back with. */
24
+ mime: string;
25
+ bytes: number;
26
+ };
27
+ /**
28
+ * One theme as it is stored and exchanged. `theme` stays opaque here: the
29
+ * Client owns the seed shape and repairs it against a preset on read, while the
30
+ * Host only ever moves the document in and out of a file.
31
+ */
32
+ export type ThemeDocument = {
33
+ v: number;
34
+ id: string;
35
+ name: string;
36
+ /** Id of the preset the seeds derive from. */
37
+ base: string;
38
+ theme: unknown;
39
+ assets: ThemeAsset[];
40
+ createdAt: string;
41
+ updatedAt: string;
42
+ };
43
+ /**
44
+ * The Host's theme-file API, all below one prefix route. Kept here so the two
45
+ * halves cannot drift on a path.
46
+ */
47
+ export declare const THEME_API_PREFIX = "/cool-theme/api";
48
+ export declare const THEME_API_PATH_THEMES = "/cool-theme/api/themes";
6
49
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/contract.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,iBAAiB,sBAAsB,CAAA;AACpD,eAAO,MAAM,wBAAwB,yBAAyB,CAAA"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/contract.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,iBAAiB,sBAAsB,CAAA;AACpD,eAAO,MAAM,wBAAwB,yBAAyB,CAAA;AAG9D,eAAO,MAAM,gBAAgB,WAAW,CAAA;AAKxC,eAAO,MAAM,wBAAwB,sBAAsB,CAAA;AAG3D,eAAO,MAAM,uBAAuB,2BAA2B,CAAA;AAI/D,eAAO,MAAM,yBAAyB,6BAA6B,CAAA;AAInE,eAAO,MAAM,2BAA2B,+BAA+B,CAAA;AAMvE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,CAAA;AAE9C,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG;IACvB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,cAAc,CAAA;IACpB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,EAAE,MAAM,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,oBAAoB,CAAA;AACjD,eAAO,MAAM,qBAAqB,2BAA+B,CAAA"}
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * Host entry for dsh-cool-theme.
3
- * No host routes needed — theme is purely client-side (localStorage + overrideTokens).
4
- * Keep a minimal apply so the cordis patch has a mount point.
3
+ *
4
+ * Owns the theme files: the browser half cannot touch the filesystem, so every
5
+ * roster change travels over one same-origin prefix route below
6
+ * {@link THEME_API_PREFIX}. The route is the whole host surface — no service is
7
+ * provided, and nothing here interprets the theme payload beyond moving it.
5
8
  */
6
9
  export declare const name = "dsh-cool-theme";
7
10
  export declare const inject: string[];
8
- export declare function apply(_ctx: any): void;
11
+ export declare function apply(ctx: any): void;
9
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,IAAI,mBAAmB,CAAA;AAEpC,eAAO,MAAM,MAAM,EAAE,MAAM,EAAO,CAAA;AAElC,wBAAgB,KAAK,CAAC,IAAI,EAAE,GAAG,QAAI"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,eAAO,MAAM,IAAI,mBAAmB,CAAA;AAEpC,eAAO,MAAM,MAAM,UAAgB,CAAA;AAwGnC,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAwCpC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Theme files owned by the Host.
3
+ *
4
+ * One directory per theme below `$DSH_HOME/cool-theme/themes/<id>/`, holding the
5
+ * document at `theme.json` and — once themes carry media — the originals under
6
+ * `assets/`. Keeping a theme a self-contained directory is what makes the later
7
+ * export a copy of that directory rather than a reassembly of scattered rows.
8
+ */
9
+ import type { ThemeAsset, ThemeDocument } from '../contract.js';
10
+ export declare function isThemeId(value: unknown): value is string;
11
+ /**
12
+ * The harness home, resolved the way the rest of DSH resolves it: an explicit
13
+ * `DSH_HOME`, else `~/.dsh`.
14
+ */
15
+ export declare function harnessHome(): string;
16
+ /** Root of every stored theme. */
17
+ export declare function themesRoot(): string;
18
+ /** One theme's own directory. Callers must have validated `id`. */
19
+ export declare function themeDir(id: string): string;
20
+ /** Every stored theme, oldest by creation time first; unreadable directories are skipped. */
21
+ export declare function listThemes(): Promise<ThemeDocument[]>;
22
+ /**
23
+ * Insert or replace one document. `createdAt` is the caller's when the theme is
24
+ * new and the stored value when it already exists, so a later rename or edit
25
+ * cannot rewrite when the theme was made.
26
+ */
27
+ export declare function putTheme(input: {
28
+ id: string;
29
+ name: string;
30
+ base: string;
31
+ theme: unknown;
32
+ assets: ThemeAsset[];
33
+ }): Promise<ThemeDocument>;
34
+ /** Remove one theme directory. A missing directory is already the goal. */
35
+ export declare function deleteTheme(id: string): Promise<void>;
36
+ /** Absolute path of a theme's media directory; used once themes carry media. */
37
+ export declare function assetsDir(id: string): string;
38
+ //# sourceMappingURL=theme-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-files.d.ts","sourceRoot":"","sources":["../../../src/host/theme-files.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAc/D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAGpC;AAED,kCAAkC;AAClC,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,mEAAmE;AACnE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3C;AAgED,6FAA6F;AAC7F,wBAAsB,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAkB3D;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,UAAU,EAAE,CAAA;CACrB,GAAG,OAAO,CAAC,aAAa,CAAC,CAezB;AAED,2EAA2E;AAC3E,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cool-theme",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "A plugin for changing themes for DSH, with a number of popular default themes built in.",
5
5
  "type": "module",
6
6
  "license": "MIT",