componentsjs 5.0.0-beta.0 → 5.0.0-beta.4

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 (34) hide show
  1. package/CHANGELOG.md +272 -0
  2. package/README.md +16 -0
  3. package/components/context.jsonld +62 -1
  4. package/lib/ComponentsManager.js +3 -5
  5. package/lib/construction/strategy/ConstructionStrategyCommonJs.d.ts +3 -1
  6. package/lib/construction/strategy/ConstructionStrategyCommonJs.js +8 -10
  7. package/lib/construction/strategy/ConstructionStrategyCommonJsString.js +6 -8
  8. package/lib/loading/ComponentRegistryFinalizer.js +7 -1
  9. package/lib/preprocess/ConfigPreprocessorComponent.d.ts +2 -0
  10. package/lib/preprocess/ConfigPreprocessorComponent.js +18 -1
  11. package/lib/preprocess/ConfigPreprocessorComponentMapped.d.ts +3 -2
  12. package/lib/preprocess/ConfigPreprocessorComponentMapped.js +9 -7
  13. package/lib/preprocess/GenericsContext.d.ts +74 -0
  14. package/lib/preprocess/GenericsContext.js +326 -0
  15. package/lib/preprocess/ParameterHandler.d.ts +6 -2
  16. package/lib/preprocess/ParameterHandler.js +7 -6
  17. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerCollectEntries.d.ts +3 -2
  18. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerCollectEntries.js +8 -6
  19. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerElements.d.ts +2 -1
  20. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerElements.js +2 -2
  21. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerFields.d.ts +2 -1
  22. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerFields.js +3 -2
  23. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerKeyValue.d.ts +4 -3
  24. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerKeyValue.js +7 -7
  25. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerList.d.ts +2 -1
  26. package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerList.js +5 -3
  27. package/lib/preprocess/constructorargumentsmapping/IConstructorArgumentsElementMappingHandler.d.ts +5 -2
  28. package/lib/preprocess/constructorargumentsmapping/IConstructorArgumentsMapper.d.ts +5 -2
  29. package/lib/preprocess/parameterproperty/IParameterPropertyHandler.d.ts +5 -2
  30. package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.d.ts +34 -11
  31. package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js +393 -88
  32. package/lib/util/ErrorResourcesContext.d.ts +11 -14
  33. package/lib/util/ErrorResourcesContext.js +44 -22
  34. package/package.json +2 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,272 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ <a name="v5.0.0-beta.4"></a>
