@design-edito/tools 0.4.11 → 0.4.12
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 +1 -1
- package/agnostic/arrays/index.js +1 -1
- package/agnostic/colors/index.d.ts +2 -2
- package/agnostic/colors/index.js +2 -2
- package/agnostic/css/index.d.ts +1 -1
- package/agnostic/css/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 +14 -14
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +14 -14
- 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 +3 -3
- package/agnostic/index.js +3 -3
- package/agnostic/misc/index.d.ts +3 -3
- package/agnostic/misc/index.js +3 -3
- package/agnostic/misc/logs/index.d.ts +1 -1
- package/agnostic/misc/logs/index.js +1 -1
- 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/sanitization/index.d.ts +1 -1
- package/agnostic/sanitization/index.js +1 -1
- package/agnostic/strings/index.d.ts +3 -2
- package/agnostic/strings/index.js +3 -2
- package/agnostic/strings/split-trim/index.d.ts +27 -0
- package/agnostic/strings/split-trim/index.js +36 -0
- 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/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/@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 +1 -1
- package/node/images/transform/operations/index.js +1 -1
- package/node/index.d.ts +1 -1
- package/node/index.js +1 -1
- package/package.json +22 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as dedupe from './dedupe/index.js'
|
|
2
2
|
export * as findDuplicates from './find-duplicates/index.js'
|
|
3
|
-
export * as make from './make/index.js'
|
|
4
3
|
export * as isArrayOf from './is-array-of/index.js'
|
|
4
|
+
export * as make from './make/index.js'
|
|
5
5
|
export * as randomPick from './random-pick/index.js'
|
|
6
6
|
export * as shuffle from './shuffle/index.js'
|
package/agnostic/arrays/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as dedupe from './dedupe/index.js'
|
|
2
2
|
export * as findDuplicates from './find-duplicates/index.js'
|
|
3
|
-
export * as make from './make/index.js'
|
|
4
3
|
export * as isArrayOf from './is-array-of/index.js'
|
|
4
|
+
export * as make from './make/index.js'
|
|
5
5
|
export * as randomPick from './random-pick/index.js'
|
|
6
6
|
export * as shuffle from './shuffle/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 lerp from './lerp/index.js'
|
|
7
8
|
export * as luminance from './luminance/index.js'
|
|
8
9
|
export * as palette from './palette/index.js'
|
|
9
|
-
export * as lerp from './lerp/index.js'
|
|
10
10
|
export * as rotate from './rotate/index.js'
|
|
11
|
-
export * as typechecks from './typechecks/index.js'
|
|
12
11
|
export * as tidy from './tidy/index.js'
|
|
12
|
+
export * as typechecks from './typechecks/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 lerp from './lerp/index.js'
|
|
7
8
|
export * as luminance from './luminance/index.js'
|
|
8
9
|
export * as palette from './palette/index.js'
|
|
9
|
-
export * as lerp from './lerp/index.js'
|
|
10
10
|
export * as rotate from './rotate/index.js'
|
|
11
|
-
export * as typechecks from './typechecks/index.js'
|
|
12
11
|
export * as tidy from './tidy/index.js'
|
|
12
|
+
export * as typechecks from './typechecks/index.js'
|
package/agnostic/css/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as bem from './bem/index.js'
|
|
2
1
|
export * as clss from './clss/index.js'
|
|
3
2
|
export * as generateNiceColor from './generate-nice-color/index.js'
|
|
4
3
|
export * as isValidCssClassName from './is-valid-css-class-name/index.js'
|
|
5
4
|
export * as scale from './scale/index.js'
|
|
5
|
+
export * as bem from './bem/index.js'
|
|
6
6
|
export * as stylesSet from './styles-set/index.js'
|
package/agnostic/css/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as bem from './bem/index.js'
|
|
2
1
|
export * as clss from './clss/index.js'
|
|
3
2
|
export * as generateNiceColor from './generate-nice-color/index.js'
|
|
4
3
|
export * as isValidCssClassName from './is-valid-css-class-name/index.js'
|
|
5
4
|
export * as scale from './scale/index.js'
|
|
5
|
+
export * as bem from './bem/index.js'
|
|
6
6
|
export * as stylesSet from './styles-set/index.js'
|
|
@@ -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 instanceof Element) {
|
|
40
|
+
if (node !== root && node.matches(selector))
|
|
41
|
+
results.push(node);
|
|
42
|
+
if (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,46 +1,47 @@
|
|
|
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
|
-
export * as at from './at/index.js'
|
|
5
5
|
export * as call from './call/index.js'
|
|
6
|
-
export * as
|
|
6
|
+
export * as at from './at/index.js'
|
|
7
7
|
export * as clone from './clone/index.js'
|
|
8
8
|
export * as deleteproperties from './deleteproperties/index.js'
|
|
9
|
+
export * as equals from './equals/index.js'
|
|
9
10
|
export * as getattribute from './getattribute/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
|
-
export * as initialize from './initialize/index.js'
|
|
17
16
|
export * as join from './join/index.js'
|
|
17
|
+
export * as initialize from './initialize/index.js'
|
|
18
18
|
export * as length from './length/index.js'
|
|
19
19
|
export * as map from './map/index.js'
|
|
20
|
-
export * as negate from './negate/index.js'
|
|
21
20
|
export * as notrailing from './notrailing/index.js'
|
|
22
21
|
export * as or from './or/index.js'
|
|
23
22
|
export * as pickrandom from './pickrandom/index.js'
|
|
23
|
+
export * as negate from './negate/index.js'
|
|
24
24
|
export * as populate from './populate/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'
|
|
27
|
-
export * as removeattribute from './removeattribute/index.js'
|
|
28
|
-
export * as removeclass from './removeclass/index.js'
|
|
29
28
|
export * as recordtoarray from './recordtoarray/index.js'
|
|
30
|
-
export * as
|
|
29
|
+
export * as removeattribute from './removeattribute/index.js'
|
|
31
30
|
export * as renameproperty from './renameproperty/index.js'
|
|
31
|
+
export * as removeclass from './removeclass/index.js'
|
|
32
32
|
export * as replace from './replace/index.js'
|
|
33
33
|
export * as select from './select/index.js'
|
|
34
|
-
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
|
+
export * as set from './set/index.js'
|
|
36
37
|
export * as sorton from './sorton/index.js'
|
|
37
|
-
export * as split from './split/index.js'
|
|
38
38
|
export * as spread from './spread/index.js'
|
|
39
|
-
export * as
|
|
40
|
-
export * as toelement from './toelement/index.js'
|
|
41
|
-
export * as toboolean from './toboolean/index.js'
|
|
39
|
+
export * as split from './split/index.js'
|
|
42
40
|
export * as toarray from './toarray/index.js'
|
|
41
|
+
export * as toboolean from './toboolean/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'
|
|
@@ -49,4 +50,3 @@ export * as tostring from './tostring/index.js'
|
|
|
49
50
|
export * as totext from './totext/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,46 +1,47 @@
|
|
|
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
|
-
export * as at from './at/index.js'
|
|
5
5
|
export * as call from './call/index.js'
|
|
6
|
-
export * as
|
|
6
|
+
export * as at from './at/index.js'
|
|
7
7
|
export * as clone from './clone/index.js'
|
|
8
8
|
export * as deleteproperties from './deleteproperties/index.js'
|
|
9
|
+
export * as equals from './equals/index.js'
|
|
9
10
|
export * as getattribute from './getattribute/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
|
-
export * as initialize from './initialize/index.js'
|
|
17
16
|
export * as join from './join/index.js'
|
|
17
|
+
export * as initialize from './initialize/index.js'
|
|
18
18
|
export * as length from './length/index.js'
|
|
19
19
|
export * as map from './map/index.js'
|
|
20
|
-
export * as negate from './negate/index.js'
|
|
21
20
|
export * as notrailing from './notrailing/index.js'
|
|
22
21
|
export * as or from './or/index.js'
|
|
23
22
|
export * as pickrandom from './pickrandom/index.js'
|
|
23
|
+
export * as negate from './negate/index.js'
|
|
24
24
|
export * as populate from './populate/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'
|
|
27
|
-
export * as removeattribute from './removeattribute/index.js'
|
|
28
|
-
export * as removeclass from './removeclass/index.js'
|
|
29
28
|
export * as recordtoarray from './recordtoarray/index.js'
|
|
30
|
-
export * as
|
|
29
|
+
export * as removeattribute from './removeattribute/index.js'
|
|
31
30
|
export * as renameproperty from './renameproperty/index.js'
|
|
31
|
+
export * as removeclass from './removeclass/index.js'
|
|
32
32
|
export * as replace from './replace/index.js'
|
|
33
33
|
export * as select from './select/index.js'
|
|
34
|
-
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
|
+
export * as set from './set/index.js'
|
|
36
37
|
export * as sorton from './sorton/index.js'
|
|
37
|
-
export * as split from './split/index.js'
|
|
38
38
|
export * as spread from './spread/index.js'
|
|
39
|
-
export * as
|
|
40
|
-
export * as toelement from './toelement/index.js'
|
|
41
|
-
export * as toboolean from './toboolean/index.js'
|
|
39
|
+
export * as split from './split/index.js'
|
|
42
40
|
export * as toarray from './toarray/index.js'
|
|
41
|
+
export * as toboolean from './toboolean/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'
|
|
@@ -49,4 +50,3 @@ export * as tostring from './tostring/index.js'
|
|
|
49
50
|
export * as totext from './totext/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,7 +1,7 @@
|
|
|
1
1
|
export * as any from './any/index.js'
|
|
2
2
|
export * as array from './array/index.js'
|
|
3
|
-
export * as element from './element/index.js'
|
|
4
3
|
export * as boolean from './boolean/index.js'
|
|
4
|
+
export * as element from './element/index.js'
|
|
5
5
|
export * as get from './get/index.js'
|
|
6
6
|
export * as guess from './guess/index.js'
|
|
7
7
|
export * as nodelist from './nodelist/index.js'
|
|
@@ -9,5 +9,5 @@ export * as null from './null/index.js'
|
|
|
9
9
|
export * as number from './number/index.js'
|
|
10
10
|
export * as record from './record/index.js'
|
|
11
11
|
export * as ref from './ref/index.js'
|
|
12
|
-
export * as text from './text/index.js'
|
|
13
12
|
export * as string from './string/index.js'
|
|
13
|
+
export * as text from './text/index.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * as any from './any/index.js'
|
|
2
2
|
export * as array from './array/index.js'
|
|
3
|
-
export * as element from './element/index.js'
|
|
4
3
|
export * as boolean from './boolean/index.js'
|
|
4
|
+
export * as element from './element/index.js'
|
|
5
5
|
export * as get from './get/index.js'
|
|
6
6
|
export * as guess from './guess/index.js'
|
|
7
7
|
export * as nodelist from './nodelist/index.js'
|
|
@@ -9,5 +9,5 @@ export * as null from './null/index.js'
|
|
|
9
9
|
export * as number from './number/index.js'
|
|
10
10
|
export * as record from './record/index.js'
|
|
11
11
|
export * as ref from './ref/index.js'
|
|
12
|
-
export * as text from './text/index.js'
|
|
13
12
|
export * as string from './string/index.js'
|
|
13
|
+
export * as text from './text/index.js'
|
package/agnostic/html/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export * as hyperJson from './hyper-json/index.js'
|
|
|
4
4
|
export * as insertNode from './insert-node/index.js'
|
|
5
5
|
export * as placeholders from './placeholders/index.js'
|
|
6
6
|
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
|
-
export * as stringToNodes from './string-to-nodes/index.js'
|
|
8
7
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
8
|
+
export * as deepSelect from './deep-select/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
|
@@ -4,5 +4,7 @@ export * as hyperJson from './hyper-json/index.js'
|
|
|
4
4
|
export * as insertNode from './insert-node/index.js'
|
|
5
5
|
export * as placeholders from './placeholders/index.js'
|
|
6
6
|
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
|
-
export * as stringToNodes from './string-to-nodes/index.js'
|
|
8
7
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
8
|
+
export * as deepSelect from './deep-select/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,12 +1,12 @@
|
|
|
1
|
-
export * as
|
|
1
|
+
export * as arrays from './arrays/index.js'
|
|
2
2
|
export * as colors from './colors/index.js'
|
|
3
3
|
export * as css from './css/index.js'
|
|
4
4
|
export * as errors from './errors/index.js'
|
|
5
|
+
export * as misc from './misc/index.js'
|
|
5
6
|
export * as html from './html/index.js'
|
|
6
7
|
export * as numbers from './numbers/index.js'
|
|
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'
|
|
9
|
+
export * as booleans from './booleans/index.js'
|
|
10
10
|
export * as optim from './optim/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
12
|
export * as regexps from './regexps/index.js'
|
package/agnostic/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * as
|
|
1
|
+
export * as arrays from './arrays/index.js'
|
|
2
2
|
export * as colors from './colors/index.js'
|
|
3
3
|
export * as css from './css/index.js'
|
|
4
4
|
export * as errors from './errors/index.js'
|
|
5
|
+
export * as misc from './misc/index.js'
|
|
5
6
|
export * as html from './html/index.js'
|
|
6
7
|
export * as numbers from './numbers/index.js'
|
|
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'
|
|
9
|
+
export * as booleans from './booleans/index.js'
|
|
10
10
|
export * as optim from './optim/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
12
|
export * as regexps from './regexps/index.js'
|
package/agnostic/misc/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * as assert from './assert/index.js'
|
|
2
|
-
export * as connection from './connection/index.js'
|
|
3
2
|
export * as cast from './cast/index.js'
|
|
3
|
+
export * as connection from './connection/index.js'
|
|
4
4
|
export * as crawler from './crawler/index.js'
|
|
5
5
|
export * as crossenv from './crossenv/index.js'
|
|
6
6
|
export * as dataSize from './data-size/index.js'
|
|
7
|
+
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
7
8
|
export * as isNullish from './is-nullish/index.js'
|
|
8
9
|
export * as logs from './logs/index.js'
|
|
9
|
-
export * as
|
|
10
|
+
export * as loremIpsum from './lorem-ipsum/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
|
-
export * as connection from './connection/index.js'
|
|
3
2
|
export * as cast from './cast/index.js'
|
|
3
|
+
export * as connection from './connection/index.js'
|
|
4
4
|
export * as crawler from './crawler/index.js'
|
|
5
5
|
export * as crossenv from './crossenv/index.js'
|
|
6
6
|
export * as dataSize from './data-size/index.js'
|
|
7
|
+
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
7
8
|
export * as isNullish from './is-nullish/index.js'
|
|
8
9
|
export * as logs from './logs/index.js'
|
|
9
|
-
export * as
|
|
10
|
+
export * as loremIpsum from './lorem-ipsum/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
|
+
export * as approximateRational from './approximate-rational/index.js'
|
|
1
2
|
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
3
|
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
3
4
|
export * as clamp from './clamp/index.js'
|
|
4
|
-
export * as interpolate from './interpolate/index.js'
|
|
5
5
|
export * as round from './round/index.js'
|
|
6
|
-
export * as
|
|
6
|
+
export * as interpolate from './interpolate/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export * as approximateRational from './approximate-rational/index.js'
|
|
1
2
|
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
3
|
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
3
4
|
export * as clamp from './clamp/index.js'
|
|
4
|
-
export * as interpolate from './interpolate/index.js'
|
|
5
5
|
export * as round from './round/index.js'
|
|
6
|
-
export * as
|
|
6
|
+
export * as interpolate from './interpolate/index.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export * as deepGetProperty from './deep-get-property/index.js'
|
|
1
2
|
export * as enums from './enums/index.js'
|
|
2
|
-
export * as isObject from './is-object/index.js'
|
|
3
3
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
4
|
-
export * as
|
|
5
|
-
export * as deepGetProperty from './deep-get-property/index.js'
|
|
4
|
+
export * as isObject from './is-object/index.js'
|
|
6
5
|
export * as recordFormat from './record-format/index.js'
|
|
6
|
+
export * as isRecord from './is-record/index.js'
|
|
7
7
|
export * as recordMap from './record-map/index.js'
|
|
8
8
|
export * as sortKeys from './sort-keys/index.js'
|
|
9
9
|
export * as validation from './validation/index.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export * as deepGetProperty from './deep-get-property/index.js'
|
|
1
2
|
export * as enums from './enums/index.js'
|
|
2
|
-
export * as isObject from './is-object/index.js'
|
|
3
3
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
4
|
-
export * as
|
|
5
|
-
export * as deepGetProperty from './deep-get-property/index.js'
|
|
4
|
+
export * as isObject from './is-object/index.js'
|
|
6
5
|
export * as recordFormat from './record-format/index.js'
|
|
6
|
+
export * as isRecord from './is-record/index.js'
|
|
7
7
|
export * as recordMap from './record-map/index.js'
|
|
8
8
|
export * as sortKeys from './sort-keys/index.js'
|
|
9
9
|
export * as validation from './validation/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
|
-
export * as parseTable from './parse-table/index.js'
|
|
4
4
|
export * as replaceAll from './replace-all/index.js'
|
|
5
5
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
6
|
+
export * as parseTable from './parse-table/index.js'
|
|
7
|
+
export * as splitTrim from './split-trim/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
|
-
export * as parseTable from './parse-table/index.js'
|
|
4
4
|
export * as replaceAll from './replace-all/index.js'
|
|
5
5
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
6
|
+
export * as parseTable from './parse-table/index.js'
|
|
7
|
+
export * as splitTrim from './split-trim/index.js'
|
|
6
8
|
export * as trim from './trim/index.js'
|
|
7
|
-
export * as charCodes from './char-codes/index.js'
|