gyosjs 0.2.4 → 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 (52) hide show
  1. package/README.md +10 -6
  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/script.d.ts.map +1 -1
  6. package/dist/core/transition.d.ts.map +1 -1
  7. package/dist/csp-auto-init.d.ts +3 -0
  8. package/dist/csp-auto-init.d.ts.map +1 -0
  9. package/dist/csp.d.ts +3 -0
  10. package/dist/csp.d.ts.map +1 -0
  11. package/dist/gyos.auto.esm.js +79 -46
  12. package/dist/gyos.auto.esm.js.map +1 -1
  13. package/dist/gyos.auto.js +79 -46
  14. package/dist/gyos.auto.js.map +1 -1
  15. package/dist/gyos.auto.min.js +2 -2
  16. package/dist/gyos.csp.auto.esm.js +14979 -0
  17. package/dist/gyos.csp.auto.esm.js.map +1 -0
  18. package/dist/gyos.csp.auto.js +14989 -0
  19. package/dist/gyos.csp.auto.js.map +1 -0
  20. package/dist/gyos.csp.auto.min.js +6 -0
  21. package/dist/gyos.csp.esm.js +14952 -0
  22. package/dist/gyos.csp.esm.js.map +1 -0
  23. package/dist/gyos.csp.js +15023 -0
  24. package/dist/gyos.csp.js.map +1 -0
  25. package/dist/gyos.csp.min.js +6 -0
  26. package/dist/gyos.css +73 -0
  27. package/dist/gyos.esm.js +81 -47
  28. package/dist/gyos.esm.js.map +1 -1
  29. package/dist/gyos.js +81 -46
  30. package/dist/gyos.js.map +1 -1
  31. package/dist/gyos.min.js +2 -2
  32. package/dist/index.d.ts +2 -85
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/public-api.d.ts +89 -0
  35. package/dist/public-api.d.ts.map +1 -0
  36. package/dist/runtime/csp-evaluator.d.ts +7 -0
  37. package/dist/runtime/csp-evaluator.d.ts.map +1 -0
  38. package/dist/runtime/csp-nonce.d.ts +7 -0
  39. package/dist/runtime/csp-nonce.d.ts.map +1 -0
  40. package/dist/runtime/evaluator.d.ts +12 -0
  41. package/dist/runtime/evaluator.d.ts.map +1 -0
  42. package/dist/runtime/install-csp.d.ts +2 -0
  43. package/dist/runtime/install-csp.d.ts.map +1 -0
  44. package/dist/runtime/install-standard.d.ts +2 -0
  45. package/dist/runtime/install-standard.d.ts.map +1 -0
  46. package/dist/runtime/standard-evaluator.d.ts +3 -0
  47. package/dist/runtime/standard-evaluator.d.ts.map +1 -0
  48. package/dist/template/events.d.ts.map +1 -1
  49. package/dist/template/expression.d.ts.map +1 -1
  50. package/dist/utils/target-spinner.d.ts +0 -4
  51. package/dist/utils/target-spinner.d.ts.map +1 -1
  52. package/package.json +29 -12
package/README.md CHANGED
@@ -12,7 +12,8 @@ GyosJS is built for developers who like server-rendered HTML, traditional MPA ar
12
12
  - Add reactivity directly in markup with `g-scope`, `g-model`, `*if`, `*for`, and events.
13
13
  - Upgrade link and form navigation with `g-boost` instead of rewriting the app as a SPA.
14
14
  - Keep specific UI islands alive across navigations with `g-persist`.
15
- - Use it with a CDN or install it from npm.
15
+ - Use it with a CDN or install it from npm.
16
+ - Choose an optional strict-CSP build when the site cannot allow `unsafe-eval` or inline runtime styles.
16
17
 
17
18
  ## When It Fits
18
19
 
@@ -33,7 +34,7 @@ GyosJS is not trying to replace a full SPA framework. If your app is primarily c
33
34
  Use the browser auto-init build when you want HTML-first usage with minimal setup.
34
35
 
35
36
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.2.4/dist/gyos.auto.min.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.3.0/dist/gyos.auto.min.js"></script>
37
38
  ```
38
39
 
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.
@@ -61,11 +62,13 @@ Gyos.ready(() => {
61
62
  });
62
63
  ```
63
64
 
64
- Or use the auto entrypoint:
65
+ Or use the auto entrypoint:
65
66
 
