solid-ui 2.4.16-29d82bfe → 2.4.16-48f3ebed
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/lib/acl/add-agent-buttons.js +1 -1
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/chat/message.js +3 -3
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/thread.js +1 -1
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.js +1 -1
- package/lib/create/create.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -8
- package/lib/index.js.map +1 -1
- package/lib/login/login.d.ts +3 -3
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +28 -25
- package/lib/login/login.js.map +1 -1
- package/lib/messageArea.js +1 -1
- package/lib/messageArea.js.map +1 -1
- package/lib/participation.d.ts.map +1 -1
- package/lib/participation.js +59 -30
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +1 -1
- package/lib/preferences.js.map +1 -1
- package/lib/utils/label.js +1 -2
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +9 -9
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +826 -628
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +3 -1
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +14 -7
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/package.json +12 -3
- package/lib/logic.d.ts +0 -8
- package/lib/logic.d.ts.map +0 -1
- package/lib/logic.js +0 -77
- package/lib/logic.js.map +0 -1
package/lib/participation.js
CHANGED
|
@@ -28,6 +28,8 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
|
|
|
28
28
|
|
|
29
29
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
30
30
|
|
|
31
|
+
var debug = _interopRequireWildcard(require("./debug"));
|
|
32
|
+
|
|
31
33
|
var _rdflib = require("rdflib");
|
|
32
34
|
|
|
33
35
|
var ns = _interopRequireWildcard(require("./ns"));
|
|
@@ -38,14 +40,18 @@ var _utils = require("./utils");
|
|
|
38
40
|
|
|
39
41
|
var _pad = require("./pad");
|
|
40
42
|
|
|
41
|
-
var _debug = require("./debug");
|
|
42
|
-
|
|
43
43
|
var _solidLogic = require("solid-logic");
|
|
44
44
|
|
|
45
45
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
46
46
|
|
|
47
47
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
48
48
|
|
|
49
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
50
|
+
|
|
51
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
52
|
+
|
|
53
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
54
|
+
|
|
49
55
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
50
56
|
|
|
51
57
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -72,7 +78,7 @@ var ParticipationTableElement = /*#__PURE__*/function (_HTMLTableElement) {
|
|
|
72
78
|
return (0, _createClass2["default"])(ParticipationTableElement);
|
|
73
79
|
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLTableElement));
|
|
74
80
|
|
|
75
|
-
var
|
|
81
|
+
var store = _solidLogic.solidLogicSingleton.store;
|
|
76
82
|
/** Manage participation in this session
|
|
77
83
|
*
|
|
78
84
|
* @param {Document} dom - the web page loaded into the browser
|
|
@@ -87,7 +93,7 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
|
|
|
87
93
|
table.setAttribute('style', 'margin: 0.8em;');
|
|
88
94
|
|
|
89
95
|
var newRowForParticpation = function newRowForParticpation(parp) {
|
|
90
|
-
var person =
|
|
96
|
+
var person = store.any(parp, ns.wf('participant'));
|
|
91
97
|
var tr;
|
|
92
98
|
|
|
93
99
|
if (!person) {
|
|
@@ -97,7 +103,7 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
|
|
|
97
103
|
return tr;
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
var bg =
|
|
106
|
+
var bg = store.anyValue(parp, ns.ui('backgroundColor')) || 'white';
|
|
101
107
|
var block = dom.createElement('div');
|
|
102
108
|
block.setAttribute('style', 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888; background-color: ' + bg);
|
|
103
109
|
tr = (0, _widgets.personTR)(dom, null, person, options);
|
|
@@ -110,9 +116,9 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
|
|
|
110
116
|
};
|
|
111
117
|
|
|
112
118
|
var syncTable = function syncTable() {
|
|
113
|
-
var parps =
|
|
114
|
-
(0,
|
|
115
|
-
return [
|
|
119
|
+
var parps = store.each(subject, ns.wf('participation')).map(function (parp) {
|
|
120
|
+
(0, debug.log)('in participants');
|
|
121
|
+
return [store.anyValue(parp, ns.cal('dtstart')) || '9999-12-31', parp];
|
|
116
122
|
});
|
|
117
123
|
parps.sort(); // List in order of joining
|
|
118
124
|
|
|
@@ -140,36 +146,57 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
|
|
|
140
146
|
function participationObject(subject, padDoc, me) {
|
|
141
147
|
return new Promise(function (resolve, reject) {
|
|
142
148
|
if (!me) {
|
|
143
|
-
throw new Error('
|
|
149
|
+
throw new Error('No user id');
|
|
144
150
|
}
|
|
145
151
|
|
|
146
|
-
var parps =
|
|
147
|
-
return
|
|
152
|
+
var parps = store.each(subject, ns.wf('participation')).filter(function (pn) {
|
|
153
|
+
return store.holds(pn, ns.wf('participant'), me);
|
|
148
154
|
});
|
|
149
155
|
|
|
150
156
|
if (parps.length > 1) {
|
|
151
|
-
|
|
157
|
+
// This can happen. https://github.com/solid/chat-pane/issues/71
|
|
158
|
+
var candidates = [];
|
|
159
|
+
|
|
160
|
+
var _iterator = _createForOfIteratorHelper(parps),
|
|
161
|
+
_step;
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
165
|
+
var participation = _step.value;
|
|
166
|
+
var date = store.anyValue(participation, ns.cal('dtstart'));
|
|
167
|
+
|
|
168
|
+
if (date) {
|
|
169
|
+
candidates.push([date, participation]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
_iterator.e(err);
|
|
174
|
+
} finally {
|
|
175
|
+
_iterator.f();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
candidates.sort(); // Pick the earliest
|
|
179
|
+
// @@ Possibly, for extra credit, delete the others, if we have write access
|
|
180
|
+
|
|
181
|
+
debug.warn('Multiple particpation objects, picking earliest, in ' + padDoc);
|
|
182
|
+
resolve(candidates[0][1]); // throw new Error('Multiple records of your participation')
|
|
152
183
|
}
|
|
153
184
|
|
|
154
185
|
if (parps.length) {
|
|
155
186
|
// If I am not already recorded
|
|
156
187
|
resolve(parps[0]); // returns the particpation object
|
|
157
188
|
} else {
|
|
158
|
-
var
|
|
159
|
-
var ins = [(0, _rdflib.st)(subject, ns.wf('participation'), participation, padDoc), (0, _rdflib.st)(participation, ns.wf('participant'), me, padDoc), (0, _rdflib.st)(participation, ns.cal('dtstart'), new Date(), padDoc), (0, _rdflib.st)(participation, ns.ui('backgroundColor'), (0, _pad.lightColorHash)(me), padDoc)];
|
|
189
|
+
var _participation2 = (0, _widgets.newThing)(padDoc);
|
|
160
190
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
kb.updater.update([], ins, function (uri, ok, errorMessage) {
|
|
191
|
+
var ins = [(0, _rdflib.st)(subject, ns.wf('participation'), _participation2, padDoc), (0, _rdflib.st)(_participation2, ns.wf('participant'), me, padDoc), (0, _rdflib.st)(_participation2, ns.cal('dtstart'), new Date(), padDoc), (0, _rdflib.st)(_participation2, ns.ui('backgroundColor'), (0, _pad.lightColorHash)(me), padDoc)];
|
|
192
|
+
store.updater.update([], ins, function (uri, ok, errorMessage) {
|
|
166
193
|
if (!ok) {
|
|
167
194
|
reject(new Error('Error recording your partipation: ' + errorMessage));
|
|
168
195
|
} else {
|
|
169
|
-
resolve(
|
|
196
|
+
resolve(_participation2);
|
|
170
197
|
}
|
|
171
198
|
});
|
|
172
|
-
resolve(
|
|
199
|
+
resolve(_participation2);
|
|
173
200
|
}
|
|
174
201
|
});
|
|
175
202
|
}
|
|
@@ -187,8 +214,8 @@ function recordParticipation(subject, padDoc, refreshable) {
|
|
|
187
214
|
|
|
188
215
|
if (!me) return; // Not logged in
|
|
189
216
|
|
|
190
|
-
var parps =
|
|
191
|
-
return
|
|
217
|
+
var parps = store.each(subject, ns.wf('participation')).filter(function (pn) {
|
|
218
|
+
return store.holds(pn, ns.wf('participant'), me);
|
|
192
219
|
});
|
|
193
220
|
|
|
194
221
|
if (parps.length > 1) {
|
|
@@ -199,14 +226,14 @@ function recordParticipation(subject, padDoc, refreshable) {
|
|
|
199
226
|
// If I am not already recorded
|
|
200
227
|
return parps[0]; // returns the particpation object
|
|
201
228
|
} else {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (!kb.updater) {
|
|
206
|
-
throw new Error('kb has no updater');
|
|
229
|
+
if (!store.updater.editable(padDoc)) {
|
|
230
|
+
debug.log('Not recording participation, as no write acesss as ' + me + ' to ' + padDoc);
|
|
231
|
+
return null;
|
|
207
232
|
}
|
|
208
233
|
|
|
209
|
-
|
|
234
|
+
var participation = (0, _widgets.newThing)(padDoc);
|
|
235
|
+
var ins = [(0, _rdflib.st)(subject, ns.wf('participation'), participation, padDoc), (0, _rdflib.st)(participation, ns.wf('participant'), me, padDoc), (0, _rdflib.st)(participation, ns.cal('dtstart'), new Date(), padDoc), (0, _rdflib.st)(participation, ns.ui('backgroundColor'), (0, _pad.lightColorHash)(me), padDoc)];
|
|
236
|
+
store.updater.update([], ins, function (uri, ok, errorMessage) {
|
|
210
237
|
if (!ok) {
|
|
211
238
|
throw new Error('Error recording your partipation: ' + errorMessage);
|
|
212
239
|
}
|
|
@@ -236,8 +263,10 @@ function manageParticipation(dom, container, padDoc, subject, me, options) {
|
|
|
236
263
|
container.appendChild(table);
|
|
237
264
|
renderPartipants(dom, table, padDoc, subject, me, options);
|
|
238
265
|
|
|
266
|
+
var _participation;
|
|
267
|
+
|
|
239
268
|
try {
|
|
240
|
-
recordParticipation(subject, padDoc, table);
|
|
269
|
+
_participation = recordParticipation(subject, padDoc, table);
|
|
241
270
|
} catch (e) {
|
|
242
271
|
container.appendChild((0, _widgets.errorMessageBlock)(dom, 'Error recording your partipation: ' + e)); // Clean up?
|
|
243
272
|
}
|
package/lib/participation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/participation.ts"],"names":["ParticipationTableElement","HTMLTableElement","kb","solidLogicSingleton","store","renderPartipants","dom","table","unused1","subject","unused2","options","setAttribute","newRowForParticpation","parp","person","any","ns","wf","tr","createElement","textContent","bg","anyValue","ui","block","appendChild","td","insertBefore","firstChild","syncTable","parps","each","map","cal","sort","participations","p","refresh","participationObject","padDoc","me","Promise","resolve","reject","Error","filter","pn","holds","length","participation","ins","Date","updater","update","uri","ok","errorMessage","recordParticipation","refreshable","authn","currentUser","managePartic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D,CAAP,EAAU;AACVD,IAAAA,SAAS,CAACrC,WAAV,CACE,gCACEpB,GADF,EAEE,uCAAuC0D,CAFzC,CADF,EADU,CAMR;AACH;;AACD,SAAOzD,KAAP;AACD","sourcesContent":["/* Manage a UI for the particpation of a person in any thing\n*/\n\n// import { currentUser } from './authn/authn'\nimport { NamedNode, st } from 'rdflib'\nimport * as ns from './ns'\nimport { personTR, newThing, errorMessageBlock } from './widgets'\nimport { syncTableToArray } from './utils'\nimport { lightColorHash } from './pad'\nimport { log } from './debug'\nimport { solidLogicSingleton, authn } from 'solid-logic'\n\ntype ParticipationOptions = {\n deleteFunction?: () => {}\n link?: string\n draggable?: boolean\n}\n\nclass ParticipationTableElement extends HTMLTableElement {\n refresh?: () => void\n}\nconst kb = solidLogicSingleton.store\n\n/** Manage participation in this session\n*\n* @param {Document} dom - the web page loaded into the browser\n* @param {HTMLTableElement} table - the table element\n* @param {NamedNode} unused1/document - the document to render (this argument is no longer used, but left in for backwards compatibility)\n* @param {NamedNode} subject - the thing in which the participation is happening\n* @param {NamedNode} unused2/me - user that is logged into the pod (this argument is no longer used, but left in for backwards compatibility)\n* @param {ParticipationOptions} options - the options that can be passed in are deleteFunction, link, and draggable these are used by the personTR button\n*/\nexport function renderPartipants (dom: HTMLDocument, table: ParticipationTableElement, unused1: NamedNode, subject: NamedNode, unused2: NamedNode, options: ParticipationOptions) {\n table.setAttribute('style', 'margin: 0.8em;')\n\n const newRowForParticpation = function (parp) {\n const person = kb.any(parp, ns.wf('participant'))\n\n let tr\n if (!person) {\n tr = dom.createElement('tr')\n tr.textContent = '???' // Don't crash - invalid part'n entry\n return tr\n }\n const bg = kb.anyValue(parp, ns.ui('backgroundColor')) || 'white'\n\n const block = dom.createElement('div')\n block.setAttribute(\n 'style',\n 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888; background-color: ' +\n bg\n )\n tr = personTR(dom, null, person, options)\n table.appendChild(tr)\n const td = dom.createElement('td')\n td.setAttribute('style', 'vertical-align: middle;')\n td.appendChild(block)\n tr.insertBefore(td, tr.firstChild)\n return tr\n }\n\n const syncTable = function () {\n const parps = kb.each(subject, ns.wf('participation')).map(function (parp) {\n log('in participants')\n return [kb.anyValue(parp as any, ns.cal('dtstart')) || '9999-12-31', parp]\n })\n parps.sort() // List in order of joining\n const participations = parps.map(function (p) {\n return p[1]\n })\n syncTableToArray(table, participations, newRowForParticpation)\n }\n table.refresh = syncTable\n syncTable()\n return table\n}\n\n/** Record, or find old, Particpation object\n *\n * A particpaption object is a place to record things specifically about\n * subject and the user, such as preferences, start of membership, etc\n * @param {NamedNode} subject - the thing in which the participation is happening\n * @param {NamedNode} document - where to record the data\n * @param {NamedNode} me - the logged in user\n *\n */\nexport function participationObject (subject: NamedNode, padDoc: NamedNode, me: NamedNode) {\n return new Promise(function (resolve, reject) {\n if (!me) {\n throw new Error('Not user id')\n }\n\n const parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {\n return kb.holds(pn, ns.wf('participant'), me)\n })\n if (parps.length > 1) {\n throw new Error('Multiple records of your participation')\n }\n if (parps.length) {\n // If I am not already recorded\n resolve(parps[0]) // returns the particpation object\n } else {\n const participation = newThing(padDoc)\n const ins = [\n st(subject, ns.wf('participation'), participation, padDoc),\n\n st(participation, ns.wf('participant'), me, padDoc),\n st(participation, ns.cal('dtstart'), new Date() as any, padDoc),\n st(\n participation,\n ns.ui('backgroundColor'),\n lightColorHash(me) as any,\n padDoc\n )\n ]\n if (!kb.updater) {\n throw new Error('kb has no updater')\n }\n kb.updater.update([], ins, function (uri: string | null | undefined, ok: boolean, errorMessage?: string) {\n if (!ok) {\n reject(new Error('Error recording your partipation: ' + errorMessage))\n } else {\n resolve(participation)\n }\n })\n resolve(participation)\n }\n })\n}\n\n/** Record my participation and display participants\n *\n * @param {NamedNode} subject - the thing in which participation is happening\n * @param {NamedNode} padDoc - the document into which the particpation should be recorded\n * @param {DOMNode} refreshable - a DOM element whose refresh() is to be called if the change works\n *\n */\nexport function recordParticipation (subject: NamedNode, padDoc: NamedNode, refreshable: any) {\n const me = authn.currentUser()\n if (!me) return // Not logged in\n\n const parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {\n return kb.holds(pn, ns.wf('participant'), me)\n })\n if (parps.length > 1) {\n throw new Error('Multiple records of your participation')\n }\n if (parps.length) {\n // If I am not already recorded\n return parps[0] // returns the particpation object\n } else {\n const participation = newThing(padDoc)\n const ins = [\n st(subject, ns.wf('participation'), participation, padDoc),\n\n st(participation, ns.wf('participant'), me, padDoc),\n st(participation, ns.cal('dtstart'), new Date() as any, padDoc),\n st(\n participation,\n ns.ui('backgroundColor'),\n lightColorHash(me) as any,\n padDoc\n )\n ]\n if (!kb.updater) {\n throw new Error('kb has no updater')\n }\n kb.updater.update([], ins, function (uri: string | null | undefined, ok: boolean, errorMessage?: string) {\n if (!ok) {\n throw new Error('Error recording your partipation: ' + errorMessage)\n }\n if (refreshable && refreshable.refresh) {\n refreshable.refresh()\n }\n // UI.pad.renderPartipants(dom, table, padDoc, subject, me, options)\n })\n return participation\n }\n}\n\n/** Record my participation and display participants\n*\n* @param {Document} dom - the web page loaded into the browser\n* @param {HTMLDivElement} container - the container element where the participants should be displayed\n* @param {NamedNode} document - the document into which the particpation should be shown\n* @param {NamedNode} subject - the thing in which participation is happening\n* @param {NamedNode} me - the logged in user\n* @param {ParticipationOptions} options - the options that can be passed in are deleteFunction, link, and draggable these are used by the personTR button\n*\n*/\nexport function manageParticipation (\n dom: Document,\n container: HTMLDivElement,\n padDoc: NamedNode,\n subject: NamedNode,\n me: NamedNode,\n options: ParticipationOptions\n) {\n const table = dom.createElement('table')\n container.appendChild(table)\n renderPartipants(dom, table, padDoc, subject, me, options)\n try {\n recordParticipation(subject, padDoc, table)\n } catch (e) {\n container.appendChild(\n errorMessageBlock(\n dom,\n 'Error recording your partipation: ' + e\n )\n ) // Clean up?\n }\n return table\n}\n"],"file":"participation.js"}
|
|
1
|
+
{"version":3,"sources":["../src/participation.ts"],"names":["ParticipationTableElement","HTMLTableElement","store","solidLogicSingleton","renderPartipants","dom","table","unused1","subject","unused2","options","setAttribute","newRowForParticpation","parp","person","any","ns","wf","tr","createElement","textContent","bg","anyValue","ui","block","appendChild","td","insertBefore","firstChild","syncTable","parps","each","map","cal","sort","participations","p","refresh","participationObject","padDoc","me","Promise","resolve","reject","Error","filter","pn","holds","length","candidates","participation","date","push","debug","warn","ins","Date","updater","update","uri","ok","errorMessage","recordParticipation","refreshable","authn","currentUser","editable","log","manageParticipation","container","_participation","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;IAQMA,yB;;;;;;;;;;;;;;;;;;;;kDAAkCC,gB;;AAGxC,IAAMC,KAAK,GAAGC,gCAAoBD,KAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASE,gBAAT,CAA2BC,GAA3B,EAA8CC,KAA9C,EAAgFC,OAAhF,EAAoGC,OAApG,EAAwHC,OAAxH,EAA4IC,OAA5I,EAA2K;AAChLJ,EAAAA,KAAK,CAACK,YAAN,CAAmB,OAAnB,EAA4B,gBAA5B;;AAEA,MAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAAUC,IAAV,EAAgB;AAC5C,QAAMC,MAAM,GAAGZ,KAAK,CAACa,GAAN,CAAUF,IAAV,EAAgBG,EAAE,CAACC,EAAH,CAAM,aAAN,CAAhB,CAAf;AAEA,QAAIC,EAAJ;;AACA,QAAI,CAACJ,MAAL,EAAa;AACXI,MAAAA,EAAE,GAAGb,GAAG,CAACc,aAAJ,CAAkB,IAAlB,CAAL;AACAD,MAAAA,EAAE,CAACE,WAAH,GAAiB,KAAjB,CAFW,CAEY;;AACvB,aAAOF,EAAP;AACD;;AACD,QAAMG,EAAE,GAAGnB,KAAK,CAACoB,QAAN,CAAeT,IAAf,EAAqBG,EAAE,CAACO,EAAH,CAAM,iBAAN,CAArB,KAA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AK,CAACuD,OAAP,CAAiCC,MAAjC,CAAwC,EAAxC,EAA4CH,GAA5C,EAAiD,UAAUI,GAAV,EAA0CC,EAA1C,EAAuDC,YAAvD,EAA8E;AAC7H,UAAI,CAACD,EAAL,EAAS;AACP,cAAM,IAAIhB,KAAJ,CAAU,uCAAuCiB,YAAjD,CAAN;AACD;;AACD,UAAIE,WAAW,IAAIA,WAAW,CAAC1B,OAA/B,EAAwC;AACtC0B,QAAAA,WAAW,CAAC1B,OAAZ;AACD,OAN4H,CAO7H;;AACD,KARD;AASA,WAAOa,aAAP;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkB,mBAAT,CACL/D,GADK,EAELgE,SAFK,EAGL9B,MAHK,EAIL/B,OAJK,EAKLgC,EALK,EAML9B,OANK,EAOL;AACA,MAAMJ,KAAK,GAAGD,GAAG,CAACc,aAAJ,CAAkB,OAAlB,CAAd;AACAkD,EAAAA,SAAS,CAAC5C,WAAV,CAAsBnB,KAAtB;AACAF,EAAAA,gBAAgB,CAACC,GAAD,EAAMC,KAAN,EAAaiC,MAAb,EAAqB/B,OAArB,EAA8BgC,EAA9B,EAAkC9B,OAAlC,CAAhB;;AACA,MAAI4D,cAAJ;;AACA,MAAI;AACFA,IAAAA,cAAc,GAAGR,mBAAmB,CAACtD,OAAD,EAAU+B,MAAV,EAAkBjC,KAAlB,CAApC;AACD,GAFD,CAEE,OAAOiE,CAAP,EAAU;AACVF,IAAAA,SAAS,CAAC5C,WAAV,CACE,gCACEpB,GADF,EAEE,uCAAuCkE,CAFzC,CADF,EADU,CAMR;AACH;;AACD,SAAOjE,KAAP;AACD","sourcesContent":["/* Manage a UI for the particpation of a person in any thing\n*/\n\n// import { currentUser } from './authn/authn'\nimport * as debug from './debug'\nimport { LiveStore, NamedNode, st, UpdateManager } from 'rdflib'\nimport * as ns from './ns'\nimport { personTR, newThing, errorMessageBlock } from './widgets'\nimport { syncTableToArray } from './utils'\nimport { lightColorHash } from './pad'\nimport { log } from './debug'\nimport { solidLogicSingleton, authn } from 'solid-logic'\n\ntype ParticipationOptions = {\n deleteFunction?: () => {}\n link?: string\n draggable?: boolean\n}\n\nclass ParticipationTableElement extends HTMLTableElement {\n refresh?: () => void\n}\nconst store = solidLogicSingleton.store as LiveStore\n\n/** Manage participation in this session\n*\n* @param {Document} dom - the web page loaded into the browser\n* @param {HTMLTableElement} table - the table element\n* @param {NamedNode} unused1/document - the document to render (this argument is no longer used, but left in for backwards compatibility)\n* @param {NamedNode} subject - the thing in which the participation is happening\n* @param {NamedNode} unused2/me - user that is logged into the pod (this argument is no longer used, but left in for backwards compatibility)\n* @param {ParticipationOptions} options - the options that can be passed in are deleteFunction, link, and draggable these are used by the personTR button\n*/\nexport function renderPartipants (dom: HTMLDocument, table: ParticipationTableElement, unused1: NamedNode, subject: NamedNode, unused2: NamedNode, options: ParticipationOptions) {\n table.setAttribute('style', 'margin: 0.8em;')\n\n const newRowForParticpation = function (parp) {\n const person = store.any(parp, ns.wf('participant'))\n\n let tr\n if (!person) {\n tr = dom.createElement('tr')\n tr.textContent = '???' // Don't crash - invalid part'n entry\n return tr\n }\n const bg = store.anyValue(parp, ns.ui('backgroundColor')) || 'white'\n\n const block = dom.createElement('div')\n block.setAttribute(\n 'style',\n 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888; background-color: ' +\n bg\n )\n tr = personTR(dom, null, person, options)\n table.appendChild(tr)\n const td = dom.createElement('td')\n td.setAttribute('style', 'vertical-align: middle;')\n td.appendChild(block)\n tr.insertBefore(td, tr.firstChild)\n return tr\n }\n\n const syncTable = function () {\n const parps = store.each(subject, ns.wf('participation')).map(function (parp) {\n log('in participants')\n return [store.anyValue(parp as any, ns.cal('dtstart')) || '9999-12-31', parp]\n })\n parps.sort() // List in order of joining\n const participations = parps.map(function (p) {\n return p[1]\n })\n syncTableToArray(table, participations, newRowForParticpation)\n }\n table.refresh = syncTable\n syncTable()\n return table\n}\n\n/** Record, or find old, Particpation object\n *\n * A particpaption object is a place to record things specifically about\n * subject and the user, such as preferences, start of membership, etc\n * @param {NamedNode} subject - the thing in which the participation is happening\n * @param {NamedNode} document - where to record the data\n * @param {NamedNode} me - the logged in user\n *\n */\nexport function participationObject (subject: NamedNode, padDoc: NamedNode, me: NamedNode) {\n return new Promise(function (resolve, reject) {\n if (!me) {\n throw new Error('No user id')\n }\n\n const parps = store.each(subject, ns.wf('participation')).filter(function (pn) {\n return store.holds(pn, ns.wf('participant'), me)\n })\n if (parps.length > 1) { // This can happen. https://github.com/solid/chat-pane/issues/71\n const candidates: (string | NamedNode) [][] = []\n for (const participation of parps) {\n const date = store.anyValue(participation as NamedNode, ns.cal('dtstart'))\n if (date) {\n candidates.push([date, participation as NamedNode])\n }\n }\n candidates.sort() // Pick the earliest\n // @@ Possibly, for extra credit, delete the others, if we have write access\n debug.warn('Multiple particpation objects, picking earliest, in ' + padDoc)\n resolve(candidates[0][1])\n // throw new Error('Multiple records of your participation')\n }\n if (parps.length) {\n // If I am not already recorded\n resolve(parps[0]) // returns the particpation object\n } else {\n const participation = newThing(padDoc)\n const ins = [\n st(subject, ns.wf('participation'), participation, padDoc),\n\n st(participation, ns.wf('participant'), me, padDoc),\n st(participation, ns.cal('dtstart'), new Date() as any, padDoc),\n st(\n participation,\n ns.ui('backgroundColor'),\n lightColorHash(me) as any,\n padDoc\n )\n ];\n (store.updater as UpdateManager).update([], ins, function (uri: string | null | undefined, ok: boolean, errorMessage?: string) {\n if (!ok) {\n reject(new Error('Error recording your partipation: ' + errorMessage))\n } else {\n resolve(participation)\n }\n })\n resolve(participation)\n }\n })\n}\n\n/** Record my participation and display participants\n *\n * @param {NamedNode} subject - the thing in which participation is happening\n * @param {NamedNode} padDoc - the document into which the particpation should be recorded\n * @param {DOMNode} refreshable - a DOM element whose refresh() is to be called if the change works\n *\n */\nexport function recordParticipation (subject: NamedNode, padDoc: NamedNode, refreshable: any) {\n const me = authn.currentUser()\n if (!me) return // Not logged in\n\n const parps = store.each(subject, ns.wf('participation')).filter(function (pn) {\n return store.holds(pn, ns.wf('participant'), me)\n })\n if (parps.length > 1) {\n throw new Error('Multiple records of your participation')\n }\n if (parps.length) {\n // If I am not already recorded\n return parps[0] // returns the particpation object\n } else {\n if (!(store.updater as UpdateManager).editable(padDoc)) {\n debug.log('Not recording participation, as no write acesss as ' + me + ' to ' + padDoc)\n return null\n }\n const participation = newThing(padDoc)\n const ins = [\n st(subject, ns.wf('participation'), participation, padDoc),\n\n st(participation, ns.wf('participant'), me, padDoc),\n st(participation, ns.cal('dtstart'), new Date() as any, padDoc),\n st(\n participation,\n ns.ui('backgroundColor'),\n lightColorHash(me) as any,\n padDoc\n )\n ];\n (store.updater as UpdateManager).update([], ins, function (uri: string | null | undefined, ok: boolean, errorMessage?: string) {\n if (!ok) {\n throw new Error('Error recording your partipation: ' + errorMessage)\n }\n if (refreshable && refreshable.refresh) {\n refreshable.refresh()\n }\n // UI.pad.renderPartipants(dom, table, padDoc, subject, me, options)\n })\n return participation\n }\n}\n\n/** Record my participation and display participants\n*\n* @param {Document} dom - the web page loaded into the browser\n* @param {HTMLDivElement} container - the container element where the participants should be displayed\n* @param {NamedNode} document - the document into which the particpation should be shown\n* @param {NamedNode} subject - the thing in which participation is happening\n* @param {NamedNode} me - the logged in user\n* @param {ParticipationOptions} options - the options that can be passed in are deleteFunction, link, and draggable these are used by the personTR button\n*\n*/\nexport function manageParticipation (\n dom: Document,\n container: HTMLDivElement,\n padDoc: NamedNode,\n subject: NamedNode,\n me: NamedNode,\n options: ParticipationOptions\n) {\n const table = dom.createElement('table')\n container.appendChild(table)\n renderPartipants(dom, table, padDoc, subject, me, options)\n let _participation\n try {\n _participation = recordParticipation(subject, padDoc, table)\n } catch (e) {\n container.appendChild(\n errorMessageBlock(\n dom,\n 'Error recording your partipation: ' + e\n )\n ) // Clean up?\n }\n return table\n}\n"],"file":"participation.js"}
|
package/lib/preferences.js
CHANGED
|
@@ -90,7 +90,7 @@ function recordSharedPreferences(subject, context) {
|
|
|
90
90
|
|
|
91
91
|
function recordPersonalDefaults(theClass, context) {
|
|
92
92
|
return new Promise(function (resolve, reject) {
|
|
93
|
-
(0, _login.
|
|
93
|
+
(0, _login.ensureLoadedPreferences)(context).then(function (context) {
|
|
94
94
|
if (!context.preferencesFile) {
|
|
95
95
|
debug.log('Not doing private class preferences as no access to preferences file. ' + context.preferencesFileError);
|
|
96
96
|
return;
|
package/lib/preferences.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preferences.js"],"names":["kb","store","value","get","k","set","v","debug","log","Error","recordSharedPreferences","subject","context","Promise","resolve","reject","sharedPreferences","any","ns","ui","sp","$rdf","sym","doc","uri","ins","st","updater","update","ok","errorMessage","recordPersonalDefaults","theClass","then","preferencesFile","preferencesFileError","regs","each","solid","prefs","reg","length","forEach","r","personalDefaults","widgets","newThing","rdf","push","errm","err","renderPreferencesForm","preferencesForm","prefContainer","dom","createElement","participation","participationObject","me","heading","text","appendChild","textContent","noun","appendForm","mes","complain","errorMessageBlock","toJS","term","datatype","equals","xsd","Date","Number","getPreferencesForClass","predicates","results","pred","v1"],"mappings":";;;;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;AAE+B;AAKkB;AAGjD,IAAMA,EAAE,GAAGC,iBAAX,C,CAEA;AACA;AACA;AAEA;AACA;AACA;;AAEO,IAAMC,KAAK,GAAG,EAAd;;;AACA,SAASC,GAAT,CAAcC,CAAd,EAAiB;AACtB,SAAOF,KAAK,CAACE,CAAD,CAAZ;AACD;;AAEM,SAASC,GAAT,CAAcD,CAAd,EAAiBE,CAAjB,EAAoB;AACzB,MAAI,OAAOA,CAAP,KAAa,QAAjB,EAA2B;AACzBC,IAAAA,KAAK,CAACC,GAAN,CAAU,oCAAoCJ,CAApC,GAAwC,IAAxC,GAA+CE,CAAzD;AACA,UAAM,IAAIG,KAAJ,CAAU,oCAAoCL,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IAA1B,CADA,IAEA9E,EAAE,CAACiB,GAAH,CAAO2B,gBAAP,EAAyBkC,IAAzB,CAHF;;AAIA,kBAAIC,EAAJ,EAAQ;AACNF,gBAAAA,OAAO,CAACC,IAAI,CAACtD,GAAN,CAAP,GAAoB4C,IAAI,CAACW,EAAD,CAAxB;AACD;AACF,aATD;AAUAjE,YAAAA,OAAO,CAAC+D,OAAD,CAAP;AACD,WAdD,EAcG9D,MAdH;AAeD,SAlBH,EAkBKA,MAlBL;AAmBD,OApBD,MAoBO;AACL;AACA,YAAM8D,OAAO,GAAG,EAAhB;AACAD,QAAAA,UAAU,CAAClC,OAAX,CAAmB,UAAAoC,IAAI,EAAI;AACzB,cAAMC,EAAE,GAAG/E,EAAE,CAACiB,GAAH,CAAOD,iBAAP,EAA0B8D,IAA1B,CAAX;;AACA,cAAIC,EAAJ,EAAQ;AACNF,YAAAA,OAAO,CAACC,IAAI,CAACtD,GAAN,CAAP,GAAoB4C,IAAI,CAACW,EAAD,CAAxB;AACD;AACF,SALD;AAMAjE,QAAAA,OAAO,CAAC+D,OAAD,CAAP;AACD;AACF,KAjCD;AAkCD,GAnCM,CAAP;AAoCD,C,CAED","sourcesContent":["// Solid-UI preferences\n// =====================\n//\n\nimport * as $rdf from 'rdflib' // pull in first avoid cross-refs\nimport { store } from 'solid-logic'\nimport * as debug from './debug'\nimport { logInLoadPreferences } from './login/login'\nimport * as ns from './ns'\nimport * as participation from './participation' // @ts-ignore\nimport * as widgets from './widgets'\n\nconst kb = store\n\n// This was tabulator . preferences in the tabulator\n// Is this functionality used anywhere?\n//\n\n// used for storing user name\n// @@ Deprocate these functions. They were used for\n// communication around the tabulator functionality about the user session\n\nexport const value = []\nexport function get (k) {\n return value[k]\n}\n\nexport function set (k, v) {\n if (typeof v !== 'string') {\n debug.log('Non-string value of preference ' + k + ': ' + v)\n throw new Error('Non-string value of preference ' + k + ': ' + v)\n }\n this.value[k] = v\n}\n\n// In a solid world, Preferences are stored in the web\n//\n// Make an RDF node for recording the common view preferences for any object\n// (maybe make it in a separate file?)\nexport function recordSharedPreferences (subject, context) {\n return new Promise(function (resolve, reject) {\n const sharedPreferences = kb.any(subject, ns.ui('sharedPreferences'))\n if (!sharedPreferences) {\n const sp = $rdf.sym(subject.doc().uri + '#SharedPreferences')\n const ins = [\n $rdf.st(subject, ns.ui('sharedPreferences'), sp, subject.doc())\n ]\n debug.log('Creating shared preferences ' + sp)\n kb.updater.update([], ins, function (uri, ok, errorMessage) {\n if (!ok) {\n reject(new Error('Error creating shared prefs: ' + errorMessage))\n } else {\n context.sharedPreferences = sp\n resolve(context)\n }\n })\n } else {\n context.sharedPreferences = sharedPreferences\n resolve(context)\n }\n })\n}\n\n// Construct a personal defaults node in the preferences file for a given class of object\n//\nexport function recordPersonalDefaults (theClass, context) {\n return new Promise(function (resolve, reject) {\n logInLoadPreferences(context).then(\n context => {\n if (!context.preferencesFile) {\n debug.log(\n 'Not doing private class preferences as no access to preferences file. ' +\n context.preferencesFileError\n )\n return\n }\n const regs = kb.each(\n null,\n ns.solid('forClass'),\n theClass,\n context.preferencesFile\n )\n let ins = []\n let prefs\n let reg\n if (regs.length) {\n // Use existing node if we can\n regs.forEach(r => {\n prefs = prefs || kb.any(r, ns.solid('personalDefaults'))\n })\n if (prefs) {\n context.personalDefaults = prefs // Found one\n resolve(context)\n return\n } else {\n prefs = widgets.newThing(context.preferencesFile)\n reg = regs[0]\n }\n } else {\n // no regs fo class\n reg = widgets.newThing(context.preferencesFile)\n ins = [\n $rdf.st(\n reg,\n ns.rdf('type'),\n ns.solid('TypeRegistration'),\n context.preferencesFile\n ),\n $rdf.st(reg, ns.solid('forClass'), theClass, context.preferencesFile)\n ]\n }\n prefs = widgets.newThing(context.preferencesFile)\n ins.push(\n $rdf.st(\n reg,\n ns.solid('personalDefaults'),\n prefs,\n context.preferencesFile\n )\n )\n kb.updater.update([], ins, function (uri, ok, errm) {\n if (!ok) {\n reject(new Error('Setting preferences for ' + theClass + ': ' + errm))\n } else {\n context.personalDefaults = prefs\n resolve(context)\n }\n })\n },\n err => {\n reject(err)\n }\n )\n })\n}\n\nexport function renderPreferencesForm (subject, theClass, preferencesForm, context) {\n const prefContainer = context.dom.createElement('div')\n participation.participationObject(subject, subject.doc(), context.me).then(\n participation => {\n const dom = context.dom\n function heading (text) {\n prefContainer.appendChild(dom.createElement('h5')).textContent = text\n }\n heading('My view of this ' + context.noun)\n widgets.appendForm(\n dom,\n prefContainer,\n {},\n participation,\n preferencesForm,\n subject.doc(),\n (ok, mes) => {\n if (!ok) widgets.complain(context, mes)\n }\n )\n\n heading(\"Everyone's view of this \" + context.noun)\n recordSharedPreferences(subject, context).then(context => {\n const sharedPreferences = context.sharedPreferences\n widgets.appendForm(\n dom,\n prefContainer,\n {},\n sharedPreferences,\n preferencesForm,\n subject.doc(),\n (ok, mes) => {\n if (!ok) widgets.complain(context, mes)\n }\n )\n\n heading('My default view of any ' + context.noun)\n recordPersonalDefaults(theClass, context).then(\n context => {\n widgets.appendForm(\n dom,\n prefContainer,\n {},\n context.personalDefaults,\n preferencesForm,\n context.preferencesFile,\n (ok, mes) => {\n if (!ok) widgets.complain(context, mes)\n }\n )\n },\n err => {\n widgets.complain(context, err)\n }\n )\n })\n },\n err => {\n // parp object fails\n prefContainer.appendChild(widgets.errorMessageBlock(context.dom, err))\n }\n )\n return prefContainer\n}\n\n// This should be part of rdflib.js ad part of the RDFJS Standard!!\n\nfunction toJS (term) {\n if (!term.datatype) return term // Objects remain objects\n if (term.datatype.equals(ns.xsd('boolean'))) {\n return term.value === '1'\n }\n if (\n term.datatype.equals(ns.xsd('dateTime')) ||\n term.datatype.equals(ns.xsd('date'))\n ) {\n return new Date(term.value)\n }\n if (\n term.datatype.equals(ns.xsd('integer')) ||\n term.datatype.equals(ns.xsd('float')) ||\n term.datatype.equals(ns.xsd('decimal'))\n ) {\n return Number(term.value)\n }\n return term.value\n}\n\n// This is the function which acuakly reads and combines the preferences\n//\n// @@ make it much more tolerant of missing buts of prefernces\nexport function getPreferencesForClass (subject, theClass, predicates, context) {\n return new Promise(function (resolve, reject) {\n recordSharedPreferences(subject, context).then(context => {\n const sharedPreferences = context.sharedPreferences\n if (context.me) {\n participation\n .participationObject(subject, subject.doc(), context.me)\n .then(participation => {\n recordPersonalDefaults(theClass, context).then(context => {\n const results = []\n const personalDefaults = context.personalDefaults\n predicates.forEach(pred => {\n // Order of preference: My settings on object, Global settings on object, my settings on class\n const v1 =\n kb.any(participation, pred) ||\n kb.any(sharedPreferences, pred) ||\n kb.any(personalDefaults, pred)\n if (v1) {\n results[pred.uri] = toJS(v1)\n }\n })\n resolve(results)\n }, reject)\n }, reject)\n } else {\n // no user defined, just use common prefs\n const results = []\n predicates.forEach(pred => {\n const v1 = kb.any(sharedPreferences, pred)\n if (v1) {\n results[pred.uri] = toJS(v1)\n }\n })\n resolve(results)\n }\n })\n })\n}\n\n// ends\n"],"file":"preferences.js"}
|
|
1
|
+
{"version":3,"sources":["../src/preferences.js"],"names":["kb","store","value","get","k","set","v","debug","log","Error","recordSharedPreferences","subject","context","Promise","resolve","reject","sharedPreferences","any","ns","ui","sp","$rdf","sym","doc","uri","ins","st","updater","update","ok","errorMessage","recordPersonalDefaults","theClass","then","preferencesFile","preferencesFileError","regs","each","solid","prefs","reg","length","forEach","r","personalDefaults","widgets","newThing","rdf","push","errm","err","renderPreferencesForm","preferencesForm","prefContainer","dom","createElement","participation","participationObject","me","heading","text","appendChild","textContent","noun","appendForm","mes","complain","errorMessageBlock","toJS","term","datatype","equals","xsd","Date","Number","getPreferencesForClass","predicates","results","pred","v1"],"mappings":";;;;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;AAE+B;AAKkB;AAGjD,IAAMA,EAAE,GAAGC,iBAAX,C,CAEA;AACA;AACA;AAEA;AACA;AACA;;AAEO,IAAMC,KAAK,GAAG,EAAd;;;AACA,SAASC,GAAT,CAAcC,CAAd,EAAiB;AACtB,SAAOF,KA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,EAAhB;AACA,gBAAMjC,gBAAgB,GAAGhC,OAAO,CAACgC,gBAAjC;AACAgC,YAAAA,UAAU,CAAClC,OAAX,CAAmB,UAAAoC,IAAI,EAAI;AACzB;AACA,kBAAMC,EAAE,GACN/E,EAAE,CAACiB,GAAH,CAAOuC,aAAP,EAAsBsB,IAAtB,KACA9E,EAAE,CAACiB,GAAH,CAAOD,iBAAP,EAA0B8D,IAA1B,CADA,IAEA9E,EAAE,CAACiB,GAAH,CAAO2B,gBAAP,EAAyBkC,IAAzB,CAHF;;AAIA,kBAAIC,EAAJ,EAAQ;AACNF,gBAAAA,OAAO,CAACC,IAAI,CAACtD,GAAN,CAAP,GAAoB4C,IAAI,CAACW,EAAD,CAAxB;AACD;AACF,aATD;AAUAjE,YAAAA,OAAO,CAAC+D,OAAD,CAAP;AACD,WAdD,EAcG9D,MAdH;AAeD,SAlBH,EAkBKA,MAlBL;AAmBD,OApBD,MAoBO;AACL;AACA,YAAM8D,OAAO,GAAG,EAAhB;AACAD,QAAAA,UAAU,CAAClC,OAAX,CAAmB,UAAAoC,IAAI,EAAI;AACzB,cAAMC,EAAE,GAAG/E,EAAE,CAACiB,GAAH,CAAOD,iBAAP,EAA0B8D,IAA1B,CAAX;;AACA,cAAIC,EAAJ,EAAQ;AACNF,YAAAA,OAAO,CAACC,IAAI,CAACtD,GAAN,CAAP,GAAoB4C,IAAI,CAACW,EAAD,CAAxB;AACD;AACF,SALD;AAMAjE,QAAAA,OAAO,CAAC+D,OAAD,CAAP;AACD;AACF,KAjCD;AAkCD,GAnCM,CAAP;AAoCD,C,CAED","sourcesContent":["// Solid-UI preferences\n// =====================\n//\n\nimport * as $rdf from 'rdflib' // pull in first avoid cross-refs\nimport { store } from 'solid-logic'\nimport * as debug from './debug'\nimport { ensureLoadedPreferences } from './login/login'\nimport * as ns from './ns'\nimport * as participation from './participation' // @ts-ignore\nimport * as widgets from './widgets'\n\nconst kb = store\n\n// This was tabulator . preferences in the tabulator\n// Is this functionality used anywhere?\n//\n\n// used for storing user name\n// @@ Deprocate these functions. They were used for\n// communication around the tabulator functionality about the user session\n\nexport const value = []\nexport function get (k) {\n return value[k]\n}\n\nexport function set (k, v) {\n if (typeof v !== 'string') {\n debug.log('Non-string value of preference ' + k + ': ' + v)\n throw new Error('Non-string value of preference ' + k + ': ' + v)\n }\n this.value[k] = v\n}\n\n// In a solid world, Preferences are stored in the web\n//\n// Make an RDF node for recording the common view preferences for any object\n// (maybe make it in a separate file?)\nexport function recordSharedPreferences (subject, context) {\n return new Promise(function (resolve, reject) {\n const sharedPreferences = kb.any(subject, ns.ui('sharedPreferences'))\n if (!sharedPreferences) {\n const sp = $rdf.sym(subject.doc().uri + '#SharedPreferences')\n const ins = [\n $rdf.st(subject, ns.ui('sharedPreferences'), sp, subject.doc())\n ]\n debug.log('Creating shared preferences ' + sp)\n kb.updater.update([], ins, function (uri, ok, errorMessage) {\n if (!ok) {\n reject(new Error('Error creating shared prefs: ' + errorMessage))\n } else {\n context.sharedPreferences = sp\n resolve(context)\n }\n })\n } else {\n context.sharedPreferences = sharedPreferences\n resolve(context)\n }\n })\n}\n\n// Construct a personal defaults node in the preferences file for a given class of object\n//\nexport function recordPersonalDefaults (theClass, context) {\n return new Promise(function (resolve, reject) {\n ensureLoadedPreferences(context).then(\n context => {\n if (!context.preferencesFile) {\n debug.log(\n 'Not doing private class preferences as no access to preferences file. ' +\n context.preferencesFileError\n )\n return\n }\n const regs = kb.each(\n null,\n ns.solid('forClass'),\n theClass,\n context.preferencesFile\n )\n let ins = []\n let prefs\n let reg\n if (regs.length) {\n // Use existing node if we can\n regs.forEach(r => {\n prefs = prefs || kb.any(r, ns.solid('personalDefaults'))\n })\n if (prefs) {\n context.personalDefaults = prefs // Found one\n resolve(context)\n return\n } else {\n prefs = widgets.newThing(context.preferencesFile)\n reg = regs[0]\n }\n } else {\n // no regs fo class\n reg = widgets.newThing(context.preferencesFile)\n ins = [\n $rdf.st(\n reg,\n ns.rdf('type'),\n ns.solid('TypeRegistration'),\n context.preferencesFile\n ),\n $rdf.st(reg, ns.solid('forClass'), theClass, context.preferencesFile)\n ]\n }\n prefs = widgets.newThing(context.preferencesFile)\n ins.push(\n $rdf.st(\n reg,\n ns.solid('personalDefaults'),\n prefs,\n context.preferencesFile\n )\n )\n kb.updater.update([], ins, function (uri, ok, errm) {\n if (!ok) {\n reject(new Error('Setting preferences for ' + theClass + ': ' + errm))\n } else {\n context.personalDefaults = prefs\n resolve(context)\n }\n })\n },\n err => {\n reject(err)\n }\n )\n })\n}\n\nexport function renderPreferencesForm (subject, theClass, preferencesForm, context) {\n const prefContainer = context.dom.createElement('div')\n participation.participationObject(subject, subject.doc(), context.me).then(\n participation => {\n const dom = context.dom\n function heading (text) {\n prefContainer.appendChild(dom.createElement('h5')).textContent = text\n }\n heading('My view of this ' + context.noun)\n widgets.appendForm(\n dom,\n prefContainer,\n {},\n participation,\n preferencesForm,\n subject.doc(),\n (ok, mes) => {\n if (!ok) widgets.complain(context, mes)\n }\n )\n\n heading(\"Everyone's view of this \" + context.noun)\n recordSharedPreferences(subject, context).then(context => {\n const sharedPreferences = context.sharedPreferences\n widgets.appendForm(\n dom,\n prefContainer,\n {},\n sharedPreferences,\n preferencesForm,\n subject.doc(),\n (ok, mes) => {\n if (!ok) widgets.complain(context, mes)\n }\n )\n\n heading('My default view of any ' + context.noun)\n recordPersonalDefaults(theClass, context).then(\n context => {\n widgets.appendForm(\n dom,\n prefContainer,\n {},\n context.personalDefaults,\n preferencesForm,\n context.preferencesFile,\n (ok, mes) => {\n if (!ok) widgets.complain(context, mes)\n }\n )\n },\n err => {\n widgets.complain(context, err)\n }\n )\n })\n },\n err => {\n // parp object fails\n prefContainer.appendChild(widgets.errorMessageBlock(context.dom, err))\n }\n )\n return prefContainer\n}\n\n// This should be part of rdflib.js ad part of the RDFJS Standard!!\n\nfunction toJS (term) {\n if (!term.datatype) return term // Objects remain objects\n if (term.datatype.equals(ns.xsd('boolean'))) {\n return term.value === '1'\n }\n if (\n term.datatype.equals(ns.xsd('dateTime')) ||\n term.datatype.equals(ns.xsd('date'))\n ) {\n return new Date(term.value)\n }\n if (\n term.datatype.equals(ns.xsd('integer')) ||\n term.datatype.equals(ns.xsd('float')) ||\n term.datatype.equals(ns.xsd('decimal'))\n ) {\n return Number(term.value)\n }\n return term.value\n}\n\n// This is the function which acuakly reads and combines the preferences\n//\n// @@ make it much more tolerant of missing buts of prefernces\nexport function getPreferencesForClass (subject, theClass, predicates, context) {\n return new Promise(function (resolve, reject) {\n recordSharedPreferences(subject, context).then(context => {\n const sharedPreferences = context.sharedPreferences\n if (context.me) {\n participation\n .participationObject(subject, subject.doc(), context.me)\n .then(participation => {\n recordPersonalDefaults(theClass, context).then(context => {\n const results = []\n const personalDefaults = context.personalDefaults\n predicates.forEach(pred => {\n // Order of preference: My settings on object, Global settings on object, my settings on class\n const v1 =\n kb.any(participation, pred) ||\n kb.any(sharedPreferences, pred) ||\n kb.any(personalDefaults, pred)\n if (v1) {\n results[pred.uri] = toJS(v1)\n }\n })\n resolve(results)\n }, reject)\n }, reject)\n } else {\n // no user defined, just use common prefs\n const results = []\n predicates.forEach(pred => {\n const v1 = kb.any(sharedPreferences, pred)\n if (v1) {\n results[pred.uri] = toJS(v1)\n }\n })\n resolve(results)\n }\n })\n })\n}\n\n// ends\n"],"file":"preferences.js"}
|
package/lib/utils/label.js
CHANGED
|
@@ -23,8 +23,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
var UI = {
|
|
24
24
|
log: log,
|
|
25
25
|
ns: ns,
|
|
26
|
-
rdf: rdf
|
|
27
|
-
store: _solidLogic.store
|
|
26
|
+
rdf: rdf
|
|
28
27
|
}; // This ubiquitous function returns the best label for a thing
|
|
29
28
|
//
|
|
30
29
|
// The hacks in this code make a major difference to the usability
|
package/lib/utils/label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/label.ts"],"names":["UI","log","ns","rdf","
|
|
1
|
+
{"version":3,"sources":["../../src/utils/label.ts"],"names":["UI","log","ns","rdf","label","thing","initialCap","doCap","slice","toUpperCase","cleanUp","result","i","length","toLowerCase","getWellKnownLabel","value","termType","elements","s","uri","toString","split","map","decodeURIComponent","join","e","hex","indexOf","String","fromCharCode","parseInt","hash","slash","lastIndexOf","suffix","store","any","ui","link","vcard","foaf","dct","dc","rss","contact","sym","cal","as","schema","rdfs"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAA8B;AAE9B,IAAMA,EAAE,GAAG;AAAEC,EAAAA,GAAG,EAAHA,GAAF;AAAOC,EAAAA,EAAE,EAAFA,EAAP;AAAWC,EAAAA,GAAG,EAAHA;AAAX,CAAX,C,CAEA;AACA;AACA;;AACO,SAASC,KAAT,CAAgBC,KAAhB,EAAmD;AAAA,MAA5BC,UAA4B,uEAAf,KAAe;;AACxD,WAASC,KAAT,CAAgBH,KAAhB,EAA+B;AAC7B,QAAIE,UAAJ,EAAgB;AACd,aAAOF,KAAK,CAACI,KAAN,CAAY,CAAZ,EAAe,CAAf,EAAkBC,WAAlB,KAAkCL,KAAK,CAACI,KAAN,CAAY,CAAZ,CAAzC;AACD;;AACD,WAAOJ,KAAP;AACD;;AACD,WAASM,OAAT,CAAkBN,KAAlB,EAAiC;AAC/B,QAAIO,MAAM,GAAG,EAAb;AACA,QAAIP,KAAK,CAACI,KAAN,CAAY,CAAC,CAAb,MAAoB,GAAxB,EAA6BJ,KAAK,GAAGA,KAAK,CAACI,KAAN,CAAY,CAAZ,EAAe,CAAC,CAAhB,CAAR,CAFE,CAEyB;;AACxD,SAAK,IAAII,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGR,KAAK,CAACS,MAA1B,EAAkCD,CAAC,EAAnC,EAAuC;AACrC,UAAIR,KAAK,CAACQ,CAAD,CAAL,KAAa,GAAb,IAAoBR,KAAK,CAACQ,CAAD,CAAL,KAAa,GAArC,EAA0C;AACxCD,QAAAA,MAAM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AAN,CAAU,OAAV,CAAjB,CANG,IAOHR,kBAAMC,GAAN,CAAUhC,KAAV,EAAiBL,EAAE,CAACE,EAAH,CAAM2C,OAAN,CAAc,UAAd,CAAjB,CAPG,IAQHT,kBAAMC,GAAN,CAAUhC,KAAV,EAAiB+B,kBAAMU,GAAN,CAAU,4CAAV,CAAjB,CARG,IASHV,kBAAMC,GAAN,CAAUhC,KAAV,EAAiBL,EAAE,CAACE,EAAH,CAAM6C,GAAN,CAAU,SAAV,CAAjB,CATG,IAUHX,kBAAMC,GAAN,CAAUhC,KAAV,EAAiBL,EAAE,CAACE,EAAH,CAAMuC,IAAN,CAAW,MAAX,CAAjB,CAVG,IAWHL,kBAAMC,GAAN,CAAUhC,KAAV,EAAiBL,EAAE,CAACE,EAAH,CAAM8C,EAAN,CAAS,MAAT,CAAjB,CAXG,IAYHZ,kBAAMC,GAAN,CAAUhC,KAAV,EAAiBL,EAAE,CAACE,EAAH,CAAM+C,MAAN,CAAa,MAAb,CAAjB,CAZG,IAaHb,kBAAMC,GAAN,CAAUhC,KAAV,EAAiBL,EAAE,CAACE,EAAH,CAAMgD,IAAN,CAAW,OAAX,CAAjB,CAbJ;AAcD","sourcesContent":["import * as log from '../log'\nimport { store } from 'solid-logic'\nimport * as ns from '../ns'\nimport * as rdf from 'rdflib' // pull in first avoid cross-refs\n\nconst UI = { log, ns, rdf }\n\n// This ubiquitous function returns the best label for a thing\n//\n// The hacks in this code make a major difference to the usability\nexport function label (thing, initialCap = false): string {\n function doCap (label: string) {\n if (initialCap) {\n return label.slice(0, 1).toUpperCase() + label.slice(1)\n }\n return label\n }\n function cleanUp (label: string) {\n let result = ''\n if (label.slice(-1) === '/') label = label.slice(0, -1) // chop trailing slash\n for (let i = 0; i < label.length; i++) {\n if (label[i] === '_' || label[i] === '-') {\n result += ' '\n continue\n }\n result += label[i]\n if (\n i + 1 < label.length &&\n label[i].toUpperCase() !== label[i] &&\n label[i + 1].toLowerCase() !== label[i + 1]\n ) {\n result += ' '\n }\n }\n if (result.slice(0, 4) === 'has ') result = result.slice(4)\n return doCap(result)\n }\n\n const label = getWellKnownLabel(thing)\n\n if (label) {\n return doCap(label.value)\n }\n\n // Default to label just generated from the URI\n\n if (thing.termType === 'BlankNode') {\n return '...'\n }\n if (thing.termType === 'Collection') {\n return '(' + thing.elements.length + ')'\n }\n let s = thing.uri\n if (typeof s === 'undefined') return thing.toString() // can't be a symbol\n // s = decodeURI(s) // This can crash is random valid @ signs are presentation\n // The idea was to clean up eg URIs encoded in query strings\n // Also encoded character in what was filenames like @ [] {}\n try {\n s = s\n .split('/')\n .map(decodeURIComponent)\n .join('/') // If it is properly encoded\n } catch (e) {\n // try individual decoding of ASCII code points\n for (let i = s.length - 3; i > 0; i--) {\n const hex = '0123456789abcefABCDEF' // The while upacks multiple layers of encoding\n while (\n s[i] === '%' &&\n hex.indexOf(s[i + 1]) >= 0 &&\n hex.indexOf(s[i + 2]) >= 0\n ) {\n s =\n s.slice(0, i) +\n String.fromCharCode(parseInt(s.slice(i + 1, i + 3), 16)) +\n s.slice(i + 3)\n }\n }\n }\n\n s = slice(s, '/profile/card#me')\n s = slice(s, '#this')\n s = slice(s, '#me')\n\n const hash = s.indexOf('#')\n if (hash >= 0) return cleanUp(s.slice(hash + 1))\n\n // Eh? Why not do this? e.g. dc:title needs it only trim URIs, not rdfs:labels\n const slash = s.lastIndexOf('/', s.length - 2) // (len-2) excludes trailing slash\n if (slash >= 0 && slash < thing.uri.length) return cleanUp(s.slice(slash + 1))\n\n return doCap(decodeURIComponent(thing.uri))\n}\n\nfunction slice (s: string, suffix: string) {\n const length = suffix.length * -1\n if (s.slice(length) === suffix) {\n return s.slice(0, length)\n }\n return s\n}\n\n// Hard coded known label predicates\n// @@ TBD: Add subproperties of rdfs:label\nfunction getWellKnownLabel (thing) {\n return store.any(thing, UI.ns.ui('label')) || // Prioritize ui:label\n store.any(thing, UI.ns.link('message')) ||\n store.any(thing, UI.ns.vcard('fn')) ||\n store.any(thing, UI.ns.foaf('name')) ||\n store.any(thing, UI.ns.dct('title')) ||\n store.any(thing, UI.ns.dc('title')) ||\n store.any(thing, UI.ns.rss('title')) ||\n store.any(thing, UI.ns.contact('fullName')) ||\n store.any(thing, store.sym('http://www.w3.org/2001/04/roadmap/org#name')) ||\n store.any(thing, UI.ns.cal('summary')) ||\n store.any(thing, UI.ns.foaf('nick')) ||\n store.any(thing, UI.ns.as('name')) ||\n store.any(thing, UI.ns.schema('name')) ||\n store.any(thing, UI.ns.rdfs('label'))\n}\n"],"file":"label.js"}
|
package/lib/versionInfo.js
CHANGED
|
@@ -5,23 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _default = {
|
|
8
|
-
buildTime: '2022-02-
|
|
9
|
-
commit: '
|
|
8
|
+
buildTime: '2022-02-15T15:20:33Z',
|
|
9
|
+
commit: '48f3ebed3572bc099bfcd5b770fd5a3f4d738795',
|
|
10
10
|
npmInfo: {
|
|
11
11
|
'solid-ui': '2.4.16',
|
|
12
|
-
npm: '6.14.
|
|
12
|
+
npm: '6.14.16',
|
|
13
13
|
ares: '1.18.1',
|
|
14
14
|
brotli: '1.0.9',
|
|
15
|
-
cldr: '
|
|
16
|
-
icu: '
|
|
15
|
+
cldr: '40.0',
|
|
16
|
+
icu: '70.1',
|
|
17
17
|
llhttp: '2.1.4',
|
|
18
18
|
modules: '83',
|
|
19
19
|
napi: '8',
|
|
20
20
|
nghttp2: '1.42.0',
|
|
21
|
-
node: '14.
|
|
22
|
-
openssl: '1.1.
|
|
23
|
-
tz: '
|
|
24
|
-
unicode: '
|
|
21
|
+
node: '14.19.0',
|
|
22
|
+
openssl: '1.1.1m',
|
|
23
|
+
tz: '2021a3',
|
|
24
|
+
unicode: '14.0',
|
|
25
25
|
uv: '1.42.0',
|
|
26
26
|
v8: '8.4.371.23-node.85',
|
|
27
27
|
zlib: '1.2.11'
|
package/lib/versionInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/versionInfo.ts"],"names":["buildTime","commit","npmInfo","npm","ares","brotli","cldr","icu","llhttp","modules","napi","nghttp2","node","openssl","tz","unicode","uv","v8","zlib"],"mappings":";;;;;;eAAe;AACbA,EAAAA,SAAS,EAAE,sBADE;AAEbC,EAAAA,MAAM,EAAE,0CAFK;AAGbC,EAAAA,OAAO,EACT;AACE,gBAAY,QADd;AAEEC,IAAAA,GAAG,EAAE,SAFP;AAGEC,IAAAA,IAAI,EAAE,QAHR;AAIEC,IAAAA,MAAM,EAAE,OAJV;AAKEC,IAAAA,IAAI,EAAE,MALR;AAMEC,IAAAA,GAAG,EAAE,MANP;AAOEC,IAAAA,MAAM,EAAE,OAPV;AAQEC,IAAAA,OAAO,EAAE,IARX;AASEC,IAAAA,IAAI,EAAE,GATR;AAUEC,IAAAA,OAAO,EAAE,QAVX;AAWEC,IAAAA,IAAI,EAAE,SAXR;AAYEC,IAAAA,OAAO,EAAE,QAZX;AAaEC,IAAAA,EAAE,EAAE,
|
|
1
|
+
{"version":3,"sources":["../src/versionInfo.ts"],"names":["buildTime","commit","npmInfo","npm","ares","brotli","cldr","icu","llhttp","modules","napi","nghttp2","node","openssl","tz","unicode","uv","v8","zlib"],"mappings":";;;;;;eAAe;AACbA,EAAAA,SAAS,EAAE,sBADE;AAEbC,EAAAA,MAAM,EAAE,0CAFK;AAGbC,EAAAA,OAAO,EACT;AACE,gBAAY,QADd;AAEEC,IAAAA,GAAG,EAAE,SAFP;AAGEC,IAAAA,IAAI,EAAE,QAHR;AAIEC,IAAAA,MAAM,EAAE,OAJV;AAKEC,IAAAA,IAAI,EAAE,MALR;AAMEC,IAAAA,GAAG,EAAE,MANP;AAOEC,IAAAA,MAAM,EAAE,OAPV;AAQEC,IAAAA,OAAO,EAAE,IARX;AASEC,IAAAA,IAAI,EAAE,GATR;AAUEC,IAAAA,OAAO,EAAE,QAVX;AAWEC,IAAAA,IAAI,EAAE,SAXR;AAYEC,IAAAA,OAAO,EAAE,QAZX;AAaEC,IAAAA,EAAE,EAAE,QAbN;AAcEC,IAAAA,OAAO,EAAE,MAdX;AAeEC,IAAAA,EAAE,EAAE,QAfN;AAgBEC,IAAAA,EAAE,EAAE,oBAhBN;AAiBEC,IAAAA,IAAI,EAAE;AAjBR;AAJe,C","sourcesContent":["export default {\n buildTime: '2022-02-15T15:20:33Z',\n commit: '48f3ebed3572bc099bfcd5b770fd5a3f4d738795',\n npmInfo:\n{\n 'solid-ui': '2.4.16',\n npm: '6.14.16',\n ares: '1.18.1',\n brotli: '1.0.9',\n cldr: '40.0',\n icu: '70.1',\n llhttp: '2.1.4',\n modules: '83',\n napi: '8',\n nghttp2: '1.42.0',\n node: '14.19.0',\n openssl: '1.1.1m',\n tz: '2021a3',\n unicode: '14.0',\n uv: '1.42.0',\n v8: '8.4.371.23-node.85',\n zlib: '1.2.11'\n}\n}\n"],"file":"versionInfo.js"}
|