@selfhelp/shared 1.30.0 → 1.31.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 +41 -0
- package/dist/index.d.mts +14 -82
- package/dist/index.d.ts +14 -82
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/inlineFormat-Duu5VLMU.d.mts +73 -0
- package/dist/inlineFormat-Duu5VLMU.d.ts +73 -0
- package/dist/{manifest-DRlcSvvy.d.mts → manifest-DWHD0PQA.d.mts} +124 -1
- package/dist/{manifest-DRlcSvvy.d.ts → manifest-DWHD0PQA.d.ts} +124 -1
- package/dist/plugin-sdk/index.d.mts +210 -10
- package/dist/plugin-sdk/index.d.ts +210 -10
- package/dist/plugin-sdk/index.js +174 -2
- package/dist/plugin-sdk/index.mjs +171 -2
- package/dist/plugin-sdk/sync-map.d.mts +22 -0
- package/dist/plugin-sdk/sync-map.d.ts +22 -0
- package/dist/plugin-sdk/sync-map.js +58 -0
- package/dist/plugin-sdk/sync-map.mjs +33 -0
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/{styles.registry-DnIJqEzM.d.mts → styles.registry-B2cyNdo3.d.mts} +26 -1
- package/dist/{styles.registry-C2ACy7H0.d.ts → styles.registry-G_KUYGPv.d.ts} +26 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/plugin-sdk/__tests__/define-sync.test.ts +106 -0
- package/src/plugin-sdk/__tests__/exports.test.ts +29 -0
- package/src/plugin-sdk/__tests__/host-services.test.ts +96 -6
- package/src/plugin-sdk/__tests__/sync-map.test.ts +48 -0
- package/src/plugin-sdk/__tests__/version.test.ts +9 -0
- package/src/plugin-sdk/host-services.ts +106 -0
- package/src/plugin-sdk/index.ts +24 -0
- package/src/plugin-sdk/manifest.ts +142 -0
- package/src/plugin-sdk/sync-map.ts +61 -0
- package/src/plugin-sdk/types.ts +89 -5
- package/src/plugin-sdk/version.ts +19 -2
- package/src/sync/__tests__/sync.test.ts +19 -0
- package/src/sync/sync.ts +3 -2
- package/src/sync/types.ts +9 -6
- package/src/types/api/form-lists.ts +16 -1
- package/src/types/api/forms.ts +10 -0
package/dist/plugin-sdk/index.js
CHANGED
|
@@ -39,16 +39,19 @@ __export(plugin_sdk_exports, {
|
|
|
39
39
|
isMobileRendererCompatible: () => isMobileRendererCompatible,
|
|
40
40
|
isPluginApiCompatible: () => isPluginApiCompatible,
|
|
41
41
|
isPluginRuntimeShimSpecifier: () => isPluginRuntimeShimSpecifier,
|
|
42
|
+
matchPluginSyncEntries: () => matchPluginSyncEntries,
|
|
43
|
+
parseInlineRich: () => parseInlineRich,
|
|
42
44
|
parseSemver: () => parseSemver,
|
|
43
45
|
satisfiesSemverRange: () => satisfiesSemverRange,
|
|
44
46
|
setMobileHostServices: () => setMobileHostServices,
|
|
47
|
+
stripHtmlToText: () => stripHtmlToText,
|
|
45
48
|
usePluginRealtime: () => usePluginRealtime
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(plugin_sdk_exports);
|
|
48
51
|
|
|
49
52
|
// src/plugin-sdk/version.ts
|
|
50
|
-
var PLUGIN_API_VERSION = "0.
|
|
51
|
-
var MOBILE_RENDERER_VERSION = "0.
|
|
53
|
+
var PLUGIN_API_VERSION = "0.2.0";
|
|
54
|
+
var MOBILE_RENDERER_VERSION = "0.4.0";
|
|
52
55
|
var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
|
|
53
56
|
function parseSemver(version) {
|
|
54
57
|
const match = SEMVER_REGEX.exec(version);
|
|
@@ -187,6 +190,37 @@ function assertPluginVersionSemantics(prevVersion, nextVersion, options) {
|
|
|
187
190
|
// src/plugin-sdk/registry.ts
|
|
188
191
|
var PLUGIN_REGISTRY_CHANNELS = ["stable", "beta", "nightly", "test"];
|
|
189
192
|
|
|
193
|
+
// src/plugin-sdk/sync-map.ts
|
|
194
|
+
function matchPluginSyncEntries(entries, tags) {
|
|
195
|
+
if (!entries?.length || tags.length === 0) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const seen = /* @__PURE__ */ new Set();
|
|
199
|
+
const keys = [];
|
|
200
|
+
for (const entry of entries) {
|
|
201
|
+
if (!entry.tags?.length || !Array.isArray(entry.queryKey)) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const matched = tags.some((tag) => entry.tags.some((pattern) => tagMatchesPattern(tag, pattern)));
|
|
205
|
+
if (!matched) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const serialized = JSON.stringify(entry.queryKey);
|
|
209
|
+
if (seen.has(serialized)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
seen.add(serialized);
|
|
213
|
+
keys.push(entry.queryKey.slice());
|
|
214
|
+
}
|
|
215
|
+
return keys;
|
|
216
|
+
}
|
|
217
|
+
function tagMatchesPattern(tag, pattern) {
|
|
218
|
+
if (pattern.endsWith("*")) {
|
|
219
|
+
return tag.startsWith(pattern.slice(0, -1));
|
|
220
|
+
}
|
|
221
|
+
return tag === pattern;
|
|
222
|
+
}
|
|
223
|
+
|
|
190
224
|
// src/registry/styles.registry.ts
|
|
191
225
|
var BASE_STYLE_REGISTRY = {
|
|
192
226
|
// ===== auth =====
|
|
@@ -381,6 +415,141 @@ function getMobileHostServices() {
|
|
|
381
415
|
return registeredHostServices;
|
|
382
416
|
}
|
|
383
417
|
|
|
418
|
+
// src/content/inlineFormat.ts
|
|
419
|
+
var HTML_ENTITIES = {
|
|
420
|
+
"&": "&",
|
|
421
|
+
"<": "<",
|
|
422
|
+
">": ">",
|
|
423
|
+
""": '"',
|
|
424
|
+
"'": "'",
|
|
425
|
+
"'": "'",
|
|
426
|
+
" ": " ",
|
|
427
|
+
"/": "/",
|
|
428
|
+
"/": "/"
|
|
429
|
+
};
|
|
430
|
+
function decodeEntities(value) {
|
|
431
|
+
if (!value.includes("&")) return value;
|
|
432
|
+
return value.replace(/&[a-zA-Z#0-9]+;/g, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
|
|
433
|
+
}
|
|
434
|
+
function looksLikeJson(trimmed) {
|
|
435
|
+
const first = trimmed[0];
|
|
436
|
+
if (first !== "{" && first !== "[") return false;
|
|
437
|
+
try {
|
|
438
|
+
JSON.parse(trimmed);
|
|
439
|
+
return true;
|
|
440
|
+
} catch {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
var SEPARATOR_TAGS = /* @__PURE__ */ new Set([
|
|
445
|
+
"br",
|
|
446
|
+
"p",
|
|
447
|
+
"div",
|
|
448
|
+
"li",
|
|
449
|
+
"ul",
|
|
450
|
+
"ol",
|
|
451
|
+
"h1",
|
|
452
|
+
"h2",
|
|
453
|
+
"h3",
|
|
454
|
+
"h4",
|
|
455
|
+
"h5",
|
|
456
|
+
"h6",
|
|
457
|
+
"blockquote",
|
|
458
|
+
"tr",
|
|
459
|
+
"section",
|
|
460
|
+
"article",
|
|
461
|
+
"header",
|
|
462
|
+
"footer",
|
|
463
|
+
"pre"
|
|
464
|
+
]);
|
|
465
|
+
var TAG_RE = /<\/?([a-z][a-z0-9]*)\b([^>]*)>/gi;
|
|
466
|
+
var HREF_RE = /href\s*=\s*(?:"([^"]*)"|'([^']*)')/i;
|
|
467
|
+
function extractHref(attrs) {
|
|
468
|
+
const match = HREF_RE.exec(attrs);
|
|
469
|
+
return (match?.[1] ?? match?.[2] ?? "").trim();
|
|
470
|
+
}
|
|
471
|
+
function formatKey(node) {
|
|
472
|
+
return `${node.bold ? 1 : 0}|${node.italic ? 1 : 0}|${node.underline ? 1 : 0}|${node.href ?? ""}`;
|
|
473
|
+
}
|
|
474
|
+
function parseInlineRich(value) {
|
|
475
|
+
if (value == null) return [];
|
|
476
|
+
const str = String(value);
|
|
477
|
+
if (str === "") return [];
|
|
478
|
+
const trimmed = str.trim();
|
|
479
|
+
if (looksLikeJson(trimmed)) return [{ text: str }];
|
|
480
|
+
if (!str.includes("<")) {
|
|
481
|
+
const text = decodeEntities(str);
|
|
482
|
+
return text === "" ? [] : [{ text }];
|
|
483
|
+
}
|
|
484
|
+
const raw = [];
|
|
485
|
+
let bold = 0;
|
|
486
|
+
let italic = 0;
|
|
487
|
+
let underline = 0;
|
|
488
|
+
const hrefStack = [];
|
|
489
|
+
const pushText = (segment) => {
|
|
490
|
+
if (segment === "") return;
|
|
491
|
+
raw.push({
|
|
492
|
+
text: segment,
|
|
493
|
+
...bold > 0 ? { bold: true } : {},
|
|
494
|
+
...italic > 0 ? { italic: true } : {},
|
|
495
|
+
...underline > 0 ? { underline: true } : {},
|
|
496
|
+
...hrefStack.length > 0 ? { href: hrefStack[hrefStack.length - 1] } : {}
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
let lastIndex = 0;
|
|
500
|
+
let match;
|
|
501
|
+
TAG_RE.lastIndex = 0;
|
|
502
|
+
while ((match = TAG_RE.exec(str)) !== null) {
|
|
503
|
+
pushText(str.slice(lastIndex, match.index));
|
|
504
|
+
lastIndex = TAG_RE.lastIndex;
|
|
505
|
+
const isClose = match[0].charAt(1) === "/";
|
|
506
|
+
const tag = match[1].toLowerCase();
|
|
507
|
+
const attrs = match[2] ?? "";
|
|
508
|
+
if (tag === "b" || tag === "strong") {
|
|
509
|
+
bold = isClose ? Math.max(0, bold - 1) : bold + 1;
|
|
510
|
+
} else if (tag === "i" || tag === "em") {
|
|
511
|
+
italic = isClose ? Math.max(0, italic - 1) : italic + 1;
|
|
512
|
+
} else if (tag === "u") {
|
|
513
|
+
underline = isClose ? Math.max(0, underline - 1) : underline + 1;
|
|
514
|
+
} else if (tag === "a") {
|
|
515
|
+
if (isClose) {
|
|
516
|
+
hrefStack.pop();
|
|
517
|
+
} else {
|
|
518
|
+
hrefStack.push(extractHref(attrs));
|
|
519
|
+
}
|
|
520
|
+
} else if (SEPARATOR_TAGS.has(tag)) {
|
|
521
|
+
pushText(" ");
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
pushText(str.slice(lastIndex));
|
|
525
|
+
const merged = [];
|
|
526
|
+
for (const node of raw) {
|
|
527
|
+
const prev = merged[merged.length - 1];
|
|
528
|
+
if (prev && formatKey(prev) === formatKey(node)) {
|
|
529
|
+
prev.text += node.text;
|
|
530
|
+
} else {
|
|
531
|
+
merged.push({ ...node });
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
for (const node of merged) {
|
|
535
|
+
node.text = decodeEntities(node.text).replace(/\s+/g, " ");
|
|
536
|
+
}
|
|
537
|
+
if (merged.length > 0) {
|
|
538
|
+
merged[0].text = merged[0].text.replace(/^\s+/, "");
|
|
539
|
+
merged[merged.length - 1].text = merged[merged.length - 1].text.replace(/\s+$/, "");
|
|
540
|
+
}
|
|
541
|
+
return merged.filter((node) => node.text !== "");
|
|
542
|
+
}
|
|
543
|
+
function stripHtmlToText(value) {
|
|
544
|
+
if (!value || typeof value !== "string") return value ?? "";
|
|
545
|
+
const trimmed = value.trim();
|
|
546
|
+
if (looksLikeJson(trimmed)) return value;
|
|
547
|
+
if (!/[<&]/.test(value)) return value;
|
|
548
|
+
let out = value.replace(/<br\s*\/?>/gi, " ").replace(/<\/(p|div|li|h[1-6]|tr|blockquote)>/gi, " ").replace(/<[^>]+>/g, "");
|
|
549
|
+
out = out.replace(/&[a-zA-Z#0-9]+;/g, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
|
|
550
|
+
return out.replace(/\s+/g, " ").trim();
|
|
551
|
+
}
|
|
552
|
+
|
|
384
553
|
// src/plugin-sdk/realtime.ts
|
|
385
554
|
var import_react = require("react");
|
|
386
555
|
var DEFAULT_ENDPOINT = "/api/plugins/events";
|
|
@@ -570,8 +739,11 @@ var PLUGIN_RUNTIME_IMPORT_MAP = Object.freeze(
|
|
|
570
739
|
isMobileRendererCompatible,
|
|
571
740
|
isPluginApiCompatible,
|
|
572
741
|
isPluginRuntimeShimSpecifier,
|
|
742
|
+
matchPluginSyncEntries,
|
|
743
|
+
parseInlineRich,
|
|
573
744
|
parseSemver,
|
|
574
745
|
satisfiesSemverRange,
|
|
575
746
|
setMobileHostServices,
|
|
747
|
+
stripHtmlToText,
|
|
576
748
|
usePluginRealtime
|
|
577
749
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/plugin-sdk/version.ts
|
|
2
|
-
var PLUGIN_API_VERSION = "0.
|
|
3
|
-
var MOBILE_RENDERER_VERSION = "0.
|
|
2
|
+
var PLUGIN_API_VERSION = "0.2.0";
|
|
3
|
+
var MOBILE_RENDERER_VERSION = "0.4.0";
|
|
4
4
|
var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
|
|
5
5
|
function parseSemver(version) {
|
|
6
6
|
const match = SEMVER_REGEX.exec(version);
|
|
@@ -139,6 +139,37 @@ function assertPluginVersionSemantics(prevVersion, nextVersion, options) {
|
|
|
139
139
|
// src/plugin-sdk/registry.ts
|
|
140
140
|
var PLUGIN_REGISTRY_CHANNELS = ["stable", "beta", "nightly", "test"];
|
|
141
141
|
|
|
142
|
+
// src/plugin-sdk/sync-map.ts
|
|
143
|
+
function matchPluginSyncEntries(entries, tags) {
|
|
144
|
+
if (!entries?.length || tags.length === 0) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
const seen = /* @__PURE__ */ new Set();
|
|
148
|
+
const keys = [];
|
|
149
|
+
for (const entry of entries) {
|
|
150
|
+
if (!entry.tags?.length || !Array.isArray(entry.queryKey)) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const matched = tags.some((tag) => entry.tags.some((pattern) => tagMatchesPattern(tag, pattern)));
|
|
154
|
+
if (!matched) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const serialized = JSON.stringify(entry.queryKey);
|
|
158
|
+
if (seen.has(serialized)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
seen.add(serialized);
|
|
162
|
+
keys.push(entry.queryKey.slice());
|
|
163
|
+
}
|
|
164
|
+
return keys;
|
|
165
|
+
}
|
|
166
|
+
function tagMatchesPattern(tag, pattern) {
|
|
167
|
+
if (pattern.endsWith("*")) {
|
|
168
|
+
return tag.startsWith(pattern.slice(0, -1));
|
|
169
|
+
}
|
|
170
|
+
return tag === pattern;
|
|
171
|
+
}
|
|
172
|
+
|
|
142
173
|
// src/registry/styles.registry.ts
|
|
143
174
|
var BASE_STYLE_REGISTRY = {
|
|
144
175
|
// ===== auth =====
|
|
@@ -333,6 +364,141 @@ function getMobileHostServices() {
|
|
|
333
364
|
return registeredHostServices;
|
|
334
365
|
}
|
|
335
366
|
|
|
367
|
+
// src/content/inlineFormat.ts
|
|
368
|
+
var HTML_ENTITIES = {
|
|
369
|
+
"&": "&",
|
|
370
|
+
"<": "<",
|
|
371
|
+
">": ">",
|
|
372
|
+
""": '"',
|
|
373
|
+
"'": "'",
|
|
374
|
+
"'": "'",
|
|
375
|
+
" ": " ",
|
|
376
|
+
"/": "/",
|
|
377
|
+
"/": "/"
|
|
378
|
+
};
|
|
379
|
+
function decodeEntities(value) {
|
|
380
|
+
if (!value.includes("&")) return value;
|
|
381
|
+
return value.replace(/&[a-zA-Z#0-9]+;/g, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
|
|
382
|
+
}
|
|
383
|
+
function looksLikeJson(trimmed) {
|
|
384
|
+
const first = trimmed[0];
|
|
385
|
+
if (first !== "{" && first !== "[") return false;
|
|
386
|
+
try {
|
|
387
|
+
JSON.parse(trimmed);
|
|
388
|
+
return true;
|
|
389
|
+
} catch {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
var SEPARATOR_TAGS = /* @__PURE__ */ new Set([
|
|
394
|
+
"br",
|
|
395
|
+
"p",
|
|
396
|
+
"div",
|
|
397
|
+
"li",
|
|
398
|
+
"ul",
|
|
399
|
+
"ol",
|
|
400
|
+
"h1",
|
|
401
|
+
"h2",
|
|
402
|
+
"h3",
|
|
403
|
+
"h4",
|
|
404
|
+
"h5",
|
|
405
|
+
"h6",
|
|
406
|
+
"blockquote",
|
|
407
|
+
"tr",
|
|
408
|
+
"section",
|
|
409
|
+
"article",
|
|
410
|
+
"header",
|
|
411
|
+
"footer",
|
|
412
|
+
"pre"
|
|
413
|
+
]);
|
|
414
|
+
var TAG_RE = /<\/?([a-z][a-z0-9]*)\b([^>]*)>/gi;
|
|
415
|
+
var HREF_RE = /href\s*=\s*(?:"([^"]*)"|'([^']*)')/i;
|
|
416
|
+
function extractHref(attrs) {
|
|
417
|
+
const match = HREF_RE.exec(attrs);
|
|
418
|
+
return (match?.[1] ?? match?.[2] ?? "").trim();
|
|
419
|
+
}
|
|
420
|
+
function formatKey(node) {
|
|
421
|
+
return `${node.bold ? 1 : 0}|${node.italic ? 1 : 0}|${node.underline ? 1 : 0}|${node.href ?? ""}`;
|
|
422
|
+
}
|
|
423
|
+
function parseInlineRich(value) {
|
|
424
|
+
if (value == null) return [];
|
|
425
|
+
const str = String(value);
|
|
426
|
+
if (str === "") return [];
|
|
427
|
+
const trimmed = str.trim();
|
|
428
|
+
if (looksLikeJson(trimmed)) return [{ text: str }];
|
|
429
|
+
if (!str.includes("<")) {
|
|
430
|
+
const text = decodeEntities(str);
|
|
431
|
+
return text === "" ? [] : [{ text }];
|
|
432
|
+
}
|
|
433
|
+
const raw = [];
|
|
434
|
+
let bold = 0;
|
|
435
|
+
let italic = 0;
|
|
436
|
+
let underline = 0;
|
|
437
|
+
const hrefStack = [];
|
|
438
|
+
const pushText = (segment) => {
|
|
439
|
+
if (segment === "") return;
|
|
440
|
+
raw.push({
|
|
441
|
+
text: segment,
|
|
442
|
+
...bold > 0 ? { bold: true } : {},
|
|
443
|
+
...italic > 0 ? { italic: true } : {},
|
|
444
|
+
...underline > 0 ? { underline: true } : {},
|
|
445
|
+
...hrefStack.length > 0 ? { href: hrefStack[hrefStack.length - 1] } : {}
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
let lastIndex = 0;
|
|
449
|
+
let match;
|
|
450
|
+
TAG_RE.lastIndex = 0;
|
|
451
|
+
while ((match = TAG_RE.exec(str)) !== null) {
|
|
452
|
+
pushText(str.slice(lastIndex, match.index));
|
|
453
|
+
lastIndex = TAG_RE.lastIndex;
|
|
454
|
+
const isClose = match[0].charAt(1) === "/";
|
|
455
|
+
const tag = match[1].toLowerCase();
|
|
456
|
+
const attrs = match[2] ?? "";
|
|
457
|
+
if (tag === "b" || tag === "strong") {
|
|
458
|
+
bold = isClose ? Math.max(0, bold - 1) : bold + 1;
|
|
459
|
+
} else if (tag === "i" || tag === "em") {
|
|
460
|
+
italic = isClose ? Math.max(0, italic - 1) : italic + 1;
|
|
461
|
+
} else if (tag === "u") {
|
|
462
|
+
underline = isClose ? Math.max(0, underline - 1) : underline + 1;
|
|
463
|
+
} else if (tag === "a") {
|
|
464
|
+
if (isClose) {
|
|
465
|
+
hrefStack.pop();
|
|
466
|
+
} else {
|
|
467
|
+
hrefStack.push(extractHref(attrs));
|
|
468
|
+
}
|
|
469
|
+
} else if (SEPARATOR_TAGS.has(tag)) {
|
|
470
|
+
pushText(" ");
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
pushText(str.slice(lastIndex));
|
|
474
|
+
const merged = [];
|
|
475
|
+
for (const node of raw) {
|
|
476
|
+
const prev = merged[merged.length - 1];
|
|
477
|
+
if (prev && formatKey(prev) === formatKey(node)) {
|
|
478
|
+
prev.text += node.text;
|
|
479
|
+
} else {
|
|
480
|
+
merged.push({ ...node });
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
for (const node of merged) {
|
|
484
|
+
node.text = decodeEntities(node.text).replace(/\s+/g, " ");
|
|
485
|
+
}
|
|
486
|
+
if (merged.length > 0) {
|
|
487
|
+
merged[0].text = merged[0].text.replace(/^\s+/, "");
|
|
488
|
+
merged[merged.length - 1].text = merged[merged.length - 1].text.replace(/\s+$/, "");
|
|
489
|
+
}
|
|
490
|
+
return merged.filter((node) => node.text !== "");
|
|
491
|
+
}
|
|
492
|
+
function stripHtmlToText(value) {
|
|
493
|
+
if (!value || typeof value !== "string") return value ?? "";
|
|
494
|
+
const trimmed = value.trim();
|
|
495
|
+
if (looksLikeJson(trimmed)) return value;
|
|
496
|
+
if (!/[<&]/.test(value)) return value;
|
|
497
|
+
let out = value.replace(/<br\s*\/?>/gi, " ").replace(/<\/(p|div|li|h[1-6]|tr|blockquote)>/gi, " ").replace(/<[^>]+>/g, "");
|
|
498
|
+
out = out.replace(/&[a-zA-Z#0-9]+;/g, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
|
|
499
|
+
return out.replace(/\s+/g, " ").trim();
|
|
500
|
+
}
|
|
501
|
+
|
|
336
502
|
// src/plugin-sdk/realtime.ts
|
|
337
503
|
import { useEffect, useRef, useState } from "react";
|
|
338
504
|
var DEFAULT_ENDPOINT = "/api/plugins/events";
|
|
@@ -521,8 +687,11 @@ export {
|
|
|
521
687
|
isMobileRendererCompatible,
|
|
522
688
|
isPluginApiCompatible,
|
|
523
689
|
isPluginRuntimeShimSpecifier,
|
|
690
|
+
matchPluginSyncEntries,
|
|
691
|
+
parseInlineRich,
|
|
524
692
|
parseSemver,
|
|
525
693
|
satisfiesSemverRange,
|
|
526
694
|
setMobileHostServices,
|
|
695
|
+
stripHtmlToText,
|
|
527
696
|
usePluginRealtime
|
|
528
697
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative plugin sync map (contract C10).
|
|
3
|
+
*
|
|
4
|
+
* A plugin lists tags (exact, or a prefix ending in `*`) and the React Query
|
|
5
|
+
* key each tag should invalidate. Hosts call {@link matchPluginSyncEntries}
|
|
6
|
+
* from `applySyncTags` and invalidate each returned key as a prefix.
|
|
7
|
+
*/
|
|
8
|
+
/** One entry of a plugin's optional `sync` map. */
|
|
9
|
+
interface IPluginSyncEntry {
|
|
10
|
+
/** Exact tags, or a prefix ending in `*` (`res:surveyjs_survey:*`, `table:*`). */
|
|
11
|
+
tags: string[];
|
|
12
|
+
/** React Query key the host invalidates as a prefix when a listed tag matches. */
|
|
13
|
+
queryKey: readonly unknown[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the unique `queryKey` values whose `tags` match any of the message
|
|
17
|
+
* tags. A pattern ending in `*` matches by prefix; every other tag must equal.
|
|
18
|
+
* Uniqueness is by `JSON.stringify(queryKey)`.
|
|
19
|
+
*/
|
|
20
|
+
declare function matchPluginSyncEntries(entries: readonly IPluginSyncEntry[] | null | undefined, tags: readonly string[]): readonly unknown[][];
|
|
21
|
+
|
|
22
|
+
export { type IPluginSyncEntry, matchPluginSyncEntries };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative plugin sync map (contract C10).
|
|
3
|
+
*
|
|
4
|
+
* A plugin lists tags (exact, or a prefix ending in `*`) and the React Query
|
|
5
|
+
* key each tag should invalidate. Hosts call {@link matchPluginSyncEntries}
|
|
6
|
+
* from `applySyncTags` and invalidate each returned key as a prefix.
|
|
7
|
+
*/
|
|
8
|
+
/** One entry of a plugin's optional `sync` map. */
|
|
9
|
+
interface IPluginSyncEntry {
|
|
10
|
+
/** Exact tags, or a prefix ending in `*` (`res:surveyjs_survey:*`, `table:*`). */
|
|
11
|
+
tags: string[];
|
|
12
|
+
/** React Query key the host invalidates as a prefix when a listed tag matches. */
|
|
13
|
+
queryKey: readonly unknown[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the unique `queryKey` values whose `tags` match any of the message
|
|
17
|
+
* tags. A pattern ending in `*` matches by prefix; every other tag must equal.
|
|
18
|
+
* Uniqueness is by `JSON.stringify(queryKey)`.
|
|
19
|
+
*/
|
|
20
|
+
declare function matchPluginSyncEntries(entries: readonly IPluginSyncEntry[] | null | undefined, tags: readonly string[]): readonly unknown[][];
|
|
21
|
+
|
|
22
|
+
export { type IPluginSyncEntry, matchPluginSyncEntries };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/plugin-sdk/sync-map.ts
|
|
21
|
+
var sync_map_exports = {};
|
|
22
|
+
__export(sync_map_exports, {
|
|
23
|
+
matchPluginSyncEntries: () => matchPluginSyncEntries
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(sync_map_exports);
|
|
26
|
+
function matchPluginSyncEntries(entries, tags) {
|
|
27
|
+
if (!entries?.length || tags.length === 0) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
const keys = [];
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
if (!entry.tags?.length || !Array.isArray(entry.queryKey)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const matched = tags.some((tag) => entry.tags.some((pattern) => tagMatchesPattern(tag, pattern)));
|
|
37
|
+
if (!matched) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const serialized = JSON.stringify(entry.queryKey);
|
|
41
|
+
if (seen.has(serialized)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
seen.add(serialized);
|
|
45
|
+
keys.push(entry.queryKey.slice());
|
|
46
|
+
}
|
|
47
|
+
return keys;
|
|
48
|
+
}
|
|
49
|
+
function tagMatchesPattern(tag, pattern) {
|
|
50
|
+
if (pattern.endsWith("*")) {
|
|
51
|
+
return tag.startsWith(pattern.slice(0, -1));
|
|
52
|
+
}
|
|
53
|
+
return tag === pattern;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
matchPluginSyncEntries
|
|
58
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/plugin-sdk/sync-map.ts
|
|
2
|
+
function matchPluginSyncEntries(entries, tags) {
|
|
3
|
+
if (!entries?.length || tags.length === 0) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7
|
+
const keys = [];
|
|
8
|
+
for (const entry of entries) {
|
|
9
|
+
if (!entry.tags?.length || !Array.isArray(entry.queryKey)) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const matched = tags.some((tag) => entry.tags.some((pattern) => tagMatchesPattern(tag, pattern)));
|
|
13
|
+
if (!matched) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const serialized = JSON.stringify(entry.queryKey);
|
|
17
|
+
if (seen.has(serialized)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
seen.add(serialized);
|
|
21
|
+
keys.push(entry.queryKey.slice());
|
|
22
|
+
}
|
|
23
|
+
return keys;
|
|
24
|
+
}
|
|
25
|
+
function tagMatchesPattern(tag, pattern) {
|
|
26
|
+
if (pattern.endsWith("*")) {
|
|
27
|
+
return tag.startsWith(pattern.slice(0, -1));
|
|
28
|
+
}
|
|
29
|
+
return tag === pattern;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
matchPluginSyncEntries
|
|
33
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TStyleName, I as IStyleRegistryEntry, a as IPluginStyleRegistryEntry, b as TStylePlacement, c as TConcretePlatform, d as TStylePlatform } from '../styles.registry-
|
|
2
|
-
export { B as BASE_STYLE_REGISTRY, F as FORM_SECTION_STYLE_NAMES, S as STYLE_REGISTRY, e as TFormSectionStyleName, f as TStyleRegistryKey, _ as _AssertRegistryMatchesStyleName, g as _resetPluginStyleRegistry, h as extendStyleRegistry, i as getMergedStyleRegistry, j as getPluginStyleRegistry } from '../styles.registry-
|
|
1
|
+
import { T as TStyleName, I as IStyleRegistryEntry, a as IPluginStyleRegistryEntry, b as TStylePlacement, c as TConcretePlatform, d as TStylePlatform } from '../styles.registry-B2cyNdo3.mjs';
|
|
2
|
+
export { B as BASE_STYLE_REGISTRY, F as FORM_SECTION_STYLE_NAMES, S as STYLE_REGISTRY, e as TFormSectionStyleName, f as TStyleRegistryKey, _ as _AssertRegistryMatchesStyleName, g as _resetPluginStyleRegistry, h as extendStyleRegistry, i as getMergedStyleRegistry, j as getPluginStyleRegistry } from '../styles.registry-B2cyNdo3.mjs';
|
|
3
3
|
import '../common-qaDIAYS3.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TStyleName, I as IStyleRegistryEntry, a as IPluginStyleRegistryEntry, b as TStylePlacement, c as TConcretePlatform, d as TStylePlatform } from '../styles.registry-
|
|
2
|
-
export { B as BASE_STYLE_REGISTRY, F as FORM_SECTION_STYLE_NAMES, S as STYLE_REGISTRY, e as TFormSectionStyleName, f as TStyleRegistryKey, _ as _AssertRegistryMatchesStyleName, g as _resetPluginStyleRegistry, h as extendStyleRegistry, i as getMergedStyleRegistry, j as getPluginStyleRegistry } from '../styles.registry-
|
|
1
|
+
import { T as TStyleName, I as IStyleRegistryEntry, a as IPluginStyleRegistryEntry, b as TStylePlacement, c as TConcretePlatform, d as TStylePlatform } from '../styles.registry-G_KUYGPv.js';
|
|
2
|
+
export { B as BASE_STYLE_REGISTRY, F as FORM_SECTION_STYLE_NAMES, S as STYLE_REGISTRY, e as TFormSectionStyleName, f as TStyleRegistryKey, _ as _AssertRegistryMatchesStyleName, g as _resetPluginStyleRegistry, h as extendStyleRegistry, i as getMergedStyleRegistry, j as getPluginStyleRegistry } from '../styles.registry-G_KUYGPv.js';
|
|
3
3
|
import '../common-qaDIAYS3.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -835,6 +835,11 @@ interface IFormSubmitData extends IFormResultLegacyFields {
|
|
|
835
835
|
user_authenticated: boolean;
|
|
836
836
|
/** The record's version after the submit (1 for a new record). */
|
|
837
837
|
version: number;
|
|
838
|
+
/**
|
|
839
|
+
* Content the write was based on (`page:<id>@v<n>|draft` or
|
|
840
|
+
* `res:<type>:<id>@v<n>`). Null when unknown.
|
|
841
|
+
*/
|
|
842
|
+
content_ref?: string | null;
|
|
838
843
|
}
|
|
839
844
|
/**
|
|
840
845
|
* Data returned by a successful PUT form update. Mirrors the backend contract
|
|
@@ -848,6 +853,11 @@ interface IFormUpdateData extends IFormResultLegacyFields {
|
|
|
848
853
|
updated_at: string;
|
|
849
854
|
/** The record's version after the update. */
|
|
850
855
|
version: number;
|
|
856
|
+
/**
|
|
857
|
+
* Content the write was based on (`page:<id>@v<n>|draft` or
|
|
858
|
+
* `res:<type>:<id>@v<n>`). Null when unknown.
|
|
859
|
+
*/
|
|
860
|
+
content_ref?: string | null;
|
|
851
861
|
}
|
|
852
862
|
/**
|
|
853
863
|
* Data returned by a successful DELETE form delete. Mirrors the backend contract
|
|
@@ -1007,6 +1017,11 @@ interface IFormListRow extends IFormListRecordAccess {
|
|
|
1007
1017
|
entry_date: string;
|
|
1008
1018
|
/** Send back as `expected_version` when changing the record. */
|
|
1009
1019
|
version: number;
|
|
1020
|
+
/**
|
|
1021
|
+
* Content the write was based on (`page:<id>@v<n>|draft` or
|
|
1022
|
+
* `res:<type>:<id>@v<n>`). Null when unknown (older rows).
|
|
1023
|
+
*/
|
|
1024
|
+
content_ref?: string | null;
|
|
1010
1025
|
/** Exactly the configured columns, by field. */
|
|
1011
1026
|
values: Record<string, TFormListCellValue>;
|
|
1012
1027
|
/**
|
|
@@ -1023,6 +1038,11 @@ interface IFormListSelected extends IFormListRecordAccess {
|
|
|
1023
1038
|
entry_date: string;
|
|
1024
1039
|
/** Send back as `expected_version` when saving, deleting, running an action or restoring. */
|
|
1025
1040
|
version: number;
|
|
1041
|
+
/**
|
|
1042
|
+
* Content the write was based on (`page:<id>@v<n>|draft` or
|
|
1043
|
+
* `res:<type>:<id>@v<n>`). Null when unknown (older rows).
|
|
1044
|
+
*/
|
|
1045
|
+
content_ref?: string | null;
|
|
1026
1046
|
values: Record<string, TFormListCellValue>;
|
|
1027
1047
|
/** The prefill the inline form receives on a page load; null when the caller cannot edit the record. */
|
|
1028
1048
|
form_values: Record<string, unknown> | unknown[] | null;
|
|
@@ -1081,7 +1101,7 @@ interface IFormListQuickActionData {
|
|
|
1081
1101
|
}
|
|
1082
1102
|
type IFormListQuickActionResponse = IBaseApiResponse<IFormListQuickActionData>;
|
|
1083
1103
|
type TDataRevisionOperation = 'create' | 'update' | 'delete' | 'restore' | 'baseline';
|
|
1084
|
-
type TDataRevisionSource = 'form' | 'admin' | 'quick_action' | 'job' | 'import' | 'system';
|
|
1104
|
+
type TDataRevisionSource = 'form' | 'admin' | 'quick_action' | 'job' | 'import' | 'system' | 'plugin';
|
|
1085
1105
|
interface IFormListActor {
|
|
1086
1106
|
id: number;
|
|
1087
1107
|
name: string | null;
|
|
@@ -1099,6 +1119,11 @@ interface IFormListRevision {
|
|
|
1099
1119
|
/** The number of fields the revision changed. */
|
|
1100
1120
|
changed_fields: number;
|
|
1101
1121
|
is_checkpoint: boolean;
|
|
1122
|
+
/**
|
|
1123
|
+
* Content that revision was based on (`page:<id>@v<n>|draft` or
|
|
1124
|
+
* `res:<type>:<id>@v<n>`). Null when unknown (older revisions).
|
|
1125
|
+
*/
|
|
1126
|
+
content_ref?: string | null;
|
|
1102
1127
|
}
|
|
1103
1128
|
/** A file a revision held; `available` is false once the file was erased. */
|
|
1104
1129
|
interface IFormListHistoricalFile {
|