@contember/react-multipass-rendering 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/ChildrenAnalyzer.js +170 -0
- package/dist/development/ChildrenAnalyzer.js.map +1 -0
- package/dist/development/ChildrenAnalyzerError.js +17 -0
- package/dist/development/ChildrenAnalyzerError.js.map +1 -0
- package/dist/development/helpers/getErrorMessage.js +7 -0
- package/dist/development/helpers/getErrorMessage.js.map +1 -0
- package/dist/development/helpers/wrapError.js +51 -0
- package/dist/development/helpers/wrapError.js.map +1 -0
- package/dist/development/index.js +11 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/nodeSpecs/BranchNode.js +41 -0
- package/dist/development/nodeSpecs/BranchNode.js.map +1 -0
- package/dist/development/nodeSpecs/Leaf.js +27 -0
- package/dist/development/nodeSpecs/Leaf.js.map +1 -0
- package/dist/production/ChildrenAnalyzer.js +170 -0
- package/dist/production/ChildrenAnalyzer.js.map +1 -0
- package/dist/production/ChildrenAnalyzerError.js +17 -0
- package/dist/production/ChildrenAnalyzerError.js.map +1 -0
- package/dist/production/helpers/getErrorMessage.js +7 -0
- package/dist/production/helpers/getErrorMessage.js.map +1 -0
- package/dist/production/helpers/wrapError.js +51 -0
- package/dist/production/helpers/wrapError.js.map +1 -0
- package/dist/production/index.js +11 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/nodeSpecs/BranchNode.js +41 -0
- package/dist/production/nodeSpecs/BranchNode.js.map +1 -0
- package/dist/production/nodeSpecs/Leaf.js +27 -0
- package/dist/production/nodeSpecs/Leaf.js.map +1 -0
- package/dist/types/BranchNodeList.d.ts +3 -0
- package/dist/types/BranchNodeList.d.ts.map +1 -0
- package/dist/types/ChildrenAnalyzer.d.ts +15 -0
- package/dist/types/ChildrenAnalyzer.d.ts.map +1 -0
- package/dist/types/ChildrenAnalyzerError.d.ts +8 -0
- package/dist/types/ChildrenAnalyzerError.d.ts.map +1 -0
- package/dist/types/ChildrenAnalyzerOptions.d.ts +10 -0
- package/dist/types/ChildrenAnalyzerOptions.d.ts.map +1 -0
- package/dist/types/ErrorMessageFactory.d.ts +3 -0
- package/dist/types/ErrorMessageFactory.d.ts.map +1 -0
- package/dist/types/LeafList.d.ts +3 -0
- package/dist/types/LeafList.d.ts.map +1 -0
- package/dist/types/helpers/getErrorMessage.d.ts +4 -0
- package/dist/types/helpers/getErrorMessage.d.ts.map +1 -0
- package/dist/types/helpers/index.d.ts +2 -0
- package/dist/types/helpers/index.d.ts.map +1 -0
- package/dist/types/helpers/wrapError.d.ts +3 -0
- package/dist/types/helpers/wrapError.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/nodeSpecs/BranchNode.d.ts +23 -0
- package/dist/types/nodeSpecs/BranchNode.d.ts.map +1 -0
- package/dist/types/nodeSpecs/BranchNodeOptions.d.ts +5 -0
- package/dist/types/nodeSpecs/BranchNodeOptions.d.ts.map +1 -0
- package/dist/types/nodeSpecs/Leaf.d.ts +20 -0
- package/dist/types/nodeSpecs/Leaf.d.ts.map +1 -0
- package/dist/types/nodeSpecs/RawNodeRepresentation.d.ts +2 -0
- package/dist/types/nodeSpecs/RawNodeRepresentation.d.ts.map +1 -0
- package/dist/types/nodeSpecs/index.d.ts +6 -0
- package/dist/types/nodeSpecs/index.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/ChildrenRepresentationReducer.d.ts +2 -0
- package/dist/types/nodeSpecs/types/ChildrenRepresentationReducer.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/ConstrainedLeafRepresentationFactory.d.ts +3 -0
- package/dist/types/nodeSpecs/types/ConstrainedLeafRepresentationFactory.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/DeclarationSiteNodeRepresentationFactory.d.ts +2 -0
- package/dist/types/nodeSpecs/types/DeclarationSiteNodeRepresentationFactory.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/RepresentationFactorySite.d.ts +2 -0
- package/dist/types/nodeSpecs/types/RepresentationFactorySite.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/StaticContextFactory.d.ts +2 -0
- package/dist/types/nodeSpecs/types/StaticContextFactory.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/SyntheticChildrenFactory.d.ts +3 -0
- package/dist/types/nodeSpecs/types/SyntheticChildrenFactory.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/UnconstrainedLeafRepresentationFactory.d.ts +3 -0
- package/dist/types/nodeSpecs/types/UnconstrainedLeafRepresentationFactory.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/UseSiteBranchNodeRepresentationFactory.d.ts +3 -0
- package/dist/types/nodeSpecs/types/UseSiteBranchNodeRepresentationFactory.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/ValidFactoryName.d.ts +2 -0
- package/dist/types/nodeSpecs/types/ValidFactoryName.d.ts.map +1 -0
- package/dist/types/nodeSpecs/types/index.d.ts +10 -0
- package/dist/types/nodeSpecs/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +37 -0
- package/src/BranchNodeList.ts +10 -0
- package/src/ChildrenAnalyzer.ts +260 -0
- package/src/ChildrenAnalyzerError.ts +8 -0
- package/src/ChildrenAnalyzerOptions.ts +12 -0
- package/src/ErrorMessageFactory.ts +5 -0
- package/src/LeafList.ts +8 -0
- package/src/helpers/getErrorMessage.ts +10 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/wrapError.ts +46 -0
- package/src/index.ts +5 -0
- package/src/nodeSpecs/BranchNode.ts +103 -0
- package/src/nodeSpecs/BranchNodeOptions.ts +4 -0
- package/src/nodeSpecs/Leaf.ts +59 -0
- package/src/nodeSpecs/RawNodeRepresentation.ts +5 -0
- package/src/nodeSpecs/index.ts +6 -0
- package/src/nodeSpecs/types/ChildrenRepresentationReducer.ts +3 -0
- package/src/nodeSpecs/types/ConstrainedLeafRepresentationFactory.ts +6 -0
- package/src/nodeSpecs/types/DeclarationSiteNodeRepresentationFactory.ts +10 -0
- package/src/nodeSpecs/types/RepresentationFactorySite.ts +1 -0
- package/src/nodeSpecs/types/StaticContextFactory.ts +4 -0
- package/src/nodeSpecs/types/SyntheticChildrenFactory.ts +6 -0
- package/src/nodeSpecs/types/UnconstrainedLeafRepresentationFactory.ts +6 -0
- package/src/nodeSpecs/types/UseSiteBranchNodeRepresentationFactory.ts +12 -0
- package/src/nodeSpecs/types/ValidFactoryName.ts +1 -0
- package/src/nodeSpecs/types/index.ts +9 -0
- package/src/tsconfig.json +9 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ElementType } from 'react'
|
|
2
|
+
import type {
|
|
3
|
+
ConstrainedLeafRepresentationFactory,
|
|
4
|
+
UnconstrainedLeafRepresentationFactory,
|
|
5
|
+
ValidFactoryName,
|
|
6
|
+
} from './types'
|
|
7
|
+
|
|
8
|
+
class Leaf<
|
|
9
|
+
Props extends {} = {},
|
|
10
|
+
StaticContext = any,
|
|
11
|
+
FactoryMethodName extends ValidFactoryName = string,
|
|
12
|
+
Representation = any,
|
|
13
|
+
> {
|
|
14
|
+
public readonly specification: Leaf.Specification<FactoryMethodName, Representation, Props, StaticContext>
|
|
15
|
+
|
|
16
|
+
public constructor(factoryMethodName: FactoryMethodName)
|
|
17
|
+
public constructor(staticFactory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>)
|
|
18
|
+
public constructor(
|
|
19
|
+
staticFactory: ConstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,
|
|
20
|
+
ComponentType: ElementType<Props>,
|
|
21
|
+
)
|
|
22
|
+
public constructor(
|
|
23
|
+
factory: FactoryMethodName | UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>,
|
|
24
|
+
ComponentType?: ElementType<Props>,
|
|
25
|
+
) {
|
|
26
|
+
if (typeof factory === 'function') {
|
|
27
|
+
this.specification = {
|
|
28
|
+
type: 'useSite',
|
|
29
|
+
ComponentType,
|
|
30
|
+
factory,
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
this.specification = {
|
|
34
|
+
type: 'declarationSite',
|
|
35
|
+
factoryMethodName: factory,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
namespace Leaf {
|
|
42
|
+
export type Specification<
|
|
43
|
+
FactoryMethodName extends ValidFactoryName,
|
|
44
|
+
Representation,
|
|
45
|
+
Props extends {},
|
|
46
|
+
StaticContext,
|
|
47
|
+
> =
|
|
48
|
+
| {
|
|
49
|
+
type: 'declarationSite'
|
|
50
|
+
factoryMethodName: FactoryMethodName
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
type: 'useSite'
|
|
54
|
+
factory: UnconstrainedLeafRepresentationFactory<Props, Representation, StaticContext>
|
|
55
|
+
ComponentType?: ElementType<Props>
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Leaf }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type DeclarationSiteNodeRepresentationFactory<
|
|
2
|
+
Props extends {},
|
|
3
|
+
ReducedChildrenRepresentation,
|
|
4
|
+
Representation,
|
|
5
|
+
StaticContext,
|
|
6
|
+
> = (
|
|
7
|
+
props: Props,
|
|
8
|
+
reducedChildrenRepresentation: ReducedChildrenRepresentation,
|
|
9
|
+
staticContext: StaticContext,
|
|
10
|
+
) => Representation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RepresentationFactorySite = 'declarationSite' | 'useSite'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactElement, ReactText } from 'react'
|
|
2
|
+
|
|
3
|
+
export type UnconstrainedLeafRepresentationFactory<Props extends {}, Representation, StaticContext> = (
|
|
4
|
+
node: ReactText | ReactElement<Props, any> | boolean | null | undefined,
|
|
5
|
+
staticContext: StaticContext,
|
|
6
|
+
) => Representation
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactElement } from 'react'
|
|
2
|
+
|
|
3
|
+
export type UseSiteBranchNodeRepresentationFactory<
|
|
4
|
+
Props extends {},
|
|
5
|
+
ChildrenRepresentation,
|
|
6
|
+
Representation,
|
|
7
|
+
StaticContext,
|
|
8
|
+
> = (
|
|
9
|
+
node: ReactElement<Props, any>,
|
|
10
|
+
childrenRepresentation: ChildrenRepresentation,
|
|
11
|
+
staticContext: StaticContext,
|
|
12
|
+
) => Representation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ValidFactoryName = string | number
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ChildrenRepresentationReducer'
|
|
2
|
+
export * from './ConstrainedLeafRepresentationFactory'
|
|
3
|
+
export * from './DeclarationSiteNodeRepresentationFactory'
|
|
4
|
+
export * from './RepresentationFactorySite'
|
|
5
|
+
export * from './StaticContextFactory'
|
|
6
|
+
export * from './SyntheticChildrenFactory'
|
|
7
|
+
export * from './UnconstrainedLeafRepresentationFactory'
|
|
8
|
+
export * from './UseSiteBranchNodeRepresentationFactory'
|
|
9
|
+
export * from './ValidFactoryName'
|