frontend-hamroun 1.2.75 → 1.2.77

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 (113) hide show
  1. package/dist/batch/package.json +16 -0
  2. package/dist/client-router/package.json +16 -0
  3. package/dist/component/package.json +16 -0
  4. package/dist/context/package.json +16 -0
  5. package/dist/event-bus/package.json +16 -0
  6. package/dist/forms/package.json +16 -0
  7. package/dist/hooks/package.json +16 -0
  8. package/dist/jsx-runtime/package.json +16 -0
  9. package/dist/lifecycle-events/package.json +16 -0
  10. package/dist/package.json +71 -0
  11. package/dist/render-component/package.json +16 -0
  12. package/dist/renderer/package.json +16 -0
  13. package/dist/router/package.json +16 -0
  14. package/dist/server/package.json +17 -0
  15. package/dist/server/src/client-router.d.ts +60 -0
  16. package/dist/server/src/client-router.js +210 -0
  17. package/dist/server/src/client-router.js.map +1 -0
  18. package/dist/server/src/component.js +1 -1
  19. package/dist/server/src/event-bus.d.ts +23 -0
  20. package/dist/server/src/event-bus.js +75 -0
  21. package/dist/server/src/event-bus.js.map +1 -0
  22. package/dist/server/src/forms.d.ts +40 -0
  23. package/dist/server/src/forms.js +148 -0
  24. package/dist/server/src/forms.js.map +1 -0
  25. package/dist/server/src/hooks.js +2 -2
  26. package/dist/server/src/index.js +19 -11
  27. package/dist/server/src/lifecycle-events.d.ts +108 -0
  28. package/dist/server/src/lifecycle-events.js +177 -0
  29. package/dist/server/src/lifecycle-events.js.map +1 -0
  30. package/dist/server/src/renderComponent.js +1 -1
  31. package/dist/server/src/renderer.js +3 -3
  32. package/dist/server/src/router.d.ts +55 -0
  33. package/dist/server/src/router.js +166 -0
  34. package/dist/server/src/router.js.map +1 -0
  35. package/dist/server/src/server/index.d.ts +75 -2
  36. package/dist/server/src/server/index.js +224 -8
  37. package/dist/server/src/server/index.js.map +1 -1
  38. package/dist/server/src/server/server.js +1 -1
  39. package/dist/server/src/server/templates.d.ts +28 -0
  40. package/dist/server/src/server/templates.js +204 -0
  41. package/dist/server/src/server/templates.js.map +1 -0
  42. package/dist/server/src/server/utils.d.ts +70 -0
  43. package/dist/server/src/server/utils.js +156 -0
  44. package/dist/server/src/server/utils.js.map +1 -0
  45. package/dist/server/src/server-renderer.js +1 -1
  46. package/dist/server/src/store.d.ts +41 -0
  47. package/dist/server/src/store.js +99 -0
  48. package/dist/server/src/store.js.map +1 -0
  49. package/dist/server/src/utils.d.ts +46 -0
  50. package/dist/server/src/utils.js +144 -0
  51. package/dist/server/src/utils.js.map +1 -0
  52. package/dist/server/tsconfig.server.tsbuildinfo +1 -1
  53. package/dist/server-renderer/package.json +16 -0
  54. package/dist/store/package.json +16 -0
  55. package/dist/types/package.json +16 -0
  56. package/dist/utils/package.json +16 -0
  57. package/dist/vdom/package.json +16 -0
  58. package/dist/wasm/package.json +16 -0
  59. package/package.json +14 -13
  60. package/templates/complete-app/build.js +284 -0
  61. package/templates/complete-app/package.json +40 -0
  62. package/templates/complete-app/public/styles.css +345 -0
  63. package/templates/complete-app/src/api/index.js +31 -0
  64. package/templates/complete-app/src/client.js +93 -0
  65. package/templates/complete-app/src/components/App.js +66 -0
  66. package/templates/complete-app/src/components/Footer.js +19 -0
  67. package/templates/complete-app/src/components/Header.js +38 -0
  68. package/templates/complete-app/src/pages/About.js +59 -0
  69. package/templates/complete-app/src/pages/Home.js +54 -0
  70. package/templates/complete-app/src/pages/WasmDemo.js +136 -0
  71. package/templates/complete-app/src/server.js +186 -0
  72. package/templates/complete-app/src/wasm/build.bat +16 -0
  73. package/templates/complete-app/src/wasm/build.sh +16 -0
  74. package/templates/complete-app/src/wasm/example.go +101 -0
  75. package/templates/fullstack-app/build/main.css +225 -15
  76. package/templates/fullstack-app/build/main.css.map +2 -2
  77. package/templates/fullstack-app/build/main.js +657 -372
  78. package/templates/fullstack-app/build/main.js.map +4 -4
  79. package/templates/fullstack-app/build.ts +3 -4
  80. package/templates/fullstack-app/public/styles.css +222 -15
  81. package/templates/fullstack-app/server.ts +46 -12
  82. package/templates/fullstack-app/src/components/ClientHome.tsx +0 -0
  83. package/templates/fullstack-app/src/components/ErrorBoundary.tsx +36 -0
  84. package/templates/fullstack-app/src/components/Layout.tsx +23 -26
  85. package/templates/fullstack-app/src/components/StateDemo.tsx +207 -0
  86. package/templates/fullstack-app/src/components/UserList.tsx +30 -13
  87. package/templates/fullstack-app/src/data/api.ts +173 -38
  88. package/templates/fullstack-app/src/main.tsx +88 -154
  89. package/templates/fullstack-app/src/middleware.ts +28 -0
  90. package/templates/fullstack-app/src/pages/404.tsx +28 -0
  91. package/templates/fullstack-app/src/pages/[id].tsx +0 -0
  92. package/templates/fullstack-app/src/pages/_app.tsx +11 -0
  93. package/templates/fullstack-app/src/pages/_document.tsx +25 -0
  94. package/templates/fullstack-app/src/pages/_error.tsx +45 -0
  95. package/templates/fullstack-app/src/pages/about.tsx +71 -0
  96. package/templates/fullstack-app/src/pages/api/users/[id].ts +73 -0
  97. package/templates/fullstack-app/src/pages/api/users/index.ts +43 -0
  98. package/templates/fullstack-app/src/pages/index.tsx +97 -20
  99. package/templates/fullstack-app/src/pages/users/[id].tsx +153 -0
  100. package/templates/fullstack-app/src/pages/wasm-demo.tsx +1 -0
  101. package/templates/go/example.go +99 -86
  102. package/templates/go-wasm-app/babel.config.js +8 -2
  103. package/templates/go-wasm-app/build.config.js +62 -0
  104. package/templates/go-wasm-app/build.js +218 -0
  105. package/templates/go-wasm-app/package.json +21 -12
  106. package/templates/go-wasm-app/server.js +59 -510
  107. package/templates/go-wasm-app/src/app.js +173 -0
  108. package/templates/go-wasm-app/vite.config.js +16 -5
  109. package/templates/ssr-template/client.js +54 -26
  110. package/templates/ssr-template/server.js +5 -28
  111. package/templates/ssr-template/vite.config.js +21 -5
  112. package/dist/server/wasm.d.ts +0 -7
  113. package/dist/wasm.d.ts +0 -37
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/batch",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/client-router",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/component",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/context",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/event-bus",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/forms",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/hooks",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/jsx-runtime",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/lifecycle-events",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "frontend-hamroun",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ },
14
+ "./jsx-runtime": {
15
+ "import": "./jsx-runtime/index.mjs",
16
+ "require": "./jsx-runtime/index.js",
17
+ "types": "./jsx-runtime/index.d.ts"
18
+ },
19
+ "./server": {
20
+ "import": "./server/index.mjs",
21
+ "require": "./server/index.js",
22
+ "types": "./server/index.d.ts"
23
+ },
24
+ "./wasm": {
25
+ "import": "./wasm/index.mjs",
26
+ "require": "./wasm/index.js",
27
+ "types": "./wasm/index.d.ts"
28
+ },
29
+ "./router": {
30
+ "import": "./router/index.mjs",
31
+ "require": "./router/index.js",
32
+ "types": "./router/index.d.ts"
33
+ },
34
+ "./forms": {
35
+ "import": "./forms/index.mjs",
36
+ "require": "./forms/index.js",
37
+ "types": "./forms/index.d.ts"
38
+ },
39
+ "./store": {
40
+ "import": "./store/index.mjs",
41
+ "require": "./store/index.js",
42
+ "types": "./store/index.d.ts"
43
+ },
44
+ "./utils": {
45
+ "import": "./utils/index.mjs",
46
+ "require": "./utils/index.js",
47
+ "types": "./utils/index.d.ts"
48
+ },
49
+ "./event-bus": {
50
+ "import": "./event-bus/index.mjs",
51
+ "require": "./event-bus/index.js",
52
+ "types": "./event-bus/index.d.ts"
53
+ },
54
+ "./lifecycle-events": {
55
+ "import": "./lifecycle-events/index.mjs",
56
+ "require": "./lifecycle-events/index.js",
57
+ "types": "./lifecycle-events/index.d.ts"
58
+ },
59
+ "./client-router": {
60
+ "import": "./client-router/index.mjs",
61
+ "require": "./client-router/index.js",
62
+ "types": "./client-router/index.d.ts"
63
+ },
64
+ "./render-component": {
65
+ "import": "./render-component/index.mjs",
66
+ "require": "./render-component/index.js",
67
+ "types": "./render-component/index.d.ts"
68
+ }
69
+ },
70
+ "sideEffects": false
71
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/render-component",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/renderer",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "frontend-hamroun/router",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "frontend-hamroun/server",
3
+ "version": "1.2.77",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.mjs",
11
+ "require": "./index.js",
12
+ "types": "./index.d.ts",
13
+ "node": "./index.js"
14
+ }
15
+ },
16
+ "sideEffects": false
17
+ }
@@ -0,0 +1,60 @@
1
+ export interface Route {
2
+ path: string;
3
+ component: any;
4
+ props?: Record<string, any>;
5
+ exact?: boolean;
6
+ }
7
+ export interface RouterState {
8
+ location: {
9
+ pathname: string;
10
+ search: string;
11
+ hash: string;
12
+ };
13
+ params: Record<string, string>;
14
+ navigate: (to: string, options?: NavigateOptions) => void;
15
+ match: (path: string) => boolean;
16
+ }
17
+ export interface NavigateOptions {
18
+ replace?: boolean;
19
+ state?: any;
20
+ }
21
+ export declare const RouterContext: import("./context.js").Context<RouterState>;
22
+ export declare function RouterProvider({ routes, children }: {
23
+ routes: Route[];
24
+ children: any;
25
+ }): any;
26
+ export declare function Route({ path, component: Component, props }: Route): any;
27
+ export declare function Switch({ children }: {
28
+ children: any;
29
+ }): any;
30
+ export declare function Link({ to, replace, state, className, activeClassName, children, ...rest }: {
31
+ to: string;
32
+ replace?: boolean;
33
+ state?: any;
34
+ className?: string;
35
+ activeClassName?: string;
36
+ children: any;
37
+ [key: string]: any;
38
+ }): any;
39
+ export declare function Redirect({ to, replace }: {
40
+ to: string;
41
+ replace?: boolean;
42
+ }): null;
43
+ export declare function useLocation(): {
44
+ pathname: string;
45
+ search: string;
46
+ hash: string;
47
+ };
48
+ export declare function useParams(): Record<string, string>;
49
+ export declare function useNavigate(): (to: string, options?: NavigateOptions) => void;
50
+ declare const _default: {
51
+ RouterProvider: typeof RouterProvider;
52
+ Route: typeof Route;
53
+ Switch: typeof Switch;
54
+ Link: typeof Link;
55
+ Redirect: typeof Redirect;
56
+ useLocation: typeof useLocation;
57
+ useParams: typeof useParams;
58
+ useNavigate: typeof useNavigate;
59
+ };
60
+ export default _default;
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Client-side router for single-page applications
3
+ */
4
+ import { useState, useEffect } from './hooks';
5
+ import { createContext, useContext } from './context';
6
+ import { jsx } from './jsx-runtime';
7
+ // Create context for router
8
+ export const RouterContext = createContext({
9
+ location: {
10
+ pathname: '/',
11
+ search: '',
12
+ hash: ''
13
+ },
14
+ params: {},
15
+ navigate: () => { },
16
+ match: () => false
17
+ });
18
+ // Parse path pattern into regex
19
+ function parsePath(path) {
20
+ // Convert :param syntax to capture groups
21
+ const pattern = path
22
+ .replace(/\/+$/, '') // Remove trailing slashes
23
+ .replace(/^\/+/, '/') // Ensure leading slash
24
+ .replace(/\/:([^/]+)/g, '/([^/]+)');
25
+ // Get param names
26
+ const paramNames = [];
27
+ path.replace(/\/:([^/]+)/g, (_, paramName) => {
28
+ paramNames.push(paramName);
29
+ return '';
30
+ });
31
+ return { pattern, paramNames };
32
+ }
33
+ // Match a path against a pattern
34
+ function matchPath(pathname, route) {
35
+ const { path, exact = false } = route;
36
+ const { pattern, paramNames } = parsePath(path);
37
+ // Create regex with or without exact matching
38
+ const regex = new RegExp(`^${pattern}${exact ? '$' : ''}`);
39
+ const match = pathname.match(regex);
40
+ if (!match)
41
+ return null;
42
+ // Extract params
43
+ const params = {};
44
+ paramNames.forEach((name, index) => {
45
+ params[name] = match[index + 1];
46
+ });
47
+ return params;
48
+ }
49
+ // Router Provider component
50
+ export function RouterProvider({ routes, children }) {
51
+ // Get initial location from window if available
52
+ const getInitialLocation = () => {
53
+ if (typeof window === 'undefined') {
54
+ return { pathname: '/', search: '', hash: '' };
55
+ }
56
+ return {
57
+ pathname: window.location.pathname,
58
+ search: window.location.search,
59
+ hash: window.location.hash
60
+ };
61
+ };
62
+ // Fix: Call the function to get the initial value instead of passing the function itself
63
+ const [location, setLocation] = useState(getInitialLocation());
64
+ const [params, setParams] = useState({});
65
+ // Update params when location changes
66
+ useEffect(() => {
67
+ for (const route of routes) {
68
+ const matchedParams = matchPath(location.pathname, route);
69
+ if (matchedParams) {
70
+ setParams(matchedParams);
71
+ break;
72
+ }
73
+ }
74
+ }, [location, routes]);
75
+ // Listen for popstate events
76
+ useEffect(() => {
77
+ if (typeof window === 'undefined')
78
+ return;
79
+ const handlePopState = () => {
80
+ setLocation({
81
+ pathname: window.location.pathname,
82
+ search: window.location.search,
83
+ hash: window.location.hash
84
+ });
85
+ };
86
+ window.addEventListener('popstate', handlePopState);
87
+ return () => window.removeEventListener('popstate', handlePopState);
88
+ }, []);
89
+ // Navigation function
90
+ const navigate = (to, options = {}) => {
91
+ if (typeof window === 'undefined')
92
+ return;
93
+ const { replace = false, state = null } = options;
94
+ if (replace) {
95
+ window.history.replaceState(state, '', to);
96
+ }
97
+ else {
98
+ window.history.pushState(state, '', to);
99
+ }
100
+ // Update location
101
+ setLocation({
102
+ pathname: window.location.pathname,
103
+ search: window.location.search,
104
+ hash: window.location.hash
105
+ });
106
+ };
107
+ // Match function to test if a path matches the current location
108
+ const match = (path) => {
109
+ const { pattern } = parsePath(path);
110
+ const regex = new RegExp(`^${pattern}`);
111
+ return regex.test(location.pathname);
112
+ };
113
+ // Router context value
114
+ const routerValue = {
115
+ location: {
116
+ pathname: location.pathname,
117
+ search: location.search,
118
+ hash: location.hash
119
+ },
120
+ params,
121
+ navigate,
122
+ match
123
+ };
124
+ return jsx(RouterContext.Provider, { value: routerValue, children });
125
+ }
126
+ // Route component
127
+ export function Route({ path, component: Component, props = {} }) {
128
+ const context = useContext(RouterContext);
129
+ const params = context.params;
130
+ const locationPathname = context.location.pathname;
131
+ const routeToMatch = { path, component: Component };
132
+ const match = matchPath(locationPathname, routeToMatch);
133
+ if (!match)
134
+ return null;
135
+ return jsx(Component, { ...props, params });
136
+ }
137
+ // Switch component
138
+ export function Switch({ children }) {
139
+ const context = useContext(RouterContext);
140
+ const locationPathname = context.location.pathname;
141
+ // Find the first matching route
142
+ const child = Array.isArray(children)
143
+ ? children.find(child => {
144
+ if (!child || typeof child.type !== 'function' || !child.props.path)
145
+ return false;
146
+ const routeObj = {
147
+ path: child.props.path,
148
+ component: child.type,
149
+ exact: child.props.exact || false
150
+ };
151
+ return matchPath(locationPathname, routeObj);
152
+ })
153
+ : children;
154
+ return child || null;
155
+ }
156
+ // Link component
157
+ export function Link({ to, replace = false, state = null, className = '', activeClassName = '', children, ...rest }) {
158
+ const context = useContext(RouterContext);
159
+ const navigate = context.navigate;
160
+ const match = context.match;
161
+ const handleClick = (e) => {
162
+ e.preventDefault();
163
+ navigate(to, { replace, state });
164
+ };
165
+ const isActive = match(to);
166
+ const classes = [
167
+ className,
168
+ isActive ? activeClassName : ''
169
+ ].filter(Boolean).join(' ');
170
+ return jsx('a', {
171
+ href: to,
172
+ className: classes || undefined,
173
+ onClick: handleClick,
174
+ ...rest,
175
+ children
176
+ });
177
+ }
178
+ // Redirect component
179
+ export function Redirect({ to, replace = true }) {
180
+ const context = useContext(RouterContext);
181
+ const navigate = context.navigate;
182
+ useEffect(() => {
183
+ navigate(to, { replace });
184
+ }, [to]);
185
+ return null;
186
+ }
187
+ // Hooks
188
+ export function useLocation() {
189
+ const context = useContext(RouterContext);
190
+ return context.location;
191
+ }
192
+ export function useParams() {
193
+ const context = useContext(RouterContext);
194
+ return context.params;
195
+ }
196
+ export function useNavigate() {
197
+ const context = useContext(RouterContext);
198
+ return context.navigate;
199
+ }
200
+ export default {
201
+ RouterProvider,
202
+ Route,
203
+ Switch,
204
+ Link,
205
+ Redirect,
206
+ useLocation,
207
+ useParams,
208
+ useNavigate
209
+ };
210
+ //# sourceMappingURL=client-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-router.js","sourceRoot":"","sources":["../../../src/client-router.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAyBvC,4BAA4B;AAC5B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAc;IACtD,QAAQ,EAAE;QACR,QAAQ,EAAE,GAAG;QACb,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;KACT;IACD,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK;CACnB,CAAC,CAAC;AAEH,gCAAgC;AAChC,SAAS,SAAS,CAAC,IAAY;IAC7B,0CAA0C;IAC1C,MAAM,OAAO,GAAG,IAAI;SACjB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,0BAA0B;SAC9C,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,uBAAuB;SAC5C,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAEtC,kBAAkB;IAClB,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI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ChF,MAAM,OAAO,GAAG,UAAU,CAAc,aAAa,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAElC,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAET,OAAO,IAAI,CAAC;AACd,CAAC;AAED,QAAQ;AACR,MAAM,UAAU,WAAW;IACzB,MAAM,OAAO,GAAG,UAAU,CAAc,aAAa,CAAC,CAAC;IACvD,OAAO,OAAO,CAAC,QAAQ,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,MAAM,OAAO,GAAG,UAAU,CAAc,aAAa,CAAC,CAAC;IACvD,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,OAAO,GAAG,UAAU,CAAc,aAAa,CAAC,CAAC;IACvD,OAAO,OAAO,CAAC,QAAQ,CAAC;AAC1B,CAAC;AAED,eAAe;IACb,cAAc;IACd,KAAK;IACL,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,WAAW;IACX,SAAS;IACT,WAAW;CACZ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { createElement } from './jsx-runtime.js';
1
+ import { createElement } from './jsx-runtime';
2
2
  export class Component {
3
3
  constructor(props = {}) {
4
4
  Object.defineProperty(this, "state", {
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Event bus for communication between components
3
+ */
4
+ export type EventHandler = (...args: any[]) => void;
5
+ export interface EventBus {
6
+ on(event: string, handler: EventHandler): () => void;
7
+ once(event: string, handler: EventHandler): () => void;
8
+ off(event: string, handler?: EventHandler): void;
9
+ emit(event: string, ...args: any[]): void;
10
+ clear(event?: string): void;
11
+ }
12
+ export declare function createEventBus(): EventBus;
13
+ declare const globalEventBus: EventBus;
14
+ export declare function useEvent(event: string, handler: EventHandler, options?: {
15
+ once?: boolean;
16
+ }): () => void;
17
+ export { globalEventBus as eventBus };
18
+ declare const _default: {
19
+ createEventBus: typeof createEventBus;
20
+ eventBus: EventBus;
21
+ useEvent: typeof useEvent;
22
+ };
23
+ export default _default;