Skip to content

Commit b500e35

Browse files
authored
Merge pull request tsparticles#5793 from tsparticles/v4
V4
2 parents e6a34b2 + d2d8a90 commit b500e35

18 files changed

Lines changed: 510 additions & 491 deletions

File tree

cli/utils/browserslist-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"browserslist": "^4.28.2",
24-
"cpx2": "^8.0.2"
24+
"cpx2": "^9.0.0"
2525
},
2626
"peerDependencies": {
2727
"browserslist": "^4"

cli/utils/depcruise-config/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@
4545
"@stylistic/eslint-plugin": "^5.10.0",
4646
"@tsparticles/eslint-config": "workspace:^",
4747
"@tsparticles/prettier-config": "workspace:^",
48-
"@types/node": "^25.8.0",
48+
"@types/node": "^25.9.1",
4949
"dependency-cruiser": "^17.4.0",
5050
"eslint": "^10.4.0",
5151
"eslint-config-prettier": "^10.1.8",
52-
"eslint-plugin-jsdoc": "^62.9.0",
52+
"eslint-plugin-jsdoc": "^63.0.0",
5353
"eslint-plugin-tsdoc": "^0.5.2",
5454
"prettier": "^3.8.3",
5555
"prettier-plugin-multiline-arrays": "^4.1.8",
5656
"tsup": "^8.5.1",
5757
"typescript": "^6.0.3",
58-
"typescript-eslint": "^8.59.3"
58+
"typescript-eslint": "^8.59.4"
5959
}
6060
}

cli/utils/eslint-config/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
"@stylistic/eslint-plugin": "^5.10.0",
4141
"@tsparticles/prettier-config": "workspace:^",
4242
"eslint-config-prettier": "^10.1.8",
43-
"eslint-plugin-jsdoc": "^62.9.0",
43+
"eslint-plugin-jsdoc": "^63.0.0",
4444
"eslint-plugin-prettier": "^5.5.5",
4545
"eslint-plugin-tsdoc": "^0.5.2",
4646
"jiti": "^2.7.0",
4747
"prettier": "^3.8.3",
4848
"prettier-plugin-multiline-arrays": "^4.1.8",
4949
"typescript": "^6.0.3",
50-
"typescript-eslint": "^8.59.3"
50+
"typescript-eslint": "^8.59.4"
5151
},
5252
"devDependencies": {
53-
"@types/node": "^25.8.0",
53+
"@types/node": "^25.9.1",
5454
"eslint": "^10.4.0"
5555
}
5656
}

cli/utils/prettier-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"prettier-plugin-multiline-arrays": "^4.1.8"
3131
},
3232
"devDependencies": {
33-
"cpx2": "^8.0.2",
33+
"cpx2": "^9.0.0",
3434
"prettier": "^3.8.3"
3535
}
3636
}

cli/utils/rollup-plugin/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@
5656
"@tsparticles/prettier-config": "workspace:^",
5757
"eslint": "^10.4.0",
5858
"eslint-config-prettier": "^10.1.8",
59-
"eslint-plugin-jsdoc": "^62.9.0",
59+
"eslint-plugin-jsdoc": "^63.0.0",
6060
"eslint-plugin-tsdoc": "^0.5.2",
6161
"prettier": "^3.8.3",
6262
"prettier-plugin-multiline-arrays": "^4.1.8",
6363
"rollup-plugin-visualizer": "^7.0.1"
6464
},
6565
"devDependencies": {
6666
"@rollup/plugin-typescript": "^12.3.0",
67-
"@types/node": "^25.8.0",
67+
"@types/node": "^25.9.1",
6868
"rimraf": "^6.1.3",
6969
"typescript": "^6.0.3",
70-
"typescript-eslint": "^8.59.3"
70+
"typescript-eslint": "^8.59.4"
7171
}
7272
}

