solid-ui 2.4.23 → 2.4.24
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.
- package/dist/main.js +2159 -5039
- package/dist/main.js.map +1 -1
- package/lib/acl/access-controller.js +4 -67
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.js +59 -137
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.js +14 -54
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.js +32 -107
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.js +0 -92
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/index.js +1 -3
- package/lib/acl/index.js.map +1 -1
- package/lib/acl/styles.js +1 -2
- package/lib/acl/styles.js.map +1 -1
- package/lib/chat/bookmarks.js +8 -80
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +109 -180
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +6 -91
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +33 -185
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +37 -150
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +23 -96
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +33 -91
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.js +19 -51
- package/lib/create/create.js.map +1 -1
- package/lib/create/index.js +0 -2
- package/lib/create/index.js.map +1 -1
- package/lib/debug.js +0 -8
- package/lib/debug.js.map +1 -1
- package/lib/folders.js +4 -27
- package/lib/folders.js.map +1 -1
- package/lib/footer/index.js +2 -24
- package/lib/footer/index.js.map +1 -1
- package/lib/footer/styleMap.js.map +1 -1
- package/lib/header/empty-profile.js.map +1 -1
- package/lib/header/index.js +3 -72
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.js +4 -3
- package/lib/header/styleMap.js.map +1 -1
- package/lib/iconBase.js +3 -4
- package/lib/iconBase.js.map +1 -1
- package/lib/index.js +5 -46
- package/lib/index.js.map +1 -1
- package/lib/jss/index.js +3 -9
- package/lib/jss/index.js.map +1 -1
- package/lib/log.js +15 -51
- package/lib/log.js.map +1 -1
- package/lib/login/login.js +74 -303
- package/lib/login/login.js.map +1 -1
- package/lib/matrix/index.js +0 -2
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/matrix.js +7 -55
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/media/index.js +0 -2
- package/lib/media/index.js.map +1 -1
- package/lib/media/media-capture.js +13 -33
- package/lib/media/media-capture.js.map +1 -1
- package/lib/messageArea.js +23 -64
- package/lib/messageArea.js.map +1 -1
- package/lib/noun_Camera_1618446_000000.js.map +1 -1
- package/lib/ns.js +5 -7
- package/lib/ns.js.map +1 -1
- package/lib/pad.js +48 -234
- package/lib/pad.js.map +1 -1
- package/lib/participation.js +10 -65
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +21 -42
- package/lib/preferences.js.map +1 -1
- package/lib/signup/config-default.js +1 -8
- package/lib/signup/config-default.js.map +1 -1
- package/lib/signup/signup.js +6 -13
- package/lib/signup/signup.js.map +1 -1
- package/lib/stories/decorators.js +0 -2
- package/lib/stories/decorators.js.map +1 -1
- package/lib/style.js +8 -5
- package/lib/style.js.map +1 -1
- package/lib/style_multiSelect.js +1 -5
- package/lib/style_multiSelect.js.map +1 -1
- package/lib/table.js +309 -322
- package/lib/table.js.map +1 -1
- package/lib/tabs.js +20 -100
- package/lib/tabs.js.map +1 -1
- package/lib/utils/headerFooterHelpers.js +4 -52
- package/lib/utils/headerFooterHelpers.js.map +1 -1
- package/lib/utils/index.js +41 -135
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/label.js +13 -34
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +4 -4
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.js +0 -8
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- package/lib/widgets/buttons.js +115 -291
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +12 -41
- package/lib/widgets/dragAndDrop.js.map +1 -1
- package/lib/widgets/error.js +3 -9
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +8 -71
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.js +13 -65
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +15 -107
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +6 -55
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +12 -131
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.js +12 -55
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.js +1 -15
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.js +3 -16
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/fieldParams.js +0 -12
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms/formStyle.js +1 -14
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +70 -474
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/index.js +0 -21
- package/lib/widgets/index.js.map +1 -1
- package/lib/widgets/multiSelect.js +48 -171
- package/lib/widgets/multiSelect.js.map +1 -1
- package/lib/widgets/peoplePicker.js +20 -90
- package/lib/widgets/peoplePicker.js.map +1 -1
- package/lib/widgets/widgetHelpers.js +2 -9
- package/lib/widgets/widgetHelpers.js.map +1 -1
- package/package.json +28 -28
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -10,23 +9,14 @@ exports.getName = getName;
|
|
|
10
9
|
exports.getPod = getPod;
|
|
11
10
|
exports.getPodOwner = getPodOwner;
|
|
12
11
|
exports.throttle = throttle;
|
|
13
|
-
|
|
14
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
-
|
|
16
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
15
|
var _rdflib = require("rdflib");
|
|
21
|
-
|
|
22
16
|
var _ = require("..");
|
|
23
|
-
|
|
24
17
|
var _styleMap = require("../header/styleMap");
|
|
25
|
-
|
|
26
18
|
var _styleMap2 = require("../footer/styleMap");
|
|
27
|
-
|
|
28
19
|
var _jss = require("../jss");
|
|
29
|
-
|
|
30
20
|
/*
|
|
31
21
|
Copied from mashlib/src/global/metadata.ts
|
|
32
22
|
*/
|
|
@@ -41,42 +31,33 @@ function getStyle(styleClass, type) {
|
|
|
41
31
|
return _styleMap.styleMap[styleClass];
|
|
42
32
|
}
|
|
43
33
|
}
|
|
34
|
+
|
|
44
35
|
/**
|
|
45
36
|
* @ignore exporting this only for the unit test
|
|
46
37
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
38
|
function addStyleClassToElement(element, styleClasses, type) {
|
|
50
39
|
styleClasses.forEach(function (styleClass) {
|
|
51
40
|
var style = getStyle(styleClass, type);
|
|
52
|
-
|
|
53
41
|
var _getClasses = (0, _jss.getClasses)(document.head, (0, _defineProperty2["default"])({}, styleClass, style)),
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
classes = _getClasses.classes;
|
|
56
43
|
element.classList.add(classes[styleClass]);
|
|
57
44
|
});
|
|
58
45
|
}
|
|
59
46
|
/**
|
|
60
47
|
* @ignore exporting this only for the unit test
|
|
61
48
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
49
|
function getPod() {
|
|
65
50
|
// @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers
|
|
66
51
|
return (0, _rdflib.sym)(document.location.origin).site();
|
|
67
52
|
}
|
|
68
53
|
/**
|
|
69
54
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
55
|
function getPodOwner(_x, _x2) {
|
|
73
56
|
return _getPodOwner.apply(this, arguments);
|
|
74
57
|
}
|
|
75
58
|
/**
|
|
76
59
|
* @ignore exporting this only for the unit test
|
|
77
60
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
61
|
function _getPodOwner() {
|
|
81
62
|
_getPodOwner = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(pod, store) {
|
|
82
63
|
var response, containerTurtle, podOwner, guess;
|
|
@@ -85,72 +66,57 @@ function _getPodOwner() {
|
|
|
85
66
|
switch (_context.prev = _context.next) {
|
|
86
67
|
case 0:
|
|
87
68
|
_context.prev = 0;
|
|
88
|
-
|
|
89
69
|
if (store.any(pod, null, _.ns.ldp('Container'), pod)) {
|
|
90
70
|
_context.next = 7;
|
|
91
71
|
break;
|
|
92
72
|
}
|
|
93
|
-
|
|
94
73
|
_context.next = 4;
|
|
95
74
|
return store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, {
|
|
96
75
|
headers: {
|
|
97
76
|
accept: 'text/turtle'
|
|
98
77
|
}
|
|
99
78
|
}));
|
|
100
|
-
|
|
101
79
|
case 4:
|
|
102
80
|
response = _context.sent;
|
|
103
81
|
containerTurtle = response.responseText;
|
|
104
82
|
(0, _rdflib.parse)(containerTurtle, store, pod.uri, 'text/turtle');
|
|
105
|
-
|
|
106
83
|
case 7:
|
|
107
84
|
_context.next = 13;
|
|
108
85
|
break;
|
|
109
|
-
|
|
110
86
|
case 9:
|
|
111
87
|
_context.prev = 9;
|
|
112
88
|
_context.t0 = _context["catch"](0);
|
|
113
89
|
console.error('Error loading pod ' + pod + ': ' + _context.t0);
|
|
114
90
|
return _context.abrupt("return", null);
|
|
115
|
-
|
|
116
91
|
case 13:
|
|
117
92
|
if (store.holds(pod, _.ns.rdf('type'), _.ns.space('Storage'), pod)) {
|
|
118
93
|
_context.next = 16;
|
|
119
94
|
break;
|
|
120
95
|
}
|
|
121
|
-
|
|
122
96
|
console.warn('Pod ' + pod + ' does not declare itself as a space:Storage');
|
|
123
97
|
return _context.abrupt("return", null);
|
|
124
|
-
|
|
125
98
|
case 16:
|
|
126
99
|
podOwner = store.any(pod, _.ns.solid('owner'), null, pod) || store.any(null, _.ns.space('storage'), pod, pod);
|
|
127
|
-
|
|
128
100
|
if (!podOwner) {
|
|
129
101
|
_context.next = 31;
|
|
130
102
|
break;
|
|
131
103
|
}
|
|
132
|
-
|
|
133
104
|
_context.prev = 18;
|
|
134
105
|
_context.next = 21;
|
|
135
106
|
return store.fetcher.load(podOwner.doc());
|
|
136
|
-
|
|
137
107
|
case 21:
|
|
138
108
|
_context.next = 27;
|
|
139
109
|
break;
|
|
140
|
-
|
|
141
110
|
case 23:
|
|
142
111
|
_context.prev = 23;
|
|
143
112
|
_context.t1 = _context["catch"](18);
|
|
144
113
|
console.warn('Unable to load profile of pod owner ' + podOwner);
|
|
145
114
|
return _context.abrupt("return", null);
|
|
146
|
-
|
|
147
115
|
case 27:
|
|
148
116
|
if (!store.holds(podOwner, _.ns.space('storage'), pod, podOwner.doc())) {
|
|
149
117
|
console.warn("Pod owner ".concat(podOwner, " does NOT list pod ").concat(pod, " as their storage"));
|
|
150
118
|
}
|
|
151
|
-
|
|
152
119
|
return _context.abrupt("return", podOwner);
|
|
153
|
-
|
|
154
120
|
case 31:
|
|
155
121
|
// pod owner not declared in pod
|
|
156
122
|
// @@ TODO: This is given the structure that NSS provides
|
|
@@ -159,29 +125,23 @@ function _getPodOwner() {
|
|
|
159
125
|
_context.prev = 32;
|
|
160
126
|
_context.next = 35;
|
|
161
127
|
return store.fetcher.load(guess);
|
|
162
|
-
|
|
163
128
|
case 35:
|
|
164
129
|
_context.next = 41;
|
|
165
130
|
break;
|
|
166
|
-
|
|
167
131
|
case 37:
|
|
168
132
|
_context.prev = 37;
|
|
169
133
|
_context.t2 = _context["catch"](32);
|
|
170
134
|
console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\'t load it.');
|
|
171
135
|
return _context.abrupt("return", null);
|
|
172
|
-
|
|
173
136
|
case 41:
|
|
174
137
|
if (!store.holds(guess, _.ns.space('storage'), pod, guess.doc())) {
|
|
175
138
|
_context.next = 44;
|
|
176
139
|
break;
|
|
177
140
|
}
|
|
178
|
-
|
|
179
141
|
console.warn('Using guessed pod owner webid but it links back.');
|
|
180
142
|
return _context.abrupt("return", guess);
|
|
181
|
-
|
|
182
143
|
case 44:
|
|
183
144
|
return _context.abrupt("return", null);
|
|
184
|
-
|
|
185
145
|
case 45:
|
|
186
146
|
case "end":
|
|
187
147
|
return _context.stop();
|
|
@@ -191,49 +151,41 @@ function _getPodOwner() {
|
|
|
191
151
|
}));
|
|
192
152
|
return _getPodOwner.apply(this, arguments);
|
|
193
153
|
}
|
|
194
|
-
|
|
195
154
|
function getName(store, user) {
|
|
196
155
|
return store.anyValue(user, _.ns.vcard('fn'), null, user.doc()) || store.anyValue(user, _.ns.foaf('name'), null, user.doc()) || user.uri;
|
|
197
156
|
}
|
|
198
157
|
/**
|
|
199
158
|
* @ignore exporting this only for the unit test
|
|
200
159
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
160
|
function throttle(func, wait) {
|
|
204
161
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
205
162
|
var context, args, result;
|
|
206
163
|
var timeout = null;
|
|
207
164
|
var previous = 0;
|
|
208
|
-
|
|
209
165
|
var later = function later() {
|
|
210
166
|
previous = !options.leading ? 0 : Date.now();
|
|
211
167
|
timeout = null;
|
|
212
168
|
result = func.apply(context, args);
|
|
213
169
|
if (!timeout) context = args = null;
|
|
214
170
|
};
|
|
215
|
-
|
|
216
171
|
return function () {
|
|
217
172
|
var now = Date.now();
|
|
218
173
|
if (!previous && !options.leading) previous = now;
|
|
219
|
-
var remaining = wait - (now - previous);
|
|
220
|
-
|
|
174
|
+
var remaining = wait - (now - previous);
|
|
175
|
+
// @ts-ignore
|
|
221
176
|
context = this;
|
|
222
177
|
args = arguments;
|
|
223
|
-
|
|
224
178
|
if (remaining <= 0 || remaining > wait) {
|
|
225
179
|
if (timeout) {
|
|
226
180
|
clearTimeout(timeout);
|
|
227
181
|
timeout = null;
|
|
228
182
|
}
|
|
229
|
-
|
|
230
183
|
previous = now;
|
|
231
184
|
result = func.apply(context, args);
|
|
232
185
|
if (!timeout) context = args = null;
|
|
233
186
|
} else if (!timeout && options.trailing !== false) {
|
|
234
187
|
timeout = setTimeout(later, remaining);
|
|
235
188
|
}
|
|
236
|
-
|
|
237
189
|
return result;
|
|
238
190
|
};
|
|
239
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headerFooterHelpers.js","names":["getStyle","styleClass","type","footerStyleMap","headerStyleMap","addStyleClassToElement","element","styleClasses","forEach","style","getClasses","document","head","classes","classList","add","getPod","sym","location","origin","site","getPodOwner","pod","store","any","ns","ldp","fetcher","webOperation","uri","initFetchOptions","headers","accept","response","containerTurtle","responseText","parse","console","error","holds","rdf","space","warn","podOwner","solid","load","doc","guess","getName","user","anyValue","vcard","foaf","throttle","func","wait","options","context","args","result","timeout","previous","later","leading","Date","now","apply","remaining","arguments","clearTimeout","trailing","setTimeout"],"sources":["../../src/utils/headerFooterHelpers.ts"],"sourcesContent":["/*\n Copied from mashlib/src/global/metadata.ts\n */\nimport { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib'\nimport { ns } from '..'\nimport { styleMap as headerStyleMap } from '../header/styleMap'\nimport { styleMap as footerStyleMap } from '../footer/styleMap'\nimport { getClasses } from '../jss'\n\n/* @ts-ignore no-console */\ntype ThrottleOptions = {\n leading?: boolean;\n throttling?: boolean;\n trailing?: boolean;\n}\n/**\n * @internal\n */\nfunction getStyle (styleClass, type?) {\n if (type && type === 'footer') {\n return footerStyleMap[styleClass]\n } else {\n return headerStyleMap[styleClass]\n }\n}\n\n/**\n * @ignore exporting this only for the unit test\n */\nexport function addStyleClassToElement (element: any, styleClasses: string[], type?: string) {\n styleClasses.forEach((styleClass) => {\n const style = getStyle(styleClass, type)\n const { classes } = getClasses(document.head, { [styleClass]: style })\n element.classList.add(classes[styleClass])\n })\n}\n/**\n * @ignore exporting this only for the unit test\n */\nexport function getPod (): NamedNode {\n // @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers\n return sym(document.location.origin).site()\n}\n/**\n */\nexport async function getPodOwner (pod: NamedNode, store: LiveStore): Promise<NamedNode | null> {\n // This is a massive guess. In future\n // const podOwner = sym(`${pod.uri}profile/card#me`)\n/* eslint-disable no-console */\n try {\n // load turtle Container representation\n if (!store.any(pod, null, ns.ldp('Container'), pod)) {\n const response = await store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, { headers: { accept: 'text/turtle' } }))\n const containerTurtle = response.responseText\n parse(containerTurtle as string, store, pod.uri, 'text/turtle')\n }\n } catch (err) {\n console.error('Error loading pod ' + pod + ': ' + err)\n return null\n }\n if (!store.holds(pod, ns.rdf('type'), ns.space('Storage'), pod)) {\n console.warn('Pod ' + pod + ' does not declare itself as a space:Storage')\n return null\n }\n const podOwner = store.any(pod, ns.solid('owner'), null, pod) ||\n store.any(null, ns.space('storage'), pod, pod)\n if (podOwner) {\n try {\n await store.fetcher.load((podOwner as NamedNode).doc())\n } catch (err) {\n console.warn('Unable to load profile of pod owner ' + podOwner)\n return null\n }\n if (!store.holds(podOwner, ns.space('storage'), pod, (podOwner as NamedNode).doc())) {\n console.warn(`Pod owner ${podOwner} does NOT list pod ${pod} as their storage`)\n }\n return podOwner as NamedNode// Success!\n } else { // pod owner not declared in pod\n // @@ TODO: This is given the structure that NSS provides\n // This is a massive guess. For old pods which don't have owner link\n const guess = sym(`${pod.uri}profile/card#me`)\n try {\n // @ts-ignore LiveStore always has fetcher\n await store.fetcher.load(guess)\n } catch (err) {\n console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\\'t load it.')\n return null\n }\n if (store.holds(guess, ns.space('storage'), pod, guess.doc())) {\n console.warn('Using guessed pod owner webid but it links back.')\n return guess\n }\n return null\n }\n /* eslint-enable no-console */\n}\n/**\n * @ignore exporting this only for the unit test\n */\nexport function getName (store: IndexedFormula, user: NamedNode): string {\n return store.anyValue(user, ns.vcard('fn'), null, user.doc()) ||\n store.anyValue(user, ns.foaf('name'), null, user.doc()) ||\n user.uri\n}\n/**\n * @ignore exporting this only for the unit test\n */\nexport function throttle (func: Function, wait: number, options: ThrottleOptions = {}): (...args: any[]) => any {\n let context: any,\n args: any,\n result: any\n let timeout: any = null\n let previous = 0\n const later = function () {\n previous = !options.leading ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n return function () {\n const now = Date.now()\n if (!previous && !options.leading) previous = now\n const remaining = wait - (now - previous)\n // @ts-ignore\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n return result\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"headerFooterHelpers.js","names":["getStyle","styleClass","type","footerStyleMap","headerStyleMap","addStyleClassToElement","element","styleClasses","forEach","style","getClasses","document","head","classes","classList","add","getPod","sym","location","origin","site","getPodOwner","pod","store","any","ns","ldp","fetcher","webOperation","uri","initFetchOptions","headers","accept","response","containerTurtle","responseText","parse","console","error","holds","rdf","space","warn","podOwner","solid","load","doc","guess","getName","user","anyValue","vcard","foaf","throttle","func","wait","options","context","args","result","timeout","previous","later","leading","Date","now","apply","remaining","arguments","clearTimeout","trailing","setTimeout"],"sources":["../../src/utils/headerFooterHelpers.ts"],"sourcesContent":["/*\n Copied from mashlib/src/global/metadata.ts\n */\nimport { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib'\nimport { ns } from '..'\nimport { styleMap as headerStyleMap } from '../header/styleMap'\nimport { styleMap as footerStyleMap } from '../footer/styleMap'\nimport { getClasses } from '../jss'\n\n/* @ts-ignore no-console */\ntype ThrottleOptions = {\n leading?: boolean;\n throttling?: boolean;\n trailing?: boolean;\n}\n/**\n * @internal\n */\nfunction getStyle (styleClass, type?) {\n if (type && type === 'footer') {\n return footerStyleMap[styleClass]\n } else {\n return headerStyleMap[styleClass]\n }\n}\n\n/**\n * @ignore exporting this only for the unit test\n */\nexport function addStyleClassToElement (element: any, styleClasses: string[], type?: string) {\n styleClasses.forEach((styleClass) => {\n const style = getStyle(styleClass, type)\n const { classes } = getClasses(document.head, { [styleClass]: style })\n element.classList.add(classes[styleClass])\n })\n}\n/**\n * @ignore exporting this only for the unit test\n */\nexport function getPod (): NamedNode {\n // @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers\n return sym(document.location.origin).site()\n}\n/**\n */\nexport async function getPodOwner (pod: NamedNode, store: LiveStore): Promise<NamedNode | null> {\n // This is a massive guess. In future\n // const podOwner = sym(`${pod.uri}profile/card#me`)\n/* eslint-disable no-console */\n try {\n // load turtle Container representation\n if (!store.any(pod, null, ns.ldp('Container'), pod)) {\n const response = await store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, { headers: { accept: 'text/turtle' } }))\n const containerTurtle = response.responseText\n parse(containerTurtle as string, store, pod.uri, 'text/turtle')\n }\n } catch (err) {\n console.error('Error loading pod ' + pod + ': ' + err)\n return null\n }\n if (!store.holds(pod, ns.rdf('type'), ns.space('Storage'), pod)) {\n console.warn('Pod ' + pod + ' does not declare itself as a space:Storage')\n return null\n }\n const podOwner = store.any(pod, ns.solid('owner'), null, pod) ||\n store.any(null, ns.space('storage'), pod, pod)\n if (podOwner) {\n try {\n await store.fetcher.load((podOwner as NamedNode).doc())\n } catch (err) {\n console.warn('Unable to load profile of pod owner ' + podOwner)\n return null\n }\n if (!store.holds(podOwner, ns.space('storage'), pod, (podOwner as NamedNode).doc())) {\n console.warn(`Pod owner ${podOwner} does NOT list pod ${pod} as their storage`)\n }\n return podOwner as NamedNode// Success!\n } else { // pod owner not declared in pod\n // @@ TODO: This is given the structure that NSS provides\n // This is a massive guess. For old pods which don't have owner link\n const guess = sym(`${pod.uri}profile/card#me`)\n try {\n // @ts-ignore LiveStore always has fetcher\n await store.fetcher.load(guess)\n } catch (err) {\n console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\\'t load it.')\n return null\n }\n if (store.holds(guess, ns.space('storage'), pod, guess.doc())) {\n console.warn('Using guessed pod owner webid but it links back.')\n return guess\n }\n return null\n }\n /* eslint-enable no-console */\n}\n/**\n * @ignore exporting this only for the unit test\n */\nexport function getName (store: IndexedFormula, user: NamedNode): string {\n return store.anyValue(user, ns.vcard('fn'), null, user.doc()) ||\n store.anyValue(user, ns.foaf('name'), null, user.doc()) ||\n user.uri\n}\n/**\n * @ignore exporting this only for the unit test\n */\nexport function throttle (func: Function, wait: number, options: ThrottleOptions = {}): (...args: any[]) => any {\n let context: any,\n args: any,\n result: any\n let timeout: any = null\n let previous = 0\n const later = function () {\n previous = !options.leading ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n return function () {\n const now = Date.now()\n if (!previous && !options.leading) previous = now\n const remaining = wait - (now - previous)\n // @ts-ignore\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n return result\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;AAPA;AACA;AACA;;AAaA;AACA;AACA;AACA,SAASA,QAAQ,CAAEC,UAAU,EAAEC,IAAK,EAAE;EACpC,IAAIA,IAAI,IAAIA,IAAI,KAAK,QAAQ,EAAE;IAC7B,OAAOC,mBAAc,CAACF,UAAU,CAAC;EACnC,CAAC,MAAM;IACL,OAAOG,kBAAc,CAACH,UAAU,CAAC;EACnC;AACF;;AAEA;AACA;AACA;AACO,SAASI,sBAAsB,CAAEC,OAAY,EAAEC,YAAsB,EAAEL,IAAa,EAAE;EAC3FK,YAAY,CAACC,OAAO,CAAC,UAACP,UAAU,EAAK;IACnC,IAAMQ,KAAK,GAAGT,QAAQ,CAACC,UAAU,EAAEC,IAAI,CAAC;IACxC,kBAAoB,IAAAQ,eAAU,EAACC,QAAQ,CAACC,IAAI,uCAAKX,UAAU,EAAGQ,KAAK,EAAG;MAA9DI,OAAO,eAAPA,OAAO;IACfP,OAAO,CAACQ,SAAS,CAACC,GAAG,CAACF,OAAO,CAACZ,UAAU,CAAC,CAAC;EAC5C,CAAC,CAAC;AACJ;AACA;AACA;AACA;AACO,SAASe,MAAM,GAAe;EACnC;EACA,OAAO,IAAAC,WAAG,EAACN,QAAQ,CAACO,QAAQ,CAACC,MAAM,CAAC,CAACC,IAAI,EAAE;AAC7C;AACA;AACA;AADA,SAEsBC,WAAW;EAAA;AAAA;AAmDjC;AACA;AACA;AAFA;EAAA,6FAnDO,iBAA4BC,GAAc,EAAEC,KAAgB;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA;YAAA,IAM1DA,KAAK,CAACC,GAAG,CAACF,GAAG,EAAE,IAAI,EAAEG,IAAE,CAACC,GAAG,CAAC,WAAW,CAAC,EAAEJ,GAAG,CAAC;cAAA;cAAA;YAAA;YAAA;YAAA,OAC1BC,KAAK,CAACI,OAAO,CAACC,YA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