@semapps/activitypub-components 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +65 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +66 -31
- package/dist/index.es.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs.js
CHANGED
|
@@ -186,6 +186,7 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
|
|
|
186
186
|
status: "connecting"
|
|
187
187
|
});
|
|
188
188
|
const dataProvider = (0, $583VT$reactadmin.useDataProvider)();
|
|
189
|
+
const webSocketRef = (0, $583VT$react.useRef)(null);
|
|
189
190
|
// Get collectionUrl from webId predicate or URL.
|
|
190
191
|
const collectionUrl = (0, $583VT$react.useMemo)(()=>{
|
|
191
192
|
if (predicateOrUrl) {
|
|
@@ -302,34 +303,55 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
|
|
|
302
303
|
// Live Updates
|
|
303
304
|
(0, $583VT$react.useEffect)(()=>{
|
|
304
305
|
if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes
|
|
305
|
-
(0, $583VT$semappssemanticdataprovider.getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((
|
|
306
|
-
|
|
306
|
+
(0, $583VT$semappssemanticdataprovider.getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((ws)=>{
|
|
307
|
+
webSocketRef.current = ws; // Keep a ref to the webSocket so that it can be used elsewhere
|
|
308
|
+
webSocketRef.current.addEventListener("message", (e)=>{
|
|
307
309
|
const data = JSON.parse(e.data);
|
|
308
310
|
if (data.type === "Add") addItem(data.object, true);
|
|
309
311
|
else if (data.type === "Remove") removeItem(data.object, true);
|
|
310
312
|
});
|
|
311
|
-
|
|
313
|
+
webSocketRef.current.addEventListener("error", (e)=>{
|
|
312
314
|
setHasLiveUpdates({
|
|
313
315
|
status: "error",
|
|
314
316
|
error: e
|
|
315
317
|
});
|
|
316
318
|
// TODO: Retry after a while
|
|
317
319
|
});
|
|
318
|
-
|
|
320
|
+
webSocketRef.current.addEventListener("close", (e)=>{
|
|
319
321
|
if (!hasLiveUpdates.error) setHasLiveUpdates({
|
|
320
322
|
...hasLiveUpdates,
|
|
321
323
|
status: "closed"
|
|
322
324
|
});
|
|
323
325
|
});
|
|
324
326
|
setHasLiveUpdates({
|
|
325
|
-
status: "connected"
|
|
326
|
-
webSocket: webSocket
|
|
327
|
+
status: "connected"
|
|
327
328
|
});
|
|
328
329
|
}).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay.
|
|
329
330
|
}, [
|
|
330
331
|
collectionUrl,
|
|
331
332
|
liveUpdates,
|
|
332
|
-
dataProvider
|
|
333
|
+
dataProvider,
|
|
334
|
+
webSocketRef
|
|
335
|
+
]);
|
|
336
|
+
const awaitWebSocketConnection = (0, $583VT$react.useCallback)((options = {})=>{
|
|
337
|
+
const { timeout: timeout = 30000 } = options;
|
|
338
|
+
return new Promise((resolve, reject)=>{
|
|
339
|
+
if (webSocketRef?.current) resolve(webSocketRef);
|
|
340
|
+
else {
|
|
341
|
+
const timeoutId = setTimeout(()=>{
|
|
342
|
+
reject(`No WebSocket connection found within ${Math.round(timeout / 1000)}s`);
|
|
343
|
+
}, timeout);
|
|
344
|
+
const intervalId = setInterval(()=>{
|
|
345
|
+
if (webSocketRef?.current) {
|
|
346
|
+
clearInterval(intervalId);
|
|
347
|
+
clearTimeout(timeoutId);
|
|
348
|
+
resolve(webSocketRef);
|
|
349
|
+
} else console.log("WebSocket is not initialized yet, waiting...");
|
|
350
|
+
}, 100);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}, [
|
|
354
|
+
webSocketRef
|
|
333
355
|
]);
|
|
334
356
|
return {
|
|
335
357
|
items: items,
|
|
@@ -344,7 +366,9 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
|
|
|
344
366
|
isFetching: isFetchingPage || isFetchingItems,
|
|
345
367
|
isFetchingNextPage: isFetchingNextPage,
|
|
346
368
|
url: collectionUrl,
|
|
347
|
-
hasLiveUpdates: hasLiveUpdates
|
|
369
|
+
hasLiveUpdates: hasLiveUpdates,
|
|
370
|
+
awaitWebSocketConnection: awaitWebSocketConnection,
|
|
371
|
+
webSocketRef: webSocketRef
|
|
348
372
|
};
|
|
349
373
|
};
|
|
350
374
|
var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollection;
|
|
@@ -354,49 +378,60 @@ var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollecti
|
|
|
354
378
|
|
|
355
379
|
/**
|
|
356
380
|
* Hook used internally by useInbox and useOutbox. This is not exported.
|
|
357
|
-
* @param
|
|
381
|
+
* @param awaitWebSocketConnection Promise returning the WebSocket which allow to listen to the inbox or outbox
|
|
358
382
|
* @param existingActivities Partial list of activities already received in the inbox and outbox
|
|
359
|
-
*/ const $5e70f9d0635e25dd$var$useAwaitActivity = (
|
|
383
|
+
*/ const $5e70f9d0635e25dd$var$useAwaitActivity = (awaitWebSocketConnection, existingActivities)=>{
|
|
360
384
|
const dataProvider = (0, $583VT$reactadmin.useDataProvider)();
|
|
361
|
-
// TODO Allow to pass an
|
|
385
|
+
// TODO Allow to pass an object, and automatically dereference it if required, like on the @semapps/activitypub matchActivity util
|
|
362
386
|
return (0, $583VT$react.useCallback)((matchActivity, options = {})=>{
|
|
363
387
|
const { timeout: timeout = 30000, checkExistingActivities: checkExistingActivities = false } = options;
|
|
364
388
|
return new Promise((resolve, reject)=>{
|
|
365
|
-
|
|
389
|
+
awaitWebSocketConnection().then((webSocketRef)=>{
|
|
366
390
|
const onMessage = (event)=>{
|
|
367
391
|
const data = JSON.parse(event.data);
|
|
368
392
|
if (data.type === "Add") dataProvider.fetch(data.object).then(({ json: json })=>{
|
|
369
393
|
if (matchActivity(json)) {
|
|
370
|
-
|
|
394
|
+
removeListeners();
|
|
371
395
|
return resolve(json);
|
|
372
396
|
}
|
|
373
397
|
});
|
|
374
398
|
};
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
399
|
+
const onError = (e)=>{
|
|
400
|
+
// TODO reconnect if connection closed
|
|
401
|
+
removeListeners();
|
|
378
402
|
reject(e);
|
|
379
|
-
}
|
|
380
|
-
|
|
403
|
+
};
|
|
404
|
+
const onClose = (e)=>{
|
|
405
|
+
removeListeners();
|
|
381
406
|
reject(new Error(`${e.reason} (Code: ${e.code})`));
|
|
382
|
-
}
|
|
407
|
+
};
|
|
408
|
+
const removeListeners = ()=>{
|
|
409
|
+
webSocketRef.current?.removeEventListener("message", onMessage);
|
|
410
|
+
webSocketRef.current?.removeEventListener("error", onError);
|
|
411
|
+
webSocketRef.current?.removeEventListener("close", onClose);
|
|
412
|
+
};
|
|
413
|
+
webSocketRef.current?.addEventListener("message", onMessage);
|
|
414
|
+
webSocketRef.current?.addEventListener("error", onError);
|
|
415
|
+
webSocketRef.current?.addEventListener("close", onClose);
|
|
383
416
|
// If a list of activities is already loaded, verify if there is a match
|
|
384
417
|
if (existingActivities && checkExistingActivities) for (const a of existingActivities){
|
|
385
418
|
if (typeof a !== "string") {
|
|
386
419
|
if (matchActivity(a)) {
|
|
387
|
-
|
|
420
|
+
removeListeners();
|
|
388
421
|
return resolve(a);
|
|
389
422
|
}
|
|
390
423
|
}
|
|
391
424
|
}
|
|
392
425
|
setTimeout(()=>{
|
|
393
|
-
|
|
426
|
+
removeListeners();
|
|
394
427
|
reject(new Error("Timeout"));
|
|
395
428
|
}, timeout);
|
|
396
|
-
}
|
|
429
|
+
}).catch((e)=>{
|
|
430
|
+
reject(e);
|
|
431
|
+
});
|
|
397
432
|
});
|
|
398
433
|
}, [
|
|
399
|
-
|
|
434
|
+
awaitWebSocketConnection,
|
|
400
435
|
existingActivities,
|
|
401
436
|
dataProvider
|
|
402
437
|
]);
|
|
@@ -415,8 +450,8 @@ var $5e70f9d0635e25dd$export$2e2bcd8739ae039 = $5e70f9d0635e25dd$var$useAwaitAct
|
|
|
415
450
|
*/ const $456aea3814dded7d$var$useOutbox = (options = {})=>{
|
|
416
451
|
const dataProvider = (0, $583VT$reactadmin.useDataProvider)();
|
|
417
452
|
const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)();
|
|
418
|
-
const { url: url,
|
|
419
|
-
const awaitActivity = (0, $5e70f9d0635e25dd$export$2e2bcd8739ae039)(
|
|
453
|
+
const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)("outbox", options);
|
|
454
|
+
const awaitActivity = (0, $5e70f9d0635e25dd$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
|
|
420
455
|
// Post an activity to the logged user's outbox and return its URI
|
|
421
456
|
const post = (0, $583VT$react.useCallback)(async (activity)=>{
|
|
422
457
|
if (!url) throw new Error("Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox");
|
|
@@ -434,8 +469,8 @@ var $5e70f9d0635e25dd$export$2e2bcd8739ae039 = $5e70f9d0635e25dd$var$useAwaitAct
|
|
|
434
469
|
]);
|
|
435
470
|
return {
|
|
436
471
|
url: url,
|
|
437
|
-
hasLiveUpdates: hasLiveUpdates,
|
|
438
472
|
items: items,
|
|
473
|
+
awaitWebSocketConnection: awaitWebSocketConnection,
|
|
439
474
|
post: post,
|
|
440
475
|
awaitActivity: awaitActivity,
|
|
441
476
|
owner: identity?.id,
|
|
@@ -897,12 +932,12 @@ var $b0c94a9bdea99da5$export$2e2bcd8739ae039 = $b0c94a9bdea99da5$var$ReferenceCo
|
|
|
897
932
|
* @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`
|
|
898
933
|
*/ const $486f741c94cd8f74$var$useInbox = (options = {})=>{
|
|
899
934
|
const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)();
|
|
900
|
-
const {
|
|
901
|
-
const awaitActivity = (0, $5e70f9d0635e25dd$export$2e2bcd8739ae039)(
|
|
935
|
+
const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)("inbox", options);
|
|
936
|
+
const awaitActivity = (0, $5e70f9d0635e25dd$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
|
|
902
937
|
return {
|
|
903
|
-
items: items,
|
|
904
938
|
url: url,
|
|
905
|
-
|
|
939
|
+
items: items,
|
|
940
|
+
awaitWebSocketConnection: awaitWebSocketConnection,
|
|
906
941
|
awaitActivity: awaitActivity,
|
|
907
942
|
owner: identity?.id,
|
|
908
943
|
...rest
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;AACR;AAEO,MAAM,4CAAc;IACzB,aAAa;IACb,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;AACX;AAEO,MAAM,4CAAe;IAC1B,SAAS;IACT,OAAO;IACP,UAAU;IACV,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;IACT,cAAc;IACd,WAAW;IACX,OAAO;AACT;AAEO,MAAM,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AG;QAC/G;IAEJ,GAAG;QAAC;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.ts","packages/activitypub-components/src/hooks/useCollection.ts","packages/activitypub-components/src/utils.ts","packages/activitypub-components/src/hooks/useAwaitActivity.ts","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useInbox.ts","packages/activitypub-components/src/hooks/useNodeinfo.ts","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n <PostCommentForm\n context={context}\n helperText={helperText}\n userResource={userResource}\n placeholder={placeholder}\n mentions={mentions}\n addItem={addItem}\n removeItem={removeItem}\n />\n <CommentsList comments={comments} loading={loading} userResource={userResource} />\n </>\n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n <Form onSubmit={onSubmit} className={classes.form}>\n <Box className={classes.container} onClick={openAuthIfDisconnected}>\n <Avatar\n src={\n identity?.webIdData?.[userDataModel?.fieldsMapping?.image] ||\n identity?.profileData?.[userDataModel?.fieldsMapping?.image]\n }\n className={classes.avatar}\n />\n <RichTextInput\n source=\"comment\"\n label=\" \"\n toolbar={<EmptyToolbar />}\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n <Button\n type=\"submit\"\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n endIcon={<SendIcon />}\n className={classes.button}\n >\n Envoyer\n </Button>\n )}\n </Box>\n </Form>\n <AuthDialog\n open={openAuth}\n onClose={() => setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n </>\n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVEL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback } from 'react';\nimport { useDataProvider, useGetIdentity } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch and post to the outbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `post`: a function to post a new activity in the user's outbox\n * - `awaitActivity`: a function to wait for a certain activity to be posted\n * - `owner`: the WebID of the outbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useoutbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useOutbox = (options: UseCollectionOptions = {}) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const { data: identity } = useGetIdentity();\n const { url, hasLiveUpdates, items, ...rest } = useCollection('outbox', options);\n const awaitActivity = useAwaitActivity(hasLiveUpdates.webSocket, items);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async (activity: object) => {\n if (!url) {\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox'\n );\n }\n const { headers } = await dataProvider.fetch(url, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n })\n });\n return headers.get('Location');\n },\n [url, dataProvider]\n );\n\n return { url, hasLiveUpdates, items, post, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useOutbox;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query';\nimport { getOrCreateWsChannel, SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\nimport type { UseCollectionOptions, SolidNotification } from '../types';\n\nconst useItemsFromPages = (pages: any[], dereferenceItems: boolean) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]);\n\n // We will force dereference, if some items are not URI string references.\n const shouldDereference = useMemo(() => {\n return dereferenceItems || items.some(item => typeof item !== 'string');\n }, [dereferenceItems, items]);\n\n // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).\n const itemQueries = useQueries(\n !shouldDereference\n ? []\n : items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n if (!shouldDereference) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 ? errors : undefined\n };\n};\n\n/**\n * Subscribe a collection. Supports pagination.\n * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId).\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState<number>();\n const queryClient = useQueryClient();\n const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any; webSocket?: WebSocket }>({\n status: 'connecting'\n });\n const dataProvider = useDataProvider<SemanticDataProvider>();\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection: QueryFunction = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data: pageData,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: (lastPage: any) => lastPage.next,\n getPreviousPageParam: (firstPage: any) => firstPage.prev\n });\n\n // Put all items together in a list (and dereference, if required).\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n const addItem = useCallback(\n (item: string | any, shouldRefetch: boolean | number = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems + 1);\n\n // Destructure, so react knows, it needs to re-render the pages.\n const pages = [...oldData.pages];\n const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || [];\n firstPageItems.unshift(item);\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n (item: string | any, shouldRefetch: boolean = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems - 1);\n\n // Destructure, so react knows, it needs to re-render the pages array.\n const pages = [...oldData.pages];\n // Find the item in all pages and remove the item to be removed (either item.id or just item)\n pages.forEach(page => {\n if (page.orderedItems) {\n page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item));\n } else if (page.items) {\n page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item));\n }\n });\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(webSocket => {\n webSocket.addEventListener('message', e => {\n const data: SolidNotification = JSON.parse(e.data);\n if (data.type === 'Add') {\n addItem(data.object, true);\n } else if (data.type === 'Remove') {\n removeItem(data.object, true);\n }\n });\n webSocket.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocket.addEventListener('close', e => {\n if (!hasLiveUpdates.error) {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' });\n }\n });\n setHasLiveUpdates({ status: 'connected', webSocket });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider]);\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n addItem,\n removeItem,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates\n };\n};\n\nexport default useCollection;\n","export const arrayOf = <T>(value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n\nexport const filterDuplicates = <T>(iterable: T[], predicate: (item: T) => string) => {\n const seen = new Set<string>();\n return iterable.filter(item => {\n const key = predicate(item);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n};\n","import { useCallback } from 'react';\nimport { useDataProvider } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { SolidNotification, AwaitActivityOptions } from '../types';\n\n/**\n * Hook used internally by useInbox and useOutbox. This is not exported.\n * @param webSocket WebSocket which allow to listen to the inbox or outbox\n * @param existingActivities Partial list of activities already received in the inbox and outbox\n */\nconst useAwaitActivity = (webSocket?: WebSocket, existingActivities?: Array<object | string>) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n\n // TODO Allow to pass an object, and automatically dereference it if required, like on the @semapps/activitypub matchActivity util\n return useCallback(\n (matchActivity: (activity: object) => boolean, options: AwaitActivityOptions = {}) => {\n const { timeout = 30000, checkExistingActivities = false } = options;\n return new Promise((resolve, reject) => {\n if (webSocket) {\n const onMessage = (event: MessageEvent<string>) => {\n const data: SolidNotification = JSON.parse(event.data);\n if (data.type === 'Add') {\n dataProvider.fetch(data.object).then(({ json }) => {\n if (matchActivity(json)) {\n webSocket.removeEventListener('message', onMessage);\n return resolve(json);\n }\n });\n }\n };\n\n webSocket.addEventListener('message', onMessage);\n\n // TODO reconnect if connection closed\n webSocket.addEventListener('error', e => {\n reject(e);\n });\n webSocket.addEventListener('close', e => {\n reject(new Error(`${e.reason} (Code: ${e.code})`));\n });\n\n // If a list of activities is already loaded, verify if there is a match\n if (existingActivities && checkExistingActivities) {\n for (const a of existingActivities) {\n if (typeof a !== 'string') {\n if (matchActivity(a)) {\n webSocket.removeEventListener('message', onMessage);\n return resolve(a);\n }\n }\n }\n }\n\n setTimeout(() => {\n webSocket.removeEventListener('message', onMessage);\n reject(new Error('Timeout'));\n }, timeout);\n } else {\n throw new Error('WebSocket is not initialized !');\n }\n });\n },\n [webSocket, existingActivities, dataProvider]\n );\n};\n\nexport default useAwaitActivity;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n <Box position=\"relative\">\n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n <Box className={classes.container} key={comment.id}>\n <Box className={classes.avatar}>\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <AvatarWithLabelField image={userDataModel?.fieldsMapping?.image} />\n </ReferenceField>\n </Box>\n <Box className={classes.text}>\n <Typography variant=\"body2\">\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <TextField variant=\"body2\" source={userDataModel?.fieldsMapping?.title} className={classes.label} />\n </ReferenceField>\n • \n <DateField record={comment} variant=\"body2\" source=\"published\" showTime />\n </Typography>\n <RichTextField record={comment} variant=\"body1\" source=\"content\" className={classes.content} />\n </Box>\n </Box>\n ))}\n {loading && (\n <Box minHeight={200}>\n <Box alignItems=\"center\" className={classes.loading}>\n <CircularProgress size={60} thickness={6} />\n </Box>\n </Box>\n )}\n </Box>\n );\n};\n\nexport default CommentsList;\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error('<CollectionList> only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return <ListContextProvider value={listContext}>{children}</ListContextProvider>;\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error('<ReferenceCollectionField> only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n <CollectionList resource={reference} collectionUrl={record[source]} {...rest}>\n {children}\n </CollectionList>\n );\n};\n\nexport default ReferenceCollectionField;\n","import { useGetIdentity } from 'react-admin';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch the inbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `awaitActivity`: a function to wait for a certain activity to be received\n * - `owner`: the WebID of the inbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useinbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useInbox = (options: UseCollectionOptions = {}) => {\n const { data: identity } = useGetIdentity();\n const { items, url, hasLiveUpdates, ...rest } = useCollection('inbox', options);\n const awaitActivity = useAwaitActivity(hasLiveUpdates.webSocket);\n return { items, url, hasLiveUpdates, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\nimport type { NodeInfo, NodeInfoLinks } from '../types';\n\nconst useNodeinfo = (host : string, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState<NodeInfo>();\n\n useEffect(() => {\n (async () => {\n if (host && rel) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n \n try {\n const { json: links } : { json: NodeInfoLinks } = await fetchUtils.fetchJson(nodeinfoUrl);\n \n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n \n if (link) {\n const { json } : { json: NodeInfo } = await fetchUtils.fetchJson(link.href);\n \n setSchema(json);\n }\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n <div className={classes.items}>\n {props.items.length ? (\n props.items.map((item, index) => (\n <button\n className={classes.item + (index === selectedIndex ? ' selected' : '')}\n key={index}\n onClick={() => selectItem(index)}\n >\n {item.label}\n </button>\n ))\n ) : (\n <div className={classes.item}>Aucun résultat</div>\n )}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"index.cjs.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP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","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.ts","packages/activitypub-components/src/hooks/useCollection.ts","packages/activitypub-components/src/utils.ts","packages/activitypub-components/src/hooks/useAwaitActivity.ts","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useInbox.ts","packages/activitypub-components/src/hooks/useNodeinfo.ts","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n <PostCommentForm\n context={context}\n helperText={helperText}\n userResource={userResource}\n placeholder={placeholder}\n mentions={mentions}\n addItem={addItem}\n removeItem={removeItem}\n />\n <CommentsList comments={comments} loading={loading} userResource={userResource} />\n </>\n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n <Form onSubmit={onSubmit} className={classes.form}>\n <Box className={classes.container} onClick={openAuthIfDisconnected}>\n <Avatar\n src={\n identity?.webIdData?.[userDataModel?.fieldsMapping?.image] ||\n identity?.profileData?.[userDataModel?.fieldsMapping?.image]\n }\n className={classes.avatar}\n />\n <RichTextInput\n source=\"comment\"\n label=\" \"\n toolbar={<EmptyToolbar />}\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n <Button\n type=\"submit\"\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n endIcon={<SendIcon />}\n className={classes.button}\n >\n Envoyer\n </Button>\n )}\n </Box>\n </Form>\n <AuthDialog\n open={openAuth}\n onClose={() => setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n </>\n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVEL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback } from 'react';\nimport { useDataProvider, useGetIdentity } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch and post to the outbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `post`: a function to post a new activity in the user's outbox\n * - `awaitActivity`: a function to wait for a certain activity to be posted\n * - `owner`: the WebID of the outbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useoutbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useOutbox = (options: UseCollectionOptions = {}) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const { data: identity } = useGetIdentity();\n const { url, items, awaitWebSocketConnection, ...rest } = useCollection('outbox', options);\n const awaitActivity = useAwaitActivity(awaitWebSocketConnection, items);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async (activity: object) => {\n if (!url) {\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox'\n );\n }\n const { headers } = await dataProvider.fetch(url, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n })\n });\n return headers.get('Location');\n },\n [url, dataProvider]\n );\n\n return { url, items, awaitWebSocketConnection, post, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useOutbox;\n","import { useCallback, useMemo, useState, useEffect, useRef, RefObject } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query';\nimport { getOrCreateWsChannel, SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\nimport type { UseCollectionOptions, SolidNotification, AwaitActivityOptions } from '../types';\n\nconst useItemsFromPages = (pages: any[], dereferenceItems: boolean) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]);\n\n // We will force dereference, if some items are not URI string references.\n const shouldDereference = useMemo(() => {\n return dereferenceItems || items.some(item => typeof item !== 'string');\n }, [dereferenceItems, items]);\n\n // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).\n const itemQueries = useQueries(\n !shouldDereference\n ? []\n : items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n if (!shouldDereference) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 ? errors : undefined\n };\n};\n\n/**\n * Subscribe a collection. Supports pagination.\n * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId).\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState<number>();\n const queryClient = useQueryClient();\n const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any }>({\n status: 'connecting'\n });\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const webSocketRef = useRef<WebSocket | null>(null);\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection: QueryFunction = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data: pageData,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: (lastPage: any) => lastPage.next,\n getPreviousPageParam: (firstPage: any) => firstPage.prev\n });\n\n // Put all items together in a list (and dereference, if required).\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n const addItem = useCallback(\n (item: string | any, shouldRefetch: boolean | number = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems + 1);\n\n // Destructure, so react knows, it needs to re-render the pages.\n const pages = [...oldData.pages];\n const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || [];\n firstPageItems.unshift(item);\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n (item: string | any, shouldRefetch: boolean = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems - 1);\n\n // Destructure, so react knows, it needs to re-render the pages array.\n const pages = [...oldData.pages];\n // Find the item in all pages and remove the item to be removed (either item.id or just item)\n pages.forEach(page => {\n if (page.orderedItems) {\n page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item));\n } else if (page.items) {\n page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item));\n }\n });\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(ws => {\n webSocketRef.current = ws; // Keep a ref to the webSocket so that it can be used elsewhere\n webSocketRef.current.addEventListener('message', e => {\n const data: SolidNotification = JSON.parse(e.data);\n if (data.type === 'Add') {\n addItem(data.object, true);\n } else if (data.type === 'Remove') {\n removeItem(data.object, true);\n }\n });\n webSocketRef.current.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocketRef.current.addEventListener('close', e => {\n if (!hasLiveUpdates.error) {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' });\n }\n });\n setHasLiveUpdates({ status: 'connected' });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider, webSocketRef]);\n\n const awaitWebSocketConnection = useCallback(\n (options: AwaitActivityOptions = {}): Promise<RefObject<WebSocket>> => {\n const { timeout = 30000 } = options;\n return new Promise((resolve, reject) => {\n if (webSocketRef?.current) {\n resolve(webSocketRef);\n } else {\n const timeoutId = setTimeout(() => {\n reject(`No WebSocket connection found within ${Math.round(timeout / 1000)}s`);\n }, timeout);\n const intervalId = setInterval(() => {\n if (webSocketRef?.current) {\n clearInterval(intervalId);\n clearTimeout(timeoutId);\n resolve(webSocketRef);\n } else {\n console.log('WebSocket is not initialized yet, waiting...');\n }\n }, 100);\n }\n });\n },\n [webSocketRef]\n );\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n addItem,\n removeItem,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates,\n awaitWebSocketConnection,\n webSocketRef\n };\n};\n\nexport default useCollection;\n","export const arrayOf = <T>(value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n\nexport const filterDuplicates = <T>(iterable: T[], predicate: (item: T) => string) => {\n const seen = new Set<string>();\n return iterable.filter(item => {\n const key = predicate(item);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n};\n","import { RefObject, useCallback } from 'react';\nimport { useDataProvider } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { SolidNotification, AwaitActivityOptions, AwaitWebSocketConnectionOptions } from '../types';\n\n/**\n * Hook used internally by useInbox and useOutbox. This is not exported.\n * @param awaitWebSocketConnection Promise returning the WebSocket which allow to listen to the inbox or outbox\n * @param existingActivities Partial list of activities already received in the inbox and outbox\n */\nconst useAwaitActivity = (\n awaitWebSocketConnection: (options?: AwaitWebSocketConnectionOptions) => Promise<RefObject<WebSocket>>,\n existingActivities?: Array<object | string>\n) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n\n // TODO Allow to pass an object, and automatically dereference it if required, like on the @semapps/activitypub matchActivity util\n return useCallback(\n (matchActivity: (activity: object) => boolean, options: AwaitActivityOptions = {}) => {\n const { timeout = 30000, checkExistingActivities = false } = options;\n return new Promise((resolve, reject) => {\n awaitWebSocketConnection()\n .then(webSocketRef => {\n const onMessage = (event: MessageEvent<string>) => {\n const data: SolidNotification = JSON.parse(event.data);\n if (data.type === 'Add') {\n dataProvider.fetch(data.object).then(({ json }) => {\n if (matchActivity(json)) {\n removeListeners();\n return resolve(json);\n }\n });\n }\n };\n const onError = (e: Event) => {\n // TODO reconnect if connection closed\n removeListeners();\n reject(e);\n };\n const onClose = (e: CloseEvent) => {\n removeListeners();\n reject(new Error(`${e.reason} (Code: ${e.code})`));\n };\n\n const removeListeners = () => {\n webSocketRef.current?.removeEventListener('message', onMessage);\n webSocketRef.current?.removeEventListener('error', onError);\n webSocketRef.current?.removeEventListener('close', onClose);\n };\n\n webSocketRef.current?.addEventListener('message', onMessage);\n webSocketRef.current?.addEventListener('error', onError);\n webSocketRef.current?.addEventListener('close', onClose);\n\n // If a list of activities is already loaded, verify if there is a match\n if (existingActivities && checkExistingActivities) {\n for (const a of existingActivities) {\n if (typeof a !== 'string') {\n if (matchActivity(a)) {\n removeListeners();\n return resolve(a);\n }\n }\n }\n }\n\n setTimeout(() => {\n removeListeners();\n reject(new Error('Timeout'));\n }, timeout);\n })\n .catch(e => {\n reject(e);\n });\n });\n },\n [awaitWebSocketConnection, existingActivities, dataProvider]\n );\n};\n\nexport default useAwaitActivity;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n <Box position=\"relative\">\n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n <Box className={classes.container} key={comment.id}>\n <Box className={classes.avatar}>\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <AvatarWithLabelField image={userDataModel?.fieldsMapping?.image} />\n </ReferenceField>\n </Box>\n <Box className={classes.text}>\n <Typography variant=\"body2\">\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <TextField variant=\"body2\" source={userDataModel?.fieldsMapping?.title} className={classes.label} />\n </ReferenceField>\n • \n <DateField record={comment} variant=\"body2\" source=\"published\" showTime />\n </Typography>\n <RichTextField record={comment} variant=\"body1\" source=\"content\" className={classes.content} />\n </Box>\n </Box>\n ))}\n {loading && (\n <Box minHeight={200}>\n <Box alignItems=\"center\" className={classes.loading}>\n <CircularProgress size={60} thickness={6} />\n </Box>\n </Box>\n )}\n </Box>\n );\n};\n\nexport default CommentsList;\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error('<CollectionList> only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return <ListContextProvider value={listContext}>{children}</ListContextProvider>;\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error('<ReferenceCollectionField> only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n <CollectionList resource={reference} collectionUrl={record[source]} {...rest}>\n {children}\n </CollectionList>\n );\n};\n\nexport default ReferenceCollectionField;\n","import { useGetIdentity } from 'react-admin';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch the inbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `awaitActivity`: a function to wait for a certain activity to be received\n * - `owner`: the WebID of the inbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useinbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useInbox = (options: UseCollectionOptions = {}) => {\n const { data: identity } = useGetIdentity();\n const { url, items, awaitWebSocketConnection, ...rest } = useCollection('inbox', options);\n const awaitActivity = useAwaitActivity(awaitWebSocketConnection, items);\n return { url, items, awaitWebSocketConnection, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\nimport type { NodeInfo, NodeInfoLinks } from '../types';\n\nconst useNodeinfo = (host: string, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState<NodeInfo>();\n\n useEffect(() => {\n (async () => {\n if (host && rel) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n\n try {\n const { json: links }: { json: NodeInfoLinks } = await fetchUtils.fetchJson(nodeinfoUrl);\n\n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n\n if (link) {\n const { json }: { json: NodeInfo } = await fetchUtils.fetchJson(link.href);\n\n setSchema(json);\n }\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n <div className={classes.items}>\n {props.items.length ? (\n props.items.map((item, index) => (\n <button\n className={classes.item + (index === selectedIndex ? ' selected' : '')}\n key={index}\n onClick={() => selectItem(index)}\n >\n {item.label}\n </button>\n ))\n ) : (\n <div className={classes.item}>Aucun résultat</div>\n )}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"index.cjs.js.map"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
export declare namespace ACTIVITY_TYPES {
|
|
2
3
|
let ACCEPT: string;
|
|
3
4
|
let ADD: string;
|
|
@@ -54,6 +55,10 @@ interface UseCollectionOptions {
|
|
|
54
55
|
dereferenceItems?: boolean;
|
|
55
56
|
liveUpdates?: boolean;
|
|
56
57
|
}
|
|
58
|
+
interface AwaitActivityOptions {
|
|
59
|
+
timeout?: number;
|
|
60
|
+
checkExistingActivities?: boolean;
|
|
61
|
+
}
|
|
57
62
|
/**
|
|
58
63
|
* NodeInfo schema version 2.1.
|
|
59
64
|
*/
|
|
@@ -212,8 +217,9 @@ export const useCollection: (
|
|
|
212
217
|
hasLiveUpdates: {
|
|
213
218
|
status: string;
|
|
214
219
|
error?: any;
|
|
215
|
-
webSocket?: WebSocket | undefined;
|
|
216
220
|
};
|
|
221
|
+
awaitWebSocketConnection: (options?: AwaitActivityOptions) => Promise<RefObject<WebSocket>>;
|
|
222
|
+
webSocketRef: import('react').MutableRefObject<WebSocket | null>;
|
|
217
223
|
};
|
|
218
224
|
/**
|
|
219
225
|
* Hook to fetch and post to the outbox of the logged user.
|
|
@@ -239,13 +245,16 @@ export const useOutbox: (options?: UseCollectionOptions) => {
|
|
|
239
245
|
isLoading: boolean;
|
|
240
246
|
isFetching: boolean;
|
|
241
247
|
isFetchingNextPage: boolean;
|
|
242
|
-
url: any;
|
|
243
248
|
hasLiveUpdates: {
|
|
244
249
|
status: string;
|
|
245
250
|
error?: any;
|
|
246
|
-
webSocket?: WebSocket | undefined;
|
|
247
251
|
};
|
|
252
|
+
webSocketRef: import('react').MutableRefObject<WebSocket | null>;
|
|
253
|
+
url: any;
|
|
248
254
|
items: any[];
|
|
255
|
+
awaitWebSocketConnection: (
|
|
256
|
+
options?: import('types').AwaitActivityOptions
|
|
257
|
+
) => Promise<import('react').RefObject<WebSocket>>;
|
|
249
258
|
post: (activity: object) => Promise<string | null>;
|
|
250
259
|
awaitActivity: (
|
|
251
260
|
matchActivity: (activity: object) => boolean,
|
|
@@ -319,13 +328,16 @@ export const useInbox: (options?: UseCollectionOptions) => {
|
|
|
319
328
|
isLoading: boolean;
|
|
320
329
|
isFetching: boolean;
|
|
321
330
|
isFetchingNextPage: boolean;
|
|
322
|
-
items: any[];
|
|
323
|
-
url: any;
|
|
324
331
|
hasLiveUpdates: {
|
|
325
332
|
status: string;
|
|
326
333
|
error?: any;
|
|
327
|
-
webSocket?: WebSocket | undefined;
|
|
328
334
|
};
|
|
335
|
+
webSocketRef: import('react').MutableRefObject<WebSocket | null>;
|
|
336
|
+
url: any;
|
|
337
|
+
items: any[];
|
|
338
|
+
awaitWebSocketConnection: (
|
|
339
|
+
options?: import('types').AwaitActivityOptions
|
|
340
|
+
) => Promise<import('react').RefObject<WebSocket>>;
|
|
329
341
|
awaitActivity: (
|
|
330
342
|
matchActivity: (activity: object) => boolean,
|
|
331
343
|
options?: import('types').AwaitActivityOptions
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,wEAAyE;AEtDzE;IACE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAMD;IAC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AAO,CAAC;IAC3B;;OAEG;IACH,KAAK,EAAE;QACL;;WAEG;QACH,KAAK,EAAE;YACL;;eAEG;YACH,KAAK,CAAC,EAAE,MAAM,CAAC;YACf;;eAEG;YACH,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB;;eAEG;YACH,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;QACF;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF;;OAEG;IACH,QAAQ,EAAE;QACR,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,CAAC;CACH;AC9GD;;;;GAIG;AACH,OAAA,MAAM,gCAAiC,MAAM,YAAW,oBAAoB;;;;;;oBAgFjE,MAAM,GAAG,GAAG,kBAAiB,OAAO,GAAG,MAAM;uBA4B7C,MAAM,GAAG,GAAG,kBAAiB,OAAO;;;;;;;gBAvGkB,MAAM;gBAAU,GAAG;;yCAuKtE,oBAAoB,KAAQ,QAAQ,UAAU,SAAS,CAAC,CAAC;;CAyCtE,CAAC;AEtQF;;;;;;;;GAQG;AACH,OAAA,MAAM,sBAAsB,oBAAoB;;;;;;;;;;;;;;;;;;;qBAQ3B,MAAM;;;CAmB1B,CAAC;AIrCF;;;;;;;4CAkBC;;;;;;;;;ACpBD;;;;4CAgBC;AChBD;;;;;mDAcC;ACbD;;;;;;;GAOG;AACH,OAAA,MAAM,qBAAqB,oBAAoB;;;;;;;;;;;;;;;;;;;;;CAK9C,CAAC;ACdF,OAAA,MAAM,oBAAqB,MAAM,uCA4BhC,CAAC;AC7BF;;EAwBC;AGtBD;;;;;;;;;;;;;EAkCC","sources":["packages/activitypub-components/src/src/constants.js","packages/activitypub-components/src/src/utils.ts","packages/activitypub-components/src/src/types.ts","packages/activitypub-components/src/src/hooks/useCollection.ts","packages/activitypub-components/src/src/hooks/useAwaitActivity.ts","packages/activitypub-components/src/src/hooks/useOutbox.ts","packages/activitypub-components/src/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/src/components/CollectionList.js","packages/activitypub-components/src/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/src/hooks/useInbox.ts","packages/activitypub-components/src/src/hooks/useNodeinfo.ts","packages/activitypub-components/src/src/hooks/useWebfinger.js","packages/activitypub-components/src/src/hooks/useMentions/MentionsList.js","packages/activitypub-components/src/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/src/index.ts","packages/activitypub-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {jsxs as $85cNH$jsxs, Fragment as $85cNH$Fragment, jsx as $85cNH$jsx} from "react/jsx-runtime";
|
|
2
|
-
import $85cNH$react, {useState as $85cNH$useState, useCallback as $85cNH$useCallback, useMemo as $85cNH$useMemo, useEffect as $85cNH$useEffect, forwardRef as $85cNH$forwardRef, useImperativeHandle as $85cNH$useImperativeHandle} from "react";
|
|
2
|
+
import $85cNH$react, {useState as $85cNH$useState, useCallback as $85cNH$useCallback, useMemo as $85cNH$useMemo, useRef as $85cNH$useRef, useEffect as $85cNH$useEffect, forwardRef as $85cNH$forwardRef, useImperativeHandle as $85cNH$useImperativeHandle} from "react";
|
|
3
3
|
import {useRecordContext as $85cNH$useRecordContext, useGetIdentity as $85cNH$useGetIdentity, useNotify as $85cNH$useNotify, Form as $85cNH$Form, useDataProvider as $85cNH$useDataProvider, TextField as $85cNH$TextField, DateField as $85cNH$DateField, RichTextField as $85cNH$RichTextField, useGetMany as $85cNH$useGetMany, useList as $85cNH$useList, ListContextProvider as $85cNH$ListContextProvider, fetchUtils as $85cNH$fetchUtils, useGetList as $85cNH$useGetList} from "react-admin";
|
|
4
4
|
import {RichTextInput as $85cNH$RichTextInput, DefaultEditorOptions as $85cNH$DefaultEditorOptions} from "ra-input-rich-text";
|
|
5
5
|
import $85cNH$tiptapextensionplaceholder from "@tiptap/extension-placeholder";
|
|
@@ -164,6 +164,7 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
|
|
|
164
164
|
status: "connecting"
|
|
165
165
|
});
|
|
166
166
|
const dataProvider = (0, $85cNH$useDataProvider)();
|
|
167
|
+
const webSocketRef = (0, $85cNH$useRef)(null);
|
|
167
168
|
// Get collectionUrl from webId predicate or URL.
|
|
168
169
|
const collectionUrl = (0, $85cNH$useMemo)(()=>{
|
|
169
170
|
if (predicateOrUrl) {
|
|
@@ -280,34 +281,55 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
|
|
|
280
281
|
// Live Updates
|
|
281
282
|
(0, $85cNH$useEffect)(()=>{
|
|
282
283
|
if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes
|
|
283
|
-
(0, $85cNH$getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((
|
|
284
|
-
|
|
284
|
+
(0, $85cNH$getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((ws)=>{
|
|
285
|
+
webSocketRef.current = ws; // Keep a ref to the webSocket so that it can be used elsewhere
|
|
286
|
+
webSocketRef.current.addEventListener("message", (e)=>{
|
|
285
287
|
const data = JSON.parse(e.data);
|
|
286
288
|
if (data.type === "Add") addItem(data.object, true);
|
|
287
289
|
else if (data.type === "Remove") removeItem(data.object, true);
|
|
288
290
|
});
|
|
289
|
-
|
|
291
|
+
webSocketRef.current.addEventListener("error", (e)=>{
|
|
290
292
|
setHasLiveUpdates({
|
|
291
293
|
status: "error",
|
|
292
294
|
error: e
|
|
293
295
|
});
|
|
294
296
|
// TODO: Retry after a while
|
|
295
297
|
});
|
|
296
|
-
|
|
298
|
+
webSocketRef.current.addEventListener("close", (e)=>{
|
|
297
299
|
if (!hasLiveUpdates.error) setHasLiveUpdates({
|
|
298
300
|
...hasLiveUpdates,
|
|
299
301
|
status: "closed"
|
|
300
302
|
});
|
|
301
303
|
});
|
|
302
304
|
setHasLiveUpdates({
|
|
303
|
-
status: "connected"
|
|
304
|
-
webSocket: webSocket
|
|
305
|
+
status: "connected"
|
|
305
306
|
});
|
|
306
307
|
}).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay.
|
|
307
308
|
}, [
|
|
308
309
|
collectionUrl,
|
|
309
310
|
liveUpdates,
|
|
310
|
-
dataProvider
|
|
311
|
+
dataProvider,
|
|
312
|
+
webSocketRef
|
|
313
|
+
]);
|
|
314
|
+
const awaitWebSocketConnection = (0, $85cNH$useCallback)((options = {})=>{
|
|
315
|
+
const { timeout: timeout = 30000 } = options;
|
|
316
|
+
return new Promise((resolve, reject)=>{
|
|
317
|
+
if (webSocketRef?.current) resolve(webSocketRef);
|
|
318
|
+
else {
|
|
319
|
+
const timeoutId = setTimeout(()=>{
|
|
320
|
+
reject(`No WebSocket connection found within ${Math.round(timeout / 1000)}s`);
|
|
321
|
+
}, timeout);
|
|
322
|
+
const intervalId = setInterval(()=>{
|
|
323
|
+
if (webSocketRef?.current) {
|
|
324
|
+
clearInterval(intervalId);
|
|
325
|
+
clearTimeout(timeoutId);
|
|
326
|
+
resolve(webSocketRef);
|
|
327
|
+
} else console.log("WebSocket is not initialized yet, waiting...");
|
|
328
|
+
}, 100);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}, [
|
|
332
|
+
webSocketRef
|
|
311
333
|
]);
|
|
312
334
|
return {
|
|
313
335
|
items: items,
|
|
@@ -322,7 +344,9 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
|
|
|
322
344
|
isFetching: isFetchingPage || isFetchingItems,
|
|
323
345
|
isFetchingNextPage: isFetchingNextPage,
|
|
324
346
|
url: collectionUrl,
|
|
325
|
-
hasLiveUpdates: hasLiveUpdates
|
|
347
|
+
hasLiveUpdates: hasLiveUpdates,
|
|
348
|
+
awaitWebSocketConnection: awaitWebSocketConnection,
|
|
349
|
+
webSocketRef: webSocketRef
|
|
326
350
|
};
|
|
327
351
|
};
|
|
328
352
|
var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollection;
|
|
@@ -332,49 +356,60 @@ var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollecti
|
|
|
332
356
|
|
|
333
357
|
/**
|
|
334
358
|
* Hook used internally by useInbox and useOutbox. This is not exported.
|
|
335
|
-
* @param
|
|
359
|
+
* @param awaitWebSocketConnection Promise returning the WebSocket which allow to listen to the inbox or outbox
|
|
336
360
|
* @param existingActivities Partial list of activities already received in the inbox and outbox
|
|
337
|
-
*/ const $600ca419166a1ded$var$useAwaitActivity = (
|
|
361
|
+
*/ const $600ca419166a1ded$var$useAwaitActivity = (awaitWebSocketConnection, existingActivities)=>{
|
|
338
362
|
const dataProvider = (0, $85cNH$useDataProvider)();
|
|
339
|
-
// TODO Allow to pass an
|
|
363
|
+
// TODO Allow to pass an object, and automatically dereference it if required, like on the @semapps/activitypub matchActivity util
|
|
340
364
|
return (0, $85cNH$useCallback)((matchActivity, options = {})=>{
|
|
341
365
|
const { timeout: timeout = 30000, checkExistingActivities: checkExistingActivities = false } = options;
|
|
342
366
|
return new Promise((resolve, reject)=>{
|
|
343
|
-
|
|
367
|
+
awaitWebSocketConnection().then((webSocketRef)=>{
|
|
344
368
|
const onMessage = (event)=>{
|
|
345
369
|
const data = JSON.parse(event.data);
|
|
346
370
|
if (data.type === "Add") dataProvider.fetch(data.object).then(({ json: json })=>{
|
|
347
371
|
if (matchActivity(json)) {
|
|
348
|
-
|
|
372
|
+
removeListeners();
|
|
349
373
|
return resolve(json);
|
|
350
374
|
}
|
|
351
375
|
});
|
|
352
376
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
377
|
+
const onError = (e)=>{
|
|
378
|
+
// TODO reconnect if connection closed
|
|
379
|
+
removeListeners();
|
|
356
380
|
reject(e);
|
|
357
|
-
}
|
|
358
|
-
|
|
381
|
+
};
|
|
382
|
+
const onClose = (e)=>{
|
|
383
|
+
removeListeners();
|
|
359
384
|
reject(new Error(`${e.reason} (Code: ${e.code})`));
|
|
360
|
-
}
|
|
385
|
+
};
|
|
386
|
+
const removeListeners = ()=>{
|
|
387
|
+
webSocketRef.current?.removeEventListener("message", onMessage);
|
|
388
|
+
webSocketRef.current?.removeEventListener("error", onError);
|
|
389
|
+
webSocketRef.current?.removeEventListener("close", onClose);
|
|
390
|
+
};
|
|
391
|
+
webSocketRef.current?.addEventListener("message", onMessage);
|
|
392
|
+
webSocketRef.current?.addEventListener("error", onError);
|
|
393
|
+
webSocketRef.current?.addEventListener("close", onClose);
|
|
361
394
|
// If a list of activities is already loaded, verify if there is a match
|
|
362
395
|
if (existingActivities && checkExistingActivities) for (const a of existingActivities){
|
|
363
396
|
if (typeof a !== "string") {
|
|
364
397
|
if (matchActivity(a)) {
|
|
365
|
-
|
|
398
|
+
removeListeners();
|
|
366
399
|
return resolve(a);
|
|
367
400
|
}
|
|
368
401
|
}
|
|
369
402
|
}
|
|
370
403
|
setTimeout(()=>{
|
|
371
|
-
|
|
404
|
+
removeListeners();
|
|
372
405
|
reject(new Error("Timeout"));
|
|
373
406
|
}, timeout);
|
|
374
|
-
}
|
|
407
|
+
}).catch((e)=>{
|
|
408
|
+
reject(e);
|
|
409
|
+
});
|
|
375
410
|
});
|
|
376
411
|
}, [
|
|
377
|
-
|
|
412
|
+
awaitWebSocketConnection,
|
|
378
413
|
existingActivities,
|
|
379
414
|
dataProvider
|
|
380
415
|
]);
|
|
@@ -393,8 +428,8 @@ var $600ca419166a1ded$export$2e2bcd8739ae039 = $600ca419166a1ded$var$useAwaitAct
|
|
|
393
428
|
*/ const $4d1d40fdbcd30589$var$useOutbox = (options = {})=>{
|
|
394
429
|
const dataProvider = (0, $85cNH$useDataProvider)();
|
|
395
430
|
const { data: identity } = (0, $85cNH$useGetIdentity)();
|
|
396
|
-
const { url: url,
|
|
397
|
-
const awaitActivity = (0, $600ca419166a1ded$export$2e2bcd8739ae039)(
|
|
431
|
+
const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)("outbox", options);
|
|
432
|
+
const awaitActivity = (0, $600ca419166a1ded$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
|
|
398
433
|
// Post an activity to the logged user's outbox and return its URI
|
|
399
434
|
const post = (0, $85cNH$useCallback)(async (activity)=>{
|
|
400
435
|
if (!url) throw new Error("Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox");
|
|
@@ -412,8 +447,8 @@ var $600ca419166a1ded$export$2e2bcd8739ae039 = $600ca419166a1ded$var$useAwaitAct
|
|
|
412
447
|
]);
|
|
413
448
|
return {
|
|
414
449
|
url: url,
|
|
415
|
-
hasLiveUpdates: hasLiveUpdates,
|
|
416
450
|
items: items,
|
|
451
|
+
awaitWebSocketConnection: awaitWebSocketConnection,
|
|
417
452
|
post: post,
|
|
418
453
|
awaitActivity: awaitActivity,
|
|
419
454
|
owner: identity?.id,
|
|
@@ -875,12 +910,12 @@ var $ea214512ab1a2e8f$export$2e2bcd8739ae039 = $ea214512ab1a2e8f$var$ReferenceCo
|
|
|
875
910
|
* @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`
|
|
876
911
|
*/ const $cc1d1cd0e97c63a2$var$useInbox = (options = {})=>{
|
|
877
912
|
const { data: identity } = (0, $85cNH$useGetIdentity)();
|
|
878
|
-
const {
|
|
879
|
-
const awaitActivity = (0, $600ca419166a1ded$export$2e2bcd8739ae039)(
|
|
913
|
+
const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)("inbox", options);
|
|
914
|
+
const awaitActivity = (0, $600ca419166a1ded$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
|
|
880
915
|
return {
|
|
881
|
-
items: items,
|
|
882
916
|
url: url,
|
|
883
|
-
|
|
917
|
+
items: items,
|
|
918
|
+
awaitWebSocketConnection: awaitWebSocketConnection,
|
|
884
919
|
awaitActivity: awaitActivity,
|
|
885
920
|
owner: identity?.id,
|
|
886
921
|
...rest
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;AACR;AAEO,MAAM,4CAAc;IACzB,aAAa;IACb,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;A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SAAE,KAAK,EAAE;YACf,OAAO,kBAAkB,MAAM,CAAC,CAAC,SAAE,KAAK,EAAE,GAAK,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,WAAW,KAAK,KAAK,CAAC,GAAG;QAC/G;IAEJ,GAAG;QAAC;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.ts","packages/activitypub-components/src/hooks/useCollection.ts","packages/activitypub-components/src/utils.ts","packages/activitypub-components/src/hooks/useAwaitActivity.ts","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useInbox.ts","packages/activitypub-components/src/hooks/useNodeinfo.ts","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n <PostCommentForm\n context={context}\n helperText={helperText}\n userResource={userResource}\n placeholder={placeholder}\n mentions={mentions}\n addItem={addItem}\n removeItem={removeItem}\n />\n <CommentsList comments={comments} loading={loading} userResource={userResource} />\n </>\n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n <Form onSubmit={onSubmit} className={classes.form}>\n <Box className={classes.container} onClick={openAuthIfDisconnected}>\n <Avatar\n src={\n identity?.webIdData?.[userDataModel?.fieldsMapping?.image] ||\n identity?.profileData?.[userDataModel?.fieldsMapping?.image]\n }\n className={classes.avatar}\n />\n <RichTextInput\n source=\"comment\"\n label=\" \"\n toolbar={<EmptyToolbar />}\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n <Button\n type=\"submit\"\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n endIcon={<SendIcon />}\n className={classes.button}\n >\n Envoyer\n </Button>\n )}\n </Box>\n </Form>\n <AuthDialog\n open={openAuth}\n onClose={() => setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n </>\n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVEL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback } from 'react';\nimport { useDataProvider, useGetIdentity } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch and post to the outbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `post`: a function to post a new activity in the user's outbox\n * - `awaitActivity`: a function to wait for a certain activity to be posted\n * - `owner`: the WebID of the outbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useoutbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useOutbox = (options: UseCollectionOptions = {}) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const { data: identity } = useGetIdentity();\n const { url, hasLiveUpdates, items, ...rest } = useCollection('outbox', options);\n const awaitActivity = useAwaitActivity(hasLiveUpdates.webSocket, items);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async (activity: object) => {\n if (!url) {\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox'\n );\n }\n const { headers } = await dataProvider.fetch(url, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n })\n });\n return headers.get('Location');\n },\n [url, dataProvider]\n );\n\n return { url, hasLiveUpdates, items, post, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useOutbox;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query';\nimport { getOrCreateWsChannel, SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\nimport type { UseCollectionOptions, SolidNotification } from '../types';\n\nconst useItemsFromPages = (pages: any[], dereferenceItems: boolean) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]);\n\n // We will force dereference, if some items are not URI string references.\n const shouldDereference = useMemo(() => {\n return dereferenceItems || items.some(item => typeof item !== 'string');\n }, [dereferenceItems, items]);\n\n // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).\n const itemQueries = useQueries(\n !shouldDereference\n ? []\n : items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n if (!shouldDereference) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 ? errors : undefined\n };\n};\n\n/**\n * Subscribe a collection. Supports pagination.\n * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId).\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState<number>();\n const queryClient = useQueryClient();\n const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any; webSocket?: WebSocket }>({\n status: 'connecting'\n });\n const dataProvider = useDataProvider<SemanticDataProvider>();\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection: QueryFunction = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data: pageData,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: (lastPage: any) => lastPage.next,\n getPreviousPageParam: (firstPage: any) => firstPage.prev\n });\n\n // Put all items together in a list (and dereference, if required).\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n const addItem = useCallback(\n (item: string | any, shouldRefetch: boolean | number = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems + 1);\n\n // Destructure, so react knows, it needs to re-render the pages.\n const pages = [...oldData.pages];\n const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || [];\n firstPageItems.unshift(item);\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n (item: string | any, shouldRefetch: boolean = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems - 1);\n\n // Destructure, so react knows, it needs to re-render the pages array.\n const pages = [...oldData.pages];\n // Find the item in all pages and remove the item to be removed (either item.id or just item)\n pages.forEach(page => {\n if (page.orderedItems) {\n page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item));\n } else if (page.items) {\n page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item));\n }\n });\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(webSocket => {\n webSocket.addEventListener('message', e => {\n const data: SolidNotification = JSON.parse(e.data);\n if (data.type === 'Add') {\n addItem(data.object, true);\n } else if (data.type === 'Remove') {\n removeItem(data.object, true);\n }\n });\n webSocket.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocket.addEventListener('close', e => {\n if (!hasLiveUpdates.error) {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' });\n }\n });\n setHasLiveUpdates({ status: 'connected', webSocket });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider]);\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n addItem,\n removeItem,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates\n };\n};\n\nexport default useCollection;\n","export const arrayOf = <T>(value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n\nexport const filterDuplicates = <T>(iterable: T[], predicate: (item: T) => string) => {\n const seen = new Set<string>();\n return iterable.filter(item => {\n const key = predicate(item);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n};\n","import { useCallback } from 'react';\nimport { useDataProvider } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { SolidNotification, AwaitActivityOptions } from '../types';\n\n/**\n * Hook used internally by useInbox and useOutbox. This is not exported.\n * @param webSocket WebSocket which allow to listen to the inbox or outbox\n * @param existingActivities Partial list of activities already received in the inbox and outbox\n */\nconst useAwaitActivity = (webSocket?: WebSocket, existingActivities?: Array<object | string>) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n\n // TODO Allow to pass an object, and automatically dereference it if required, like on the @semapps/activitypub matchActivity util\n return useCallback(\n (matchActivity: (activity: object) => boolean, options: AwaitActivityOptions = {}) => {\n const { timeout = 30000, checkExistingActivities = false } = options;\n return new Promise((resolve, reject) => {\n if (webSocket) {\n const onMessage = (event: MessageEvent<string>) => {\n const data: SolidNotification = JSON.parse(event.data);\n if (data.type === 'Add') {\n dataProvider.fetch(data.object).then(({ json }) => {\n if (matchActivity(json)) {\n webSocket.removeEventListener('message', onMessage);\n return resolve(json);\n }\n });\n }\n };\n\n webSocket.addEventListener('message', onMessage);\n\n // TODO reconnect if connection closed\n webSocket.addEventListener('error', e => {\n reject(e);\n });\n webSocket.addEventListener('close', e => {\n reject(new Error(`${e.reason} (Code: ${e.code})`));\n });\n\n // If a list of activities is already loaded, verify if there is a match\n if (existingActivities && checkExistingActivities) {\n for (const a of existingActivities) {\n if (typeof a !== 'string') {\n if (matchActivity(a)) {\n webSocket.removeEventListener('message', onMessage);\n return resolve(a);\n }\n }\n }\n }\n\n setTimeout(() => {\n webSocket.removeEventListener('message', onMessage);\n reject(new Error('Timeout'));\n }, timeout);\n } else {\n throw new Error('WebSocket is not initialized !');\n }\n });\n },\n [webSocket, existingActivities, dataProvider]\n );\n};\n\nexport default useAwaitActivity;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n <Box position=\"relative\">\n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n <Box className={classes.container} key={comment.id}>\n <Box className={classes.avatar}>\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <AvatarWithLabelField image={userDataModel?.fieldsMapping?.image} />\n </ReferenceField>\n </Box>\n <Box className={classes.text}>\n <Typography variant=\"body2\">\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <TextField variant=\"body2\" source={userDataModel?.fieldsMapping?.title} className={classes.label} />\n </ReferenceField>\n • \n <DateField record={comment} variant=\"body2\" source=\"published\" showTime />\n </Typography>\n <RichTextField record={comment} variant=\"body1\" source=\"content\" className={classes.content} />\n </Box>\n </Box>\n ))}\n {loading && (\n <Box minHeight={200}>\n <Box alignItems=\"center\" className={classes.loading}>\n <CircularProgress size={60} thickness={6} />\n </Box>\n </Box>\n )}\n </Box>\n );\n};\n\nexport default CommentsList;\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error('<CollectionList> only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return <ListContextProvider value={listContext}>{children}</ListContextProvider>;\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error('<ReferenceCollectionField> only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n <CollectionList resource={reference} collectionUrl={record[source]} {...rest}>\n {children}\n </CollectionList>\n );\n};\n\nexport default ReferenceCollectionField;\n","import { useGetIdentity } from 'react-admin';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch the inbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `awaitActivity`: a function to wait for a certain activity to be received\n * - `owner`: the WebID of the inbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useinbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useInbox = (options: UseCollectionOptions = {}) => {\n const { data: identity } = useGetIdentity();\n const { items, url, hasLiveUpdates, ...rest } = useCollection('inbox', options);\n const awaitActivity = useAwaitActivity(hasLiveUpdates.webSocket);\n return { items, url, hasLiveUpdates, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\nimport type { NodeInfo, NodeInfoLinks } from '../types';\n\nconst useNodeinfo = (host : string, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState<NodeInfo>();\n\n useEffect(() => {\n (async () => {\n if (host && rel) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n \n try {\n const { json: links } : { json: NodeInfoLinks } = await fetchUtils.fetchJson(nodeinfoUrl);\n \n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n \n if (link) {\n const { json } : { json: NodeInfo } = await fetchUtils.fetchJson(link.href);\n \n setSchema(json);\n }\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n <div className={classes.items}>\n {props.items.length ? (\n props.items.map((item, index) => (\n <button\n className={classes.item + (index === selectedIndex ? ' selected' : '')}\n key={index}\n onClick={() => selectItem(index)}\n >\n {item.label}\n </button>\n ))\n ) : (\n <div className={classes.item}>Aucun résultat</div>\n )}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"index.es.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT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;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.ts","packages/activitypub-components/src/hooks/useCollection.ts","packages/activitypub-components/src/utils.ts","packages/activitypub-components/src/hooks/useAwaitActivity.ts","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useInbox.ts","packages/activitypub-components/src/hooks/useNodeinfo.ts","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n <PostCommentForm\n context={context}\n helperText={helperText}\n userResource={userResource}\n placeholder={placeholder}\n mentions={mentions}\n addItem={addItem}\n removeItem={removeItem}\n />\n <CommentsList comments={comments} loading={loading} userResource={userResource} />\n </>\n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n <Form onSubmit={onSubmit} className={classes.form}>\n <Box className={classes.container} onClick={openAuthIfDisconnected}>\n <Avatar\n src={\n identity?.webIdData?.[userDataModel?.fieldsMapping?.image] ||\n identity?.profileData?.[userDataModel?.fieldsMapping?.image]\n }\n className={classes.avatar}\n />\n <RichTextInput\n source=\"comment\"\n label=\" \"\n toolbar={<EmptyToolbar />}\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n <Button\n type=\"submit\"\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n endIcon={<SendIcon />}\n className={classes.button}\n >\n Envoyer\n </Button>\n )}\n </Box>\n </Form>\n <AuthDialog\n open={openAuth}\n onClose={() => setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n </>\n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVEL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback } from 'react';\nimport { useDataProvider, useGetIdentity } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch and post to the outbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `post`: a function to post a new activity in the user's outbox\n * - `awaitActivity`: a function to wait for a certain activity to be posted\n * - `owner`: the WebID of the outbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useoutbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useOutbox = (options: UseCollectionOptions = {}) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const { data: identity } = useGetIdentity();\n const { url, items, awaitWebSocketConnection, ...rest } = useCollection('outbox', options);\n const awaitActivity = useAwaitActivity(awaitWebSocketConnection, items);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async (activity: object) => {\n if (!url) {\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox'\n );\n }\n const { headers } = await dataProvider.fetch(url, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n })\n });\n return headers.get('Location');\n },\n [url, dataProvider]\n );\n\n return { url, items, awaitWebSocketConnection, post, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useOutbox;\n","import { useCallback, useMemo, useState, useEffect, useRef, RefObject } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query';\nimport { getOrCreateWsChannel, SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\nimport type { UseCollectionOptions, SolidNotification, AwaitActivityOptions } from '../types';\n\nconst useItemsFromPages = (pages: any[], dereferenceItems: boolean) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]);\n\n // We will force dereference, if some items are not URI string references.\n const shouldDereference = useMemo(() => {\n return dereferenceItems || items.some(item => typeof item !== 'string');\n }, [dereferenceItems, items]);\n\n // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).\n const itemQueries = useQueries(\n !shouldDereference\n ? []\n : items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n if (!shouldDereference) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 ? errors : undefined\n };\n};\n\n/**\n * Subscribe a collection. Supports pagination.\n * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId).\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState<number>();\n const queryClient = useQueryClient();\n const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any }>({\n status: 'connecting'\n });\n const dataProvider = useDataProvider<SemanticDataProvider>();\n const webSocketRef = useRef<WebSocket | null>(null);\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection: QueryFunction = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data: pageData,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: (lastPage: any) => lastPage.next,\n getPreviousPageParam: (firstPage: any) => firstPage.prev\n });\n\n // Put all items together in a list (and dereference, if required).\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n const addItem = useCallback(\n (item: string | any, shouldRefetch: boolean | number = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems + 1);\n\n // Destructure, so react knows, it needs to re-render the pages.\n const pages = [...oldData.pages];\n const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || [];\n firstPageItems.unshift(item);\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n (item: string | any, shouldRefetch: boolean = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems - 1);\n\n // Destructure, so react knows, it needs to re-render the pages array.\n const pages = [...oldData.pages];\n // Find the item in all pages and remove the item to be removed (either item.id or just item)\n pages.forEach(page => {\n if (page.orderedItems) {\n page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item));\n } else if (page.items) {\n page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item));\n }\n });\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(ws => {\n webSocketRef.current = ws; // Keep a ref to the webSocket so that it can be used elsewhere\n webSocketRef.current.addEventListener('message', e => {\n const data: SolidNotification = JSON.parse(e.data);\n if (data.type === 'Add') {\n addItem(data.object, true);\n } else if (data.type === 'Remove') {\n removeItem(data.object, true);\n }\n });\n webSocketRef.current.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocketRef.current.addEventListener('close', e => {\n if (!hasLiveUpdates.error) {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' });\n }\n });\n setHasLiveUpdates({ status: 'connected' });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider, webSocketRef]);\n\n const awaitWebSocketConnection = useCallback(\n (options: AwaitActivityOptions = {}): Promise<RefObject<WebSocket>> => {\n const { timeout = 30000 } = options;\n return new Promise((resolve, reject) => {\n if (webSocketRef?.current) {\n resolve(webSocketRef);\n } else {\n const timeoutId = setTimeout(() => {\n reject(`No WebSocket connection found within ${Math.round(timeout / 1000)}s`);\n }, timeout);\n const intervalId = setInterval(() => {\n if (webSocketRef?.current) {\n clearInterval(intervalId);\n clearTimeout(timeoutId);\n resolve(webSocketRef);\n } else {\n console.log('WebSocket is not initialized yet, waiting...');\n }\n }, 100);\n }\n });\n },\n [webSocketRef]\n );\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n addItem,\n removeItem,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates,\n awaitWebSocketConnection,\n webSocketRef\n };\n};\n\nexport default useCollection;\n","export const arrayOf = <T>(value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n\nexport const filterDuplicates = <T>(iterable: T[], predicate: (item: T) => string) => {\n const seen = new Set<string>();\n return iterable.filter(item => {\n const key = predicate(item);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n};\n","import { RefObject, useCallback } from 'react';\nimport { useDataProvider } from 'react-admin';\nimport { SemanticDataProvider } from '@semapps/semantic-data-provider';\nimport { SolidNotification, AwaitActivityOptions, AwaitWebSocketConnectionOptions } from '../types';\n\n/**\n * Hook used internally by useInbox and useOutbox. This is not exported.\n * @param awaitWebSocketConnection Promise returning the WebSocket which allow to listen to the inbox or outbox\n * @param existingActivities Partial list of activities already received in the inbox and outbox\n */\nconst useAwaitActivity = (\n awaitWebSocketConnection: (options?: AwaitWebSocketConnectionOptions) => Promise<RefObject<WebSocket>>,\n existingActivities?: Array<object | string>\n) => {\n const dataProvider = useDataProvider<SemanticDataProvider>();\n\n // TODO Allow to pass an object, and automatically dereference it if required, like on the @semapps/activitypub matchActivity util\n return useCallback(\n (matchActivity: (activity: object) => boolean, options: AwaitActivityOptions = {}) => {\n const { timeout = 30000, checkExistingActivities = false } = options;\n return new Promise((resolve, reject) => {\n awaitWebSocketConnection()\n .then(webSocketRef => {\n const onMessage = (event: MessageEvent<string>) => {\n const data: SolidNotification = JSON.parse(event.data);\n if (data.type === 'Add') {\n dataProvider.fetch(data.object).then(({ json }) => {\n if (matchActivity(json)) {\n removeListeners();\n return resolve(json);\n }\n });\n }\n };\n const onError = (e: Event) => {\n // TODO reconnect if connection closed\n removeListeners();\n reject(e);\n };\n const onClose = (e: CloseEvent) => {\n removeListeners();\n reject(new Error(`${e.reason} (Code: ${e.code})`));\n };\n\n const removeListeners = () => {\n webSocketRef.current?.removeEventListener('message', onMessage);\n webSocketRef.current?.removeEventListener('error', onError);\n webSocketRef.current?.removeEventListener('close', onClose);\n };\n\n webSocketRef.current?.addEventListener('message', onMessage);\n webSocketRef.current?.addEventListener('error', onError);\n webSocketRef.current?.addEventListener('close', onClose);\n\n // If a list of activities is already loaded, verify if there is a match\n if (existingActivities && checkExistingActivities) {\n for (const a of existingActivities) {\n if (typeof a !== 'string') {\n if (matchActivity(a)) {\n removeListeners();\n return resolve(a);\n }\n }\n }\n }\n\n setTimeout(() => {\n removeListeners();\n reject(new Error('Timeout'));\n }, timeout);\n })\n .catch(e => {\n reject(e);\n });\n });\n },\n [awaitWebSocketConnection, existingActivities, dataProvider]\n );\n};\n\nexport default useAwaitActivity;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n <Box position=\"relative\">\n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n <Box className={classes.container} key={comment.id}>\n <Box className={classes.avatar}>\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <AvatarWithLabelField image={userDataModel?.fieldsMapping?.image} />\n </ReferenceField>\n </Box>\n <Box className={classes.text}>\n <Typography variant=\"body2\">\n <ReferenceField record={comment} reference={userResource} source=\"attributedTo\" linkType=\"show\">\n <TextField variant=\"body2\" source={userDataModel?.fieldsMapping?.title} className={classes.label} />\n </ReferenceField>\n • \n <DateField record={comment} variant=\"body2\" source=\"published\" showTime />\n </Typography>\n <RichTextField record={comment} variant=\"body1\" source=\"content\" className={classes.content} />\n </Box>\n </Box>\n ))}\n {loading && (\n <Box minHeight={200}>\n <Box alignItems=\"center\" className={classes.loading}>\n <CircularProgress size={60} thickness={6} />\n </Box>\n </Box>\n )}\n </Box>\n );\n};\n\nexport default CommentsList;\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error('<CollectionList> only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return <ListContextProvider value={listContext}>{children}</ListContextProvider>;\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error('<ReferenceCollectionField> only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n <CollectionList resource={reference} collectionUrl={record[source]} {...rest}>\n {children}\n </CollectionList>\n );\n};\n\nexport default ReferenceCollectionField;\n","import { useGetIdentity } from 'react-admin';\nimport useCollection from './useCollection';\nimport useAwaitActivity from './useAwaitActivity';\nimport type { UseCollectionOptions } from '../types';\n\n/**\n * Hook to fetch the inbox of the logged user.\n * Returns the same data as the useCollection hooks, plus:\n * - `awaitActivity`: a function to wait for a certain activity to be received\n * - `owner`: the WebID of the inbox's owner\n * See https://semapps.org/docs/frontend/activitypub-components#useinbox for usage\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useInbox = (options: UseCollectionOptions = {}) => {\n const { data: identity } = useGetIdentity();\n const { url, items, awaitWebSocketConnection, ...rest } = useCollection('inbox', options);\n const awaitActivity = useAwaitActivity(awaitWebSocketConnection, items);\n return { url, items, awaitWebSocketConnection, awaitActivity, owner: identity?.id, ...rest };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\nimport type { NodeInfo, NodeInfoLinks } from '../types';\n\nconst useNodeinfo = (host: string, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState<NodeInfo>();\n\n useEffect(() => {\n (async () => {\n if (host && rel) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n\n try {\n const { json: links }: { json: NodeInfoLinks } = await fetchUtils.fetchJson(nodeinfoUrl);\n\n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n\n if (link) {\n const { json }: { json: NodeInfo } = await fetchUtils.fetchJson(link.href);\n\n setSchema(json);\n }\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n <div className={classes.items}>\n {props.items.length ? (\n props.items.map((item, index) => (\n <button\n className={classes.item + (index === selectedIndex ? ' selected' : '')}\n key={index}\n onClick={() => selectItem(index)}\n >\n {item.label}\n </button>\n ))\n ) : (\n <div className={classes.item}>Aucun résultat</div>\n )}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"index.es.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semapps/activitypub-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React-Admin components for ActivityPub display",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Virtual Assembly",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "parcel build && yalc publish --push --changed",
|
|
16
|
-
"watch": "nodemon --watch src --exec 'yarn build'"
|
|
16
|
+
"watch": "nodemon --ext ts,tsx,js --watch src --exec 'yarn build'"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@semapps/auth-provider": "0.
|
|
20
|
-
"@semapps/field-components": "0.
|
|
21
|
-
"@semapps/semantic-data-provider": "0.
|
|
19
|
+
"@semapps/auth-provider": "0.8.0",
|
|
20
|
+
"@semapps/field-components": "0.8.0",
|
|
21
|
+
"@semapps/semantic-data-provider": "0.8.0",
|
|
22
22
|
"@tiptap/core": "^2.0.0-beta.95",
|
|
23
23
|
"@tiptap/extension-mention": "^2.0.0-beta.95",
|
|
24
24
|
"@tiptap/extension-placeholder": "^2.0.0-beta.95",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "631b3b60dea5b364c2b9db82026b883d1e3e15b2"
|
|
42
42
|
}
|