gyosjs 0.2.3 → 0.3.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.
Files changed (54) hide show
  1. package/README.md +129 -125
  2. package/dist/auto-init.d.ts +1 -1
  3. package/dist/auto-init.d.ts.map +1 -1
  4. package/dist/core/component.d.ts.map +1 -1
  5. package/dist/core/router/router.d.ts.map +1 -1
  6. package/dist/core/router/script.d.ts.map +1 -1
  7. package/dist/core/transition.d.ts.map +1 -1
  8. package/dist/csp-auto-init.d.ts +3 -0
  9. package/dist/csp-auto-init.d.ts.map +1 -0
  10. package/dist/csp.d.ts +3 -0
  11. package/dist/csp.d.ts.map +1 -0
  12. package/dist/form/form-validation.d.ts.map +1 -1
  13. package/dist/gyos.auto.esm.js +89 -55
  14. package/dist/gyos.auto.esm.js.map +1 -1
  15. package/dist/gyos.auto.js +89 -55
  16. package/dist/gyos.auto.js.map +1 -1
  17. package/dist/gyos.auto.min.js +2 -2
  18. package/dist/gyos.csp.auto.esm.js +14979 -0
  19. package/dist/gyos.csp.auto.esm.js.map +1 -0
  20. package/dist/gyos.csp.auto.js +14989 -0
  21. package/dist/gyos.csp.auto.js.map +1 -0
  22. package/dist/gyos.csp.auto.min.js +6 -0
  23. package/dist/gyos.csp.esm.js +14952 -0
  24. package/dist/gyos.csp.esm.js.map +1 -0
  25. package/dist/gyos.csp.js +15023 -0
  26. package/dist/gyos.csp.js.map +1 -0
  27. package/dist/gyos.csp.min.js +6 -0
  28. package/dist/gyos.css +73 -0
  29. package/dist/gyos.esm.js +91 -56
  30. package/dist/gyos.esm.js.map +1 -1
  31. package/dist/gyos.js +91 -55
  32. package/dist/gyos.js.map +1 -1
  33. package/dist/gyos.min.js +2 -2
  34. package/dist/index.d.ts +2 -85
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/public-api.d.ts +89 -0
  37. package/dist/public-api.d.ts.map +1 -0
  38. package/dist/runtime/csp-evaluator.d.ts +7 -0
  39. package/dist/runtime/csp-evaluator.d.ts.map +1 -0
  40. package/dist/runtime/csp-nonce.d.ts +7 -0
  41. package/dist/runtime/csp-nonce.d.ts.map +1 -0
  42. package/dist/runtime/evaluator.d.ts +12 -0
  43. package/dist/runtime/evaluator.d.ts.map +1 -0
  44. package/dist/runtime/install-csp.d.ts +2 -0
  45. package/dist/runtime/install-csp.d.ts.map +1 -0
  46. package/dist/runtime/install-standard.d.ts +2 -0
  47. package/dist/runtime/install-standard.d.ts.map +1 -0
  48. package/dist/runtime/standard-evaluator.d.ts +3 -0
  49. package/dist/runtime/standard-evaluator.d.ts.map +1 -0
  50. package/dist/template/events.d.ts.map +1 -1
  51. package/dist/template/expression.d.ts.map +1 -1
  52. package/dist/utils/target-spinner.d.ts +0 -4
  53. package/dist/utils/target-spinner.d.ts.map +1 -1
  54. package/package.json +72 -55
package/README.md CHANGED
@@ -1,131 +1,135 @@
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`.
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
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
-
16
+ - Choose an optional strict-CSP build when the site cannot allow `unsafe-eval` or inline runtime styles.
17
+
18
+ ## When It Fits
19
+
20
+ GyosJS is a good fit when you are building:
21
+
22
+ - Laravel, PHP, Rails, MVC, and other server-rendered apps
23
+ - admin tools and internal dashboards
24
+ - marketing sites with small interactive sections
25
+ - MPA products that want smoother navigation without client-side routing everywhere
26
+ - projects that do not need React/Vue-level component systems
27
+
28
+ 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.
29
+
30
+ ## Quick Start
31
+
32
+ ### CDN: no build step
33
+
34
+ Use the browser auto-init build when you want HTML-first usage with minimal setup.
35
+
36
+ ```html
37
+ <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.3.0/dist/gyos.auto.min.js"></script>
38
+ ```
39
+
40
+ That build attaches `window.Gyos`, starts the router when `g-boost` exists, injects transition styles, and mounts scopes when the page is ready.
41
+
42
+ ### npm: bundler or app build
43
+
44
+ ```bash
45
+ npm install gyosjs
46
+ ```
47
+
48
+ Use the core runtime when you want explicit control:
49
+
50
+ ```js
51
+ import Gyos from 'gyosjs';
52
+
53
+ Gyos.scope('Counter', {
54
+ count: 0,
55
+ increment() {
56
+ this.count++;
57
+ }
58
+ });
59
+
60
+ Gyos.ready(() => {
61
+ Gyos.mountAll();
62
+ });
63
+ ```
64
+
64
65
  Or use the auto entrypoint:
65
-
66
- ```js
66
+
67
+ ```js
67
68
  import 'gyosjs/auto';
68
69
  ```
