@design-edito/tools 0.2.40 → 0.2.41

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 (161) hide show
  1. package/agnostic/booleans/is-falsy/index.test.d.ts +1 -0
  2. package/agnostic/colors/channels/index.js +3 -3
  3. package/agnostic/colors/channels/index.test.d.ts +1 -0
  4. package/agnostic/colors/contrast/index.js +3 -3
  5. package/agnostic/colors/contrast/index.test.d.ts +1 -0
  6. package/agnostic/colors/convert/index.js +2 -2
  7. package/agnostic/colors/convert/index.test.d.ts +1 -0
  8. package/agnostic/colors/distance/index.js +2 -2
  9. package/agnostic/colors/distance/index.test.d.ts +1 -0
  10. package/agnostic/colors/grayscale/index.js +2 -2
  11. package/agnostic/colors/grayscale/index.test.d.ts +1 -0
  12. package/agnostic/colors/invert/index.js +4 -4
  13. package/agnostic/colors/invert/index.test.d.ts +1 -0
  14. package/agnostic/colors/lerp/index.js +2 -2
  15. package/agnostic/colors/lerp/index.test.d.ts +1 -0
  16. package/agnostic/colors/luminance/index.js +3 -3
  17. package/agnostic/colors/luminance/index.test.d.ts +1 -0
  18. package/agnostic/colors/palette/index.js +4 -4
  19. package/agnostic/colors/palette/index.test.d.ts +1 -0
  20. package/agnostic/colors/rotate/index.js +4 -4
  21. package/agnostic/colors/rotate/index.test.d.ts +1 -0
  22. package/agnostic/colors/tidy/index.js +2 -2
  23. package/agnostic/colors/tidy/index.test.d.ts +1 -0
  24. package/agnostic/colors/typechecks/index.test.d.ts +1 -0
  25. package/agnostic/css/bem/index.js +3 -3
  26. package/agnostic/css/generate-nice-color/index.test.d.ts +1 -0
  27. package/agnostic/css/is-valid-css-class-name/index.test.d.ts +1 -0
  28. package/agnostic/errors/unknown-to-string/index.test.d.ts +1 -0
  29. package/agnostic/html/get-node-ancestors/index.js +2 -1
  30. package/agnostic/html/get-node-ancestors/index.test.d.ts +1 -0
  31. package/agnostic/html/get-position-inside-parent/index.test.d.ts +1 -0
  32. package/agnostic/html/hyper-json/cast/index.js +7 -7
  33. package/agnostic/html/hyper-json/index.js +7 -7
  34. package/agnostic/html/hyper-json/serialize/index.js +1 -1
  35. package/agnostic/html/hyper-json/smart-tags/coalesced/add/index.js +7 -7
  36. package/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.js +7 -7
  37. package/agnostic/html/hyper-json/smart-tags/coalesced/and/index.js +7 -7
  38. package/agnostic/html/hyper-json/smart-tags/coalesced/append/index.js +7 -7
  39. package/agnostic/html/hyper-json/smart-tags/coalesced/at/index.js +7 -7
  40. package/agnostic/html/hyper-json/smart-tags/coalesced/call/index.js +7 -7
  41. package/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.js +7 -7
  42. package/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.js +7 -7
  43. package/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.js +7 -7
  44. package/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.js +7 -7
  45. package/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.js +7 -7
  46. package/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.js +7 -7
  47. package/agnostic/html/hyper-json/smart-tags/coalesced/hjparse/index.js +7 -7
  48. package/agnostic/html/hyper-json/smart-tags/coalesced/hjstringify/index.js +7 -7
  49. package/agnostic/html/hyper-json/smart-tags/coalesced/if/index.js +7 -7
  50. package/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.js +7 -7
  51. package/agnostic/html/hyper-json/smart-tags/coalesced/join/index.js +7 -7
  52. package/agnostic/html/hyper-json/smart-tags/coalesced/length/index.js +7 -7
  53. package/agnostic/html/hyper-json/smart-tags/coalesced/map/index.js +7 -7
  54. package/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.js +7 -7
  55. package/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.js +7 -7
  56. package/agnostic/html/hyper-json/smart-tags/coalesced/or/index.js +7 -7
  57. package/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.js +7 -7
  58. package/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.js +7 -7
  59. package/agnostic/html/hyper-json/smart-tags/coalesced/print/index.js +7 -7
  60. package/agnostic/html/hyper-json/smart-tags/coalesced/push/index.js +7 -7
  61. package/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.js +7 -7
  62. package/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.js +7 -7
  63. package/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.js +7 -7
  64. package/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.js +7 -7
  65. package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.js +7 -7
  66. package/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.js +7 -7
  67. package/agnostic/html/hyper-json/smart-tags/coalesced/select/index.js +7 -7
  68. package/agnostic/html/hyper-json/smart-tags/coalesced/set/index.js +7 -7
  69. package/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.js +7 -7
  70. package/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.js +7 -7
  71. package/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.js +7 -7
  72. package/agnostic/html/hyper-json/smart-tags/coalesced/split/index.js +7 -7
  73. package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.js +7 -7
  74. package/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.js +7 -7
  75. package/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.js +7 -7
  76. package/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.js +7 -7
  77. package/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.js +7 -7
  78. package/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.js +7 -7
  79. package/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.js +7 -7
  80. package/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.js +7 -7
  81. package/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.js +7 -7
  82. package/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.js +7 -7
  83. package/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.js +7 -7
  84. package/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.js +7 -7
  85. package/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.js +7 -7
  86. package/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.js +7 -7
  87. package/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.js +7 -7
  88. package/agnostic/html/hyper-json/smart-tags/isolated/element/index.js +7 -7
  89. package/agnostic/html/hyper-json/smart-tags/isolated/get/index.js +7 -7
  90. package/agnostic/html/hyper-json/smart-tags/isolated/global/index.js +7 -7
  91. package/agnostic/html/hyper-json/smart-tags/isolated/guess/index.js +7 -7
  92. package/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.js +7 -7
  93. package/agnostic/html/hyper-json/smart-tags/isolated/number/index.js +7 -7
  94. package/agnostic/html/hyper-json/smart-tags/isolated/record/index.js +7 -7
  95. package/agnostic/html/hyper-json/smart-tags/isolated/ref/index.js +7 -7
  96. package/agnostic/html/hyper-json/smart-tags/isolated/string/index.js +7 -7
  97. package/agnostic/html/hyper-json/smart-tags/isolated/text/index.js +7 -7
  98. package/agnostic/html/hyper-json/tree/index.js +7 -7
  99. package/agnostic/html/hyper-json/utils/index.js +7 -7
  100. package/agnostic/html/insert-node/index.test.d.ts +1 -0
  101. package/agnostic/html/replace-in-element/index.js +2 -1
  102. package/agnostic/html/replace-in-element/index.test.d.ts +1 -0
  103. package/agnostic/html/selector-to-element/index.js +5 -4
  104. package/agnostic/html/selector-to-element/index.test.d.ts +1 -0
  105. package/agnostic/html/string-to-nodes/index.js +3 -1
  106. package/agnostic/html/string-to-nodes/index.test.d.ts +1 -0
  107. package/agnostic/misc/cast/index.d.ts +1 -1
  108. package/agnostic/misc/cast/index.js +1 -1
  109. package/agnostic/misc/cast/index.test.d.ts +1 -0
  110. package/agnostic/misc/connection/index.test.d.ts +1 -0
  111. package/agnostic/misc/crawler/index.d.ts +6 -6
  112. package/agnostic/misc/crawler/index.js +1 -5
  113. package/agnostic/misc/crawler/index.test.d.ts +1 -0
  114. package/agnostic/misc/crossenv/detect-runtime/index.test.d.ts +1 -0
  115. package/agnostic/misc/crossenv/types.d.ts +1 -0
  116. package/agnostic/misc/data-size/index.test.d.ts +1 -0
  117. package/agnostic/misc/is-constructor-function/index.test.d.ts +1 -0
  118. package/agnostic/misc/is-nullish/index.test.d.ts +1 -0
  119. package/agnostic/misc/lorem-ipsum/index.test.d.ts +1 -0
  120. package/agnostic/misc/normalize-extension/index.test.d.ts +1 -0
  121. package/agnostic/misc/outcome/index.test.d.ts +1 -0
  122. package/agnostic/numbers/absolute-modulo/index.test.d.ts +1 -0
  123. package/agnostic/numbers/approximate-rational/index.d.ts +22 -0
  124. package/agnostic/numbers/approximate-rational/index.js +72 -0
  125. package/agnostic/numbers/approximate-rational/index.test.d.ts +1 -0
  126. package/agnostic/numbers/clamp/index.test.d.ts +1 -0
  127. package/agnostic/numbers/interpolate/index.test.d.ts +1 -0
  128. package/agnostic/numbers/round/index.test.d.ts +1 -0
  129. package/agnostic/objects/flatten-getters/index.js +1 -1
  130. package/agnostic/typescript/types.d.ts +37 -0
  131. package/agnostic/typescript/types.js +0 -0
  132. package/chunks/{chunk-LUPVHC73.js → chunk-3MPXVP4L.js} +11 -3
  133. package/chunks/{chunk-ENOTZXFS.js → chunk-6KOJFWH3.js} +1 -1
  134. package/chunks/{chunk-WF2JNQV4.js → chunk-FXISVWGE.js} +3 -3
  135. package/chunks/{chunk-MSJ7WDFX.js → chunk-HMPY32F7.js} +3 -3
  136. package/chunks/{chunk-FAAIUU6V.js → chunk-MSAAQTCE.js} +4 -4
  137. package/chunks/{chunk-27SSMK5F.js → chunk-MZYCKOLN.js} +4 -4
  138. package/chunks/{chunk-53ILYMIY.js → chunk-QFBVETGF.js} +3 -3
  139. package/chunks/{chunk-U225LGOV.js → chunk-TLWVLCIQ.js} +3 -3
  140. package/chunks/{chunk-AKFDKOHE.js → chunk-TTJXJX4E.js} +2 -2
  141. package/chunks/{chunk-C4VX4TTP.js → chunk-UR5BUIPU.js} +2 -2
  142. package/chunks/{chunk-HOFEVF7T.js → chunk-YWSXCFYY.js} +1 -1
  143. package/node/@google-cloud/storage/file/revoke-signed-urls/index.js +3 -3
  144. package/node/cloud-storage/operations/copy-dir/index.js +3 -3
  145. package/node/cloud-storage/operations/copy-file/index.js +3 -3
  146. package/node/cloud-storage/operations/move-dir/index.js +3 -3
  147. package/node/cloud-storage/operations/remove-dir/index.js +3 -3
  148. package/node/cloud-storage/operations/upload-file/index.js +3 -3
  149. package/node/images/create/index.js +3 -3
  150. package/node/images/format/index.js +6 -6
  151. package/node/images/metadata/index.js +3 -3
  152. package/node/images/transform/index.js +40 -40
  153. package/node/images/transform/operations/extend/index.js +4 -4
  154. package/node/images/transform/operations/flatten/index.js +4 -4
  155. package/node/images/transform/operations/overlay/index.js +4 -4
  156. package/node/images/transform/operations/resize/index.js +4 -4
  157. package/node/images/transform/operations/rotate/index.js +4 -4
  158. package/node/images/utils/index.js +3 -3
  159. package/package.json +1 -1
  160. package/chunks/{chunk-SGGJJ46D.js → chunk-ALLCYHRY.js} +15 -15
  161. package/chunks/{chunk-2QDYPY2O.js → chunk-RNXRHCHQ.js} +3 -3
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  getNodeAncestors
3
- } from "../../../chunks/chunk-LUPVHC73.js";
3
+ } from "../../../chunks/chunk-3MPXVP4L.js";
4
+ import "../../../chunks/chunk-ROWPCMQY.js";
4
5
  import "../../../chunks/chunk-XCBH6NLF.js";
