@lobehub/ui 6.9.0 → 6.9.1
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/es/Accordion/style.d.mts +2 -2
- package/es/AutoComplete/style.d.mts +1 -1
- package/es/Button/style.mjs +14 -14
- package/es/ColorPicker/style.mjs +2 -2
- package/es/ColorSwatches/style.mjs +2 -2
- package/es/DraggablePanel/style.mjs +1 -1
- package/es/DraggableSideNav/style.mjs +1 -1
- package/es/FloatingPanel/style.mjs +1 -1
- package/es/Image/style.mjs +1 -1
- package/es/Input/style.mjs +3 -3
- package/es/Markdown/plugins/rehypeCustomFootnotes.mjs +1 -1
- package/es/Markdown/plugins/rehypeKatexDir.mjs +1 -1
- package/es/Markdown/plugins/remarkBr.mjs +1 -1
- package/es/Markdown/plugins/remarkCjkAutolink.mjs +1 -1
- package/es/Markdown/plugins/remarkColor.mjs +1 -1
- package/es/Markdown/plugins/remarkCustomFootnotes.mjs +1 -1
- package/es/Markdown/plugins/remarkGfmPlus.mjs +1 -1
- package/es/Markdown/plugins/remarkVideo.mjs +1 -1
- package/es/Select/style.mjs +1 -1
- package/es/Slider/style.mjs +1 -1
- package/es/Text/style.d.mts +1 -1
- package/es/awesome/GradientButton/style.mjs +1 -1
- package/es/node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs +289 -0
- package/es/node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs.map +1 -0
- package/es/styles/createGlobalStyle.mjs +19 -5
- package/es/styles/createGlobalStyle.mjs.map +1 -1
- package/es/styles/css.mjs +18 -1
- package/es/styles/css.mjs.map +1 -1
- package/package.json +1 -1
- package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs +0 -288
- package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs.map +0 -1
package/es/Accordion/style.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "@stylexjs/stylex";
|
|
2
2
|
export declare const accordionStyles: {
|
|
3
3
|
panel: string;
|
|
4
|
-
header: string;
|
|
5
4
|
action: string;
|
|
6
5
|
content: string;
|
|
7
6
|
trigger: string;
|
|
8
|
-
|
|
7
|
+
header: string;
|
|
9
8
|
root: string;
|
|
10
9
|
indicator: string;
|
|
10
|
+
item: string;
|
|
11
11
|
itemOutlined: string;
|
|
12
12
|
rootOutlined: string;
|
|
13
13
|
actionAlwaysVisible: string;
|
|
@@ -41,7 +41,7 @@ declare const styleArrays: {
|
|
|
41
41
|
}> | Readonly<{
|
|
42
42
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
|
|
43
43
|
readonly cursor: stylex.StyleXClassNameFor<"cursor", "default">;
|
|
44
|
-
readonly display: stylex.StyleXClassNameFor<"display", "
|
|
44
|
+
readonly display: stylex.StyleXClassNameFor<"display", "flex" | "none">;
|
|
45
45
|
}>)[];
|
|
46
46
|
item: Readonly<{
|
|
47
47
|
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
package/es/Button/style.mjs
CHANGED
|
@@ -6,20 +6,20 @@ const buttonPaddingInline = {
|
|
|
6
6
|
middle: 14,
|
|
7
7
|
small: 8
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
23
|
const styles = {
|
|
24
24
|
base: {
|
|
25
25
|
kVAM5u: "lbqnr5ac",
|
package/es/ColorPicker/style.mjs
CHANGED
package/es/Image/style.mjs
CHANGED
package/es/Input/style.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { cssVar } from "../styles/stylex/cssVar.stylex.mjs";
|
|
|
3
3
|
import { inputMarker } from "./marker.stylex.mjs";
|
|
4
4
|
import * as stylex from "@stylexjs/stylex";
|
|
5
5
|
// src/Input/style.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
9
|
const styles = {
|
|
10
10
|
borderless: {
|
|
11
11
|
kVAM5u: "lb9r1u3d lb11xq1n2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/rehypeCustomFootnotes.ts
|
|
3
3
|
const rehypeCustomFootnotes = () => (tree, file) => {
|
|
4
4
|
const linksData = file.data.footnoteLinks || {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/rehypeKatexDir.ts
|
|
3
3
|
const rehypeKatexDir = () => (tree) => {
|
|
4
4
|
visit(tree, "element", (node) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/remarkBr.ts
|
|
3
3
|
/**
|
|
4
4
|
* Remark plugin to handle <br> and <br/> tags in markdown text
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
import { gfmAutolinkLiteralFromMarkdown } from "mdast-util-gfm-autolink-literal";
|
|
3
3
|
// src/Markdown/plugins/remarkCjkAutolink.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/remarkColor.ts
|
|
3
3
|
/**
|
|
4
4
|
* Remark plugin to handle color syntax in markdown code spans
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SKIP, visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { SKIP, visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/remarkCustomFootnotes.ts
|
|
3
3
|
const remarkCustomFootnotes = () => (tree, file) => {
|
|
4
4
|
const footnoteLinks = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/remarkGfmPlus.ts
|
|
3
3
|
const DEFAULT_ALLOW_HTML_TAGS = [
|
|
4
4
|
"sub",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.
|
|
1
|
+
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
2
2
|
// src/Markdown/plugins/remarkVideo.ts
|
|
3
3
|
/**
|
|
4
4
|
* Remark plugin to handle <video> tags in markdown text
|
package/es/Select/style.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { cssVar } from "../styles/stylex/cssVar.stylex.mjs";
|
|
|
2
2
|
import { focusRing } from "../styles/stylex/focusRing.mjs";
|
|
3
3
|
import { selectMarker } from "./marker.stylex.mjs";
|
|
4
4
|
// src/Select/style.ts
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
const styles = {
|
|
7
7
|
arrow: {
|
|
8
8
|
k1xSpc: "lb78zum5",
|
package/es/Slider/style.mjs
CHANGED
package/es/Text/style.d.mts
CHANGED
package/es/node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { SKIP as SKIP$1, visitParents } from "unist-util-visit-parents";
|
|
2
|
+
// node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
|
|
3
|
+
/**
|
|
4
|
+
* @import {Node as UnistNode, Parent as UnistParent} from 'unist'
|
|
5
|
+
* @import {
|
|
6
|
+
* InclusiveDescendant,
|
|
7
|
+
* Matches,
|
|
8
|
+
* Visitors as ParentsVisitors,
|
|
9
|
+
* VisitorResult,
|
|
10
|
+
* VisitorResultExit
|
|
11
|
+
* } from 'unist-util-visit-parents'
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
|
|
15
|
+
* Test from `unist-util-is`.
|
|
16
|
+
*
|
|
17
|
+
* Note: we have remove and add `undefined`, because otherwise when generating
|
|
18
|
+
* automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
|
|
19
|
+
* which doesn’t work when publishing on npm.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {(
|
|
23
|
+
* Node extends UnistParent
|
|
24
|
+
* ? Node extends {children: Array<infer Children>}
|
|
25
|
+
* ? Child extends Children ? Node : never
|
|
26
|
+
* : never
|
|
27
|
+
* : never
|
|
28
|
+
* )} InternalParent
|
|
29
|
+
* Collect nodes that can be parents of `Child`.
|
|
30
|
+
* @template {UnistNode} Node
|
|
31
|
+
* All node types in a tree.
|
|
32
|
+
* @template {UnistNode} Child
|
|
33
|
+
* Node to search for.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
|
|
37
|
+
* Collect nodes in `Tree` that can be parents of `Child`.
|
|
38
|
+
* @template {UnistNode} Tree
|
|
39
|
+
* All node types in a tree.
|
|
40
|
+
* @template {UnistNode} Child
|
|
41
|
+
* Node to search for.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @callback Visitor
|
|
45
|
+
* Handle a node (matching `test`, if given) before its children.
|
|
46
|
+
*
|
|
47
|
+
* Like `Visitor` in `unist-util-visit-parents`,
|
|
48
|
+
* but with `index` and `parent` instead of `parents`.
|
|
49
|
+
* @param {Visited} node
|
|
50
|
+
* Found node.
|
|
51
|
+
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
52
|
+
* Index of `node` in `parent`,
|
|
53
|
+
* or `undefined` for the tree itself.
|
|
54
|
+
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
55
|
+
* Parent of `node`,
|
|
56
|
+
* or `undefined` for the tree itself.
|
|
57
|
+
* @returns {VisitorResult}
|
|
58
|
+
* What to do next.
|
|
59
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
60
|
+
* Visited node type.
|
|
61
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
62
|
+
* Ancestor type.
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* @callback VisitorExit
|
|
66
|
+
* Handle a node (matching `test`, if given) after its children.
|
|
67
|
+
*
|
|
68
|
+
* Like `VisitorExit` in `unist-util-visit-parents`,
|
|
69
|
+
* but with `index` and `parent` instead of `parents`.
|
|
70
|
+
* @param {Visited} node
|
|
71
|
+
* Found node.
|
|
72
|
+
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
73
|
+
* Index of `node` in `parent`,
|
|
74
|
+
* or `undefined` for the tree itself.
|
|
75
|
+
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
76
|
+
* Parent of `node`,
|
|
77
|
+
* or `undefined` for the tree itself.
|
|
78
|
+
* @returns {VisitorResultExit}
|
|
79
|
+
* What to do next.
|
|
80
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
81
|
+
* Visited node type.
|
|
82
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
83
|
+
* Ancestor type.
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
87
|
+
* Visited node type.
|
|
88
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
89
|
+
* Ancestor type.
|
|
90
|
+
* @typedef Visitors
|
|
91
|
+
* Handle nodes when entering and exiting them.
|
|
92
|
+
*
|
|
93
|
+
* Like `Visitors` in `unist-util-visit-parents`.
|
|
94
|
+
* @property {Visitor<Visited, Ancestor> | null | undefined} [enter]
|
|
95
|
+
* Handle a node before its children (optional).
|
|
96
|
+
* @property {VisitorExit<Visited, Ancestor>} exit
|
|
97
|
+
* Handle a node after its children.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
|
|
101
|
+
* Build a typed `Visitor` function from a node and all possible parents.
|
|
102
|
+
*
|
|
103
|
+
* It will infer which values are passed as `node` and which as `parent`.
|
|
104
|
+
* @template {UnistNode} Visited
|
|
105
|
+
* Node type.
|
|
106
|
+
* @template {UnistParent} Ancestor
|
|
107
|
+
* Parent type.
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {(
|
|
111
|
+
* BuildVisitorFromMatch<
|
|
112
|
+
* Matches<Descendant, Check>,
|
|
113
|
+
* Extract<Descendant, UnistParent>
|
|
114
|
+
* >
|
|
115
|
+
* )} BuildVisitorFromDescendants
|
|
116
|
+
* Build a typed `Visitor` function from a list of descendants and a test.
|
|
117
|
+
*
|
|
118
|
+
* It will infer which values are passed as `node` and which as `parent`.
|
|
119
|
+
* @template {UnistNode} Descendant
|
|
120
|
+
* Node type.
|
|
121
|
+
* @template {Test} Check
|
|
122
|
+
* Test type.
|
|
123
|
+
*/
|
|
124
|
+
/**
|
|
125
|
+
* @typedef {(
|
|
126
|
+
* BuildVisitorFromDescendants<
|
|
127
|
+
* InclusiveDescendant<Tree>,
|
|
128
|
+
* Check
|
|
129
|
+
* >
|
|
130
|
+
* )} BuildVisitor
|
|
131
|
+
* Build a typed `Visitor` function from a tree and a test.
|
|
132
|
+
*
|
|
133
|
+
* It will infer which values are passed as `node` and which as `parent`.
|
|
134
|
+
* @template {UnistNode} [Tree=UnistNode]
|
|
135
|
+
* Node type.
|
|
136
|
+
* @template {Test} [Check=Test]
|
|
137
|
+
* Test type.
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* @typedef {(
|
|
141
|
+
* Visitors<
|
|
142
|
+
* Matches<InclusiveDescendant<Tree>, Check>,
|
|
143
|
+
* Parent<
|
|
144
|
+
* Extract<InclusiveDescendant<Tree>, UnistParent>,
|
|
145
|
+
* Matches<InclusiveDescendant<Tree>, Check>
|
|
146
|
+
* >
|
|
147
|
+
* >
|
|
148
|
+
* )} BuildVisitors
|
|
149
|
+
* Build typed `Visitors` from a tree and a test.
|
|
150
|
+
*
|
|
151
|
+
* It will infer which values are passed as `node` and which as `parent`.
|
|
152
|
+
* @template {UnistNode} [Tree=UnistNode]
|
|
153
|
+
* Node type.
|
|
154
|
+
* @template {Test} [Check=Test]
|
|
155
|
+
* Test type.
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* Visit nodes.
|
|
159
|
+
*
|
|
160
|
+
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
161
|
+
* (**NLR**) or if `reverse` is given,
|
|
162
|
+
* in *reverse preorder* (**NRL**).
|
|
163
|
+
* An `exit` visitor is called in *postorder* (**LRN**)
|
|
164
|
+
* or if `reverse` is given, in *reverse postorder* (**RLN**).
|
|
165
|
+
*
|
|
166
|
+
* You can choose which nodes are visited by passing a `test`.
|
|
167
|
+
* For complex tests, you should test yourself in a visitor, as it will be
|
|
168
|
+
* faster and will have improved type information.
|
|
169
|
+
*
|
|
170
|
+
* Walking the tree is an intensive task.
|
|
171
|
+
* Make use of the return values of the visitor when possible.
|
|
172
|
+
* Instead of walking a tree multiple times, walk it once, use `unist-util-is`
|
|
173
|
+
* to check if a node matches, and then perform different operations.
|
|
174
|
+
*
|
|
175
|
+
* You can change the tree.
|
|
176
|
+
* Changes inside a node made when entering it are walked,
|
|
177
|
+
* changes made when exiting it are not.
|
|
178
|
+
* See `Visitor` and `VisitorExit` for more info.
|
|
179
|
+
*
|
|
180
|
+
* @overload
|
|
181
|
+
* @param {Tree} tree
|
|
182
|
+
* Tree to traverse.
|
|
183
|
+
* @param {Check} check
|
|
184
|
+
* `unist-util-is`-compatible test.
|
|
185
|
+
* @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors
|
|
186
|
+
* Handle each node when entering it,
|
|
187
|
+
* or `{enter, exit}` to also handle it when exiting it.
|
|
188
|
+
* @param {boolean | null | undefined} [reverse]
|
|
189
|
+
* Walk children from last to first;
|
|
190
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
191
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
192
|
+
* @returns {undefined}
|
|
193
|
+
* Nothing.
|
|
194
|
+
*
|
|
195
|
+
* @overload
|
|
196
|
+
* @param {Tree} tree
|
|
197
|
+
* Tree to traverse.
|
|
198
|
+
* @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors
|
|
199
|
+
* Handle each node when entering it,
|
|
200
|
+
* or `{enter, exit}` to also handle it when exiting it.
|
|
201
|
+
* @param {boolean | null | undefined} [reverse]
|
|
202
|
+
* Walk children from last to first;
|
|
203
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
204
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
205
|
+
* @returns {undefined}
|
|
206
|
+
* Nothing.
|
|
207
|
+
*
|
|
208
|
+
* @param {UnistNode} tree
|
|
209
|
+
* Tree to traverse.
|
|
210
|
+
* @param {Visitor | Visitors | Test} testOrEnterOrVisitors
|
|
211
|
+
* `unist-util-is`-compatible test, `enter`, or `visitors`.
|
|
212
|
+
* @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
|
|
213
|
+
* `enter`, `visitors`, or `reverse` after a test.
|
|
214
|
+
* @param {boolean | null | undefined} [maybeReverse]
|
|
215
|
+
* Walk children from last to first;
|
|
216
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
217
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
218
|
+
* @returns {undefined}
|
|
219
|
+
* Nothing.
|
|
220
|
+
*
|
|
221
|
+
* @template {UnistNode} Tree
|
|
222
|
+
* Node type.
|
|
223
|
+
* @template {Test} Check
|
|
224
|
+
* `unist-util-is`-compatible test.
|
|
225
|
+
*/
|
|
226
|
+
function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
|
|
227
|
+
/** @type {Test} */
|
|
228
|
+
let check;
|
|
229
|
+
/** @type {Visitor | Visitors} */
|
|
230
|
+
let visitors;
|
|
231
|
+
/** @type {boolean | null | undefined} */
|
|
232
|
+
let reverse;
|
|
233
|
+
if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
|
|
234
|
+
check = testOrEnterOrVisitors;
|
|
235
|
+
visitors = enterOrVisitorsOrReverse;
|
|
236
|
+
reverse = maybeReverse;
|
|
237
|
+
} else {
|
|
238
|
+
visitors = testOrEnterOrVisitors;
|
|
239
|
+
reverse = enterOrVisitorsOrReverse;
|
|
240
|
+
}
|
|
241
|
+
if (typeof visitors === "function") visitParents(tree, check, wrap(visitors), reverse);
|
|
242
|
+
else visitParents(tree, check, wrapVisitors(visitors), reverse);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Turn `visit` visitors into `visitParents` visitors.
|
|
246
|
+
*
|
|
247
|
+
* @param {Visitors} visitors
|
|
248
|
+
* Visitors for `visit`.
|
|
249
|
+
* @returns {ParentsVisitors}
|
|
250
|
+
* Visitors for `visitParents`.
|
|
251
|
+
*/
|
|
252
|
+
function wrapVisitors(visitors) {
|
|
253
|
+
if (!visitors || typeof visitors !== "object") return visitors;
|
|
254
|
+
return {
|
|
255
|
+
enter: typeof visitors.enter === "function" ? wrap(visitors.enter) : visitors.enter,
|
|
256
|
+
exit: typeof visitors.exit === "function" ? wrap(visitors.exit) : visitors.exit
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Turn a `visit` visitor into a `visitParents` one.
|
|
261
|
+
*
|
|
262
|
+
* @template {VisitorResult} Result
|
|
263
|
+
* Result type.
|
|
264
|
+
* @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor
|
|
265
|
+
* Visitor for `visit`.
|
|
266
|
+
* @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}
|
|
267
|
+
* Visitor for `visitParents`.
|
|
268
|
+
*/
|
|
269
|
+
function wrap(visitor) {
|
|
270
|
+
return overload;
|
|
271
|
+
/**
|
|
272
|
+
* Call `visitor` with `index` and `parent` instead of `parents`.
|
|
273
|
+
*
|
|
274
|
+
* @param {UnistNode} node
|
|
275
|
+
* Visited node.
|
|
276
|
+
* @param {Array<UnistParent>} parents
|
|
277
|
+
* Ancestors of `node`.
|
|
278
|
+
* @param {number | undefined} index
|
|
279
|
+
* Index of `node` in its parent.
|
|
280
|
+
* @returns {Result}
|
|
281
|
+
* What to do next.
|
|
282
|
+
*/
|
|
283
|
+
function overload(node, parents, index) {
|
|
284
|
+
return visitor(node, index, parents[parents.length - 1]);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
export { SKIP$1 as SKIP, visit };
|
|
288
|
+
|
|
289
|
+
//# sourceMappingURL=index.mjs.map
|
package/es/node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js"],"sourcesContent":["/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {\n * InclusiveDescendant,\n * Matches,\n * Visitors as ParentsVisitors,\n * VisitorResult,\n * VisitorResultExit\n * } from 'unist-util-visit-parents'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given) before its children.\n *\n * Like `Visitor` in `unist-util-visit-parents`,\n * but with `index` and `parent` instead of `parents`.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`,\n * or `undefined` for the tree itself.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`,\n * or `undefined` for the tree itself.\n * @returns {VisitorResult}\n * What to do next.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @callback VisitorExit\n * Handle a node (matching `test`, if given) after its children.\n *\n * Like `VisitorExit` in `unist-util-visit-parents`,\n * but with `index` and `parent` instead of `parents`.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`,\n * or `undefined` for the tree itself.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`,\n * or `undefined` for the tree itself.\n * @returns {VisitorResultExit}\n * What to do next.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n * @typedef Visitors\n * Handle nodes when entering and exiting them.\n *\n * Like `Visitors` in `unist-util-visit-parents`.\n * @property {Visitor<Visited, Ancestor> | null | undefined} [enter]\n * Handle a node before its children (optional).\n * @property {VisitorExit<Visited, Ancestor>} exit\n * Handle a node after its children.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\n/**\n * @typedef {(\n * Visitors<\n * Matches<InclusiveDescendant<Tree>, Check>,\n * Parent<\n * Extract<InclusiveDescendant<Tree>, UnistParent>,\n * Matches<InclusiveDescendant<Tree>, Check>\n * >\n * >\n * )} BuildVisitors\n * Build typed `Visitors` from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given,\n * in *reverse preorder* (**NRL**).\n * An `exit` visitor is called in *postorder* (**LRN**)\n * or if `reverse` is given, in *reverse postorder* (**RLN**).\n *\n * You can choose which nodes are visited by passing a `test`.\n * For complex tests, you should test yourself in a visitor, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * Changes inside a node made when entering it are walked,\n * changes made when exiting it are not.\n * See `Visitor` and `VisitorExit` for more info.\n *\n * @overload\n * @param {Tree} tree\n * Tree to traverse.\n * @param {Check} check\n * `unist-util-is`-compatible test.\n * @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors\n * Handle each node when entering it,\n * or `{enter, exit}` to also handle it when exiting it.\n * @param {boolean | null | undefined} [reverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @overload\n * @param {Tree} tree\n * Tree to traverse.\n * @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors\n * Handle each node when entering it,\n * or `{enter, exit}` to also handle it when exiting it.\n * @param {boolean | null | undefined} [reverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Visitors | Test} testOrEnterOrVisitors\n * `unist-util-is`-compatible test, `enter`, or `visitors`.\n * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]\n * `enter`, `visitors`, or `reverse` after a test.\n * @param {boolean | null | undefined} [maybeReverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(\n tree,\n testOrEnterOrVisitors,\n enterOrVisitorsOrReverse,\n maybeReverse\n) {\n /** @type {Test} */\n let check\n /** @type {Visitor | Visitors} */\n let visitors\n /** @type {boolean | null | undefined} */\n let reverse\n\n // Third parameter is an enter visitor or a visitors object, so expect a `test` too.\n if (\n typeof enterOrVisitorsOrReverse === 'function' ||\n (enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')\n ) {\n check = /** @type {Test} */ (testOrEnterOrVisitors)\n visitors = enterOrVisitorsOrReverse\n reverse = maybeReverse\n }\n // Assume no test.\n else {\n visitors = /** @type {Visitor | Visitors} */ (testOrEnterOrVisitors)\n reverse = enterOrVisitorsOrReverse\n }\n\n if (typeof visitors === 'function') {\n visitParents(tree, check, wrap(visitors), reverse)\n } else {\n visitParents(tree, check, wrapVisitors(visitors), reverse)\n }\n}\n\n/**\n * Turn `visit` visitors into `visitParents` visitors.\n *\n * @param {Visitors} visitors\n * Visitors for `visit`.\n * @returns {ParentsVisitors}\n * Visitors for `visitParents`.\n */\nfunction wrapVisitors(visitors) {\n // Pass anything else straight to `visitParents` to get its errors.\n if (!visitors || typeof visitors !== 'object') return visitors\n\n return {\n enter:\n typeof visitors.enter === 'function'\n ? wrap(visitors.enter)\n : visitors.enter,\n exit:\n typeof visitors.exit === 'function' ? wrap(visitors.exit) : visitors.exit\n }\n}\n\n/**\n * Turn a `visit` visitor into a `visitParents` one.\n *\n * @template {VisitorResult} Result\n * Result type.\n * @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor\n * Visitor for `visit`.\n * @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}\n * Visitor for `visitParents`.\n */\nfunction wrap(visitor) {\n return overload\n\n /**\n * Call `visitor` with `index` and `parent` instead of `parents`.\n *\n * @param {UnistNode} node\n * Visited node.\n * @param {Array<UnistParent>} parents\n * Ancestors of `node`.\n * @param {number | undefined} index\n * Index of `node` in its parent.\n * @returns {Result}\n * What to do next.\n */\n function overload(node, parents, index) {\n return visitor(node, index, parents[parents.length - 1])\n }\n}\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OA,SAAgB,MACd,MACA,uBACA,0BACA,cACA;;CAEA,IAAI;;CAEJ,IAAI;;CAEJ,IAAI;CAGJ,IACE,OAAO,6BAA6B,cACnC,4BAA4B,OAAO,6BAA6B,UACjE;EACA,QAA6B;EAC7B,WAAW;EACX,UAAU;CACZ,OAEK;EACH,WAA8C;EAC9C,UAAU;CACZ;CAEA,IAAI,OAAO,aAAa,YACtB,aAAa,MAAM,OAAO,KAAK,QAAQ,GAAG,OAAO;MAEjD,aAAa,MAAM,OAAO,aAAa,QAAQ,GAAG,OAAO;AAE7D;;;;;;;;;AAUA,SAAS,aAAa,UAAU;CAE9B,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO;CAEtD,OAAO;EACL,OACE,OAAO,SAAS,UAAU,aACtB,KAAK,SAAS,KAAK,IACnB,SAAS;EACf,MACE,OAAO,SAAS,SAAS,aAAa,KAAK,SAAS,IAAI,IAAI,SAAS;CACzE;AACF;;;;;;;;;;;AAYA,SAAS,KAAK,SAAS;CACrB,OAAO;;;;;;;;;;;;;CAcP,SAAS,SAAS,MAAM,SAAS,OAAO;EACtC,OAAO,QAAQ,MAAM,OAAO,QAAQ,QAAQ,SAAS,EAAE;CACzD;AACF"}
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { css, injectGlobal } from "./css.mjs";
|
|
2
|
+
import { createGlobalSheet, css, injectGlobal } from "./css.mjs";
|
|
3
3
|
import { useTheme } from "./theme/scope.mjs";
|
|
4
|
-
import { useMemo } from "react";
|
|
4
|
+
import { useInsertionEffect, useMemo, useRef } from "react";
|
|
5
5
|
// src/styles/createGlobalStyle.ts
|
|
6
|
+
const isServer = typeof document === "undefined";
|
|
6
7
|
const createGlobalStyle = (template, ...args) => {
|
|
7
8
|
const GlobalStyle = () => {
|
|
8
9
|
const theme = useTheme();
|
|
9
|
-
|
|
10
|
+
const sheetRef = useRef(null);
|
|
11
|
+
const styles = useMemo(() => {
|
|
10
12
|
const props = { theme };
|
|
11
|
-
const
|
|
12
|
-
injectGlobal(
|
|
13
|
+
const resolved = typeof template === "function" ? template(props) : css(template, ...args.map((arg) => typeof arg === "function" ? arg(props) : arg));
|
|
14
|
+
if (isServer) injectGlobal(resolved);
|
|
15
|
+
return resolved;
|
|
13
16
|
}, [theme]);
|
|
17
|
+
useInsertionEffect(() => {
|
|
18
|
+
const sheet = createGlobalSheet();
|
|
19
|
+
sheetRef.current = sheet;
|
|
20
|
+
return () => {
|
|
21
|
+
sheet.remove();
|
|
22
|
+
sheetRef.current = null;
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
useInsertionEffect(() => {
|
|
26
|
+
sheetRef.current?.update(styles);
|
|
27
|
+
}, [styles]);
|
|
14
28
|
return null;
|
|
15
29
|
};
|
|
16
30
|
return GlobalStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobalStyle.mjs","names":[],"sources":["../../src/styles/createGlobalStyle.ts"],"sourcesContent":["'use client';\n\nimport type { CSSInterpolation } from '@emotion/serialize';\nimport { useMemo } from 'react';\n\nimport { css, injectGlobal } from './css';\nimport { type LobeTheme, useTheme } from './theme/scope';\n\ntype GlobalStyleProps = { theme: LobeTheme };\ntype GlobalInterpolation = CSSInterpolation | ((props: GlobalStyleProps) => CSSInterpolation);\n\nexport const createGlobalStyle = (\n template: TemplateStringsArray | ((props: GlobalStyleProps) => CSSInterpolation),\n ...args: GlobalInterpolation[]\n) => {\n const GlobalStyle = () => {\n const theme = useTheme();\n\n useMemo(() => {\n const props = { theme };\n const
|
|
1
|
+
{"version":3,"file":"createGlobalStyle.mjs","names":[],"sources":["../../src/styles/createGlobalStyle.ts"],"sourcesContent":["'use client';\n\nimport type { CSSInterpolation } from '@emotion/serialize';\nimport { useInsertionEffect, useMemo, useRef } from 'react';\n\nimport { createGlobalSheet, css, injectGlobal } from './css';\nimport { type LobeTheme, useTheme } from './theme/scope';\n\ntype GlobalStyleProps = { theme: LobeTheme };\ntype GlobalInterpolation = CSSInterpolation | ((props: GlobalStyleProps) => CSSInterpolation);\n\nconst isServer = typeof document === 'undefined';\n\nexport const createGlobalStyle = (\n template: TemplateStringsArray | ((props: GlobalStyleProps) => CSSInterpolation),\n ...args: GlobalInterpolation[]\n) => {\n const GlobalStyle = () => {\n const theme = useTheme();\n const sheetRef = useRef<ReturnType<typeof createGlobalSheet>>(null);\n\n const styles = useMemo(() => {\n const props = { theme };\n const resolved =\n typeof template === 'function'\n ? template(props)\n : css(template, ...args.map((arg) => (typeof arg === 'function' ? arg(props) : arg)));\n // Server renders keep feeding the shared cache so extractStaticStyle ships them.\n if (isServer) injectGlobal(resolved as TemplateStringsArray);\n return resolved;\n }, [theme]);\n\n useInsertionEffect(() => {\n const sheet = createGlobalSheet();\n sheetRef.current = sheet;\n return () => {\n sheet.remove();\n sheetRef.current = null;\n };\n }, []);\n\n useInsertionEffect(() => {\n sheetRef.current?.update(styles);\n }, [styles]);\n\n return null;\n };\n\n return GlobalStyle;\n};\n"],"mappings":";;;;;AAWA,MAAM,WAAW,OAAO,aAAa;AAErC,MAAa,qBACX,UACA,GAAG,SACA;CACH,MAAM,oBAAoB;EACxB,MAAM,QAAQ,SAAS;EACvB,MAAM,WAAW,OAA6C,IAAI;EAElE,MAAM,SAAS,cAAc;GAC3B,MAAM,QAAQ,EAAE,MAAM;GACtB,MAAM,WACJ,OAAO,aAAa,aAChB,SAAS,KAAK,IACd,IAAI,UAAU,GAAG,KAAK,KAAK,QAAS,OAAO,QAAQ,aAAa,IAAI,KAAK,IAAI,GAAI,CAAC;GAExF,IAAI,UAAU,aAAa,QAAgC;GAC3D,OAAO;EACT,GAAG,CAAC,KAAK,CAAC;EAEV,yBAAyB;GACvB,MAAM,QAAQ,kBAAkB;GAChC,SAAS,UAAU;GACnB,aAAa;IACX,MAAM,OAAO;IACb,SAAS,UAAU;GACrB;EACF,GAAG,CAAC,CAAC;EAEL,yBAAyB;GACvB,SAAS,SAAS,OAAO,MAAM;EACjC,GAAG,CAAC,MAAM,CAAC;EAEX,OAAO;CACT;CAEA,OAAO;AACT"}
|
package/es/styles/css.mjs
CHANGED
|
@@ -45,6 +45,23 @@ const isSerialized = (value) => typeof value === "object" && value !== null && "
|
|
|
45
45
|
const css = (template, ...args) => serializeStyles([template, ...args], emotion.cache.registered);
|
|
46
46
|
const cx = (...classNames) => emotion.cx(...classNames.map((value) => isSerialized(value) ? emotion.css(value) : value));
|
|
47
47
|
const { injectGlobal, keyframes } = emotion;
|
|
48
|
+
const compileGlobal = (styles) => {
|
|
49
|
+
let rules = "";
|
|
50
|
+
emotion.cache.insert("", serializeStyles([styles], emotion.cache.registered), { insert: (rule) => rules += rule }, false);
|
|
51
|
+
return rules;
|
|
52
|
+
};
|
|
53
|
+
const createGlobalSheet = () => {
|
|
54
|
+
const element = document.createElement("style");
|
|
55
|
+
element.dataset.emotion = `${emotion.cache.key}-global`;
|
|
56
|
+
const { container, tags } = emotion.sheet;
|
|
57
|
+
container.insertBefore(element, tags[0] ?? null);
|
|
58
|
+
return {
|
|
59
|
+
remove: () => element.remove(),
|
|
60
|
+
update: (styles) => {
|
|
61
|
+
element.textContent = compileGlobal(styles);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
48
65
|
const staticCss = (template, ...args) => emotion.css(template, ...args);
|
|
49
66
|
const createStaticStyles = (stylesFn) => stylesFn({
|
|
50
67
|
css: staticCss,
|
|
@@ -65,6 +82,6 @@ const extractStaticStyle = Object.assign((html, _options) => {
|
|
|
65
82
|
tag: `<style data-emotion="${key} ${ids.join(" ")}">${styles}</style>`
|
|
66
83
|
}];
|
|
67
84
|
}, { cache: emotion.cache });
|
|
68
|
-
export { createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive, toCssVarName, toCssVariables, toKebabCase };
|
|
85
|
+
export { createGlobalSheet, createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive, toCssVarName, toCssVariables, toKebabCase };
|
|
69
86
|
|
|
70
87
|
//# sourceMappingURL=css.mjs.map
|
package/es/styles/css.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.mjs","names":[],"sources":["../../src/styles/css.ts"],"sourcesContent":["import createEmotion from '@emotion/css/create-instance';\nimport { type CSSInterpolation, type SerializedStyles, serializeStyles } from '@emotion/serialize';\n\nimport { createLobeToken, type LobeToken } from './theme/createLobeToken';\n\nconst UNITLESS = new Set([\n 'fontWeightStrong',\n 'lineHeight',\n 'lineHeightHeading1',\n 'lineHeightHeading2',\n 'lineHeightHeading3',\n 'lineHeightHeading4',\n 'lineHeightHeading5',\n 'lineHeightLG',\n 'lineHeightSM',\n 'opacityImage',\n 'opacityLoading',\n 'zIndexBase',\n 'zIndexPopupBase',\n]);\n\nconst IGNORED = new Set(['motionBase', 'motionUnit']);\n\nexport const toKebabCase = (str: string) =>\n str\n .replaceAll(/([a-z])([A-Z])/g, '$1-$2')\n .replaceAll(/([a-z])(\\d)/g, '$1-$2')\n .replaceAll(/(\\d)([A-Z])/g, '$1-$2')\n .replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n\nexport const toCssVarName = (key: string) => `--lobe-${toKebabCase(key)}`;\n\nexport const toCssVariables = (token: Record<string, number | string>) =>\n Object.fromEntries(\n Object.entries(token)\n .filter(([key]) => !IGNORED.has(key))\n .map(([key, value]) => [\n toCssVarName(key),\n typeof value === 'number' && !UNITLESS.has(key)\n ? `${value}px`\n : String(value).replaceAll(/\\s+/g, ' ').trim(),\n ]),\n );\n\nexport type LobeCssVar = Record<Exclude<keyof LobeToken, 'motionBase' | 'motionUnit'>, string>;\n\nexport const cssVar = Object.fromEntries(\n Object.keys(createLobeToken({ appearance: 'light' }))\n .filter((key) => !IGNORED.has(key))\n .map((key) => [key, `var(${toCssVarName(key)})`]),\n) as LobeCssVar;\n\nconst breakpoints = {\n xs: '@media (max-width: 479.98px)',\n sm: '@media (max-width: 575.98px)',\n md: '@media (max-width: 767.98px)',\n lg: '@media (max-width: 991.98px)',\n xl: '@media (max-width: 1199.98px)',\n xxl: '@media (min-width: 1200px)',\n};\n\nexport const responsive = {\n ...breakpoints,\n desktop: breakpoints.xxl,\n laptop: breakpoints.lg,\n mobile: breakpoints.xs,\n tablet: breakpoints.md,\n};\n\nexport interface StaticStyleUtils {\n css: (template: TemplateStringsArray, ...args: any[]) => string;\n cssVar: LobeCssVar;\n cx: (...classNames: any[]) => string;\n responsive: typeof responsive;\n}\n\nconst emotion = createEmotion({ key: 'acss', speedy: true });\n\nconst isSerialized = (value: unknown): value is SerializedStyles =>\n typeof value === 'object' && value !== null && 'name' in value && 'styles' in value;\n\nexport const css = (\n template: TemplateStringsArray | CSSInterpolation,\n ...args: CSSInterpolation[]\n): SerializedStyles =>\n serializeStyles([template as CSSInterpolation, ...args], emotion.cache.registered);\n\nexport const cx = (...classNames: unknown[]): string =>\n emotion.cx(\n ...(classNames.map((value) => (isSerialized(value) ? emotion.css(value) : value)) as Parameters<\n typeof emotion.cx\n >),\n );\n\nexport const { injectGlobal, keyframes } = emotion;\n\nconst staticCss: StaticStyleUtils['css'] = (template, ...args) => emotion.css(template, ...args);\n\nexport const createStaticStyles = <T>(stylesFn: (utils: StaticStyleUtils) => T): T =>\n stylesFn({ css: staticCss, cssVar, cx, responsive });\n\nexport interface StaticStyleExtract {\n css: string;\n ids: string[];\n key: string;\n tag: string;\n}\n\n// emotion rehydrates `<style data-emotion=\"acss id…\">` from SSR into its cache on the client\nexport const extractStaticStyle = Object.assign(\n (html?: string, _options?: Record<string, unknown>): StaticStyleExtract[] => {\n const { inserted, key, registered } = emotion.cache;\n const used = html\n ? new Set([...html.matchAll(new RegExp(`${key}-([\\\\w-]+)`, 'g'))].map((match) => match[1]))\n : undefined;\n // Same rule as @emotion/server extractCritical: unregistered ids are globals/keyframes and always ship\n const ids = Object.keys(inserted).filter(\n (id) =>\n typeof inserted[id] === 'string' &&\n (!used || used.has(id) || registered[`${key}-${id}`] === undefined),\n );\n const styles = ids.map((id) => inserted[id]).join('');\n if (!styles) return [];\n return [\n {\n css: styles,\n ids,\n key,\n tag: `<style data-emotion=\"${key} ${ids.join(' ')}\">${styles}</style>`,\n },\n ];\n },\n { cache: emotion.cache },\n);\n"],"mappings":";;;;AAKA,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,0BAAU,IAAI,IAAI,CAAC,cAAc,YAAY,CAAC;AAEpD,MAAa,eAAe,QAC1B,IACG,WAAW,mBAAmB,OAAO,CAAC,CACtC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,yBAAyB,OAAO,CAAC,CAC5C,YAAY;AAEjB,MAAa,gBAAgB,QAAgB,UAAU,YAAY,GAAG;AAEtE,MAAa,kBAAkB,UAC7B,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAClB,QAAQ,CAAC,SAAS,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CACpC,KAAK,CAAC,KAAK,WAAW,CACrB,aAAa,GAAG,GAChB,OAAO,UAAU,YAAY,CAAC,SAAS,IAAI,GAAG,IAC1C,GAAG,MAAM,MACT,OAAO,KAAK,CAAC,CAAC,WAAW,QAAQ,GAAG,CAAC,CAAC,KAAK,CACjD,CAAC,CACL;AAIF,MAAa,SAAS,OAAO,YAC3B,OAAO,KAAK,gBAAgB,EAAE,YAAY,QAAQ,CAAC,CAAC,CAAC,CAClD,QAAQ,QAAQ,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAClC,KAAK,QAAQ,CAAC,KAAK,OAAO,aAAa,GAAG,EAAE,EAAE,CAAC,CACpD;AAEA,MAAM,cAAc;CAClB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,KAAK;AACP;AAEA,MAAa,aAAa;CACxB,GAAG;CACH,SAAS,YAAY;CACrB,QAAQ,YAAY;CACpB,QAAQ,YAAY;CACpB,QAAQ,YAAY;AACtB;AASA,MAAM,UAAU,cAAc;CAAE,KAAK;CAAQ,QAAQ;AAAK,CAAC;AAE3D,MAAM,gBAAgB,UACpB,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,YAAY;AAEhF,MAAa,OACX,UACA,GAAG,SAEH,gBAAgB,CAAC,UAA8B,GAAG,IAAI,GAAG,QAAQ,MAAM,UAAU;AAEnF,MAAa,MAAM,GAAG,eACpB,QAAQ,GACN,GAAI,WAAW,KAAK,UAAW,aAAa,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAM,CAGlF;AAEF,MAAa,EAAE,cAAc,cAAc;
|
|
1
|
+
{"version":3,"file":"css.mjs","names":[],"sources":["../../src/styles/css.ts"],"sourcesContent":["import createEmotion from '@emotion/css/create-instance';\nimport { type CSSInterpolation, type SerializedStyles, serializeStyles } from '@emotion/serialize';\n\nimport { createLobeToken, type LobeToken } from './theme/createLobeToken';\n\nconst UNITLESS = new Set([\n 'fontWeightStrong',\n 'lineHeight',\n 'lineHeightHeading1',\n 'lineHeightHeading2',\n 'lineHeightHeading3',\n 'lineHeightHeading4',\n 'lineHeightHeading5',\n 'lineHeightLG',\n 'lineHeightSM',\n 'opacityImage',\n 'opacityLoading',\n 'zIndexBase',\n 'zIndexPopupBase',\n]);\n\nconst IGNORED = new Set(['motionBase', 'motionUnit']);\n\nexport const toKebabCase = (str: string) =>\n str\n .replaceAll(/([a-z])([A-Z])/g, '$1-$2')\n .replaceAll(/([a-z])(\\d)/g, '$1-$2')\n .replaceAll(/(\\d)([A-Z])/g, '$1-$2')\n .replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n\nexport const toCssVarName = (key: string) => `--lobe-${toKebabCase(key)}`;\n\nexport const toCssVariables = (token: Record<string, number | string>) =>\n Object.fromEntries(\n Object.entries(token)\n .filter(([key]) => !IGNORED.has(key))\n .map(([key, value]) => [\n toCssVarName(key),\n typeof value === 'number' && !UNITLESS.has(key)\n ? `${value}px`\n : String(value).replaceAll(/\\s+/g, ' ').trim(),\n ]),\n );\n\nexport type LobeCssVar = Record<Exclude<keyof LobeToken, 'motionBase' | 'motionUnit'>, string>;\n\nexport const cssVar = Object.fromEntries(\n Object.keys(createLobeToken({ appearance: 'light' }))\n .filter((key) => !IGNORED.has(key))\n .map((key) => [key, `var(${toCssVarName(key)})`]),\n) as LobeCssVar;\n\nconst breakpoints = {\n xs: '@media (max-width: 479.98px)',\n sm: '@media (max-width: 575.98px)',\n md: '@media (max-width: 767.98px)',\n lg: '@media (max-width: 991.98px)',\n xl: '@media (max-width: 1199.98px)',\n xxl: '@media (min-width: 1200px)',\n};\n\nexport const responsive = {\n ...breakpoints,\n desktop: breakpoints.xxl,\n laptop: breakpoints.lg,\n mobile: breakpoints.xs,\n tablet: breakpoints.md,\n};\n\nexport interface StaticStyleUtils {\n css: (template: TemplateStringsArray, ...args: any[]) => string;\n cssVar: LobeCssVar;\n cx: (...classNames: any[]) => string;\n responsive: typeof responsive;\n}\n\nconst emotion = createEmotion({ key: 'acss', speedy: true });\n\nconst isSerialized = (value: unknown): value is SerializedStyles =>\n typeof value === 'object' && value !== null && 'name' in value && 'styles' in value;\n\nexport const css = (\n template: TemplateStringsArray | CSSInterpolation,\n ...args: CSSInterpolation[]\n): SerializedStyles =>\n serializeStyles([template as CSSInterpolation, ...args], emotion.cache.registered);\n\nexport const cx = (...classNames: unknown[]): string =>\n emotion.cx(\n ...(classNames.map((value) => (isSerialized(value) ? emotion.css(value) : value)) as Parameters<\n typeof emotion.cx\n >),\n );\n\nexport const { injectGlobal, keyframes } = emotion;\n\ntype EmotionSheet = Parameters<typeof emotion.cache.insert>[2];\n\nconst compileGlobal = (styles: CSSInterpolation): string => {\n let rules = '';\n const collector = { insert: (rule: string) => (rules += rule) } as unknown as EmotionSheet;\n emotion.cache.insert('', serializeStyles([styles], emotion.cache.registered), collector, false);\n return rules;\n};\n\n// Owns its rules instead of going through `injectGlobal`, whose per-hash dedupe never\n// re-inserts a style it has seen: switching A → B → A would leave B's rules last and winning.\nexport const createGlobalSheet = () => {\n const element = document.createElement('style');\n element.dataset.emotion = `${emotion.cache.key}-global`;\n const { container, tags } = emotion.sheet as unknown as { container: Node; tags: Node[] };\n container.insertBefore(element, tags[0] ?? null);\n\n return {\n remove: () => element.remove(),\n update: (styles: CSSInterpolation) => {\n element.textContent = compileGlobal(styles);\n },\n };\n};\n\nconst staticCss: StaticStyleUtils['css'] = (template, ...args) => emotion.css(template, ...args);\n\nexport const createStaticStyles = <T>(stylesFn: (utils: StaticStyleUtils) => T): T =>\n stylesFn({ css: staticCss, cssVar, cx, responsive });\n\nexport interface StaticStyleExtract {\n css: string;\n ids: string[];\n key: string;\n tag: string;\n}\n\n// emotion rehydrates `<style data-emotion=\"acss id…\">` from SSR into its cache on the client\nexport const extractStaticStyle = Object.assign(\n (html?: string, _options?: Record<string, unknown>): StaticStyleExtract[] => {\n const { inserted, key, registered } = emotion.cache;\n const used = html\n ? new Set([...html.matchAll(new RegExp(`${key}-([\\\\w-]+)`, 'g'))].map((match) => match[1]))\n : undefined;\n // Same rule as @emotion/server extractCritical: unregistered ids are globals/keyframes and always ship\n const ids = Object.keys(inserted).filter(\n (id) =>\n typeof inserted[id] === 'string' &&\n (!used || used.has(id) || registered[`${key}-${id}`] === undefined),\n );\n const styles = ids.map((id) => inserted[id]).join('');\n if (!styles) return [];\n return [\n {\n css: styles,\n ids,\n key,\n tag: `<style data-emotion=\"${key} ${ids.join(' ')}\">${styles}</style>`,\n },\n ];\n },\n { cache: emotion.cache },\n);\n"],"mappings":";;;;AAKA,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,0BAAU,IAAI,IAAI,CAAC,cAAc,YAAY,CAAC;AAEpD,MAAa,eAAe,QAC1B,IACG,WAAW,mBAAmB,OAAO,CAAC,CACtC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,yBAAyB,OAAO,CAAC,CAC5C,YAAY;AAEjB,MAAa,gBAAgB,QAAgB,UAAU,YAAY,GAAG;AAEtE,MAAa,kBAAkB,UAC7B,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAClB,QAAQ,CAAC,SAAS,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CACpC,KAAK,CAAC,KAAK,WAAW,CACrB,aAAa,GAAG,GAChB,OAAO,UAAU,YAAY,CAAC,SAAS,IAAI,GAAG,IAC1C,GAAG,MAAM,MACT,OAAO,KAAK,CAAC,CAAC,WAAW,QAAQ,GAAG,CAAC,CAAC,KAAK,CACjD,CAAC,CACL;AAIF,MAAa,SAAS,OAAO,YAC3B,OAAO,KAAK,gBAAgB,EAAE,YAAY,QAAQ,CAAC,CAAC,CAAC,CAClD,QAAQ,QAAQ,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAClC,KAAK,QAAQ,CAAC,KAAK,OAAO,aAAa,GAAG,EAAE,EAAE,CAAC,CACpD;AAEA,MAAM,cAAc;CAClB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,KAAK;AACP;AAEA,MAAa,aAAa;CACxB,GAAG;CACH,SAAS,YAAY;CACrB,QAAQ,YAAY;CACpB,QAAQ,YAAY;CACpB,QAAQ,YAAY;AACtB;AASA,MAAM,UAAU,cAAc;CAAE,KAAK;CAAQ,QAAQ;AAAK,CAAC;AAE3D,MAAM,gBAAgB,UACpB,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,YAAY;AAEhF,MAAa,OACX,UACA,GAAG,SAEH,gBAAgB,CAAC,UAA8B,GAAG,IAAI,GAAG,QAAQ,MAAM,UAAU;AAEnF,MAAa,MAAM,GAAG,eACpB,QAAQ,GACN,GAAI,WAAW,KAAK,UAAW,aAAa,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAM,CAGlF;AAEF,MAAa,EAAE,cAAc,cAAc;AAI3C,MAAM,iBAAiB,WAAqC;CAC1D,IAAI,QAAQ;CAEZ,QAAQ,MAAM,OAAO,IAAI,gBAAgB,CAAC,MAAM,GAAG,QAAQ,MAAM,UAAU,GAAG,EAD1D,SAAS,SAAkB,SAAS,KAC8B,GAAG,KAAK;CAC9F,OAAO;AACT;AAIA,MAAa,0BAA0B;CACrC,MAAM,UAAU,SAAS,cAAc,OAAO;CAC9C,QAAQ,QAAQ,UAAU,GAAG,QAAQ,MAAM,IAAI;CAC/C,MAAM,EAAE,WAAW,SAAS,QAAQ;CACpC,UAAU,aAAa,SAAS,KAAK,MAAM,IAAI;CAE/C,OAAO;EACL,cAAc,QAAQ,OAAO;EAC7B,SAAS,WAA6B;GACpC,QAAQ,cAAc,cAAc,MAAM;EAC5C;CACF;AACF;AAEA,MAAM,aAAsC,UAAU,GAAG,SAAS,QAAQ,IAAI,UAAU,GAAG,IAAI;AAE/F,MAAa,sBAAyB,aACpC,SAAS;CAAE,KAAK;CAAW;CAAQ;CAAI;AAAW,CAAC;AAUrD,MAAa,qBAAqB,OAAO,QACtC,MAAe,aAA6D;CAC3E,MAAM,EAAE,UAAU,KAAK,eAAe,QAAQ;CAC9C,MAAM,OAAO,OACT,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,GAAG,IAAI,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,MAAM,EAAE,CAAC,IACxF,KAAA;CAEJ,MAAM,MAAM,OAAO,KAAK,QAAQ,CAAC,CAAC,QAC/B,OACC,OAAO,SAAS,QAAQ,aACvB,CAAC,QAAQ,KAAK,IAAI,EAAE,KAAK,WAAW,GAAG,IAAI,GAAG,UAAU,KAAA,EAC7D;CACA,MAAM,SAAS,IAAI,KAAK,OAAO,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE;CACpD,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,OAAO,CACL;EACE,KAAK;EACL;EACA;EACA,KAAK,wBAAwB,IAAI,GAAG,IAAI,KAAK,GAAG,EAAE,IAAI,OAAO;CAC/D,CACF;AACF,GACA,EAAE,OAAO,QAAQ,MAAM,CACzB"}
|
package/package.json
CHANGED
package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { SKIP as SKIP$1, visitParents } from "unist-util-visit-parents";
|
|
2
|
-
// node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.js
|
|
3
|
-
/**
|
|
4
|
-
* @import {Node as UnistNode, Parent as UnistParent} from 'unist'
|
|
5
|
-
* @import {VisitorResult} from 'unist-util-visit-parents'
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
|
|
9
|
-
* Test from `unist-util-is`.
|
|
10
|
-
*
|
|
11
|
-
* Note: we have remove and add `undefined`, because otherwise when generating
|
|
12
|
-
* automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
|
|
13
|
-
* which doesn’t work when publishing on npm.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {(
|
|
17
|
-
* Fn extends (value: any) => value is infer Thing
|
|
18
|
-
* ? Thing
|
|
19
|
-
* : Fallback
|
|
20
|
-
* )} Predicate
|
|
21
|
-
* Get the value of a type guard `Fn`.
|
|
22
|
-
* @template Fn
|
|
23
|
-
* Value; typically function that is a type guard (such as `(x): x is Y`).
|
|
24
|
-
* @template Fallback
|
|
25
|
-
* Value to yield if `Fn` is not a type guard.
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {(
|
|
29
|
-
* Check extends null | undefined // No test.
|
|
30
|
-
* ? Value
|
|
31
|
-
* : Value extends {type: Check} // String (type) test.
|
|
32
|
-
* ? Value
|
|
33
|
-
* : Value extends Check // Partial test.
|
|
34
|
-
* ? Value
|
|
35
|
-
* : Check extends Function // Function test.
|
|
36
|
-
* ? Predicate<Check, Value> extends Value
|
|
37
|
-
* ? Predicate<Check, Value>
|
|
38
|
-
* : never
|
|
39
|
-
* : never // Some other test?
|
|
40
|
-
* )} MatchesOne
|
|
41
|
-
* Check whether a node matches a primitive check in the type system.
|
|
42
|
-
* @template Value
|
|
43
|
-
* Value; typically unist `Node`.
|
|
44
|
-
* @template Check
|
|
45
|
-
* Value; typically `unist-util-is`-compatible test, but not arrays.
|
|
46
|
-
*/
|
|
47
|
-
/**
|
|
48
|
-
* @typedef {(
|
|
49
|
-
* Check extends ReadonlyArray<any>
|
|
50
|
-
* ? MatchesOne<Value, Check[number]>
|
|
51
|
-
* : MatchesOne<Value, Check>
|
|
52
|
-
* )} Matches
|
|
53
|
-
* Check whether a node matches a check in the type system.
|
|
54
|
-
* @template Value
|
|
55
|
-
* Value; typically unist `Node`.
|
|
56
|
-
* @template Check
|
|
57
|
-
* Value; typically `unist-util-is`-compatible test.
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
|
|
61
|
-
* Number; capped reasonably.
|
|
62
|
-
*/
|
|
63
|
-
/**
|
|
64
|
-
* @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment
|
|
65
|
-
* Increment a number in the type system.
|
|
66
|
-
* @template {Uint} [I=0]
|
|
67
|
-
* Index.
|
|
68
|
-
*/
|
|
69
|
-
/**
|
|
70
|
-
* @typedef {(
|
|
71
|
-
* Node extends UnistParent
|
|
72
|
-
* ? Node extends {children: Array<infer Children>}
|
|
73
|
-
* ? Child extends Children ? Node : never
|
|
74
|
-
* : never
|
|
75
|
-
* : never
|
|
76
|
-
* )} InternalParent
|
|
77
|
-
* Collect nodes that can be parents of `Child`.
|
|
78
|
-
* @template {UnistNode} Node
|
|
79
|
-
* All node types in a tree.
|
|
80
|
-
* @template {UnistNode} Child
|
|
81
|
-
* Node to search for.
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
|
|
85
|
-
* Collect nodes in `Tree` that can be parents of `Child`.
|
|
86
|
-
* @template {UnistNode} Tree
|
|
87
|
-
* All node types in a tree.
|
|
88
|
-
* @template {UnistNode} Child
|
|
89
|
-
* Node to search for.
|
|
90
|
-
*/
|
|
91
|
-
/**
|
|
92
|
-
* @typedef {(
|
|
93
|
-
* Depth extends Max
|
|
94
|
-
* ? never
|
|
95
|
-
* :
|
|
96
|
-
* | InternalParent<Node, Child>
|
|
97
|
-
* | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
|
|
98
|
-
* )} InternalAncestor
|
|
99
|
-
* Collect nodes in `Tree` that can be ancestors of `Child`.
|
|
100
|
-
* @template {UnistNode} Node
|
|
101
|
-
* All node types in a tree.
|
|
102
|
-
* @template {UnistNode} Child
|
|
103
|
-
* Node to search for.
|
|
104
|
-
* @template {Uint} [Max=10]
|
|
105
|
-
* Max; searches up to this depth.
|
|
106
|
-
* @template {Uint} [Depth=0]
|
|
107
|
-
* Current depth.
|
|
108
|
-
*/
|
|
109
|
-
/**
|
|
110
|
-
* @typedef {(
|
|
111
|
-
* Tree extends UnistParent
|
|
112
|
-
* ? Depth extends Max
|
|
113
|
-
* ? Tree
|
|
114
|
-
* : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
|
|
115
|
-
* : Tree
|
|
116
|
-
* )} InclusiveDescendant
|
|
117
|
-
* Collect all (inclusive) descendants of `Tree`.
|
|
118
|
-
*
|
|
119
|
-
* > 👉 **Note**: for performance reasons, this seems to be the fastest way to
|
|
120
|
-
* > recurse without actually running into an infinite loop, which the
|
|
121
|
-
* > previous version did.
|
|
122
|
-
* >
|
|
123
|
-
* > Practically, a max of `2` is typically enough assuming a `Root` is
|
|
124
|
-
* > passed, but it doesn’t improve performance.
|
|
125
|
-
* > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
|
|
126
|
-
* > Using up to `10` doesn’t hurt or help either.
|
|
127
|
-
* @template {UnistNode} Tree
|
|
128
|
-
* Tree type.
|
|
129
|
-
* @template {Uint} [Max=10]
|
|
130
|
-
* Max; searches up to this depth.
|
|
131
|
-
* @template {Uint} [Depth=0]
|
|
132
|
-
* Current depth.
|
|
133
|
-
*/
|
|
134
|
-
/**
|
|
135
|
-
* @callback Visitor
|
|
136
|
-
* Handle a node (matching `test`, if given).
|
|
137
|
-
*
|
|
138
|
-
* Visitors are free to transform `node`.
|
|
139
|
-
* They can also transform `parent`.
|
|
140
|
-
*
|
|
141
|
-
* Replacing `node` itself, if `SKIP` is not returned, still causes its
|
|
142
|
-
* descendants to be walked (which is a bug).
|
|
143
|
-
*
|
|
144
|
-
* When adding or removing previous siblings of `node` (or next siblings, in
|
|
145
|
-
* case of reverse), the `Visitor` should return a new `Index` to specify the
|
|
146
|
-
* sibling to traverse after `node` is traversed.
|
|
147
|
-
* Adding or removing next siblings of `node` (or previous siblings, in case
|
|
148
|
-
* of reverse) is handled as expected without needing to return a new `Index`.
|
|
149
|
-
*
|
|
150
|
-
* Removing the children property of `parent` still results in them being
|
|
151
|
-
* traversed.
|
|
152
|
-
* @param {Visited} node
|
|
153
|
-
* Found node.
|
|
154
|
-
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
155
|
-
* Index of `node` in `parent`.
|
|
156
|
-
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
157
|
-
* Parent of `node`.
|
|
158
|
-
* @returns {VisitorResult}
|
|
159
|
-
* What to do next.
|
|
160
|
-
*
|
|
161
|
-
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
|
|
162
|
-
* An `Action` is treated as a tuple of `[Action]`.
|
|
163
|
-
*
|
|
164
|
-
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
|
|
165
|
-
* When the `Action` is `EXIT`, that action can be returned.
|
|
166
|
-
* When the `Action` is `CONTINUE`, `Index` can be returned.
|
|
167
|
-
* @template {UnistNode} [Visited=UnistNode]
|
|
168
|
-
* Visited node type.
|
|
169
|
-
* @template {UnistParent} [Ancestor=UnistParent]
|
|
170
|
-
* Ancestor type.
|
|
171
|
-
*/
|
|
172
|
-
/**
|
|
173
|
-
* @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
|
|
174
|
-
* Build a typed `Visitor` function from a node and all possible parents.
|
|
175
|
-
*
|
|
176
|
-
* It will infer which values are passed as `node` and which as `parent`.
|
|
177
|
-
* @template {UnistNode} Visited
|
|
178
|
-
* Node type.
|
|
179
|
-
* @template {UnistParent} Ancestor
|
|
180
|
-
* Parent type.
|
|
181
|
-
*/
|
|
182
|
-
/**
|
|
183
|
-
* @typedef {(
|
|
184
|
-
* BuildVisitorFromMatch<
|
|
185
|
-
* Matches<Descendant, Check>,
|
|
186
|
-
* Extract<Descendant, UnistParent>
|
|
187
|
-
* >
|
|
188
|
-
* )} BuildVisitorFromDescendants
|
|
189
|
-
* Build a typed `Visitor` function from a list of descendants and a test.
|
|
190
|
-
*
|
|
191
|
-
* It will infer which values are passed as `node` and which as `parent`.
|
|
192
|
-
* @template {UnistNode} Descendant
|
|
193
|
-
* Node type.
|
|
194
|
-
* @template {Test} Check
|
|
195
|
-
* Test type.
|
|
196
|
-
*/
|
|
197
|
-
/**
|
|
198
|
-
* @typedef {(
|
|
199
|
-
* BuildVisitorFromDescendants<
|
|
200
|
-
* InclusiveDescendant<Tree>,
|
|
201
|
-
* Check
|
|
202
|
-
* >
|
|
203
|
-
* )} BuildVisitor
|
|
204
|
-
* Build a typed `Visitor` function from a tree and a test.
|
|
205
|
-
*
|
|
206
|
-
* It will infer which values are passed as `node` and which as `parent`.
|
|
207
|
-
* @template {UnistNode} [Tree=UnistNode]
|
|
208
|
-
* Node type.
|
|
209
|
-
* @template {Test} [Check=Test]
|
|
210
|
-
* Test type.
|
|
211
|
-
*/
|
|
212
|
-
/**
|
|
213
|
-
* Visit nodes.
|
|
214
|
-
*
|
|
215
|
-
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
216
|
-
* (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
|
|
217
|
-
*
|
|
218
|
-
* You can choose for which nodes `visitor` is called by passing a `test`.
|
|
219
|
-
* For complex tests, you should test yourself in `visitor`, as it will be
|
|
220
|
-
* faster and will have improved type information.
|
|
221
|
-
*
|
|
222
|
-
* Walking the tree is an intensive task.
|
|
223
|
-
* Make use of the return values of the visitor when possible.
|
|
224
|
-
* Instead of walking a tree multiple times, walk it once, use `unist-util-is`
|
|
225
|
-
* to check if a node matches, and then perform different operations.
|
|
226
|
-
*
|
|
227
|
-
* You can change the tree.
|
|
228
|
-
* See `Visitor` for more info.
|
|
229
|
-
*
|
|
230
|
-
* @overload
|
|
231
|
-
* @param {Tree} tree
|
|
232
|
-
* @param {Check} check
|
|
233
|
-
* @param {BuildVisitor<Tree, Check>} visitor
|
|
234
|
-
* @param {boolean | null | undefined} [reverse]
|
|
235
|
-
* @returns {undefined}
|
|
236
|
-
*
|
|
237
|
-
* @overload
|
|
238
|
-
* @param {Tree} tree
|
|
239
|
-
* @param {BuildVisitor<Tree>} visitor
|
|
240
|
-
* @param {boolean | null | undefined} [reverse]
|
|
241
|
-
* @returns {undefined}
|
|
242
|
-
*
|
|
243
|
-
* @param {UnistNode} tree
|
|
244
|
-
* Tree to traverse.
|
|
245
|
-
* @param {Visitor | Test} testOrVisitor
|
|
246
|
-
* `unist-util-is`-compatible test (optional, omit to pass a visitor).
|
|
247
|
-
* @param {Visitor | boolean | null | undefined} [visitorOrReverse]
|
|
248
|
-
* Handle each node (when test is omitted, pass `reverse`).
|
|
249
|
-
* @param {boolean | null | undefined} [maybeReverse=false]
|
|
250
|
-
* Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
|
|
251
|
-
* @returns {undefined}
|
|
252
|
-
* Nothing.
|
|
253
|
-
*
|
|
254
|
-
* @template {UnistNode} Tree
|
|
255
|
-
* Node type.
|
|
256
|
-
* @template {Test} Check
|
|
257
|
-
* `unist-util-is`-compatible test.
|
|
258
|
-
*/
|
|
259
|
-
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
260
|
-
/** @type {boolean | null | undefined} */
|
|
261
|
-
let reverse;
|
|
262
|
-
/** @type {Test} */
|
|
263
|
-
let test;
|
|
264
|
-
/** @type {Visitor} */
|
|
265
|
-
let visitor;
|
|
266
|
-
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
267
|
-
test = void 0;
|
|
268
|
-
visitor = testOrVisitor;
|
|
269
|
-
reverse = visitorOrReverse;
|
|
270
|
-
} else {
|
|
271
|
-
test = testOrVisitor;
|
|
272
|
-
visitor = visitorOrReverse;
|
|
273
|
-
reverse = maybeReverse;
|
|
274
|
-
}
|
|
275
|
-
visitParents(tree, test, overload, reverse);
|
|
276
|
-
/**
|
|
277
|
-
* @param {UnistNode} node
|
|
278
|
-
* @param {Array<UnistParent>} parents
|
|
279
|
-
*/
|
|
280
|
-
function overload(node, parents) {
|
|
281
|
-
const parent = parents[parents.length - 1];
|
|
282
|
-
const index = parent ? parent.children.indexOf(node) : void 0;
|
|
283
|
-
return visitor(node, index, parent);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
export { SKIP$1 as SKIP, visit };
|
|
287
|
-
|
|
288
|
-
//# sourceMappingURL=index.mjs.map
|
package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.js"],"sourcesContent":["/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {VisitorResult} from 'unist-util-visit-parents'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<any>\n * ? MatchesOne<Value, Check[number]>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n * `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n * Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n /** @type {boolean | null | undefined} */\n let reverse\n /** @type {Test} */\n let test\n /** @type {Visitor} */\n let visitor\n\n if (\n typeof testOrVisitor === 'function' &&\n typeof visitorOrReverse !== 'function'\n ) {\n test = undefined\n visitor = testOrVisitor\n reverse = visitorOrReverse\n } else {\n // @ts-expect-error: assume the overload with test was given.\n test = testOrVisitor\n // @ts-expect-error: assume the overload with test was given.\n visitor = visitorOrReverse\n reverse = maybeReverse\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {UnistNode} node\n * @param {Array<UnistParent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n const index = parent ? parent.children.indexOf(node) : undefined\n return visitor(node, index, parent)\n }\n}\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqRA,SAAgB,MAAM,MAAM,eAAe,kBAAkB,cAAc;;CAEzE,IAAI;;CAEJ,IAAI;;CAEJ,IAAI;CAEJ,IACE,OAAO,kBAAkB,cACzB,OAAO,qBAAqB,YAC5B;EACA,OAAO,KAAA;EACP,UAAU;EACV,UAAU;CACZ,OAAO;EAEL,OAAO;EAEP,UAAU;EACV,UAAU;CACZ;CAEA,aAAa,MAAM,MAAM,UAAU,OAAO;;;;;CAM1C,SAAS,SAAS,MAAM,SAAS;EAC/B,MAAM,SAAS,QAAQ,QAAQ,SAAS;EACxC,MAAM,QAAQ,SAAS,OAAO,SAAS,QAAQ,IAAI,IAAI,KAAA;EACvD,OAAO,QAAQ,MAAM,OAAO,MAAM;CACpC;AACF"}
|