69
70
 
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)
71
+ Strict CSP deployments use `gyosjs/csp` or `gyosjs/csp/auto` with the static `gyosjs/styles.css` export. CSP mode keeps the same directives and router but intentionally supports a smaller expression language. See [Content Security Policy](./docs/en/content-security-policy.md).
72
+
73
+ ## Minimal Example
74
+
75
+ ```html
76
+ <div g-scope="{ name: 'GyosJS' }">
77
+ <p>Hello, {name}</p>
78
+ <input g-model="name">
79
+ </div>
80
+ ```
81
+
82
+ 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.
83
+
84
+ ## MPA Boost Example
85
+
86
+ ```html
87
+ <body g-boost>
88
+ <main id="app" g-outlet g-snapshot>
89
+ <nav>
90
+ <a href="/posts.html">Posts</a>
91
+ <a href="/about.html">About</a>
92
+ </nav>
93
+ </main>
94
+ </body>
95
+ ```
96
+
97
+ 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.
98
+
99
+ ## Documentation
100
+
101
+ - [Introduction](./docs/en/introduction.md)
102
+ - [Getting Started](./docs/en/getting-started.md)
103
+ - [What Is G-Scope](./docs/en/what-is-gscope.md)
104
+ - [Reactivity and Signals](./docs/en/reactivity-signals.md)
105
+ - [Template Syntax](./docs/en/template-syntax.md)
106
+ - [Examples](./docs/en/examples.md)
107
+ - [Tutorial Guide](./docs/en/tutorial-guide.md)
108
+ - [API Reference](./docs/en/api-reference.md)
109
+ - [MPA Boost Deep Dive](./docs/en/mpa-boost-deep-dive.md)
110
+ - [Layouts, Scripts, and Lifecycle](./docs/en/layouts-scripts-lifecycle.md)
111
+ - [Best Practices](./docs/en/best-practices.md)
109
112
  - [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)