66
67
  ```js
67
- import 'gyosjs/auto';
68
- ```
68
+ import 'gyosjs/auto';
69
+ ```
70
+
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).
69
72
 
70
73
  ## Minimal Example
71
74
 
@@ -106,7 +109,8 @@ With `g-boost`, same-origin links and forms can be intercepted and swapped into
106
109
  - [MPA Boost Deep Dive](./docs/en/mpa-boost-deep-dive.md)
107
110
  - [Layouts, Scripts, and Lifecycle](./docs/en/layouts-scripts-lifecycle.md)
108
111
  - [Best Practices](./docs/en/best-practices.md)
109
- - [Distribution and Installation](./docs/en/distribution-and-installation.md)
112
+ - [Distribution and Installation](./docs/en/distribution-and-installation.md)
113
+ - [Content Security Policy](./docs/en/content-security-policy.md)
110
114
  - [Migration Guide](./docs/en/migrate-from-javascript.md)
111
115
 
112
116
  ## Examples In This Repo
@@ -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
- {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/core/router/script.ts"],"names":[],"mappings":"AAiBA;;;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,E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mD;IACnD,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;CACzC;AA2DD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,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,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.2.4
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;
@@ -3679,24 +3678,7 @@ function executeHandler(handler, scope, e, modifiers) {
3679
3678
  if (modifiers.includes('stop'))
3680
3679
  e.stopPropagation();
3681
3680
  try {
3682
- const isMethodCall = handler.includes('(');
3683
- if (isMethodCall) {
3684
- // Method call with args: "doSomething()" or "method(arg1, arg2)"
3685
- const fn = new Function('$event', `with(this) { ${handler} }`);
3686
- fn.call(scope, e);
3687
- }
3688
- else {
3689
- // Check if it's a method name or expression
3690
- const method = scope[handler];
3691
- if (typeof method === 'function') {
3692
- method.call(scope, e);
3693
- }
3694
- else {
3695
- // Expression like "count++", "count = 0"
3696
- const fn = new Function('$event', `with(this) { ${handler} }`);
3697
- fn.call(scope, e);
3698
- }
3699
- }
3681
+ expressionRuntime().execute(handler, scope, e);
3700
3682
  }
3701
3683
  catch (err) {
3702
3684
  console.error('[GyosJS] Error in event handler:', err);
@@ -5672,10 +5654,7 @@ function parseInlineScope(scopeStr) {
5672
5654
  if (!trimmed.startsWith('{')) {
5673
5655
  return undefined; // Not an inline definition
5674
5656
  }
5675
- // Parse as JavaScript object using Function constructor
5676
- // This allows methods and complex expressions
5677
- const fn = new Function(`return (${trimmed})`);
5678
- const definition = fn();
5657
+ const definition = expressionRuntime().parseScope(trimmed);
5679
5658
  DEBUG() && console.log('[GyosJS] Parsed inline scope:', definition);
5680
5659
  return definition;
5681
5660
  }
@@ -5739,10 +5718,10 @@ function parseAutoScope(el) {
5739
5718
  if (forbidden.some(f => expr.includes(f))) {
5740
5719
  DEBUG() && console.log("[GyosJS] Scope mount error: Forbidden expression:", expr);
5741
5720
  }
5742
- const args = key.split(':').slice(1).join(', ');
5721
+ const args = key.split(':').slice(1);
5743
5722
  const propName = key.split(':')[0];
5744
5723
  try {
5745
- definition[propName] = new Function(args, `with(this) { ${expr} }`);
5724
+ definition[propName] = expressionRuntime().createMethod(args, expr);
5746
5725
  removeAttrs.push(attr.name);
5747
5726
  }
5748
5727
  catch (_) {
@@ -6722,7 +6701,7 @@ function createTargetSpinner() {
6722
6701
  </div>
6723
6702
  `;
6724
6703
  // Inject styles if not already present
6725
- if (!document.getElementById('gyos-target-spinner-styles')) {
6704
+ if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
6726
6705
  const style = document.createElement('style');
6727
6706
  style.id = 'gyos-target-spinner-styles';
6728
6707
  style.textContent = `
@@ -6776,6 +6755,16 @@ function hideTargetSpinner(spinner) {
6776
6755
  }
6777
6756
  }
6778
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
+
6779
6768
  // Cache executed scripts to prevent duplicate execution
6780
6769
  const executedScripts = new Set();
6781
6770
  /**
@@ -6876,6 +6865,12 @@ async function executeScript(old, signal) {
6876
6865
  old.remove();
6877
6866
  return;
6878
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
+ }
6879
6874
  const executionKey = getScriptExecutionKey(old);
6880
6875
  // Check if script should execute
6881
6876
  if (!shouldExecuteScript(old)) {
@@ -6885,6 +6880,10 @@ async function executeScript(old, signal) {
6885
6880
  }
6886
6881
  const newScript = document.createElement('script');
6887
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);
6888
6887
  newScript.textContent = old.hasAttribute('g-script-wrap')
6889
6888
  ? wrapScriptExecution(old.textContent)
6890
6889
  : old.textContent;
@@ -8231,7 +8230,7 @@ function onPopState(event) {
8231
8230
  });
8232
8231
  }
8233
8232
 
8234
- // Default export
8233
+ // Shared public surface used by the standard and CSP entries.
8235
8234
  // Default export remains for convenience (no side effects here)
8236
8235
  const Gyos = {
8237
8236
  scope,
@@ -8294,10 +8293,44 @@ const Gyos = {
8294
8293
  onAfterNavigate,
8295
8294
  portalCreate,
8296
8295
  portalDestroy,
8297
- version: '0.2.4'
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
+ }
8298
8330
  };
8299
8331
 
8300
8332
  var _a, _b, _c;
8333
+ setExpressionRuntime(standardExpressionRuntime);
8301
8334
  /**
8302
8335
  * Browser auto-init entry.
8303
8336
  * Attaches Gyos to window, sets debug defaults, injects transitions, starts router,