@startinblox/core 0.17.18 → 0.17.21-beta.2

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 (262) 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 -25
  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.js +0 -14066
  34. package/dist/_snowpack/pkg/leaflet.js.map +0 -1
  35. package/dist/_snowpack/pkg/leaflet.js.map.proxy.js +0 -1
  36. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +0 -60
  37. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  38. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +0 -14
  39. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  40. package/dist/_snowpack/pkg/leaflet.markercluster.js +0 -2697
  41. package/dist/_snowpack/pkg/leaflet.markercluster.js.map +0 -1
  42. package/dist/_snowpack/pkg/leaflet.markercluster.js.map.proxy.js +0 -1
  43. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -40
  44. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  45. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
  46. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -46
  47. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  48. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
  49. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -88
  50. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  51. package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
  52. package/dist/_snowpack/pkg/lit-html.js +0 -92
  53. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  54. package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
  55. package/dist/_snowpack/pkg/markdown-it.js +0 -11860
  56. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  57. package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
  58. package/dist/_snowpack/pkg/quill/dist/quill.snow.css +0 -945
  59. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  60. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -1029
  61. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  62. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
  63. package/dist/_snowpack/pkg/quill.js +0 -13382
  64. package/dist/_snowpack/pkg/quill.js.map +0 -1
  65. package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
  66. package/dist/_snowpack/pkg/slim-select.js +0 -4
  67. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  68. package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
  69. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1164
  70. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  71. package/dist/_snowpack/pkg/tui-calendar.js +0 -42285
  72. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  73. package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
  74. package/dist/components/solid-ac-checker.js +0 -58
  75. package/dist/components/solid-ac-checker.js.map +0 -1
  76. package/dist/components/solid-calendar.js +0 -87
  77. package/dist/components/solid-calendar.js.map +0 -1
  78. package/dist/components/solid-delete.js +0 -111
  79. package/dist/components/solid-delete.js.map +0 -1
  80. package/dist/components/solid-display.js +0 -194
  81. package/dist/components/solid-display.js.map +0 -1
  82. package/dist/components/solid-form-search.js +0 -226
  83. package/dist/components/solid-form-search.js.map +0 -1
  84. package/dist/components/solid-form.js +0 -354
  85. package/dist/components/solid-form.js.map +0 -1
  86. package/dist/components/solid-lang.js +0 -46
  87. package/dist/components/solid-lang.js.map +0 -1
  88. package/dist/components/solid-map.js +0 -239
  89. package/dist/components/solid-map.js.map +0 -1
  90. package/dist/components/solid-table.js +0 -263
  91. package/dist/components/solid-table.js.map +0 -1
  92. package/dist/components/solid-widget.js +0 -94
  93. package/dist/components/solid-widget.js.map +0 -1
  94. package/dist/import.css +0 -4
  95. package/dist/index.js +0 -43
  96. package/dist/index.js.map +0 -1
  97. package/dist/libs/Component.js +0 -19
  98. package/dist/libs/Component.js.map +0 -1
  99. package/dist/libs/ComponentFactory.js +0 -196
  100. package/dist/libs/ComponentFactory.js.map +0 -1
  101. package/dist/libs/Compositor.js +0 -103
  102. package/dist/libs/Compositor.js.map +0 -1
  103. package/dist/libs/Sib.js +0 -58
  104. package/dist/libs/Sib.js.map +0 -1
  105. package/dist/libs/helpers.js +0 -219
  106. package/dist/libs/helpers.js.map +0 -1
  107. package/dist/libs/interfaces.js +0 -6
  108. package/dist/libs/interfaces.js.map +0 -1
  109. package/dist/libs/lit-helpers.js +0 -169
  110. package/dist/libs/lit-helpers.js.map +0 -1
  111. package/dist/libs/polyfills.js +0 -40
  112. package/dist/libs/polyfills.js.map +0 -1
  113. package/dist/libs/store/store.js +0 -768
  114. package/dist/libs/store/store.js.map +0 -1
  115. package/dist/locales/en.json +0 -10
  116. package/dist/locales/en.json.proxy.js +0 -2
  117. package/dist/locales/fr.json +0 -10
  118. package/dist/locales/fr.json.proxy.js +0 -2
  119. package/dist/mixins/attributeBinderMixin.js +0 -124
  120. package/dist/mixins/attributeBinderMixin.js.map +0 -1
  121. package/dist/mixins/contextMixin.js +0 -28
  122. package/dist/mixins/contextMixin.js.map +0 -1
  123. package/dist/mixins/counterMixin.js +0 -75
  124. package/dist/mixins/counterMixin.js.map +0 -1
  125. package/dist/mixins/federationMixin.js +0 -63
  126. package/dist/mixins/federationMixin.js.map +0 -1
  127. package/dist/mixins/filterMixin.js +0 -195
  128. package/dist/mixins/filterMixin.js.map +0 -1
  129. package/dist/mixins/grouperMixin.js +0 -80
  130. package/dist/mixins/grouperMixin.js.map +0 -1
  131. package/dist/mixins/highlighterMixin.js +0 -42
  132. package/dist/mixins/highlighterMixin.js.map +0 -1
  133. package/dist/mixins/interfaces.js +0 -8
  134. package/dist/mixins/interfaces.js.map +0 -1
  135. package/dist/mixins/listMixin.js +0 -136
  136. package/dist/mixins/listMixin.js.map +0 -1
  137. package/dist/mixins/nextMixin.js +0 -26
  138. package/dist/mixins/nextMixin.js.map +0 -1
  139. package/dist/mixins/paginateMixin.js +0 -110
  140. package/dist/mixins/paginateMixin.js.map +0 -1
  141. package/dist/mixins/requiredMixin.js +0 -34
  142. package/dist/mixins/requiredMixin.js.map +0 -1
  143. package/dist/mixins/sorterMixin.js +0 -149
  144. package/dist/mixins/sorterMixin.js.map +0 -1
  145. package/dist/mixins/storeMixin.js +0 -102
  146. package/dist/mixins/storeMixin.js.map +0 -1
  147. package/dist/mixins/translationMixin.js +0 -68
  148. package/dist/mixins/translationMixin.js.map +0 -1
  149. package/dist/mixins/validationMixin.js +0 -113
  150. package/dist/mixins/validationMixin.js.map +0 -1
  151. package/dist/mixins/widgetMixin.js +0 -447
  152. package/dist/mixins/widgetMixin.js.map +0 -1
  153. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -14
  154. package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
  155. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -10
  156. package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
  157. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -10
  158. package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
  159. package/dist/new-widgets/attributeMixins/index.js +0 -20
  160. package/dist/new-widgets/attributeMixins/index.js.map +0 -1
  161. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -10
  162. package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
  163. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -28
  164. package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
  165. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -10
  166. package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
  167. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -19
  168. package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
  169. package/dist/new-widgets/attributeMixins/telMixin.js +0 -10
  170. package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
  171. package/dist/new-widgets/baseWidgetMixin.js +0 -122
  172. package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
  173. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -104
  174. package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
  175. package/dist/new-widgets/callbackMixins/index.js +0 -8
  176. package/dist/new-widgets/callbackMixins/index.js.map +0 -1
  177. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -42
  178. package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
  179. package/dist/new-widgets/callbackMixins/slimselect.css +0 -2
  180. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  181. package/dist/new-widgets/new-widget-factory.js +0 -96
  182. package/dist/new-widgets/new-widget-factory.js.map +0 -1
  183. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -41
  184. package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
  185. package/dist/new-widgets/templateAdditionMixins/index.js +0 -14
  186. package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
  187. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -29
  188. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
  189. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -31
  190. package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
  191. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -35
  192. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
  193. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -89
  194. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
  195. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -397
  196. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
  197. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -21
  198. package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
  199. package/dist/new-widgets/templates/index.js +0 -7
  200. package/dist/new-widgets/templates/index.js.map +0 -1
  201. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -49
  202. package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
  203. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -13
  204. package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
  205. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -77
  206. package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
  207. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -38
  208. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
  209. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -14
  210. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
  211. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -51
  212. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
  213. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -66
  214. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
  215. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -81
  216. package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
  217. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -19
  218. package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
  219. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -19
  220. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
  221. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -66
  222. package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
  223. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -14
  224. package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
  225. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -16
  226. package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
  227. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -13
  228. package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
  229. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -107
  230. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
  231. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
  232. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
  233. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -19
  234. package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
  235. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -110
  236. package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
  237. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -12
  238. package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
  239. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -12
  240. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
  241. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -18
  242. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
  243. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -35
  244. package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
  245. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -16
  246. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
  247. package/dist/new-widgets/valueTransformationMixins/index.js +0 -16
  248. package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
  249. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -25
  250. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
  251. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -17
  252. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
  253. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -27
  254. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
  255. package/dist/solid-template-element.js +0 -164
  256. package/dist/solid-template-element.js.map +0 -1
  257. package/dist/style/default-theme.css +0 -24
  258. package/dist/style/default-theme.css.proxy.js +0 -10
  259. package/dist/widgets/baseWidget.js +0 -332
  260. package/dist/widgets/baseWidget.js.map +0 -1
  261. package/dist/widgets/widget-factory.js +0 -24
  262. package/dist/widgets/widget-factory.js.map +0 -1
