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.
- package/README.md +10 -6
- 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/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/gyos.auto.esm.js +79 -46
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +79 -46
- 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 +81 -47
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +81 -46
- 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 +29 -12
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;
|
|
@@ -3679,24 +3710,7 @@ function executeHandler(handler, scope, e, modifiers) {
|
|
|
3679
3710
|
if (modifiers.includes('stop'))
|
|
3680
3711
|
e.stopPropagation();
|
|
3681
3712
|
try {
|
|
3682
|
-
|
|
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
|
-
}
|
|
3713
|
+
expressionRuntime().execute(handler, scope, e);
|
|
3700
3714
|
}
|
|
3701
3715
|
catch (err) {
|
|
3702
3716
|
console.error('[GyosJS] Error in event handler:', err);
|
|
@@ -5672,10 +5686,7 @@ function parseInlineScope(scopeStr) {
|
|
|
5672
5686
|
if (!trimmed.startsWith('{')) {
|
|
5673
5687
|
return undefined; // Not an inline definition
|
|
5674
5688
|
}
|
|
5675
|
-
|
|
5676
|
-
// This allows methods and complex expressions
|
|
5677
|
-
const fn = new Function(`return (${trimmed})`);
|
|
5678
|
-
const definition = fn();
|
|
5689
|
+
const definition = expressionRuntime().parseScope(trimmed);
|
|
5679
5690
|
DEBUG() && console.log('[GyosJS] Parsed inline scope:', definition);
|
|
5680
5691
|
return definition;
|
|
5681
5692
|
}
|
|
@@ -5739,10 +5750,10 @@ function parseAutoScope(el) {
|
|
|
5739
5750
|
if (forbidden.some(f => expr.includes(f))) {
|
|
5740
5751
|
DEBUG() && console.log("[GyosJS] Scope mount error: Forbidden expression:", expr);
|
|
5741
5752
|
}
|
|
5742
|
-
const args = key.split(':').slice(1)
|
|
5753
|
+
const args = key.split(':').slice(1);
|
|
5743
5754
|
const propName = key.split(':')[0];
|
|
5744
5755
|
try {
|
|
5745
|
-
definition[propName] =
|
|
5756
|
+
definition[propName] = expressionRuntime().createMethod(args, expr);
|
|
5746
5757
|
removeAttrs.push(attr.name);
|
|
5747
5758
|
}
|
|
5748
5759
|
catch (_) {
|
|
@@ -6722,7 +6733,7 @@ function createTargetSpinner() {
|
|
|
6722
6733
|
</div>
|
|
6723
6734
|
`;
|
|
6724
6735
|
// Inject styles if not already present
|
|
6725
|
-
if (!document.getElementById('gyos-target-spinner-styles')) {
|
|
6736
|
+
if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
|
|
6726
6737
|
const style = document.createElement('style');
|
|
6727
6738
|
style.id = 'gyos-target-spinner-styles';
|
|
6728
6739
|
style.textContent = `
|
|
@@ -6776,6 +6787,16 @@ function hideTargetSpinner(spinner) {
|
|
|
6776
6787
|
}
|
|
6777
6788
|
}
|
|
6778
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
|
+
|
|
6779
6800
|
// Cache executed scripts to prevent duplicate execution
|
|
6780
6801
|
const executedScripts = new Set();
|
|
6781
6802
|
/**
|
|
@@ -6876,6 +6897,12 @@ async function executeScript(old, signal) {
|
|
|
6876
6897
|
old.remove();
|
|
6877
6898
|
return;
|
|
6878
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
|
+
}
|
|
6879
6906
|
const executionKey = getScriptExecutionKey(old);
|
|
6880
6907
|
// Check if script should execute
|
|
6881
6908
|
if (!shouldExecuteScript(old)) {
|
|
@@ -6885,6 +6912,10 @@ async function executeScript(old, signal) {
|
|
|
6885
6912
|
}
|
|
6886
6913
|
const newScript = document.createElement('script');
|
|
6887
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);
|
|
6888
6919
|
newScript.textContent = old.hasAttribute('g-script-wrap')
|
|
6889
6920
|
? wrapScriptExecution(old.textContent)
|
|
6890
6921
|
: old.textContent;
|
|
@@ -8231,7 +8262,7 @@ function onPopState(event) {
|
|
|
8231
8262
|
});
|
|
8232
8263
|
}
|
|
8233
8264
|
|
|
8234
|
-
//
|
|
8265
|
+
// Shared public surface used by the standard and CSP entries.
|
|
8235
8266
|
// Default export remains for convenience (no side effects here)
|
|
8236
8267
|
const Gyos = {
|
|
8237
8268
|
scope,
|
|
@@ -8294,8 +8325,11 @@ const Gyos = {
|
|
|
8294
8325
|
onAfterNavigate,
|
|
8295
8326
|
portalCreate,
|
|
8296
8327
|
portalDestroy,
|
|
8297
|
-
|
|
8328
|
+
setCspNonce,
|
|
8329
|
+
version: '0.3.0'
|
|
8298
8330
|
};
|
|
8299
8331
|
|
|
8300
|
-
|
|
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 };
|
|
8301
8335
|
//# sourceMappingURL=gyos.esm.js.map
|