cli/utils/webpack-config/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@
4848
"browserslist": "^4.28.2",
4949
"eslint": "^10.4.0",
5050
"eslint-config-prettier": "^10.1.8",
51-
"eslint-plugin-jsdoc": "^62.9.0",
51+
"eslint-plugin-jsdoc": "^63.0.0",
5252
"eslint-plugin-tsdoc": "^0.5.2",
5353
"prettier": "^3.8.3",
5454
"prettier-plugin-multiline-arrays": "^4.1.8",
5555
"swc-loader": "^0.2.7",
5656
"terser-webpack-plugin": "^5.6.0",
5757
"typescript": "^6.0.3",
58-
"typescript-eslint": "^8.59.3",
58+
"typescript-eslint": "^8.59.4",
5959
"webpack-bundle-analyzer": "^5.3.0",
6060
"webpack-cli": "^7.0.2"
6161
},
6262
"devDependencies": {
63-
"@types/node": "^25.8.0",
63+
"@types/node": "^25.9.1",
6464
"@types/webpack-bundle-analyzer": "^4.7.0",
6565
"@types/webpack-env": "^1.18.8",
6666
"rimraf": "^6.1.3",
67-
"webpack": "^5.106.2"
67+
"webpack": "^5.107.1"
6868
}
6969
}

demo/stencil/src/components/app-root/app-root.tsx renamed to demo/stencil/src/components/app-root/AppRoot.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Component, h, State } from "@stencil/core";
1+
import { Component, type JSX, State, h } from "@stencil/core";
22
import type { ISourceOptions } from "@tsparticles/engine";
3-
import type { JSX } from "@stencil/core";
43
import { defineCustomElements } from "@tsparticles/stencil/loader";
54
import { loadSlim } from "@tsparticles/slim";
65

demo/stencil/www/index.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>tsParticles Stencil Demo</title> <link rel="modulepreload" href="/build/p-Dty2eZEw.js"><link rel="modulepreload" href="/build/p-U3e3s9OI.js"><script type="module" data-stencil data-resources-url="/build/" data-stencil-namespace="tsparticlesstencildemo">import{p as n,b as o}from"/build/p-U3e3s9OI.js";export{s as setNonce}from"/build/p-U3e3s9OI.js";import{g as r}from"/build/p-DQuL1Twl.js";(()=>{const o=import.meta.url,r={};return""!==o&&(r.resourcesUrl=new URL(".",o).href),n(r)})().then((async n=>(await r(),o([["p-125b30fc",[[0,"app-root",{engineReady:[32],initError:[32]}],[0,"stencil-particles",{containerId:[1,"container-id"],options:[16],url:[1],init:[16]},null,{containerId:[{onPropsChange:0}],options:[{onPropsChange:0}],url:[{onPropsChange:0}],init:[{onPropsChange:0}]}]]]],n))));
2-
</script> <script nomodule="" src="/build/tsparticlesstencildemo.js" data-stencil></script> </head> <body> <app-root></app-root> </body></html>
1+
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>tsParticles Stencil Demo</title> <script type="module" src="/build/tsparticlesstencildemo.esm.js" data-stencil></script> <script nomodule="" src="/build/tsparticlesstencildemo.js" data-stencil></script> </head> <body> <app-root></app-root> <script>
2+
if ('serviceWorker' in navigator && location.protocol !== 'file:') {
3+
// auto-unregister service worker during dev mode
4+
navigator.serviceWorker.getRegistration().then(function(registration) {
5+
if (registration) {
6+
registration.unregister().then(function() { location.reload() });
7+
}
8+
});
9+
}
10+
</script></body></html>

