solid-ui 2.4.16-ad065869 → 2.4.16-ea33598d

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 CHANGED
@@ -52,14 +52,9 @@ document.body.appendChild(aclControlBox)
52
52
 
53
53
 
54
54
  ## Documentation
55
-
56
- ### API
57
-
58
- See https://solid.github.io/solid-ui/Documentation/api/ for the API documentation.
59
-
60
- ### Components
61
-
62
- The UI components are presented in a [storybook](http://solid.github.io/solid-ui/examples/storybook/).
55
+ - [talk presentation](https://solid.github.io/solid-ui/Documentation/talks/FormsTalk.html)
56
+ - API https://solid.github.io/solid-ui/Documentation/api/ for the API documentation.
57
+ - The UI components are presented in a [storybook](http://solid.github.io/solid-ui/examples/storybook/).
63
58
 
64
59
  ## Overview
65
60
  This has been a place to put any functionality from solid views which has been generalized to be usable in other views.
@@ -109,4 +104,4 @@ npm run storybook
109
104
  If there is no story for the component yet, add a new one to `./src/stories`.
110
105
 
111
106
  When you want to test the component within a solid-pane, you can use the [development mode of solid-panes](https://github.com/solid/solid-panes#development) or
112
- [mashlib-dev](https://github.com/solid/mashlib-dev).
107
+ [mashlib-dev](https://github.com/solid/mashlib-dev).
@@ -1 +1 @@
1
- {"version":3,"file":"participation.d.ts","sourceRoot":"","sources":["../src/participation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAM,MAAM,QAAQ,CAAA;AAQtC,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,S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AAgB,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"}
@@ -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 _authn = require("./authn/authn");
32
34
 
33
35
  var _rdflib = require("rdflib");
@@ -40,14 +42,18 @@ var _utils = require("./utils");
40
42
 
41
43
  var _pad = require("./pad");
42
44
 
43
- var _debug = require("./debug");
44
-
45
45
  var _logic = require("./logic");
46
46
 
47
47
  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); }
48
48
 
49
49
  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; }
50
50
 
51
+ 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; } } }; }
52
+
53
+ 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); }
54
+
55
+ 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; }
56
+
51
57
  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); }; }
52
58
 
53
59
  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; } }
@@ -74,7 +80,7 @@ var ParticipationTableElement = /*#__PURE__*/function (_HTMLTableElement) {
74
80
  return (0, _createClass2["default"])(ParticipationTableElement);
75
81
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLTableElement));
76
82
 
