@semapps/activitypub-components 0.6.0-alpha.2 → 0.6.0-alpha.4

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.es.js CHANGED
@@ -1,18 +1,18 @@
1
- import {jsxs as $2hSwr$jsxs, Fragment as $2hSwr$Fragment, jsx as $2hSwr$jsx} from "react/jsx-runtime";
2
- import $2hSwr$react, {useState as $2hSwr$useState, useCallback as $2hSwr$useCallback, useMemo as $2hSwr$useMemo, useEffect as $2hSwr$useEffect, forwardRef as $2hSwr$forwardRef, useImperativeHandle as $2hSwr$useImperativeHandle} from "react";
3
- import {useRecordContext as $2hSwr$useRecordContext, useGetIdentity as $2hSwr$useGetIdentity, useNotify as $2hSwr$useNotify, Form as $2hSwr$Form, fetchUtils as $2hSwr$fetchUtils, TextField as $2hSwr$TextField, DateField as $2hSwr$DateField, RichTextField as $2hSwr$RichTextField, useGetOne as $2hSwr$useGetOne, LinearProgress as $2hSwr$LinearProgress, useGetList as $2hSwr$useGetList} from "react-admin";
4
- import {RichTextInput as $2hSwr$RichTextInput, DefaultEditorOptions as $2hSwr$DefaultEditorOptions} from "ra-input-rich-text";
5
- import $2hSwr$tiptapextensionplaceholder from "@tiptap/extension-placeholder";
6
- import {Box as $2hSwr$Box, Avatar as $2hSwr$Avatar, Button as $2hSwr$Button, Typography as $2hSwr$Typography, CircularProgress as $2hSwr$CircularProgress} from "@mui/material";
7
- import $2hSwr$muistylesmakeStyles from "@mui/styles/makeStyles";
8
- import $2hSwr$muiiconsmaterialSend from "@mui/icons-material/Send";
9
- import {useDataModel as $2hSwr$useDataModel, buildBlankNodesQuery as $2hSwr$buildBlankNodesQuery} from "@semapps/semantic-data-provider";
10
- import {AuthDialog as $2hSwr$AuthDialog} from "@semapps/auth-provider";
11
- import {mergeAttributes as $2hSwr$mergeAttributes} from "@tiptap/core";
12
- import $2hSwr$tiptapextensionmention from "@tiptap/extension-mention";
13
- import {ReferenceField as $2hSwr$ReferenceField, AvatarWithLabelField as $2hSwr$AvatarWithLabelField, ReferenceArrayField as $2hSwr$ReferenceArrayField} from "@semapps/field-components";
14
- import {ReactRenderer as $2hSwr$ReactRenderer} from "@tiptap/react";
15
- import $2hSwr$tippyjs from "tippy.js";
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";
3
+ import {useRecordContext as $85cNH$useRecordContext, useGetIdentity as $85cNH$useGetIdentity, useNotify as $85cNH$useNotify, Form as $85cNH$Form, fetchUtils as $85cNH$fetchUtils, TextField as $85cNH$TextField, DateField as $85cNH$DateField, RichTextField as $85cNH$RichTextField, useGetOne as $85cNH$useGetOne, LinearProgress as $85cNH$LinearProgress, useGetList as $85cNH$useGetList} from "react-admin";
4
+ import {RichTextInput as $85cNH$RichTextInput, DefaultEditorOptions as $85cNH$DefaultEditorOptions} from "ra-input-rich-text";
5
+ import $85cNH$tiptapextensionplaceholder from "@tiptap/extension-placeholder";
6
+ import {Box as $85cNH$Box, Avatar as $85cNH$Avatar, Button as $85cNH$Button, Typography as $85cNH$Typography, CircularProgress as $85cNH$CircularProgress} from "@mui/material";
7
+ import $85cNH$muistylesmakeStyles from "@mui/styles/makeStyles";
8
+ import $85cNH$muiiconsmaterialSend from "@mui/icons-material/Send";
9
+ import {useDataModel as $85cNH$useDataModel, buildBlankNodesQuery as $85cNH$buildBlankNodesQuery} from "@semapps/semantic-data-provider";
10
+ import {AuthDialog as $85cNH$AuthDialog} from "@semapps/auth-provider";
11
+ import {mergeAttributes as $85cNH$mergeAttributes} from "@tiptap/core";
12
+ import $85cNH$tiptapextensionmention from "@tiptap/extension-mention";
13
+ import {ReferenceField as $85cNH$ReferenceField, AvatarWithLabelField as $85cNH$AvatarWithLabelField, ReferenceArrayField as $85cNH$ReferenceArrayField} from "@semapps/field-components";
14
+ import {ReactRenderer as $85cNH$ReactRenderer} from "@tiptap/react";
15
+ import $85cNH$tippyjs from "tippy.js";
16
16
 
17
17
  // Components
18
18
 
@@ -86,22 +86,22 @@ const $338f387df48a40d7$export$4d8d554031975581 = "https://www.w3.org/ns/activit
86
86
 