5
6
 
6
7
  // src/agnostic/html/replace-in-element/index.ts
@@ -0,0 +1 @@
1
+ export {};
@@ -7,14 +7,14 @@ import "../../../chunks/chunk-XCBH6NLF.js";
7
7
  function selectorToElement(selector) {
8
8
  const tagRegexp = /^[A-Za-z]+/;
9
9
  const idRegexp = /#[A-Za-z]+[\w\-\:]*/;
10
- const classRegexp = /\.[A-Za-z]+[\w\-]*/;
11
- const attributeRegexp = /\[[A-Za-z]+[\w\-]*(="[\w\-]+")?\]/;
10
+ const classRegexp = /\.[A-Za-z]+[\w\-]*/g;
11
+ const attributeRegexp = /\[[A-Za-z]+[\w\-]*(="[\w\-]+")?\]/g;
12
12
  const matchedTags = selector.match(tagRegexp) ?? [];
13
13
  const matchedIds = selector.match(idRegexp) ?? [];
14
14
  const matchedClasses = selector.match(classRegexp) ?? [];
15
15
  const matchedAttrs = selector.match(attributeRegexp) ?? [];
16
16
  const tag = matchedTags[matchedTags.length - 1] ?? "div";
17
- const id = matchedIds[matchedIds.length - 1] ?? null;
17
+ const id = matchedIds.length > 0 ? matchedIds[matchedIds.length - 1]?.replace(/^#/, "") : null;
18
18
  const classes = matchedClasses.map((matchedClass) => matchedClass.replace(/^\./, ""));
19
19
  const attributes = matchedAttrs.map((matchedAttr) => matchedAttr.replace(/^\[/, "").replace(/\]$/, "").split("="));
20
20
  const element = get().document.createElement(tag);
@@ -24,7 +24,8 @@ function selectorToElement(selector) {
24
24
  element.classList.add(...classes);
25
25
  attributes.forEach(([name, value = ""]) => {
26
26
  if (name === void 0) return;
27
- element.setAttribute(name, value);
27
+ const cleanValue = value.replace(/^"(.*)"$/, "$1");
28
+ element.setAttribute(name, cleanValue);
28
29
  });
29
30
  return element;
30
31
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,7 +5,9 @@ import "../../../chunks/chunk-XCBH6NLF.js";
5
5
 
6
6
  // src/agnostic/html/string-to-nodes/index.ts
7
7
  function stringToNodes(inputStr) {
8
- const wrapperDiv = get().document.createElement("div");
8
+ const window = get();
9
+ const { document, Node } = window;
10
+ const wrapperDiv = document.createElement("div");
9
11
  wrapperDiv.innerHTML = inputStr;
10
12
  const nodes = Array.from(wrapperDiv.childNodes).filter((node) => {
11
13
  const allowedNodeTypes = [Node.ELEMENT_NODE, Node.TEXT_NODE];
@@ -0,0 +1 @@
1
+ export {};
@@ -41,7 +41,7 @@ export declare function toNull(_value: unknown): null;
41
41
  * Converts a value to an array.
42
42
  *
43
43
  * - Arrays are returned as-is.
44
- * - Objects are converted to an array of `{ key, value }` pairs.
44
+ * - Objects are converted to an array of `[key, value]` pairs.
45
45
  * - Other values are wrapped in a single-element array.
46
46
  *
47
47
  * @param {unknown} value - The value to convert.
@@ -7,7 +7,7 @@ import {
7
7
  toNumberArr,
8
8
  toRecord,
9
9
  toString
10
- } from "../../../chunks/chunk-HOFEVF7T.js";
10
+ } from "../../../chunks/chunk-YWSXCFYY.js";
11
11
  import "../../../chunks/chunk-QXAJXTXV.js";
12
12
  import "../../../chunks/chunk-HC6ZOHCS.js";
13
13
  import "../../../chunks/chunk-XCBH6NLF.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -51,13 +51,13 @@ export type Options<T extends any> = {
51
51
  * @template T - The type of content returned by the fetcher.
52
52
  * @param {Options<T>} options - Crawler configuration options.
53
53
  * @returns {{
54
- * crawl: (startUrl: string) => Promise<void>,
55
- * push: (url: string) => void,
56
- * flush: () => void
57
- * }} An object with methods to start crawling, enqueue URLs, and flush the waitlist.
58
- */
54
+ * crawl: (startUrl: string) => Promise<void>,
55
+ * push: (url: string) => void,
56
+ * flush: () => void
57
+ * }} An object with methods to start crawling, enqueue URLs, and flush the waitlist.
58
+ */
59
59
  export declare function create<T extends any>(options: Options<T>): {
60
60
  crawl: (startUrl: string) => Promise<void>;
61
- push: (url: string) => number;
61
+ push: (url: string) => void;
62
62
  flush: () => void;
63
63
  };
@@ -28,11 +28,7 @@ function create(options) {
28
28
  if (delayMs !== 0) await wait(delayMs);
29
29
  }
30
30
  };
31
- return {
32
- crawl,
33
- push,
34
- flush
35
- };
31
+ return { crawl, push, flush };
36
32
  }
37
33
  export {
38
34
  create
@@ -0,0 +1 @@
1
+ export {};
@@ -35,5 +35,6 @@ export interface MinimalWindow {
35
35
  Text: typeof Text;
36
36
  NodeList: typeof NodeList;
37
37
  Attr: typeof Attr;
38
+ ShadowRoot: typeof ShadowRoot;
38
39
  document: Document;
39
40
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Approximates a decimal number as a rational number using a simple iterative approach.
3
+ *
4
+ * Uses a naive algorithm that increments the numerator or denominator each round
5
+ * to find the closest approximation. Stops early if an exact match is found.
6
+ *
7
+ * @param {number} target - The decimal number to approximate.
8
+ * @param {number} maxRounds - The maximum number of iterations to perform.
9
+ * @returns {[number, number]} A tuple `[numerator, denominator]` representing the rational approximation.
10
+ */
11
+ export declare function approximateRationalDumb(target: number, maxRounds: number): [number, number];
12
+ /**
13
+ * Approximates a decimal number as a rational number (fraction) using continued fractions.
14
+ *
15
+ * Uses the continued fractions algorithm to find the best rational approximation
16
+ * of a decimal number within the specified maximum denominator limit.
17
+ *
18
+ * @param {number} target - The decimal number to approximate.
19
+ * @param {number} [maxDenominator=1000] - The maximum allowed denominator value.
20
+ * @returns {[number, number]} A tuple `[numerator, denominator]` representing the rational approximation.
21
+ */
22
+ export declare function approximateRational(target: number, maxDenominator?: number): [number, number];
@@ -0,0 +1,72 @@
1
+ import "../../../chunks/chunk-XCBH6NLF.js";
2
+
3
+ // src/agnostic/numbers/approximate-rational/index.ts
4
+ function approximateRationalDumb(target, maxRounds) {
5
+ let numerator = 0;
6
+ let denominator = 1;
7
+ let currentRound = 0;
8
+ let foundExact = false;
9
+ const closestFound = {
10
+ numerator,
11
+ denominator,
12
+ found: 0
13
+ };
14
+ const positiveTarget = Math.abs(target);
15
+ while (currentRound < maxRounds && !foundExact) {
16
+ currentRound++;
17
+ const roundResult = numerator / denominator;
18
+ if (roundResult === positiveTarget) {
19
+ closestFound.numerator = numerator;
20
+ closestFound.denominator = denominator;
21
+ closestFound.found = roundResult;
22
+ foundExact = true;
23
+ } else {
24
+ const roundAbsDiff = Math.abs(roundResult - positiveTarget);
25
+ const closestAbsDiff = Math.abs(closestFound.found - positiveTarget);
26
+ if (roundAbsDiff < closestAbsDiff) {
27
+ closestFound.numerator = numerator;
28
+ closestFound.denominator = denominator;
29
+ closestFound.found = roundResult;
30
+ }
31
+ if (roundResult < positiveTarget) {
32
+ numerator++;
33
+ } else {
34
+ denominator++;
35
+ }
36
+ }
37
+ }
38
+ if (target < 0) {
39
+ closestFound.numerator = closestFound.numerator * -1;
40
+ }
41
+ return [
42
+ closestFound.numerator,
43
+ closestFound.denominator
44
+ ];
45
+ }
46
+ function approximateRational(target, maxDenominator = 1e3) {
47
+ const sign = target < 0 ? -1 : 1;
48
+ const absTarget = Math.abs(target);
49
+ let h1 = 1, h2 = 0;
50
+ let k1 = 0, k2 = 1;
51
+ let b = absTarget;
52
+ do {
53
+ const a = Math.floor(b);
54
+ let temp = h1;
55
+ h1 = a * h1 + h2;
56
+ h2 = temp;
57
+ temp = k1;
58
+ k1 = a * k1 + k2;
59
+ k2 = temp;
60
+ if (k1 > maxDenominator) {
61
+ k1 = k2;
62
+ h1 = h2;
63
+ break;
64
+ }
65
+ b = 1 / (b - a);
66
+ } while (Math.abs(absTarget - h1 / k1) > 1e-10 && Number.isFinite(b));
67
+ return [sign * h1, k1];
68
+ }
69
+ export {
70
+ approximateRational,
71
+ approximateRationalDumb
72
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  toRecord
3
- } from "../../../chunks/chunk-HOFEVF7T.js";
3
+ } from "../../../chunks/chunk-YWSXCFYY.js";
4
4
  import "../../../chunks/chunk-QXAJXTXV.js";
5
5
  import "../../../chunks/chunk-HC6ZOHCS.js";
6
6
  import "../../../chunks/chunk-XCBH6NLF.js";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Converts `undefined` to `null` in a type, while preserving other types.
3
+ *
4
+ * @template T - The type to transform
5
+ * @returns If T extends `undefined`, returns `null`, otherwise returns T
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * type Example1 = NullIfUndefined<string | undefined>; // string | null
10
+ * type Example2 = NullIfUndefined<number>; // number
11
+ * type Example3 = NullIfUndefined<undefined>; // null
12
+ * ```
13
+ */
14
+ export type NullIfUndefined<T> = T extends undefined ? null : T;
15
+ /**
16
+ * Makes specific keys of a type required, while keeping other keys optional.
17
+ *
18
+ * @template T - The base type
19
+ * @template K - The keys of T that should be required
20
+ * @returns A new type where keys K are required and other keys remain as they were
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * interface User {
25
+ * name?: string;
26
+ * age?: number;
27
+ * email?: string;
28
+ * }
29
+ *
30
+ * type UserWithRequiredName = RequireKeys<User, 'name'>;
31
+ * // { name: string; age?: number; email?: string; }
32
+ *
33
+ * type UserWithRequiredNameAndEmail = RequireKeys<User, 'name' | 'email'>;
34
+ * // { name: string; age?: number; email: string; }
35
+ * ```
36
+ */
37
+ export type RequireKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
File without changes
@@ -1,13 +1,21 @@
1
+ import {
2
+ get
3
+ } from "./chunk-ROWPCMQY.js";
4
+
1
5
  // src/agnostic/html/get-node-ancestors/index.ts
2
6
  function getNodeAncestors(node, traverseShadowRoots) {
3
7
  const returned = [];
4
8
  let currentNode = node;
9
+ const { ShadowRoot } = get();
5
10
  while (currentNode !== null) {
6
11
  returned.push(currentNode);
7
12
  const parentNode = currentNode.parentNode;
8
- const parentElement = currentNode.parentElement;
9
- const nextNode = parentNode instanceof ShadowRoot ? traverseShadowRoots ? parentNode.host : parentElement : parentElement;
10
- currentNode = nextNode;
13
+ if (parentNode instanceof ShadowRoot) {
14
+ returned.push(parentNode);
15
+ currentNode = traverseShadowRoots ? parentNode.host : null;
16
+ continue;
17
+ }
18
+ currentNode = currentNode.parentElement;
11
19
  }
12
20
  return returned;
13
21
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  tidy,
3
3
  toRgb
4
- } from "./chunk-2QDYPY2O.js";
4
+ } from "./chunk-RNXRHCHQ.js";
5
5
  import {
6
6
  isNonNullObject
7
7
  } from "./chunk-HQLRJ7XW.js";
@@ -1,9 +1,9 @@
1
+ import {
2
+ toSharpColor
3
+ } from "./chunk-6KOJFWH3.js";
1
4
  import {
2
5
  zod_default
3
6
  } from "./chunk-LFHDJTZJ.js";
4
- import {
5
- toSharpColor
6
- } from "./chunk-ENOTZXFS.js";
7
7
  import {
8
8
  makeFailure,
9
9
  makeSuccess
@@ -1,9 +1,9 @@
1
+ import {
2
+ toSharpColor
3
+ } from "./chunk-6KOJFWH3.js";
1
4
  import {
2
5
  zod_default
3
6
  } from "./chunk-LFHDJTZJ.js";
4
- import {
5
- toSharpColor
6
- } from "./chunk-ENOTZXFS.js";
7
7
  import {
8
8
  makeFailure,
9
9
  makeSuccess
@@ -13,13 +13,13 @@ import {
13
13
  viaLch,
14
14
  viaRgb,
15
15
  viaXyz
16
- } from "./chunk-2QDYPY2O.js";
17
- import {
18
- clamp
19
- } from "./chunk-OSAXBA7G.js";
16
+ } from "./chunk-RNXRHCHQ.js";
20
17
  import {
21
18
  absoluteModulo
22
19
  } from "./chunk-DNIOWD7K.js";
20
+ import {
21
+ clamp
22
+ } from "./chunk-OSAXBA7G.js";
23
23
 
24
24
  // src/agnostic/colors/channels/index.ts
25
25
  function setChannel(color, channel, value) {
@@ -1,10 +1,10 @@
1
- import {
2
- zod_default
3
- } from "./chunk-LFHDJTZJ.js";
4
1
  import {
5
2
  isDuckTypedSharpInstance,
6
3
  toSharpInstance
7
- } from "./chunk-ENOTZXFS.js";
4
+ } from "./chunk-6KOJFWH3.js";
5
+ import {
6
+ zod_default
7
+ } from "./chunk-LFHDJTZJ.js";
8
8
  import {
9
9
  makeFailure,
10
10
  makeSuccess
@@ -1,9 +1,9 @@
1
+ import {
2
+ toSharpColor
3
+ } from "./chunk-6KOJFWH3.js";
1
4
  import {
2
5
  zod_default
3
6
  } from "./chunk-LFHDJTZJ.js";
4
- import {
5
- toSharpColor
6
- } from "./chunk-ENOTZXFS.js";
7
7
  import {
8
8
  makeFailure,
9
9
  makeSuccess
@@ -1,9 +1,9 @@
1
+ import {
2
+ toSharpColor
3
+ } from "./chunk-6KOJFWH3.js";
1
4
  import {
2
5
  zod_default
3
6
  } from "./chunk-LFHDJTZJ.js";
4
- import {
5
- toSharpColor
6
- } from "./chunk-ENOTZXFS.js";
7
7
  import {
8
8
  makeFailure,
9
9
  makeSuccess
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  addChannel
3
- } from "./chunk-FAAIUU6V.js";
3
+ } from "./chunk-MSAAQTCE.js";
4
4
  import {
5
5
  viaLab,
6
6
  viaLch
7
- } from "./chunk-2QDYPY2O.js";
7
+ } from "./chunk-RNXRHCHQ.js";
8
8
  import {
9
9
  absoluteModulo
10
10
  } from "./chunk-DNIOWD7K.js";
@@ -3,12 +3,12 @@ import {
3
3
  toLab,
4
4
  toRgb,
5
5
  toXyz
6
- } from "./chunk-2QDYPY2O.js";
6
+ } from "./chunk-RNXRHCHQ.js";
7
7
 
8
8
  // src/agnostic/colors/luminance/index.ts
9
9
  function luminanceRgb(rgb) {
10
10
  const { linearR, linearG, linearB } = linearizeToSRgb(rgb);
11
- return (0.2126 * linearR + 0.7152 * linearG + 0.0722 * linearB) / 255;
11
+ return 0.2126 * linearR + 0.7152 * linearG + 0.0722 * linearB;
12
12
  }
13
13
  function luminance(color, method = "lab") {
14
14
  switch (method) {
@@ -25,7 +25,7 @@ function toNull(_value) {
25
25
  }
26
26
  function toArray(value) {
27
27
  if (Array.isArray(value)) return value;
28
- if (typeof value === "object" && value !== null) return Object.entries(value).map((key, value2) => ({ key, value: value2 }));
28
+ if (typeof value === "object" && value !== null) return Object.entries(value);
29
29
  return [value];
30
30
  }
31
31
  function toNumberArr(value) {
@@ -1,12 +1,12 @@
1
- import {
2
- remove
3
- } from "../../../../../chunks/chunk-66BURDRK.js";
4
1
  import {
5
2
  upload
6
3
  } from "../../../../../chunks/chunk-UZ4SWSOZ.js";
7
4
  import {
8
5
  download
9
6
  } from "../../../../../chunks/chunk-O66PEU62.js";
7
+ import {
8
+ remove
9
+ } from "../../../../../chunks/chunk-66BURDRK.js";
10
10
  import {
11
11
  makeSuccess
12
12
  } from "../../../../../chunks/chunk-QEKI6WGQ.js";
@@ -1,9 +1,9 @@
1
- import {
2
- copyDir as copyDir3
3
- } from "../../../../chunks/chunk-VU6JYR3W.js";
4
1
  import {
5
2
  copyDir as copyDir4
6
3
  } from "../../../../chunks/chunk-IBQQCUYV.js";
4
+ import {
5
+ copyDir as copyDir3
6
+ } from "../../../../chunks/chunk-VU6JYR3W.js";
7
7
  import {
8
8
  copyDir as copyDir2
9
9
  } from "../../../../chunks/chunk-OF2W4ZRG.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  copy as copy4
3
3
  } from "../../../../chunks/chunk-S6ZFFGWH.js";
4
- import {
5
- copy as copy3
6
- } from "../../../../chunks/chunk-YOP6WVCF.js";
7
4
  import {
8
5
  copy as copy2
9
6
  } from "../../../../chunks/chunk-O7UCJNVF.js";
7
+ import {
8
+ copy as copy3
9
+ } from "../../../../chunks/chunk-YOP6WVCF.js";
10
10
  import {
11
11
  copy
12
12
  } from "../../../../chunks/chunk-7B2E2NGH.js";
@@ -1,9 +1,9 @@
1
- import {
2
- moveDir as moveDir3
3
- } from "../../../../chunks/chunk-2WSVYQ5Q.js";
4
1
  import {
5
2
  moveDir as moveDir4
6
3
  } from "../../../../chunks/chunk-NIIAUOBO.js";
4
+ import {
5
+ moveDir as moveDir3
6
+ } from "../../../../chunks/chunk-2WSVYQ5Q.js";
7
7
  import {
8
8
  moveDir as moveDir2
9
9
  } from "../../../../chunks/chunk-JN2UETL4.js";
@@ -1,9 +1,9 @@
1
- import {
2
- removeDir as removeDir3
3
- } from "../../../../chunks/chunk-5X76KDYN.js";
4
1
  import {
5
2
  removeDir as removeDir4
6
3
  } from "../../../../chunks/chunk-ZTPRFEPV.js";
4
+ import {
5
+ removeDir as removeDir3
6
+ } from "../../../../chunks/chunk-5X76KDYN.js";
7
7
  import {
8
8
  removeDir as removeDir2
9
9
  } from "../../../../chunks/chunk-6YVXSCRH.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  upload as upload4
3
3
  } from "../../../../chunks/chunk-UZ4SWSOZ.js";
4
- import {
5
- upload as upload2
6
- } from "../../../../chunks/chunk-Y6FD4ASO.js";
7
4
  import {
8
5
  upload as upload3
9
6
  } from "../../../../chunks/chunk-FM3HGCFL.js";
7
+ import {
8
+ upload as upload2
9
+ } from "../../../../chunks/chunk-Y6FD4ASO.js";
10
10
  import {
11
11
  upload
12
12
  } from "../../../../chunks/chunk-AOEOW5XW.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  toCreateOptions
3
- } from "../../../chunks/chunk-ENOTZXFS.js";
4
- import "../../../chunks/chunk-2QDYPY2O.js";
3
+ } from "../../../chunks/chunk-6KOJFWH3.js";
4
+ import "../../../chunks/chunk-RNXRHCHQ.js";
5
+ import "../../../chunks/chunk-DNIOWD7K.js";
5
6
  import "../../../chunks/chunk-OSAXBA7G.js";