plugins/colors/oklab/src/OklabColorManager.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
type IValueColor,
1111
getRangeValue,
1212
identity,
13+
none,
1314
parseAlpha,
1415
percentDenominator,
1516
} from "@tsparticles/engine";
@@ -64,7 +65,7 @@ export class OklabColorManager implements IColorManager {
6465

6566
/**
6667
* Parses an OKLAB color string to RGBA
67-
* @param input
68+
* @param input -
6869
*/
6970
parseString(input: string): IRgba | undefined {
7071
if (!this.accepts(input)) {
@@ -81,13 +82,30 @@ export class OklabColorManager implements IColorManager {
8182
},
8283
defaultAlpha = 1;
8384

84-
return result
85-
? oklabaToRgba({
86-
a: result[indexes.a] ? parseAlpha(result[indexes.a]) : defaultAlpha,
87-
l: parseFloat(result[indexes.l] ?? "0") * (result[indexes.lPercent] ? identity : percentDenominator),
88-
aAxis: parseFloat(result[indexes.aAxis] ?? "0"),
89-
bAxis: parseFloat(result[indexes.bAxis] ?? "0"),
90-
})
91-
: undefined;
85+
if (!result) {
86+
return undefined;
87+
}
88+
89+
const rawL = parseFloat(result[indexes.l] ?? "0");
90+
91+
// Validate lightness range BEFORE scaling
92+
if (result[indexes.lPercent]) {
93+
// Percentage format: must be 0..100
94+
if (rawL < none || rawL > percentDenominator) {
95+
return undefined;
96+
}
97+
} else {
98+
// Unitless format: must be 0..1
99+
if (rawL < none || rawL > identity) {
100+
return undefined;
101+
}
102+
}
103+
104+
return oklabaToRgba({
105+
a: result[indexes.a] ? parseAlpha(result[indexes.a]) : defaultAlpha,
106+
l: rawL * (result[indexes.lPercent] ? identity : percentDenominator),
107+
aAxis: parseFloat(result[indexes.aAxis] ?? "0"),
108+
bAxis: parseFloat(result[indexes.bAxis] ?? "0"),
109+
});
92110
}
93111
}

plugins/colors/oklch/src/OklchColorManager.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
type IValueColor,
1111
getRangeValue,
1212
identity,
13+
none,
1314
parseAlpha,
1415
percentDenominator,
1516
} from "@tsparticles/engine";
@@ -64,7 +65,7 @@ export class OklchColorManager implements IColorManager {
6465

6566
/**
6667
* Parses an OKLCH color string to RGBA
67-
* @param input
68+
* @param input -
6869
*/
6970
parseString(input: string): IRgba | undefined {
7071
if (!this.accepts(input)) {
@@ -81,13 +82,30 @@ export class OklchColorManager implements IColorManager {
8182
},
8283
defaultAlpha = 1;
8384

84-
return result
85-
? oklchaToRgba({
86-
a: result[indexes.a] ? parseAlpha(result[indexes.a]) : defaultAlpha,
87-
c: parseFloat(result[indexes.c] ?? "0"),
88-
h: parseFloat(result[indexes.h] ?? "0"),
89-
l: parseFloat(result[indexes.l] ?? "0") * (result[indexes.lPercent] ? identity : percentDenominator),
90-
})
91-
: undefined; // OKLCH parsing without alpha
85+
if (!result) {
86+
return undefined;
87+
}
88+
89+
const rawL = parseFloat(result[indexes.l] ?? "0");
90+
91+
// Validate lightness range BEFORE scaling
92+
if (result[indexes.lPercent]) {
93+
// Percentage format: must be 0..100
94+
if (rawL < none || rawL > percentDenominator) {
95+
return undefined;
96+
}
97+
} else {
98+
// Unitless format: must be 0..1
99+
if (rawL < none || rawL > identity) {
100+
return undefined;
101+
}
102+
}
103+
104+
return oklchaToRgba({
105+
a: result[indexes.a] ? parseAlpha(result[indexes.a]) : defaultAlpha,
106+
c: parseFloat(result[indexes.c] ?? "0"),
107+
h: parseFloat(result[indexes.h] ?? "0"),
108+
l: rawL * (result[indexes.lPercent] ? identity : percentDenominator),
109+
});
92110
}
93111
}

0 commit comments

Comments
 (0)