87
87
 
88
88
  const $712f7f004b5f345e$var$useOutbox = ()=>{
89
- const { identity: identity } = (0, $2hSwr$useGetIdentity)();
90
- const outboxUrl = (0, $2hSwr$useMemo)(()=>{
89
+ const { identity: identity } = (0, $85cNH$useGetIdentity)();
90
+ const outboxUrl = (0, $85cNH$useMemo)(()=>{
91
91
  if (identity?.webIdData) return identity?.webIdData?.outbox;
92
92
  }, [
93
93
  identity
94
94
  ]);
95
- const sparqlEndpoint = (0, $2hSwr$useMemo)(()=>{
95
+ const sparqlEndpoint = (0, $85cNH$useMemo)(()=>{
96
96
  if (identity?.webIdData) return identity?.webIdData?.endpoints?.["void:sparqlEndpoint"] || `${identity?.id}/sparql`;
97
97
  }, [
98
98
  identity
99
99
  ]);
100
100
  // Post an activity to the logged user's outbox and return its URI
101
- const post = (0, $2hSwr$useCallback)(async (activity)=>{
101
+ const post = (0, $85cNH$useCallback)(async (activity)=>{
102
102
  if (!outboxUrl) throw new Error("Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox");
103
103
  const token = localStorage.getItem("token");
104
- const { headers: headers } = await (0, $2hSwr$fetchUtils).fetchJson(outboxUrl, {
104
+ const { headers: headers } = await (0, $85cNH$fetchUtils).fetchJson(outboxUrl, {
105
105
  method: "POST",
106
106
  body: JSON.stringify({
107
107
  "@context": "https://www.w3.org/ns/activitystreams",
@@ -116,10 +116,10 @@ const $712f7f004b5f345e$var$useOutbox = ()=>{
116
116
  }, [
117
117
  outboxUrl
118
118
  ]);
119
- const fetch = (0, $2hSwr$useCallback)(async ()=>{
119
+ const fetch = (0, $85cNH$useCallback)(async ()=>{
120
120
  if (!sparqlEndpoint || !outboxUrl) return;
121
121
  const token = localStorage.getItem("token");
122
- const blankNodesQuery = (0, $2hSwr$buildBlankNodesQuery)([
122
+ const blankNodesQuery = (0, $85cNH$buildBlankNodesQuery)([
123
123
  "as:object"
124
124
  ]);
125
125
  const query = `
@@ -134,7 +134,7 @@ const $712f7f004b5f345e$var$useOutbox = ()=>{
134
134
  ${blankNodesQuery.where}
135
135
  }
136
136
  `;
137
- const { json: json } = await (0, $2hSwr$fetchUtils).fetchJson(sparqlEndpoint, {
137
+ const { json: json } = await (0, $85cNH$fetchUtils).fetchJson(sparqlEndpoint, {
138
138
  method: "POST",
139
139
  body: query,
140
140
  headers: new Headers({
@@ -164,11 +164,11 @@ var $712f7f004b5f345e$export$2e2bcd8739ae039 = $712f7f004b5f345e$var$useOutbox;
164
164
  // Fix a bug in the current version of the mention extension
165
165
  // (The { id, label } object is located inside the id property)
166
166
  // See https://github.com/ueberdosis/tiptap/pull/1322
167
- const $6080c8a288f71367$var$CustomMention = (0, $2hSwr$tiptapextensionmention).extend({
167
+ const $6080c8a288f71367$var$CustomMention = (0, $85cNH$tiptapextensionmention).extend({
168
168
  renderHTML ({ node: node, HTMLAttributes: HTMLAttributes }) {
169
169
  return [
170
170
  "span",
171
- (0, $2hSwr$mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
171
+ (0, $85cNH$mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
172
172
  `@${node.attrs.id.label}`
173
173
  ];
174
174
  },
@@ -208,7 +208,7 @@ const $6080c8a288f71367$var$CustomMention = (0, $2hSwr$tiptapextensionmention).e
208
208
  var $6080c8a288f71367$export$2e2bcd8739ae039 = $6080c8a288f71367$var$CustomMention;
209
209
 
210
210
 
211
- const $3c17312a40ebf1ed$var$useStyles = (0, $2hSwr$muistylesmakeStyles)((theme)=>({
211
+ const $3c17312a40ebf1ed$var$useStyles = (0, $85cNH$muistylesmakeStyles)((theme)=>({
212
212
  form: {
213
213
  marginTop: -12 // Negative margin to keep the form close to the label
214
214
  },
@@ -256,15 +256,15 @@ const $3c17312a40ebf1ed$var$useStyles = (0, $2hSwr$muistylesmakeStyles)((theme)=
256
256
  }));
257
257
  const $3c17312a40ebf1ed$var$EmptyToolbar = ()=>null;
258
258
  const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder: placeholder, helperText: helperText, mentions: mentions, userResource: userResource, addItem: addItem, removeItem: removeItem })=>{
259
- const record = (0, $2hSwr$useRecordContext)();
260
- const { identity: identity, isLoading: isLoading } = (0, $2hSwr$useGetIdentity)();
261
- const userDataModel = (0, $2hSwr$useDataModel)(userResource);
259
+ const record = (0, $85cNH$useRecordContext)();
260
+ const { identity: identity, isLoading: isLoading } = (0, $85cNH$useGetIdentity)();
261
+ const userDataModel = (0, $85cNH$useDataModel)(userResource);
262
262
  const classes = $3c17312a40ebf1ed$var$useStyles();
263
- const notify = (0, $2hSwr$useNotify)();
263
+ const notify = (0, $85cNH$useNotify)();
264
264
  const outbox = (0, $712f7f004b5f345e$export$2e2bcd8739ae039)();
265
- const [expanded, setExpanded] = (0, $2hSwr$useState)(false);
266
- const [openAuth, setOpenAuth] = (0, $2hSwr$useState)(false);
267
- const onSubmit = (0, $2hSwr$useCallback)(async (values)=>{
265
+ const [expanded, setExpanded] = (0, $85cNH$useState)(false);
266
+ const [openAuth, setOpenAuth] = (0, $85cNH$useState)(false);
267
+ const onSubmit = (0, $85cNH$useCallback)(async (values)=>{
268
268
  const document = new DOMParser().parseFromString(values.comment, "text/html");
269
269
  const mentions = Array.from(document.body.getElementsByClassName("mention"));
270
270
  const mentionedUsersUris = [];
@@ -321,7 +321,7 @@ const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder:
321
321
  addItem,
322
322
  removeItem
323
323
  ]);
324
- const openAuthIfDisconnected = (0, $2hSwr$useCallback)(()=>{
324
+ const openAuthIfDisconnected = (0, $85cNH$useCallback)(()=>{
325
325
  if (!identity?.id) setOpenAuth(true);
326
326
  }, [
327
327
  identity,
@@ -329,35 +329,35 @@ const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder:
329
329
  ]);
330
330
  // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once
331
331
  if (mentions && !mentions.items || isLoading) return null;
332
- return /*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Fragment), {
332
+ return /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Fragment), {
333
333
  children: [
334
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$Form), {
334
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$Form), {
335
335
  onSubmit: onSubmit,
336
336
  className: classes.form,
337
- children: /*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Box), {
337
+ children: /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Box), {
338
338
  className: classes.container,
339
339
  onClick: openAuthIfDisconnected,
340
340
  children: [
341
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$Avatar), {
341
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$Avatar), {
342
342
  src: identity?.webIdData?.[userDataModel?.fieldsMapping?.image] || identity?.profileData?.[userDataModel?.fieldsMapping?.image],
343
343
  className: classes.avatar
344
344
  }),
345
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$RichTextInput), {
345
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$RichTextInput), {
346
346
  source: "comment",
347
347
  label: " ",
348
- toolbar: /*#__PURE__*/ (0, $2hSwr$jsx)($3c17312a40ebf1ed$var$EmptyToolbar, {}),
348
+ toolbar: /*#__PURE__*/ (0, $85cNH$jsx)($3c17312a40ebf1ed$var$EmptyToolbar, {}),
349
349
  fullWidth: true,
350
350
  classes: {
351
351
  editorContent: classes.editorContent
352
352
  },
353
353
  editorOptions: {
354
- ...(0, $2hSwr$DefaultEditorOptions),
354
+ ...(0, $85cNH$DefaultEditorOptions),
355
355
  onFocus () {
356
356
  setExpanded(true);
357
357
  },
358
358
  extensions: [
359
- ...(0, $2hSwr$DefaultEditorOptions).extensions,
360
- placeholder ? (0, $2hSwr$tiptapextensionplaceholder).configure({
359
+ ...(0, $85cNH$DefaultEditorOptions).extensions,
360
+ placeholder ? (0, $85cNH$tiptapextensionplaceholder).configure({
361
361
  placeholder: placeholder
362
362
  }) : null,
363
363
  mentions ? (0, $6080c8a288f71367$export$2e2bcd8739ae039).configure({
@@ -372,19 +372,19 @@ const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder:
372
372
  },
373
373
  helperText: helperText
374
374
  }),
375
- expanded && /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$Button), {
375
+ expanded && /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$Button), {
376
376
  type: "submit",
377
377
  size: "small",
378
378
  variant: "contained",
379
379
  color: "primary",
380
- endIcon: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$muiiconsmaterialSend), {}),
380
+ endIcon: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$muiiconsmaterialSend), {}),
381
381
  className: classes.button,
382
382
  children: "Envoyer"
383
383
  })
384
384
  ]
385
385
  })
386
386
  }),
387
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$AuthDialog), {
387
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$AuthDialog), {
388
388
  open: openAuth,
389
389
  onClose: ()=>setOpenAuth(false),
390
390
  message: "Pour poster un commentaire, vous devez \xeatre connect\xe9."
@@ -402,7 +402,7 @@ var $3c17312a40ebf1ed$export$2e2bcd8739ae039 = $3c17312a40ebf1ed$var$PostComment
402
402
 
403
403
 
404
404
 
405
- const $be88b298220210d1$var$useStyles = (0, $2hSwr$muistylesmakeStyles)(()=>({
405
+ const $be88b298220210d1$var$useStyles = (0, $85cNH$muistylesmakeStyles)(()=>({
406
406
  container: {
407
407
  paddingLeft: 80,
408
408
  marginTop: 8,
@@ -448,44 +448,44 @@ const $be88b298220210d1$var$useStyles = (0, $2hSwr$muistylesmakeStyles)(()=>({
448
448
  }));
449
449
  const $be88b298220210d1$var$CommentsList = ({ comments: comments, userResource: userResource, loading: loading })=>{
450
450
  const classes = $be88b298220210d1$var$useStyles();
451
- const userDataModel = (0, $2hSwr$useDataModel)(userResource);
452
- return /*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Box), {
451
+ const userDataModel = (0, $85cNH$useDataModel)(userResource);
452
+ return /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Box), {
453
453
  position: "relative",
454
454
  children: [
455
- comments && comments.sort((a, b)=>new Date(b.published) - new Date(a.published)).map((comment)=>/*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Box), {
455
+ comments && comments.sort((a, b)=>new Date(b.published) - new Date(a.published)).map((comment)=>/*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Box), {
456
456
  className: classes.container,
457
457
  children: [
458
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$Box), {
458
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$Box), {
459
459
  className: classes.avatar,
460
- children: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$ReferenceField), {
460
+ children: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$ReferenceField), {
461
461
  record: comment,
462
462
  reference: userResource,
463
463
  source: "attributedTo",
464
464
  linkType: "show",
465
- children: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$AvatarWithLabelField), {
465
+ children: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$AvatarWithLabelField), {
466
466
  image: userDataModel?.fieldsMapping?.image
467
467
  })
468
468
  })
469
469
  }),
470
- /*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Box), {
470
+ /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Box), {
471
471
  className: classes.text,
472
472
  children: [
473
- /*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Typography), {
473
+ /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Typography), {
474
474
  variant: "body2",
475
475
  children: [
476
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$ReferenceField), {
476
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$ReferenceField), {
477
477
  record: comment,
478
478
  reference: userResource,
479
479
  source: "attributedTo",
480
480
  linkType: "show",
481
- children: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$TextField), {
481
+ children: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$TextField), {
482
482
  variant: "body2",
483
483
  source: userDataModel?.fieldsMapping?.title,
484
484
  className: classes.label
485
485
  })
486
486
  }),
487
- "\xa0•\xa0",
488
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$DateField), {
487
+ "\xa0\u2022\xa0",
488
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$DateField), {
489
489
  record: comment,
490
490
  variant: "body2",
491
491
  source: "published",
@@ -493,7 +493,7 @@ const $be88b298220210d1$var$CommentsList = ({ comments: comments, userResource:
493
493
  })
494
494
  ]
495
495
  }),
496
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$RichTextField), {
496
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$RichTextField), {
497
497
  record: comment,
498
498
  variant: "body1",
499
499
  source: "content",
@@ -503,12 +503,12 @@ const $be88b298220210d1$var$CommentsList = ({ comments: comments, userResource:
503
503
  })
504
504
  ]
505
505
  }, comment.id)),
506
- loading && /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$Box), {
506
+ loading && /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$Box), {
507
507
  minHeight: 200,
508
- children: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$Box), {
508
+ children: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$Box), {
509
509
  alignItems: "center",
510
510
  className: classes.loading,
511
- children: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$CircularProgress), {
511
+ children: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$CircularProgress), {
512
512
  size: 60,
513
513
  thickness: 6
514
514
  })
@@ -523,12 +523,12 @@ var $be88b298220210d1$export$2e2bcd8739ae039 = $be88b298220210d1$var$CommentsLis
523
523
 
524
524
 
525
525
  const $c1e897431d8c5742$var$useCollection = (predicateOrUrl)=>{
526
- const { identity: identity, isLoading: identityLoading } = (0, $2hSwr$useGetIdentity)();
527
- const [items, setItems] = (0, $2hSwr$useState)([]);
528
- const [loading, setLoading] = (0, $2hSwr$useState)(false);
529
- const [loaded, setLoaded] = (0, $2hSwr$useState)(false);
530
- const [error, setError] = (0, $2hSwr$useState)(false);
531
- const collectionUrl = (0, $2hSwr$useMemo)(()=>{
526
+ const { identity: identity, isLoading: identityLoading } = (0, $85cNH$useGetIdentity)();
527
+ const [items, setItems] = (0, $85cNH$useState)([]);
528
+ const [loading, setLoading] = (0, $85cNH$useState)(false);
529
+ const [loaded, setLoaded] = (0, $85cNH$useState)(false);
530
+ const [error, setError] = (0, $85cNH$useState)(false);
531
+ const collectionUrl = (0, $85cNH$useMemo)(()=>{
532
532
  if (predicateOrUrl) {
533
533
  if (predicateOrUrl.startsWith("http")) return predicateOrUrl;
534
534
  if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl];
@@ -537,7 +537,7 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl)=>{
537
537
  identity,
538
538
  predicateOrUrl
539
539
  ]);
540
- const fetch = (0, $2hSwr$useCallback)(async ()=>{
540
+ const fetch = (0, $85cNH$useCallback)(async ()=>{
541
541
  if (!collectionUrl) return;
542
542
  setLoading(true);
543
543
  const headers = new Headers({
@@ -548,7 +548,7 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl)=>{
548
548
  const collectionOrigin = new URL(collectionUrl).origin;
549
549
  const token = localStorage.getItem("token");
550
550
  if (identityOrigin === collectionOrigin && token) headers.set("Authorization", `Bearer ${token}`);
551
- (0, $2hSwr$fetchUtils).fetchJson(collectionUrl, {
551
+ (0, $85cNH$fetchUtils).fetchJson(collectionUrl, {
552
552
  headers: headers
553
553
  }).then(({ json: json })=>{
554
554
  if (json && json.items) setItems(json.items);
@@ -570,7 +570,7 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl)=>{
570
570
  collectionUrl,
571
571
  identity
572
572
  ]);
573
- (0, $2hSwr$useEffect)(()=>{
573
+ (0, $85cNH$useEffect)(()=>{
574
574
  if (!identityLoading && !loading && !loaded && !error) fetch();
575
575
  }, [
576
576
  fetch,
@@ -579,7 +579,7 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl)=>{
579
579
  loaded,
580
580
  error
581
581
  ]);
582
- const addItem = (0, $2hSwr$useCallback)((item)=>{
582
+ const addItem = (0, $85cNH$useCallback)((item)=>{
583
583
  setItems((oldItems)=>[
584
584
  ...oldItems,
585
585
  item
@@ -587,7 +587,7 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl)=>{
587
587
  }, [
588
588
  setItems
589
589
  ]);
590
- const removeItem = (0, $2hSwr$useCallback)((itemId)=>{
590
+ const removeItem = (0, $85cNH$useCallback)((itemId)=>{
591
591
  setItems((oldItems)=>oldItems.filter((item)=>typeof item === "string" ? item !== itemId : item.id !== itemId));
592
592
  }, [
593
593
  setItems
@@ -607,12 +607,12 @@ var $c1e897431d8c5742$export$2e2bcd8739ae039 = $c1e897431d8c5742$var$useCollecti
607
607
 
608
608
 
609
609
  const $7ce737d4a1c88e63$var$CommentsField = ({ source: source, context: context, helperText: helperText, placeholder: placeholder, userResource: userResource, mentions: mentions })=>{
610
- const record = (0, $2hSwr$useRecordContext)();
610
+ const record = (0, $85cNH$useRecordContext)();
611
611
  const { items: comments, loading: loading, addItem: addItem, removeItem: removeItem } = (0, $c1e897431d8c5742$export$2e2bcd8739ae039)(record.replies);
612
612
  if (!userResource) throw new Error("No userResource defined for CommentsField");
613
- return /*#__PURE__*/ (0, $2hSwr$jsxs)((0, $2hSwr$Fragment), {
613
+ return /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Fragment), {
614
614
  children: [
615
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $3c17312a40ebf1ed$export$2e2bcd8739ae039), {
615
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $3c17312a40ebf1ed$export$2e2bcd8739ae039), {
616
616
  context: context,
617
617
  helperText: helperText,
618
618
  userResource: userResource,
@@ -621,7 +621,7 @@ const $7ce737d4a1c88e63$var$CommentsField = ({ source: source, context: context,
621
621
  addItem: addItem,
622
622
  removeItem: removeItem
623
623
  }),
624
- /*#__PURE__*/ (0, $2hSwr$jsx)((0, $be88b298220210d1$export$2e2bcd8739ae039), {
624
+ /*#__PURE__*/ (0, $85cNH$jsx)((0, $be88b298220210d1$export$2e2bcd8739ae039), {
625
625
  comments: comments,
626
626
  loading: loading,
627
627
  userResource: userResource
@@ -643,19 +643,19 @@ var $7ce737d4a1c88e63$export$2e2bcd8739ae039 = $7ce737d4a1c88e63$var$CommentsFie
643
643
 
644
644
 
645
645
  const $d3be168cd1e7aaae$var$CollectionList = ({ collectionUrl: collectionUrl, resource: resource, children: children, ...rest })=>{
646
- if ((0, $2hSwr$react).Children.count(children) !== 1) throw new Error("<CollectionList> only accepts a single child");
646
+ if ((0, $85cNH$react).Children.count(children) !== 1) throw new Error("<CollectionList> only accepts a single child");
647
647
  // TODO use a simple fetch call, as the resource is not good and it is useless
648
- const { data: collection, isLoading: isLoading } = (0, $2hSwr$useGetOne)(resource, collectionUrl, {
648
+ const { data: collection, isLoading: isLoading } = (0, $85cNH$useGetOne)(resource, collectionUrl, {
649
649
  enabled: !!collectionUrl
650
650
  });
651
- if (isLoading) return /*#__PURE__*/ (0, $2hSwr$jsx)("div", {
651
+ if (isLoading) return /*#__PURE__*/ (0, $85cNH$jsx)("div", {
652
652
  style: {
653
653
  marginTop: 8
654
654
  },
655
- children: /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$LinearProgress), {})
655
+ children: /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$LinearProgress), {})
656
656
  });
657
657
  if (!collection) return null;
658
- return /*#__PURE__*/ (0, $2hSwr$jsx)((0, $2hSwr$ReferenceArrayField), {
658
+ return /*#__PURE__*/ (0, $85cNH$jsx)((0, $85cNH$ReferenceArrayField), {
659
659
  reference: resource,
660
660
  record: collection,
661
661
  source: "items",
@@ -670,9 +670,9 @@ var $d3be168cd1e7aaae$export$2e2bcd8739ae039 = $d3be168cd1e7aaae$var$CollectionL
670
670
 
671
671
 
672
672
  const $ea214512ab1a2e8f$var$ReferenceCollectionField = ({ source: source, record: record, reference: reference, children: children, ...rest })=>{
673
- if ((0, $2hSwr$react).Children.count(children) !== 1) throw new Error("<ReferenceCollectionField> only accepts a single child");
673
+ if ((0, $85cNH$react).Children.count(children) !== 1) throw new Error("<ReferenceCollectionField> only accepts a single child");
674
674
  if (!record || !record[source]) return null;
675
- return /*#__PURE__*/ (0, $2hSwr$jsx)((0, $d3be168cd1e7aaae$export$2e2bcd8739ae039), {
675
+ return /*#__PURE__*/ (0, $85cNH$jsx)((0, $d3be168cd1e7aaae$export$2e2bcd8739ae039), {
676
676
  resource: reference,
677
677
  collectionUrl: record[source],
678
678
  ...rest,
@@ -687,21 +687,21 @@ var $ea214512ab1a2e8f$export$2e2bcd8739ae039 = $ea214512ab1a2e8f$var$ReferenceCo
687
687
 
688
688
 
689
689
  const $542b37cc25b8ccca$var$useInbox = ()=>{
690
- const { identity: identity } = (0, $2hSwr$useGetIdentity)();
691
- const inboxUrl = (0, $2hSwr$useMemo)(()=>{
690
+ const { identity: identity } = (0, $85cNH$useGetIdentity)();
691
+ const inboxUrl = (0, $85cNH$useMemo)(()=>{
692
692
  if (identity?.webIdData) return identity?.webIdData?.inbox;
693
693
  }, [
694
694
  identity
695
695
  ]);
696
- const sparqlEndpoint = (0, $2hSwr$useMemo)(()=>{
696
+ const sparqlEndpoint = (0, $85cNH$useMemo)(()=>{
697
697
  if (identity?.webIdData) return identity?.webIdData?.endpoints?.["void:sparqlEndpoint"] || `${identity?.id}/sparql`;
698
698
  }, [
699
699
  identity
700
700
  ]);
701
- const fetch = (0, $2hSwr$useCallback)(async ({ filters: filters })=>{
701
+ const fetch = (0, $85cNH$useCallback)(async ({ filters: filters })=>{
702
702
  if (!sparqlEndpoint || !inboxUrl) return;
703
703
  const token = localStorage.getItem("token");
704
- const blankNodesQuery = (0, $2hSwr$buildBlankNodesQuery)([
704
+ const blankNodesQuery = (0, $85cNH$buildBlankNodesQuery)([
705
705
  "as:object"
706
706
  ]);
707
707
  let filtersWhereQuery = "";
@@ -725,7 +725,7 @@ const $542b37cc25b8ccca$var$useInbox = ()=>{
725
725
  ${blankNodesQuery.where}
726
726
  }
727
727
  `;
728
- const { json: json } = await (0, $2hSwr$fetchUtils).fetchJson(sparqlEndpoint, {
728
+ const { json: json } = await (0, $85cNH$fetchUtils).fetchJson(sparqlEndpoint, {
729
729
  method: "POST",
730
730
  body: query,
731
731
  headers: new Headers({
@@ -750,17 +750,45 @@ var $542b37cc25b8ccca$export$2e2bcd8739ae039 = $542b37cc25b8ccca$var$useInbox;
750
750
 
751
751
 
752
752
 
753
+ const $641e93142bcf5435$var$useNodeinfo = (host, rel = "http://nodeinfo.diaspora.software/ns/schema/2.1")=>{
754
+ const [schema, setSchema] = (0, $85cNH$useState)();
755
+ (0, $85cNH$useEffect)(()=>{
756
+ (async ()=>{
757
+ const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are likely on HTTP
758
+ const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;
759
+ try {
760
+ const { json: links } = await (0, $85cNH$fetchUtils).fetchJson(nodeinfoUrl);
761
+ // Accept any version of the nodeinfo protocol
762
+ const link = links?.links?.find((l)=>l.rel === rel);
763
+ const { json: json } = await (0, $85cNH$fetchUtils).fetchJson(link.href);
764
+ setSchema(json);
765
+ } catch (e) {
766
+ // Do nothing if nodeinfo can't be fetched
767
+ }
768
+ })();
769
+ }, [
770
+ host,
771
+ setSchema,
772
+ rel
773
+ ]);
774
+ return schema;
775
+ };
776
+ var $641e93142bcf5435$export$2e2bcd8739ae039 = $641e93142bcf5435$var$useNodeinfo;
777
+
778
+
779
+
780
+
753
781
 
754
782
  const $2514c63dc8f4867c$var$useWebfinger = ()=>{
755
783
  // Post an activity to the logged user's outbox and return its URI
756
- const fetch = (0, $2hSwr$useCallback)(async (id)=>{
784
+ const fetch = (0, $85cNH$useCallback)(async (id)=>{
757
785
  // eslint-disable-next-line
758
786
  const [_, username, host] = id.split("@");
759
787
  if (host) {
760
788
  const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are most likely on localhost
761
789
  const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;
762
790
  try {
763
- const { json: json } = await (0, $2hSwr$fetchUtils).fetchJson(webfingerUrl);
791
+ const { json: json } = await (0, $85cNH$fetchUtils).fetchJson(webfingerUrl);
764
792
  const link = json.links.find((l)=>l.type === "application/activity+json");
765
793
  return link ? link.href : null;
766
794
  } catch (e) {
@@ -783,7 +811,7 @@ var $2514c63dc8f4867c$export$2e2bcd8739ae039 = $2514c63dc8f4867c$var$useWebfinge
783
811
 
784
812
 
785
813
 
786
- const $cebd295d444aa91c$var$useStyles = (0, $2hSwr$muistylesmakeStyles)((theme)=>({
814
+ const $cebd295d444aa91c$var$useStyles = (0, $85cNH$muistylesmakeStyles)((theme)=>({
787
815
  items: {
788
816
  background: "#fff",
789
817
  borderRadius: "0.5rem",
@@ -808,8 +836,8 @@ const $cebd295d444aa91c$var$useStyles = (0, $2hSwr$muistylesmakeStyles)((theme)=
808
836
  }
809
837
  }
810
838
  }));
811
- var $cebd295d444aa91c$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $2hSwr$forwardRef)((props, ref)=>{
812
- const [selectedIndex, setSelectedIndex] = (0, $2hSwr$useState)(0);
839
+ var $cebd295d444aa91c$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $85cNH$forwardRef)((props, ref)=>{
840
+ const [selectedIndex, setSelectedIndex] = (0, $85cNH$useState)(0);
813
841
  const classes = $cebd295d444aa91c$var$useStyles();
814
842
  const selectItem = (index)=>{
815
843
  const item = props.items[index];
@@ -826,10 +854,10 @@ var $cebd295d444aa91c$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $2hSwr$forwardR
826
854
  const enterHandler = ()=>{
827
855
  selectItem(selectedIndex);
828
856
  };
829
- (0, $2hSwr$useEffect)(()=>setSelectedIndex(0), [
857
+ (0, $85cNH$useEffect)(()=>setSelectedIndex(0), [
830
858
  props.items
831
859
  ]);
832
- (0, $2hSwr$useImperativeHandle)(ref, ()=>({
860
+ (0, $85cNH$useImperativeHandle)(ref, ()=>({
833
861
  onKeyDown: ({ event: event })=>{
834
862
  if (event.key === "ArrowUp") {
835
863
  upHandler();
@@ -846,13 +874,13 @@ var $cebd295d444aa91c$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $2hSwr$forwardR
846
874
  return false;
847
875
  }
848
876
  }));
849
- return /*#__PURE__*/ (0, $2hSwr$jsx)("div", {
877
+ return /*#__PURE__*/ (0, $85cNH$jsx)("div", {
850
878
  className: classes.items,
851
- children: props.items.length ? props.items.map((item, index)=>/*#__PURE__*/ (0, $2hSwr$jsx)("button", {
879
+ children: props.items.length ? props.items.map((item, index)=>/*#__PURE__*/ (0, $85cNH$jsx)("button", {
852
880
  className: classes.item + (index === selectedIndex ? " selected" : ""),
853
881
  onClick: ()=>selectItem(index),
854
882
  children: item.label
855
- }, index)) : /*#__PURE__*/ (0, $2hSwr$jsx)("div", {
883
+ }, index)) : /*#__PURE__*/ (0, $85cNH$jsx)("div", {
856
884
  className: classes.item,
857
885
  children: "Aucun r\xe9sultat"
858
886
  })
@@ -865,11 +893,11 @@ const $a2389704c0801b9a$var$renderMentions = ()=>{
865
893
  let popup;
866
894
  return {
867
895
  onStart: (props)=>{
868
- component = new (0, $2hSwr$ReactRenderer)((0, $cebd295d444aa91c$export$2e2bcd8739ae039), {
896
+ component = new (0, $85cNH$ReactRenderer)((0, $cebd295d444aa91c$export$2e2bcd8739ae039), {
869
897
  props: props,
870
898
  editor: props.editor
871
899
  });
872
- popup = (0, $2hSwr$tippyjs)("body", {
900
+ popup = (0, $85cNH$tippyjs)("body", {
873
901
  getReferenceClientRect: props.clientRect,
874
902
  appendTo: ()=>document.body,
875
903
  content: component.element,
@@ -902,8 +930,8 @@ var $a2389704c0801b9a$export$2e2bcd8739ae039 = $a2389704c0801b9a$var$renderMenti
902
930
 
903
931
 
904
932
  const $51cccd331ea8b13d$var$useMentions = (userResource)=>{
905
- const userDataModel = (0, $2hSwr$useDataModel)(userResource);
906
- const { data: data } = (0, $2hSwr$useGetList)(userResource, {
933
+ const userDataModel = (0, $85cNH$useDataModel)(userResource);
934
+ const { data: data } = (0, $85cNH$useGetList)(userResource, {
907
935
  filter: {
908
936
  _predicates: [
909
937
  userDataModel?.fieldsMapping?.title
@@ -913,7 +941,7 @@ const $51cccd331ea8b13d$var$useMentions = (userResource)=>{
913
941
  }, {
914
942
  enabled: !!userDataModel?.fieldsMapping?.title
915
943
  });
916
- const availableMentions = (0, $2hSwr$useMemo)(()=>{
944
+ const availableMentions = (0, $85cNH$useMemo)(()=>{
917
945
  if (data) return data.map((item)=>({
918
946
  id: item.id,
919
947
  label: item[userDataModel?.fieldsMapping?.title]
@@ -921,7 +949,7 @@ const $51cccd331ea8b13d$var$useMentions = (userResource)=>{
921
949
  }, [
922
950
  data
923
951
  ]);
924
- const items = (0, $2hSwr$useMemo)(()=>{
952
+ const items = (0, $85cNH$useMemo)(()=>{
925
953
  if (availableMentions) return ({ query: query })=>{
926
954
  return availableMentions.filter(({ label: label })=>label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);
927
955
  };
@@ -939,5 +967,5 @@ var $51cccd331ea8b13d$export$2e2bcd8739ae039 = $51cccd331ea8b13d$var$useMentions
939
967
 
940
968
 
941
969
 
942
- export {$7ce737d4a1c88e63$export$2e2bcd8739ae039 as CommentsField, $d3be168cd1e7aaae$export$2e2bcd8739ae039 as CollectionList, $ea214512ab1a2e8f$export$2e2bcd8739ae039 as ReferenceCollectionField, $c1e897431d8c5742$export$2e2bcd8739ae039 as useCollection, $542b37cc25b8ccca$export$2e2bcd8739ae039 as useInbox, $712f7f004b5f345e$export$2e2bcd8739ae039 as useOutbox, $2514c63dc8f4867c$export$2e2bcd8739ae039 as useWebfinger, $51cccd331ea8b13d$export$2e2bcd8739ae039 as useMentions, $338f387df48a40d7$export$1ec8e53e7d982d22 as ACTIVITY_TYPES, $338f387df48a40d7$export$9649665d7ccb0dc2 as ACTOR_TYPES, $338f387df48a40d7$export$c49cfb2681596b20 as OBJECT_TYPES, $338f387df48a40d7$export$4d8d554031975581 as PUBLIC_URI};
970
+ export {$7ce737d4a1c88e63$export$2e2bcd8739ae039 as CommentsField, $d3be168cd1e7aaae$export$2e2bcd8739ae039 as CollectionList, $ea214512ab1a2e8f$export$2e2bcd8739ae039 as ReferenceCollectionField, $c1e897431d8c5742$export$2e2bcd8739ae039 as useCollection, $542b37cc25b8ccca$export$2e2bcd8739ae039 as useInbox, $641e93142bcf5435$export$2e2bcd8739ae039 as useNodeinfo, $712f7f004b5f345e$export$2e2bcd8739ae039 as useOutbox, $2514c63dc8f4867c$export$2e2bcd8739ae039 as useWebfinger, $51cccd331ea8b13d$export$2e2bcd8739ae039 as useMentions, $338f387df48a40d7$export$1ec8e53e7d982d22 as ACTIVITY_TYPES, $338f387df48a40d7$export$9649665d7ccb0dc2 as ACTOR_TYPES, $338f387df48a40d7$export$c49cfb2681596b20 as OBJECT_TYPES, $338f387df48a40d7$export$4d8d554031975581 as PUBLIC_URI};
943
971
  //# sourceMappingURL=index.es.js.map