slicejs-web-framework 4.1.0 → 4.2.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.
package/types/index.d.ts CHANGED
@@ -1,219 +1,347 @@
1
- export type SliceMode = 'development' | 'production' | string;
2
-
3
- export interface RouteConfig {
4
- path: string;
5
- component: string;
6
- children?: RouteConfig[];
7
- metadata?: Record<string, unknown>;
8
- fullPath?: string;
9
- parentPath?: string | null;
10
- parentRoute?: RouteConfig | null;
11
- }
12
-
13
- export interface RouteInfo {
14
- path: string;
15
- component: string;
16
- params: Record<string, string>;
17
- query: Record<string, string>;
18
- metadata: Record<string, unknown>;
19
- }
20
-
21
- export interface RouteMatch {
22
- route: RouteConfig | null;
23
- params: Record<string, string>;
24
- childRoute?: RouteConfig;
25
- }
26
-
27
- export type RouterNext = (arg?: void | false | string | { path: string; replace?: boolean }) => void;
28
-
29
- export interface SliceControllerApi {
30
- componentCategories: Map<string, string>;
31
- templates: Map<string, HTMLTemplateElement>;
32
- classes: Map<string, new (...args: any[]) => HTMLElement>;
33
- requestedStyles: Set<string>;
34
- activeComponents: Map<string, HTMLElement>;
35
- getComponent(sliceId: string): HTMLElement | undefined;
36
- getComponentCategory(componentSliceId: string): string | undefined;
37
- fetchText(
38
- componentName: string,
39
- resourceType: 'html' | 'css' | 'theme' | 'styles',
40
- componentCategory?: string,
41
- customPath?: string
42
- ): Promise<string>;
43
- setComponentProps(component: HTMLElement, props: Record<string, unknown>): void;
44
- destroyComponent(components: HTMLElement | string | Array<HTMLElement | string>): number;
45
- destroyByContainer(container: HTMLElement): number;
46
- destroyByPattern(pattern: string | RegExp): number;
47
- findOrphans(): Array<{ sliceId: string; name: string; reason: string; retainPath: string[] }>;
48
- registerLeakExclusion(predicate: (component: HTMLElement) => boolean): void;
49
- sampleComponentGrowth(): void;
50
- isGrowthMonotonic(): boolean;
51
- }
52
-
53
- export interface SliceStylesManagerApi {
54
- componentStyles: HTMLStyleElement;
55
- themeManager?: SliceThemeManagerApi;
56
- init(): Promise<void>;
57
- appendComponentStyles(cssText: string): void;
58
- registerComponentStyles(componentName: string, cssText: string): void;
59
- }
60
-
61
- export interface SliceThemeManagerApi {
62
- currentTheme: string | null;
63
- applyTheme(themeName: string): Promise<void>;
64
- }
65
-
66
- export interface SliceLoggerApi {
67
- logError(componentSliceId: string, message: string, error?: unknown): void;
68
- logWarning(componentSliceId: string, message: string): void;
69
- logInfo(componentSliceId: string, message: string): void;
70
- getLogs(): unknown[];
71
- clearLogs(): void;
72
- }
73
-
74
- export interface SliceEventBindingApi {
75
- subscribe(eventName: string, callback: (data?: unknown) => void): string | null;
76
- subscribeOnce(eventName: string, callback: (data?: unknown) => void): string | null;
77
- emit(eventName: string, data?: unknown): void;
78
- }
79
-
80
- export interface SliceEventManagerApi {
81
- init(): boolean;
82
- subscribe(
83
- eventName: string,
84
- callback: (data?: unknown) => void,
85
- options?: { component?: HTMLElement }
86
- ): string | null;
87
- subscribeOnce(
88
- eventName: string,
89
- callback: (data?: unknown) => void,
90
- options?: { component?: HTMLElement }
91
- ): string | null;
92
- unsubscribe(eventName: string, subscriptionId: string): boolean;
93
- emit(eventName: string, ...data: unknown[]): void;
94
- bind(component: HTMLElement): SliceEventBindingApi | null;
95
- register(namespace: string, catalog: Record<string, { description?: string; payload?: unknown }>): SliceEventManagerApi;
96
- register(catalog: Record<string, { description?: string; payload?: unknown }>): SliceEventManagerApi;
97
- loadGraph(graph: { events: Record<string, unknown>; dynamic?: unknown }): SliceEventManagerApi;
98
- staticEmittersOf(eventName: string): Array<{ file: string; line: number; component: string | null }>;
99
- staticListenersOf(eventName: string): Array<{ file: string; line: number; component: string | null }>;
100
- isDeclared(eventName: string): boolean;
101
- namespaceOf(eventName: string): string | null;
102
- cleanupComponent(sliceId: string): number;
103
- hasSubscribers(eventName: string): boolean;
104
- subscriberCount(eventName: string): number;
105
- clear(): void;
106
- }
107
-
108
- export interface SliceContextOptions {
109
- persist?: boolean;
110
- storageKey?: string;
111
- }
112
-
113
- export interface SliceContextManagerApi {
114
- init(): boolean;
115
- create(name: string, initialState?: Record<string, unknown>, options?: SliceContextOptions): boolean;
116
- getState<T = unknown>(name: string): T | null;
117
- setState<T = unknown>(name: string, updater: T | ((prevState: T) => T)): void;
118
- watch<TSelected = unknown>(
119
- name: string,
120
- component: HTMLElement,
121
- callback: (value: TSelected) => void,
122
- selector?: (state: unknown) => TSelected
123
- ): string | null;
124
- has(name: string): boolean;
125
- destroy(name: string): boolean;
126
- list(): string[];
127
- }
128
-
129
- export interface SliceRouterApi {
130
- activeRoute: RouteConfig | null;
131
- pathToRouteMap: Map<string, RouteConfig>;
132
- init(): void;
133
- start(): Promise<void>;
134
- beforeEach(guard: (to: RouteInfo, from: RouteInfo, next: RouterNext) => void | Promise<void>): void;
135
- afterEach(guard: (to: RouteInfo, from: RouteInfo) => void): void;
136
- navigate(path: string, redirectChain?: string[], options?: { replace?: boolean }): Promise<void>;
137
- matchRoute(path: string): RouteMatch;
138
- }
139
-
140
- export interface SlicePanelDebuggerApi {
141
- init(): Promise<void>;
142
- toggle(): void;
143
- open(): void;
144
- close(): void;
145
- }
146
-
147
- export interface SliceDebuggerApi {
148
- enableDebugMode(): Promise<boolean>;
149
- attachDebugMode(component: HTMLElement): void;
150
- hide(): void;
151
- }
152
-
153
- export interface SliceLoadingApi {
154
- start?: () => void;
155
- stop?: () => void;
156
- }
157
-
158
- export interface SlicePaths {
159
- routesFile?: string;
160
- themes?: string;
161
- styles?: string;
162
- structuralComponentFolderPath?: string;
163
- components?: Record<string, { path: string; type?: string }>;
164
- [key: string]: unknown;
165
- }
166
-
167
- export interface SliceFrameworkClasses {
168
- Controller?: new () => SliceControllerApi;
169
- StylesManager?: new () => SliceStylesManagerApi;
170
- Router?: new (routes: RouteConfig[]) => SliceRouterApi;
171
- Logger?: new () => SliceLoggerApi;
172
- EventManager?: new () => SliceEventManagerApi;
173
- ContextManager?: new () => SliceContextManagerApi;
174
- Debugger?: new () => SliceDebuggerApi;
175
- EventManagerDebugger?: new () => SlicePanelDebuggerApi;
176
- ContextManagerDebugger?: new () => SlicePanelDebuggerApi;
177
- ThemeManager?: new () => SliceThemeManagerApi;
178
- [key: string]: unknown;
179
- }
180
-
181
- export interface SliceApi {
182
- frameworkClasses: SliceFrameworkClasses | null;
183
- controller: SliceControllerApi;
184
- stylesManager: SliceStylesManagerApi;
185
- logger: SliceLoggerApi;
186
- router: SliceRouterApi;
187
- events: SliceEventManagerApi;
188
- context: SliceContextManagerApi;
189
- debugger?: SliceDebuggerApi;
190
- eventsDebugger?: SlicePanelDebuggerApi;
191
- contextDebugger?: SlicePanelDebuggerApi;
192
- leakInspector?: SlicePanelDebuggerApi;
193
- loading?: SliceLoadingApi;
194
- paths: SlicePaths;
195
- _mode: SliceMode;
196
- getClass<T = unknown>(module: string): Promise<T | undefined>;
197
- isProduction(): boolean;
198
- getEnv(name: string, fallbackValue?: string): string | undefined;
199
- getPublicEnv(): Record<string, string>;
200
- getComponent(componentSliceId: string): HTMLElement | undefined;
201
- build<T = HTMLElement>(componentName: string, props?: Record<string, unknown>): Promise<T | null>;
202
- setTheme(themeName: string): Promise<void>;
203
- readonly theme: string | null;
204
- attachTemplate(componentInstance: HTMLElement): void;
205
- }
206
-
207
- declare class Slice {
208
- constructor(sliceConfig: Record<string, unknown>, frameworkClasses?: SliceFrameworkClasses | null);
209
- }
210
-
211
- export default Slice;
212
-
213
- declare global {
214
- interface Window {
215
- slice: SliceApi;
216
- }
217
-
218
- const slice: SliceApi;
219
- }
1
+ export type SliceMode = 'development' | 'production' | string;
2
+
3
+ export interface RouteConfig {
4
+ path: string;
5
+ component: string;
6
+ children?: RouteConfig[];
7
+ metadata?: Record<string, unknown>;
8
+ fullPath?: string;
9
+ parentPath?: string | null;
10
+ parentRoute?: RouteConfig | null;
11
+ }
12
+
13
+ export interface RouteInfo {
14
+ /** The app path, without locale prefix: '/pricing'. */
15
+ path: string;
16
+ component: string;
17
+ params: Record<string, string>;
18
+ query: Record<string, string>;
19
+ metadata: Record<string, unknown>;
20
+ /** The locale of this navigation (null without slice.translator). */
21
+ locale: string | null;
22
+ /** What the address bar shows: '/en/pricing' with routing, '/pricing' without. */
23
+ url: string;
24
+ }
25
+
26
+ export interface RouteMatch {
27
+ route: RouteConfig | null;
28
+ params: Record<string, string>;
29
+ childRoute?: RouteConfig;
30
+ }
31
+
32
+ export type RouterNext = (arg?: void | false | string | { path: string; replace?: boolean }) => void;
33
+
34
+ export interface SliceControllerApi {
35
+ componentCategories: Map<string, string>;
36
+ templates: Map<string, HTMLTemplateElement>;
37
+ classes: Map<string, new (...args: any[]) => HTMLElement>;
38
+ requestedStyles: Set<string>;
39
+ activeComponents: Map<string, HTMLElement>;
40
+ getComponent(sliceId: string): HTMLElement | undefined;
41
+ getComponentCategory(componentSliceId: string): string | undefined;
42
+ fetchText(
43
+ componentName: string,
44
+ resourceType: 'html' | 'css' | 'theme' | 'styles',
45
+ componentCategory?: string,
46
+ customPath?: string
47
+ ): Promise<string>;
48
+ setComponentProps(component: HTMLElement, props: Record<string, unknown>): void;
49
+ destroyComponent(components: HTMLElement | string | Array<HTMLElement | string>): number;
50
+ destroyByContainer(container: HTMLElement): number;
51
+ destroyByPattern(pattern: string | RegExp): number;
52
+ findOrphans(): Array<{ sliceId: string; name: string; reason: string; retainPath: string[] }>;
53
+ registerLeakExclusion(predicate: (component: HTMLElement) => boolean): void;
54
+ sampleComponentGrowth(): void;
55
+ isGrowthMonotonic(): boolean;
56
+ }
57
+
58
+ export interface SliceStylesManagerApi {
59
+ componentStyles: HTMLStyleElement;
60
+ themeManager?: SliceThemeManagerApi;
61
+ init(): Promise<void>;
62
+ appendComponentStyles(cssText: string): void;
63
+ registerComponentStyles(componentName: string, cssText: string): void;
64
+ }
65
+
66
+ export interface SliceThemeManagerApi {
67
+ currentTheme: string | null;
68
+ applyTheme(themeName: string): Promise<void>;
69
+ }
70
+
71
+ export interface SliceLoggerApi {
72
+ logError(componentSliceId: string, message: string, error?: unknown): void;
73
+ logWarning(componentSliceId: string, message: string): void;
74
+ logInfo(componentSliceId: string, message: string): void;
75
+ getLogs(): unknown[];
76
+ clearLogs(): void;
77
+ }
78
+
79
+ export interface SliceEventBindingApi {
80
+ subscribe(eventName: string, callback: (data?: unknown) => void): string | null;
81
+ subscribeOnce(eventName: string, callback: (data?: unknown) => void): string | null;
82
+ emit(eventName: string, data?: unknown): void;
83
+ }
84
+
85
+ export interface SliceEventManagerApi {
86
+ init(): boolean;
87
+ subscribe(
88
+ eventName: string,
89
+ callback: (data?: unknown) => void,
90
+ options?: { component?: HTMLElement }
91
+ ): string | null;
92
+ subscribeOnce(
93
+ eventName: string,
94
+ callback: (data?: unknown) => void,
95
+ options?: { component?: HTMLElement }
96
+ ): string | null;
97
+ unsubscribe(eventName: string, subscriptionId: string): boolean;
98
+ emit(eventName: string, ...data: unknown[]): void;
99
+ bind(component: HTMLElement): SliceEventBindingApi | null;
100
+ register(namespace: string, catalog: Record<string, { description?: string; payload?: unknown }>): SliceEventManagerApi;
101
+ register(catalog: Record<string, { description?: string; payload?: unknown }>): SliceEventManagerApi;
102
+ loadGraph(graph: { events: Record<string, unknown>; dynamic?: unknown }): SliceEventManagerApi;
103
+ staticEmittersOf(eventName: string): Array<{ file: string; line: number; component: string | null }>;
104
+ staticListenersOf(eventName: string): Array<{ file: string; line: number; component: string | null }>;
105
+ isDeclared(eventName: string): boolean;
106
+ namespaceOf(eventName: string): string | null;
107
+ cleanupComponent(sliceId: string): number;
108
+ hasSubscribers(eventName: string): boolean;
109
+ subscriberCount(eventName: string): number;
110
+ clear(): void;
111
+ }
112
+
113
+ export interface SliceContextOptions {
114
+ persist?: boolean;
115
+ storageKey?: string;
116
+ }
117
+
118
+ export interface SliceContextManagerApi {
119
+ init(): boolean;
120
+ create(name: string, initialState?: Record<string, unknown>, options?: SliceContextOptions): boolean;
121
+ getState<T = unknown>(name: string): T | null;
122
+ setState<T = unknown>(name: string, updater: T | ((prevState: T) => T)): void;
123
+ watch<TSelected = unknown>(
124
+ name: string,
125
+ component: HTMLElement,
126
+ callback: (value: TSelected) => void,
127
+ selector?: (state: unknown) => TSelected
128
+ ): string | null;
129
+ has(name: string): boolean;
130
+ destroy(name: string): boolean;
131
+ list(): string[];
132
+ }
133
+
134
+ export interface SliceRouterApi {
135
+ activeRoute: RouteConfig | null;
136
+ pathToRouteMap: Map<string, RouteConfig>;
137
+ init(): void;
138
+ start(): Promise<void>;
139
+ beforeEach(guard: (to: RouteInfo, from: RouteInfo, next: RouterNext) => void | Promise<void>): void;
140
+ afterEach(guard: (to: RouteInfo, from: RouteInfo) => void): void;
141
+ navigate(path: string, options?: { replace?: boolean; locale?: string }): Promise<void>;
142
+ /** @deprecated legacy signature */
143
+ navigate(path: string, redirectChain: string[], options?: { replace?: boolean; locale?: string }): Promise<void>;
144
+ /** Strips a known locale prefix before matching. */
145
+ matchRoute(path: string): RouteMatch;
146
+ /** The current app path, without locale prefix. */
147
+ readonly path: string;
148
+ /** The URL for an app path in the active (or given) locale. */
149
+ href(path: string, options?: { locale?: string }): string;
150
+ /** Metadata of the route being shown (re-applied, translated, after a locale change). */
151
+ activeMetadata: Record<string, unknown> | null;
152
+ applyMetadata(metadata: Record<string, unknown> | null): void;
153
+ }
154
+
155
+ export type TranslatorParams = Record<string, string | number | TranslationRef>;
156
+
157
+ /** A key reference for a component prop, from `slice.t.ref()`. */
158
+ export interface TranslationRef {
159
+ readonly key: string;
160
+ readonly params?: Readonly<TranslatorParams>;
161
+ }
162
+
163
+ /** A list reference for a component prop, from `slice.t.ref.list()`. */
164
+ export interface TranslationListRef {
165
+ readonly key: string;
166
+ readonly params?: Readonly<TranslatorParams>;
167
+ }
168
+
169
+ export interface TranslatorConfig {
170
+ enabled?: boolean;
171
+ defaultLocale?: string;
172
+ fallbackLocale?: string | null;
173
+ locales?: string[];
174
+ path?: string;
175
+ saveLocally?: boolean;
176
+ useBrowserLocale?: boolean;
177
+ routing?: false | 'prefix' | 'prefix-except-default';
178
+ ui?: { enabled?: boolean; shortcut?: string };
179
+ }
180
+
181
+ export interface SliceTranslatorFormatApi {
182
+ number(value: number, options?: Intl.NumberFormatOptions): string;
183
+ currency(value: number, currency: string, options?: Intl.NumberFormatOptions): string;
184
+ percent(value: number, options?: Intl.NumberFormatOptions): string;
185
+ date(value: Date | number | string, options?: Intl.DateTimeFormatOptions): string;
186
+ time(value: Date | number | string, options?: Intl.DateTimeFormatOptions): string;
187
+ relative(value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions): string;
188
+ list(items: string[], options?: Intl.ListFormatOptions): string;
189
+ }
190
+
191
+ export interface SliceTranslatorApi {
192
+ readonly enabled: boolean;
193
+ /** The active locale, e.g. 'es'. */
194
+ readonly locale: string;
195
+ readonly locales: readonly string[];
196
+ readonly defaultLocale: string;
197
+ readonly fallbackLocale: string | null;
198
+ readonly format: SliceTranslatorFormatApi;
199
+ /** Translate a key; returns the key when it is missing (or the translator is off). */
200
+ t(key: string, params?: TranslatorParams): string;
201
+ /** Translate a list of messages, or read a list of records; `[]` when missing. */
202
+ list<T = unknown>(key: string, params?: TranslatorParams): T[];
203
+ /** Resolve a localized content value (`{ en: …, es: … }`) for the active locale. */
204
+ localized<T = unknown>(value: T): T;
205
+ /** Load `<path>/content/<name>.json` and resolve its `copy` branches for the active locale. */
206
+ content(name: string): Promise<Record<string, unknown> | null>;
207
+ has(key: string, locale?: string): boolean;
208
+ /** Merge messages; `{ defaults: true }` adds a layer the app's dictionaries always override. */
209
+ add(locale: string, messages: Record<string, unknown>, options?: { defaults?: boolean }): void;
210
+ /** Load `<path>/<locale>/<namespace>.json` for the active locale and the fallback. */
211
+ load(namespace: string): Promise<void>;
212
+ setLocale(locale: string): Promise<string>;
213
+ /** Load a locale's dictionaries without switching to it; resolves to the configured locale. */
214
+ preload(locale: string): Promise<string>;
215
+ readonly routing: false | 'prefix' | 'prefix-except-default';
216
+ /** '/en/pricing' → { locale: 'en', path: '/pricing' } (whole URL, locale null, without routing). */
217
+ splitPath(url: string): { locale: string | null; path: string };
218
+ /** The URL of an app path in a locale (default: the active one). */
219
+ localizePath(path: string, locale?: string): string;
220
+ /** The locale a URL stands for; null without routing. */
221
+ localeOfUrl(url: string): string | null;
222
+ /** Rewrite the address bar to the active locale (replaceState). */
223
+ syncUrl(): void;
224
+ /** A key reference for a component prop: resolved before the component sees it, refreshed on a locale change. */
225
+ ref(key: string, params?: TranslatorParams): TranslationRef;
226
+ /** A list reference for a component prop: resolves to an array, refreshed on a locale change. */
227
+ refList(key: string, params?: TranslatorParams): TranslationListRef;
228
+ isRef(value: unknown): boolean;
229
+ resolve<T = unknown>(value: T): T;
230
+ /** Translate every `data-t` element under `root` (default: the document) right now. */
231
+ apply(root?: ParentNode): number;
232
+ /** Called after every locale change; with a component, until it is destroyed. Returns an unsubscribe function. */
233
+ watch(component: object, callback: (locale: string, previous: string) => void): () => void;
234
+ watch(callback: (locale: string, previous: string) => void): () => void;
235
+ forget(component: object): void;
236
+ /** Debugger switch: `t()` returns keys instead of texts. Re-renders the document. */
237
+ showKeys: boolean;
238
+ setShowKeys(enabled: boolean): boolean;
239
+ }
240
+
241
+ export interface SlicePanelDebuggerApi {
242
+ init(): Promise<void>;
243
+ toggle(): void;
244
+ open(): void;
245
+ close(): void;
246
+ }
247
+
248
+ export interface SliceDebuggerApi {
249
+ enableDebugMode(): Promise<boolean>;
250
+ attachDebugMode(component: HTMLElement): void;
251
+ hide(): void;
252
+ }
253
+
254
+ export interface SliceLoadingApi {
255
+ start?: () => void;
256
+ stop?: () => void;
257
+ }
258
+
259
+ export interface SlicePaths {
260
+ routesFile?: string;
261
+ themes?: string;
262
+ styles?: string;
263
+ structuralComponentFolderPath?: string;
264
+ components?: Record<string, { path: string; type?: string }>;
265
+ [key: string]: unknown;
266
+ }
267
+
268
+ export interface SliceFrameworkClasses {
269
+ Controller?: new () => SliceControllerApi;
270
+ StylesManager?: new () => SliceStylesManagerApi;
271
+ Router?: new (routes: RouteConfig[]) => SliceRouterApi;
272
+ Logger?: new () => SliceLoggerApi;
273
+ EventManager?: new () => SliceEventManagerApi;
274
+ ContextManager?: new () => SliceContextManagerApi;
275
+ Debugger?: new () => SliceDebuggerApi;
276
+ EventManagerDebugger?: new () => SlicePanelDebuggerApi;
277
+ ContextManagerDebugger?: new () => SlicePanelDebuggerApi;
278
+ ThemeManager?: new () => SliceThemeManagerApi;
279
+ Translator?: new (config?: TranslatorConfig) => SliceTranslatorApi;
280
+ TranslatorDebugger?: new () => SlicePanelDebuggerApi;
281
+ [key: string]: unknown;
282
+ }
283
+
284
+ /** `slice.t.ref` and its `slice.t.ref.list` namespace. */
285
+ export interface SliceTranslateRef {
286
+ (key: string, params?: TranslatorParams): TranslationRef;
287
+ list(key: string, params?: TranslatorParams): TranslationListRef;
288
+ }
289
+
290
+ /** `slice.t`: call it for text, `slice.t.ref()` for a prop reference. */
291
+ export interface SliceTranslate {
292
+ (key: string, params?: TranslatorParams): string;
293
+ ref: SliceTranslateRef;
294
+ list<T = unknown>(key: string, params?: TranslatorParams): T[];
295
+ localized<T = unknown>(value: T): T;
296
+ content(name: string): Promise<Record<string, unknown> | null>;
297
+ }
298
+
299
+ export interface SliceApi {
300
+ frameworkClasses: SliceFrameworkClasses | null;
301
+ controller: SliceControllerApi;
302
+ stylesManager: SliceStylesManagerApi;
303
+ logger: SliceLoggerApi;
304
+ router: SliceRouterApi;
305
+ events: SliceEventManagerApi;
306
+ context: SliceContextManagerApi;
307
+ translator: SliceTranslatorApi;
308
+ debugger?: SliceDebuggerApi;
309
+ eventsDebugger?: SlicePanelDebuggerApi;
310
+ contextDebugger?: SlicePanelDebuggerApi;
311
+ translatorDebugger?: SlicePanelDebuggerApi;
312
+ leakInspector?: SlicePanelDebuggerApi;
313
+ loading?: SliceLoadingApi;
314
+ paths: SlicePaths;
315
+ _mode: SliceMode;
316
+ getClass<T = unknown>(module: string): Promise<T | undefined>;
317
+ isProduction(): boolean;
318
+ getEnv(name: string, fallbackValue?: string): string | undefined;
319
+ getPublicEnv(): Record<string, string>;
320
+ getComponent(componentSliceId: string): HTMLElement | undefined;
321
+ build<T = HTMLElement>(componentName: string, props?: Record<string, unknown>): Promise<T | null>;
322
+ setTheme(themeName: string): Promise<void>;
323
+ readonly theme: string | null;
324
+ /** The app path the router is showing, without locale or query. */
325
+ readonly path: string;
326
+ /** The URL for an app path in the active (or given) locale. */
327
+ href(path: string, options?: { locale?: string }): string;
328
+ attachTemplate(componentInstance: HTMLElement): void;
329
+ /** `t()` returns text; `t.ref()` returns a reference for a prop. */
330
+ t: SliceTranslate;
331
+ /** The active locale. */
332
+ readonly locale: string;
333
+ }
334
+
335
+ declare class Slice {
336
+ constructor(sliceConfig: Record<string, unknown>, frameworkClasses?: SliceFrameworkClasses | null);
337
+ }
338
+
339
+ export default Slice;
340
+
341
+ declare global {
342
+ interface Window {
343
+ slice: SliceApi;
344
+ }
345
+
346
+ const slice: SliceApi;
347
+ }