brix-runtime-sdk-api-web 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/index.js +190 -0
  2. package/dist/types/api-exports.test.d.ts +33 -0
  3. package/dist/types/api-exports.test.d.ts.map +1 -0
  4. package/dist/types/context/RuntimeContext.d.ts +69 -0
  5. package/dist/types/context/RuntimeContext.d.ts.map +1 -0
  6. package/dist/types/context/index.d.ts +23 -0
  7. package/dist/types/context/index.d.ts.map +1 -0
  8. package/dist/types/index.d.ts +52 -0
  9. package/dist/types/index.d.ts.map +1 -0
  10. package/dist/types/types/auth.d.ts +405 -0
  11. package/dist/types/types/auth.d.ts.map +1 -0
  12. package/dist/types/types/capability.d.ts +218 -0
  13. package/dist/types/types/capability.d.ts.map +1 -0
  14. package/dist/types/types/common.d.ts +99 -0
  15. package/dist/types/types/common.d.ts.map +1 -0
  16. package/dist/types/types/config.d.ts +85 -0
  17. package/dist/types/types/config.d.ts.map +1 -0
  18. package/dist/types/types/event.d.ts +658 -0
  19. package/dist/types/types/event.d.ts.map +1 -0
  20. package/dist/types/types/http.d.ts +132 -0
  21. package/dist/types/types/http.d.ts.map +1 -0
  22. package/dist/types/types/i18n.d.ts +327 -0
  23. package/dist/types/types/i18n.d.ts.map +1 -0
  24. package/dist/types/types/index.d.ts +61 -0
  25. package/dist/types/types/index.d.ts.map +1 -0
  26. package/dist/types/types/layout.d.ts +301 -0
  27. package/dist/types/types/layout.d.ts.map +1 -0
  28. package/dist/types/types/module.d.ts +78 -0
  29. package/dist/types/types/module.d.ts.map +1 -0
  30. package/dist/types/types/navigation.d.ts +295 -0
  31. package/dist/types/types/navigation.d.ts.map +1 -0
  32. package/dist/types/types/plugin-loader-capability.d.ts +142 -0
  33. package/dist/types/types/plugin-loader-capability.d.ts.map +1 -0
  34. package/dist/types/types/plugin.d.ts +250 -0
  35. package/dist/types/types/plugin.d.ts.map +1 -0
  36. package/dist/types/types/state.d.ts +306 -0
  37. package/dist/types/types/state.d.ts.map +1 -0
  38. package/dist/types/types/theme.d.ts +279 -0
  39. package/dist/types/types/theme.d.ts.map +1 -0
  40. package/dist/types/types/ui/adapter.d.ts +181 -0
  41. package/dist/types/types/ui/adapter.d.ts.map +1 -0
  42. package/dist/types/types/ui/avatar.d.ts +102 -0
  43. package/dist/types/types/ui/avatar.d.ts.map +1 -0
  44. package/dist/types/types/ui/badge.d.ts +101 -0
  45. package/dist/types/types/ui/badge.d.ts.map +1 -0
  46. package/dist/types/types/ui/button.d.ts +135 -0
  47. package/dist/types/types/ui/button.d.ts.map +1 -0
  48. package/dist/types/types/ui/card.d.ts +105 -0
  49. package/dist/types/types/ui/card.d.ts.map +1 -0
  50. package/dist/types/types/ui/common.d.ts +29 -0
  51. package/dist/types/types/ui/common.d.ts.map +1 -0
  52. package/dist/types/types/ui/icon.d.ts +78 -0
  53. package/dist/types/types/ui/icon.d.ts.map +1 -0
  54. package/dist/types/types/ui/index.d.ts +59 -0
  55. package/dist/types/types/ui/index.d.ts.map +1 -0
  56. package/dist/types/types/ui/input.d.ts +200 -0
  57. package/dist/types/types/ui/input.d.ts.map +1 -0
  58. package/dist/types/types/ui/menu.d.ts +211 -0
  59. package/dist/types/types/ui/menu.d.ts.map +1 -0
  60. package/dist/types/types/ui/message.d.ts +121 -0
  61. package/dist/types/types/ui/message.d.ts.map +1 -0
  62. package/dist/types/types/ui/modal.d.ts +167 -0
  63. package/dist/types/types/ui/modal.d.ts.map +1 -0
  64. package/dist/types/types/ui/select.d.ts +213 -0
  65. package/dist/types/types/ui/select.d.ts.map +1 -0
  66. package/dist/types/types/ui/theme-tokens.d.ts +226 -0
  67. package/dist/types/types/ui/theme-tokens.d.ts.map +1 -0
  68. package/dist/types/types/ui/tooltip.d.ts +98 -0
  69. package/dist/types/types/ui/tooltip.d.ts.map +1 -0
  70. package/dist/types/types/ui.d.ts +49 -0
  71. package/dist/types/types/ui.d.ts.map +1 -0
  72. package/package.json +34 -0
  73. package/src/api-exports.test.ts +199 -0
  74. package/src/context/RuntimeContext.d.ts +69 -0
  75. package/src/context/RuntimeContext.d.ts.map +1 -0
  76. package/src/context/RuntimeContext.ts +75 -0
  77. package/src/context/index.d.ts +23 -0
  78. package/src/context/index.d.ts.map +1 -0
  79. package/src/context/index.ts +23 -0
  80. package/src/index.d.ts +52 -0
  81. package/src/index.d.ts.map +1 -0
  82. package/src/index.ts +59 -0
  83. package/src/types/auth.d.ts +146 -0
  84. package/src/types/auth.d.ts.map +1 -0
  85. package/src/types/auth.ts +479 -0
  86. package/src/types/capability.d.ts +218 -0
  87. package/src/types/capability.d.ts.map +1 -0
  88. package/src/types/capability.ts +302 -0
  89. package/src/types/common.d.ts +99 -0
  90. package/src/types/common.d.ts.map +1 -0
  91. package/src/types/common.ts +115 -0
  92. package/src/types/config.d.ts +64 -0
  93. package/src/types/config.d.ts.map +1 -0
  94. package/src/types/config.ts +96 -0
  95. package/src/types/event.d.ts +206 -0
  96. package/src/types/event.d.ts.map +1 -0
  97. package/src/types/event.ts +776 -0
  98. package/src/types/http.d.ts +132 -0
  99. package/src/types/http.d.ts.map +1 -0
  100. package/src/types/http.ts +156 -0
  101. package/src/types/i18n.ts +420 -0
  102. package/src/types/index.d.ts +50 -0
  103. package/src/types/index.d.ts.map +1 -0
  104. package/src/types/index.ts +120 -0
  105. package/src/types/layout.ts +394 -0
  106. package/src/types/module.d.ts +78 -0
  107. package/src/types/module.d.ts.map +1 -0
  108. package/src/types/module.ts +92 -0
  109. package/src/types/navigation.d.ts +101 -0
  110. package/src/types/navigation.d.ts.map +1 -0
  111. package/src/types/navigation.ts +361 -0
  112. package/src/types/plugin-loader-capability.ts +159 -0
  113. package/src/types/plugin.d.ts +250 -0
  114. package/src/types/plugin.d.ts.map +1 -0
  115. package/src/types/plugin.ts +344 -0
  116. package/src/types/state.d.ts +119 -0
  117. package/src/types/state.d.ts.map +1 -0
  118. package/src/types/state.ts +366 -0
  119. package/src/types/theme.ts +378 -0
  120. package/src/types/ui/adapter.ts +222 -0
  121. package/src/types/ui/avatar.ts +113 -0
  122. package/src/types/ui/badge.ts +112 -0
  123. package/src/types/ui/button.ts +148 -0
  124. package/src/types/ui/card.ts +116 -0
  125. package/src/types/ui/common.ts +29 -0
  126. package/src/types/ui/icon.ts +85 -0
  127. package/src/types/ui/index.ts +78 -0
  128. package/src/types/ui/input.ts +225 -0
  129. package/src/types/ui/menu.ts +237 -0
  130. package/src/types/ui/message.ts +135 -0
  131. package/src/types/ui/modal.ts +188 -0
  132. package/src/types/ui/select.ts +239 -0
  133. package/src/types/ui/theme-tokens.ts +357 -0
  134. package/src/types/ui/tooltip.ts +120 -0
  135. package/src/types/ui.ts +49 -0
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Copyright 2026 Brix Platform Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @file HTTP Client Capability Type Definitions
18
+ * @description Defines HTTP client capability contract, replacing direct use of fetch/axios
19
+ * @module @brix/runtime-sdk-api-web/types/http
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Changes]
23
+ * Extracted from index.ts into a standalone type file.
24
+ *
25
+ * [Architectural Constraint - R3]
26
+ * Plugin layer is prohibited from using HTTP client libraries like axios/fetch directly,
27
+ * requests must be made through the HttpCapability.
28
+ */
29
+ /**
30
+ * HTTP Client Capability Type Identifier
31
+ */
32
+ export declare const HttpCapabilityType: unique symbol;
33
+ /**
34
+ * HTTP Request Configuration Options
35
+ */
36
+ export interface HttpRequestConfig {
37
+ /** Request URL (relative to baseURL or absolute path) */
38
+ readonly url: string;
39
+ /** HTTP Method */
40
+ readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
41
+ /** Request Headers */
42
+ readonly headers?: Record<string, string>;
43
+ /** URL Query Parameters */
44
+ readonly params?: Record<string, unknown>;
45
+ /** Request Body */
46
+ readonly data?: unknown;
47
+ /** Timeout (milliseconds) */
48
+ readonly timeout?: number;
49
+ /** Base URL */
50
+ readonly baseURL?: string;
51
+ }
52
+ /**
53
+ * HTTP Response Structure
54
+ */
55
+ export interface HttpResponse<T = unknown> {
56
+ /** Response Data */
57
+ readonly data: T;
58
+ /** HTTP Status Code */
59
+ readonly status: number;
60
+ /** Status Text */
61
+ readonly statusText: string;
62
+ /** Response Headers */
63
+ readonly headers: Record<string, string>;
64
+ }
65
+ /**
66
+ * HTTP Client Capability Contract
67
+ *
68
+ * <p>Provides a unified HTTP request abstraction for the plugin layer, replacing direct axios/fetch calls.</p>
69
+ *
70
+ * <h3>Usage Example</h3>
71
+ * ```typescript
72
+ * const http = runtimeContext.getCapability<HttpCapability>(HttpCapabilityType);
73
+ * const products = await http.get<Product[]>('/api/v1/products');
74
+ * const created = await http.post<Product>('/api/v1/products', newProduct);
75
+ * ```
76
+ *
77
+ * <h3>Architecture Notes</h3>
78
+ * <ul>
79
+ * <li>Shell layer provides the implementation (can be based on fetch/axios, transparent to plugins)</li>
80
+ * <li>Automatically injects auth tokens, tenant IDs, and other context headers</li>
81
+ * <li>Unified error handling and retry strategies</li>
82
+ * </ul>
83
+ */
84
+ export interface HttpCapability {
85
+ /**
86
+ * Send Generic Request
87
+ *
88
+ * @param config Request configuration
89
+ * @returns Response result
90
+ */
91
+ request<T = unknown>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
92
+ /**
93
+ * GET Request
94
+ *
95
+ * @param url Request URL
96
+ * @param params Query parameters
97
+ * @returns Response data
98
+ */
99
+ get<T = unknown>(url: string, params?: Record<string, unknown>): Promise<T>;
100
+ /**
101
+ * POST Request
102
+ *
103
+ * @param url Request URL
104
+ * @param data Request body
105
+ * @returns Response data
106
+ */
107
+ post<T = unknown>(url: string, data?: unknown): Promise<T>;
108
+ /**
109
+ * PUT Request
110
+ *
111
+ * @param url Request URL
112
+ * @param data Request body
113
+ * @returns Response data
114
+ */
115
+ put<T = unknown>(url: string, data?: unknown): Promise<T>;
116
+ /**
117
+ * DELETE Request
118
+ *
119
+ * @param url Request URL
120
+ * @returns Response data
121
+ */
122
+ delete<T = unknown>(url: string): Promise<T>;
123
+ /**
124
+ * PATCH Request
125
+ *
126
+ * @param url Request URL
127
+ * @param data Request body
128
+ * @returns Response data
129
+ */
130
+ patch<T = unknown>(url: string, data?: unknown): Promise<T>;
131
+ }
132
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/types/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;GAYG;AAMH;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAM/D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kBAAkB;IAClB,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACnF,sBAAsB;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,mBAAmB;IACnB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,CAAC,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AAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC7D"}
@@ -0,0 +1,327 @@
1
+ /**
2
+ * Copyright 2026 Brix Platform Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @file Internationalization Capability Type Definitions
18
+ * @description Defines core types for the internationalization system, including language switching, translation, date/number formatting, etc.
19
+ * @module @brix/runtime-sdk-api-web/types/i18n
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2.0 Added]
23
+ * Phase 1 contract layer fix: Promoted the I18nCapability interface to runtime-sdk-api-web.
24
+ *
25
+ * [Design Principles]
26
+ * - Plugins obtain translations through I18nCapability, hardcoded text is prohibited
27
+ * - Translation keys use namespace format: {moduleName}:{translationKey}
28
+ * - Language switching notifies all modules via events
29
+ * - Supports localized formatting for dates, numbers, relative time, etc.
30
+ *
31
+ * [Architectural Constraints]
32
+ * ❌ Hardcoding text in components is prohibited
33
+ * ❌ Direct use of libraries like i18next is prohibited
34
+ * ✅ Obtain translations through I18nCapability or useI18n hook
35
+ */
36
+ import type { Unsubscribe } from './event';
37
+ /**
38
+ * Locale Code
39
+ *
40
+ * <p>Language tag conforming to BCP 47 specification.</p>
41
+ *
42
+ * @example
43
+ * - 'zh-CN': Simplified Chinese
44
+ * - 'zh-TW': Traditional Chinese
45
+ * - 'en-US': American English
46
+ * - 'ja-JP': Japanese
47
+ */
48
+ export type LocaleCode = string;
49
+ /**
50
+ * Language Information
51
+ *
52
+ * <p>Describes a supported language.</p>
53
+ */
54
+ export interface LanguageInfo {
55
+ /** Locale Code */
56
+ readonly code: LocaleCode;
57
+ /** Language Name (localized display name) */
58
+ readonly name: string;
59
+ /** English Name of the Language */
60
+ readonly englishName: string;
61
+ /** Whether it's an RTL (Right-to-Left) Language */
62
+ readonly rtl?: boolean;
63
+ /** Whether it's the Default Language */
64
+ readonly isDefault?: boolean;
65
+ }
66
+ /**
67
+ * Translation Options
68
+ *
69
+ * <p>Configuration parameters controlling translation behavior.</p>
70
+ */
71
+ export interface TranslateOptions {
72
+ /**
73
+ * Interpolation Variables
74
+ *
75
+ * <p>Used to replace placeholders in translation text.</p>
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Translation template: "Welcome, {{name}}!"
80
+ * t('common:welcome', { name: 'John' }) // => "Welcome, John!"
81
+ * ```
82
+ */
83
+ readonly [key: string]: unknown;
84
+ /**
85
+ * Default Value
86
+ *
87
+ * <p>Returned when the translation key does not exist.</p>
88
+ */
89
+ readonly defaultValue?: string;
90
+ /**
91
+ * Specified Locale
92
+ *
93
+ * <p>Use specified language for translation instead of current language.</p>
94
+ */
95
+ readonly lng?: LocaleCode;
96
+ /**
97
+ * Specified Namespace
98
+ *
99
+ * <p>Overrides the namespace in the key.</p>
100
+ */
101
+ readonly ns?: string;
102
+ /**
103
+ * Plural Count
104
+ *
105
+ * <p>Used for plural rule selection.</p>
106
+ */
107
+ readonly count?: number;
108
+ }
109
+ /**
110
+ * Language Bundle
111
+ *
112
+ * <p>Translation resources under a namespace.</p>
113
+ */
114
+ export interface LanguageBundle {
115
+ /** Locale Code */
116
+ readonly locale: LocaleCode;
117
+ /** Namespace */
118
+ readonly namespace: string;
119
+ /** Translation Resources (key-value pairs) */
120
+ readonly resources: Record<string, string>;
121
+ }
122
+ /**
123
+ * Date Formatting Options
124
+ *
125
+ * <p>Subset based on Intl.DateTimeFormatOptions.</p>
126
+ */
127
+ export interface DateFormatOptions {
128
+ /** Date Style */
129
+ readonly dateStyle?: 'full' | 'long' | 'medium' | 'short';
130
+ /** Time Style */
131
+ readonly timeStyle?: 'full' | 'long' | 'medium' | 'short';
132
+ /** Time Zone */
133
+ readonly timeZone?: string;
134
+ /** Whether to Use 12-Hour Clock */
135
+ readonly hour12?: boolean;
136
+ }
137
+ /**
138
+ * Number Formatting Options
139
+ *
140
+ * <p>Subset based on Intl.NumberFormatOptions.</p>
141
+ */
142
+ export interface NumberFormatOptions {
143
+ /** Formatting Style */
144
+ readonly style?: 'decimal' | 'currency' | 'percent' | 'unit';
145
+ /** Currency Code (required when style='currency') */
146
+ readonly currency?: string;
147
+ /** Currency Display Mode */
148
+ readonly currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
149
+ /** Minimum Fraction Digits */
150
+ readonly minimumFractionDigits?: number;
151
+ /** Maximum Fraction Digits */
152
+ readonly maximumFractionDigits?: number;
153
+ /** Whether to Use Grouping (thousands separator) */
154
+ readonly useGrouping?: boolean;
155
+ }
156
+ /**
157
+ * Relative Time Formatting Options
158
+ */
159
+ export interface RelativeTimeFormatOptions {
160
+ /** Relative Time Unit */
161
+ readonly unit?: 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
162
+ /** Display Style */
163
+ readonly style?: 'long' | 'short' | 'narrow';
164
+ /** Numeric Display Mode */
165
+ readonly numeric?: 'always' | 'auto';
166
+ }
167
+ /**
168
+ * Locale Change Event
169
+ *
170
+ * <p>Event triggered when language is switched.</p>
171
+ */
172
+ export interface LocaleChangeEvent {
173
+ /** New Locale Code */
174
+ readonly locale: LocaleCode;
175
+ /** Previous Locale Code */
176
+ readonly previousLocale: LocaleCode;
177
+ /** Switch Timestamp */
178
+ readonly timestamp: number;
179
+ }
180
+ /**
181
+ * Locale Change Listener
182
+ */
183
+ export type LocaleChangeListener = (event: LocaleChangeEvent) => void;
184
+ /**
185
+ * Internationalization Capability Type Identifier
186
+ */
187
+ export declare const I18nCapabilityType: unique symbol;
188
+ /**
189
+ * Internationalization Capability Contract
190
+ *
191
+ * <p>Provides multi-language support for plugins, including translation, date/number formatting, etc.</p>
192
+ *
193
+ * <h3>Design Principles</h3>
194
+ * <ul>
195
+ * <li>Translation keys use namespace format: {moduleName}:{translationKey}</li>
196
+ * <li>Language bundles are registered when modules load</li>
197
+ * <li>Language switching notifies all modules via events</li>
198
+ * </ul>
199
+ *
200
+ * <h3>Usage Example</h3>
201
+ * ```typescript
202
+ * const i18n = context.getCapability<I18nCapability>(I18nCapabilityType);
203
+ *
204
+ * // Get translation
205
+ * const greeting = i18n.t('booking:greeting', { name: 'John' });
206
+ *
207
+ * // Format date
208
+ * const dateStr = i18n.formatDate(new Date(), { dateStyle: 'long' });
209
+ *
210
+ * // Switch language
211
+ * await i18n.setLocale('en-US');
212
+ *
213
+ * // Listen for language changes
214
+ * const unsubscribe = i18n.onLocaleChange((event) => {
215
+ * console.log(`Language changed from ${event.previousLocale} to ${event.locale}`);
216
+ * });
217
+ * ```
218
+ *
219
+ * @since 3.2.0
220
+ */
221
+ export interface I18nCapability {
222
+ /**
223
+ * Get Translation Text
224
+ *
225
+ * @param key Translation key (format: {namespace}:{key})
226
+ * @param options Translation options (interpolation variables, etc.)
227
+ * @returns Translated text
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * // Simple translation
232
+ * i18n.t('booking:pageTitle') // => "Booking Management"
233
+ *
234
+ * // With interpolation
235
+ * i18n.t('booking:welcome', { name: 'John' }) // => "Welcome, John!"
236
+ *
237
+ * // With pluralization
238
+ * i18n.t('booking:itemCount', { count: 5 }) // => "5 items"
239
+ * ```
240
+ */
241
+ t(key: string, options?: TranslateOptions): string;
242
+ /**
243
+ * Check if Translation Key Exists
244
+ *
245
+ * @param key Translation key
246
+ * @param options Options
247
+ * @returns Whether exists
248
+ */
249
+ exists(key: string, options?: {
250
+ lng?: LocaleCode;
251
+ ns?: string;
252
+ }): boolean;
253
+ /**
254
+ * Get Current Locale
255
+ *
256
+ * @returns Current locale code
257
+ */
258
+ getLocale(): LocaleCode;
259
+ /**
260
+ * Set Current Locale
261
+ *
262
+ * <p>Triggers LocaleChangeEvent after switching.</p>
263
+ *
264
+ * @param locale Target locale code
265
+ * @returns Whether switch succeeded
266
+ */
267
+ setLocale(locale: LocaleCode): Promise<boolean>;
268
+ /**
269
+ * Get Supported Locales List
270
+ *
271
+ * @returns Array of language information
272
+ */
273
+ getSupportedLocales(): LanguageInfo[];
274
+ /**
275
+ * Register Language Bundle
276
+ *
277
+ * @param bundle Language bundle definition
278
+ */
279
+ addResourceBundle(bundle: LanguageBundle): void;
280
+ /**
281
+ * Register Multiple Language Bundles
282
+ *
283
+ * @param bundles Array of language bundles
284
+ */
285
+ addResourceBundles?(bundles: LanguageBundle[]): void;
286
+ /**
287
+ * Format Date
288
+ *
289
+ * @param date Date object or timestamp
290
+ * @param options Formatting options
291
+ * @returns Formatted date string
292
+ */
293
+ formatDate?(date: Date | number, options?: DateFormatOptions): string;
294
+ /**
295
+ * Format Number
296
+ *
297
+ * @param value Numeric value
298
+ * @param options Formatting options
299
+ * @returns Formatted number string
300
+ */
301
+ formatNumber?(value: number, options?: NumberFormatOptions): string;
302
+ /**
303
+ * Format Currency
304
+ *
305
+ * @param value Amount
306
+ * @param currency Currency code (e.g., 'CNY', 'USD')
307
+ * @param options Formatting options
308
+ * @returns Formatted currency string
309
+ */
310
+ formatCurrency?(value: number, currency: string, options?: Omit<NumberFormatOptions, 'style' | 'currency'>): string;
311
+ /**
312
+ * Format Relative Time
313
+ *
314
+ * @param date Date object or timestamp
315
+ * @param options Formatting options
316
+ * @returns Relative time string (e.g., "3 days ago")
317
+ */
318
+ formatRelativeTime?(date: Date | number, options?: RelativeTimeFormatOptions): string;
319
+ /**
320
+ * Subscribe to Locale Change Event
321
+ *
322
+ * @param listener Event listener
323
+ * @returns Unsubscribe function
324
+ */
325
+ onLocaleChange?(listener: LocaleChangeListener): Unsubscribe;
326
+ }
327
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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AAM,CAAC;IAEtE;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IAEpE;;;;;;;OAOG;IACH,cAAc,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG,MAAM,CAAC;IAEpH;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,MAAM,CAAC;IAMtF;;;;;OAKG;IACH,cAAc,CAAC,CAAC,QAAQ,EAAE,oBAAoB,GAAG,WAAW,CAAC;CAC9D"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright 2026 Brix Platform Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @file Type Definitions Unified Export
18
+ * @description Re-export all type definitions from categorized files
19
+ * @module @brix/runtime-sdk-api-web/types
20
+ * @version 3.2.0
21
+ *
22
+ * [v3.2 Refactoring Notes]
23
+ * Split the original 1000+ lines in index.ts into the following modules:
24
+ * - capability.ts: Capability system types
25
+ * - plugin.ts: Plugin system types
26
+ * - navigation.ts: Navigation system types
27
+ * - state.ts: State management types
28
+ * - event.ts: Event system types
29
+ * - module.ts: Module system types
30
+ * - http.ts: HTTP client capability types
31
+ * - auth.ts: Authentication capability types
32
+ * - config.ts: Configuration capability types
33
+ * - common.ts: Common utility types and API response types
34
+ *
35
+ * [v3.2.0 Phase 1 Contract Layer Fix]
36
+ * Added the following capability interface type files:
37
+ * - i18n.ts: Internationalization capability types (I18nCapability)
38
+ * - theme.ts: Theme capability types (ThemeCapability)
39
+ * - layout.ts: Layout capability types (LayoutCapability)
40
+ *
41
+ * [Design Principles]
42
+ * - Each file has a single responsibility
43
+ * - Facilitates on-demand imports
44
+ * - Easy to maintain and extend
45
+ */
46
+ export * from './capability';
47
+ export * from './plugin';
48
+ export * from './navigation';
49
+ export * from './state';
50
+ export * from './event';
51
+ export * from './module';
52
+ export * from './http';
53
+ export * from './auth';
54
+ export * from './config';
55
+ export * from './common';
56
+ export * from './i18n';
57
+ export * from './theme';
58
+ export * from './layout';
59
+ export * from './ui';
60
+ export * from './plugin-loader-capability';
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,cAAc,cAAc,CAAC;AAK7B,cAAc,UAAU,CAAC;AAKzB,cAAc,cAAc,CAAC;AAK7B,cAAc,SAAS,CAAC;AAKxB,cAAc,SAAS,CAAC;AAKxB,cAAc,UAAU,CAAC;AAKzB,cAAc,QAAQ,CAAC;AAKvB,cAAc,QAAQ,CAAC;AAKvB,cAAc,UAAU,CAAC;AAKzB,cAAc,UAAU,CAAC;AAKzB,cAAc,QAAQ,CAAC;AAKvB,cAAc,SAAS,CAAC;AAKxB,cAAc,UAAU,CAAC;AAKzB,cAAc,MAAM,CAAC;AAKrB,cAAc,4BAA4B,CAAC"}