application.ts 1.0.1 → 1.0.3
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 +4 -0
- package/dist/app/App.js +8 -4
- package/dist/app/App.js.map +1 -1
- package/dist/app/AppView.d.ts +4 -3
- package/dist/app/AppView.js +43 -7
- package/dist/app/AppView.js.map +1 -1
- package/package.json +11 -3
- package/src/app/App.ts +0 -391
- package/src/app/AppView.ts +0 -359
- package/src/app/types.ts +0 -78
- package/src/index.ts +0 -28
- package/src/navigation/route.ts +0 -87
- package/src/navigation/router.ts +0 -284
- package/src/navigation/types.ts +0 -73
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A lightweight, dependency-free except template.ts and stackview.ts TypeScript framework for building single-page applications (SPAs) with pure vanilla JavaScript and CSS. No build tools required, just modern web standards.
|
|
4
4
|
|
|
5
|
+
**[📺 Live Examples →](http://app.dev.xoboto.com/)**
|
|
6
|
+
|
|
5
7
|
## What is Application.Ts?
|
|
6
8
|
|
|
7
9
|
Application.Ts is a minimalist SPA framework that combines:
|
|
@@ -293,6 +295,8 @@ Use in templates:
|
|
|
293
295
|
|
|
294
296
|
## Examples
|
|
295
297
|
|
|
298
|
+
**[🚀 View Live Examples](http://app.dev.xoboto.com/)**
|
|
299
|
+
|
|
296
300
|
Explore the `/examples` folder for complete working examples:
|
|
297
301
|
|
|
298
302
|
- **Minimal** - The simplest possible app
|
package/dist/app/App.js
CHANGED
|
@@ -68,8 +68,10 @@ export class App {
|
|
|
68
68
|
* @param viewClass - The AppView class constructor
|
|
69
69
|
*/
|
|
70
70
|
registerView(handler, viewClass) {
|
|
71
|
-
// Auto-register the custom element
|
|
72
|
-
viewClass.register
|
|
71
|
+
// Auto-register the custom element if register method exists
|
|
72
|
+
if (typeof viewClass.register === 'function') {
|
|
73
|
+
viewClass.register();
|
|
74
|
+
}
|
|
73
75
|
this.viewRegistry.set(handler, viewClass);
|
|
74
76
|
return this;
|
|
75
77
|
}
|
|
@@ -89,8 +91,10 @@ export class App {
|
|
|
89
91
|
* @param layoutClass - The AppView layout class constructor
|
|
90
92
|
*/
|
|
91
93
|
registerLayout(handler, layoutClass) {
|
|
92
|
-
// Auto-register the custom element
|
|
93
|
-
layoutClass.register
|
|
94
|
+
// Auto-register the custom element if register method exists
|
|
95
|
+
if (typeof layoutClass.register === 'function') {
|
|
96
|
+
layoutClass.register();
|
|
97
|
+
}
|
|
94
98
|
this.layoutRegistry.set(handler, layoutClass);
|
|
95
99
|
return this;
|
|
96
100
|
}
|
package/dist/app/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","sourceRoot":"","sources":["../../src/app/App.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAA8B,MAAM,qBAAqB,CAAC;AAGnF,2DAA2D;AAC3D,sEAAsE;AAEtE,6DAA6D;AAC7D,MAAM,UAAU,GAAG,SAAS,CAAC;AAO7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,GAAG;IAWZ;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,OAA2B;QAC1C,IAAI,OAAO,GAAG,OAAO,CAAC;QAEtB,OAAO,OAAO,EAAE,CAAC;YACb,IAAK,OAAe,CAAC,OAAO,EAAE,CAAC;gBAC3B,OAAQ,OAAe,CAAC,OAAO,CAAC;YACpC,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;QACpC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,YAAY,YAAqB;QA3BzB,cAAS,GAAQ,IAAI,CAAC;QACtB,gBAAW,GAAuB,IAAI,CAAC;QACvC,iBAAY,GAAiC,IAAI,GAAG,EAAE,CAAC;QACvD,mBAAc,GAAiC,IAAI,GAAG,EA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AY,CAAC;QAExC,yDAAyD;QACzD,MAAM,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,IAAY;QAC/B,qEAAqE;QACrE,6DAA6D;QAC7D,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAK,IAAI,CAAC,MAAc,CAAC,MAAM,EAAE,CAAC;YACrD,MAAM,KAAK,GAAI,IAAI,CAAC,MAAc,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;YAC7D,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC7B,OAAO,OAAO,CAAC;YACnB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,IAAY;QACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QACR,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;YAC/C,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QACpC,CAAC;IACL,CAAC;CACJ"}
|
package/dist/app/AppView.d.ts
CHANGED
|
@@ -143,10 +143,11 @@ export declare abstract class AppView<TState extends AppViewState = AppViewState
|
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* Decorator to register a view as a custom element
|
|
146
|
-
*
|
|
146
|
+
* Supports both @Register and @Register('tag-name') syntax
|
|
147
147
|
*
|
|
148
148
|
* @example
|
|
149
|
-
* @Register
|
|
149
|
+
* @Register // Auto-generates tag name from class name
|
|
150
|
+
* @Register() // Same as above
|
|
150
151
|
* @Register('my-component') // Explicit tag name (recommended for production)
|
|
151
152
|
*/
|
|
152
|
-
export declare function Register(
|
|
153
|
+
export declare function Register(tagNameOrTarget?: string | any): any;
|
package/dist/app/AppView.js
CHANGED
|
@@ -265,17 +265,23 @@ export class AppView extends HTMLElement {
|
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
267
|
* Decorator to register a view as a custom element
|
|
268
|
-
*
|
|
268
|
+
* Supports both @Register and @Register('tag-name') syntax
|
|
269
269
|
*
|
|
270
270
|
* @example
|
|
271
|
-
* @Register
|
|
271
|
+
* @Register // Auto-generates tag name from class name
|
|
272
|
+
* @Register() // Same as above
|
|
272
273
|
* @Register('my-component') // Explicit tag name (recommended for production)
|
|
273
274
|
*/
|
|
274
|
-
export function Register(
|
|
275
|
-
|
|
275
|
+
export function Register(tagNameOrTarget) {
|
|
276
|
+
// Helper function to do the actual registration
|
|
277
|
+
const registerClass = (target, customTagName) => {
|
|
278
|
+
if (!target) {
|
|
279
|
+
console.warn('Register decorator: target is undefined');
|
|
280
|
+
return target;
|
|
281
|
+
}
|
|
276
282
|
// Use provided tag name or generate from class name
|
|
277
|
-
if (
|
|
278
|
-
target.tagName =
|
|
283
|
+
if (customTagName) {
|
|
284
|
+
target.tagName = customTagName;
|
|
279
285
|
}
|
|
280
286
|
else if (!target.tagName) {
|
|
281
287
|
// Fallback to class name conversion (may fail with minification)
|
|
@@ -283,8 +289,38 @@ export function Register(tagName) {
|
|
|
283
289
|
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
284
290
|
.toLowerCase();
|
|
285
291
|
}
|
|
286
|
-
|
|
292
|
+
// Check if register method exists (for safety with inheritance)
|
|
293
|
+
if (typeof target.register === 'function') {
|
|
294
|
+
try {
|
|
295
|
+
target.register();
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
console.warn('Register decorator: failed to call register method', error);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
// Fallback: manually register the element
|
|
303
|
+
try {
|
|
304
|
+
const elementTagName = target.tagName || target.name
|
|
305
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
306
|
+
.toLowerCase();
|
|
307
|
+
if (!customElements.get(elementTagName)) {
|
|
308
|
+
customElements.define(elementTagName, target);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
console.warn('Register decorator: failed to register custom element', error);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
287
315
|
return target;
|
|
288
316
|
};
|
|
317
|
+
// Check if used as @Register (without parentheses) - target is passed directly
|
|
318
|
+
if (typeof tagNameOrTarget === 'function') {
|
|
319
|
+
return registerClass(tagNameOrTarget);
|
|
320
|
+
}
|
|
321
|
+
// Used as @Register() or @Register('tag-name') - return decorator function
|
|
322
|
+
return function (target) {
|
|
323
|
+
return registerClass(target, tagNameOrTarget);
|
|
324
|
+
};
|
|
289
325
|
}
|
|
290
326
|
//# sourceMappingURL=AppView.js.map
|
package/dist/app/AppView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppView.js","sourceRoot":"","sources":["../../src/app/AppView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAO5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAgB,OAAoD,SAAQ,WAAW;IAOzF,YAAY,OAAwB;QAChC,KAAK,EAAE,CAAC;QAPF,WAAM,GAA0B,IAAI,CAAC;QACrC,WAAM,GAAkB,IAAI,CAAC;QAG/B,mBAAc,GAAY,KAAK,CAAC;QAKpC,IAAI,CAAC,QAAQ,GAAG;YACZ,eAAe,EAAE,iBAAiB;YAClC,UAAU,EAAE,IAAI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AAC,cAAc,CAAC,EAAE,CAAC;oBACtC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;gBAClD,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,KAAK,CAAC,CAAC;YACjF,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;IAEF,+EAA+E;IAC/E,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE,CAAC;QACxC,OAAO,aAAa,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC;IAED,2EAA2E;IAC3E,OAAO,UAAS,MAAW;QACvB,OAAO,aAAa,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAClD,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "application.ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Simplified Web SPA app framework with vanilla JavaScript and CSS",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
7
16
|
"files": [
|
|
8
|
-
"src/",
|
|
9
17
|
"dist/",
|
|
10
18
|
"README.md",
|
|
11
19
|
"LICENSE"
|
package/src/app/App.ts
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
import StackView from 'stackview.ts';
|
|
2
|
-
import { Router } from '../navigation/router';
|
|
3
|
-
import { NavigationEvents, type NavigationEventDetail } from '../navigation/types';
|
|
4
|
-
import type { AppView } from './AppView';
|
|
5
|
-
|
|
6
|
-
// Force StackView to be included in the bundle by using it
|
|
7
|
-
// This ensures the custom element is registered when the module loads
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
const _stackView = StackView;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* View constructor type
|
|
14
|
-
*/
|
|
15
|
-
type ViewConstructor = new () => AppView<any>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Main App class that manages routing and view rendering
|
|
19
|
-
* Integrates Router with StackView.Ts for navigation
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* import { App } from 'application.ts';
|
|
24
|
-
* import { HomeView, AboutView, NotFoundView } from './views';
|
|
25
|
-
*
|
|
26
|
-
* const app = new App('#root');
|
|
27
|
-
*
|
|
28
|
-
* app.router
|
|
29
|
-
* .map('/', HomeView)
|
|
30
|
-
* .map('/about', AboutView)
|
|
31
|
-
* .notFound(NotFoundView);
|
|
32
|
-
*
|
|
33
|
-
* app.start();
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export class App {
|
|
37
|
-
public readonly router: Router;
|
|
38
|
-
private stackView: any = null;
|
|
39
|
-
private rootElement: HTMLElement | null = null;
|
|
40
|
-
private viewRegistry: Map<string, ViewConstructor> = new Map();
|
|
41
|
-
private layoutRegistry: Map<string, ViewConstructor> = new Map();
|
|
42
|
-
private currentViewInstance: AppView<any> | null = null;
|
|
43
|
-
private currentLayoutInstance: AppView<any> | null = null;
|
|
44
|
-
private currentRoutePath: string | null = null;
|
|
45
|
-
private defaultLayout: string | null = null;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the App instance from any element by traversing up the DOM tree
|
|
49
|
-
* @param element - Any HTMLElement in the app
|
|
50
|
-
* @returns App instance or null if not found
|
|
51
|
-
*/
|
|
52
|
-
static fromElement(element: HTMLElement | null): App | null {
|
|
53
|
-
let current = element;
|
|
54
|
-
|
|
55
|
-
while (current) {
|
|
56
|
-
if ((current as any).__app__) {
|
|
57
|
-
return (current as any).__app__;
|
|
58
|
-
}
|
|
59
|
-
current = current.parentElement;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
constructor(rootSelector?: string) {
|
|
66
|
-
this.router = new Router();
|
|
67
|
-
|
|
68
|
-
// Listen to navigation events
|
|
69
|
-
this.router.addEventListener(NavigationEvents.NAVIGATE, ((e: CustomEvent<NavigationEventDetail>) => {
|
|
70
|
-
this.handleNavigation(e);
|
|
71
|
-
}) as EventListener);
|
|
72
|
-
|
|
73
|
-
this.router.addEventListener(NavigationEvents.NOT_FOUND, ((e: CustomEvent<NavigationEventDetail>) => {
|
|
74
|
-
this.handleNotFound(e);
|
|
75
|
-
}) as EventListener);
|
|
76
|
-
|
|
77
|
-
// If root selector provided, initialize immediately
|
|
78
|
-
if (rootSelector) {
|
|
79
|
-
this.initializeRoot(rootSelector);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Register a view class with a handler name
|
|
85
|
-
* @param handler - The view handler/identifier used in router.map()
|
|
86
|
-
* @param viewClass - The AppView class constructor
|
|
87
|
-
*/
|
|
88
|
-
registerView(handler: string, viewClass: ViewConstructor): this {
|
|
89
|
-
// Auto-register the custom element
|
|
90
|
-
(viewClass as any).register();
|
|
91
|
-
this.viewRegistry.set(handler, viewClass);
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Register multiple views at once
|
|
97
|
-
* @param views - Object mapping handler names to view classes
|
|
98
|
-
*/
|
|
99
|
-
registerViews(views: Record<string, ViewConstructor>): this {
|
|
100
|
-
for (const [handler, viewClass] of Object.entries(views)) {
|
|
101
|
-
this.registerView(handler, viewClass);
|
|
102
|
-
}
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Register a layout class with a handler name
|
|
108
|
-
* @param handler - The layout handler/identifier
|
|
109
|
-
* @param layoutClass - The AppView layout class constructor
|
|
110
|
-
*/
|
|
111
|
-
registerLayout(handler: string, layoutClass: ViewConstructor): this {
|
|
112
|
-
// Auto-register the custom element
|
|
113
|
-
(layoutClass as any).register();
|
|
114
|
-
this.layoutRegistry.set(handler, layoutClass);
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Register multiple layouts at once
|
|
120
|
-
* @param layouts - Object mapping handler names to layout classes
|
|
121
|
-
*/
|
|
122
|
-
registerLayouts(layouts: Record<string, ViewConstructor>): this {
|
|
123
|
-
for (const [handler, layoutClass] of Object.entries(layouts)) {
|
|
124
|
-
this.registerLayout(handler, layoutClass);
|
|
125
|
-
}
|
|
126
|
-
return this;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Set the default layout for all routes
|
|
131
|
-
* @param handler - The layout handler name, or null for no layout
|
|
132
|
-
*/
|
|
133
|
-
setDefaultLayout(handler: string | null): this {
|
|
134
|
-
this.defaultLayout = handler;
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Initialize the root element and StackView
|
|
140
|
-
* @param selector - CSS selector for the root element
|
|
141
|
-
*/
|
|
142
|
-
private initializeRoot(selector: string): void {
|
|
143
|
-
const element = document.querySelector(selector);
|
|
144
|
-
if (!element) {
|
|
145
|
-
throw new Error(`Root element not found: ${selector}`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
this.rootElement = element as HTMLElement;
|
|
149
|
-
|
|
150
|
-
// Attach app instance to root element
|
|
151
|
-
(this.rootElement as any).__app__ = this;
|
|
152
|
-
|
|
153
|
-
// Create StackView if it doesn't exist
|
|
154
|
-
if (!this.stackView) {
|
|
155
|
-
// Create or use existing stack-view element
|
|
156
|
-
let stackViewElement = this.rootElement.querySelector('stack-view') as StackView;
|
|
157
|
-
|
|
158
|
-
if (!stackViewElement) {
|
|
159
|
-
stackViewElement = new StackView();
|
|
160
|
-
stackViewElement.effect = 'fade';
|
|
161
|
-
stackViewElement.backButton = false;
|
|
162
|
-
this.rootElement.appendChild(stackViewElement);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
this.stackView = stackViewElement;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Start the application
|
|
171
|
-
* @param rootSelector - Optional root selector if not provided in constructor
|
|
172
|
-
*/
|
|
173
|
-
start(rootSelector?: string): void {
|
|
174
|
-
if (rootSelector) {
|
|
175
|
-
this.initializeRoot(rootSelector);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (!this.rootElement || !this.stackView) {
|
|
179
|
-
throw new Error('Root element not initialized. Provide selector in constructor or start()');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Start the router
|
|
183
|
-
this.router.start();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Resolve view class from handler (supports both class constructor and string lookup)
|
|
188
|
-
* @param handler - View class constructor or string identifier
|
|
189
|
-
* @returns View class constructor or null
|
|
190
|
-
*/
|
|
191
|
-
private resolveViewClass(handler: any): ViewConstructor | null {
|
|
192
|
-
// If handler is already a class constructor, use it directly
|
|
193
|
-
if (typeof handler === 'function') {
|
|
194
|
-
// Auto-register the custom element
|
|
195
|
-
(handler as any).register?.();
|
|
196
|
-
return handler as ViewConstructor;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// If handler is a string, look it up in the registry (backward compatibility)
|
|
200
|
-
if (typeof handler === 'string') {
|
|
201
|
-
return this.viewRegistry.get(handler) || null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Handle navigation event from router
|
|
209
|
-
*/
|
|
210
|
-
private async handleNavigation(event: CustomEvent<NavigationEventDetail>): Promise<void> {
|
|
211
|
-
const { handler, params, meta, path } = event.detail;
|
|
212
|
-
|
|
213
|
-
// Store the current route path pattern
|
|
214
|
-
this.currentRoutePath = this.getRoutePattern(path);
|
|
215
|
-
|
|
216
|
-
// Resolve view class from handler (can be class constructor or string)
|
|
217
|
-
const ViewClass = this.resolveViewClass(handler);
|
|
218
|
-
|
|
219
|
-
if (!ViewClass) {
|
|
220
|
-
console.error(`View not found or registered: ${handler}`);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Check if we're navigating to the same view instance with different params
|
|
225
|
-
if (this.currentViewInstance && this.currentViewInstance.constructor === ViewClass) {
|
|
226
|
-
// Same view, just update parameters
|
|
227
|
-
await this.currentViewInstance.updateParams(params);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Determine which layout to use
|
|
232
|
-
const layoutHandler = meta?.layout !== undefined ? meta.layout : this.defaultLayout;
|
|
233
|
-
|
|
234
|
-
// Create view instance
|
|
235
|
-
const viewInstance = new ViewClass();
|
|
236
|
-
|
|
237
|
-
// Store current view instance
|
|
238
|
-
this.currentViewInstance = viewInstance;
|
|
239
|
-
|
|
240
|
-
// If layout is specified, wrap view in layout
|
|
241
|
-
if (layoutHandler) {
|
|
242
|
-
await this.renderWithLayout(viewInstance, layoutHandler, meta);
|
|
243
|
-
} else {
|
|
244
|
-
await this.renderWithoutLayout(viewInstance, meta);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Render view wrapped in a layout
|
|
250
|
-
*/
|
|
251
|
-
private async renderWithLayout(viewInstance: AppView<any>, layoutHandler: string, meta?: any): Promise<void> {
|
|
252
|
-
const LayoutClass = this.layoutRegistry.get(layoutHandler);
|
|
253
|
-
|
|
254
|
-
if (!LayoutClass) {
|
|
255
|
-
console.error(`Layout not registered: ${layoutHandler}`);
|
|
256
|
-
// Fallback to no layout
|
|
257
|
-
await this.renderWithoutLayout(viewInstance, meta);
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Create or reuse layout instance
|
|
262
|
-
if (!this.currentLayoutInstance || this.currentLayoutInstance.constructor !== LayoutClass) {
|
|
263
|
-
// Create new layout instance
|
|
264
|
-
const layoutInstance = new LayoutClass();
|
|
265
|
-
this.currentLayoutInstance = layoutInstance;
|
|
266
|
-
|
|
267
|
-
// Show layout in StackView
|
|
268
|
-
if (this.stackView) {
|
|
269
|
-
await this.stackView.begin(layoutInstance, meta?.effect);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Find content outlet in layout (should be a <stack-view> element)
|
|
274
|
-
const outlet = this.currentLayoutInstance.querySelector('[data-outlet="content"]') as StackView;
|
|
275
|
-
|
|
276
|
-
if (!outlet) {
|
|
277
|
-
console.error('Layout does not have a content outlet [data-outlet="content"]');
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Check if outlet is a stack-view, if not create one
|
|
282
|
-
let stackViewElement: StackView;
|
|
283
|
-
|
|
284
|
-
if (outlet.tagName.toLowerCase() === 'stack-view') {
|
|
285
|
-
stackViewElement = outlet;
|
|
286
|
-
} else {
|
|
287
|
-
// Outlet is not a stack-view, create one inside it
|
|
288
|
-
let existingStackView = outlet.querySelector('stack-view') as StackView;
|
|
289
|
-
|
|
290
|
-
if (!existingStackView) {
|
|
291
|
-
existingStackView = new StackView();
|
|
292
|
-
existingStackView.effect = 'fade';
|
|
293
|
-
existingStackView.backButton = false;
|
|
294
|
-
outlet.appendChild(existingStackView);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
stackViewElement = existingStackView;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Use stack-view's begin method for smooth transitions
|
|
301
|
-
await stackViewElement.begin(viewInstance, meta?.effect);
|
|
302
|
-
|
|
303
|
-
// Trigger view lifecycle
|
|
304
|
-
if (viewInstance.onMounted) {
|
|
305
|
-
await viewInstance.onMounted();
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Render view without layout
|
|
311
|
-
*/
|
|
312
|
-
private async renderWithoutLayout(viewInstance: AppView<any>, meta?: any): Promise<void> {
|
|
313
|
-
// Clear current layout if exists
|
|
314
|
-
this.currentLayoutInstance = null;
|
|
315
|
-
|
|
316
|
-
// Show view using StackView
|
|
317
|
-
if (this.stackView) {
|
|
318
|
-
await this.stackView.begin(viewInstance, meta?.effect);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Handle not found event from router
|
|
324
|
-
*/
|
|
325
|
-
private async handleNotFound(event: CustomEvent<NavigationEventDetail>): Promise<void> {
|
|
326
|
-
const { handler } = event.detail;
|
|
327
|
-
|
|
328
|
-
// Resolve view class from handler (can be class constructor or string)
|
|
329
|
-
const ViewClass = this.resolveViewClass(handler);
|
|
330
|
-
|
|
331
|
-
if (!ViewClass) {
|
|
332
|
-
console.error(`404 View not found or registered: ${handler}`);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Create view instance
|
|
337
|
-
const viewInstance = new ViewClass();
|
|
338
|
-
|
|
339
|
-
// Store current view instance
|
|
340
|
-
this.currentViewInstance = viewInstance;
|
|
341
|
-
|
|
342
|
-
// 404 pages typically don't use layouts, render directly
|
|
343
|
-
await this.renderWithoutLayout(viewInstance);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Get the route pattern that matches the given path
|
|
348
|
-
*/
|
|
349
|
-
public getRoutePattern(path: string): string | null {
|
|
350
|
-
// Iterate through all registered routes to find the matching pattern
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
352
|
-
for (const [pattern, _] of (this.router as any).routes) {
|
|
353
|
-
const route = (this.router as any).routes.get(pattern).route;
|
|
354
|
-
if (route.match(path) !== null) {
|
|
355
|
-
return pattern;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Get the current view instance
|
|
363
|
-
*/
|
|
364
|
-
get currentView(): AppView<any> | null {
|
|
365
|
-
return this.currentViewInstance;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Get the current route pattern (e.g., '/user/:id')
|
|
370
|
-
*/
|
|
371
|
-
get currentRoute(): string | null {
|
|
372
|
-
return this.currentRoutePath;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Navigate to a specific path
|
|
377
|
-
* @param path - The path to navigate to
|
|
378
|
-
*/
|
|
379
|
-
navigate(path: string): void {
|
|
380
|
-
this.router.navigate(path);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Go back in navigation history
|
|
385
|
-
*/
|
|
386
|
-
async goBack(): Promise<void> {
|
|
387
|
-
if (this.stackView && this.stackView.canGoBack()) {
|
|
388
|
-
await this.stackView.complete();
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|