113
+ - [Content Security Policy](./docs/en/content-security-policy.md)
114
+ - [Migration Guide](./docs/en/migrate-from-javascript.md)
115
+
116
+ ## Examples In This Repo
117
+
118
+ - [`examples/router`](./examples/router) covers router behaviors such as `g-target`, `g-router-link`, `g-persist`, `g-swap`, and snapshots.
119
+ - [`examples/mpa-demo`](./examples/mpa-demo) shows the smaller MPA boost flow.
120
+ - [`examples`](./examples) includes reactive demos, forms, async rendering, and stress-test style development examples.
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ npm install
126
+ npm run build
127
+ npm run test
128
+ npm run typecheck
129
+ ```
130
+
131
+ ## Open Source Files
132
+
133
+ - [License](./LICENSE.md)
134
+ - [Security Policy](./SECURITY.md)
135
+ - [Contributing](./CONTRIBUTING.md)
@@ -1,3 +1,3 @@
1
- import Gyos from './index';
1
+ import Gyos from './public-api';
2
2
  export default Gyos;
3
3
  //# sourceMappingURL=auto-init.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"auto-init.d.ts","sourceRoot":"","sources":["../src/auto-init.ts"],"names":[],"mappings":"AAAA,OAAO,IAA6D,MAAM,cAAc,CAAC;AAwBzF,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAkC,MAAM,UAAU,CAAC;AAoBvF;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAWnF;AAWD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAyBzE;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAc/C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe3C"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAkC,MAAM,UAAU,CAAC;AAqBvF;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAWnF;AAWD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAyBzE;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAc/C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe3C"}
@@ -1 +1 @@
1
- {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,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAYtG;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG;AAED,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAGjE"}
1
+ {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/core/router/script.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAiB9C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAkBtE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAG9E;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,YAAY,gBAAgC,GAAG,IAAI,CAGlH;AAED,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,WAAW,EACpB,YAAY,gBAAgC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAwBf;AAqCD,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAYtG;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG;AAED,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAGjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../src/core/transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,gBAAgB;IAChC,gEAAgE;IAChE,KAAK,CAAC,EAAE,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E,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAE/E;AAED;;GAEG;AACH,cAAM,iBAAiB;IACtB,OAAO,CAAC,MAAM,CAAgF;IAE9F,MAAM,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI;IAI7B,KAAK,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAM1F,KAAK,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,UAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxF,OAAO,CAAC,GAAG;IAmEX;;OAEG;IACH,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAMrB;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,gBAAgB;IAQ5D;;;;OAIG;IACH,uBAAuB,IAAI,MAAM,EAAE;CAGnC;AAGD,eAAO,MAAM,iBAAiB,mBAA0B,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAoCzF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAiE5C"}
@@ -0,0 +1,3 @@
1
+ import Gyos from './public-api';
2
+ export default Gyos;
3
+ //# sourceMappingURL=csp-auto-init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp-auto-init.d.ts","sourceRoot":"","sources":["../src/csp-auto-init.ts"],"names":[],"mappings":"AAAA,OAAO,IAAsC,MAAM,cAAc,CAAC;AAqBlE,eAAe,IAAI,CAAC"}
package/dist/csp.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './public-api';
2
+ export { default } from './public-api';
3
+ //# sourceMappingURL=csp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.d.ts","sourceRoot":"","sources":["../src/csp.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -1 +1 @@
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,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.3.0
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -1236,6 +1236,20 @@ pipe('reverse', (value) => {
1236
1236
  return value;
1237
1237
  });
1238
1238
 
1239
+ let activeRuntime;
1240
+ function setExpressionRuntime(runtime) {
1241
+ activeRuntime = runtime;
1242
+ }
1243
+ function expressionRuntime() {
1244
+ if (!activeRuntime) {
1245
+ throw new Error('[GyosJS] Expression runtime is not configured. Import GyosJS from a public entry point.');
1246
+ }
1247
+ return activeRuntime;
1248
+ }
1249
+ function expressionRuntimeMode() {
1250
+ return activeRuntime?.mode ?? 'standard';
1251
+ }
1252
+
1239
1253
  /**
1240
1254
  * Expression Evaluation & Interpolation
1241
1255
  * Handles template expressions, pipes, and string interpolation
@@ -1337,24 +1351,7 @@ function evaluateSimpleExpression(expr, scope) {
1337
1351
  if (!isNaN(Number(expr))) {
1338
1352
  return Number(expr);
1339
1353
  }
1340
- // Use Function to evaluate in scope context
1341
- // This allows getters and signals to be tracked properly
1342
- try {
1343
- const method = scope[expr];
1344
- if (typeof method === "function") {
1345
- return method.call(scope);
1346
- }
1347
- else {
1348
- // Wrap expression in try-catch to handle null/undefined access gracefully
1349
- const safeExpr = `try { return ${expr} } catch(e) { return undefined }`;
1350
- const fn = new Function("$scope", `with($scope) { ${safeExpr} }`);
1351
- return fn(scope);
1352
- }
1353
- }
1354
- catch (e) {
1355
- console.error("[GyosJS] Error evaluating expression:", expr, e);
1356
- return undefined;
1357
- }
1354
+ return expressionRuntime().evaluate(expr, scope);
1358
1355
  }
1359
1356
 
1360
1357
  /**
@@ -2192,6 +2189,8 @@ function getTransitionConfig(source) {
2192
2189
  function applyTransitionStyles() {
2193
2190
  if (typeof document === 'undefined')
2194
2191
  return;
2192
+ if (expressionRuntimeMode() === 'csp')
2193
+ return;
2195
2194
  const styleId = 'gyos-transitions';
2196
2195
  if (document.getElementById(styleId))
2197
2196
  return;
@@ -3262,8 +3261,8 @@ validator('between', (value, min, max) => {
3262
3261
 
3263
3262
  const managedForms = new WeakSet();
3264
3263
  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.
3264
+ // Coordinates the form capture validator with the Router's document listener
3265
+ // without exposing state on application elements.
3267
3266
  function registerValidatedForm(form) {
3268
3267
  managedForms.add(form);
3269
3268
  }
@@ -3413,7 +3412,6 @@ function processFormDirective(form, scope) {
3413
3412
  const submitListener = async (e) => {
3414
3413
  if (replayingSubmission) {
3415
3414
  replayingSubmission = false;
3416
- cancelApprovedFormSubmission(form);
3417
3415
  return;
3418
3416
  }
3419
3417
  e.preventDefault();
@@ -3444,11 +3442,11 @@ function processFormDirective(form, scope) {
3444
3442
  }
3445
3443
  finally {
3446
3444
  // requestSubmit dispatches synchronously. If native validation or
3447
- // another capture listener stopped it, do not leak approval state.
3445
+ // another listener stopped it, do not leak approval state.
3448
3446
  if (replayingSubmission) {
3449
3447
  replayingSubmission = false;
3450
- cancelApprovedFormSubmission(form);
3451
3448
  }
3449
+ cancelApprovedFormSubmission(form);
3452
3450
  }
3453
3451
  }, 0);
3454
3452
  return;
@@ -3680,24 +3678,7 @@ function executeHandler(handler, scope, e, modifiers) {
3680
3678
  if (modifiers.includes('stop'))
3681
3679
  e.stopPropagation();
3682
3680
  try {
3683
- const isMethodCall = handler.includes('(');
3684
- if (isMethodCall) {
3685
- // Method call with args: "doSomething()" or "method(arg1, arg2)"
3686
- const fn = new Function('$event', `with(this) { ${handler} }`);
3687
- fn.call(scope, e);
3688
- }
3689
- else {
3690
- // Check if it's a method name or expression
3691
- const method = scope[handler];
3692
- if (typeof method === 'function') {
3693
- method.call(scope, e);
3694
- }
3695
- else {
3696
- // Expression like "count++", "count = 0"
3697
- const fn = new Function('$event', `with(this) { ${handler} }`);
3698
- fn.call(scope, e);
3699
- }
3700
- }
3681
+ expressionRuntime().execute(handler, scope, e);
3701
3682
  }
3702
3683
  catch (err) {
3703
3684
  console.error('[GyosJS] Error in event handler:', err);
@@ -5673,10 +5654,7 @@ function parseInlineScope(scopeStr) {
5673
5654
  if (!trimmed.startsWith('{')) {
5674
5655
  return undefined; // Not an inline definition
5675
5656
  }
5676
- // Parse as JavaScript object using Function constructor
5677
- // This allows methods and complex expressions
5678
- const fn = new Function(`return (${trimmed})`);
5679
- const definition = fn();
5657
+ const definition = expressionRuntime().parseScope(trimmed);
5680
5658
  DEBUG() && console.log('[GyosJS] Parsed inline scope:', definition);
5681
5659
  return definition;
5682
5660
  }
@@ -5740,10 +5718,10 @@ function parseAutoScope(el) {
5740
5718
  if (forbidden.some(f => expr.includes(f))) {
5741
5719
  DEBUG() && console.log("[GyosJS] Scope mount error: Forbidden expression:", expr);
5742
5720
  }
5743
- const args = key.split(':').slice(1).join(', ');
5721
+ const args = key.split(':').slice(1);
5744
5722
  const propName = key.split(':')[0];
5745
5723
  try {
5746
- definition[propName] = new Function(args, `with(this) { ${expr} }`);
5724
+ definition[propName] = expressionRuntime().createMethod(args, expr);
5747
5725
  removeAttrs.push(attr.name);
5748
5726
  }
5749
5727
  catch (_) {
@@ -6723,7 +6701,7 @@ function createTargetSpinner() {
6723
6701
  </div>
6724
6702
  `;
