open-mcp-app 0.0.2 → 0.0.4

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.
@@ -903,118 +903,49 @@ declare class StandaloneHostClient extends Subscribable implements UnifiedHostCl
903
903
  }
904
904
 
905
905
  /**
906
- * Environment-Aware Default Styles
906
+ * SDK Layout Variables
907
907
  *
908
- * This module provides default CSS variable values for MCP Apps and ChatGPT Apps.
909
- * Import `initDefaultStyles` early in your app entry point to prevent flash of unstyled content.
908
+ * This module provides SDK-only CSS variables for spacing, containers, and component sizing.
909
+ * These are NOT part of the MCP Apps spec - they are convenient defaults for clean layouts.
910
910
  *
911
- * The MCP Apps spec defines CSS variable names (e.g., --color-background-primary).
912
- * This module provides environment-specific VALUES for those variables as sensible
913
- * defaults until the host injects its own values.
911
+ * Host-provided spec variables (colors, typography, etc.) are applied automatically
912
+ * when the app initializes via hostContext.styles.variables. Apps are not shown until
913
+ * initialization is complete, so there's no need for pre-host defaults.
914
914
  *
915
- * Flow:
916
- * 1. Detect environment (ChatGPT, MCP Apps, or Standalone)
917
- * 2. Detect theme (light or dark)
918
- * 3. Inject defaults immediately on document.documentElement
919
- * 4. When host connects, host variables override these defaults
920
- *
921
- * IMPORTANT: MCP Apps defaults match Creature's actual values exactly.
922
- * The observer only runs for ChatGPT (MCP Apps hosts handle theme changes themselves).
923
- */
924
-
925
- /**
926
- * Theme mode for styling.
927
- */
928
- type Theme = "light" | "dark";
929
- /**
930
- * Options for initializing styles.
931
- */
932
- interface InitStylesOptions {
933
- /** Whether to set up a MutationObserver for dynamic theme changes. Default: true for ChatGPT only */
934
- observeThemeChanges?: boolean;
935
- }
936
- /**
937
- * MCP Apps / Creature default values - DARK mode.
938
- * These values are extracted directly from Creature's globals.css.
939
- * They MUST match exactly what Creature sends via hostContext.styles.variables.
940
- */
941
- declare const MCP_APPS_DARK_DEFAULTS: Record<string, string>;
942
- /**
943
- * MCP Apps / Creature default values - LIGHT mode.
944
- * These values are extracted directly from Creature's globals.css.
945
- */
946
- declare const MCP_APPS_LIGHT_DEFAULTS: Record<string, string>;
947
- /**
948
- * Shared MCP Apps / Creature typography and layout tokens (same for light/dark).
949
- * These values are extracted directly from Creature's globals.css.
950
- */
951
- declare const MCP_APPS_SHARED_DEFAULTS: Record<string, string>;
952
- /**
953
- * ChatGPT Apps default values - LIGHT mode.
954
- * Ported from @openai/apps-sdk-ui design tokens.
955
- */
956
- declare const CHATGPT_LIGHT_DEFAULTS: Record<string, string>;
957
- /**
958
- * ChatGPT Apps default values - DARK mode.
959
- */
960
- declare const CHATGPT_DARK_DEFAULTS: Record<string, string>;
961
- /**
962
- * Shared ChatGPT typography and layout tokens (same for light/dark).
963
- */
964
- declare const CHATGPT_SHARED_DEFAULTS: Record<string, string>;
965
- /**
966
- * Get MCP Apps default styles for the specified theme.
967
- * Returns CSS variable names with their default values.
968
- * These values match exactly what Creature sends via hostContext.styles.variables.
969
- *
970
- * @param theme - The theme to get defaults for
971
- * @returns Record of CSS variable names to their values
972
- */
973
- declare const getMcpAppDefaultStyles: ({ theme }: {
974
- theme: Theme;
975
- }) => Record<string, string>;
976
- /**
977
- * Get ChatGPT Apps default styles for the specified theme.
978
- * Returns CSS variable names with their values matching the @openai/apps-sdk-ui design tokens.
979
- *
980
- * @param theme - The theme to get defaults for
981
- * @returns Record of CSS variable names to their values
915
+ * Usage:
916
+ * 1. Import base.css which uses these variables
917
+ * 2. Or apply them manually via applyLayoutDefaults()
982
918
  */
