react-component-name 0.0.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.md ADDED
@@ -0,0 +1,46 @@
1
+ # react-component-name
2
+
3
+ Get a React component name from its rendered element
4
+
5
+ _These examples use **Testing Library** but you can also get the component name from any rendered element with `getComponentNameFromElement` or from its `Fiber` node with `getComponentNameFromFiber`_
6
+
7
+ ```javascript
8
+ import {
9
+ getComponentNameFromRender,
10
+ getComponentNameFromContainerElement,
11
+ getComponentNameFromElement
12
+ } from 'react-component-name'
13
+
14
+ import {
15
+ render
16
+ } from '@testing-library/react'
17
+
18
+ function Component () {
19
+ return <div />
20
+ }
21
+
22
+ expect(getComponentNameFromRender(render(
23
+ <Component />
24
+ )))
25
+ .toBe('div')
26
+
27
+ const {
28
+ container
29
+ } = render(
30
+ <Component />
31
+ )
32
+
33
+ expect(getComponentNameFromContainerElement(container))
34
+ .toBe('div')
35
+
36
+ const {
37
+ container: {
38
+ firstElementChild: element
39
+ }
40
+ } = render(
41
+ <Component />
42
+ )
43
+
44
+ expect(getComponentNameFromElement(element))
45
+ .toBe('div')
46
+ ```
package/index.d.mts ADDED
@@ -0,0 +1,109 @@
1
+ import type React from 'react'
2
+
3
+ declare global {
4
+ namespace ReactComponentNameTypes {
5
+ /**
6
+ * React constants
7
+ */
8
+ export type RootWorkTag = 0 | 1
9
+
10
+ /**
11
+ * React constants
12
+ */
13
+ export type WorkTag = (
14
+ 0 |
15
+ 1 |
16
+ 2 |
17
+ 3 |
18
+ 4 |
19
+ 5 |
20
+ 6 |
21
+ 7 |
22
+ 8 |
23
+ 9 |
24
+ 10 |
25
+ 11 |
26
+ 12 |
27
+ 13 |
28
+ 14 |
29
+ 15 |
30
+ 16 |
31
+ 17 |
32
+ 18 |
33
+ 19 |
34
+ 20 |
35
+ 21 |
36
+ 22 |
37
+ 23 |
38
+ 24 |
39
+ 25 |
40
+ 26 |
41
+ 27 |
42
+ 28 |
43
+ 29 |
44
+ 30 |
45
+ 31
46
+ )
47
+
48
+ /**
49
+ * https://github.com/bendtherules/react-fiber-traverse
50
+ */
51
+ export type FiberNode =
52
+ | FiberNodeForClassComponent
53
+ | FiberNodeForFunctionComponent
54
+ | FiberNodeForInstrinsicElement
55
+ | FiberNodeForTextNode
56
+
57
+ interface FiberType {
58
+ child: FiberNode | null
59
+ sibling: FiberNode | null
60
+
61
+ tag: WorkTag
62
+ return?: FiberRootNode | FiberNode
63
+ }
64
+
65
+ export interface FiberRootNode extends FiberType {
66
+ child: FiberNode
67
+
68
+ elementType: React.FunctionComponent
69
+ type: React.FunctionComponent
70
+
71
+ stateNode: {
72
+ current: FiberRootNode
73
+ }
74
+ return?: FiberRootNode
75
+ }
76
+
77
+ export interface FiberNodeForFunctionComponent extends FiberType {
78
+ elementType: React.FunctionComponent
79
+ type: React.FunctionComponent
80
+
81
+ stateNode: null
82
+ }
83
+
84
+ export interface FiberNodeForClassComponent extends FiberType {
85
+ elementType: React.ComponentClass
86
+ type: React.ComponentClass
87
+
88
+ stateNode: React.Component
89
+ }
90
+
91
+ export interface FiberNodeForInstrinsicElement extends FiberType {
92
+ elementType: keyof React.JSX.IntrinsicElements
93
+ type: keyof React.JSX.IntrinsicElements
94
+
95
+ stateNode: HTMLElement
96
+ }
97
+
98
+ export interface FiberNodeForTextNode extends FiberType {
99
+ child: null
100
+
101
+ elementType: null
102
+ type: null
103
+
104
+ stateNode: Text
105
+ }
106
+ }
107
+ }
108
+
109
+ export {}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "react-component-name",
3
+ "version": "0.0.0",
4
+ "description": "Get a React component name from Fiber",
5
+ "keywords": [
6
+ "react",
7
+ "component",
8
+ "name"
9
+ ],
10
+ "main": "./src/index.mjs",
11
+ "type": "module",
12
+ "types": "./index.d.mts",
13
+ "author": {
14
+ "name": "Jonathan Perry for Modern Poacher Limited",
15
+ "email": "jonathanperry@modernpoacher.com",
16
+ "url": "https://modernpoacher.com"
17
+ },
18
+ "license": "ISC",
19
+ "engines": {
20
+ "node": ">=18.12.0 <=21.7.3 || >=22.2.0"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git://github.com/modernpoacher/react-component-name.git"
25
+ },
26
+ "scripts": {
27
+ "lint": "eslint",
28
+ "lint:fix": "npm run lint -- --fix",
29
+ "test": "NODE_ENV=test jest"
30
+ },
31
+ "dependencies": {
32
+ "debug": "^4.4.0"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/core": "^7.26.10",
36
+ "@babel/eslint-parser": "^7.26.10",
37
+ "@babel/preset-env": "^7.26.9",
38
+ "@babel/preset-react": "^7.26.3",
39
+ "@sequencemedia/eslint-config-standard": "^0.2.43",
40
+ "@sequencemedia/eslint-config-typescript": "^0.1.62",
41
+ "@testing-library/jest-dom": "^6.6.3",
42
+ "@testing-library/react": "^16.2.0",
43
+ "@types/debug": "^4.1.12",
44
+ "@types/jest": "^29.5.14",
45
+ "@types/prop-types": "^15.7.14",
46
+ "@types/react": "^19.0.11",
47
+ "@types/testing-library__react": "^10.0.1",
48
+ "@typescript-eslint/parser": "^8.26.1",
49
+ "core-js": "^3.41.0",
50
+ "eslint": "^9.22.0",
51
+ "eslint-plugin-react": "^7.37.4",
52
+ "globals": "^16.0.0",
53
+ "jest": "^29.7.0",
54
+ "jest-environment-jsdom": "^29.7.0",
55
+ "react": "^19.0.0"
56
+ },
57
+ "imports": {
58
+ "#react-component-name": "./src/index.mjs"
59
+ },
60
+ "exports": {
61
+ ".": "./src/index.mjs"
62
+ }
63
+ }
@@ -0,0 +1,40 @@
1
+ import type {
2
+ RenderResult as RenderType
3
+ } from '@testing-library/react'
4
+
5
+ type FiberNode = ReactComponentNameTypes.FiberNode
6
+
7
+ export function getElementFromRender (render: RenderType): Element | null
8
+
9
+ export function getContainerElementFromRender (render: RenderType): Element
10
+
11
+ declare function getElementFromContainerElement (containerElement: Element): Element | null
12
+
13
+ export function isReactFiberKey (key: PropertyKey): boolean
14
+
15
+ export function isReactContainerFiberKey (key: PropertyKey) : boolean
16
+
17
+ export function getReactFiberKey (element: Element): string | undefined
18
+
19
+ export function getReactContainerFiberKey (containerElement: Element) : string | undefined
20
+
21
+ export function getFiberFromRender (render: RenderType): FiberNode | null
22
+
23
+ export function getFiberFromElement (element: Element) : FiberNode | null
24
+
25
+ export function getContainerFiberFromContainerElement (containerElement: Element): FiberNode | null
26
+
27
+ interface OuterType { displayName?: string | null }
28
+ interface InnerType { displayName?: string | null; name?: string | null }
29
+
30
+ declare function getComponentNameFromForwardRef (outerType: OuterType, innerType: InnerType): string | null
31
+
32
+ export function getComponentNameFromFiberType (type: unknown): string | null
33
+
34
+ export function getComponentNameFromFiber (fiberNode: FiberNode): string | null
35
+
36
+ export function getComponentNameFromRender (render: RenderType | null): string | null
37
+
38
+ export function getComponentNameFromElement (elemen: Element | null): string | null
39
+
40
+ export function getComponentNameFromContainerElement (containerElement: Element | null): string | null
package/src/index.mjs ADDED
@@ -0,0 +1,426 @@
1
+ // @ts-nocheck
2
+
3
+ /**
4
+ * @typedef {import('@testing-library/react').RenderResult} RenderType
5
+ * @typedef {ReactComponentNameTypes.FiberNode} FiberNode
6
+ */
7
+
8
+ import debug from 'debug'
9
+
10
+ import {
11
+ REACT_PORTAL_TYPE,
12
+ REACT_FRAGMENT_TYPE,
13
+ REACT_STRICT_MODE_TYPE,
14
+ REACT_PROFILER_TYPE,
15
+ REACT_CONSUMER_TYPE,
16
+ REACT_CONTEXT_TYPE,
17
+ REACT_FORWARD_REF_TYPE,
18
+ REACT_SUSPENSE_TYPE,
19
+ REACT_SUSPENSE_LIST_TYPE,
20
+ REACT_MEMO_TYPE,
21
+ REACT_LAZY_TYPE,
22
+ REACT_CLIENT_REFERENCE
23
+ } from './symbols.mjs'
24
+
25
+ import {
26
+ FUNCTION_COMPONENT,
27
+ CLASS_COMPONENT,
28
+ HOST_ROOT,
29
+ HOST_PORTAL,
30
+ HOST_COMPONENT,
31
+ HOST_TEXT,
32
+ FRAGMENT,
33
+ MODE,
34
+ CONTEXT_CONSUMER,
35
+ CONTEXT_PROVIDER,
36
+ FORWARD_REF,
37
+ PROFILER,
38
+ SUSPENSE_COMPONENT,
39
+ MEMO_COMPONENT,
40
+ SIMPLE_MEMO_COMPONENT,
41
+ LAZY_COMPONENT,
42
+ DEYDRATED_FRAGMENT,
43
+ SUSPENSE_LIST_COMPONENT,
44
+ SCOPE_COMPONENT,
45
+ OFFSCREEN_COMPONENT,
46
+ CACHE_COMPONENT,
47
+ TRACING_MARKER_COMPONENT,
48
+ HOST_HOISTABLE,
49
+ HOST_SINGLETON,
50
+ THROW
51
+ } from './work-tags.mjs'
52
+
53
+ const log = debug('react-component-name')
54
+
55
+ /**
56
+ * @param {RenderType} render
57
+ * @returns {Element | null}
58
+ */
59
+ export function getElementFromRender (render) {
60
+ return (
61
+ getElementFromContainerElement(
62
+ getContainerElementFromRender(render)
63
+ )
64
+ )
65
+ }
66
+
67
+ /**
68
+ * @param {RenderType} render
69
+ * @returns {Element}
70
+ */
71
+ export function getContainerElementFromRender (render) {
72
+ const {
73
+ container: containerElement
74
+ } = render
75
+
76
+ return containerElement
77
+ }
78
+
79
+ /**
80
+ * @param {Element} containerElement
81
+ * @returns {Element | null}
82
+ */
83
+ function getElementFromContainerElement (containerElement) {
84
+ const {
85
+ firstElementChild: element = null
86
+ } = containerElement
87
+
88
+ return element
89
+ }
90
+
91
+ /**
92
+ * @param {PropertyKey} key
93
+ * @returns {boolean}
94
+ */
95
+ export function isReactFiberKey (key) {
96
+ return String(key).startsWith('__reactFiber$')
97
+ }
98
+
99
+ /**
100
+ * @param {PropertyKey} key
101
+ * @returns {boolean}
102
+ */
103
+ export function isReactContainerFiberKey (key) {
104
+ return String(key).startsWith('__reactContainer$')
105
+ }
106
+
107
+ /**
108
+ * @param {Element} element
109
+ * @returns {string | undefined}
110
+ */
111
+ export function getReactFiberKey (element) {
112
+ return (
113
+ Object.keys(element)
114
+ .find(isReactFiberKey)
115
+ )
116
+ }
117
+
118
+ /**
119
+ * @param {Element} containerElement
120
+ * @returns {string | undefined}
121
+ */
122
+ export function getReactContainerFiberKey (containerElement) {
123
+ return (
124
+ Object.keys(containerElement)
125
+ .find(isReactContainerFiberKey)
126
+ )
127
+ }
128
+
129
+ /**
130
+ * @param {RenderType} render
131
+ * @returns {FiberNode | null}
132
+ */
133
+ export function getFiberFromRender (render) {
134
+ const element = getElementFromRender(render)
135
+
136
+ if (element) {
137
+ return (
138
+ getFiberFromElement(element)
139
+ )
140
+ }
141
+
142
+ return null
143
+ }
144
+
145
+ /**
146
+ * @param {Element} element
147
+ * @returns {FiberNode | null}
148
+ */
149
+ export function getFiberFromElement (element) {
150
+ const key = getReactFiberKey(element)
151
+
152
+ if (key) {
153
+ const { // @ts-expect-error
154
+ [key]: fiber = null
155
+ } = element
156
+
157
+ return fiber
158
+ }
159
+
160
+ throw new Error('Fiber is not found')
161
+ }
162
+
163
+ /**
164
+ * @param {Element} containerElement
165
+ * @returns {FiberNode | null}
166
+ */
167
+ export function getContainerFiberFromContainerElement (containerElement) {
168
+ const key = getReactContainerFiberKey(containerElement)
169
+
170
+ if (key) {
171
+ const { // @ts-expect-error
172
+ [key]: fiber = null
173
+ } = containerElement
174
+
175
+ return fiber
176
+ }
177
+
178
+ throw new Error('Fiber is not found')
179
+ }
180
+
181
+ /**
182
+ * @param {{displayName?: string | null}} outerType
183
+ * @param {{displayName?: string | null, name?: string | null}} innerType
184
+ * @returns {string | null}
185
+ */
186
+ function getComponentNameFromForwardRef (outerType, innerType) {
187
+ const outerName = outerType.displayName || null
188
+
189
+ if (outerName) return outerName
190
+
191
+ const innerName = innerType.displayName || innerType.name || null
192
+
193
+ if (innerName) return `ForwardRef(${innerName})`
194
+
195
+ return 'ForwardRef'
196
+ }
197
+
198
+ /**
199
+ * @param {*} type
200
+ * @returns {string | null}
201
+ */
202
+ export function getComponentNameFromFiberType (type) {
203
+ if (type == null) return null
204
+
205
+ if (typeof type === 'function') {
206
+ return (
207
+ type.$$typeof === REACT_CLIENT_REFERENCE
208
+ ? null
209
+ : type.displayName || type.name || null
210
+ )
211
+ }
212
+
213
+ if (typeof type === 'string') return type
214
+
215
+ switch (type) {
216
+ case REACT_FRAGMENT_TYPE:
217
+ return 'Fragment'
218
+
219
+ case REACT_PORTAL_TYPE:
220
+ return 'Portal'
221
+
222
+ case REACT_PROFILER_TYPE:
223
+ return 'Profiler'
224
+
225
+ case REACT_STRICT_MODE_TYPE:
226
+ return 'StrictMode'
227
+
228
+ case REACT_SUSPENSE_TYPE:
229
+ return 'Suspense'
230
+
231
+ case REACT_SUSPENSE_LIST_TYPE:
232
+ return 'SuspenseList'
233
+ }
234
+
235
+ if (typeof type === 'object') {
236
+ switch (type.$$typeof) {
237
+ case REACT_CONTEXT_TYPE:
238
+ return (type.displayName || 'Context') + '.Provider'
239
+
240
+ case REACT_CONSUMER_TYPE:
241
+ return (type._context.displayName || 'Context') + '.Consumer'
242
+
243
+ case REACT_FORWARD_REF_TYPE:
244
+ return getComponentNameFromForwardRef(type, type.render)
245
+
246
+ case REACT_MEMO_TYPE:
247
+ return (
248
+ type.displayName || getComponentNameFromFiberType(type.type) || 'Memo'
249
+ )
250
+
251
+ case REACT_LAZY_TYPE:
252
+ {
253
+ const {
254
+ _payload: payload,
255
+ _init: init
256
+ } = type
257
+
258
+ try {
259
+ return getComponentNameFromFiberType(init(payload))
260
+ } catch (e) {
261
+ log(`Lazy Component error. Error was "${e}"`, e)
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ return null
268
+ }
269
+
270
+ /**
271
+ * @param {FiberNode} fiberNode
272
+ * @returns {string | null}
273
+ */
274
+ export function getComponentNameFromFiber (fiberNode) {
275
+ const {
276
+ tag,
277
+ type
278
+ } = fiberNode
279
+
280
+ switch (tag) {
281
+ case CACHE_COMPONENT:
282
+ return 'Cache'
283
+
284
+ case CONTEXT_CONSUMER:
285
+ return (type._context.displayName || 'Context') + '.Consumer'
286
+
287
+ case CONTEXT_PROVIDER:
288
+ return (type.displayName || 'Context') + '.Provider'
289
+
290
+ case DEYDRATED_FRAGMENT:
291
+ return 'DehydratedFragment'
292
+
293
+ case FORWARD_REF:
294
+ return getComponentNameFromForwardRef(type, type.render, 'ForwardRef')
295
+
296
+ case FRAGMENT:
297
+ return 'Fragment'
298
+
299
+ case HOST_HOISTABLE:
300
+ case HOST_SINGLETON:
301
+ case HOST_COMPONENT:
302
+ return type
303
+
304
+ case HOST_PORTAL:
305
+ return 'Portal'
306
+
307
+ case HOST_ROOT:
308
+ return 'Root'
309
+
310
+ case HOST_TEXT:
311
+ return 'Text'
312
+
313
+ case LAZY_COMPONENT:
314
+ return getComponentNameFromFiberType(type)
315
+
316
+ case MODE:
317
+ return (
318
+ type === REACT_STRICT_MODE_TYPE
319
+ ? 'StrictMode'
320
+ : 'Mode'
321
+ )
322
+ case OFFSCREEN_COMPONENT:
323
+ return 'Offscreen'
324
+
325
+ case PROFILER:
326
+ return 'Profiler'
327
+
328
+ case SCOPE_COMPONENT:
329
+ return 'Scope'
330
+
331
+ case SUSPENSE_COMPONENT:
332
+ return 'Suspense'
333
+
334
+ case SUSPENSE_LIST_COMPONENT:
335
+ return 'SuspenseList'
336
+
337
+ case TRACING_MARKER_COMPONENT:
338
+ return 'TracingMarker'
339
+
340
+ case CLASS_COMPONENT:
341
+ case FUNCTION_COMPONENT:
342
+ case MEMO_COMPONENT:
343
+ case SIMPLE_MEMO_COMPONENT:
344
+ if (typeof type === 'function') return type.displayName || type.name || null
345
+ if (typeof type === 'string') return type
346
+ return null
347
+
348
+ case THROW:
349
+ {
350
+ const info = fiberNode._debugInfo || null
351
+
352
+ if (info != null) {
353
+ let i = info.length - 1
354
+
355
+ for (i; i >= 0; i--) {
356
+ const t = info[i]
357
+ const n = t.name
358
+
359
+ if (typeof n === 'string') return n
360
+ }
361
+ }
362
+
363
+ if (fiberNode.return !== null) return getComponentNameFromFiber(fiberNode.return)
364
+ }
365
+ }
366
+
367
+ return null
368
+ }
369
+
370
+ /**
371
+ * @param {RenderType | null} render
372
+ * @returns {string | null}
373
+ */
374
+ export function getComponentNameFromRender (render) {
375
+ if (render) {
376
+ const fiberNode = getFiberFromRender(render)
377
+
378
+ if (fiberNode) {
379
+ return (
380
+ getComponentNameFromFiber(fiberNode)
381
+ )
382
+ }
383
+ }
384
+
385
+ return null
386
+ }
387
+
388
+ /**
389
+ * @param {Element | null} element
390
+ * @returns {string | null}
391
+ */
392
+ export function getComponentNameFromElement (element) {
393
+ if (element instanceof HTMLElement) {
394
+ const fiberNode = getFiberFromElement(element)
395
+
396
+ if (fiberNode) {
397
+ return (
398
+ getComponentNameFromFiber(fiberNode)
399
+ )
400
+ }
401
+ }
402
+
403
+ return null
404
+ }
405
+
406
+ /**
407
+ * @param {Element | null} containerElement
408
+ * @returns {string | null}
409
+ */
410
+ export function getComponentNameFromContainerElement (containerElement) {
411
+ if (containerElement instanceof HTMLElement) {
412
+ const element = getElementFromContainerElement(containerElement)
413
+
414
+ if (element instanceof HTMLElement) {
415
+ const fiberNode = getFiberFromElement(element)
416
+
417
+ if (fiberNode) {
418
+ return (
419
+ getComponentNameFromFiber(fiberNode)
420
+ )
421
+ }
422
+ }
423
+ }
424
+
425
+ return null
426
+ }
@@ -0,0 +1,4 @@
1
+ type RootWorkTag = ReactComponentNameTypes.RootWorkTag
2
+
3
+ export declare const LEGACY_ROOT: RootWorkTag
4
+ export declare const CONCURRENT_ROOT: RootWorkTag
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of https://github.com/facebook/react
6
+ */
7
+
8
+ export const LEGACY_ROOT = 0
9
+ export const CONCURRENT_ROOT = 1
@@ -0,0 +1,12 @@
1
+ export const REACT_PORTAL_TYPE = Symbol.for('react.portal')
2
+ export const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment')
3
+ export const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode')
4
+ export const REACT_PROFILER_TYPE = Symbol.for('react.profiler')
5
+ export const REACT_CONSUMER_TYPE = Symbol.for('react.consumer')
6
+ export const REACT_CONTEXT_TYPE = Symbol.for('react.context')
7
+ export const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref')
8
+ export const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense')
9
+ export const REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list')
10
+ export const REACT_MEMO_TYPE = Symbol.for('react.memo')
11
+ export const REACT_LAZY_TYPE = Symbol.for('react.lazy')
12
+ export const REACT_CLIENT_REFERENCE = Symbol.for('react.client.reference')
@@ -0,0 +1,32 @@
1
+ type WorkTag = ReactComponentNameTypes.WorkTag
2
+
3
+ export declare const FUNCTION_COMPONENT: WorkTag
4
+ export declare const CLASS_COMPONENT: WorkTag
5
+ export declare const HOST_ROOT: WorkTag
6
+ export declare const HOST_PORTAL: WorkTag
7
+ export declare const HOST_COMPONENT: WorkTag
8
+ export declare const HOST_TEXT: WorkTag
9
+ export declare const FRAGMENT: WorkTag
10
+ export declare const MODE: WorkTag
11
+ export declare const CONTEXT_CONSUMER: WorkTag
12
+ export declare const CONTEXT_PROVIDER: WorkTag
13
+ export declare const FORWARD_REF: WorkTag
14
+ export declare const PROFILER: WorkTag
15
+ export declare const SUSPENSE_COMPONENT: WorkTag
16
+ export declare const MEMO_COMPONENT: WorkTag
17
+ export declare const SIMPLE_MEMO_COMPONENT: WorkTag
18
+ export declare const LAZY_COMPONENT: WorkTag
19
+ export declare const INCOMPLETE_CLASS_COMPONENT: WorkTag
20
+ export declare const DEYDRATED_FRAGMENT: WorkTag
21
+ export declare const SUSPENSE_LIST_COMPONENT: WorkTag
22
+ export declare const SCOPE_COMPONENT: WorkTag
23
+ export declare const OFFSCREEN_COMPONENT: WorkTag
24
+ export declare const LEGACY_HIDDEN_COMPONENT: WorkTag
25
+ export declare const CACHE_COMPONENT: WorkTag
26
+ export declare const TRACING_MARKER_COMPONENT: WorkTag
27
+ export declare const HOST_HOISTABLE: WorkTag
28
+ export declare const HOST_SINGLETON: WorkTag
29
+ export declare const INCOMPLETE_FUNCTION_COMPONENT: WorkTag
30
+ export declare const THROW: WorkTag
31
+ export declare const VIEW_TRANSITION_COMPONENT: WorkTag
32
+ export declare const ACTIVITY_COMPONENT: WorkTag
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of https://github.com/facebook/react
6
+ */
7
+
8
+ export const FUNCTION_COMPONENT = 0
9
+ export const CLASS_COMPONENT = 1
10
+ export const HOST_ROOT = 3
11
+ export const HOST_PORTAL = 4
12
+ export const HOST_COMPONENT = 5
13
+ export const HOST_TEXT = 6
14
+ export const FRAGMENT = 7
15
+ export const MODE = 8
16
+ export const CONTEXT_CONSUMER = 9
17
+ export const CONTEXT_PROVIDER = 10
18
+ export const FORWARD_REF = 11
19
+ export const PROFILER = 12
20
+ export const SUSPENSE_COMPONENT = 13
21
+ export const MEMO_COMPONENT = 14
22
+ export const SIMPLE_MEMO_COMPONENT = 15
23
+ export const LAZY_COMPONENT = 16
24
+ export const INCOMPLETE_CLASS_COMPONENT = 17
25
+ export const DEYDRATED_FRAGMENT = 18
26
+ export const SUSPENSE_LIST_COMPONENT = 19
27
+ export const SCOPE_COMPONENT = 21
28
+ export const OFFSCREEN_COMPONENT = 22
29
+ export const LEGACY_HIDDEN_COMPONENT = 23
30
+ export const CACHE_COMPONENT = 24
31
+ export const TRACING_MARKER_COMPONENT = 25
32
+ export const HOST_HOISTABLE = 26
33
+ export const HOST_SINGLETON = 27
34
+ export const INCOMPLETE_FUNCTION_COMPONENT = 28
35
+ export const THROW = 29
36
+ export const VIEW_TRANSITION_COMPONENT = 30
37
+ export const ACTIVITY_COMPONENT = 31
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "NodeNext",
4
+ "target": "ESNext",
5
+ "allowJs": true,
6
+ "checkJs": true,
7
+ "noEmit": true,
8
+ "strict": true,
9
+ "jsx": "react"
10
+ },
11
+ "include": [
12
+ "."
13
+ ]
14
+ }