77
- var kb = _logic.solidLogicSingleton.store;
83
+ var store = _logic.solidLogicSingleton.store;
78
84
  /** Manage participation in this session
79
85
  *
80
86
  * @param {Document} dom - the web page loaded into the browser
@@ -89,7 +95,7 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
89
95
  table.setAttribute('style', 'margin: 0.8em;');
90
96
 
91
97
  var newRowForParticpation = function newRowForParticpation(parp) {
92
- var person = kb.any(parp, ns.wf('participant'));
98
+ var person = store.any(parp, ns.wf('participant'));
93
99
  var tr;
94
100
 
95
101
  if (!person) {
@@ -99,7 +105,7 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
99
105
  return tr;
100
106
  }
101
107
 
102
- var bg = kb.anyValue(parp, ns.ui('backgroundColor')) || 'white';
108
+ var bg = store.anyValue(parp, ns.ui('backgroundColor')) || 'white';
103
109
  var block = dom.createElement('div');
104
110
  block.setAttribute('style', 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888; background-color: ' + bg);
105
111
  tr = (0, _widgets.personTR)(dom, null, person, options);
@@ -112,9 +118,9 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
112
118
  };
113
119
 
114
120
  var syncTable = function syncTable() {
115
- var parps = kb.each(subject, ns.wf('participation')).map(function (parp) {
116
- (0, _debug.log)('in participants');
117
- return [kb.anyValue(parp, ns.cal('dtstart')) || '9999-12-31', parp];
121
+ var parps = store.each(subject, ns.wf('participation')).map(function (parp) {
122
+ (0, debug.log)('in participants');
123
+ return [store.anyValue(parp, ns.cal('dtstart')) || '9999-12-31', parp];
118
124
  });
119
125
  parps.sort(); // List in order of joining
120
126
 
@@ -142,36 +148,57 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
142
148
  function participationObject(subject, padDoc, me) {
143
149
  return new Promise(function (resolve, reject) {
144
150
  if (!me) {
145
- throw new Error('Not user id');
151
+ throw new Error('No user id');
146
152
  }
147
153
 
148
- var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
149
- return kb.holds(pn, ns.wf('participant'), me);
154
+ var parps = store.each(subject, ns.wf('participation')).filter(function (pn) {
155
+ return store.holds(pn, ns.wf('participant'), me);
150
156
  });
151
157
 
152
158
  if (parps.length > 1) {
153
- throw new Error('Multiple records of your participation');
159
+ // This can happen. https://github.com/solid/chat-pane/issues/71
160
+ var candidates = [];
161
+
162
+ var _iterator = _createForOfIteratorHelper(parps),
163
+ _step;
164
+
165
+ try {
166
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
167
+ var participation = _step.value;
168
+ var date = store.anyValue(participation, ns.cal('dtstart'));
169
+
170
+ if (date) {
171
+ candidates.push([date, participation]);
172
+ }
173
+ }
174
+ } catch (err) {
175
+ _iterator.e(err);
176
+ } finally {
177
+ _iterator.f();
178
+ }
179
+
180
+ candidates.sort(); // Pick the earliest
181
+ // @@ Possibly, for extra credit, delete the others, if we have write access
182
+
183
+ debug.warn('Multiple particpation objects, picking earliest, in ' + padDoc);
184
+ resolve(candidates[0][1]); // throw new Error('Multiple records of your participation')
154
185
  }
155
186
 
156
187
  if (parps.length) {
157
188
  // If I am not already recorded
158
189
  resolve(parps[0]); // returns the particpation object
159
190
  } else {
160
- var participation = (0, _widgets.newThing)(padDoc);
161
- 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)];
191
+ var _participation2 = (0, _widgets.newThing)(padDoc);
162
192
 
163
- if (!kb.updater) {
164
- throw new Error('kb has no updater');
165
- }
166
-
167
- kb.updater.update([], ins, function (uri, ok, errorMessage) {
193
+ 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)];
194
+ store.updater.update([], ins, function (uri, ok, errorMessage) {
168
195
  if (!ok) {
169
196
  reject(new Error('Error recording your partipation: ' + errorMessage));
170
197
  } else {
171
- resolve(participation);
198
+ resolve(_participation2);
172
199
  }
173
200
  });
174
- resolve(participation);
201
+ resolve(_participation2);
175
202
  }
176
203
  });
177
204
  }
@@ -188,8 +215,8 @@ function recordParticipation(subject, padDoc, refreshable) {
188
215
  var me = (0, _authn.currentUser)();
189
216
  if (!me) return; // Not logged in
190
217
 
191
- var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
192
- return kb.holds(pn, ns.wf('participant'), me);
218
+ var parps = store.each(subject, ns.wf('participation')).filter(function (pn) {
219
+ return store.holds(pn, ns.wf('participant'), me);
193
220
  });
194
221
 
195
222
  if (parps.length > 1) {
@@ -200,14 +227,14 @@ function recordParticipation(subject, padDoc, refreshable) {
200
227
  // If I am not already recorded
201
228
  return parps[0]; // returns the particpation object
202
229
  } else {
203
- var participation = (0, _widgets.newThing)(padDoc);
204
- 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)];
205
-
206
- if (!kb.updater) {
207
- throw new Error('kb has no updater');
230
+ if (!store.updater.editable(padDoc)) {
231
+ debug.log('Not recording participation, as no write acesss as ' + me + ' to ' + padDoc);
232
+ return null;
208
233
  }
209
234
 
210
- kb.updater.update([], ins, function (uri, ok, errorMessage) {
235
+ var participation = (0, _widgets.newThing)(padDoc);
236
+ 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)];
237
+ store.updater.update([], ins, function (uri, ok, errorMessage) {
211
238
  if (!ok) {
212
239
  throw new Error('Error recording your partipation: ' + errorMessage);
213
240
  }
@@ -237,8 +264,10 @@ function manageParticipation(dom, container, padDoc, subject, me, options) {
237
264
  container.appendChild(table);
238
265
  renderPartipants(dom, table, padDoc, subject, me, options);
239
266
 
267
+ var _participation;
268
+
240
269
  try {
241
- recordParticipation(subject, padDoc, table);
270
+ _participation = recordParticipation(subject, padDoc, table);
242
271
  } catch (e) {
243
272
  container.appendChild((0, _widgets.errorMessageBlock)(dom, 'Error recording your partipation: ' + e)); // Clean up?
244
273
  }
@@ -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","manageParticipation","container","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAQMA,yB;;;;;;;;;;;;;;;;;;;;kDAAkCC,gB;;AAGxC,IAAMC,EAAE,GAAGC,2BAAoBC,KA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F,EAGE,yBAAeiB,EAAf,CAHF,EAIED,MAJF,CALU,CAAZ;;AAYA,QAAI,CAACtC,EAAE,CAACmD,OAAR,EAAiB;AACf,YAAM,IAAIR,KAAJ,CAAU,mBAAV,CAAN;AACD;;AACD3C,IAAAA,EAAE,CAACmD,OAAH,CAAWC,MAAX,CAAkB,EAAlB,EAAsBH,GAAtB,EAA2B,UAAUI,GAAV,EAA0CC,EAA1C,EAAuDC,YAAvD,EAA8E;AACvG,UAAI,CAACD,EAAL,EAAS;AACP,cAAM,IAAIX,KAAJ,CAAU,uCAAuCY,YAAjD,CAAN;AACD;;AACD,UAAIE,WAAW,IAAIA,WAAW,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,SAASU,mBAAT,CACLtD,GADK,EAELuD,SAFK,EAGLrB,MAHK,EAIL/B,OAJK,EAKLgC,EALK,EAML9B,OANK,EAOL;AACA,MAAMJ,KAAK,GAAGD,GAAG,CAACc,aAAJ,CAAkB,OAAlB,CAAd;AACAyC,EAAAA,SAAS,CAACnC,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,OAAOuD,CAAP,EAAU;AACVD,IAAAA,SAAS,CAACnC,WAAV,CACE,gCACEpB,GADF,EAEE,uCAAuCwD,CAFzC,CADF,EADU,CAMR;AACH;;AACD,SAAOvD,KAAP;AACD","sourcesContent":["/* Manage a UI for the particpation of a person in any thing\n*/\n\nimport { 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 } from './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 = 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","editable","log","manageParticipation","container","_participation","e"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;IAQMA,yB;;;;;;;;;;;;;;;;;;;;kDAAkCC,gB;;AAGxC,IAAMC,KAAK,GAAGC,2BAAoBD,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,KAAkD,OAA7D;AAEA,QAAMC,KAAK,GAAGnB,GAAG,CAACc,aAAJ,CAAkB,KAAlB,CAAd;AACAK,IAAAA,KAAK,CAACb,YAAN,CACE,OADF,EAEE,6FACAU,EAHF;AAKAH,IAAAA,EAAE,GAAG,uBAASb,GAAT,EAAc,IAAd,EAAoBS,MAApB,EAA4BJ,OAA5B,CAAL;AACAJ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1B,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,SAASgB,mBAAT,CACL7D,GADK,EAEL8D,SAFK,EAGL5B,MAHK,EAIL/B,OAJK,EAKLgC,EALK,EAML9B,OANK,EAOL;AACA,MAAMJ,KAAK,GAAGD,GAAG,CAACc,aAAJ,CAAkB,OAAlB,CAAd;AACAgD,EAAAA,SAAS,CAAC1C,WAAV,CAAsBnB,KAAtB;AACAF,EAAAA,gBAAgB,CAACC,GAAD,EAAMC,KAAN,EAAaiC,MAAb,EAAqB/B,OAArB,EAA8BgC,EAA9B,EAAkC9B,OAAlC,CAAhB;;AACA,MAAI0D,cAAJ;;AACA,MAAI;AACFA,IAAAA,cAAc,GAAGN,mBAAmB,CAACtD,OAAD,EAAU+B,MAAV,EAAkBjC,KAAlB,CAApC;AACD,GAFD,CAEE,OAAO+D,CAAP,EAAU;AACVF,IAAAA,SAAS,CAAC1C,WAAV,CACE,gCACEpB,GADF,EAEE,uCAAuCgE,CAFzC,CADF,EADU,CAMR;AACH;;AACD,SAAO/D,KAAP;AACD","sourcesContent":["/* Manage a UI for the particpation of a person in any thing\n*/\nimport * as debug from './debug'\nimport { currentUser } from './authn/authn'\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 } from './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 = 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"}
@@ -5,23 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _default = {
8
- buildTime: '2022-01-30T10:49:38Z',
9
- commit: 'ad0658696d9c3b3ba573f6e3b58c45e285b4d0ba',
8
+ buildTime: '2022-02-12T13:53:21Z',
9
+ commit: 'ea33598dce93d43d9a960c114f9d08be648003e9',
10
10
  npmInfo: {
11
11
  'solid-ui': '2.4.16',
12
- npm: '6.14.15',
12
+ npm: '6.14.16',
13
13
  ares: '1.18.1',
14
14
  brotli: '1.0.9',
15
- cldr: '39.0',
16
- icu: '69.1',
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.18.3',
22
- openssl: '1.1.1l',
23
- tz: '2021a',
24
- unicode: '13.0',
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'
@@ -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,OAbN;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-01-30T10:49:38Z',\n commit: 'ad0658696d9c3b3ba573f6e3b58c45e285b4d0ba',\n npmInfo:\n{\n 'solid-ui': '2.4.16',\n npm: '6.14.15',\n ares: '1.18.1',\n brotli: '1.0.9',\n cldr: '39.0',\n icu: '69.1',\n llhttp: '2.1.4',\n modules: '83',\n napi: '8',\n nghttp2: '1.42.0',\n node: '14.18.3',\n openssl: '1.1.1l',\n tz: '2021a',\n unicode: '13.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"}
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-12T13:53:21Z',\n commit: 'ea33598dce93d43d9a960c114f9d08be648003e9',\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"}
@@ -12461,6 +12461,8 @@ var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/ru
12461
12461
 
12462
12462
  var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"));
12463
12463
 
12464
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ./debug */ "./lib/debug.js"));
12465
+
12464
12466
  var _authn = __webpack_require__(/*! ./authn/authn */ "./lib/authn/authn.js");
