gyosjs 0.1.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/LICENSE.md +21 -0
- package/README.md +131 -0
- package/dist/auto-init.d.ts +3 -0
- package/dist/auto-init.d.ts.map +1 -0
- package/dist/core/component.d.ts +15 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/composables.d.ts +113 -0
- package/dist/core/composables.d.ts.map +1 -0
- package/dist/core/di.d.ts +56 -0
- package/dist/core/di.d.ts.map +1 -0
- package/dist/core/directive.d.ts +52 -0
- package/dist/core/directive.d.ts.map +1 -0
- package/dist/core/events.d.ts +88 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/hydration.d.ts +96 -0
- package/dist/core/hydration.d.ts.map +1 -0
- package/dist/core/pipe.d.ts +34 -0
- package/dist/core/pipe.d.ts.map +1 -0
- package/dist/core/portal.d.ts +37 -0
- package/dist/core/portal.d.ts.map +1 -0
- package/dist/core/reactive.d.ts +15 -0
- package/dist/core/reactive.d.ts.map +1 -0
- package/dist/core/router/diff-nodes.d.ts +2 -0
- package/dist/core/router/diff-nodes.d.ts.map +1 -0
- package/dist/core/router/persist.d.ts +4 -0
- package/dist/core/router/persist.d.ts.map +1 -0
- package/dist/core/router/router.d.ts +43 -0
- package/dist/core/router/router.d.ts.map +1 -0
- package/dist/core/router/script.d.ts +18 -0
- package/dist/core/router/script.d.ts.map +1 -0
- package/dist/core/router/scroll.d.ts +6 -0
- package/dist/core/router/scroll.d.ts.map +1 -0
- package/dist/core/router/swap.d.ts +8 -0
- package/dist/core/router/swap.d.ts.map +1 -0
- package/dist/core/scope-registry.d.ts +36 -0
- package/dist/core/scope-registry.d.ts.map +1 -0
- package/dist/core/store.d.ts +32 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/transition.d.ts +130 -0
- package/dist/core/transition.d.ts.map +1 -0
- package/dist/form/form-validation.d.ts +36 -0
- package/dist/form/form-validation.d.ts.map +1 -0
- package/dist/form/validator.d.ts +124 -0
- package/dist/form/validator.d.ts.map +1 -0
- package/dist/gyos.auto.esm.js +7890 -0
- package/dist/gyos.auto.esm.js.map +1 -0
- package/dist/gyos.auto.js +7900 -0
- package/dist/gyos.auto.js.map +1 -0
- package/dist/gyos.auto.min.js +6 -0
- package/dist/gyos.esm.js +7872 -0
- package/dist/gyos.esm.js.map +1 -0
- package/dist/gyos.js +7942 -0
- package/dist/gyos.js.map +1 -0
- package/dist/gyos.min.js +6 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/reactivity/signal.d.ts +224 -0
- package/dist/reactivity/signal.d.ts.map +1 -0
- package/dist/template/bindings.d.ts +21 -0
- package/dist/template/bindings.d.ts.map +1 -0
- package/dist/template/cleanup.d.ts +9 -0
- package/dist/template/cleanup.d.ts.map +1 -0
- package/dist/template/directives.d.ts +22 -0
- package/dist/template/directives.d.ts.map +1 -0
- package/dist/template/effect-queue.d.ts +18 -0
- package/dist/template/effect-queue.d.ts.map +1 -0
- package/dist/template/events.d.ts +2 -0
- package/dist/template/events.d.ts.map +1 -0
- package/dist/template/expression.d.ts +25 -0
- package/dist/template/expression.d.ts.map +1 -0
- package/dist/template/model.d.ts +19 -0
- package/dist/template/model.d.ts.map +1 -0
- package/dist/template/parser.d.ts +9 -0
- package/dist/template/parser.d.ts.map +1 -0
- package/dist/template/process.d.ts +3 -0
- package/dist/template/process.d.ts.map +1 -0
- package/dist/template/structurals/structural.d.ts +41 -0
- package/dist/template/structurals/structural.d.ts.map +1 -0
- package/dist/template/structurals/transition-helpers.d.ts +60 -0
- package/dist/template/structurals/transition-helpers.d.ts.map +1 -0
- package/dist/template/text.d.ts +19 -0
- package/dist/template/text.d.ts.map +1 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +54 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/progress-bar.d.ts +20 -0
- package/dist/utils/progress-bar.d.ts.map +1 -0
- package/dist/utils/target-spinner.d.ts +13 -0
- package/dist/utils/target-spinner.d.ts.map +1 -0
- package/package.json +94 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ho Hoang Phu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# GyosJS
|
|
2
|
+
|
|
3
|
+
<img src="./examples/p5-2-no-bg.png" alt="GyosJS logo" width="100" height="100" />
|
|
4
|
+
|
|
5
|
+
Reactive HTML for server-rendered websites, with fine-grained signals, attribute-driven templates, and MPA boost navigation.
|
|
6
|
+
|
|
7
|
+
GyosJS is built for developers who like server-rendered HTML, traditional MPA architecture, and small amounts of JavaScript that stay close to the DOM. If AlpineJS feels familiar but you also want boosted MPA navigation similar to Turbo or Hotwire, GyosJS is designed for that middle ground.
|
|
8
|
+
|
|
9
|
+
## Why GyosJS
|
|
10
|
+
|
|
11
|
+
- Keep your backend-rendered HTML and existing routes.
|
|
12
|
+
- Add reactivity directly in markup with `g-scope`, `g-model`, `*if`, `*for`, and events.
|
|
13
|
+
- Upgrade link and form navigation with `g-boost` instead of rewriting the app as a SPA.
|
|
14
|
+
- Keep specific UI islands alive across navigations with `g-persist`.
|
|
15
|
+
- Use it with a CDN or install it from npm.
|
|
16
|
+
|
|
17
|
+
## When It Fits
|
|
18
|
+
|
|
19
|
+
GyosJS is a good fit when you are building:
|
|
20
|
+
|
|
21
|
+
- Laravel, PHP, Rails, MVC, and other server-rendered apps
|
|
22
|
+
- admin tools and internal dashboards
|
|
23
|
+
- marketing sites with small interactive sections
|
|
24
|
+
- MPA products that want smoother navigation without client-side routing everywhere
|
|
25
|
+
- projects that do not need React/Vue-level component systems
|
|
26
|
+
|
|
27
|
+
GyosJS is not trying to replace a full SPA framework. If your app is primarily client-rendered and depends on complex client routing or large client-side state graphs, a SPA framework is usually the better tool.
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### CDN: no build step
|
|
32
|
+
|
|
33
|
+
Use the browser auto-init build when you want HTML-first usage with minimal setup.
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/gyosjs@0.1.0/dist/gyos.auto.min.js"></script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
That build attaches `window.Gyos`, starts the router when `g-boost` exists, injects transition styles, and mounts scopes when the page is ready.
|
|
40
|
+
|
|
41
|
+
### npm: bundler or app build
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install gyosjs
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use the core runtime when you want explicit control:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import Gyos from 'gyosjs';
|
|
51
|
+
|
|
52
|
+
Gyos.scope('Counter', {
|
|
53
|
+
count: 0,
|
|
54
|
+
increment() {
|
|
55
|
+
this.count++;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
Gyos.ready(() => {
|
|
60
|
+
Gyos.mountAll();
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Or use the auto entrypoint:
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import 'gyosjs/auto';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Minimal Example
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<div g-scope="{ name: 'GyosJS' }">
|
|
74
|
+
<p>Hello, {name}</p>
|
|
75
|
+
<input g-model="name">
|
|
76
|
+
</div>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This is the core GyosJS experience: state lives next to HTML, the DOM updates automatically, and you do not need a component compiler or virtual DOM to get there.
|
|
80
|
+
|
|
81
|
+
## MPA Boost Example
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<body g-boost>
|
|
85
|
+
<main id="app" g-outlet g-snapshot>
|
|
86
|
+
<nav>
|
|
87
|
+
<a href="/posts.html">Posts</a>
|
|
88
|
+
<a href="/about.html">About</a>
|
|
89
|
+
</nav>
|
|
90
|
+
</main>
|
|
91
|
+
</body>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
With `g-boost`, same-origin links and forms can be intercepted and swapped into the current outlet. Add `g-persist` to keep a player, timer, or other live island mounted across page transitions.
|
|
95
|
+
|
|
96
|
+
## Documentation
|
|
97
|
+
|
|
98
|
+
- [Introduction](./docs/en/introduction.md)
|
|
99
|
+
- [Getting Started](./docs/en/getting-started.md)
|
|
100
|
+
- [What Is G-Scope](./docs/en/what-is-gscope.md)
|
|
101
|
+
- [Reactivity and Signals](./docs/en/reactivity-signals.md)
|
|
102
|
+
- [Template Syntax](./docs/en/template-syntax.md)
|
|
103
|
+
- [Examples](./docs/en/examples.md)
|
|
104
|
+
- [Tutorial Guide](./docs/en/tutorial-guide.md)
|
|
105
|
+
- [API Reference](./docs/en/api-reference.md)
|
|
106
|
+
- [MPA Boost Deep Dive](./docs/en/mpa-boost-deep-dive.md)
|
|
107
|
+
- [Layouts, Scripts, and Lifecycle](./docs/en/layouts-scripts-lifecycle.md)
|
|
108
|
+
- [Best Practices](./docs/en/best-practices.md)
|
|
109
|
+
- [Distribution and Installation](./docs/en/distribution-and-installation.md)
|
|
110
|
+
- [Migration Guide](./docs/en/migrate-from-javascript.md)
|
|
111
|
+
|
|
112
|
+
## Examples In This Repo
|
|
113
|
+
|
|
114
|
+
- [`examples/router`](./examples/router) covers router behaviors such as `g-target`, `g-router-link`, `g-persist`, `g-swap`, and snapshots.
|
|
115
|
+
- [`examples/mpa-demo`](./examples/mpa-demo) shows the smaller MPA boost flow.
|
|
116
|
+
- [`examples`](./examples) includes reactive demos, forms, async rendering, and stress-test style development examples.
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install
|
|
122
|
+
npm run build
|
|
123
|
+
npm run test
|
|
124
|
+
npm run typecheck
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Open Source Files
|
|
128
|
+
|
|
129
|
+
- [License](./LICENSE.md)
|
|
130
|
+
- [Security Policy](./SECURITY.md)
|
|
131
|
+
- [Contributing](./CONTRIBUTING.md)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-init.d.ts","sourceRoot":"","sources":["../src/auto-init.ts"],"names":[],"mappings":"AAAA,OAAO,IAA6D,MAAM,SAAS,CAAC;AAoBpF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Scope } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Register a scope
|
|
4
|
+
*/
|
|
5
|
+
export declare function scope(name: string | HTMLElement, definition: Scope): void;
|
|
6
|
+
/**
|
|
7
|
+
* Mount all scopes in the document
|
|
8
|
+
*/
|
|
9
|
+
export declare function mountAll(): void;
|
|
10
|
+
export declare function mountTree(el: HTMLElement): void;
|
|
11
|
+
/**
|
|
12
|
+
* Mount a element with g-scope attribute
|
|
13
|
+
*/
|
|
14
|
+
export declare function mount(el: HTMLElement): void;
|
|
15
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAkC,MAAM,UAAU,CAAC;AAoBtE;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,UAAU,EAAE,KAAK,GAAG,IAAI,CAWzE;AAWD;;GAEG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAmB/B;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe/C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe3C"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Signal } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* useFetch - Fetch data composable
|
|
4
|
+
*/
|
|
5
|
+
export declare function useFetch<T = any>(url: string | (() => string | Response | Promise<string | Response>)): {
|
|
6
|
+
data: Signal<T | null>;
|
|
7
|
+
loading: Signal<boolean>;
|
|
8
|
+
error: Signal<Error | null>;
|
|
9
|
+
refetch: () => Promise<void>;
|
|
10
|
+
onMount: () => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* useCounter - Counter composable
|
|
14
|
+
*/
|
|
15
|
+
export declare function useCounter(initialValue?: number): {
|
|
16
|
+
count: Signal<number>;
|
|
17
|
+
double: import("../types").Computed<number>;
|
|
18
|
+
increment: (step?: number) => void;
|
|
19
|
+
decrement: (step?: number) => void;
|
|
20
|
+
reset: () => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* useToggle - Toggle composable
|
|
24
|
+
*/
|
|
25
|
+
export declare function useToggle(initialValue?: boolean): {
|
|
26
|
+
state: Signal<boolean>;
|
|
27
|
+
toggle: () => void;
|
|
28
|
+
setTrue: () => void;
|
|
29
|
+
setFalse: () => void;
|
|
30
|
+
value: Signal<boolean>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* useLocalStorage - LocalStorage composable
|
|
34
|
+
*/
|
|
35
|
+
export declare function useLocalStorage<T>(key: string, defaultValue?: T): {
|
|
36
|
+
state: Signal<T>;
|
|
37
|
+
remove: () => void;
|
|
38
|
+
onUnmount: () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* useInterval - Interval composable
|
|
42
|
+
*/
|
|
43
|
+
export declare function useInterval(callback: () => void, delay: number | null): {
|
|
44
|
+
start: () => void;
|
|
45
|
+
stop: () => void;
|
|
46
|
+
onMount: () => void;
|
|
47
|
+
onUnmount: () => void;
|
|
48
|
+
restart: () => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* useTimeout - Timeout composable
|
|
52
|
+
*/
|
|
53
|
+
export declare function useTimeout(callback: () => void, delay: number): {
|
|
54
|
+
start: () => void;
|
|
55
|
+
clear: () => void;
|
|
56
|
+
onMount: () => void;
|
|
57
|
+
onUnmount: () => void;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* useDebounce - Debounce composable
|
|
61
|
+
*/
|
|
62
|
+
export declare function useDebounce(initialValue: string | undefined, delay: number): {
|
|
63
|
+
value: Signal<string>;
|
|
64
|
+
debounced: import("../types").Computed<string>;
|
|
65
|
+
onUnmount: () => void;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* useThrottle - Throttle composable
|
|
69
|
+
*/
|
|
70
|
+
export declare function useThrottle(initialValue: string | undefined, delay: number): {
|
|
71
|
+
value: Signal<string>;
|
|
72
|
+
throttled: import("../types").Computed<string>;
|
|
73
|
+
onUnmount: () => void;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* useMouse - Mouse position composable
|
|
77
|
+
*/
|
|
78
|
+
export declare function useMouse(): {
|
|
79
|
+
x: Signal<number>;
|
|
80
|
+
y: Signal<number>;
|
|
81
|
+
onMount: () => void;
|
|
82
|
+
onUnmount: () => void;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* useWindowSize - Window size composable
|
|
86
|
+
*/
|
|
87
|
+
export declare function useWindowSize(): {
|
|
88
|
+
width: Signal<number>;
|
|
89
|
+
height: Signal<number>;
|
|
90
|
+
onMount: () => void;
|
|
91
|
+
onUnmount: () => void;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* useMediaQuery - Media query composable
|
|
95
|
+
*/
|
|
96
|
+
export declare function useMediaQuery(queries: {
|
|
97
|
+
[key: string]: string;
|
|
98
|
+
}): {
|
|
99
|
+
matches: Record<string, Signal<boolean>>;
|
|
100
|
+
onMount: () => void;
|
|
101
|
+
onUnmount: () => void;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* useAsync - Async state composable
|
|
105
|
+
*/
|
|
106
|
+
export declare function useAsync<T>(asyncFn: () => Promise<T>, immediate?: boolean): {
|
|
107
|
+
data: Signal<T | null>;
|
|
108
|
+
loading: Signal<boolean>;
|
|
109
|
+
error: Signal<Error | null>;
|
|
110
|
+
execute: () => Promise<void>;
|
|
111
|
+
onMount: () => void;
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=composables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables.d.ts","sourceRoot":"","sources":["../../src/core/composables.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAC/B,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;;;;;;EAkCpE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,YAAY,SAAI;;;;;;EAuB1C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,YAAY,UAAQ;;;;;;EAsB7C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;;;;EAiB/D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;;;;;;EA2BrE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM;;;;;EAwB7D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,YAAY,oBAAK,EAAE,KAAK,EAAE,MAAM;;;;EA6B3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,YAAY,oBAAK,EAAE,KAAK,EAAE,MAAM;;;;EAyB3D;AAED;;GAEG;AACH,wBAAgB,QAAQ;;;;;EAkBvB;AAED;;GAEG;AACH,wBAAgB,aAAa;;;;;EAkB5B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;EA0C/D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,UAAO;;;;;;EA2BtE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Injection System
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Service container
|
|
6
|
+
*/
|
|
7
|
+
declare class Container {
|
|
8
|
+
private services;
|
|
9
|
+
private parent;
|
|
10
|
+
constructor(parent?: Container);
|
|
11
|
+
set(key: string, value: any): void;
|
|
12
|
+
get<T = any>(key: string): T;
|
|
13
|
+
has(key: string): boolean;
|
|
14
|
+
createChild(): Container;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get or create injector for element
|
|
18
|
+
*/
|
|
19
|
+
export declare function getInjector(el: HTMLElement): Container;
|
|
20
|
+
/**
|
|
21
|
+
* Provide a service globally
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Provide API service
|
|
25
|
+
* Gyos.provide('api', {
|
|
26
|
+
* fetchUser: () => fetch('/api/user').then(r => r.json())
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
export declare function provide(key: string, value: any): void;
|
|
30
|
+
/**
|
|
31
|
+
* Inject a service from global DI container
|
|
32
|
+
*
|
|
33
|
+
* NOTE: This only works with globally provided services via Gyos.provide().
|
|
34
|
+
* To use element-scoped services (g-provide), use this.$inject() inside scopes.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Global provide + inject
|
|
38
|
+
* Gyos.provide('api', apiService);
|
|
39
|
+
* const api = Gyos.inject('api'); // Works
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Element-scoped provide + inject
|
|
43
|
+
* // <div g-provide='{"theme": "dark"}' g-scope="Demo">
|
|
44
|
+
* Gyos.scope('Demo', {
|
|
45
|
+
* onMount() {
|
|
46
|
+
* const theme = this.$inject('theme'); // Use this.$inject, not Gyos.inject
|
|
47
|
+
* }
|
|
48
|
+
* });
|
|
49
|
+
*/
|
|
50
|
+
export declare function inject<T = any>(key: string, defaultValue?: T): T;
|
|
51
|
+
/**
|
|
52
|
+
* Get global container (for internal use)
|
|
53
|
+
*/
|
|
54
|
+
export declare function getGlobalContainer(): Container;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=di.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"di.d.ts","sourceRoot":"","sources":["../../src/core/di.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,cAAM,SAAS;IACd,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,CAAC,EAAE,SAAS;IAI9B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIlC,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAY5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,WAAW,IAAI,SAAS;CAGxB;AAYD;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,GAAG,SAAS,CA8CtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAErD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAYhE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,CAE9C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Directive System
|
|
3
|
+
* Allows creating reusable DOM manipulation behaviors
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Register a directive
|
|
7
|
+
* Gyos.directive('focus', {
|
|
8
|
+
* mounted(el) {
|
|
9
|
+
* el.focus();
|
|
10
|
+
* }
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // Use in HTML
|
|
14
|
+
* // <input g-focus />
|
|
15
|
+
*/
|
|
16
|
+
import type { Directive } from '../types';
|
|
17
|
+
/**
|
|
18
|
+
* Register a custom directive
|
|
19
|
+
*
|
|
20
|
+
* @param name - Directive name (without 'g-' prefix)
|
|
21
|
+
* @param def - Directive definition with lifecycle hooks or simple function
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Full definition
|
|
25
|
+
* Gyos.directive('tooltip', {
|
|
26
|
+
* mounted(el, binding) {
|
|
27
|
+
* el.title = binding.value;
|
|
28
|
+
* },
|
|
29
|
+
* updated(el, binding) {
|
|
30
|
+
* el.title = binding.value;
|
|
31
|
+
* },
|
|
32
|
+
* unmounted(el) {
|
|
33
|
+
* el.title = '';
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Shorthand (function applies to both mounted and updated)
|
|
39
|
+
* Gyos.directive('color', (el, binding) => {
|
|
40
|
+
* el.style.color = binding.value;
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
43
|
+
export declare function directive(name: string, def: Directive | Function): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get a directive
|
|
46
|
+
*/
|
|
47
|
+
export declare function getDirective(name: string): Directive | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Apply directive to element
|
|
50
|
+
*/
|
|
51
|
+
export declare function applyDirective(el: HTMLElement, name: string, value: any, arg?: string[]): () => void;
|
|
52
|
+
//# sourceMappingURL=directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../src/core/directive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAK1C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CASvE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEhE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,EACV,GAAG,CAAC,EAAE,MAAM,EAAE,GACZ,MAAM,IAAI,CAwBZ"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Event Bus System
|
|
3
|
+
* Pub/sub pattern for cross-component communication
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Component A - emit event
|
|
7
|
+
* Gyos.emit('user-login', { id: 123, name: 'John' });
|
|
8
|
+
*
|
|
9
|
+
* // Component B - listen for event
|
|
10
|
+
* Gyos.on('user-login', (user) => {
|
|
11
|
+
* console.log('User logged in:', user);
|
|
12
|
+
* });
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Subscribe to an event
|
|
16
|
+
*
|
|
17
|
+
* @param event - Event name to listen for
|
|
18
|
+
* @param handler - Callback function to execute when event is emitted
|
|
19
|
+
* @returns Unsubscribe function
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Subscribe
|
|
23
|
+
* const unsubscribe = Gyos.on('data-changed', (data) => {
|
|
24
|
+
* console.log('Data:', data);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Unsubscribe later
|
|
28
|
+
* unsubscribe();
|
|
29
|
+
*/
|
|
30
|
+
export declare function on(event: string, handler: Function): () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Emit an event
|
|
33
|
+
*
|
|
34
|
+
* @param event - Event name to emit
|
|
35
|
+
* @param args - Arguments to pass to handlers
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* Gyos.emit('cart-updated', { items: 3, total: 99.99 });
|
|
39
|
+
* Gyos.emit('modal-close');
|
|
40
|
+
*/
|
|
41
|
+
export declare function emit(event: string, ...args: any[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Unsubscribe from an event
|
|
44
|
+
*
|
|
45
|
+
* @param event - Event name
|
|
46
|
+
* @param handler - Specific handler to remove (optional, removes all if not provided)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Remove specific handler
|
|
50
|
+
* Gyos.off('data-changed', myHandler);
|
|
51
|
+
*
|
|
52
|
+
* // Remove all handlers for event
|
|
53
|
+
* Gyos.off('data-changed');
|
|
54
|
+
*/
|
|
55
|
+
export declare function off(event: string, handler?: Function): void;
|
|
56
|
+
/**
|
|
57
|
+
* Subscribe once - handler will be called only once then auto-unsubscribed
|
|
58
|
+
*
|
|
59
|
+
* @param event - Event name to listen for
|
|
60
|
+
* @param handler - Callback function (will only execute once)
|
|
61
|
+
* @returns Unsubscribe function
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Listen for first load only
|
|
65
|
+
* Gyos.once('app-ready', () => {
|
|
66
|
+
* console.log('App is ready!');
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* Gyos.emit('app-ready'); // Handler called
|
|
70
|
+
* Gyos.emit('app-ready'); // Handler NOT called (already unsubscribed)
|
|
71
|
+
*/
|
|
72
|
+
export declare function once(event: string, handler: Function): () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Get all active event listeners (for debugging)
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* console.log('Active events:', Gyos.getEventListeners());
|
|
78
|
+
*/
|
|
79
|
+
export declare function getEventListeners(): Record<string, number>;
|
|
80
|
+
/**
|
|
81
|
+
* Clear all event listeners
|
|
82
|
+
* Useful for cleanup in tests or when unmounting app
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* Gyos.clearAllEvents();
|
|
86
|
+
*/
|
|
87
|
+
export declare function clearAllEvents(): void;
|
|
88
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAW/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAWxD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAQ3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAOjE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM1D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hydration Strategies System
|
|
3
|
+
* Load scopes smartly to improve initial page load performance
|
|
4
|
+
*
|
|
5
|
+
* Strategies:
|
|
6
|
+
* - 'idle': Load when browser is idle (requestIdleCallback)
|
|
7
|
+
* - 'visible': Load when scrolled into viewport (IntersectionObserver)
|
|
8
|
+
* - 'interaction': Load on user interaction (mouseenter, touchstart, focus)
|
|
9
|
+
* - 'media(query)': Load based on media query match
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Lazy load on scroll
|
|
13
|
+
* <div g-scope="HeavyScope" g-hydrate="visible">...</div>
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Load on interaction
|
|
17
|
+
* <div g-scope="TooltipScope" g-hydrate="interaction">...</div>
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Load on mobile only
|
|
21
|
+
* <div g-scope="MobileMenu" g-hydrate="media(max-width: 768px)">...</div>
|
|
22
|
+
*/
|
|
23
|
+
import { HydrationStrategy } from "../types";
|
|
24
|
+
/**
|
|
25
|
+
* Hydration manager - Singleton class managing scope hydration
|
|
26
|
+
*/
|
|
27
|
+
declare class HydrationManager {
|
|
28
|
+
private observers;
|
|
29
|
+
private intersectionObserver?;
|
|
30
|
+
private pending;
|
|
31
|
+
/**
|
|
32
|
+
* Setup hydration for element based on strategy
|
|
33
|
+
*
|
|
34
|
+
* @param el - Element to hydrate
|
|
35
|
+
* @param strategy - Hydration strategy ('idle', 'visible', 'interaction', or 'media(query)')
|
|
36
|
+
* @param callback - Function to call when hydration should occur
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* hydrationManager.setup(el, 'visible', () => {
|
|
40
|
+
* mountScope(el);
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
43
|
+
setup(el: HTMLElement, strategy: HydrationStrategy, callback: () => void): void;
|
|
44
|
+
/**
|
|
45
|
+
* Hydrate when browser is idle (uses requestIdleCallback)
|
|
46
|
+
* Falls back to setTimeout if requestIdleCallback not available
|
|
47
|
+
*
|
|
48
|
+
* @param callback - Function to call when browser is idle
|
|
49
|
+
*/
|
|
50
|
+
private hydrateOnIdle;
|
|
51
|
+
/**
|
|
52
|
+
* Hydrate when element becomes visible in viewport
|
|
53
|
+
* Uses IntersectionObserver with 50px rootMargin for preloading
|
|
54
|
+
*
|
|
55
|
+
* @param el - Element to observe
|
|
56
|
+
* @param callback - Function to call when element becomes visible
|
|
57
|
+
*/
|
|
58
|
+
private hydrateOnVisible;
|
|
59
|
+
/**
|
|
60
|
+
* Hydrate on user interaction (mouseenter, touchstart, or focus)
|
|
61
|
+
* Automatically removes listeners after first interaction
|
|
62
|
+
*
|
|
63
|
+
* @param el - Element to attach interaction listeners to
|
|
64
|
+
* @param callback - Function to call on first interaction
|
|
65
|
+
*/
|
|
66
|
+
private hydrateOnInteraction;
|
|
67
|
+
/**
|
|
68
|
+
* Hydrate based on media query match
|
|
69
|
+
* Hydrates immediately if query matches, otherwise waits for match
|
|
70
|
+
*
|
|
71
|
+
* @param mediaQuery - CSS media query string (e.g., "(max-width: 768px)")
|
|
72
|
+
* @param callback - Function to call when media query matches
|
|
73
|
+
*/
|
|
74
|
+
private hydrateOnMedia;
|
|
75
|
+
private trackCleanup;
|
|
76
|
+
/**
|
|
77
|
+
* Cleanup observers for element (called on unmount)
|
|
78
|
+
*
|
|
79
|
+
* @param el - Element to cleanup
|
|
80
|
+
*/
|
|
81
|
+
cleanup(el: HTMLElement): void;
|
|
82
|
+
}
|
|
83
|
+
export declare const hydrationManager: HydrationManager;
|
|
84
|
+
/**
|
|
85
|
+
* Get hydration strategy from element's g-hydrate attribute
|
|
86
|
+
*
|
|
87
|
+
* @param el - Element to check
|
|
88
|
+
* @returns Hydration strategy or null if not set
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* <div g-hydrate="visible">...</div>
|
|
92
|
+
* getHydrationStrategy(el) // Returns 'visible'
|
|
93
|
+
*/
|
|
94
|
+
export declare function getHydrationStrategy(el: HTMLElement): HydrationStrategy | null;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=hydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../src/core/hydration.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,cAAM,gBAAgB;IACrB,OAAO,CAAC,SAAS,CAAsC;IACvD,OAAO,CAAC,oBAAoB,CAAC,CAAuB;IACpD,OAAO,CAAC,OAAO,CAA8B;IAE7C;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IA6B/E;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAwBrB;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAsCxB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IA0B5B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,YAAY;IAUpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI;CAO9B;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,WAAW,GAAG,iBAAiB,GAAG,IAAI,CAK9E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PipeFn } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Register a custom pipe
|
|
4
|
+
*
|
|
5
|
+
* @param name - Pipe name (used in templates)
|
|
6
|
+
* @param fn - Transform function (first param is value, rest are args)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* Gyos.pipe('multiply', (value, factor = 2) => {
|
|
10
|
+
* return value * factor;
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // In template: {count | multiply(3)}
|
|
14
|
+
*/
|
|
15
|
+
export declare function pipe(name: string, fn: PipeFn): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get a pipe
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPipe(name: string): Function | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Apply pipe to value
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyPipe(value: any, pipeName: string, args?: any[]): any;
|
|
24
|
+
/**
|
|
25
|
+
* Parse pipe expression: {value | pipe1(arg1, arg2) | pipe2}
|
|
26
|
+
*/
|
|
27
|
+
export declare function parsePipeExpression(expr: string): {
|
|
28
|
+
base: string;
|
|
29
|
+
pipes: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
args: string[];
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=pipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/core/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAwBlC;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE1D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,EAAO,GAAG,GAAG,CAa7E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,CAkIlH"}
|