@design-edito/tools 0.4.11 → 0.4.13
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/arrays/index.d.ts +2 -2
- package/agnostic/arrays/index.js +2 -2
- package/agnostic/colors/index.d.ts +3 -3
- package/agnostic/colors/index.js +3 -3
- package/agnostic/errors/index.d.ts +1 -1
- package/agnostic/errors/index.js +1 -1
- package/agnostic/html/deep-select/index.d.ts +31 -0
- package/agnostic/html/deep-select/index.js +52 -0
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.d.ts +11 -11
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +11 -11
- package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/index.js +2 -2
- package/agnostic/html/index.d.ts +3 -1
- package/agnostic/html/index.js +3 -1
- package/agnostic/html/watch-selection/index.d.ts +41 -0
- package/agnostic/html/watch-selection/index.js +50 -0
- package/agnostic/index.d.ts +2 -2
- package/agnostic/index.js +2 -2
- package/agnostic/misc/index.d.ts +3 -3
- package/agnostic/misc/index.js +3 -3
- package/agnostic/misc/logs/index.d.ts +2 -2
- package/agnostic/misc/logs/index.js +2 -2
- package/agnostic/numbers/index.d.ts +2 -2
- package/agnostic/numbers/index.js +2 -2
- package/agnostic/objects/index.d.ts +3 -3
- package/agnostic/objects/index.js +3 -3
- package/agnostic/random/index.d.ts +1 -1
- package/agnostic/random/index.js +1 -1
- package/agnostic/strings/index.d.ts +2 -1
- package/agnostic/strings/index.js +2 -1
- package/agnostic/strings/split-trim/index.d.ts +27 -0
- package/agnostic/strings/split-trim/index.js +36 -0
- package/agnostic/time/index.d.ts +1 -1
- package/agnostic/time/index.js +1 -1
- package/components/Video/index.controlled.d.ts +153 -0
- package/components/Video/index.controlled.js +255 -0
- package/components/Video/index.d.ts +10 -114
- package/components/Video/index.js +140 -265
- package/components/Video/utils.d.ts +11 -10
- package/components/Video/utils.js +30 -37
- package/components/index.d.ts +1 -1
- package/components/index.js +1 -1
- package/components/public-classnames.d.ts +1 -0
- package/components/public-classnames.js +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/node/@aws-s3/storage/file/index.d.ts +1 -1
- package/node/@aws-s3/storage/file/index.js +1 -1
- package/node/@google-cloud/storage/file/index.d.ts +2 -2
- package/node/@google-cloud/storage/file/index.js +2 -2
- package/node/ftps/file/index.d.ts +2 -2
- package/node/ftps/file/index.js +2 -2
- package/node/images/transform/operations/index.d.ts +2 -2
- package/node/images/transform/operations/index.js +2 -2
- package/node/index.d.ts +1 -1
- package/node/index.js +1 -1
- package/package.json +22 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as dedupe from './dedupe/index.js'
|
|
2
1
|
export * as findDuplicates from './find-duplicates/index.js'
|
|
3
|
-
export * as make from './make/index.js'
|
|
4
2
|
export * as isArrayOf from './is-array-of/index.js'
|
|
5
3
|
export * as randomPick from './random-pick/index.js'
|
|
4
|
+
export * as make from './make/index.js'
|
|
6
5
|
export * as shuffle from './shuffle/index.js'
|
|
6
|
+
export * as dedupe from './dedupe/index.js'
|
package/agnostic/arrays/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as dedupe from './dedupe/index.js'
|
|
2
1
|
export * as findDuplicates from './find-duplicates/index.js'
|
|
3
|
-
export * as make from './make/index.js'
|
|
4
2
|
export * as isArrayOf from './is-array-of/index.js'
|
|
5
3
|
export * as randomPick from './random-pick/index.js'
|
|
4
|
+
export * as make from './make/index.js'
|
|
6
5
|
export * as shuffle from './shuffle/index.js'
|
|
6
|
+
export * as dedupe from './dedupe/index.js'
|
|
@@ -4,9 +4,9 @@ export * as convert from './convert/index.js'
|
|
|
4
4
|
export * as distance from './distance/index.js'
|
|
5
5
|
export * as grayscale from './grayscale/index.js'
|
|
6
6
|
export * as invert from './invert/index.js'
|
|
7
|
-
export * as luminance from './luminance/index.js'
|
|
8
|
-
export * as palette from './palette/index.js'
|
|
9
7
|
export * as lerp from './lerp/index.js'
|
|
8
|
+
export * as palette from './palette/index.js'
|
|
10
9
|
export * as rotate from './rotate/index.js'
|
|
11
|
-
export * as typechecks from './typechecks/index.js'
|
|
12
10
|
export * as tidy from './tidy/index.js'
|
|
11
|
+
export * as typechecks from './typechecks/index.js'
|
|
12
|
+
export * as luminance from './luminance/index.js'
|
package/agnostic/colors/index.js
CHANGED
|
@@ -4,9 +4,9 @@ export * as convert from './convert/index.js'
|
|
|
4
4
|
export * as distance from './distance/index.js'
|
|
5
5
|
export * as grayscale from './grayscale/index.js'
|
|
6
6
|
export * as invert from './invert/index.js'
|
|
7
|
-
export * as luminance from './luminance/index.js'
|
|
8
|
-
export * as palette from './palette/index.js'
|
|
9
7
|
export * as lerp from './lerp/index.js'
|
|
8
|
+
export * as palette from './palette/index.js'
|
|
10
9
|
export * as rotate from './rotate/index.js'
|
|
11
|
-
export * as typechecks from './typechecks/index.js'
|
|
12
10
|
export * as tidy from './tidy/index.js'
|
|
11
|
+
export * as typechecks from './typechecks/index.js'
|
|
12
|
+
export * as luminance from './luminance/index.js'
|
package/agnostic/errors/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Options for `deepSelect`. */
|
|
2
|
+
type Options = {
|
|
3
|
+
/** Root node to start traversal from. Defaults to `document`. */
|
|
4
|
+
fromElement?: Element;
|
|
5
|
+
/** Number of element nodes to visit before yielding to the main thread. Defaults to `500`. */
|
|
6
|
+
chunkSize?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Queries the DOM for all elements matching a CSS selector, including inside open shadow roots.
|
|
10
|
+
*
|
|
11
|
+
* Walks the tree with `document.createTreeWalker` instead of `querySelectorAll`, so traversal can
|
|
12
|
+
* descend into `element.shadowRoot` trees that standard selectors do not pierce. The traversal
|
|
13
|
+
* root (`fromElement` or `document`) is never included in the results, even if it matches.
|
|
14
|
+
*
|
|
15
|
+
* Yields to the main thread every `chunkSize` visited nodes, using `scheduler.yield()` when
|
|
16
|
+
* available or `setTimeout(0)` as a fallback. Requires a browser environment with `document`.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} selector - CSS selector tested with `Element.prototype.matches`.
|
|
19
|
+
* @param {Options} [options] - Optional configuration:
|
|
20
|
+
* - `fromElement`: Element (or `document`) to start the walk from.
|
|
21
|
+
* - `chunkSize`: How many element nodes to process between yields.
|
|
22
|
+
* @returns {Promise<Element[]>} All matching elements in tree-walker order (depth-first).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const items = await deepSelect('[data-item]', { fromElement: app })
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const labels = await deepSelect('.label', { chunkSize: 100 })
|
|
29
|
+
*/
|
|
30
|
+
export declare const deepSelect: (selector: string, options?: Options) => Promise<Element[]>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as Window from '../../misc/crossenv/window/index.js';
|
|
2
|
+
const yieldToMain = async (windowLike) => {
|
|
3
|
+
if (typeof windowLike.scheduler?.yield === 'function')
|
|
4
|
+
return windowLike.scheduler.yield();
|
|
5
|
+
return await new Promise(resolve => setTimeout(resolve, 0));
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Queries the DOM for all elements matching a CSS selector, including inside open shadow roots.
|
|
9
|
+
*
|
|
10
|
+
* Walks the tree with `document.createTreeWalker` instead of `querySelectorAll`, so traversal can
|
|
11
|
+
* descend into `element.shadowRoot` trees that standard selectors do not pierce. The traversal
|
|
12
|
+
* root (`fromElement` or `document`) is never included in the results, even if it matches.
|
|
13
|
+
*
|
|
14
|
+
* Yields to the main thread every `chunkSize` visited nodes, using `scheduler.yield()` when
|
|
15
|
+
* available or `setTimeout(0)` as a fallback. Requires a browser environment with `document`.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} selector - CSS selector tested with `Element.prototype.matches`.
|
|
18
|
+
* @param {Options} [options] - Optional configuration:
|
|
19
|
+
* - `fromElement`: Element (or `document`) to start the walk from.
|
|
20
|
+
* - `chunkSize`: How many element nodes to process between yields.
|
|
21
|
+
* @returns {Promise<Element[]>} All matching elements in tree-walker order (depth-first).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const items = await deepSelect('[data-item]', { fromElement: app })
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const labels = await deepSelect('.label', { chunkSize: 100 })
|
|
28
|
+
*/
|
|
29
|
+
export const deepSelect = async (selector, options) => {
|
|
30
|
+
const window = Window.get();
|
|
31
|
+
const { document } = window;
|
|
32
|
+
const from = options?.fromElement ?? document;
|
|
33
|
+
const results = [];
|
|
34
|
+
const chunkSize = options?.chunkSize ?? 500;
|
|
35
|
+
let nodeCount = 0;
|
|
36
|
+
const traverse = async (root) => {
|
|
37
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
38
|
+
let node = walker.currentNode;
|
|
39
|
+
while (node !== null) {
|
|
40
|
+
if (node !== root && node instanceof Element && node.matches(selector))
|
|
41
|
+
results.push(node);
|
|
42
|
+
if (node instanceof Element && node.shadowRoot !== null)
|
|
43
|
+
await traverse(node.shadowRoot);
|
|
44
|
+
nodeCount++;
|
|
45
|
+
if (nodeCount % chunkSize === 0)
|
|
46
|
+
await yieldToMain(window);
|
|
47
|
+
node = walker.nextNode();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
await traverse(from);
|
|
51
|
+
return results;
|
|
52
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * as add from './add/index.js'
|
|
2
|
+
export * as addclass from './addclass/index.js'
|
|
2
3
|
export * as and from './and/index.js'
|
|
3
4
|
export * as append from './append/index.js'
|
|
4
5
|
export * as at from './at/index.js'
|
|
5
6
|
export * as call from './call/index.js'
|
|
6
|
-
export * as addclass from './addclass/index.js'
|
|
7
7
|
export * as clone from './clone/index.js'
|
|
8
8
|
export * as deleteproperties from './deleteproperties/index.js'
|
|
9
9
|
export * as getattribute from './getattribute/index.js'
|
|
10
|
+
export * as equals from './equals/index.js'
|
|
10
11
|
export * as getproperties from './getproperties/index.js'
|
|
11
12
|
export * as getproperty from './getproperty/index.js'
|
|
12
13
|
export * as hjparse from './hjparse/index.js'
|
|
13
|
-
export * as equals from './equals/index.js'
|
|
14
14
|
export * as hjstringify from './hjstringify/index.js'
|
|
15
15
|
export * as if from './if/index.js'
|
|
16
16
|
export * as initialize from './initialize/index.js'
|
|
@@ -20,33 +20,33 @@ export * as map from './map/index.js'
|
|
|
20
20
|
export * as negate from './negate/index.js'
|
|
21
21
|
export * as notrailing from './notrailing/index.js'
|
|
22
22
|
export * as or from './or/index.js'
|
|
23
|
-
export * as pickrandom from './pickrandom/index.js'
|
|
24
23
|
export * as populate from './populate/index.js'
|
|
24
|
+
export * as pickrandom from './pickrandom/index.js'
|
|
25
|
+
export * as print from './print/index.js'
|
|
25
26
|
export * as push from './push/index.js'
|
|
26
27
|
export * as pusheach from './pusheach/index.js'
|
|
28
|
+
export * as recordtoarray from './recordtoarray/index.js'
|
|
27
29
|
export * as removeattribute from './removeattribute/index.js'
|
|
28
30
|
export * as removeclass from './removeclass/index.js'
|
|
29
|
-
export * as recordtoarray from './recordtoarray/index.js'
|
|
30
|
-
export * as print from './print/index.js'
|
|
31
|
-
export * as renameproperty from './renameproperty/index.js'
|
|
32
31
|
export * as replace from './replace/index.js'
|
|
33
32
|
export * as select from './select/index.js'
|
|
34
33
|
export * as set from './set/index.js'
|
|
35
34
|
export * as setattribute from './setattribute/index.js'
|
|
35
|
+
export * as setproperty from './setproperty/index.js'
|
|
36
36
|
export * as sorton from './sorton/index.js'
|
|
37
37
|
export * as split from './split/index.js'
|
|
38
38
|
export * as spread from './spread/index.js'
|
|
39
|
-
export * as setproperty from './setproperty/index.js'
|
|
40
|
-
export * as toelement from './toelement/index.js'
|
|
41
|
-
export * as toboolean from './toboolean/index.js'
|
|
42
39
|
export * as toarray from './toarray/index.js'
|
|
40
|
+
export * as toboolean from './toboolean/index.js'
|
|
41
|
+
export * as renameproperty from './renameproperty/index.js'
|
|
42
|
+
export * as toelement from './toelement/index.js'
|
|
43
43
|
export * as toggleclass from './toggleclass/index.js'
|
|
44
|
+
export * as tonodelist from './tonodelist/index.js'
|
|
44
45
|
export * as tonull from './tonull/index.js'
|
|
45
46
|
export * as tonumber from './tonumber/index.js'
|
|
46
47
|
export * as torecord from './torecord/index.js'
|
|
47
|
-
export * as toref from './toref/index.js'
|
|
48
48
|
export * as tostring from './tostring/index.js'
|
|
49
49
|
export * as totext from './totext/index.js'
|
|
50
|
+
export * as toref from './toref/index.js'
|
|
50
51
|
export * as transformselected from './transformselected/index.js'
|
|
51
52
|
export * as trim from './trim/index.js'
|
|
52
|
-
export * as tonodelist from './tonodelist/index.js'
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * as add from './add/index.js'
|
|
2
|
+
export * as addclass from './addclass/index.js'
|
|
2
3
|
export * as and from './and/index.js'
|
|
3
4
|
export * as append from './append/index.js'
|
|
4
5
|
export * as at from './at/index.js'
|
|
5
6
|
export * as call from './call/index.js'
|
|
6
|
-
export * as addclass from './addclass/index.js'
|
|
7
7
|
export * as clone from './clone/index.js'
|
|
8
8
|
export * as deleteproperties from './deleteproperties/index.js'
|
|
9
9
|
export * as getattribute from './getattribute/index.js'
|
|
10
|
+
export * as equals from './equals/index.js'
|
|
10
11
|
export * as getproperties from './getproperties/index.js'
|
|
11
12
|
export * as getproperty from './getproperty/index.js'
|
|
12
13
|
export * as hjparse from './hjparse/index.js'
|
|
13
|
-
export * as equals from './equals/index.js'
|
|
14
14
|
export * as hjstringify from './hjstringify/index.js'
|
|
15
15
|
export * as if from './if/index.js'
|
|
16
16
|
export * as initialize from './initialize/index.js'
|
|
@@ -20,33 +20,33 @@ export * as map from './map/index.js'
|
|
|
20
20
|
export * as negate from './negate/index.js'
|
|
21
21
|
export * as notrailing from './notrailing/index.js'
|
|
22
22
|
export * as or from './or/index.js'
|
|
23
|
-
export * as pickrandom from './pickrandom/index.js'
|
|
24
23
|
export * as populate from './populate/index.js'
|
|
24
|
+
export * as pickrandom from './pickrandom/index.js'
|
|
25
|
+
export * as print from './print/index.js'
|
|
25
26
|
export * as push from './push/index.js'
|
|
26
27
|
export * as pusheach from './pusheach/index.js'
|
|
28
|
+
export * as recordtoarray from './recordtoarray/index.js'
|
|
27
29
|
export * as removeattribute from './removeattribute/index.js'
|
|
28
30
|
export * as removeclass from './removeclass/index.js'
|
|
29
|
-
export * as recordtoarray from './recordtoarray/index.js'
|
|
30
|
-
export * as print from './print/index.js'
|
|
31
|
-
export * as renameproperty from './renameproperty/index.js'
|
|
32
31
|
export * as replace from './replace/index.js'
|
|
33
32
|
export * as select from './select/index.js'
|
|
34
33
|
export * as set from './set/index.js'
|
|
35
34
|
export * as setattribute from './setattribute/index.js'
|
|
35
|
+
export * as setproperty from './setproperty/index.js'
|
|
36
36
|
export * as sorton from './sorton/index.js'
|
|
37
37
|
export * as split from './split/index.js'
|
|
38
38
|
export * as spread from './spread/index.js'
|
|
39
|
-
export * as setproperty from './setproperty/index.js'
|
|
40
|
-
export * as toelement from './toelement/index.js'
|
|
41
|
-
export * as toboolean from './toboolean/index.js'
|
|
42
39
|
export * as toarray from './toarray/index.js'
|
|
40
|
+
export * as toboolean from './toboolean/index.js'
|
|
41
|
+
export * as renameproperty from './renameproperty/index.js'
|
|
42
|
+
export * as toelement from './toelement/index.js'
|
|
43
43
|
export * as toggleclass from './toggleclass/index.js'
|
|
44
|
+
export * as tonodelist from './tonodelist/index.js'
|
|
44
45
|
export * as tonull from './tonull/index.js'
|
|
45
46
|
export * as tonumber from './tonumber/index.js'
|
|
46
47
|
export * as torecord from './torecord/index.js'
|
|
47
|
-
export * as toref from './toref/index.js'
|
|
48
48
|
export * as tostring from './tostring/index.js'
|
|
49
49
|
export * as totext from './totext/index.js'
|
|
50
|
+
export * as toref from './toref/index.js'
|
|
50
51
|
export * as transformselected from './transformselected/index.js'
|
|
51
52
|
export * as trim from './trim/index.js'
|
|
52
|
-
export * as tonodelist from './tonodelist/index.js'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * as any from './any/index.js'
|
|
2
1
|
export * as array from './array/index.js'
|
|
3
|
-
export * as element from './element/index.js'
|
|
4
2
|
export * as boolean from './boolean/index.js'
|
|
3
|
+
export * as element from './element/index.js'
|
|
5
4
|
export * as get from './get/index.js'
|
|
6
5
|
export * as guess from './guess/index.js'
|
|
7
6
|
export * as nodelist from './nodelist/index.js'
|
|
8
7
|
export * as null from './null/index.js'
|
|
9
8
|
export * as number from './number/index.js'
|
|
9
|
+
export * as any from './any/index.js'
|
|
10
10
|
export * as record from './record/index.js'
|
|
11
11
|
export * as ref from './ref/index.js'
|
|
12
12
|
export * as text from './text/index.js'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * as any from './any/index.js'
|
|
2
1
|
export * as array from './array/index.js'
|
|
3
|
-
export * as element from './element/index.js'
|
|
4
2
|
export * as boolean from './boolean/index.js'
|
|
3
|
+
export * as element from './element/index.js'
|
|
5
4
|
export * as get from './get/index.js'
|
|
6
5
|
export * as guess from './guess/index.js'
|
|
7
6
|
export * as nodelist from './nodelist/index.js'
|
|
8
7
|
export * as null from './null/index.js'
|
|
9
8
|
export * as number from './number/index.js'
|
|
9
|
+
export * as any from './any/index.js'
|
|
10
10
|
export * as record from './record/index.js'
|
|
11
11
|
export * as ref from './ref/index.js'
|
|
12
12
|
export * as text from './text/index.js'
|
package/agnostic/html/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export * as deepSelect from './deep-select/index.js'
|
|
1
2
|
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
2
3
|
export * as getPositionInsideParent from './get-position-inside-parent/index.js'
|
|
3
4
|
export * as hyperJson from './hyper-json/index.js'
|
|
4
5
|
export * as insertNode from './insert-node/index.js'
|
|
5
6
|
export * as placeholders from './placeholders/index.js'
|
|
6
7
|
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
|
-
export * as stringToNodes from './string-to-nodes/index.js'
|
|
8
8
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
9
|
+
export * as stringToNodes from './string-to-nodes/index.js'
|
|
10
|
+
export * as watchSelection from './watch-selection/index.js'
|
package/agnostic/html/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export * as deepSelect from './deep-select/index.js'
|
|
1
2
|
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
2
3
|
export * as getPositionInsideParent from './get-position-inside-parent/index.js'
|
|
3
4
|
export * as hyperJson from './hyper-json/index.js'
|
|
4
5
|
export * as insertNode from './insert-node/index.js'
|
|
5
6
|
export * as placeholders from './placeholders/index.js'
|
|
6
7
|
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
|
-
export * as stringToNodes from './string-to-nodes/index.js'
|
|
8
8
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
9
|
+
export * as stringToNodes from './string-to-nodes/index.js'
|
|
10
|
+
export * as watchSelection from './watch-selection/index.js'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Options for `watchSelection`. */
|
|
2
|
+
type Options = {
|
|
3
|
+
/** Called when a matching element newly appears in the selection. Defaults to a no-op. */
|
|
4
|
+
watch?: (elt: Element) => void;
|
|
5
|
+
/** Called when a matching element is no longer in the selection. Defaults to a no-op. */
|
|
6
|
+
unwatch?: (elt: Element) => void;
|
|
7
|
+
/** Interval in milliseconds between selection polls. Defaults to `100`. */
|
|
8
|
+
selectIntervalMs?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Watches a CSS selector over time and invokes callbacks when the matching set changes.
|
|
12
|
+
*
|
|
13
|
+
* Performs an initial `deepSelect`, calls `watch` on every match, then polls on a fixed interval.
|
|
14
|
+
* On each poll, newly matched elements trigger `watch` and elements that disappeared trigger
|
|
15
|
+
* `unwatch`. Comparison uses element identity (`===`), not structural equality.
|
|
16
|
+
*
|
|
17
|
+
* Requires a browser environment with `window` and `document`.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} selector - CSS selector passed to `deepSelect`.
|
|
20
|
+
* @param {Options} options - Callbacks and polling configuration:
|
|
21
|
+
* - `watch`: Handler for elements that enter the selection.
|
|
22
|
+
* - `unwatch`: Handler for elements that leave the selection.
|
|
23
|
+
* - `selectIntervalMs`: Delay between polls in milliseconds.
|
|
24
|
+
* @returns {Promise<{ kill: () => void }>}
|
|
25
|
+
* Resolves after the initial selection is processed. `kill` stops polling and calls `unwatch`
|
|
26
|
+
* on every element still watched.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const { kill } = await watchSelection('.widget', {
|
|
30
|
+
* watch: elt => elt.classList.add('is-active'),
|
|
31
|
+
* unwatch: elt => elt.classList.remove('is-active'),
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // later, when tearing down:
|
|
36
|
+
* kill()
|
|
37
|
+
*/
|
|
38
|
+
export declare const watchSelection: (selector: string, options: Options) => Promise<{
|
|
39
|
+
kill: () => void;
|
|
40
|
+
}>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { deepSelect } from '../deep-select/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Watches a CSS selector over time and invokes callbacks when the matching set changes.
|
|
4
|
+
*
|
|
5
|
+
* Performs an initial `deepSelect`, calls `watch` on every match, then polls on a fixed interval.
|
|
6
|
+
* On each poll, newly matched elements trigger `watch` and elements that disappeared trigger
|
|
7
|
+
* `unwatch`. Comparison uses element identity (`===`), not structural equality.
|
|
8
|
+
*
|
|
9
|
+
* Requires a browser environment with `window` and `document`.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} selector - CSS selector passed to `deepSelect`.
|
|
12
|
+
* @param {Options} options - Callbacks and polling configuration:
|
|
13
|
+
* - `watch`: Handler for elements that enter the selection.
|
|
14
|
+
* - `unwatch`: Handler for elements that leave the selection.
|
|
15
|
+
* - `selectIntervalMs`: Delay between polls in milliseconds.
|
|
16
|
+
* @returns {Promise<{ kill: () => void }>}
|
|
17
|
+
* Resolves after the initial selection is processed. `kill` stops polling and calls `unwatch`
|
|
18
|
+
* on every element still watched.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const { kill } = await watchSelection('.widget', {
|
|
22
|
+
* watch: elt => elt.classList.add('is-active'),
|
|
23
|
+
* unwatch: elt => elt.classList.remove('is-active'),
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // later, when tearing down:
|
|
28
|
+
* kill()
|
|
29
|
+
*/
|
|
30
|
+
export const watchSelection = async (selector, options) => {
|
|
31
|
+
const watch = options?.watch ?? (() => { });
|
|
32
|
+
const unwatch = options?.unwatch ?? (() => { });
|
|
33
|
+
let watched = await deepSelect(selector);
|
|
34
|
+
watched.forEach(watch);
|
|
35
|
+
const selectIntervalMs = options?.selectIntervalMs ?? 100;
|
|
36
|
+
const interval = window.setInterval(() => {
|
|
37
|
+
void deepSelect(selector).then(watchedNow => {
|
|
38
|
+
const staleWatched = watched.filter(elt => !watchedNow.includes(elt));
|
|
39
|
+
const newWatched = watchedNow.filter(elt => !watched.includes(elt));
|
|
40
|
+
staleWatched.forEach(unwatch);
|
|
41
|
+
newWatched.forEach(watch);
|
|
42
|
+
watched = watchedNow;
|
|
43
|
+
});
|
|
44
|
+
}, selectIntervalMs);
|
|
45
|
+
const kill = () => {
|
|
46
|
+
window.clearInterval(interval);
|
|
47
|
+
watched.forEach(unwatch);
|
|
48
|
+
};
|
|
49
|
+
return { kill };
|
|
50
|
+
};
|
package/agnostic/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
export * as arrays from './arrays/index.js'
|
|
1
2
|
export * as booleans from './booleans/index.js'
|
|
2
3
|
export * as colors from './colors/index.js'
|
|
3
4
|
export * as css from './css/index.js'
|
|
4
5
|
export * as errors from './errors/index.js'
|
|
5
6
|
export * as html from './html/index.js'
|
|
6
|
-
export * as numbers from './numbers/index.js'
|
|
7
7
|
export * as misc from './misc/index.js'
|
|
8
|
-
export * as arrays from './arrays/index.js'
|
|
9
8
|
export * as objects from './objects/index.js'
|
|
10
9
|
export * as optim from './optim/index.js'
|
|
10
|
+
export * as numbers from './numbers/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
12
|
export * as regexps from './regexps/index.js'
|
|
13
13
|
export * as sanitization from './sanitization/index.js'
|
package/agnostic/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
export * as arrays from './arrays/index.js'
|
|
1
2
|
export * as booleans from './booleans/index.js'
|
|
2
3
|
export * as colors from './colors/index.js'
|
|
3
4
|
export * as css from './css/index.js'
|
|
4
5
|
export * as errors from './errors/index.js'
|
|
5
6
|
export * as html from './html/index.js'
|
|
6
|
-
export * as numbers from './numbers/index.js'
|
|
7
7
|
export * as misc from './misc/index.js'
|
|
8
|
-
export * as arrays from './arrays/index.js'
|
|
9
8
|
export * as objects from './objects/index.js'
|
|
10
9
|
export * as optim from './optim/index.js'
|
|
10
|
+
export * as numbers from './numbers/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
12
|
export * as regexps from './regexps/index.js'
|
|
13
13
|
export * as sanitization from './sanitization/index.js'
|
package/agnostic/misc/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * as assert from './assert/index.js'
|
|
2
2
|
export * as connection from './connection/index.js'
|
|
3
|
-
export * as cast from './cast/index.js'
|
|
4
3
|
export * as crawler from './crawler/index.js'
|
|
5
4
|
export * as crossenv from './crossenv/index.js'
|
|
6
5
|
export * as dataSize from './data-size/index.js'
|
|
6
|
+
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
7
|
+
export * as cast from './cast/index.js'
|
|
7
8
|
export * as isNullish from './is-nullish/index.js'
|
|
9
|
+
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
8
10
|
export * as logs from './logs/index.js'
|
|
9
|
-
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
10
11
|
export * as normalizeExtension from './normalize-extension/index.js'
|
|
11
12
|
export * as outcome from './outcome/index.js'
|
|
12
|
-
export * as loremIpsum from './lorem-ipsum/index.js'
|
package/agnostic/misc/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * as assert from './assert/index.js'
|
|
2
2
|
export * as connection from './connection/index.js'
|
|
3
|
-
export * as cast from './cast/index.js'
|
|
4
3
|
export * as crawler from './crawler/index.js'
|
|
5
4
|
export * as crossenv from './crossenv/index.js'
|
|
6
5
|
export * as dataSize from './data-size/index.js'
|
|
6
|
+
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
7
|
+
export * as cast from './cast/index.js'
|
|
7
8
|
export * as isNullish from './is-nullish/index.js'
|
|
9
|
+
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
8
10
|
export * as logs from './logs/index.js'
|
|
9
|
-
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
10
11
|
export * as normalizeExtension from './normalize-extension/index.js'
|
|
11
12
|
export * as outcome from './outcome/index.js'
|
|
12
|
-
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
|
-
export * as
|
|
2
|
+
export * as approximateRational from './approximate-rational/index.js'
|
|
3
3
|
export * as clamp from './clamp/index.js'
|
|
4
|
+
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
4
5
|
export * as interpolate from './interpolate/index.js'
|
|
5
6
|
export * as round from './round/index.js'
|
|
6
|
-
export * as approximateRational from './approximate-rational/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
|
-
export * as
|
|
2
|
+
export * as approximateRational from './approximate-rational/index.js'
|
|
3
3
|
export * as clamp from './clamp/index.js'
|
|
4
|
+
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
4
5
|
export * as interpolate from './interpolate/index.js'
|
|
5
6
|
export * as round from './round/index.js'
|
|
6
|
-
export * as approximateRational from './approximate-rational/index.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * as enums from './enums/index.js'
|
|
2
|
-
export * as isObject from './is-object/index.js'
|
|
3
2
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
3
|
+
export * as isObject from './is-object/index.js'
|
|
4
4
|
export * as isRecord from './is-record/index.js'
|
|
5
|
-
export * as deepGetProperty from './deep-get-property/index.js'
|
|
6
5
|
export * as recordFormat from './record-format/index.js'
|
|
7
6
|
export * as recordMap from './record-map/index.js'
|
|
8
|
-
export * as sortKeys from './sort-keys/index.js'
|
|
9
7
|
export * as validation from './validation/index.js'
|
|
8
|
+
export * as sortKeys from './sort-keys/index.js'
|
|
9
|
+
export * as deepGetProperty from './deep-get-property/index.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * as enums from './enums/index.js'
|
|
2
|
-
export * as isObject from './is-object/index.js'
|
|
3
2
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
3
|
+
export * as isObject from './is-object/index.js'
|
|
4
4
|
export * as isRecord from './is-record/index.js'
|
|
5
|
-
export * as deepGetProperty from './deep-get-property/index.js'
|
|
6
5
|
export * as recordFormat from './record-format/index.js'
|
|
7
6
|
export * as recordMap from './record-map/index.js'
|
|
8
|
-
export * as sortKeys from './sort-keys/index.js'
|
|
9
7
|
export * as validation from './validation/index.js'
|
|
8
|
+
export * as sortKeys from './sort-keys/index.js'
|
|
9
|
+
export * as deepGetProperty from './deep-get-property/index.js'
|
package/agnostic/random/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export * as charCodes from './char-codes/index.js'
|
|
1
2
|
export * as matches from './matches/index.js'
|
|
2
3
|
export * as normalizeIndent from './normalize-indent/index.js'
|
|
3
4
|
export * as parseTable from './parse-table/index.js'
|
|
4
5
|
export * as replaceAll from './replace-all/index.js'
|
|
6
|
+
export * as splitTrim from './split-trim/index.js'
|
|
5
7
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
6
8
|
export * as trim from './trim/index.js'
|
|
7
|
-
export * as charCodes from './char-codes/index.js'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export * as charCodes from './char-codes/index.js'
|
|
1
2
|
export * as matches from './matches/index.js'
|
|
2
3
|
export * as normalizeIndent from './normalize-indent/index.js'
|
|
3
4
|
export * as parseTable from './parse-table/index.js'
|
|
4
5
|
export * as replaceAll from './replace-all/index.js'
|
|
6
|
+
export * as splitTrim from './split-trim/index.js'
|
|
5
7
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
6
8
|
export * as trim from './trim/index.js'
|
|
7
|
-
export * as charCodes from './char-codes/index.js'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits a string into segments, trims whitespace from each part, and optionally removes empty segments.
|
|
3
|
+
*
|
|
4
|
+
* Each segment is trimmed with `String.prototype.trim`. When `removeEmpty` is `true`, segments that
|
|
5
|
+
* become empty after trimming are filtered out.
|
|
6
|
+
*
|
|
7
|
+
* When `splitter` is an array, each separator is applied in order: every current segment is split
|
|
8
|
+
* with the next separator before moving on to the following one.
|
|
9
|
+
*
|
|
10
|
+
* @param toSplit - The string to split.
|
|
11
|
+
* @param splitter - A single separator, or an ordered list of separators passed to `String.prototype.split`.
|
|
12
|
+
* @param removeEmpty - When `true`, drops segments that are empty after trimming. Defaults to `false`.
|
|
13
|
+
* @returns An array of trimmed string segments.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* splitTrim(' foo , bar , baz ', ',')
|
|
17
|
+
* // => ['foo', 'bar', 'baz']
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* splitTrim('foo,,bar', ',', true)
|
|
21
|
+
* // => ['foo', 'bar']
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* splitTrim('foo bar,baz', [' ', ','])
|
|
25
|
+
* // => ['foo', 'bar', 'baz']
|
|
26
|
+
*/
|
|
27
|
+
export declare const splitTrim: (toSplit: string, splitter: string | RegExp | Array<string | RegExp>, removeEmpty?: boolean) => string[];
|