6
7
  import "../../../chunks/chunk-JDINERKY.js";
7
8
  import "../../../chunks/chunk-HQLRJ7XW.js";
8
- import "../../../chunks/chunk-DNIOWD7K.js";
9
9
  import "../../../chunks/chunk-KRYJVBO5.js";
10
10
  import "../../../chunks/chunk-XCBH6NLF.js";
11
11
 
@@ -1,14 +1,15 @@
1
- import {
2
- zod_default
3
- } from "../../../chunks/chunk-LFHDJTZJ.js";
4
1
  import {
5
2
  toSharpColor,
6
3
  toSharpInstance
7
- } from "../../../chunks/chunk-ENOTZXFS.js";
4
+ } from "../../../chunks/chunk-6KOJFWH3.js";
5
+ import {
6
+ zod_default
7
+ } from "../../../chunks/chunk-LFHDJTZJ.js";
8
8
  import {
9
9
  makeSuccess
10
10
  } from "../../../chunks/chunk-QEKI6WGQ.js";
11
- import "../../../chunks/chunk-2QDYPY2O.js";
11
+ import "../../../chunks/chunk-RNXRHCHQ.js";
12
+ import "../../../chunks/chunk-DNIOWD7K.js";
12
13
  import {
13
14
  clamp
14
15
  } from "../../../chunks/chunk-OSAXBA7G.js";
