@quillmark/wasm 0.133.0 → 0.134.1
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 +355 -0
- package/README.md +19 -76
- package/THIRD_PARTY_LICENSES.md +443 -103
- package/core/wasm.d.ts +521 -390
- package/core/wasm.js +635 -226
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +26 -12
- package/package.json +1 -1
- package/render/wasm.d.ts +534 -406
- package/render/wasm.js +643 -252
- package/render/wasm_bg.wasm +0 -0
- package/render/wasm_bg.wasm.d.ts +26 -13
- package/runtime/runtime.d.ts +89 -121
- package/runtime/runtime.js +53 -136
- package/sbom.cdx.json +337 -542
package/runtime/runtime.js
CHANGED
|
@@ -19,7 +19,8 @@ import initCore, { Quill, Document } from '../core/wasm.js';
|
|
|
19
19
|
// itself), a `node:fs` read under Node, whose `fetch` rejects `file:` URLs.
|
|
20
20
|
// Resolution-time, so `node:fs` never enters a browser graph.
|
|
21
21
|
import { toModuleSource } from '#quillmark-env';
|
|
22
|
-
import { importMarkdown, exportMarkdown, normalize,
|
|
22
|
+
import { importMarkdown, exportMarkdown, normalize, invert, diff } from '../core/wasm.js';
|
|
23
|
+
import { splitBlock, joinBlocks, deleteRange, indent, outdent, wrap, inheritedMarks, mapPos, repair } from '../core/wasm.js';
|
|
23
24
|
import { isInline, isPlain } from '../core/wasm.js';
|
|
24
25
|
import { parseDocPath, formatDocPath, formatDiagnostic } from '../core/wasm.js';
|
|
25
26
|
|
|
@@ -48,9 +49,17 @@ const CORE_SURFACE = Object.freeze({
|
|
|
48
49
|
importMarkdown,
|
|
49
50
|
exportMarkdown,
|
|
50
51
|
normalize,
|
|
51
|
-
|
|
52
|
+
invert,
|
|
53
|
+
diff,
|
|
54
|
+
splitBlock,
|
|
55
|
+
joinBlocks,
|
|
56
|
+
deleteRange,
|
|
57
|
+
indent,
|
|
58
|
+
outdent,
|
|
59
|
+
wrap,
|
|
60
|
+
inheritedMarks,
|
|
52
61
|
mapPos,
|
|
53
|
-
|
|
62
|
+
repair,
|
|
54
63
|
isInline,
|
|
55
64
|
isPlain,
|
|
56
65
|
parseDocPath,
|
|
@@ -321,50 +330,16 @@ function requireLocalQuill(quill, method) {
|
|
|
321
330
|
throw notLocal(quill, method, 'Quill');
|
|
322
331
|
}
|
|
323
332
|
|
|
324
|
-
// WELD_KEYS is the rule `Container::same_weld` owns upstream: which `attrs`
|
|
325
|
-
// entries two adjacent runs must share for the markdown projection to read them
|
|
326
|
-
// as one. `start` is not among them, since CommonMark reads only a list's first
|
|
327
|
-
// number — a subset, which is why every container needs its own entry.
|
|
328
|
-
//
|
|
329
|
-
// Re-spelled here rather than called, because `assignInstances` answers before
|
|
330
|
-
// wasm initializes (`prose/canon/BINDINGS.md` § "WebAssembly"). What holds the
|
|
331
|
-
// two spellings equal is running the rule, not comparing their sources:
|
|
332
|
-
// `runtime.test.js` § "container run boundaries" stamps a pair and re-imports
|
|
333
|
-
// it, where `Content::normalize` re-mints against the Rust predicate. A tag the
|
|
334
|
-
// table omits welds with nothing, so `tests/known_names_drift.rs` pins that
|
|
335
|
-
// every container has an entry.
|
|
336
|
-
|
|
337
|
-
const WELD_KEYS = { list_item: ['ordered'], quote: [] };
|
|
338
|
-
|
|
339
333
|
/**
|
|
340
|
-
*
|
|
341
|
-
* @param {
|
|
342
|
-
* @
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
// A malformed value welds with nothing: answer rather than throw.
|
|
346
|
-
if (typeof a?.container !== 'string' || a.container !== b?.container) return false;
|
|
347
|
-
// `hasOwn`, so a tag colliding with an `Object.prototype` member answers
|
|
348
|
-
// `false` rather than reaching a function.
|
|
349
|
-
if (!Object.hasOwn(WELD_KEYS, a.container)) return false;
|
|
350
|
-
return WELD_KEYS[a.container].every((k) => a.attrs?.[k] === b.attrs?.[k]);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* @param {(import('../core/wasm.js').ContentContainer | null)[]} runs
|
|
355
|
-
* @returns {(import('../core/wasm.js').ContentContainer | null)[]}
|
|
334
|
+
* Throw unless `quill` and `doc` are both THIS copy's.
|
|
335
|
+
* @param {unknown} quill
|
|
336
|
+
* @param {unknown} doc
|
|
337
|
+
* @param {string} method
|
|
338
|
+
* @returns {void}
|
|
356
339
|
*/
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (run == null) {
|
|
361
|
-
prev = null;
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
const instance = prev && weldsWith(prev, run) ? 1 - prev.instance : 0;
|
|
365
|
-
prev = { ...run, instance };
|
|
366
|
-
return prev;
|
|
367
|
-
});
|
|
340
|
+
function requireLocalBind(quill, doc, method) {
|
|
341
|
+
requireLocalQuill(quill, method);
|
|
342
|
+
requireLocalDoc(doc, method);
|
|
368
343
|
}
|
|
369
344
|
|
|
370
345
|
/**
|
|
@@ -751,9 +726,6 @@ export class LiveSession {
|
|
|
751
726
|
get pageCount() {
|
|
752
727
|
return this.#inner.pageCount;
|
|
753
728
|
}
|
|
754
|
-
get backendId() {
|
|
755
|
-
return this.#inner.backendId;
|
|
756
|
-
}
|
|
757
729
|
get warnings() {
|
|
758
730
|
return this.#inner.warnings;
|
|
759
731
|
}
|
|
@@ -856,13 +828,22 @@ export class DocumentWriter {
|
|
|
856
828
|
* @param {Document} doc the document to mutate, held by reference (not owned)
|
|
857
829
|
*/
|
|
858
830
|
constructor(quill, doc) {
|
|
859
|
-
|
|
860
|
-
requireLocalDoc(doc, 'quill.writer(doc)');
|
|
831
|
+
requireLocalBind(quill, doc, 'quill.writer(doc)');
|
|
861
832
|
this.#quill = quill;
|
|
862
833
|
this.#doc = doc;
|
|
863
834
|
}
|
|
864
|
-
|
|
865
|
-
|
|
835
|
+
/**
|
|
836
|
+
* @returns {string}
|
|
837
|
+
*/
|
|
838
|
+
hash() {
|
|
839
|
+
return this.#doc._hash(this.#quill);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* @param {import('../core/wasm.js').Addr | string} addr
|
|
843
|
+
* @returns {string}
|
|
844
|
+
*/
|
|
845
|
+
hashAt(addr) {
|
|
846
|
+
return this.#doc._hashAt(this.#quill, addr);
|
|
866
847
|
}
|
|
867
848
|
/**
|
|
868
849
|
* @param {string} name
|
|
@@ -881,25 +862,28 @@ export class DocumentWriter {
|
|
|
881
862
|
}
|
|
882
863
|
/**
|
|
883
864
|
* @param {string} markdown
|
|
865
|
+
* @param {import('../core/wasm.js').BaseOptions} [opts]
|
|
884
866
|
* @returns {import('../core/wasm.js').Revised}
|
|
885
867
|
*/
|
|
886
|
-
reviseBody(markdown) {
|
|
887
|
-
return this.#doc.
|
|
868
|
+
reviseBody(markdown, opts) {
|
|
869
|
+
return this.#doc._revise({}, markdown, opts);
|
|
888
870
|
}
|
|
889
871
|
/**
|
|
890
872
|
* @param {string} name
|
|
891
873
|
* @param {string} text
|
|
874
|
+
* @param {import('../core/wasm.js').BaseOptions} [opts]
|
|
892
875
|
* @returns {import('../core/wasm.js').Revised}
|
|
893
876
|
*/
|
|
894
|
-
reviseField(name, text) {
|
|
895
|
-
return this.#doc._reviseField(this.#quill, name, text);
|
|
877
|
+
reviseField(name, text, opts) {
|
|
878
|
+
return this.#doc._reviseField(this.#quill, name, text, opts);
|
|
896
879
|
}
|
|
897
880
|
/**
|
|
898
881
|
* @param {string} markdown
|
|
882
|
+
* @param {import('../core/wasm.js').BaseOptions} [opts]
|
|
899
883
|
* @returns {import('../core/wasm.js').DocumentRevised}
|
|
900
884
|
*/
|
|
901
|
-
reviseDocument(markdown) {
|
|
902
|
-
return this.#doc._reviseDocument(this.#quill, markdown);
|
|
885
|
+
reviseDocument(markdown, opts) {
|
|
886
|
+
return this.#doc._reviseDocument(this.#quill, markdown, opts);
|
|
903
887
|
}
|
|
904
888
|
/**
|
|
905
889
|
* @param {string} kind
|
|
@@ -937,20 +921,17 @@ export class CardWriter {
|
|
|
937
921
|
* @param {number} index the composable card's index
|
|
938
922
|
*/
|
|
939
923
|
constructor(quill, doc, index) {
|
|
940
|
-
|
|
941
|
-
requireLocalDoc(doc, 'writer.card(index)');
|
|
924
|
+
requireLocalBind(quill, doc, 'writer.card(index)');
|
|
942
925
|
this.#quill = quill;
|
|
943
926
|
this.#doc = doc;
|
|
944
927
|
this.#index = index;
|
|
945
928
|
}
|
|
946
|
-
get index() {
|
|
947
|
-
return this.#index;
|
|
948
|
-
}
|
|
949
929
|
/**
|
|
930
|
+
* @param {string} [field]
|
|
950
931
|
* @returns {string}
|
|
951
932
|
*/
|
|
952
|
-
|
|
953
|
-
return this.#doc.
|
|
933
|
+
hashAt(field) {
|
|
934
|
+
return this.#doc._hashAt(this.#quill, { card: this.#index, field });
|
|
954
935
|
}
|
|
955
936
|
/**
|
|
956
937
|
* @param {string} name
|
|
@@ -969,18 +950,20 @@ export class CardWriter {
|
|
|
969
950
|
}
|
|
970
951
|
/**
|
|
971
952
|
* @param {string} markdown
|
|
953
|
+
* @param {import('../core/wasm.js').BaseOptions} [opts]
|
|
972
954
|
* @returns {import('../core/wasm.js').Revised}
|
|
973
955
|
*/
|
|
974
|
-
reviseBody(markdown) {
|
|
975
|
-
return this.#doc.
|
|
956
|
+
reviseBody(markdown, opts) {
|
|
957
|
+
return this.#doc._revise({ card: this.#index }, markdown, opts);
|
|
976
958
|
}
|
|
977
959
|
/**
|
|
978
960
|
* @param {string} name
|
|
979
961
|
* @param {string} text
|
|
962
|
+
* @param {import('../core/wasm.js').BaseOptions} [opts]
|
|
980
963
|
* @returns {import('../core/wasm.js').Revised}
|
|
981
964
|
*/
|
|
982
|
-
reviseField(name, text) {
|
|
983
|
-
return this.#doc._reviseField(this.#quill, { card: this.#index, field: name }, text);
|
|
965
|
+
reviseField(name, text, opts) {
|
|
966
|
+
return this.#doc._reviseField(this.#quill, { card: this.#index, field: name }, text, opts);
|
|
984
967
|
}
|
|
985
968
|
}
|
|
986
969
|
|
|
@@ -1008,14 +991,10 @@ export class DocumentReader {
|
|
|
1008
991
|
* @param {Document} doc the document to read, held by reference (not owned)
|
|
1009
992
|
*/
|
|
1010
993
|
constructor(quill, doc) {
|
|
1011
|
-
|
|
1012
|
-
requireLocalDoc(doc, 'quill.reader(doc)');
|
|
994
|
+
requireLocalBind(quill, doc, 'quill.reader(doc)');
|
|
1013
995
|
this.#quill = quill;
|
|
1014
996
|
this.#doc = doc;
|
|
1015
997
|
}
|
|
1016
|
-
get document() {
|
|
1017
|
-
return this.#doc;
|
|
1018
|
-
}
|
|
1019
998
|
/**
|
|
1020
999
|
* @param {import('../core/wasm.js').Addr | string} addr
|
|
1021
1000
|
* @returns {unknown}
|
|
@@ -1051,68 +1030,6 @@ export class DocumentReader {
|
|
|
1051
1030
|
resolve(today) {
|
|
1052
1031
|
return this.#quill._resolve(this.#doc, today);
|
|
1053
1032
|
}
|
|
1054
|
-
/**
|
|
1055
|
-
* @param {number} index
|
|
1056
|
-
* @returns {CardReader}
|
|
1057
|
-
*/
|
|
1058
|
-
card(index) {
|
|
1059
|
-
return new CardReader(this.#quill, this.#doc, index);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
export class CardReader {
|
|
1064
|
-
#quill;
|
|
1065
|
-
#doc;
|
|
1066
|
-
#index;
|
|
1067
|
-
/**
|
|
1068
|
-
* @param {Quill} quill the schema source
|
|
1069
|
-
* @param {Document} doc the document to read, held by reference (not owned)
|
|
1070
|
-
* @param {number} index the composable card's index
|
|
1071
|
-
*/
|
|
1072
|
-
constructor(quill, doc, index) {
|
|
1073
|
-
requireLocalQuill(quill, 'reader.card(index)');
|
|
1074
|
-
requireLocalDoc(doc, 'reader.card(index)');
|
|
1075
|
-
this.#quill = quill;
|
|
1076
|
-
this.#doc = doc;
|
|
1077
|
-
this.#index = index;
|
|
1078
|
-
}
|
|
1079
|
-
get index() {
|
|
1080
|
-
return this.#index;
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* @returns {string}
|
|
1084
|
-
*/
|
|
1085
|
-
get kind() {
|
|
1086
|
-
return this.#doc.card(this.#index).kind;
|
|
1087
|
-
}
|
|
1088
|
-
/**
|
|
1089
|
-
* @param {string} name
|
|
1090
|
-
* @returns {unknown}
|
|
1091
|
-
*/
|
|
1092
|
-
get(name) {
|
|
1093
|
-
return this.#doc._readerGet(this.#quill, { card: this.#index, field: name });
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
* @param {string} name
|
|
1097
|
-
* @returns {import('../core/wasm.js').Content | undefined}
|
|
1098
|
-
*/
|
|
1099
|
-
getContent(name) {
|
|
1100
|
-
return this.#doc._readerGetContent(this.#quill, { card: this.#index, field: name });
|
|
1101
|
-
}
|
|
1102
|
-
/**
|
|
1103
|
-
* @param {string} name
|
|
1104
|
-
* @param {import('../core/wasm.js').PathStep[]} path
|
|
1105
|
-
* @returns {import('../core/wasm.js').Content | undefined}
|
|
1106
|
-
*/
|
|
1107
|
-
getContentAt(name, path) {
|
|
1108
|
-
return this.#doc._readerGetContentAt(this.#quill, { card: this.#index, field: name }, path);
|
|
1109
|
-
}
|
|
1110
|
-
/**
|
|
1111
|
-
* @returns {string}
|
|
1112
|
-
*/
|
|
1113
|
-
bodyMarkdown() {
|
|
1114
|
-
return this.#doc._readerGet(this.#quill, { card: this.#index });
|
|
1115
|
-
}
|
|
1116
1033
|
}
|
|
1117
1034
|
|
|
1118
1035
|
// Patched onto the same re-exported `Quill` prototype as `writer`.
|