@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.
Files changed (106) hide show
  1. package/dist/development/ChildrenAnalyzer.js +170 -0
  2. package/dist/development/ChildrenAnalyzer.js.map +1 -0
  3. package/dist/development/ChildrenAnalyzerError.js +17 -0
  4. package/dist/development/ChildrenAnalyzerError.js.map +1 -0
  5. package/dist/development/helpers/getErrorMessage.js +7 -0
  6. package/dist/development/helpers/getErrorMessage.js.map +1 -0
  7. package/dist/development/helpers/wrapError.js +51 -0
  8. package/dist/development/helpers/wrapError.js.map +1 -0
  9. package/dist/development/index.js +11 -0
  10. package/dist/development/index.js.map +1 -0
  11. package/dist/development/nodeSpecs/BranchNode.js +41 -0
  12. package/dist/development/nodeSpecs/BranchNode.js.map +1 -0
  13. package/dist/development/nodeSpecs/Leaf.js +27 -0
  14. package/dist/development/nodeSpecs/Leaf.js.map +1 -0
  15. package/dist/production/ChildrenAnalyzer.js +170 -0
  16. package/dist/production/ChildrenAnalyzer.js.map +1 -0
  17. package/dist/production/ChildrenAnalyzerError.js +17 -0
  18. package/dist/production/ChildrenAnalyzerError.js.map +1 -0
  19. package/dist/production/helpers/getErrorMessage.js +7 -0
  20. package/dist/production/helpers/getErrorMessage.js.map +1 -0
  21. package/dist/production/helpers/wrapError.js +51 -0
  22. package/dist/production/helpers/wrapError.js.map +1 -0
  23. package/dist/production/index.js +11 -0
  24. package/dist/production/index.js.map +1 -0
  25. package/dist/production/nodeSpecs/BranchNode.js +41 -0
  26. package/dist/production/nodeSpecs/BranchNode.js.map +1 -0
  27. package/dist/production/nodeSpecs/Leaf.js +27 -0
  28. package/dist/production/nodeSpecs/Leaf.js.map +1 -0
  29. package/dist/types/BranchNodeList.d.ts +3 -0
  30. package/dist/types/BranchNodeList.d.ts.map +1 -0
  31. package/dist/types/ChildrenAnalyzer.d.ts +15 -0
  32. package/dist/types/ChildrenAnalyzer.d.ts.map +1 -0
  33. package/dist/types/ChildrenAnalyzerError.d.ts +8 -0
  34. package/dist/types/ChildrenAnalyzerError.d.ts.map +1 -0
  35. package/dist/types/ChildrenAnalyzerOptions.d.ts +10 -0
  36. package/dist/types/ChildrenAnalyzerOptions.d.ts.map +1 -0
  37. package/dist/types/ErrorMessageFactory.d.ts +3 -0
  38. package/dist/types/ErrorMessageFactory.d.ts.map +1 -0
  39. package/dist/types/LeafList.d.ts +3 -0
  40. package/dist/types/LeafList.d.ts.map +1 -0
  41. package/dist/types/helpers/getErrorMessage.d.ts +4 -0
  42. package/dist/types/helpers/getErrorMessage.d.ts.map +1 -0
  43. package/dist/types/helpers/index.d.ts +2 -0
  44. package/dist/types/helpers/index.d.ts.map +1 -0
  45. package/dist/types/helpers/wrapError.d.ts +3 -0
  46. package/dist/types/helpers/wrapError.d.ts.map +1 -0
  47. package/dist/types/index.d.ts +5 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/nodeSpecs/BranchNode.d.ts +23 -0
  50. package/dist/types/nodeSpecs/BranchNode.d.ts.map +1 -0
  51. package/dist/types/nodeSpecs/BranchNodeOptions.d.ts +5 -0
  52. package/dist/types/nodeSpecs/BranchNodeOptions.d.ts.map +1 -0
  53. package/dist/types/nodeSpecs/Leaf.d.ts +20 -0
  54. package/dist/types/nodeSpecs/Leaf.d.ts.map +1 -0
  55. package/dist/types/nodeSpecs/RawNodeRepresentation.d.ts +2 -0
  56. package/dist/types/nodeSpecs/RawNodeRepresentation.d.ts.map +1 -0
  57. package/dist/types/nodeSpecs/index.d.ts +6 -0
  58. package/dist/types/nodeSpecs/index.d.ts.map +1 -0
  59. package/dist/types/nodeSpecs/types/ChildrenRepresentationReducer.d.ts +2 -0
  60. package/dist/types/nodeSpecs/types/ChildrenRepresentationReducer.d.ts.map +1 -0
  61. package/dist/types/nodeSpecs/types/ConstrainedLeafRepresentationFactory.d.ts +3 -0
  62. package/dist/types/nodeSpecs/types/ConstrainedLeafRepresentationFactory.d.ts.map +1 -0
  63. package/dist/types/nodeSpecs/types/DeclarationSiteNodeRepresentationFactory.d.ts +2 -0
  64. package/dist/types/nodeSpecs/types/DeclarationSiteNodeRepresentationFactory.d.ts.map +1 -0
  65. package/dist/types/nodeSpecs/types/RepresentationFactorySite.d.ts +2 -0
  66. package/dist/types/nodeSpecs/types/RepresentationFactorySite.d.ts.map +1 -0
  67. package/dist/types/nodeSpecs/types/StaticContextFactory.d.ts +2 -0
  68. package/dist/types/nodeSpecs/types/StaticContextFactory.d.ts.map +1 -0
  69. package/dist/types/nodeSpecs/types/SyntheticChildrenFactory.d.ts +3 -0
  70. package/dist/types/nodeSpecs/types/SyntheticChildrenFactory.d.ts.map +1 -0
  71. package/dist/types/nodeSpecs/types/UnconstrainedLeafRepresentationFactory.d.ts +3 -0
  72. package/dist/types/nodeSpecs/types/UnconstrainedLeafRepresentationFactory.d.ts.map +1 -0
  73. package/dist/types/nodeSpecs/types/UseSiteBranchNodeRepresentationFactory.d.ts +3 -0
  74. package/dist/types/nodeSpecs/types/UseSiteBranchNodeRepresentationFactory.d.ts.map +1 -0
  75. package/dist/types/nodeSpecs/types/ValidFactoryName.d.ts +2 -0
  76. package/dist/types/nodeSpecs/types/ValidFactoryName.d.ts.map +1 -0
  77. package/dist/types/nodeSpecs/types/index.d.ts +10 -0
  78. package/dist/types/nodeSpecs/types/index.d.ts.map +1 -0
  79. package/dist/types/tsconfig.tsbuildinfo +1 -0
  80. package/package.json +37 -0
  81. package/src/BranchNodeList.ts +10 -0
  82. package/src/ChildrenAnalyzer.ts +260 -0
  83. package/src/ChildrenAnalyzerError.ts +8 -0
  84. package/src/ChildrenAnalyzerOptions.ts +12 -0
  85. package/src/ErrorMessageFactory.ts +5 -0
  86. package/src/LeafList.ts +8 -0
  87. package/src/helpers/getErrorMessage.ts +10 -0
  88. package/src/helpers/index.ts +1 -0
  89. package/src/helpers/wrapError.ts +46 -0
  90. package/src/index.ts +5 -0
  91. package/src/nodeSpecs/BranchNode.ts +103 -0
  92. package/src/nodeSpecs/BranchNodeOptions.ts +4 -0
  93. package/src/nodeSpecs/Leaf.ts +59 -0
  94. package/src/nodeSpecs/RawNodeRepresentation.ts +5 -0
  95. package/src/nodeSpecs/index.ts +6 -0
  96. package/src/nodeSpecs/types/ChildrenRepresentationReducer.ts +3 -0
  97. package/src/nodeSpecs/types/ConstrainedLeafRepresentationFactory.ts +6 -0
  98. package/src/nodeSpecs/types/DeclarationSiteNodeRepresentationFactory.ts +10 -0
  99. package/src/nodeSpecs/types/RepresentationFactorySite.ts +1 -0
  100. package/src/nodeSpecs/types/StaticContextFactory.ts +4 -0
  101. package/src/nodeSpecs/types/SyntheticChildrenFactory.ts +6 -0
  102. package/src/nodeSpecs/types/UnconstrainedLeafRepresentationFactory.ts +6 -0
  103. package/src/nodeSpecs/types/UseSiteBranchNodeRepresentationFactory.ts +12 -0
  104. package/src/nodeSpecs/types/ValidFactoryName.ts +1 -0
  105. package/src/nodeSpecs/types/index.ts +9 -0
  106. 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,5 @@
