@splendidlabz/utils 1.12.1 → 1.13.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.
Files changed (45) hide show
  1. package/dist/cjs/dom/font-size.cjs +1 -1
  2. package/dist/cjs/dom/index.cjs +1 -1
  3. package/dist/cjs/lib/colors.cjs +39 -0
  4. package/dist/cjs/lib/date/index.cjs +1 -1
  5. package/dist/cjs/lib/date/time.cjs +1 -1
  6. package/dist/cjs/lib/index.cjs +140 -2
  7. package/dist/cjs/lib/numbers/index.cjs +12 -1
  8. package/dist/cjs/lib/numbers/random.cjs +35 -0
  9. package/dist/cjs/lib/numbers/split-unit.cjs +35 -0
  10. package/dist/cjs/lib/style/index.cjs +35 -1
  11. package/dist/cjs/lib/style/scatter.cjs +60 -0
  12. package/dist/cjs/lib/style/to-style-string.cjs +64 -0
  13. package/dist/cjs/lib/svg/displace.cjs +94 -0
  14. package/dist/cjs/lib/svg/index.cjs +126 -0
  15. package/dist/cjs/lib/svg/noise.cjs +56 -0
  16. package/dist/esm/lib/colors.js +14 -0
  17. package/dist/esm/lib/index.js +2 -0
  18. package/dist/esm/lib/numbers/index.js +2 -10
  19. package/dist/esm/lib/numbers/random.js +10 -0
  20. package/dist/esm/lib/numbers/split-unit.js +10 -0
  21. package/dist/esm/lib/style/index.js +2 -12
  22. package/dist/esm/lib/style/scatter.js +25 -0
  23. package/dist/esm/lib/style/to-style-string.js +12 -0
  24. package/dist/esm/lib/svg/displace.js +68 -0
  25. package/dist/esm/lib/svg/index.js +2 -0
  26. package/dist/esm/lib/svg/noise.js +16 -0
  27. package/dist/types/dom/font-size.d.cts +1 -1
  28. package/dist/types/lib/colors.d.cts +12 -0
  29. package/dist/types/lib/index.d.cts +8 -3
  30. package/dist/types/lib/numbers/index.d.cts +2 -4
  31. package/dist/types/lib/numbers/random.d.cts +14 -0
  32. package/dist/types/lib/numbers/split-unit.d.cts +8 -0
  33. package/dist/types/lib/style/index.d.cts +2 -3
  34. package/dist/types/lib/style/scatter.d.cts +48 -0
  35. package/dist/types/lib/style/to-style-string.d.cts +8 -0
  36. package/dist/types/lib/svg/displace.d.cts +54 -0
  37. package/dist/types/lib/svg/index.d.cts +2 -0
  38. package/dist/types/lib/svg/noise.d.cts +24 -0
  39. package/dist/types/node/dirname.d.cts +2 -2
  40. package/dist/types/node/file.d.cts +1 -1
  41. package/dist/types/node/hash.d.cts +1 -1
  42. package/dist/types/node/pkce.d.cts +4 -4
  43. package/dist/types/node/random-string.d.cts +1 -1
  44. package/dist/types/node/uuid.d.cts +1 -1
  45. package/package.json +2 -3
