@contember/react-multipass-rendering 2.0.0-alpha.4 → 2.0.0-alpha.40

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.
Files changed (91) hide show
  1. package/api-extractor.json +3 -0
  2. package/dist/development/index.cjs +4 -4
  3. package/dist/development/index.js +4 -4
  4. package/dist/development/{ChildrenAnalyzer.cjs → src/ChildrenAnalyzer.cjs} +5 -8
  5. package/dist/development/src/ChildrenAnalyzer.cjs.map +1 -0
  6. package/dist/development/{ChildrenAnalyzer.js → src/ChildrenAnalyzer.js} +5 -8
  7. package/dist/development/src/ChildrenAnalyzer.js.map +1 -0
  8. package/dist/development/{ChildrenAnalyzerError.cjs → src/ChildrenAnalyzerError.cjs} +2 -5
  9. package/dist/development/src/ChildrenAnalyzerError.cjs.map +1 -0
  10. package/dist/development/{ChildrenAnalyzerError.js → src/ChildrenAnalyzerError.js} +1 -4
  11. package/dist/development/src/ChildrenAnalyzerError.js.map +1 -0
  12. package/dist/development/src/helpers/getErrorMessage.cjs.map +1 -0
  13. package/dist/development/src/helpers/getErrorMessage.js.map +1 -0
  14. package/dist/development/src/helpers/wrapError.cjs.map +1 -0
  15. package/dist/development/{helpers → src/helpers}/wrapError.js +2 -2
  16. package/dist/development/src/helpers/wrapError.js.map +1 -0
  17. package/dist/{production → development/src}/nodeSpecs/BranchNode.cjs +5 -8
  18. package/dist/development/src/nodeSpecs/BranchNode.cjs.map +1 -0
  19. package/dist/{production → development/src}/nodeSpecs/BranchNode.js +4 -7
  20. package/dist/development/src/nodeSpecs/BranchNode.js.map +1 -0
  21. package/dist/{production → development/src}/nodeSpecs/Leaf.cjs +2 -5
  22. package/dist/development/src/nodeSpecs/Leaf.cjs.map +1 -0
  23. package/dist/development/{nodeSpecs → src/nodeSpecs}/Leaf.js +1 -4
  24. package/dist/development/src/nodeSpecs/Leaf.js.map +1 -0
  25. package/dist/production/index.cjs +4 -4
  26. package/dist/production/index.js +4 -4
  27. package/dist/production/{ChildrenAnalyzer.cjs → src/ChildrenAnalyzer.cjs} +5 -8
  28. package/dist/production/src/ChildrenAnalyzer.cjs.map +1 -0
  29. package/dist/production/{ChildrenAnalyzer.js → src/ChildrenAnalyzer.js} +5 -8
  30. package/dist/production/src/ChildrenAnalyzer.js.map +1 -0
  31. package/dist/production/{ChildrenAnalyzerError.cjs → src/ChildrenAnalyzerError.cjs} +2 -5
  32. package/dist/production/src/ChildrenAnalyzerError.cjs.map +1 -0
  33. package/dist/production/{ChildrenAnalyzerError.js → src/ChildrenAnalyzerError.js} +1 -4
  34. package/dist/production/src/ChildrenAnalyzerError.js.map +1 -0
  35. package/dist/production/src/helpers/getErrorMessage.cjs.map +1 -0
  36. package/dist/production/src/helpers/getErrorMessage.js.map +1 -0
  37. package/dist/production/src/helpers/wrapError.cjs.map +1 -0
  38. package/dist/production/{helpers → src/helpers}/wrapError.js +2 -2
  39. package/dist/production/src/helpers/wrapError.js.map +1 -0
  40. package/dist/{development → production/src}/nodeSpecs/BranchNode.cjs +5 -8
  41. package/dist/production/src/nodeSpecs/BranchNode.cjs.map +1 -0
  42. package/dist/{development → production/src}/nodeSpecs/BranchNode.js +4 -7
  43. package/dist/production/src/nodeSpecs/BranchNode.js.map +1 -0
  44. package/dist/{development → production/src}/nodeSpecs/Leaf.cjs +2 -5
  45. package/dist/production/src/nodeSpecs/Leaf.cjs.map +1 -0
  46. package/dist/production/{nodeSpecs → src/nodeSpecs}/Leaf.js +1 -4
  47. package/dist/production/src/nodeSpecs/Leaf.js.map +1 -0
  48. package/dist/types/helpers/getErrorMessage.d.ts.map +1 -1
  49. package/dist/types/nodeSpecs/BranchNode.d.ts.map +1 -1
  50. package/dist/types/nodeSpecs/Leaf.d.ts.map +1 -1
  51. package/dist/types/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +7 -14
  53. package/src/ChildrenAnalyzer.ts +7 -7
  54. package/src/ChildrenAnalyzerError.ts +1 -1
  55. package/src/helpers/wrapError.ts +8 -8
  56. package/src/nodeSpecs/BranchNode.ts +6 -6
  57. package/src/nodeSpecs/Leaf.ts +5 -5
  58. package/tests/cases/unit/childrenAnalyzer.spec.tsx +208 -0
  59. package/tests/tsconfig.json +10 -0
  60. package/tsconfig.json +8 -0
  61. package/tsdoc.json +6 -0
  62. package/dist/development/ChildrenAnalyzer.cjs.map +0 -1
  63. package/dist/development/ChildrenAnalyzer.js.map +0 -1
  64. package/dist/development/ChildrenAnalyzerError.cjs.map +0 -1
  65. package/dist/development/ChildrenAnalyzerError.js.map +0 -1
  66. package/dist/development/helpers/getErrorMessage.cjs.map +0 -1
  67. package/dist/development/helpers/getErrorMessage.js.map +0 -1
  68. package/dist/development/helpers/wrapError.cjs.map +0 -1
  69. package/dist/development/helpers/wrapError.js.map +0 -1
  70. package/dist/development/nodeSpecs/BranchNode.cjs.map +0 -1
  71. package/dist/development/nodeSpecs/BranchNode.js.map +0 -1
  72. package/dist/development/nodeSpecs/Leaf.cjs.map +0 -1
  73. package/dist/development/nodeSpecs/Leaf.js.map +0 -1
  74. package/dist/production/ChildrenAnalyzer.cjs.map +0 -1
  75. package/dist/production/ChildrenAnalyzer.js.map +0 -1
  76. package/dist/production/ChildrenAnalyzerError.cjs.map +0 -1
  77. package/dist/production/ChildrenAnalyzerError.js.map +0 -1
  78. package/dist/production/helpers/getErrorMessage.cjs.map +0 -1
  79. package/dist/production/helpers/getErrorMessage.js.map +0 -1
  80. package/dist/production/helpers/wrapError.cjs.map +0 -1
  81. package/dist/production/helpers/wrapError.js.map +0 -1
  82. package/dist/production/nodeSpecs/BranchNode.cjs.map +0 -1
  83. package/dist/production/nodeSpecs/BranchNode.js.map +0 -1
  84. package/dist/production/nodeSpecs/Leaf.cjs.map +0 -1
  85. package/dist/production/nodeSpecs/Leaf.js.map +0 -1
  86. /package/dist/development/{helpers → src/helpers}/getErrorMessage.cjs +0 -0
  87. /package/dist/development/{helpers → src/helpers}/getErrorMessage.js +0 -0
  88. /package/dist/development/{helpers → src/helpers}/wrapError.cjs +0 -0
  89. /package/dist/production/{helpers → src/helpers}/getErrorMessage.cjs +0 -0
  90. /package/dist/production/{helpers → src/helpers}/getErrorMessage.js +0 -0
  91. /package/dist/production/{helpers → src/helpers}/wrapError.cjs +0 -0
