@novely/particles 0.11.0 → 0.12.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 CHANGED
@@ -1,31 +1,31 @@
1
- # @novely/particles
2
-
3
- Particles effect based on [ts-particles](https://particles.js.org/).
4
-
5
- ## Usage
6
-
7
- ```ts
8
- import { showParticles, hideParticles } from '@novely/particles';
9
-
10
- const snow = {
11
- // @see https://particles.js.org/
12
- ...
13
- };
14
-
15
- engine.script({
16
- start: [
17
- /**
18
- * Will show particles
19
- */
20
- engine.action.custom(showParticles(snow)),
21
- /**
22
- * Will hide particles
23
- */
24
- engine.action.custom(hideParticles()),
25
- ]
26
- });
27
- ```
28
-
29
- ## Additional Info
30
-
31
- CSS `zIndex` of layer with particles is `2`.
1
+ # @novely/particles
2
+
3
+ Particles effect based on [ts-particles](https://particles.js.org/).
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { showParticles, hideParticles } from '@novely/particles';
9
+
10
+ const snow = {
11
+ // @see https://particles.js.org/
12
+ ...
13
+ };
14
+
15
+ engine.script({
16
+ start: [
17
+ /**
18
+ * Will show particles
19
+ */
20
+ engine.action.custom(showParticles(snow)),
21
+ /**
22
+ * Will hide particles
23
+ */
24
+ engine.action.custom(hideParticles()),
25
+ ]
26
+ });
27
+ ```
28
+
29
+ ## Additional Info
30
+
31
+ CSS `zIndex` of layer with particles is `2`.
@@ -0,0 +1,9 @@
1
+ import { t as hideParticles } from "./particles-C_OsZg92.mjs";
2
+ import * as _tsparticles_engine0 from "@tsparticles/engine";
3
+ import * as _novely_core0 from "@novely/core";
4
+
5
+ //#region src/eager.d.ts
6
+ declare const showParticlesEager: (options: _tsparticles_engine0.RecursivePartial<_tsparticles_engine0.IOptions>) => _novely_core0.CustomHandler;
7
+ //#endregion
8
+ export { hideParticles, showParticlesEager as showParticles };
9
+ //# sourceMappingURL=eager.d.mts.map
package/dist/eager.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"./tsparticles-CISqpimk.mjs";import{n,t as r}from"./particles-DHiWDLbq.mjs";const i=n.bind({getParticles:()=>Promise.resolve({loadSlim:t,tsParticles:e})});export{r as hideParticles,i as showParticles};
2
+ //# sourceMappingURL=eager.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eager.mjs","names":[],"sources":["../src/eager.ts"],"sourcesContent":["import { hideParticles, showParticles } from './particles';\r\nimport { loadSlim, tsParticles } from './tsparticles';\r\n\r\nconst getParticles = () =>\r\n\tPromise.resolve({\r\n\t\tloadSlim,\r\n\t\ttsParticles,\r\n\t});\r\n\r\nconst showParticlesEager = showParticles.bind({\r\n\tgetParticles,\r\n});\r\n\r\nexport { showParticlesEager as showParticles, hideParticles };\r\n"],"mappings":"gGASA,MAAM,EAAqB,EAAc,KAAK,CAC7C,iBANA,QAAQ,QAAQ,CACf,WACA,cACA,CAAC,CAIF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { t as hideParticles } from "./particles-C_OsZg92.mjs";
2
+ import * as _tsparticles_engine0 from "@tsparticles/engine";
3
+ import * as _novely_core0 from "@novely/core";
4
+
5
+ //#region src/lazy.d.ts
6
+ declare const showParticlesLazy: (options: _tsparticles_engine0.RecursivePartial<_tsparticles_engine0.IOptions>) => _novely_core0.CustomHandler;
7
+ //#endregion
8
+ export { hideParticles, showParticlesLazy as showParticles };
9
+ //# sourceMappingURL=lazy.d.mts.map
package/dist/lazy.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"./particles-DHiWDLbq.mjs";const n=e.bind({getParticles:()=>import(`./tsparticles-CISqpimk.mjs`).then(e=>e.r)});export{t as hideParticles,n as showParticles};
2
+ //# sourceMappingURL=lazy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.mjs","names":[],"sources":["../src/lazy.ts"],"sourcesContent":["import { hideParticles, showParticles } from './particles';\r\n\r\nconst getParticles = () => import('./tsparticles');\r\n\r\nconst showParticlesLazy = showParticles.bind({\r\n\tgetParticles,\r\n});\r\n\r\nexport { showParticlesLazy as showParticles, hideParticles };\r\n"],"mappings":"+CAIA,MAAM,EAAoB,EAAc,KAAK,CAC5C,iBAH0B,OAAO,8BAAA,KAAA,GAAA,EAAA,EAAA,CAIjC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { CustomHandler } from "@novely/core";
2
+
3
+ //#region src/particles.d.ts
4
+ declare const hideParticles: () => CustomHandler;
5
+ //#endregion
6
+ export { hideParticles as t };
7
+ //# sourceMappingURL=particles-C_OsZg92.d.mts.map
@@ -0,0 +1,2 @@
1
+ let e=!1;const t=Symbol(),n=e=>(e.autoPlay||=!0,e.fullScreen||={enable:!0,zIndex:2},e),r=function(r){let i=async({clear:t,data:i,getDomNodes:a,paused:o,flags:{goingBack:s,preview:c}})=>{if(c)return;let{loadSlim:l,tsParticles:u}=await this.getParticles();e||=(await l(u),!0);let{element:d}=a(!0);t(()=>{let{instance:e,unsubscribe:t}=i();e&&(e.destroy(),t&&t(),i({}))});let f=i(),p=f.options===r,m=!!f.instance;p&&m||p&&s||(async()=>{let e=await u.load({element:d,options:n(r)});i({instance:e,options:r,unsubscribe:o.subscribe(t=>{if(e)try{t?e.pause():e.play()}catch{}})})})()};return i.callOnlyLatest=!0,i.id=t,i.key=`particles`,i},i=()=>{let e=({data:e,remove:t,flags:{preview:n}})=>{if(n)return;let{instance:r}=e();r&&r.destroy(),t()};return e.callOnlyLatest=!0,e.id=t,e.key=`particles`,e};export{r as n,i as t};
2
+ //# sourceMappingURL=particles-DHiWDLbq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"particles-DHiWDLbq.mjs","names":[],"sources":["../src/particles.ts"],"sourcesContent":["import type { CustomHandler } from '@novely/core';\r\nimport type { Container, IOptions, RecursivePartial } from '@tsparticles/engine';\r\n\r\nlet loaded = false;\r\n\r\nconst PARTICLES_ID = Symbol();\r\n\r\ntype ParticlesOptions = RecursivePartial<IOptions>;\r\n\r\ntype Data = {\r\n\tinstance?: Container;\r\n\tunsubscribe?: () => void;\r\n\toptions?: ParticlesOptions;\r\n};\r\n\r\ntype TSParticles = {\r\n\ttsParticles: typeof import('@tsparticles/engine').tsParticles;\r\n\tloadSlim: typeof import('@tsparticles/slim').loadSlim;\r\n};\r\n\r\ntype TSParticlesGetter = () => Promise<TSParticles>;\r\n\r\ntype ParticlesThis = {\r\n\tgetParticles: TSParticlesGetter;\r\n};\r\n\r\nconst withDefault = (options: ParticlesOptions) => {\r\n\toptions.autoPlay ||= true;\r\n\toptions.fullScreen ||= { enable: true, zIndex: 2 };\r\n\r\n\treturn options;\r\n};\r\n\r\nconst showParticles = function (this: ParticlesThis, options: ParticlesOptions): CustomHandler {\r\n\tconst handler: CustomHandler = async ({ clear, data, getDomNodes, paused, flags: { goingBack, preview } }) => {\r\n\t\tif (preview) return;\r\n\r\n\t\tconst { loadSlim, tsParticles } = await this.getParticles();\r\n\r\n\t\tif (!loaded) {\r\n\t\t\t/**\r\n\t\t\t * Load `tsParticles` in case it's not loaded\r\n\t\t\t */\r\n\t\t\tawait loadSlim(tsParticles);\r\n\t\t\t/**\r\n\t\t\t * Do not load it later\r\n\t\t\t */\r\n\t\t\tloaded = true;\r\n\t\t}\r\n\r\n\t\tconst { element } = getDomNodes(true);\r\n\r\n\t\t// Remove previous instance\r\n\t\tclear(() => {\r\n\t\t\t// Get the instance\r\n\t\t\tconst { instance, unsubscribe } = data<Data>();\r\n\r\n\t\t\tif (!instance) return;\r\n\r\n\t\t\t// Destroy the instance\r\n\t\t\tinstance.destroy();\r\n\r\n\t\t\t// Unsubscribe from 'paused' listener\r\n\t\t\tif (unsubscribe) {\r\n\t\t\t\tunsubscribe();\r\n\t\t\t}\r\n\r\n\t\t\t// Empty the `data`\r\n\t\t\tdata({});\r\n\t\t});\r\n\r\n\t\tconst _data = data<Data>();\r\n\r\n\t\tconst optionsEqual = _data.options === options;\r\n\t\tconst instancePresent = Boolean(_data.instance);\r\n\r\n\t\t/**\r\n\t\t * Skip re-rendering if:\r\n\t\t * 1) Options has not changed and instance is present\r\n\t\t * 2) Options has not changed and we are goingBack\r\n\t\t */\r\n\t\tif (optionsEqual && instancePresent) return;\r\n\t\tif (optionsEqual && goingBack) return;\r\n\r\n\t\t/**\r\n\t\t * We can not wait until particles is loaded\r\n\t\t */\r\n\t\tconst load = async () => {\r\n\t\t\tconst instance = await tsParticles.load({\r\n\t\t\t\telement: element,\r\n\t\t\t\toptions: withDefault(options),\r\n\t\t\t});\r\n\r\n\t\t\tconst unsubscribe = paused.subscribe((paused) => {\r\n\t\t\t\tif (!instance) return;\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\tif (paused) {\r\n\t\t\t\t\t\tinstance.pause();\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tinstance.play();\r\n\t\t\t\t\t}\r\n\t\t\t\t} catch {}\r\n\t\t\t});\r\n\r\n\t\t\tdata<Data>({ instance, options, unsubscribe });\r\n\t\t};\r\n\r\n\t\t/**\r\n\t\t * Should be safe because in restore only latest is called, and when playing it is not expected to change frequently\r\n\t\t */\r\n\t\tvoid load();\r\n\t};\r\n\r\n\thandler.callOnlyLatest = true;\r\n\thandler.id = PARTICLES_ID;\r\n\thandler.key = 'particles';\r\n\r\n\treturn handler;\r\n};\r\n\r\nconst hideParticles = () => {\r\n\tconst handler: CustomHandler = ({ data, remove, flags: { preview } }) => {\r\n\t\tif (preview) return;\r\n\r\n\t\t/**\r\n\t\t * Get the instance\r\n\t\t */\r\n\t\tconst { instance } = data<Data>();\r\n\r\n\t\t/**\r\n\t\t * Destroy it\r\n\t\t */\r\n\t\tif (instance) instance.destroy();\r\n\r\n\t\t/**\r\n\t\t * Delete the layer\r\n\t\t */\r\n\t\tremove();\r\n\t};\r\n\r\n\thandler.callOnlyLatest = true;\r\n\thandler.id = PARTICLES_ID;\r\n\thandler.key = 'particles';\r\n\r\n\treturn handler;\r\n};\r\n\r\nexport { showParticles, hideParticles };\r\n"],"mappings":"AAGA,IAAI,EAAS,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perty,r=((e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r})({loadSlim:()=>t,tsParticles:()=>e});export{e as n,r,t};
2
+ //# sourceMappingURL=tsparticles-CISqpimk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsparticles-CISqpimk.mjs","names":[],"sources":["../src/tsparticles.ts"],"sourcesContent":["export { tsParticles } from '@tsparticles/engine';\r\nexport { loadSlim } from '@tsparticles/slim';\r\n"],"mappings":""}
package/license CHANGED
@@ -1,15 +1,15 @@
1
- ISC License
2
-
3
- Copyright (c) 2024, Artem Schukin
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright (c) 2024, Artem Schukin
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/package.json CHANGED
@@ -1,19 +1,41 @@
1
1
  {
2
2
  "name": "@novely/particles",
3
+ "version": "0.12.0",
3
4
  "description": "Particles Action",
4
- "version": "0.11.0",
5
+ "keywords": [
6
+ "novely",
7
+ "particles",
8
+ "ts-particles"
9
+ ],
10
+ "homepage": "https://github.com/yhdgms1/novely/tree/main/packages/particles",
11
+ "bugs": {
12
+ "url": "https://github.com/yhdgms1/novely/issues"
13
+ },
14
+ "license": "ISC",
15
+ "author": {
16
+ "name": "Artemiy Schukin",
17
+ "url": "https://github.com/yhdgms1"
18
+ },
19
+ "contributors": [],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/yhdgms1/novely.git"
23
+ },
24
+ "files": [
25
+ "dist/*"
26
+ ],
5
27
  "type": "module",
6
28
  "sideEffects": false,
7
29
  "exports": {
8
30
  ".": {
9
- "types": "./dist/lazy.d.ts",
10
- "import": "./dist/lazy.js",
11
- "default": "./dist/lazy.js"
31
+ "types": "./dist/lazy.d.mts",
32
+ "import": "./dist/lazy.mjs",
33
+ "default": "./dist/lazy.mjs"
12
34
  },
13
35
  "./eager": {
14
- "types": "./dist/eager.d.ts",
15
- "import": "./dist/eager.js",
16
- "default": "./dist/eager.js"
36
+ "types": "./dist/eager.d.mts",
37
+ "import": "./dist/eager.mjs",
38
+ "default": "./dist/eager.mjs"
17
39
  },
18
40
  "./*": "./dist/*",
19
41
  "./package.json": "./package.json"
@@ -22,41 +44,19 @@
22
44
  "access": "public"
23
45
  },
24
46
  "dependencies": {
47
+ "@novely/core": "^0.56.0",
25
48
  "@tsparticles/engine": "~3.8.1",
26
- "@tsparticles/slim": "~3.8.1",
27
- "@novely/core": "^0.52.0"
49
+ "@tsparticles/slim": "~3.8.1"
28
50
  },
29
51
  "devDependencies": {
30
- "tsup": "^8.5.0",
31
- "typescript": "^5.8.3"
52
+ "tsdown": "^0.21.4",
53
+ "typescript": "^5.9.3"
32
54
  },
33
55
  "peerDependencies": {
34
56
  "@novely/core": "*"
35
57
  },
36
- "license": "ISC",
37
- "bugs": {
38
- "url": "https://github.com/yhdgms1/novely/issues"
39
- },
40
- "homepage": "https://github.com/yhdgms1/novely/tree/main/packages/particles",
41
- "keywords": [
42
- "ts-particles",
43
- "particles",
44
- "novely"
45
- ],
46
- "author": {
47
- "name": "Artemiy Schukin",
48
- "url": "https://github.com/yhdgms1"
49
- },
50
- "contributors": [],
51
- "repository": {
52
- "type": "git",
53
- "url": "git+https://github.com/yhdgms1/novely.git"
54
- },
55
- "files": [
56
- "dist/*"
57
- ],
58
58
  "scripts": {
59
- "dev": "tsup --watch --dts",
60
- "build": "tsup --dts"
59
+ "dev": "tsdown --watch --dts",
60
+ "build": "tsdown --dts"
61
61
  }
62
62
  }