5
+ ## [v5.0.0-beta.4](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.3...v5.0.0-beta.4) - 2022-01-29
6
+
7
+ ### Added
8
+ * [Support ParameterRangeIndexed for fixed literals](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0d97782a4a8dcca9fc5bbb3389a4213eca5a5205)
9
+
10
+ ### Changed
11
+ * [Propagate original error messages to require calls, Closes #65](https://github.com/LinkedSoftwareDependencies/Components.js/commit/8934ec9b784def601730b3d3f2e60c4ff0b8776e)
12
+ * [Include config id in invalid param error message](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e724f44e2222eb9917da3b227e2ce0dc9cde15f9)
13
+ * [Update memberKeys to memberFields](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2c7437e1519c1813fb1a29f50d7c20bdbdf7f06e)
14
+
15
+ <a name="v5.0.0-beta.3"></a>
16
+ ## [v5.0.0-beta.3](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.2...v5.0.0-beta.3) - 2022-01-17
17
+
18
+ ### Added
19
+ * [Add support for wildcard parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/83238a9fa08877f29326be562d7d3d5fff860c69)
20
+ * Improve error reporting:
21
+ * [Add causes for param check failures in error messages](https://github.com/LinkedSoftwareDependencies/Components.js/commit/9be1fd0899ffb8a77ea99e5fb86e661526ef6d1a)
22
+ * [Improve error message on invalid generic type instantiations](https://github.com/LinkedSoftwareDependencies/Components.js/commit/6ecb9798eeb84f09fece68b3a47454fa8c857ba4)
23
+ * [Move error context to error state file](https://github.com/LinkedSoftwareDependencies/Components.js/commit/dbf26e072bdc63168814ef4d503777efaf4745eb)
24
+
25
+ ### Fixed
26
+ * Resolve several issues related to generics:
27
+ * [Throw error on invalid ParameterRangeGenericComponent](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c692ab6175ce466fb32fbe38b973644e2601b2e6)
28
+ * [Fix generic components not accepting specific types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c7739182fddcb92d46a86fe3e33d6e29fd1134b6)
29
+ * [Support generic type instantiation during component extension](https://github.com/LinkedSoftwareDependencies/Components.js/commit/98f70e350cc3f9bf8a4ea632db546f74624ddda7)
30
+ * [Support generic components in params with fixed generics](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d8b30972e1306e9fe9db391d4693aa6000917e60)
31
+ * [Use GenericComponentExtension to refer to wrapped generic comp extensions](https://github.com/LinkedSoftwareDependencies/Components.js/commit/239895accfdb7f09a7ac8454928bd3e0be5e5f15)
32
+ * [Fix invalid range display with multiple generics](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b98baf0bcf4546b60299ae548f929693345292bc)
33
+ * [Handle range merging if left or right is union](https://github.com/LinkedSoftwareDependencies/Components.js/commit/637e140106691b95f0f546cf88eb39f3f80dc61d)
34
+ * [Handle sub-types when merging param ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/43290525b2e244f5fbb6d5f344760b863329c31b)
35
+ * [Allow merging of generic component param types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/ee8de7d9b8d18bf6968a17078e493946e5fca8cd)
36
+ * [Allow param range merging with generic components](https://github.com/LinkedSoftwareDependencies/Components.js/commit/bcea7dcff288ce7068ee244c49c12134208c89da)
37
+ * [Fix generics crash when doing repeated param type checking](https://github.com/LinkedSoftwareDependencies/Components.js/commit/237572cb8a9c546b098582041ccd7a457b41aecd)
38
+
39
+ <a name="v5.0.0-beta.2"></a>
40
+ ## [v5.0.0-beta.2](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.1...v5.0.0-beta.2) - 2021-12-09
41
+
42
+ ### Added
43
+ * [Handle keyof parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0f55ba05bff5311d111ca97256aaa2e7be7ae83b)
44
+
45
+ <a name="v5.0.0-beta.1"></a>
46
+ ## [v5.0.0-beta.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.0...v5.0.0-beta.1) - 2021-12-07
47
+
48
+ ### Added
49
+ * [Handle generics in nested components](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d33d4c2668974087873943b3d5c66300fa3df65b)
50
+ * [Handle generics in parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d3358b74ab25a3aca13d6dfc97b16cfd836d4ba9)
51
+ * [Add generic vocabulary changes to context](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b8af018bb8f344833c07d1ef795a6b08d414c2ad)
52
+
53
+ <a name="v5.0.0-beta.0"></a>
54
+ ## [v5.0.0-beta.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.5.0...v5.0.0-beta.0) - 2021-11-30
55
+
56
+ ### BREAKING CHANGES
57
+ * [Remove required and unique param flags in favor of parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0df26318e4803b06660b3458fc75d565c4b60f67):
58
+ This allows more complex ranges to be defined, such as nested arrays, or arrays of union types.
59
+ **Because of this change, arrays now must always be explicitly defined within an RDF list (or @list in JSON-LD).**
60
+ If one param value is provided, it is considered a singular value.
61
+ If the param value contains an RDF list, it is considered an array.
62
+ If multiple param values are provided without RDF list, an error is thrown.
63
+
64
+ ### Added
65
+ * Validate parameter values by type:
66
+ * [Validate param ranges with union and intersection types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d08ecdb94051d3e88e7e1ea09f0f77518fb0debf)
67
+ * [Validate types of resource-based param values](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2be90ccb416215261ef9c785e89302f3c4ef9264)
68
+ * [Validate param ranges with tuple types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/05d84c4c1d4bde6bcb5a99d53df4e66ca69536bf)
69
+ * [Validate param ranges with literal types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/7373b0fc06bdaf95a8099b9f58b741cd6f4f1b9d)
70
+
71
+ ### Changed
72
+ * [Allow IRIs to be casted to string params](https://github.com/LinkedSoftwareDependencies/Components.js/commit/978985684dcba67629d44bfd0e5cf75293c5ea7a)
73
+ * [Allow components to be registered to multiple modules](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e575e64ebd26092a6bb005d837023e35877e9308)
74
+ * [Make relative IRIs make use of importPaths-based URLs if possible](https://github.com/LinkedSoftwareDependencies/Components.js/commit/6a2e18c3bf6a1b95f826b66ee0ef8b154f10c3cc)
75
+
76
+ ### Fixed
77
+ * [Fix raw JSON values not being serializable to strings](https://github.com/LinkedSoftwareDependencies/Components.js/commit/96fe46eda1e153e87b29689196506ce6fbbdae58)
78
+
79
+ <a name="v4.5.0"></a>
80
+ ## [v4.5.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.4.1...v4.5.0) - 2021-08-30
81
+
82
+ ### Changed
83
+ * [Migrate to @rdfjs/types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b2f9f2e0c5512e743b324f48f332d96e4214ec84)
84
+
85
+ <a name="v4.4.1"></a>
86
+ ## [v4.4.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.4.0...v4.4.1) - 2021-07-26
87
+
88
+ ### Fixed
89
+ * [Fix RDF lists not being accepted for all params](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a01e3c80a3a5ce28180f57e8358327c53774b9ba)
90
+
91
+ <a name="v4.4.0"></a>
92
+ ## [v4.4.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.2.1...v4.4.0) - 2021-06-30
93
+
94
+ ### Added
95
+ * [Accept RDF lists as argument values, #47](https://github.com/LinkedSoftwareDependencies/Components.js/commit/3501a0fe676d1bc43c2d3ad329fca0adef48c8cd)
96
+
97
+ ### Changed
98
+ * [Allow arrays of resources to be passed to ErrorResourcesContext](https://github.com/LinkedSoftwareDependencies/Components.js/commit/aedd53a3e923e030bf0d8433c27f1259183a0a14)
99
+
100
+ <a name="v4.3.0"></a>
101
+ ## [v4.3.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.2.1...v4.3.0) - 2021-06-14
102
+
103
+ ### Added
104
+ * [Support JSON param ranges via rdf:JSON, Closes #37](https://github.com/LinkedSoftwareDependencies/Components.js/commit/339d2219915bc618991a42adcd8b63a3d6caa9b5)
105
+
106
+ <a name="v4.2.1"></a>
107
+ ## [v4.2.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.2.0...v4.2.1) - 2021-05-26
108
+
109
+ ### Fixed
110
+ * [Allow configs to have multiple identical types, comunica/examples#11](https://github.com/LinkedSoftwareDependencies/Components.js/commit/5285f8e68fefb13d46538c6949238200055a2047)
111
+
112
+ <a name="v4.2.0"></a>
113
+ ## [v4.2.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.1.0...v4.2.0) - 2021-05-19
114
+
115
+ ### Added
116
+ * [Expose RdfObjectLoader ctor from ComponentsManagerBuilder](https://github.com/LinkedSoftwareDependencies/Components.js/commit/1b1c85adb50855eed5b628788ccea3609aa841ca)
117
+
118
+ <a name="v4.1.0"></a>
119
+ ## [v4.1.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.6...v4.1.0) - 2021-04-27
120
+
121
+ ### Added
122
+ * [Allow JSON-LD context validation to be skipped](https://github.com/LinkedSoftwareDependencies/Components.js/commit/40931625dc0a577800c60e0cb4aa12393eb26bab)
123
+
124
+ <a name="v4.0.6"></a>
125
+ ## [v4.0.6](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.5...v4.0.6) - 2021-01-27
126
+
127
+ ### Fixed
128
+ * [Fix undefined root constructor args missing instead of being undefined](https://github.com/LinkedSoftwareDependencies/Components.js/commit/de14c611122ddb031d2973d4e667efa5b13bdf45)
129
+
130
+ <a name="v4.0.5"></a>
131
+ ## [v4.0.5](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.4...v4.0.5) - 2021-01-18
132
+
133
+ ### Fixed
134
+ * [Allow module discovery in packages without package.json](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a0ac0cb47b2ed07ef7a88619133af15ba71f3577)
135
+
136
+ <a name="v4.0.4"></a>
137
+ ## [v4.0.4](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.3...v4.0.4) - 2021-01-15
138
+
139
+ ### Changed
140
+ * [Bump rdf-parse with updated components.js context URL](https://github.com/LinkedSoftwareDependencies/Components.js/commit/7525a027c683890f30f4e47402c89dcca7dd89d7)
141
+
142
+ <a name="v4.0.3"></a>
143
+ ## [v4.0.3](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.2...v4.0.3) - 2021-01-15
144
+
145
+ ### Fixed
146
+ * [Fix broken infinite recursion workaround, #31](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e9f2fdc78eca77f3070663c4dc360e93b1f4c0bb)
147
+
148
+ <a name="v4.0.2"></a>
149
+ ## [v4.0.2](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.1...v4.0.2) - 2021-01-15
150
+
151
+ ### Fixed
152
+ * [Fix instances being created multiple times, Closes #31](https://github.com/LinkedSoftwareDependencies/Components.js/commit/94ce08874b24bf9c64d7f722beb2d5556aa9c7e9)
153
+ * [Fix value inheritance happening multiple times](https://github.com/LinkedSoftwareDependencies/Components.js/commit/1855178930d2babd2c3a4c6cdad66087c1db79cd)
154
+
155
+ <a name="v4.0.1"></a>
156
+ ## [v4.0.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.0...v4.0.1) - 2021-01-14
157
+
158
+ ### Fixed
159
+ * [Fix module resolution failure when outside main module](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2fb4de8abda5d5e91d39942edcc0bafd29acd8ce)
160
+
161
+ <a name="v4.0.0"></a>
162
+ ## [v4.0.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.6.0...v4.0.0) - 2021-01-14
163
+
164
+ This release contains breaking changes in the programmatic API,
165
+ but module and configuration files remain backwards-compatible.
166
+
167
+ ### Added
168
+ * Developer convenience
169
+ * [Allow `lsd:module` to be set to true in package.json](https://github.com/LinkedSoftwareDependencies/Components.js/commit/afeac8ab11e801376d265d3e42b5df7e113bfce4)
170
+ * [Emit warning when a remote context lookup is being done](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0f3968c26ff5c3d38e3cc8282c6039ff1221b4fd)
171
+ * [Emit warning on potentially invalid parameters in config](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a3ebb95a8d0e18ad062269c47b65cc2d9d1b603a)
172
+ * [Emit warning on potentially invalid IRIs](https://github.com/LinkedSoftwareDependencies/Components.js/commit/18f9f974965d049fd3808ae3a725a36bf264183b)
173
+ * [Generate componentsjs-error-state.json on error](https://github.com/LinkedSoftwareDependencies/Components.js/commit/bd47b17ba3fe82b2486e86bc678d950a9c478d18)
174
+ * [Validate multiple key-value occurences in collectEntries](https://github.com/LinkedSoftwareDependencies/Components.js/commit/ab88b14aa5f2c0c18b34668d6ca1aed8d611de11)
175
+ * [Improve printing of Resources in error reporting](https://github.com/LinkedSoftwareDependencies/Components.js/commit/48d2df7196a1e80e1bb55ac5c6518394b0942d4d)
176
+ * [Rewrite injection of custom JSON-LD document loader](https://github.com/LinkedSoftwareDependencies/Components.js/commit/98ae62f9ddb6589a8651f3a4b9bac6b2bb6642b4)
177
+ * [Migrate RDF loading logic to rdf-object](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e5eb9d27e04a4a333487d5805ce5b0d17cd578a7)
178
+
179
+ ### Changed
180
+ * [Use rdfs:seeAlso instead of owl:imports for importing](https://github.com/LinkedSoftwareDependencies/Components.js/commit/4e4227cca2c588e008259440e211af90e6756949)
181
+ * [Handle semver on multiple occurrences of module packages](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c8b2e3377d397179505064e43c4408e19447df6f)
182
+ * [Improve performance of module state loading through parallelization](https://github.com/LinkedSoftwareDependencies/Components.js/commit/4c475b0ee4d7fae31a818dc72fe28223827fd1f1)
183
+ * Refactoring
184
+ * [Accept loading from RDF/JS streams, Closes #1](https://github.com/LinkedSoftwareDependencies/Components.js/commit/749a7e7b5166414f68b5aabd285e5fd747b4dac4)
185
+ * [Add logger](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a5497590d3dabf06c00831f53d95da1554305b10)
186
+ * [Split up Loader into ComponentsManager and loading classes](https://github.com/LinkedSoftwareDependencies/Components.js/commit/687b15c61ea8766b49dadf132fd38b0151f7f6ac)
187
+ * [Split parameter property handling into seperate handlers](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e60a2a8bddc8a89b834cc21db51964bb2f8c3a93)
188
+ * [Create dedicated ParameterHandler component](https://github.com/LinkedSoftwareDependencies/Components.js/commit/408d299f77bc172e61a46d7dfbc4a6c931cecff6)
189
+ * [Reorganize relevant classes into construction package](https://github.com/LinkedSoftwareDependencies/Components.js/commit/aa6b56328fd4442886a82fcad187bd7380c05f27)
190
+ * [Split arguments creation into separate handlers](https://github.com/LinkedSoftwareDependencies/Components.js/commit/f3e995bd603369fb6e21d9be041ce96bec3b475b)
191
+ * [Split constructor args handling into separate handlers](https://github.com/LinkedSoftwareDependencies/Components.js/commit/33f678c5e5df96277243feca893d46882ebdd927)
192
+ * [Refactor component factories as config preprocessors](https://github.com/LinkedSoftwareDependencies/Components.js/commit/181b165f929cfcab206bc6d5ba22032f76d723c8)
193
+ * [Remove Util.PREFIXES in favour if Iris](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0c0c671b18bd8fe2161d56fd39ee8645adc12c63)
194
+ * [Decouple CommonJS instantiation and serialization into strategies](https://github.com/LinkedSoftwareDependencies/Components.js/commit/4756e0ce2f52711d7eb6df7afcc1011da210dbf0)
195
+ * [Decouple instantiation logic from Loader class](https://github.com/LinkedSoftwareDependencies/Components.js/commit/02dd0e64e37c9961be68beba09f03a3b52d0c00f)
196
+ * [Rewrite RdfStreamIncluder as Transform stream](https://github.com/LinkedSoftwareDependencies/Components.js/commit/edf6c61b28f06d2539bcdc8498f10586272a2632)
197
+ * [Delay module registration until finalization phase](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0de3b7940277fd207d7729da4921e62063434e20)
198
+ * [Refactor module loading into ModuleStateBuilder](https://github.com/LinkedSoftwareDependencies/Components.js/commit/6e6e54b498efb3e922466ef9868995926cd20ca8)
199
+
200
+ ### Removed
201
+ * [Remove feature to use global modules](https://github.com/LinkedSoftwareDependencies/Components.js/commit/fc0f943ac7e1cda4f84b3a65e2ad05ad1c7c42dc)
202
+
203
+ ### Fixed
204
+ * [Fix config compilation using wrong file path](https://github.com/LinkedSoftwareDependencies/Components.js/commit/fd3f806fe9cbb4f74a433e2a31212b5acdddf056)
205
+ * [Fix mapped components only keeping first element of root arrays](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0d33a9d88d473f930ce60c80949d13f5679b0df0)
206
+
207
+ <a name="v3.6.1"></a>
208
+ ## [v3.6.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.6.0...v3.6.1) - 2020-11-25
209
+
210
+ ### Fixed
211
+ * [Fix Array checks.](https://github.com/LinkedSoftwareDependencies/Components.js/commit/fdd48f6910ce395c72607992056f724953729f32)
212
+ * [Fix function check.](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b685468cfc9de39c74207a1f79cc9efae2bffa4e)
213
+
214
+ <a name="v3.6.0"></a>
215
+ ## [v3.6.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.5.0...v3.6.0) - 2020-09-14
216
+
217
+ ### Added
218
+ * [Supporting variables in config compilation](https://github.com/LinkedSoftwareDependencies/Components.js/commit/5eb5def9d77b7755d9e121b07c9d23676684a5f1)
219
+
220
+ <a name="v3.5.0"></a>
221
+ ## [v3.5.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.4.2...v3.5.0) - 2020-09-11
222
+
223
+ ### Added
224
+ * [Accept variables as parameter values, that can be set at init](https://github.com/LinkedSoftwareDependencies/Components.js/commit/cbd6f115cabf2bfcdcc8466f434d5cf52a4c23d5)
225
+
226
+ <a name="v3.4.2"></a>
227
+ ## [v3.4.2](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.4.1...v3.4.2) - 2020-08-27
228
+
229
+ ### Fixed
230
+ * [Fix empty list class loading failure](https://github.com/LinkedSoftwareDependencies/Components.js/commit/3590171287d2d765417469ea85012b651c88064b)
231
+
232
+ <a name="v3.4.1"></a>
233
+ ## [v3.4.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.4.0...v3.4.1) - 2020-07-01
234
+
235
+ ### Changed
236
+ * [Make types proper dependencies](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d50005517d606798de130a6cb2a4a4456683574c)
237
+
238
+ <a name="v3.4.0"></a>
239
+ ## [v3.4.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.3.0...v3.4.0) - 2020-04-06
240
+
241
+ ### Added
242
+ * [Add requireNoConstructor option for raw requireElements](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2d3144b8baad1464d590b691da10b752f7b83342)
243
+
244
+ ### Fixed
245
+ * [Fix incorrect error message for invalid dynamic entries](https://github.com/LinkedSoftwareDependencies/Components.js/commit/91b3a543973c06e3a0f3b6f667cc04a49e499103)
246
+
247
+ <a name="v3.3.0"></a>
248
+ ## [v3.3.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.2.1...v3.3.0) - 2019-10-21
249
+
250
+ ### Added
251
+ * [Allow requireName to be a relative path inside the module](https://github.com/LinkedSoftwareDependencies/Components.js/commit/562470dfbe6d3b1ab50e1202d8319adfafda024c)
252
+
253
+ ### Changed
254
+ * [Return error code on failure to compile](https://github.com/LinkedSoftwareDependencies/Components.js/commit/06aa3420911a41963a97586cabbf34ae477084b1)
255
+
256
+ <a name="v3.2.1"></a>
257
+ ## [v3.2.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.2.0...v3.2.1) - 2019-02-21
258
+
259
+ ### Fixed
260
+ * [Fix issues where context and component files would conflict](https://github.com/LinkedSoftwareDependencies/Components.js/commit/9e4812b23f6bc70099672172d480fc4855775622)
261
+ * [Fix incorrect comment context entry](https://github.com/LinkedSoftwareDependencies/Components.js/commit/21873b34a0dfc366f02ee1ad7dbd580795254ba5)
262
+
263
+ <a name="v3.2.0"></a>
264
+ ## [v3.2.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/2.0.0...v3.2.0) - 2018-11-13
265
+
266
+ ### Changed
267
+ * [Prioritize main modules when instantiating](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c97f104d101f8dac96b501def69698615f58385b)
268
+
269
+ <a name="v3.1.0"></a>
270
+ ## [v3.1.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/2.0.0...v3.1.0) - 2018-11-13
271
+
272
+ _Start tracking of changelog_
package/README.md CHANGED
@@ -202,6 +202,22 @@ const myInstance = await manager.instantiate('http://example.org/myInstance');
202
202
  [RDF]: https://www.w3.org/RDF/
203
203
  [JSON-LD]: https://json-ld.org/
204
204
 
205
+ ## Cite
206
+
207
+ If you are using or extending Components.js as part of a scientific publication,
208
+ we would appreciate a citation of our [article](https://linkedsoftwaredependencies.github.io/Article-System-Components/).
209
+
210
+ ```bibtex
211
+ @article{taelman_swj_componentsjs_2022,
212
+ author = {Taelman, Ruben and Van Herwegen, Joachim and Vander Sande, Miel and Verborgh, Ruben},
213
+ title = {Components.js: Semantic Dependency Injection},
214
+ journal = {Semantic Web Journal},
215
+ year = {2022},
216
+ month = jan,
217
+ url = {https://linkedsoftwaredependencies.github.io/Article-System-Components/}
218
+ }
219
+ ```
220
+
205
221
  ## License
206
222
  Components.js is written by [Ruben Taelman](http://www.rubensworks.net/).
207
223
 
@@ -2,6 +2,9 @@
2
2
  "@context": {
3
3
  "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
4
4
  "xsd": "http://www.w3.org/2001/XMLSchema#",
5
+ "type": {
6
+ "@id": "rdf:type"
7
+ },
5
8
  "types": {
6
9
  "@id": "rdf:type"
7
10
  },
@@ -22,9 +25,22 @@
22
25
  "components": {
23
26
  "@id": "oo:component"
24
27
  },
28
+ "component": {
29
+ "@id": "oo:component",
30
+ "@type": "@id"
31
+ },
25
32
  "parameters": {
26
33
  "@id": "oo:parameter"
27
34
  },
35
+ "memberFields": {
36
+ "@id": "oo:memberFields"
37
+ },
38
+ "memberFieldName": {
39
+ "@id": "oo:memberFieldName"
40
+ },
41
+ "genericTypeParameters": {
42
+ "@id": "oo:genericTypeParameter"
43
+ },
28
44
  "constructorArguments": {
29
45
  "@id": "oo:constructorArguments",
30
46
  "@container": "@list"
@@ -67,9 +83,18 @@
67
83
  "ParameterRangeUndefined": {
68
84
  "@id": "oo:ParameterRangeUndefined"
69
85
  },
86
+ "ParameterRangeWildcard": {
87
+ "@id": "oo:ParameterRangeWildcard"
88
+ },
70
89
  "ParameterRangeArray": {
71
90
  "@id": "oo:ParameterRangeArray"
72
91
  },
92
+ "ParameterRangeRest": {
93
+ "@id": "oo:ParameterRangeRest"
94
+ },
95
+ "ParameterRangeKeyof": {
96
+ "@id": "oo:ParameterRangeKeyof"
97
+ },
73
98
  "ParameterRangeLiteral": {
74
99
  "@id": "oo:ParameterRangeLiteral"
75
100
  },
@@ -94,7 +119,43 @@
94
119
  "@id": "oo:ParameterRangeCollectEntries"
95
120
  },
96
121
  "parameterRangeCollectEntriesParameters": {
97
- "@id": "oo:parameterRangeCollectEntriesParameters",
122
+ "@id": "oo:parameterRangeCollectEntriesParameter",
123
+ "@type": "@id"
124
+ },
125
+ "ParameterRangeGenericComponent": {
126
+ "@id": "oo:ParameterRangeGenericComponent"
127
+ },
128
+ "genericTypeInstancesComponentScope": {
129
+ "@id": "oo:genericTypeInstancesComponentScope",
130
+ "@type": "@id"
131
+ },
132
+ "genericTypeInstances": {
133
+ "@id": "oo:genericTypeInstance",
134
+ "@type": "@id"
135
+ },
136
+ "ParameterRangeGenericTypeReference": {
137
+ "@id": "oo:ParameterRangeGenericTypeReference"
138
+ },
139
+ "parameterRangeGenericType": {
140
+ "@id": "oo:parameterRangeGenericType",
141
+ "@type": "@id"
142
+ },
143
+ "parameterRangeGenericBindings": {
144
+ "@id": "oo:parameterRangeGenericBindings",
145
+ "@type": "@id"
146
+ },
147
+ "GenericComponentExtension": {
148
+ "@id": "oo:GenericComponentExtension"
149
+ },
150
+ "ParameterRangeIndexed": {
151
+ "@id": "oo:ParameterRangeIndexed"
152
+ },
153
+ "parameterRangeIndexedObject": {
154
+ "@id": "oo:parameterRangeIndexedObject",
155
+ "@type": "@id"
156
+ },
157
+ "parameterRangeIndexedIndex": {
158
+ "@id": "oo:parameterRangeIndexedIndex",
98
159
  "@type": "@id"
99
160
  },
100
161
 
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentsManager = void 0;
4
4
  const fs = require("fs");
5
5
  const ComponentsManagerBuilder_1 = require("./loading/ComponentsManagerBuilder");
6
+ const ErrorResourcesContext_1 = require("./util/ErrorResourcesContext");
6
7
  /**
7
8
  * A components manager can instantiate components.
8
9
  * This manager should be created using {@link ComponentsManager.build}.
@@ -51,17 +52,14 @@ class ComponentsManager {
51
52
  */
52
53
  generateErrorLog(error) {
53
54
  if (this.dumpErrorState) {
54
- const contents = JSON.stringify({
55
- componentTypes: Object.keys(this.componentResources),
56
- moduleState: {
55
+ const contents = JSON.stringify(Object.assign(Object.assign({}, error instanceof ErrorResourcesContext_1.ErrorResourcesContext ? error.exportContext() : {}), { componentTypes: Object.keys(this.componentResources), moduleState: {
57
56
  mainModulePath: this.moduleState.mainModulePath,
58
57
  componentModules: this.moduleState.componentModules,
59
58
  importPaths: this.moduleState.importPaths,
60
59
  contexts: this.moduleState.contexts,
61
60
  nodeModuleImportPaths: this.moduleState.nodeModuleImportPaths,
62
61
  nodeModulePaths: this.moduleState.nodeModulePaths,
63
- },
64
- }, null, ' ');
62
+ } }), null, ' ');
65
63
  fs.writeFileSync('componentsjs-error-state.json', contents, 'utf8');
66
64
  this.logger.error(`Detected fatal error. Generated 'componentsjs-error-state.json' with more information.`);
67
65
  }
@@ -16,7 +16,9 @@ export declare class ConstructionStrategyCommonJs implements IConstructionStrate
16
16
  * @param requireName The module name that should be required.
17
17
  * @returns {any} The require() result
18
18
  */
19
- requireCurrentRunningModuleIfCurrent(moduleState: IModuleState, requireName: string): void;
19
+ requireCurrentRunningModuleIfCurrent(moduleState: IModuleState, requireName: string): {
20
+ value: any;
21
+ } | false;
20
22
  createHash(options: ICreationStrategyHashOptions<any>): any;
21
23
  createArray(options: ICreationStrategyArrayOptions<any>): any;
22
24
  createLazySupplier(options: ICreationStrategySupplierOptions<any>): Promise<any>;
@@ -14,16 +14,14 @@ class ConstructionStrategyCommonJs {
14
14
  createInstance(options) {
15
15
  // Call require()
16
16
  options.requireName = this.overrideRequireNames[options.requireName] || options.requireName;
17
+ // First try requiring current module, and fallback to a plain require
17
18
  let object;
18
- try {
19
- object = this.requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
20
- }
21
- catch (_a) {
22
- // Always require relative from main module, because Components.js will in most cases just be dependency.
23
- object = this.req(options.requireName.startsWith('.') ?
19
+ const currentResult = this.requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
20
+ object = currentResult !== false ?
21
+ currentResult.value :
22
+ this.req(options.requireName.startsWith('.') ?
24
23
  Path.join(process.cwd(), options.requireName) :
25
24
  this.req.resolve(options.requireName, { paths: [options.moduleState.mainModulePath] }));
26
- }
27
25
  // Determine the child of the require'd element
28
26
  let subObject;
29
27
  if (options.requireElement) {
@@ -31,7 +29,7 @@ class ConstructionStrategyCommonJs {
31
29
  try {
32
30
  subObject = requireElementPath.reduce((acc, subRequireElement) => acc[subRequireElement], object);
33
31
  }
34
- catch (_b) {
32
+ catch (_a) {
35
33
  throw new Error(`Failed to get module element ${options.requireElement} from module ${options.requireName}`);
36
34
  }
37
35
  }
@@ -65,11 +63,11 @@ class ConstructionStrategyCommonJs {
65
63
  const mainPath = Path.posix.join(moduleState.mainModulePath, pckg.main);
66
64
  const required = this.req(mainPath);
67
65
  if (required) {
68
- return required;
66
+ return { value: required };
69
67
  }
70
68
  }
71
69
  }
72
- throw new Error('Component is not the main module');
70
+ return false;
73
71
  }
74
72
  createHash(options) {
75
73
  return options.entries.reduce((data, entry) => {
@@ -30,14 +30,12 @@ class ConstructionStrategyCommonJsString {
30
30
  createInstance(options) {
31
31
  // Call require()
32
32
  options.requireName = this.overrideRequireNames[options.requireName] || options.requireName;
33
- let resultingRequirePath;
34
- try {
35
- this.strategyCommonJs.requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
36
- resultingRequirePath = `.${Path.sep}${Path.relative(options.moduleState.mainModulePath, this.getCurrentRunningModuleMain(options.moduleState))}`;
37
- }
38
- catch (_a) {
39
- resultingRequirePath = options.requireName;
40
- }
33
+ // First try requiring current module, and fallback to a plain require
34
+ const currentResult = this.strategyCommonJs
35
+ .requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
36
+ const resultingRequirePath = currentResult !== false ?
37
+ `.${Path.sep}${Path.relative(options.moduleState.mainModulePath, this.getCurrentRunningModuleMain(options.moduleState))}` :
38
+ options.requireName;
41
39
  let serialization = `require('${resultingRequirePath.replace(/\\/gu, '/')}')`;
42
40
  // Determine the child of the require'd element
43
41
  if (options.requireElement) {
@@ -41,7 +41,13 @@ class ComponentRegistryFinalizer {
41
41
  * @param superComponents The components to inherit from.
42
42
  */
43
43
  inheritParameters(component, superComponents) {
44
- for (const superComponent of superComponents) {
44
+ var _a;
45
+ for (let superComponent of superComponents) {
46
+ // Check if the super component is wrapped in a generic component instantiation
47
+ if (((_a = superComponent.property.type) === null || _a === void 0 ? void 0 : _a.value) === this.objectLoader.contextResolved
48
+ .expandTerm('oo:GenericComponentExtension')) {
49
+ superComponent = superComponent.property.component;
50
+ }
45
51
  this.componentRegistry.requireValidComponent(superComponent, component);
46
52
  for (const parameter of superComponent.properties.parameters) {
47
53
  if (!component.properties.parameters.includes(parameter)) {
@@ -1,5 +1,6 @@
1
1
  import type { Resource, RdfObjectLoader } from 'rdf-object';
2
2
  import type { Logger } from 'winston';
3
+ import { GenericsContext } from './GenericsContext';
3
4
  import type { IConfigPreprocessor } from './IConfigPreprocessor';
4
5
  import type { ParameterHandler } from './ParameterHandler';
5
6
  /**
@@ -15,6 +16,7 @@ export declare class ConfigPreprocessorComponent implements IConfigPreprocessor<
15
16
  constructor(options: IComponentConfigPreprocessorOptions);
16
17
  canHandle(config: Resource): IComponentConfigPreprocessorHandleResponse | undefined;
17
18
  transform(config: Resource, handleResponse: IComponentConfigPreprocessorHandleResponse): Resource;
19
+ protected createGenericsContext(handleResponse: IComponentConfigPreprocessorHandleResponse, config: Resource): GenericsContext;
18
20
  /**
19
21
  * Determine the constructor arguments of the given config.
20
22
  * @param config A config.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigPreprocessorComponent = void 0;
4
4
  const Iris_1 = require("../rdf/Iris");
5
5
  const ErrorResourcesContext_1 = require("../util/ErrorResourcesContext");
6
+ const GenericsContext_1 = require("./GenericsContext");
6
7
  /**
7
8
  * Handles config that refer to a component as type.
8
9
  * The component may have parameters that can be applied on the config.
@@ -87,6 +88,20 @@ class ConfigPreprocessorComponent {
87
88
  this.validateConfig(config, handleResponse);
88
89
  return configRaw;
89
90
  }
91
+ createGenericsContext(handleResponse, config) {
92
+ // Create a new generics context for the component's generic type parameters
93
+ const genericsContext = new GenericsContext_1.GenericsContext(this.objectLoader, handleResponse.component.properties.genericTypeParameters);
94
+ // If the config has a genericTypeInstancesComponentScope, it will also have genericTypeInstances.
95
+ // In that case, we bind these instances to the component's generic type parameters within the context.
96
+ // (these values may have been set during generic param type-checking in
97
+ // ParameterPropertyHandlerRange#hasParamValueValidType)
98
+ if (config.property.genericTypeInstancesComponentScope &&
99
+ handleResponse.component.value === config.property.genericTypeInstancesComponentScope.value) {
100
+ genericsContext.bindComponentGenericTypes(handleResponse.component, config.properties.genericTypeInstances, { config }, (subType, superType) => this.parameterHandler.parameterPropertyHandlerRange
101
+ .hasType(subType, superType, genericsContext, config.property.genericTypeInstancesComponentScope, config.properties.genericTypeInstances, { config }));
102
+ }
103
+ return genericsContext;
104
+ }
90
105
  /**
91
106
  * Determine the constructor arguments of the given config.
92
107
  * @param config A config.
@@ -94,10 +109,12 @@ class ConfigPreprocessorComponent {
94
109
  */
95
110
  transformConstructorArguments(config, handleResponse) {
96
111
  const entries = [];
112
+ const genericsContext = this.createGenericsContext(handleResponse, config);
97
113
  for (const fieldData of handleResponse.component.properties.parameters) {
98
114
  const field = this.objectLoader.createCompactedResource({});
99
115
  field.property.key = this.objectLoader.createCompactedResource(`"${fieldData.term.value}"`);
100
- const value = this.parameterHandler.applyParameterValues(handleResponse.component, fieldData, config);
116
+ const value = this.parameterHandler
117
+ .applyParameterValues(handleResponse.component, fieldData, config, genericsContext);
101
118
  if (value) {
102
119
  field.property.value = value;
103
120
  }
@@ -2,6 +2,7 @@ import type { Resource } from 'rdf-object';
2
2
  import type { IComponentConfigPreprocessorHandleResponse } from './ConfigPreprocessorComponent';
3
3
  import { ConfigPreprocessorComponent } from './ConfigPreprocessorComponent';
4
4
  import type { IConstructorArgumentsMapper } from './constructorargumentsmapping/IConstructorArgumentsMapper';
5
+ import type { GenericsContext } from './GenericsContext';
5
6
  /**
6
7
  * Handles config that refer to a component as type.
7
8
  * The component may have parameters that can be applied on the config.
@@ -11,6 +12,6 @@ export declare class ConfigPreprocessorComponentMapped extends ConfigPreprocesso
11
12
  private readonly mappingHandlers;
12
13
  canHandle(config: Resource): IComponentConfigPreprocessorHandleResponse | undefined;
13
14
  transformConstructorArguments(config: Resource, handleResponse: IComponentConfigPreprocessorHandleResponse): Resource;
14
- applyConstructorArgumentsParameters(configRoot: Resource, constructorArgs: Resource, configElement: Resource): Resource;
15
- getParameterValue(configRoot: Resource, parameter: Resource, configElement: Resource, rawValue: boolean): Resource | undefined;
15
+ applyConstructorArgumentsParameters(configRoot: Resource, constructorArgs: Resource, configElement: Resource, genericsContext: GenericsContext): Resource;
16
+ getParameterValue(configRoot: Resource, parameter: Resource, configElement: Resource, rawValue: boolean, genericsContext: GenericsContext): Resource | undefined;
16
17
  }
@@ -33,28 +33,30 @@ class ConfigPreprocessorComponentMapped extends ConfigPreprocessorComponent_1.Co
33
33
  }
34
34
  transformConstructorArguments(config, handleResponse) {
35
35
  const constructorArgs = handleResponse.component.property.constructorArguments;
36
- return this.applyConstructorArgumentsParameters(config, constructorArgs, config);
36
+ const genericsContext = this.createGenericsContext(handleResponse, config);
37
+ return this.applyConstructorArgumentsParameters(config, constructorArgs, config, genericsContext);
37
38
  }
38
- applyConstructorArgumentsParameters(configRoot, constructorArgs, configElement) {
39
+ applyConstructorArgumentsParameters(configRoot, constructorArgs, configElement, genericsContext) {
39
40
  // Check if this constructor args resource can be handled by one of the built-in handlers.
40
41
  for (const handler of this.mappingHandlers) {
41
- if (handler.canHandle(configRoot, constructorArgs, configElement, this)) {
42
- return handler.handle(configRoot, constructorArgs, configElement, this);
42
+ if (handler.canHandle(configRoot, constructorArgs, configElement, this, genericsContext)) {
43
+ return handler.handle(configRoot, constructorArgs, configElement, this, genericsContext);
43
44
  }
44
45
  }
45
46
  // Fallback to original constructor args
46
47
  return constructorArgs;
47
48
  }
48
- getParameterValue(configRoot, parameter, configElement, rawValue) {
49
+ getParameterValue(configRoot, parameter, configElement, rawValue, genericsContext) {
49
50
  let valueOut;
50
51
  if (parameter.type === 'NamedNode' && parameter.value === Iris_1.IRIS_RDF.subject) {
51
52
  valueOut = this.objectLoader.createCompactedResource(`"${configElement.value}"`);
52
53
  }
53
54
  else if (parameter.type === 'NamedNode' && !parameter.property.fields) {
54
- valueOut = this.parameterHandler.applyParameterValues(configRoot, parameter, configElement);
55
+ valueOut = this.parameterHandler
56
+ .applyParameterValues(configRoot, parameter, configElement, genericsContext);
55
57
  }
56
58
  else {
57
- valueOut = this.applyConstructorArgumentsParameters(configRoot, parameter, configElement);
59
+ valueOut = this.applyConstructorArgumentsParameters(configRoot, parameter, configElement, genericsContext);
58
60
  }
59
61
  // If the referenced IRI should become a plain string
60
62
  if (rawValue) {