@@ -0,0 +1,126 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/svg/index.js
20
+ var svg_exports = {};
21
+ __export(svg_exports, {
22
+ displacePresets: () => displacePresets,
23
+ displaceSettings: () => displaceSettings,
24
+ noiseColorMatrix: () => noiseColorMatrix,
25
+ noisePresets: () => noisePresets
26
+ });
27
+ module.exports = __toCommonJS(svg_exports);
28
+
29
+ // src/lib/svg/displace.js
30
+ var displacePresets = {
31
+ // Ink bleeding into absorbent paper. Long wavelength, small push.
32
+ "wet-ink": {
33
+ type: "fractalNoise",
34
+ frequency: 0.015,
35
+ octaves: 3,
36
+ scale: 9,
37
+ seed: 2
38
+ },
39
+ // Ink bitten into paper tooth. The edge roughens without the letterform
40
+ // moving, so this is the only preset that survives at body sizes.
41
+ letterpress: {
42
+ type: "fractalNoise",
43
+ frequency: 0.09,
44
+ octaves: 1,
45
+ scale: 2,
46
+ seed: 5
47
+ },
48
+ // Air over heat. Anisotropic so the shimmer rises instead of swimming.
49
+ // Reads as nothing unless animated.
50
+ "heat-haze": {
51
+ type: "fractalNoise",
52
+ frequency: [4e-3, 0.02],
53
+ animateTo: [6e-3, 0.03],
54
+ duration: 8,
55
+ octaves: 2,
56
+ scale: 7,
57
+ seed: 11
58
+ },
59
+ // Tracking error on worn tape. A near-infinite horizontal wavelength against
60
+ // a very short vertical one is what tears rather than blobs.
61
+ "bad-tape": {
62
+ type: "turbulence",
63
+ frequency: [8e-4, 0.06],
64
+ animateTo: [8e-4, 0.09],
65
+ duration: 2.5,
66
+ octaves: 1,
67
+ scale: 14,
68
+ seed: 3
69
+ },
70
+ // Past the shred threshold on purpose.
71
+ shred: {
72
+ type: "turbulence",
73
+ frequency: 0.055,
74
+ octaves: 2,
75
+ scale: 32,
76
+ seed: 7
77
+ }
78
+ };
79
+ var format = (f) => Array.isArray(f) ? f.join(" ") : String(f);
80
+ function displaceSettings(opts = {}) {
81
+ const base = opts.preset && displacePresets[opts.preset] || displacePresets["wet-ink"];
82
+ const frequency = opts.frequency ?? base.frequency;
83
+ const animateTo = opts.animateTo ?? base.animateTo;
84
+ return {
85
+ type: opts.type ?? base.type,
86
+ frequency: format(frequency),
87
+ animateTo: animateTo ? format(animateTo) : null,
88
+ duration: opts.duration ?? base.duration ?? 6,
89
+ octaves: opts.octaves ?? base.octaves,
90
+ scale: opts.scale ?? base.scale,
91
+ seed: opts.seed ?? base.seed
92
+ };
93
+ }
94
+
95
+ // src/lib/colors.js
96
+ function hexToRgb(hex) {
97
+ let h = hex.replace("#", "");
98
+ if (h.length === 3)
99
+ h = h.split("").map((c) => c + c).join("");
100
+ const int = parseInt(h, 16);
101
+ return {
102
+ r: +((int >> 16 & 255) / 255).toFixed(3),
103
+ g: +((int >> 8 & 255) / 255).toFixed(3),
104
+ b: +((int & 255) / 255).toFixed(3)
105
+ };
106
+ }
107
+
108
+ // src/lib/svg/noise.js
109
+ var noisePresets = {
110
+ black: "#000000",
111
+ sepia: "#a67c52",
112
+ synthwave: "#ff2bd6"
113
+ };
114
+ function noiseColorMatrix(color, strength) {
115
+ if (!color || color === "rainbow")
116
+ return `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${strength} 0`;
117
+ const { r, g, b } = hexToRgb(noisePresets[color] ?? color);
118
+ return `0 0 0 0 ${r} 0 0 0 0 ${g} 0 0 0 0 ${b} 0 0 0 ${strength} 0`;
119
+ }
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ displacePresets,
123
+ displaceSettings,
124
+ noiseColorMatrix,
125
+ noisePresets
126
+ });
@@ -0,0 +1,56 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/svg/noise.js
20
+ var noise_exports = {};
21
+ __export(noise_exports, {
22
+ noiseColorMatrix: () => noiseColorMatrix,
23
+ noisePresets: () => noisePresets
24
+ });
25
+ module.exports = __toCommonJS(noise_exports);
26
+
27
+ // src/lib/colors.js
28
+ function hexToRgb(hex) {
29
+ let h = hex.replace("#", "");
30
+ if (h.length === 3)
31
+ h = h.split("").map((c) => c + c).join("");
32
+ const int = parseInt(h, 16);
33
+ return {
34
+ r: +((int >> 16 & 255) / 255).toFixed(3),
35
+ g: +((int >> 8 & 255) / 255).toFixed(3),
36
+ b: +((int & 255) / 255).toFixed(3)
37
+ };
38
+ }
39
+
40
+ // src/lib/svg/noise.js
41
+ var noisePresets = {
42
+ black: "#000000",
43
+ sepia: "#a67c52",
44
+ synthwave: "#ff2bd6"
45
+ };
46
+ function noiseColorMatrix(color, strength) {
47
+ if (!color || color === "rainbow")
48
+ return `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${strength} 0`;
49
+ const { r, g, b } = hexToRgb(noisePresets[color] ?? color);
50
+ return `0 0 0 0 ${r} 0 0 0 0 ${g} 0 0 0 0 ${b} 0 0 0 ${strength} 0`;
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ noiseColorMatrix,
55
+ noisePresets
56
+ });
@@ -0,0 +1,14 @@
1
+ function hexToRgb(hex) {
2
+ let h = hex.replace("#", "");
3
+ if (h.length === 3)
4
+ h = h.split("").map((c) => c + c).join("");
5
+ const int = parseInt(h, 16);
6
+ return {
7
+ r: +((int >> 16 & 255) / 255).toFixed(3),
8
+ g: +((int >> 8 & 255) / 255).toFixed(3),
9
+ b: +((int & 255) / 255).toFixed(3)
10
+ };
11
+ }
12
+ export {
13
+ hexToRgb
14
+ };
@@ -1,6 +1,7 @@
1
1
  export * from "./arrays/index.js";
