@hdcodedev/snowfall 1.0.0 → 1.0.2

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.
Files changed (50) hide show
  1. package/README.md +3 -1
  2. package/dist/index.d.mts +38 -4
  3. package/dist/index.d.ts +38 -4
  4. package/dist/index.js +661 -16
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +656 -3
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +2 -2
  9. package/dist/Snowfall.d.mts +0 -5
  10. package/dist/Snowfall.d.ts +0 -5
  11. package/dist/Snowfall.js +0 -162
  12. package/dist/Snowfall.js.map +0 -1
  13. package/dist/Snowfall.mjs +0 -142
  14. package/dist/Snowfall.mjs.map +0 -1
  15. package/dist/SnowfallProvider.d.mts +0 -32
  16. package/dist/SnowfallProvider.d.ts +0 -32
  17. package/dist/SnowfallProvider.js +0 -89
  18. package/dist/SnowfallProvider.js.map +0 -1
  19. package/dist/SnowfallProvider.mjs +0 -63
  20. package/dist/SnowfallProvider.mjs.map +0 -1
  21. package/dist/utils/snowfall/constants.d.mts +0 -10
  22. package/dist/utils/snowfall/constants.d.ts +0 -10
  23. package/dist/utils/snowfall/constants.js +0 -50
  24. package/dist/utils/snowfall/constants.js.map +0 -1
  25. package/dist/utils/snowfall/constants.mjs +0 -19
  26. package/dist/utils/snowfall/constants.mjs.map +0 -1
  27. package/dist/utils/snowfall/dom.d.mts +0 -11
  28. package/dist/utils/snowfall/dom.d.ts +0 -11
  29. package/dist/utils/snowfall/dom.js +0 -130
  30. package/dist/utils/snowfall/dom.js.map +0 -1
  31. package/dist/utils/snowfall/dom.mjs +0 -113
  32. package/dist/utils/snowfall/dom.mjs.map +0 -1
  33. package/dist/utils/snowfall/draw.d.mts +0 -7
  34. package/dist/utils/snowfall/draw.d.ts +0 -7
  35. package/dist/utils/snowfall/draw.js +0 -160
  36. package/dist/utils/snowfall/draw.js.map +0 -1
  37. package/dist/utils/snowfall/draw.mjs +0 -134
  38. package/dist/utils/snowfall/draw.mjs.map +0 -1
  39. package/dist/utils/snowfall/physics.d.mts +0 -11
  40. package/dist/utils/snowfall/physics.d.ts +0 -11
  41. package/dist/utils/snowfall/physics.js +0 -233
  42. package/dist/utils/snowfall/physics.js.map +0 -1
  43. package/dist/utils/snowfall/physics.mjs +0 -206
  44. package/dist/utils/snowfall/physics.mjs.map +0 -1
  45. package/dist/utils/snowfall/types.d.mts +0 -28
  46. package/dist/utils/snowfall/types.d.ts +0 -28
  47. package/dist/utils/snowfall/types.js +0 -17
  48. package/dist/utils/snowfall/types.js.map +0 -1
  49. package/dist/utils/snowfall/types.mjs +0 -1
  50. package/dist/utils/snowfall/types.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/SnowfallProvider.tsx"],"sourcesContent":["'use client';\n\nimport React, { createContext, useContext, useState, ReactNode } from 'react';\n\nexport interface PhysicsConfig {\n MAX_FLAKES: number;\n MELT_SPEED: number;\n WIND_STRENGTH: number;\n ACCUMULATION: {\n SIDE_RATE: number;\n TOP_CARD_RATE: number;\n TOP_HEADER_RATE: number;\n };\n MAX_DEPTH: {\n CARD_TOP: number;\n HEADER_TOP: number;\n CARD_SIDE: number;\n };\n}\n\nexport const DEFAULT_PHYSICS: PhysicsConfig = {\n MAX_FLAKES: 500,\n MELT_SPEED: 0.00005,\n WIND_STRENGTH: 0.8,\n ACCUMULATION: {\n SIDE_RATE: 1.2,\n TOP_CARD_RATE: 1.9,\n TOP_HEADER_RATE: 1.2,\n },\n MAX_DEPTH: {\n CARD_TOP: 50,\n HEADER_TOP: 25,\n CARD_SIDE: 8,\n }\n};\n\ninterface SnowfallContextType {\n isEnabled: boolean;\n toggleSnow: () => void;\n physicsConfig: PhysicsConfig;\n updatePhysicsConfig: (config: Partial<PhysicsConfig>) => void;\n resetPhysics: () => void;\n}\n\nconst SnowfallContext = createContext<SnowfallContextType | undefined>(undefined);\n\nexport function SnowfallProvider({ children }: { children: ReactNode }) {\n const [isEnabled, setIsEnabled] = useState(true);\n const [physicsConfig, setPhysicsConfig] = useState<PhysicsConfig>(DEFAULT_PHYSICS);\n\n const toggleSnow = () => {\n setIsEnabled((prev) => !prev);\n };\n\n const updatePhysicsConfig = (config: Partial<PhysicsConfig>) => {\n setPhysicsConfig((prev) => ({\n ...prev,\n ...config,\n ACCUMULATION: {\n ...prev.ACCUMULATION,\n ...(config.ACCUMULATION || {}),\n },\n MAX_DEPTH: {\n ...prev.MAX_DEPTH,\n ...(config.MAX_DEPTH || {}),\n },\n }));\n };\n\n const resetPhysics = () => {\n setPhysicsConfig(DEFAULT_PHYSICS);\n };\n\n return (\n <SnowfallContext.Provider value={{\n isEnabled,\n toggleSnow,\n physicsConfig,\n updatePhysicsConfig,\n resetPhysics\n }}>\n {children}\n </SnowfallContext.Provider>\n );\n}\n\nexport function useSnowfall() {\n const context = useContext(SnowfallContext);\n if (context === undefined) {\n throw new Error('useSnowfall must be used within a SnowfallProvider');\n }\n return context;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0EQ;AAxER,mBAAsE;AAkB/D,MAAM,kBAAiC;AAAA,EAC1C,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,cAAc;AAAA,IACV,WAAW;AAAA,IACX,eAAe;AAAA,IACf,iBAAiB;AAAA,EACrB;AAAA,EACA,WAAW;AAAA,IACP,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,EACf;AACJ;AAUA,MAAM,sBAAkB,4BAA+C,MAAS;AAEzE,SAAS,iBAAiB,EAAE,SAAS,GAA4B;AACpE,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAwB,eAAe;AAEjF,QAAM,aAAa,MAAM;AACrB,iBAAa,CAAC,SAAS,CAAC,IAAI;AAAA,EAChC;AAEA,QAAM,sBAAsB,CAAC,WAAmC;AAC5D,qBAAiB,CAAC,UAAU;AAAA,MACxB,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc;AAAA,QACV,GAAG,KAAK;AAAA,QACR,GAAI,OAAO,gBAAgB,CAAC;AAAA,MAChC;AAAA,MACA,WAAW;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAI,OAAO,aAAa,CAAC;AAAA,MAC7B;AAAA,IACJ,EAAE;AAAA,EACN;AAEA,QAAM,eAAe,MAAM;AACvB,qBAAiB,eAAe;AAAA,EACpC;AAEA,SACI,4CAAC,gBAAgB,UAAhB,EAAyB,OAAO;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,GACK,UACL;AAER;AAEO,SAAS,cAAc;AAC1B,QAAM,cAAU,yBAAW,eAAe;AAC1C,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,SAAO;AACX;","names":[]}
@@ -1,63 +0,0 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { createContext, useContext, useState } from "react";
4
- const DEFAULT_PHYSICS = {
5
- MAX_FLAKES: 500,
6
- MELT_SPEED: 5e-5,
7
- WIND_STRENGTH: 0.8,
8
- ACCUMULATION: {
9
- SIDE_RATE: 1.2,
10
- TOP_CARD_RATE: 1.9,
11
- TOP_HEADER_RATE: 1.2
12
- },
13
- MAX_DEPTH: {
14
- CARD_TOP: 50,
15
- HEADER_TOP: 25,
16
- CARD_SIDE: 8
17
- }
18
- };
19
- const SnowfallContext = createContext(void 0);
20
- function SnowfallProvider({ children }) {
21
- const [isEnabled, setIsEnabled] = useState(true);
22
- const [physicsConfig, setPhysicsConfig] = useState(DEFAULT_PHYSICS);
23
- const toggleSnow = () => {
24
- setIsEnabled((prev) => !prev);
25
- };
26
- const updatePhysicsConfig = (config) => {
27
- setPhysicsConfig((prev) => ({
28
- ...prev,
29
- ...config,
30
- ACCUMULATION: {
31
- ...prev.ACCUMULATION,
32
- ...config.ACCUMULATION || {}
33
- },
34
- MAX_DEPTH: {
35
- ...prev.MAX_DEPTH,
36
- ...config.MAX_DEPTH || {}
37
- }
38
- }));
39
- };
40
- const resetPhysics = () => {
41
- setPhysicsConfig(DEFAULT_PHYSICS);
42
- };
43
- return /* @__PURE__ */ jsx(SnowfallContext.Provider, { value: {
44
- isEnabled,
45
- toggleSnow,
46
- physicsConfig,
47
- updatePhysicsConfig,
48
- resetPhysics
49
- }, children });
50
- }
51
- function useSnowfall() {
52
- const context = useContext(SnowfallContext);
53
- if (context === void 0) {
54
- throw new Error("useSnowfall must be used within a SnowfallProvider");
55
- }
56
- return context;
57
- }
58
- export {
59
- DEFAULT_PHYSICS,
60
- SnowfallProvider,
61
- useSnowfall
62
- };
63
- //# sourceMappingURL=SnowfallProvider.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/SnowfallProvider.tsx"],"sourcesContent":["'use client';\n\nimport React, { createContext, useContext, useState, ReactNode } from 'react';\n\nexport interface PhysicsConfig {\n MAX_FLAKES: number;\n MELT_SPEED: number;\n WIND_STRENGTH: number;\n ACCUMULATION: {\n SIDE_RATE: number;\n TOP_CARD_RATE: number;\n TOP_HEADER_RATE: number;\n };\n MAX_DEPTH: {\n CARD_TOP: number;\n HEADER_TOP: number;\n CARD_SIDE: number;\n };\n}\n\nexport const DEFAULT_PHYSICS: PhysicsConfig = {\n MAX_FLAKES: 500,\n MELT_SPEED: 0.00005,\n WIND_STRENGTH: 0.8,\n ACCUMULATION: {\n SIDE_RATE: 1.2,\n TOP_CARD_RATE: 1.9,\n TOP_HEADER_RATE: 1.2,\n },\n MAX_DEPTH: {\n CARD_TOP: 50,\n HEADER_TOP: 25,\n CARD_SIDE: 8,\n }\n};\n\ninterface SnowfallContextType {\n isEnabled: boolean;\n toggleSnow: () => void;\n physicsConfig: PhysicsConfig;\n updatePhysicsConfig: (config: Partial<PhysicsConfig>) => void;\n resetPhysics: () => void;\n}\n\nconst SnowfallContext = createContext<SnowfallContextType | undefined>(undefined);\n\nexport function SnowfallProvider({ children }: { children: ReactNode }) {\n const [isEnabled, setIsEnabled] = useState(true);\n const [physicsConfig, setPhysicsConfig] = useState<PhysicsConfig>(DEFAULT_PHYSICS);\n\n const toggleSnow = () => {\n setIsEnabled((prev) => !prev);\n };\n\n const updatePhysicsConfig = (config: Partial<PhysicsConfig>) => {\n setPhysicsConfig((prev) => ({\n ...prev,\n ...config,\n ACCUMULATION: {\n ...prev.ACCUMULATION,\n ...(config.ACCUMULATION || {}),\n },\n MAX_DEPTH: {\n ...prev.MAX_DEPTH,\n ...(config.MAX_DEPTH || {}),\n },\n }));\n };\n\n const resetPhysics = () => {\n setPhysicsConfig(DEFAULT_PHYSICS);\n };\n\n return (\n <SnowfallContext.Provider value={{\n isEnabled,\n toggleSnow,\n physicsConfig,\n updatePhysicsConfig,\n resetPhysics\n }}>\n {children}\n </SnowfallContext.Provider>\n );\n}\n\nexport function useSnowfall() {\n const context = useContext(SnowfallContext);\n if (context === undefined) {\n throw new Error('useSnowfall must be used within a SnowfallProvider');\n }\n return context;\n}\n"],"mappings":";AA0EQ;AAxER,SAAgB,eAAe,YAAY,gBAA2B;AAkB/D,MAAM,kBAAiC;AAAA,EAC1C,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,cAAc;AAAA,IACV,WAAW;AAAA,IACX,eAAe;AAAA,IACf,iBAAiB;AAAA,EACrB;AAAA,EACA,WAAW;AAAA,IACP,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,EACf;AACJ;AAUA,MAAM,kBAAkB,cAA+C,MAAS;AAEzE,SAAS,iBAAiB,EAAE,SAAS,GAA4B;AACpE,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,eAAe;AAEjF,QAAM,aAAa,MAAM;AACrB,iBAAa,CAAC,SAAS,CAAC,IAAI;AAAA,EAChC;AAEA,QAAM,sBAAsB,CAAC,WAAmC;AAC5D,qBAAiB,CAAC,UAAU;AAAA,MACxB,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc;AAAA,QACV,GAAG,KAAK;AAAA,QACR,GAAI,OAAO,gBAAgB,CAAC;AAAA,MAChC;AAAA,MACA,WAAW;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAI,OAAO,aAAa,CAAC;AAAA,MAC7B;AAAA,IACJ,EAAE;AAAA,EACN;AAEA,QAAM,eAAe,MAAM;AACvB,qBAAiB,eAAe;AAAA,EACpC;AAEA,SACI,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,GACK,UACL;AAER;AAEO,SAAS,cAAc;AAC1B,QAAM,UAAU,WAAW,eAAe;AAC1C,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,SAAO;AACX;","names":[]}
@@ -1,10 +0,0 @@
1
- declare const ATTR_SNOWFALL = "data-snowfall";
2
- declare const VAL_IGNORE = "ignore";
3
- declare const VAL_TOP = "top";
4
- declare const VAL_BOTTOM = "bottom";
5
- declare const TAG_HEADER = "header";
6
- declare const TAG_FOOTER = "footer";
7
- declare const ROLE_BANNER = "banner";
8
- declare const ROLE_CONTENTINFO = "contentinfo";
9
-
10
- export { ATTR_SNOWFALL, ROLE_BANNER, ROLE_CONTENTINFO, TAG_FOOTER, TAG_HEADER, VAL_BOTTOM, VAL_IGNORE, VAL_TOP };
@@ -1,10 +0,0 @@
1
- declare const ATTR_SNOWFALL = "data-snowfall";
2
- declare const VAL_IGNORE = "ignore";
3
- declare const VAL_TOP = "top";
4
- declare const VAL_BOTTOM = "bottom";
5
- declare const TAG_HEADER = "header";
6
- declare const TAG_FOOTER = "footer";
7
- declare const ROLE_BANNER = "banner";
8
- declare const ROLE_CONTENTINFO = "contentinfo";
9
-
10
- export { ATTR_SNOWFALL, ROLE_BANNER, ROLE_CONTENTINFO, TAG_FOOTER, TAG_HEADER, VAL_BOTTOM, VAL_IGNORE, VAL_TOP };
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var constants_exports = {};
20
- __export(constants_exports, {
21
- ATTR_SNOWFALL: () => ATTR_SNOWFALL,
22
- ROLE_BANNER: () => ROLE_BANNER,
23
- ROLE_CONTENTINFO: () => ROLE_CONTENTINFO,
24
- TAG_FOOTER: () => TAG_FOOTER,
25
- TAG_HEADER: () => TAG_HEADER,
26
- VAL_BOTTOM: () => VAL_BOTTOM,
27
- VAL_IGNORE: () => VAL_IGNORE,
28
- VAL_TOP: () => VAL_TOP
29
- });
30
- module.exports = __toCommonJS(constants_exports);
31
- const ATTR_SNOWFALL = "data-snowfall";
32
- const VAL_IGNORE = "ignore";
33
- const VAL_TOP = "top";
34
- const VAL_BOTTOM = "bottom";
35
- const TAG_HEADER = "header";
36
- const TAG_FOOTER = "footer";
37
- const ROLE_BANNER = "banner";
38
- const ROLE_CONTENTINFO = "contentinfo";
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- ATTR_SNOWFALL,
42
- ROLE_BANNER,
43
- ROLE_CONTENTINFO,
44
- TAG_FOOTER,
45
- TAG_HEADER,
46
- VAL_BOTTOM,
47
- VAL_IGNORE,
48
- VAL_TOP
49
- });
50
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/snowfall/constants.ts"],"sourcesContent":["export const ATTR_SNOWFALL = 'data-snowfall';\n\nexport const VAL_IGNORE = 'ignore';\nexport const VAL_TOP = 'top';\nexport const VAL_BOTTOM = 'bottom';\n\nexport const TAG_HEADER = 'header';\nexport const TAG_FOOTER = 'footer';\n\nexport const ROLE_BANNER = 'banner';\nexport const ROLE_CONTENTINFO = 'contentinfo';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,gBAAgB;AAEtB,MAAM,aAAa;AACnB,MAAM,UAAU;AAChB,MAAM,aAAa;AAEnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,cAAc;AACpB,MAAM,mBAAmB;","names":[]}
@@ -1,19 +0,0 @@
1
- const ATTR_SNOWFALL = "data-snowfall";
2
- const VAL_IGNORE = "ignore";
3
- const VAL_TOP = "top";
4
- const VAL_BOTTOM = "bottom";
5
- const TAG_HEADER = "header";
6
- const TAG_FOOTER = "footer";
7
- const ROLE_BANNER = "banner";
8
- const ROLE_CONTENTINFO = "contentinfo";
9
- export {
10
- ATTR_SNOWFALL,
11
- ROLE_BANNER,
12
- ROLE_CONTENTINFO,
13
- TAG_FOOTER,
14
- TAG_HEADER,
15
- VAL_BOTTOM,
16
- VAL_IGNORE,
17
- VAL_TOP
18
- };
19
- //# sourceMappingURL=constants.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/snowfall/constants.ts"],"sourcesContent":["export const ATTR_SNOWFALL = 'data-snowfall';\n\nexport const VAL_IGNORE = 'ignore';\nexport const VAL_TOP = 'top';\nexport const VAL_BOTTOM = 'bottom';\n\nexport const TAG_HEADER = 'header';\nexport const TAG_FOOTER = 'footer';\n\nexport const ROLE_BANNER = 'banner';\nexport const ROLE_CONTENTINFO = 'contentinfo';\n"],"mappings":"AAAO,MAAM,gBAAgB;AAEtB,MAAM,aAAa;AACnB,MAAM,UAAU;AAChB,MAAM,aAAa;AAEnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,cAAc;AACpB,MAAM,mBAAmB;","names":[]}
@@ -1,11 +0,0 @@
1
- import { SnowfallSurface, SnowAccumulation, ElementSurface } from './types.mjs';
2
-
3
- declare const getElementType: (el: Element) => SnowfallSurface;
4
- declare const getAccumulationSurfaces: () => {
5
- el: Element;
6
- type: SnowfallSurface;
7
- isFixed: boolean;
8
- }[];
9
- declare const getElementRects: (accumulationMap: Map<Element, SnowAccumulation>) => ElementSurface[];
10
-
11
- export { getAccumulationSurfaces, getElementRects, getElementType };
@@ -1,11 +0,0 @@
1
- import { SnowfallSurface, SnowAccumulation, ElementSurface } from './types.js';
2
-
3
- declare const getElementType: (el: Element) => SnowfallSurface;
4
- declare const getAccumulationSurfaces: () => {
5
- el: Element;
6
- type: SnowfallSurface;
7
- isFixed: boolean;
8
- }[];
9
- declare const getElementRects: (accumulationMap: Map<Element, SnowAccumulation>) => ElementSurface[];
10
-
11
- export { getAccumulationSurfaces, getElementRects, getElementType };
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var dom_exports = {};
20
- __export(dom_exports, {
21
- getAccumulationSurfaces: () => getAccumulationSurfaces,
22
- getElementRects: () => getElementRects,
23
- getElementType: () => getElementType
24
- });
25
- module.exports = __toCommonJS(dom_exports);
26
- var import_constants = require("./constants");
27
- const BOTTOM_TAGS = [import_constants.TAG_HEADER, import_constants.TAG_FOOTER];
28
- const BOTTOM_ROLES = [import_constants.ROLE_BANNER, import_constants.ROLE_CONTENTINFO];
29
- const AUTO_DETECT_TAGS = ["header", "footer", "article", "section", "aside", "nav"];
30
- const AUTO_DETECT_ROLES = ['[role="banner"]', '[role="contentinfo"]', '[role="main"]'];
31
- const AUTO_DETECT_CLASSES = [
32
- ".card",
33
- '[class*="card"]',
34
- '[class*="Card"]',
35
- '[class*="bg-"]',
36
- '[class*="shadow-"]',
37
- '[class*="rounded-"]'
38
- ];
39
- const getElementType = (el) => {
40
- const tagName = el.tagName.toLowerCase();
41
- if (BOTTOM_TAGS.includes(tagName)) return import_constants.VAL_BOTTOM;
42
- const role = el.getAttribute("role");
43
- if (role && BOTTOM_ROLES.includes(role)) return import_constants.VAL_BOTTOM;
44
- return import_constants.VAL_TOP;
45
- };
46
- const shouldAccumulate = (el) => {
47
- if (el.getAttribute(import_constants.ATTR_SNOWFALL) === import_constants.VAL_IGNORE) return false;
48
- if (el.hasAttribute(import_constants.ATTR_SNOWFALL)) return true;
49
- const styles = window.getComputedStyle(el);
50
- const rect = el.getBoundingClientRect();
51
- const isVisible = styles.display !== "none" && styles.visibility !== "hidden" && parseFloat(styles.opacity) > 0.1;
52
- if (!isVisible) return false;
53
- const bgColor = styles.backgroundColor;
54
- const hasBackground = bgColor !== "rgba(0, 0, 0, 0)" && bgColor !== "transparent";
55
- const hasBorder = parseFloat(styles.borderWidth) > 0 || styles.borderStyle !== "none";
56
- const hasBoxShadow = styles.boxShadow !== "none";
57
- const hasBorderRadius = parseFloat(styles.borderRadius) > 0;
58
- return hasBackground || hasBorder || hasBoxShadow || hasBorderRadius;
59
- };
60
- const getAccumulationSurfaces = () => {
61
- const surfaces = [];
62
- const seen = /* @__PURE__ */ new Set();
63
- const candidates = document.querySelectorAll(
64
- [
65
- `[${import_constants.ATTR_SNOWFALL}]`,
66
- ...AUTO_DETECT_TAGS,
67
- ...AUTO_DETECT_ROLES,
68
- ...AUTO_DETECT_CLASSES
69
- ].join(", ")
70
- );
71
- candidates.forEach((el) => {
72
- if (seen.has(el)) return;
73
- const rect = el.getBoundingClientRect();
74
- const manualOverride = el.getAttribute(import_constants.ATTR_SNOWFALL);
75
- if (manualOverride === import_constants.VAL_IGNORE) return;
76
- const isManuallyIncluded = manualOverride !== null;
77
- const styles = window.getComputedStyle(el);
78
- const isVisible = styles.display !== "none" && styles.visibility !== "hidden" && parseFloat(styles.opacity) > 0.1;
79
- if (!isVisible && !isManuallyIncluded) return;
80
- const hasSize = rect.width >= 100 && rect.height >= 50;
81
- if (!hasSize && !isManuallyIncluded) return;
82
- const isFullPageWrapper = rect.top <= 10 && rect.height >= window.innerHeight * 0.9;
83
- const isBottomTag = BOTTOM_TAGS.includes(el.tagName.toLowerCase());
84
- const isBottomRole = BOTTOM_ROLES.includes(el.getAttribute("role") || "");
85
- const isBottomSurface = isBottomTag || isBottomRole || manualOverride === import_constants.VAL_BOTTOM;
86
- if (isFullPageWrapper && !isBottomSurface && !isManuallyIncluded) return;
87
- const isFixed = styles.position === "fixed" || styles.position === "sticky";
88
- if (shouldAccumulate(el)) {
89
- let type = getElementType(el);
90
- if (manualOverride === import_constants.VAL_BOTTOM) {
91
- type = import_constants.VAL_BOTTOM;
92
- } else if (manualOverride === import_constants.VAL_TOP) {
93
- type = import_constants.VAL_TOP;
94
- }
95
- surfaces.push({ el, type, isFixed });
96
- seen.add(el);
97
- }
98
- });
99
- console.log(`[Snowfall] Auto-detection found ${surfaces.length} surfaces`);
100
- return surfaces;
101
- };
102
- const getElementRects = (accumulationMap) => {
103
- const elementRects = [];
104
- for (const [el, acc] of accumulationMap.entries()) {
105
- if (!el.isConnected) continue;
106
- const rect = el.getBoundingClientRect();
107
- const absoluteRect = {
108
- left: rect.left + window.scrollX,
109
- right: rect.right + window.scrollX,
110
- top: rect.top + window.scrollY,
111
- bottom: rect.bottom + window.scrollY,
112
- width: rect.width,
113
- height: rect.height,
114
- x: rect.x,
115
- // Note: these are strictly viewport relative in DOMRect usually,
116
- // but we just need consistent absolute coords for physics
117
- y: rect.y,
118
- toJSON: rect.toJSON
119
- };
120
- elementRects.push({ el, rect: absoluteRect, acc });
121
- }
122
- return elementRects;
123
- };
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- getAccumulationSurfaces,
127
- getElementRects,
128
- getElementType
129
- });
130
- //# sourceMappingURL=dom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/snowfall/dom.ts"],"sourcesContent":["import { SnowAccumulation, ElementSurface, SnowfallSurface } from './types';\nimport {\n ATTR_SNOWFALL, VAL_IGNORE, VAL_TOP, VAL_BOTTOM,\n TAG_HEADER, TAG_FOOTER, ROLE_BANNER, ROLE_CONTENTINFO\n} from './constants';\n\nconst BOTTOM_TAGS = [TAG_HEADER, TAG_FOOTER];\nconst BOTTOM_ROLES = [ROLE_BANNER, ROLE_CONTENTINFO];\n\nconst AUTO_DETECT_TAGS = ['header', 'footer', 'article', 'section', 'aside', 'nav'];\nconst AUTO_DETECT_ROLES = ['[role=\"banner\"]', '[role=\"contentinfo\"]', '[role=\"main\"]'];\nconst AUTO_DETECT_CLASSES = [\n '.card', '[class*=\"card\"]', '[class*=\"Card\"]',\n '[class*=\"bg-\"]', '[class*=\"shadow-\"]', '[class*=\"rounded-\"]'\n];\n\nexport const getElementType = (el: Element): SnowfallSurface => {\n const tagName = el.tagName.toLowerCase();\n if (BOTTOM_TAGS.includes(tagName)) return VAL_BOTTOM;\n\n const role = el.getAttribute('role');\n if (role && BOTTOM_ROLES.includes(role)) return VAL_BOTTOM;\n\n return VAL_TOP;\n};\n\nconst shouldAccumulate = (el: Element): boolean => {\n // Explicit opt-out\n if (el.getAttribute(ATTR_SNOWFALL) === VAL_IGNORE) return false;\n\n // Explicit opt-in\n if (el.hasAttribute(ATTR_SNOWFALL)) return true;\n\n // Heuristics\n const styles = window.getComputedStyle(el);\n const rect = el.getBoundingClientRect();\n\n const isVisible = styles.display !== 'none' &&\n styles.visibility !== 'hidden' &&\n parseFloat(styles.opacity) > 0.1;\n if (!isVisible) return false;\n\n // Check for visual prominence\n const bgColor = styles.backgroundColor;\n const hasBackground = bgColor !== 'rgba(0, 0, 0, 0)' && bgColor !== 'transparent';\n const hasBorder = parseFloat(styles.borderWidth) > 0 || styles.borderStyle !== 'none';\n const hasBoxShadow = styles.boxShadow !== 'none';\n const hasBorderRadius = parseFloat(styles.borderRadius) > 0;\n\n return hasBackground || hasBorder || hasBoxShadow || hasBorderRadius;\n};\n\nexport const getAccumulationSurfaces = (): { el: Element; type: SnowfallSurface; isFixed: boolean }[] => {\n const surfaces: { el: Element; type: SnowfallSurface; isFixed: boolean }[] = [];\n const seen = new Set<Element>();\n\n const candidates = document.querySelectorAll(\n [\n `[${ATTR_SNOWFALL}]`,\n ...AUTO_DETECT_TAGS,\n ...AUTO_DETECT_ROLES,\n ...AUTO_DETECT_CLASSES\n ].join(', ')\n );\n\n candidates.forEach(el => {\n if (seen.has(el)) return;\n\n const rect = el.getBoundingClientRect();\n\n // Manual override check first\n const manualOverride = el.getAttribute(ATTR_SNOWFALL);\n if (manualOverride === VAL_IGNORE) return;\n\n // If manually opted in, skip some heuristic checks but keep basic visibility/size sanity\n const isManuallyIncluded = manualOverride !== null;\n\n const styles = window.getComputedStyle(el);\n const isVisible = styles.display !== 'none' &&\n styles.visibility !== 'hidden' &&\n parseFloat(styles.opacity) > 0.1;\n\n if (!isVisible && !isManuallyIncluded) return;\n\n // Skip really small elements unless manually forced\n const hasSize = rect.width >= 100 && rect.height >= 50;\n if (!hasSize && !isManuallyIncluded) return;\n\n // HEURISTIC: Skip full-page wrappers\n const isFullPageWrapper = rect.top <= 10 && rect.height >= window.innerHeight * 0.9;\n\n\n const isBottomTag = BOTTOM_TAGS.includes(el.tagName.toLowerCase());\n const isBottomRole = BOTTOM_ROLES.includes(el.getAttribute('role') || '');\n const isBottomSurface = isBottomTag || isBottomRole ||\n manualOverride === VAL_BOTTOM;\n\n if (isFullPageWrapper && !isBottomSurface && !isManuallyIncluded) return;\n\n const isFixed = styles.position === 'fixed' || styles.position === 'sticky';\n\n if (shouldAccumulate(el)) {\n // Determine type: manual override takes precedence\n let type: SnowfallSurface = getElementType(el);\n\n if (manualOverride === VAL_BOTTOM) {\n type = VAL_BOTTOM;\n } else if (manualOverride === VAL_TOP) {\n type = VAL_TOP;\n }\n\n surfaces.push({ el, type, isFixed });\n seen.add(el);\n }\n });\n\n console.log(`[Snowfall] Auto-detection found ${surfaces.length} surfaces`);\n return surfaces;\n};\n\nexport const getElementRects = (accumulationMap: Map<Element, SnowAccumulation>): ElementSurface[] => {\n const elementRects: ElementSurface[] = [];\n\n for (const [el, acc] of accumulationMap.entries()) {\n if (!el.isConnected) continue;\n const rect = el.getBoundingClientRect();\n // Convert viewport coordinates to absolute page coordinates\n const absoluteRect = {\n left: rect.left + window.scrollX,\n right: rect.right + window.scrollX,\n top: rect.top + window.scrollY,\n bottom: rect.bottom + window.scrollY,\n width: rect.width,\n height: rect.height,\n x: rect.x, // Note: these are strictly viewport relative in DOMRect usually, \n // but we just need consistent absolute coords for physics\n y: rect.y,\n toJSON: rect.toJSON\n };\n // We cast because we constructed a compatible object, though strictly DOMRect has readonly properties\n elementRects.push({ el, rect: absoluteRect as unknown as DOMRect, acc });\n }\n return elementRects;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAGO;AAEP,MAAM,cAAc,CAAC,6BAAY,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,gBAAgB,QAAQ,GAAG;AAC/C,QAAI,CAAC,GAAG,YAAa;AACrB,UAAM,OAAO,GAAG,sBAAsB;AAEtC,UAAM,eAAe;AAAA,MACjB,MAAM,KAAK,OAAO,OAAO;AAAA,MACzB,OAAO,KAAK,QAAQ,OAAO;AAAA,MAC3B,KAAK,KAAK,MAAM,OAAO;AAAA,MACvB,QAAQ,KAAK,SAAS,OAAO;AAAA,MAC7B,OAAO,KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,MACb,GAAG,KAAK;AAAA;AAAA;AAAA,MAER,GAAG,KAAK;AAAA,MACR,QAAQ,KAAK;AAAA,IACjB;AAEA,iBAAa,KAAK,EAAE,IAAI,MAAM,cAAoC,IAAI,CAAC;AAAA,EAC3E;AACA,SAAO;AACX;","names":[]}
@@ -1,113 +0,0 @@
1
- import {
2
- ATTR_SNOWFALL,
3
- VAL_IGNORE,
4
- VAL_TOP,
5
- VAL_BOTTOM,
6
- TAG_HEADER,
7
- TAG_FOOTER,
8
- ROLE_BANNER,
9
- ROLE_CONTENTINFO
10
- } from "./constants";
11
- const BOTTOM_TAGS = [TAG_HEADER, TAG_FOOTER];
12
- const BOTTOM_ROLES = [ROLE_BANNER, ROLE_CONTENTINFO];
13
- const AUTO_DETECT_TAGS = ["header", "footer", "article", "section", "aside", "nav"];
14
- const AUTO_DETECT_ROLES = ['[role="banner"]', '[role="contentinfo"]', '[role="main"]'];
15
- const AUTO_DETECT_CLASSES = [
16
- ".card",
17
- '[class*="card"]',
18
- '[class*="Card"]',
19
- '[class*="bg-"]',
20
- '[class*="shadow-"]',
21
- '[class*="rounded-"]'
22
- ];
23
- const getElementType = (el) => {
24
- const tagName = el.tagName.toLowerCase();
25
- if (BOTTOM_TAGS.includes(tagName)) return VAL_BOTTOM;
26
- const role = el.getAttribute("role");
27
- if (role && BOTTOM_ROLES.includes(role)) return VAL_BOTTOM;
28
- return VAL_TOP;
29
- };
30
- const shouldAccumulate = (el) => {
31
- if (el.getAttribute(ATTR_SNOWFALL) === VAL_IGNORE) return false;
32
- if (el.hasAttribute(ATTR_SNOWFALL)) return true;
33
- const styles = window.getComputedStyle(el);
34
- const rect = el.getBoundingClientRect();
35
- const isVisible = styles.display !== "none" && styles.visibility !== "hidden" && parseFloat(styles.opacity) > 0.1;
36
- if (!isVisible) return false;
37
- const bgColor = styles.backgroundColor;
38
- const hasBackground = bgColor !== "rgba(0, 0, 0, 0)" && bgColor !== "transparent";
39
- const hasBorder = parseFloat(styles.borderWidth) > 0 || styles.borderStyle !== "none";
40
- const hasBoxShadow = styles.boxShadow !== "none";
41
- const hasBorderRadius = parseFloat(styles.borderRadius) > 0;
42
- return hasBackground || hasBorder || hasBoxShadow || hasBorderRadius;
43
- };
44
- const getAccumulationSurfaces = () => {
45
- const surfaces = [];
46
- const seen = /* @__PURE__ */ new Set();
47
- const candidates = document.querySelectorAll(
48
- [
49
- `[${ATTR_SNOWFALL}]`,
50
- ...AUTO_DETECT_TAGS,
51
- ...AUTO_DETECT_ROLES,
52
- ...AUTO_DETECT_CLASSES
53
- ].join(", ")
54
- );
55
- candidates.forEach((el) => {
56
- if (seen.has(el)) return;
57
- const rect = el.getBoundingClientRect();
58
- const manualOverride = el.getAttribute(ATTR_SNOWFALL);
59
- if (manualOverride === VAL_IGNORE) return;
60
- const isManuallyIncluded = manualOverride !== null;
61
- const styles = window.getComputedStyle(el);
62
- const isVisible = styles.display !== "none" && styles.visibility !== "hidden" && parseFloat(styles.opacity) > 0.1;
63
- if (!isVisible && !isManuallyIncluded) return;
64
- const hasSize = rect.width >= 100 && rect.height >= 50;
65
- if (!hasSize && !isManuallyIncluded) return;
66
- const isFullPageWrapper = rect.top <= 10 && rect.height >= window.innerHeight * 0.9;
67
- const isBottomTag = BOTTOM_TAGS.includes(el.tagName.toLowerCase());
68
- const isBottomRole = BOTTOM_ROLES.includes(el.getAttribute("role") || "");
69
- const isBottomSurface = isBottomTag || isBottomRole || manualOverride === VAL_BOTTOM;
70
- if (isFullPageWrapper && !isBottomSurface && !isManuallyIncluded) return;
71
- const isFixed = styles.position === "fixed" || styles.position === "sticky";
72
- if (shouldAccumulate(el)) {
73
- let type = getElementType(el);
74
- if (manualOverride === VAL_BOTTOM) {
75
- type = VAL_BOTTOM;
76
- } else if (manualOverride === VAL_TOP) {
77
- type = VAL_TOP;
78
- }
79
- surfaces.push({ el, type, isFixed });
80
- seen.add(el);
81
- }
82
- });
83
- console.log(`[Snowfall] Auto-detection found ${surfaces.length} surfaces`);
84
- return surfaces;
85
- };
86
- const getElementRects = (accumulationMap) => {
87
- const elementRects = [];
88
- for (const [el, acc] of accumulationMap.entries()) {
89
- if (!el.isConnected) continue;
90
- const rect = el.getBoundingClientRect();
91
- const absoluteRect = {
92
- left: rect.left + window.scrollX,
93
- right: rect.right + window.scrollX,
94
- top: rect.top + window.scrollY,
95
- bottom: rect.bottom + window.scrollY,
96
- width: rect.width,
97
- height: rect.height,
98
- x: rect.x,
99
- // Note: these are strictly viewport relative in DOMRect usually,
100
- // but we just need consistent absolute coords for physics
101
- y: rect.y,
102
- toJSON: rect.toJSON
103
- };
104
- elementRects.push({ el, rect: absoluteRect, acc });
105
- }
106
- return elementRects;
107
- };
108
- export {
109
- getAccumulationSurfaces,
110
- getElementRects,
111
- getElementType
112
- };
113
- //# sourceMappingURL=dom.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/snowfall/dom.ts"],"sourcesContent":["import { SnowAccumulation, ElementSurface, SnowfallSurface } from './types';\nimport {\n ATTR_SNOWFALL, VAL_IGNORE, VAL_TOP, VAL_BOTTOM,\n TAG_HEADER, TAG_FOOTER, ROLE_BANNER, ROLE_CONTENTINFO\n} from './constants';\n\nconst BOTTOM_TAGS = [TAG_HEADER, TAG_FOOTER];\nconst BOTTOM_ROLES = [ROLE_BANNER, ROLE_CONTENTINFO];\n\nconst AUTO_DETECT_TAGS = ['header', 'footer', 'article', 'section', 'aside', 'nav'];\nconst AUTO_DETECT_ROLES = ['[role=\"banner\"]', '[role=\"contentinfo\"]', '[role=\"main\"]'];\nconst AUTO_DETECT_CLASSES = [\n '.card', '[class*=\"card\"]', '[class*=\"Card\"]',\n '[class*=\"bg-\"]', '[class*=\"shadow-\"]', '[class*=\"rounded-\"]'\n];\n\nexport const getElementType = (el: Element): SnowfallSurface => {\n const tagName = el.tagName.toLowerCase();\n if (BOTTOM_TAGS.includes(tagName)) return VAL_BOTTOM;\n\n const role = el.getAttribute('role');\n if (role && BOTTOM_ROLES.includes(role)) return VAL_BOTTOM;\n\n return VAL_TOP;\n};\n\nconst shouldAccumulate = (el: Element): boolean => {\n // Explicit opt-out\n if (el.getAttribute(ATTR_SNOWFALL) === VAL_IGNORE) return false;\n\n // Explicit opt-in\n if (el.hasAttribute(ATTR_SNOWFALL)) return true;\n\n // Heuristics\n const styles = window.getComputedStyle(el);\n const rect = el.getBoundingClientRect();\n\n const isVisible = styles.display !== 'none' &&\n styles.visibility !== 'hidden' &&\n parseFloat(styles.opacity) > 0.1;\n if (!isVisible) return false;\n\n // Check for visual prominence\n const bgColor = styles.backgroundColor;\n const hasBackground = bgColor !== 'rgba(0, 0, 0, 0)' && bgColor !== 'transparent';\n const hasBorder = parseFloat(styles.borderWidth) > 0 || styles.borderStyle !== 'none';\n const hasBoxShadow = styles.boxShadow !== 'none';\n const hasBorderRadius = parseFloat(styles.borderRadius) > 0;\n\n return hasBackground || hasBorder || hasBoxShadow || hasBorderRadius;\n};\n\nexport const getAccumulationSurfaces = (): { el: Element; type: SnowfallSurface; isFixed: boolean }[] => {\n const surfaces: { el: Element; type: SnowfallSurface; isFixed: boolean }[] = [];\n const seen = new Set<Element>();\n\n const candidates = document.querySelectorAll(\n [\n `[${ATTR_SNOWFALL}]`,\n ...AUTO_DETECT_TAGS,\n ...AUTO_DETECT_ROLES,\n ...AUTO_DETECT_CLASSES\n ].join(', ')\n );\n\n candidates.forEach(el => {\n if (seen.has(el)) return;\n\n const rect = el.getBoundingClientRect();\n\n // Manual override check first\n const manualOverride = el.getAttribute(ATTR_SNOWFALL);\n if (manualOverride === VAL_IGNORE) return;\n\n // If manually opted in, skip some heuristic checks but keep basic visibility/size sanity\n const isManuallyIncluded = manualOverride !== null;\n\n const styles = window.getComputedStyle(el);\n const isVisible = styles.display !== 'none' &&\n styles.visibility !== 'hidden' &&\n parseFloat(styles.opacity) > 0.1;\n\n if (!isVisible && !isManuallyIncluded) return;\n\n // Skip really small elements unless manually forced\n const hasSize = rect.width >= 100 && rect.height >= 50;\n if (!hasSize && !isManuallyIncluded) return;\n\n // HEURISTIC: Skip full-page wrappers\n const isFullPageWrapper = rect.top <= 10 && rect.height >= window.innerHeight * 0.9;\n\n\n const isBottomTag = BOTTOM_TAGS.includes(el.tagName.toLowerCase());\n const isBottomRole = BOTTOM_ROLES.includes(el.getAttribute('role') || '');\n const isBottomSurface = isBottomTag || isBottomRole ||\n manualOverride === VAL_BOTTOM;\n\n if (isFullPageWrapper && !isBottomSurface && !isManuallyIncluded) return;\n\n const isFixed = styles.position === 'fixed' || styles.position === 'sticky';\n\n if (shouldAccumulate(el)) {\n // Determine type: manual override takes precedence\n let type: SnowfallSurface = getElementType(el);\n\n if (manualOverride === VAL_BOTTOM) {\n type = VAL_BOTTOM;\n } else if (manualOverride === VAL_TOP) {\n type = VAL_TOP;\n }\n\n surfaces.push({ el, type, isFixed });\n seen.add(el);\n }\n });\n\n console.log(`[Snowfall] Auto-detection found ${surfaces.length} surfaces`);\n return surfaces;\n};\n\nexport const getElementRects = (accumulationMap: Map<Element, SnowAccumulation>): ElementSurface[] => {\n const elementRects: ElementSurface[] = [];\n\n for (const [el, acc] of accumulationMap.entries()) {\n if (!el.isConnected) continue;\n const rect = el.getBoundingClientRect();\n // Convert viewport coordinates to absolute page coordinates\n const absoluteRect = {\n left: rect.left + window.scrollX,\n right: rect.right + window.scrollX,\n top: rect.top + window.scrollY,\n bottom: rect.bottom + window.scrollY,\n width: rect.width,\n height: rect.height,\n x: rect.x, // Note: these are strictly viewport relative in DOMRect usually, \n // but we just need consistent absolute coords for physics\n y: rect.y,\n toJSON: rect.toJSON\n };\n // We cast because we constructed a compatible object, though strictly DOMRect has readonly properties\n elementRects.push({ el, rect: absoluteRect as unknown as DOMRect, acc });\n }\n return elementRects;\n};\n"],"mappings":"AACA;AAAA,EACI;AAAA,EAAe;AAAA,EAAY;AAAA,EAAS;AAAA,EACpC;AAAA,EAAY;AAAA,EAAY;AAAA,EAAa;AAAA,OAClC;AAEP,MAAM,cAAc,CAAC,YAAY,UAAU;AAC3C,MAAM,eAAe,CAAC,aAAa,gBAAgB;AAEnD,MAAM,mBAAmB,CAAC,UAAU,UAAU,WAAW,WAAW,SAAS,KAAK;AAClF,MAAM,oBAAoB,CAAC,mBAAmB,wBAAwB,eAAe;AACrF,MAAM,sBAAsB;AAAA,EACxB;AAAA,EAAS;AAAA,EAAmB;AAAA,EAC5B;AAAA,EAAkB;AAAA,EAAsB;AAC5C;AAEO,MAAM,iBAAiB,CAAC,OAAiC;AAC5D,QAAM,UAAU,GAAG,QAAQ,YAAY;AACvC,MAAI,YAAY,SAAS,OAAO,EAAG,QAAO;AAE1C,QAAM,OAAO,GAAG,aAAa,MAAM;AACnC,MAAI,QAAQ,aAAa,SAAS,IAAI,EAAG,QAAO;AAEhD,SAAO;AACX;AAEA,MAAM,mBAAmB,CAAC,OAAyB;AAE/C,MAAI,GAAG,aAAa,aAAa,MAAM,WAAY,QAAO;AAG1D,MAAI,GAAG,aAAa,aAAa,EAAG,QAAO;AAG3C,QAAM,SAAS,OAAO,iBAAiB,EAAE;AACzC,QAAM,OAAO,GAAG,sBAAsB;AAEtC,QAAM,YAAY,OAAO,YAAY,UACjC,OAAO,eAAe,YACtB,WAAW,OAAO,OAAO,IAAI;AACjC,MAAI,CAAC,UAAW,QAAO;AAGvB,QAAM,UAAU,OAAO;AACvB,QAAM,gBAAgB,YAAY,sBAAsB,YAAY;AACpE,QAAM,YAAY,WAAW,OAAO,WAAW,IAAI,KAAK,OAAO,gBAAgB;AAC/E,QAAM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,SAAS;AACnC,eAAO;AAAA,MACX;AAEA,eAAS,KAAK,EAAE,IAAI,MAAM,QAAQ,CAAC;AACnC,WAAK,IAAI,EAAE;AAAA,IACf;AAAA,EACJ,CAAC;AAED,UAAQ,IAAI,mCAAmC,SAAS,MAAM,WAAW;AACzE,SAAO;AACX;AAEO,MAAM,kBAAkB,CAAC,oBAAsE;AAClG,QAAM,eAAiC,CAAC;AAExC,aAAW,CAAC,IAAI,GAAG,KAAK,gBAAgB,QAAQ,GAAG;AAC/C,QAAI,CAAC,GAAG,YAAa;AACrB,UAAM,OAAO,GAAG,sBAAsB;AAEtC,UAAM,eAAe;AAAA,MACjB,MAAM,KAAK,OAAO,OAAO;AAAA,MACzB,OAAO,KAAK,QAAQ,OAAO;AAAA,MAC3B,KAAK,KAAK,MAAM,OAAO;AAAA,MACvB,QAAQ,KAAK,SAAS,OAAO;AAAA,MAC7B,OAAO,KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,MACb,GAAG,KAAK;AAAA;AAAA;AAAA,MAER,GAAG,KAAK;AAAA,MACR,QAAQ,KAAK;AAAA,IACjB;AAEA,iBAAa,KAAK,EAAE,IAAI,MAAM,cAAoC,IAAI,CAAC;AAAA,EAC3E;AACA,SAAO;AACX;","names":[]}
@@ -1,7 +0,0 @@
1
- import { Snowflake, ElementSurface } from './types.mjs';
2
-
3
- declare const drawSnowflake: (ctx: CanvasRenderingContext2D, flake: Snowflake) => void;
4
- declare const drawAccumulations: (ctx: CanvasRenderingContext2D, fixedCtx: CanvasRenderingContext2D | null, elementRects: ElementSurface[]) => void;
5
- declare const drawSideAccumulations: (ctx: CanvasRenderingContext2D, fixedCtx: CanvasRenderingContext2D | null, elementRects: ElementSurface[]) => void;
6
-
7
- export { drawAccumulations, drawSideAccumulations, drawSnowflake };
@@ -1,7 +0,0 @@
1
- import { Snowflake, ElementSurface } from './types.js';
2
-
3
- declare const drawSnowflake: (ctx: CanvasRenderingContext2D, flake: Snowflake) => void;
4
- declare const drawAccumulations: (ctx: CanvasRenderingContext2D, fixedCtx: CanvasRenderingContext2D | null, elementRects: ElementSurface[]) => void;
5
- declare const drawSideAccumulations: (ctx: CanvasRenderingContext2D, fixedCtx: CanvasRenderingContext2D | null, elementRects: ElementSurface[]) => void;
6
-
7
- export { drawAccumulations, drawSideAccumulations, drawSnowflake };