gyosjs 0.2.3 → 0.2.4

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 CHANGED
@@ -1,131 +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.2.3/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)
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.2.4/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)
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,aAAa;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,eAAe;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B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"mappings":"AAqGA;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAmI5E;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CA6F9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAiD5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAqBzE"}
1
+ {"version":3,"file":"form-validation.d.ts","sourceRoot":"","sources":["../../src/form/form-validation.ts"],"names":[],"mappings":"AAqGA;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAkI5E;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CA6F9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAiD5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAqBzE"}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.2.3
2
+ * GyosJS v0.2.4
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -3262,8 +3262,8 @@ validator('between', (value, min, max) => {
3262
3262
 
3263
3263
  const managedForms = new WeakSet();
3264
3264
  const approvedSubmissions = new WeakSet();
3265
- // Coordinates the validation listener on a form with the Router's earlier
3266
- // document-capture listener without exposing state on application elements.
3265
+ // Coordinates the form capture validator with the Router's document listener
3266
+ // without exposing state on application elements.
3267
3267
  function registerValidatedForm(form) {
3268
3268
  managedForms.add(form);
3269
3269
  }
@@ -3413,7 +3413,6 @@ function processFormDirective(form, scope) {
3413
3413
  const submitListener = async (e) => {
3414
3414
  if (replayingSubmission) {
3415
3415
  replayingSubmission = false;
3416
- cancelApprovedFormSubmission(form);
3417
3416
  return;
3418
3417
  }
3419
3418
  e.preventDefault();
@@ -3444,11 +3443,11 @@ function processFormDirective(form, scope) {
3444
3443
  }
3445
3444
  finally {
3446
3445
  // requestSubmit dispatches synchronously. If native validation or
3447
- // another capture listener stopped it, do not leak approval state.
3446
+ // another listener stopped it, do not leak approval state.
3448
3447
  if (replayingSubmission) {
3449
3448
  replayingSubmission = false;
3450
- cancelApprovedFormSubmission(form);
3451
3449
  }
3450
+ cancelApprovedFormSubmission(form);
3452
3451
  }
3453
3452
  }, 0);
3454
3453
  return;
@@ -7438,8 +7437,8 @@ function startRouter(options) {
7438
7437
  if (progressBarEnabled) {
7439
7438
  progressBar = new ProgressBar(progressBarEnabled);
7440
7439
  }
7441
- document.addEventListener('click', onClickCapture, true);
7442
- document.addEventListener('submit', onSubmitCapture, true);
7440
+ document.addEventListener('click', onClick);
7441
+ document.addEventListener('submit', onSubmit);
7443
7442
  document.addEventListener('mouseover', onMouseOverCapture, true);
7444
7443
  window.addEventListener('popstate', onPopState);
7445
7444
  if ('scrollRestoration' in history) {
@@ -8110,7 +8109,7 @@ function onClickRouter(element) {
8110
8109
  return; // this case not link (tag a) or form so do nothing
8111
8110
  }
8112
8111
  }
8113
- function onClickCapture(event) {
8112
+ function onClick(event) {
8114
8113
  if (event.defaultPrevented)
8115
8114
  return;
8116
8115
  if (event.button !== 0)
@@ -8167,7 +8166,9 @@ function onMouseOverCapture(event) {
8167
8166
  return;
8168
8167
  preload(url.toString());
8169
8168
  }
8170
- function onSubmitCapture(event) {
8169
+ function onSubmit(event) {
8170
+ if (event.defaultPrevented)
8171
+ return;
8171
8172
  const form = event.target;
8172
8173
  if (!form || form.tagName.toLowerCase() !== 'form')
8173
8174
  return;
@@ -8293,7 +8294,7 @@ const Gyos = {
8293
8294
  onAfterNavigate,
8294
8295
  portalCreate,
8295
8296
  portalDestroy,
8296
- version: '0.2.3'
8297
+ version: '0.2.4'
8297
8298
  };
8298
8299
 
8299
8300
  var _a, _b, _c;