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.
- package/README.md +129 -125
- package/dist/auto-init.d.ts +1 -1
- package/dist/auto-init.d.ts.map +1 -1
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/core/router/script.d.ts.map +1 -1
- package/dist/core/transition.d.ts.map +1 -1
- package/dist/csp-auto-init.d.ts +3 -0
- package/dist/csp-auto-init.d.ts.map +1 -0
- package/dist/csp.d.ts +3 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/form/form-validation.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +89 -55
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +89 -55
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +14979 -0
- package/dist/gyos.csp.auto.esm.js.map +1 -0
- package/dist/gyos.csp.auto.js +14989 -0
- package/dist/gyos.csp.auto.js.map +1 -0
- package/dist/gyos.csp.auto.min.js +6 -0
- package/dist/gyos.csp.esm.js +14952 -0
- package/dist/gyos.csp.esm.js.map +1 -0
- package/dist/gyos.csp.js +15023 -0
- package/dist/gyos.csp.js.map +1 -0
- package/dist/gyos.csp.min.js +6 -0
- package/dist/gyos.css +73 -0
- package/dist/gyos.esm.js +91 -56
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +91 -55
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/index.d.ts +2 -85
- package/dist/index.d.ts.map +1 -1
- package/dist/public-api.d.ts +89 -0
- package/dist/public-api.d.ts.map +1 -0
- package/dist/runtime/csp-evaluator.d.ts +7 -0
- package/dist/runtime/csp-evaluator.d.ts.map +1 -0
- package/dist/runtime/csp-nonce.d.ts +7 -0
- package/dist/runtime/csp-nonce.d.ts.map +1 -0
- package/dist/runtime/evaluator.d.ts +12 -0
- package/dist/runtime/evaluator.d.ts.map +1 -0
- package/dist/runtime/install-csp.d.ts +2 -0
- package/dist/runtime/install-csp.d.ts.map +1 -0
- package/dist/runtime/install-standard.d.ts +2 -0
- package/dist/runtime/install-standard.d.ts.map +1 -0
- package/dist/runtime/standard-evaluator.d.ts +3 -0
- package/dist/runtime/standard-evaluator.d.ts.map +1 -0
- package/dist/template/events.d.ts.map +1 -1
- package/dist/template/expression.d.ts.map +1 -1
- package/dist/utils/target-spinner.d.ts +0 -4
- package/dist/utils/target-spinner.d.ts.map +1 -1
- package/package.json +72 -55
package/dist/gyos.css
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* GyosJS built-in transition utilities. Required by the CSP build. */
|
|
2
|
+
.gyos-t-opacity-0 { opacity: 0; }
|
|
3
|
+
.gyos-t-opacity-100 { opacity: 1; }
|
|
4
|
+
|
|
5
|
+
.gyos-t-translate-y-0 { transform: translateY(0); }
|
|
6
|
+
.gyos-t-translate-y--100 { transform: translateY(-100%); }
|
|
7
|
+
.gyos-t-translate-y-100 { transform: translateY(100%); }
|
|
8
|
+
.gyos-t-translate-x-0 { transform: translateX(0); }
|
|
9
|
+
.gyos-t-translate-x--100 { transform: translateX(-100%); }
|
|
10
|
+
.gyos-t-translate-x-100 { transform: translateX(100%); }
|
|
11
|
+
|
|
12
|
+
.gyos-t-scale-0 { transform: scale(0); }
|
|
13
|
+
.gyos-t-scale-50 { transform: scale(0.5); }
|
|
14
|
+
.gyos-t-scale-100 { transform: scale(1); }
|
|
15
|
+
|
|
16
|
+
@keyframes gyos-fade-in {
|
|
17
|
+
from { opacity: 0; }
|
|
18
|
+
to { opacity: 1; }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes gyos-fade-out {
|
|
22
|
+
from { opacity: 1; }
|
|
23
|
+
to { opacity: 0; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@keyframes gyos-slide-down {
|
|
27
|
+
from { transform: translateY(-100%); opacity: 0; }
|
|
28
|
+
to { transform: translateY(0); opacity: 1; }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@keyframes gyos-slide-up {
|
|
32
|
+
from { transform: translateY(100%); opacity: 0; }
|
|
33
|
+
to { transform: translateY(0); opacity: 1; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@keyframes gyos-scale-in {
|
|
37
|
+
from { transform: scale(0); opacity: 0; }
|
|
38
|
+
to { transform: scale(1); opacity: 1; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@keyframes gyos-scale-out {
|
|
42
|
+
from { transform: scale(1); opacity: 1; }
|
|
43
|
+
to { transform: scale(0); opacity: 0; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[g-cloak] { display: none !important; }
|
|
47
|
+
|
|
48
|
+
.gyos-target-spinner {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
padding: 20px;
|
|
53
|
+
min-height: 60px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.gyos-spinner-content {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
gap: 10px;
|
|
60
|
+
color: var(--gyos-spinner-color, #667eea);
|
|
61
|
+
font-size: 14px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.gyos-spinner-icon {
|
|
65
|
+
width: 24px;
|
|
66
|
+
height: 24px;
|
|
67
|
+
animation: gyos-spin 1s linear infinite;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@keyframes gyos-spin {
|
|
71
|
+
0% { transform: rotate(0deg); }
|
|
72
|
+
100% { transform: rotate(360deg); }
|
|
73
|
+
}
|
package/dist/gyos.esm.js
CHANGED
|
@@ -1,8 +1,54 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.
|
|
2
|
+
* GyosJS v0.3.0
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
+
let activeRuntime;
|
|
7
|
+
function setExpressionRuntime(runtime) {
|
|
8
|
+
activeRuntime = runtime;
|
|
9
|
+
}
|
|
10
|
+
function expressionRuntime() {
|
|
11
|
+
if (!activeRuntime) {
|
|
12
|
+
throw new Error('[GyosJS] Expression runtime is not configured. Import GyosJS from a public entry point.');
|
|
13
|
+
}
|
|
14
|
+
return activeRuntime;
|
|
15
|
+
}
|
|
16
|
+
function expressionRuntimeMode() {
|
|
17
|
+
return activeRuntime?.mode ?? 'standard';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const standardExpressionRuntime = {
|
|
21
|
+
mode: 'standard',
|
|
22
|
+
evaluate(expression, scope) {
|
|
23
|
+
const method = scope?.[expression];
|
|
24
|
+
if (typeof method === 'function')
|
|
25
|
+
return method.call(scope);
|
|
26
|
+
try {
|
|
27
|
+
const safeExpression = `try { return ${expression} } catch(e) { return undefined }`;
|
|
28
|
+
const evaluate = new Function('$scope', `with($scope) { ${safeExpression} }`);
|
|
29
|
+
return evaluate(scope);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('[GyosJS] Error evaluating expression:', expression, error);
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
execute(expression, scope, event) {
|
|
37
|
+
const method = scope?.[expression];
|
|
38
|
+
if (typeof method === 'function')
|
|
39
|
+
return method.call(scope, event);
|
|
40
|
+
const execute = new Function('$event', `with(this) { ${expression} }`);
|
|
41
|
+
return execute.call(scope, event);
|
|
42
|
+
},
|
|
43
|
+
parseScope(expression) {
|
|
44
|
+
const parse = new Function(`return (${expression})`);
|
|
45
|
+
return parse();
|
|
46
|
+
},
|
|
47
|
+
createMethod(parameters, body) {
|
|
48
|
+
return new Function(parameters.join(', '), `with(this) { ${body} }`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
6
52
|
/**
|
|
7
53
|
* Utility helpers
|
|
8
54
|
*/
|
|
@@ -1337,24 +1383,7 @@ function evaluateSimpleExpression(expr, scope) {
|
|
|
1337
1383
|
if (!isNaN(Number(expr))) {
|
|
1338
1384
|
return Number(expr);
|
|
1339
1385
|
}
|
|
1340
|
-
|
|
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
|
-
}
|
|
1386
|
+
return expressionRuntime().evaluate(expr, scope);
|
|
1358
1387
|
}
|
|
1359
1388
|
|
|
1360
1389
|
/**
|
|
@@ -2192,6 +2221,8 @@ function getTransitionConfig(source) {
|
|
|
2192
2221
|
function applyTransitionStyles() {
|
|
2193
2222
|
if (typeof document === 'undefined')
|
|
2194
2223
|
return;
|
|
2224
|
+
if (expressionRuntimeMode() === 'csp')
|
|
2225
|
+
return;
|
|
2195
2226
|
const styleId = 'gyos-transitions';
|
|
2196
2227
|
if (document.getElementById(styleId))
|
|
2197
2228
|
return;
|
|
@@ -3262,8 +3293,8 @@ validator('between', (value, min, max) => {
|
|
|
3262
3293
|
|
|
3263
3294
|
const managedForms = new WeakSet();
|
|
3264
3295
|
const approvedSubmissions = new WeakSet();
|
|
3265
|
-
// Coordinates the
|
|
3266
|
-
//
|
|
3296
|
+
// Coordinates the form capture validator with the Router's document listener
|
|
3297
|
+
// without exposing state on application elements.
|
|
3267
3298
|
function registerValidatedForm(form) {
|
|
3268
3299
|
managedForms.add(form);
|
|
3269
3300
|
}
|
|
@@ -3413,7 +3444,6 @@ function processFormDirective(form, scope) {
|
|
|
3413
3444
|
const submitListener = async (e) => {
|
|
3414
3445
|
if (replayingSubmission) {
|
|
3415
3446
|
replayingSubmission = false;
|
|
3416
|
-
cancelApprovedFormSubmission(form);
|
|
3417
3447
|
return;
|
|
3418
3448
|
}
|
|
3419
3449
|
e.preventDefault();
|
|
@@ -3444,11 +3474,11 @@ function processFormDirective(form, scope) {
|
|
|
3444
3474
|
}
|
|
3445
3475
|
finally {
|
|
3446
3476
|
// requestSubmit dispatches synchronously. If native validation or
|
|
3447
|
-
// another
|
|
3477
|
+
// another listener stopped it, do not leak approval state.
|
|
3448
3478
|
if (replayingSubmission) {
|
|
3449
3479
|
replayingSubmission = false;
|
|
3450
|
-
cancelApprovedFormSubmission(form);
|
|
3451
3480
|
}
|
|
3481
|
+
cancelApprovedFormSubmission(form);
|
|
3452
3482
|
}
|
|
3453
3483
|
}, 0);
|
|
3454
3484
|
return;
|
|
@@ -3680,24 +3710,7 @@ function executeHandler(handler, scope, e, modifiers) {
|
|
|
3680
3710
|
if (modifiers.includes('stop'))
|
|
3681
3711
|
e.stopPropagation();
|
|
3682
3712
|
try {
|
|
3683
|
-
|
|
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
|
-
}
|
|
3713
|
+
expressionRuntime().execute(handler, scope, e);
|
|
3701
3714
|
}
|
|
3702
3715
|
catch (err) {
|
|
3703
3716
|
console.error('[GyosJS] Error in event handler:', err);
|
|
@@ -5673,10 +5686,7 @@ function parseInlineScope(scopeStr) {
|
|
|
5673
5686
|
if (!trimmed.startsWith('{')) {
|
|
5674
5687
|
return undefined; // Not an inline definition
|
|
5675
5688
|
}
|
|
5676
|
-
|
|
5677
|
-
// This allows methods and complex expressions
|
|
5678
|
-
const fn = new Function(`return (${trimmed})`);
|
|
5679
|
-
const definition = fn();
|
|
5689
|
+
const definition = expressionRuntime().parseScope(trimmed);
|
|
5680
5690
|
DEBUG() && console.log('[GyosJS] Parsed inline scope:', definition);
|
|
5681
5691
|
return definition;
|
|
5682
5692
|
}
|
|
@@ -5740,10 +5750,10 @@ function parseAutoScope(el) {
|
|
|
5740
5750
|
if (forbidden.some(f => expr.includes(f))) {
|
|
5741
5751
|
DEBUG() && console.log("[GyosJS] Scope mount error: Forbidden expression:", expr);
|
|
5742
5752
|
}
|
|
5743
|
-
const args = key.split(':').slice(1)
|
|
5753
|
+
const args = key.split(':').slice(1);
|
|
5744
5754
|
const propName = key.split(':')[0];
|
|
5745
5755
|
try {
|
|
5746
|
-
definition[propName] =
|
|
5756
|
+
definition[propName] = expressionRuntime().createMethod(args, expr);
|
|
5747
5757
|
removeAttrs.push(attr.name);
|
|
5748
5758
|
}
|
|
5749
5759
|
catch (_) {
|
|
@@ -6723,7 +6733,7 @@ function createTargetSpinner() {
|
|
|
6723
6733
|
</div>
|
|
6724
6734
|
`;
|
|
6725
6735
|
// Inject styles if not already present
|
|
6726
|
-
if (!document.getElementById('gyos-target-spinner-styles')) {
|
|
6736
|
+
if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
|
|
6727
6737
|
const style = document.createElement('style');
|
|
6728
6738
|
style.id = 'gyos-target-spinner-styles';
|
|
6729
6739
|
style.textContent = `
|
|
@@ -6777,6 +6787,16 @@ function hideTargetSpinner(spinner) {
|
|
|
6777
6787
|
}
|
|
6778
6788
|
}
|
|
6779
6789
|
|
|
6790
|
+
let nonceSource;
|
|
6791
|
+
/** Configure the nonce used when Gyos recreates scripts during MPA navigation. */
|
|
6792
|
+
function setCspNonce(source) {
|
|
6793
|
+
nonceSource = source;
|
|
6794
|
+
}
|
|
6795
|
+
function resolveCspNonce() {
|
|
6796
|
+
const value = typeof nonceSource === 'function' ? nonceSource() : nonceSource;
|
|
6797
|
+
return value || undefined;
|
|
6798
|
+
}
|
|
6799
|
+
|
|
6780
6800
|
// Cache executed scripts to prevent duplicate execution
|
|
6781
6801
|
const executedScripts = new Set();
|
|
6782
6802
|
/**
|
|
@@ -6877,6 +6897,12 @@ async function executeScript(old, signal) {
|
|
|
6877
6897
|
old.remove();
|
|
6878
6898
|
return;
|
|
6879
6899
|
}
|
|
6900
|
+
const activeNonce = resolveCspNonce();
|
|
6901
|
+
if (expressionRuntimeMode() === 'csp' && !old.src && !activeNonce) {
|
|
6902
|
+
console.warn('[GyosJS CSP] Skipped an inline MPA script because no active document nonce is configured.');
|
|
6903
|
+
old.textContent = '';
|
|
6904
|
+
return;
|
|
6905
|
+
}
|
|
6880
6906
|
const executionKey = getScriptExecutionKey(old);
|
|
6881
6907
|
// Check if script should execute
|
|
6882
6908
|
if (!shouldExecuteScript(old)) {
|
|
@@ -6886,6 +6912,10 @@ async function executeScript(old, signal) {
|
|
|
6886
6912
|
}
|
|
6887
6913
|
const newScript = document.createElement('script');
|
|
6888
6914
|
Array.from(old.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value));
|
|
6915
|
+
if (expressionRuntimeMode() === 'csp')
|
|
6916
|
+
newScript.removeAttribute('nonce');
|
|
6917
|
+
if (activeNonce)
|
|
6918
|
+
newScript.setAttribute('nonce', activeNonce);
|
|
6889
6919
|
newScript.textContent = old.hasAttribute('g-script-wrap')
|
|
6890
6920
|
? wrapScriptExecution(old.textContent)
|
|
6891
6921
|
: old.textContent;
|
|
@@ -7438,8 +7468,8 @@ function startRouter(options) {
|
|
|
7438
7468
|
if (progressBarEnabled) {
|
|
7439
7469
|
progressBar = new ProgressBar(progressBarEnabled);
|
|
7440
7470
|
}
|
|
7441
|
-
document.addEventListener('click',
|
|
7442
|
-
document.addEventListener('submit',
|
|
7471
|
+
document.addEventListener('click', onClick);
|
|
7472
|
+
document.addEventListener('submit', onSubmit);
|
|
7443
7473
|
document.addEventListener('mouseover', onMouseOverCapture, true);
|
|
7444
7474
|
window.addEventListener('popstate', onPopState);
|
|
7445
7475
|
if ('scrollRestoration' in history) {
|
|
@@ -8110,7 +8140,7 @@ function onClickRouter(element) {
|
|
|
8110
8140
|
return; // this case not link (tag a) or form so do nothing
|
|
8111
8141
|
}
|
|
8112
8142
|
}
|
|
8113
|
-
function
|
|
8143
|
+
function onClick(event) {
|
|
8114
8144
|
if (event.defaultPrevented)
|
|
8115
8145
|
return;
|
|
8116
8146
|
if (event.button !== 0)
|
|
@@ -8167,7 +8197,9 @@ function onMouseOverCapture(event) {
|
|
|
8167
8197
|
return;
|
|
8168
8198
|
preload(url.toString());
|
|
8169
8199
|
}
|
|
8170
|
-
function
|
|
8200
|
+
function onSubmit(event) {
|
|
8201
|
+
if (event.defaultPrevented)
|
|
8202
|
+
return;
|
|
8171
8203
|
const form = event.target;
|
|
8172
8204
|
if (!form || form.tagName.toLowerCase() !== 'form')
|
|
8173
8205
|
return;
|
|
@@ -8230,7 +8262,7 @@ function onPopState(event) {
|
|
|
8230
8262
|
});
|
|
8231
8263
|
}
|
|
8232
8264
|
|
|
8233
|
-
//
|
|
8265
|
+
// Shared public surface used by the standard and CSP entries.
|
|
8234
8266
|
// Default export remains for convenience (no side effects here)
|
|
8235
8267
|
const Gyos = {
|
|
8236
8268
|
scope,
|
|
@@ -8293,8 +8325,11 @@ const Gyos = {
|
|
|
8293
8325
|
onAfterNavigate,
|
|
8294
8326
|
portalCreate,
|
|
8295
8327
|
portalDestroy,
|
|
8296
|
-
|
|
8328
|
+
setCspNonce,
|
|
8329
|
+
version: '0.3.0'
|
|
8297
8330
|
};
|
|
8298
8331
|
|
|
8299
|
-
|
|
8332
|
+
setExpressionRuntime(standardExpressionRuntime);
|
|
8333
|
+
|
|
8334
|
+
export { applyDirective, applyTransitionStyles, batch, disposeEffects as cleanup, clearAllEvents, computed, debounce, Gyos as default, directive, effect, emit, getEventListeners, getGlobalContainer, getStoreNames, getTransitionConfig, getValidator, getValidatorNames, hasStore, inject, isComputed, isSignal, markRaw, mount, mountAll, mountTree, getAllMountedScopes as mountedScopes, nextTick, off, on, onAfterNavigate, onBeforeNavigate, once, pipe, portalCreate, portalDestroy, provide, ready, registerTransition, removeStore, scope, setCspNonce, shallow, signal, startRouter, store, throttle, unref, untrack, useAsync, useCounter, useDebounce, useFetch, useInterval, useLocalStorage, useMediaQuery, useMouse, useThrottle, useTimeout, useToggle, useWindowSize, validate, validator };
|
|
8300
8335
|
//# sourceMappingURL=gyos.esm.js.map
|