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