@deephaven/components 0.107.3-alpha-parent-theme.15 → 0.107.3-alpha-parent-theme.38

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.
@@ -7,8 +7,9 @@ export type ThemePreloadColorVariable = '--dh-color-accent-contrast' | '--dh-col
7
7
  export type ThemeIconsRequiringManualColorChanges = '--dh-svg-icon-select-indicator' | '--dh-svg-icon-select-indicator-hover' | '--dh-svg-icon-select-indicator-disabled' | '--dh-svg-icon-error';
8
8
  export declare const DEFAULT_DARK_THEME_KEY = "default-dark";
9
9
  export declare const DEFAULT_LIGHT_THEME_KEY = "default-light";
10
- export declare const PARENT_THEME_KEY: "parent-theme";
11
- export declare const PARENT_THEME_REQUEST = "io.deephaven.message.ParentTheme.request";
10
+ export declare const EXTERNAL_THEME_KEY: "external-theme";
11
+ export declare const MSG_REQUEST_GET_THEME = "io.deephaven.message.ThemeModel.requestExternalTheme";
12
+ export declare const MSG_REQUEST_SET_THEME = "io.deephaven.message.ThemeModel.requestSetTheme";
12
13
  export declare const PRELOAD_TRANSPARENT_THEME_QUERY_PARAM: "preloadTransparentTheme";
13
14
  export declare const THEME_KEY_OVERRIDE_QUERY_PARAM: "theme";
