@startinblox/core 0.17.21-beta.9 → 0.17.22

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 (260) hide show
  1. package/package.json +2 -2
  2. package/dist/_snowpack/env.js +0 -3
  3. package/dist/_snowpack/pkg/autolinker.js +0 -4281
  4. package/dist/_snowpack/pkg/autolinker.js.map +0 -1
  5. package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
  6. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js +0 -377
  7. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map +0 -1
  8. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
  9. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js +0 -22
  10. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +0 -1
  11. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +0 -1
  12. package/dist/_snowpack/pkg/common/decode-a4c334cf.js +0 -216
  13. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +0 -1
  14. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +0 -1
  15. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +0 -1119
  16. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +0 -1
  17. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +0 -1
  18. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -25677
  19. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
  20. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
  21. package/dist/_snowpack/pkg/dialog-polyfill.js +0 -859
  22. package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
  23. package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
  24. package/dist/_snowpack/pkg/fusejs.js +0 -1783
  25. package/dist/_snowpack/pkg/fusejs.js.map +0 -1
  26. package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
  27. package/dist/_snowpack/pkg/import-map.json +0 -23
  28. package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -804
  29. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
  30. package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
  31. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +0 -640
  32. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
  33. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +0 -60
  34. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  35. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +0 -14
  36. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  37. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -40
  38. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  39. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
  40. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -46
  41. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  42. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
  43. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -88
  44. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  45. package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
  46. package/dist/_snowpack/pkg/lit-html.js +0 -92
  47. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  48. package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
  49. package/dist/_snowpack/pkg/markdown-it.js +0 -11860
  50. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  51. package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
  52. package/dist/_snowpack/pkg/quill/dist/quill.snow.css +0 -945
  53. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  54. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -1029
  55. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  56. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
  57. package/dist/_snowpack/pkg/quill.js +0 -13382
  58. package/dist/_snowpack/pkg/quill.js.map +0 -1
  59. package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
  60. package/dist/_snowpack/pkg/slim-select.js +0 -4
  61. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  62. package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
  63. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1164
  64. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  65. package/dist/_snowpack/pkg/tui-calendar.js +0 -42285
  66. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  67. package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
  68. package/dist/components/solid-ac-checker.js +0 -51
  69. package/dist/components/solid-ac-checker.js.map +0 -1
  70. package/dist/components/solid-calendar.js +0 -87
  71. package/dist/components/solid-calendar.js.map +0 -1
  72. package/dist/components/solid-delete.js +0 -111
  73. package/dist/components/solid-delete.js.map +0 -1
  74. package/dist/components/solid-display.js +0 -194
  75. package/dist/components/solid-display.js.map +0 -1
  76. package/dist/components/solid-form-search.js +0 -226
  77. package/dist/components/solid-form-search.js.map +0 -1
  78. package/dist/components/solid-form.js +0 -354
  79. package/dist/components/solid-form.js.map +0 -1
  80. package/dist/components/solid-lang.js +0 -46
  81. package/dist/components/solid-lang.js.map +0 -1
  82. package/dist/components/solid-map.js +0 -242
  83. package/dist/components/solid-map.js.map +0 -1
  84. package/dist/components/solid-table.js +0 -263
  85. package/dist/components/solid-table.js.map +0 -1
  86. package/dist/components/solid-widget.js +0 -94
  87. package/dist/components/solid-widget.js.map +0 -1
  88. package/dist/import.css +0 -4
  89. package/dist/index.js +0 -43
  90. package/dist/index.js.map +0 -1
  91. package/dist/libs/Component.js +0 -19
  92. package/dist/libs/Component.js.map +0 -1
  93. package/dist/libs/ComponentFactory.js +0 -196
  94. package/dist/libs/ComponentFactory.js.map +0 -1
  95. package/dist/libs/Compositor.js +0 -103
  96. package/dist/libs/Compositor.js.map +0 -1
  97. package/dist/libs/Sib.js +0 -58
  98. package/dist/libs/Sib.js.map +0 -1
  99. package/dist/libs/filter.js +0 -214
  100. package/dist/libs/filter.js.map +0 -1
  101. package/dist/libs/helpers.js +0 -219
  102. package/dist/libs/helpers.js.map +0 -1
  103. package/dist/libs/interfaces.js +0 -6
  104. package/dist/libs/interfaces.js.map +0 -1
  105. package/dist/libs/lit-helpers.js +0 -169
  106. package/dist/libs/lit-helpers.js.map +0 -1
  107. package/dist/libs/polyfills.js +0 -40
  108. package/dist/libs/polyfills.js.map +0 -1
  109. package/dist/libs/store/store.js +0 -863
  110. package/dist/libs/store/store.js.map +0 -1
  111. package/dist/locales/en.json +0 -10
  112. package/dist/locales/en.json.proxy.js +0 -2
  113. package/dist/locales/fr.json +0 -10
  114. package/dist/locales/fr.json.proxy.js +0 -2
  115. package/dist/mixins/attributeBinderMixin.js +0 -124
  116. package/dist/mixins/attributeBinderMixin.js.map +0 -1
  117. package/dist/mixins/contextMixin.js +0 -28
  118. package/dist/mixins/contextMixin.js.map +0 -1
  119. package/dist/mixins/counterMixin.js +0 -75
  120. package/dist/mixins/counterMixin.js.map +0 -1
  121. package/dist/mixins/federationMixin.js +0 -63
  122. package/dist/mixins/federationMixin.js.map +0 -1
  123. package/dist/mixins/filterMixin.js +0 -136
  124. package/dist/mixins/filterMixin.js.map +0 -1
  125. package/dist/mixins/grouperMixin.js +0 -80
  126. package/dist/mixins/grouperMixin.js.map +0 -1
  127. package/dist/mixins/highlighterMixin.js +0 -42
  128. package/dist/mixins/highlighterMixin.js.map +0 -1
  129. package/dist/mixins/interfaces.js +0 -8
  130. package/dist/mixins/interfaces.js.map +0 -1
  131. package/dist/mixins/listMixin.js +0 -136
  132. package/dist/mixins/listMixin.js.map +0 -1
  133. package/dist/mixins/nextMixin.js +0 -26
  134. package/dist/mixins/nextMixin.js.map +0 -1
  135. package/dist/mixins/paginateMixin.js +0 -110
  136. package/dist/mixins/paginateMixin.js.map +0 -1
  137. package/dist/mixins/requiredMixin.js +0 -34
  138. package/dist/mixins/requiredMixin.js.map +0 -1
  139. package/dist/mixins/sorterMixin.js +0 -149
  140. package/dist/mixins/sorterMixin.js.map +0 -1
  141. package/dist/mixins/storeMixin.js +0 -102
  142. package/dist/mixins/storeMixin.js.map +0 -1
  143. package/dist/mixins/translationMixin.js +0 -68
  144. package/dist/mixins/translationMixin.js.map +0 -1
  145. package/dist/mixins/validationMixin.js +0 -113
  146. package/dist/mixins/validationMixin.js.map +0 -1
  147. package/dist/mixins/widgetMixin.js +0 -447
  148. package/dist/mixins/widgetMixin.js.map +0 -1
  149. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -14
  150. package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
  151. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -10
  152. package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
  153. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -10
  154. package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
  155. package/dist/new-widgets/attributeMixins/index.js +0 -20
  156. package/dist/new-widgets/attributeMixins/index.js.map +0 -1
  157. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -10
  158. package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
  159. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -28
  160. package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
  161. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -10
  162. package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
  163. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -19
  164. package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
  165. package/dist/new-widgets/attributeMixins/telMixin.js +0 -10
  166. package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
  167. package/dist/new-widgets/baseWidgetMixin.js +0 -122
  168. package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
  169. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -104
  170. package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
  171. package/dist/new-widgets/callbackMixins/index.js +0 -8
  172. package/dist/new-widgets/callbackMixins/index.js.map +0 -1
  173. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -42
  174. package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
  175. package/dist/new-widgets/callbackMixins/slimselect.css +0 -2
  176. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  177. package/dist/new-widgets/new-widget-factory.js +0 -96
  178. package/dist/new-widgets/new-widget-factory.js.map +0 -1
  179. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -41
  180. package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
  181. package/dist/new-widgets/templateAdditionMixins/index.js +0 -14
  182. package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
  183. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -29
  184. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
  185. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -31
  186. package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
  187. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -36
  188. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
  189. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -90
  190. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
  191. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -397
  192. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
  193. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -21
  194. package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
  195. package/dist/new-widgets/templates/index.js +0 -7
  196. package/dist/new-widgets/templates/index.js.map +0 -1
  197. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -49
  198. package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
  199. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -13
  200. package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
  201. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -77
  202. package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
  203. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -38
  204. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
  205. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -14
  206. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
  207. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -51
  208. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
  209. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -66
  210. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
  211. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -81
  212. package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
  213. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -19
  214. package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
  215. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -19
  216. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
  217. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -66
  218. package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
  219. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -14
  220. package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
  221. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -16
  222. package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
  223. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -13
  224. package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
  225. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -14
  226. package/dist/new-widgets/templatesDependencies/linkTextMixin.js.map +0 -1
  227. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -125
  228. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
  229. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
  230. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
  231. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -19
  232. package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
  233. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -110
  234. package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
  235. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -12
  236. package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
  237. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -12
  238. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
  239. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -18
  240. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
  241. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -35
  242. package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
  243. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -16
  244. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
  245. package/dist/new-widgets/valueTransformationMixins/index.js +0 -16
  246. package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
  247. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -25
  248. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
  249. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -17
  250. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
  251. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -27
  252. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
  253. package/dist/solid-template-element.js +0 -164
  254. package/dist/solid-template-element.js.map +0 -1
  255. package/dist/style/default-theme.css +0 -24
  256. package/dist/style/default-theme.css.proxy.js +0 -10
  257. package/dist/widgets/baseWidget.js +0 -332
  258. package/dist/widgets/baseWidget.js.map +0 -1
  259. package/dist/widgets/widget-factory.js +0 -24
  260. package/dist/widgets/widget-factory.js.map +0 -1
