slicejs-web-framework 4.0.2 → 4.1.1
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/LICENSE +21 -21
- package/README.md +97 -97
- package/Slice/Components/Structural/ContextManager/ContextManager.js +422 -422
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +470 -470
- package/Slice/Components/Structural/Controller/Controller.js +1406 -1406
- package/Slice/Components/Structural/Controller/allowedValuesValidation.js +52 -52
- package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
- package/Slice/Components/Structural/Debugger/Debugger.js +1505 -1505
- package/Slice/Components/Structural/EventManager/EventManager.js +651 -651
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +985 -985
- package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -296
- package/Slice/Components/Structural/Logger/Log.js +10 -10
- package/Slice/Components/Structural/Logger/LogViewer/LogViewer.js +662 -662
- package/Slice/Components/Structural/Logger/Logger.js +225 -225
- package/Slice/Components/Structural/Router/Router.js +820 -810
- package/Slice/Components/Structural/Router/applyRouteMetadata.js +39 -0
- package/Slice/Components/Structural/StylesManager/StylesManager.js +82 -82
- package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +175 -175
- package/Slice/Slice.js +711 -710
- package/api/framework/devDepsOptimizer.js +335 -335
- package/api/framework/express.js +3 -3
- package/api/framework/precompressedStatic.js +102 -93
- package/api/framework/publicEnvResolver.js +123 -123
- package/api/framework/securityMiddleware.js +197 -197
- package/api/framework/seo.js +387 -0
- package/api/framework/server.js +777 -410
- package/api/index.js +14 -4
- package/package.json +6 -2
- package/sliceConfig.schema.json +122 -122
- package/src/App/index.html +69 -69
- package/src/App/index.js +20 -20
- package/src/App/style.css +11 -11
- package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -9
- package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -8
- package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -12
- package/src/Components/AppComponents/AppShell/AppShell.css +10 -10
- package/src/Components/AppComponents/AppShell/AppShell.html +4 -4
- package/src/Components/AppComponents/AppShell/AppShell.js +36 -36
- package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -20
- package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -10
- package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -19
- package/src/Components/components.js +8 -8
- package/src/public/Styles/sliceStyles.css +34 -34
- package/src/public/Themes/Dark.css +42 -42
- package/src/public/Themes/Light.css +31 -31
- package/src/public/Themes/Slice.css +47 -47
- package/src/public/manifest.json +15 -15
- package/src/public/robots.txt +4 -4
- package/src/public/sitemap.xml +8 -8
- package/src/routes.js +9 -9
- package/src/sliceConfig.json +72 -72
- package/types/index.d.ts +219 -219
- package/.opencode/opencode.json +0 -15
- package/Slice/tests/build-bundled-component-without-category.test.js +0 -103
- package/Slice/tests/build-js-only-visual-components.test.js +0 -144
- package/Slice/tests/build-singleton.test.js +0 -244
- package/Slice/tests/bundle-v2-runtime-contract.test.js +0 -747
- package/Slice/tests/context-patch-use.test.js +0 -95
- package/Slice/tests/destroy-cascade.test.js +0 -215
- package/Slice/tests/event-emitters.test.js +0 -79
- package/Slice/tests/event-registry.test.js +0 -141
- package/Slice/tests/fixtures/real-runtime-loader.mjs +0 -21
- package/Slice/tests/leak-orphans.test.js +0 -131
- package/Slice/tests/props-allowed-values-validation.test.js +0 -119
- package/Slice/tests/public-env-runtime-accessors.test.js +0 -44
- package/Slice/tests/public-env-typed-accessors.test.js +0 -66
- package/Slice/tests/router-loading-finally.test.js +0 -68
- package/api/tests/dev-deps-optimizer.test.js +0 -137
- package/api/tests/dev-server-external.test.js +0 -56
- package/api/tests/precompressed-static.test.js +0 -119
- package/api/tests/public-env-resolver.test.js +0 -193
- package/tests/router-build-failure.test.js +0 -125
- package/tests/router-emit-ordering.test.js +0 -63
package/src/sliceConfig.json
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
{
|
|
2
|
-
"server": {
|
|
3
|
-
"port": 3001,
|
|
4
|
-
"host": "localhost"
|
|
5
|
-
},
|
|
6
|
-
"debugger": {
|
|
7
|
-
"enabled": false,
|
|
8
|
-
"click": "right",
|
|
9
|
-
"leakInspector": {
|
|
10
|
-
"enabled": true,
|
|
11
|
-
"shortcut": "alt+shift+k"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"events": {
|
|
15
|
-
"enabled": true,
|
|
16
|
-
"ui": {
|
|
17
|
-
"enabled": true,
|
|
18
|
-
"shortcut": "alt+shift+e"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"context": {
|
|
22
|
-
"enabled": true,
|
|
23
|
-
"ui": {
|
|
24
|
-
"enabled": true,
|
|
25
|
-
"shortcut": "alt+shift+c"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"stylesManager": {
|
|
29
|
-
"requestedStyles": ["sliceStyles"]
|
|
30
|
-
},
|
|
31
|
-
"themeManager": {
|
|
32
|
-
"enabled": true,
|
|
33
|
-
"defaultTheme": "Slice",
|
|
34
|
-
"saveThemeLocally": false,
|
|
35
|
-
"useBrowserTheme": false
|
|
36
|
-
},
|
|
37
|
-
"logger": {
|
|
38
|
-
"enabled": true,
|
|
39
|
-
"showLogs": {
|
|
40
|
-
"console": {
|
|
41
|
-
"error": true,
|
|
42
|
-
"warning": true,
|
|
43
|
-
"info": false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"paths": {
|
|
48
|
-
"components": {
|
|
49
|
-
"AppComponents": {
|
|
50
|
-
"path": "/Components/AppComponents",
|
|
51
|
-
"type": "Visual"
|
|
52
|
-
},
|
|
53
|
-
"Visual": {
|
|
54
|
-
"path": "/Components/Visual",
|
|
55
|
-
"type": "Visual"
|
|
56
|
-
},
|
|
57
|
-
"Service": {
|
|
58
|
-
"path": "/Components/Service",
|
|
59
|
-
"type": "Service"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"themes": "/Themes",
|
|
63
|
-
"styles": "/Styles",
|
|
64
|
-
"routesFile": "/routes.js"
|
|
65
|
-
},
|
|
66
|
-
"router": {
|
|
67
|
-
"defaultRoute": "/"
|
|
68
|
-
},
|
|
69
|
-
"loading": {
|
|
70
|
-
"enabled": true
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"server": {
|
|
3
|
+
"port": 3001,
|
|
4
|
+
"host": "localhost"
|
|
5
|
+
},
|
|
6
|
+
"debugger": {
|
|
7
|
+
"enabled": false,
|
|
8
|
+
"click": "right",
|
|
9
|
+
"leakInspector": {
|
|
10
|
+
"enabled": true,
|
|
11
|
+
"shortcut": "alt+shift+k"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"events": {
|
|
15
|
+
"enabled": true,
|
|
16
|
+
"ui": {
|
|
17
|
+
"enabled": true,
|
|
18
|
+
"shortcut": "alt+shift+e"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"context": {
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"ui": {
|
|
24
|
+
"enabled": true,
|
|
25
|
+
"shortcut": "alt+shift+c"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"stylesManager": {
|
|
29
|
+
"requestedStyles": ["sliceStyles"]
|
|
30
|
+
},
|
|
31
|
+
"themeManager": {
|
|
32
|
+
"enabled": true,
|
|
33
|
+
"defaultTheme": "Slice",
|
|
34
|
+
"saveThemeLocally": false,
|
|
35
|
+
"useBrowserTheme": false
|
|
36
|
+
},
|
|
37
|
+
"logger": {
|
|
38
|
+
"enabled": true,
|
|
39
|
+
"showLogs": {
|
|
40
|
+
"console": {
|
|
41
|
+
"error": true,
|
|
42
|
+
"warning": true,
|
|
43
|
+
"info": false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"paths": {
|
|
48
|
+
"components": {
|
|
49
|
+
"AppComponents": {
|
|
50
|
+
"path": "/Components/AppComponents",
|
|
51
|
+
"type": "Visual"
|
|
52
|
+
},
|
|
53
|
+
"Visual": {
|
|
54
|
+
"path": "/Components/Visual",
|
|
55
|
+
"type": "Visual"
|
|
56
|
+
},
|
|
57
|
+
"Service": {
|
|
58
|
+
"path": "/Components/Service",
|
|
59
|
+
"type": "Service"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"themes": "/Themes",
|
|
63
|
+
"styles": "/Styles",
|
|
64
|
+
"routesFile": "/routes.js"
|
|
65
|
+
},
|
|
66
|
+
"router": {
|
|
67
|
+
"defaultRoute": "/"
|
|
68
|
+
},
|
|
69
|
+
"loading": {
|
|
70
|
+
"enabled": true
|
|
71
|
+
}
|
|
72
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,219 +1,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
|
-
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
|
+
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
|
+
}
|
package/.opencode/opencode.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://opencode.ai/config.json",
|
|
3
|
-
"mcp": {
|
|
4
|
-
"thinking": {
|
|
5
|
-
"type": "local",
|
|
6
|
-
"command": ["npx", "-y", "@modelcontextprotocol/server-sequential-thinking"],
|
|
7
|
-
"enabled": true
|
|
8
|
-
},
|
|
9
|
-
"slicemcp": {
|
|
10
|
-
"type": "local",
|
|
11
|
-
"command": ["npx", "-y", "slicejs-mcp"],
|
|
12
|
-
"enabled": true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|