sdoc-editor-cli 0.9.2 → 0.10.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/README.md +467 -467
- package/bin/sdoc.js +0 -0
- package/dist/examples/operations/delete-block.json +17 -17
- package/dist/examples/operations/delete-section.json +12 -12
- package/dist/examples/operations/insert-block.json +19 -19
- package/dist/examples/operations/insert-section.json +21 -21
- package/dist/examples/operations/move-block.json +21 -21
- package/dist/examples/operations/move-section.json +16 -16
- package/dist/examples/operations/rename-block-id.json +13 -13
- package/dist/examples/operations/rename-heading.json +13 -13
- package/dist/examples/operations/replace-block.json +21 -21
- package/dist/examples/operations/set-document-title.json +17 -17
- package/dist/examples/operations/set-heading-level.json +13 -13
- package/dist/examples/operations/update-block-attrs.json +13 -13
- package/dist/examples/operations/update-document-metadata.json +15 -15
- package/dist/examples/operations/update-document-settings.json +16 -16
- package/dist/schemas/sdoc.operations.schema.json +385 -385
- package/dist/schemas/sdoc.schema.json +559 -559
- package/dist/sdoc.js +299 -185
- package/package.json +30 -30
package/dist/sdoc.js
CHANGED
|
@@ -658,6 +658,156 @@ __export(operations_exports, {
|
|
|
658
658
|
validateDocumentBytes: () => validateDocumentBytes
|
|
659
659
|
});
|
|
660
660
|
|
|
661
|
+
// ../shared/document/operations/sha256.ts
|
|
662
|
+
var K = [
|
|
663
|
+
1116352408,
|
|
664
|
+
1899447441,
|
|
665
|
+
3049323471,
|
|
666
|
+
3921009573,
|
|
667
|
+
961987163,
|
|
668
|
+
1508970993,
|
|
669
|
+
2453635748,
|
|
670
|
+
2870763221,
|
|
671
|
+
3624381080,
|
|
672
|
+
310598401,
|
|
673
|
+
607225278,
|
|
674
|
+
1426881987,
|
|
675
|
+
1925078388,
|
|
676
|
+
2162078206,
|
|
677
|
+
2614888103,
|
|
678
|
+
3248222580,
|
|
679
|
+
3835390401,
|
|
680
|
+
4022224774,
|
|
681
|
+
264347078,
|
|
682
|
+
604807628,
|
|
683
|
+
770255983,
|
|
684
|
+
1249150122,
|
|
685
|
+
1555081692,
|
|
686
|
+
1996064986,
|
|
687
|
+
2554220882,
|
|
688
|
+
2821834349,
|
|
689
|
+
2952996808,
|
|
690
|
+
3210313671,
|
|
691
|
+
3336571891,
|
|
692
|
+
3584528711,
|
|
693
|
+
113926993,
|
|
694
|
+
338241895,
|
|
695
|
+
666307205,
|
|
696
|
+
773529912,
|
|
697
|
+
1294757372,
|
|
698
|
+
1396182291,
|
|
699
|
+
1695183700,
|
|
700
|
+
1986661051,
|
|
701
|
+
2177026350,
|
|
702
|
+
2456956037,
|
|
703
|
+
2730485921,
|
|
704
|
+
2820302411,
|
|
705
|
+
3259730800,
|
|
706
|
+
3345764771,
|
|
707
|
+
3516065817,
|
|
708
|
+
3600352804,
|
|
709
|
+
4094571909,
|
|
710
|
+
275423344,
|
|
711
|
+
430227734,
|
|
712
|
+
506948616,
|
|
713
|
+
659060556,
|
|
714
|
+
883997877,
|
|
715
|
+
958139571,
|
|
716
|
+
1322822218,
|
|
717
|
+
1537002063,
|
|
718
|
+
1747873779,
|
|
719
|
+
1955562222,
|
|
720
|
+
2024104815,
|
|
721
|
+
2227730452,
|
|
722
|
+
2361852424,
|
|
723
|
+
2428436474,
|
|
724
|
+
2756734187,
|
|
725
|
+
3204031479,
|
|
726
|
+
3329325298
|
|
727
|
+
];
|
|
728
|
+
function encodeUtf8(value) {
|
|
729
|
+
const bytes = [];
|
|
730
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
731
|
+
let code = value.charCodeAt(index);
|
|
732
|
+
if (code >= 55296 && code <= 56319 && index + 1 < value.length) {
|
|
733
|
+
const low = value.charCodeAt(index + 1);
|
|
734
|
+
if (low >= 56320 && low <= 57343) {
|
|
735
|
+
code = 65536 + (code - 55296 << 10) + low - 56320;
|
|
736
|
+
index += 1;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (code < 128) bytes.push(code);
|
|
740
|
+
else if (code < 2048) bytes.push(192 | code >> 6, 128 | code & 63);
|
|
741
|
+
else if (code < 65536) {
|
|
742
|
+
bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
|
|
743
|
+
} else {
|
|
744
|
+
bytes.push(
|
|
745
|
+
240 | code >> 18,
|
|
746
|
+
128 | code >> 12 & 63,
|
|
747
|
+
128 | code >> 6 & 63,
|
|
748
|
+
128 | code & 63
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return new Uint8Array(bytes);
|
|
753
|
+
}
|
|
754
|
+
function decodeUtf8(input) {
|
|
755
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(input);
|
|
756
|
+
}
|
|
757
|
+
var rotate = (value, bits) => value >>> bits | value << 32 - bits;
|
|
758
|
+
function computeRevision(bytes) {
|
|
759
|
+
const source = typeof bytes === "string" ? encodeUtf8(bytes) : bytes;
|
|
760
|
+
const bitLength = source.length * 8;
|
|
761
|
+
const paddedLength = Math.ceil((source.length + 9) / 64) * 64;
|
|
762
|
+
const data = new Uint8Array(paddedLength);
|
|
763
|
+
data.set(source);
|
|
764
|
+
data[source.length] = 128;
|
|
765
|
+
const view = new DataView(data.buffer);
|
|
766
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
767
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
768
|
+
const hash = new Uint32Array([
|
|
769
|
+
1779033703,
|
|
770
|
+
3144134277,
|
|
771
|
+
1013904242,
|
|
772
|
+
2773480762,
|
|
773
|
+
1359893119,
|
|
774
|
+
2600822924,
|
|
775
|
+
528734635,
|
|
776
|
+
1541459225
|
|
777
|
+
]);
|
|
778
|
+
const words = new Uint32Array(64);
|
|
779
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
780
|
+
for (let index = 0; index < 16; index += 1) words[index] = view.getUint32(offset + index * 4);
|
|
781
|
+
for (let index = 16; index < 64; index += 1) {
|
|
782
|
+
const a2 = words[index - 15];
|
|
783
|
+
const b2 = words[index - 2];
|
|
784
|
+
words[index] = words[index - 16] + (rotate(a2, 7) ^ rotate(a2, 18) ^ a2 >>> 3) + words[index - 7] + (rotate(b2, 17) ^ rotate(b2, 19) ^ b2 >>> 10) >>> 0;
|
|
785
|
+
}
|
|
786
|
+
let [a, b, c, d, e, f, g, h] = hash;
|
|
787
|
+
for (let index = 0; index < 64; index += 1) {
|
|
788
|
+
const t1 = h + (rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25)) + (e & f ^ ~e & g) + K[index] + words[index] >>> 0;
|
|
789
|
+
const t2 = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
790
|
+
h = g;
|
|
791
|
+
g = f;
|
|
792
|
+
f = e;
|
|
793
|
+
e = d + t1 >>> 0;
|
|
794
|
+
d = c;
|
|
795
|
+
c = b;
|
|
796
|
+
b = a;
|
|
797
|
+
a = t1 + t2 >>> 0;
|
|
798
|
+
}
|
|
799
|
+
hash[0] = hash[0] + a >>> 0;
|
|
800
|
+
hash[1] = hash[1] + b >>> 0;
|
|
801
|
+
hash[2] = hash[2] + c >>> 0;
|
|
802
|
+
hash[3] = hash[3] + d >>> 0;
|
|
803
|
+
hash[4] = hash[4] + e >>> 0;
|
|
804
|
+
hash[5] = hash[5] + f >>> 0;
|
|
805
|
+
hash[6] = hash[6] + g >>> 0;
|
|
806
|
+
hash[7] = hash[7] + h >>> 0;
|
|
807
|
+
}
|
|
808
|
+
return `sha256:${Array.from(hash, (word) => word.toString(16).padStart(8, "0")).join("")}`;
|
|
809
|
+
}
|
|
810
|
+
|
|
661
811
|
// ../shared/settingsResolver.ts
|
|
662
812
|
var CAPTION_PRESETS = {
|
|
663
813
|
ieee: {
|
|
@@ -709,29 +859,57 @@ function toRoman(num) {
|
|
|
709
859
|
}
|
|
710
860
|
return result;
|
|
711
861
|
}
|
|
712
|
-
var
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
862
|
+
var setting = (defaultValue, appliesTo) => ({
|
|
863
|
+
defaultValue,
|
|
864
|
+
appliesTo
|
|
865
|
+
});
|
|
866
|
+
var ALL_CONTENT_TARGETS = [
|
|
867
|
+
"editor-view",
|
|
868
|
+
"html",
|
|
869
|
+
"pdf",
|
|
870
|
+
"markdown",
|
|
871
|
+
"asciidoc",
|
|
872
|
+
"slides"
|
|
873
|
+
];
|
|
874
|
+
var VISUAL_DOCUMENT_TARGETS = [
|
|
875
|
+
"editor-view",
|
|
876
|
+
"html",
|
|
877
|
+
"pdf"
|
|
878
|
+
];
|
|
879
|
+
var ALL_EXPORT_TARGETS = [
|
|
880
|
+
"html",
|
|
881
|
+
"pdf",
|
|
882
|
+
"markdown",
|
|
883
|
+
"asciidoc",
|
|
884
|
+
"slides"
|
|
885
|
+
];
|
|
886
|
+
var DOCUMENT_SETTING_REGISTRY = {
|
|
887
|
+
headingNumbering: setting(true, ALL_CONTENT_TARGETS),
|
|
888
|
+
headingStartNumber: setting(1, ALL_CONTENT_TARGETS),
|
|
889
|
+
headingDecoration: setting(true, VISUAL_DOCUMENT_TARGETS),
|
|
890
|
+
headingH1Color: setting("#2563EB", VISUAL_DOCUMENT_TARGETS),
|
|
891
|
+
headingH2Color: setting("#2563EB", VISUAL_DOCUMENT_TARGETS),
|
|
892
|
+
headingH3Color: setting("#2563EB", VISUAL_DOCUMENT_TARGETS),
|
|
893
|
+
headingH4Color: setting("#2563EB", VISUAL_DOCUMENT_TARGETS),
|
|
894
|
+
headingH5Color: setting("#2563EB", VISUAL_DOCUMENT_TARGETS),
|
|
895
|
+
headingH6Color: setting("#2563EB", VISUAL_DOCUMENT_TARGETS),
|
|
896
|
+
captionStyle: setting("modern", ALL_CONTENT_TARGETS),
|
|
897
|
+
captionNumbering: setting("sequential", ALL_CONTENT_TARGETS),
|
|
898
|
+
equationNumbering: setting("sequential", ALL_CONTENT_TARGETS),
|
|
899
|
+
crossRefIncludeCaption: setting(false, ALL_CONTENT_TARGETS),
|
|
900
|
+
slideCssPath: setting("", ["slides"]),
|
|
901
|
+
htmlCssPath: setting("", ["html", "pdf"]),
|
|
902
|
+
pdfScale: setting(70, ["pdf"]),
|
|
903
|
+
selfContained: setting("images-only", ["html", "pdf", "slides"]),
|
|
904
|
+
slideBreakLevel: setting("h1-only", ["slides"]),
|
|
905
|
+
slideTransition: setting("none", ["slides"]),
|
|
906
|
+
showTitleSlide: setting(true, ["slides"]),
|
|
907
|
+
outputDir: setting("", ALL_EXPORT_TARGETS)
|
|
734
908
|
};
|
|
909
|
+
var DOCUMENT_SETTING_KEYS = Object.keys(DOCUMENT_SETTING_REGISTRY);
|
|
910
|
+
var SETTINGS_DEFAULTS = Object.freeze(Object.fromEntries(
|
|
911
|
+
DOCUMENT_SETTING_KEYS.map((key) => [key, DOCUMENT_SETTING_REGISTRY[key].defaultValue])
|
|
912
|
+
));
|
|
735
913
|
var EDITOR_SETTINGS_DEFAULTS = {
|
|
736
914
|
captionStyle: SETTINGS_DEFAULTS.captionStyle,
|
|
737
915
|
imageCaptionPrefix: CAPTION_PRESETS.modern.figurePrefix,
|
|
@@ -762,19 +940,105 @@ var EDITOR_SETTINGS_DEFAULTS = {
|
|
|
762
940
|
outputDir: SETTINGS_DEFAULTS.outputDir
|
|
763
941
|
};
|
|
764
942
|
function resolveSettings(docSettings, externalDefaults) {
|
|
765
|
-
return {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
};
|
|
943
|
+
return { ...resolveDocumentSettingsSnapshot({
|
|
944
|
+
context: "editor",
|
|
945
|
+
documentSettings: docSettings,
|
|
946
|
+
hostSettings: externalDefaults
|
|
947
|
+
}).values };
|
|
948
|
+
}
|
|
949
|
+
var SOURCE_METADATA = {
|
|
950
|
+
document: { scope: "document", portability: "portable" },
|
|
951
|
+
"book-profile": { scope: "book", portability: "portable" },
|
|
952
|
+
host: { scope: "host", portability: "host-local" },
|
|
953
|
+
"built-in": { scope: "product", portability: "portable" },
|
|
954
|
+
"temporary-view": { scope: "session", portability: "session-only" }
|
|
955
|
+
};
|
|
956
|
+
function getDefinedSetting(settings, key) {
|
|
957
|
+
const value = settings?.[key];
|
|
958
|
+
return value === void 0 ? void 0 : value;
|
|
959
|
+
}
|
|
960
|
+
function getTemporaryViewValue(preferences, key) {
|
|
961
|
+
if (key !== "headingNumbering" && key !== "headingDecoration") return void 0;
|
|
962
|
+
const preference = preferences?.[key];
|
|
963
|
+
if (preference === "show") return true;
|
|
964
|
+
if (preference === "hide") return false;
|
|
965
|
+
return void 0;
|
|
770
966
|
}
|
|
771
|
-
function
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
967
|
+
function createResolvedEntry(key, value, source) {
|
|
968
|
+
return Object.freeze({
|
|
969
|
+
value,
|
|
970
|
+
source,
|
|
971
|
+
...SOURCE_METADATA[source],
|
|
972
|
+
appliesTo: DOCUMENT_SETTING_REGISTRY[key].appliesTo
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
function resolveDocumentSettingsSnapshot(options) {
|
|
976
|
+
const valueRecord = {};
|
|
977
|
+
const entryRecord = {};
|
|
978
|
+
for (const key of DOCUMENT_SETTING_KEYS) {
|
|
979
|
+
let value = DOCUMENT_SETTING_REGISTRY[key].defaultValue;
|
|
980
|
+
let source = "built-in";
|
|
981
|
+
if (options.context === "book") {
|
|
982
|
+
const profileValue = getDefinedSetting(options.bookProfileSettings, key);
|
|
983
|
+
if (profileValue !== void 0) {
|
|
984
|
+
value = profileValue;
|
|
985
|
+
source = "book-profile";
|
|
986
|
+
}
|
|
987
|
+
} else {
|
|
988
|
+
if (options.context === "editor") {
|
|
989
|
+
const hostValue = getDefinedSetting(options.hostSettings, key);
|
|
990
|
+
if (hostValue !== void 0) {
|
|
991
|
+
value = hostValue;
|
|
992
|
+
source = "host";
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
const documentValue = getDefinedSetting(options.documentSettings, key);
|
|
996
|
+
if (documentValue !== void 0) {
|
|
997
|
+
value = documentValue;
|
|
998
|
+
source = "document";
|
|
999
|
+
}
|
|
1000
|
+
if (options.context === "editor") {
|
|
1001
|
+
const temporaryValue = getTemporaryViewValue(options.temporaryView, key);
|
|
1002
|
+
if (temporaryValue !== void 0) {
|
|
1003
|
+
value = temporaryValue;
|
|
1004
|
+
source = "temporary-view";
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
valueRecord[key] = value;
|
|
1009
|
+
entryRecord[key] = createResolvedEntry(key, value, source);
|
|
1010
|
+
}
|
|
1011
|
+
const values = Object.freeze(valueRecord);
|
|
1012
|
+
const entries = Object.freeze(entryRecord);
|
|
1013
|
+
const diagnostics2 = options.context === "book" ? Object.freeze((options.chapterSettings ?? []).flatMap(({ documentPath, settings }) => DOCUMENT_SETTING_KEYS.flatMap((key) => {
|
|
1014
|
+
const chapterValue = getDefinedSetting(settings, key);
|
|
1015
|
+
if (chapterValue === void 0 || Object.is(chapterValue, values[key])) return [];
|
|
1016
|
+
return [Object.freeze({
|
|
1017
|
+
severity: "warning",
|
|
1018
|
+
code: "CHAPTER_SETTING_OVERRIDDEN",
|
|
1019
|
+
key,
|
|
1020
|
+
documentPath,
|
|
1021
|
+
message: `${documentPath} stores ${key}, but the Book publish profile overrides it.`
|
|
1022
|
+
})];
|
|
1023
|
+
}))) : Object.freeze([]);
|
|
1024
|
+
const fingerprint = computeRevision(JSON.stringify({
|
|
1025
|
+
version: "1",
|
|
1026
|
+
context: options.context,
|
|
1027
|
+
entries: DOCUMENT_SETTING_KEYS.map((key) => ({
|
|
1028
|
+
key,
|
|
1029
|
+
value: entries[key].value,
|
|
1030
|
+
source: entries[key].source
|
|
1031
|
+
})),
|
|
1032
|
+
diagnostics: diagnostics2
|
|
1033
|
+
}));
|
|
1034
|
+
return Object.freeze({
|
|
1035
|
+
version: "1",
|
|
1036
|
+
context: options.context,
|
|
1037
|
+
values,
|
|
1038
|
+
entries,
|
|
1039
|
+
diagnostics: diagnostics2,
|
|
1040
|
+
fingerprint
|
|
1041
|
+
});
|
|
778
1042
|
}
|
|
779
1043
|
|
|
780
1044
|
// ../shared/document/migrations.ts
|
|
@@ -5322,156 +5586,6 @@ function parsePortableAssetPath(value, expectedDirectory) {
|
|
|
5322
5586
|
};
|
|
5323
5587
|
}
|
|
5324
5588
|
|
|
5325
|
-
// ../shared/document/operations/sha256.ts
|
|
5326
|
-
var K = [
|
|
5327
|
-
1116352408,
|
|
5328
|
-
1899447441,
|
|
5329
|
-
3049323471,
|
|
5330
|
-
3921009573,
|
|
5331
|
-
961987163,
|
|
5332
|
-
1508970993,
|
|
5333
|
-
2453635748,
|
|
5334
|
-
2870763221,
|
|
5335
|
-
3624381080,
|
|
5336
|
-
310598401,
|
|
5337
|
-
607225278,
|
|
5338
|
-
1426881987,
|
|
5339
|
-
1925078388,
|
|
5340
|
-
2162078206,
|
|
5341
|
-
2614888103,
|
|
5342
|
-
3248222580,
|
|
5343
|
-
3835390401,
|
|
5344
|
-
4022224774,
|
|
5345
|
-
264347078,
|
|
5346
|
-
604807628,
|
|
5347
|
-
770255983,
|
|
5348
|
-
1249150122,
|
|
5349
|
-
1555081692,
|
|
5350
|
-
1996064986,
|
|
5351
|
-
2554220882,
|
|
5352
|
-
2821834349,
|
|
5353
|
-
2952996808,
|
|
5354
|
-
3210313671,
|
|
5355
|
-
3336571891,
|
|
5356
|
-
3584528711,
|
|
5357
|
-
113926993,
|
|
5358
|
-
338241895,
|
|
5359
|
-
666307205,
|
|
5360
|
-
773529912,
|
|
5361
|
-
1294757372,
|
|
5362
|
-
1396182291,
|
|
5363
|
-
1695183700,
|
|
5364
|
-
1986661051,
|
|
5365
|
-
2177026350,
|
|
5366
|
-
2456956037,
|
|
5367
|
-
2730485921,
|
|
5368
|
-
2820302411,
|
|
5369
|
-
3259730800,
|
|
5370
|
-
3345764771,
|
|
5371
|
-
3516065817,
|
|
5372
|
-
3600352804,
|
|
5373
|
-
4094571909,
|
|
5374
|
-
275423344,
|
|
5375
|
-
430227734,
|
|
5376
|
-
506948616,
|
|
5377
|
-
659060556,
|
|
5378
|
-
883997877,
|
|
5379
|
-
958139571,
|
|
5380
|
-
1322822218,
|
|
5381
|
-
1537002063,
|
|
5382
|
-
1747873779,
|
|
5383
|
-
1955562222,
|
|
5384
|
-
2024104815,
|
|
5385
|
-
2227730452,
|
|
5386
|
-
2361852424,
|
|
5387
|
-
2428436474,
|
|
5388
|
-
2756734187,
|
|
5389
|
-
3204031479,
|
|
5390
|
-
3329325298
|
|
5391
|
-
];
|
|
5392
|
-
function encodeUtf8(value) {
|
|
5393
|
-
const bytes = [];
|
|
5394
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
5395
|
-
let code = value.charCodeAt(index);
|
|
5396
|
-
if (code >= 55296 && code <= 56319 && index + 1 < value.length) {
|
|
5397
|
-
const low = value.charCodeAt(index + 1);
|
|
5398
|
-
if (low >= 56320 && low <= 57343) {
|
|
5399
|
-
code = 65536 + (code - 55296 << 10) + low - 56320;
|
|
5400
|
-
index += 1;
|
|
5401
|
-
}
|
|
5402
|
-
}
|
|
5403
|
-
if (code < 128) bytes.push(code);
|
|
5404
|
-
else if (code < 2048) bytes.push(192 | code >> 6, 128 | code & 63);
|
|
5405
|
-
else if (code < 65536) {
|
|
5406
|
-
bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
|
|
5407
|
-
} else {
|
|
5408
|
-
bytes.push(
|
|
5409
|
-
240 | code >> 18,
|
|
5410
|
-
128 | code >> 12 & 63,
|
|
5411
|
-
128 | code >> 6 & 63,
|
|
5412
|
-
128 | code & 63
|
|
5413
|
-
);
|
|
5414
|
-
}
|
|
5415
|
-
}
|
|
5416
|
-
return new Uint8Array(bytes);
|
|
5417
|
-
}
|
|
5418
|
-
function decodeUtf8(input) {
|
|
5419
|
-
return new TextDecoder("utf-8", { fatal: true }).decode(input);
|
|
5420
|
-
}
|
|
5421
|
-
var rotate = (value, bits) => value >>> bits | value << 32 - bits;
|
|
5422
|
-
function computeRevision(bytes) {
|
|
5423
|
-
const source = typeof bytes === "string" ? encodeUtf8(bytes) : bytes;
|
|
5424
|
-
const bitLength = source.length * 8;
|
|
5425
|
-
const paddedLength = Math.ceil((source.length + 9) / 64) * 64;
|
|
5426
|
-
const data = new Uint8Array(paddedLength);
|
|
5427
|
-
data.set(source);
|
|
5428
|
-
data[source.length] = 128;
|
|
5429
|
-
const view = new DataView(data.buffer);
|
|
5430
|
-
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
5431
|
-
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
5432
|
-
const hash = new Uint32Array([
|
|
5433
|
-
1779033703,
|
|
5434
|
-
3144134277,
|
|
5435
|
-
1013904242,
|
|
5436
|
-
2773480762,
|
|
5437
|
-
1359893119,
|
|
5438
|
-
2600822924,
|
|
5439
|
-
528734635,
|
|
5440
|
-
1541459225
|
|
5441
|
-
]);
|
|
5442
|
-
const words = new Uint32Array(64);
|
|
5443
|
-
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
5444
|
-
for (let index = 0; index < 16; index += 1) words[index] = view.getUint32(offset + index * 4);
|
|
5445
|
-
for (let index = 16; index < 64; index += 1) {
|
|
5446
|
-
const a2 = words[index - 15];
|
|
5447
|
-
const b2 = words[index - 2];
|
|
5448
|
-
words[index] = words[index - 16] + (rotate(a2, 7) ^ rotate(a2, 18) ^ a2 >>> 3) + words[index - 7] + (rotate(b2, 17) ^ rotate(b2, 19) ^ b2 >>> 10) >>> 0;
|
|
5449
|
-
}
|
|
5450
|
-
let [a, b, c, d, e, f, g, h] = hash;
|
|
5451
|
-
for (let index = 0; index < 64; index += 1) {
|
|
5452
|
-
const t1 = h + (rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25)) + (e & f ^ ~e & g) + K[index] + words[index] >>> 0;
|
|
5453
|
-
const t2 = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
5454
|
-
h = g;
|
|
5455
|
-
g = f;
|
|
5456
|
-
f = e;
|
|
5457
|
-
e = d + t1 >>> 0;
|
|
5458
|
-
d = c;
|
|
5459
|
-
c = b;
|
|
5460
|
-
b = a;
|
|
5461
|
-
a = t1 + t2 >>> 0;
|
|
5462
|
-
}
|
|
5463
|
-
hash[0] = hash[0] + a >>> 0;
|
|
5464
|
-
hash[1] = hash[1] + b >>> 0;
|
|
5465
|
-
hash[2] = hash[2] + c >>> 0;
|
|
5466
|
-
hash[3] = hash[3] + d >>> 0;
|
|
5467
|
-
hash[4] = hash[4] + e >>> 0;
|
|
5468
|
-
hash[5] = hash[5] + f >>> 0;
|
|
5469
|
-
hash[6] = hash[6] + g >>> 0;
|
|
5470
|
-
hash[7] = hash[7] + h >>> 0;
|
|
5471
|
-
}
|
|
5472
|
-
return `sha256:${Array.from(hash, (word) => word.toString(16).padStart(8, "0")).join("")}`;
|
|
5473
|
-
}
|
|
5474
|
-
|
|
5475
5589
|
// ../shared/document/operations/readCursor.ts
|
|
5476
5590
|
var MAX_READ_CURSOR_LENGTH = 4096;
|
|
5477
5591
|
var BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
@@ -8325,7 +8439,7 @@ async function createDocumentPlan(documentPath, options = {}) {
|
|
|
8325
8439
|
}
|
|
8326
8440
|
|
|
8327
8441
|
// src/main.ts
|
|
8328
|
-
var VERSION = true ? "0.
|
|
8442
|
+
var VERSION = true ? "0.10.1" : packageMetadata.version;
|
|
8329
8443
|
var DEFAULT_DEPENDENCIES = {
|
|
8330
8444
|
replaceDocument: atomicReplace,
|
|
8331
8445
|
createDocument: atomicCreate
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sdoc-editor-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Preview-first command line operations for Structured Doc Editor documents",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"sdoc": "bin/sdoc.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"bin/sdoc.js",
|
|
11
|
-
"dist/sdoc.js",
|
|
12
|
-
"dist/schemas/*.json",
|
|
13
|
-
"dist/examples/operations/*.json",
|
|
14
|
-
"README.md",
|
|
15
|
-
"LICENSE"
|
|
16
|
-
],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=22.22.2"
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "node build.mjs",
|
|
22
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
23
|
-
"test": "vitest run --config vitest.config.ts"
|
|
24
|
-
},
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/SWBaek/sdoc-editor.git"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "sdoc-editor-cli",
|
|
3
|
+
"version": "0.10.1",
|
|
4
|
+
"description": "Preview-first command line operations for Structured Doc Editor documents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sdoc": "bin/sdoc.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/sdoc.js",
|
|
11
|
+
"dist/sdoc.js",
|
|
12
|
+
"dist/schemas/*.json",
|
|
13
|
+
"dist/examples/operations/*.json",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.22.2"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "node build.mjs",
|
|
22
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
23
|
+
"test": "vitest run --config vitest.config.ts"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/SWBaek/sdoc-editor.git"
|
|
29
|
+
}
|
|
30
|
+
}
|