12465
12467
 
12466
12468
  var _rdflib = __webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js");
@@ -12473,14 +12475,18 @@ var _utils = __webpack_require__(/*! ./utils */ "./lib/utils/index.js");
12473
12475
 
12474
12476
  var _pad = __webpack_require__(/*! ./pad */ "./lib/pad.js");
12475
12477
 
12476
- var _debug = __webpack_require__(/*! ./debug */ "./lib/debug.js");
12477
-
12478
12478
  var _logic = __webpack_require__(/*! ./logic */ "./lib/logic.js");
12479
12479
 
12480
12480
  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); }
12481
12481
 
12482
12482
  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; }
12483
12483
 
12484
+ 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; } } }; }
12485
+
12486
+ 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); }
12487
+
12488
+ 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; }
12489
+
12484
12490
  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); }; }
12485
12491
 
12486
12492
  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; } }
@@ -12507,7 +12513,7 @@ var ParticipationTableElement = /*#__PURE__*/function (_HTMLTableElement) {
12507
12513
  return (0, _createClass2["default"])(ParticipationTableElement);
12508
12514
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLTableElement));
12509
12515
 
12510
- var kb = _logic.solidLogicSingleton.store;
12516
+ var store = _logic.solidLogicSingleton.store;
12511
12517
  /** Manage participation in this session
12512
12518
  *
12513
12519
  * @param {Document} dom - the web page loaded into the browser
@@ -12522,7 +12528,7 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
12522
12528
  table.setAttribute('style', 'margin: 0.8em;');
12523
12529
 
12524
12530
  var newRowForParticpation = function newRowForParticpation(parp) {
12525
- var person = kb.any(parp, ns.wf('participant'));
12531
+ var person = store.any(parp, ns.wf('participant'));
12526
12532
  var tr;
12527
12533
 
12528
12534
  if (!person) {
@@ -12532,7 +12538,7 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
12532
12538
  return tr;
12533
12539
  }
12534
12540
 
12535
- var bg = kb.anyValue(parp, ns.ui('backgroundColor')) || 'white';
12541
+ var bg = store.anyValue(parp, ns.ui('backgroundColor')) || 'white';
12536
12542
  var block = dom.createElement('div');
12537
12543
  block.setAttribute('style', 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888; background-color: ' + bg);
12538
12544
  tr = (0, _widgets.personTR)(dom, null, person, options);
@@ -12545,9 +12551,9 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
12545
12551
  };
12546
12552
 
12547
12553
  var syncTable = function syncTable() {
12548
- var parps = kb.each(subject, ns.wf('participation')).map(function (parp) {
12549
- (0, _debug.log)('in participants');
12550
- return [kb.anyValue(parp, ns.cal('dtstart')) || '9999-12-31', parp];
12554
+ var parps = store.each(subject, ns.wf('participation')).map(function (parp) {
12555
+ (0, debug.log)('in participants');
12556
+ return [store.anyValue(parp, ns.cal('dtstart')) || '9999-12-31', parp];
12551
12557
  });
12552
12558
  parps.sort(); // List in order of joining
12553
12559
 
@@ -12575,36 +12581,57 @@ function renderPartipants(dom, table, unused1, subject, unused2, options) {
12575
12581
  function participationObject(subject, padDoc, me) {
12576
12582
  return new Promise(function (resolve, reject) {
12577
12583
  if (!me) {
12578
- throw new Error('Not user id');
12584
+ throw new Error('No user id');
12579
12585
  }
12580
12586
 
12581
- var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
12582
- return kb.holds(pn, ns.wf('participant'), me);
12587
+ var parps = store.each(subject, ns.wf('participation')).filter(function (pn) {
12588
+ return store.holds(pn, ns.wf('participant'), me);
12583
12589
  });
12584
12590
 
12585
12591
  if (parps.length > 1) {
12586
- throw new Error('Multiple records of your participation');
12592
+ // This can happen. https://github.com/solid/chat-pane/issues/71
12593
+ var candidates = [];
12594
+
12595
+ var _iterator = _createForOfIteratorHelper(parps),
12596
+ _step;
12597
+
12598
+ try {
12599
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
12600
+ var participation = _step.value;
12601
+ var date = store.anyValue(participation, ns.cal('dtstart'));
12602
+
12603
+ if (date) {
12604
+ candidates.push([date, participation]);
12605
+ }
12606
+ }
12607
+ } catch (err) {
12608
+ _iterator.e(err);
12609
+ } finally {
12610
+ _iterator.f();
12611
+ }
12612
+
12613
+ candidates.sort(); // Pick the earliest
12614
+ // @@ Possibly, for extra credit, delete the others, if we have write access
12615
+
12616
+ debug.warn('Multiple particpation objects, picking earliest, in ' + padDoc);
12617
+ resolve(candidates[0][1]); // throw new Error('Multiple records of your participation')
12587
12618
  }
12588
12619
 
12589
12620
  if (parps.length) {
12590
12621
  // If I am not already recorded
12591
12622
  resolve(parps[0]); // returns the particpation object
12592
12623
  } else {
12593
- var participation = (0, _widgets.newThing)(padDoc);
12594
- 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)];
12624
+ var _participation2 = (0, _widgets.newThing)(padDoc);
12595
12625
 
12596
- if (!kb.updater) {
12597
- throw new Error('kb has no updater');
12598
- }
12599
-
12600
- kb.updater.update([], ins, function (uri, ok, errorMessage) {
12626
+ 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)];
12627
+ store.updater.update([], ins, function (uri, ok, errorMessage) {
12601
12628
  if (!ok) {
12602
12629
  reject(new Error('Error recording your partipation: ' + errorMessage));
12603
12630
  } else {
12604
- resolve(participation);
12631
+ resolve(_participation2);
12605
12632
  }
12606
12633
  });
12607
- resolve(participation);
12634
+ resolve(_participation2);
12608
12635
  }
12609
12636
  });
12610
12637
  }
@@ -12621,8 +12648,8 @@ function recordParticipation(subject, padDoc, refreshable) {
12621
12648
  var me = (0, _authn.currentUser)();
12622
12649
  if (!me) return; // Not logged in
12623
12650
 
12624
- var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
12625
- return kb.holds(pn, ns.wf('participant'), me);
12651
+ var parps = store.each(subject, ns.wf('participation')).filter(function (pn) {
12652
+ return store.holds(pn, ns.wf('participant'), me);
12626
12653
  });
12627
12654
 
12628
12655
  if (parps.length > 1) {
@@ -12633,14 +12660,14 @@ function recordParticipation(subject, padDoc, refreshable) {
12633
12660
  // If I am not already recorded
12634
12661
  return parps[0]; // returns the particpation object
12635
12662
  } else {
12636
- var participation = (0, _widgets.newThing)(padDoc);
12637
- 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)];
12638
-
12639
- if (!kb.updater) {
12640
- throw new Error('kb has no updater');
12663
+ if (!store.updater.editable(padDoc)) {
12664
+ debug.log('Not recording participation, as no write acesss as ' + me + ' to ' + padDoc);
12665
+ return null;
12641
12666
  }
12642
12667
 
12643
- kb.updater.update([], ins, function (uri, ok, errorMessage) {
12668
+ var participation = (0, _widgets.newThing)(padDoc);
12669
+ 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)];
12670
+ store.updater.update([], ins, function (uri, ok, errorMessage) {
12644
12671
  if (!ok) {
12645
12672
  throw new Error('Error recording your partipation: ' + errorMessage);
12646
12673
  }
@@ -12670,8 +12697,10 @@ function manageParticipation(dom, container, padDoc, subject, me, options) {
12670
12697
  container.appendChild(table);
12671
12698
  renderPartipants(dom, table, padDoc, subject, me, options);
12672
12699
 
12700
+ var _participation;
12701
+
12673
12702
  try {
12674
- recordParticipation(subject, padDoc, table);
12703
+ _participation = recordParticipation(subject, padDoc, table);
12675
12704
  } catch (e) {
12676
12705
  container.appendChild((0, _widgets.errorMessageBlock)(dom, 'Error recording your partipation: ' + e)); // Clean up?
12677
12706
  }
@@ -16141,23 +16170,23 @@ Object.defineProperty(exports, "__esModule", {
16141
16170
  });
16142
16171
  exports["default"] = void 0;
16143
16172
  var _default = {
16144
- buildTime: '2022-01-30T10:49:38Z',
16145
- commit: 'ad0658696d9c3b3ba573f6e3b58c45e285b4d0ba',
16173
+ buildTime: '2022-02-12T13:53:21Z',
16174
+ commit: 'ea33598dce93d43d9a960c114f9d08be648003e9',
16146
16175
  npmInfo: {
16147
16176
  'solid-ui': '2.4.16',
16148
- npm: '6.14.15',
16177
+ npm: '6.14.16',
16149
16178
  ares: '1.18.1',
16150
16179
  brotli: '1.0.9',
16151
- cldr: '39.0',
16152
- icu: '69.1',
16180
+ cldr: '40.0',
16181
+ icu: '70.1',
16153
16182
  llhttp: '2.1.4',
16154
16183
  modules: '83',
16155
16184
  napi: '8',
16156
16185
  nghttp2: '1.42.0',
16157
- node: '14.18.3',
16158
- openssl: '1.1.1l',
16159
- tz: '2021a',
16160
- unicode: '13.0',
16186
+ node: '14.19.0',
16187
+ openssl: '1.1.1m',
16188
+ tz: '2021a3',
16189
+ unicode: '14.0',
16161
16190
  uv: '1.42.0',
16162
16191
  v8: '8.4.371.23-node.85',
16163
16192
  zlib: '1.2.11'