@@ -0,0 +1,208 @@
1
+ import { expect, it, describe } from 'bun:test'
2
+ import type { FunctionComponent, ReactElement, ReactNode } from 'react'
3
+ import * as React from 'react'
4
+ import { BranchNode, ChildrenAnalyzer, Leaf, RawNodeRepresentation } from '../../../src'
5
+
6
+ interface FooComponentProps {
7
+ foo: string
8
+ baz: number
9
+ }
10
+ interface BarComponentProps {
11
+ bar: string
12
+ baz: number
13
+ }
14
+
15
+ const FooComponent = (props: FooComponentProps) => null
16
+ const BarComponent = (props: BarComponentProps) => null
17
+
18
+ const simpleFooComponentTree = (
19
+ <>
20
+ <>
21
+ {/* This is to also test that fragments are properly ignored */}
22
+ <FooComponent foo="abc" baz={123} />
23
+ </>
24
+ <FooComponent foo="def" baz={456} />
25
+ <FooComponent foo="ghi" baz={789} />
26
+ </>
27
+ )
28
+ const simpleFooBarComponentTree = (
29
+ <>
30
+ <FooComponent foo="abc" baz={123} />
31
+ <BarComponent bar="pqr" baz={369} />
32
+ <FooComponent foo="ghi" baz={789} />
33
+ </>
34
+ )
35
+
36
+ type Op = 'plus' | 'minus' | 'times'
37
+
38
+ interface CalculatorBranchNodeProps {
39
+ op: Op
40
+ children: ReactNode
41
+ }
42
+ const CalculatorBranchNode = (props: CalculatorBranchNodeProps) => null
43
+ CalculatorBranchNode.compute = (props: CalculatorBranchNodeProps, [operand1, operand2]: [number, number]) => {
44
+ if (props.op === 'plus') {
45
+ return operand1 + operand2
46
+ } else if (props.op === 'minus') {
47
+ return operand1 - operand2
48
+ }
49
+ return operand1 * operand2
50
+ }
51
+
52
+ interface NumberComponentProps {
53
+ value: number
54
+ }
55
+ const NumberComponent = (props: NumberComponentProps) => null
56
+
57
+ const calculatorFormula = ( // 10 * ((5 - 3) + (2 * 6)) === 140
58
+ <>
59
+ <CalculatorBranchNode op="times">
60
+ <NumberComponent value={10} />
61
+ <CalculatorBranchNode op="plus">
62
+ <CalculatorBranchNode op="minus">
63
+ <NumberComponent value={5} />
64
+ <NumberComponent value={3} />
65
+ </CalculatorBranchNode>
66
+ <CalculatorBranchNode op="times">
67
+ <NumberComponent value={2} />
68
+ <NumberComponent value={6} />
69
+ </CalculatorBranchNode>
70
+ </CalculatorBranchNode>
71
+ </CalculatorBranchNode>
72
+ </>
73
+ )
74
+
75
+ describe('children analyzer', () => {
76
+ it('should gather children props', () => {
77
+ const fooLeaf = new Leaf<FooComponentProps>(node => (node as ReactElement<FooComponentProps>).props)
78
+ const analyzer = new ChildrenAnalyzer<FooComponentProps>([fooLeaf])
79
+
80
+ expect(analyzer.processChildren(simpleFooComponentTree, undefined)).toEqual([
81
+ { foo: 'abc', baz: 123 },
82
+ { foo: 'def', baz: 456 },
83
+ { foo: 'ghi', baz: 789 },
84
+ ])
85
+ })
86
+ it('should filter leaves by component type', () => {
87
+ const fooLeaf = new Leaf(node => node.props, FooComponent)
88
+ const barLeaf = new Leaf((node): BarComponentProps => {
89
+ const props = node.props
90
+ return {
91
+ bar: `${props.bar}${props.bar}`,
92
+ baz: props.baz + 1,
93
+ }
94
+ }, BarComponent)
95
+ const analyzer = new ChildrenAnalyzer<FooComponentProps | BarComponentProps>([fooLeaf, barLeaf])
96
+
97
+ expect(analyzer.processChildren(simpleFooBarComponentTree, undefined)).toEqual([
98
+ { foo: 'abc', baz: 123 },
99
+ { bar: 'pqrpqr', baz: 370 },
100
+ { foo: 'ghi', baz: 789 },
101
+ ])
102
+ })
103
+ it('should correctly process leaves & branch nodes', () => {
104
+ const numberLeaf = new Leaf(node => node.props.value, NumberComponent)
105
+ const calculatorBranchNode = new BranchNode(
106
+ 'compute',
107
+ (children: RawNodeRepresentation<number, number>): [number, number] => {
108
+ if (!children || typeof children === 'number' || children.length !== 2) {
109
+ throw new Error('We only support binary ops')
110
+ }
111
+ return [children[0], children[1]]
112
+ },
113
+ )
114
+ const analyser = new ChildrenAnalyzer<number, number>([numberLeaf], [calculatorBranchNode])
115
+ expect(analyser.processChildren(calculatorFormula, undefined)).toEqual([140])
116
+ })
117
+ it('should not ignore unhandled nodes when appropriate', () => {
118
+ const fooLeaf = new Leaf(node => node.props, FooComponent)
119
+ const Container: FunctionComponent<{ children: ReactNode }> = props => <>{props.children}</>
120
+ ;(Container as any).staticRender = (props: any) => props.children
121
+
122
+ const analyzer = new ChildrenAnalyzer<FooComponentProps>([fooLeaf], {
123
+ ignoreUnhandledNodes: false,
124
+ staticRenderFactoryName: 'staticRender',
125
+ unhandledNodeErrorMessage: 'Only foo children are supported.',
126
+ })
127
+
128
+ const RendersIgnoredNodes1: FunctionComponent<{ children?: ReactNode }> = props => <>{props.children}</>
129
+ const RendersIgnoredNodes2: FunctionComponent<{ children?: ReactNode }> = props => <>{props.children}</>
130
+ ;(RendersIgnoredNodes1 as any).staticRender = () => (
131
+ <>
132
+ {null}
133
+ {[null, false]}
134
+ </>
135
+ )
136
+ ;(RendersIgnoredNodes2 as any).staticRender = () => null
137
+
138
+ const nodesToBeIgnoredAnyway = (
139
+ <>
140
+ <RendersIgnoredNodes1 />
141
+ <RendersIgnoredNodes2 />
142
+ {[<RendersIgnoredNodes1 key={1} />, <RendersIgnoredNodes2 key={2} />]}
143
+ {void 0}
144
+ <></>
145
+ {null}
146
+ {/* */}
147
+ {false}
148
+ </>
149
+ )
150
+ const nodes = (
151
+ <>
152
+ <>
153
+ <Container>
154
+ {nodesToBeIgnoredAnyway}
155
+ <>
156
+ <FooComponent foo="123" baz={123} />
157
+ <FooComponent foo="456" baz={456} />
158
+ </>
159
+ <FooComponent foo="789" baz={789} />
160
+ <Container>
161
+ <FooComponent foo="135" baz={135} />
162
+ </Container>
163
+ </Container>
164
+ </>
165
+ </>
166
+ )
167
+
168
+ expect(analyzer.processChildren(nodes, undefined)).toEqual([
169
+ { foo: '123', baz: 123 },
170
+ { foo: '456', baz: 456 },
171
+ { foo: '789', baz: 789 },
172
+ { foo: '135', baz: 135 },
173
+ ])
174
+ })
175
+ it('should process arbitrary nodes and support catch-all leaves', () => {
176
+ const fooLeaf = new Leaf(node => node.props, FooComponent)
177
+ const catchAllLef = new Leaf<any>(node => node)
178
+
179
+ const analyzer = new ChildrenAnalyzer([fooLeaf, catchAllLef])
180
+
181
+ const nodes = (
182
+ <>
183
+ <>
184
+ {0}
185
+ {123}
186
+ <FooComponent foo="123" baz={123} />
187
+ bar<a href="#baz">baz</a>
188
+ <FooComponent foo="456" baz={456} />
189
+ <br />
190
+ <FooComponent foo="789" baz={789} />
191
+ </>
192
+ </>
193
+ )
194
+
195
+ expect(analyzer.processChildren(nodes, undefined)).toEqual([
196
+ 0,
197
+ 123,
198
+ { foo: '123', baz: 123 },
199
+ 'bar',
200
+ // eslint-disable-next-line react/jsx-key
201
+ <a href="#baz">baz</a>,
202
+ { foo: '456', baz: 456 },
203
+ // eslint-disable-next-line react/jsx-key
204
+ <br />,
205
+ { foo: '789', baz: 789 },
206
+ ])
207
+ })
208
+ })
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../../tsconfig.settings.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "emitDeclarationOnly": false
6
+ },
7
+ "references": [
8
+ { "path": "../src" }
9
+ ]
10
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "files": [],
3
+ "include": [],
4
+ "references": [
5
+ { "path": "./src" },
6
+ { "path": "./tests" }
7
+ ]
8
+ }
package/tsdoc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3
+ "extends": [
4
+ "../../tsdoc.json"
5
+ ]
6
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzer.cjs","sources":["../../src/ChildrenAnalyzer.ts"],"sourcesContent":["import { assertNever } from '@contember/utilities'\nimport type { ElementType, ReactElement, ReactNode } from 'react'\nimport type { BranchNodeList } from './BranchNodeList'\nimport { ChildrenAnalyzerError } from './ChildrenAnalyzerError'\nimport type { ChildrenAnalyzerOptions } from './ChildrenAnalyzerOptions'\nimport type { LeafList } from './LeafList'\nimport { getErrorMessage } from './helpers'\nimport { wrapError } from './helpers/wrapError'\nimport type {\n\tDeclarationSiteNodeRepresentationFactory,\n\tRawNodeRepresentation,\n\tStaticContextFactory,\n\tSyntheticChildrenFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './nodeSpecs'\n\nexport class ChildrenAnalyzer<\n\tAllLeavesRepresentation = any,\n\tAllBranchNodesRepresentation = never,\n\tStaticContext = undefined,\n> {\n\tprivate static defaultOptions: ChildrenAnalyzerOptions = {\n\t\tignoreRenderProps: true,\n\t\trenderPropsErrorMessage: 'Render props (functions as React component children) are not supported.',\n\n\t\tignoreUnhandledNodes: true,\n\t\tunhandledNodeErrorMessage: 'Encountered an unknown child.',\n\n\t\tstaticContextFactoryName: 'getStaticContext',\n\t\tstaticRenderFactoryName: 'staticRender',\n\t}\n\n\tprivate readonly leaves: LeafList<AllLeavesRepresentation, StaticContext>\n\tprivate readonly branchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>\n\tprivate readonly options: ChildrenAnalyzerOptions<StaticContext>\n\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tbranchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tdecider:\n\t\t\t| Partial<ChildrenAnalyzerOptions>\n\t\t\t| BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext> = [],\n\t\toptions: Partial<ChildrenAnalyzerOptions> = {},\n\t) {\n\t\tthis.leaves = leaves\n\n\t\tif (Array.isArray(decider)) {\n\t\t\tthis.branchNodes = decider\n\t\t} else {\n\t\t\tthis.branchNodes = []\n\t\t\toptions = decider\n\t\t}\n\t\tthis.options = { ...ChildrenAnalyzer.defaultOptions, ...options }\n\t}\n\n\tpublic processChildren(\n\t\tchildren: ReactNode,\n\t\tinitialStaticContext: StaticContext,\n\t): Array<AllLeavesRepresentation | AllBranchNodesRepresentation> {\n\t\tconst processed = this.processNode(children, initialStaticContext, [])\n\n\t\tconst rawResult: Array<AllLeavesRepresentation | AllBranchNodesRepresentation | undefined> = Array.isArray(\n\t\t\tprocessed,\n\t\t)\n\t\t\t? processed\n\t\t\t: [processed]\n\n\t\treturn rawResult.filter(\n\t\t\t(item): item is AllLeavesRepresentation | AllBranchNodesRepresentation => item !== undefined,\n\t\t)\n\t}\n\n\tprivate processNode(\n\t\tnode: ReactNode,\n\t\tstaticContext: StaticContext,\n\t\tcomponentPath: ReactElement[],\n\t): RawNodeRepresentation<AllLeavesRepresentation, AllBranchNodesRepresentation> {\n\t\tif (!node || typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean') {\n\t\t\tfor (const leaf of this.leaves) {\n\t\t\t\tconst specification = leaf.specification\n\t\t\t\tif (specification.type === 'useSite') {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node === false || node === undefined || node === null) {\n\t\t\t\t// This adds seamless support for conditionals and such.\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (!this.options.ignoreUnhandledNodes) {\n\t\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\n\t\tif (typeof node === 'function') {\n\t\t\tif (this.options.ignoreRenderProps) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.renderPropsErrorMessage, node, staticContext))\n\t\t}\n\n\t\tif (Array.isArray(node)) {\n\t\t\tlet mapped: Array<AllLeavesRepresentation | AllBranchNodesRepresentation> = []\n\n\t\t\tfor (const subNode of node) {\n\t\t\t\tconst processed = this.processNode(subNode, staticContext, componentPath)\n\n\t\t\t\tif (processed !== undefined) {\n\t\t\t\t\tif (Array.isArray(processed)) {\n\t\t\t\t\t\tmapped = mapped.concat(processed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmapped.push(processed)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mapped\n\t\t}\n\n\t\tlet children: ReactNode = undefined\n\n\t\tif (!('type' in node)) {\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\tchildren = node.props.children\n\n\t\tif (typeof node.type === 'symbol') {\n\t\t\t// Fragment, Portal or other non-component\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\t// if (typeof node.type === 'string') {\n\t\t// \t// Typically a host component\n\t\t// \tif (!this.options.ignoreUnhandledNodes) {\n\t\t// \t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t// \t}\n\t\t// \treturn this.processNode(children, staticContext)\n\t\t// }\n\n\t\t// Component, PureComponent, FunctionComponent\n\n\t\tconst treeNode = node.type as ElementType &\n\t\t\t{\n\t\t\t\t[staticMethod in ValidFactoryName]:\n\t\t\t\t| StaticContextFactory<any, StaticContext>\n\t\t\t\t| SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\t| UnconstrainedLeafRepresentationFactory<any, AllLeavesRepresentation, StaticContext>\n\t\t\t\t| DeclarationSiteNodeRepresentationFactory<any, unknown, AllBranchNodesRepresentation, StaticContext>\n\t\t\t}\n\n\t\tcomponentPath = [...componentPath, node]\n\t\tif (typeof treeNode !== 'string') {\n\t\t\tif (this.options.staticContextFactoryName in treeNode) {\n\t\t\t\tconst staticContextFactory = treeNode[this.options.staticContextFactoryName] as StaticContextFactory<\n\t\t\t\t\tany,\n\t\t\t\t\tStaticContext\n\t\t\t\t>\n\t\t\t\ttry {\n\t\t\t\t\tstaticContext = staticContextFactory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticContextFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.options.staticRenderFactoryName in treeNode) {\n\t\t\t\tconst factory = treeNode[this.options.staticRenderFactoryName] as SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\ttry {\n\t\t\t\t\tchildren = factory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticRenderFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const leaf of this.leaves) {\n\t\t\tconst specification = leaf.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as UnconstrainedLeafRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tconst processedChildren = this.processNode(children, staticContext, componentPath)\n\n\t\tfor (const branchNode of this.branchNodes) {\n\t\t\tconst specification = branchNode.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName, childrenRepresentationReducer } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as DeclarationSiteNodeRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, childrenRepresentationReducer(processedChildren), staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { factory, ComponentType } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn factory(node, processedChildren, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t!this.options.ignoreUnhandledNodes &&\n\t\t\t!(typeof treeNode !== 'string' && this.options.staticRenderFactoryName in treeNode)\n\t\t) {\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t}\n\n\t\treturn processedChildren\n\t}\n}\n"],"names":["ChildrenAnalyzerError","getErrorMessage","wrapError","assertNever"],"mappings":";;;;;;;;;;;;AAiBO,MAAM,oBAAN,MAAM,kBAIX;AAAA,EAyBM,YACN,QACA,UAE0F,CAAA,GAC1F,UAA4C,CAAA,GAC3C;AAnBe;AACA;AACA;AAkBhB,SAAK,SAAS;AAEV,QAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,WAAK,cAAc;AAAA,IAAA,OACb;AACN,WAAK,cAAc;AACT,gBAAA;AAAA,IACX;AACA,SAAK,UAAU,EAAE,GAAG,kBAAiB,gBAAgB,GAAG;EACzD;AAAA,EAEO,gBACN,UACA,sBACgE;AAChE,UAAM,YAAY,KAAK,YAAY,UAAU,sBAAsB,CAAA,CAAE;AAErE,UAAM,YAAuF,MAAM;AAAA,MAClG;AAAA,IAAA,IAEE,YACA,CAAC,SAAS;AAEb,WAAO,UAAU;AAAA,MAChB,CAAC,SAAyE,SAAS;AAAA,IAAA;AAAA,EAErF;AAAA,EAEQ,YACP,MACA,eACA,eAC+E;AAC3E,QAAA,CAAC,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW;AACpF,iBAAA,QAAQ,KAAK,QAAQ;AAC/B,cAAM,gBAAgB,KAAK;AACvB,YAAA,cAAc,SAAS,WAAW;AAC/B,gBAAA,EAAE,eAAe,QAAY,IAAA;AACnC,cAAI,kBAAkB,QAAW;AACzB,mBAAA,QAAQ,MAAM,aAAa;AAAA,UACnC;AAAA,QACD;AAAA,MACD;AACA,UAAI,SAAS,SAAS,SAAS,UAAa,SAAS,MAAM;AAEnD,eAAA;AAAA,MACR;AACI,UAAA,CAAC,KAAK,QAAQ,sBAAsB;AACjC,cAAA,IAAIA,sBAAAA,sBAAsBC,gBAAAA,gBAAgB,K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T,gBAAA,EAAE,SAAS,cAAkB,IAAA;AACnC,cAAI,kBAAkB,UAAa,KAAK,SAAS,eAAe;AAC/D,gBAAI,sBAAsB,UAAa,CAAC,WAAW,QAAQ,qBAAqB;AAC/E,oBAAM,IAAIA,sBAAAA,sBAAsB,WAAW,QAAQ,0BAA0B;AAAA,YAC9E;AACO,mBAAA,QAAQ,MAAM,mBAAmB,aAAa;AAAA,UACtD;AACA;AAAA,QACD;AAAA,QACA;AACC,iBAAOG,UAAAA,YAAY,aAAa;AAAA,MAClC;AAAA,IACD;AAGC,QAAA,CAAC,KAAK,QAAQ,wBACd,EAAE,OAAO,aAAa,YAAY,KAAK,QAAQ,2BAA2B,WACzE;AACK,YAAA,IAAIH,sBAAAA,sBAAsBC,gBAAAA,gBAAgB,KAAK,QAAQ,2BAA2B,MAAM,aAAa,CAAC;AAAA,IAC7G;AAEO,WAAA;AAAA,EACR;AACD;AA7OC,cALY,mBAKG,kBAA0C;AAAA,EACxD,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EAEzB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA,EAE3B,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA;AAbpB,IAAM,mBAAN;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzer.js","sources":["../../src/ChildrenAnalyzer.ts"],"sourcesContent":["import { assertNever } from '@contember/utilities'\nimport type { ElementType, ReactElement, ReactNode } from 'react'\nimport type { BranchNodeList } from './BranchNodeList'\nimport { ChildrenAnalyzerError } from './ChildrenAnalyzerError'\nimport type { ChildrenAnalyzerOptions } from './ChildrenAnalyzerOptions'\nimport type { LeafList } from './LeafList'\nimport { getErrorMessage } from './helpers'\nimport { wrapError } from './helpers/wrapError'\nimport type {\n\tDeclarationSiteNodeRepresentationFactory,\n\tRawNodeRepresentation,\n\tStaticContextFactory,\n\tSyntheticChildrenFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './nodeSpecs'\n\nexport class ChildrenAnalyzer<\n\tAllLeavesRepresentation = any,\n\tAllBranchNodesRepresentation = never,\n\tStaticContext = undefined,\n> {\n\tprivate static defaultOptions: ChildrenAnalyzerOptions = {\n\t\tignoreRenderProps: true,\n\t\trenderPropsErrorMessage: 'Render props (functions as React component children) are not supported.',\n\n\t\tignoreUnhandledNodes: true,\n\t\tunhandledNodeErrorMessage: 'Encountered an unknown child.',\n\n\t\tstaticContextFactoryName: 'getStaticContext',\n\t\tstaticRenderFactoryName: 'staticRender',\n\t}\n\n\tprivate readonly leaves: LeafList<AllLeavesRepresentation, StaticContext>\n\tprivate readonly branchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>\n\tprivate readonly options: ChildrenAnalyzerOptions<StaticContext>\n\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tbranchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tdecider:\n\t\t\t| Partial<ChildrenAnalyzerOptions>\n\t\t\t| BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext> = [],\n\t\toptions: Partial<ChildrenAnalyzerOptions> = {},\n\t) {\n\t\tthis.leaves = leaves\n\n\t\tif (Array.isArray(decider)) {\n\t\t\tthis.branchNodes = decider\n\t\t} else {\n\t\t\tthis.branchNodes = []\n\t\t\toptions = decider\n\t\t}\n\t\tthis.options = { ...ChildrenAnalyzer.defaultOptions, ...options }\n\t}\n\n\tpublic processChildren(\n\t\tchildren: ReactNode,\n\t\tinitialStaticContext: StaticContext,\n\t): Array<AllLeavesRepresentation | AllBranchNodesRepresentation> {\n\t\tconst processed = this.processNode(children, initialStaticContext, [])\n\n\t\tconst rawResult: Array<AllLeavesRepresentation | AllBranchNodesRepresentation | undefined> = Array.isArray(\n\t\t\tprocessed,\n\t\t)\n\t\t\t? processed\n\t\t\t: [processed]\n\n\t\treturn rawResult.filter(\n\t\t\t(item): item is AllLeavesRepresentation | AllBranchNodesRepresentation => item !== undefined,\n\t\t)\n\t}\n\n\tprivate processNode(\n\t\tnode: ReactNode,\n\t\tstaticContext: StaticContext,\n\t\tcomponentPath: ReactElement[],\n\t): RawNodeRepresentation<AllLeavesRepresentation, AllBranchNodesRepresentation> {\n\t\tif (!node || typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean') {\n\t\t\tfor (const leaf of this.leaves) {\n\t\t\t\tconst specification = leaf.specification\n\t\t\t\tif (specification.type === 'useSite') {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node === false || node === undefined || node === null) {\n\t\t\t\t// This adds seamless support for conditionals and such.\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (!this.options.ignoreUnhandledNodes) {\n\t\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\n\t\tif (typeof node === 'function') {\n\t\t\tif (this.options.ignoreRenderProps) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.renderPropsErrorMessage, node, staticContext))\n\t\t}\n\n\t\tif (Array.isArray(node)) {\n\t\t\tlet mapped: Array<AllLeavesRepresentation | AllBranchNodesRepresentation> = []\n\n\t\t\tfor (const subNode of node) {\n\t\t\t\tconst processed = this.processNode(subNode, staticContext, componentPath)\n\n\t\t\t\tif (processed !== undefined) {\n\t\t\t\t\tif (Array.isArray(processed)) {\n\t\t\t\t\t\tmapped = mapped.concat(processed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmapped.push(processed)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mapped\n\t\t}\n\n\t\tlet children: ReactNode = undefined\n\n\t\tif (!('type' in node)) {\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\tchildren = node.props.children\n\n\t\tif (typeof node.type === 'symbol') {\n\t\t\t// Fragment, Portal or other non-component\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\t// if (typeof node.type === 'string') {\n\t\t// \t// Typically a host component\n\t\t// \tif (!this.options.ignoreUnhandledNodes) {\n\t\t// \t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t// \t}\n\t\t// \treturn this.processNode(children, staticContext)\n\t\t// }\n\n\t\t// Component, PureComponent, FunctionComponent\n\n\t\tconst treeNode = node.type as ElementType &\n\t\t\t{\n\t\t\t\t[staticMethod in ValidFactoryName]:\n\t\t\t\t| StaticContextFactory<any, StaticContext>\n\t\t\t\t| SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\t| UnconstrainedLeafRepresentationFactory<any, AllLeavesRepresentation, StaticContext>\n\t\t\t\t| DeclarationSiteNodeRepresentationFactory<any, unknown, AllBranchNodesRepresentation, StaticContext>\n\t\t\t}\n\n\t\tcomponentPath = [...componentPath, node]\n\t\tif (typeof treeNode !== 'string') {\n\t\t\tif (this.options.staticContextFactoryName in treeNode) {\n\t\t\t\tconst staticContextFactory = treeNode[this.options.staticContextFactoryName] as StaticContextFactory<\n\t\t\t\t\tany,\n\t\t\t\t\tStaticContext\n\t\t\t\t>\n\t\t\t\ttry {\n\t\t\t\t\tstaticContext = staticContextFactory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticContextFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.options.staticRenderFactoryName in treeNode) {\n\t\t\t\tconst factory = treeNode[this.options.staticRenderFactoryName] as SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\ttry {\n\t\t\t\t\tchildren = factory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticRenderFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const leaf of this.leaves) {\n\t\t\tconst specification = leaf.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as UnconstrainedLeafRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tconst processedChildren = this.processNode(children, staticContext, componentPath)\n\n\t\tfor (const branchNode of this.branchNodes) {\n\t\t\tconst specification = branchNode.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName, childrenRepresentationReducer } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as DeclarationSiteNodeRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, childrenRepresentationReducer(processedChildren), staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { factory, ComponentType } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn factory(node, processedChildren, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t!this.options.ignoreUnhandledNodes &&\n\t\t\t!(typeof treeNode !== 'string' && this.options.staticRenderFactoryName in treeNode)\n\t\t) {\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t}\n\n\t\treturn processedChildren\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;AAiBO,MAAM,oBAAN,MAAM,kBAIX;AAAA,EAyBM,YACN,QACA,UAE0F,CAAA,GAC1F,UAA4C,CAAA,GAC3C;AAnBe;AACA;AACA;AAkBhB,SAAK,SAAS;AAEV,QAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,WAAK,cAAc;AAAA,IAAA,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,QAAQ,2BAA2B,MAAM,aAAa,CAAC;AAAA,IAC7G;AAEO,WAAA;AAAA,EACR;AACD;AA7OC,cALY,mBAKG,kBAA0C;AAAA,EACxD,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EAEzB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA,EAE3B,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA;AAbpB,IAAM,mBAAN;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzerError.cjs","sources":["../../src/ChildrenAnalyzerError.ts"],"sourcesContent":["export class ChildrenAnalyzerError extends Error {\n\tpublic details?: string\n\n\tconstructor(message: string, options?: { cause: Error, details?: string }) {\n\t\tsuper(message, options)\n\t\tthis.details = options?.details\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;AAAO,MAAM,8BAA8B,MAAM;AAAA,EAGhD,YAAY,SAAiB,SAA8C;AAC1E,UAAM,SAAS,OAAO;AAHhB;AAIN,SAAK,UAAU,SAAS;AAAA,EACzB;AACD;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzerError.js","sources":["../../src/ChildrenAnalyzerError.ts"],"sourcesContent":["export class ChildrenAnalyzerError extends Error {\n\tpublic details?: string\n\n\tconstructor(message: string, options?: { cause: Error, details?: string }) {\n\t\tsuper(message, options)\n\t\tthis.details = options?.details\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAAO,MAAM,8BAA8B,MAAM;AAAA,EAGhD,YAAY,SAAiB,SAA8C;AAC1E,UAAM,SAAS,OAAO;AAHhB;AAIN,SAAK,UAAU,SAAS;AAAA,EACzB;AACD;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getErrorMessage.cjs","sources":["../../../src/helpers/getErrorMessage.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ErrorMessageFactory } from '../ErrorMessageFactory'\n\nexport const getErrorMessage = <StaticContext>(\n\tfactory: ErrorMessageFactory<StaticContext>,\n\tnode: ReactNode,\n\tstaticContext: StaticContext,\n): string => {\n\treturn typeof factory === 'string' ? factory : factory(node, staticContext)\n}\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAkB,CAC9B,SACA,MACA,kBACY;AACZ,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,MAAM,aAAa;AAC3E;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getErrorMessage.js","sources":["../../../src/helpers/getErrorMessage.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ErrorMessageFactory } from '../ErrorMessageFactory'\n\nexport const getErrorMessage = <StaticContext>(\n\tfactory: ErrorMessageFactory<StaticContext>,\n\tnode: ReactNode,\n\tstaticContext: StaticContext,\n): string => {\n\treturn typeof factory === 'string' ? factory : factory(node, staticContext)\n}\n"],"names":[],"mappings":"AAGO,MAAM,kBAAkB,CAC9B,SACA,MACA,kBACY;AACZ,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,MAAM,aAAa;AAC3E;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapError.cjs","sources":["../../../src/helpers/wrapError.ts"],"sourcesContent":["import React, { ReactElement } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\n\nexport const wrapError = (e: unknown, currentComponentName: string, methodName: string, path: ReactElement[]): never => {\n\tif (!(e instanceof Error)) {\n\t\tthrow e\n\t}\n\n\tconst componentPath = path.map((it, index) => {\n\t\tconst { children, ...props } = it.props\n\t\tconst printProps = (props: any) => {\n\t\t\tlet result = ''\n\t\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst valuePrinted = JSON.stringify(value, (key, value) => {\n\t\t\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t\t\treturn '(function)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (React.isValidElement(value)) {\n\t\t\t\t\t\t\t\treturn '(react element)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tresult += ` ${key}=${valuePrinted}`\n\t\t\t\t} catch {\n\t\t\t\t\tresult += ` ${key}=(failed to print a value)`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst componentName = typeof it.type === 'object' && 'displayName' in it.type ? (it.type as any).displayName : null\n\t\tconst propsPrinted = printProps(props)\n\t\tconst indent = ' '.repeat(index)\n\t\treturn `${indent}<${componentName ?? '???'}${propsPrinted}>`\n\t})\n\tconst errorMessage = `Error during static render of ${currentComponentName} in ${methodName}:\\n${e.message || 'unknown error'}`\n\n\tthrow new ChildrenAnalyzerError(errorMessage, {\n\t\tcause: e,\n\t\tdetails: `Component path:\\n${componentPath.join('\\n')}`,\n\t})\n}\n"],"names":["props","key","value","ChildrenAnalyzerError"],"mappings":";;;;AAGO,MAAM,YAAY,CAAC,GAAY,sBAA8B,YAAoB,SAAgC;AACnH,MAAA,EAAE,aAAa,QAAQ;AACpB,UAAA;AAAA,EACP;AAEA,QAAM,gBAAgB,KAAK,IAAI,CAAC,IAAI,UAAU;AAC7C,UAAM,EAAE,UAAU,GAAG,MAAA,IAAU,GAAG;AAC5B,UAAA,aAAa,CAACA,WAAe;AAClC,UAAI,SAAS;AACb,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQA,MAAK,GAAG;AACjD,YAAI,UAAU,QAAW;AACxB;AAAA,QACD;AACI,YAAA;AACH,gBAAM,eAAe,KAAK;AAAA,YAAU;AAAA,YAAO,CAACC,MAAKC,WAAU;AACrD,kBAAA,OAAOA,WAAU,YAAY;AACzB,uBAAA;AAAA,cACR;AACI,kBAAA,MAAM,eAAeA,MAAK,GAAG;AACzB,uBAAA;AAAA,cACR;AACOA,qBAAAA;AAAAA,YACR;AAAA,UAAA;AAES,oBAAA,IAAI,GAAG,IAAI,YAAY;AAAA,QAAA,QAC1B;AACP,oBAAU,IAAI,GAAG;AAAA,QAClB;AAAA,MACD;AACO,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,OAAO,GAAG,SAAS,YAAY,iBAAiB,GAAG,OAAQ,GAAG,KAAa,cAAc;AACzG,UAAA,eAAe,WAAW,KAAK;AAC/B,UAAA,SAAS,KAAK,OAAO,KAAK;AAChC,WAAO,GAAG,MAAM,IAAI,iBAAiB,KAAK,GAAG,YAAY;AAAA,EAAA,CACzD;AACD,QAAM,eAAe,iCAAiC,oBAAoB,OAAO,UAAU;AAAA,EAAM,EAAE,WAAW,eAAe;AAEvH,QAAA,IAAIC,4CAAsB,cAAc;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EAAoB,cAAc,KAAK,IAAI,CAAC;AAAA,EAAA,CACrD;AACF;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapError.js","sources":["../../../src/helpers/wrapError.ts"],"sourcesContent":["import React, { ReactElement } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\n\nexport const wrapError = (e: unknown, currentComponentName: string, methodName: string, path: ReactElement[]): never => {\n\tif (!(e instanceof Error)) {\n\t\tthrow e\n\t}\n\n\tconst componentPath = path.map((it, index) => {\n\t\tconst { children, ...props } = it.props\n\t\tconst printProps = (props: any) => {\n\t\t\tlet result = ''\n\t\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst valuePrinted = JSON.stringify(value, (key, value) => {\n\t\t\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t\t\treturn '(function)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (React.isValidElement(value)) {\n\t\t\t\t\t\t\t\treturn '(react element)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tresult += ` ${key}=${valuePrinted}`\n\t\t\t\t} catch {\n\t\t\t\t\tresult += ` ${key}=(failed to print a value)`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst componentName = typeof it.type === 'object' && 'displayName' in it.type ? (it.type as any).displayName : null\n\t\tconst propsPrinted = printProps(props)\n\t\tconst indent = ' '.repeat(index)\n\t\treturn `${indent}<${componentName ?? '???'}${propsPrinted}>`\n\t})\n\tconst errorMessage = `Error during static render of ${currentComponentName} in ${methodName}:\\n${e.message || 'unknown error'}`\n\n\tthrow new ChildrenAnalyzerError(errorMessage, {\n\t\tcause: e,\n\t\tdetails: `Component path:\\n${componentPath.join('\\n')}`,\n\t})\n}\n"],"names":["props","key","value"],"mappings":";;AAGO,MAAM,YAAY,CAAC,GAAY,sBAA8B,YAAoB,SAAgC;AACnH,MAAA,EAAE,aAAa,QAAQ;AACpB,UAAA;AAAA,EACP;AAEA,QAAM,gBAAgB,KAAK,IAAI,CAAC,IAAI,UAAU;AAC7C,UAAM,EAAE,UAAU,GAAG,MAAA,IAAU,GAAG;AAC5B,UAAA,aAAa,CAACA,WAAe;AAClC,UAAI,SAAS;AACb,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQA,MAAK,GAAG;AACjD,YAAI,UAAU,QAAW;AACxB;AAAA,QACD;AACI,YAAA;AACH,gBAAM,eAAe,KAAK;AAAA,YAAU;AAAA,YAAO,CAACC,MAAKC,WAAU;AACrD,kBAAA,OAAOA,WAAU,YAAY;AACzB,uBAAA;AAAA,cACR;AACI,kBAAA,MAAM,eAAeA,MAAK,GAAG;AACzB,uBAAA;AAAA,cACR;AACOA,qBAAAA;AAAAA,YACR;AAAA,UAAA;AAES,oBAAA,IAAI,GAAG,IAAI,YAAY;AAAA,QAAA,QAC1B;AACP,oBAAU,IAAI,GAAG;AAAA,QAClB;AAAA,MACD;AACO,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,OAAO,GAAG,SAAS,YAAY,iBAAiB,GAAG,OAAQ,GAAG,KAAa,cAAc;AACzG,UAAA,eAAe,WAAW,KAAK;AAC/B,UAAA,SAAS,KAAK,OAAO,KAAK;AAChC,WAAO,GAAG,MAAM,IAAI,iBAAiB,KAAK,GAAG,YAAY;AAAA,EAAA,CACzD;AACD,QAAM,eAAe,iCAAiC,oBAAoB,OAAO,UAAU;AAAA,EAAM,EAAE,WAAW,eAAe;AAEvH,QAAA,IAAI,sBAAsB,cAAc;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EAAoB,cAAc,KAAK,IAAI,CAAC;AAAA,EAAA,CACrD;AACF;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BranchNode.cjs","sources":["../../../src/nodeSpecs/BranchNode.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\nimport type { BranchNodeOptions } from './BranchNodeOptions'\nimport type { ChildrenRepresentationReducer, UseSiteBranchNodeRepresentationFactory, ValidFactoryName } from './types'\n\nclass BranchNode<\n\tProps extends {} = {},\n\tStaticContext = undefined,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tChildrenRepresentation = any,\n\tReducedChildrenRepresentation = any,\n\tRepresentation = any,\n> {\n\tprivate static defaultOptions: BranchNodeOptions = {\n\t\tchildrenAreOptional: false,\n\t\tchildrenAbsentErrorMessage: 'Component must have children!',\n\t}\n\n\tpublic readonly specification: BranchNode.Specification<\n\t\tProps,\n\t\tStaticContext,\n\t\tFactoryMethodName,\n\t\tChildrenRepresentation,\n\t\tReducedChildrenRepresentation,\n\t\tRepresentation\n\t>\n\n\tpublic readonly options: BranchNodeOptions\n\n\tpublic constructor(\n\t\tfactoryMethodName: FactoryMethodName,\n\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tuseSiteFactory: UseSiteBranchNodeRepresentationFactory<\n\t\t\tProps,\n\t\t\tChildrenRepresentation,\n\t\t\tRepresentation,\n\t\t\tStaticContext\n\t\t>,\n\t\tComponentType?: ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tfactory:\n\t\t\t| FactoryMethodName\n\t\t\t| UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>,\n\t\tcomponentOrReducer?:\n\t\t\t| ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>\n\t\t\t| ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t) {\n\t\tif (typeof factory !== 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t\tchildrenRepresentationReducer: componentOrReducer as ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>,\n\t\t\t}\n\t\t} else if (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tfactory,\n\t\t\t\tComponentType: componentOrReducer as ElementType<Props>,\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new ChildrenAnalyzerError('Invalid arguments')\n\t\t}\n\t\tthis.options = {\n\t\t\t...BranchNode.defaultOptions,\n\t\t\t...options,\n\t\t}\n\t}\n}\n\nnamespace BranchNode {\n\texport type Specification<\n\t\tProps extends {} = {},\n\t\tStaticContext = any,\n\t\tFactoryMethodName extends ValidFactoryName = string,\n\t\tChildrenRepresentation = any,\n\t\tReducedChildrenRepresentation = any,\n\t\tRepresentation = any,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { BranchNode }\n"],"names":["ChildrenAnalyzerError"],"mappings":";;;;;;;;;AAKA,MAAM,cAAN,MAAM,YAOJ;AAAA,EAgCM,YACN,SAGA,oBAGA,SACC;AAlCc;AASA;AA0BX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,QACnB,+BAA+B;AAAA,MAAA;AAAA,IAIhC,WACU,OAAO,YAAY,YAAY;AACzC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA,eAAe;AAAA,MAAA;AAAA,IAChB,OACM;AACA,YAAA,IAAIA,sBAAAA,sBAAsB,mBAAmB;AAAA,IACpD;AACA,SAAK,UAAU;AAAA,MACd,GAAG,YAAW;AAAA,MACd,GAAG;AAAA,IAAA;AAAA,EAEL;AACD;AA/DC,cARK,aAQU,kBAAoC;AAAA,EAClD,qBAAqB;AAAA,EACrB,4BAA4B;AAAA;AAV9B,IAAM,aAAN;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BranchNode.js","sources":["../../../src/nodeSpecs/BranchNode.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\nimport type { BranchNodeOptions } from './BranchNodeOptions'\nimport type { ChildrenRepresentationReducer, UseSiteBranchNodeRepresentationFactory, ValidFactoryName } from './types'\n\nclass BranchNode<\n\tProps extends {} = {},\n\tStaticContext = undefined,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tChildrenRepresentation = any,\n\tReducedChildrenRepresentation = any,\n\tRepresentation = any,\n> {\n\tprivate static defaultOptions: BranchNodeOptions = {\n\t\tchildrenAreOptional: false,\n\t\tchildrenAbsentErrorMessage: 'Component must have children!',\n\t}\n\n\tpublic readonly specification: BranchNode.Specification<\n\t\tProps,\n\t\tStaticContext,\n\t\tFactoryMethodName,\n\t\tChildrenRepresentation,\n\t\tReducedChildrenRepresentation,\n\t\tRepresentation\n\t>\n\n\tpublic readonly options: BranchNodeOptions\n\n\tpublic constructor(\n\t\tfactoryMethodName: FactoryMethodName,\n\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tuseSiteFactory: UseSiteBranchNodeRepresentationFactory<\n\t\t\tProps,\n\t\t\tChildrenRepresentation,\n\t\t\tRepresentation,\n\t\t\tStaticContext\n\t\t>,\n\t\tComponentType?: ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tfactory:\n\t\t\t| FactoryMethodName\n\t\t\t| UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>,\n\t\tcomponentOrReducer?:\n\t\t\t| ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>\n\t\t\t| ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t) {\n\t\tif (typeof factory !== 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t\tchildrenRepresentationReducer: componentOrReducer as ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>,\n\t\t\t}\n\t\t} else if (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tfactory,\n\t\t\t\tComponentType: componentOrReducer as ElementType<Props>,\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new ChildrenAnalyzerError('Invalid arguments')\n\t\t}\n\t\tthis.options = {\n\t\t\t...BranchNode.defaultOptions,\n\t\t\t...options,\n\t\t}\n\t}\n}\n\nnamespace BranchNode {\n\texport type Specification<\n\t\tProps extends {} = {},\n\t\tStaticContext = any,\n\t\tFactoryMethodName extends ValidFactoryName = string,\n\t\tChildrenRepresentation = any,\n\t\tReducedChildrenRepresentation = any,\n\t\tRepresentation = any,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { BranchNode }\n"],"names":[],"mappings":";;;;;;;AAKA,MAAM,cAAN,MAAM,YAOJ;AAAA,EAgCM,YACN,SAGA,oBAGA,SACC;AAlCc;AASA;AA0BX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,QACnB,+BAA+B;AAAA,MAAA;AAAA,IAIhC,WACU,OAAO,YAAY,YAAY;AACzC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA,eAAe;AAAA,MAAA;AAAA,IAChB,OACM;AACA,YAAA,IAAI,sBAAsB,mBAAmB;AAAA,IACpD;AACA,SAAK,UAAU;AAAA,MACd,GAAG,YAAW;AAAA,MACd,GAAG;AAAA,IAAA;AAAA,EAEL;AACD;AA/DC,cARK,aAQU,kBAAoC;AAAA,EAClD,qBAAqB;AAAA,EACrB,4BAA4B;AAAA;AAV9B,IAAM,aAAN;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Leaf.cjs","sources":["../../../src/nodeSpecs/Leaf.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport type {\n\tConstrainedLeafRepresentationFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './types'\n\nclass Leaf<\n\tProps extends {} = {},\n\tStaticContext = any,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tRepresentation = any,\n> {\n\tpublic readonly specification: Leaf.Specification<FactoryMethodName, Representation, Props, StaticContext>\n\n\tpublic constructor(factoryMethodName: FactoryMethodName)\n\tpublic constructor(staticFactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>)\n\tpublic constructor(\n\t\tstaticFactory: ConstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType: ElementType<Props>,\n\t)\n\tpublic constructor(\n\t\tfactory: FactoryMethodName | UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType?: ElementType<Props>,\n\t) {\n\t\tif (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tComponentType,\n\t\t\t\tfactory,\n\t\t\t}\n\t\t} else {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t}\n\t\t}\n\t}\n}\n\nnamespace Leaf {\n\texport type Specification<\n\t\tFactoryMethodName extends ValidFactoryName,\n\t\tRepresentation,\n\t\tProps extends {},\n\t\tStaticContext,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { Leaf }\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,KAKJ;AAAA,EASM,YACN,SACA,eACC;AAXc;AAYX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MAAA;AAAA,IACD,OACM;AACN,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EACD;AACD;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Leaf.js","sources":["../../../src/nodeSpecs/Leaf.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport type {\n\tConstrainedLeafRepresentationFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './types'\n\nclass Leaf<\n\tProps extends {} = {},\n\tStaticContext = any,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tRepresentation = any,\n> {\n\tpublic readonly specification: Leaf.Specification<FactoryMethodName, Representation, Props, StaticContext>\n\n\tpublic constructor(factoryMethodName: FactoryMethodName)\n\tpublic constructor(staticFactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>)\n\tpublic constructor(\n\t\tstaticFactory: ConstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType: ElementType<Props>,\n\t)\n\tpublic constructor(\n\t\tfactory: FactoryMethodName | UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType?: ElementType<Props>,\n\t) {\n\t\tif (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tComponentType,\n\t\t\t\tfactory,\n\t\t\t}\n\t\t} else {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t}\n\t\t}\n\t}\n}\n\nnamespace Leaf {\n\texport type Specification<\n\t\tFactoryMethodName extends ValidFactoryName,\n\t\tRepresentation,\n\t\tProps extends {},\n\t\tStaticContext,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { Leaf }\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,KAKJ;AAAA,EASM,YACN,SACA,eACC;AAXc;AAYX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MAAA;AAAA,IACD,OACM;AACN,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EACD;AACD;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzer.cjs","sources":["../../src/ChildrenAnalyzer.ts"],"sourcesContent":["import { assertNever } from '@contember/utilities'\nimport type { ElementType, ReactElement, ReactNode } from 'react'\nimport type { BranchNodeList } from './BranchNodeList'\nimport { ChildrenAnalyzerError } from './ChildrenAnalyzerError'\nimport type { ChildrenAnalyzerOptions } from './ChildrenAnalyzerOptions'\nimport type { LeafList } from './LeafList'\nimport { getErrorMessage } from './helpers'\nimport { wrapError } from './helpers/wrapError'\nimport type {\n\tDeclarationSiteNodeRepresentationFactory,\n\tRawNodeRepresentation,\n\tStaticContextFactory,\n\tSyntheticChildrenFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './nodeSpecs'\n\nexport class ChildrenAnalyzer<\n\tAllLeavesRepresentation = any,\n\tAllBranchNodesRepresentation = never,\n\tStaticContext = undefined,\n> {\n\tprivate static defaultOptions: ChildrenAnalyzerOptions = {\n\t\tignoreRenderProps: true,\n\t\trenderPropsErrorMessage: 'Render props (functions as React component children) are not supported.',\n\n\t\tignoreUnhandledNodes: true,\n\t\tunhandledNodeErrorMessage: 'Encountered an unknown child.',\n\n\t\tstaticContextFactoryName: 'getStaticContext',\n\t\tstaticRenderFactoryName: 'staticRender',\n\t}\n\n\tprivate readonly leaves: LeafList<AllLeavesRepresentation, StaticContext>\n\tprivate readonly branchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>\n\tprivate readonly options: ChildrenAnalyzerOptions<StaticContext>\n\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tbranchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tdecider:\n\t\t\t| Partial<ChildrenAnalyzerOptions>\n\t\t\t| BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext> = [],\n\t\toptions: Partial<ChildrenAnalyzerOptions> = {},\n\t) {\n\t\tthis.leaves = leaves\n\n\t\tif (Array.isArray(decider)) {\n\t\t\tthis.branchNodes = decider\n\t\t} else {\n\t\t\tthis.branchNodes = []\n\t\t\toptions = decider\n\t\t}\n\t\tthis.options = { ...ChildrenAnalyzer.defaultOptions, ...options }\n\t}\n\n\tpublic processChildren(\n\t\tchildren: ReactNode,\n\t\tinitialStaticContext: StaticContext,\n\t): Array<AllLeavesRepresentation | AllBranchNodesRepresentation> {\n\t\tconst processed = this.processNode(children, initialStaticContext, [])\n\n\t\tconst rawResult: Array<AllLeavesRepresentation | AllBranchNodesRepresentation | undefined> = Array.isArray(\n\t\t\tprocessed,\n\t\t)\n\t\t\t? processed\n\t\t\t: [processed]\n\n\t\treturn rawResult.filter(\n\t\t\t(item): item is AllLeavesRepresentation | AllBranchNodesRepresentation => item !== undefined,\n\t\t)\n\t}\n\n\tprivate processNode(\n\t\tnode: ReactNode,\n\t\tstaticContext: StaticContext,\n\t\tcomponentPath: ReactElement[],\n\t): RawNodeRepresentation<AllLeavesRepresentation, AllBranchNodesRepresentation> {\n\t\tif (!node || typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean') {\n\t\t\tfor (const leaf of this.leaves) {\n\t\t\t\tconst specification = leaf.specification\n\t\t\t\tif (specification.type === 'useSite') {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node === false || node === undefined || node === null) {\n\t\t\t\t// This adds seamless support for conditionals and such.\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (!this.options.ignoreUnhandledNodes) {\n\t\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\n\t\tif (typeof node === 'function') {\n\t\t\tif (this.options.ignoreRenderProps) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.renderPropsErrorMessage, node, staticContext))\n\t\t}\n\n\t\tif (Array.isArray(node)) {\n\t\t\tlet mapped: Array<AllLeavesRepresentation | AllBranchNodesRepresentation> = []\n\n\t\t\tfor (const subNode of node) {\n\t\t\t\tconst processed = this.processNode(subNode, staticContext, componentPath)\n\n\t\t\t\tif (processed !== undefined) {\n\t\t\t\t\tif (Array.isArray(processed)) {\n\t\t\t\t\t\tmapped = mapped.concat(processed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmapped.push(processed)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mapped\n\t\t}\n\n\t\tlet children: ReactNode = undefined\n\n\t\tif (!('type' in node)) {\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\tchildren = node.props.children\n\n\t\tif (typeof node.type === 'symbol') {\n\t\t\t// Fragment, Portal or other non-component\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\t// if (typeof node.type === 'string') {\n\t\t// \t// Typically a host component\n\t\t// \tif (!this.options.ignoreUnhandledNodes) {\n\t\t// \t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t// \t}\n\t\t// \treturn this.processNode(children, staticContext)\n\t\t// }\n\n\t\t// Component, PureComponent, FunctionComponent\n\n\t\tconst treeNode = node.type as ElementType &\n\t\t\t{\n\t\t\t\t[staticMethod in ValidFactoryName]:\n\t\t\t\t| StaticContextFactory<any, StaticContext>\n\t\t\t\t| SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\t| UnconstrainedLeafRepresentationFactory<any, AllLeavesRepresentation, StaticContext>\n\t\t\t\t| DeclarationSiteNodeRepresentationFactory<any, unknown, AllBranchNodesRepresentation, StaticContext>\n\t\t\t}\n\n\t\tcomponentPath = [...componentPath, node]\n\t\tif (typeof treeNode !== 'string') {\n\t\t\tif (this.options.staticContextFactoryName in treeNode) {\n\t\t\t\tconst staticContextFactory = treeNode[this.options.staticContextFactoryName] as StaticContextFactory<\n\t\t\t\t\tany,\n\t\t\t\t\tStaticContext\n\t\t\t\t>\n\t\t\t\ttry {\n\t\t\t\t\tstaticContext = staticContextFactory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticContextFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.options.staticRenderFactoryName in treeNode) {\n\t\t\t\tconst factory = treeNode[this.options.staticRenderFactoryName] as SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\ttry {\n\t\t\t\t\tchildren = factory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticRenderFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const leaf of this.leaves) {\n\t\t\tconst specification = leaf.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as UnconstrainedLeafRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tconst processedChildren = this.processNode(children, staticContext, componentPath)\n\n\t\tfor (const branchNode of this.branchNodes) {\n\t\t\tconst specification = branchNode.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName, childrenRepresentationReducer } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as DeclarationSiteNodeRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, childrenRepresentationReducer(processedChildren), staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { factory, ComponentType } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn factory(node, processedChildren, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t!this.options.ignoreUnhandledNodes &&\n\t\t\t!(typeof treeNode !== 'string' && this.options.staticRenderFactoryName in treeNode)\n\t\t) {\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t}\n\n\t\treturn processedChildren\n\t}\n}\n"],"names":["ChildrenAnalyzerError","getErrorMessage","wrapError","assertNever"],"mappings":";;;;;;;;;;;;AAiBO,MAAM,oBAAN,MAAM,kBAIX;AAAA,EAyBM,YACN,QACA,UAE0F,CAAA,GAC1F,UAA4C,CAAA,GAC3C;AAnBe;AACA;AACA;AAkBhB,SAAK,SAAS;AAEV,QAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,WAAK,cAAc;AAAA,IAAA,OACb;AACN,WAAK,cAAc;AACT,gBAAA;AAAA,IACX;AACA,SAAK,UAAU,EAAE,GAAG,kBAAiB,gBAAgB,GAAG;EACzD;AAAA,EAEO,gBACN,UACA,sBACgE;AAChE,UAAM,YAAY,KAAK,YAAY,UAAU,sBAAsB,CAAA,CAAE;AAErE,UAAM,YAAuF,MAAM;AAAA,MAClG;AAAA,IAAA,IAEE,YACA,CAAC,SAAS;AAEb,WAAO,UAAU;AAAA,MAChB,CAAC,SAAyE,SAAS;AAAA,IAAA;AAAA,EAErF;AAAA,EAEQ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AAN;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzer.js","sources":["../../src/ChildrenAnalyzer.ts"],"sourcesContent":["import { assertNever } from '@contember/utilities'\nimport type { ElementType, ReactElement, ReactNode } from 'react'\nimport type { BranchNodeList } from './BranchNodeList'\nimport { ChildrenAnalyzerError } from './ChildrenAnalyzerError'\nimport type { ChildrenAnalyzerOptions } from './ChildrenAnalyzerOptions'\nimport type { LeafList } from './LeafList'\nimport { getErrorMessage } from './helpers'\nimport { wrapError } from './helpers/wrapError'\nimport type {\n\tDeclarationSiteNodeRepresentationFactory,\n\tRawNodeRepresentation,\n\tStaticContextFactory,\n\tSyntheticChildrenFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './nodeSpecs'\n\nexport class ChildrenAnalyzer<\n\tAllLeavesRepresentation = any,\n\tAllBranchNodesRepresentation = never,\n\tStaticContext = undefined,\n> {\n\tprivate static defaultOptions: ChildrenAnalyzerOptions = {\n\t\tignoreRenderProps: true,\n\t\trenderPropsErrorMessage: 'Render props (functions as React component children) are not supported.',\n\n\t\tignoreUnhandledNodes: true,\n\t\tunhandledNodeErrorMessage: 'Encountered an unknown child.',\n\n\t\tstaticContextFactoryName: 'getStaticContext',\n\t\tstaticRenderFactoryName: 'staticRender',\n\t}\n\n\tprivate readonly leaves: LeafList<AllLeavesRepresentation, StaticContext>\n\tprivate readonly branchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>\n\tprivate readonly options: ChildrenAnalyzerOptions<StaticContext>\n\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tbranchNodes: BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext>,\n\t\toptions?: Partial<ChildrenAnalyzerOptions>,\n\t)\n\tpublic constructor(\n\t\tleaves: LeafList<AllLeavesRepresentation, StaticContext>,\n\t\tdecider:\n\t\t\t| Partial<ChildrenAnalyzerOptions>\n\t\t\t| BranchNodeList<AllLeavesRepresentation, AllBranchNodesRepresentation, StaticContext> = [],\n\t\toptions: Partial<ChildrenAnalyzerOptions> = {},\n\t) {\n\t\tthis.leaves = leaves\n\n\t\tif (Array.isArray(decider)) {\n\t\t\tthis.branchNodes = decider\n\t\t} else {\n\t\t\tthis.branchNodes = []\n\t\t\toptions = decider\n\t\t}\n\t\tthis.options = { ...ChildrenAnalyzer.defaultOptions, ...options }\n\t}\n\n\tpublic processChildren(\n\t\tchildren: ReactNode,\n\t\tinitialStaticContext: StaticContext,\n\t): Array<AllLeavesRepresentation | AllBranchNodesRepresentation> {\n\t\tconst processed = this.processNode(children, initialStaticContext, [])\n\n\t\tconst rawResult: Array<AllLeavesRepresentation | AllBranchNodesRepresentation | undefined> = Array.isArray(\n\t\t\tprocessed,\n\t\t)\n\t\t\t? processed\n\t\t\t: [processed]\n\n\t\treturn rawResult.filter(\n\t\t\t(item): item is AllLeavesRepresentation | AllBranchNodesRepresentation => item !== undefined,\n\t\t)\n\t}\n\n\tprivate processNode(\n\t\tnode: ReactNode,\n\t\tstaticContext: StaticContext,\n\t\tcomponentPath: ReactElement[],\n\t): RawNodeRepresentation<AllLeavesRepresentation, AllBranchNodesRepresentation> {\n\t\tif (!node || typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean') {\n\t\t\tfor (const leaf of this.leaves) {\n\t\t\t\tconst specification = leaf.specification\n\t\t\t\tif (specification.type === 'useSite') {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node === false || node === undefined || node === null) {\n\t\t\t\t// This adds seamless support for conditionals and such.\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (!this.options.ignoreUnhandledNodes) {\n\t\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\n\t\tif (typeof node === 'function') {\n\t\t\tif (this.options.ignoreRenderProps) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.renderPropsErrorMessage, node, staticContext))\n\t\t}\n\n\t\tif (Array.isArray(node)) {\n\t\t\tlet mapped: Array<AllLeavesRepresentation | AllBranchNodesRepresentation> = []\n\n\t\t\tfor (const subNode of node) {\n\t\t\t\tconst processed = this.processNode(subNode, staticContext, componentPath)\n\n\t\t\t\tif (processed !== undefined) {\n\t\t\t\t\tif (Array.isArray(processed)) {\n\t\t\t\t\t\tmapped = mapped.concat(processed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmapped.push(processed)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mapped\n\t\t}\n\n\t\tlet children: ReactNode = undefined\n\n\t\tif (!('type' in node)) {\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\tchildren = node.props.children\n\n\t\tif (typeof node.type === 'symbol') {\n\t\t\t// Fragment, Portal or other non-component\n\t\t\treturn this.processNode(children, staticContext, componentPath)\n\t\t}\n\t\t// if (typeof node.type === 'string') {\n\t\t// \t// Typically a host component\n\t\t// \tif (!this.options.ignoreUnhandledNodes) {\n\t\t// \t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t// \t}\n\t\t// \treturn this.processNode(children, staticContext)\n\t\t// }\n\n\t\t// Component, PureComponent, FunctionComponent\n\n\t\tconst treeNode = node.type as ElementType &\n\t\t\t{\n\t\t\t\t[staticMethod in ValidFactoryName]:\n\t\t\t\t| StaticContextFactory<any, StaticContext>\n\t\t\t\t| SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\t| UnconstrainedLeafRepresentationFactory<any, AllLeavesRepresentation, StaticContext>\n\t\t\t\t| DeclarationSiteNodeRepresentationFactory<any, unknown, AllBranchNodesRepresentation, StaticContext>\n\t\t\t}\n\n\t\tcomponentPath = [...componentPath, node]\n\t\tif (typeof treeNode !== 'string') {\n\t\t\tif (this.options.staticContextFactoryName in treeNode) {\n\t\t\t\tconst staticContextFactory = treeNode[this.options.staticContextFactoryName] as StaticContextFactory<\n\t\t\t\t\tany,\n\t\t\t\t\tStaticContext\n\t\t\t\t>\n\t\t\t\ttry {\n\t\t\t\t\tstaticContext = staticContextFactory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticContextFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.options.staticRenderFactoryName in treeNode) {\n\t\t\t\tconst factory = treeNode[this.options.staticRenderFactoryName] as SyntheticChildrenFactory<any, StaticContext>\n\t\t\t\ttry {\n\t\t\t\t\tchildren = factory(node.props, staticContext)\n\t\t\t\t} catch (e) {\n\t\t\t\t\twrapError(e, treeNode.displayName ?? '???', this.options.staticRenderFactoryName, componentPath)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const leaf of this.leaves) {\n\t\t\tconst specification = leaf.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as UnconstrainedLeafRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { ComponentType, factory } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\treturn factory(node, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tconst processedChildren = this.processNode(children, staticContext, componentPath)\n\n\t\tfor (const branchNode of this.branchNodes) {\n\t\t\tconst specification = branchNode.specification\n\t\t\tswitch (specification.type) {\n\t\t\t\tcase 'declarationSite': {\n\t\t\t\t\tconst { factoryMethodName, childrenRepresentationReducer } = specification\n\n\t\t\t\t\tif (typeof treeNode !== 'string' && factoryMethodName in treeNode) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst factory = treeNode[factoryMethodName] as DeclarationSiteNodeRepresentationFactory<\n\t\t\t\t\t\t\tany,\n\t\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t\tAllBranchNodesRepresentation | AllLeavesRepresentation,\n\t\t\t\t\t\t\tStaticContext\n\t\t\t\t\t\t>\n\t\t\t\t\t\treturn factory(node.props, childrenRepresentationReducer(processedChildren), staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'useSite': {\n\t\t\t\t\tconst { factory, ComponentType } = specification\n\t\t\t\t\tif (ComponentType === undefined || node.type === ComponentType) {\n\t\t\t\t\t\tif (processedChildren === undefined && !branchNode.options.childrenAreOptional) {\n\t\t\t\t\t\t\tthrow new ChildrenAnalyzerError(branchNode.options.childrenAbsentErrorMessage)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn factory(node, processedChildren, staticContext)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn assertNever(specification)\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t!this.options.ignoreUnhandledNodes &&\n\t\t\t!(typeof treeNode !== 'string' && this.options.staticRenderFactoryName in treeNode)\n\t\t) {\n\t\t\tthrow new ChildrenAnalyzerError(getErrorMessage(this.options.unhandledNodeErrorMessage, node, staticContext))\n\t\t}\n\n\t\treturn processedChildren\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;AAiBO,MAAM,oBAAN,MAAM,kBAIX;AAAA,EAyBM,YACN,QACA,UAE0F,CAAA,GAC1F,UAA4C,CAAA,GAC3C;AAnBe;AACA;AACA;AAkBhB,SAAK,SAAS;AAEV,QAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,WAAK,cAAc;AAAA,IAAA,OACb;AACN,WAAK,cAAc;AACT,gBAAA;AAAA,IACX;AACA,SAAK,UAAU,EAAE,GAAG,kBAAiB,gBAAgB,GAAG;EACzD;AAAA,EAEO,gBACN,UACA,sBACgE;AAChE,UAAM,YAAY,KAAK,YAAY,UAAU,sBAAsB,CAAA,CAAE;AAErE,UAAM,YAAuF,MAAM;AAAA,MAClG;AAAA,IAAA,IAEE,YACA,CAAC,SAAS;AAEb,WAAO,UAAU;AAAA,MAChB,CAAC,SAAyE,SAAS;AAAA,IAAA;AAAA,EAErF;AAAA,EAEQ,YACP,MACA,eACA,eAC+E;AAC3E,QAAA,CAAC,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW;AACpF,iBAAA,QAAQ,KAAK,QAAQ;AAC/B,cAAM,gBAAgB,KAAK;AACvB,YAAA,cAAc,SAAS,WAAW;AAC/B,gBAAA,EAAE,eAAe,QAAY,IAAA;AACnC,cAAI,kBAAkB,QAAW;AACzB,mBAAA,QAAQ,MAAM,aAAa;AAAA,UACnC;AAAA,QACD;AAAA,MACD;AACA,UAAI,SAAS,SAAS,SAAS,UAAa,SAAS,MAAM;AAEnD,eAAA;AAAA,MAC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A;AAAA,QACD;AAAA,QACA,KAAK,WAAW;AACT,gBAAA,EAAE,SAAS,cAAkB,IAAA;AACnC,cAAI,kBAAkB,UAAa,KAAK,SAAS,eAAe;AAC/D,gBAAI,sBAAsB,UAAa,CAAC,WAAW,QAAQ,qBAAqB;AAC/E,oBAAM,IAAI,sBAAsB,WAAW,QAAQ,0BAA0B;AAAA,YAC9E;AACO,mBAAA,QAAQ,MAAM,mBAAmB,aAAa;AAAA,UACtD;AACA;AAAA,QACD;AAAA,QACA;AACC,iBAAO,YAAY,aAAa;AAAA,MAClC;AAAA,IACD;AAGC,QAAA,CAAC,KAAK,QAAQ,wBACd,EAAE,OAAO,aAAa,YAAY,KAAK,QAAQ,2BAA2B,WACzE;AACK,YAAA,IAAI,sBAAsB,gBAAgB,KAAK,QAAQ,2BAA2B,MAAM,aAAa,CAAC;AAAA,IAC7G;AAEO,WAAA;AAAA,EACR;AACD;AA7OC,cALY,mBAKG,kBAA0C;AAAA,EACxD,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EAEzB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA,EAE3B,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA;AAbpB,IAAM,mBAAN;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzerError.cjs","sources":["../../src/ChildrenAnalyzerError.ts"],"sourcesContent":["export class ChildrenAnalyzerError extends Error {\n\tpublic details?: string\n\n\tconstructor(message: string, options?: { cause: Error, details?: string }) {\n\t\tsuper(message, options)\n\t\tthis.details = options?.details\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;AAAO,MAAM,8BAA8B,MAAM;AAAA,EAGhD,YAAY,SAAiB,SAA8C;AAC1E,UAAM,SAAS,OAAO;AAHhB;AAIN,SAAK,UAAU,SAAS;AAAA,EACzB;AACD;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChildrenAnalyzerError.js","sources":["../../src/ChildrenAnalyzerError.ts"],"sourcesContent":["export class ChildrenAnalyzerError extends Error {\n\tpublic details?: string\n\n\tconstructor(message: string, options?: { cause: Error, details?: string }) {\n\t\tsuper(message, options)\n\t\tthis.details = options?.details\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAAO,MAAM,8BAA8B,MAAM;AAAA,EAGhD,YAAY,SAAiB,SAA8C;AAC1E,UAAM,SAAS,OAAO;AAHhB;AAIN,SAAK,UAAU,SAAS;AAAA,EACzB;AACD;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getErrorMessage.cjs","sources":["../../../src/helpers/getErrorMessage.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ErrorMessageFactory } from '../ErrorMessageFactory'\n\nexport const getErrorMessage = <StaticContext>(\n\tfactory: ErrorMessageFactory<StaticContext>,\n\tnode: ReactNode,\n\tstaticContext: StaticContext,\n): string => {\n\treturn typeof factory === 'string' ? factory : factory(node, staticContext)\n}\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAkB,CAC9B,SACA,MACA,kBACY;AACZ,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,MAAM,aAAa;AAC3E;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getErrorMessage.js","sources":["../../../src/helpers/getErrorMessage.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ErrorMessageFactory } from '../ErrorMessageFactory'\n\nexport const getErrorMessage = <StaticContext>(\n\tfactory: ErrorMessageFactory<StaticContext>,\n\tnode: ReactNode,\n\tstaticContext: StaticContext,\n): string => {\n\treturn typeof factory === 'string' ? factory : factory(node, staticContext)\n}\n"],"names":[],"mappings":"AAGO,MAAM,kBAAkB,CAC9B,SACA,MACA,kBACY;AACZ,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,MAAM,aAAa;AAC3E;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapError.cjs","sources":["../../../src/helpers/wrapError.ts"],"sourcesContent":["import React, { ReactElement } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\n\nexport const wrapError = (e: unknown, currentComponentName: string, methodName: string, path: ReactElement[]): never => {\n\tif (!(e instanceof Error)) {\n\t\tthrow e\n\t}\n\n\tconst componentPath = path.map((it, index) => {\n\t\tconst { children, ...props } = it.props\n\t\tconst printProps = (props: any) => {\n\t\t\tlet result = ''\n\t\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst valuePrinted = JSON.stringify(value, (key, value) => {\n\t\t\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t\t\treturn '(function)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (React.isValidElement(value)) {\n\t\t\t\t\t\t\t\treturn '(react element)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tresult += ` ${key}=${valuePrinted}`\n\t\t\t\t} catch {\n\t\t\t\t\tresult += ` ${key}=(failed to print a value)`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst componentName = typeof it.type === 'object' && 'displayName' in it.type ? (it.type as any).displayName : null\n\t\tconst propsPrinted = printProps(props)\n\t\tconst indent = ' '.repeat(index)\n\t\treturn `${indent}<${componentName ?? '???'}${propsPrinted}>`\n\t})\n\tconst errorMessage = `Error during static render of ${currentComponentName} in ${methodName}:\\n${e.message || 'unknown error'}`\n\n\tthrow new ChildrenAnalyzerError(errorMessage, {\n\t\tcause: e,\n\t\tdetails: `Component path:\\n${componentPath.join('\\n')}`,\n\t})\n}\n"],"names":["props","key","value","ChildrenAnalyzerError"],"mappings":";;;;AAGO,MAAM,YAAY,CAAC,GAAY,sBAA8B,YAAoB,SAAgC;AACnH,MAAA,EAAE,aAAa,QAAQ;AACpB,UAAA;AAAA,EACP;AAEA,QAAM,gBAAgB,KAAK,IAAI,CAAC,IAAI,UAAU;AAC7C,UAAM,EAAE,UAAU,GAAG,MAAA,IAAU,GAAG;AAC5B,UAAA,aAAa,CAACA,WAAe;AAClC,UAAI,SAAS;AACb,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQA,MAAK,GAAG;AACjD,YAAI,UAAU,QAAW;AACxB;AAAA,QACD;AACI,YAAA;AACH,gBAAM,eAAe,KAAK;AAAA,YAAU;AAAA,YAAO,CAACC,MAAKC,WAAU;AACrD,kBAAA,OAAOA,WAAU,YAAY;AACzB,uBAAA;AAAA,cACR;AACI,kBAAA,MAAM,eAAeA,MAAK,GAAG;AACzB,uBAAA;AAAA,cACR;AACOA,qBAAAA;AAAAA,YACR;AAAA,UAAA;AAES,oBAAA,IAAI,GAAG,IAAI,YAAY;AAAA,QAAA,QAC1B;AACP,oBAAU,IAAI,GAAG;AAAA,QAClB;AAAA,MACD;AACO,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,OAAO,GAAG,SAAS,YAAY,iBAAiB,GAAG,OAAQ,GAAG,KAAa,cAAc;AACzG,UAAA,eAAe,WAAW,KAAK;AAC/B,UAAA,SAAS,KAAK,OAAO,KAAK;AAChC,WAAO,GAAG,MAAM,IAAI,iBAAiB,KAAK,GAAG,YAAY;AAAA,EAAA,CACzD;AACD,QAAM,eAAe,iCAAiC,oBAAoB,OAAO,UAAU;AAAA,EAAM,EAAE,WAAW,eAAe;AAEvH,QAAA,IAAIC,4CAAsB,cAAc;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EAAoB,cAAc,KAAK,IAAI,CAAC;AAAA,EAAA,CACrD;AACF;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapError.js","sources":["../../../src/helpers/wrapError.ts"],"sourcesContent":["import React, { ReactElement } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\n\nexport const wrapError = (e: unknown, currentComponentName: string, methodName: string, path: ReactElement[]): never => {\n\tif (!(e instanceof Error)) {\n\t\tthrow e\n\t}\n\n\tconst componentPath = path.map((it, index) => {\n\t\tconst { children, ...props } = it.props\n\t\tconst printProps = (props: any) => {\n\t\t\tlet result = ''\n\t\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst valuePrinted = JSON.stringify(value, (key, value) => {\n\t\t\t\t\t\t\tif (typeof value === 'function') {\n\t\t\t\t\t\t\t\treturn '(function)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (React.isValidElement(value)) {\n\t\t\t\t\t\t\t\treturn '(react element)'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tresult += ` ${key}=${valuePrinted}`\n\t\t\t\t} catch {\n\t\t\t\t\tresult += ` ${key}=(failed to print a value)`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst componentName = typeof it.type === 'object' && 'displayName' in it.type ? (it.type as any).displayName : null\n\t\tconst propsPrinted = printProps(props)\n\t\tconst indent = ' '.repeat(index)\n\t\treturn `${indent}<${componentName ?? '???'}${propsPrinted}>`\n\t})\n\tconst errorMessage = `Error during static render of ${currentComponentName} in ${methodName}:\\n${e.message || 'unknown error'}`\n\n\tthrow new ChildrenAnalyzerError(errorMessage, {\n\t\tcause: e,\n\t\tdetails: `Component path:\\n${componentPath.join('\\n')}`,\n\t})\n}\n"],"names":["props","key","value"],"mappings":";;AAGO,MAAM,YAAY,CAAC,GAAY,sBAA8B,YAAoB,SAAgC;AACnH,MAAA,EAAE,aAAa,QAAQ;AACpB,UAAA;AAAA,EACP;AAEA,QAAM,gBAAgB,KAAK,IAAI,CAAC,IAAI,UAAU;AAC7C,UAAM,EAAE,UAAU,GAAG,MAAA,IAAU,GAAG;AAC5B,UAAA,aAAa,CAACA,WAAe;AAClC,UAAI,SAAS;AACb,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQA,MAAK,GAAG;AACjD,YAAI,UAAU,QAAW;AACxB;AAAA,QACD;AACI,YAAA;AACH,gBAAM,eAAe,KAAK;AAAA,YAAU;AAAA,YAAO,CAACC,MAAKC,WAAU;AACrD,kBAAA,OAAOA,WAAU,YAAY;AACzB,uBAAA;AAAA,cACR;AACI,kBAAA,MAAM,eAAeA,MAAK,GAAG;AACzB,uBAAA;AAAA,cACR;AACOA,qBAAAA;AAAAA,YACR;AAAA,UAAA;AAES,oBAAA,IAAI,GAAG,IAAI,YAAY;AAAA,QAAA,QAC1B;AACP,oBAAU,IAAI,GAAG;AAAA,QAClB;AAAA,MACD;AACO,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,OAAO,GAAG,SAAS,YAAY,iBAAiB,GAAG,OAAQ,GAAG,KAAa,cAAc;AACzG,UAAA,eAAe,WAAW,KAAK;AAC/B,UAAA,SAAS,KAAK,OAAO,KAAK;AAChC,WAAO,GAAG,MAAM,IAAI,iBAAiB,KAAK,GAAG,YAAY;AAAA,EAAA,CACzD;AACD,QAAM,eAAe,iCAAiC,oBAAoB,OAAO,UAAU;AAAA,EAAM,EAAE,WAAW,eAAe;AAEvH,QAAA,IAAI,sBAAsB,cAAc;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EAAoB,cAAc,KAAK,IAAI,CAAC;AAAA,EAAA,CACrD;AACF;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BranchNode.cjs","sources":["../../../src/nodeSpecs/BranchNode.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\nimport type { BranchNodeOptions } from './BranchNodeOptions'\nimport type { ChildrenRepresentationReducer, UseSiteBranchNodeRepresentationFactory, ValidFactoryName } from './types'\n\nclass BranchNode<\n\tProps extends {} = {},\n\tStaticContext = undefined,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tChildrenRepresentation = any,\n\tReducedChildrenRepresentation = any,\n\tRepresentation = any,\n> {\n\tprivate static defaultOptions: BranchNodeOptions = {\n\t\tchildrenAreOptional: false,\n\t\tchildrenAbsentErrorMessage: 'Component must have children!',\n\t}\n\n\tpublic readonly specification: BranchNode.Specification<\n\t\tProps,\n\t\tStaticContext,\n\t\tFactoryMethodName,\n\t\tChildrenRepresentation,\n\t\tReducedChildrenRepresentation,\n\t\tRepresentation\n\t>\n\n\tpublic readonly options: BranchNodeOptions\n\n\tpublic constructor(\n\t\tfactoryMethodName: FactoryMethodName,\n\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tuseSiteFactory: UseSiteBranchNodeRepresentationFactory<\n\t\t\tProps,\n\t\t\tChildrenRepresentation,\n\t\t\tRepresentation,\n\t\t\tStaticContext\n\t\t>,\n\t\tComponentType?: ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tfactory:\n\t\t\t| FactoryMethodName\n\t\t\t| UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>,\n\t\tcomponentOrReducer?:\n\t\t\t| ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>\n\t\t\t| ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t) {\n\t\tif (typeof factory !== 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t\tchildrenRepresentationReducer: componentOrReducer as ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>,\n\t\t\t}\n\t\t} else if (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tfactory,\n\t\t\t\tComponentType: componentOrReducer as ElementType<Props>,\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new ChildrenAnalyzerError('Invalid arguments')\n\t\t}\n\t\tthis.options = {\n\t\t\t...BranchNode.defaultOptions,\n\t\t\t...options,\n\t\t}\n\t}\n}\n\nnamespace BranchNode {\n\texport type Specification<\n\t\tProps extends {} = {},\n\t\tStaticContext = any,\n\t\tFactoryMethodName extends ValidFactoryName = string,\n\t\tChildrenRepresentation = any,\n\t\tReducedChildrenRepresentation = any,\n\t\tRepresentation = any,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { BranchNode }\n"],"names":["ChildrenAnalyzerError"],"mappings":";;;;;;;;;AAKA,MAAM,cAAN,MAAM,YAOJ;AAAA,EAgCM,YACN,SAGA,oBAGA,SACC;AAlCc;AASA;AA0BX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,QACnB,+BAA+B;AAAA,MAAA;AAAA,IAIhC,WACU,OAAO,YAAY,YAAY;AACzC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA,eAAe;AAAA,MAAA;AAAA,IAChB,OACM;AACA,YAAA,IAAIA,sBAAAA,sBAAsB,mBAAmB;AAAA,IACpD;AACA,SAAK,UAAU;AAAA,MACd,GAAG,YAAW;AAAA,MACd,GAAG;AAAA,IAAA;AAAA,EAEL;AACD;AA/DC,cARK,aAQU,kBAAoC;AAAA,EAClD,qBAAqB;AAAA,EACrB,4BAA4B;AAAA;AAV9B,IAAM,aAAN;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BranchNode.js","sources":["../../../src/nodeSpecs/BranchNode.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport { ChildrenAnalyzerError } from '../ChildrenAnalyzerError'\nimport type { BranchNodeOptions } from './BranchNodeOptions'\nimport type { ChildrenRepresentationReducer, UseSiteBranchNodeRepresentationFactory, ValidFactoryName } from './types'\n\nclass BranchNode<\n\tProps extends {} = {},\n\tStaticContext = undefined,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tChildrenRepresentation = any,\n\tReducedChildrenRepresentation = any,\n\tRepresentation = any,\n> {\n\tprivate static defaultOptions: BranchNodeOptions = {\n\t\tchildrenAreOptional: false,\n\t\tchildrenAbsentErrorMessage: 'Component must have children!',\n\t}\n\n\tpublic readonly specification: BranchNode.Specification<\n\t\tProps,\n\t\tStaticContext,\n\t\tFactoryMethodName,\n\t\tChildrenRepresentation,\n\t\tReducedChildrenRepresentation,\n\t\tRepresentation\n\t>\n\n\tpublic readonly options: BranchNodeOptions\n\n\tpublic constructor(\n\t\tfactoryMethodName: FactoryMethodName,\n\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tuseSiteFactory: UseSiteBranchNodeRepresentationFactory<\n\t\t\tProps,\n\t\t\tChildrenRepresentation,\n\t\t\tRepresentation,\n\t\t\tStaticContext\n\t\t>,\n\t\tComponentType?: ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t)\n\tpublic constructor(\n\t\tfactory:\n\t\t\t| FactoryMethodName\n\t\t\t| UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>,\n\t\tcomponentOrReducer?:\n\t\t\t| ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation>\n\t\t\t| ElementType<Props>,\n\t\toptions?: Partial<BranchNodeOptions>,\n\t) {\n\t\tif (typeof factory !== 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t\tchildrenRepresentationReducer: componentOrReducer as ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>,\n\t\t\t}\n\t\t} else if (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tfactory,\n\t\t\t\tComponentType: componentOrReducer as ElementType<Props>,\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new ChildrenAnalyzerError('Invalid arguments')\n\t\t}\n\t\tthis.options = {\n\t\t\t...BranchNode.defaultOptions,\n\t\t\t...options,\n\t\t}\n\t}\n}\n\nnamespace BranchNode {\n\texport type Specification<\n\t\tProps extends {} = {},\n\t\tStaticContext = any,\n\t\tFactoryMethodName extends ValidFactoryName = string,\n\t\tChildrenRepresentation = any,\n\t\tReducedChildrenRepresentation = any,\n\t\tRepresentation = any,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t\t\tchildrenRepresentationReducer: ChildrenRepresentationReducer<\n\t\t\t\t\tChildrenRepresentation,\n\t\t\t\t\tReducedChildrenRepresentation\n\t\t\t\t>\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UseSiteBranchNodeRepresentationFactory<Props, ChildrenRepresentation, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { BranchNode }\n"],"names":[],"mappings":";;;;;;;AAKA,MAAM,cAAN,MAAM,YAOJ;AAAA,EAgCM,YACN,SAGA,oBAGA,SACC;AAlCc;AASA;AA0BX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,QACnB,+BAA+B;AAAA,MAAA;AAAA,IAIhC,WACU,OAAO,YAAY,YAAY;AACzC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA,eAAe;AAAA,MAAA;AAAA,IAChB,OACM;AACA,YAAA,IAAI,sBAAsB,mBAAmB;AAAA,IACpD;AACA,SAAK,UAAU;AAAA,MACd,GAAG,YAAW;AAAA,MACd,GAAG;AAAA,IAAA;AAAA,EAEL;AACD;AA/DC,cARK,aAQU,kBAAoC;AAAA,EAClD,qBAAqB;AAAA,EACrB,4BAA4B;AAAA;AAV9B,IAAM,aAAN;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Leaf.cjs","sources":["../../../src/nodeSpecs/Leaf.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport type {\n\tConstrainedLeafRepresentationFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './types'\n\nclass Leaf<\n\tProps extends {} = {},\n\tStaticContext = any,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tRepresentation = any,\n> {\n\tpublic readonly specification: Leaf.Specification<FactoryMethodName, Representation, Props, StaticContext>\n\n\tpublic constructor(factoryMethodName: FactoryMethodName)\n\tpublic constructor(staticFactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>)\n\tpublic constructor(\n\t\tstaticFactory: ConstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType: ElementType<Props>,\n\t)\n\tpublic constructor(\n\t\tfactory: FactoryMethodName | UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType?: ElementType<Props>,\n\t) {\n\t\tif (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tComponentType,\n\t\t\t\tfactory,\n\t\t\t}\n\t\t} else {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t}\n\t\t}\n\t}\n}\n\nnamespace Leaf {\n\texport type Specification<\n\t\tFactoryMethodName extends ValidFactoryName,\n\t\tRepresentation,\n\t\tProps extends {},\n\t\tStaticContext,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { Leaf }\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,KAKJ;AAAA,EASM,YACN,SACA,eACC;AAXc;AAYX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MAAA;AAAA,IACD,OACM;AACN,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EACD;AACD;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Leaf.js","sources":["../../../src/nodeSpecs/Leaf.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport type {\n\tConstrainedLeafRepresentationFactory,\n\tUnconstrainedLeafRepresentationFactory,\n\tValidFactoryName,\n} from './types'\n\nclass Leaf<\n\tProps extends {} = {},\n\tStaticContext = any,\n\tFactoryMethodName extends ValidFactoryName = string,\n\tRepresentation = any,\n> {\n\tpublic readonly specification: Leaf.Specification<FactoryMethodName, Representation, Props, StaticContext>\n\n\tpublic constructor(factoryMethodName: FactoryMethodName)\n\tpublic constructor(staticFactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>)\n\tpublic constructor(\n\t\tstaticFactory: ConstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType: ElementType<Props>,\n\t)\n\tpublic constructor(\n\t\tfactory: FactoryMethodName | UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,\n\t\tComponentType?: ElementType<Props>,\n\t) {\n\t\tif (typeof factory === 'function') {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'useSite',\n\t\t\t\tComponentType,\n\t\t\t\tfactory,\n\t\t\t}\n\t\t} else {\n\t\t\tthis.specification = {\n\t\t\t\ttype: 'declarationSite',\n\t\t\t\tfactoryMethodName: factory,\n\t\t\t}\n\t\t}\n\t}\n}\n\nnamespace Leaf {\n\texport type Specification<\n\t\tFactoryMethodName extends ValidFactoryName,\n\t\tRepresentation,\n\t\tProps extends {},\n\t\tStaticContext,\n\t> =\n\t\t| {\n\t\t\t\ttype: 'declarationSite'\n\t\t\t\tfactoryMethodName: FactoryMethodName\n\t\t }\n\t\t| {\n\t\t\t\ttype: 'useSite'\n\t\t\t\tfactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>\n\t\t\t\tComponentType?: ElementType<Props>\n\t\t }\n}\n\nexport { Leaf }\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,KAKJ;AAAA,EASM,YACN,SACA,eACC;AAXc;AAYX,QAAA,OAAO,YAAY,YAAY;AAClC,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MAAA;AAAA,IACD,OACM;AACN,WAAK,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EACD;AACD;"}