2
2
  export * from "./auth/index.js";
3
3
  export * from "./checks.js";
4
+ export * from "./colors.js";
4
5
  export * from "./date/index.js";
5
6
  export * from "./form/index.js";
6
7
  export * from "./functions/index.js";
@@ -12,4 +13,5 @@ export * from "./promises/index.js";
12
13
  export * from "./sse.js";
13
14
  export * from "./strings/index.js";
14
15
  export * from "./style/index.js";
16
+ export * from "./svg/index.js";
15
17
  export * from "./symbols/index.js";
@@ -1,11 +1,3 @@
1
1
  export * from "./math.js";
2
- function splitUnit(string) {
3
- if (typeof string === "number") return [string, null];
4
- const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
5
- const match = string.match(regex);
6
- if (match) return [parseFloat(match[1]), match[2]];
7
- return [parseFloat(string), null];
8
- }
9
- export {
10
- splitUnit
11
- };
2
+ export * from "./random.js";
3
+ export * from "./split-unit.js";
@@ -0,0 +1,10 @@
1
+ function seededRandom(seed = 1) {
2
+ let state = seed >>> 0;
3
+ return () => {
4
+ state = state * 1664525 + 1013904223 >>> 0;
5
+ return state / 4294967296;
6
+ };
7
+ }
8
+ export {
9
+ seededRandom
10
+ };
@@ -0,0 +1,10 @@
1
+ function splitUnit(string) {
2
+ if (typeof string === "number") return [string, null];
3
+ const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
4
+ const match = string.match(regex);
5
+ if (match) return [parseFloat(match[1]), match[2]];
6
+ return [parseFloat(string), null];
7
+ }
8
+ export {
9
+ splitUnit
10
+ };
@@ -1,12 +1,2 @@
1
- import { toKebab } from "../strings/convert-case/convert-case.js";
2
- function toStyleString(style) {
3
- if (!style) return null;
4
- if (typeof style === "string") return style;
5
- return Object.entries(style).map(([k, v]) => {
6
- if (k.startsWith("--")) return `${k}:${v}`;
7
- else return `${toKebab(k)}:${v}`;
8
- }).join("; ").concat(";");
9
- }
10
- export {
11
- toStyleString
12
- };
1
+ export * from "./scatter.js";
2
+ export * from "./to-style-string.js";
@@ -0,0 +1,25 @@
1
+ import { seededRandom } from "../numbers/random.js";
2
+ const round = (n) => {
3
+ const value = Math.round(n * 100) / 100;
4
+ return value === 0 ? 0 : value;
5
+ };
6
+ function scatter(count, options = {}) {
7
+ const { seed = 1, spread = 20, rotation = 6, amount = 1 } = options;
8
+ const random = seededRandom(seed);
9
+ const items = [];
10
+ for (let i = 0; i < count; i++) {
11
+ const x = round((random() - 0.5) * 2 * spread * amount);
12
+ const y = round((random() - 0.5) * 2 * spread * amount);
13
+ const r = round((random() - 0.5) * 2 * rotation * amount);
14
+ items.push({
15
+ x,
16
+ y,
17
+ rotation: r,
18
+ transform: `translate(${x}%, ${y}%) rotate(${r}deg)`
19
+ });
20
+ }
21
+ return items;
22
+ }
23
+ export {
24
+ scatter
25
+ };
@@ -0,0 +1,12 @@
1
+ import { toKebab } from "../strings/convert-case/convert-case.js";
2
+ function toStyleString(style) {
3
+ if (!style) return null;
4
+ if (typeof style === "string") return style;
5
+ return Object.entries(style).map(([k, v]) => {
6
+ if (k.startsWith("--")) return `${k}:${v}`;
7
+ else return `${toKebab(k)}:${v}`;
8
+ }).join("; ").concat(";");
9
+ }
10
+ export {
11
+ toStyleString
12
+ };
@@ -0,0 +1,68 @@
1
+ const displacePresets = {
2
+ // Ink bleeding into absorbent paper. Long wavelength, small push.
3
+ "wet-ink": {
4
+ type: "fractalNoise",
5
+ frequency: 0.015,
6
+ octaves: 3,
7
+ scale: 9,
8
+ seed: 2
9
+ },
10
+ // Ink bitten into paper tooth. The edge roughens without the letterform
11
+ // moving, so this is the only preset that survives at body sizes.
12
+ letterpress: {
13
+ type: "fractalNoise",
14
+ frequency: 0.09,
15
+ octaves: 1,
16
+ scale: 2,
17
+ seed: 5
18
+ },
19
+ // Air over heat. Anisotropic so the shimmer rises instead of swimming.
20
+ // Reads as nothing unless animated.
21
+ "heat-haze": {
22
+ type: "fractalNoise",
23
+ frequency: [4e-3, 0.02],
24
+ animateTo: [6e-3, 0.03],
25
+ duration: 8,
26
+ octaves: 2,
27
+ scale: 7,
28
+ seed: 11
29
+ },
30
+ // Tracking error on worn tape. A near-infinite horizontal wavelength against
31
+ // a very short vertical one is what tears rather than blobs.
32
+ "bad-tape": {
33
+ type: "turbulence",
34
+ frequency: [8e-4, 0.06],
35
+ animateTo: [8e-4, 0.09],
36
+ duration: 2.5,
37
+ octaves: 1,
38
+ scale: 14,
39
+ seed: 3
40
+ },
41
+ // Past the shred threshold on purpose.
42
+ shred: {
43
+ type: "turbulence",
44
+ frequency: 0.055,
45
+ octaves: 2,
46
+ scale: 32,
47
+ seed: 7
48
+ }
49
+ };
50
+ const format = (f) => Array.isArray(f) ? f.join(" ") : String(f);
51
+ function displaceSettings(opts = {}) {
52
+ const base = opts.preset && displacePresets[opts.preset] || displacePresets["wet-ink"];
53
+ const frequency = opts.frequency ?? base.frequency;
54
+ const animateTo = opts.animateTo ?? base.animateTo;
55
+ return {
56
+ type: opts.type ?? base.type,
57
+ frequency: format(frequency),
58
+ animateTo: animateTo ? format(animateTo) : null,
59
+ duration: opts.duration ?? base.duration ?? 6,
60
+ octaves: opts.octaves ?? base.octaves,
61
+ scale: opts.scale ?? base.scale,
62
+ seed: opts.seed ?? base.seed
63
+ };
64
+ }
65
+ export {
66
+ displacePresets,
67
+ displaceSettings
68
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./displace.js";
2
+ export * from "./noise.js";
@@ -0,0 +1,16 @@
1
+ import { hexToRgb } from "../colors.js";
2
+ const noisePresets = {
3
+ black: "#000000",
4
+ sepia: "#a67c52",
5
+ synthwave: "#ff2bd6"
6
+ };
7
+ function noiseColorMatrix(color, strength) {
8
+ if (!color || color === "rainbow")
9
+ return `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${strength} 0`;
10
+ const { r, g, b } = hexToRgb(noisePresets[color] ?? color);
11
+ return `0 0 0 0 ${r} 0 0 0 0 ${g} 0 0 0 0 ${b} 0 0 0 ${strength} 0`;
12
+ }
13
+ export {
14
+ noiseColorMatrix,
15
+ noisePresets
16
+ };
@@ -1,4 +1,4 @@
1
- declare function getUnit(value: any): any;
1
+ declare function getUnit(value: any): string;
2
2
  declare function rem(multiple?: number): number;
3
3
  declare function em(element?: HTMLElement, multiple?: number): number;
4
4
  declare function rlh(multiple?: number): number;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Parse #rgb or #rrggbb into 0–1 channels (3dp, keeps the data URI short).
3
+ * @param {string} hex
4
+ * @returns {{r: number, g: number, b: number}}
5
+ */
6
+ declare function hexToRgb(hex: string): {
7
+ r: number;
8
+ g: number;
9
+ b: number;
10
+ };
11
+
12
+ export { hexToRgb };
@@ -6,6 +6,7 @@ export { splitArray } from './arrays/split-array.cjs';
6
6
  export { uniqueArray } from './arrays/unique.cjs';
7
7
  export { AuthManager, RouteManager } from './auth/route-manager.cjs';
8
8
  export { getType, isArray, isFunction, isObject, notObject } from './checks.cjs';
9
+ export { hexToRgb } from './colors.cjs';
9
10
  export { DAYS } from './date/days.cjs';
10
11
  export { MONTHS } from './date/months.cjs';
11
12
  export { getTimeInMs, ms, toDays, toHours, toMinutes, toReadableTime, toSeconds, toWeeks } from './date/time.cjs';
@@ -18,7 +19,9 @@ export { throttle } from './functions/throttle.cjs';
18
19
  export { delay, timeout, wait } from './functions/timeout.cjs';
19
20
  export { isHashedValue } from './hash.cjs';
20
21
  export { statusText, statusTexts } from './http/status-text.cjs';
21
- export { splitUnit } from './numbers/index.cjs';
22
+ export { toDegrees, toRadians } from './numbers/math.cjs';
23
+ export { seededRandom } from './numbers/random.cjs';
24
+ export { splitUnit } from './numbers/split-unit.cjs';
22
25
  export { camelCaseKeys } from './objects/camelcase-keys.cjs';
23
26
  export { isEmpty, notEmpty } from './objects/empty.cjs';
24
27
  export { isEqual, notEqual } from './objects/equal.cjs';
@@ -39,6 +42,8 @@ export { markdown, treatMarkdownWhitespace } from './strings/markdown.cjs';
39
42
  export { parseFullName } from './strings/name.cjs';
40
43
  export { createPluralize, isPlural, isSingular, plural, pluralize, singular } from './strings/pluralize.cjs';
41
44
  export { parseQueryString, stripNumbers, toQueryString } from './strings/query-string.cjs';
42
- export { toStyleString } from './style/index.cjs';
45
+ export { ScatterItem, scatter } from './style/scatter.cjs';
46
+ export { toStyleString } from './style/to-style-string.cjs';
47
+ export { DisplacePreset, displacePresets, displaceSettings } from './svg/displace.cjs';
48
+ export { noiseColorMatrix, noisePresets } from './svg/noise.cjs';
43
49
  export { getSymbol, getSymbolValue } from './symbols/symbols.cjs';
44
- export { toDegrees, toRadians } from './numbers/math.cjs';
@@ -1,5 +1,3 @@
1
1
  export { toDegrees, toRadians } from './math.cjs';
2
-
3
- declare function splitUnit(string: any): any[];
4
-
5
- export { splitUnit };
2
+ export { seededRandom } from './random.cjs';
3
+ export { splitUnit } from './split-unit.cjs';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Deterministic pseudo-random generator.
3
+ *
4
+ * Math.random() runs once on the server and again on the client, so anything
5
+ * built from it disagrees between SSR and hydration and jumps on load. Seeding
6
+ * makes both passes produce the same sequence. Change the seed for a different
7
+ * arrangement.
8
+ *
9
+ * @param {number} [seed]
10
+ * @returns {() => number} Generator returning a value in [0, 1)
11
+ */
12
+ declare function seededRandom(seed?: number): () => number;
13
+
14
+ export { seededRandom };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Splits a value into its numeric part and unit.
3
+ * @param {string|number} string - Value like `'2rem'`, `'30 days'`, or a plain number.
4
+ * @returns {[number, string|null]} `[value, unit]` — unit is null when there isn't one.
5
+ */
6
+ declare function splitUnit(string: string | number): [number, string | null];
7
+
8
+ export { splitUnit };
@@ -1,3 +1,2 @@
1
- declare function toStyleString(style: any): string;
2
-
3
- export { toStyleString };
1
+ export { ScatterItem, scatter } from './scatter.cjs';
2
+ export { toStyleString } from './to-style-string.cjs';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @typedef {Object} ScatterItem
3
+ * @property {number} x Horizontal offset, in % of the element's own size
4
+ * @property {number} y Vertical offset, in % of the element's own size
5
+ * @property {number} rotation Rotation in degrees
6
+ * @property {string} transform Ready-to-use CSS transform value
7
+ */
8
+ /**
9
+ * Places elements off a perfect grid so they read as laid down by hand rather
10
+ * than generated. Offsets are in % so they scale with the element.
11
+ *
12
+ * Seeded, so the same seed always produces the same arrangement — which is what
13
+ * keeps SSR and hydration in agreement.
14
+ *
15
+ * @param {number} count Number of elements to place
16
+ * @param {Object} [options]
17
+ * @param {number} [options.seed] Change for a different arrangement
18
+ * @param {number} [options.spread] Max offset, in % of the element's own size
19
+ * @param {number} [options.rotation] Max rotation in degrees
20
+ * @param {number} [options.amount] 0–1 dial over both spread and rotation
21
+ * @returns {ScatterItem[]}
22
+ */
23
+ declare function scatter(count: number, options?: {
24
+ seed?: number;
25
+ spread?: number;
26
+ rotation?: number;
27
+ amount?: number;
28
+ }): ScatterItem[];
29
+ type ScatterItem = {
30
+ /**
31
+ * Horizontal offset, in % of the element's own size
32
+ */
33
+ x: number;
34
+ /**
35
+ * Vertical offset, in % of the element's own size
36
+ */
37
+ y: number;
38
+ /**
39
+ * Rotation in degrees
40
+ */
41
+ rotation: number;
42
+ /**
43
+ * Ready-to-use CSS transform value
44
+ */
45
+ transform: string;
46
+ };
47
+
48
+ export { type ScatterItem, scatter };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts a style object into a CSS style string. Passes strings through untouched.
3
+ * @param {string|Object} style - Style string or object of camelCase/custom properties.
4
+ * @returns {string|null} CSS style string, or null if no style given.
5
+ */
6
+ declare function toStyleString(style: string | any): string | null;
7
+
8
+ export { toStyleString };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Merge a preset with explicit overrides. Explicit always wins.
3
+ * @param {Partial<DisplacePreset> & { preset?: string }} [opts]
4
+ */
5
+ declare function displaceSettings(opts?: Partial<DisplacePreset> & {
6
+ preset?: string;
7
+ }): {
8
+ type: string;
9
+ frequency: string;
10
+ animateTo: string;
11
+ duration: number;
12
+ octaves: number;
13
+ scale: number;
14
+ seed: number;
15
+ };
16
+ /**
17
+ * Two numbers govern the effect.
18
+ *
19
+ * frequency — wavelength of the distortion, roughly (1 / frequency) px
20
+ * scale — how far each pixel is pushed
21
+ *
22
+ * Their ratio decides the outcome. Once scale approaches the wavelength,
23
+ * neighbouring pixels displace past each other and the form comes apart.
24
+ *
25
+ * scale < wavelength × 0.25 warp — shape survives, edges soften
26
+ * scale ≈ wavelength × 0.5 distress — edges tear, holes open
27
+ * scale > wavelength shred — shape is destroyed
28
+ *
29
+ * type='fractalNoise' is smooth and symmetric — warps.
30
+ * type='turbulence' takes the absolute value, so it creases — wisps and tears.
31
+ */
32
+ /**
33
+ * @typedef {Object} DisplacePreset
34
+ * @property {string} type
35
+ * @property {number|number[]} frequency
36
+ * @property {number|number[]} [animateTo]
37
+ * @property {number} [duration]
38
+ * @property {number} octaves
39
+ * @property {number} scale
40
+ * @property {number} seed
41
+ */
42
+ /** @type {Record<string, DisplacePreset>} */
43
+ declare const displacePresets: Record<string, DisplacePreset>;
44
+ type DisplacePreset = {
45
+ type: string;
46
+ frequency: number | number[];
47
+ animateTo?: number | number[];
48
+ duration?: number;
49
+ octaves: number;
50
+ scale: number;
51
+ seed: number;
52
+ };
53
+
54
+ export { type DisplacePreset, displacePresets, displaceSettings };
@@ -0,0 +1,2 @@
1
+ export { DisplacePreset, displacePresets, displaceSettings } from './displace.cjs';
2
+ export { noiseColorMatrix, noisePresets } from './noise.cjs';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Build the feColorMatrix values for a noise colour.
3
+ *
4
+ * feTurbulence outputs independent noise per RGB channel, so colour is the
5
+ * natural state — the matrix decides what survives:
6
+ * - no color or 'rainbow' → RGB passes through: coloured static (default)
7
+ * - preset name ('black', 'sepia', 'synthwave') or hex → constant tint,
8
+ * alpha still noise-driven
9
+ *
10
+ * strength scales the per-pixel alpha. 0–1 fades the grain; above 1 the
11
+ * alpha saturates, so the grain gets denser rather than stronger.
12
+ *
13
+ * @param {string} [color] - 'rainbow' (default), a preset name, or a hex colour.
14
+ * @param {number} strength - Per-pixel alpha multiplier.
15
+ * @returns {string}
16
+ */
17
+ declare function noiseColorMatrix(color?: string, strength: number): string;
18
+ declare namespace noisePresets {
19
+ let black: string;
20
+ let sepia: string;
21
+ let synthwave: string;
22
+ }
23
+
24
+ export { noiseColorMatrix, noisePresets };
@@ -3,7 +3,7 @@
3
3
  * @param url — import.meta.url
4
4
  * @returns
5
5
  */
6
- declare function __dirname$1(url: any): string;
7
- declare function dirname(url: any): string;
6
+ declare function __dirname$1(url: any): any;
7
+ declare function dirname(url: any): any;
8
8
 
9
9
  export { __dirname$1 as __dirname, dirname };
@@ -1,4 +1,4 @@
1
- declare function mkdir(path: any): Promise<string>;
1
+ declare function mkdir(path: any): Promise<any>;
2
2
  declare function copyFile(from: any, to: any): Promise<void>;
3
3
 
4
4
  export { copyFile, mkdir };
@@ -1,3 +1,3 @@
1
- declare function sha256Hash(string: any): string;
1
+ declare function sha256Hash(string: any): any;
2
2
 
3
3
  export { sha256Hash };