@design-edito/tools 0.2.40 → 0.3.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.
- package/agnostic/booleans/is-falsy/index.test.d.ts +1 -0
- package/agnostic/colors/channels/index.js +3 -3
- package/agnostic/colors/channels/index.test.d.ts +1 -0
- package/agnostic/colors/contrast/index.js +3 -3
- package/agnostic/colors/contrast/index.test.d.ts +1 -0
- package/agnostic/colors/convert/index.js +2 -2
- package/agnostic/colors/convert/index.test.d.ts +1 -0
- package/agnostic/colors/distance/index.js +2 -2
- package/agnostic/colors/distance/index.test.d.ts +1 -0
- package/agnostic/colors/grayscale/index.js +2 -2
- package/agnostic/colors/grayscale/index.test.d.ts +1 -0
- package/agnostic/colors/invert/index.js +3 -3
- package/agnostic/colors/invert/index.test.d.ts +1 -0
- package/agnostic/colors/lerp/index.js +2 -2
- package/agnostic/colors/lerp/index.test.d.ts +1 -0
- package/agnostic/colors/luminance/index.js +3 -3
- package/agnostic/colors/luminance/index.test.d.ts +1 -0
- package/agnostic/colors/palette/index.js +4 -4
- package/agnostic/colors/palette/index.test.d.ts +1 -0
- package/agnostic/colors/rotate/index.js +4 -4
- package/agnostic/colors/rotate/index.test.d.ts +1 -0
- package/agnostic/colors/tidy/index.js +2 -2
- package/agnostic/colors/tidy/index.test.d.ts +1 -0
- package/agnostic/colors/typechecks/index.test.d.ts +1 -0
- package/agnostic/css/bem/index.js +3 -3
- package/agnostic/css/generate-nice-color/index.test.d.ts +1 -0
- package/agnostic/css/is-valid-css-class-name/index.test.d.ts +1 -0
- package/agnostic/errors/unknown-to-string/index.test.d.ts +1 -0
- package/agnostic/html/get-node-ancestors/index.js +2 -1
- package/agnostic/html/get-node-ancestors/index.test.d.ts +1 -0
- package/agnostic/html/get-position-inside-parent/index.test.d.ts +1 -0
- package/agnostic/html/hyper-json/cast/index.js +6 -6
- package/agnostic/html/hyper-json/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/add/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/and/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/append/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/at/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/call/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/hjparse/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/hjstringify/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/if/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/join/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/length/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/map/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/or/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/print/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/push/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/select/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/set/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/split/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/element/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/get/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/global/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/guess/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/number/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/record/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/ref/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/string/index.js +6 -6
- package/agnostic/html/hyper-json/smart-tags/isolated/text/index.js +6 -6
- package/agnostic/html/hyper-json/tree/index.js +6 -6
- package/agnostic/html/hyper-json/utils/index.js +6 -6
- package/agnostic/html/insert-node/index.test.d.ts +1 -0
- package/agnostic/html/replace-in-element/index.js +2 -1
- package/agnostic/html/replace-in-element/index.test.d.ts +1 -0
- package/agnostic/html/selector-to-element/index.js +5 -4
- package/agnostic/html/selector-to-element/index.test.d.ts +1 -0
- package/agnostic/html/string-to-nodes/index.js +3 -1
- package/agnostic/html/string-to-nodes/index.test.d.ts +1 -0
- package/agnostic/misc/cast/index.d.ts +1 -1
- package/agnostic/misc/cast/index.js +1 -1
- package/agnostic/misc/cast/index.test.d.ts +1 -0
- package/agnostic/misc/connection/index.test.d.ts +1 -0
- package/agnostic/misc/crawler/index.d.ts +6 -6
- package/agnostic/misc/crawler/index.js +1 -5
- package/agnostic/misc/crawler/index.test.d.ts +1 -0
- package/agnostic/misc/crossenv/detect-runtime/index.test.d.ts +1 -0
- package/agnostic/misc/crossenv/types.d.ts +1 -0
- package/agnostic/misc/data-size/index.test.d.ts +1 -0
- package/agnostic/misc/is-constructor-function/index.test.d.ts +1 -0
- package/agnostic/misc/is-nullish/index.test.d.ts +1 -0
- package/agnostic/misc/lorem-ipsum/index.test.d.ts +1 -0
- package/agnostic/misc/normalize-extension/index.test.d.ts +1 -0
- package/agnostic/misc/outcome/index.test.d.ts +1 -0
- package/agnostic/numbers/absolute-modulo/index.test.d.ts +1 -0
- package/agnostic/numbers/approximate-rational/index.d.ts +22 -0
- package/agnostic/numbers/approximate-rational/index.js +72 -0
- package/agnostic/numbers/approximate-rational/index.test.d.ts +1 -0
- package/agnostic/numbers/clamp/index.test.d.ts +1 -0
- package/agnostic/numbers/interpolate/index.test.d.ts +1 -0
- package/agnostic/numbers/round/index.test.d.ts +1 -0
- package/agnostic/objects/flatten-getters/index.js +1 -1
- package/agnostic/typescript/types.d.ts +37 -0
- package/agnostic/typescript/types.js +0 -0
- package/chunks/{chunk-27SSMK5F.js → chunk-33SNWUIB.js} +4 -4
- package/chunks/{chunk-LUPVHC73.js → chunk-3MPXVP4L.js} +11 -3
- package/chunks/{chunk-53ILYMIY.js → chunk-AOR2M2H3.js} +3 -3
- package/chunks/{chunk-MSJ7WDFX.js → chunk-ASNS7K6J.js} +3 -3
- package/chunks/{chunk-ENOTZXFS.js → chunk-P6K7NPUZ.js} +1 -1
- package/chunks/{chunk-WF2JNQV4.js → chunk-PC62QFWI.js} +3 -3
- package/chunks/{chunk-C4VX4TTP.js → chunk-QWBT7W6I.js} +2 -2
- package/chunks/{chunk-U225LGOV.js → chunk-RJK53Q5I.js} +3 -3
- package/chunks/{chunk-AKFDKOHE.js → chunk-THWQ7NVE.js} +2 -2
- package/chunks/{chunk-FAAIUU6V.js → chunk-UL4SNGRK.js} +1 -1
- package/chunks/{chunk-HOFEVF7T.js → chunk-YWSXCFYY.js} +1 -1
- package/node/@google-cloud/storage/file/revoke-signed-urls/index.js +3 -3
- package/node/cloud-storage/operations/copy-dir/index.js +3 -3
- package/node/cloud-storage/operations/move-dir/index.js +3 -3
- package/node/cloud-storage/operations/remove-dir/index.js +3 -3
- package/node/cloud-storage/operations/upload-file/index.js +3 -3
- package/node/images/create/index.js +3 -3
- package/node/images/format/index.js +6 -6
- package/node/images/metadata/index.js +3 -3
- package/node/images/transform/index.js +36 -36
- package/node/images/transform/operations/extend/index.js +4 -4
- package/node/images/transform/operations/flatten/index.js +4 -4
- package/node/images/transform/operations/overlay/index.js +4 -4
- package/node/images/transform/operations/resize/index.js +4 -4
- package/node/images/transform/operations/rotate/index.js +4 -4
- package/node/images/utils/index.js +3 -3
- package/package.json +1 -1
- package/chunks/{chunk-2QDYPY2O.js → chunk-LU47ASMQ.js} +3 -3
- package/chunks/{chunk-SGGJJ46D.js → chunk-QQO4QKH2.js} +15 -15
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tree
|
|
3
|
-
} from "../../../../chunks/chunk-
|
|
4
|
-
import "../../../../chunks/chunk-USIYKRNX.js";
|
|
3
|
+
} from "../../../../chunks/chunk-QQO4QKH2.js";
|
|
5
4
|
import "../../../../chunks/chunk-AKNR3U25.js";
|
|
6
|
-
import "../../../../chunks/chunk-ZKIQ753F.js";
|
|
7
5
|
import "../../../../chunks/chunk-XEQ2PBT2.js";
|
|
6
|
+
import "../../../../chunks/chunk-USIYKRNX.js";
|
|
7
|
+
import "../../../../chunks/chunk-ZKIQ753F.js";
|
|
8
8
|
import "../../../../chunks/chunk-HEY7J6GI.js";
|
|
9
|
+
import "../../../../chunks/chunk-XA4HVHJ4.js";
|
|
9
10
|
import "../../../../chunks/chunk-DUCLFPGE.js";
|
|
10
11
|
import "../../../../chunks/chunk-JVMFT3IT.js";
|
|
11
12
|
import "../../../../chunks/chunk-RW7VAKJW.js";
|
|
12
|
-
import "../../../../chunks/chunk-XA4HVHJ4.js";
|
|
13
13
|
import "../../../../chunks/chunk-XNF5MLCQ.js";
|
|
14
14
|
import "../../../../chunks/chunk-E6MSDKON.js";
|
|
15
15
|
import "../../../../chunks/chunk-YDIBNEGA.js";
|
|
16
|
-
import "../../../../chunks/chunk-6XL25OZX.js";
|
|
17
16
|
import "../../../../chunks/chunk-EPUHVR7J.js";
|
|
17
|
+
import "../../../../chunks/chunk-6XL25OZX.js";
|
|
18
18
|
import "../../../../chunks/chunk-QEKI6WGQ.js";
|
|
19
19
|
import "../../../../chunks/chunk-ROWPCMQY.js";
|
|
20
|
-
import "../../../../chunks/chunk-HQLRJ7XW.js";
|
|
21
20
|
import "../../../../chunks/chunk-FENXVJYO.js";
|
|
21
|
+
import "../../../../chunks/chunk-HQLRJ7XW.js";
|
|
22
22
|
import "../../../../chunks/chunk-XCBH6NLF.js";
|
|
23
23
|
export {
|
|
24
24
|
Tree
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Utils
|
|
3
|
-
} from "../../../../chunks/chunk-
|
|
4
|
-
import "../../../../chunks/chunk-USIYKRNX.js";
|
|
3
|
+
} from "../../../../chunks/chunk-QQO4QKH2.js";
|
|
5
4
|
import "../../../../chunks/chunk-AKNR3U25.js";
|
|
6
|
-
import "../../../../chunks/chunk-ZKIQ753F.js";
|
|
7
5
|
import "../../../../chunks/chunk-XEQ2PBT2.js";
|
|
6
|
+
import "../../../../chunks/chunk-USIYKRNX.js";
|
|
7
|
+
import "../../../../chunks/chunk-ZKIQ753F.js";
|
|
8
8
|
import "../../../../chunks/chunk-HEY7J6GI.js";
|
|
9
|
+
import "../../../../chunks/chunk-XA4HVHJ4.js";
|
|
9
10
|
import "../../../../chunks/chunk-DUCLFPGE.js";
|
|
10
11
|
import "../../../../chunks/chunk-JVMFT3IT.js";
|
|
11
12
|
import "../../../../chunks/chunk-RW7VAKJW.js";
|
|
12
|
-
import "../../../../chunks/chunk-XA4HVHJ4.js";
|
|
13
13
|
import "../../../../chunks/chunk-XNF5MLCQ.js";
|
|
14
14
|
import "../../../../chunks/chunk-E6MSDKON.js";
|
|
15
15
|
import "../../../../chunks/chunk-YDIBNEGA.js";
|
|
16
|
-
import "../../../../chunks/chunk-6XL25OZX.js";
|
|
17
16
|
import "../../../../chunks/chunk-EPUHVR7J.js";
|
|
17
|
+
import "../../../../chunks/chunk-6XL25OZX.js";
|
|
18
18
|
import "../../../../chunks/chunk-QEKI6WGQ.js";
|
|
19
19
|
import "../../../../chunks/chunk-ROWPCMQY.js";
|
|
20
|
-
import "../../../../chunks/chunk-HQLRJ7XW.js";
|
|
21
20
|
import "../../../../chunks/chunk-FENXVJYO.js";
|
|
21
|
+
import "../../../../chunks/chunk-HQLRJ7XW.js";
|
|
22
22
|
import "../../../../chunks/chunk-XCBH6NLF.js";
|
|
23
23
|
export {
|
|
24
24
|
Utils
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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]
|
|
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
|
-
|
|
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
|
|
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 `
|
|
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-
|
|
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) =>
|
|
61
|
+
push: (url: string) => void;
|
|
62
62
|
flush: () => void;
|
|
63
63
|
};
|
|
@@ -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 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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-
|
|
4
|
+
} from "./chunk-P6K7NPUZ.js";
|
|
5
|
+
import {
|
|
6
|
+
zod_default
|
|
7
|
+
} from "./chunk-LFHDJTZJ.js";
|
|
8
8
|
import {
|
|
9
9
|
makeFailure,
|
|
10
10
|
makeSuccess
|
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
}
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
toLab,
|
|
4
4
|
toRgb,
|
|
5
5
|
toXyz
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LU47ASMQ.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
|
|
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)
|
|
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,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-
|
|
4
|
-
import "../../../chunks/chunk-
|
|
3
|
+
} from "../../../chunks/chunk-P6K7NPUZ.js";
|
|
4
|
+
import "../../../chunks/chunk-LU47ASMQ.js";
|
|
5
5
|
import "../../../chunks/chunk-OSAXBA7G.js";
|
|
6
|
+
import "../../../chunks/chunk-DNIOWD7K.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
|
|