@splendidlabz/utils 1.12.0 → 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 (62) 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/http/index.cjs +100 -0
  7. package/dist/cjs/lib/http/status-text.cjs +98 -0
  8. package/dist/cjs/lib/index.cjs +584 -11
  9. package/dist/cjs/lib/numbers/index.cjs +12 -1
  10. package/dist/cjs/lib/numbers/random.cjs +35 -0
  11. package/dist/cjs/lib/numbers/split-unit.cjs +35 -0
  12. package/dist/cjs/lib/promises/index.cjs +72 -15
  13. package/dist/cjs/lib/promises/reject.cjs +72 -13
  14. package/dist/cjs/lib/strings/index.cjs +368 -6
  15. package/dist/cjs/lib/strings/pluralize.cjs +372 -14
  16. package/dist/cjs/lib/strings/query-string.cjs +0 -6
  17. package/dist/cjs/lib/style/index.cjs +35 -1
  18. package/dist/cjs/lib/style/scatter.cjs +60 -0
  19. package/dist/cjs/lib/style/to-style-string.cjs +64 -0
  20. package/dist/cjs/lib/svg/displace.cjs +94 -0
  21. package/dist/cjs/lib/svg/index.cjs +126 -0
  22. package/dist/cjs/lib/svg/noise.cjs +56 -0
  23. package/dist/esm/lib/colors.js +14 -0
  24. package/dist/esm/lib/http/index.js +1 -0
  25. package/dist/esm/lib/http/status-text.js +72 -0
  26. package/dist/esm/lib/index.js +3 -0
  27. package/dist/esm/lib/numbers/index.js +2 -10
  28. package/dist/esm/lib/numbers/random.js +10 -0
  29. package/dist/esm/lib/numbers/split-unit.js +10 -0
  30. package/dist/esm/lib/promises/reject.js +2 -2
  31. package/dist/esm/lib/strings/pluralize.js +366 -3
  32. package/dist/esm/lib/strings/query-string.js +0 -5
  33. package/dist/esm/lib/style/index.js +2 -12
  34. package/dist/esm/lib/style/scatter.js +25 -0
  35. package/dist/esm/lib/style/to-style-string.js +12 -0
  36. package/dist/esm/lib/svg/displace.js +68 -0
  37. package/dist/esm/lib/svg/index.js +2 -0
  38. package/dist/esm/lib/svg/noise.js +16 -0
  39. package/dist/types/dom/font-size.d.cts +1 -1
  40. package/dist/types/lib/colors.d.cts +12 -0
  41. package/dist/types/lib/http/index.d.cts +1 -0
  42. package/dist/types/lib/http/status-text.d.cts +73 -0
  43. package/dist/types/lib/index.d.cts +11 -5
  44. package/dist/types/lib/numbers/index.d.cts +2 -4
  45. package/dist/types/lib/numbers/random.d.cts +14 -0
  46. package/dist/types/lib/numbers/split-unit.d.cts +8 -0
  47. package/dist/types/lib/strings/index.d.cts +2 -2
  48. package/dist/types/lib/strings/pluralize.d.cts +24 -2
  49. package/dist/types/lib/strings/query-string.d.cts +1 -2
  50. package/dist/types/lib/style/index.d.cts +2 -3
  51. package/dist/types/lib/style/scatter.d.cts +48 -0
  52. package/dist/types/lib/style/to-style-string.d.cts +8 -0
  53. package/dist/types/lib/svg/displace.d.cts +54 -0
  54. package/dist/types/lib/svg/index.d.cts +2 -0
  55. package/dist/types/lib/svg/noise.d.cts +24 -0
  56. package/dist/types/node/dirname.d.cts +2 -2
  57. package/dist/types/node/file.d.cts +1 -1
  58. package/dist/types/node/hash.d.cts +1 -1
  59. package/dist/types/node/pkce.d.cts +4 -4
  60. package/dist/types/node/random-string.d.cts +1 -1
  61. package/dist/types/node/uuid.d.cts +1 -1
  62. package/package.json +3 -6
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,25 +14,385 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // src/lib/strings/pluralize.js
30
20
  var pluralize_exports = {};