983
- declare const getChatGptDefaultStyles: ({ theme }: {
984
- theme: Theme;
985
- }) => Record<string, string>;
986
919
  /**
987
- * Detect the current theme from the document.
988
- * Checks data-theme attribute, dark class (Tailwind), and prefers-color-scheme.
920
+ * SDK-only layout variables for spacing, containers, and component sizing.
921
+ * These are NOT part of the MCP Apps spec but provide sensible defaults
922
+ * for clean layouts.
989
923
  *
990
- * @returns The detected theme
924
+ * Based on a 4px (0.25rem) base unit, similar to Tailwind's spacing scale.
925
+ * Component sizing follows patterns from @openai/apps-sdk-ui for consistency.
991
926
  */
992
- declare const detectTheme: () => Theme;
927
+ declare const LAYOUT_DEFAULTS: Record<string, string>;
993
928
  /**
994
- * Apply CSS variables to the document root.
929
+ * Apply CSS variables to an element (defaults to document root).
995
930
  *
996
931
  * @param styles - Record of CSS variable names to their values
932
+ * @param root - Element to apply styles to (defaults to document.documentElement)
997
933
  */
998
- declare const applyStyles: ({ styles }: {
934
+ declare const applyStyles: ({ styles, root, }: {
999
935
  styles: Record<string, string>;
936
+ root?: HTMLElement;
1000
937
  }) => void;
1001
938
  /**
1002
- * Initialize default styles based on detected environment and theme.
1003
- * This should be called early in your app entry point to prevent FOUC.
939
+ * Apply SDK layout defaults to the document.
940
+ * This applies spacing, container, and control variables.
1004
941
  *
1005
- * For MCP Apps (Creature): Applies defaults once. The host handles theme changes
1006
- * and sends new styles via hostContext, which override these defaults.
942
+ * Note: If you import base.css, these variables are already defined via :root.
943
+ * Only call this manually if you need to apply them programmatically or
944
+ * to a specific element other than document root.
1007
945
  *
1008
- * For ChatGPT: Applies defaults and sets up an observer to handle theme changes,
1009
- * since ChatGPT may change theme before sending new hostContext.
1010
- *
1011
- * @param environment - The detected environment (from detectEnvironment)
1012
- * @param options - Configuration options
946
+ * @param root - Element to apply styles to (defaults to document.documentElement)
1013
947
  */
1014
- declare const initDefaultStyles: ({ environment, options, }: {
1015
- environment: Environment;
1016
- options?: InitStylesOptions;
1017
- }) => void;
948
+ declare const applyLayoutDefaults: (root?: HTMLElement) => void;
1018
949
 
1019
950
  /**
1020
951
  * Create a WebSocket client with automatic reconnection.
@@ -1092,4 +1023,4 @@ declare const createHost: (config: HostClientConfig) => UnifiedHostClient;
1092
1023
  */
1093
1024
  declare const createHostAsync: (config: HostClientConfig) => Promise<UnifiedHostClient>;
1094
1025
 
1095
- export { CHATGPT_DARK_DEFAULTS, CHATGPT_LIGHT_DEFAULTS, CHATGPT_SHARED_DEFAULTS, ChatGptWebHostClient, ClaudeDesktopHostClient, type ContentBlock, CreatureDesktopHostClient, type DisplayMode, type Environment, type ExpHostApi, type HostClientConfig, type HostClientEvents, type HostClientState, type HostContext, type ImageContentBlock, type InitStylesOptions, type LogLevel, MCP_APPS_DARK_DEFAULTS, MCP_APPS_LIGHT_DEFAULTS, MCP_APPS_SHARED_DEFAULTS, type OpenContext, StandaloneHostClient, type StateListener, type StructuredWidgetState, type TextContentBlock, type Theme, type ToolResult, type UnifiedHostClient, type WebSocketClient, type WebSocketClientConfig, type WebSocketStatus, type WidgetState, applyStyles, createHost, createHostAsync, createWebSocket, detectEnvironment, detectTheme, getChatGptDefaultStyles, getMcpAppDefaultStyles, initDefaultStyles };
1026
+ export { ChatGptWebHostClient, ClaudeDesktopHostClient, type ContentBlock, CreatureDesktopHostClient, type DisplayMode, type Environment, type ExpHostApi, type HostClientConfig, type HostClientEvents, type HostClientState, type HostContext, type ImageContentBlock, LAYOUT_DEFAULTS, type LogLevel, type OpenContext, StandaloneHostClient, type StateListener, type StructuredWidgetState, type TextContentBlock, type ToolResult, type UnifiedHostClient, type WebSocketClient, type WebSocketClientConfig, type WebSocketStatus, type WidgetState, applyLayoutDefaults, applyStyles, createHost, createHostAsync, createWebSocket, detectEnvironment };