From f887100777937ff6447a1c2bed8cab4094acf6fc Mon Sep 17 00:00:00 2001 From: Cahil Foley Date: Fri, 6 Sep 2024 18:35:37 +0800 Subject: [PATCH] chore: Update built files for latest changes --- packages/react-snowfall/lib/Snowfall.d.ts | 2 +- packages/react-snowfall/lib/Snowfall.js | 6 +- packages/react-snowfall/lib/Snowfall.js.map | 2 +- .../react-snowfall/lib/SnowfallCanvas.d.ts | 2 +- packages/react-snowfall/lib/SnowfallCanvas.js | 39 ++++++++---- .../react-snowfall/lib/SnowfallCanvas.js.map | 2 +- packages/react-snowfall/lib/Snowflake.d.ts | 26 +++++++- packages/react-snowfall/lib/Snowflake.js | 62 ++++++++++++------- packages/react-snowfall/lib/Snowflake.js.map | 2 +- packages/react-snowfall/lib/config.d.ts | 1 - packages/react-snowfall/lib/hooks.d.ts | 1 - packages/react-snowfall/lib/hooks.js | 9 ++- packages/react-snowfall/lib/hooks.js.map | 2 +- packages/react-snowfall/lib/index.d.ts | 6 +- packages/react-snowfall/lib/index.js | 6 +- packages/react-snowfall/lib/index.js.map | 2 +- packages/react-snowfall/lib/utils.d.ts | 6 ++ packages/react-snowfall/lib/utils.js | 6 ++ packages/react-snowfall/lib/utils.js.map | 2 +- 19 files changed, 128 insertions(+), 56 deletions(-) diff --git a/packages/react-snowfall/lib/Snowfall.d.ts b/packages/react-snowfall/lib/Snowfall.d.ts index d811f37..e9453c9 100644 --- a/packages/react-snowfall/lib/Snowfall.d.ts +++ b/packages/react-snowfall/lib/Snowfall.d.ts @@ -1,5 +1,5 @@ import React from 'react'; -import { SnowfallCanvasConfig } from './SnowfallCanvas'; +import { SnowfallCanvasConfig } from './SnowfallCanvas.js'; export interface SnowfallProps extends Partial { /** * Any style properties that will be passed to the canvas element. diff --git a/packages/react-snowfall/lib/Snowfall.js b/packages/react-snowfall/lib/Snowfall.js index 3501f3d..53135e2 100644 --- a/packages/react-snowfall/lib/Snowfall.js +++ b/packages/react-snowfall/lib/Snowfall.js @@ -1,7 +1,7 @@ import React, { useEffect, useRef } from 'react'; -import { SnowfallCanvas } from './SnowfallCanvas'; -import { defaultConfig } from './Snowflake'; -import { useComponentSize, useDeepMemo, useSnowfallStyle } from './hooks'; +import { SnowfallCanvas } from './SnowfallCanvas.js'; +import { defaultConfig } from './Snowflake.js'; +import { useComponentSize, useDeepMemo, useSnowfallStyle } from './hooks.js'; export const Snowfall = ({ color = defaultConfig.color, changeFrequency = defaultConfig.changeFrequency, radius = defaultConfig.radius, speed = defaultConfig.speed, wind = defaultConfig.wind, rotationSpeed = defaultConfig.rotationSpeed, snowflakeCount = 150, images, style, } = {}) => { const mergedStyle = useSnowfallStyle(style); const canvasRef = useRef(null); diff --git a/packages/react-snowfall/lib/Snowfall.js.map b/packages/react-snowfall/lib/Snowfall.js.map index 431ecb9..78ce89c 100644 --- a/packages/react-snowfall/lib/Snowfall.js.map +++ b/packages/react-snowfall/lib/Snowfall.js.map @@ -1 +1 @@ -{"version":3,"file":"Snowfall.js","sourceRoot":"","sources":["../src/Snowfall.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AASzE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,KAAK,GAAG,aAAa,CAAC,KAAK,EAC3B,eAAe,GAAG,aAAa,CAAC,eAAe,EAC/C,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,KAAK,GAAG,aAAa,CAAC,KAAK,EAC3B,IAAI,GAAG,aAAa,CAAC,IAAI,EACzB,aAAa,GAAG,aAAa,CAAC,aAAa,EAC3C,cAAc,GAAG,GAAG,EACpB,MAAM,EACN,KAAK,MACY,EAAE,EAAe,EAAE;I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O,GAAG,IAAI,cAAc,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;QACtF,CAAC;QAED,OAAO,GAAG,EAAE;;YACV,MAAA,iBAAiB,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA;YAClC,iBAAiB,CAAC,OAAO,GAAG,SAAS,CAAA;QACvC,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,CAAC,OAAO,EAAE,CAAC;YAC9B,iBAAiB,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;QAChD,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAEZ,OAAO,CACL,gCACE,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,UAAU,CAAC,MAAM,EACzB,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,KAAK,EAAE,WAAW,iBACN,gBAAgB,GAC5B,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA"} \ No newline at end of file diff --git a/packages/react-snowfall/lib/SnowfallCanvas.d.ts b/packages/react-snowfall/lib/SnowfallCanvas.d.ts index e19576b..ba6cebc 100644 --- a/packages/react-snowfall/lib/SnowfallCanvas.d.ts +++ b/packages/react-snowfall/lib/SnowfallCanvas.d.ts @@ -1,4 +1,4 @@ -import { SnowflakeConfig } from './Snowflake'; +import { SnowflakeConfig } from './Snowflake.js'; export interface SnowfallCanvasConfig extends SnowflakeConfig { /** * The number of snowflakes to be rendered. diff --git a/packages/react-snowfall/lib/SnowfallCanvas.js b/packages/react-snowfall/lib/SnowfallCanvas.js index 13061d8..7be8a9c 100644 --- a/packages/react-snowfall/lib/SnowfallCanvas.js +++ b/packages/react-snowfall/lib/SnowfallCanvas.js @@ -10,8 +10,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function ( return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var _SnowfallCanvas_ctx, _SnowfallCanvas_canvas; -import Snowflake, { defaultConfig } from './Snowflake'; -import { targetFrameTime } from './config'; +import Snowflake, { defaultConfig } from './Snowflake.js'; +import { targetFrameTime } from './config.js'; export class SnowfallCanvas { get ctx() { return __classPrivateFieldGet(this, _SnowfallCanvas_ctx, "f"); @@ -30,7 +30,7 @@ export class SnowfallCanvas { _SnowfallCanvas_canvas.set(this, void 0); __classPrivateFieldSet(this, _SnowfallCanvas_canvas, canvas, "f"); __classPrivateFieldSet(this, _SnowfallCanvas_ctx, canvas.getContext('2d'), "f"); - this.config = Object.assign(Object.assign({ snowflakeCount: 150 }, defaultConfig), config); + this.config = { snowflakeCount: 150, ...defaultConfig, ...config }; this.snowflakes = []; this.snowflakes = Snowflake.createSnowflakes(canvas, config.snowflakeCount || 150, config); this.play(); @@ -41,7 +41,7 @@ export class SnowfallCanvas { * to retain the position of as many existing snowflakes as possible. */ updateConfig(config) { - this.config = Object.assign(Object.assign({}, this.config), config); + this.config = { ...this.config, ...config }; const sizeDifference = this.config.snowflakeCount - this.snowflakes.length; if (sizeDifference > 0) { this.snowflakes = [...this.snowflakes, ...Snowflake.createSnowflakes(this.canvas, sizeDifference, config)]; @@ -49,7 +49,9 @@ export class SnowfallCanvas { if (sizeDifference < 0) { this.snowflakes = this.snowflakes.slice(0, this.config.snowflakeCount); } - this.snowflakes.forEach((snowflake) => snowflake.updateConfig(this.config)); + for (const snowflake of this.snowflakes) { + snowflake.updateConfig(this.config); + } } /** * Updates the location of each snowflake based on the number of frames passed then @@ -57,15 +59,30 @@ export class SnowfallCanvas { */ render(framesPassed = 1) { const { ctx, canvas, snowflakes } = this; + if (!ctx || !canvas) + return; const { offsetWidth, offsetHeight } = canvas; // Update the position of each snowflake - snowflakes.forEach((snowflake) => snowflake.update(offsetWidth, offsetHeight, framesPassed)); - // Render them if the canvas is available - if (ctx) { - ctx.setTransform(1, 0, 0, 1, 0, 0); - ctx.clearRect(0, 0, offsetWidth, offsetHeight); - snowflakes.forEach((snowflake) => snowflake.draw(ctx)); + for (const snowflake of snowflakes) { + snowflake.update(offsetWidth, offsetHeight, framesPassed); + } + // Render the snowflakes + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.clearRect(0, 0, offsetWidth, offsetHeight); + // If using images, draw each image individually + if (this.config.images && this.config.images.length > 0) { + for (const snowflake of snowflakes) { + snowflake.drawImage(ctx); + } + return; + } + // Not using images, draw circles in a single path + ctx.beginPath(); + for (const snowflake of snowflakes) { + snowflake.drawCircle(ctx); } + ctx.fillStyle = this.config.color; + ctx.fill(); } /** * The animation loop, will calculate the time since the last render and update diff --git a/packages/react-snowfall/lib/SnowfallCanvas.js.map b/packages/react-snowfall/lib/SnowfallCanvas.js.map index 8a93039..33091af 100644 --- a/packages/react-snowfall/lib/SnowfallCanvas.js.map +++ b/packages/react-snowfall/lib/SnowfallCanvas.js.map @@ -1 +1 @@ -{"version":3,"file":"SnowfallCanvas.js","sourceRoot":"","sources":["../src/SnowfallCanvas.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,SAAS,EAAE,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAW1C,MAAM,OAAO,cAAc;IAMzB,IAAI,GAAG;QACL,OAAO,uBAAA,IAAI,2BAAK,CAAA;IAClB,CAAC;IAGD,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,8BAAQ,CAAA;IACrB,CAAC;IACD,IAAI,MAAM,CAAC,MAAyB;QAClC,uBAAA,IAAI,0BAAW,MAAM,MAAA,CAAA;QACrB,uBAAA,IAAI,uBAAQ,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAA,CAAA;IACrC,CAAC;IAED,YAAY,MAAyB,EAAE,MAAqC;QAlBpE,eAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACvB,eAAU,GAAgB,EAAE,CAAA;QAGpC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IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YACzC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAA;QACjC,CAAC;IACH,CAAC;CACF;;AAED,eAAe,cAAc,CAAA"} \ No newline at end of file diff --git a/packages/react-snowfall/lib/Snowflake.d.ts b/packages/react-snowfall/lib/Snowflake.d.ts index 8572a77..08f3442 100644 --- a/packages/react-snowfall/lib/Snowflake.d.ts +++ b/packages/react-snowfall/lib/Snowflake.d.ts @@ -80,6 +80,30 @@ declare class Snowflake { private updateTargetParams; update(offsetWidth: number, offsetHeight: number, framesPassed?: number): void; private getImageOffscreenCanvas; - draw(ctx: CanvasRenderingContext2D): void; + /** + * Draws a circular snowflake to the canvas. + * + * This method should only be called if our config does not have images. + * + * This method assumes that a path has already been started on the canvas. + * `ctx.beginPath()` should be called before calling this method. + * + * After calling this method, the fillStyle should be set to the snowflake's + * color and `ctx.fill()` should be called to fill the snowflake. + * + * Calling `ctx.fill()` after multiple snowflakes have had `drawCircle` called + * will render all of the snowflakes since the last call to `ctx.beginPath()`. + * + * @param ctx The canvas context to draw to + */ + drawCircle(ctx: CanvasRenderingContext2D): void; + /** + * Draws an image-based snowflake to the canvas. + * + * This method should only be called if our config has images. + * + * @param ctx The canvas context to draw to + */ + drawImage(ctx: CanvasRenderingContext2D): void; } export default Snowflake; diff --git a/packages/react-snowfall/lib/Snowflake.js b/packages/react-snowfall/lib/Snowflake.js index 133b455..89107c7 100644 --- a/packages/react-snowfall/lib/Snowflake.js +++ b/packages/react-snowfall/lib/Snowflake.js @@ -1,5 +1,5 @@ import isEqual from 'react-fast-compare'; -import { lerp, random, randomElement } from './utils'; +import { lerp, random, randomElement, twoPi } from './utils.js'; export const defaultConfig = { color: '#dee4fd', radius: [0.5, 3.0], @@ -57,7 +57,7 @@ class Snowflake { } updateConfig(config) { const previousConfig = this.config; - this.config = Object.assign(Object.assign({}, defaultConfig), config); + this.config = { ...defaultConfig, ...config }; this.config.changeFrequency = random(this.config.changeFrequency, this.config.changeFrequency * 1.5); // Update the radius if the config has changed, it won't gradually update on it's own if (this.params && !isEqual(this.config.radius, previousConfig === null || previousConfig === void 0 ? void 0 : previousConfig.radius)) { @@ -114,27 +114,45 @@ class Snowflake { } return (_b = sizes[size]) !== null && _b !== void 0 ? _b : image; } - draw(ctx) { + /** + * Draws a circular snowflake to the canvas. + * + * This method should only be called if our config does not have images. + * + * This method assumes that a path has already been started on the canvas. + * `ctx.beginPath()` should be called before calling this method. + * + * After calling this method, the fillStyle should be set to the snowflake's + * color and `ctx.fill()` should be called to fill the snowflake. + * + * Calling `ctx.fill()` after multiple snowflakes have had `drawCircle` called + * will render all of the snowflakes since the last call to `ctx.beginPath()`. + * + * @param ctx The canvas context to draw to + */ + drawCircle(ctx) { + ctx.moveTo(this.params.x, this.params.y); + ctx.arc(this.params.x, this.params.y, this.params.radius, 0, twoPi); + } + /** + * Draws an image-based snowflake to the canvas. + * + * This method should only be called if our config has images. + * + * @param ctx The canvas context to draw to + */ + drawImage(ctx) { const { x, y, rotation, radius } = this.params; - if (this.image) { - const radian = (rotation * Math.PI) / 180; - const cos = Math.cos(radian); - const sin = Math.sin(radian); - // Translate to the location that we will be drawing the snowflake, including any rotation that needs to be applied - // The arguments for setTransform are: a, b, c, d, e, f - // a (scaleX), b (skewY), c (skewX), d (scaleY), e (translateX), f (translateY) - ctx.setTransform(cos, sin, -sin, cos, x, y); - // Draw the image with the center of the image at the center of the current location - const image = this.getImageOffscreenCanvas(this.image, radius); - ctx.drawImage(image, -(radius / 2), -(radius / 2), radius, radius); - } - else { - // Not using images so no need to use transforms, just draw an arc in the right location - ctx.beginPath(); - ctx.arc(x, y, radius, 0, 2 * Math.PI); - ctx.fillStyle = this.config.color; - ctx.fill(); - } + const radian = (rotation * Math.PI) / 180; + const cos = Math.cos(radian); + const sin = Math.sin(radian); + // Translate to the location that we will be drawing the snowflake, including any rotation that needs to be applied + // The arguments for setTransform are: a, b, c, d, e, f + // a (scaleX), b (skewY), c (skewX), d (scaleY), e (translateX), f (translateY) + ctx.setTransform(cos, sin, -sin, cos, x, y); + // Draw the image with the center of the image at the center of the current location + const image = this.getImageOffscreenCanvas(this.image, radius); + ctx.drawImage(image, -(radius / 2), -(radius / 2), radius, radius); } } Snowflake.offscreenCanvases = new WeakMap(); diff --git a/packages/react-snowfall/lib/Snowflake.js.map b/packages/react-snowfall/lib/Snowflake.js.map index d90e80a..fcbf2e2 100644 --- a/packages/react-snowfall/lib/Snowflake.js.map +++ b/packages/react-snowfall/lib/Snowflake.js.map @@ -1 +1 @@ -{"version":3,"file":"Snowflake.js","sourceRoot":"","sources":["../src/Snowflake.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA8DrD,MAAM,CAAC,MAAM,aAAa,GAAmB;IAC3C,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;IACjB,eAAe,EAAE,GAAG;IACpB,aAAa,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;CAC3B,CAAA;AAeD;;;GAGG;AACH,MAAM,SAAS;IAGb;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAgC,EAAE,MAAc,EAAE,MAAuB;QAC/F,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAA;QAEtB,MAAM,UAAU,GAAgB,EAAE,CAAA;QAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CA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AS,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACpE,CAAC;;AAvKc,2BAAiB,GAAG,IAAI,OAAO,EAAwD,CAAA;AA0KxG,eAAe,SAAS,CAAA"} \ No newline at end of file diff --git a/packages/react-snowfall/lib/config.d.ts b/packages/react-snowfall/lib/config.d.ts index 27650f8..657dd44 100644 --- a/packages/react-snowfall/lib/config.d.ts +++ b/packages/react-snowfall/lib/config.d.ts @@ -1,3 +1,2 @@ -/// export declare const snowfallBaseStyle: React.CSSProperties; export declare const targetFrameTime: number; diff --git a/packages/react-snowfall/lib/hooks.d.ts b/packages/react-snowfall/lib/hooks.d.ts index 63d7503..c464c05 100644 --- a/packages/react-snowfall/lib/hooks.d.ts +++ b/packages/react-snowfall/lib/hooks.d.ts @@ -1,4 +1,3 @@ -/// /** * Returns the height and width of a HTML element, uses the `ResizeObserver` api if available to detect changes to the * size. Falls back to listening for resize events on the window. diff --git a/packages/react-snowfall/lib/hooks.js b/packages/react-snowfall/lib/hooks.js index b8596ef..e518c97 100644 --- a/packages/react-snowfall/lib/hooks.js +++ b/packages/react-snowfall/lib/hooks.js @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState, useMemo } from 'react'; import isEqual from 'react-fast-compare'; -import { snowfallBaseStyle } from './config'; -import { getSize } from './utils'; +import { snowfallBaseStyle } from './config.js'; +import { getSize } from './utils.js'; /** * Returns the height and width of a HTML element, uses the `ResizeObserver` api if available to detect changes to the * size. Falls back to listening for resize events on the window. @@ -36,7 +36,10 @@ export const useComponentSize = (ref) => { * @param overrides The style prop passed into the component */ export const useSnowfallStyle = (overrides) => { - const styles = useMemo(() => (Object.assign(Object.assign({}, snowfallBaseStyle), (overrides || {}))), [overrides]); + const styles = useMemo(() => ({ + ...snowfallBaseStyle, + ...(overrides || {}), + }), [overrides]); return styles; }; /** diff --git a/packages/react-snowfall/lib/hooks.js.map b/packages/react-snowfall/lib/hooks.js.map index f704f77..cb298b0 100644 --- a/packages/react-snowfall/lib/hooks.js.map +++ b/packages/react-snowfall/lib/hooks.js.map @@ -1 +1 @@ -{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC1F,OAAO,OAAO,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAiC,EAAE,EAAE;IACpE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAEtD,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IAET,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;QAEjC,IAAI,CAAC,GAAG,CAAC,OAAO;YAAE,OAAM;QACxB,aAAa,EAAE,CAAA;QAEf,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,aAAa,CAAC,CAAA;YACxD,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YAEnC,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,CAAA;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QAClE,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAA;IAExB,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAA+B,EAAuB,EAAE;IACvF,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,iBAAiB;QACpB,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;KACrB,CAAC,EACF,CAAC,SAAS,CAAC,CACZ,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B,EAAE,IAA0B;IAC3F,MAAM,GAAG,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAA;IAE9C,kEAAkE;IAClE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAA;IACpB,CAAC;IAED,uDAAuD;IACvD,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAI,KAAQ;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEzC,oBAAoB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEpD,OAAO,KAAK,CAAA;AACd,CAAC"} \ No newline at end of file diff --git a/packages/react-snowfall/lib/index.d.ts b/packages/react-snowfall/lib/index.d.ts index 26f5a1b..6ec8178 100644 --- a/packages/react-snowfall/lib/index.d.ts +++ b/packages/react-snowfall/lib/index.d.ts @@ -1,3 +1,3 @@ -export * from './SnowfallCanvas'; -export * from './Snowfall'; -export { default } from './Snowfall'; +export * from './SnowfallCanvas.js'; +export * from './Snowfall.js'; +export { default } from './Snowfall.js'; diff --git a/packages/react-snowfall/lib/index.js b/packages/react-snowfall/lib/index.js index b244255..11b79b5 100644 --- a/packages/react-snowfall/lib/index.js +++ b/packages/react-snowfall/lib/index.js @@ -1,4 +1,4 @@ -export * from './SnowfallCanvas'; -export * from './Snowfall'; -export { default } from './Snowfall'; +export * from './SnowfallCanvas.js'; +export * from './Snowfall.js'; +export { default } from './Snowfall.js'; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/react-snowfall/lib/index.js.map b/packages/react-snowfall/lib/index.js.map index a39aa80..b233976 100644 --- a/packages/react-snowfall/lib/index.js.map +++ b/packages/react-snowfall/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA"} \ No newline at end of file diff --git a/packages/react-snowfall/lib/utils.d.ts b/packages/react-snowfall/lib/utils.d.ts index 2002ca6..bf33e33 100644 --- a/packages/react-snowfall/lib/utils.d.ts +++ b/packages/react-snowfall/lib/utils.d.ts @@ -27,3 +27,9 @@ export declare function getSize(element?: HTMLElement | null): { height: number; width: number; }; +/** + * Store the value of PI * 2. + * + * This is so we can avoid calculating this value every time we draw a circle. + */ +export declare const twoPi: number; diff --git a/packages/react-snowfall/lib/utils.js b/packages/react-snowfall/lib/utils.js index 041ae1e..35670ff 100644 --- a/packages/react-snowfall/lib/utils.js +++ b/packages/react-snowfall/lib/utils.js @@ -44,4 +44,10 @@ export function getSize(element) { width: element.offsetWidth, }; } +/** + * Store the value of PI * 2. + * + * This is so we can avoid calculating this value every time we draw a circle. + */ +export const twoPi = Math.PI * 2; //# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/packages/react-snowfall/lib/utils.js.map b/packages/react-snowfall/lib/utils.js.map index ef84590..3e51b28 100644 --- a/packages/react-snowfall/lib/utils.js.map +++ b/packages/react-snowfall/lib/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,GAAW;IAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAA;IAE1D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,YAAY,CAAA;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IACjC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,KAAa,EAAE,GAAW,EAAE,MAAc;IAC7D,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,GAAG,MAAM,GAAG,GAAG,CAAA;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAI,KAAU;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;IACtD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,OAA4B;IAClD,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE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AY;QAC5B,KAAK,EAAE,OAAO,CAAC,WAAW;KAC3B,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA"} \ No newline at end of file