31
21
  __export(pluralize_exports, {
32
- pluralize: () => pluralize
22
+ createPluralize: () => createPluralize,
23
+ isPlural: () => isPlural,
24
+ isSingular: () => isSingular,
25
+ plural: () => plural,
26
+ pluralize: () => pluralize,
27
+ singular: () => singular
33
28
  });
34
29
  module.exports = __toCommonJS(pluralize_exports);
35
- var import_pluralize = __toESM(require("pluralize"), 1);
36
- var pluralize = import_pluralize.default;
30
+ function sanitizeRule(rule) {
31
+ if (typeof rule === "string") return new RegExp("^" + rule + "$", "i");
32
+ return rule;
33
+ }
34
+ function restoreCase(word, token) {
35
+ if (word === token) return token;
36
+ if (word === word.toLowerCase()) return token.toLowerCase();
37
+ if (word === word.toUpperCase()) return token.toUpperCase();
38
+ if (word[0] === word[0].toUpperCase()) {
39
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
40
+ }
41
+ return token.toLowerCase();
42
+ }
43
+ function interpolate(str, args) {
44
+ return str.replace(/\$(\d{1,2})/g, (match, index) => args[index] || "");
45
+ }
46
+ function replace(word, rule) {
47
+ return word.replace(rule[0], function(match, index) {
48
+ const result = interpolate(rule[1], arguments);
49
+ if (match === "") return restoreCase(word[index - 1], result);
50
+ return restoreCase(match, result);
51
+ });
52
+ }
53
+ function sanitizeWord(token, word, rules, uncountables) {
54
+ if (!token.length || uncountables.hasOwnProperty(token)) return word;
55
+ let len = rules.length;
56
+ while (len--) {
57
+ const rule = rules[len];
58
+ if (rule[0].test(word)) return replace(word, rule);
59
+ }
60
+ return word;
61
+ }
62
+ function replaceWord(replaceMap, keepMap, rules, uncountables) {
63
+ return function(word) {
64
+ const token = word.toLowerCase();
65
+ if (keepMap.hasOwnProperty(token)) return restoreCase(word, token);
66
+ if (replaceMap.hasOwnProperty(token)) {
67
+ return restoreCase(word, replaceMap[token]);
68
+ }
69
+ return sanitizeWord(token, word, rules, uncountables);
70
+ };
71
+ }
72
+ function checkWord(replaceMap, keepMap, rules, uncountables) {
73
+ return function(word) {
74
+ const token = word.toLowerCase();
75
+ if (keepMap.hasOwnProperty(token)) return true;
76
+ if (replaceMap.hasOwnProperty(token)) return false;
77
+ return sanitizeWord(token, token, rules, uncountables) === token;
78
+ };
79
+ }
80
+ var BASE_IRREGULAR = [
81
+ // Pronouns.
82
+ ["I", "we"],
83
+ ["me", "us"],
84
+ ["he", "they"],
85
+ ["she", "they"],
86
+ ["them", "them"],
87
+ ["myself", "ourselves"],
88
+ ["yourself", "yourselves"],
89
+ ["itself", "themselves"],
90
+ ["herself", "themselves"],
91
+ ["himself", "themselves"],
92
+ ["themself", "themselves"],
93
+ ["is", "are"],
94
+ ["was", "were"],
95
+ ["has", "have"],
96
+ ["this", "these"],
97
+ ["that", "those"],
98
+ // Words ending with a consonant and `o`.
99
+ ["echo", "echoes"],
100
+ ["dingo", "dingoes"],
101
+ ["volcano", "volcanoes"],
102
+ ["tornado", "tornadoes"],
103
+ ["torpedo", "torpedoes"],
104
+ // Ends with `us`.
105
+ ["genus", "genera"],
106
+ ["viscus", "viscera"],
107
+ // Ends with `ma`.
108
+ ["stigma", "stigmata"],
109
+ ["stoma", "stomata"],
110
+ ["dogma", "dogmata"],
111
+ ["lemma", "lemmata"],
112
+ ["schema", "schemata"],
113
+ ["anathema", "anathemata"],
114
+ // Other irregular rules.
115
+ ["ox", "oxen"],
116
+ ["axe", "axes"],
117
+ ["die", "dice"],
118
+ ["yes", "yeses"],
119
+ ["foot", "feet"],
120
+ ["eave", "eaves"],
121
+ ["goose", "geese"],
122
+ ["tooth", "teeth"],
123
+ ["quiz", "quizzes"],
124
+ ["human", "humans"],
125
+ ["proof", "proofs"],
126
+ ["carve", "carves"],
127
+ ["valve", "valves"],
128
+ ["looey", "looies"],
129
+ ["thief", "thieves"],
130
+ ["groove", "grooves"],
131
+ ["pickaxe", "pickaxes"],
132
+ ["passerby", "passersby"]
133
+ ];
134
+ var BASE_PLURAL = [
135
+ [/s?$/i, "s"],
136
+ // eslint-disable-next-line no-control-regex
137
+ [/[^\u0000-\u007F]$/i, "$0"],
138
+ [/([^aeiou]ese)$/i, "$1"],
139
+ [/(ax|test)is$/i, "$1es"],
140
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
141
+ [/(e[mn]u)s?$/i, "$1s"],
142
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
143
+ [
144
+ /(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
145
+ "$1i"
146
+ ],
147
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
148
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
149
+ [/(her|at|gr)o$/i, "$1oes"],
150
+ [
151
+ /(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,
152
+ "$1a"
153
+ ],
154
+ [
155
+ /(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,
156
+ "$1a"
157
+ ],
158
+ [/sis$/i, "ses"],
159
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
160
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
161
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
162
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
163
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
164
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
165
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
166
+ [/(child)(?:ren)?$/i, "$1ren"],
167
+ [/eaux$/i, "$0"],
168
+ [/m[ae]n$/i, "men"],
169
+ ["thou", "you"]
170
+ ];
171
+ var BASE_SINGULAR = [
172
+ [/s$/i, ""],
173
+ [/(ss)$/i, "$1"],
174
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
175
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
176
+ [/ies$/i, "y"],
177
+ [
178
+ /\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,
179
+ "$1ie"
180
+ ],
181
+ [/\b(mon|smil)ies$/i, "$1ey"],
182
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
183
+ [/(seraph|cherub)im$/i, "$1"],
184
+ [
185
+ /(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
186
+ "$1"
187
+ ],
188
+ [
189
+ /(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
190
+ "$1sis"
191
+ ],
192
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
193
+ [/(test)(?:is|es)$/i, "$1is"],
194
+ [
195
+ /(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
196
+ "$1us"
197
+ ],
198
+ [
199
+ /(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
200
+ "$1um"
201
+ ],
202
+ [
203
+ /(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
204
+ "$1on"
205
+ ],
206
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
207
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
208
+ [/(matr|append)ices$/i, "$1ix"],
209
+ [/(pe)(rson|ople)$/i, "$1rson"],
210
+ [/(child)ren$/i, "$1"],
211
+ [/(eau)x?$/i, "$1"],
212
+ [/men$/i, "man"]
213
+ ];
214
+ var BASE_UNCOUNTABLE = [
215
+ // Singular words with no plurals.
216
+ "adulthood",
217
+ "advice",
218
+ "agenda",
219
+ "aid",
220
+ "aircraft",
221
+ "alcohol",
222
+ "ammo",
223
+ "analytics",
224
+ "anime",
225
+ "athletics",
226
+ "audio",
227
+ "bison",
228
+ "blood",
229
+ "bream",
230
+ "buffalo",
231
+ "butter",
232
+ "carp",
233
+ "cash",
234
+ "chassis",
235
+ "chess",
236
+ "clothing",
237
+ "cod",
238
+ "commerce",
239
+ "cooperation",
240
+ "corps",
241
+ "debris",
242
+ "diabetes",
243
+ "digestion",
244
+ "elk",
245
+ "energy",
246
+ "equipment",
247
+ "excretion",
248
+ "expertise",
249
+ "firmware",
250
+ "flounder",
251
+ "fun",
252
+ "gallows",
253
+ "garbage",
254
+ "graffiti",
255
+ "hardware",
256
+ "headquarters",
257
+ "health",
258
+ "herpes",
259
+ "highjinks",
260
+ "homework",
261
+ "housework",
262
+ "information",
263
+ "jeans",
264
+ "justice",
265
+ "kudos",
266
+ "labour",
267
+ "literature",
268
+ "machinery",
269
+ "mackerel",
270
+ "mail",
271
+ "media",
272
+ "mews",
273
+ "moose",
274
+ "music",
275
+ "mud",
276
+ "manga",
277
+ "news",
278
+ "only",
279
+ "personnel",
280
+ "pike",
281
+ "plankton",
282
+ "pliers",
283
+ "police",
284
+ "pollution",
285
+ "premises",
286
+ "rain",
287
+ "research",
288
+ "rice",
289
+ "salmon",
290
+ "scissors",
291
+ "series",
292
+ "sewage",
293
+ "shambles",
294
+ "shrimp",
295
+ "software",
296
+ "species",
297
+ "staff",
298
+ "swine",
299
+ "tennis",
300
+ "traffic",
301
+ "transportation",
302
+ "trout",
303
+ "tuna",
304
+ "wealth",
305
+ "welfare",
306
+ "whiting",
307
+ "wildebeest",
308
+ "wildlife",
309
+ "you",
310
+ /pok[eé]mon$/i,
311
+ // Regexes.
312
+ /[^aeiou]ese$/i,
313
+ // "chinese", "japanese"
314
+ /deer$/i,
315
+ // "deer", "reindeer"
316
+ /fish$/i,
317
+ // "fish", "blowfish", "angelfish"
318
+ /measles$/i,
319
+ /o[iu]s$/i,
320
+ // "carnivorous"
321
+ /pox$/i,
322
+ // "chickpox", "smallpox"
323
+ /sheep$/i
324
+ ];
325
+ function createPluralize(config = {}) {
326
+ const pluralRules = [];
327
+ const singularRules = [];
328
+ const uncountables = {};
329
+ const irregularPlurals = {};
330
+ const irregularSingles = {};
331
+ for (const [single, plur] of [
332
+ ...BASE_IRREGULAR,
333
+ ...config.irregular || []
334
+ ]) {
335
+ irregularSingles[single.toLowerCase()] = plur.toLowerCase();
336
+ irregularPlurals[plur.toLowerCase()] = single.toLowerCase();
337
+ }
338
+ for (const [rule, replacement] of [...BASE_PLURAL, ...config.plural || []]) {
339
+ pluralRules.push([sanitizeRule(rule), replacement]);
340
+ }
341
+ for (const [rule, replacement] of [
342
+ ...BASE_SINGULAR,
343
+ ...config.singular || []
344
+ ]) {
345
+ singularRules.push([sanitizeRule(rule), replacement]);
346
+ }
347
+ for (const word of [...BASE_UNCOUNTABLE, ...config.uncountable || []]) {
348
+ if (typeof word === "string") {
349
+ uncountables[word.toLowerCase()] = true;
350
+ } else {
351
+ pluralRules.push([sanitizeRule(word), "$0"]);
352
+ singularRules.push([sanitizeRule(word), "$0"]);
353
+ }
354
+ }
355
+ const plural2 = replaceWord(
356
+ irregularSingles,
357
+ irregularPlurals,
358
+ pluralRules,
359
+ uncountables
360
+ );
361
+ const singular2 = replaceWord(
362
+ irregularPlurals,
363
+ irregularSingles,
364
+ singularRules,
365
+ uncountables
366
+ );
367
+ const isPlural2 = checkWord(
368
+ irregularSingles,
369
+ irregularPlurals,
370
+ pluralRules,
371
+ uncountables
372
+ );
373
+ const isSingular2 = checkWord(
374
+ irregularPlurals,
375
+ irregularSingles,
376
+ singularRules,
377
+ uncountables
378
+ );
379
+ function pluralize2(word, count, inclusive) {
380
+ const out = count === 1 ? singular2(word) : plural2(word);
381
+ return (inclusive ? count + " " : "") + out;
382
+ }
383
+ return Object.assign(pluralize2, { plural: plural2, singular: singular2, isPlural: isPlural2, isSingular: isSingular2 });
384
+ }
385
+ var pluralize = createPluralize();
386
+ var plural = pluralize.plural;
387
+ var singular = pluralize.singular;
388
+ var isPlural = pluralize.isPlural;
389
+ var isSingular = pluralize.isSingular;
37
390
  // Annotate the CommonJS export names for ESM import in node:
38
391
  0 && (module.exports = {
39
- pluralize
392
+ createPluralize,
393
+ isPlural,
394
+ isSingular,
395
+ plural,
396
+ pluralize,
397
+ singular
40
398
  });
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var query_string_exports = {};
21
21
  __export(query_string_exports, {
22
22
  parseQueryString: () => parseQueryString,
23
- plural: () => plural,
24
23
  stripNumbers: () => stripNumbers,
25
24
  toQueryString: () => toQueryString
26
25
  });
@@ -56,17 +55,12 @@ function parseQueryString(string = "") {
56
55
  }
57
56
  return result;
58
57
  }
59
- function plural(count, noun, suffix = "s") {
60
- console.warn("plural is deprecated. Use pluralize instead");
61
- return `${count} ${noun}${count !== 1 ? suffix : ""}`;
62
- }
63
58
  function stripNumbers(string) {
64
59
  return string.replace(/\d*/, "");
65
60
  }
66
61
  // Annotate the CommonJS export names for ESM import in node:
67
62
  0 && (module.exports = {
68
63
  parseQueryString,
69
- plural,
70
64
  stripNumbers,
71
65
  toQueryString
72
66
  });
@@ -19,10 +19,43 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/lib/style/index.js
20
20
  var style_exports = {};
21
21
  __export(style_exports, {
22
+ scatter: () => scatter,
22
23
  toStyleString: () => toStyleString
23
24
  });
24
25
  module.exports = __toCommonJS(style_exports);
25
26
 
27
+ // src/lib/numbers/random.js
28
+ function seededRandom(seed = 1) {
29
+ let state = seed >>> 0;
30
+ return () => {
31
+ state = state * 1664525 + 1013904223 >>> 0;
32
+ return state / 4294967296;
33
+ };
34
+ }
35
+
36
+ // src/lib/style/scatter.js
37
+ var round = (n) => {
38
+ const value = Math.round(n * 100) / 100;
39
+ return value === 0 ? 0 : value;
40
+ };
41
+ function scatter(count, options = {}) {
42
+ const { seed = 1, spread = 20, rotation = 6, amount = 1 } = options;
43
+ const random = seededRandom(seed);
44
+ const items = [];
45
+ for (let i = 0; i < count; i++) {
46
+ const x = round((random() - 0.5) * 2 * spread * amount);
47
+ const y = round((random() - 0.5) * 2 * spread * amount);
48
+ const r = round((random() - 0.5) * 2 * rotation * amount);
49
+ items.push({
50
+ x,
51
+ y,
52
+ rotation: r,
53
+ transform: `translate(${x}%, ${y}%) rotate(${r}deg)`
54
+ });
55
+ }
56
+ return items;
57
+ }
58
+
26
59
  // src/lib/strings/convert-case/convert-case.js
27
60
  function toKebab(string) {
28
61
  if (!string) return "";
@@ -49,7 +82,7 @@ function isDigit(char) {
49
82
  return /[0-9]/.test(char);
50
83
  }
51
84
 
52
- // src/lib/style/index.js
85
+ // src/lib/style/to-style-string.js
53
86
  function toStyleString(style) {
54
87
  if (!style) return null;
55
88
  if (typeof style === "string") return style;
@@ -60,5 +93,6 @@ function toStyleString(style) {
60
93
  }
61
94
  // Annotate the CommonJS export names for ESM import in node:
62
95
  0 && (module.exports = {
96
+ scatter,
63
97
  toStyleString
64
98
  });
@@ -0,0 +1,60 @@
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/style/scatter.js
20
+ var scatter_exports = {};
21
+ __export(scatter_exports, {
22
+ scatter: () => scatter
23
+ });
24
+ module.exports = __toCommonJS(scatter_exports);
25
+
26
+ // src/lib/numbers/random.js
27
+ function seededRandom(seed = 1) {
28
+ let state = seed >>> 0;
29
+ return () => {
30
+ state = state * 1664525 + 1013904223 >>> 0;
31
+ return state / 4294967296;
32
+ };
33
+ }
34
+
35
+ // src/lib/style/scatter.js
36
+ var round = (n) => {
37
+ const value = Math.round(n * 100) / 100;
38
+ return value === 0 ? 0 : value;
39
+ };
40
+ function scatter(count, options = {}) {
41
+ const { seed = 1, spread = 20, rotation = 6, amount = 1 } = options;
42
+ const random = seededRandom(seed);
43
+ const items = [];
44
+ for (let i = 0; i < count; i++) {
45
+ const x = round((random() - 0.5) * 2 * spread * amount);
46
+ const y = round((random() - 0.5) * 2 * spread * amount);
47
+ const r = round((random() - 0.5) * 2 * rotation * amount);
48
+ items.push({
49
+ x,
50
+ y,
51
+ rotation: r,
52
+ transform: `translate(${x}%, ${y}%) rotate(${r}deg)`
53
+ });
54
+ }
55
+ return items;
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ scatter
60
+ });
@@ -0,0 +1,64 @@
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/style/to-style-string.js
20
+ var to_style_string_exports = {};
21
+ __export(to_style_string_exports, {
22
+ toStyleString: () => toStyleString
23
+ });
24
+ module.exports = __toCommonJS(to_style_string_exports);
25
+
26
+ // src/lib/strings/convert-case/convert-case.js
27
+ function toKebab(string) {
28
+ if (!string) return "";
29
+ return string.split("").map((letter, index) => {
30
+ const previousLetter = string[index - 1] || "";
31
+ const currentLetter = letter;
32
+ if (isDigit(currentLetter) && !isDigit(previousLetter)) {
33
+ return `-${currentLetter}`;
34
+ }
35
+ if (!isCaps(currentLetter)) return currentLetter;
36
+ if (previousLetter === "") {
37
+ return `${currentLetter.toLowerCase()}`;
38
+ }
39
+ if (isCaps(previousLetter)) {
40
+ return `${currentLetter.toLowerCase()}`;
41
+ }
42
+ return `-${currentLetter.toLowerCase()}`;
43
+ }).join("").trim().replace(/[-_\s]+/g, "-");
44
+ }
45
+ function isCaps(char) {
46
+ return /\p{Lu}/u.test(char);
47
+ }
48
+ function isDigit(char) {
49
+ return /[0-9]/.test(char);
50
+ }
51
+
52
+ // src/lib/style/to-style-string.js
53
+ function toStyleString(style) {
54
+ if (!style) return null;
55
+ if (typeof style === "string") return style;
56
+ return Object.entries(style).map(([k, v]) => {
57
+ if (k.startsWith("--")) return `${k}:${v}`;
58
+ else return `${toKebab(k)}:${v}`;
59
+ }).join("; ").concat(";");
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ toStyleString
64
+ });