1
+ export type RawNodeRepresentation<AllLeavesRepresentation, AllBranchNodesRepresentation = AllLeavesRepresentation> =
2
+ | AllLeavesRepresentation
3
+ | AllBranchNodesRepresentation
4
+ | Array<AllLeavesRepresentation | AllBranchNodesRepresentation>
5
+ | undefined
@@ -0,0 +1,6 @@
1
+ export * from './types'
2
+
3
+ export * from './BranchNode'
4
+ export * from './BranchNodeOptions'
5
+ export * from './Leaf'
6
+ export * from './RawNodeRepresentation'
@@ -0,0 +1,3 @@
1
+ export type ChildrenRepresentationReducer<ChildrenRepresentation, ReducedChildrenRepresentation> = (
2
+ childrenRepresentations: ChildrenRepresentation,
3
+ ) => ReducedChildrenRepresentation
@@ -0,0 +1,6 @@
1
+ import type { ReactElement } from 'react'
2
+
3
+ export type ConstrainedLeafRepresentationFactory<Props extends {}, Representation, StaticContext> = (
4
+ node: ReactElement<Props, any>,
5
+ staticContext: StaticContext,
6
+ ) => Representation
@@ -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,4 @@
1
+ export type StaticContextFactory<Props extends {}, StaticContext> = (
2
+ props: Props,
3
+ staticContext: StaticContext,
4
+ ) => StaticContext
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react'
2
+
3
+ export type SyntheticChildrenFactory<Props extends {}, StaticContext> = (
4
+ props: Props,
5
+ staticContext: StaticContext,
6
+ ) => ReactNode
@@ -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'
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../../tsconfig.settings.json",
3
+ "compilerOptions": {
4
+ "outDir": "../dist/types"
5
+ },
6
+ "references": [
7
+ { "path": "../../utilities/src" }
8
+ ]
9
+ }