Skip to content

Commit 6cafe8b

Browse files
authored
Merge pull request #42 from tsparticles/dev
3.0.0
2 parents c4f8473 + 69065b6 commit 6cafe8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1558
-15562
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [3.0.0](https://github.com/tsparticles/svelte/compare/v2.12.0...v3.0.0) (2023-12-24)
7+
8+
9+
### Features
10+
11+
* migrated to v3, used new init structure ([bee139b](https://github.com/tsparticles/svelte/commit/bee139bd3466725681212a5d662060cd2f1b3dc2))
12+
* updated to v3, needs new initialization function to replace particlesInit ([404d847](https://github.com/tsparticles/svelte/commit/404d847673d7d6d830b8ecf9433e4bd468a475fd))
13+
14+
15+
16+
17+
618
# [2.12.0](https://github.com/tsparticles/svelte/compare/v2.11.0...v2.12.0) (2023-08-04)
719

820
**Note:** Version bump only for package svelte-particles-workspace

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)
22

3-
# svelte-particles
3+
# @tsparticles/svelte
44

5-
[![npm](https://img.shields.io/npm/v/svelte-particles)](https://www.npmjs.com/package/svelte-particles) [![npm downloads](https://img.shields.io/npm/dm/svelte-particles)](https://www.npmjs.com/package/svelte-particles) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5+
[![npm](https://img.shields.io/npm/v/@tsparticles/svelte)](https://www.npmjs.com/package/@tsparticles/svelte) [![npm downloads](https://img.shields.io/npm/dm/@tsparticles/svelte)](https://www.npmjs.com/package/@tsparticles/svelte) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
66

77
Official [tsParticles](https://github.com/matteobruni/tsparticles) SvelteJS component
88

@@ -13,22 +13,22 @@ Official [tsParticles](https://github.com/matteobruni/tsparticles) SvelteJS comp
1313
## Installation
1414

1515
```shell
16-
npm install svelte-particles
16+
npm install @tsparticles/svelte
1717
```
1818

1919
or
2020

2121
```shell
22-
yarn add svelte-particles
22+
yarn add @tsparticles/svelte
2323
```
2424

2525
## Usage
2626

2727
```html
2828
<script>
29-
import Particles from "svelte-particles";
29+
import Particles from "@tsparticles/svelte";
3030
//import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
31-
import { loadSlim } from "tsparticles-slim"; // if you are going to use `loadSlim`, install the "tsparticles-slim" package too.
31+
import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
3232
3333
let particlesUrl = "http://foo.bar/particles.json"; // placeholder, replace it with a real url
3434
@@ -98,12 +98,12 @@ You can see a sample below:
9898
<script>
9999
import { onMount } from "svelte";
100100
//import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
101-
import { loadSlim } from "tsparticles-slim"; // if you are going to use `loadSlim`, install the "tsparticles-slim" package too.
101+
import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
102102
103103
let ParticlesComponent;
104104
105105
onMount(async () => {
106-
const module = await import("svelte-particles");
106+
const module = await import("@tsparticles/svelte");
107107
108108
ParticlesComponent = module.default;
109109
});
@@ -191,7 +191,7 @@ import { defineConfig } from "vite";
191191
export default defineConfig({
192192
plugins: [sveltekit()],
193193
ssr: {
194-
noExternal: ["tsparticles", "tsparticles-slim", "tsparticles-engine", "svelte-particles"], // add all tsparticles libraries here, they're not made for SSR, they're client only
194+
noExternal: ["tsparticles", "@tsparticles/slim", "@tsparticles/engine", "@tsparticles/svelte"], // add all tsparticles libraries here, they're not made for SSR, they're client only
195195
},
196196
});
197197
```

apps/svelte-kit/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [3.0.0](https://github.com/tsparticles/svelte/compare/v2.12.0...v3.0.0) (2023-12-24)
7+
8+
9+
### Features
10+
11+
* migrated to v3, used new init structure ([bee139b](https://github.com/tsparticles/svelte/commit/bee139bd3466725681212a5d662060cd2f1b3dc2))
12+
* updated to v3, needs new initialization function to replace particlesInit ([404d847](https://github.com/tsparticles/svelte/commit/404d847673d7d6d830b8ecf9433e4bd468a475fd))
13+
14+
15+
16+
17+
618
# [2.12.0](https://github.com/tsparticles/svelte/compare/v2.11.0...v2.12.0) (2023-08-04)
719

820
**Note:** Version bump only for package svelte-kit-demo

apps/svelte-kit/package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-kit-demo",
3-
"version": "2.12.0",
3+
"version": "3.0.0",
44
"private": true,
55
"scripts": {
66
"dev": "vite dev",
@@ -12,27 +12,27 @@
1212
"format": "prettier --plugin=\"prettier-plugin-svelte\" --write ."
1313
},
1414
"devDependencies": {
15-
"@fontsource/fira-mono": "^5.0.7",
16-
"@neoconfetti/svelte": "^1.0.0",
17-
"@sveltejs/adapter-auto": "^2.1.0",
18-
"@sveltejs/kit": "^1.22.4",
19-
"@types/cookie": "^0.5.1",
20-
"@typescript-eslint/eslint-plugin": "^6.2.1",
21-
"@typescript-eslint/parser": "^6.2.1",
22-
"eslint": "^8.46.0",
23-
"eslint-config-prettier": "^9.0.0",
24-
"eslint-plugin-svelte": "^2.32.4",
25-
"prettier": "^3.0.1",
26-
"prettier-plugin-svelte": "^3.0.3",
27-
"svelte": "^4.1.2",
28-
"svelte-check": "^3.4.6",
29-
"svelte-particles": "^2.12.0",
30-
"svelte-preprocess": "^5.0.4",
31-
"tslib": "^2.6.1",
32-
"tsparticles": "^2.12.0",
33-
"tsparticles-engine": "^2.12.0",
34-
"typescript": "^5.1.6",
35-
"vite": "^4.4.8"
15+
"@fontsource/fira-mono": "^5.0.8",
16+
"@sveltejs/adapter-auto": "^3.0.1",
17+
"@sveltejs/kit": "^2.0.6",
18+
"@sveltejs/vite-plugin-svelte": "^3.0.1",
19+
"@tsparticles/engine": "^3.0.2",
20+
"@tsparticles/svelte": "workspace:^",
21+
"@types/cookie": "^0.6.0",
22+
"@typescript-eslint/eslint-plugin": "^6.15.0",
23+
"@typescript-eslint/parser": "^6.15.0",
24+
"eslint": "^8.56.0",
25+
"eslint-config-prettier": "^9.1.0",
26+
"eslint-plugin-svelte": "^2.35.1",
27+
"prettier": "^3.1.1",
28+
"prettier-plugin-svelte": "^3.1.2",
29+
"svelte": "^4.2.8",
30+
"svelte-check": "^3.6.2",
31+
"svelte-preprocess": "^5.1.3",
32+
"tslib": "^2.6.2",
33+
"tsparticles": "^3.0.2",
34+
"typescript": "^5.3.3",
35+
"vite": "^5.0.10"
3636
},
3737
"type": "module"
3838
}
Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,99 @@
1-
<script>
2-
import Counter from './Counter.svelte';
3-
import welcome from '$lib/images/svelte-welcome.webp';
4-
import welcome_fallback from '$lib/images/svelte-welcome.png';
5-
import Particles from "svelte-particles";
6-
import { loadFull } from "tsparticles";
1+
<script lang="ts">
2+
import Counter from './Counter.svelte';
3+
import welcome from '$lib/images/svelte-welcome.webp';
4+
import welcome_fallback from '$lib/images/svelte-welcome.png';
5+
import { particlesInit } from "@tsparticles/svelte";
6+
import { loadFull } from "tsparticles";
7+
import { type Engine } from "@tsparticles/engine";
8+
import { browser } from '$app/environment';
79
8-
let particlesConfig = {
9-
particles: {
10-
color: {
11-
value: "#000",
12-
},
13-
links: {
14-
enable: true,
15-
color: "#000",
16-
},
17-
number: {
18-
value: 80
19-
},
20-
move: {
21-
enable: true,
22-
},
23-
},
24-
};
10+
let particlesConfig = {
11+
particles: {
12+
color: {
13+
value: "#000",
14+
},
15+
links: {
16+
enable: true,
17+
color: "#000",
18+
},
19+
number: {
20+
value: 80
21+
},
22+
move: {
23+
enable: true,
24+
},
25+
},
26+
};
2527
26-
let particlesInit = async engine => {
27-
// you can use main to customize the tsParticles instance adding presets or custom shapes
28-
// this loads the tsparticles package bundle, it's the easiest method for getting everything ready
29-
// starting from v2 you can add only the features you need reducing the bundle size
30-
await loadFull(engine);
31-
};
28+
void particlesInit(async (engine: Engine) => {
29+
await loadFull(engine);
30+
});
31+
32+
const ParticlesConstructor = browser ?
33+
import('@tsparticles/svelte').then((module) => module.default) :
34+
new Promise(() => {
35+
});
3236
</script>
3337

3438
<svelte:head>
35-
<title>Home</title>
36-
<meta name="description" content="Svelte demo app" />
39+
<title>Home</title>
40+
<meta name="description" content="Svelte demo app"/>
3741
</svelte:head>
3842

3943
<section>
40-
<h1>
44+
<h1>
4145
<span class="welcome">
4246
<picture>
43-
<source srcset={welcome} type="image/webp" />
44-
<img src={welcome_fallback} alt="Welcome" />
47+
<source srcset={welcome} type="image/webp"/>
48+
<img src={welcome_fallback} alt="Welcome"/>
4549
</picture>
4650
</span>
4751

48-
to your new<br />SvelteKit app
49-
</h1>
52+
to your new<br/>SvelteKit app
53+
</h1>
5054

51-
<h2>
52-
try editing <strong>src/routes/+page.svelte</strong>
53-
</h2>
55+
<h2>
56+
try editing <strong>src/routes/+page.svelte</strong>
57+
</h2>
5458

55-
<Counter />
59+
<Counter/>
5660

57-
<Particles
58-
id="tsparticles"
59-
class="foo bar"
60-
style=""
61-
options="{particlesConfig}"
62-
particlesInit="{particlesInit}"
63-
/>
61+
{#await ParticlesConstructor}
62+
<p>Loading...</p>
63+
{:then component}
64+
<svelte:component this={component} id="tsparticles"
65+
options="{particlesConfig}"/>
66+
{:catch error}
67+
<p>Something went wrong: {error.message}</p>
68+
{/await}
6469
</section>
6570

6671
<style>
67-
section {
68-
display: flex;
69-
flex-direction: column;
70-
justify-content: center;
71-
align-items: center;
72-
flex: 0.6;
73-
}
72+
section {
73+
display: flex;
74+
flex-direction: column;
75+
justify-content: center;
76+
align-items: center;
77+
flex: 0.6;
78+
}
7479
75-
h1 {
76-
width: 100%;
77-
}
80+
h1 {
81+
width: 100%;
82+
}
7883
79-
.welcome {
80-
display: block;
81-
position: relative;
82-
width: 100%;
83-
height: 0;
84-
padding: 0 0 calc(100% * 495 / 2048) 0;
85-
}
84+
.welcome {
85+
display: block;
86+
position: relative;
87+
width: 100%;
88+
height: 0;
89+
padding: 0 0 calc(100% * 495 / 2048) 0;
90+
}
8691
87-
.welcome img {
88-
position: absolute;
89-
width: 100%;
90-
height: 100%;
91-
top: 0;
92-
display: block;
93-
}
92+
.welcome img {
93+
position: absolute;
94+
width: 100%;
95+
height: 100%;
96+
top: 0;
97+
display: block;
98+
}
9499
</style>

apps/svelte-kit/src/routes/Header.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
<li aria-current={$page.url.pathname === '/about' ? 'page' : undefined}>
2323
<a href="/about">About</a>
2424
</li>
25-
<li aria-current={$page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
26-
<a href="/sverdle">Sverdle</a>
27-
</li>
2825
</ul>
2926
<svg viewBox="0 0 2 3" aria-hidden="true">
3027
<path d="M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z" />

apps/svelte-kit/src/routes/about/+page.svelte

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,4 @@
1818
Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening
1919
the devtools network panel and reloading.
2020
</p>
21-
22-
<p>
23-
The <a href="/sverdle">Sverdle</a> page illustrates SvelteKit's data loading and form handling. Try
24-
using it with JavaScript disabled!
25-
</p>
2621
</div>

0 commit comments

Comments
 (0)