@relyio/sdk 0.12.0 → 0.13.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/CHANGELOG.md +84 -0
- package/dist/{chunk-3DRDHXLY.js → chunk-3NPPMGB6.js} +435 -23
- package/dist/{chunk-FRJEUAAF.js → chunk-6NGJXLOR.js} +22 -11
- package/dist/{chunk-DXCVO6M5.cjs → chunk-DEDIJKHY.cjs} +22 -11
- package/dist/{chunk-POEEDYFM.js → chunk-EW23SZPX.js} +7 -2
- package/dist/{chunk-3MSFWXQL.cjs → chunk-FOSM4LMM.cjs} +7 -2
- package/dist/{chunk-FI5VIF4M.cjs → chunk-Z6GLWSSD.cjs} +442 -22
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +4 -5
- package/dist/client/index.d.ts +4 -5
- package/dist/client/index.js +1 -1
- package/dist/{define-schema-mrEZbY1h.d.ts → define-schema-UHViXKiv.d.ts} +2 -219
- package/dist/{define-schema-DgctHlI2.d.cts → define-schema-sWJ8Zn7C.d.cts} +2 -219
- package/dist/{include-paths-CL4gHv6I.d.cts → include-paths-Bs5FhNw2.d.cts} +2191 -108
- package/dist/{include-paths-CrJNTsMl.d.ts → include-paths-Cb7iPCW2.d.ts} +2191 -108
- package/dist/index--_u1nPHv.d.cts +507 -0
- package/dist/index-8DozAWsA.d.ts +507 -0
- package/dist/{index-BrvEg6-A.d.cts → index-BT0L8xJj.d.cts} +41 -53
- package/dist/{index-Pw0onkJe.d.ts → index-CPjJ25R4.d.ts} +41 -53
- package/dist/index.cjs +119 -112
- package/dist/index.d.cts +39 -70
- package/dist/index.d.ts +39 -70
- package/dist/index.js +5 -29
- package/dist/markdown/index.cjs +13750 -0
- package/dist/markdown/index.d.cts +111 -0
- package/dist/markdown/index.d.ts +111 -0
- package/dist/markdown/index.js +13742 -0
- package/dist/rich-text/index.cjs +26 -6
- package/dist/rich-text/index.d.cts +3 -148
- package/dist/rich-text/index.d.ts +3 -148
- package/dist/rich-text/index.js +1 -1
- package/dist/rich-text.d-BWc-5gX1.d.cts +326 -0
- package/dist/rich-text.d-BWc-5gX1.d.ts +326 -0
- package/dist/schema/index.cjs +34 -34
- package/dist/schema/index.d.cts +9 -178
- package/dist/schema/index.d.ts +9 -178
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.ts +2 -3
- package/package.json +14 -3
- package/dist/index-B9RfZVF1.d.ts +0 -861
- package/dist/index-b-AkfTUv.d.cts +0 -861
- package/dist/rich-text.d-rKmpgdGd.d.cts +0 -200
- package/dist/rich-text.d-rKmpgdGd.d.ts +0 -200
|
@@ -4,20 +4,252 @@ var chunkMWMSFIWN_cjs = require('./chunk-MWMSFIWN.cjs');
|
|
|
4
4
|
|
|
5
5
|
/* RelyIO SDK - Built with ❤️ by the RelyIO Team */
|
|
6
6
|
|
|
7
|
+
// src/rich-text/anchors.ts
|
|
8
|
+
function richTextHeadingSlug(text) {
|
|
9
|
+
return text.trim().toLowerCase().replace(/[^\p{L}\p{M}\p{N}\s_-]/gu, "").replace(/\s/gu, "-");
|
|
10
|
+
}
|
|
11
|
+
chunkMWMSFIWN_cjs.__name(richTextHeadingSlug, "richTextHeadingSlug");
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
chunkMWMSFIWN_cjs.__name(isRecord, "isRecord");
|
|
16
|
+
var BUILT_IN_CONTAINERS = /* @__PURE__ */ new Set([
|
|
17
|
+
"paragraph",
|
|
18
|
+
"heading",
|
|
19
|
+
"quote",
|
|
20
|
+
"list",
|
|
21
|
+
"listItem",
|
|
22
|
+
"codeGroup",
|
|
23
|
+
"table",
|
|
24
|
+
"tableRow",
|
|
25
|
+
"tableCell"
|
|
26
|
+
]);
|
|
27
|
+
function headingText(heading) {
|
|
28
|
+
if (!Array.isArray(heading.children)) return "";
|
|
29
|
+
let text = "";
|
|
30
|
+
for (const child of heading.children) {
|
|
31
|
+
if (!isRecord(child)) continue;
|
|
32
|
+
if (child._type === "lineBreak") text += " ";
|
|
33
|
+
else if (child._type === "text" && typeof child.text === "string") text += child.text;
|
|
34
|
+
}
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
chunkMWMSFIWN_cjs.__name(headingText, "headingText");
|
|
38
|
+
function richTextHeadingAnchors(value) {
|
|
39
|
+
return anchorsAcross([value]);
|
|
40
|
+
}
|
|
41
|
+
chunkMWMSFIWN_cjs.__name(richTextHeadingAnchors, "richTextHeadingAnchors");
|
|
42
|
+
function entryHeadingAnchors(entry) {
|
|
43
|
+
return anchorsAcross(isRecord(entry) ? Object.values(entry) : []);
|
|
44
|
+
}
|
|
45
|
+
chunkMWMSFIWN_cjs.__name(entryHeadingAnchors, "entryHeadingAnchors");
|
|
46
|
+
function anchorsAcross(values) {
|
|
47
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
48
|
+
const taken = /* @__PURE__ */ new Map();
|
|
49
|
+
const unique = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((slug) => {
|
|
50
|
+
let anchor = slug;
|
|
51
|
+
const seen = taken.get(slug);
|
|
52
|
+
if (seen !== void 0) {
|
|
53
|
+
let count = seen;
|
|
54
|
+
do {
|
|
55
|
+
count += 1;
|
|
56
|
+
anchor = `${slug}-${count}`;
|
|
57
|
+
} while (taken.has(anchor));
|
|
58
|
+
taken.set(slug, count);
|
|
59
|
+
}
|
|
60
|
+
taken.set(anchor, 0);
|
|
61
|
+
return anchor;
|
|
62
|
+
}, "unique");
|
|
63
|
+
const visit = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((nodes) => {
|
|
64
|
+
for (const node of nodes) {
|
|
65
|
+
if (!isRecord(node) || typeof node._type !== "string") continue;
|
|
66
|
+
if (node._type === "heading") {
|
|
67
|
+
const slug = richTextHeadingSlug(headingText(node));
|
|
68
|
+
if (slug !== "") anchors.set(node, unique(slug));
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (BUILT_IN_CONTAINERS.has(node._type) && Array.isArray(node.children)) visit(node.children);
|
|
72
|
+
}
|
|
73
|
+
}, "visit");
|
|
74
|
+
for (const value of values) {
|
|
75
|
+
if (isRecord(value) && value._type === "richText" && Array.isArray(value.children)) {
|
|
76
|
+
visit(value.children);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return anchors;
|
|
80
|
+
}
|
|
81
|
+
chunkMWMSFIWN_cjs.__name(anchorsAcross, "anchorsAcross");
|
|
82
|
+
|
|
83
|
+
// src/binding/key-path.ts
|
|
84
|
+
var ITEM_SELECTOR = "[_key==";
|
|
85
|
+
function formatKeyPath(listPath, key, field) {
|
|
86
|
+
const item = `${listPath}${ITEM_SELECTOR}${JSON.stringify(key)}]`;
|
|
87
|
+
return field === void 0 ? item : `${item}.${field}`;
|
|
88
|
+
}
|
|
89
|
+
chunkMWMSFIWN_cjs.__name(formatKeyPath, "formatKeyPath");
|
|
90
|
+
function parseKeyPath(path) {
|
|
91
|
+
const segments = [];
|
|
92
|
+
let at = 0;
|
|
93
|
+
let expectField = true;
|
|
94
|
+
while (at < path.length) {
|
|
95
|
+
if (path.startsWith(ITEM_SELECTOR, at)) {
|
|
96
|
+
const previous = segments[segments.length - 1];
|
|
97
|
+
if (expectField || previous === void 0 || !("field" in previous)) return null;
|
|
98
|
+
const quoted = readQuoted(path, at + ITEM_SELECTOR.length);
|
|
99
|
+
if (quoted === null || path[quoted.end] !== "]") return null;
|
|
100
|
+
segments.push({ key: quoted.value });
|
|
101
|
+
at = quoted.end + 1;
|
|
102
|
+
if (at < path.length && path[at] !== "." && !path.startsWith(ITEM_SELECTOR, at)) return null;
|
|
103
|
+
if (path[at] === ".") {
|
|
104
|
+
at += 1;
|
|
105
|
+
expectField = true;
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
let end = at;
|
|
110
|
+
while (end < path.length && path[end] !== "." && path[end] !== "[") end += 1;
|
|
111
|
+
const field = path.slice(at, end);
|
|
112
|
+
if (field.length === 0) return null;
|
|
113
|
+
segments.push({ field });
|
|
114
|
+
expectField = false;
|
|
115
|
+
at = end;
|
|
116
|
+
if (path[at] === ".") {
|
|
117
|
+
at += 1;
|
|
118
|
+
expectField = true;
|
|
119
|
+
if (at === path.length) return null;
|
|
120
|
+
} else if (at < path.length && !path.startsWith(ITEM_SELECTOR, at)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return segments.length === 0 || expectField ? null : segments;
|
|
125
|
+
}
|
|
126
|
+
chunkMWMSFIWN_cjs.__name(parseKeyPath, "parseKeyPath");
|
|
127
|
+
function readQuoted(path, start) {
|
|
128
|
+
if (path[start] !== '"') return null;
|
|
129
|
+
for (let end = start + 1; end < path.length; end += 1) {
|
|
130
|
+
if (path[end] === "\\") {
|
|
131
|
+
end += 1;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (path[end] !== '"') continue;
|
|
135
|
+
try {
|
|
136
|
+
const value = JSON.parse(path.slice(start, end + 1));
|
|
137
|
+
return typeof value === "string" && value.length > 0 ? { value, end: end + 1 } : null;
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
chunkMWMSFIWN_cjs.__name(readQuoted, "readQuoted");
|
|
145
|
+
|
|
146
|
+
// src/binding/relyio-field.ts
|
|
147
|
+
var BINDING_VERSION = "1";
|
|
148
|
+
function relyioField(subject, path) {
|
|
149
|
+
if (subject === void 0) return void 0;
|
|
150
|
+
if (isBindingShaped(subject)) return continued(subject, path);
|
|
151
|
+
const field = typeof path === "string" ? path : String(path);
|
|
152
|
+
const metadata = subject._metadata;
|
|
153
|
+
const attributes = {
|
|
154
|
+
"data-relyio-entry": requireMetadata(metadata, "id", field),
|
|
155
|
+
"data-relyio-type": requireMetadata(metadata, "type", field),
|
|
156
|
+
"data-relyio-field": field,
|
|
157
|
+
"data-relyio-locale": requireMetadata(metadata, "locale", field),
|
|
158
|
+
"data-relyio-v": BINDING_VERSION
|
|
159
|
+
};
|
|
160
|
+
requireKeyPath("entry", field, field);
|
|
161
|
+
return attributes;
|
|
162
|
+
}
|
|
163
|
+
chunkMWMSFIWN_cjs.__name(relyioField, "relyioField");
|
|
164
|
+
function isBindingShaped(value) {
|
|
165
|
+
return "data-relyio-field" in value;
|
|
166
|
+
}
|
|
167
|
+
chunkMWMSFIWN_cjs.__name(isBindingShaped, "isBindingShaped");
|
|
168
|
+
function continued(binding, path) {
|
|
169
|
+
const spelled = typeof path === "string" ? path : `{ _key: ${JSON.stringify(path._key)} }`;
|
|
170
|
+
const complete = binding["data-relyio-v"] === BINDING_VERSION && [
|
|
171
|
+
binding["data-relyio-entry"],
|
|
172
|
+
binding["data-relyio-type"],
|
|
173
|
+
binding["data-relyio-field"],
|
|
174
|
+
binding["data-relyio-locale"]
|
|
175
|
+
].every((value) => typeof value === "string" && value.length > 0);
|
|
176
|
+
if (!complete) {
|
|
177
|
+
throw new TypeError(
|
|
178
|
+
`relyioField(binding, '${spelled}'): the binding is not one relyioField returned \u2014 continue the attributes relyioField(entry, field) gave, or a renderer handed you.`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const field = typeof path === "string" ? `${binding["data-relyio-field"]}.${path}` : formatKeyPath(binding["data-relyio-field"], path._key);
|
|
182
|
+
requireKeyPath("binding", spelled, field);
|
|
183
|
+
return {
|
|
184
|
+
"data-relyio-entry": binding["data-relyio-entry"],
|
|
185
|
+
"data-relyio-type": binding["data-relyio-type"],
|
|
186
|
+
"data-relyio-field": field,
|
|
187
|
+
"data-relyio-locale": binding["data-relyio-locale"],
|
|
188
|
+
"data-relyio-v": BINDING_VERSION
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
chunkMWMSFIWN_cjs.__name(continued, "continued");
|
|
192
|
+
function requireKeyPath(form, given, field) {
|
|
193
|
+
if (parseKeyPath(field) !== null) return;
|
|
194
|
+
throw new TypeError(
|
|
195
|
+
`relyioField(${form}, '${given}'): '${field}' is not a field or a key path. Name a field (\`title\`), or a value inside one by its items\u2019 keys (\`sections[_key=="k1"].heading\`).`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
chunkMWMSFIWN_cjs.__name(requireKeyPath, "requireKeyPath");
|
|
199
|
+
function requireMetadata(metadata, key, field) {
|
|
200
|
+
const value = metadata?.[key];
|
|
201
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
202
|
+
throw new TypeError(
|
|
203
|
+
`relyioField(entry, '${field}'): the entry has no _metadata.${key}, so the field cannot be bound. Pass an entry as the RelyIO API returned it.`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return value;
|
|
207
|
+
}
|
|
208
|
+
chunkMWMSFIWN_cjs.__name(requireMetadata, "requireMetadata");
|
|
209
|
+
|
|
7
210
|
// src/rich-text/render.ts
|
|
8
211
|
var RICH_TEXT_VOID_TAGS = /* @__PURE__ */ new Set([
|
|
9
212
|
"hr",
|
|
10
213
|
"br",
|
|
11
214
|
"input"
|
|
12
215
|
]);
|
|
216
|
+
var BUILT_IN_NODES = {
|
|
217
|
+
paragraph: true,
|
|
218
|
+
heading: true,
|
|
219
|
+
quote: true,
|
|
220
|
+
list: true,
|
|
221
|
+
listItem: true,
|
|
222
|
+
codeBlock: true,
|
|
223
|
+
codeGroup: true,
|
|
224
|
+
table: true,
|
|
225
|
+
tableRow: true,
|
|
226
|
+
tableCell: true,
|
|
227
|
+
divider: true,
|
|
228
|
+
text: true,
|
|
229
|
+
lineBreak: true
|
|
230
|
+
};
|
|
231
|
+
function isDeclaredRichTextNode(node) {
|
|
232
|
+
if (typeof node !== "object" || node === null) return false;
|
|
233
|
+
const type = node._type;
|
|
234
|
+
return typeof type === "string" && type !== "" && !Object.prototype.hasOwnProperty.call(BUILT_IN_NODES, type);
|
|
235
|
+
}
|
|
236
|
+
chunkMWMSFIWN_cjs.__name(isDeclaredRichTextNode, "isDeclaredRichTextNode");
|
|
13
237
|
var PLAIN = Object.freeze({ header: false });
|
|
14
238
|
var HEADER = Object.freeze({ header: true });
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
239
|
+
var headingAnchors = /* @__PURE__ */ new Map();
|
|
240
|
+
function renderRichText(value, target, options = {}) {
|
|
241
|
+
const held = value;
|
|
242
|
+
if (held._type !== "richText") {
|
|
243
|
+
const drawn = block(held, target);
|
|
18
244
|
return drawn === void 0 ? [] : [drawn];
|
|
19
245
|
}
|
|
20
|
-
|
|
246
|
+
const outer = headingAnchors;
|
|
247
|
+
headingAnchors = options.anchors ?? richTextHeadingAnchors(held);
|
|
248
|
+
try {
|
|
249
|
+
return Array.isArray(held.children) ? blocks(held.children, target) : [];
|
|
250
|
+
} finally {
|
|
251
|
+
headingAnchors = outer;
|
|
252
|
+
}
|
|
21
253
|
}
|
|
22
254
|
chunkMWMSFIWN_cjs.__name(renderRichText, "renderRichText");
|
|
23
255
|
function blocks(nodes, target) {
|
|
@@ -38,6 +270,9 @@ var HEADING_TAGS = {
|
|
|
38
270
|
6: "h6"
|
|
39
271
|
};
|
|
40
272
|
function block(node, target) {
|
|
273
|
+
if (isDeclaredRichTextNode(node)) {
|
|
274
|
+
return target.declared(node, "block");
|
|
275
|
+
}
|
|
41
276
|
switch (node._type) {
|
|
42
277
|
case "paragraph": {
|
|
43
278
|
return target.node(
|
|
@@ -49,10 +284,16 @@ function block(node, target) {
|
|
|
49
284
|
}
|
|
50
285
|
case "heading": {
|
|
51
286
|
const tag = HEADING_TAGS[node.level] ?? "p";
|
|
287
|
+
const anchor = headingAnchors.get(node);
|
|
52
288
|
return target.node(
|
|
53
289
|
node,
|
|
54
290
|
inline(node.children, target),
|
|
55
|
-
(contents) => target.element(
|
|
291
|
+
(contents) => target.element(
|
|
292
|
+
tag,
|
|
293
|
+
anchor === void 0 ? void 0 : { id: anchor },
|
|
294
|
+
contents,
|
|
295
|
+
node._key
|
|
296
|
+
),
|
|
56
297
|
PLAIN
|
|
57
298
|
);
|
|
58
299
|
}
|
|
@@ -255,6 +496,12 @@ function inline(nodes, target) {
|
|
|
255
496
|
runs = [];
|
|
256
497
|
}, "flush");
|
|
257
498
|
for (const node of nodes) {
|
|
499
|
+
if (isDeclaredRichTextNode(node)) {
|
|
500
|
+
flush();
|
|
501
|
+
const drawn = target.declared(node, "inline");
|
|
502
|
+
if (drawn !== void 0) out.push(drawn);
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
258
505
|
switch (node._type) {
|
|
259
506
|
case "text": {
|
|
260
507
|
runs.push({ span: node, drawn: 0 });
|
|
@@ -303,9 +550,22 @@ function nextMark(run) {
|
|
|
303
550
|
chunkMWMSFIWN_cjs.__name(nextMark, "nextMark");
|
|
304
551
|
function sameMark(a, b) {
|
|
305
552
|
if (a?._type !== b._type) return false;
|
|
306
|
-
|
|
553
|
+
if (a._type === "link" && b._type === "link") return a.href === b.href;
|
|
554
|
+
if (a._type === "entryLink" && b._type === "entryLink") {
|
|
555
|
+
return linkedEntryId(a) === linkedEntryId(b) && a.anchor === b.anchor;
|
|
556
|
+
}
|
|
557
|
+
return true;
|
|
307
558
|
}
|
|
308
559
|
chunkMWMSFIWN_cjs.__name(sameMark, "sameMark");
|
|
560
|
+
function linkedEntryId(link) {
|
|
561
|
+
const to = link.to;
|
|
562
|
+
if (typeof to === "object" && to !== null && "_metadata" in to) {
|
|
563
|
+
const metadata = to._metadata;
|
|
564
|
+
return metadata?.id ?? to;
|
|
565
|
+
}
|
|
566
|
+
return to;
|
|
567
|
+
}
|
|
568
|
+
chunkMWMSFIWN_cjs.__name(linkedEntryId, "linkedEntryId");
|
|
309
569
|
var MARK_TAGS = {
|
|
310
570
|
bold: "strong",
|
|
311
571
|
italic: "em",
|
|
@@ -318,6 +578,9 @@ var MARK_TAGS = {
|
|
|
318
578
|
};
|
|
319
579
|
function applyMark(mark, inner, target) {
|
|
320
580
|
switch (mark._type) {
|
|
581
|
+
case "entryLink": {
|
|
582
|
+
return [target.entryLink(mark, inner)];
|
|
583
|
+
}
|
|
321
584
|
case "link": {
|
|
322
585
|
const href = safeRichTextHref(mark.href);
|
|
323
586
|
if (href === void 0) return inner;
|
|
@@ -391,28 +654,168 @@ function attributesOf(attributes) {
|
|
|
391
654
|
return written;
|
|
392
655
|
}
|
|
393
656
|
chunkMWMSFIWN_cjs.__name(attributesOf, "attributesOf");
|
|
394
|
-
var
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
657
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
658
|
+
"area",
|
|
659
|
+
"base",
|
|
660
|
+
"br",
|
|
661
|
+
"col",
|
|
662
|
+
"embed",
|
|
663
|
+
"hr",
|
|
664
|
+
"img",
|
|
665
|
+
"input",
|
|
666
|
+
"link",
|
|
667
|
+
"meta",
|
|
668
|
+
"source",
|
|
669
|
+
"track",
|
|
670
|
+
"wbr"
|
|
671
|
+
]);
|
|
672
|
+
var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["script", "style", "textarea", "title"]);
|
|
673
|
+
var BOUND = /\sdata-relyio-entry(?:[\s=/>]|$)/i;
|
|
674
|
+
function tagEnd(html, start) {
|
|
675
|
+
let quote;
|
|
676
|
+
for (let index = start + 1; index < html.length; index++) {
|
|
677
|
+
const character = html[index];
|
|
678
|
+
if (quote !== void 0) {
|
|
679
|
+
if (character === quote) quote = void 0;
|
|
680
|
+
} else if (character === '"' || character === "'") {
|
|
681
|
+
quote = character;
|
|
682
|
+
} else if (character === ">") {
|
|
683
|
+
return index + 1;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return -1;
|
|
687
|
+
}
|
|
688
|
+
chunkMWMSFIWN_cjs.__name(tagEnd, "tagEnd");
|
|
689
|
+
var TAG_NAME = /^<\/?([A-Za-z][\w:-]*)/;
|
|
690
|
+
function soleElementStartTag(html) {
|
|
691
|
+
const from = html.length - html.trimStart().length;
|
|
692
|
+
const to = html.trimEnd().length;
|
|
693
|
+
const root = TAG_NAME.exec(html.slice(from));
|
|
694
|
+
if (root === null || html[from + 1] === "/") return void 0;
|
|
695
|
+
let depth = 0;
|
|
696
|
+
let index = from;
|
|
697
|
+
let startTag;
|
|
698
|
+
while (index < to) {
|
|
699
|
+
if (depth === 0 && startTag !== void 0) return void 0;
|
|
700
|
+
const open = html.indexOf("<", index);
|
|
701
|
+
if (open !== index) {
|
|
702
|
+
if (depth === 0) return void 0;
|
|
703
|
+
if (open === -1 || open >= to) return void 0;
|
|
704
|
+
index = open;
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (html.startsWith("<!--", index)) {
|
|
708
|
+
if (depth === 0) return void 0;
|
|
709
|
+
const close = html.indexOf("-->", index + 4);
|
|
710
|
+
if (close === -1) return void 0;
|
|
711
|
+
index = close + 3;
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const name = TAG_NAME.exec(html.slice(index));
|
|
715
|
+
if (name === null) {
|
|
716
|
+
if (depth === 0) return void 0;
|
|
717
|
+
index += 1;
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
const end = tagEnd(html, index);
|
|
721
|
+
if (end === -1 || end > to) return void 0;
|
|
722
|
+
const tag = (name[1] ?? "").toLowerCase();
|
|
723
|
+
if (html[index + 1] === "/") {
|
|
724
|
+
depth -= 1;
|
|
725
|
+
if (depth < 0) return void 0;
|
|
726
|
+
index = end;
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
const selfClosing = html[end - 2] === "/";
|
|
730
|
+
if (startTag === void 0) {
|
|
731
|
+
let insertAt = selfClosing ? end - 2 : end - 1;
|
|
732
|
+
while (insertAt > index && /\s/.test(html[insertAt - 1] ?? "")) insertAt -= 1;
|
|
733
|
+
startTag = { insertAt, tag: html.slice(index, end) };
|
|
734
|
+
}
|
|
735
|
+
if (selfClosing || VOID_ELEMENTS.has(tag)) {
|
|
736
|
+
index = end;
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (RAW_TEXT_ELEMENTS.has(tag)) {
|
|
740
|
+
const close = html.toLowerCase().indexOf(`</${tag}`, end);
|
|
741
|
+
if (close === -1) return void 0;
|
|
742
|
+
depth += 1;
|
|
743
|
+
index = close;
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
depth += 1;
|
|
747
|
+
index = end;
|
|
748
|
+
}
|
|
749
|
+
return depth === 0 ? startTag : void 0;
|
|
750
|
+
}
|
|
751
|
+
chunkMWMSFIWN_cjs.__name(soleElementStartTag, "soleElementStartTag");
|
|
752
|
+
function stamped(html, binding) {
|
|
753
|
+
if (binding === void 0) return html;
|
|
754
|
+
const root = soleElementStartTag(html);
|
|
755
|
+
if (root === void 0) return html;
|
|
756
|
+
if (BOUND.test(root.tag)) return html;
|
|
757
|
+
return `${html.slice(0, root.insertAt)}${attributesOf(binding)}${html.slice(root.insertAt)}`;
|
|
758
|
+
}
|
|
759
|
+
chunkMWMSFIWN_cjs.__name(stamped, "stamped");
|
|
760
|
+
function htmlTarget(declared2, entryLink, field) {
|
|
761
|
+
return {
|
|
762
|
+
element(tag, attributes, children) {
|
|
763
|
+
return RICH_TEXT_VOID_TAGS.has(tag) ? `<${tag}${attributesOf(attributes)}/>` : `<${tag}${attributesOf(attributes)}>${children.join("")}</${tag}>`;
|
|
764
|
+
},
|
|
765
|
+
text: escapeHtml,
|
|
766
|
+
node: /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((_node, contents, draw) => draw(contents), "node"),
|
|
767
|
+
mark: /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((_mark, contents, draw) => draw(contents), "mark"),
|
|
768
|
+
// A value built by hand holding an entry link no writer draws: its text, with no anchor
|
|
769
|
+
entryLink: /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((link, contents) => entryLink === void 0 ? contents.join("") : entryLink(link, contents.join("")), "entryLink"),
|
|
770
|
+
// A declared node's writer (REL-1807), handed the node's key path below the field's binding and
|
|
771
|
+
// stamped with it (REL-2142); no binding asks the core nothing
|
|
772
|
+
declared(node) {
|
|
773
|
+
const write = Object.prototype.hasOwnProperty.call(declared2, node._type) ? declared2[node._type] : void 0;
|
|
774
|
+
if (write === void 0) return void 0;
|
|
775
|
+
const binding = field === void 0 ? void 0 : relyioField(field, node);
|
|
776
|
+
return stamped(write(node, binding), binding);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
chunkMWMSFIWN_cjs.__name(htmlTarget, "htmlTarget");
|
|
781
|
+
function richTextToHtml(value, ...[options]) {
|
|
403
782
|
if (value === void 0) return "";
|
|
404
|
-
|
|
783
|
+
const declared2 = options?.declared ?? {};
|
|
784
|
+
const entryLink = options?.entryLink;
|
|
785
|
+
return renderRichText(
|
|
786
|
+
value,
|
|
787
|
+
htmlTarget(declared2, entryLink, options?.field),
|
|
788
|
+
options?.anchors === void 0 ? {} : { anchors: options.anchors }
|
|
789
|
+
).join("");
|
|
405
790
|
}
|
|
406
791
|
chunkMWMSFIWN_cjs.__name(richTextToHtml, "richTextToHtml");
|
|
407
792
|
|
|
408
793
|
// src/rich-text/markdown.ts
|
|
409
|
-
|
|
794
|
+
var entryLinkWriter;
|
|
795
|
+
var writers = {};
|
|
796
|
+
function declared(node) {
|
|
797
|
+
const type = node._type;
|
|
798
|
+
const write = Object.prototype.hasOwnProperty.call(writers, type) ? writers[type] : void 0;
|
|
799
|
+
return write === void 0 ? void 0 : write(node);
|
|
800
|
+
}
|
|
801
|
+
chunkMWMSFIWN_cjs.__name(declared, "declared");
|
|
802
|
+
function richTextToMarkdown(value, ...[options]) {
|
|
410
803
|
if (value === void 0) return "";
|
|
411
|
-
const
|
|
804
|
+
const tree = value;
|
|
805
|
+
const held = tree._type === "richText" ? tree.children : [tree];
|
|
412
806
|
if (!Array.isArray(held)) return "";
|
|
413
|
-
const
|
|
414
|
-
|
|
807
|
+
const outer = writers;
|
|
808
|
+
const outerLink = entryLinkWriter;
|
|
809
|
+
writers = options?.declared ?? {};
|
|
810
|
+
entryLinkWriter = options?.entryLink;
|
|
811
|
+
try {
|
|
812
|
+
const written = blocks2(held);
|
|
813
|
+
return written.length === 0 ? "" : `${written.join("\n\n")}
|
|
415
814
|
`;
|
|
815
|
+
} finally {
|
|
816
|
+
writers = outer;
|
|
817
|
+
entryLinkWriter = outerLink;
|
|
818
|
+
}
|
|
416
819
|
}
|
|
417
820
|
chunkMWMSFIWN_cjs.__name(richTextToMarkdown, "richTextToMarkdown");
|
|
418
821
|
function blocks2(nodes) {
|
|
@@ -425,6 +828,7 @@ function blocks2(nodes) {
|
|
|
425
828
|
}
|
|
426
829
|
chunkMWMSFIWN_cjs.__name(blocks2, "blocks");
|
|
427
830
|
function block2(node) {
|
|
831
|
+
if (isDeclaredRichTextNode(node)) return declared(node);
|
|
428
832
|
switch (node._type) {
|
|
429
833
|
case "paragraph": {
|
|
430
834
|
return escapeLineStarts(inline2(node.children, "\\\n"));
|
|
@@ -568,6 +972,11 @@ function inline2(nodes, lineBreak) {
|
|
|
568
972
|
runs = [];
|
|
569
973
|
}, "flush");
|
|
570
974
|
for (const node of nodes) {
|
|
975
|
+
if (isDeclaredRichTextNode(node)) {
|
|
976
|
+
flush();
|
|
977
|
+
out += declared(node) ?? "";
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
571
980
|
switch (node._type) {
|
|
572
981
|
case "text": {
|
|
573
982
|
runs.push({ span: node, drawn: 0 });
|
|
@@ -618,6 +1027,9 @@ function marked2(runs) {
|
|
|
618
1027
|
chunkMWMSFIWN_cjs.__name(marked2, "marked");
|
|
619
1028
|
function applyMark2(mark, inner) {
|
|
620
1029
|
switch (mark._type) {
|
|
1030
|
+
case "entryLink": {
|
|
1031
|
+
return entryLinkWriter === void 0 || inner === "" ? inner : entryLinkWriter(mark, inner);
|
|
1032
|
+
}
|
|
621
1033
|
case "link": {
|
|
622
1034
|
const href = safeRichTextHref(mark.href);
|
|
623
1035
|
if (href === void 0 || inner === "") return inner;
|
|
@@ -678,9 +1090,17 @@ function escapeLineStarts(paragraph) {
|
|
|
678
1090
|
chunkMWMSFIWN_cjs.__name(escapeLineStarts, "escapeLineStarts");
|
|
679
1091
|
|
|
680
1092
|
exports.RICH_TEXT_VOID_TAGS = RICH_TEXT_VOID_TAGS;
|
|
1093
|
+
exports.entryHeadingAnchors = entryHeadingAnchors;
|
|
1094
|
+
exports.escapeHtml = escapeHtml;
|
|
1095
|
+
exports.formatKeyPath = formatKeyPath;
|
|
1096
|
+
exports.isDeclaredRichTextNode = isDeclaredRichTextNode;
|
|
1097
|
+
exports.parseKeyPath = parseKeyPath;
|
|
1098
|
+
exports.relyioField = relyioField;
|
|
681
1099
|
exports.renderRichText = renderRichText;
|
|
1100
|
+
exports.richTextHeadingAnchors = richTextHeadingAnchors;
|
|
1101
|
+
exports.richTextHeadingSlug = richTextHeadingSlug;
|
|
682
1102
|
exports.richTextToHtml = richTextToHtml;
|
|
683
1103
|
exports.richTextToMarkdown = richTextToMarkdown;
|
|
684
1104
|
exports.safeRichTextHref = safeRichTextHref;
|
|
685
|
-
//# sourceMappingURL=chunk-
|
|
686
|
-
//# sourceMappingURL=chunk-
|
|
1105
|
+
//# sourceMappingURL=chunk-Z6GLWSSD.cjs.map
|
|
1106
|
+
//# sourceMappingURL=chunk-Z6GLWSSD.cjs.map
|
package/dist/client/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDEDIJKHY_cjs = require('../chunk-DEDIJKHY.cjs');
|
|
4
4
|
require('../chunk-LSRPMNPT.cjs');
|
|
5
5
|
require('../chunk-TZL374LS.cjs');
|
|
6
6
|
require('../chunk-MWMSFIWN.cjs');
|
|
@@ -9,11 +9,11 @@ require('../chunk-MWMSFIWN.cjs');
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "TypedRelyIOClient", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkDEDIJKHY_cjs.TypedRelyIOClient; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "createClient", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkDEDIJKHY_cjs.createClient; }
|
|
17
17
|
});
|
|
18
18
|
//# sourceMappingURL=index.cjs.map
|
|
19
19
|
//# sourceMappingURL=index.cjs.map
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-
|
|
2
|
-
import '../
|
|
3
|
-
import '../rich-text.d-
|
|
4
|
-
import '../
|
|
5
|
-
import '../define-schema-DgctHlI2.cjs';
|
|
1
|
+
export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-BT0L8xJj.cjs';
|
|
2
|
+
import '../include-paths-Bs5FhNw2.cjs';
|
|
3
|
+
import '../rich-text.d-BWc-5gX1.cjs';
|
|
4
|
+
import '../define-schema-sWJ8Zn7C.cjs';
|
|
6
5
|
import './live-visitor.js';
|
|
7
6
|
import '../dev-handshake/index.cjs';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-
|
|
2
|
-
import '../
|
|
3
|
-
import '../rich-text.d-
|
|
4
|
-
import '../
|
|
5
|
-
import '../define-schema-mrEZbY1h.js';
|
|
1
|
+
export { e as ClientSchema, R as Register, f as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-CPjJ25R4.js';
|
|
2
|
+
import '../include-paths-Cb7iPCW2.js';
|
|
3
|
+
import '../rich-text.d-BWc-5gX1.js';
|
|
4
|
+
import '../define-schema-UHViXKiv.js';
|
|
6
5
|
import './live-visitor.js';
|
|
7
6
|
import '../dev-handshake/index.js';
|
package/dist/client/index.js
CHANGED