6725
6703
  // Inject styles if not already present
6726
- if (!document.getElementById('gyos-target-spinner-styles')) {
6704
+ if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
6727
6705
  const style = document.createElement('style');
6728
6706
  style.id = 'gyos-target-spinner-styles';
6729
6707
  style.textContent = `
@@ -6777,6 +6755,16 @@ function hideTargetSpinner(spinner) {
6777
6755
  }
6778
6756
  }
6779
6757
 
6758
+ let nonceSource;
6759
+ /** Configure the nonce used when Gyos recreates scripts during MPA navigation. */
6760
+ function setCspNonce(source) {
6761
+ nonceSource = source;
6762
+ }
6763
+ function resolveCspNonce() {
6764
+ const value = typeof nonceSource === 'function' ? nonceSource() : nonceSource;
6765
+ return value || undefined;
6766
+ }
6767
+
6780
6768
  // Cache executed scripts to prevent duplicate execution
6781
6769
  const executedScripts = new Set();
6782
6770
  /**
@@ -6877,6 +6865,12 @@ async function executeScript(old, signal) {
6877
6865
  old.remove();
6878
6866
  return;
6879
6867
  }
6868
+ const activeNonce = resolveCspNonce();
6869
+ if (expressionRuntimeMode() === 'csp' && !old.src && !activeNonce) {
6870
+ console.warn('[GyosJS CSP] Skipped an inline MPA script because no active document nonce is configured.');
6871
+ old.textContent = '';
6872
+ return;
6873
+ }
6880
6874
  const executionKey = getScriptExecutionKey(old);
6881
6875
  // Check if script should execute
6882
6876
  if (!shouldExecuteScript(old)) {
@@ -6886,6 +6880,10 @@ async function executeScript(old, signal) {
6886
6880
  }
6887
6881
  const newScript = document.createElement('script');
6888
6882
  Array.from(old.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value));
6883
+ if (expressionRuntimeMode() === 'csp')
6884
+ newScript.removeAttribute('nonce');
6885
+ if (activeNonce)
6886
+ newScript.setAttribute('nonce', activeNonce);
6889
6887
  newScript.textContent = old.hasAttribute('g-script-wrap')
6890
6888
  ? wrapScriptExecution(old.textContent)
6891
6889
  : old.textContent;
@@ -7438,8 +7436,8 @@ function startRouter(options) {
7438
7436
  if (progressBarEnabled) {
7439
7437
  progressBar = new ProgressBar(progressBarEnabled);
7440
7438
  }
7441
- document.addEventListener('click', onClickCapture, true);
7442
- document.addEventListener('submit', onSubmitCapture, true);
7439
+ document.addEventListener('click', onClick);
7440
+ document.addEventListener('submit', onSubmit);
7443
7441
  document.addEventListener('mouseover', onMouseOverCapture, true);
7444
7442
  window.addEventListener('popstate', onPopState);
7445
7443
  if ('scrollRestoration' in history) {
@@ -8110,7 +8108,7 @@ function onClickRouter(element) {
8110
8108
  return; // this case not link (tag a) or form so do nothing
8111
8109
  }
8112
8110
  }
8113
- function onClickCapture(event) {
8111
+ function onClick(event) {
8114
8112
  if (event.defaultPrevented)
8115
8113
  return;
8116
8114
  if (event.button !== 0)
@@ -8167,7 +8165,9 @@ function onMouseOverCapture(event) {
8167
8165
  return;
8168
8166
  preload(url.toString());
8169
8167
  }
8170
- function onSubmitCapture(event) {
8168
+ function onSubmit(event) {
8169
+ if (event.defaultPrevented)
8170
+ return;
8171
8171
  const form = event.target;
8172
8172
  if (!form || form.tagName.toLowerCase() !== 'form')
8173
8173
  return;
@@ -8230,7 +8230,7 @@ function onPopState(event) {
8230
8230
  });
8231
8231
  }
8232
8232
 
8233
- // Default export
8233
+ // Shared public surface used by the standard and CSP entries.
8234
8234
  // Default export remains for convenience (no side effects here)
8235
8235
  const Gyos = {
8236
8236
  scope,
@@ -8293,10 +8293,44 @@ const Gyos = {
8293
8293
  onAfterNavigate,
8294
8294
  portalCreate,
8295
8295
  portalDestroy,
8296
- version: '0.2.3'
8296
+ setCspNonce,
8297
+ version: '0.3.0'
8298
+ };
8299
+
8300
+ const standardExpressionRuntime = {
8301
+ mode: 'standard',
8302
+ evaluate(expression, scope) {
8303
+ const method = scope?.[expression];
8304
+ if (typeof method === 'function')
8305
+ return method.call(scope);
8306
+ try {
8307
+ const safeExpression = `try { return ${expression} } catch(e) { return undefined }`;
8308
+ const evaluate = new Function('$scope', `with($scope) { ${safeExpression} }`);
8309
+ return evaluate(scope);
8310
+ }
8311
+ catch (error) {
8312
+ console.error('[GyosJS] Error evaluating expression:', expression, error);
8313
+ return undefined;
8314
+ }
8315
+ },
8316
+ execute(expression, scope, event) {
8317
+ const method = scope?.[expression];
8318
+ if (typeof method === 'function')
8319
+ return method.call(scope, event);
8320
+ const execute = new Function('$event', `with(this) { ${expression} }`);
8321
+ return execute.call(scope, event);
8322
+ },
8323
+ parseScope(expression) {
8324
+ const parse = new Function(`return (${expression})`);
8325
+ return parse();
8326
+ },
8327
+ createMethod(parameters, body) {
8328
+ return new Function(parameters.join(', '), `with(this) { ${body} }`);
8329
+ }
8297
8330
  };
8298
8331
 
8299
8332
  var _a, _b, _c;
8333
+ setExpressionRuntime(standardExpressionRuntime);
8300
8334
  /**
8301
8335
  * Browser auto-init entry.
8302
8336
  * Attaches Gyos to window, sets debug defaults, injects transitions, starts router,