dsh-cool-theme 0.4.0 → 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.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Browser half of the theme-file transport.
3
+ *
4
+ * The Host owns the files; this module is the only place that knows the wire
5
+ * shape, so the rest of the client keeps working with plain `SavedTheme`
6
+ * records. Every call is same-origin against the Host's own prefix route.
7
+ */
8
+ import type { ThemeDocument } from '../contract.js';
9
+ import { type CustomTheme, type SavedTheme } from './custom.js';
10
+ /** Repair one stored document against the preset its seeds derive from. */
11
+ export declare function documentToSaved(doc: ThemeDocument, fallbackFor: (base: string) => CustomTheme): SavedTheme;
12
+ /** The document payload for one entry; timestamps stay the Host's business. */
13
+ export declare function savedToDocument(entry: SavedTheme): Record<string, unknown>;
14
+ /**
15
+ * The Host answered as something other than this API — its route half is not
16
+ * mounted (the usual cause is a DSH process started before this plugin's host
17
+ * half existed). Distinguished from a write failure because only this one tells
18
+ * the user to restart, and the browser copy is still intact meanwhile.
19
+ */
20
+ export declare class ThemeApiUnavailableError extends Error {
21
+ }
22
+ /** Every stored theme, in the Host's creation-time order (oldest first). */
23
+ export declare function fetchThemes(fallbackFor: (base: string) => CustomTheme): Promise<SavedTheme[]>;
24
+ /** Insert or replace the given entries; resolves with what the Host stored. */
25
+ export declare function pushThemes(entries: SavedTheme[], fallbackFor: (base: string) => CustomTheme): Promise<SavedTheme[]>;
26
+ /** Remove one theme's directory. */
27
+ export declare function removeTheme(id: string): Promise<void>;
28
+ /**
29
+ * The themes a browser saved before files became the store, minus those the
30
+ * Host already has.
31
+ *
32
+ * Ids are the join key: a theme another browser already migrated must not be
33
+ * written twice, while one this roster lacks would otherwise disappear from the
34
+ * UI. Callers adopt the result, then stop reading the browser copy.
35
+ */
36
+ export declare function legacyThemesToAdopt(legacy: SavedTheme[], hostThemes: SavedTheme[]): SavedTheme[];
37
+ //# sourceMappingURL=theme-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-files.d.ts","sourceRoot":"","sources":["../../../src/client/theme-files.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAEhF,2EAA2E;AAC3E,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GACzC,UAAU,CAQZ;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS1E;AAMD;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;CAAG;AA4DtD,4EAA4E;AAC5E,wBAAsB,WAAW,CAC/B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GACzC,OAAO,CAAC,UAAU,EAAE,CAAC,CAEvB;AAED,+EAA+E;AAC/E,wBAAsB,UAAU,CAC9B,OAAO,EAAE,UAAU,EAAE,EACrB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GACzC,OAAO,CAAC,UAAU,EAAE,CAAC,CAMvB;AAED,oCAAoC;AACpC,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAAE,EACpB,UAAU,EAAE,UAAU,EAAE,GACvB,UAAU,EAAE,CAGd"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/client/theme.tsx"],"names":[],"mappings":"AAyCA,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,QAsQrC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/client/theme.tsx"],"names":[],"mappings":"AA2KA,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,QAqcrC"}
@@ -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.4.0",
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",