@@ -16,7 +17,6 @@ import {
16
17
  isColor
17
18
  } from "../../../chunks/chunk-JDINERKY.js";
18
19
  import "../../../chunks/chunk-HQLRJ7XW.js";
19
- import "../../../chunks/chunk-DNIOWD7K.js";
20
20
  import "../../../chunks/chunk-KRYJVBO5.js";
21
21
  import "../../../chunks/chunk-XCBH6NLF.js";
22
22
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  toSharpInstance
3
- } from "../../../chunks/chunk-ENOTZXFS.js";
4
- import "../../../chunks/chunk-2QDYPY2O.js";
3
+ } from "../../../chunks/chunk-6KOJFWH3.js";
4
+ import "../../../chunks/chunk-RNXRHCHQ.js";
5
+ import "../../../chunks/chunk-DNIOWD7K.js";
5
6
  import "../../../chunks/chunk-OSAXBA7G.js";
6
7
  import "../../../chunks/chunk-JDINERKY.js";
7
8
  import "../../../chunks/chunk-HQLRJ7XW.js";
8
- import "../../../chunks/chunk-DNIOWD7K.js";
9
9
  import "../../../chunks/chunk-KRYJVBO5.js";
10
10
  import "../../../chunks/chunk-XCBH6NLF.js";
11
11