solid-ui 2.4.16-74e478b4 → 2.4.16-95fad2d0
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/README.md +1 -0
- package/lib/participation.d.ts.map +1 -1
- package/lib/participation.js +59 -30
- package/lib/participation.js.map +1 -1
- package/lib/versionInfo.js +9 -9
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +204 -117
- package/lib/webpack-bundle.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
User Interface widgets and utilities for Solid
|
|
6
6
|
|
|
7
7
|
These are HTML5 widgets which connect to a solid store. Building blocks for solid-based apps.
|
|
8
|
+
Vanilla JS. Includes large widgets like chat, table, matrix, form fields, and small widgets.
|
|
8
9
|
|
|
9
10
|
## Getting started
|
|
10
11
|
### In npm-based projects
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participation.d.ts","sourceRoot":"","sources":["../src/participation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"participation.d.ts","sourceRoot":"","sources":["../src/participation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,SAAS,EAAqB,MAAM,QAAQ,CAAA;AAQhE,aAAK,oBAAoB,GAAG;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,cAAM,yBAA0B,SAAQ,gBAAgB;IACtD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAGD;;;;;;;;EAQE;AACF,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,6BA2C/K;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,oBAkDxF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OA0C3F;AAED;;;;;;;;;EASE;AACF,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,EAAE,EAAE,SAAS,EACb,OAAO,EAAE,oBAAoB,oBAiB9B"}
|
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","manageParticipation","container","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAQMA,yB;;;;;;;;;;;;;;;;;;;;kDAAkCC,gB;;AAGxC,IAAMC,EAAE,GAAGC,gCAAoBC,KAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,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,GAAGb,EAAE,CAACc,GAAH,CAAOF,IAAP,EAAaG,EAAE,CAACC,EAAH,CAAM,aAAN,CAAb,CAAf;AAEA,QAAIC,EAAJ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W,CAACrB,OAA/B,EAAwC;AACtCqB,QAAAA,WAAW,CAACrB,OAAZ;AACD,OANsG,CAOvG;;AACD,KARD;AASA,WAAOY,aAAP;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASY,mBAAT,CACLxD,GADK,EAELyD,SAFK,EAGLvB,MAHK,EAIL/B,OAJK,EAKLgC,EALK,EAML9B,OANK,EAOL;AACA,MAAMJ,KAAK,GAAGD,GAAG,CAACc,aAAJ,CAAkB,OAAlB,CAAd;AACA2C,EAAAA,SAAS,CAACrC,WAAV,CAAsBnB,KAAtB;AACAF,EAAAA,gBAAgB,CAACC,GAAD,EAAMC,KAAN,EAAaiC,MAAb,EAAqB/B,OAArB,EAA8BgC,EAA9B,EAAkC9B,OAAlC,CAAhB;;AACA,MAAI;AACF+C,IAAAA,mBAAmB,CAACjD,OAAD,EAAU+B,MAAV,EAAkBjC,KAAlB,CAAnB;AACD,GAFD,CAEE,OAAOyD,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,EAAgF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AV,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/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-22T11:38:35Z',
|
|
9
|
+
commit: '95fad2d0d00906c65f888869a788719e15b6726e',
|
|
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-22T11:38:35Z',\n commit: '95fad2d0d00906c65f888869a788719e15b6726e',\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"}
|