diff --git a/.gitignore b/.gitignore index 310ada1..72a7670 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ coverage.out # 主题包依赖 theme/node_modules/ +theme/dist/ diff --git a/theme/dist/index.d.ts b/theme/dist/index.d.ts index ab4d1d6..8b4e981 100644 --- a/theme/dist/index.d.ts +++ b/theme/dist/index.d.ts @@ -3,5 +3,5 @@ export { appShellTokens, darkTheme, foundationTokens, lightElevationContexts, li export { createAppShellCssVarMap, createFoundationCssVarMap, createStaticCssVarMap, createTailwindThemeBridge, createThemeCssVarMap, generateThemeCSS, getStoredTheme, injectThemeStyle, setTheme, staticToCssVar, tokenToCssVar, } from './css.js'; export type { TokenName } from './helpers.js'; export { cssVar, themeStyle } from './helpers.js'; -export type { AccountSurfaceProps, AccountFormProps, BadgeProps, ButtonProps, ButtonVariant, CardProps, FieldProps, FormActionsProps, PluginBatchAccountInput, PluginBatchImportResult, PluginFrontendModule, PluginMenuItemDefinition, PluginOAuthBatchExchangeResult, PluginOAuthBridge, PluginOAuthExchangeResult, PluginOAuthStartResult, PanelHeaderProps, PluginPlatformIconProps, PluginStatusKind, PluginStyleFoundationOptions, PluginTailwindConfigOptions, PluginRouteDefinition, ResolvePluginThemeOptions, ScopedPluginThemeOptions, SectionProps, SelectableCardProps, StatusTextProps, UsageRecordSurfaceProps, } from './plugin.js'; +export type { AccountSurfaceProps, AccountFormProps, BadgeProps, ButtonProps, ButtonVariant, CardProps, FieldProps, FormActionsProps, PluginBatchAccountInput, PluginBatchImportResult, PluginFrontendModule, PluginMenuItemDefinition, PluginOAuthBatchExchangeResult, PluginOAuthBridge, PluginOAuthExchangeResult, PluginOAuthStartResult, PanelHeaderProps, PluginPlatformIconProps, PluginStatusKind, PluginStyleFoundationOptions, PluginTailwindConfigOptions, PluginRouteDefinition, ResolvePluginThemeOptions, ScopedPluginThemeOptions, SectionProps, SelectableCardProps, StatusTextProps, UsageRecordSurfaceProps, UsageServiceTierFastResolver, } from './plugin.js'; export { DEFAULT_PLUGIN_CLASS_PREFIX, DEFAULT_PLUGIN_FOUNDATION_STYLE_ID, DEFAULT_PLUGIN_THEME_ATTRIBUTE, DEFAULT_PLUGIN_THEME_STYLE_ID, Badge, Button, Card, Field, FormActions, PanelHeader, Section, SecretInput, SelectableCard, StatusText, TextInput, TextArea, cn, createPluginTailwindConfig, ensurePluginStyleFoundation, injectStyle, pluginFoundationCssText, resolvePluginTheme, useScopedPluginTheme, } from './plugin.js'; diff --git a/theme/dist/plugin.d.ts b/theme/dist/plugin.d.ts index 07eb669..cf89b7c 100644 --- a/theme/dist/plugin.d.ts +++ b/theme/dist/plugin.d.ts @@ -91,6 +91,13 @@ export interface UsageRecordSurfaceProps { recordId?: string | number; context?: Record; } +/** + * 平台插件自行判断某条 usage 的 service_tier 是否应展示为 fast。 + * + * 不同上游平台可能使用不同字段值表达 fast/priority/flex 等服务层级, + * Core 只负责调用该函数并套用统一 fast 样式,不内置平台语义。 + */ +export type UsageServiceTierFastResolver = (context?: Record) => boolean; export interface PluginFrontendModule { routes?: PluginRouteDefinition[]; menuItems?: PluginMenuItemDefinition[]; @@ -105,6 +112,7 @@ export interface PluginFrontendModule { * Core 只提供表格骨架与回退渲染,不内置平台语义。 */ usageModelMeta?: ComponentType; + isUsageServiceTierFast?: UsageServiceTierFastResolver; usageMetricDetail?: ComponentType; usageCostDetail?: ComponentType; platformIcon?: ComponentType; diff --git a/theme/package.json b/theme/package.json index c69c029..614d434 100644 --- a/theme/package.json +++ b/theme/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "AirGate 插件前端主题、样式隔离和公共组件包", "type": "module", - "packageManager": "npm@11.6.2", + "packageManager": "pnpm@11.1.1", "license": "MIT", "repository": { "type": "git", @@ -43,7 +43,7 @@ ], "scripts": { "build": "tsc", - "prepack": "npm run build", + "prepack": "pnpm run build", "dev": "tsc --watch" }, "peerDependencies": { diff --git a/theme/pnpm-lock.yaml b/theme/pnpm-lock.yaml new file mode 100644 index 0000000..089aebe --- /dev/null +++ b/theme/pnpm-lock.yaml @@ -0,0 +1,48 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@types/react': + specifier: ^19.0.0 + version: 19.2.14 + react: + specifier: ^19.0.0 + version: 19.2.6 + typescript: + specifier: ^5.7.0 + version: 5.9.3 + +packages: + + '@types/react@19.2.14': + resolution: {integrity: sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==} + + csstype@3.2.3: + resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} + + react@19.2.6: + resolution: {integrity: sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q==} + engines: {node: '>=0.10.0'} + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + +snapshots: + + '@types/react@19.2.14': + dependencies: + csstype: 3.2.3 + + csstype@3.2.3: {} + + react@19.2.6: {} + + typescript@5.9.3: {} diff --git a/theme/src/index.ts b/theme/src/index.ts index 79a5f71..8a26324 100644 --- a/theme/src/index.ts +++ b/theme/src/index.ts @@ -76,6 +76,7 @@ export type { SelectableCardProps, StatusTextProps, UsageRecordSurfaceProps, + UsageServiceTierFastResolver, } from './plugin.js'; // 插件前端 SDK:样式注入、主题同步、Tailwind bridge 和公共组件 diff --git a/theme/src/plugin.tsx b/theme/src/plugin.tsx index 1e5e250..a01a8ad 100644 --- a/theme/src/plugin.tsx +++ b/theme/src/plugin.tsx @@ -123,6 +123,14 @@ export interface UsageRecordSurfaceProps { context?: Record; } +/** + * 平台插件自行判断某条 usage 的 service_tier 是否应展示为 fast。 + * + * 不同上游平台可能使用不同字段值表达 fast/priority/flex 等服务层级, + * Core 只负责调用该函数并套用统一 fast 样式,不内置平台语义。 + */ +export type UsageServiceTierFastResolver = (context?: Record) => boolean; + export interface PluginFrontendModule { routes?: PluginRouteDefinition[]; menuItems?: PluginMenuItemDefinition[]; @@ -137,6 +145,7 @@ export interface PluginFrontendModule { * Core 只提供表格骨架与回退渲染,不内置平台语义。 */ usageModelMeta?: ComponentType; + isUsageServiceTierFast?: UsageServiceTierFastResolver; usageMetricDetail?: ComponentType; usageCostDetail?: ComponentType; platformIcon?: ComponentType;