@startinblox/core 0.17.22 → 0.17.23

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