@jasonshimmy/custom-elements-runtime 0.0.3 → 0.0.4-beta.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/README.md +50 -44
- package/dist/custom-elements-runtime.cjs.js +5 -5
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +307 -235
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.umd.js +5 -5
- package/dist/custom-elements-runtime.umd.js.map +1 -1
- package/dist/router.d.ts +52 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/store.d.ts +4 -8
- package/package.json +1 -1
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight, scalable router for Custom Elements Runtime
|
|
3
|
+
* - Functional API, zero dependencies, SSR/static site compatible
|
|
4
|
+
* - Integrates with Store and runtime.ts
|
|
5
|
+
*/
|
|
6
|
+
export interface Route {
|
|
7
|
+
path: string;
|
|
8
|
+
component: string;
|
|
9
|
+
}
|
|
10
|
+
export interface RouterConfig {
|
|
11
|
+
routes: Route[];
|
|
12
|
+
base?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface RouteState {
|
|
15
|
+
path: string;
|
|
16
|
+
params: Record<string, string>;
|
|
17
|
+
query: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export declare function useRouter(config: RouterConfig): {
|
|
20
|
+
store: {
|
|
21
|
+
subscribe: (listener: (state: object) => void) => void;
|
|
22
|
+
getState: () => object;
|
|
23
|
+
};
|
|
24
|
+
push: (path: string) => void;
|
|
25
|
+
replace: (path: string) => void;
|
|
26
|
+
back: () => void;
|
|
27
|
+
subscribe: (listener: (state: object) => void) => void;
|
|
28
|
+
matchRoute: (path: string) => {
|
|
29
|
+
route: Route | null;
|
|
30
|
+
params: Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
getCurrent: () => object;
|
|
33
|
+
};
|
|
34
|
+
export declare function initRouter(config: RouterConfig): {
|
|
35
|
+
store: {
|
|
36
|
+
subscribe: (listener: (state: object) => void) => void;
|
|
37
|
+
getState: () => object;
|
|
38
|
+
};
|
|
39
|
+
push: (path: string) => void;
|
|
40
|
+
replace: (path: string) => void;
|
|
41
|
+
back: () => void;
|
|
42
|
+
subscribe: (listener: (state: object) => void) => void;
|
|
43
|
+
matchRoute: (path: string) => {
|
|
44
|
+
route: Route | null;
|
|
45
|
+
params: Record<string, string>;
|
|
46
|
+
};
|
|
47
|
+
getCurrent: () => object;
|
|
48
|
+
};
|
|
49
|
+
export declare function matchRouteSSR(routes: Route[], path: string): {
|
|
50
|
+
route: Route | null;
|
|
51
|
+
params: Record<string, string>;
|
|
52
|
+
};
|
package/dist/runtime.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ export { useDataModel } from './data-binding';
|
|
|
79
79
|
export { compileTemplate, renderCompiledTemplate, updateCompiledTemplate } from './template-compiler';
|
|
80
80
|
export { mountVNode, patchVNode, createVNodeFromElement, parseVNodeFromHTML, safeReplaceChild, getVNodeKey } from './v-dom';
|
|
81
81
|
export type { VNode } from './v-dom';
|
|
82
|
+
export { initRouter, useRouter, matchRouteSSR } from './router';
|
|
83
|
+
export type { RouterConfig, RouteState } from './router';
|
|
82
84
|
import type { CompiledTemplate } from './template-compiler';
|
|
83
85
|
/**
|
|
84
86
|
* Recursively sanitizes an object, removing dangerous keys and prototype pollution.
|
package/dist/store.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
type Listener<T> = (state: T) => void;
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
subscribe(listener: Listener<T>): void;
|
|
7
|
-
getState(): T;
|
|
8
|
-
private notify;
|
|
9
|
-
}
|
|
2
|
+
export declare function Store<T extends object>(initial: T): {
|
|
3
|
+
subscribe: (listener: Listener<T>) => void;
|
|
4
|
+
getState: () => T;
|
|
5
|
+
};
|
|
10
6
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jasonshimmy/custom-elements-runtime",
|
|
3
3
|
"description": "A powerful, modern, and lightweight runtime for creating reactive web components with TypeScript",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4-beta.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"web-components",
|