@novely/particles 0.8.0 → 0.9.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.
@@ -0,0 +1,2 @@
1
+ var c=!1,p=Symbol(),f=t=>(t.autoPlay||=!0,t.fullScreen||={enable:!0,zIndex:2},t),h=function(t){let e=async({clear:r,data:s,getDomNodes:a,flags:{goingBack:u,preview:P}})=>{if(P)return;let{loadSlim:y,tsParticles:n}=await this.getParticles();c||(await y(n),c=!0);let{element:d}=a(!0);r(()=>{let{instance:i}=s();i&&(i.destroy(),s({}))});let l=s(),o=l.options===t,m=!!l.instance;if(o&&m||o&&u)return;(async()=>{let i=await n.load({element:d,options:f(t)});s({instance:i,options:t})})()};return e.callOnlyLatest=e.skipClearOnGoingBack=!0,e.id=p,e.key="particles",e},O=()=>{let t=({data:e,remove:r,flags:{preview:s}})=>{if(s)return;let{instance:a}=e();a&&a.destroy(),r()};return t.callOnlyLatest=!0,t.id=p,t.key="particles",t};export{h as a,O as b};
2
+ //# sourceMappingURL=chunk-ZNV5PZ6I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/particles.ts"],"sourcesContent":["import type { CustomHandler } from '@novely/core';\nimport type { Container, IOptions, RecursivePartial } from '@tsparticles/engine';\n\nlet loaded = false;\n\nconst PARTICLES_ID = Symbol();\n\ntype ParticlesOptions = RecursivePartial<IOptions>;\n\ntype Data = {\n\tinstance?: Container;\n\toptions?: ParticlesOptions;\n};\n\ntype TSParticles = {\n\ttsParticles: typeof import('@tsparticles/engine').tsParticles;\n\tloadSlim: typeof import('@tsparticles/slim').loadSlim;\n};\n\ntype TSParticlesGetter = () => Promise<TSParticles>;\n\ntype ParticlesThis = {\n\tgetParticles: TSParticlesGetter;\n};\n\nconst withDefault = (options: ParticlesOptions) => {\n\toptions.autoPlay ||= true;\n\toptions.fullScreen ||= { enable: true, zIndex: 2 };\n\n\treturn options;\n};\n\nconst showParticles = function (this: ParticlesThis, options: ParticlesOptions): CustomHandler {\n\tconst handler: CustomHandler = async ({ clear, data, getDomNodes, flags: { goingBack, preview } }) => {\n\t\tif (preview) return;\n\n\t\tconst { loadSlim, tsParticles } = await this.getParticles();\n\n\t\tif (!loaded) {\n\t\t\t/**\n\t\t\t * Load `tsParticles` in case it's not loaded\n\t\t\t */\n\t\t\tawait loadSlim(tsParticles);\n\t\t\t/**\n\t\t\t * Do not load it later\n\t\t\t */\n\t\t\tloaded = true;\n\t\t}\n\n\t\tconst { element } = getDomNodes(true);\n\n\t\t/**\n\t\t * Remove previous instance\n\t\t */\n\t\tclear(() => {\n\t\t\t/**\n\t\t\t * Get the instance\n\t\t\t */\n\t\t\tconst { instance } = data<Data>();\n\n\t\t\tif (!instance) return;\n\n\t\t\t/**\n\t\t\t * Destroy the instance\n\t\t\t */\n\t\t\tinstance.destroy();\n\n\t\t\t/**\n\t\t\t * Empty the `data`\n\t\t\t */\n\t\t\tdata({});\n\t\t});\n\n\t\tconst _data = data<Data>();\n\n\t\tconst optionsEqual = _data.options === options;\n\t\tconst instancePresent = Boolean(_data.instance);\n\n\t\t/**\n\t\t * Skip re-rendering if:\n\t\t * 1) Options has not changed and instance is present\n\t\t * 2) Options has not changed and we are goingBack\n\t\t */\n\t\tif (optionsEqual && instancePresent) return;\n\t\tif (optionsEqual && goingBack) return;\n\n\t\t/**\n\t\t * We can not wait until particles is loaded\n\t\t */\n\t\tconst load = async () => {\n\t\t\tconst instance = await tsParticles.load({\n\t\t\t\telement: element,\n\t\t\t\toptions: withDefault(options),\n\t\t\t});\n\n\t\t\tdata<Data>({ instance, options });\n\t\t};\n\n\t\t/**\n\t\t * Should be safe because in restore only latest is called, and when playing it is not expected to change frequently\n\t\t */\n\t\tvoid load();\n\t};\n\n\thandler.callOnlyLatest = handler.skipClearOnGoingBack = true;\n\thandler.id = PARTICLES_ID;\n\thandler.key = 'particles';\n\n\treturn handler;\n};\n\nconst hideParticles = () => {\n\tconst handler: CustomHandler = ({ data, remove, flags: { preview } }) => {\n\t\tif (preview) return;\n\n\t\t/**\n\t\t * Get the instance\n\t\t */\n\t\tconst { instance } = data<Data>();\n\n\t\t/**\n\t\t * Destroy it\n\t\t */\n\t\tif (instance) instance.destroy();\n\n\t\t/**\n\t\t * Delete the layer\n\t\t */\n\t\tremove();\n\t};\n\n\thandler.callOnlyLatest = true;\n\thandler.id = PARTICLES_ID;\n\thandler.key = 'particles';\n\n\treturn handler;\n};\n\nexport { showParticles, hideParticles };\n"],"mappings":"AAGA,IAAIA,EAAS,GAEPC,EAAe,OAAO,EAoBtBC,EAAeC,IACpBA,EAAQ,WAAa,GACrBA,EAAQ,aAAe,CAAE,OAAQ,GAAM,OAAQ,CAAE,EAE1CA,GAGFC,EAAgB,SAA+BD,EAA0C,CAC9F,IAAME,EAAyB,MAAO,CAAE,MAAAC,EAAO,KAAAC,EAAM,YAAAC,EAAa,MAAO,CAAE,UAAAC,EAAW,QAAAC,CAAQ,CAAE,IAAM,CACrG,GAAIA,EAAS,OAEb,GAAM,CAAE,SAAAC,EAAU,YAAAC,CAAY,EAAI,MAAM,KAAK,aAAa,EAErDZ,IAIJ,MAAMW,EAASC,CAAW,EAI1BZ,EAAS,IAGV,GAAM,CAAE,QAAAa,CAAQ,EAAIL,EAAY,EAAI,EAKpCF,EAAM,IAAM,CAIX,GAAM,CAAE,SAAAQ,CAAS,EAAIP,EAAW,EAE3BO,IAKLA,EAAS,QAAQ,EAKjBP,EAAK,CAAC,CAAC,EACR,CAAC,EAED,IAAMQ,EAAQR,EAAW,EAEnBS,EAAeD,EAAM,UAAYZ,EACjCc,EAAkB,EAAQF,EAAM,SAQtC,GADIC,GAAgBC,GAChBD,GAAgBP,EAAW,QAKlB,SAAY,CACxB,IAAMK,EAAW,MAAMF,EAAY,KAAK,CACvC,QAASC,EACT,QAASX,EAAYC,CAAO,CAC7B,CAAC,EAEDI,EAAW,CAAE,SAAAO,EAAU,QAAAX,CAAQ,CAAC,CACjC,GAKU,CACX,EAEA,OAAAE,EAAQ,eAAiBA,EAAQ,qBAAuB,GACxDA,EAAQ,GAAKJ,EACbI,EAAQ,IAAM,YAEPA,CACR,EAEMa,EAAgB,IAAM,CAC3B,IAAMb,EAAyB,CAAC,CAAE,KAAAE,EAAM,OAAAY,EAAQ,MAAO,CAAE,QAAAT,CAAQ,CAAE,IAAM,CACxE,GAAIA,EAAS,OAKb,GAAM,CAAE,SAAAI,CAAS,EAAIP,EAAW,EAK5BO,GAAUA,EAAS,QAAQ,EAK/BK,EAAO,CACR,EAEA,OAAAd,EAAQ,eAAiB,GACzBA,EAAQ,GAAKJ,EACbI,EAAQ,IAAM,YAEPA,CACR","names":["loaded","PARTICLES_ID","withDefault","options","showParticles","handler","clear","data","getDomNodes","goingBack","preview","loadSlim","tsParticles","element","instance","_data","optionsEqual","instancePresent","hideParticles","remove"]}
@@ -0,0 +1,7 @@
1
+ import * as _novely_core from '@novely/core';
2
+ import * as _tsparticles_engine from '@tsparticles/engine';
3
+ export { h as hideParticles } from './particles-B-Ej9Zxz.js';
4
+
5
+ declare const showParticlesEager: (options: _tsparticles_engine.RecursivePartial<_tsparticles_engine.IOptions>) => _novely_core.CustomHandler;
6
+
7
+ export { showParticlesEager as showParticles };
package/dist/eager.js ADDED
@@ -0,0 +1,2 @@
1
+ import{a as s,b as o}from"./chunk-ZNV5PZ6I.js";import{a as r,b as e}from"./chunk-QB4O5T45.js";var t=()=>Promise.resolve({loadSlim:e,tsParticles:r}),l=s.bind({getParticles:t});export{o as hideParticles,l as showParticles};
2
+ //# sourceMappingURL=eager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/eager.ts"],"sourcesContent":["import { hideParticles, showParticles } from './particles';\nimport { loadSlim, tsParticles } from './tsparticles';\n\nconst getParticles = () =>\n\tPromise.resolve({\n\t\tloadSlim,\n\t\ttsParticles,\n\t});\n\nconst showParticlesEager = showParticles.bind({\n\tgetParticles,\n});\n\nexport { showParticlesEager as showParticles, hideParticles };\n"],"mappings":"8FAGA,IAAMA,EAAe,IACpB,QAAQ,QAAQ,CACf,SAAAC,EACA,YAAAC,CACD,CAAC,EAEIC,EAAqBC,EAAc,KAAK,CAC7C,aAAAJ,CACD,CAAC","names":["getParticles","loadSlim","tsParticles","showParticlesEager","showParticles"]}
package/dist/lazy.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import * as _novely_core from '@novely/core';
2
+ import * as _tsparticles_engine from '@tsparticles/engine';
3
+ export { h as hideParticles } from './particles-B-Ej9Zxz.js';
4
+
5
+ declare const showParticlesLazy: (options: _tsparticles_engine.RecursivePartial<_tsparticles_engine.IOptions>) => _novely_core.CustomHandler;
6
+
7
+ export { showParticlesLazy as showParticles };
package/dist/lazy.js ADDED
@@ -0,0 +1,2 @@
1
+ import{a as s,b as t}from"./chunk-ZNV5PZ6I.js";var i=()=>import("./tsparticles-U2KDNUB2.js"),r=s.bind({getParticles:i});export{t as hideParticles,r as showParticles};
2
+ //# sourceMappingURL=lazy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lazy.ts"],"sourcesContent":["import { hideParticles, showParticles } from './particles';\n\nconst getParticles = () => import('./tsparticles');\n\nconst showParticlesLazy = showParticles.bind({\n\tgetParticles,\n});\n\nexport { showParticlesLazy as showParticles, hideParticles };\n"],"mappings":"+CAEA,IAAMA,EAAe,IAAM,OAAO,2BAAe,EAE3CC,EAAoBC,EAAc,KAAK,CAC5C,aAAAF,CACD,CAAC","names":["getParticles","showParticlesLazy","showParticles"]}
@@ -0,0 +1,5 @@
1
+ import { CustomHandler } from '@novely/core';
2
+
3
+ declare const hideParticles: () => CustomHandler;
4
+
5
+ export { hideParticles as h };
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-QB4O5T45.js";export{b as loadSlim,a as tsParticles};
2
+ //# sourceMappingURL=tsparticles-U2KDNUB2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,26 +1,37 @@
1
1
  {
2
2
  "name": "@novely/particles",
3
3
  "description": "Particles Action",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
- "types": "./dist/index.d.ts",
8
- "main": "./dist/index.js",
9
- "module": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/lazy.d.ts",
10
+ "import": "./dist/lazy.js",
11
+ "default": "./dist/lazy.js"
12
+ },
13
+ "./eager": {
14
+ "types": "./dist/eager.d.ts",
15
+ "import": "./dist/eager.js",
16
+ "default": "./dist/eager.js"
17
+ },
18
+ "./*": "./dist/*",
19
+ "./package.json": "./package.json"
20
+ },
10
21
  "publishConfig": {
11
22
  "access": "public"
12
23
  },
13
24
  "dependencies": {
14
25
  "@tsparticles/engine": "~3.7.1",
15
26
  "@tsparticles/slim": "~3.7.1",
16
- "@novely/core": "0.46.0-next.0"
27
+ "@novely/core": "0.46.0"
17
28
  },
18
29
  "devDependencies": {
19
30
  "tsup": "^8.3.0",
20
31
  "typescript": "^5.6.2"
21
32
  },
22
33
  "peerDependencies": {
23
- "@novely/core": "0.46.0-next.0"
34
+ "@novely/core": "*"
24
35
  },
25
36
  "license": "ISC",
26
37
  "bugs": {
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { CustomHandler } from '@novely/core';
2
- import { RecursivePartial, IOptions } from '@tsparticles/engine';
3
-
4
- type ParticlesOptions = RecursivePartial<IOptions>;
5
- declare const showParticles: (options: ParticlesOptions) => CustomHandler;
6
- declare const hideParticles: () => CustomHandler;
7
-
8
- export { hideParticles, showParticles };