@tsparticles/template-confetti 4.1.3
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/LICENSE +21 -0
- package/package.json +14 -0
- package/scripts/prebuild.js +64 -0
- package/template/vanilla/README.md +10 -0
- package/template/vanilla/gitignore +14 -0
- package/template/vanilla/index.html +22 -0
- package/template/vanilla/package.json +11 -0
- package/template/vanilla/src/main.ts +54 -0
- package/template/vanilla/src/style.css +54 -0
- package/template/vanilla/tsconfig.json +19 -0
- package/template/vanilla/vite.config.ts +5 -0
- package/template.json +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Matteo Bruni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/template-confetti",
|
|
3
|
+
"version": "4.1.3",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "node scripts/prebuild.js",
|
|
10
|
+
"build": "pnpm run prebuild",
|
|
11
|
+
"build:ci": "pnpm run prebuild"
|
|
12
|
+
},
|
|
13
|
+
"gitHead": "0551736c55ae8eec3855a693af8a99b1b4420350"
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const fs = require("fs-extra");
|
|
2
|
+
|
|
3
|
+
const libPackage = "./template.json";
|
|
4
|
+
|
|
5
|
+
const workspaceVersions = {
|
|
6
|
+
"@tsparticles/engine": require("../../../engine/package.json").version,
|
|
7
|
+
"@tsparticles/confetti": require("../../../bundles/confetti/package.json").version,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function resolveWorkspaceDependency(name) {
|
|
11
|
+
const libObj = JSON.parse(fs.readFileSync(libPackage, "utf-8"));
|
|
12
|
+
|
|
13
|
+
const allDeps = {
|
|
14
|
+
...libObj.package.dependencies,
|
|
15
|
+
...libObj.package.devDependencies,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const spec = allDeps[name];
|
|
19
|
+
|
|
20
|
+
if (!spec?.startsWith("workspace:")) {
|
|
21
|
+
return spec;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const workspaceRange = spec.replace("workspace:", "");
|
|
25
|
+
|
|
26
|
+
if (workspaceRange.length > 0 && workspaceRange !== "*" && workspaceRange !== "^" && workspaceRange !== "~") {
|
|
27
|
+
return workspaceRange;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const version = workspaceVersions[name];
|
|
31
|
+
|
|
32
|
+
if (!version) {
|
|
33
|
+
throw new Error(`Cannot resolve workspace dependency version for ${name}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return workspaceRange === "^" || workspaceRange === "~" ? `${workspaceRange}${version}` : `^${version}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fs.readFile(libPackage, function (error, data) {
|
|
40
|
+
if (error) {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const text = data.toString();
|
|
45
|
+
const libObj = JSON.parse(text);
|
|
46
|
+
|
|
47
|
+
for (const dep of Object.keys(libObj.package.dependencies)) {
|
|
48
|
+
const resolved = resolveWorkspaceDependency(dep);
|
|
49
|
+
if (resolved) {
|
|
50
|
+
libObj.package.dependencies[dep] = resolved;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const dep of Object.keys(libObj.package.devDependencies)) {
|
|
55
|
+
const resolved = resolveWorkspaceDependency(dep);
|
|
56
|
+
if (resolved) {
|
|
57
|
+
libObj.package.devDependencies[dep] = resolved;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fs.writeFile(libPackage, JSON.stringify(libObj, undefined, 2), "utf-8", function () {
|
|
62
|
+
console.log("template.json dependencies updated successfully");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{{projectName}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app">
|
|
10
|
+
<h1>Confetti!</h1>
|
|
11
|
+
<div class="controls">
|
|
12
|
+
<button id="fireBtn">Fire Confetti</button>
|
|
13
|
+
<select id="modeSelect">
|
|
14
|
+
<option value="cannon">Cannon</option>
|
|
15
|
+
<option value="waterfall">Waterfall</option>
|
|
16
|
+
<option value="random">Random</option>
|
|
17
|
+
</select>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<script type="module" src="/src/main.ts"></script>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "./style.css";
|
|
2
|
+
import { confetti } from "@tsparticles/confetti";
|
|
3
|
+
|
|
4
|
+
function randomInRange(min: number, max: number): number {
|
|
5
|
+
return Math.random() * (max - min) + min;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const fireBtn = document.getElementById("fireBtn") as HTMLButtonElement;
|
|
9
|
+
const modeSelect = document.getElementById("modeSelect") as HTMLSelectElement;
|
|
10
|
+
|
|
11
|
+
fireBtn.addEventListener("click", () => {
|
|
12
|
+
const mode = modeSelect.value;
|
|
13
|
+
|
|
14
|
+
switch (mode) {
|
|
15
|
+
case "cannon":
|
|
16
|
+
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
17
|
+
break;
|
|
18
|
+
|
|
19
|
+
case "waterfall":
|
|
20
|
+
{
|
|
21
|
+
const duration = 3000;
|
|
22
|
+
const end = Date.now() + duration;
|
|
23
|
+
|
|
24
|
+
const interval = setInterval(() => {
|
|
25
|
+
if (Date.now() > end) {
|
|
26
|
+
clearInterval(interval);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
confetti({
|
|
30
|
+
particleCount: 10,
|
|
31
|
+
angle: 60,
|
|
32
|
+
spread: 55,
|
|
33
|
+
origin: { x: 0, y: 0.6 },
|
|
34
|
+
});
|
|
35
|
+
confetti({
|
|
36
|
+
particleCount: 10,
|
|
37
|
+
angle: 120,
|
|
38
|
+
spread: 55,
|
|
39
|
+
origin: { x: 1, y: 0.6 },
|
|
40
|
+
});
|
|
41
|
+
}, 100);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case "random":
|
|
46
|
+
confetti({
|
|
47
|
+
angle: randomInRange(55, 125),
|
|
48
|
+
spread: randomInRange(50, 70),
|
|
49
|
+
particleCount: randomInRange(50, 100),
|
|
50
|
+
origin: { y: 0.6 },
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
background: #1a1a2e;
|
|
5
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
#app {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 50%;
|
|
11
|
+
left: 50%;
|
|
12
|
+
transform: translate(-50%, -50%);
|
|
13
|
+
z-index: 10;
|
|
14
|
+
text-align: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
h1 {
|
|
18
|
+
font-size: 3.2em;
|
|
19
|
+
color: #fff;
|
|
20
|
+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.controls {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 1rem;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-top: 2rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button {
|
|
32
|
+
padding: 0.8em 2em;
|
|
33
|
+
font-size: 1.1em;
|
|
34
|
+
border: none;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
background: #e94560;
|
|
37
|
+
color: #fff;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: background 0.2s;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
button:hover {
|
|
43
|
+
background: #ff6b81;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
select {
|
|
47
|
+
padding: 0.8em 1em;
|
|
48
|
+
font-size: 1em;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
border: 1px solid #444;
|
|
51
|
+
background: #16213e;
|
|
52
|
+
color: #fff;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noUnusedParameters": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"]
|
|
19
|
+
}
|