@soomo/react-text-annotator 3.0.0-staging.56 → 3.0.0-staging.58

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.
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es24.js","sources":["../../../node_modules/CETEIcean/src/behaviors.js"],"sourcesContent":["\n/* \n Add a user-defined set of behaviors to CETEIcean's processing\n workflow. Added behaviors will override predefined behaviors with the\n same name.\n*/\nexport function addBehaviors(bhvs) {\n if (bhvs.namespaces) {\n for (let prefix of Object.keys(bhvs.namespaces)) {\n if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {\n this.namespaces.set(bhvs.namespaces[prefix], prefix);\n }\n }\n }\n for (let prefix of this.namespaces.values()) {\n if (bhvs[prefix]) {\n for (let b of Object.keys(bhvs[prefix])) {\n this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];\n }\n }\n }\n if (bhvs[\"functions\"]) {\n for (let fn of Object.keys(bhvs[\"functions\"])) {\n this.utilities[fn] = bhvs[\"functions\"][fn].bind(this.utilities);\n }\n }\n if (bhvs[\"handlers\"]) {\n console.log(\"Behavior handlers are no longer used.\")\n }\n if (bhvs[\"fallbacks\"]) {\n console.log(\"Fallback behaviors are no longer used.\")\n }\n}\n\n/* \n Adds or replaces an individual behavior. Takes a namespace prefix or namespace definition,\n the element name, and the behavior. E.g.\n addBehavior(\"tei\", \"add\", [\"`\",\"`\"]) for an already-declared namespace or\n addBehavior({\"doc\": \"http://docbook.org/ns/docbook\"}, \"note\", [\"[\",\"]\"]) for a new one\n*/\nexport function addBehavior(ns, element, b) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n this.behaviors[`${p}:${element}`] = b;\n}\n\n/*\n Removes a previously-defined or default behavior. Takes a namespace prefix or namespace definition\n and the element name.\n*/\nexport function removeBehavior(ns, element) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n delete this.behaviors[`${p}:${element}`];\n}\n"],"names":[],"mappings":"AAMO,SAAS,aAAa,MAAM;AACjC,MAAI,KAAK,YAAY;AACnB,aAAS,UAAU,OAAO,KAAK,KAAK,UAAU,GAAG;AAC/C,UAAI,CAAC,KAAK,WAAW,IAAI,KAAK,WAAW,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,WAAW,OAAM,CAAE,EAAE,SAAS,MAAM,GAAG;AAC3G,aAAK,WAAW,IAAI,KAAK,WAAW,MAAM,GAAG,MAAM;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACD,WAAS,UAAU,KAAK,WAAW,OAAM,GAAI;AAC3C,QAAI,KAAK,MAAM,GAAG;AAChB,eAAS,KAAK,OAAO,KAAK,KAAK,MAAM,CAAC,GAAG;AACvC,aAAK,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACD,MAAI,KAAK,WAAW,GAAG;AACrB,aAAS,MAAM,OAAO,KAAK,KAAK,WAAW,CAAC,GAAG;AAC7C,WAAK,UAAU,EAAE,IAAI,KAAK,WAAW,EAAE,EAAE,EAAE,KAAK,KAAK,SAAS;AAAA,IAC/D;AAAA,EACF;AACD,MAAI,KAAK,UAAU,GAAG;AACpB,YAAQ,IAAI,uCAAuC;AAAA,EACpD;AACD,MAAI,KAAK,WAAW,GAAG;AACrB,YAAQ,IAAI,wCAAwC;AAAA,EACrD;AACH;AAQO,SAAS,YAAY,IAAI,SAAS,GAAG;AAC1C,MAAI;AACJ,MAAI,OAAO,OAAO,EAAE,GAAG;AACrB,aAAS,UAAU,OAAO,KAAK,EAAE,GAAG;AAClC,UAAI,CAAC,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACL;AAAA,IACF;AAAA,EACL,OAAS;AACL,QAAI;AAAA,EACL;AACD,OAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE,IAAI;AACtC;AAMO,SAAS,eAAe,IAAI,SAAS;AAC1C,MAAI;AACJ,MAAI,OAAO,OAAO,EAAE,GAAG;AACrB,aAAS,UAAU,OAAO,KAAK,EAAE,GAAG;AAClC,UAAI,CAAC,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACL;AAAA,IACF;AAAA,EACL,OAAS;AACL,QAAI;AAAA,EACL;AACD,SAAO,KAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE;AACzC;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"react-text-annotator.es24.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,23 +1,5 @@
1
- function learnElementNames(XML_dom, namespaces) {
2
- const root = XML_dom.documentElement;
3
- let i = 1;
4
- let qname = function(e) {
5
- if (!namespaces.has(e.namespaceURI ? e.namespaceURI : "")) {
6
- namespaces.set(e.namespaceURI, "ns" + i++);
7
- }
8
- return namespaces.get(e.namespaceURI ? e.namespaceURI : "") + ":" + e.localName;
9
- };
10
- const els = new Set(
11
- Array.from(root.querySelectorAll("*"), qname)
12
- );
13
- els.add(qname(root));
14
- return els;
15
- }
16
- function learnCustomElementNames(HTML_dom) {
17
- return new Set(Array.from(HTML_dom.querySelectorAll("*[data-origname]"), (e) => e.localName.replace(/(\w+)-.+/, "$1:") + e.getAttribute("data-origname")));
18
- }
1
+ var reactJsxRuntime_development = {};
19
2
  export {
20
- learnCustomElementNames,
21
- learnElementNames
3
+ reactJsxRuntime_development as __exports
22
4
  };
23
5
  //# sourceMappingURL=react-text-annotator.es25.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es25.js","sources":["../../../node_modules/CETEIcean/src/dom.js"],"sourcesContent":["export function learnElementNames(XML_dom, namespaces) {\n const root = XML_dom.documentElement;\n let i = 1;\n let qname = function(e) { \n if (!namespaces.has(e.namespaceURI ? e.namespaceURI : \"\")) {\n namespaces.set(e.namespaceURI, \"ns\" + i++);\n } \n return namespaces.get(e.namespaceURI ? e.namespaceURI : \"\") + \":\" + e.localName;\n };\n const els = new Set(\n Array.from(root.querySelectorAll(\"*\"), qname));\n \n // Add the root element to the array\n els.add(qname(root));\n return els\n}\n\nexport function learnCustomElementNames(HTML_dom) {\n return new Set(Array.from(HTML_dom.querySelectorAll(\"*[data-origname]\"), e => e.localName.replace(/(\\w+)-.+/,\"$1:\") + e.getAttribute(\"data-origname\")));\n}"],"names":[],"mappings":"AAAO,SAAS,kBAAkB,SAAS,YAAY;AACrD,QAAM,OAAO,QAAQ;AACrB,MAAI,IAAI;AACR,MAAI,QAAQ,SAAS,GAAG;AACtB,QAAI,CAAC,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG;AACzD,iBAAW,IAAI,EAAE,cAAc,OAAO,GAAG;AAAA,IAC1C;AACD,WAAO,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,MAAM,EAAE;AAAA,EAC1E;AACE,QAAM,MAAM,IAAI;AAAA,IACd,MAAM,KAAK,KAAK,iBAAiB,GAAG,GAAG,KAAK;AAAA,EAAC;AAG/C,MAAI,IAAI,MAAM,IAAI,CAAC;AACnB,SAAO;AACT;AAEO,SAAS,wBAAwB,UAAU;AAChD,SAAO,IAAI,IAAI,MAAM,KAAK,SAAS,iBAAiB,kBAAkB,GAAG,OAAK,EAAE,UAAU,QAAQ,YAAW,KAAK,IAAI,EAAE,aAAa,eAAe,CAAC,CAAC;AACxJ;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"react-text-annotator.es25.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useLayoutEffect, useMemo, useRef, useEffect } from "react";
2
2
  import { useAnnotationStore, useSelection, Origin } from "@annotorious/react";
3
- import { announce as $319e236875307eab$export$a9b970dcc4ae71a9, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f } from "./react-text-annotator.es10.js";
4
- import { exhaustiveUniqueRandom } from "./react-text-annotator.es11.js";
3
+ import { announce as $319e236875307eab$export$a9b970dcc4ae71a9, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f } from "./react-text-annotator.es11.js";
4
+ import { exhaustiveUniqueRandom } from "./react-text-annotator.es12.js";
5
5
  const useAnnouncePopupNavigation = (args) => {
6
6
  const {
7
7
  message = "Press Tab to move to Notes Dialog",
@@ -1,52 +1,52 @@
1
- const Dt = "not-annotatable", X = `.${Dt}`, mt = (t) => {
1
+ const kt = "not-annotatable", X = `.${kt}`, bt = (t) => {
2
2
  const e = t.cloneContents();
3
3
  return e.querySelectorAll(X).forEach((n) => n.remove()), e;
4
- }, re = (t, e, n = 10, o) => {
4
+ }, ee = (t, e, n = 10, o) => {
5
5
  const i = e, r = document.createRange();
6
6
  r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
7
- const s = mt(r).textContent, a = document.createRange();
7
+ const c = bt(r).textContent, a = document.createRange();
8
8
  a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
9
- const u = mt(a).textContent;
9
+ const d = bt(a).textContent;
10
10
  return {
11
- prefix: s.substring(s.length - n),
12
- suffix: u.substring(0, n)
11
+ prefix: c.substring(c.length - n),
12
+ suffix: d.substring(0, n)
13
13
  };
14
14
  };
15
15
  var U = [];
16
16
  for (var dt = 0; dt < 256; ++dt)
17
17
  U.push((dt + 256).toString(16).slice(1));
18
- function Oe(t, e = 0) {
18
+ function Me(t, e = 0) {
19
19
  return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
20
20
  }
21
- var Z, Ie = new Uint8Array(16);
22
- function Ue() {
21
+ var Z, Oe = new Uint8Array(16);
22
+ function Ie() {
23
23
  if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
24
24
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
25
- return Z(Ie);
25
+ return Z(Oe);
26
26
  }
27
- var Ve = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
27
+ var Ne = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
28
28
  const Ot = {
29
- randomUUID: Ve
29
+ randomUUID: Ne
30
30
  };
31
31
  function Pt(t, e, n) {
32
32
  if (Ot.randomUUID && !e && !t)
33
33
  return Ot.randomUUID();
34
34
  t = t || {};
35
- var o = t.random || (t.rng || Ue)();
36
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Oe(o);
35
+ var o = t.random || (t.rng || Ie)();
36
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Me(o);
37
37
  }
38
38
  var V = [];
39
39
  for (var ht = 0; ht < 256; ++ht)
40
40
  V.push((ht + 256).toString(16).slice(1));
41
41
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
42
- const sn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
43
- let dn = (t = 21) => {
42
+ const on = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
43
+ let cn = (t = 21) => {
44
44
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
45
45
  for (; t--; )
46
- e += sn[n[t] & 63];
46
+ e += on[n[t] & 63];
47
47
  return e;
48
48
  };
49
- const hn = (t) => {
49
+ const dn = (t) => {
50
50
  const e = JSON.stringify(t);
51
51
  let n = 0;
52
52
  for (let o = 0, i = e.length; o < i; o++) {
@@ -54,108 +54,108 @@ const hn = (t) => {
54
54
  n = (n << 5) - n + r, n |= 0;
55
55
  }
56
56
  return `${n}`;
57
- }, jt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, fn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
58
- const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: h, ...g } = n;
57
+ }, Ft = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, un = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
58
+ const { id: o, type: i, purpose: r, value: c, created: a, modified: d, creator: u, ...g } = n;
59
59
  return {
60
- id: o || `temp-${hn(n)}`,
60
+ id: o || `temp-${dn(n)}`,
61
61
  annotation: e,
62
62
  type: i,
63
63
  purpose: r,
64
- value: s,
65
- creator: jt(h),
64
+ value: c,
65
+ creator: Ft(u),
66
66
  created: a ? new Date(a) : void 0,
67
- updated: u ? new Date(u) : void 0,
67
+ updated: d ? new Date(d) : void 0,
68
68
  ...g
69
69
  };
70
- }), gn = (t) => t.map((e) => {
70
+ }), hn = (t) => t.map((e) => {
71
71
  var n;
72
- const { annotation: o, created: i, updated: r, ...s } = e, a = {
73
- ...s,
72
+ const { annotation: o, created: i, updated: r, ...c } = e, a = {
73
+ ...c,
74
74
  created: i == null ? void 0 : i.toISOString(),
75
75
  modified: r == null ? void 0 : r.toISOString()
76
76
  };
77
77
  return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
78
78
  });
79
- dn();
80
- const kn = (t, e) => ({
81
- parse: (n) => bn(n),
82
- serialize: (n) => vn(n, t, e)
83
- }), pn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, mn = (t) => {
79
+ cn();
80
+ const In = (t, e) => ({
81
+ parse: (n) => pn(n),
82
+ serialize: (n) => mn(n, t, e)
83
+ }), fn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, gn = (t) => {
84
84
  const {
85
85
  id: e,
86
86
  creator: n,
87
87
  created: o,
88
88
  modified: i,
89
89
  target: r
90
- } = t, s = Array.isArray(r) ? r : [r], a = {
91
- creator: jt(n),
90
+ } = t, c = Array.isArray(r) ? r : [r], a = {
91
+ creator: Ft(n),
92
92
  created: o ? new Date(o) : void 0,
93
93
  updated: i ? new Date(i) : void 0,
94
94
  annotation: e,
95
95
  selector: []
96
96
  };
97
- for (const u of s) {
98
- const g = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((d, b) => {
99
- switch (b.type) {
97
+ for (const d of c) {
98
+ const g = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((h, v) => {
99
+ switch (v.type) {
100
100
  case "TextQuoteSelector":
101
- d.quote = b.exact;
101
+ h.quote = v.exact;
102
102
  break;
103
103
  case "TextPositionSelector":
104
- d.start = b.start, d.end = b.end;
104
+ h.start = v.start, h.end = v.end;
105
105
  break;
106
106
  }
107
- return d;
107
+ return h;
108
108
  }, {});
109
- if (pn(g))
110
- a.selector.push({ id: u.id, ...g });
109
+ if (fn(g))
110
+ a.selector.push({ id: d.id, ...g });
111
111
  else {
112
- const d = [
112
+ const h = [
113
113
  g.start ? void 0 : "TextPositionSelector",
114
114
  g.quote ? void 0 : "TextQuoteSelector"
115
115
  ].filter(Boolean);
116
- return { error: Error(`Missing selector types: ${d.join(" and ")} for annotation: ${t.id}`) };
116
+ return { error: Error(`Missing selector types: ${h.join(" and ")} for annotation: ${t.id}`) };
117
117
  }
118
118
  }
119
119
  return { parsed: a };
120
- }, bn = (t) => {
120
+ }, pn = (t) => {
121
121
  const e = t.id || Pt(), {
122
122
  creator: n,
123
123
  created: o,
124
124
  modified: i,
125
125
  body: r,
126
- ...s
127
- } = t, a = fn(r, e), u = mn(t);
128
- return "error" in u ? { error: u.error } : {
126
+ ...c
127
+ } = t, a = un(r, e), d = gn(t);
128
+ return "error" in d ? { error: d.error } : {
129
129
  parsed: {
130
- ...s,
130
+ ...c,
131
131
  id: e,
132
132
  bodies: a,
133
- target: u.parsed
133
+ target: d.parsed
134
134
  }
135
135
  };
136
- }, vn = (t, e, n) => {
136
+ }, mn = (t, e, n) => {
137
137
  const { bodies: o, target: i, ...r } = t, {
138
- selector: s,
138
+ selector: c,
139
139
  creator: a,
140
- created: u,
141
- updated: h,
140
+ created: d,
141
+ updated: u,
142
142
  ...g
143
- } = i, d = s.map((b) => {
144
- const { quote: f, start: A, end: v, range: p } = b, { prefix: l, suffix: c } = re(p, n), m = [{
143
+ } = i, h = c.map((v) => {
144
+ const { quote: f, start: S, end: y, range: b } = v, { prefix: l, suffix: s } = ee(b, n), p = [{
145
145
  type: "TextQuoteSelector",
146
146
  exact: f,
147
147
  prefix: l,
148
- suffix: c
148
+ suffix: s
149
149
  }, {
150
150
  type: "TextPositionSelector",
151
- start: A,
152
- end: v
151
+ start: S,
152
+ end: y
153
153
  }];
154
154
  return {
155
155
  ...g,
156
- id: b.id,
156
+ id: v.id,
157
157
  source: e,
158
- selector: m
158
+ selector: p
159
159
  };
160
160
  });
161
161
  return {
@@ -163,20 +163,20 @@ const kn = (t, e) => ({
163
163
  "@context": "http://www.w3.org/ns/anno.jsonld",
164
164
  id: t.id,
165
165
  type: "Annotation",
166
- body: gn(t.bodies),
166
+ body: hn(t.bodies),
167
167
  creator: a,
168
- created: u == null ? void 0 : u.toISOString(),
169
- modified: h == null ? void 0 : h.toISOString(),
170
- target: d
168
+ created: d == null ? void 0 : d.toISOString(),
169
+ modified: u == null ? void 0 : u.toISOString(),
170
+ target: h
171
171
  };
172
172
  };
173
173
  export {
174
- Dt as NOT_ANNOTATABLE_CLASS,
174
+ kt as NOT_ANNOTATABLE_CLASS,
175
175
  X as NOT_ANNOTATABLE_SELECTOR,
176
- kn as W3CTextFormat,
177
- re as getQuoteContext,
178
- mt as getRangeAnnotatableContents,
179
- bn as parseW3CTextAnnotation,
180
- vn as serializeW3CTextAnnotation
176
+ In as W3CTextFormat,
177
+ ee as getQuoteContext,
178
+ bt as getRangeAnnotatableContents,
179
+ pn as parseW3CTextAnnotation,
180
+ mn as serializeW3CTextAnnotation
181
181
  };
182
182
  //# sourceMappingURL=react-text-annotator.es7.js.map