14
15
  export declare const DEFAULT_DARK_THEME_PALETTE: {
@@ -56,7 +57,7 @@ export interface ThemeRegistrationData {
56
57
  base: ThemeData[];
57
58
  custom: ThemeData[];
58
59
  }
59
- export interface ParentThemeData {
60
+ export interface ExternalThemeData {
60
61
  baseThemeKey?: BaseThemeKey;
61
62
  name: string;
62
63
  cssVars: Record<ThemeCssColorVariableName, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeModel.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeModel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7C,MAAM,MAAM,YAAY,GAAG,WAAW,aAAa,EAAE,CAAC;AACtD,MAAM,MAAM,uBAAuB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iB;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;CACpD"}
@@ -5,8 +5,9 @@
5
5
  // codebase. To be addressed by #1679
6
6
  export var DEFAULT_DARK_THEME_KEY = 'default-dark';
7
7
  export var DEFAULT_LIGHT_THEME_KEY = 'default-light';
8
- export var PARENT_THEME_KEY = 'parent-theme';
9
- export var PARENT_THEME_REQUEST = 'io.deephaven.message.ParentTheme.request';
8
+ export var EXTERNAL_THEME_KEY = 'external-theme';
9
+ export var MSG_REQUEST_GET_THEME = 'io.deephaven.message.ThemeModel.requestExternalTheme';
10
+ export var MSG_REQUEST_SET_THEME = 'io.deephaven.message.ThemeModel.requestSetTheme';
10
11
  export var PRELOAD_TRANSPARENT_THEME_QUERY_PARAM = 'preloadTransparentTheme';
11
12
  export var THEME_KEY_OVERRIDE_QUERY_PARAM = 'theme';
12
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeModel.js","names":["DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","PARENT_THEME_KEY","PARENT_THEME_REQUEST","PRELOAD_TRANSPARENT_THEME_QUERY_PARAM","THEME_KEY_OVERRIDE_QUERY_PARAM","DEFAULT_DARK_THEME_PALETTE","blue","red","gray","DEFAULT_PRELOAD_DATA_VARIABLES","concat","TRANSPARENT_PRELOAD_DATA_VARIABLES","SVG_ICON_MANUAL_COLOR_MAP","THEME_CACHE_LOCAL_STORAGE_KEY"],"sources":["../../src/theme/ThemeModel.ts"],"sourcesContent":["export type BaseThemeType = 'dark' | 'light';\nexport type BaseThemeKey = `default-${BaseThemeType}`;\nexport type CssVariableStyleContent = `:root{${string}`;\nexport type ThemeCssVariableName = `--dh-${string}`;\nexport type ThemeCssColorVariableName = `--dh-color-${string}`;\n\n// DHC should only need to preload variables that are required by the empty page\n// with loading spinner that shows while plugins are loading. The rest of the\n// preload variables defined here are required by DHE due to theme plugins\n// loading after login. We should consider moving most of these to the DHE\n// codebase. To be addressed by #1679\nexport type ThemePreloadColorVariable =\n | '--dh-color-accent-contrast'\n | '--dh-color-accent-bg'\n | '--dh-color-accent-hover-bg'\n | '--dh-color-accent-down-bg'\n | '--dh-color-accent-key-focus-bg'\n | '--dh-color-negative-bg'\n | '--dh-color-loading-spinner-primary'\n | '--dh-color-loading-spinner-secondary'\n | '--dh-color-bg'\n | '--dh-color-fg'\n | '--dh-color-input-bg'\n | '--dh-color-input-fg'\n | '--dh-color-input-disabled-bg'\n | '--dh-color-input-border'\n | '--dh-color-input-placeholder'\n | '--dh-color-input-focus-border'\n | '--dh-color-text-highlight'\n | '--dh-color-login-form-bg'\n | '--dh-color-login-status-message'\n | '--dh-color-login-logo-bg'\n | '--dh-color-login-footer-fg'\n | '--dh-color-random-area-plot-animation-fg-fill'\n | '--dh-color-random-area-plot-animation-fg-stroke'\n | '--dh-color-random-area-plot-animation-bg'\n | '--dh-color-random-area-plot-animation-grid';\n\nexport type ThemeIconsRequiringManualColorChanges =\n | '--dh-svg-icon-select-indicator'\n | '--dh-svg-icon-select-indicator-hover'\n | '--dh-svg-icon-select-indicator-disabled'\n | '--dh-svg-icon-error';\n\nexport const DEFAULT_DARK_THEME_KEY = 'default-dark' satisfies BaseThemeKey;\nexport const DEFAULT_LIGHT_THEME_KEY = 'default-light' satisfies BaseThemeKey;\nexport const PARENT_THEME_KEY = 'parent-theme' as const;\nexport const PARENT_THEME_REQUEST = 'io.deephaven.message.ParentTheme.request';\nexport const PRELOAD_TRANSPARENT_THEME_QUERY_PARAM =\n 'preloadTransparentTheme' as const;\nexport const THEME_KEY_OVERRIDE_QUERY_PARAM = 'theme' as const;\n\n// Hex versions of some of the default dark theme color palette needed for\n// preload defaults.\nexport const DEFAULT_DARK_THEME_PALETTE = {\n blue: {\n 500: '#2f5bc0',\n 400: '#254ba4',\n 600: '#3b6bda', // accent color\n 700: '#4c7dee',\n },\n red: {\n 600: '#c73f61',\n },\n gray: {\n 50: '#1a171a',\n 75: '#211f22',\n 300: '#373438',\n 400: '#403e41',\n 500: '#5b5a5c',\n 600: '#929192',\n 700: '#c0bfbf',\n 800: '#f0f0ee',\n 900: '#fcfcfa',\n },\n} as const;\n\n// Css properties that are used in preload data with default values.\n// DHC should only need to preload variables that are required by the empty page\n// with loading spinner that shows while plugins are loading. The rest of the\n// preload variables defined here are required by DHE due to theme plugins\n// loading after login. We should consider moving most of these to the DHE\n// codebase. To be addressed by #1679\nexport const DEFAULT_PRELOAD_DATA_VARIABLES: Record<\n ThemePreloadColorVariable,\n string\n> = {\n '--dh-color-accent-contrast': DEFAULT_DARK_THEME_PALETTE.gray[900],\n '--dh-color-accent-bg': DEFAULT_DARK_THEME_PALETTE.blue[600],\n '--dh-color-accent-hover-bg': DEFAULT_DARK_THEME_PALETTE.blue[500],\n '--dh-color-accent-down-bg': DEFAULT_DARK_THEME_PALETTE.blue[400],\n '--dh-color-accent-key-focus-bg': DEFAULT_DARK_THEME_PALETTE.blue[500],\n '--dh-color-negative-bg': DEFAULT_DARK_THEME_PALETTE.red[600],\n '--dh-color-loading-spinner-primary': DEFAULT_DARK_THEME_PALETTE.blue[600],\n '--dh-color-loading-spinner-secondary': `${DEFAULT_DARK_THEME_PALETTE.gray[800]}80`, // 50% opacity\n '--dh-color-bg': DEFAULT_DARK_THEME_PALETTE.gray[50],\n '--dh-color-fg': DEFAULT_DARK_THEME_PALETTE.gray[800],\n '--dh-color-input-bg': DEFAULT_DARK_THEME_PALETTE.gray[500],\n '--dh-color-input-fg': DEFAULT_DARK_THEME_PALETTE.gray[800],\n '--dh-color-input-disabled-bg': DEFAULT_DARK_THEME_PALETTE.gray[300],\n '--dh-color-input-border': DEFAULT_DARK_THEME_PALETTE.gray[600],\n '--dh-color-input-placeholder': DEFAULT_DARK_THEME_PALETTE.gray[600],\n '--dh-color-input-focus-border': `${DEFAULT_DARK_THEME_PALETTE.blue[600]}d9`, // 85% opacity\n '--dh-color-text-highlight': `${DEFAULT_DARK_THEME_PALETTE.blue[700]}4d`, // 30% opacity\n '--dh-color-login-form-bg': DEFAULT_DARK_THEME_PALETTE.gray[400],\n '--dh-color-login-status-message': DEFAULT_DARK_THEME_PALETTE.gray[600],\n '--dh-color-login-logo-bg': DEFAULT_DARK_THEME_PALETTE.gray[900],\n '--dh-color-login-footer-fg': DEFAULT_DARK_THEME_PALETTE.gray[700],\n '--dh-color-random-area-plot-animation-fg-fill': `${DEFAULT_DARK_THEME_PALETTE.blue[600]}14`, // .08 opacity\n '--dh-color-random-area-plot-animation-fg-stroke': `${DEFAULT_DARK_THEME_PALETTE.blue[600]}33`, // .2 opacity\n '--dh-color-random-area-plot-animation-bg':\n DEFAULT_DARK_THEME_PALETTE.gray[75],\n '--dh-color-random-area-plot-animation-grid':\n DEFAULT_DARK_THEME_PALETTE.gray[300],\n};\n\nexport const TRANSPARENT_PRELOAD_DATA_VARIABLES: Partial<\n Record<ThemePreloadColorVariable, string>\n> = {\n '--dh-color-bg': 'transparent',\n '--dh-color-loading-spinner-primary': 'transparent',\n '--dh-color-loading-spinner-secondary': 'transparent',\n};\n\n/**\n * Some inline SVGs require manually updating their fill color via\n * `updateSVGFillColors`. This object maps these variables to their respective\n * fill color variables.\n */\nexport const SVG_ICON_MANUAL_COLOR_MAP: Record<\n ThemeIconsRequiringManualColorChanges,\n string\n> = {\n '--dh-svg-icon-select-indicator': '--dh-color-selector-fg',\n '--dh-svg-icon-select-indicator-hover': '--dh-color-selector-hover-fg',\n '--dh-svg-icon-select-indicator-disabled': '--dh-color-selector-disabled-fg',\n '--dh-svg-icon-error': '--dh-color-form-control-error',\n};\n\nexport const THEME_CACHE_LOCAL_STORAGE_KEY = 'deephaven.themeCache';\n\nexport interface ThemePreloadData {\n themeKey: string;\n preloadStyleContent?: CssVariableStyleContent;\n}\n\nexport interface ThemeData {\n baseThemeKey?: BaseThemeKey;\n themeKey: string;\n name: string;\n styleContent: string;\n}\n\nexport interface ThemeRegistrationData {\n base: ThemeData[];\n custom: ThemeData[];\n}\n\nexport interface ParentThemeData {\n baseThemeKey?: BaseThemeKey;\n name: string;\n cssVars: Record<ThemeCssColorVariableName, string>;\n}\n"],"mappings":"AAMA;AACA;AACA;AACA;AACA;AAkCA,OAAO,IAAMA,sBAAsB,GAAG,cAAqC;AAC3E,OAAO,IAAMC,uBAAuB,GAAG,eAAsC;AAC7E,OAAO,IAAMC,gBAAgB,GAAG,cAAuB;AACvD,OAAO,IAAMC,oBAAoB,GAAG,0CAA0C;AAC9E,OAAO,IAAMC,qCAAqC,GAChD,yBAAkC;AACpC,OAAO,IAAMC,8BAA8B,GAAG,OAAgB;;AAE9D;AACA;AACA,OAAO,IAAMC,0BAA0B,GAAG;EACxCC,IAAI,EAAE;IACJ,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IAAE;IAChB,GAAG,EAAE;EACP,CAAC;EACDC,GAAG,EAAE;IACH,GAAG,EAAE;EACP,CAAC;EACDC,IAAI,EAAE;IACJ,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,SAAS;IACb,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE;EACP;AACF,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,8BAGZ,GAAG;EACF,4BAA4B,EAAEJ,0BAA0B,CAACG,IAAI,CAAC,GAAG,CAAC;EAClE,sBAAsB,EAAEH,0BAA0B,CAACC,IAAI,CAAC,GAAG,CAAC;EAC5D,4BAA4B,EAAED,0BAA0B,CAACC,IAAI,CAAC,GAAG,CAAC;EAClE,2BAA2B,EAAED,0BAA0B,CAACC,IAAI,CAAC,GAAG,CAAC;EACjE,gCAAgC,EAAED,0BAA0B,CAACC,IAAI,CAAC,GAAG,CAAC;EACtE,w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B,CAACG,IAAI,CAAC,EAAE,CAAC;EACrC,4CAA4C,EAC1CH,0BAA0B,CAACG,IAAI,CAAC,GAAG;AACvC,CAAC;AAED,OAAO,IAAMG,kCAEZ,GAAG;EACF,eAAe,EAAE,aAAa;EAC9B,oCAAoC,EAAE,aAAa;EACnD,sCAAsC,EAAE;AAC1C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,yBAGZ,GAAG;EACF,gCAAgC,EAAE,wBAAwB;EAC1D,sCAAsC,EAAE,8BAA8B;EACtE,yCAAyC,EAAE,iCAAiC;EAC5E,qBAAqB,EAAE;AACzB,CAAC;AAED,OAAO,IAAMC,6BAA6B,GAAG,sBAAsB"}
1
+ {"version":3,"file":"ThemeModel.js","names":["DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","EXTERNAL_THEME_KEY","MSG_REQUEST_GET_THEME","MSG_REQUEST_SET_THEME","PRELOAD_TRANSPARENT_THEME_QUERY_PARAM","THEME_KEY_OVERRIDE_QUERY_PARAM","DEFAULT_DARK_THEME_PALETTE","blue","red","gray","DEFAULT_PRELOAD_DATA_VARIABLES","concat","TRANSPARENT_PRELOAD_DATA_VARIABLES","SVG_ICON_MANUAL_COLOR_MAP","THEME_CACHE_LOCAL_STORAGE_KEY"],"sources":["../../src/theme/ThemeModel.ts"],"sourcesContent":["export type BaseThemeType = 'dark' | 'light';\nexport type BaseThemeKey = `default-${BaseThemeType}`;\nexport type CssVariableStyleContent = `:root{${string}`;\nexport type ThemeCssVariableName = `--dh-${string}`;\nexport type ThemeCssColorVariableName = `--dh-color-${string}`;\n\n// DHC should only need to preload variables that are required by the empty page\n// with loading spinner that shows while plugins are loading. The rest of the\n// preload variables defined here are required by DHE due to theme plugins\n// loading after login. We should consider moving most of these to the DHE\n// codebase. To be addressed by #1679\nexport type ThemePreloadColorVariable =\n | '--dh-color-accent-contrast'\n | '--dh-color-accent-bg'\n | '--dh-color-accent-hover-bg'\n | '--dh-color-accent-down-bg'\n | '--dh-color-accent-key-focus-bg'\n | '--dh-color-negative-bg'\n | '--dh-color-loading-spinner-primary'\n | '--dh-color-loading-spinner-secondary'\n | '--dh-color-bg'\n | '--dh-color-fg'\n | '--dh-color-input-bg'\n | '--dh-color-input-fg'\n | '--dh-color-input-disabled-bg'\n | '--dh-color-input-border'\n | '--dh-color-input-placeholder'\n | '--dh-color-input-focus-border'\n | '--dh-color-text-highlight'\n | '--dh-color-login-form-bg'\n | '--dh-color-login-status-message'\n | '--dh-color-login-logo-bg'\n | '--dh-color-login-footer-fg'\n | '--dh-color-random-area-plot-animation-fg-fill'\n | '--dh-color-random-area-plot-animation-fg-stroke'\n | '--dh-color-random-area-plot-animation-bg'\n | '--dh-color-random-area-plot-animation-grid';\n\nexport type ThemeIconsRequiringManualColorChanges =\n | '--dh-svg-icon-select-indicator'\n | '--dh-svg-icon-select-indicator-hover'\n | '--dh-svg-icon-select-indicator-disabled'\n | '--dh-svg-icon-error';\n\nexport const DEFAULT_DARK_THEME_KEY = 'default-dark' satisfies BaseThemeKey;\nexport const DEFAULT_LIGHT_THEME_KEY = 'default-light' satisfies BaseThemeKey;\nexport const EXTERNAL_THEME_KEY = 'external-theme' as const;\nexport const MSG_REQUEST_GET_THEME =\n 'io.deephaven.message.ThemeModel.requestExternalTheme';\nexport const MSG_REQUEST_SET_THEME =\n 'io.deephaven.message.ThemeModel.requestSetTheme';\nexport const PRELOAD_TRANSPARENT_THEME_QUERY_PARAM =\n 'preloadTransparentTheme' as const;\nexport const THEME_KEY_OVERRIDE_QUERY_PARAM = 'theme' as const;\n\n// Hex versions of some of the default dark theme color palette needed for\n// preload defaults.\nexport const DEFAULT_DARK_THEME_PALETTE = {\n blue: {\n 500: '#2f5bc0',\n 400: '#254ba4',\n 600: '#3b6bda', // accent color\n 700: '#4c7dee',\n },\n red: {\n 600: '#c73f61',\n },\n gray: {\n 50: '#1a171a',\n 75: '#211f22',\n 300: '#373438',\n 400: '#403e41',\n 500: '#5b5a5c',\n 600: '#929192',\n 700: '#c0bfbf',\n 800: '#f0f0ee',\n 900: '#fcfcfa',\n },\n} as const;\n\n// Css properties that are used in preload data with default values.\n// DHC should only need to preload variables that are required by the empty page\n// with loading spinner that shows while plugins are loading. The rest of the\n// preload variables defined here are required by DHE due to theme plugins\n// loading after login. We should consider moving most of these to the DHE\n// codebase. To be addressed by #1679\nexport const DEFAULT_PRELOAD_DATA_VARIABLES: Record<\n ThemePreloadColorVariable,\n string\n> = {\n '--dh-color-accent-contrast': DEFAULT_DARK_THEME_PALETTE.gray[900],\n '--dh-color-accent-bg': DEFAULT_DARK_THEME_PALETTE.blue[600],\n '--dh-color-accent-hover-bg': DEFAULT_DARK_THEME_PALETTE.blue[500],\n '--dh-color-accent-down-bg': DEFAULT_DARK_THEME_PALETTE.blue[400],\n '--dh-color-accent-key-focus-bg': DEFAULT_DARK_THEME_PALETTE.blue[500],\n '--dh-color-negative-bg': DEFAULT_DARK_THEME_PALETTE.red[600],\n '--dh-color-loading-spinner-primary': DEFAULT_DARK_THEME_PALETTE.blue[600],\n '--dh-color-loading-spinner-secondary': `${DEFAULT_DARK_THEME_PALETTE.gray[800]}80`, // 50% opacity\n '--dh-color-bg': DEFAULT_DARK_THEME_PALETTE.gray[50],\n '--dh-color-fg': DEFAULT_DARK_THEME_PALETTE.gray[800],\n '--dh-color-input-bg': DEFAULT_DARK_THEME_PALETTE.gray[500],\n '--dh-color-input-fg': DEFAULT_DARK_THEME_PALETTE.gray[800],\n '--dh-color-input-disabled-bg': DEFAULT_DARK_THEME_PALETTE.gray[300],\n '--dh-color-input-border': DEFAULT_DARK_THEME_PALETTE.gray[600],\n '--dh-color-input-placeholder': DEFAULT_DARK_THEME_PALETTE.gray[600],\n '--dh-color-input-focus-border': `${DEFAULT_DARK_THEME_PALETTE.blue[600]}d9`, // 85% opacity\n '--dh-color-text-highlight': `${DEFAULT_DARK_THEME_PALETTE.blue[700]}4d`, // 30% opacity\n '--dh-color-login-form-bg': DEFAULT_DARK_THEME_PALETTE.gray[400],\n '--dh-color-login-status-message': DEFAULT_DARK_THEME_PALETTE.gray[600],\n '--dh-color-login-logo-bg': DEFAULT_DARK_THEME_PALETTE.gray[900],\n '--dh-color-login-footer-fg': DEFAULT_DARK_THEME_PALETTE.gray[700],\n '--dh-color-random-area-plot-animation-fg-fill': `${DEFAULT_DARK_THEME_PALETTE.blue[600]}14`, // .08 opacity\n '--dh-color-random-area-plot-animation-fg-stroke': `${DEFAULT_DARK_THEME_PALETTE.blue[600]}33`, // .2 opacity\n '--dh-color-random-area-plot-animation-bg':\n DEFAULT_DARK_THEME_PALETTE.gray[75],\n '--dh-color-random-area-plot-animation-grid':\n DEFAULT_DARK_THEME_PALETTE.gray[300],\n};\n\nexport const TRANSPARENT_PRELOAD_DATA_VARIABLES: Partial<\n Record<ThemePreloadColorVariable, string>\n> = {\n '--dh-color-bg': 'transparent',\n '--dh-color-loading-spinner-primary': 'transparent',\n '--dh-color-loading-spinner-secondary': 'transparent',\n};\n\n/**\n * Some inline SVGs require manually updating their fill color via\n * `updateSVGFillColors`. This object maps these variables to their respective\n * fill color variables.\n */\nexport const SVG_ICON_MANUAL_COLOR_MAP: Record<\n ThemeIconsRequiringManualColorChanges,\n string\n> = {\n '--dh-svg-icon-select-indicator': '--dh-color-selector-fg',\n '--dh-svg-icon-select-indicator-hover': '--dh-color-selector-hover-fg',\n '--dh-svg-icon-select-indicator-disabled': '--dh-color-selector-disabled-fg',\n '--dh-svg-icon-error': '--dh-color-form-control-error',\n};\n\nexport const THEME_CACHE_LOCAL_STORAGE_KEY = 'deephaven.themeCache';\n\nexport interface ThemePreloadData {\n themeKey: string;\n preloadStyleContent?: CssVariableStyleContent;\n}\n\nexport interface ThemeData {\n baseThemeKey?: BaseThemeKey;\n themeKey: string;\n name: string;\n styleContent: string;\n}\n\nexport interface ThemeRegistrationData {\n base: ThemeData[];\n custom: ThemeData[];\n}\n\nexport interface ExternalThemeData {\n baseThemeKey?: BaseThemeKey;\n name: string;\n cssV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1CH,0BAA0B,CAACG,IAAI,CAAC,GAAG;AACvC,CAAC;AAED,OAAO,IAAMG,kCAEZ,GAAG;EACF,eAAe,EAAE,aAAa;EAC9B,oCAAoC,EAAE,aAAa;EACnD,sCAAsC,EAAE;AAC1C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,yBAGZ,GAAG;EACF,gCAAgC,EAAE,wBAAwB;EAC1D,sCAAsC,EAAE,8BAA8B;EACtE,yCAAyC,EAAE,iCAAiC;EAC5E,qBAAqB,EAAE;AACzB,CAAC;AAED,OAAO,IAAMC,6BAA6B,GAAG,sBAAsB"}
@@ -13,6 +13,6 @@ export interface ThemeProviderProps {
13
13
  defaultPreloadValues?: Record<string, string>;
14
14
  children: ReactNode;
15
15
  }
16
- export declare function ThemeProvider({ themes: propThemes, defaultPreloadValues, children, }: ThemeProviderProps): JSX.Element | null;
16
+ export declare function ThemeProvider({ themes: customThemes, defaultPreloadValues, children, }: ThemeProviderProps): JSX.Element | null;
17
17
  export default ThemeProvider;
18
18
  //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9E,OAAO,kBAAkB,CAAC;AAG1B,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAID,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E,MAAM,WAAW,kBAAkB;IAMjC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EAAE,UAAU,EAClB,oBAAqD,EACrD,QAAQ,GACT,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmIzC;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9E,OAAO,kBAAkB,CAAC;AAE1B,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAID,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E,MAAM,WAAW,kBAAkB;IAMjC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EAAE,YAAY,EACpB,oBAAqD,EACrD,QAAQ,GACT,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAkFzC;AAED,eAAe,aAAa,CAAC"}
@@ -1,11 +1,9 @@
1
1
  import { createContext, useEffect, useMemo, useState } from 'react';
2
2
  import Log from '@deephaven/log';
3
- import { assertNotNull } from '@deephaven/utils';
4
3
  import { DEFAULT_PRELOAD_DATA_VARIABLES } from "./ThemeModel.js";
5
4
  import { calculatePreloadStyleContent, getActiveThemes, getDefaultBaseThemes, setThemePreloadData, overrideSVGFillColors, getDefaultSelectedThemeKey } from "./ThemeUtils.js";
6
5
  import { SpectrumThemeProvider } from "./SpectrumThemeProvider.js";
7
6
  import "./theme-svg.css";
8
- import useParentWindowTheme from "./useParentWindowTheme.js";
9
7
  import { jsx as _jsx } from "react/jsx-runtime";
10
8
  import { Fragment as _Fragment } from "react/jsx-runtime";
11
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -13,62 +11,19 @@ var log = Log.module('ThemeProvider');
13
11
  export var ThemeContext = /*#__PURE__*/createContext(null);
14
12
  export function ThemeProvider(_ref) {
15
13
  var {
16
- themes: propThemes,
14
+ themes: customThemes,
17
15
  defaultPreloadValues = DEFAULT_PRELOAD_DATA_VARIABLES,
18
16
  children
19
17
  } = _ref;
20
18
  var baseThemes = useMemo(() => getDefaultBaseThemes(), []);
21
- var {
22
- isEnabled: isParentThemeEnabled,
23
- isPending: isParentThemePending,
24
- themeData: parentThemeData
25
- } = useParentWindowTheme();
26
19
  var [value, setValue] = useState(null);
27
20
  var [selectedThemeKey, setSelectedThemeKey] = useState(getDefaultSelectedThemeKey);
28
21
 
29
- /**
30
- * Custom themes can be provided via props or by a `postMessage` from the
31
- * parent window. In either case, the themes may get loaded asynchronously.
32
- * A `null` value indicates that the themes are still being loaded. e.g.
33
- * plugins that provide themes after login may provide custom themes via props,
34
- * while `postMessage` apis are by nature asynchronous.
35
- * Note prop themes are ignored when parent themes are enabled.
36
- */
37
- var customThemes = useMemo(() => {
38
- // Custom theme provided by `postMessage` from the parent window.
39
- if (isParentThemeEnabled && !isParentThemePending) {
40
- return parentThemeData ? [parentThemeData] : [];
41
- }
42
-
43
- // Custom themes provided by props.
44
- if (!isParentThemeEnabled) {
45
- return propThemes;
46
- }
47
- return null;
48
- }, [isParentThemeEnabled, isParentThemePending, parentThemeData, propThemes]);
49
-
50
- // Calculate active themes once custom themes are loaded
51
- var activeThemes = useMemo(() => {
52
- if (isParentThemeEnabled && isParentThemePending) {
53
- return null;
54
- }
55
-
56
- // Give plugins a chance to provide custom themes.
57
- if (!isParentThemeEnabled && customThemes == null) {
58
- return null;
59
- }
60
- var custom;
61
- if (isParentThemeEnabled) {
62
- custom = parentThemeData ? [parentThemeData] : [];
63
- } else {
64
- assertNotNull(customThemes);
65
- custom = customThemes;
66
- }
67
- return getActiveThemes(selectedThemeKey, {
68
- base: baseThemes,
69
- custom
70
- });
71
- }, [isParentThemeEnabled, isParentThemePending, customThemes, selectedThemeKey, baseThemes, parentThemeData]);
22
+ // Calculate active themes once a non-null themes array is provided.
23
+ var activeThemes = useMemo(() => customThemes == null ? null : getActiveThemes(selectedThemeKey, {
24
+ base: baseThemes,
25
+ custom: customThemes !== null && customThemes !== void 0 ? customThemes : []
26
+ }), [baseThemes, selectedThemeKey, customThemes]);
72
27
  var themes = useMemo(() => [...baseThemes, ...(customThemes !== null && customThemes !== void 0 ? customThemes : [])], [baseThemes, customThemes]);
73
28
  useEffect(function updateThemePreloadData() {
74
29
  // Don't update preload data until themes have been loaded and activated
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","names":["createContext","useEffect","useMemo","useState","Log","assertNotNull","DEFAULT_PRELOAD_DATA_VARIABLES","calculatePreloadStyleContent","getActiveThemes","getDefaultBaseThemes","setThemePreloadData","overrideSVGFillColors","getDefaultSelectedThemeKey","SpectrumThemeProvider","useParentWindowTheme","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","ThemeContext","ThemeProvider","_ref","themes","propThemes","defaultPreloadValues","children","baseThemes","isEnabled","isParentThemeEnabled","isPending","isParentThemePending","themeData","parentThemeData","value","setValue","selectedThemeKey","setSelectedThemeKey","customThemes","activeThemes","custom","base","updateThemePreloadData","preloadStyleContent","debug2","active","map","theme","themeKey","styleContent","Provider"],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport Log from '@deephaven/log';\nimport { assertNotNull } from '@deephaven/utils';\nimport { DEFAULT_PRELOAD_DATA_VARIABLES, type ThemeData } from './ThemeModel';\nimport {\n calculatePreloadStyleContent,\n getActiveThemes,\n getDefaultBaseThemes,\n setThemePreloadData,\n overrideSVGFillColors,\n getDefaultSelectedThemeKey,\n} from './ThemeUtils';\nimport { SpectrumThemeProvider } from './SpectrumThemeProvider';\nimport './theme-svg.scss';\nimport useParentWindowTheme from './useParentWindowTheme';\n\nexport interface ThemeContextValue {\n activeThemes: ThemeData[] | null;\n selectedThemeKey: string;\n themes: ThemeData[];\n setSelectedThemeKey: (themeKey: string) => void;\n}\n\nconst log = Log.module('ThemeProvider');\n\nexport const ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n /*\n * Additional themes to load in addition to the base themes. If no additional\n * themes are to be loaded, this must be set to an empty array in order to\n * tell the provider to activate the base themes.\n */\n themes: ThemeData[] | null;\n defaultPreloadValues?: Record<string, string>;\n children: ReactNode;\n}\n\nexport function ThemeProvider({\n themes: propThemes,\n defaultPreloadValues = DEFAULT_PRELOAD_DATA_VARIABLES,\n children,\n}: ThemeProviderProps): JSX.Element | null {\n const baseThemes = useMemo(() => getDefaultBaseThemes(), []);\n\n const {\n isEnabled: isParentThemeEnabled,\n isPending: isParentThemePending,\n themeData: parentThemeData,\n } = useParentWindowTheme();\n\n const [value, setValue] = useState<ThemeContextValue | null>(null);\n\n const [selectedThemeKey, setSelectedThemeKey] = useState<string>(\n getDefaultSelectedThemeKey\n );\n\n /**\n * Custom themes can be provided via props or by a `postMessage` from the\n * parent window. In either case, the themes may get loaded asynchronously.\n * A `null` value indicates that the themes are still being loaded. e.g.\n * plugins that provide themes after login may provide custom themes via props,\n * while `postMessage` apis are by nature asynchronous.\n * Note prop themes are ignored when parent themes are enabled.\n */\n const customThemes = useMemo(() => {\n // Custom theme provided by `postMessage` from the parent window.\n if (isParentThemeEnabled && !isParentThemePending) {\n return parentThemeData ? [parentThemeData] : [];\n }\n\n // Custom themes provided by props.\n if (!isParentThemeEnabled) {\n return propThemes;\n }\n\n return null;\n }, [isParentThemeEnabled, isParentThemePending, parentThemeData, propThemes]);\n\n // Calculate active themes once custom themes are loaded\n const activeThemes = useMemo(() => {\n if (isParentThemeEnabled && isParentThemePending) {\n return null;\n }\n\n // Give plugins a chance to provide custom themes.\n if (!isParentThemeEnabled && customThemes == null) {\n return null;\n }\n\n let custom: ThemeData[];\n\n if (isParentThemeEnabled) {\n custom = parentThemeData ? [parentThemeData] : [];\n } else {\n assertNotNull(customThemes);\n custom = customThemes;\n }\n\n return getActiveThemes(selectedThemeKey, {\n base: baseThemes,\n custom,\n });\n }, [\n isParentThemeEnabled,\n isParentThemePending,\n customThemes,\n selectedThemeKey,\n baseThemes,\n parentThemeData,\n ]);\n\n const themes = useMemo(\n () => [...baseThemes, ...(customThemes ?? [])],\n [baseThemes, customThemes]\n );\n\n useEffect(\n function updateThemePreloadData() {\n // Don't update preload data until themes have been loaded and activated\n if (activeThemes == null || customThemes == null) {\n return;\n }\n\n // Override fill color for certain inline SVGs (the originals are provided\n // by theme-svg.scss)\n overrideSVGFillColors(defaultPreloadValues);\n\n const preloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug2('updateThemePreloadData:', {\n active: activeThemes.map(theme => theme.themeKey),\n custom: customThemes.map(theme => theme.themeKey),\n preloadStyleContent,\n selectedThemeKey,\n });\n\n setThemePreloadData({\n themeKey: selectedThemeKey,\n preloadStyleContent,\n });\n },\n [activeThemes, selectedThemeKey, customThemes, defaultPreloadValues]\n );\n\n useEffect(() => {\n setValue({\n activeThemes,\n selectedThemeKey,\n themes,\n setSelectedThemeKey,\n });\n }, [activeThemes, selectedThemeKey, themes]);\n\n return (\n <>\n {activeThemes == null ? null : (\n <>\n {activeThemes.map(theme => (\n <style data-theme-key={theme.themeKey} key={theme.themeKey}>\n {theme.styleContent}\n </style>\n ))}\n </>\n )}\n {value == null ? null : (\n <ThemeContext.Provider value={value}>\n <SpectrumThemeProvider>{children}</SpectrumThemeProvider>\n </ThemeContext.Provider>\n )}\n </>\n );\n}\n\nexport default ThemeProvider;\n"],"mappings":"AAAA,SACEA,aAAa,EAEbC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,QAAQ,kBAAkB;AAAC,SACxCC,8BAA8B;AAAA,SAErCC,4BAA4B,EAC5BC,eAAe,EACfC,oBAAoB,EACpBC,mBAAmB,EACnBC,qBAAqB,EACrBC,0BAA0B;AAAA,SAEnBC,qBAAqB;AAAA;AAAA,OAEvBC,oBAAoB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAS3B,IAAMC,GAAG,GAAGjB,GAAG,CAACkB,MAAM,CAAC,eAAe,CAAC;AAEvC,OAAO,IAAMC,YAAY,gBAAGvB,aAAa,CAA2B,IAAI,CAAC;AAazE,OAAO,SAASwB,aAAaA,CAAAC,IAAA,EAIc;EAAA,IAJb;IAC5BC,MAAM,EAAEC,UAAU;IAClBC,oBAAoB,GAAGtB,8BAA8B;IACrDuB;EACkB,CAAC,GAAAJ,IAAA;EACnB,IAAMK,UAAU,GAAG5B,OAAO,CAAC,MAAMO,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC;EAE5D,IAAM;IACJsB,SAAS,EAAEC,oBAAoB;IAC/BC,SAAS,EAAEC,oBAAoB;IAC/BC,SAAS,EAAEC;EACb,CAAC,GAAGtB,oBAAoB,CAAC,CAAC;EAE1B,IAAM,CAACuB,KAAK,EAAEC,QAAQ,CAAC,GAAGnC,QAAQ,CAA2B,IAAI,CAAC;EAElE,IAAM,CAACoC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGrC,QAAQ,CACtDS,0BACF,CAA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EAAEA;MAAQ,CAAwB;IAAC,CACpC,CACxB;EAAA,CACD,CAAC;AAEP;AAEA,eAAeL,aAAa"}
1
+ {"version":3,"file":"ThemeProvider.js","names":["createContext","useEffect","useMemo","useState","Log","DEFAULT_PRELOAD_DATA_VARIABLES","calculatePreloadStyleContent","getActiveThemes","getDefaultBaseThemes","setThemePreloadData","overrideSVGFillColors","getDefaultSelectedThemeKey","SpectrumThemeProvider","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","ThemeContext","ThemeProvider","_ref","themes","customThemes","defaultPreloadValues","children","baseThemes","value","setValue","selectedThemeKey","setSelectedThemeKey","activeThemes","base","custom","updateThemePreloadData","preloadStyleContent","debug2","active","map","theme","themeKey","styleContent","Provider"],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport Log from '@deephaven/log';\nimport { DEFAULT_PRELOAD_DATA_VARIABLES, type ThemeData } from './ThemeModel';\nimport {\n calculatePreloadStyleContent,\n getActiveThemes,\n getDefaultBaseThemes,\n setThemePreloadData,\n overrideSVGFillColors,\n getDefaultSelectedThemeKey,\n} from './ThemeUtils';\nimport { SpectrumThemeProvider } from './SpectrumThemeProvider';\nimport './theme-svg.scss';\n\nexport interface ThemeContextValue {\n activeThemes: ThemeData[] | null;\n selectedThemeKey: string;\n themes: ThemeData[];\n setSelectedThemeKey: (themeKey: string) => void;\n}\n\nconst log = Log.module('ThemeProvider');\n\nexport const ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n /*\n * Additional themes to load in addition to the base themes. If no additional\n * themes are to be loaded, this must be set to an empty array in order to\n * tell the provider to activate the base themes.\n */\n themes: ThemeData[] | null;\n defaultPreloadValues?: Record<string, string>;\n children: ReactNode;\n}\n\nexport function ThemeProvider({\n themes: customThemes,\n defaultPreloadValues = DEFAULT_PRELOAD_DATA_VARIABLES,\n children,\n}: ThemeProviderProps): JSX.Element | null {\n const baseThemes = useMemo(() => getDefaultBaseThemes(), []);\n\n const [value, setValue] = useState<ThemeContextValue | null>(null);\n\n const [selectedThemeKey, setSelectedThemeKey] = useState<string>(\n getDefaultSelectedThemeKey\n );\n\n // Calculate active themes once a non-null themes array is provided.\n const activeThemes = useMemo(\n () =>\n customThemes == null\n ? null\n : getActiveThemes(selectedThemeKey, {\n base: baseThemes,\n custom: customThemes ?? [],\n }),\n [baseThemes, selectedThemeKey, customThemes]\n );\n\n const themes = useMemo(\n () => [...baseThemes, ...(customThemes ?? [])],\n [baseThemes, customThemes]\n );\n\n useEffect(\n function updateThemePreloadData() {\n // Don't update preload data until themes have been loaded and activated\n if (activeThemes == null || customThemes == null) {\n return;\n }\n\n // Override fill color for certain inline SVGs (the originals are provided\n // by theme-svg.scss)\n overrideSVGFillColors(defaultPreloadValues);\n\n const preloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug2('updateThemePreloadData:', {\n active: activeThemes.map(theme => theme.themeKey),\n custom: customThemes.map(theme => theme.themeKey),\n preloadStyleContent,\n selectedThemeKey,\n });\n\n setThemePreloadData({\n themeKey: selectedThemeKey,\n preloadStyleContent,\n });\n },\n [activeThemes, selectedThemeKey, customThemes, defaultPreloadValues]\n );\n\n useEffect(() => {\n setValue({\n activeThemes,\n selectedThemeKey,\n themes,\n setSelectedThemeKey,\n });\n }, [activeThemes, selectedThemeKey, themes]);\n\n return (\n <>\n {activeThemes == null ? null : (\n <>\n {activeThemes.map(theme => (\n <style data-theme-key={theme.themeKey} key={theme.themeKey}>\n {theme.styleContent}\n </style>\n ))}\n </>\n )}\n {value == null ? null : (\n <ThemeContext.Provider value={value}>\n <SpectrumThemeProvider>{children}</SpectrumThemeProvider>\n </ThemeContext.Provider>\n )}\n </>\n );\n}\n\nexport default ThemeProvider;\n"],"mappings":"AAAA,SACEA,aAAa,EAEbC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,OAAOC,GAAG,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AQ;MAACf,KAAK,EAAEA,KAAM;MAAAF,QAAA,eAClCb,IAAA,CAACF,qBAAqB;QAAAe,QAAA,EAAEA;MAAQ,CAAwB;IAAC,CACpC,CACxB;EAAA,CACD,CAAC;AAEP;AAEA,eAAeL,aAAa"}
@@ -1,4 +1,4 @@
1
- import { type BaseThemeKey, type ThemeData, type ThemePreloadData, type CssVariableStyleContent, type ThemeRegistrationData, type ThemeCssVariableName, type ParentThemeData, type ThemeCssColorVariableName } from './ThemeModel';
1
+ import { type BaseThemeKey, type ThemeData, type ThemePreloadData, type CssVariableStyleContent, type ThemeRegistrationData, type ThemeCssVariableName, type ExternalThemeData, type ThemeCssColorVariableName } from './ThemeModel';
2
2
  export declare const CSS_VAR_EXPRESSION_PREFIX = "var(--";
3
3
  export declare const DH_VAR_PREFIX = "--dh-color-";
4
4
  export declare const TMP_CSS_PROP_PREFIX = "dh-tmp";
@@ -52,6 +52,12 @@ export declare function getDefaultBaseThemes(): ThemeData[];
52
52
  * @returns The default selected theme key
53
53
  */
54
54
  export declare function getDefaultSelectedThemeKey(): string;
55
+ /**
56
+ * Derive unique theme key from plugin root path and theme name.
57
+ * @param pluginName The root path of the plugin
58
+ * @param themeName The name of the theme
59
+ */
60
+ export declare function getThemeKey(pluginName: string, themeName: string): string;
55
61
  /**
56
62
  * A theme key override can be set via a query parameter to force a specific
57
63
  * theme selection. Useful for embedded widget scenarios that don't expose the
@@ -91,18 +97,22 @@ export declare function getThemePreloadData(): ThemePreloadData | null;
91
97
  */
92
98
  export declare function getExpressionRanges(value: string): [number, number][];
93
99
  /**
94
- * Request parent theme data from the parent window.
95
- * @returns A promise that resolves to the parent theme data
96
- * @throws Error if the response is not a valid `ParentThemeData`
100
+ * Check if the given theme key is one of the base themes.
101
+ * @param themeKey The theme key to check
102
+ * @returns True if the theme key is a base theme key, false otherwise
97
103
  */
98
- export declare function requestParentThemeData(): Promise<ParentThemeData>;
99
- export declare function isValidColorVar(name: string, value: string): name is ThemeCssColorVariableName;
100
- export declare function parseParentThemeData({ baseThemeKey, name, cssVars, }: ParentThemeData): ThemeData;
104
+ export declare function isBaseThemeKey(themeKey: string): themeKey is BaseThemeKey;
105
+ /**
106
+ * Determine if a given object is a `ExternalThemeData` object.
107
+ * @param maybeExternalThemeData An object that may or may not be a `ExternalThemeData`
108
+ * @returns True if the object is a `ExternalThemeData`, false otherwise
109
+ */
110
+ export declare function isExternalThemeData(maybeExternalThemeData: unknown): maybeExternalThemeData is ExternalThemeData;
101
111
  /**
102
- * Check if the current URL specifies a parent theme key override.
103
- * @returns True if the parent theme key override is set, false otherwise
112
+ * Check if the current URL specifies an external theme key override.
113
+ * @returns True if the external theme key override is set, false otherwise
104
114
  */
105
- export declare function isParentThemeEnabled(): boolean;
115
+ export declare function isExternalThemeEnabled(): boolean;
106
116
  /**
107
117
  * Check if PRELOAD_TRANSPARENT_THEME_QUERY_PARAM query parameter is set to true.
108
118
  * @returns True if the preload transparent theme query parameter is set, false
@@ -110,17 +120,21 @@ export declare function isParentThemeEnabled(): boolean;
110
120
  */
111
121
  export declare function isPreloadTransparentTheme(): boolean;
112
122
  /**
113
- * Check if the given theme key is one of the base themes.
114
- * @param themeKey The theme key to check
115
- * @returns True if the theme key is a base theme key, false otherwise
123
+ * Validate that a given CSS variable name / value pair is a valid Deephaven
124
+ * color variable.
125
+ * @param name The name of the CSS variable to validate, e.g. '--dh-color-primary'
126
+ * @param value The value of the CSS color to validate
127
+ * @returns True if the name is a valid Deephaven color variable and the value
128
+ * is a valid CSS color, false otherwise
116
129
  */
117
- export declare function isBaseThemeKey(themeKey: string): themeKey is BaseThemeKey;
130
+ export declare function isValidColorVar(name: string, value: string): name is ThemeCssColorVariableName;
118
131
  /**
119
- * Determine if a given object is a `ParentThemeData` object.
120
- * @param maybeParentThemeData An object that may or may not be a `ParentThemeData`
121
- * @returns True if the object is a `ParentThemeData`, false otherwise
132
+ * Parse external theme data into a `ThemeData` object. Invalid CSS color variable
133
+ * pairs are excluded from the resulting `ThemeData` object.
134
+ * @param externalThemeData The external theme data to parse
135
+ * @returns A `ThemeData` object representing the external theme
122
136
  */
123
- export declare function isParentThemeData(maybeParentThemeData: unknown): maybeParentThemeData is ParentThemeData;
137
+ export declare function parseExternalThemeData({ baseThemeKey, name, cssVars, }: ExternalThemeData): ThemeData;
124
138
  /**
125
139
  * Replace the `fill='...'` attribute in the given SVG content with the given
126
140
  * color string.
@@ -128,6 +142,12 @@ export declare function isParentThemeData(maybeParentThemeData: unknown): maybeP
128
142
  * @param fillColor The color to replace the fill color with
129
143
  */
130
144
  export declare function replaceSVGFillColor(svgContent: string, fillColor: string): string;
145
+ /**
146
+ * Request theme data from the parent window.
147
+ * @returns A promise that resolves to the external theme data
148
+ * @throws Error if the response is not a valid `ExternalThemeData`
149
+ */
150
+ export declare function requestExternalThemeData(): Promise<ExternalThemeData>;
131
151
  /**
132
152
  * Make a copy of the given object replacing any css variable expressions
133
153
  * contained in its prop values with values resolved from the given HTML element.
@@ -162,12 +182,6 @@ export declare function resolveCssVariablesInString(resolver: VarExpressionResol
162
182
  * @param preloadData The preload data to set
163
183
  */
164
184
  export declare function setThemePreloadData(preloadData: ThemePreloadData): void;
165
- /**
166
- * Derive unique theme key from plugin root path and theme name.
167
- * @param pluginName The root path of the plugin
168
- * @param themeName The name of the theme
169
- */
170
- export declare function getThemeKey(pluginName: string, themeName: string): string;
171
185
  /**
172
186
  * Preload minimal theme variables from the cache.
173
187
  * @defaultPreloadValues Optional default values to use if a preload variable is not set.
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeUtils.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeUtils.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,KAAK,qBAAqB,EAG1B,KAAK,oBAAoB,EAIzB,KAAK,eAAe,EAEpB,KAAK,yBAAyB,EAG/B,MAAM,cAAc,CAAC;AAItB,eAAO,MAA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AAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,IAAI,IAAI,yBAAyB,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,YAAqC,EACrC,IAAI,EACJ,OAAO,GACR,EAAE,iBAAiB,GAAG,SAAS,CAiB/B;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAU3E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1E,MAAM,EAAE,CAAC,EACT,aAAa,GAAE,WAA2B,EAC1C,eAAe,UAAQ,GACtB,CAAC,CAyDH;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,MAAM,GACZ,MAAM,CAyBR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAKvE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,oBAAoB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAkC,GAC5E,IAAI,CAuCN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,IAAI,CAkBN"}
@@ -4,7 +4,7 @@ import Log from '@deephaven/log';
4
4
  import { assertNotNull, ColorUtils, requestParentResponse } from '@deephaven/utils';
5
5
  import { themeDark } from "./theme-dark/index.js";
6
6
  import { themeLight } from "./theme-light/index.js";
7
- import { DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY, DEFAULT_PRELOAD_DATA_VARIABLES, THEME_CACHE_LOCAL_STORAGE_KEY, SVG_ICON_MANUAL_COLOR_MAP, THEME_KEY_OVERRIDE_QUERY_PARAM, PARENT_THEME_KEY, PARENT_THEME_REQUEST, TRANSPARENT_PRELOAD_DATA_VARIABLES, PRELOAD_TRANSPARENT_THEME_QUERY_PARAM } from "./ThemeModel.js";
7
+ import { DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY, DEFAULT_PRELOAD_DATA_VARIABLES, THEME_CACHE_LOCAL_STORAGE_KEY, SVG_ICON_MANUAL_COLOR_MAP, THEME_KEY_OVERRIDE_QUERY_PARAM, EXTERNAL_THEME_KEY, MSG_REQUEST_GET_THEME, TRANSPARENT_PRELOAD_DATA_VARIABLES, PRELOAD_TRANSPARENT_THEME_QUERY_PARAM } from "./ThemeModel.js";
8
8
  var log = Log.module('ThemeUtils');
9
9
  export var CSS_VAR_EXPRESSION_PREFIX = 'var(--';
10
10
  export var DH_VAR_PREFIX = '--dh-color-';
@@ -133,6 +133,15 @@ export function getDefaultSelectedThemeKey() {
133
133
  return (_ref2 = (_getThemeKeyOverride = getThemeKeyOverride()) !== null && _getThemeKeyOverride !== void 0 ? _getThemeKeyOverride : (_getThemePreloadData = getThemePreloadData()) === null || _getThemePreloadData === void 0 ? void 0 : _getThemePreloadData.themeKey) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_DARK_THEME_KEY;
134
134
  }
135
135
 
136
+ /**
137
+ * Derive unique theme key from plugin root path and theme name.
138
+ * @param pluginName The root path of the plugin
139
+ * @param themeName The name of the theme
140
+ */
141
+ export function getThemeKey(pluginName, themeName) {
142
+ return "".concat(pluginName, "_").concat(themeName);
143
+ }
144
+
136
145
  /**
137
146
  * A theme key override can be set via a query parameter to force a specific
138
147
  * theme selection. Useful for embedded widget scenarios that don't expose the
@@ -210,53 +219,33 @@ export function getExpressionRanges(value) {
210
219
  }
211
220
 
212
221
  /**
213
- * Request parent theme data from the parent window.
214
- * @returns A promise that resolves to the parent theme data
215
- * @throws Error if the response is not a valid `ParentThemeData`
222
+ * Check if the given theme key is one of the base themes.
223
+ * @param themeKey The theme key to check
224
+ * @returns True if the theme key is a base theme key, false otherwise
216
225
  */
217
- export function requestParentThemeData() {
218
- return _requestParentThemeData.apply(this, arguments);
219
- }
220
- function _requestParentThemeData() {
221
- _requestParentThemeData = _asyncToGenerator(function* () {
222
- var result = yield requestParentResponse(PARENT_THEME_REQUEST);
223
- if (!isParentThemeData(result)) {
224
- throw new Error("Unexpected parent theme data response: ".concat(JSON.stringify(result)));
225
- }
226
- return result;
227
- });
228
- return _requestParentThemeData.apply(this, arguments);
229
- }
230
- export function isValidColorVar(name, value) {
231
- return DH_CSS_VAR_NAME_REGEXP.test(name) && CSS.supports('color', value);
226
+ export function isBaseThemeKey(themeKey) {
227
+ return [DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY].includes(themeKey);
232
228
  }
233
- export function parseParentThemeData(_ref3) {
234
- var {
235
- baseThemeKey = DEFAULT_DARK_THEME_KEY,
236
- name,
237
- cssVars
238
- } = _ref3;
239
- var toExpression = _ref4 => {
240
- var [varName, varValue] = _ref4;
241
- return isValidColorVar(varName, varValue) ? "".concat(varName, ":").concat(varValue) : null;
242
- };
243
- var sanitized = Object.entries(cssVars).map(toExpression).filter(str => str != null);
244
- var styleContent = ":root{".concat(sanitized.length === 0 ? '' : sanitized.join(';'), ";}");
245
- return {
246
- baseThemeKey,
247
- themeKey: PARENT_THEME_KEY,
248
- name,
249
- styleContent
250
- };
229
+
230
+ /**
231
+ * Determine if a given object is a `ExternalThemeData` object.
232
+ * @param maybeExternalThemeData An object that may or may not be a `ExternalThemeData`
233
+ * @returns True if the object is a `ExternalThemeData`, false otherwise
234
+ */
235
+ export function isExternalThemeData(maybeExternalThemeData) {
236
+ if (typeof maybeExternalThemeData !== 'object' || maybeExternalThemeData == null) {
237
+ return false;
238
+ }
239
+ return 'name' in maybeExternalThemeData && typeof maybeExternalThemeData.name === 'string' && 'cssVars' in maybeExternalThemeData && typeof maybeExternalThemeData.cssVars === 'object' && maybeExternalThemeData.cssVars != null;
251
240
  }
252
241
 
253
242
  /**
254
- * Check if the current URL specifies a parent theme key override.
255
- * @returns True if the parent theme key override is set, false otherwise
243
+ * Check if the current URL specifies an external theme key override.
244
+ * @returns True if the external theme key override is set, false otherwise
256
245
  */
257
- export function isParentThemeEnabled() {
246
+ export function isExternalThemeEnabled() {
258
247
  var searchParams = new URLSearchParams(window.location.search);
259
- return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM) === PARENT_THEME_KEY;
248
+ return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM) === EXTERNAL_THEME_KEY;
260
249
  }
261
250
 
262
251
  /**
@@ -270,24 +259,41 @@ export function isPreloadTransparentTheme() {
270
259
  }
271
260
 
272
261
  /**
273
- * Check if the given theme key is one of the base themes.
274
- * @param themeKey The theme key to check
275
- * @returns True if the theme key is a base theme key, false otherwise
262
+ * Validate that a given CSS variable name / value pair is a valid Deephaven
263
+ * color variable.
264
+ * @param name The name of the CSS variable to validate, e.g. '--dh-color-primary'
265
+ * @param value The value of the CSS color to validate
266
+ * @returns True if the name is a valid Deephaven color variable and the value
267
+ * is a valid CSS color, false otherwise
276
268
  */
277
- export function isBaseThemeKey(themeKey) {
278
- return [DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY].includes(themeKey);
269
+ export function isValidColorVar(name, value) {
270
+ return DH_CSS_VAR_NAME_REGEXP.test(name) && CSS.supports('color', value);
279
271
  }
280
272
 
281
273
  /**
282
- * Determine if a given object is a `ParentThemeData` object.
283
- * @param maybeParentThemeData An object that may or may not be a `ParentThemeData`
284
- * @returns True if the object is a `ParentThemeData`, false otherwise
274
+ * Parse external theme data into a `ThemeData` object. Invalid CSS color variable
275
+ * pairs are excluded from the resulting `ThemeData` object.
276
+ * @param externalThemeData The external theme data to parse
277
+ * @returns A `ThemeData` object representing the external theme
285
278
  */
286
- export function isParentThemeData(maybeParentThemeData) {
287
- if (typeof maybeParentThemeData !== 'object' || maybeParentThemeData == null) {
288
- return false;
289
- }
290
- return 'name' in maybeParentThemeData && typeof maybeParentThemeData.name === 'string' && 'cssVars' in maybeParentThemeData && maybeParentThemeData.cssVars != null;
279
+ export function parseExternalThemeData(_ref3) {
280
+ var {
281
+ baseThemeKey = DEFAULT_DARK_THEME_KEY,
282
+ name,
283
+ cssVars
284
+ } = _ref3;
285
+ var toExpression = _ref4 => {
286
+ var [varName, varValue] = _ref4;
287
+ return isValidColorVar(varName, varValue) ? "".concat(varName, ":").concat(varValue, ";") : null;
288
+ };
289
+ var sanitized = Object.entries(cssVars).map(toExpression).filter(str => str != null);
290
+ var styleContent = sanitized.length === 0 ? '' : ":root{".concat(sanitized.join(''), "}");
291
+ return {
292
+ baseThemeKey,
293
+ themeKey: EXTERNAL_THEME_KEY,
294
+ name,
295
+ styleContent
296
+ };
291
297
  }
292
298
 
293
299
  /**
@@ -300,6 +306,15 @@ export function replaceSVGFillColor(svgContent, fillColor) {
300
306
  return svgContent.replace(/fill='.*?'/, "fill='".concat(encodeURIComponent(fillColor), "'"));
301
307
  }
302
308
 
309
+ /**
310
+ * Request theme data from the parent window.
311
+ * @returns A promise that resolves to the external theme data
312
+ * @throws Error if the response is not a valid `ExternalThemeData`
313
+ */
314
+ export function requestExternalThemeData() {
315
+ return _requestExternalThemeData.apply(this, arguments);
316
+ }
317
+
303
318
  /**
304
319
  * Make a copy of the given object replacing any css variable expressions
305
320
  * contained in its prop values with values resolved from the given HTML element.
@@ -320,6 +335,16 @@ export function replaceSVGFillColor(svgContent, fillColor) {
320
335
  * @param isAlphaOptional If true, the alpha value will be dropped from resolved
321
336
  * 8 character hex colors if it is 'ff'. Defaults to false.
322
337
  */
338
+ function _requestExternalThemeData() {
339
+ _requestExternalThemeData = _asyncToGenerator(function* () {
340
+ var result = yield requestParentResponse(MSG_REQUEST_GET_THEME);
341
+ if (!isExternalThemeData(result)) {
342
+ throw new Error("Unexpected external theme data response: ".concat(JSON.stringify(result)));
343
+ }
344
+ return result;
345
+ });
346
+ return _requestExternalThemeData.apply(this, arguments);
347
+ }
323
348
  export function resolveCssVariablesInRecord(record) {
324
349
  var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.body;
325
350
  var isAlphaOptional = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -406,15 +431,6 @@ export function setThemePreloadData(preloadData) {
406
431
  localStorage.setItem(THEME_CACHE_LOCAL_STORAGE_KEY, JSON.stringify(preloadData));
407
432
  }
408
433
 
409
- /**
410
- * Derive unique theme key from plugin root path and theme name.
411
- * @param pluginName The root path of the plugin
412
- * @param themeName The name of the theme
413
- */
414
- export function getThemeKey(pluginName, themeName) {
415
- return "".concat(pluginName, "_").concat(themeName);
416
- }
417
-
418
434
  /**
419
435
  * Preload minimal theme variables from the cache.
420
436
  * @defaultPreloadValues Optional default values to use if a preload variable is not set.
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeUtils.js","names":["Log","assertNotNull","ColorUtils","requestParentResponse","themeDark","themeLight","DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","DEFAULT_PRELOAD_DATA_VARIABLES","THEME_CACHE_LOCAL_STORAGE_KEY","SVG_ICON_MANUAL_COLOR_MAP","THEME_KEY_OVERRIDE_QUERY_PARAM","PARENT_THEME_KEY","PARENT_THEME_REQUEST","TRANSPARENT_PRELOAD_DATA_VARIABLES","PRELOAD_TRANSPARENT_THEME_QUERY_PARAM","log","module","CSS_VAR_EXPRESSION_PREFIX","DH_VAR_PREFIX","TMP_CSS_PROP_PREFIX","NON_WHITESPACE_REGEX","WHITESPACE_REGEX","DH_CSS_VAR_NAME_REGEXP","calculatePreloadStyleContent","defaultPreloadValues","resolveVar","createCssVariableResolver","document","body","pairs","Object","keys","map","key","concat","join","el","defaultValues","computedStyle","getComputedStyle","cssVariableResolver","varName","_defaultValues","value","getPropertyValue","createPreloadStyleElement","id","preloadStyleContent","style","createElement","innerHTML","head","appendChild","extractDistinctCssVariableExpressions","record","set","Set","values","forEach","getExpressionRanges","_ref","start","end","expression","substring","includes","add","getActiveThemes","themeKey","themeRegistration","_custom$baseThemeKey","custom","find","theme","baseThemeKey","base","error","debug","getDefaultBaseThemes","name","styleContent","getDefaultSelectedThemeKey","_ref2","_getThemeKeyOverride","_getThemePreloadData","getThemeKeyOverride","getThemePreloadData","searchParams","URLSearchParams","window","location","search","get","data","localStorage","getItem","JSON","parse","_unused","_NON_WHITESPACE_REGEX","_NON_WHITESPACE_REGEX2","ranges","exec","index","parenLevel","i","length","test","push","requestParentThemeData","_requestParentThemeData","apply","arguments","_asyncToGenerator","result","isParentThemeData","Error","stringify","isValidColorVar","CSS","supports","parseParentThemeData","_ref3","cssVars","toExpression","_ref4","varValue","sanitized","entries","filter","str","isParentThemeEnabled","isPreloadTransparentTheme","isBaseThemeKey","maybeParentThemeData","replaceSVGFillColor","svgContent","fillColor","replace","encodeURIComponent","resolveCssVariablesInRecord","targetElement","undefined","isAlphaOptional","perfStart","performance","now","tmpPropEl","display","recordArray","_ref5","setProperty","backgroundColor","tempPropElComputedStyle","_ref6","resolved","containsCssVar","isColor","children","color","normalizeCssColor","remove","resolveCssVariablesInString","resolver","_ref7","setThemePreloadData","preloadData","setItem","getThemeKey","pluginName","themeName","preloadTheme","_getThemePreloadData2","previousPreloadStyleContent","defaultPreloadStyleContent","overrideSVGFillColors","_ref8","removeProperty","newSVGContent"],"sources":["../../src/theme/ThemeUtils.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport {\n assertNotNull,\n ColorUtils,\n requestParentResponse,\n} from '@deephaven/utils';\nimport { themeDark } from './theme-dark';\nimport { themeLight } from './theme-light';\nimport {\n DEFAULT_DARK_THEME_KEY,\n DEFAULT_LIGHT_THEME_KEY,\n DEFAULT_PRELOAD_DATA_VARIABLES,\n type BaseThemeKey,\n type ThemeData,\n type ThemePreloadData,\n type CssVariableStyleContent,\n type ThemePreloadColorVariable,\n type ThemeRegistrationData,\n THEME_CACHE_LOCAL_STORAGE_KEY,\n SVG_ICON_MANUAL_COLOR_MAP,\n type ThemeCssVariableName,\n type ThemeIconsRequiringManualColorChanges,\n THEME_KEY_OVERRIDE_QUERY_PARAM,\n PARENT_THEME_KEY,\n type ParentThemeData,\n PARENT_THEME_REQUEST,\n type ThemeCssColorVariableName,\n TRANSPARENT_PRELOAD_DATA_VARIABLES,\n PRELOAD_TRANSPARENT_THEME_QUERY_PARAM,\n} from './ThemeModel';\n\nconst log = Log.module('ThemeUtils');\n\nexport const CSS_VAR_EXPRESSION_PREFIX = 'var(--';\nexport const DH_VAR_PREFIX = '--dh-color-';\nexport const TMP_CSS_PROP_PREFIX = 'dh-tmp';\nexport const NON_WHITESPACE_REGEX = /\\S/;\nexport const WHITESPACE_REGEX = /\\s/;\n\nexport const DH_CSS_VAR_NAME_REGEXP = /^--dh-color-[a-z0-9_-]+$/;\n\nexport type VarExpressionResolver = (varExpression: string) => string;\n\n/**\n * Resolves the current values of CSS variables we want to preload. Preloading\n * happens before themes are fully loaded so that we can style things like the\n * loading spinner and background color which are shown to the user early on in\n * the app lifecycle.\n * @defaultPreloadValues Default values to use if a preload variable is not set.\n */\nexport function calculatePreloadStyleContent(\n defaultPreloadValues: Record<string, string>\n): CssVariableStyleContent {\n const resolveVar = createCssVariableResolver(\n document.body,\n defaultPreloadValues\n );\n\n // Calculate the current preload variables. If the variable is not set, use\n // the default value.\n const pairs = Object.keys(defaultPreloadValues).map(\n key => `${key}:${resolveVar(key as ThemePreloadColorVariable)}`\n );\n\n return `:root{${pairs.join(';')}}`;\n}\n\n/**\n * Create a resolver function for calculating the value of a css variable based\n * on a given element's computed style. If the variable resolves to '', we check\n * `defaultValues` for a default value, and if one does not exist,\n * return ''.\n * @param el Element to resolve css variables against\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function createCssVariableResolver(\n el: Element,\n defaultValues: Record<string, string>\n): (varName: ThemeCssVariableName) => string {\n const computedStyle = getComputedStyle(el);\n\n /**\n * Resolve the given css variable name to a value. If the variable is not set,\n * return the default preload value or '' if one does not exist.\n */\n return function cssVariableResolver(varName: ThemeCssVariableName): string {\n const value = computedStyle.getPropertyValue(varName);\n\n if (value !== '') {\n return value;\n }\n\n return defaultValues[varName as ThemePreloadColorVariable] ?? '';\n };\n}\n\n/**\n * Create a style tag containing preload css variables and add to the head.\n * @param id The id of the style tag\n * @param preloadStyleContent The css variable content to add to the style tag\n */\nexport function createPreloadStyleElement(\n id: `theme-preload-${string}`,\n preloadStyleContent: CssVariableStyleContent\n): void {\n const style = document.createElement('style');\n style.id = id;\n style.innerHTML = preloadStyleContent;\n document.head.appendChild(style);\n}\n\n/**\n * Extracts all css variable expressions from the given record and returns\n * a set of unique expressions.\n * @param record The record to extract css variable expressions from\n */\nexport function extractDistinctCssVariableExpressions(\n record: Record<string, string>\n): Set<string> {\n const set = new Set<string>();\n\n Object.values(record).forEach(value => {\n getExpressionRanges(value).forEach(([start, end]) => {\n const expression = value.substring(start, end + 1);\n\n if (expression.includes(CSS_VAR_EXPRESSION_PREFIX)) {\n set.add(expression);\n }\n });\n });\n\n return set;\n}\n\n/**\n * Returns an array of the active themes. The first item will always be one\n * of the base themes. Optionally, the second item will be a custom theme.\n */\nexport function getActiveThemes(\n themeKey: string,\n themeRegistration: ThemeRegistrationData\n): [ThemeData] | [ThemeData, ThemeData] {\n const custom = themeRegistration.custom.find(\n theme => theme.themeKey === themeKey\n );\n\n const baseThemeKey = custom?.baseThemeKey ?? themeKey;\n\n let base = themeRegistration.base.find(\n theme => theme.themeKey === baseThemeKey\n );\n\n if (base == null) {\n log.error(\n `No registered base theme found for theme key: '${baseThemeKey}'`,\n 'Registered:',\n themeRegistration.base.map(theme => theme.themeKey),\n themeRegistration.custom.map(theme => theme.themeKey)\n );\n base = themeRegistration.base.find(\n theme => theme.themeKey === DEFAULT_DARK_THEME_KEY\n );\n\n assertNotNull(\n base,\n `Default base theme '${DEFAULT_DARK_THEME_KEY}' is not registered`\n );\n }\n\n log.debug('Applied themes:', base.themeKey, custom?.themeKey);\n\n return custom == null ? [base] : [base, custom];\n}\n\n/**\n * Get default base theme data.\n */\nexport function getDefaultBaseThemes(): ThemeData[] {\n return [\n {\n name: 'Default Dark',\n themeKey: DEFAULT_DARK_THEME_KEY,\n styleContent: themeDark,\n },\n // The ThemePicker shows whenever more than 1 theme is available. Disable\n // light theme for now to keep the picker hidden until it is fully\n // implemented by #1539.\n {\n name: 'Default Light',\n themeKey: DEFAULT_LIGHT_THEME_KEY,\n styleContent: themeLight,\n },\n ];\n}\n\n/**\n * Get the default selected theme key. Precedence is:\n * 1. Theme key override query parameter\n * 2. Theme key from preload data\n * 3. Default dark theme key\n * @returns The default selected theme key\n */\nexport function getDefaultSelectedThemeKey(): string {\n return (\n getThemeKeyOverride() ??\n getThemePreloadData()?.themeKey ??\n DEFAULT_DARK_THEME_KEY\n );\n}\n\n/**\n * A theme key override can be set via a query parameter to force a specific\n * theme selection. Useful for embedded widget scenarios that don't expose the\n * theme selector.\n */\nexport function getThemeKeyOverride(): string | null {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM);\n}\n\n/**\n * Get the preload data from local storage or null if it does not exist or is\n * invalid\n */\nexport function getThemePreloadData(): ThemePreloadData | null {\n const data = localStorage.getItem(THEME_CACHE_LOCAL_STORAGE_KEY);\n\n try {\n return data == null ? null : JSON.parse(data);\n } catch {\n // ignore\n }\n\n return null;\n}\n\n/**\n * Identifies start and end indices of any top-level expressions in the given\n * string.\n *\n * e.g.\n * getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')\n * yields:\n * [\n * [0, 12], // 'var(--aaa-aa)'\n * [14, 17] // '#fff'\n * [19, 31], // 'var(--bbb-bb)'\n * ]\n *\n * In cases where there are nested expressions, only the indices of the outermost\n * expression will be included.\n *\n * e.g.\n * getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')\n * yields:\n * [\n * [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'\n * [36, 48], // 'var(--bbb-bb)'\n * ]\n * @param value The string to search for expressions\n * @returns An array of [start, end] index pairs for each expression\n */\nexport function getExpressionRanges(value: string): [number, number][] {\n const ranges: [number, number][] = [];\n\n let start = NON_WHITESPACE_REGEX.exec(value)?.index ?? 0;\n let parenLevel = 0;\n\n for (let i = 0; i < value.length; i += 1) {\n if (value[i] === '(') {\n parenLevel += 1;\n } else if (value[i] === ')') {\n parenLevel -= 1;\n }\n\n if (\n i === value.length - 1 ||\n (WHITESPACE_REGEX.test(value[i + 1]) && parenLevel === 0)\n ) {\n ranges.push([start, i]);\n\n while (i < value.length - 1 && WHITESPACE_REGEX.test(value[i + 1])) {\n i += 1;\n }\n\n start = i + 1;\n }\n }\n\n if (parenLevel !== 0) {\n log.error('Unbalanced parentheses in css var expression', value);\n return [];\n }\n\n return ranges;\n}\n\n/**\n * Request parent theme data from the parent window.\n * @returns A promise that resolves to the parent theme data\n * @throws Error if the response is not a valid `ParentThemeData`\n */\nexport async function requestParentThemeData(): Promise<ParentThemeData> {\n const result = await requestParentResponse(PARENT_THEME_REQUEST);\n\n if (!isParentThemeData(result)) {\n throw new Error(\n `Unexpected parent theme data response: ${JSON.stringify(result)}`\n );\n }\n\n return result;\n}\n\nexport function isValidColorVar(\n name: string,\n value: string\n): name is ThemeCssColorVariableName {\n return DH_CSS_VAR_NAME_REGEXP.test(name) && CSS.supports('color', value);\n}\n\nexport function parseParentThemeData({\n baseThemeKey = DEFAULT_DARK_THEME_KEY,\n name,\n cssVars,\n}: ParentThemeData): ThemeData {\n const toExpression = ([varName, varValue]: [string, string]) =>\n isValidColorVar(varName, varValue) ? `${varName}:${varValue}` : null;\n\n const sanitized = Object.entries(cssVars)\n .map(toExpression)\n .filter((str): str is string => str != null);\n\n const styleContent = `:root{${\n sanitized.length === 0 ? '' : sanitized.join(';')\n };}`;\n\n return {\n baseThemeKey,\n themeKey: PARENT_THEME_KEY,\n name,\n styleContent,\n };\n}\n\n/**\n * Check if the current URL specifies a parent theme key override.\n * @returns True if the parent theme key override is set, false otherwise\n */\nexport function isParentThemeEnabled(): boolean {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM) === PARENT_THEME_KEY;\n}\n\n/**\n * Check if PRELOAD_TRANSPARENT_THEME_QUERY_PARAM query parameter is set to true.\n * @returns True if the preload transparent theme query parameter is set, false\n * otherwise\n */\nexport function isPreloadTransparentTheme(): boolean {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(PRELOAD_TRANSPARENT_THEME_QUERY_PARAM) === 'true';\n}\n\n/**\n * Check if the given theme key is one of the base themes.\n * @param themeKey The theme key to check\n * @returns True if the theme key is a base theme key, false otherwise\n */\nexport function isBaseThemeKey(themeKey: string): themeKey is BaseThemeKey {\n return [DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY].includes(themeKey);\n}\n\n/**\n * Determine if a given object is a `ParentThemeData` object.\n * @param maybeParentThemeData An object that may or may not be a `ParentThemeData`\n * @returns True if the object is a `ParentThemeData`, false otherwise\n */\nexport function isParentThemeData(\n maybeParentThemeData: unknown\n): maybeParentThemeData is ParentThemeData {\n if (\n typeof maybeParentThemeData !== 'object' ||\n maybeParentThemeData == null\n ) {\n return false;\n }\n\n return (\n 'name' in maybeParentThemeData &&\n typeof maybeParentThemeData.name === 'string' &&\n 'cssVars' in maybeParentThemeData &&\n maybeParentThemeData.cssVars != null\n );\n}\n\n/**\n * Replace the `fill='...'` attribute in the given SVG content with the given\n * color string.\n * @param svgContent Inline SVG content to replace the fill color in\n * @param fillColor The color to replace the fill color with\n */\nexport function replaceSVGFillColor(\n svgContent: string,\n fillColor: string\n): string {\n return svgContent.replace(\n /fill='.*?'/,\n `fill='${encodeURIComponent(fillColor)}'`\n );\n}\n\n/**\n * Make a copy of the given object replacing any css variable expressions\n * contained in its prop values with values resolved from the given HTML element.\n * Variables that resolve to color strings will also be normalized to 8 digit\n * hex values (or optionally 6 digit hex if `isAlphaOptional` is true).\n *\n * Note that the browser will force a reflow when calling `getComputedStyle` if\n * css properties have changed. In order to avoid a reflow for every property\n * check we use distinct setup, resolve / normalize, and cleanup passes:\n * 1. Setup - Create a tmp element and set all css props we want to evaluate\n * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls\n * and replace the original expressions with resolved values. Also normalize\n * css colors to rgb/a.\n * 3. Cleanup - Remove the tmp element\n * @param record An object whose values may contain css var expressions\n * @param targetElement The element to resolve css variables against. Defaults\n * to document.body\n * @param isAlphaOptional If true, the alpha value will be dropped from resolved\n * 8 character hex colors if it is 'ff'. Defaults to false.\n */\nexport function resolveCssVariablesInRecord<T extends Record<string, string>>(\n record: T,\n targetElement: HTMLElement = document.body,\n isAlphaOptional = false\n): T {\n const perfStart = performance.now();\n\n // Add a temporary div to attach temp css variables to\n const tmpPropEl = document.createElement('div');\n tmpPropEl.style.display = 'none';\n\n const recordArray = Object.entries(record);\n recordArray.forEach(([, value], i) => {\n tmpPropEl.style.setProperty(`--${TMP_CSS_PROP_PREFIX}-${i}`, value);\n // faster to create these now all at once, even if we don't use them all\n // since the parent isn't added yet to the DOM\n const el = document.createElement('div');\n // use background color instead of color to avoid inherited values\n el.style.backgroundColor = value;\n tmpPropEl.appendChild(el);\n });\n\n // append only once to avoid multiple re-layouts\n // must be part of DOM to get computed color\n targetElement.appendChild(tmpPropEl);\n const tempPropElComputedStyle = window.getComputedStyle(tmpPropEl);\n\n const result = {} as T;\n recordArray.forEach(([key, value], i) => {\n // resolves any variables in the expression\n let resolved = tempPropElComputedStyle.getPropertyValue(\n `--${TMP_CSS_PROP_PREFIX}-${i}`\n );\n\n const containsCssVar = value.includes(CSS_VAR_EXPRESSION_PREFIX);\n const isColor = CSS.supports('color', resolved);\n\n if (\n // only try to normalize non-hex strings that are valid colors\n // otherwise non-colors will be made #00000000\n isColor &&\n !/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(resolved)\n ) {\n // getting the computed background color is necessary\n // because resolved can still contain a color-mix() function\n const el = tmpPropEl.children[i] as HTMLDivElement;\n const computedStyle = window.getComputedStyle(el);\n const color = computedStyle.getPropertyValue('background-color');\n // convert color to hex, which is what monaco and plotly require\n resolved = ColorUtils.normalizeCssColor(color, isAlphaOptional);\n }\n (result as Record<string, string>)[key] =\n containsCssVar || isColor ? resolved : value;\n });\n\n // Remove the temporary div\n tmpPropEl.remove();\n\n log.debug('Resolved css variables', performance.now() - perfStart, 'ms');\n\n return result;\n}\n\n/**\n * Resolve css variable expressions in the given string using the\n * given resolver and replace the original expressions with the resolved values.\n *\n * @param resolver Function that can resolve a css variable expression\n * @param value Value that may contain css variable expressions\n */\nexport function resolveCssVariablesInString(\n resolver: VarExpressionResolver,\n value: string\n): string {\n const result: string[] = [];\n let i = 0;\n getExpressionRanges(value).forEach(([start, end]) => {\n if (i < start) {\n result.push(value.substring(i, start));\n i += start - i;\n }\n\n const expression = value.substring(start, end + 1);\n\n result.push(\n expression.includes(CSS_VAR_EXPRESSION_PREFIX)\n ? resolver(expression)\n : expression\n );\n\n i += end - start + 1;\n });\n\n if (result.length === 0) {\n return value;\n }\n\n return result.join('');\n}\n\n/**\n * Store theme preload data in local storage.\n * @param preloadData The preload data to set\n */\nexport function setThemePreloadData(preloadData: ThemePreloadData): void {\n localStorage.setItem(\n THEME_CACHE_LOCAL_STORAGE_KEY,\n JSON.stringify(preloadData)\n );\n}\n\n/**\n * Derive unique theme key from plugin root path and theme name.\n * @param pluginName The root path of the plugin\n * @param themeName The name of the theme\n */\nexport function getThemeKey(pluginName: string, themeName: string): string {\n return `${pluginName}_${themeName}`;\n}\n\n/**\n * Preload minimal theme variables from the cache.\n * @defaultPreloadValues Optional default values to use if a preload variable is not set.\n */\nexport function preloadTheme(\n defaultPreloadValues: Record<string, string> = DEFAULT_PRELOAD_DATA_VARIABLES\n): void {\n // In certain cases we may want to preload a transparent theme to allow the\n // parent container to show through. For example, when a parent Window is\n // providing a theme via `postMessage` apis, we may not have enough information\n // to properly preload the theme, so we can just preload a transparent\n // theme and let the parent container show through until `postMessage`\n // communication is complete.\n if (isPreloadTransparentTheme()) {\n createPreloadStyleElement(\n 'theme-preload-transparent',\n calculatePreloadStyleContent(TRANSPARENT_PRELOAD_DATA_VARIABLES)\n );\n return;\n }\n\n const previousPreloadStyleContent =\n getThemePreloadData()?.preloadStyleContent;\n\n const defaultPreloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug('Preloading theme content:', {\n defaultPreloadStyleContent,\n previousPreloadStyleContent,\n });\n\n createPreloadStyleElement(\n 'theme-preload-defaults',\n defaultPreloadStyleContent\n );\n\n // Any preload variables that were saved by last theme load should override\n // the defaults\n if (previousPreloadStyleContent != null) {\n createPreloadStyleElement(\n 'theme-preload-previous',\n previousPreloadStyleContent\n );\n }\n}\n\n/**\n * Inline SVGs cannot depend on dynamic CSS variables, so we have to statically\n * update them if we want to change their color.\n *\n * This function:\n * 1. Clears any previous overrides\n * 2. Resolves CSS variables containing inline SVG urls\n * 3. Resolves mapped color variables and replaces the `fill='...'` attribute with the result\n * 4. Sets the original CSS variable to the new replaced value\n *\n * Note that it is preferable to use inline SVGs as background-mask values and\n * just change the background color instead of relying on this util, but this\n * is not always possible. e.g. <select> elements don't support pseudo elements,\n * so there's not a good way to set icons via masks.\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function overrideSVGFillColors(\n defaultValues: Record<string, string>\n): void {\n const resolveVar = createCssVariableResolver(document.body, defaultValues);\n\n Object.entries(SVG_ICON_MANUAL_COLOR_MAP).forEach(([key, value]) => {\n // Clear any previous override so that our variables get resolved against the\n // actual svg content provided by the active themes and not from a previous\n // override\n document.body.style.removeProperty(key);\n\n const svgContent = resolveVar(key as ThemeIconsRequiringManualColorChanges);\n const fillColor = resolveVar(value as ThemePreloadColorVariable);\n\n const newSVGContent = replaceSVGFillColor(svgContent, fillColor);\n\n // This will take precedence over any values for the variable provided by\n // the active themes\n document.body.style.setProperty(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AS,GAAGhH,UAAU,CAACkB,KAAkC,CAAC;IAEhE,IAAMuI,aAAa,GAAG3C,mBAAmB,CAACC,UAAU,EAAEC,SAAS,CAAC;;IAEhE;IACA;IACA9G,QAAQ,CAACC,IAAI,CAACoB,KAAK,CAACuG,WAAW,CAACtH,GAAG,EAAEiJ,aAAa,CAAC;EACrD,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"ThemeUtils.js","names":["Log","assertNotNull","ColorUtils","requestParentResponse","themeDark","themeLight","DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","DEFAULT_PRELOAD_DATA_VARIABLES","THEME_CACHE_LOCAL_STORAGE_KEY","SVG_ICON_MANUAL_COLOR_MAP","THEME_KEY_OVERRIDE_QUERY_PARAM","EXTERNAL_THEME_KEY","MSG_REQUEST_GET_THEME","TRANSPARENT_PRELOAD_DATA_VARIABLES","PRELOAD_TRANSPARENT_THEME_QUERY_PARAM","log","module","CSS_VAR_EXPRESSION_PREFIX","DH_VAR_PREFIX","TMP_CSS_PROP_PREFIX","NON_WHITESPACE_REGEX","WHITESPACE_REGEX","DH_CSS_VAR_NAME_REGEXP","calculatePreloadStyleContent","defaultPreloadValues","resolveVar","createCssVariableResolver","document","body","pairs","Object","keys","map","key","concat","join","el","defaultValues","computedStyle","getComputedStyle","cssVariableResolver","varName","_defaultValues","value","getPropertyValue","createPreloadStyleElement","id","preloadStyleContent","style","createElement","innerHTML","head","appendChild","extractDistinctCssVariableExpressions","record","set","Set","values","forEach","getExpressionRanges","_ref","start","end","expression","substring","includes","add","getActiveThemes","themeKey","themeRegistration","_custom$baseThemeKey","custom","find","theme","baseThemeKey","base","error","debug","getDefaultBaseThemes","name","styleContent","getDefaultSelectedThemeKey","_ref2","_getThemeKeyOverride","_getThemePreloadData","getThemeKeyOverride","getThemePreloadData","getThemeKey","pluginName","themeName","searchParams","URLSearchParams","window","location","search","get","data","localStorage","getItem","JSON","parse","_unused","_NON_WHITESPACE_REGEX","_NON_WHITESPACE_REGEX2","ranges","exec","index","parenLevel","i","length","test","push","isBaseThemeKey","isExternalThemeData","maybeExternalThemeData","cssVars","isExternalThemeEnabled","isPreloadTransparentTheme","isValidColorVar","CSS","supports","parseExternalThemeData","_ref3","toExpression","_ref4","varValue","sanitized","entries","filter","str","replaceSVGFillColor","svgContent","fillColor","replace","encodeURIComponent","requestExternalThemeData","_requestExternalThemeData","apply","arguments","_asyncToGenerator","result","Error","stringify","resolveCssVariablesInRecord","targetElement","undefined","isAlphaOptional","perfStart","performance","now","tmpPropEl","display","recordArray","_ref5","setProperty","backgroundColor","tempPropElComputedStyle","_ref6","resolved","containsCssVar","isColor","children","color","normalizeCssColor","remove","resolveCssVariablesInString","resolver","_ref7","setThemePreloadData","preloadData","setItem","preloadTheme","_getThemePreloadData2","previousPreloadStyleContent","defaultPreloadStyleContent","overrideSVGFillColors","_ref8","removeProperty","newSVGContent"],"sources":["../../src/theme/ThemeUtils.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport {\n assertNotNull,\n ColorUtils,\n requestParentResponse,\n} from '@deephaven/utils';\nimport { themeDark } from './theme-dark';\nimport { themeLight } from './theme-light';\nimport {\n DEFAULT_DARK_THEME_KEY,\n DEFAULT_LIGHT_THEME_KEY,\n DEFAULT_PRELOAD_DATA_VARIABLES,\n type BaseThemeKey,\n type ThemeData,\n type ThemePreloadData,\n type CssVariableStyleContent,\n type ThemePreloadColorVariable,\n type ThemeRegistrationData,\n THEME_CACHE_LOCAL_STORAGE_KEY,\n SVG_ICON_MANUAL_COLOR_MAP,\n type ThemeCssVariableName,\n type ThemeIconsRequiringManualColorChanges,\n THEME_KEY_OVERRIDE_QUERY_PARAM,\n EXTERNAL_THEME_KEY,\n type ExternalThemeData,\n MSG_REQUEST_GET_THEME,\n type ThemeCssColorVariableName,\n TRANSPARENT_PRELOAD_DATA_VARIABLES,\n PRELOAD_TRANSPARENT_THEME_QUERY_PARAM,\n} from './ThemeModel';\n\nconst log = Log.module('ThemeUtils');\n\nexport const CSS_VAR_EXPRESSION_PREFIX = 'var(--';\nexport const DH_VAR_PREFIX = '--dh-color-';\nexport const TMP_CSS_PROP_PREFIX = 'dh-tmp';\nexport const NON_WHITESPACE_REGEX = /\\S/;\nexport const WHITESPACE_REGEX = /\\s/;\n\nexport const DH_CSS_VAR_NAME_REGEXP = /^--dh-color-[a-z0-9_-]+$/;\n\nexport type VarExpressionResolver = (varExpression: string) => string;\n\n/**\n * Resolves the current values of CSS variables we want to preload. Preloading\n * happens before themes are fully loaded so that we can style things like the\n * loading spinner and background color which are shown to the user early on in\n * the app lifecycle.\n * @defaultPreloadValues Default values to use if a preload variable is not set.\n */\nexport function calculatePreloadStyleContent(\n defaultPreloadValues: Record<string, string>\n): CssVariableStyleContent {\n const resolveVar = createCssVariableResolver(\n document.body,\n defaultPreloadValues\n );\n\n // Calculate the current preload variables. If the variable is not set, use\n // the default value.\n const pairs = Object.keys(defaultPreloadValues).map(\n key => `${key}:${resolveVar(key as ThemePreloadColorVariable)}`\n );\n\n return `:root{${pairs.join(';')}}`;\n}\n\n/**\n * Create a resolver function for calculating the value of a css variable based\n * on a given element's computed style. If the variable resolves to '', we check\n * `defaultValues` for a default value, and if one does not exist,\n * return ''.\n * @param el Element to resolve css variables against\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function createCssVariableResolver(\n el: Element,\n defaultValues: Record<string, string>\n): (varName: ThemeCssVariableName) => string {\n const computedStyle = getComputedStyle(el);\n\n /**\n * Resolve the given css variable name to a value. If the variable is not set,\n * return the default preload value or '' if one does not exist.\n */\n return function cssVariableResolver(varName: ThemeCssVariableName): string {\n const value = computedStyle.getPropertyValue(varName);\n\n if (value !== '') {\n return value;\n }\n\n return defaultValues[varName as ThemePreloadColorVariable] ?? '';\n };\n}\n\n/**\n * Create a style tag containing preload css variables and add to the head.\n * @param id The id of the style tag\n * @param preloadStyleContent The css variable content to add to the style tag\n */\nexport function createPreloadStyleElement(\n id: `theme-preload-${string}`,\n preloadStyleContent: CssVariableStyleContent\n): void {\n const style = document.createElement('style');\n style.id = id;\n style.innerHTML = preloadStyleContent;\n document.head.appendChild(style);\n}\n\n/**\n * Extracts all css variable expressions from the given record and returns\n * a set of unique expressions.\n * @param record The record to extract css variable expressions from\n */\nexport function extractDistinctCssVariableExpressions(\n record: Record<string, string>\n): Set<string> {\n const set = new Set<string>();\n\n Object.values(record).forEach(value => {\n getExpressionRanges(value).forEach(([start, end]) => {\n const expression = value.substring(start, end + 1);\n\n if (expression.includes(CSS_VAR_EXPRESSION_PREFIX)) {\n set.add(expression);\n }\n });\n });\n\n return set;\n}\n\n/**\n * Returns an array of the active themes. The first item will always be one\n * of the base themes. Optionally, the second item will be a custom theme.\n */\nexport function getActiveThemes(\n themeKey: string,\n themeRegistration: ThemeRegistrationData\n): [ThemeData] | [ThemeData, ThemeData] {\n const custom = themeRegistration.custom.find(\n theme => theme.themeKey === themeKey\n );\n\n const baseThemeKey = custom?.baseThemeKey ?? themeKey;\n\n let base = themeRegistration.base.find(\n theme => theme.themeKey === baseThemeKey\n );\n\n if (base == null) {\n log.error(\n `No registered base theme found for theme key: '${baseThemeKey}'`,\n 'Registered:',\n themeRegistration.base.map(theme => theme.themeKey),\n themeRegistration.custom.map(theme => theme.themeKey)\n );\n base = themeRegistration.base.find(\n theme => theme.themeKey === DEFAULT_DARK_THEME_KEY\n );\n\n assertNotNull(\n base,\n `Default base theme '${DEFAULT_DARK_THEME_KEY}' is not registered`\n );\n }\n\n log.debug('Applied themes:', base.themeKey, custom?.themeKey);\n\n return custom == null ? [base] : [base, custom];\n}\n\n/**\n * Get default base theme data.\n */\nexport function getDefaultBaseThemes(): ThemeData[] {\n return [\n {\n name: 'Default Dark',\n themeKey: DEFAULT_DARK_THEME_KEY,\n styleContent: themeDark,\n },\n // The ThemePicker shows whenever more than 1 theme is available. Disable\n // light theme for now to keep the picker hidden until it is fully\n // implemented by #1539.\n {\n name: 'Default Light',\n themeKey: DEFAULT_LIGHT_THEME_KEY,\n styleContent: themeLight,\n },\n ];\n}\n\n/**\n * Get the default selected theme key. Precedence is:\n * 1. Theme key override query parameter\n * 2. Theme key from preload data\n * 3. Default dark theme key\n * @returns The default selected theme key\n */\nexport function getDefaultSelectedThemeKey(): string {\n return (\n getThemeKeyOverride() ??\n getThemePreloadData()?.themeKey ??\n DEFAULT_DARK_THEME_KEY\n );\n}\n\n/**\n * Derive unique theme key from plugin root path and theme name.\n * @param pluginName The root path of the plugin\n * @param themeName The name of the theme\n */\nexport function getThemeKey(pluginName: string, themeName: string): string {\n return `${pluginName}_${themeName}`;\n}\n\n/**\n * A theme key override can be set via a query parameter to force a specific\n * theme selection. Useful for embedded widget scenarios that don't expose the\n * theme selector.\n */\nexport function getThemeKeyOverride(): string | null {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM);\n}\n\n/**\n * Get the preload data from local storage or null if it does not exist or is\n * invalid\n */\nexport function getThemePreloadData(): ThemePreloadData | null {\n const data = localStorage.getItem(THEME_CACHE_LOCAL_STORAGE_KEY);\n\n try {\n return data == null ? null : JSON.parse(data);\n } catch {\n // ignore\n }\n\n return null;\n}\n\n/**\n * Identifies start and end indices of any top-level expressions in the given\n * string.\n *\n * e.g.\n * getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')\n * yields:\n * [\n * [0, 12], // 'var(--aaa-aa)'\n * [14, 17] // '#fff'\n * [19, 31], // 'var(--bbb-bb)'\n * ]\n *\n * In cases where there are nested expressions, only the indices of the outermost\n * expression will be included.\n *\n * e.g.\n * getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')\n * yields:\n * [\n * [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'\n * [36, 48], // 'var(--bbb-bb)'\n * ]\n * @param value The string to search for expressions\n * @returns An array of [start, end] index pairs for each expression\n */\nexport function getExpressionRanges(value: string): [number, number][] {\n const ranges: [number, number][] = [];\n\n let start = NON_WHITESPACE_REGEX.exec(value)?.index ?? 0;\n let parenLevel = 0;\n\n for (let i = 0; i < value.length; i += 1) {\n if (value[i] === '(') {\n parenLevel += 1;\n } else if (value[i] === ')') {\n parenLevel -= 1;\n }\n\n if (\n i === value.length - 1 ||\n (WHITESPACE_REGEX.test(value[i + 1]) && parenLevel === 0)\n ) {\n ranges.push([start, i]);\n\n while (i < value.length - 1 && WHITESPACE_REGEX.test(value[i + 1])) {\n i += 1;\n }\n\n start = i + 1;\n }\n }\n\n if (parenLevel !== 0) {\n log.error('Unbalanced parentheses in css var expression', value);\n return [];\n }\n\n return ranges;\n}\n\n/**\n * Check if the given theme key is one of the base themes.\n * @param themeKey The theme key to check\n * @returns True if the theme key is a base theme key, false otherwise\n */\nexport function isBaseThemeKey(themeKey: string): themeKey is BaseThemeKey {\n return [DEFAULT_DARK_THEME_KEY, DEFAULT_LIGHT_THEME_KEY].includes(themeKey);\n}\n\n/**\n * Determine if a given object is a `ExternalThemeData` object.\n * @param maybeExternalThemeData An object that may or may not be a `ExternalThemeData`\n * @returns True if the object is a `ExternalThemeData`, false otherwise\n */\nexport function isExternalThemeData(\n maybeExternalThemeData: unknown\n): maybeExternalThemeData is ExternalThemeData {\n if (\n typeof maybeExternalThemeData !== 'object' ||\n maybeExternalThemeData == null\n ) {\n return false;\n }\n\n return (\n 'name' in maybeExternalThemeData &&\n typeof maybeExternalThemeData.name === 'string' &&\n 'cssVars' in maybeExternalThemeData &&\n typeof maybeExternalThemeData.cssVars === 'object' &&\n maybeExternalThemeData.cssVars != null\n );\n}\n\n/**\n * Check if the current URL specifies an external theme key override.\n * @returns True if the external theme key override is set, false otherwise\n */\nexport function isExternalThemeEnabled(): boolean {\n const searchParams = new URLSearchParams(window.location.search);\n return (\n searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM) === EXTERNAL_THEME_KEY\n );\n}\n\n/**\n * Check if PRELOAD_TRANSPARENT_THEME_QUERY_PARAM query parameter is set to true.\n * @returns True if the preload transparent theme query parameter is set, false\n * otherwise\n */\nexport function isPreloadTransparentTheme(): boolean {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(PRELOAD_TRANSPARENT_THEME_QUERY_PARAM) === 'true';\n}\n\n/**\n * Validate that a given CSS variable name / value pair is a valid Deephaven\n * color variable.\n * @param name The name of the CSS variable to validate, e.g. '--dh-color-primary'\n * @param value The value of the CSS color to validate\n * @returns True if the name is a valid Deephaven color variable and the value\n * is a valid CSS color, false otherwise\n */\nexport function isValidColorVar(\n name: string,\n value: string\n): name is ThemeCssColorVariableName {\n return DH_CSS_VAR_NAME_REGEXP.test(name) && CSS.supports('color', value);\n}\n\n/**\n * Parse external theme data into a `ThemeData` object. Invalid CSS color variable\n * pairs are excluded from the resulting `ThemeData` object.\n * @param externalThemeData The external theme data to parse\n * @returns A `ThemeData` object representing the external theme\n */\nexport function parseExternalThemeData({\n baseThemeKey = DEFAULT_DARK_THEME_KEY,\n name,\n cssVars,\n}: ExternalThemeData): ThemeData {\n const toExpression = ([varName, varValue]: [string, string]) =>\n isValidColorVar(varName, varValue) ? `${varName}:${varValue};` : null;\n\n const sanitized = Object.entries(cssVars)\n .map(toExpression)\n .filter((str): str is string => str != null);\n\n const styleContent =\n sanitized.length === 0 ? '' : `:root{${sanitized.join('')}}`;\n\n return {\n baseThemeKey,\n themeKey: EXTERNAL_THEME_KEY,\n name,\n styleContent,\n };\n}\n\n/**\n * Replace the `fill='...'` attribute in the given SVG content with the given\n * color string.\n * @param svgContent Inline SVG content to replace the fill color in\n * @param fillColor The color to replace the fill color with\n */\nexport function replaceSVGFillColor(\n svgContent: string,\n fillColor: string\n): string {\n return svgContent.replace(\n /fill='.*?'/,\n `fill='${encodeURIComponent(fillColor)}'`\n );\n}\n\n/**\n * Request theme data from the parent window.\n * @returns A promise that resolves to the external theme data\n * @throws Error if the response is not a valid `ExternalThemeData`\n */\nexport async function requestExternalThemeData(): Promise<ExternalThemeData> {\n const result = await requestParentResponse(MSG_REQUEST_GET_THEME);\n\n if (!isExternalThemeData(result)) {\n throw new Error(\n `Unexpected external theme data response: ${JSON.stringify(result)}`\n );\n }\n\n return result;\n}\n\n/**\n * Make a copy of the given object replacing any css variable expressions\n * contained in its prop values with values resolved from the given HTML element.\n * Variables that resolve to color strings will also be normalized to 8 digit\n * hex values (or optionally 6 digit hex if `isAlphaOptional` is true).\n *\n * Note that the browser will force a reflow when calling `getComputedStyle` if\n * css properties have changed. In order to avoid a reflow for every property\n * check we use distinct setup, resolve / normalize, and cleanup passes:\n * 1. Setup - Create a tmp element and set all css props we want to evaluate\n * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls\n * and replace the original expressions with resolved values. Also normalize\n * css colors to rgb/a.\n * 3. Cleanup - Remove the tmp element\n * @param record An object whose values may contain css var expressions\n * @param targetElement The element to resolve css variables against. Defaults\n * to document.body\n * @param isAlphaOptional If true, the alpha value will be dropped from resolved\n * 8 character hex colors if it is 'ff'. Defaults to false.\n */\nexport function resolveCssVariablesInRecord<T extends Record<string, string>>(\n record: T,\n targetElement: HTMLElement = document.body,\n isAlphaOptional = false\n): T {\n const perfStart = performance.now();\n\n // Add a temporary div to attach temp css variables to\n const tmpPropEl = document.createElement('div');\n tmpPropEl.style.display = 'none';\n\n const recordArray = Object.entries(record);\n recordArray.forEach(([, value], i) => {\n tmpPropEl.style.setProperty(`--${TMP_CSS_PROP_PREFIX}-${i}`, value);\n // faster to create these now all at once, even if we don't use them all\n // since the parent isn't added yet to the DOM\n const el = document.createElement('div');\n // use background color instead of color to avoid inherited values\n el.style.backgroundColor = value;\n tmpPropEl.appendChild(el);\n });\n\n // append only once to avoid multiple re-layouts\n // must be part of DOM to get computed color\n targetElement.appendChild(tmpPropEl);\n const tempPropElComputedStyle = window.getComputedStyle(tmpPropEl);\n\n const result = {} as T;\n recordArray.forEach(([key, value], i) => {\n // resolves any variables in the expression\n let resolved = tempPropElComputedStyle.getPropertyValue(\n `--${TMP_CSS_PROP_PREFIX}-${i}`\n );\n\n const containsCssVar = value.includes(CSS_VAR_EXPRESSION_PREFIX);\n const isColor = CSS.supports('color', resolved);\n\n if (\n // only try to normalize non-hex strings that are valid colors\n // otherwise non-colors will be made #00000000\n isColor &&\n !/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(resolved)\n ) {\n // getting the computed background color is necessary\n // because resolved can still contain a color-mix() function\n const el = tmpPropEl.children[i] as HTMLDivElement;\n const computedStyle = window.getComputedStyle(el);\n const color = computedStyle.getPropertyValue('background-color');\n // convert color to hex, which is what monaco and plotly require\n resolved = ColorUtils.normalizeCssColor(color, isAlphaOptional);\n }\n (result as Record<string, string>)[key] =\n containsCssVar || isColor ? resolved : value;\n });\n\n // Remove the temporary div\n tmpPropEl.remove();\n\n log.debug('Resolved css variables', performance.now() - perfStart, 'ms');\n\n return result;\n}\n\n/**\n * Resolve css variable expressions in the given string using the\n * given resolver and replace the original expressions with the resolved values.\n *\n * @param resolver Function that can resolve a css variable expression\n * @param value Value that may contain css variable expressions\n */\nexport function resolveCssVariablesInString(\n resolver: VarExpressionResolver,\n value: string\n): string {\n const result: string[] = [];\n let i = 0;\n getExpressionRanges(value).forEach(([start, end]) => {\n if (i < start) {\n result.push(value.substring(i, start));\n i += start - i;\n }\n\n const expression = value.substring(start, end + 1);\n\n result.push(\n expression.includes(CSS_VAR_EXPRESSION_PREFIX)\n ? resolver(expression)\n : expression\n );\n\n i += end - start + 1;\n });\n\n if (result.length === 0) {\n return value;\n }\n\n return result.join('');\n}\n\n/**\n * Store theme preload data in local storage.\n * @param preloadData The preload data to set\n */\nexport function setThemePreloadData(preloadData: ThemePreloadData): void {\n localStorage.setItem(\n THEME_CACHE_LOCAL_STORAGE_KEY,\n JSON.stringify(preloadData)\n );\n}\n\n/**\n * Preload minimal theme variables from the cache.\n * @defaultPreloadValues Optional default values to use if a preload variable is not set.\n */\nexport function preloadTheme(\n defaultPreloadValues: Record<string, string> = DEFAULT_PRELOAD_DATA_VARIABLES\n): void {\n // In certain cases we may want to preload a transparent theme to allow the\n // parent container to show through. For example, when a parent Window is\n // providing a theme via `postMessage` apis, we may not have enough information\n // to properly preload the theme, so we can just preload a transparent\n // theme and let the parent container show through until `postMessage`\n // communication is complete.\n if (isPreloadTransparentTheme()) {\n createPreloadStyleElement(\n 'theme-preload-transparent',\n calculatePreloadStyleContent(TRANSPARENT_PRELOAD_DATA_VARIABLES)\n );\n return;\n }\n\n const previousPreloadStyleContent =\n getThemePreloadData()?.preloadStyleContent;\n\n const defaultPreloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug('Preloading theme content:', {\n defaultPreloadStyleContent,\n previousPreloadStyleContent,\n });\n\n createPreloadStyleElement(\n 'theme-preload-defaults',\n defaultPreloadStyleContent\n );\n\n // Any preload variables that were saved by last theme load should override\n // the defaults\n if (previousPreloadStyleContent != null) {\n createPreloadStyleElement(\n 'theme-preload-previous',\n previousPreloadStyleContent\n );\n }\n}\n\n/**\n * Inline SVGs cannot depend on dynamic CSS variables, so we have to statically\n * update them if we want to change their color.\n *\n * This function:\n * 1. Clears any previous overrides\n * 2. Resolves CSS variables containing inline SVG urls\n * 3. Resolves mapped color variables and replaces the `fill='...'` attribute with the result\n * 4. Sets the original CSS variable to the new replaced value\n *\n * Note that it is preferable to use inline SVGs as background-mask values and\n * just change the background color instead of relying on this util, but this\n * is not always possible. e.g. <select> elements don't support pseudo elements,\n * so there's not a good way to set icons via masks.\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function overrideSVGFillColors(\n defaultValues: Record<string, string>\n): void {\n const resolveVar = createCssVariableResolver(document.body, defaultValues);\n\n Object.entries(SVG_ICON_MANUAL_COLOR_MAP).forEach(([key, value]) => {\n // Clear any previous override so that our variables get resolved against the\n // actual svg content provided by the active themes and not from a previous\n // override\n document.body.style.removeProperty(key);\n\n const svgContent = resolveVar(key as ThemeIconsRequiringManualColorChanges);\n const fillColor = resolveVar(value as ThemePreloadColorVariable);\n\n const newSVGContent = replaceSVGFillColor(svgContent, fillColor);\n\n // This will take precedence over any values for the variable provided by\n // the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AAQ,CAACC,IAAI,CAACoB,KAAK,CAACiI,cAAc,CAAChJ,GAAG,CAAC;IAEvC,IAAMkG,UAAU,GAAG1G,UAAU,CAACQ,GAA4C,CAAC;IAC3E,IAAMmG,SAAS,GAAG3G,UAAU,CAACkB,KAAkC,CAAC;IAEhE,IAAMuI,aAAa,GAAGhD,mBAAmB,CAACC,UAAU,EAAEC,SAAS,CAAC;;IAEhE;IACA;IACAzG,QAAQ,CAACC,IAAI,CAACoB,KAAK,CAAC0G,WAAW,CAACzH,GAAG,EAAEiJ,aAAa,CAAC;EACrD,CAAC,CAAC;AACJ"}
@@ -7,6 +7,6 @@ export * from './ThemeUtils';
7
7
  export * from './useTheme';
8
8
  export * from './Logo';
9
9
  export * from './colorUtils';
10
- export * from './useParentWindowTheme';
10
+ export * from './useExternalTheme';
11
11
  export * from './useSpectrumThemeProvider';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
@@ -7,6 +7,6 @@ export * from "./ThemeUtils.js";
7
7
  export * from "./useTheme.js";
8
8
  export * from "./Logo.js";
9
9
  export * from "./colorUtils.js";
10
- export * from "./useParentWindowTheme.js";
10
+ export * from "./useExternalTheme.js";
11
11
  export * from "./useSpectrumThemeProvider.js";
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/theme/index.ts"],"sourcesContent":["export * from './theme-dark';\nexport * from './theme-light';\nexport * from './ThemeModel';\nexport * from './ThemePicker';\nexport * from './ThemeProvider';\nexport * from './ThemeUtils';\nexport * from './useTheme';\nexport * from './Logo';\nexport * from './colorUtils';\nexport * from './useParentWindowTheme';\nexport * from './useSpectrumThemeProvider';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/theme/index.ts"],"sourcesContent":["export * from './theme-dark';\nexport * from './theme-light';\nexport * from './ThemeModel';\nexport * from './ThemePicker';\nexport * from './ThemeProvider';\nexport * from './ThemeUtils';\nexport * from './useTheme';\nexport * from './Logo';\nexport * from './colorUtils';\nexport * from './useExternalTheme';\nexport * from './useSpectrumThemeProvider';\n"],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { type ThemeData } from './ThemeModel';
2
+ export interface UseExternalThemeResult {
3
+ isEnabled: boolean;
4
+ isPending: boolean;
5
+ themeData?: ThemeData;
6
+ }
7
+ /**
8
+ * If external theme is configured via `theme=EXTERNAL_THEME_KEY` query param,
9
+ * handle `postMessage` communication to retrieve the theme data from the parent
10
+ * Window. The hook will also listen for `MSG_REQUEST_SET_THEME` messages from
11
+ * the parent and current Window to allow explicitly setting the theme.
12
+ */
13
+ export declare function useExternalTheme(): UseExternalThemeResult;
14
+ export default useExternalTheme;
15
+ //# sourceMappingURL=useExternalTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExternalTheme.d.ts","sourceRoot":"","sources":["../../src/theme/useExternalTheme.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAStB,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CA2DzD;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { useEffect, useState } from 'react';
2
+ import Log from '@deephaven/log';
3
+ import { getWindowParent } from '@deephaven/utils';
4
+ import { MSG_REQUEST_SET_THEME } from "./ThemeModel.js";
5
+ import { isExternalThemeData, isExternalThemeEnabled, parseExternalThemeData, requestExternalThemeData } from "./ThemeUtils.js";
6
+ var logger = Log.module('useExternalTheme');
7
+ /**
8
+ * If external theme is configured via `theme=EXTERNAL_THEME_KEY` query param,
9
+ * handle `postMessage` communication to retrieve the theme data from the parent
10
+ * Window. The hook will also listen for `MSG_REQUEST_SET_THEME` messages from
11
+ * the parent and current Window to allow explicitly setting the theme.
12
+ */
13
+ export function useExternalTheme() {
14
+ var [result, setResult] = useState(() => {
15
+ var isEnabled = isExternalThemeEnabled();
16
+ return {
17
+ isEnabled,
18
+ isPending: isEnabled
19
+ };
20
+ });
21
+ useEffect(() => {
22
+ if (!result.isEnabled) {
23
+ return;
24
+ }
25
+ logger.debug('Requesting external theme data');
26
+
27
+ /** Parse external theme data and update the result */
28
+ function handleExternalThemeData(externalThemeData) {
29
+ var themeData = parseExternalThemeData(externalThemeData);
30
+ setResult({
31
+ isEnabled: true,
32
+ isPending: false,
33
+ themeData
34
+ });
35
+ }
36
+
37
+ /** Parent or current Window can explicitly set the theme */
38
+ function onMessage(event) {
39
+ var parent = getWindowParent();
40
+
41
+ // Allow messages from parent or current window
42
+ if (event.source !== window && event.source !== parent) {
43
+ return;
44
+ }
45
+ if (event.data.message === MSG_REQUEST_SET_THEME) {
46
+ if (isExternalThemeData(event.data.payload)) {
47
+ handleExternalThemeData(event.data.payload);
48
+ }
49
+ }
50
+ }
51
+ window.addEventListener('message', onMessage);
52
+
53
+ /** Request initial theme data from parent window */
54
+ requestExternalThemeData().then(handleExternalThemeData).catch(err => {
55
+ logger.error(err);
56
+ setResult({
57
+ isEnabled: true,
58
+ isPending: false
59
+ });
60
+ });
61
+ return () => {
62
+ window.removeEventListener('message', onMessage);
63
+ };
64
+ }, [result.isEnabled]);
65
+ return result;
66
+ }
67
+ export default useExternalTheme;
68
+ //# sourceMappingURL=useExternalTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExternalTheme.js","names":["useEffect","useState","Log","getWindowParent","MSG_REQUEST_SET_THEME","isExternalThemeData","isExternalThemeEnabled","parseExternalThemeData","requestExternalThemeData","logger","module","useExternalTheme","result","setResult","isEnabled","isPending","debug","handleExternalThemeData","externalThemeData","themeData","onMessage","event","parent","source","window","data","message","payload","addEventListener","then","catch","err","error","removeEventListener"],"sources":["../../src/theme/useExternalTheme.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport Log from '@deephaven/log';\nimport { getWindowParent, type PostMessage } from '@deephaven/utils';\nimport {\n MSG_REQUEST_SET_THEME,\n type ExternalThemeData,\n type ThemeData,\n} from './ThemeModel';\nimport {\n isExternalThemeData,\n isExternalThemeEnabled,\n parseExternalThemeData,\n requestExternalThemeData,\n} from './ThemeUtils';\n\nconst logger = Log.module('useExternalTheme');\nexport interface UseExternalThemeResult {\n isEnabled: boolean;\n isPending: boolean;\n themeData?: ThemeData;\n}\n\n/**\n * If external theme is configured via `theme=EXTERNAL_THEME_KEY` query param,\n * handle `postMessage` communication to retrieve the theme data from the parent\n * Window. The hook will also listen for `MSG_REQUEST_SET_THEME` messages from\n * the parent and current Window to allow explicitly setting the theme.\n */\nexport function useExternalTheme(): UseExternalThemeResult {\n const [result, setResult] = useState<UseExternalThemeResult>(() => {\n const isEnabled = isExternalThemeEnabled();\n return {\n isEnabled,\n isPending: isEnabled,\n };\n });\n\n useEffect(() => {\n if (!result.isEnabled) {\n return;\n }\n\n logger.debug('Requesting external theme data');\n\n /** Parse external theme data and update the result */\n function handleExternalThemeData(externalThemeData: ExternalThemeData) {\n const themeData = parseExternalThemeData(externalThemeData);\n\n setResult({\n isEnabled: true,\n isPending: false,\n themeData,\n });\n }\n\n /** Parent or current Window can explicitly set the theme */\n function onMessage(event: MessageEvent<PostMessage<unknown>>): void {\n const parent = getWindowParent();\n\n // Allow messages from parent or current window\n if (event.source !== window && event.source !== parent) {\n return;\n }\n\n if (event.data.message === MSG_REQUEST_SET_THEME) {\n if (isExternalThemeData(event.data.payload)) {\n handleExternalThemeData(event.data.payload);\n }\n }\n }\n\n window.addEventListener('message', onMessage);\n\n /** Request initial theme data from parent window */\n requestExternalThemeData()\n .then(handleExternalThemeData)\n .catch(err => {\n logger.error(err);\n setResult({ isEnabled: true, isPending: false });\n });\n\n return () => {\n window.removeEventListener('message', onMessage);\n };\n }, [result.isEnabled]);\n\n return result;\n}\n\nexport default useExternalTheme;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,eAAe,QAA0B,kBAAkB;AAAC,SAEnEC,qBAAqB;AAAA,SAKrBC,mBAAmB,EACnBC,sBAAsB,EACtBC,sBAAsB,EACtBC,wBAAwB;AAG1B,IAAMC,MAAM,GAAGP,GAAG,CAACQ,MAAM,CAAC,kBAAkB,CAAC;AAO7C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAA2B;EACzD,IAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGZ,QAAQ,CAAyB,MAAM;IACjE,IAAMa,SAAS,GAAGR,sBAAsB,CAAC,CAAC;IAC1C,OAAO;MACLQ,SAAS;MACTC,SAAS,EAAED;IACb,CAAC;EACH,CAAC,C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gBAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/components",
3
- "version": "0.107.3-alpha-parent-theme.15+43d3de7e",
3
+ "version": "0.107.3-alpha-parent-theme.38+614bb272",
4
4
  "description": "Deephaven React component library",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@adobe/react-spectrum": "3.38.0",
28
- "@deephaven/icons": "^0.107.3-alpha-parent-theme.15+43d3de7e",
29
- "@deephaven/log": "^0.107.3-alpha-parent-theme.15+43d3de7e",
30
- "@deephaven/react-hooks": "^0.107.3-alpha-parent-theme.15+43d3de7e",
31
- "@deephaven/utils": "^0.107.3-alpha-parent-theme.15+43d3de7e",
28
+ "@deephaven/icons": "^0.107.3-alpha-parent-theme.38+614bb272",
29
+ "@deephaven/log": "^0.107.3-alpha-parent-theme.38+614bb272",
30
+ "@deephaven/react-hooks": "^0.107.3-alpha-parent-theme.38+614bb272",
31
+ "@deephaven/utils": "^0.107.3-alpha-parent-theme.38+614bb272",
32
32
  "@fortawesome/fontawesome-svg-core": "^6.2.1",
33
33
  "@fortawesome/react-fontawesome": "^0.2.0",
34
34
  "@internationalized/date": "^3.5.5",
@@ -60,8 +60,8 @@
60
60
  "react-is": ">=16.8.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@deephaven/mocks": "^0.107.3-alpha-parent-theme.15+43d3de7e",
64
- "@deephaven/test-utils": "^0.107.3-alpha-parent-theme.15+43d3de7e",
63
+ "@deephaven/mocks": "^0.107.3-alpha-parent-theme.38+614bb272",
64
+ "@deephaven/test-utils": "^0.107.3-alpha-parent-theme.38+614bb272",
65
65
  "react-redux": "^7.2.4"
66
66
  },
67
67
  "files": [
@@ -76,5 +76,5 @@
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  },
79
- "gitHead": "43d3de7ed90cd7b5e827ec11173a41752773762e"
79
+ "gitHead": "614bb27236022295152c82fcf1d941fd8a95cd0c"
80
80
  }
@@ -1,13 +0,0 @@
1
- import { type ThemeData } from './ThemeModel';
2
- export interface UseParentWindowThemeResult {
3
- isEnabled: boolean;
4
- isPending: boolean;
5
- themeData?: ThemeData;
6
- }
7
- /**
8
- * If parent theme is configured via `theme=PARENT_THEME_KEY` query param, handle
9
- * `postMessage` communication to retrieve the theme data from the parent window.
10
- */
11
- export declare function useParentWindowTheme(): UseParentWindowThemeResult;
12
- export default useParentWindowTheme;
13
- //# sourceMappingURL=useParentWindowTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useParentWindowTheme.d.ts","sourceRoot":"","sources":["../../src/theme/useParentWindowTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAQ9C,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,0BAA0B,CAgCjE;AAED,eAAe,oBAAoB,CAAC"}
@@ -1,37 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import Log from '@deephaven/log';
3
- import { isParentThemeEnabled, parseParentThemeData, requestParentThemeData } from "./ThemeUtils.js";
4
- var logger = Log.module('useParentWindowTheme');
5
- /**
6
- * If parent theme is configured via `theme=PARENT_THEME_KEY` query param, handle
7
- * `postMessage` communication to retrieve the theme data from the parent window.
8
- */
9
- export function useParentWindowTheme() {
10
- var [result, setResult] = useState(() => {
11
- var isEnabled = isParentThemeEnabled();
12
- return {
13
- isEnabled,
14
- isPending: isEnabled
15
- };
16
- });
17
- useEffect(() => {
18
- if (!result.isEnabled) {
19
- return;
20
- }
21
- logger.debug('Requesting parent theme data');
22
- requestParentThemeData().then(parseParentThemeData).then(themeData => setResult({
23
- isEnabled: true,
24
- isPending: false,
25
- themeData
26
- })).catch(err => {
27
- logger.error(err);
28
- setResult({
29
- isEnabled: true,
30
- isPending: false
31
- });
32
- });
33
- }, [result.isEnabled]);
34
- return result;
35
- }
36
- export default useParentWindowTheme;
37
- //# sourceMappingURL=useParentWindowTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useParentWindowTheme.js","names":["useEffect","useState","Log","isParentThemeEnabled","parseParentThemeData","requestParentThemeData","logger","module","useParentWindowTheme","result","setResult","isEnabled","isPending","debug","then","themeData","catch","err","error"],"sources":["../../src/theme/useParentWindowTheme.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport Log from '@deephaven/log';\nimport { type ThemeData } from './ThemeModel';\nimport {\n isParentThemeEnabled,\n parseParentThemeData,\n requestParentThemeData,\n} from './ThemeUtils';\n\nconst logger = Log.module('useParentWindowTheme');\nexport interface UseParentWindowThemeResult {\n isEnabled: boolean;\n isPending: boolean;\n themeData?: ThemeData;\n}\n\n/**\n * If parent theme is configured via `theme=PARENT_THEME_KEY` query param, handle\n * `postMessage` communication to retrieve the theme data from the parent window.\n */\nexport function useParentWindowTheme(): UseParentWindowThemeResult {\n const [result, setResult] = useState<UseParentWindowThemeResult>(() => {\n const isEnabled = isParentThemeEnabled();\n return {\n isEnabled,\n isPending: isEnabled,\n };\n });\n\n useEffect(() => {\n if (!result.isEnabled) {\n return;\n }\n\n logger.debug('Requesting parent theme data');\n\n requestParentThemeData()\n .then(parseParentThemeData)\n .then(themeData =>\n setResult({\n isEnabled: true,\n isPending: false,\n themeData,\n })\n )\n .catch(err => {\n logger.error(err);\n setResult({ isEnabled: true, isPending: false });\n });\n }, [result.isEnabled]);\n\n return result;\n}\n\nexport default useParentWindowTheme;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SAG/BC,oBAAoB,EACpBC,oBAAoB,EACpBC,sBAAsB;AAGxB,IAAMC,MAAM,GAAGJ,GAAG,CAACK,MAAM,CAAC,sBAAsB,CAAC;AAOjD;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAA,EAA+B;EACjE,IAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGT,QAAQ,CAA6B,MAAM;IACrE,IAAMU,SAAS,GAAGR,oBAAoB,CAAC,CAAC;IACxC,OAAO;MACLQ,SAAS;MACTC,SAAS,EAAED;IACb,CAAC;EACH,CAAC,CAAC;EAEFX,SAAS,CAAC,MAAM;IACd,IAAI,CAACS,MAAM,CAACE,SAAS,EAAE;MACrB;IACF;IAEAL,MAAM,CAACO,KAAK,CAAC,8BAA8B,CAAC;IAE5CR,sBAAsB,CAAC,CAAC,CACrBS,IAAI,CAACV,oBAAoB,CAAC,CAC1BU,IAAI,CAACC,SAAS,IACbL,SAAS,CAAC;MACRC,SAAS,EAAE,IAAI;MACfC,SAAS,EAAE,KAAK;MAChBG;IACF,CAAC,CACH,CAAC,CACAC,KAAK,CAACC,GAAG,IAAI;MACZX,MAAM,CAACY,KAAK,CAACD,GAAG,CAAC;MACjBP,SAAS,CAAC;QAAEC,SAAS,EAAE,IAAI;QAAEC,SAAS,EAAE;MAAM,CAAC,CAAC;IAClD,CAAC,CAAC;EACN,CAAC,EAAE,CAACH,MAAM,CAACE,SAAS,CAAC,CAAC;EAEtB,OAAOF,MAAM;AACf;AAEA,eAAeD,oBAAoB"}