@agimon-ai/po-theme 0.0.0-stage → 0.0.2-alpha.1

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 (37) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +7 -2
  3. package/dist/index.cjs +44 -0
  4. package/dist/index.d.mts +9 -0
  5. package/dist/index.mjs +9 -0
  6. package/dist/po-runtime-identity.json +1 -0
  7. package/dist/src/theme/apply.cjs +33 -0
  8. package/dist/src/theme/apply.d.mts +24 -0
  9. package/dist/src/theme/apply.mjs +30 -0
  10. package/dist/src/theme/builtinThemes.cjs +23 -0
  11. package/dist/src/theme/builtinThemes.d.mts +10 -0
  12. package/dist/src/theme/builtinThemes.mjs +20 -0
  13. package/dist/src/theme/derive.cjs +31 -0
  14. package/dist/src/theme/derive.d.mts +13 -0
  15. package/dist/src/theme/derive.mjs +28 -0
  16. package/dist/src/theme/nativeTheme.cjs +195 -0
  17. package/dist/src/theme/nativeTheme.d.mts +130 -0
  18. package/dist/src/theme/nativeTheme.mjs +183 -0
  19. package/dist/src/theme/parse.cjs +41 -0
  20. package/dist/src/theme/parse.d.mts +9 -0
  21. package/dist/src/theme/parse.mjs +41 -0
  22. package/dist/src/theme/piTheme.cjs +75 -0
  23. package/dist/src/theme/piTheme.d.mts +18 -0
  24. package/dist/src/theme/piTheme.mjs +75 -0
  25. package/dist/src/theme/preference.cjs +23 -0
  26. package/dist/src/theme/preference.d.mts +14 -0
  27. package/dist/src/theme/preference.mjs +21 -0
  28. package/dist/src/types/theme.cjs +74 -0
  29. package/dist/src/types/theme.d.mts +37 -0
  30. package/dist/src/types/theme.mjs +70 -0
  31. package/dist/themes/po-nord-dark.cjs +35 -0
  32. package/dist/themes/po-nord-dark.mjs +30 -0
  33. package/dist/themes/po-one-light.cjs +36 -0
  34. package/dist/themes/po-one-light.mjs +31 -0
  35. package/package.json +51 -3
  36. package/themes/po-nord-dark.json +27 -0
  37. package/themes/po-one-light.json +28 -0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Agimon Pty Ltd
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
- # Temporary Holding Version
1
+ # po-theme
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Po palette and theme tokens with no framework or runtime dependencies, shared by web, native and server-rendered pages.
4
+
5
+ - `@agimon-ai/po-theme`: theme types, parsing, derivation, CSS variables (`themeCssVariables`), the native palette (`nativeTheme`) and the Pi theme bridge.
6
+ - `@agimon-ai/po-theme/themes/*.json`: the shipped Po Bloom light (`po-one-light`) and Po Nord dark (`po-nord-dark`) themes.
7
+
8
+ `@agimon-ai/po-web-components` re-exports these through `./theme`, `./nativeTheme` and `./themes/*.json`. Change a colour here, in `po-web-components/styles/theme.css` and in `apps/desktop/resources/` together; the contrast and copy tests in `po-web-components/tests/theme` guard the pairing.
package/dist/index.cjs ADDED
@@ -0,0 +1,44 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_theme = require("./src/types/theme.cjs");
3
+ const require_derive = require("./src/theme/derive.cjs");
4
+ const require_apply = require("./src/theme/apply.cjs");
5
+ const require_parse = require("./src/theme/parse.cjs");
6
+ const require_builtinThemes = require("./src/theme/builtinThemes.cjs");
7
+ const require_nativeTheme = require("./src/theme/nativeTheme.cjs");
8
+ const require_piTheme = require("./src/theme/piTheme.cjs");
9
+ const require_preference = require("./src/theme/preference.cjs");
10
+ exports.ACCENT_TOKENS = require_theme.ACCENT_TOKENS;
11
+ exports.BUILTIN_THEMES = require_builtinThemes.BUILTIN_THEMES;
12
+ exports.DEFAULT_FONT_MONO = require_derive.DEFAULT_FONT_MONO;
13
+ exports.DEFAULT_THEME = require_builtinThemes.DEFAULT_THEME;
14
+ exports.DEFAULT_THEME_NAME = require_builtinThemes.DEFAULT_THEME_NAME;
15
+ exports.DERIVED_TOKENS = require_theme.DERIVED_TOKENS;
16
+ exports.NATIVE_BORDER_RADIUS = require_nativeTheme.NATIVE_BORDER_RADIUS;
17
+ exports.NATIVE_FONT_FAMILY = require_nativeTheme.NATIVE_FONT_FAMILY;
18
+ exports.NATIVE_FONT_WEIGHT = require_nativeTheme.NATIVE_FONT_WEIGHT;
19
+ exports.NATIVE_LEADING_RELAXED = require_nativeTheme.NATIVE_LEADING_RELAXED;
20
+ exports.NATIVE_LETTER_SPACING_EM = require_nativeTheme.NATIVE_LETTER_SPACING_EM;
21
+ exports.NATIVE_MOTION = require_nativeTheme.NATIVE_MOTION;
22
+ exports.NATIVE_RADII = require_nativeTheme.NATIVE_RADII;
23
+ exports.NATIVE_SPACING_BASE = require_nativeTheme.NATIVE_SPACING_BASE;
24
+ exports.NATIVE_THEMES = require_nativeTheme.NATIVE_THEMES;
25
+ exports.NATIVE_TYPE_RAMP = require_nativeTheme.NATIVE_TYPE_RAMP;
26
+ exports.PALETTE_TOKENS = require_theme.PALETTE_TOKENS;
27
+ exports.THEME_ATTRIBUTE = require_apply.THEME_ATTRIBUTE;
28
+ exports.THEME_STORAGE_KEY = require_preference.THEME_STORAGE_KEY;
29
+ exports.THEME_TOKENS = require_theme.THEME_TOKENS;
30
+ exports.applyTheme = require_apply.applyTheme;
31
+ exports.builtinTheme = require_builtinThemes.builtinTheme;
32
+ exports.derivedFallback = require_derive.derivedFallback;
33
+ exports.derivedTokens = require_derive.derivedTokens;
34
+ exports.mixHex = require_nativeTheme.mixHex;
35
+ exports.nativeTheme = require_nativeTheme.nativeTheme;
36
+ exports.parseThemeConfig = require_parse.parseThemeConfig;
37
+ exports.readThemePreference = require_preference.readThemePreference;
38
+ exports.themeCssText = require_apply.themeCssText;
39
+ exports.themeCssVariables = require_apply.themeCssVariables;
40
+ exports.themeFromPiTheme = require_piTheme.themeFromPiTheme;
41
+ exports.themeVariable = require_theme.themeVariable;
42
+ exports.tokenValue = require_derive.tokenValue;
43
+ exports.withAlpha = require_nativeTheme.withAlpha;
44
+ exports.writeThemePreference = require_preference.writeThemePreference;
@@ -0,0 +1,9 @@
1
+ import { ACCENT_TOKENS, AccentToken, DERIVED_TOKENS, DerivedToken, PALETTE_TOKENS, PaletteToken, THEME_TOKENS, ThemeConfig, ThemeScheme, ThemeToken, themeVariable } from "./src/types/theme.mjs";
2
+ import { THEME_ATTRIBUTE, ThemeRoot, applyTheme, themeCssText, themeCssVariables } from "./src/theme/apply.mjs";
3
+ import { BUILTIN_THEMES, DEFAULT_THEME, DEFAULT_THEME_NAME, builtinTheme } from "./src/theme/builtinThemes.mjs";
4
+ import { DEFAULT_FONT_MONO, derivedFallback, derivedTokens, tokenValue } from "./src/theme/derive.mjs";
5
+ import { NATIVE_BORDER_RADIUS, NATIVE_FONT_FAMILY, NATIVE_FONT_WEIGHT, NATIVE_LEADING_RELAXED, NATIVE_LETTER_SPACING_EM, NATIVE_MOTION, NATIVE_RADII, NATIVE_SPACING_BASE, NATIVE_THEMES, NATIVE_TYPE_RAMP, NativeColorToken, NativeFontStack, NativeNamedTheme, NativeTypeStep, PoNativeTheme, mixHex, nativeTheme, withAlpha } from "./src/theme/nativeTheme.mjs";
6
+ import { parseThemeConfig } from "./src/theme/parse.mjs";
7
+ import { PiThemeBridgeOptions, themeFromPiTheme } from "./src/theme/piTheme.mjs";
8
+ import { PreferenceStorage, THEME_STORAGE_KEY, readThemePreference, writeThemePreference } from "./src/theme/preference.mjs";
9
+ export { ACCENT_TOKENS, type AccentToken, BUILTIN_THEMES, DEFAULT_FONT_MONO, DEFAULT_THEME, DEFAULT_THEME_NAME, DERIVED_TOKENS, type DerivedToken, NATIVE_BORDER_RADIUS, NATIVE_FONT_FAMILY, NATIVE_FONT_WEIGHT, NATIVE_LEADING_RELAXED, NATIVE_LETTER_SPACING_EM, NATIVE_MOTION, NATIVE_RADII, NATIVE_SPACING_BASE, NATIVE_THEMES, NATIVE_TYPE_RAMP, type NativeColorToken, type NativeFontStack, type NativeNamedTheme, type NativeTypeStep, PALETTE_TOKENS, type PaletteToken, type PiThemeBridgeOptions, type PoNativeTheme, type PreferenceStorage, THEME_ATTRIBUTE, THEME_STORAGE_KEY, THEME_TOKENS, type ThemeConfig, type ThemeRoot, type ThemeScheme, type ThemeToken, applyTheme, builtinTheme, derivedFallback, derivedTokens, mixHex, nativeTheme, parseThemeConfig, readThemePreference, themeCssText, themeCssVariables, themeFromPiTheme, themeVariable, tokenValue, withAlpha, writeThemePreference };
package/dist/index.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import { ACCENT_TOKENS, DERIVED_TOKENS, PALETTE_TOKENS, THEME_TOKENS, themeVariable } from "./src/types/theme.mjs";
2
+ import { DEFAULT_FONT_MONO, derivedFallback, derivedTokens, tokenValue } from "./src/theme/derive.mjs";
3
+ import { THEME_ATTRIBUTE, applyTheme, themeCssText, themeCssVariables } from "./src/theme/apply.mjs";
4
+ import { parseThemeConfig } from "./src/theme/parse.mjs";
5
+ import { BUILTIN_THEMES, DEFAULT_THEME, DEFAULT_THEME_NAME, builtinTheme } from "./src/theme/builtinThemes.mjs";
6
+ import { NATIVE_BORDER_RADIUS, NATIVE_FONT_FAMILY, NATIVE_FONT_WEIGHT, NATIVE_LEADING_RELAXED, NATIVE_LETTER_SPACING_EM, NATIVE_MOTION, NATIVE_RADII, NATIVE_SPACING_BASE, NATIVE_THEMES, NATIVE_TYPE_RAMP, mixHex, nativeTheme, withAlpha } from "./src/theme/nativeTheme.mjs";
7
+ import { themeFromPiTheme } from "./src/theme/piTheme.mjs";
8
+ import { THEME_STORAGE_KEY, readThemePreference, writeThemePreference } from "./src/theme/preference.mjs";
9
+ export { ACCENT_TOKENS, BUILTIN_THEMES, DEFAULT_FONT_MONO, DEFAULT_THEME, DEFAULT_THEME_NAME, DERIVED_TOKENS, NATIVE_BORDER_RADIUS, NATIVE_FONT_FAMILY, NATIVE_FONT_WEIGHT, NATIVE_LEADING_RELAXED, NATIVE_LETTER_SPACING_EM, NATIVE_MOTION, NATIVE_RADII, NATIVE_SPACING_BASE, NATIVE_THEMES, NATIVE_TYPE_RAMP, PALETTE_TOKENS, THEME_ATTRIBUTE, THEME_STORAGE_KEY, THEME_TOKENS, applyTheme, builtinTheme, derivedFallback, derivedTokens, mixHex, nativeTheme, parseThemeConfig, readThemePreference, themeCssText, themeCssVariables, themeFromPiTheme, themeVariable, tokenValue, withAlpha, writeThemePreference };
@@ -0,0 +1 @@
1
+ {"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","package.json","src/exports/index.ts","src/theme/apply.ts","src/theme/builtinThemes.ts","src/theme/derive.ts","src/theme/nativeTheme.ts","src/theme/parse.ts","src/theme/piTheme.ts","src/theme/preference.ts","src/types/theme.ts","themes/po-nord-dark.json","themes/po-one-light.json","tsdown.config.ts"],"sourceRevision":"8130f9eb4203aa8c2927a9b2c47beb1f","manifestRevision":"a3231bc74e392c991f23743db69641a6","outputFiles":["LICENSE","README.md","dist/index.cjs","dist/index.mjs","dist/src/theme/apply.cjs","dist/src/theme/apply.mjs","dist/src/theme/builtinThemes.cjs","dist/src/theme/builtinThemes.mjs","dist/src/theme/derive.cjs","dist/src/theme/derive.mjs","dist/src/theme/nativeTheme.cjs","dist/src/theme/nativeTheme.mjs","dist/src/theme/parse.cjs","dist/src/theme/parse.mjs","dist/src/theme/piTheme.cjs","dist/src/theme/piTheme.mjs","dist/src/theme/preference.cjs","dist/src/theme/preference.mjs","dist/src/types/theme.cjs","dist/src/types/theme.mjs","dist/themes/po-nord-dark.cjs","dist/themes/po-nord-dark.mjs","dist/themes/po-one-light.cjs","dist/themes/po-one-light.mjs","themes/po-nord-dark.json","themes/po-one-light.json"],"outputRevision":"ba24bb683fd27f21f9b3d2ee1b1a227b"}
@@ -0,0 +1,33 @@
1
+ const require_theme = require("../types/theme.cjs");
2
+ const require_derive = require("./derive.cjs");
3
+ //#region src/theme/apply.ts
4
+ /** The attribute the active theme's name is stamped on, for CSS that keys off a theme. */
5
+ const THEME_ATTRIBUTE = "data-theme";
6
+ /** Every custom property a theme publishes, keyed by property name. */
7
+ function themeCssVariables(theme) {
8
+ const variables = {};
9
+ for (const token of require_theme.PALETTE_TOKENS) variables[require_theme.themeVariable(token)] = theme.tokens[token];
10
+ for (const token of require_derive.derivedTokens()) variables[require_theme.themeVariable(token)] = require_derive.tokenValue(theme, token);
11
+ return variables;
12
+ }
13
+ /** The theme as a stylesheet rule, for a server that wants to inline it. */
14
+ function themeCssText(theme, selector = ":root") {
15
+ const declarations = Object.entries(themeCssVariables(theme)).map(([name, value]) => ` ${name}: ${value};`);
16
+ return `${selector} {\n color-scheme: ${theme.scheme};\n${declarations.join("\n")}\n}\n`;
17
+ }
18
+ /**
19
+ * Applies a theme to the page: every token becomes a custom property on the
20
+ * root, the colour scheme follows, and the theme name is stamped so a style
21
+ * may key off it. Idempotent and synchronous, so calling it before the first
22
+ * render avoids a flash of the default theme.
23
+ */
24
+ function applyTheme(theme, root) {
25
+ for (const [name, value] of Object.entries(themeCssVariables(theme))) root.style.setProperty(name, value);
26
+ root.style.colorScheme = theme.scheme;
27
+ root.setAttribute(THEME_ATTRIBUTE, theme.name);
28
+ }
29
+ //#endregion
30
+ exports.THEME_ATTRIBUTE = THEME_ATTRIBUTE;
31
+ exports.applyTheme = applyTheme;
32
+ exports.themeCssText = themeCssText;
33
+ exports.themeCssVariables = themeCssVariables;
@@ -0,0 +1,24 @@
1
+ import { ThemeConfig } from "../types/theme.mjs";
2
+ //#region src/theme/apply.d.ts
3
+ /** The attribute the active theme's name is stamped on, for CSS that keys off a theme. */
4
+ export declare const THEME_ATTRIBUTE = "data-theme";
5
+ /** Every custom property a theme publishes, keyed by property name. */
6
+ export declare function themeCssVariables(theme: ThemeConfig): Record<string, string>;
7
+ /** The theme as a stylesheet rule, for a server that wants to inline it. */
8
+ export declare function themeCssText(theme: ThemeConfig, selector?: string): string;
9
+ /** The subset of an element the theme touches, so tests can pass a plain object. */
10
+ export interface ThemeRoot {
11
+ style: {
12
+ setProperty(name: string, value: string): void;
13
+ colorScheme: string;
14
+ };
15
+ setAttribute(name: string, value: string): void;
16
+ }
17
+ /**
18
+ * Applies a theme to the page: every token becomes a custom property on the
19
+ * root, the colour scheme follows, and the theme name is stamped so a style
20
+ * may key off it. Idempotent and synchronous, so calling it before the first
21
+ * render avoids a flash of the default theme.
22
+ */
23
+ export declare function applyTheme(theme: ThemeConfig, root: ThemeRoot): void;
24
+ //#endregion
@@ -0,0 +1,30 @@
1
+ import { PALETTE_TOKENS, themeVariable } from "../types/theme.mjs";
2
+ import { derivedTokens, tokenValue } from "./derive.mjs";
3
+ //#region src/theme/apply.ts
4
+ /** The attribute the active theme's name is stamped on, for CSS that keys off a theme. */
5
+ const THEME_ATTRIBUTE = "data-theme";
6
+ /** Every custom property a theme publishes, keyed by property name. */
7
+ function themeCssVariables(theme) {
8
+ const variables = {};
9
+ for (const token of PALETTE_TOKENS) variables[themeVariable(token)] = theme.tokens[token];
10
+ for (const token of derivedTokens()) variables[themeVariable(token)] = tokenValue(theme, token);
11
+ return variables;
12
+ }
13
+ /** The theme as a stylesheet rule, for a server that wants to inline it. */
14
+ function themeCssText(theme, selector = ":root") {
15
+ const declarations = Object.entries(themeCssVariables(theme)).map(([name, value]) => ` ${name}: ${value};`);
16
+ return `${selector} {\n color-scheme: ${theme.scheme};\n${declarations.join("\n")}\n}\n`;
17
+ }
18
+ /**
19
+ * Applies a theme to the page: every token becomes a custom property on the
20
+ * root, the colour scheme follows, and the theme name is stamped so a style
21
+ * may key off it. Idempotent and synchronous, so calling it before the first
22
+ * render avoids a flash of the default theme.
23
+ */
24
+ function applyTheme(theme, root) {
25
+ for (const [name, value] of Object.entries(themeCssVariables(theme))) root.style.setProperty(name, value);
26
+ root.style.colorScheme = theme.scheme;
27
+ root.setAttribute(THEME_ATTRIBUTE, theme.name);
28
+ }
29
+ //#endregion
30
+ export { THEME_ATTRIBUTE, applyTheme, themeCssText, themeCssVariables };
@@ -0,0 +1,23 @@
1
+ const require_po_nord_dark = require("../../themes/po-nord-dark.cjs");
2
+ const require_po_one_light = require("../../themes/po-one-light.cjs");
3
+ const require_parse = require("./parse.cjs");
4
+ //#region src/theme/builtinThemes.ts
5
+ function shipped(input, file) {
6
+ const theme = require_parse.parseThemeConfig(input);
7
+ if (theme === null) throw new Error(`The shipped theme ${file} is malformed.`);
8
+ return theme;
9
+ }
10
+ /** The theme the cockpit renders with until a preference says otherwise. */
11
+ const DEFAULT_THEME_NAME = "po-one-light";
12
+ /** The themes this package ships, default first. */
13
+ const BUILTIN_THEMES = [shipped(require_po_one_light.default, "po-one-light.json"), shipped(require_po_nord_dark.default, "po-nord-dark.json")];
14
+ const DEFAULT_THEME = BUILTIN_THEMES[0];
15
+ /** A shipped theme by name, or undefined for a name nothing shipped under. */
16
+ function builtinTheme(name) {
17
+ return BUILTIN_THEMES.find((theme) => theme.name === name);
18
+ }
19
+ //#endregion
20
+ exports.BUILTIN_THEMES = BUILTIN_THEMES;
21
+ exports.DEFAULT_THEME = DEFAULT_THEME;
22
+ exports.DEFAULT_THEME_NAME = DEFAULT_THEME_NAME;
23
+ exports.builtinTheme = builtinTheme;
@@ -0,0 +1,10 @@
1
+ import { ThemeConfig } from "../types/theme.mjs";
2
+ //#region src/theme/builtinThemes.d.ts
3
+ /** The theme the cockpit renders with until a preference says otherwise. */
4
+ export declare const DEFAULT_THEME_NAME = "po-one-light";
5
+ /** The themes this package ships, default first. */
6
+ export declare const BUILTIN_THEMES: readonly ThemeConfig[];
7
+ export declare const DEFAULT_THEME: ThemeConfig;
8
+ /** A shipped theme by name, or undefined for a name nothing shipped under. */
9
+ export declare function builtinTheme(name: string): ThemeConfig | undefined;
10
+ //#endregion
@@ -0,0 +1,20 @@
1
+ import po_nord_dark_default from "../../themes/po-nord-dark.mjs";
2
+ import po_one_light_default from "../../themes/po-one-light.mjs";
3
+ import { parseThemeConfig } from "./parse.mjs";
4
+ //#region src/theme/builtinThemes.ts
5
+ function shipped(input, file) {
6
+ const theme = parseThemeConfig(input);
7
+ if (theme === null) throw new Error(`The shipped theme ${file} is malformed.`);
8
+ return theme;
9
+ }
10
+ /** The theme the cockpit renders with until a preference says otherwise. */
11
+ const DEFAULT_THEME_NAME = "po-one-light";
12
+ /** The themes this package ships, default first. */
13
+ const BUILTIN_THEMES = [shipped(po_one_light_default, "po-one-light.json"), shipped(po_nord_dark_default, "po-nord-dark.json")];
14
+ const DEFAULT_THEME = BUILTIN_THEMES[0];
15
+ /** A shipped theme by name, or undefined for a name nothing shipped under. */
16
+ function builtinTheme(name) {
17
+ return BUILTIN_THEMES.find((theme) => theme.name === name);
18
+ }
19
+ //#endregion
20
+ export { BUILTIN_THEMES, DEFAULT_THEME, DEFAULT_THEME_NAME, builtinTheme };
@@ -0,0 +1,31 @@
1
+ const require_theme = require("../types/theme.cjs");
2
+ const DEFAULT_FONT_MONO = "'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace";
3
+ /**
4
+ * A derived token's fallback: a CSS colour expression over the palette, so a
5
+ * theme that supplies only its palette still gets coherent tints and edges.
6
+ */
7
+ function derivedFallback(token) {
8
+ if (token === "font-mono") return DEFAULT_FONT_MONO;
9
+ if (token === "on-selected") return `color-mix(in srgb, var(--po-selected) ${String(12)}%, white)`;
10
+ const [kind, accent] = token.split("-");
11
+ return kind === "tint" ? `color-mix(in srgb, var(--po-${accent}) ${String(16)}%, var(--po-panel))` : `color-mix(in srgb, var(--po-${accent}) ${String(40)}%, var(--po-border))`;
12
+ }
13
+ /** Every derived token, in a stable order. */
14
+ function derivedTokens() {
15
+ const tokens = [];
16
+ for (const accent of require_theme.ACCENT_TOKENS) tokens.push(`tint-${accent}`);
17
+ for (const accent of require_theme.ACCENT_TOKENS) tokens.push(`edge-${accent}`);
18
+ tokens.push("on-selected", "font-mono");
19
+ return tokens;
20
+ }
21
+ /** The value a theme publishes for a token: its own, or the derived fallback. */
22
+ function tokenValue(theme, token) {
23
+ const own = theme.tokens[token];
24
+ if (own !== void 0) return own;
25
+ return derivedFallback(token);
26
+ }
27
+ //#endregion
28
+ exports.DEFAULT_FONT_MONO = DEFAULT_FONT_MONO;
29
+ exports.derivedFallback = derivedFallback;
30
+ exports.derivedTokens = derivedTokens;
31
+ exports.tokenValue = tokenValue;
@@ -0,0 +1,13 @@
1
+ import { DerivedToken, ThemeConfig, ThemeToken } from "../types/theme.mjs";
2
+ //#region src/theme/derive.d.ts
3
+ export declare const DEFAULT_FONT_MONO = "'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace";
4
+ /**
5
+ * A derived token's fallback: a CSS colour expression over the palette, so a
6
+ * theme that supplies only its palette still gets coherent tints and edges.
7
+ */
8
+ export declare function derivedFallback(token: DerivedToken): string;
9
+ /** Every derived token, in a stable order. */
10
+ export declare function derivedTokens(): DerivedToken[];
11
+ /** The value a theme publishes for a token: its own, or the derived fallback. */
12
+ export declare function tokenValue(theme: ThemeConfig, token: ThemeToken): string;
13
+ //#endregion
@@ -0,0 +1,28 @@
1
+ import { ACCENT_TOKENS } from "../types/theme.mjs";
2
+ const DEFAULT_FONT_MONO = "'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace";
3
+ /**
4
+ * A derived token's fallback: a CSS colour expression over the palette, so a
5
+ * theme that supplies only its palette still gets coherent tints and edges.
6
+ */
7
+ function derivedFallback(token) {
8
+ if (token === "font-mono") return DEFAULT_FONT_MONO;
9
+ if (token === "on-selected") return `color-mix(in srgb, var(--po-selected) ${String(12)}%, white)`;
10
+ const [kind, accent] = token.split("-");
11
+ return kind === "tint" ? `color-mix(in srgb, var(--po-${accent}) ${String(16)}%, var(--po-panel))` : `color-mix(in srgb, var(--po-${accent}) ${String(40)}%, var(--po-border))`;
12
+ }
13
+ /** Every derived token, in a stable order. */
14
+ function derivedTokens() {
15
+ const tokens = [];
16
+ for (const accent of ACCENT_TOKENS) tokens.push(`tint-${accent}`);
17
+ for (const accent of ACCENT_TOKENS) tokens.push(`edge-${accent}`);
18
+ tokens.push("on-selected", "font-mono");
19
+ return tokens;
20
+ }
21
+ /** The value a theme publishes for a token: its own, or the derived fallback. */
22
+ function tokenValue(theme, token) {
23
+ const own = theme.tokens[token];
24
+ if (own !== void 0) return own;
25
+ return derivedFallback(token);
26
+ }
27
+ //#endregion
28
+ export { DEFAULT_FONT_MONO, derivedFallback, derivedTokens, tokenValue };
@@ -0,0 +1,195 @@
1
+ const require_theme = require("../types/theme.cjs");
2
+ require("./derive.cjs");
3
+ const require_builtinThemes = require("./builtinThemes.cjs");
4
+ //#region src/theme/nativeTheme.ts
5
+ /** The spacing unit, matching `--spacing: 0.25rem` at a 16px root. */
6
+ const NATIVE_SPACING_BASE = 4;
7
+ /** Corner radii in px, matching `--radius-*`. */
8
+ const NATIVE_RADII = {
9
+ xs: 2,
10
+ sm: 3,
11
+ md: 5,
12
+ lg: 10
13
+ };
14
+ /**
15
+ * Every radius a native style may name: the retunable `--radius-*` steps, plus
16
+ * Tailwind's hardcoded bare `rounded` (4px) and `rounded-full`.
17
+ */
18
+ const NATIVE_BORDER_RADIUS = {
19
+ ...NATIVE_RADII,
20
+ DEFAULT: 4,
21
+ full: 9999
22
+ };
23
+ /** The type ramp, matching `--text-*` (px) and `--text-*--line-height` (a multiple of the size). */
24
+ const NATIVE_TYPE_RAMP = {
25
+ "2xs": {
26
+ size: 9,
27
+ leading: 1.45
28
+ },
29
+ xs: {
30
+ size: 10,
31
+ leading: 1.45
32
+ },
33
+ sm: {
34
+ size: 12,
35
+ leading: 1.45
36
+ },
37
+ base: {
38
+ size: 13,
39
+ leading: 1.5
40
+ },
41
+ lg: {
42
+ size: 15,
43
+ leading: 1.4
44
+ },
45
+ xl: {
46
+ size: 18,
47
+ leading: 1.3
48
+ },
49
+ "2xl": {
50
+ size: 22,
51
+ leading: 1.25
52
+ },
53
+ "3xl": {
54
+ size: 28,
55
+ leading: 1.2
56
+ }
57
+ };
58
+ /** Title tracking in em, matching `--text-*--letter-spacing`; steps not listed track at 0. */
59
+ const NATIVE_LETTER_SPACING_EM = {
60
+ xl: -.01,
61
+ "2xl": -.01,
62
+ "3xl": -.01
63
+ };
64
+ /** Tailwind's `leading-relaxed` multiple, which theme.css does not override. */
65
+ const NATIVE_LEADING_RELAXED = 1.625;
66
+ /** Font weights as React Native takes them, matching `font-normal`, `font-medium` and `font-semibold`. */
67
+ const NATIVE_FONT_WEIGHT = {
68
+ regular: "400",
69
+ medium: "500",
70
+ semibold: "600"
71
+ };
72
+ /**
73
+ * Durations in ms and the shared easing curve of `--animate-po-*`. `slide`
74
+ * covers both slide directions; `easing` is the `cubic-bezier()` control points
75
+ * for Reanimated's `Easing.bezier`.
76
+ */
77
+ const NATIVE_MOTION = {
78
+ fade: 140,
79
+ pop: 160,
80
+ rise: 160,
81
+ slide: 180,
82
+ easing: [
83
+ .16,
84
+ 1,
85
+ .3,
86
+ 1
87
+ ]
88
+ };
89
+ /** The sans and mono families of `--font-sans` and `--po-font-mono`, with system fallbacks. */
90
+ const NATIVE_FONT_FAMILY = {
91
+ sans: {
92
+ family: "IBM Plex Sans",
93
+ ios: "System",
94
+ android: "sans-serif"
95
+ },
96
+ mono: {
97
+ family: "JetBrains Mono",
98
+ ios: "Menlo",
99
+ android: "monospace"
100
+ }
101
+ };
102
+ /** The foreground `on-selected` mixes toward, as `white` in derive.ts. */
103
+ const ON_SELECTED_BASE = "#ffffff";
104
+ const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
105
+ const PERCENT = 100;
106
+ const CHANNEL_MAX = 255;
107
+ /** Rounds px values to hundredths so `18 * -0.01` reads -0.18, not a float tail. */
108
+ const PX_PRECISION = 100;
109
+ function hexChannels(hex) {
110
+ if (!HEX_COLOR.test(hex)) throw new Error(`Native themes need hex colours; got "${hex}".`);
111
+ const digits = hex.length === 4 ? hex.slice(1).split("").map((digit) => digit + digit).join("") : hex.slice(1);
112
+ return [
113
+ 0,
114
+ 2,
115
+ 4
116
+ ].map((offset) => Number.parseInt(digits.slice(offset, offset + 2), 16));
117
+ }
118
+ /**
119
+ * `color-mix(in srgb, first percent%, second)` for hex inputs: a straight
120
+ * per-channel blend, rounded to the nearest 8-bit value.
121
+ */
122
+ function mixHex(first, percent, second) {
123
+ const weight = percent / PERCENT;
124
+ const a = hexChannels(first);
125
+ const b = hexChannels(second);
126
+ return `#${a.map((channel, index) => {
127
+ const mixed = Math.round(channel * weight + b[index] * (1 - weight));
128
+ return Math.min(CHANNEL_MAX, Math.max(0, mixed)).toString(16).padStart(2, "0");
129
+ }).join("")}`;
130
+ }
131
+ /**
132
+ * A hex colour at `percent` opacity as `#rrggbbaa`: the native form of
133
+ * Tailwind's `/40`-style opacity modifiers.
134
+ */
135
+ function withAlpha(hex, percent) {
136
+ const alpha = Math.min(CHANNEL_MAX, Math.max(0, Math.round(percent / PERCENT * CHANNEL_MAX)));
137
+ return `#${[...hexChannels(hex), alpha].map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
138
+ }
139
+ function rampValues(pick) {
140
+ const values = {};
141
+ for (const step of Object.keys(NATIVE_TYPE_RAMP)) values[step] = pick(step);
142
+ return values;
143
+ }
144
+ /** Resolves a web theme config to native values; tokens the theme pins win over the derived mix. */
145
+ function nativeTheme(config) {
146
+ const pinned = config.tokens;
147
+ const colors = {};
148
+ for (const token of require_theme.PALETTE_TOKENS) colors[token] = config.tokens[token];
149
+ const resolve = (token, fallback) => {
150
+ colors[token] = pinned[token] ?? fallback();
151
+ };
152
+ for (const accent of require_theme.ACCENT_TOKENS) resolve(`tint-${accent}`, () => mixHex(colors[accent], 16, colors.panel));
153
+ for (const accent of require_theme.ACCENT_TOKENS) resolve(`edge-${accent}`, () => mixHex(colors[accent], 40, colors.border));
154
+ resolve("on-selected", () => mixHex(colors.selected, 12, ON_SELECTED_BASE));
155
+ return {
156
+ scheme: config.scheme,
157
+ colors,
158
+ spacing: (steps) => steps * 4,
159
+ borderRadius: NATIVE_BORDER_RADIUS,
160
+ fontSize: rampValues((step) => NATIVE_TYPE_RAMP[step].size),
161
+ lineHeight: rampValues((step) => Math.round(NATIVE_TYPE_RAMP[step].size * NATIVE_TYPE_RAMP[step].leading)),
162
+ lineHeightRelaxed: rampValues((step) => Math.round(NATIVE_TYPE_RAMP[step].size * NATIVE_LEADING_RELAXED)),
163
+ letterSpacing: rampValues((step) => {
164
+ const em = NATIVE_LETTER_SPACING_EM[step] ?? 0;
165
+ return Math.round(NATIVE_TYPE_RAMP[step].size * em * PX_PRECISION) / PX_PRECISION;
166
+ }),
167
+ fontWeight: NATIVE_FONT_WEIGHT,
168
+ fontFamily: NATIVE_FONT_FAMILY,
169
+ motion: NATIVE_MOTION
170
+ };
171
+ }
172
+ function shippedNative(name) {
173
+ const theme = require_builtinThemes.builtinTheme(name);
174
+ if (theme === void 0) throw new Error(`The shipped theme ${name} is missing.`);
175
+ return nativeTheme(theme);
176
+ }
177
+ /** The native themes by the names the native shell registers: `dark` and `light`. */
178
+ const NATIVE_THEMES = {
179
+ dark: shippedNative("po-nord-dark"),
180
+ light: shippedNative("po-one-light")
181
+ };
182
+ //#endregion
183
+ exports.NATIVE_BORDER_RADIUS = NATIVE_BORDER_RADIUS;
184
+ exports.NATIVE_FONT_FAMILY = NATIVE_FONT_FAMILY;
185
+ exports.NATIVE_FONT_WEIGHT = NATIVE_FONT_WEIGHT;
186
+ exports.NATIVE_LEADING_RELAXED = NATIVE_LEADING_RELAXED;
187
+ exports.NATIVE_LETTER_SPACING_EM = NATIVE_LETTER_SPACING_EM;
188
+ exports.NATIVE_MOTION = NATIVE_MOTION;
189
+ exports.NATIVE_RADII = NATIVE_RADII;
190
+ exports.NATIVE_SPACING_BASE = NATIVE_SPACING_BASE;
191
+ exports.NATIVE_THEMES = NATIVE_THEMES;
192
+ exports.NATIVE_TYPE_RAMP = NATIVE_TYPE_RAMP;
193
+ exports.mixHex = mixHex;
194
+ exports.nativeTheme = nativeTheme;
195
+ exports.withAlpha = withAlpha;