application.ts 1.0.0 → 1.0.2
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/AppView.d.ts +11 -2
- package/dist/app/AppView.js +30 -4
- package/dist/app/AppView.js.map +1 -1
- package/package.json +23 -4
- package/src/app/AppView.ts +30 -4
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/AppView.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export declare abstract class AppView<TState extends AppViewState = AppViewState
|
|
|
50
50
|
initialize(): void;
|
|
51
51
|
/**
|
|
52
52
|
* Get the custom element tag name for this class
|
|
53
|
-
*
|
|
53
|
+
* Uses explicit tagName property or falls back to class name conversion
|
|
54
|
+
* To prevent minification issues, define static tagName property in your class
|
|
54
55
|
*/
|
|
55
56
|
static getTagName(): string;
|
|
56
57
|
/**
|
|
@@ -140,4 +141,12 @@ export declare abstract class AppView<TState extends AppViewState = AppViewState
|
|
|
140
141
|
onStateChanged?(key: string, value: any): void;
|
|
141
142
|
onParamsChanged?(newParams: RouteParams, oldParams: RouteParams): void | Promise<void>;
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Decorator to register a view as a custom element
|
|
146
|
+
* Optionally accepts a custom tag name to prevent minification issues
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* @Register() // Auto-generates tag name from class name
|
|
150
|
+
* @Register('my-component') // Explicit tag name (recommended for production)
|
|
151
|
+
*/
|
|
152
|
+
export declare function Register(tagName?: string): any;
|
package/dist/app/AppView.js
CHANGED
|
@@ -85,9 +85,15 @@ export class AppView extends HTMLElement {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Get the custom element tag name for this class
|
|
88
|
-
*
|
|
88
|
+
* Uses explicit tagName property or falls back to class name conversion
|
|
89
|
+
* To prevent minification issues, define static tagName property in your class
|
|
89
90
|
*/
|
|
90
91
|
static getTagName() {
|
|
92
|
+
// Use explicit tagName if provided (prevents minification issues)
|
|
93
|
+
if (this.tagName && typeof this.tagName === 'string') {
|
|
94
|
+
return this.tagName;
|
|
95
|
+
}
|
|
96
|
+
// Fallback to class name conversion (may break with minification)
|
|
91
97
|
return this.name
|
|
92
98
|
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
93
99
|
.toLowerCase();
|
|
@@ -257,8 +263,28 @@ export class AppView extends HTMLElement {
|
|
|
257
263
|
return this._isInitialized;
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Decorator to register a view as a custom element
|
|
268
|
+
* Optionally accepts a custom tag name to prevent minification issues
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* @Register() // Auto-generates tag name from class name
|
|
272
|
+
* @Register('my-component') // Explicit tag name (recommended for production)
|
|
273
|
+
*/
|
|
274
|
+
export function Register(tagName) {
|
|
275
|
+
return function (target) {
|
|
276
|
+
// Use provided tag name or generate from class name
|
|
277
|
+
if (tagName) {
|
|
278
|
+
target.tagName = tagName;
|
|
279
|
+
}
|
|
280
|
+
else if (!target.tagName) {
|
|
281
|
+
// Fallback to class name conversion (may fail with minification)
|
|
282
|
+
target.tagName = target.name
|
|
283
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
284
|
+
.toLowerCase();
|
|
285
|
+
}
|
|
286
|
+
target.register();
|
|
287
|
+
return target;
|
|
288
|
+
};
|
|
263
289
|
}
|
|
264
290
|
//# 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;YAChB,YAAY,EAAE,KAAK;YACnB,GAAG,OAAO;SACb,CAAC;QAEF,gCAAgC;QAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YACnD,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,iBAAiB,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAiB,YAAY,WAAW,CAAC,EAAE,CAAC;gBAClF,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACxE,CAAC;YACD,IAAI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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "application.ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Simplified Web SPA app framework with vanilla JavaScript and CSS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -13,13 +13,18 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"dev": "vite",
|
|
15
15
|
"build": "tsc",
|
|
16
|
-
"build:examples": "vite build",
|
|
17
16
|
"preview": "vite preview",
|
|
17
|
+
"example": "npm run build && vite examples --open",
|
|
18
|
+
"example:build": "npm run build && vite build --config vite.config.ts",
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"prebuild": "npm run clean",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
18
22
|
"typecheck": "tsc --noEmit",
|
|
19
23
|
"lint": "eslint src/**/*.ts",
|
|
20
24
|
"lint:fix": "eslint src/**/*.ts --fix",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
25
|
+
"type-check": "tsc --noEmit",
|
|
26
|
+
"test": "echo \"No tests specified\" && exit 0",
|
|
27
|
+
"test:coverage": "echo \"No tests specified\" && exit 0"
|
|
23
28
|
},
|
|
24
29
|
"keywords": [
|
|
25
30
|
"spa",
|
|
@@ -33,6 +38,20 @@
|
|
|
33
38
|
],
|
|
34
39
|
"author": "Xoboto Contributors",
|
|
35
40
|
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/Xoboto/application.ts.git"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/Xoboto/application.ts/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/Xoboto/application.ts#readme",
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=14.0.0"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
36
55
|
"dependencies": {
|
|
37
56
|
"stackview.ts": "^1.0.1",
|
|
38
57
|
"template.ts": "^2.0.0"
|
package/src/app/AppView.ts
CHANGED
|
@@ -108,9 +108,16 @@ export abstract class AppView<TState extends AppViewState = AppViewState> extend
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Get the custom element tag name for this class
|
|
111
|
-
*
|
|
111
|
+
* Uses explicit tagName property or falls back to class name conversion
|
|
112
|
+
* To prevent minification issues, define static tagName property in your class
|
|
112
113
|
*/
|
|
113
114
|
static getTagName(): string {
|
|
115
|
+
// Use explicit tagName if provided (prevents minification issues)
|
|
116
|
+
if ((this as any).tagName && typeof (this as any).tagName === 'string') {
|
|
117
|
+
return (this as any).tagName;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Fallback to class name conversion (may break with minification)
|
|
114
121
|
return this.name
|
|
115
122
|
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
116
123
|
.toLowerCase();
|
|
@@ -327,7 +334,26 @@ export abstract class AppView<TState extends AppViewState = AppViewState> extend
|
|
|
327
334
|
onParamsChanged?(newParams: RouteParams, oldParams: RouteParams): void | Promise<void>;
|
|
328
335
|
}
|
|
329
336
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Decorator to register a view as a custom element
|
|
339
|
+
* Optionally accepts a custom tag name to prevent minification issues
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* @Register() // Auto-generates tag name from class name
|
|
343
|
+
* @Register('my-component') // Explicit tag name (recommended for production)
|
|
344
|
+
*/
|
|
345
|
+
export function Register(tagName?: string) : any {
|
|
346
|
+
return function(target: any) {
|
|
347
|
+
// Use provided tag name or generate from class name
|
|
348
|
+
if (tagName) {
|
|
349
|
+
target.tagName = tagName;
|
|
350
|
+
} else if (!target.tagName) {
|
|
351
|
+
// Fallback to class name conversion (may fail with minification)
|
|
352
|
+
target.tagName = target.name
|
|
353
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
354
|
+
.toLowerCase();
|
|
355
|
+
}
|
|
356
|
+
target.register();
|
|
357
|
+
return target;
|
|
358
|
+
};
|
|
333
359
|
}
|