@@ -1,804 +0,0 @@
1
- import { c as createCommonjsModule, a as commonjsGlobal, g as getDefaultExportFromCjs } from './common/_commonjsHelpers-8c19dec8.js';
2
-
3
- // native patch for: node-fetch, whatwg-fetch
4
- // ref: https://github.com/tc39/proposal-global
5
- var getGlobal = function () {
6
- if (typeof self !== 'undefined') { return self; }
7
- if (typeof window !== 'undefined') { return window; }
8
- if (typeof global !== 'undefined') { return global; }
9
- throw new Error('unable to locate global object');
10
- };
11
- var global = getGlobal();
12
- global.fetch.bind(global);
13
- global.Headers;
14
- global.Request;
15
- global.Response;
16
-
17
- // the whatwg-fetch polyfill installs the fetch() function
18
- // on the global object (window or self)
19
- //
20
- // Return that as the export for use in Webpack, Browserify etc.
21
-
22
- self.fetch.bind(self);
23
-
24
- var Resolve = createCommonjsModule(function (module, exports) {
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- /**
27
- * Convert the given relative IRI to an absolute IRI
28
- * by taking into account the given optional baseIRI.
29
- *
30
- * @param {string} relativeIRI The relative IRI to convert to an absolute IRI.
31
- * @param {string} baseIRI The optional base IRI.
32
- * @return {string} an absolute IRI.
33
- */
34
- function resolve(relativeIRI, baseIRI) {
35
- baseIRI = baseIRI || '';
36
- const baseFragmentPos = baseIRI.indexOf('#');
37
- // Ignore any fragments in the base IRI
38
- if (baseFragmentPos > 0) {
39
- baseIRI = baseIRI.substr(0, baseFragmentPos);
40
- }
41
- // Convert empty value directly to base IRI
42
- if (!relativeIRI.length) {
43
- // At this point, the baseIRI MUST be absolute, otherwise we error
44
- if (baseIRI.indexOf(':') < 0) {
45
- throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`);
46
- }
47
- return baseIRI;
48
- }
49
- // If the value starts with a query character, concat directly (but strip the existing query)
50
- if (relativeIRI.startsWith('?')) {
51
- const baseQueryPos = baseIRI.indexOf('?');
52
- if (baseQueryPos > 0) {
53
- baseIRI = baseIRI.substr(0, baseQueryPos);
54
- }
55
- return baseIRI + relativeIRI;
56
- }
57
- // If the value starts with a fragment character, concat directly
58
- if (relativeIRI.startsWith('#')) {
59
- return baseIRI + relativeIRI;
60
- }
61
- // Ignore baseIRI if it is empty
62
- if (!baseIRI.length) {
63
- const relativeColonPos = relativeIRI.indexOf(':');
64
- if (relativeColonPos < 0) {
65
- throw new Error(`Found invalid relative IRI '${relativeIRI}' for a missing baseIRI`);
66
- }
67
- return removeDotSegmentsOfPath(relativeIRI, relativeColonPos);
68
- }
69
- // Ignore baseIRI if the value is absolute
70
- const valueColonPos = relativeIRI.indexOf(':');
71
- if (valueColonPos >= 0) {
72
- return removeDotSegmentsOfPath(relativeIRI, valueColonPos);
73
- }
74
- // At this point, the baseIRI MUST be absolute, otherwise we error
75
- const baseColonPos = baseIRI.indexOf(':');
76
- if (baseColonPos < 0) {
77
- throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`);
78
- }
79
- const baseIRIScheme = baseIRI.substr(0, baseColonPos + 1);
80
- // Inherit the baseIRI scheme if the value starts with '//'
81
- if (relativeIRI.indexOf('//') === 0) {
82
- return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
83
- }
84
- // Check cases where '://' occurs in the baseIRI, and where there is no '/' after a ':' anymore.
85
- let baseSlashAfterColonPos;
86
- if (baseIRI.indexOf('//', baseColonPos) === baseColonPos + 1) {
87
- // If there is no additional '/' after the '//'.
88
- baseSlashAfterColonPos = baseIRI.indexOf('/', baseColonPos + 3);
89
- if (baseSlashAfterColonPos < 0) {
90
- // If something other than a '/' follows the '://', append the value after a '/',
91
- // otherwise, prefix the value with only the baseIRI scheme.
92
- if (baseIRI.length > baseColonPos + 3) {
93
- return baseIRI + '/' + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
94
- }
95
- else {
96
- return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
97
- }
98
- }
99
- }
100
- else {
101
- // If there is not even a single '/' after the ':'
102
- baseSlashAfterColonPos = baseIRI.indexOf('/', baseColonPos + 1);
103
- if (baseSlashAfterColonPos < 0) {
104
- // If we don't have a '/' after the ':',
105
- // prefix the value with only the baseIRI scheme.
106
- return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
107
- }
108
- }
109
- // If the value starts with a '/', then prefix it with everything before the first effective slash of the base IRI.
110
- if (relativeIRI.indexOf('/') === 0) {
111
- return baseIRI.substr(0, baseSlashAfterColonPos) + removeDotSegments(relativeIRI);
112
- }
113
- let baseIRIPath = baseIRI.substr(baseSlashAfterColonPos);
114
- const baseIRILastSlashPos = baseIRIPath.lastIndexOf('/');
115
- // Ignore everything after the last '/' in the baseIRI path
116
- if (baseIRILastSlashPos >= 0 && baseIRILastSlashPos < baseIRIPath.length - 1) {
117
- baseIRIPath = baseIRIPath.substr(0, baseIRILastSlashPos + 1);
118
- // Also remove the first character of the relative path if it starts with '.' (and not '..' or './')
119
- // This change is only allowed if there is something else following the path
120
- if (relativeIRI[0] === '.' && relativeIRI[1] !== '.' && relativeIRI[1] !== '/' && relativeIRI[2]) {
121
- relativeIRI = relativeIRI.substr(1);
122
- }
123
- }
124
- // Prefix the value with the baseIRI path where
125
- relativeIRI = baseIRIPath + relativeIRI;
126
- // Remove dot segment from the IRI
127
- relativeIRI = removeDotSegments(relativeIRI);
128
- // Prefix our transformed value with the part of the baseIRI until the first '/' after the first ':'.
129
- return baseIRI.substr(0, baseSlashAfterColonPos) + relativeIRI;
130
- }
131
- exports.resolve = resolve;
132
- /**
133
- * Remove dot segments from the given path,
134
- * as described in https://www.ietf.org/rfc/rfc3986.txt (page 32).
135
- * @param {string} path An IRI path.
136
- * @return {string} A path, will always start with a '/'.
137
- */
138
- function removeDotSegments(path) {
139
- // Prepare a buffer with segments between each '/.
140
- // Each segment represents an array of characters.
141
- const segmentBuffers = [];
142
- let i = 0;
143
- while (i < path.length) {
144
- // Remove '/.' or '/..'
145
- switch (path[i]) {
146
- case '/':
147
- if (path[i + 1] === '.') {
148
- if (path[i + 2] === '.') {
149
- // Start a new segment if we find an invalid character after the '.'
150
- if (!isCharacterAllowedAfterRelativePathSegment(path[i + 3])) {
151
- segmentBuffers.push([]);
152
- i++;
153
- break;
154
- }
155
- // Go to parent directory,
156
- // so we remove a parent segment
157
- segmentBuffers.pop();
158
- // Ensure that we end with a slash if there is a trailing '/..'
159
- if (!path[i + 3]) {
160
- segmentBuffers.push([]);
161
- }
162
- i += 3;
163
- }
164
- else {
165
- // Start a new segment if we find an invalid character after the '.'
166
- if (!isCharacterAllowedAfterRelativePathSegment(path[i + 2])) {
167
- segmentBuffers.push([]);
168
- i++;
169
- break;
170
- }
171
- // Ensure that we end with a slash if there is a trailing '/.'
172
- if (!path[i + 2]) {
173
- segmentBuffers.push([]);
174
- }
175
- // Go to the current directory,
176
- // so we do nothing
177
- i += 2;
178
- }
179
- }
180
- else {
181
- // Start a new segment
182
- segmentBuffers.push([]);
183
- i++;
184
- }
185
- break;
186
- case '#':
187
- case '?':
188
- // Query and fragment string should be appended unchanged
189
- if (!segmentBuffers.length) {
190
- segmentBuffers.push([]);
191
- }
192
- segmentBuffers[segmentBuffers.length - 1].push(path.substr(i));
193
- // Break the while loop
194
- i = path.length;
195
- break;
196
- default:
197
- // Not a special character, just append it to our buffer
198
- if (!segmentBuffers.length) {
199
- segmentBuffers.push([]);
200
- }
201
- segmentBuffers[segmentBuffers.length - 1].push(path[i]);
202
- i++;
203
- break;
204
- }
205
- }
206
- return '/' + segmentBuffers.map((buffer) => buffer.join('')).join('/');
207
- }
208
- exports.removeDotSegments = removeDotSegments;
209
- /**
210
- * Removes dot segments of the given IRI.
211
- * @param {string} iri An IRI (or part of IRI).
212
- * @param {number} colonPosition The position of the first ':' in the IRI.
213
- * @return {string} The IRI where dot segments were removed.
214
- */
215
- function removeDotSegmentsOfPath(iri, colonPosition) {
216
- // Determine where we should start looking for the first '/' that indicates the start of the path
217
- let searchOffset = colonPosition + 1;
218
- if (colonPosition >= 0) {
219
- if (iri[colonPosition + 1] === '/' && iri[colonPosition + 2] === '/') {
220
- searchOffset = colonPosition + 3;
221
- }
222
- }
223
- else {
224
- if (iri[0] === '/' && iri[1] === '/') {
225
- searchOffset = 2;
226
- }
227
- }
228
- // Determine the path
229
- const pathSeparator = iri.indexOf('/', searchOffset);
230
- if (pathSeparator < 0) {
231
- return iri;
232
- }
233
- const base = iri.substr(0, pathSeparator);
234
- const path = iri.substr(pathSeparator);
235
- // Remove dot segments from the path
236
- return base + removeDotSegments(path);
237
- }
238
- exports.removeDotSegmentsOfPath = removeDotSegmentsOfPath;
239
- function isCharacterAllowedAfterRelativePathSegment(character) {
240
- return !character || character === '#' || character === '?' || character === '/';
241
- }
242
-
243
- });
244
-
245
- var relativeToAbsoluteIri = createCommonjsModule(function (module, exports) {
246
- function __export(m) {
247
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
248
- }
249
- Object.defineProperty(exports, "__esModule", { value: true });
250
- __export(Resolve);
251
-
252
- });
253
-
254
- var FetchDocumentLoader_1 = createCommonjsModule(function (module, exports) {
255
- var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
256
- return new (P || (P = Promise))(function (resolve, reject) {
257
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
258
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
259
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
260
- step((generator = generator.apply(thisArg, _arguments || [])).next());
261
- });
262
- };
263
- Object.defineProperty(exports, "__esModule", { value: true });
264
-
265
- /**
266
- * Loads documents via the fetch API.
267
- */
268
- class FetchDocumentLoader {
269
- load(url) {
270
- return __awaiter(this, void 0, void 0, function* () {
271
- const response = yield fetch(url, { headers: { accept: 'application/ld+json' } });
272
- if (response.ok) {
273
- return (yield response.json());
274
- }
275
- else {
276
- throw new Error(`No valid context was found at ${url}: ${response.statusText}`);
277
- }
278
- });
279
- }
280
- }
281
- exports.FetchDocumentLoader = FetchDocumentLoader;
282
-
283
- });
284
-
285
- var ContextParser_1 = createCommonjsModule(function (module, exports) {
286
- var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
287
- return new (P || (P = Promise))(function (resolve, reject) {
288
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
289
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
290
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
291
- step((generator = generator.apply(thisArg, _arguments || [])).next());
292
- });
293
- };
294
- Object.defineProperty(exports, "__esModule", { value: true });
295
-
296
-
297
-
298
- /**
299
- * Parses JSON-LD contexts.
300
- */
301
- class ContextParser {
302
- constructor(options) {
303
- options = options || {};
304
- this.documentLoader = options.documentLoader || new FetchDocumentLoader_1.FetchDocumentLoader();
305
- this.documentCache = {};
306
- this.validate = !options.skipValidation;
307
- this.expandContentTypeToBase = options.expandContentTypeToBase;
308
- }
309
- /**
310
- * Check if the given term is a valid compact IRI.
311
- * Otherwise, it may be an IRI.
312
- * @param {string} term A term.
313
- * @return {boolean} If it is a compact IRI.
314
- */
315
- static isCompactIri(term) {
316
- return term.indexOf(':') >= 0 && !(term && term[0] === '#');
317
- }
318
- /**
319
- * Get the prefix from the given term.
320
- * @see https://json-ld.org/spec/latest/json-ld/#compact-iris
321
- * @param {string} term A term that is an URL or a prefixed URL.
322
- * @param {IJsonLdContextNormalized} context A context.
323
- * @return {string} The prefix or null.
324
- */
325
- static getPrefix(term, context) {
326
- // Do not consider relative IRIs starting with a hash as compact IRIs
327
- if (term && term[0] === '#') {
328
- return null;
329
- }
330
- const separatorPos = term.indexOf(':');
331
- if (separatorPos >= 0) {
332
- // Suffix can not begin with two slashes
333
- if (term.length > separatorPos + 1
334
- && term.charAt(separatorPos + 1) === '/'
335
- && term.charAt(separatorPos + 2) === '/') {
336
- return null;
337
- }
338
- const prefix = term.substr(0, separatorPos);
339
- // Prefix can not be an underscore (this is a blank node)
340
- if (prefix === '_') {
341
- return null;
342
- }
343
- // Prefix must match a term in the active context
344
- if (context[prefix]) {
345
- return prefix;
346
- }
347
- }
348
- return null;
349
- }
350
- /**
351
- * From a given context entry value, get the string value, or the @id field.
352
- * @param contextValue A value for a term in a context.
353
- * @return {string} The id value, or null.
354
- */
355
- static getContextValueId(contextValue) {
356
- if (contextValue === null || typeof contextValue === 'string') {
357
- return contextValue;
358
- }
359
- const id = contextValue['@id'];
360
- return id ? id : null;
361
- }
362
- /**
363
- * Expand the term or prefix of the given term if it has one,
364
- * otherwise return the term as-is.
365
- *
366
- * This will try to expand the IRI as much as possible.
367
- *
368
- * Iff in vocab-mode, then other references to other terms in the context can be used,
369
- * such as to `myTerm`:
370
- * ```
371
- * {
372
- * "myTerm": "http://example.org/myLongTerm"
373
- * }
374
- * ```
375
- *
376
- * @param {string} term A term that is an URL or a prefixed URL.
377
- * @param {IJsonLdContextNormalized} context A context.
378
- * @param {boolean} vocab If the term is a predicate or type and should be expanded based on @vocab,
379
- * otherwise it is considered a regular term that is expanded based on @base.
380
- * @return {string} The expanded term, the term as-is, or null if it was explicitly disabled in the context.
381
- */
382
- static expandTerm(term, context, vocab) {
383
- ContextParser.assertNormalized(context);
384
- const contextValue = context[term];
385
- // Immediately return if the term was disabled in the context
386
- if (contextValue === null || (contextValue && contextValue['@id'] === null)) {
387
- return null;
388
- }
389
- // Check the @id
390
- if (contextValue && vocab) {
391
- const value = this.getContextValueId(contextValue);
392
- if (value && value !== term) {
393
- return value;
394
- }
395
- }
396
- // Check if the term is prefixed
397
- const prefix = ContextParser.getPrefix(term, context);
398
- if (prefix) {
399
- const value = this.getContextValueId(context[prefix]);
400
- if (value) {
401
- return value + term.substr(prefix.length + 1);
402
- }
403
- }
404
- else if (vocab && context['@vocab'] && term.charAt(0) !== '@' && !ContextParser.isCompactIri(term)) {
405
- return context['@vocab'] + term;
406
- }
407
- else if (!vocab && context['@base'] && term.charAt(0) !== '@' && !ContextParser.isCompactIri(term)) {
408
- return relativeToAbsoluteIri.resolve(term, context['@base']);
409
- }
410
- return term;
411
- }
412
- /**
413
- * Compact the given term using @base, @vocab, an aliased term, or a prefixed term.
414
- *
415
- * This will try to compact the IRI as much as possible.
416
- *
417
- * @param {string} iri An IRI to compact.
418
- * @param {IJsonLdContextNormalized} context The context to compact with.
419
- * @param {boolean} vocab If the term is a predicate or type and should be compacted based on @vocab,
420
- * otherwise it is considered a regular term that is compacted based on @base.
421
- * @return {string} The compacted term or the IRI as-is.
422
- */
423
- static compactIri(iri, context, vocab) {
424
- ContextParser.assertNormalized(context);
425
- // Try @vocab compacting
426
- if (vocab && context['@vocab'] && iri.startsWith(context['@vocab'])) {
427
- return iri.substr(context['@vocab'].length);
428
- }
429
- // Try @base compacting
430
- if (!vocab && context['@base'] && iri.startsWith(context['@base'])) {
431
- return iri.substr(context['@base'].length);
432
- }
433
- // Loop over all terms in the context
434
- // This will try to prefix as short as possible.
435
- // Once a fully compacted alias is found, return immediately, as we can not go any shorter.
436
- const shortestPrefixing = { prefix: '', suffix: iri };
437
- for (const key in context) {
438
- const value = context[key];
439
- if (value && !key.startsWith('@')) {
440
- const contextIri = this.getContextValueId(value);
441
- if (iri.startsWith(contextIri)) {
442
- const suffix = iri.substr(contextIri.length);
443
- if (!suffix) {
444
- if (vocab) {
445
- // Immediately return on compacted alias
446
- return key;
447
- }
448
- }
449
- else if (suffix.length < shortestPrefixing.suffix.length) {
450
- // Overwrite the shortest prefix
451
- shortestPrefixing.prefix = key;
452
- shortestPrefixing.suffix = suffix;
453
- }
454
- }
455
- }
456
- }
457
- // Return the shortest prefix
458
- if (shortestPrefixing.prefix) {
459
- return shortestPrefixing.prefix + ':' + shortestPrefixing.suffix;
460
- }
461
- return iri;
462
- }
463
- /**
464
- * An an assert to check if the given context has been normalized.
465
- * An error will be thrown otherwise.
466
- * @param {JsonLdContext} context A context.
467
- */
468
- static assertNormalized(context) {
469
- if (typeof context === 'string' || Array.isArray(context) || context['@context']) {
470
- throw new Error('The given context is not normalized. Make sure to call ContextParser.parse() first.');
471
- }
472
- }
473
- /**
474
- * Check if the given context value can be a prefix value.
475
- * @param value A context value.
476
- * @return {boolean} If it can be a prefix value.
477
- */
478
- static isPrefixValue(value) {
479
- return value && (typeof value === 'string' || value['@id'] || value['@type']);
480
- }
481
- /**
482
- * Check if the given IRI is valid.
483
- * @param {string} iri A potential IRI.
484
- * @return {boolean} If the given IRI is valid.
485
- */
486
- static isValidIri(iri) {
487
- return ContextParser.IRI_REGEX.test(iri);
488
- }
489
- /**
490
- * Add an @id term for all @reverse terms.
491
- * @param {IJsonLdContextNormalized} context A context.
492
- * @return {IJsonLdContextNormalized} The mutated input context.
493
- */
494
- static idifyReverseTerms(context) {
495
- for (const key of Object.keys(context)) {
496
- const value = context[key];
497
- if (value && typeof value === 'object') {
498
- if (value['@reverse'] && !value['@id']) {
499
- if (typeof value['@reverse'] !== 'string') {
500
- throw new Error(`Invalid @reverse value: '${value['@reverse']}'`);
501
- }
502
- value['@id'] = value['@reverse'];
503
- value['@reverse'] = true;
504
- }
505
- }
506
- }
507
- return context;
508
- }
509
- /**
510
- * Expand all prefixed terms in the given context.
511
- * @param {IJsonLdContextNormalized} context A context.
512
- * @param {boolean} expandContentTypeToBase If @type inside the context may be expanded
513
- * via @base if @vocab is set to null.
514
- * @return {IJsonLdContextNormalized} The mutated input context.
515
- */
516
- static expandPrefixedTerms(context, expandContentTypeToBase) {
517
- for (const key of Object.keys(context)) {
518
- // Only expand allowed keys
519
- if (ContextParser.EXPAND_KEYS_BLACKLIST.indexOf(key) < 0) {
520
- // Error if we try to alias a keyword to something else.
521
- if (key[0] === '@' && ContextParser.ALIAS_KEYS_BLACKLIST.indexOf(key) >= 0) {
522
- throw new Error(`Keywords can not be aliased to something else.
523
- Tried mapping ${key} to ${context[key]}`);
524
- }
525
- // Loop because prefixes might be nested
526
- while (ContextParser.isPrefixValue(context[key])) {
527
- const value = context[key];
528
- let changed = false;
529
- if (typeof value === 'string') {
530
- context[key] = ContextParser.expandTerm(value, context, true);
531
- changed = changed || value !== context[key];
532
- }
533
- else {
534
- const id = value['@id'];
535
- const type = value['@type'];
536
- if (id) {
537
- context[key]['@id'] = ContextParser.expandTerm(id, context, true);
538
- changed = changed || id !== context[key]['@id'];
539
- }
540
- if (type && type !== '@vocab') {
541
- // First check @vocab, then fallback to @base
542
- context[key]['@type'] = ContextParser.expandTerm(type, context, true);
543
- if (expandContentTypeToBase && type === context[key]['@type']) {
544
- context[key]['@type'] = ContextParser.expandTerm(type, context, false);
545
- }
546
- changed = changed || type !== context[key]['@type'];
547
- }
548
- }
549
- if (!changed) {
550
- break;
551
- }
552
- }
553
- }
554
- }
555
- return context;
556
- }
557
- /**
558
- * Normalize the @language entries in the given context to lowercase.
559
- * @param {IJsonLdContextNormalized} context A context.
560
- * @return {IJsonLdContextNormalized} The mutated input context.
561
- */
562
- static normalize(context) {
563
- for (const key of Object.keys(context)) {
564
- if (key === '@language' && typeof context[key] === 'string') {
565
- context[key] = context[key].toLowerCase();
566
- }
567
- else {
568
- const value = context[key];
569
- if (value && typeof value === 'object') {
570
- if (typeof value['@language'] === 'string') {
571
- value['@language'] = value['@language'].toLowerCase();
572
- }
573
- }
574
- }
575
- }
576
- return context;
577
- }
578
- /**
579
- * Validate the entries of the given context.
580
- * @param {IJsonLdContextNormalized} context A context.
581
- */
582
- static validate(context) {
583
- for (const key of Object.keys(context)) {
584
- const value = context[key];
585
- const valueType = typeof value;
586
- // First check if the key is a keyword
587
- if (key[0] === '@') {
588
- switch (key.substr(1)) {
589
- case 'vocab':
590
- if (value !== null && valueType !== 'string') {
591
- throw new Error(`Found an invalid @vocab IRI: ${value}`);
592
- }
593
- break;
594
- case 'base':
595
- if (value !== null && valueType !== 'string') {
596
- throw new Error(`Found an invalid @base IRI: ${context[key]}`);
597
- }
598
- break;
599
- case 'language':
600
- if (value !== null && valueType !== 'string') {
601
- throw new Error(`Found an invalid @language string: ${value}`);
602
- }
603
- break;
604
- }
605
- }
606
- // Otherwise, consider the key a term
607
- if (value !== null) {
608
- switch (valueType) {
609
- case 'string':
610
- // Always valid
611
- break;
612
- case 'object':
613
- if (!ContextParser.isCompactIri(key) && !('@id' in value)
614
- && (value['@type'] === '@id' ? !context['@base'] : !context['@vocab'])) {
615
- throw new Error(`Missing @id in context entry: '${key}': '${JSON.stringify(value)}'`);
616
- }
617
- for (const objectKey of Object.keys(value)) {
618
- const objectValue = value[objectKey];
619
- if (!objectValue) {
620
- continue;
621
- }
622
- switch (objectKey) {
623
- case '@id':
624
- if (objectValue[0] === '@' && objectValue !== '@type' && objectValue !== '@id') {
625
- throw new Error(`Illegal keyword alias in term value, found: '${key}': '${JSON.stringify(value)}'`);
626
- }
627
- break;
628
- case '@type':
629
- if (objectValue !== '@id' && objectValue !== '@vocab'
630
- && (objectValue[0] === '_' || !ContextParser.isValidIri(objectValue))) {
631
- throw new Error(`A context @type must be an absolute IRI, found: '${key}': '${objectValue}'`);
632
- }
633
- break;
634
- case '@reverse':
635
- if (typeof objectValue === 'string' && value['@id'] && value['@id'] !== objectValue) {
636
- throw new Error(`Found non-matching @id and @reverse term values in '${key}':\
637
- '${objectValue}' and '${value['@id']}'`);
638
- }
639
- break;
640
- case '@container':
641
- if (objectValue === '@list' && value['@reverse']) {
642
- throw new Error(`Term value can not be @container: @list and @reverse at the same time on '${key}'`);
643
- }
644
- if (ContextParser.CONTAINERS.indexOf(objectValue) < 0) {
645
- throw new Error(`Invalid term @container for '${key}' ('${objectValue}'), \
646
- must be one of ${ContextParser.CONTAINERS.join(', ')}`);
647
- }
648
- break;
649
- case '@language':
650
- if (objectValue !== null && typeof objectValue !== 'string') {
651
- throw new Error(`Found an invalid term @language string in: '${key}': '${JSON.stringify(value)}'`);
652
- }
653
- break;
654
- }
655
- }
656
- break;
657
- default:
658
- throw new Error(`Found an invalid term value: '${key}': '${value}'`);
659
- }
660
- }
661
- }
662
- }
663
- /**
664
- * Resolve relative context IRIs, or return full IRIs as-is.
665
- * @param {string} contextIri A context IRI.
666
- * @param {string} baseIri A base IRI.
667
- * @return {string} The normalized context IRI.
668
- */
669
- static normalizeContextIri(contextIri, baseIri) {
670
- if (!ContextParser.isValidIri(contextIri)) {
671
- contextIri = relativeToAbsoluteIri.resolve(contextIri, baseIri);
672
- if (!ContextParser.isValidIri(contextIri)) {
673
- throw new Error(`Invalid context IRI: ${contextIri}`);
674
- }
675
- }
676
- return contextIri;
677
- }
678
- /**
679
- * Parse a JSON-LD context in any form.
680
- * @param {JsonLdContext} context A context, URL to a context, or an array of contexts/URLs.
681
- * @param {IParseOptions} options Optional parsing options.
682
- * @return {Promise<IJsonLdContextNormalized>} A promise resolving to the context.
683
- */
684
- parse(context, { baseIri, parentContext, external } = {}) {
685
- return __awaiter(this, void 0, void 0, function* () {
686
- if (context === null || context === undefined) {
687
- // Context that are explicitly set to null are empty.
688
- return baseIri ? { '@base': baseIri } : {};
689
- }
690
- else if (typeof context === 'string') {
691
- return this.parse(yield this.load(ContextParser.normalizeContextIri(context, baseIri)), { baseIri, parentContext, external: true });
692
- }
693
- else if (Array.isArray(context)) {
694
- // As a performance consideration, first load all external contexts in parallel.
695
- const contexts = yield Promise.all(context.map((subContext) => {
696
- if (typeof subContext === 'string') {
697
- return this.load(ContextParser.normalizeContextIri(subContext, baseIri));
698
- }
699
- else {
700
- return subContext;
701
- }
702
- }));
703
- return contexts.reduce((accContextPromise, contextEntry) => accContextPromise
704
- .then((accContext) => this.parse(contextEntry, {
705
- baseIri: accContext && accContext['@base'] || baseIri,
706
- external,
707
- parentContext: accContext,
708
- })), Promise.resolve(parentContext));
709
- }
710
- else if (typeof context === 'object') {
711
- if (context['@context']) {
712
- return yield this.parse(context['@context'], { baseIri, parentContext, external });
713
- }
714
- // Make a deep clone of the given context, to avoid modifying it.
715
- context = JSON.parse(JSON.stringify(context)); // No better way in JS at the moment...
716
- // We have an actual context object.
717
- let newContext = {};
718
- // According to the JSON-LD spec, @base must be ignored from external contexts.
719
- if (external) {
720
- delete context['@base'];
721
- }
722
- // Override the base IRI if provided.
723
- if (baseIri) {
724
- if (!('@base' in context)) {
725
- // The context base is the document base
726
- context['@base'] = baseIri;
727
- }
728
- else if (context['@base'] !== null && !ContextParser.isValidIri(context['@base'])) {
729
- // The context base is relative to the document base
730
- context['@base'] = relativeToAbsoluteIri.resolve(context['@base'], baseIri);
731
- }
732
- }
733
- newContext = Object.assign({}, newContext, parentContext, context);
734
- ContextParser.idifyReverseTerms(newContext);
735
- ContextParser.expandPrefixedTerms(newContext, this.expandContentTypeToBase);
736
- ContextParser.normalize(newContext);
737
- if (this.validate) {
738
- ContextParser.validate(newContext);
739
- }
740
- return newContext;
741
- }
742
- else {
743
- throw new Error(`Tried parsing a context that is not a string, array or object, but got ${context}`);
744
- }
745
- });
746
- }
747
- load(url) {
748
- return __awaiter(this, void 0, void 0, function* () {
749
- const cached = this.documentCache[url];
750
- if (cached) {
751
- return Array.isArray(cached) ? cached.slice() : Object.assign({}, cached);
752
- }
753
- return this.documentCache[url] = (yield this.documentLoader.load(url))['@context'];
754
- });
755
- }
756
- }
757
- // Regex for valid IRIs
758
- ContextParser.IRI_REGEX = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^ "<>{}|\\\[\]`]*$/;
759
- // Keys in the contexts that will not be expanded based on the base IRI
760
- ContextParser.EXPAND_KEYS_BLACKLIST = [
761
- '@base',
762
- '@vocab',
763
- '@language',
764
- ];
765
- // Keys in the contexts that may not be aliased
766
- ContextParser.ALIAS_KEYS_BLACKLIST = [
767
- '@container',
768
- '@graph',
769
- '@id',
770
- '@index',
771
- '@list',
772
- '@nest',
773
- '@none',
774
- '@prefix',
775
- '@reverse',
776
- '@set',
777
- '@type',
778
- '@value',
779
- ];
780
- // All valid @container values
781
- ContextParser.CONTAINERS = [
782
- '@list',
783
- '@set',
784
- '@index',
785
- '@language',
786
- ];
787
- exports.ContextParser = ContextParser;
788
-
789
- });
790
-
791
- var jsonldContextParser = createCommonjsModule(function (module, exports) {
792
- function __export(m) {
793
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
794
- }
795
- Object.defineProperty(exports, "__esModule", { value: true });
796
- __export(ContextParser_1);
797
- __export(FetchDocumentLoader_1);
798
-
799
- });
800
-
801
- var __pika_web_default_export_for_treeshaking__ = /*@__PURE__*/getDefaultExportFromCjs(jsonldContextParser);
802
-
803
- export default __pika_web_default_export_for_treeshaking__;
804
- //# sourceMappingURL=jsonld-context-parser.js.map