@@ -1,768 +0,0 @@
1
- let _Symbol$toPrimitive;
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
- import JSONLDContextParser from '../../_snowpack/pkg/jsonld-context-parser.js'; //@ts-ignore
6
-
7
- import PubSub from 'https://cdn.skypack.dev/pubsub-js';
8
- const ContextParser = JSONLDContextParser.ContextParser;
9
- const myParser = new ContextParser();
10
- export const base_context = {
11
- '@vocab': 'http://happy-dev.fr/owl/#',
12
- rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
13
- rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
14
- ldp: 'http://www.w3.org/ns/ldp#',
15
- foaf: 'http://xmlns.com/foaf/0.1/',
16
- name: 'rdfs:label',
17
- acl: 'http://www.w3.org/ns/auth/acl#',
18
- permissions: 'acl:accessControl',
19
- mode: 'acl:mode',
20
- geo: "http://www.w3.org/2003/01/geo/wgs84_pos#",
21
- lat: "geo:lat",
22
- lng: "geo:long"
23
- };
24
-
25
- class Store {
26
- // index of all the containers per resource
27
- // index of all the containers per resource
28
- constructor(storeOptions) {
29
- this.storeOptions = storeOptions;
30
-
31
- _defineProperty(this, "cache", void 0);
32
-
33
- _defineProperty(this, "subscriptionIndex", void 0);
34
-
35
- _defineProperty(this, "subscriptionVirtualContainersIndex", void 0);
36
-
37
- _defineProperty(this, "loadingList", void 0);
38
-
39
- _defineProperty(this, "headers", void 0);
40
-
41
- _defineProperty(this, "fetch", void 0);
42
-
43
- _defineProperty(this, "session", void 0);
44
-
45
- _defineProperty(this, "resolveResource", function (id, resolve) {
46
- const handler = function (event) {
47
- if (event.detail.id === id) {
48
- resolve(event.detail.resource); // TODO : callback
49
-
50
- document.removeEventListener('resourceReady', handler);
51
- }
52
- };
53
-
54
- return handler;
55
- });
56
-
57
- this.cache = new Map();
58
- this.subscriptionIndex = new Map();
59
- this.subscriptionVirtualContainersIndex = new Map();
60
- this.loadingList = new Set();
61
- this.headers = new Headers();
62
- this.headers.set('Content-Type', 'application/ld+json');
63
- this.fetch = this.storeOptions.fetchMethod;
64
- this.session = this.storeOptions.session;
65
- }
66
- /**
67
- * Fetch data and cache it
68
- * @param id - uri of the resource to fetch
69
- * @param context - context used to expand id and predicates when accessing the resource
70
- * @param idParent - uri of the parent caller used to expand uri for local files
71
- *
72
- * @returns The fetched resource
73
- *
74
- * @async
75
- */
76
-
77
-
78
- async getData(id, context = {}, idParent = "", localData) {
79
- if (localData == null && this.cache.has(id) && !this.loadingList.has(id)) {
80
- const resource = this.get(id);
81
- if (resource && resource.isFullResource()) return resource; // if resource is not complete, re-fetch it
82
- }
83
-
84
- return new Promise(async resolve => {
85
- document.addEventListener('resourceReady', this.resolveResource(id, resolve));
86
- if (this.loadingList.has(id)) return;
87
- this.loadingList.add(id); // Generate proxy
88
-
89
- const clientContext = await myParser.parse(context);
90
- let resource = null;
91
-
92
- if (this._isLocalId(id)) {
93
- if (localData == null) localData = {};
94
- localData["@id"] = id;
95
- resource = localData;
96
- } else try {
97
- resource = localData || (await this.fetchData(id, clientContext, idParent));
98
- } catch (error) {
99
- console.error(error);
100
- }
101
-
102
- if (!resource) {
103
- this.loadingList.delete(id);
104
- resolve(null);
105
- return;
106
- }
107
-
108
- const serverContext = await myParser.parse([resource['@context'] || {}]);
109
- const resourceProxy = new CustomGetter(id, resource, clientContext, serverContext, idParent).getProxy(); // Cache proxy
110
-
111
- await this.cacheGraph(id, resourceProxy, clientContext, serverContext, idParent || id);
112
- this.loadingList.delete(id);
113
- document.dispatchEvent(new CustomEvent('resourceReady', {
114
- detail: {
115
- id: id,
116
- resource: this.get(id)
117
- }
118
- }));
119
- });
120
- }
121
-
122
- async fetchAuthn(iri, options) {
123
- let authenticated = false;
124
- if (this.session) authenticated = await this.session;
125
- return this.fetch && authenticated ? this.fetch.then(fn => fn(iri, options)) : fetch(iri, options);
126
- }
127
-
128
- async fetchData(id, context = {}, idParent = "") {
129
- const iri = this._getAbsoluteIri(id, context, idParent);
130
-
131
- const headers = this.headers;
132
- headers.set('accept-language', this._getLanguage());
133
- return this.fetchAuthn(iri, {
134
- method: 'GET',
135
- headers: headers,
136
- credentials: 'include'
137
- }).then(response => {
138
- if (!response.ok) return;
139
- return response.json();
140
- });
141
- }
142
-
143
- async cacheGraph(key, resource, clientContext, parentContext, parentId) {
144
- if (resource.properties) {
145
- // if proxy, cache it
146
- if (this.get(key)) {
147
- // if already cached, merge data
148
- this.cache.get(key).merge(resource);
149
- } else {
150
- // else, put in cache
151
- this.cache.set(key, resource);
152
- }
153
- } // Cache nested resources
154
-
155
-
156
- if (resource.getSubObjects) {
157
- for (let res of resource.getSubObjects()) {
158
- let newParentContext = parentContext; // If additional context in resource, use it to expand properties
159
-
160
- if (res['@context']) newParentContext = await myParser.parse({ ...parentContext,
161
- ...res['@context']
162
- });
163
- const resourceProxy = new CustomGetter(res['@id'], res, clientContext, newParentContext, parentId).getProxy(); // this.subscribeResourceTo(resource['@id'], res['@id']); // removed to prevent useless updates
164
-
165
- await this.cacheGraph(res['@id'], resourceProxy, clientContext, parentContext, parentId);
166
- }
167
- } // Cache children of container
168
-
169
-
170
- if (resource['@type'] == "ldp:Container" && resource.getChildren) {
171
- const cacheChildrenPromises = [];
172
-
173
- for (let res of resource.getChildren()) {
174
- this.subscribeResourceTo(resource['@id'], res['@id']);
175
- cacheChildrenPromises.push(this.cacheGraph(res['@id'], res, clientContext, parentContext, parentId));
176
- }
177
-
178
- await Promise.all(cacheChildrenPromises);
179
- return;
180
- } // Create proxy, (fetch data) and cache resource
181
-
182
-
183
- if (resource['@id'] && !resource.properties) {
184
- if (resource['@id'].match(/^b\d+$/)) return; // not anonymous node
185
- // Fetch data if
186
-
187
- if (resource['@type'] === "sib:federatedContainer" && resource['@cache'] !== 'false') {
188
- // if object is federated container
189
- await this.getData(resource['@id'], clientContext, parentId); // then init graph
190
-
191
- return;
192
- }
193
-
194
- const resourceProxy = new CustomGetter(resource['@id'], resource, clientContext, parentContext, parentId).getProxy();
195
- await this.cacheGraph(key, resourceProxy, clientContext, parentContext, parentId);
196
- }
197
- }
198
-
199
- async _fetch(method, resource, id) {
200
- if (method !== '_LOCAL') return fetch(id, {
201
- method: method,
202
- headers: await this.headers,
203
- body: JSON.stringify(resource),
204
- credentials: 'include'
205
- });
206
- const resourceProxy = store.get(id);
207
- const clientContext = resourceProxy ? resourceProxy.clientContext : resource['@context'];
208
- this.clearCache(id);
209
- await this.getData(id, clientContext, '', resource);
210
- return {
211
- ok: true
212
- };
213
- }
214
-
215
- async _updateResource(method, resource, id) {
216
- if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) throw new Error('Error: method not allowed');
217
- const context = await myParser.parse([resource['@context'] || {}]); // parse context before expandTerm
218
-
219
- const expandedId = this._getExpandedId(id, context);
220
-
221
- return this._fetch(method, resource, id).then(response => {
222
- if (response.ok) {
223
- var _response$headers;
224
-
225
- if (method !== '_LOCAL') this.clearCache(expandedId); // clear cache
226
-
227
- this.getData(expandedId, resource['@context']).then(async () => {
228
- // re-fetch data
229
- const nestedResources = await this.getNestedResources(resource, id);
230
- const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
231
- const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
232
- return this.refreshResources([...nestedResources, ...resourcesToRefresh]) // refresh related resources
233
- .then(resourceIds => this.notifyResources([expandedId, ...resourceIds, ...resourcesToNotify])); // notify components
234
- });
235
- return ((_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('Location')) || null;
236
- } else {
237
- throw response;
238
- }
239
- });
240
- }
241
- /**
242
- * Clear cache and refetch data for a list of ids
243
- * @param resourceIds -
244
- * @returns - all the resource ids
245
- */
246
-
247
-
248
- async refreshResources(resourceIds) {
249
- resourceIds = [...new Set(resourceIds.filter(id => this.cache.has(id)))]; // remove duplicates and not cached resources
250
-
251
- const resourceWithContexts = resourceIds.map(resourceId => {
252
- var _store$get;
253
-
254
- return {
255
- "id": resourceId,
256
- "context": (_store$get = store.get(resourceId)) === null || _store$get === void 0 ? void 0 : _store$get.clientContext
257
- };
258
- });
259
-
260
- for (const resource of resourceWithContexts) {
261
- if (!this._isLocalId(resource.id)) this.clearCache(resource.id);
262
- }
263
-
264
- await Promise.all(resourceWithContexts.map(({
265
- id,
266
- context
267
- }) => this.getData(id, context || base_context)));
268
- return resourceIds;
269
- }
270
- /**
271
- * Notifies all components for a list of ids
272
- * @param resourceIds -
273
- */
274
-
275
-
276
- async notifyResources(resourceIds) {
277
- resourceIds = [...new Set(resourceIds)]; // remove duplicates
278
-
279
- for (const id of resourceIds) PubSub.publish(id);
280
- }
281
- /**
282
- * Return id of nested properties of a resource
283
- * @param resource - object
284
- * @param id - string
285
- */
286
-
287
-
288
- async getNestedResources(resource, id) {
289
- const cachedResource = store.get(id);
290
- if (!cachedResource || cachedResource.isContainer()) return [];
291
- let nestedProperties = [];
292
- const excludeKeys = ['@context'];
293
-
294
- for (let p of Object.keys(resource)) {
295
- if (resource[p] && typeof resource[p] === 'object' && !excludeKeys.includes(p) && resource[p]['@id']) {
296
- nestedProperties.push(resource[p]['@id']);
297
- }
298
- }
299
-
300
- return nestedProperties;
301
- }
302
- /**
303
- * Returns the resource with id from the cache
304
- * @param id - id of the resource to retrieve
305
- *
306
- * @returns Resource (Proxy) if in the cache, null otherwise
307
- */
308
-
309
-
310
- get(id) {
311
- return this.cache.get(id) || null;
312
- }
313
- /**
314
- * Removes a resource from the cache
315
- * @param id - id of the resource to remove from the cache
316
- */
317
-
318
-
319
- clearCache(id) {
320
- if (this.cache.has(id)) {
321
- // For federation, clear each source
322
- const resource = this.cache.get(id);
323
-
324
- if (resource['@type'] === 'ldp:Container') {
325
- resource['ldp:contains'].forEach(child => {
326
- if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id']);
327
- });
328
- }
329
-
330
- this.cache.delete(id);
331
- }
332
- }
333
- /**
334
- * Send data to create a local resource in a container
335
- * @param resource - resource to create
336
- * @param id - uri of the container to add resource. should start with ``
337
- *
338
- * @returns id of the posted resource
339
- */
340
-
341
-
342
- async setLocalData(resource, id) {
343
- return this._updateResource('_LOCAL', resource, id);
344
- }
345
- /**
346
- * Send a POST request to create a resource in a container
347
- * @param resource - resource to create
348
- * @param id - uri of the container to add resource
349
- *
350
- * @returns id of the posted resource
351
- */
352
-
353
-
354
- async post(resource, id) {
355
- return this._updateResource('POST', resource, id);
356
- }
357
- /**
358
- * Send a PUT request to edit a resource
359
- * @param resource - resource data to send
360
- * @param id - uri of the resource to edit
361
- *
362
- * @returns id of the edited resource
363
- */
364
-
365
-
366
- async put(resource, id) {
367
- return this._updateResource('PUT', resource, id);
368
- }
369
- /**
370
- * Send a PATCH request to edit a resource
371
- * @param resource - resource data to send
372
- * @param id - uri of the resource to patch
373
- *
374
- * @returns id of the edited resource
375
- */
376
-
377
-
378
- async patch(resource, id) {
379
- return this._updateResource('PATCH', resource, id);
380
- }
381
- /**
382
- * Send a DELETE request to delete a resource
383
- * @param id - uri of the resource to delete
384
- * @param context - can be used to expand id
385
- *
386
- * @returns id of the deleted resource
387
- */
388
-
389
-
390
- async delete(id, context = {}) {
391
- const expandedId = this._getExpandedId(id, context);
392
-
393
- const deleted = await this.fetchAuthn(expandedId, {
394
- method: 'DELETE',
395
- headers: this.headers,
396
- credentials: 'include'
397
- });
398
- const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
399
- const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
400
- this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(resourceIds => this.notifyResources(resourceIds));
401
- return deleted;
402
- }
403
-
404
- _getExpandedId(id, context) {
405
- return context && Object.keys(context) ? ContextParser.expandTerm(id, context) : id;
406
- }
407
-
408
- _isLocalId(id) {
409
- return id.startsWith('store://local.');
410
- }
411
- /**
412
- * Make a resource listen changes of another one
413
- * @param resourceId - id of the resource which needs to be updated
414
- * @param nestedResourceId - id of the resource which will change
415
- */
416
-
417
-
418
- subscribeResourceTo(resourceId, nestedResourceId) {
419
- const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || [];
420
- this.subscriptionIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, resourceId])]);
421
- }
422
- /**
423
- * Make a virtual container listen for changes of a resource
424
- * @param virtualContainerId - id of the container which needs to be updated
425
- * @param nestedResourceId - id of the resource which will change
426
- */
427
-
428
-
429
- subscribeVirtualContainerTo(virtualContainerId, nestedResourceId) {
430
- const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || [];
431
- this.subscriptionVirtualContainersIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, virtualContainerId])]);
432
- }
433
- /**
434
- * Return absolute IRI of the resource
435
- * @param id
436
- * @param context
437
- * @param parentId
438
- */
439
-
440
-
441
- _getAbsoluteIri(id, context, parentId) {
442
- let iri = ContextParser.expandTerm(id, context); // expand if reduced ids
443
-
444
- if (parentId) {
445
- // and get full URL from parent caller for local files
446
- let parentIri = new URL(parentId, document.location.href).href;
447
- iri = new URL(iri, parentIri).href;
448
- } else {
449
- iri = new URL(iri, document.location.href).href;
450
- }
451
-
452
- return iri;
453
- }
454
- /**
455
- * Check if object is a full resource
456
- * @param resource
457
- */
458
-
459
-
460
- _resourceIsComplete(resource) {
461
- return !!(Object.keys(resource).filter(p => !p.startsWith('@')).length > 0 && resource['@id']);
462
- }
463
- /**
464
- * Return language of the users
465
- */
466
-
467
-
468
- _getLanguage() {
469
- return localStorage.getItem('language') || window.navigator.language.slice(0, 2);
470
- }
471
- /**
472
- * Save the preferred language of the user
473
- * @param selectedLanguageCode
474
- */
475
-
476
-
477
- selectLanguage(selectedLanguageCode) {
478
- localStorage.setItem('language', selectedLanguageCode);
479
- }
480
-
481
- }
482
-
483
- let store;
484
-
485
- if (window.sibStore) {
486
- store = window.sibStore;
487
- } else {
488
- const sibAuth = document.querySelector('sib-auth');
489
- const storeOptions = {};
490
-
491
- if (sibAuth) {
492
- const sibAuthDefined = customElements.whenDefined(sibAuth.localName);
493
- storeOptions.session = sibAuthDefined.then(() => sibAuth.session);
494
- storeOptions.fetchMethod = sibAuthDefined.then(() => sibAuth.getFetch());
495
- }
496
-
497
- store = new Store(storeOptions);
498
- window.sibStore = store;
499
- }
500
-
501
- export { store };
502
- _Symbol$toPrimitive = Symbol.toPrimitive;
503
-
504
- class CustomGetter {
505
- // content of the requested resource
506
- // context given by the app
507
- // context given by the server
508
- // id of the parent resource, used to get the absolute url of the current resource
509
- constructor(resourceId, resource, clientContext, serverContext = {}, parentId = "") {
510
- _defineProperty(this, "resource", void 0);
511
-
512
- _defineProperty(this, "resourceId", void 0);
513
-
514
- _defineProperty(this, "clientContext", void 0);
515
-
516
- _defineProperty(this, "serverContext", void 0);
517
-
518
- _defineProperty(this, "parentId", void 0);
519
-
520
- this.clientContext = clientContext;
521
- this.serverContext = serverContext;
522
- this.parentId = parentId;
523
- this.resource = this.expandProperties({ ...resource
524
- }, serverContext);
525
- this.resourceId = resourceId;
526
- }
527
- /**
528
- * Expand all predicates of a resource with a given context
529
- * @param resource: object
530
- * @param context: object
531
- */
532
-
533
-
534
- expandProperties(resource, context) {
535
- for (let prop of Object.keys(resource)) {
536
- if (!prop) continue;
537
- this.objectReplaceProperty(resource, prop, ContextParser.expandTerm(prop, context, true));
538
- }
539
-
540
- return resource;
541
- }
542
- /**
543
- * Change the key of an object
544
- * @param object: object
545
- * @param oldProp: string - current key
546
- * @param newProp: string - new key to set
547
- */
548
-
549
-
550
- objectReplaceProperty(object, oldProp, newProp) {
551
- if (newProp !== oldProp) {
552
- Object.defineProperty(object, newProp, Object.getOwnPropertyDescriptor(object, oldProp) || '');
553
- delete object[oldProp];
554
- }
555
- }
556
- /**
557
- * Get the property of a resource for a given path
558
- * @param path: string
559
- */
560
-
561
-
562
- async get(path) {
563
- if (!path) return;
564
- const path1 = path.split('.');
565
- const path2 = [];
566
- let value;
567
-
568
- if (!this.isFullResource()) {
569
- // if resource is not complete, fetch it first
570
- await this.getResource(this.resourceId, this.clientContext, this.parentId);
571
- }
572
-
573
- while (true) {
574
- try {
575
- value = this.resource[this.getExpandedPredicate(path1[0])];
576
- } catch (e) {
577
- break;
578
- }
579
-
580
- if (path1.length <= 1) break; // no dot path
581
-
582
- const lastPath1El = path1.pop();
583
- if (lastPath1El) path2.unshift(lastPath1El);
584
- }
585
-
586
- if (path2.length === 0) {
587
- // end of the path
588
- if (!value || !value['@id']) return value; // no value or not a resource
589
-
590
- return await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId); // return complete resource
591
- }
592
-
593
- if (!value) return undefined;
594
- let resource = await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId);
595
- store.subscribeResourceTo(this.resourceId, value['@id']);
596
- return resource ? await resource[path2.join('.')] : undefined; // return value
597
- }
598
- /**
599
- * Cache resource in the store, and return the created proxy
600
- * @param id
601
- * @param context
602
- * @param iriParent
603
- */
604
-
605
-
606
- async getResource(id, context, iriParent) {
607
- return store.getData(id, context, iriParent);
608
- }
609
- /**
610
- * Return true if the resource is a container
611
- */
612
-
613
-
614
- isContainer() {
615
- return this.resource["@type"] == "ldp:Container" || this.resource["@type"] == "sib:federatedContainer";
616
- }
617
- /**
618
- * Get all properties of a resource
619
- */
620
-
621
-
622
- getProperties() {
623
- return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop));
624
- }
625
- /**
626
- * Get children of container as objects
627
- */
628
-
629
-
630
- getChildren() {
631
- return this.resource[this.getExpandedPredicate("ldp:contains")] || [];
632
- }
633
- /**
634
- * Get children of container as Proxys
635
- */
636
-
637
-
638
- getLdpContains() {
639
- const children = this.resource[this.getExpandedPredicate("ldp:contains")];
640
- return children ? children.map(res => store.get(res['@id'])) : [];
641
- }
642
- /**
643
- * Get all nested resource or containers which contains datas
644
- */
645
-
646
-
647
- getSubObjects() {
648
- let subObjects = [];
649
-
650
- for (let p of Object.keys(this.resource)) {
651
- let property = this.resource[p];
652
- if (!this.isFullNestedResource(property)) continue; // if not a resource, stop
653
-
654
- if (property['@type'] == "ldp:Container" && (property['ldp:contains'] == undefined || property['ldp:contains'].length >= 1 && !this.isFullNestedResource(property['ldp:contains'][0]))) continue; // if not a full container
655
-
656
- subObjects.push(property);
657
- }
658
-
659
- return subObjects;
660
- }
661
-
662
- merge(resource) {
663
- this.resource = { ...this.getResourceData(),
664
- ...resource.getResourceData()
665
- };
666
- }
667
-
668
- getResourceData() {
669
- return this.resource;
670
- }
671
- /**
672
- * return true if prop is a resource with an @id and some properties
673
- * @param prop
674
- */
675
-
676
-
677
- isFullNestedResource(prop) {
678
- return prop && typeof prop == "object" && prop['@id'] != undefined && Object.keys(prop).filter(p => !p.startsWith('@')).length > 0;
679
- }
680
- /**
681
- * return true resource seems complete
682
- * @param prop
683
- */
684
-
685
-
686
- isFullResource() {
687
- return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0;
688
- }
689
-
690
- getPermissions() {
691
- const permissions = this.resource[this.getExpandedPredicate("permissions")];
692
- return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];
693
- }
694
- /**
695
- * Remove the resource from the cache
696
- */
697
-
698
-
699
- clearCache() {
700
- store.clearCache(this.resourceId);
701
- }
702
-
703
- getExpandedPredicate(property) {
704
- return ContextParser.expandTerm(property, this.clientContext, true);
705
- }
706
-
707
- getCompactedPredicate(property) {
708
- return ContextParser.compactIri(property, this.clientContext, true);
709
- }
710
-
711
- getCompactedIri(id) {
712
- return ContextParser.compactIri(id, this.clientContext);
713
- }
714
-
715
- toString() {
716
- return this.getCompactedIri(this.resource['@id']);
717
- }
718
-
719
- [_Symbol$toPrimitive]() {
720
- return this.getCompactedIri(this.resource['@id']);
721
- }
722
- /**
723
- * Returns a Proxy which handles the different get requests
724
- */
725
-
726
-
727
- getProxy() {
728
- return new Proxy(this, {
729
- get: (resource, property) => {
730
- if (!this.resource) return undefined;
731
- if (typeof resource[property] === 'function') return resource[property].bind(resource);
732
-
733
- switch (property) {
734
- case '@id':
735
- return this.getCompactedIri(this.resource['@id']);
736
- // Compact @id if possible
737
-
738
- case '@type':
739
- return this.resource['@type'];
740
- // return synchronously
741
-
742
- case 'properties':
743
- return this.getProperties();
744
-
745
- case 'ldp:contains':
746
- return this.getLdpContains();
747
- // returns standard arrays synchronously
748
-
749
- case 'permissions':
750
- return this.getPermissions();
751
- // get expanded permissions
752
-
753
- case 'clientContext':
754
- return this.clientContext;
755
- // get saved client context to re-fetch easily a resource
756
-
757
- case 'then':
758
- return;
759
-
760
- default:
761
- return resource.get(property);
762
- }
763
- }
764
- });
765
- }
766
-
767
- }
768
- //# sourceMappingURL=store.js.map