@fringeworks/react-utils 0.10.0 → 0.12.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/README.ja.md +118 -43
- package/README.md +118 -43
- package/{_helpers → _internal}/_traverseChildren.cjs +1 -1
- package/{_helpers → _internal}/_traverseChildren.d.cts +1 -1
- package/{_helpers → _internal}/_traverseChildren.d.mts +1 -1
- package/{_helpers → _internal}/_traverseChildren.mjs +1 -1
- package/_internal/_useChangeHandler.cjs +48 -0
- package/_internal/_useChangeHandler.d.cts +18 -0
- package/_internal/_useChangeHandler.d.mts +18 -0
- package/_internal/_useChangeHandler.mjs +47 -0
- package/{_helpers → _internal}/_useExecutionHandler.cjs +13 -12
- package/{_helpers → _internal}/_useExecutionHandler.d.cts +7 -4
- package/{_helpers → _internal}/_useExecutionHandler.d.mts +7 -4
- package/_internal/_useExecutionHandler.mjs +37 -0
- package/hooks/index.cjs +11 -2
- package/hooks/index.d.cts +11 -2
- package/hooks/index.d.mts +11 -2
- package/hooks/index.mjs +9 -3
- package/hooks/useChangeEffect/index.cjs +5 -0
- package/hooks/useChangeEffect/index.d.cts +3 -0
- package/hooks/useChangeEffect/index.d.mts +3 -0
- package/hooks/useChangeEffect/index.mjs +3 -0
- package/hooks/useChangeEffect/types.d.cts +11 -0
- package/hooks/useChangeEffect/types.d.mts +11 -0
- package/hooks/useChangeEffect/useChangeEffect.cjs +37 -0
- package/hooks/useChangeEffect/useChangeEffect.d.cts +27 -0
- package/hooks/useChangeEffect/useChangeEffect.d.mts +27 -0
- package/hooks/useChangeEffect/useChangeEffect.mjs +36 -0
- package/hooks/useChangeLayoutEffect/index.cjs +5 -0
- package/hooks/useChangeLayoutEffect/index.d.cts +2 -0
- package/hooks/useChangeLayoutEffect/index.d.mts +2 -0
- package/hooks/useChangeLayoutEffect/index.mjs +3 -0
- package/hooks/useChangeLayoutEffect/useChangeLayoutEffect.cjs +24 -0
- package/hooks/useChangeLayoutEffect/useChangeLayoutEffect.d.cts +14 -0
- package/hooks/useChangeLayoutEffect/useChangeLayoutEffect.d.mts +14 -0
- package/hooks/useChangeLayoutEffect/useChangeLayoutEffect.mjs +23 -0
- package/hooks/useCombinedRefs/useCombinedRefs.cjs +2 -0
- package/hooks/useCombinedRefs/useCombinedRefs.d.cts +3 -1
- package/hooks/useCombinedRefs/useCombinedRefs.d.mts +3 -1
- package/hooks/useCombinedRefs/useCombinedRefs.mjs +2 -0
- package/hooks/useExecutionAt/index.d.cts +2 -2
- package/hooks/useExecutionAt/index.d.mts +2 -2
- package/hooks/useExecutionAt/types.d.cts +2 -11
- package/hooks/useExecutionAt/types.d.mts +2 -11
- package/hooks/useExecutionAt/useExecutionAt.cjs +2 -3
- package/hooks/useExecutionAt/useExecutionAt.d.cts +2 -3
- package/hooks/useExecutionAt/useExecutionAt.d.mts +2 -3
- package/hooks/useExecutionAt/useExecutionAt.mjs +2 -3
- package/hooks/useExecutionEffect/useExecutionEffect.cjs +8 -6
- package/hooks/useExecutionEffect/useExecutionEffect.d.cts +9 -5
- package/hooks/useExecutionEffect/useExecutionEffect.d.mts +9 -5
- package/hooks/useExecutionEffect/useExecutionEffect.mjs +7 -5
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.cjs +3 -3
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.d.cts +4 -2
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.d.mts +4 -2
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.mjs +2 -2
- package/hooks/useExecutionMark/index.cjs +5 -0
- package/hooks/useExecutionMark/index.d.cts +3 -0
- package/hooks/useExecutionMark/index.d.mts +3 -0
- package/hooks/useExecutionMark/index.mjs +3 -0
- package/hooks/useExecutionMark/types.cjs +1 -0
- package/hooks/useExecutionMark/types.d.cts +7 -0
- package/hooks/useExecutionMark/types.d.mts +7 -0
- package/hooks/useExecutionMark/types.mjs +1 -0
- package/hooks/useExecutionMark/useExecutionMark.cjs +29 -0
- package/hooks/useExecutionMark/useExecutionMark.d.cts +19 -0
- package/hooks/useExecutionMark/useExecutionMark.d.mts +19 -0
- package/hooks/useExecutionMark/useExecutionMark.mjs +28 -0
- package/index.cjs +7 -1
- package/index.d.cts +9 -5
- package/index.d.mts +9 -5
- package/index.mjs +5 -2
- package/package.json +32 -2
- package/types.d.cts +10 -0
- package/types.d.mts +10 -0
- package/utils/forEachContent/forEachContent.cjs +2 -2
- package/utils/forEachContent/forEachContent.mjs +1 -1
- package/utils/forEachElement/forEachElement.cjs +2 -2
- package/utils/forEachElement/forEachElement.mjs +1 -1
- package/utils/index.d.cts +3 -3
- package/utils/index.d.mts +3 -3
- package/utils/markAt/index.d.cts +1 -2
- package/utils/markAt/index.d.mts +1 -2
- package/utils/markAt/markAt.cjs +2 -2
- package/utils/markAt/markAt.d.cts +4 -4
- package/utils/markAt/markAt.d.mts +4 -4
- package/utils/markAt/markAt.mjs +2 -2
- package/utils/transformContent/transformContent.cjs +2 -2
- package/utils/transformContent/transformContent.mjs +1 -1
- package/utils/transformElement/transformElement.cjs +2 -2
- package/utils/transformElement/transformElement.mjs +1 -1
- package/_helpers/_useExecutionHandler.mjs +0 -36
- package/utils/markAt/types.d.cts +0 -3
- package/utils/markAt/types.d.mts +0 -3
- /package/{utils/markAt → hooks/useChangeEffect}/types.cjs +0 -0
- /package/{utils/markAt → hooks/useChangeEffect}/types.mjs +0 -0
package/index.d.mts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { ExecutionFunction, ExecutionRequest,
|
|
1
|
+
import { ChangeDependencies } from "./hooks/useChangeEffect/types.mjs";
|
|
2
|
+
import { CSSPropertiesWithVars, ExecutionMark } from "./types.mjs";
|
|
3
|
+
import { ExecutionFunction, ExecutionRequest, UseExecutionAtResult } from "./hooks/useExecutionAt/types.mjs";
|
|
4
4
|
import useExecutionAt from "./hooks/useExecutionAt/useExecutionAt.mjs";
|
|
5
|
+
import useChangeEffect from "./hooks/useChangeEffect/useChangeEffect.mjs";
|
|
6
|
+
import useChangeLayoutEffect from "./hooks/useChangeLayoutEffect/useChangeLayoutEffect.mjs";
|
|
5
7
|
import useCombinedRefs from "./hooks/useCombinedRefs/useCombinedRefs.mjs";
|
|
6
8
|
import useConstant from "./hooks/useConstant/useConstant.mjs";
|
|
7
9
|
import useExecutionEffect from "./hooks/useExecutionEffect/useExecutionEffect.mjs";
|
|
8
10
|
import useExecutionLayoutEffect from "./hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.mjs";
|
|
11
|
+
import { UseExecutionMarkResult } from "./hooks/useExecutionMark/types.mjs";
|
|
12
|
+
import useExecutionMark from "./hooks/useExecutionMark/useExecutionMark.mjs";
|
|
9
13
|
import useIsHydrated from "./hooks/useIsHydrated/useIsHydrated.mjs";
|
|
10
14
|
import useIsMounted from "./hooks/useIsMounted/useIsMounted.mjs";
|
|
11
15
|
import { LatestRef } from "./hooks/useLatestRef/types.mjs";
|
|
@@ -16,7 +20,6 @@ import useRerender from "./hooks/useRerender/useRerender.mjs";
|
|
|
16
20
|
import useStableCallback from "./hooks/useStableCallback/useStableCallback.mjs";
|
|
17
21
|
import useStableLength from "./hooks/useStableLength/useStableLength.mjs";
|
|
18
22
|
import "./hooks/index.mjs";
|
|
19
|
-
import { CSSPropertiesWithVars } from "./types.mjs";
|
|
20
23
|
import { AppliedProps, SkippedDefaults } from "./utils/applyDefaultProps/types.mjs";
|
|
21
24
|
import applyDefaultProps from "./utils/applyDefaultProps/applyDefaultProps.mjs";
|
|
22
25
|
import ensureComponent from "./utils/ensureComponent/ensureComponent.mjs";
|
|
@@ -25,8 +28,9 @@ import extendElement from "./utils/extendElement/extendElement.mjs";
|
|
|
25
28
|
import forEachContent from "./utils/forEachContent/forEachContent.mjs";
|
|
26
29
|
import forEachElement from "./utils/forEachElement/forEachElement.mjs";
|
|
27
30
|
import getComponentName from "./utils/getComponentName/getComponentName.mjs";
|
|
31
|
+
import markAt from "./utils/markAt/markAt.mjs";
|
|
28
32
|
import setRefCurrent from "./utils/setRefCurrent/setRefCurrent.mjs";
|
|
29
33
|
import transformContent from "./utils/transformContent/transformContent.mjs";
|
|
30
34
|
import transformElement from "./utils/transformElement/transformElement.mjs";
|
|
31
35
|
import "./utils/index.mjs";
|
|
32
|
-
export { type AppliedProps, type CSSPropertiesWithVars, type ExecutionFunction, type
|
|
36
|
+
export { type AppliedProps, type CSSPropertiesWithVars, type ChangeDependencies, type ExecutionFunction, type ExecutionMark, type ExecutionRequest, type ExtendableProps, type LatestRef, type SkippedDefaults, type UseExecutionAtResult, type UseExecutionMarkResult, type UsePreviousValueOptions, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement, useChangeEffect, useChangeLayoutEffect, useCombinedRefs, useConstant, useExecutionAt, useExecutionEffect, useExecutionLayoutEffect, useExecutionMark, useIsHydrated, useIsMounted, useLatestRef, usePreviousValue, useRerender, useStableCallback, useStableLength };
|
package/index.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import useLatestRef from "./hooks/useLatestRef/useLatestRef.mjs";
|
|
2
|
+
import useChangeEffect from "./hooks/useChangeEffect/useChangeEffect.mjs";
|
|
3
|
+
import useChangeLayoutEffect from "./hooks/useChangeLayoutEffect/useChangeLayoutEffect.mjs";
|
|
1
4
|
import setRefCurrent from "./utils/setRefCurrent/setRefCurrent.mjs";
|
|
2
5
|
import useStableLength from "./hooks/useStableLength/useStableLength.mjs";
|
|
3
6
|
import useCombinedRefs from "./hooks/useCombinedRefs/useCombinedRefs.mjs";
|
|
4
7
|
import useConstant from "./hooks/useConstant/useConstant.mjs";
|
|
5
8
|
import markAt from "./utils/markAt/markAt.mjs";
|
|
6
9
|
import useExecutionAt from "./hooks/useExecutionAt/useExecutionAt.mjs";
|
|
7
|
-
import useLatestRef from "./hooks/useLatestRef/useLatestRef.mjs";
|
|
8
10
|
import useExecutionEffect from "./hooks/useExecutionEffect/useExecutionEffect.mjs";
|
|
9
11
|
import useExecutionLayoutEffect from "./hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.mjs";
|
|
12
|
+
import useExecutionMark from "./hooks/useExecutionMark/useExecutionMark.mjs";
|
|
10
13
|
import useIsHydrated from "./hooks/useIsHydrated/useIsHydrated.mjs";
|
|
11
14
|
import useIsMounted from "./hooks/useIsMounted/useIsMounted.mjs";
|
|
12
15
|
import usePreviousValue from "./hooks/usePreviousValue/usePreviousValue.mjs";
|
|
@@ -23,4 +26,4 @@ import transformContent from "./utils/transformContent/transformContent.mjs";
|
|
|
23
26
|
import transformElement from "./utils/transformElement/transformElement.mjs";
|
|
24
27
|
import "./utils/index.mjs";
|
|
25
28
|
|
|
26
|
-
export { applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement, useCombinedRefs, useConstant, useExecutionAt, useExecutionEffect, useExecutionLayoutEffect, useIsHydrated, useIsMounted, useLatestRef, usePreviousValue, useRerender, useStableCallback, useStableLength };
|
|
29
|
+
export { applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement, useChangeEffect, useChangeLayoutEffect, useCombinedRefs, useConstant, useExecutionAt, useExecutionEffect, useExecutionLayoutEffect, useExecutionMark, useIsHydrated, useIsMounted, useLatestRef, usePreviousValue, useRerender, useStableCallback, useStableLength };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fringeworks/react-utils",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A library some will find handy,
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"description": "A library some will find handy, offering hooks and functions for building React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
7
7
|
],
|
|
@@ -34,6 +34,26 @@
|
|
|
34
34
|
"default": "./hooks/index.cjs"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
+
"./hooks/useChangeEffect": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./hooks/useChangeEffect/index.d.mts",
|
|
40
|
+
"default": "./hooks/useChangeEffect/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./hooks/useChangeEffect/index.d.cts",
|
|
44
|
+
"default": "./hooks/useChangeEffect/index.cjs"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"./hooks/useChangeLayoutEffect": {
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./hooks/useChangeLayoutEffect/index.d.mts",
|
|
50
|
+
"default": "./hooks/useChangeLayoutEffect/index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./hooks/useChangeLayoutEffect/index.d.cts",
|
|
54
|
+
"default": "./hooks/useChangeLayoutEffect/index.cjs"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
37
57
|
"./hooks/useCombinedRefs": {
|
|
38
58
|
"import": {
|
|
39
59
|
"types": "./hooks/useCombinedRefs/index.d.mts",
|
|
@@ -84,6 +104,16 @@
|
|
|
84
104
|
"default": "./hooks/useExecutionLayoutEffect/index.cjs"
|
|
85
105
|
}
|
|
86
106
|
},
|
|
107
|
+
"./hooks/useExecutionMark": {
|
|
108
|
+
"import": {
|
|
109
|
+
"types": "./hooks/useExecutionMark/index.d.mts",
|
|
110
|
+
"default": "./hooks/useExecutionMark/index.mjs"
|
|
111
|
+
},
|
|
112
|
+
"require": {
|
|
113
|
+
"types": "./hooks/useExecutionMark/index.d.cts",
|
|
114
|
+
"default": "./hooks/useExecutionMark/index.cjs"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
87
117
|
"./hooks/useIsHydrated": {
|
|
88
118
|
"import": {
|
|
89
119
|
"types": "./hooks/useIsHydrated/index.d.mts",
|
package/types.d.cts
CHANGED
|
@@ -6,4 +6,14 @@ import { CSSProperties } from "react";
|
|
|
6
6
|
export type CSSPropertiesWithVars = CSSProperties & {
|
|
7
7
|
[key: `--${string}`]: string | number | undefined;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* 実行の印(payload の無い Execution Request)
|
|
11
|
+
*
|
|
12
|
+
* 実体は数値。Execution Request プロパティ(xxxAt)に渡し、値が変わるたびに1回の要求とみなす。
|
|
13
|
+
* `ExecutionRequest` の `at` もこの型。
|
|
14
|
+
* **要求のたびに、前回と異なる値にすること**(同じ値を続けて渡しても、2回目は要求とみなさない)。
|
|
15
|
+
* `markAt()` で作ると、呼ぶたびに異なる値になる。`useExecutionMark` を使うと、`markAt()` で作った値と、要求する関数を受け取れる。
|
|
16
|
+
* `0` は「まだ要求していない」を表し、実行しない。
|
|
17
|
+
*/
|
|
18
|
+
export type ExecutionMark = number;
|
|
9
19
|
//#endregion
|
package/types.d.mts
CHANGED
|
@@ -6,4 +6,14 @@ import { CSSProperties } from "react";
|
|
|
6
6
|
export type CSSPropertiesWithVars = CSSProperties & {
|
|
7
7
|
[key: `--${string}`]: string | number | undefined;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* 実行の印(payload の無い Execution Request)
|
|
11
|
+
*
|
|
12
|
+
* 実体は数値。Execution Request プロパティ(xxxAt)に渡し、値が変わるたびに1回の要求とみなす。
|
|
13
|
+
* `ExecutionRequest` の `at` もこの型。
|
|
14
|
+
* **要求のたびに、前回と異なる値にすること**(同じ値を続けて渡しても、2回目は要求とみなさない)。
|
|
15
|
+
* `markAt()` で作ると、呼ぶたびに異なる値になる。`useExecutionMark` を使うと、`markAt()` で作った値と、要求する関数を受け取れる。
|
|
16
|
+
* `0` は「まだ要求していない」を表し、実行しない。
|
|
17
|
+
*/
|
|
18
|
+
export type ExecutionMark = number;
|
|
9
19
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const
|
|
2
|
+
const require__internal__traverseChildren = require("../../_internal/_traverseChildren.cjs");
|
|
3
3
|
|
|
4
4
|
//#region src/utils/forEachContent/forEachContent.ts
|
|
5
5
|
/**
|
|
@@ -8,7 +8,7 @@ const require__helpers__traverseChildren = require("../../_helpers/_traverseChil
|
|
|
8
8
|
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
9
9
|
*/
|
|
10
10
|
function forEachContent(children, callback) {
|
|
11
|
-
|
|
11
|
+
require__internal__traverseChildren.default(children, require__internal__traverseChildren._isContent, callback);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const
|
|
2
|
+
const require__internal__traverseChildren = require("../../_internal/_traverseChildren.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/forEachElement/forEachElement.ts
|
|
@@ -9,7 +9,7 @@ let react = require("react");
|
|
|
9
9
|
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
10
10
|
*/
|
|
11
11
|
function forEachElement(children, callback) {
|
|
12
|
-
|
|
12
|
+
require__internal__traverseChildren.default(children, react.isValidElement, callback);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
//#endregion
|
package/utils/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { MarkAtResult } from "./markAt/types.cjs";
|
|
2
|
-
import markAt from "./markAt/markAt.cjs";
|
|
3
1
|
import { AppliedProps, SkippedDefaults } from "./applyDefaultProps/types.cjs";
|
|
4
2
|
import applyDefaultProps from "./applyDefaultProps/applyDefaultProps.cjs";
|
|
5
3
|
import ensureComponent from "./ensureComponent/ensureComponent.cjs";
|
|
@@ -13,10 +11,12 @@ import forEachElement from "./forEachElement/forEachElement.cjs";
|
|
|
13
11
|
import "./forEachElement/index.cjs";
|
|
14
12
|
import getComponentName from "./getComponentName/getComponentName.cjs";
|
|
15
13
|
import "./getComponentName/index.cjs";
|
|
14
|
+
import markAt from "./markAt/markAt.cjs";
|
|
15
|
+
import "./markAt/index.cjs";
|
|
16
16
|
import setRefCurrent from "./setRefCurrent/setRefCurrent.cjs";
|
|
17
17
|
import "./setRefCurrent/index.cjs";
|
|
18
18
|
import transformContent from "./transformContent/transformContent.cjs";
|
|
19
19
|
import "./transformContent/index.cjs";
|
|
20
20
|
import transformElement from "./transformElement/transformElement.cjs";
|
|
21
21
|
import "./transformElement/index.cjs";
|
|
22
|
-
export { type AppliedProps, type ExtendableProps, type
|
|
22
|
+
export { type AppliedProps, type ExtendableProps, type SkippedDefaults, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement };
|
package/utils/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { MarkAtResult } from "./markAt/types.mjs";
|
|
2
|
-
import markAt from "./markAt/markAt.mjs";
|
|
3
1
|
import { AppliedProps, SkippedDefaults } from "./applyDefaultProps/types.mjs";
|
|
4
2
|
import applyDefaultProps from "./applyDefaultProps/applyDefaultProps.mjs";
|
|
5
3
|
import ensureComponent from "./ensureComponent/ensureComponent.mjs";
|
|
@@ -13,10 +11,12 @@ import forEachElement from "./forEachElement/forEachElement.mjs";
|
|
|
13
11
|
import "./forEachElement/index.mjs";
|
|
14
12
|
import getComponentName from "./getComponentName/getComponentName.mjs";
|
|
15
13
|
import "./getComponentName/index.mjs";
|
|
14
|
+
import markAt from "./markAt/markAt.mjs";
|
|
15
|
+
import "./markAt/index.mjs";
|
|
16
16
|
import setRefCurrent from "./setRefCurrent/setRefCurrent.mjs";
|
|
17
17
|
import "./setRefCurrent/index.mjs";
|
|
18
18
|
import transformContent from "./transformContent/transformContent.mjs";
|
|
19
19
|
import "./transformContent/index.mjs";
|
|
20
20
|
import transformElement from "./transformElement/transformElement.mjs";
|
|
21
21
|
import "./transformElement/index.mjs";
|
|
22
|
-
export { type AppliedProps, type ExtendableProps, type
|
|
22
|
+
export { type AppliedProps, type ExtendableProps, type SkippedDefaults, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement };
|
package/utils/markAt/index.d.cts
CHANGED
package/utils/markAt/index.d.mts
CHANGED
package/utils/markAt/markAt.cjs
CHANGED
|
@@ -2,8 +2,8 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
2
2
|
//#region src/utils/markAt/markAt.ts
|
|
3
3
|
let count = 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @returns
|
|
5
|
+
* 呼び出す度に単調増加する一意な値(実行の印)を返す
|
|
6
|
+
* @returns 1 から始まり、呼ぶたびに増える値
|
|
7
7
|
*/
|
|
8
8
|
function markAt() {
|
|
9
9
|
count += 1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExecutionMark } from "../../types.cjs";
|
|
2
2
|
//#region src/utils/markAt/markAt.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @returns
|
|
4
|
+
* 呼び出す度に単調増加する一意な値(実行の印)を返す
|
|
5
|
+
* @returns 1 から始まり、呼ぶたびに増える値
|
|
6
6
|
*/
|
|
7
|
-
declare function markAt():
|
|
7
|
+
declare function markAt(): ExecutionMark;
|
|
8
8
|
export = markAt;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExecutionMark } from "../../types.mjs";
|
|
2
2
|
//#region src/utils/markAt/markAt.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @returns
|
|
4
|
+
* 呼び出す度に単調増加する一意な値(実行の印)を返す
|
|
5
|
+
* @returns 1 から始まり、呼ぶたびに増える値
|
|
6
6
|
*/
|
|
7
|
-
export default function markAt():
|
|
7
|
+
export default function markAt(): ExecutionMark;
|
|
8
8
|
//#endregion
|
package/utils/markAt/markAt.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const
|
|
2
|
+
const require__internal__traverseChildren = require("../../_internal/_traverseChildren.cjs");
|
|
3
3
|
|
|
4
4
|
//#region src/utils/transformContent/transformContent.ts
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ const require__helpers__traverseChildren = require("../../_helpers/_traverseChil
|
|
|
15
15
|
*/
|
|
16
16
|
function transformContent(children, callback) {
|
|
17
17
|
const result = [];
|
|
18
|
-
|
|
18
|
+
require__internal__traverseChildren.default(children, require__internal__traverseChildren._isContent, callback, (value) => result.push(value));
|
|
19
19
|
return result;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const
|
|
2
|
+
const require__internal__traverseChildren = require("../../_internal/_traverseChildren.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/transformElement/transformElement.ts
|
|
@@ -16,7 +16,7 @@ let react = require("react");
|
|
|
16
16
|
*/
|
|
17
17
|
function transformElement(children, callback) {
|
|
18
18
|
const result = [];
|
|
19
|
-
|
|
19
|
+
require__internal__traverseChildren.default(children, react.isValidElement, callback, (value) => result.push(value));
|
|
20
20
|
return result;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import useConstant from "../hooks/useConstant/useConstant.mjs";
|
|
2
|
-
import "../hooks/useConstant/index.mjs";
|
|
3
|
-
import markAt from "../utils/markAt/markAt.mjs";
|
|
4
|
-
import useLatestRef from "../hooks/useLatestRef/useLatestRef.mjs";
|
|
5
|
-
import "../hooks/useLatestRef/index.mjs";
|
|
6
|
-
import { useCallback, useRef } from "react";
|
|
7
|
-
|
|
8
|
-
//#region src/_helpers/_useExecutionHandler.ts
|
|
9
|
-
/**
|
|
10
|
-
* Execution Request を受け取り、要求があれば処理を実行する関数を返すフック
|
|
11
|
-
*
|
|
12
|
-
* `useExecutionEffect`・`useExecutionLayoutEffect` に共通の処理。返す関数をエフェクトで呼ぶ。
|
|
13
|
-
*
|
|
14
|
-
* - 初回のレンダリングで `markAt()` の値を基準にし、`at` がそれより大きい要求だけを実行する。
|
|
15
|
-
* `at` は `markAt()` で単調に増えるため、マウントより前に出た要求は実行しない
|
|
16
|
-
* - 一度実行した要求は、エフェクトが再実行されても(StrictMode など)実行しない
|
|
17
|
-
* - コールバックは最新のものを呼ぶ
|
|
18
|
-
*
|
|
19
|
-
* @param request 受け取った Execution Request。undefined の場合は要求なし
|
|
20
|
-
* @param callback 要求があったときに実行する処理
|
|
21
|
-
* @returns エフェクトで呼ぶ関数。参照は request が変わったときだけ変わる
|
|
22
|
-
*/
|
|
23
|
-
function useExecutionHandler(request, callback) {
|
|
24
|
-
const callbackRef = useLatestRef(callback);
|
|
25
|
-
const baseline = useConstant(markAt);
|
|
26
|
-
const handledAtRef = useRef(baseline);
|
|
27
|
-
return useCallback(() => {
|
|
28
|
-
if (request && request.at > handledAtRef.current) {
|
|
29
|
-
handledAtRef.current = request.at;
|
|
30
|
-
callbackRef.current(request.payload);
|
|
31
|
-
}
|
|
32
|
-
}, [request, callbackRef]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { useExecutionHandler as default };
|
package/utils/markAt/types.d.cts
DELETED
package/utils/markAt/types.d.mts
DELETED
|
File without changes
|
|
File without changes
|