markdown-design-doc-viewer-embed 1.5.3 → 1.5.5
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.ja.md +89 -3
- package/README.md +89 -3
- package/export.js +16 -0
- package/index.js +1887 -1214
- package/package.json +5 -1
- package/react.js +78 -10
- package/types/embed/designDocList.d.ts +39 -0
- package/types/embed/export.d.ts +4 -0
- package/types/embed/react.d.ts +13 -2
- package/types/embed/viewer.d.ts +58 -2
- package/types/src/shared/l10n.d.ts +10 -0
- package/viewer.css +9 -0
package/index.js
CHANGED
|
@@ -14587,6 +14587,248 @@ function translatorFor(messages) {
|
|
|
14587
14587
|
return (message, ...args) => formatMessage(messages[message] ?? message, ...args);
|
|
14588
14588
|
}
|
|
14589
14589
|
|
|
14590
|
+
// src/shared/protocol.ts
|
|
14591
|
+
var WEBVIEW_TITLES = {
|
|
14592
|
+
"splitter-title": "Drag to resize, double-click to reset",
|
|
14593
|
+
"hide-warnings-title": "Hide warnings",
|
|
14594
|
+
"toc-title": "Contents",
|
|
14595
|
+
"zoom-title": "Zoom diagram",
|
|
14596
|
+
"zoom-image-title": "Zoom image",
|
|
14597
|
+
"zoom-in-title": "Zoom in",
|
|
14598
|
+
"zoom-out-title": "Zoom out",
|
|
14599
|
+
"zoom-fit-title": "Fit to window",
|
|
14600
|
+
"zoom-close-title": "Close",
|
|
14601
|
+
"diff-added": "{0} added",
|
|
14602
|
+
"diff-changed": "{0} changed",
|
|
14603
|
+
"diff-deleted": "{0} deleted",
|
|
14604
|
+
"diff-no-changes": "No changes",
|
|
14605
|
+
"diff-previous-title": "Previous change",
|
|
14606
|
+
"diff-next-title": "Next change",
|
|
14607
|
+
"diff-close-title": "Stop comparing",
|
|
14608
|
+
"diff-hide-title": "Hide changes",
|
|
14609
|
+
"diff-show-title": "Show changes",
|
|
14610
|
+
"diff-old-diagram": "Diagram before the change"
|
|
14611
|
+
};
|
|
14612
|
+
|
|
14613
|
+
// node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/base.js
|
|
14614
|
+
var Diff = class {
|
|
14615
|
+
diff(oldStr, newStr, options = {}) {
|
|
14616
|
+
let callback;
|
|
14617
|
+
if (typeof options === "function") {
|
|
14618
|
+
callback = options;
|
|
14619
|
+
options = {};
|
|
14620
|
+
} else if ("callback" in options) {
|
|
14621
|
+
callback = options.callback;
|
|
14622
|
+
}
|
|
14623
|
+
const oldString = this.castInput(oldStr, options);
|
|
14624
|
+
const newString = this.castInput(newStr, options);
|
|
14625
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
14626
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
14627
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
14628
|
+
}
|
|
14629
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
14630
|
+
var _a;
|
|
14631
|
+
const done = (value) => {
|
|
14632
|
+
value = this.postProcess(value, options);
|
|
14633
|
+
if (callback) {
|
|
14634
|
+
setTimeout(function() {
|
|
14635
|
+
callback(value);
|
|
14636
|
+
}, 0);
|
|
14637
|
+
return void 0;
|
|
14638
|
+
} else {
|
|
14639
|
+
return value;
|
|
14640
|
+
}
|
|
14641
|
+
};
|
|
14642
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
14643
|
+
let editLength = 1;
|
|
14644
|
+
let maxEditLength = newLen + oldLen;
|
|
14645
|
+
if (options.maxEditLength != null) {
|
|
14646
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
14647
|
+
}
|
|
14648
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
14649
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
14650
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
14651
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
14652
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
14653
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
14654
|
+
}
|
|
14655
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
14656
|
+
const execEditLength = () => {
|
|
14657
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
14658
|
+
let basePath;
|
|
14659
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
14660
|
+
if (removePath) {
|
|
14661
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
14662
|
+
}
|
|
14663
|
+
let canAdd = false;
|
|
14664
|
+
if (addPath) {
|
|
14665
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
14666
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
14667
|
+
}
|
|
14668
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
14669
|
+
if (!canAdd && !canRemove) {
|
|
14670
|
+
bestPath[diagonalPath] = void 0;
|
|
14671
|
+
continue;
|
|
14672
|
+
}
|
|
14673
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
14674
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
14675
|
+
} else {
|
|
14676
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
14677
|
+
}
|
|
14678
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
14679
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
14680
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
14681
|
+
} else {
|
|
14682
|
+
bestPath[diagonalPath] = basePath;
|
|
14683
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
14684
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
14685
|
+
}
|
|
14686
|
+
if (newPos + 1 >= newLen) {
|
|
14687
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
14688
|
+
}
|
|
14689
|
+
}
|
|
14690
|
+
}
|
|
14691
|
+
editLength++;
|
|
14692
|
+
};
|
|
14693
|
+
if (callback) {
|
|
14694
|
+
(function exec() {
|
|
14695
|
+
setTimeout(function() {
|
|
14696
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
14697
|
+
return callback(void 0);
|
|
14698
|
+
}
|
|
14699
|
+
if (!execEditLength()) {
|
|
14700
|
+
exec();
|
|
14701
|
+
}
|
|
14702
|
+
}, 0);
|
|
14703
|
+
})();
|
|
14704
|
+
} else {
|
|
14705
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
14706
|
+
const ret = execEditLength();
|
|
14707
|
+
if (ret) {
|
|
14708
|
+
return ret;
|
|
14709
|
+
}
|
|
14710
|
+
}
|
|
14711
|
+
}
|
|
14712
|
+
}
|
|
14713
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
14714
|
+
const last = path.lastComponent;
|
|
14715
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
14716
|
+
return {
|
|
14717
|
+
oldPos: path.oldPos + oldPosInc,
|
|
14718
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
14719
|
+
};
|
|
14720
|
+
} else {
|
|
14721
|
+
return {
|
|
14722
|
+
oldPos: path.oldPos + oldPosInc,
|
|
14723
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
14724
|
+
};
|
|
14725
|
+
}
|
|
14726
|
+
}
|
|
14727
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
14728
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
14729
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
14730
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
14731
|
+
newPos++;
|
|
14732
|
+
oldPos++;
|
|
14733
|
+
commonCount++;
|
|
14734
|
+
if (options.oneChangePerToken) {
|
|
14735
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
14736
|
+
}
|
|
14737
|
+
}
|
|
14738
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
14739
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
14740
|
+
}
|
|
14741
|
+
basePath.oldPos = oldPos;
|
|
14742
|
+
return newPos;
|
|
14743
|
+
}
|
|
14744
|
+
equals(left, right, options) {
|
|
14745
|
+
if (options.comparator) {
|
|
14746
|
+
return options.comparator(left, right);
|
|
14747
|
+
} else {
|
|
14748
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
14749
|
+
}
|
|
14750
|
+
}
|
|
14751
|
+
removeEmpty(array) {
|
|
14752
|
+
const ret = [];
|
|
14753
|
+
for (let i = 0; i < array.length; i++) {
|
|
14754
|
+
if (array[i]) {
|
|
14755
|
+
ret.push(array[i]);
|
|
14756
|
+
}
|
|
14757
|
+
}
|
|
14758
|
+
return ret;
|
|
14759
|
+
}
|
|
14760
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14761
|
+
castInput(value, options) {
|
|
14762
|
+
return value;
|
|
14763
|
+
}
|
|
14764
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14765
|
+
tokenize(value, options) {
|
|
14766
|
+
return Array.from(value);
|
|
14767
|
+
}
|
|
14768
|
+
join(chars) {
|
|
14769
|
+
return chars.join("");
|
|
14770
|
+
}
|
|
14771
|
+
postProcess(changeObjects, options) {
|
|
14772
|
+
return changeObjects;
|
|
14773
|
+
}
|
|
14774
|
+
get useLongestToken() {
|
|
14775
|
+
return false;
|
|
14776
|
+
}
|
|
14777
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
14778
|
+
const components = [];
|
|
14779
|
+
let nextComponent;
|
|
14780
|
+
while (lastComponent) {
|
|
14781
|
+
components.push(lastComponent);
|
|
14782
|
+
nextComponent = lastComponent.previousComponent;
|
|
14783
|
+
delete lastComponent.previousComponent;
|
|
14784
|
+
lastComponent = nextComponent;
|
|
14785
|
+
}
|
|
14786
|
+
components.reverse();
|
|
14787
|
+
const componentLen = components.length;
|
|
14788
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
14789
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
14790
|
+
const component = components[componentPos];
|
|
14791
|
+
if (!component.removed) {
|
|
14792
|
+
if (!component.added && this.useLongestToken) {
|
|
14793
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
14794
|
+
value = value.map(function(value2, i) {
|
|
14795
|
+
const oldValue = oldTokens[oldPos + i];
|
|
14796
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
14797
|
+
});
|
|
14798
|
+
component.value = this.join(value);
|
|
14799
|
+
} else {
|
|
14800
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
14801
|
+
}
|
|
14802
|
+
newPos += component.count;
|
|
14803
|
+
if (!component.added) {
|
|
14804
|
+
oldPos += component.count;
|
|
14805
|
+
}
|
|
14806
|
+
} else {
|
|
14807
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
14808
|
+
oldPos += component.count;
|
|
14809
|
+
}
|
|
14810
|
+
}
|
|
14811
|
+
return components;
|
|
14812
|
+
}
|
|
14813
|
+
};
|
|
14814
|
+
|
|
14815
|
+
// node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/array.js
|
|
14816
|
+
var ArrayDiff = class extends Diff {
|
|
14817
|
+
tokenize(value) {
|
|
14818
|
+
return value.slice();
|
|
14819
|
+
}
|
|
14820
|
+
join(value) {
|
|
14821
|
+
return value;
|
|
14822
|
+
}
|
|
14823
|
+
removeEmpty(value) {
|
|
14824
|
+
return value;
|
|
14825
|
+
}
|
|
14826
|
+
};
|
|
14827
|
+
var arrayDiff = new ArrayDiff();
|
|
14828
|
+
function diffArrays(oldArr, newArr, options) {
|
|
14829
|
+
return arrayDiff.diff(oldArr, newArr, options);
|
|
14830
|
+
}
|
|
14831
|
+
|
|
14590
14832
|
// node_modules/.pnpm/mdurl@2.1.0/node_modules/mdurl/index.mjs
|
|
14591
14833
|
var mdurl_exports = {};
|
|
14592
14834
|
__export(mdurl_exports, {
|
|
@@ -19879,265 +20121,6 @@ _defineProperty(MarkdownIt, "ParserInline", ParserInline);
|
|
|
19879
20121
|
_defineProperty(MarkdownIt, "StateInline", StateInline);
|
|
19880
20122
|
var MarkdownItCallable = callable(MarkdownIt);
|
|
19881
20123
|
|
|
19882
|
-
// node_modules/.pnpm/markdown-it-footnote@4.0.0/node_modules/markdown-it-footnote/index.mjs
|
|
19883
|
-
function render_footnote_anchor_name(tokens, idx, options, env) {
|
|
19884
|
-
const n = Number(tokens[idx].meta.id + 1).toString();
|
|
19885
|
-
let prefix = "";
|
|
19886
|
-
if (typeof env.docId === "string") prefix = `-${env.docId}-`;
|
|
19887
|
-
return prefix + n;
|
|
19888
|
-
}
|
|
19889
|
-
function render_footnote_caption(tokens, idx) {
|
|
19890
|
-
let n = Number(tokens[idx].meta.id + 1).toString();
|
|
19891
|
-
if (tokens[idx].meta.subId > 0) n += `:${tokens[idx].meta.subId}`;
|
|
19892
|
-
return `[${n}]`;
|
|
19893
|
-
}
|
|
19894
|
-
function render_footnote_ref(tokens, idx, options, env, slf) {
|
|
19895
|
-
const id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
19896
|
-
const caption = slf.rules.footnote_caption(tokens, idx, options, env, slf);
|
|
19897
|
-
let refid = id;
|
|
19898
|
-
if (tokens[idx].meta.subId > 0) refid += `:${tokens[idx].meta.subId}`;
|
|
19899
|
-
return `<sup class="footnote-ref"><a href="#fn${id}" id="fnref${refid}">${caption}</a></sup>`;
|
|
19900
|
-
}
|
|
19901
|
-
function render_footnote_block_open(tokens, idx, options) {
|
|
19902
|
-
return (options.xhtmlOut ? '<hr class="footnotes-sep" />\n' : '<hr class="footnotes-sep">\n') + '<section class="footnotes">\n<ol class="footnotes-list">\n';
|
|
19903
|
-
}
|
|
19904
|
-
function render_footnote_block_close() {
|
|
19905
|
-
return "</ol>\n</section>\n";
|
|
19906
|
-
}
|
|
19907
|
-
function render_footnote_open(tokens, idx, options, env, slf) {
|
|
19908
|
-
let id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
19909
|
-
if (tokens[idx].meta.subId > 0) id += `:${tokens[idx].meta.subId}`;
|
|
19910
|
-
return `<li id="fn${id}" class="footnote-item">`;
|
|
19911
|
-
}
|
|
19912
|
-
function render_footnote_close() {
|
|
19913
|
-
return "</li>\n";
|
|
19914
|
-
}
|
|
19915
|
-
function render_footnote_anchor(tokens, idx, options, env, slf) {
|
|
19916
|
-
let id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
19917
|
-
if (tokens[idx].meta.subId > 0) id += `:${tokens[idx].meta.subId}`;
|
|
19918
|
-
return ` <a href="#fnref${id}" class="footnote-backref">\u21A9\uFE0E</a>`;
|
|
19919
|
-
}
|
|
19920
|
-
function footnote_plugin(md2) {
|
|
19921
|
-
const parseLinkLabel2 = md2.helpers.parseLinkLabel;
|
|
19922
|
-
const isSpace2 = md2.utils.isSpace;
|
|
19923
|
-
md2.renderer.rules.footnote_ref = render_footnote_ref;
|
|
19924
|
-
md2.renderer.rules.footnote_block_open = render_footnote_block_open;
|
|
19925
|
-
md2.renderer.rules.footnote_block_close = render_footnote_block_close;
|
|
19926
|
-
md2.renderer.rules.footnote_open = render_footnote_open;
|
|
19927
|
-
md2.renderer.rules.footnote_close = render_footnote_close;
|
|
19928
|
-
md2.renderer.rules.footnote_anchor = render_footnote_anchor;
|
|
19929
|
-
md2.renderer.rules.footnote_caption = render_footnote_caption;
|
|
19930
|
-
md2.renderer.rules.footnote_anchor_name = render_footnote_anchor_name;
|
|
19931
|
-
function footnote_def(state, startLine, endLine, silent) {
|
|
19932
|
-
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
19933
|
-
const max = state.eMarks[startLine];
|
|
19934
|
-
if (start + 4 > max) return false;
|
|
19935
|
-
if (state.src.charCodeAt(start) !== 91) return false;
|
|
19936
|
-
if (state.src.charCodeAt(start + 1) !== 94) return false;
|
|
19937
|
-
let pos;
|
|
19938
|
-
for (pos = start + 2; pos < max; pos++) {
|
|
19939
|
-
if (state.src.charCodeAt(pos) === 32) return false;
|
|
19940
|
-
if (state.src.charCodeAt(pos) === 93) {
|
|
19941
|
-
break;
|
|
19942
|
-
}
|
|
19943
|
-
}
|
|
19944
|
-
if (pos === start + 2) return false;
|
|
19945
|
-
if (pos + 1 >= max || state.src.charCodeAt(++pos) !== 58) return false;
|
|
19946
|
-
if (silent) return true;
|
|
19947
|
-
pos++;
|
|
19948
|
-
if (!state.env.footnotes) state.env.footnotes = {};
|
|
19949
|
-
if (!state.env.footnotes.refs) state.env.footnotes.refs = {};
|
|
19950
|
-
const label = state.src.slice(start + 2, pos - 2);
|
|
19951
|
-
state.env.footnotes.refs[`:${label}`] = -1;
|
|
19952
|
-
const token_fref_o = new state.Token("footnote_reference_open", "", 1);
|
|
19953
|
-
token_fref_o.meta = { label };
|
|
19954
|
-
token_fref_o.level = state.level++;
|
|
19955
|
-
state.tokens.push(token_fref_o);
|
|
19956
|
-
const oldBMark = state.bMarks[startLine];
|
|
19957
|
-
const oldTShift = state.tShift[startLine];
|
|
19958
|
-
const oldSCount = state.sCount[startLine];
|
|
19959
|
-
const oldParentType = state.parentType;
|
|
19960
|
-
const posAfterColon = pos;
|
|
19961
|
-
const initial = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);
|
|
19962
|
-
let offset = initial;
|
|
19963
|
-
while (pos < max) {
|
|
19964
|
-
const ch = state.src.charCodeAt(pos);
|
|
19965
|
-
if (isSpace2(ch)) {
|
|
19966
|
-
if (ch === 9) {
|
|
19967
|
-
offset += 4 - offset % 4;
|
|
19968
|
-
} else {
|
|
19969
|
-
offset++;
|
|
19970
|
-
}
|
|
19971
|
-
} else {
|
|
19972
|
-
break;
|
|
19973
|
-
}
|
|
19974
|
-
pos++;
|
|
19975
|
-
}
|
|
19976
|
-
state.tShift[startLine] = pos - posAfterColon;
|
|
19977
|
-
state.sCount[startLine] = offset - initial;
|
|
19978
|
-
state.bMarks[startLine] = posAfterColon;
|
|
19979
|
-
state.blkIndent += 4;
|
|
19980
|
-
state.parentType = "footnote";
|
|
19981
|
-
if (state.sCount[startLine] < state.blkIndent) {
|
|
19982
|
-
state.sCount[startLine] += state.blkIndent;
|
|
19983
|
-
}
|
|
19984
|
-
state.md.block.tokenize(state, startLine, endLine, true);
|
|
19985
|
-
state.parentType = oldParentType;
|
|
19986
|
-
state.blkIndent -= 4;
|
|
19987
|
-
state.tShift[startLine] = oldTShift;
|
|
19988
|
-
state.sCount[startLine] = oldSCount;
|
|
19989
|
-
state.bMarks[startLine] = oldBMark;
|
|
19990
|
-
const token_fref_c = new state.Token("footnote_reference_close", "", -1);
|
|
19991
|
-
token_fref_c.level = --state.level;
|
|
19992
|
-
state.tokens.push(token_fref_c);
|
|
19993
|
-
return true;
|
|
19994
|
-
}
|
|
19995
|
-
function footnote_inline(state, silent) {
|
|
19996
|
-
const max = state.posMax;
|
|
19997
|
-
const start = state.pos;
|
|
19998
|
-
if (start + 2 >= max) return false;
|
|
19999
|
-
if (state.src.charCodeAt(start) !== 94) return false;
|
|
20000
|
-
if (state.src.charCodeAt(start + 1) !== 91) return false;
|
|
20001
|
-
const labelStart = start + 2;
|
|
20002
|
-
const labelEnd = parseLinkLabel2(state, start + 1);
|
|
20003
|
-
if (labelEnd < 0) return false;
|
|
20004
|
-
if (!silent) {
|
|
20005
|
-
if (!state.env.footnotes) state.env.footnotes = {};
|
|
20006
|
-
if (!state.env.footnotes.list) state.env.footnotes.list = [];
|
|
20007
|
-
const footnoteId = state.env.footnotes.list.length;
|
|
20008
|
-
const tokens = [];
|
|
20009
|
-
state.md.inline.parse(
|
|
20010
|
-
state.src.slice(labelStart, labelEnd),
|
|
20011
|
-
state.md,
|
|
20012
|
-
state.env,
|
|
20013
|
-
tokens
|
|
20014
|
-
);
|
|
20015
|
-
const token = state.push("footnote_ref", "", 0);
|
|
20016
|
-
token.meta = { id: footnoteId };
|
|
20017
|
-
state.env.footnotes.list[footnoteId] = {
|
|
20018
|
-
content: state.src.slice(labelStart, labelEnd),
|
|
20019
|
-
tokens
|
|
20020
|
-
};
|
|
20021
|
-
}
|
|
20022
|
-
state.pos = labelEnd + 1;
|
|
20023
|
-
state.posMax = max;
|
|
20024
|
-
return true;
|
|
20025
|
-
}
|
|
20026
|
-
function footnote_ref(state, silent) {
|
|
20027
|
-
const max = state.posMax;
|
|
20028
|
-
const start = state.pos;
|
|
20029
|
-
if (start + 3 > max) return false;
|
|
20030
|
-
if (!state.env.footnotes || !state.env.footnotes.refs) return false;
|
|
20031
|
-
if (state.src.charCodeAt(start) !== 91) return false;
|
|
20032
|
-
if (state.src.charCodeAt(start + 1) !== 94) return false;
|
|
20033
|
-
let pos;
|
|
20034
|
-
for (pos = start + 2; pos < max; pos++) {
|
|
20035
|
-
if (state.src.charCodeAt(pos) === 32) return false;
|
|
20036
|
-
if (state.src.charCodeAt(pos) === 10) return false;
|
|
20037
|
-
if (state.src.charCodeAt(pos) === 93) {
|
|
20038
|
-
break;
|
|
20039
|
-
}
|
|
20040
|
-
}
|
|
20041
|
-
if (pos === start + 2) return false;
|
|
20042
|
-
if (pos >= max) return false;
|
|
20043
|
-
pos++;
|
|
20044
|
-
const label = state.src.slice(start + 2, pos - 1);
|
|
20045
|
-
if (typeof state.env.footnotes.refs[`:${label}`] === "undefined") return false;
|
|
20046
|
-
if (!silent) {
|
|
20047
|
-
if (!state.env.footnotes.list) state.env.footnotes.list = [];
|
|
20048
|
-
let footnoteId;
|
|
20049
|
-
if (state.env.footnotes.refs[`:${label}`] < 0) {
|
|
20050
|
-
footnoteId = state.env.footnotes.list.length;
|
|
20051
|
-
state.env.footnotes.list[footnoteId] = { label, count: 0 };
|
|
20052
|
-
state.env.footnotes.refs[`:${label}`] = footnoteId;
|
|
20053
|
-
} else {
|
|
20054
|
-
footnoteId = state.env.footnotes.refs[`:${label}`];
|
|
20055
|
-
}
|
|
20056
|
-
const footnoteSubId = state.env.footnotes.list[footnoteId].count;
|
|
20057
|
-
state.env.footnotes.list[footnoteId].count++;
|
|
20058
|
-
const token = state.push("footnote_ref", "", 0);
|
|
20059
|
-
token.meta = { id: footnoteId, subId: footnoteSubId, label };
|
|
20060
|
-
}
|
|
20061
|
-
state.pos = pos;
|
|
20062
|
-
state.posMax = max;
|
|
20063
|
-
return true;
|
|
20064
|
-
}
|
|
20065
|
-
function footnote_tail(state) {
|
|
20066
|
-
let tokens;
|
|
20067
|
-
let current;
|
|
20068
|
-
let currentLabel;
|
|
20069
|
-
let insideRef = false;
|
|
20070
|
-
const refTokens = {};
|
|
20071
|
-
if (!state.env.footnotes) {
|
|
20072
|
-
return;
|
|
20073
|
-
}
|
|
20074
|
-
state.tokens = state.tokens.filter(function(tok) {
|
|
20075
|
-
if (tok.type === "footnote_reference_open") {
|
|
20076
|
-
insideRef = true;
|
|
20077
|
-
current = [];
|
|
20078
|
-
currentLabel = tok.meta.label;
|
|
20079
|
-
return false;
|
|
20080
|
-
}
|
|
20081
|
-
if (tok.type === "footnote_reference_close") {
|
|
20082
|
-
insideRef = false;
|
|
20083
|
-
refTokens[":" + currentLabel] = current;
|
|
20084
|
-
return false;
|
|
20085
|
-
}
|
|
20086
|
-
if (insideRef) {
|
|
20087
|
-
current.push(tok);
|
|
20088
|
-
}
|
|
20089
|
-
return !insideRef;
|
|
20090
|
-
});
|
|
20091
|
-
if (!state.env.footnotes.list) {
|
|
20092
|
-
return;
|
|
20093
|
-
}
|
|
20094
|
-
const list2 = state.env.footnotes.list;
|
|
20095
|
-
state.tokens.push(new state.Token("footnote_block_open", "", 1));
|
|
20096
|
-
for (let i = 0, l = list2.length; i < l; i++) {
|
|
20097
|
-
const token_fo = new state.Token("footnote_open", "", 1);
|
|
20098
|
-
token_fo.meta = { id: i, label: list2[i].label };
|
|
20099
|
-
state.tokens.push(token_fo);
|
|
20100
|
-
if (list2[i].tokens) {
|
|
20101
|
-
tokens = [];
|
|
20102
|
-
const token_po = new state.Token("paragraph_open", "p", 1);
|
|
20103
|
-
token_po.block = true;
|
|
20104
|
-
tokens.push(token_po);
|
|
20105
|
-
const token_i = new state.Token("inline", "", 0);
|
|
20106
|
-
token_i.children = list2[i].tokens;
|
|
20107
|
-
token_i.content = list2[i].content;
|
|
20108
|
-
tokens.push(token_i);
|
|
20109
|
-
const token_pc = new state.Token("paragraph_close", "p", -1);
|
|
20110
|
-
token_pc.block = true;
|
|
20111
|
-
tokens.push(token_pc);
|
|
20112
|
-
} else if (list2[i].label) {
|
|
20113
|
-
tokens = refTokens[`:${list2[i].label}`];
|
|
20114
|
-
}
|
|
20115
|
-
if (tokens) state.tokens = state.tokens.concat(tokens);
|
|
20116
|
-
let lastParagraph;
|
|
20117
|
-
if (state.tokens[state.tokens.length - 1].type === "paragraph_close") {
|
|
20118
|
-
lastParagraph = state.tokens.pop();
|
|
20119
|
-
} else {
|
|
20120
|
-
lastParagraph = null;
|
|
20121
|
-
}
|
|
20122
|
-
const t = list2[i].count > 0 ? list2[i].count : 1;
|
|
20123
|
-
for (let j = 0; j < t; j++) {
|
|
20124
|
-
const token_a = new state.Token("footnote_anchor", "", 0);
|
|
20125
|
-
token_a.meta = { id: i, subId: j, label: list2[i].label };
|
|
20126
|
-
state.tokens.push(token_a);
|
|
20127
|
-
}
|
|
20128
|
-
if (lastParagraph) {
|
|
20129
|
-
state.tokens.push(lastParagraph);
|
|
20130
|
-
}
|
|
20131
|
-
state.tokens.push(new state.Token("footnote_close", "", -1));
|
|
20132
|
-
}
|
|
20133
|
-
state.tokens.push(new state.Token("footnote_block_close", "", -1));
|
|
20134
|
-
}
|
|
20135
|
-
md2.block.ruler.before("reference", "footnote_def", footnote_def, { alt: ["paragraph", "reference"] });
|
|
20136
|
-
md2.inline.ruler.after("image", "footnote_inline", footnote_inline);
|
|
20137
|
-
md2.inline.ruler.after("footnote_inline", "footnote_ref", footnote_ref);
|
|
20138
|
-
md2.core.ruler.after("inline", "footnote_tail", footnote_tail);
|
|
20139
|
-
}
|
|
20140
|
-
|
|
20141
20124
|
// src/diagrams/diagramWording.ts
|
|
20142
20125
|
function diagramWording(kind, t) {
|
|
20143
20126
|
switch (kind) {
|
|
@@ -20519,104 +20502,6 @@ function stripStepNumber(heading2) {
|
|
|
20519
20502
|
return void 0;
|
|
20520
20503
|
}
|
|
20521
20504
|
|
|
20522
|
-
// src/diagrams/sequenceWrap.ts
|
|
20523
|
-
var DEFAULT_MESSAGE_WRAP_WIDTH = 40;
|
|
20524
|
-
var WIDE_RE = /[ᄀ-ᅟ⺀-〾ぁ-㏿㐀-䶿一-鿿ꀀ-가-힣豈-︰-﹏-⦆¢-₩\u{1F300}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1FAFF}\u{20000}-\u{3FFFD}]/u;
|
|
20525
|
-
var NO_START = new Set(Array.from("\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u309D\u309E\u30FC\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u3095\u3096\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u3019\u3017\u301F\u2019\u201D\uFF60\xBB,.:;!?)]}"));
|
|
20526
|
-
var NO_END = new Set(Array.from("\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3018\u3016\u301D\u2018\u201C\uFF5F\xAB([{"));
|
|
20527
|
-
var KEEP_RE = /<br\s*\/?>|#|;|%%|\$\$|^:?(?:no)?wrap:/i;
|
|
20528
|
-
var TAG_RE = /<\/?[a-z][a-z0-9]*(?:\s[^>]*)?\/?>/;
|
|
20529
|
-
var keepsLabel = (text3) => KEEP_RE.test(text3) || TAG_RE.test(text3);
|
|
20530
|
-
var charWidth = (c) => WIDE_RE.test(c) ? 2 : 1;
|
|
20531
|
-
var textWidth = (text3) => Array.from(text3).reduce((sum, c) => sum + charWidth(c), 0);
|
|
20532
|
-
function canBreakBefore(chars, i) {
|
|
20533
|
-
const before = chars[i - 1];
|
|
20534
|
-
const after = chars[i];
|
|
20535
|
-
if (before === " " || after === " ") {
|
|
20536
|
-
return true;
|
|
20537
|
-
}
|
|
20538
|
-
if (NO_START.has(after) || NO_END.has(before)) {
|
|
20539
|
-
return false;
|
|
20540
|
-
}
|
|
20541
|
-
if (before === "/" && after !== "/") {
|
|
20542
|
-
return true;
|
|
20543
|
-
}
|
|
20544
|
-
return WIDE_RE.test(before) || WIDE_RE.test(after);
|
|
20545
|
-
}
|
|
20546
|
-
function fillLines(chars, limit) {
|
|
20547
|
-
const lines = [];
|
|
20548
|
-
let start = 0;
|
|
20549
|
-
while (start < chars.length) {
|
|
20550
|
-
while (chars[start] === " ") {
|
|
20551
|
-
start++;
|
|
20552
|
-
}
|
|
20553
|
-
if (start >= chars.length) {
|
|
20554
|
-
break;
|
|
20555
|
-
}
|
|
20556
|
-
let width = 0;
|
|
20557
|
-
let end = start;
|
|
20558
|
-
let lastBreak = -1;
|
|
20559
|
-
while (end < chars.length) {
|
|
20560
|
-
if (end > start && canBreakBefore(chars, end)) {
|
|
20561
|
-
lastBreak = end;
|
|
20562
|
-
}
|
|
20563
|
-
const w = charWidth(chars[end]);
|
|
20564
|
-
if (end > start && width + w > limit) {
|
|
20565
|
-
break;
|
|
20566
|
-
}
|
|
20567
|
-
width += w;
|
|
20568
|
-
end++;
|
|
20569
|
-
}
|
|
20570
|
-
const cut = end < chars.length && lastBreak > start ? lastBreak : end;
|
|
20571
|
-
lines.push(chars.slice(start, cut).join("").trimEnd());
|
|
20572
|
-
start = cut;
|
|
20573
|
-
}
|
|
20574
|
-
return lines;
|
|
20575
|
-
}
|
|
20576
|
-
function wrapLabel(text3, maxWidth) {
|
|
20577
|
-
const normalized = text3.replace(/\s+/g, " ").trim();
|
|
20578
|
-
const total = textWidth(normalized);
|
|
20579
|
-
if (maxWidth <= 0 || total <= maxWidth) {
|
|
20580
|
-
return [normalized];
|
|
20581
|
-
}
|
|
20582
|
-
const chars = Array.from(normalized);
|
|
20583
|
-
const count = fillLines(chars, maxWidth).length;
|
|
20584
|
-
for (let limit = Math.ceil(total / count); limit < maxWidth; limit++) {
|
|
20585
|
-
const lines = fillLines(chars, limit);
|
|
20586
|
-
if (lines.length <= count) {
|
|
20587
|
-
return lines;
|
|
20588
|
-
}
|
|
20589
|
-
}
|
|
20590
|
-
return fillLines(chars, maxWidth);
|
|
20591
|
-
}
|
|
20592
|
-
function wrapSequenceMessages(source, maxWidth) {
|
|
20593
|
-
if (!(maxWidth > 0) || !isSequenceDiagram(source)) {
|
|
20594
|
-
return source;
|
|
20595
|
-
}
|
|
20596
|
-
const { messages } = parseSequence(source, 0);
|
|
20597
|
-
const lines = source.split("\n");
|
|
20598
|
-
let changed = false;
|
|
20599
|
-
for (const { line } of messages) {
|
|
20600
|
-
const raw = lines[line];
|
|
20601
|
-
const colon = raw.indexOf(":");
|
|
20602
|
-
const label = raw.slice(colon + 1);
|
|
20603
|
-
const text3 = label.trim();
|
|
20604
|
-
if (keepsLabel(text3) || textWidth(text3) <= maxWidth) {
|
|
20605
|
-
continue;
|
|
20606
|
-
}
|
|
20607
|
-
const lead = /^\s*/.exec(label)[0];
|
|
20608
|
-
const trail = /\s*$/.exec(label)[0];
|
|
20609
|
-
lines[line] = `${raw.slice(0, colon + 1)}${lead}${wrapLabel(text3, maxWidth).join("<br>")}${trail}`;
|
|
20610
|
-
changed = true;
|
|
20611
|
-
}
|
|
20612
|
-
return changed ? lines.join("\n") : source;
|
|
20613
|
-
}
|
|
20614
|
-
|
|
20615
|
-
// src/markdown/htmlTags.ts
|
|
20616
|
-
var RAW_TEXT = "script|style|textarea|title";
|
|
20617
|
-
var ATTR_RE = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
20618
|
-
var decodeAttribute = (md2, value) => md2.utils.unescapeAll(value.replace(/\\/g, "\\\\"));
|
|
20619
|
-
|
|
20620
20505
|
// src/diagrams/diagramNodes.ts
|
|
20621
20506
|
function readNodes(lines, start, firstLine, rules, reader) {
|
|
20622
20507
|
const excluded = reader.excluded ?? /* @__PURE__ */ new Set();
|
|
@@ -21347,6 +21232,11 @@ function tableWarnings(tokens) {
|
|
|
21347
21232
|
return tokens.flatMap((token) => token.meta?.[WARNINGS] ?? []);
|
|
21348
21233
|
}
|
|
21349
21234
|
|
|
21235
|
+
// src/markdown/htmlTags.ts
|
|
21236
|
+
var RAW_TEXT = "script|style|textarea|title";
|
|
21237
|
+
var ATTR_RE = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
21238
|
+
var decodeAttribute = (md2, value) => md2.utils.unescapeAll(value.replace(/\\/g, "\\\\"));
|
|
21239
|
+
|
|
21350
21240
|
// src/markdown/wireframe.ts
|
|
21351
21241
|
var WIREFRAME_TOKEN = "wireframe";
|
|
21352
21242
|
var SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
|
|
@@ -21897,94 +21787,446 @@ function linkParts(diagram, tokens, headings, numberedHeadings, steps, wording,
|
|
|
21897
21787
|
}
|
|
21898
21788
|
}
|
|
21899
21789
|
|
|
21900
|
-
// node_modules/.pnpm/
|
|
21901
|
-
|
|
21902
|
-
|
|
21903
|
-
|
|
21904
|
-
|
|
21905
|
-
|
|
21906
|
-
if (!lang || !common_default.getLanguage(lang)) {
|
|
21907
|
-
return "";
|
|
21908
|
-
}
|
|
21909
|
-
try {
|
|
21910
|
-
return common_default.highlight(code2, { language: lang, ignoreIllegals: true }).value;
|
|
21911
|
-
} catch {
|
|
21912
|
-
return "";
|
|
21913
|
-
}
|
|
21790
|
+
// node_modules/.pnpm/markdown-it-footnote@4.0.0/node_modules/markdown-it-footnote/index.mjs
|
|
21791
|
+
function render_footnote_anchor_name(tokens, idx, options, env) {
|
|
21792
|
+
const n = Number(tokens[idx].meta.id + 1).toString();
|
|
21793
|
+
let prefix = "";
|
|
21794
|
+
if (typeof env.docId === "string") prefix = `-${env.docId}-`;
|
|
21795
|
+
return prefix + n;
|
|
21914
21796
|
}
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
|
|
21918
|
-
|
|
21919
|
-
if (quoted) {
|
|
21920
|
-
return /^\s*(?:#.*)?$/.test(s.slice(quoted[0].length)) ? quoted[0] : s;
|
|
21921
|
-
}
|
|
21922
|
-
const comment = /(?:^|\s)#/.exec(s);
|
|
21923
|
-
return comment ? s.slice(0, comment.index).trimEnd() : s;
|
|
21797
|
+
function render_footnote_caption(tokens, idx) {
|
|
21798
|
+
let n = Number(tokens[idx].meta.id + 1).toString();
|
|
21799
|
+
if (tokens[idx].meta.subId > 0) n += `:${tokens[idx].meta.subId}`;
|
|
21800
|
+
return `[${n}]`;
|
|
21924
21801
|
}
|
|
21925
|
-
function
|
|
21926
|
-
const
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
} else if (entries2.length > 0 && !/^#/.test(line)) {
|
|
21932
|
-
entries2[entries2.length - 1].lines.push(line);
|
|
21933
|
-
}
|
|
21934
|
-
}
|
|
21935
|
-
return entries2.map(({ key, rest, lines }) => {
|
|
21936
|
-
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
21937
|
-
lines.pop();
|
|
21938
|
-
}
|
|
21939
|
-
const indent = Math.min(...lines.filter((l) => l.trim() !== "").map((l) => /^\s*/.exec(l)[0].length));
|
|
21940
|
-
const body = lines.map((l) => l.slice(indent));
|
|
21941
|
-
let value;
|
|
21942
|
-
if (/^[|>][+-]?\d*$/.test(rest)) {
|
|
21943
|
-
value = body.join(rest.startsWith(">") ? " " : "\n");
|
|
21944
|
-
} else if (rest === "" && body.length > 0 && body.every((l) => /^-(\s|$)/.test(l))) {
|
|
21945
|
-
value = body.map((l) => unquote2(stripComment(l.slice(1).trim()))).join(", ");
|
|
21946
|
-
} else if (body.length === 0 && /^\[.*\]$/.test(rest)) {
|
|
21947
|
-
value = rest.slice(1, -1).split(",").map((item) => unquote2(item.trim())).filter((item) => item !== "").join(", ");
|
|
21948
|
-
} else {
|
|
21949
|
-
value = [unquote2(rest), ...body].filter((l, i) => i > 0 || l !== "").join("\n");
|
|
21950
|
-
}
|
|
21951
|
-
return { key, value };
|
|
21952
|
-
});
|
|
21802
|
+
function render_footnote_ref(tokens, idx, options, env, slf) {
|
|
21803
|
+
const id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
21804
|
+
const caption = slf.rules.footnote_caption(tokens, idx, options, env, slf);
|
|
21805
|
+
let refid = id;
|
|
21806
|
+
if (tokens[idx].meta.subId > 0) refid += `:${tokens[idx].meta.subId}`;
|
|
21807
|
+
return `<sup class="footnote-ref"><a href="#fn${id}" id="fnref${refid}">${caption}</a></sup>`;
|
|
21953
21808
|
}
|
|
21954
|
-
function
|
|
21955
|
-
|
|
21956
|
-
return value?.trim() ? value : void 0;
|
|
21809
|
+
function render_footnote_block_open(tokens, idx, options) {
|
|
21810
|
+
return (options.xhtmlOut ? '<hr class="footnotes-sep" />\n' : '<hr class="footnotes-sep">\n') + '<section class="footnotes">\n<ol class="footnotes-list">\n';
|
|
21957
21811
|
}
|
|
21958
|
-
|
|
21959
|
-
|
|
21960
|
-
return entries2.find((entry) => entry.key === "type")?.value.trim() === DESIGN_DOC_TYPE;
|
|
21812
|
+
function render_footnote_block_close() {
|
|
21813
|
+
return "</ol>\n</section>\n";
|
|
21961
21814
|
}
|
|
21962
|
-
|
|
21963
|
-
|
|
21964
|
-
|
|
21965
|
-
|
|
21966
|
-
|
|
21967
|
-
|
|
21968
|
-
|
|
21969
|
-
|
|
21970
|
-
|
|
21971
|
-
|
|
21972
|
-
|
|
21815
|
+
function render_footnote_open(tokens, idx, options, env, slf) {
|
|
21816
|
+
let id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
21817
|
+
if (tokens[idx].meta.subId > 0) id += `:${tokens[idx].meta.subId}`;
|
|
21818
|
+
return `<li id="fn${id}" class="footnote-item">`;
|
|
21819
|
+
}
|
|
21820
|
+
function render_footnote_close() {
|
|
21821
|
+
return "</li>\n";
|
|
21822
|
+
}
|
|
21823
|
+
function render_footnote_anchor(tokens, idx, options, env, slf) {
|
|
21824
|
+
let id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
|
|
21825
|
+
if (tokens[idx].meta.subId > 0) id += `:${tokens[idx].meta.subId}`;
|
|
21826
|
+
return ` <a href="#fnref${id}" class="footnote-backref">\u21A9\uFE0E</a>`;
|
|
21827
|
+
}
|
|
21828
|
+
function footnote_plugin(md2) {
|
|
21829
|
+
const parseLinkLabel2 = md2.helpers.parseLinkLabel;
|
|
21830
|
+
const isSpace2 = md2.utils.isSpace;
|
|
21831
|
+
md2.renderer.rules.footnote_ref = render_footnote_ref;
|
|
21832
|
+
md2.renderer.rules.footnote_block_open = render_footnote_block_open;
|
|
21833
|
+
md2.renderer.rules.footnote_block_close = render_footnote_block_close;
|
|
21834
|
+
md2.renderer.rules.footnote_open = render_footnote_open;
|
|
21835
|
+
md2.renderer.rules.footnote_close = render_footnote_close;
|
|
21836
|
+
md2.renderer.rules.footnote_anchor = render_footnote_anchor;
|
|
21837
|
+
md2.renderer.rules.footnote_caption = render_footnote_caption;
|
|
21838
|
+
md2.renderer.rules.footnote_anchor_name = render_footnote_anchor_name;
|
|
21839
|
+
function footnote_def(state, startLine, endLine, silent) {
|
|
21840
|
+
const start = state.bMarks[startLine] + state.tShift[startLine];
|
|
21841
|
+
const max = state.eMarks[startLine];
|
|
21842
|
+
if (start + 4 > max) return false;
|
|
21843
|
+
if (state.src.charCodeAt(start) !== 91) return false;
|
|
21844
|
+
if (state.src.charCodeAt(start + 1) !== 94) return false;
|
|
21845
|
+
let pos;
|
|
21846
|
+
for (pos = start + 2; pos < max; pos++) {
|
|
21847
|
+
if (state.src.charCodeAt(pos) === 32) return false;
|
|
21848
|
+
if (state.src.charCodeAt(pos) === 93) {
|
|
21849
|
+
break;
|
|
21850
|
+
}
|
|
21973
21851
|
}
|
|
21974
|
-
|
|
21975
|
-
|
|
21976
|
-
|
|
21977
|
-
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21852
|
+
if (pos === start + 2) return false;
|
|
21853
|
+
if (pos + 1 >= max || state.src.charCodeAt(++pos) !== 58) return false;
|
|
21854
|
+
if (silent) return true;
|
|
21855
|
+
pos++;
|
|
21856
|
+
if (!state.env.footnotes) state.env.footnotes = {};
|
|
21857
|
+
if (!state.env.footnotes.refs) state.env.footnotes.refs = {};
|
|
21858
|
+
const label = state.src.slice(start + 2, pos - 2);
|
|
21859
|
+
state.env.footnotes.refs[`:${label}`] = -1;
|
|
21860
|
+
const token_fref_o = new state.Token("footnote_reference_open", "", 1);
|
|
21861
|
+
token_fref_o.meta = { label };
|
|
21862
|
+
token_fref_o.level = state.level++;
|
|
21863
|
+
state.tokens.push(token_fref_o);
|
|
21864
|
+
const oldBMark = state.bMarks[startLine];
|
|
21865
|
+
const oldTShift = state.tShift[startLine];
|
|
21866
|
+
const oldSCount = state.sCount[startLine];
|
|
21867
|
+
const oldParentType = state.parentType;
|
|
21868
|
+
const posAfterColon = pos;
|
|
21869
|
+
const initial = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);
|
|
21870
|
+
let offset = initial;
|
|
21871
|
+
while (pos < max) {
|
|
21872
|
+
const ch = state.src.charCodeAt(pos);
|
|
21873
|
+
if (isSpace2(ch)) {
|
|
21874
|
+
if (ch === 9) {
|
|
21875
|
+
offset += 4 - offset % 4;
|
|
21876
|
+
} else {
|
|
21877
|
+
offset++;
|
|
21981
21878
|
}
|
|
21982
|
-
|
|
21983
|
-
|
|
21879
|
+
} else {
|
|
21880
|
+
break;
|
|
21984
21881
|
}
|
|
21882
|
+
pos++;
|
|
21985
21883
|
}
|
|
21986
|
-
|
|
21987
|
-
|
|
21884
|
+
state.tShift[startLine] = pos - posAfterColon;
|
|
21885
|
+
state.sCount[startLine] = offset - initial;
|
|
21886
|
+
state.bMarks[startLine] = posAfterColon;
|
|
21887
|
+
state.blkIndent += 4;
|
|
21888
|
+
state.parentType = "footnote";
|
|
21889
|
+
if (state.sCount[startLine] < state.blkIndent) {
|
|
21890
|
+
state.sCount[startLine] += state.blkIndent;
|
|
21891
|
+
}
|
|
21892
|
+
state.md.block.tokenize(state, startLine, endLine, true);
|
|
21893
|
+
state.parentType = oldParentType;
|
|
21894
|
+
state.blkIndent -= 4;
|
|
21895
|
+
state.tShift[startLine] = oldTShift;
|
|
21896
|
+
state.sCount[startLine] = oldSCount;
|
|
21897
|
+
state.bMarks[startLine] = oldBMark;
|
|
21898
|
+
const token_fref_c = new state.Token("footnote_reference_close", "", -1);
|
|
21899
|
+
token_fref_c.level = --state.level;
|
|
21900
|
+
state.tokens.push(token_fref_c);
|
|
21901
|
+
return true;
|
|
21902
|
+
}
|
|
21903
|
+
function footnote_inline(state, silent) {
|
|
21904
|
+
const max = state.posMax;
|
|
21905
|
+
const start = state.pos;
|
|
21906
|
+
if (start + 2 >= max) return false;
|
|
21907
|
+
if (state.src.charCodeAt(start) !== 94) return false;
|
|
21908
|
+
if (state.src.charCodeAt(start + 1) !== 91) return false;
|
|
21909
|
+
const labelStart = start + 2;
|
|
21910
|
+
const labelEnd = parseLinkLabel2(state, start + 1);
|
|
21911
|
+
if (labelEnd < 0) return false;
|
|
21912
|
+
if (!silent) {
|
|
21913
|
+
if (!state.env.footnotes) state.env.footnotes = {};
|
|
21914
|
+
if (!state.env.footnotes.list) state.env.footnotes.list = [];
|
|
21915
|
+
const footnoteId = state.env.footnotes.list.length;
|
|
21916
|
+
const tokens = [];
|
|
21917
|
+
state.md.inline.parse(
|
|
21918
|
+
state.src.slice(labelStart, labelEnd),
|
|
21919
|
+
state.md,
|
|
21920
|
+
state.env,
|
|
21921
|
+
tokens
|
|
21922
|
+
);
|
|
21923
|
+
const token = state.push("footnote_ref", "", 0);
|
|
21924
|
+
token.meta = { id: footnoteId };
|
|
21925
|
+
state.env.footnotes.list[footnoteId] = {
|
|
21926
|
+
content: state.src.slice(labelStart, labelEnd),
|
|
21927
|
+
tokens
|
|
21928
|
+
};
|
|
21929
|
+
}
|
|
21930
|
+
state.pos = labelEnd + 1;
|
|
21931
|
+
state.posMax = max;
|
|
21932
|
+
return true;
|
|
21933
|
+
}
|
|
21934
|
+
function footnote_ref(state, silent) {
|
|
21935
|
+
const max = state.posMax;
|
|
21936
|
+
const start = state.pos;
|
|
21937
|
+
if (start + 3 > max) return false;
|
|
21938
|
+
if (!state.env.footnotes || !state.env.footnotes.refs) return false;
|
|
21939
|
+
if (state.src.charCodeAt(start) !== 91) return false;
|
|
21940
|
+
if (state.src.charCodeAt(start + 1) !== 94) return false;
|
|
21941
|
+
let pos;
|
|
21942
|
+
for (pos = start + 2; pos < max; pos++) {
|
|
21943
|
+
if (state.src.charCodeAt(pos) === 32) return false;
|
|
21944
|
+
if (state.src.charCodeAt(pos) === 10) return false;
|
|
21945
|
+
if (state.src.charCodeAt(pos) === 93) {
|
|
21946
|
+
break;
|
|
21947
|
+
}
|
|
21948
|
+
}
|
|
21949
|
+
if (pos === start + 2) return false;
|
|
21950
|
+
if (pos >= max) return false;
|
|
21951
|
+
pos++;
|
|
21952
|
+
const label = state.src.slice(start + 2, pos - 1);
|
|
21953
|
+
if (typeof state.env.footnotes.refs[`:${label}`] === "undefined") return false;
|
|
21954
|
+
if (!silent) {
|
|
21955
|
+
if (!state.env.footnotes.list) state.env.footnotes.list = [];
|
|
21956
|
+
let footnoteId;
|
|
21957
|
+
if (state.env.footnotes.refs[`:${label}`] < 0) {
|
|
21958
|
+
footnoteId = state.env.footnotes.list.length;
|
|
21959
|
+
state.env.footnotes.list[footnoteId] = { label, count: 0 };
|
|
21960
|
+
state.env.footnotes.refs[`:${label}`] = footnoteId;
|
|
21961
|
+
} else {
|
|
21962
|
+
footnoteId = state.env.footnotes.refs[`:${label}`];
|
|
21963
|
+
}
|
|
21964
|
+
const footnoteSubId = state.env.footnotes.list[footnoteId].count;
|
|
21965
|
+
state.env.footnotes.list[footnoteId].count++;
|
|
21966
|
+
const token = state.push("footnote_ref", "", 0);
|
|
21967
|
+
token.meta = { id: footnoteId, subId: footnoteSubId, label };
|
|
21968
|
+
}
|
|
21969
|
+
state.pos = pos;
|
|
21970
|
+
state.posMax = max;
|
|
21971
|
+
return true;
|
|
21972
|
+
}
|
|
21973
|
+
function footnote_tail(state) {
|
|
21974
|
+
let tokens;
|
|
21975
|
+
let current;
|
|
21976
|
+
let currentLabel;
|
|
21977
|
+
let insideRef = false;
|
|
21978
|
+
const refTokens = {};
|
|
21979
|
+
if (!state.env.footnotes) {
|
|
21980
|
+
return;
|
|
21981
|
+
}
|
|
21982
|
+
state.tokens = state.tokens.filter(function(tok) {
|
|
21983
|
+
if (tok.type === "footnote_reference_open") {
|
|
21984
|
+
insideRef = true;
|
|
21985
|
+
current = [];
|
|
21986
|
+
currentLabel = tok.meta.label;
|
|
21987
|
+
return false;
|
|
21988
|
+
}
|
|
21989
|
+
if (tok.type === "footnote_reference_close") {
|
|
21990
|
+
insideRef = false;
|
|
21991
|
+
refTokens[":" + currentLabel] = current;
|
|
21992
|
+
return false;
|
|
21993
|
+
}
|
|
21994
|
+
if (insideRef) {
|
|
21995
|
+
current.push(tok);
|
|
21996
|
+
}
|
|
21997
|
+
return !insideRef;
|
|
21998
|
+
});
|
|
21999
|
+
if (!state.env.footnotes.list) {
|
|
22000
|
+
return;
|
|
22001
|
+
}
|
|
22002
|
+
const list2 = state.env.footnotes.list;
|
|
22003
|
+
state.tokens.push(new state.Token("footnote_block_open", "", 1));
|
|
22004
|
+
for (let i = 0, l = list2.length; i < l; i++) {
|
|
22005
|
+
const token_fo = new state.Token("footnote_open", "", 1);
|
|
22006
|
+
token_fo.meta = { id: i, label: list2[i].label };
|
|
22007
|
+
state.tokens.push(token_fo);
|
|
22008
|
+
if (list2[i].tokens) {
|
|
22009
|
+
tokens = [];
|
|
22010
|
+
const token_po = new state.Token("paragraph_open", "p", 1);
|
|
22011
|
+
token_po.block = true;
|
|
22012
|
+
tokens.push(token_po);
|
|
22013
|
+
const token_i = new state.Token("inline", "", 0);
|
|
22014
|
+
token_i.children = list2[i].tokens;
|
|
22015
|
+
token_i.content = list2[i].content;
|
|
22016
|
+
tokens.push(token_i);
|
|
22017
|
+
const token_pc = new state.Token("paragraph_close", "p", -1);
|
|
22018
|
+
token_pc.block = true;
|
|
22019
|
+
tokens.push(token_pc);
|
|
22020
|
+
} else if (list2[i].label) {
|
|
22021
|
+
tokens = refTokens[`:${list2[i].label}`];
|
|
22022
|
+
}
|
|
22023
|
+
if (tokens) state.tokens = state.tokens.concat(tokens);
|
|
22024
|
+
let lastParagraph;
|
|
22025
|
+
if (state.tokens[state.tokens.length - 1].type === "paragraph_close") {
|
|
22026
|
+
lastParagraph = state.tokens.pop();
|
|
22027
|
+
} else {
|
|
22028
|
+
lastParagraph = null;
|
|
22029
|
+
}
|
|
22030
|
+
const t = list2[i].count > 0 ? list2[i].count : 1;
|
|
22031
|
+
for (let j = 0; j < t; j++) {
|
|
22032
|
+
const token_a = new state.Token("footnote_anchor", "", 0);
|
|
22033
|
+
token_a.meta = { id: i, subId: j, label: list2[i].label };
|
|
22034
|
+
state.tokens.push(token_a);
|
|
22035
|
+
}
|
|
22036
|
+
if (lastParagraph) {
|
|
22037
|
+
state.tokens.push(lastParagraph);
|
|
22038
|
+
}
|
|
22039
|
+
state.tokens.push(new state.Token("footnote_close", "", -1));
|
|
22040
|
+
}
|
|
22041
|
+
state.tokens.push(new state.Token("footnote_block_close", "", -1));
|
|
22042
|
+
}
|
|
22043
|
+
md2.block.ruler.before("reference", "footnote_def", footnote_def, { alt: ["paragraph", "reference"] });
|
|
22044
|
+
md2.inline.ruler.after("image", "footnote_inline", footnote_inline);
|
|
22045
|
+
md2.inline.ruler.after("footnote_inline", "footnote_ref", footnote_ref);
|
|
22046
|
+
md2.core.ruler.after("inline", "footnote_tail", footnote_tail);
|
|
22047
|
+
}
|
|
22048
|
+
|
|
22049
|
+
// src/diagrams/sequenceWrap.ts
|
|
22050
|
+
var DEFAULT_MESSAGE_WRAP_WIDTH = 40;
|
|
22051
|
+
var WIDE_RE = /[ᄀ-ᅟ⺀-〾ぁ-㏿㐀-䶿一-鿿ꀀ-가-힣豈-︰-﹏-⦆¢-₩\u{1F300}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1FAFF}\u{20000}-\u{3FFFD}]/u;
|
|
22052
|
+
var NO_START = new Set(Array.from("\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u309D\u309E\u30FC\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u3095\u3096\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u3019\u3017\u301F\u2019\u201D\uFF60\xBB,.:;!?)]}"));
|
|
22053
|
+
var NO_END = new Set(Array.from("\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3018\u3016\u301D\u2018\u201C\uFF5F\xAB([{"));
|
|
22054
|
+
var KEEP_RE = /<br\s*\/?>|#|;|%%|\$\$|^:?(?:no)?wrap:/i;
|
|
22055
|
+
var TAG_RE = /<\/?[a-z][a-z0-9]*(?:\s[^>]*)?\/?>/;
|
|
22056
|
+
var keepsLabel = (text3) => KEEP_RE.test(text3) || TAG_RE.test(text3);
|
|
22057
|
+
var charWidth = (c) => WIDE_RE.test(c) ? 2 : 1;
|
|
22058
|
+
var textWidth = (text3) => Array.from(text3).reduce((sum, c) => sum + charWidth(c), 0);
|
|
22059
|
+
function canBreakBefore(chars, i) {
|
|
22060
|
+
const before = chars[i - 1];
|
|
22061
|
+
const after = chars[i];
|
|
22062
|
+
if (before === " " || after === " ") {
|
|
22063
|
+
return true;
|
|
22064
|
+
}
|
|
22065
|
+
if (NO_START.has(after) || NO_END.has(before)) {
|
|
22066
|
+
return false;
|
|
22067
|
+
}
|
|
22068
|
+
if (before === "/" && after !== "/") {
|
|
22069
|
+
return true;
|
|
22070
|
+
}
|
|
22071
|
+
return WIDE_RE.test(before) || WIDE_RE.test(after);
|
|
22072
|
+
}
|
|
22073
|
+
function fillLines(chars, limit) {
|
|
22074
|
+
const lines = [];
|
|
22075
|
+
let start = 0;
|
|
22076
|
+
while (start < chars.length) {
|
|
22077
|
+
while (chars[start] === " ") {
|
|
22078
|
+
start++;
|
|
22079
|
+
}
|
|
22080
|
+
if (start >= chars.length) {
|
|
22081
|
+
break;
|
|
22082
|
+
}
|
|
22083
|
+
let width = 0;
|
|
22084
|
+
let end = start;
|
|
22085
|
+
let lastBreak = -1;
|
|
22086
|
+
while (end < chars.length) {
|
|
22087
|
+
if (end > start && canBreakBefore(chars, end)) {
|
|
22088
|
+
lastBreak = end;
|
|
22089
|
+
}
|
|
22090
|
+
const w = charWidth(chars[end]);
|
|
22091
|
+
if (end > start && width + w > limit) {
|
|
22092
|
+
break;
|
|
22093
|
+
}
|
|
22094
|
+
width += w;
|
|
22095
|
+
end++;
|
|
22096
|
+
}
|
|
22097
|
+
const cut = end < chars.length && lastBreak > start ? lastBreak : end;
|
|
22098
|
+
lines.push(chars.slice(start, cut).join("").trimEnd());
|
|
22099
|
+
start = cut;
|
|
22100
|
+
}
|
|
22101
|
+
return lines;
|
|
22102
|
+
}
|
|
22103
|
+
function wrapLabel(text3, maxWidth) {
|
|
22104
|
+
const normalized = text3.replace(/\s+/g, " ").trim();
|
|
22105
|
+
const total = textWidth(normalized);
|
|
22106
|
+
if (maxWidth <= 0 || total <= maxWidth) {
|
|
22107
|
+
return [normalized];
|
|
22108
|
+
}
|
|
22109
|
+
const chars = Array.from(normalized);
|
|
22110
|
+
const count = fillLines(chars, maxWidth).length;
|
|
22111
|
+
for (let limit = Math.ceil(total / count); limit < maxWidth; limit++) {
|
|
22112
|
+
const lines = fillLines(chars, limit);
|
|
22113
|
+
if (lines.length <= count) {
|
|
22114
|
+
return lines;
|
|
22115
|
+
}
|
|
22116
|
+
}
|
|
22117
|
+
return fillLines(chars, maxWidth);
|
|
22118
|
+
}
|
|
22119
|
+
function wrapSequenceMessages(source, maxWidth) {
|
|
22120
|
+
if (!(maxWidth > 0) || !isSequenceDiagram(source)) {
|
|
22121
|
+
return source;
|
|
22122
|
+
}
|
|
22123
|
+
const { messages } = parseSequence(source, 0);
|
|
22124
|
+
const lines = source.split("\n");
|
|
22125
|
+
let changed = false;
|
|
22126
|
+
for (const { line } of messages) {
|
|
22127
|
+
const raw = lines[line];
|
|
22128
|
+
const colon = raw.indexOf(":");
|
|
22129
|
+
const label = raw.slice(colon + 1);
|
|
22130
|
+
const text3 = label.trim();
|
|
22131
|
+
if (keepsLabel(text3) || textWidth(text3) <= maxWidth) {
|
|
22132
|
+
continue;
|
|
22133
|
+
}
|
|
22134
|
+
const lead = /^\s*/.exec(label)[0];
|
|
22135
|
+
const trail = /\s*$/.exec(label)[0];
|
|
22136
|
+
lines[line] = `${raw.slice(0, colon + 1)}${lead}${wrapLabel(text3, maxWidth).join("<br>")}${trail}`;
|
|
22137
|
+
changed = true;
|
|
22138
|
+
}
|
|
22139
|
+
return changed ? lines.join("\n") : source;
|
|
22140
|
+
}
|
|
22141
|
+
|
|
22142
|
+
// node_modules/.pnpm/highlight.js@11.12.0/node_modules/highlight.js/es/common.js
|
|
22143
|
+
var import_common = __toESM(require_common(), 1);
|
|
22144
|
+
var common_default = import_common.default;
|
|
22145
|
+
|
|
22146
|
+
// src/markdown/markdownExtras.ts
|
|
22147
|
+
function highlight(code2, lang) {
|
|
22148
|
+
if (!lang || !common_default.getLanguage(lang)) {
|
|
22149
|
+
return "";
|
|
22150
|
+
}
|
|
22151
|
+
try {
|
|
22152
|
+
return common_default.highlight(code2, { language: lang, ignoreIllegals: true }).value;
|
|
22153
|
+
} catch {
|
|
22154
|
+
return "";
|
|
22155
|
+
}
|
|
22156
|
+
}
|
|
22157
|
+
var YAML_KEY_RE = /^(?:"[^"]*"|'[^']*'|[^\s#:"'-][^:]*?)\s*:(?:\s|$)/;
|
|
22158
|
+
var unquote2 = (s) => /^(["']).*\1$/.test(s) ? s.slice(1, -1) : s;
|
|
22159
|
+
function stripComment(s) {
|
|
22160
|
+
const quoted = /^(["'])(?:(?!\1).)*\1/.exec(s);
|
|
22161
|
+
if (quoted) {
|
|
22162
|
+
return /^\s*(?:#.*)?$/.test(s.slice(quoted[0].length)) ? quoted[0] : s;
|
|
22163
|
+
}
|
|
22164
|
+
const comment = /(?:^|\s)#/.exec(s);
|
|
22165
|
+
return comment ? s.slice(0, comment.index).trimEnd() : s;
|
|
22166
|
+
}
|
|
22167
|
+
function parseFrontMatter(yaml) {
|
|
22168
|
+
const entries2 = [];
|
|
22169
|
+
for (const line of yaml.split(/\r?\n/)) {
|
|
22170
|
+
const m = /^\S/.test(line) ? YAML_KEY_RE.exec(line) : null;
|
|
22171
|
+
if (m) {
|
|
22172
|
+
entries2.push({ key: unquote2(m[0].replace(/\s*:\s*$/, "")), rest: stripComment(line.slice(m[0].length).trim()), lines: [] });
|
|
22173
|
+
} else if (entries2.length > 0 && !/^#/.test(line)) {
|
|
22174
|
+
entries2[entries2.length - 1].lines.push(line);
|
|
22175
|
+
}
|
|
22176
|
+
}
|
|
22177
|
+
return entries2.map(({ key, rest, lines }) => {
|
|
22178
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
22179
|
+
lines.pop();
|
|
22180
|
+
}
|
|
22181
|
+
const indent = Math.min(...lines.filter((l) => l.trim() !== "").map((l) => /^\s*/.exec(l)[0].length));
|
|
22182
|
+
const body = lines.map((l) => l.slice(indent));
|
|
22183
|
+
let value;
|
|
22184
|
+
if (/^[|>][+-]?\d*$/.test(rest)) {
|
|
22185
|
+
value = body.join(rest.startsWith(">") ? " " : "\n");
|
|
22186
|
+
} else if (rest === "" && body.length > 0 && body.every((l) => /^-(\s|$)/.test(l))) {
|
|
22187
|
+
value = body.map((l) => unquote2(stripComment(l.slice(1).trim()))).join(", ");
|
|
22188
|
+
} else if (body.length === 0 && /^\[.*\]$/.test(rest)) {
|
|
22189
|
+
value = rest.slice(1, -1).split(",").map((item) => unquote2(item.trim())).filter((item) => item !== "").join(", ");
|
|
22190
|
+
} else {
|
|
22191
|
+
value = [unquote2(rest), ...body].filter((l, i) => i > 0 || l !== "").join("\n");
|
|
22192
|
+
}
|
|
22193
|
+
return { key, value };
|
|
22194
|
+
});
|
|
22195
|
+
}
|
|
22196
|
+
function frontMatterValue(entries2, key) {
|
|
22197
|
+
const value = entries2.find((entry) => entry.key === key)?.value;
|
|
22198
|
+
return value?.trim() ? value : void 0;
|
|
22199
|
+
}
|
|
22200
|
+
var DESIGN_DOC_TYPE = "design_doc";
|
|
22201
|
+
function isDesignDoc(entries2) {
|
|
22202
|
+
return entries2.find((entry) => entry.key === "type")?.value.trim() === DESIGN_DOC_TYPE;
|
|
22203
|
+
}
|
|
22204
|
+
var DESIGN_DOC_META = [
|
|
22205
|
+
{ key: "version", label: "Version" },
|
|
22206
|
+
{ key: "product", label: "Product" },
|
|
22207
|
+
{ key: "status", label: "Status" },
|
|
22208
|
+
{ key: "updated", label: "Updated" }
|
|
22209
|
+
];
|
|
22210
|
+
function frontMatter(md2) {
|
|
22211
|
+
md2.block.ruler.before("table", "seqnotes_front_matter", (state, startLine, endLine, silent) => {
|
|
22212
|
+
const line = (n) => state.src.slice(state.bMarks[n], state.eMarks[n]).trimEnd();
|
|
22213
|
+
if (startLine !== 0 || state.parentType !== "root" || line(0) !== "---" || endLine < 2 || !YAML_KEY_RE.test(line(1))) {
|
|
22214
|
+
return false;
|
|
22215
|
+
}
|
|
22216
|
+
for (let n = 1; n < endLine; n++) {
|
|
22217
|
+
if (line(n) === "---" || line(n) === "...") {
|
|
22218
|
+
if (!silent) {
|
|
22219
|
+
const token = state.push("front_matter", "", 0);
|
|
22220
|
+
token.block = true;
|
|
22221
|
+
token.map = [0, n + 1];
|
|
22222
|
+
token.content = n > 1 ? state.src.slice(state.bMarks[1], state.eMarks[n - 1]) : "";
|
|
22223
|
+
}
|
|
22224
|
+
state.line = n + 1;
|
|
22225
|
+
return true;
|
|
22226
|
+
}
|
|
22227
|
+
}
|
|
22228
|
+
return false;
|
|
22229
|
+
});
|
|
21988
22230
|
md2.renderer.rules.front_matter = (tokens, idx, _options, env, self) => {
|
|
21989
22231
|
const entries2 = env?.frontMatter === false ? [] : parseFrontMatter(tokens[idx].content);
|
|
21990
22232
|
const escape2 = md2.utils.escapeHtml;
|
|
@@ -22278,88 +22520,490 @@ function inRawText(tokens, idx) {
|
|
|
22278
22520
|
}
|
|
22279
22521
|
}
|
|
22280
22522
|
}
|
|
22281
|
-
return open !== void 0;
|
|
22523
|
+
return open !== void 0;
|
|
22524
|
+
}
|
|
22525
|
+
function resourceLinks(md2) {
|
|
22526
|
+
const defaultImage = md2.renderer.rules.image;
|
|
22527
|
+
md2.renderer.rules.image = (tokens, idx, options, env, self) => {
|
|
22528
|
+
const token = tokens[idx];
|
|
22529
|
+
const src = token.attrGet("src");
|
|
22530
|
+
if (src && env?.resolveResource) {
|
|
22531
|
+
token.attrSet("src", env.resolveResource(String(src)));
|
|
22532
|
+
}
|
|
22533
|
+
return defaultImage(tokens, idx, options, env, self);
|
|
22534
|
+
};
|
|
22535
|
+
for (const type of ["html_block", "html_inline"]) {
|
|
22536
|
+
const defaultHtml = md2.renderer.rules[type];
|
|
22537
|
+
md2.renderer.rules[type] = (tokens, idx, options, env, self) => {
|
|
22538
|
+
const html2 = defaultHtml(tokens, idx, options, env, self);
|
|
22539
|
+
const resolve = env?.resolveResource;
|
|
22540
|
+
const rendered = tokens[idx].meta?.[RENDERED_HTML] === true;
|
|
22541
|
+
if (!resolve || rendered || type === "html_inline" && inRawText(tokens, idx)) {
|
|
22542
|
+
return html2;
|
|
22543
|
+
}
|
|
22544
|
+
return resolveHtmlImages(md2, html2, resolve);
|
|
22545
|
+
};
|
|
22546
|
+
}
|
|
22547
|
+
}
|
|
22548
|
+
function createMarkdown() {
|
|
22549
|
+
const md2 = MarkdownItCallable({ html: true, linkify: true });
|
|
22550
|
+
md2.use(footnote_plugin).use(markdownExtras).use(tableOptions).use(wireframes).use(headingIds).use(sourceLines).use(mermaidFence).use(wireframeBlock).use(resourceLinks);
|
|
22551
|
+
return md2;
|
|
22552
|
+
}
|
|
22553
|
+
function renderDocument(md2, source, env = {}) {
|
|
22554
|
+
return renderTokens(md2, md2.parse(source, env), env);
|
|
22555
|
+
}
|
|
22556
|
+
function renderTokens(md2, tokens, env) {
|
|
22557
|
+
const t = env.t ?? formatMessage;
|
|
22558
|
+
const { diagrams, warnings: linkWarnings } = linkDiagrams(tokens, t);
|
|
22559
|
+
const warnings = [...linkWarnings, ...tableWarnings(tokens)].sort((a, b) => a.line - b.line);
|
|
22560
|
+
for (const diagram of diagrams) {
|
|
22561
|
+
const fence2 = tokens[diagram.fenceIndex];
|
|
22562
|
+
fence2.meta = { ...fence2.meta, seqNotes: diagram };
|
|
22563
|
+
const wording = diagramWording(diagram.kind, t);
|
|
22564
|
+
for (const index of env.forExport ? [] : diagram.unlinkedHeadings) {
|
|
22565
|
+
tokens[index].attrJoin("class", "seqnotes-unlinked");
|
|
22566
|
+
tokens[index].attrSet("title", wording.unlinkedHeadingTitle);
|
|
22567
|
+
tokens[index].attrSet("data-seqnotes-mark", wording.unlinkedHeadingMark);
|
|
22568
|
+
}
|
|
22569
|
+
for (const row of diagram.rows) {
|
|
22570
|
+
if (row.target) {
|
|
22571
|
+
tokens[row.index].attrSet("data-seqnotes-section", row.target);
|
|
22572
|
+
tokens[row.index].attrJoin("class", "seqnotes-row");
|
|
22573
|
+
} else if (row.unlinked && !env.forExport) {
|
|
22574
|
+
const rows = rowWording(t);
|
|
22575
|
+
tokens[row.index].attrJoin("class", "seqnotes-unlinked");
|
|
22576
|
+
tokens[row.cell].attrSet("title", rows.title);
|
|
22577
|
+
tokens[row.cell].attrSet("data-seqnotes-mark", rows.mark);
|
|
22578
|
+
}
|
|
22579
|
+
}
|
|
22580
|
+
}
|
|
22581
|
+
const render = (slice) => md2.renderer.render(slice, md2.options, env);
|
|
22582
|
+
let html2 = "";
|
|
22583
|
+
if (warnings.length > 0 && !env.forExport) {
|
|
22584
|
+
const key = warnings.map((w) => w.message).join("\n");
|
|
22585
|
+
html2 += `<div class="seqnotes-warnings" data-seqnotes-key="${escapeHtml2(key)}">`;
|
|
22586
|
+
for (const w of warnings) {
|
|
22587
|
+
html2 += `<p data-seqnotes-jump="${w.line}">${escapeHtml2(t("\u26A0 Line {0}: {1}", w.line + 1, w.message))}</p>`;
|
|
22588
|
+
}
|
|
22589
|
+
html2 += "</div>\n";
|
|
22590
|
+
}
|
|
22591
|
+
let pos = 0;
|
|
22592
|
+
for (const diagram of diagrams) {
|
|
22593
|
+
if (!diagram.paired) {
|
|
22594
|
+
continue;
|
|
22595
|
+
}
|
|
22596
|
+
html2 += render(tokens.slice(pos, diagram.fenceIndex));
|
|
22597
|
+
html2 += `<div class="seqnotes-pair${diagram.stacked ? " seqnotes-pair-stacked" : ""}" data-diagram="${diagram.id}">`;
|
|
22598
|
+
html2 += `<div class="seqnotes-seq-col">${render(tokens.slice(diagram.fenceIndex, diagram.fenceIndex + 1))}</div>`;
|
|
22599
|
+
html2 += `<div class="seqnotes-overview-col">${render(tokens.slice(diagram.fenceIndex + 1, diagram.rangeEnd))}</div>`;
|
|
22600
|
+
html2 += "</div>\n";
|
|
22601
|
+
pos = diagram.rangeEnd;
|
|
22602
|
+
}
|
|
22603
|
+
html2 += render(tokens.slice(pos));
|
|
22604
|
+
return html2;
|
|
22605
|
+
}
|
|
22606
|
+
|
|
22607
|
+
// src/diff/textDiff.ts
|
|
22608
|
+
var WORD_RE = /[\p{L}\p{N}_]+|\s+|[^]/gu;
|
|
22609
|
+
var UNSPACED_RE = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Thai}]/u;
|
|
22610
|
+
function wordSegmenter(lang) {
|
|
22611
|
+
try {
|
|
22612
|
+
return typeof Intl.Segmenter === "function" ? new Intl.Segmenter(lang, { granularity: "word" }) : void 0;
|
|
22613
|
+
} catch {
|
|
22614
|
+
return void 0;
|
|
22615
|
+
}
|
|
22616
|
+
}
|
|
22617
|
+
function splitWords(text3, segmenter2) {
|
|
22618
|
+
const words2 = [];
|
|
22619
|
+
for (const [word] of text3.matchAll(WORD_RE)) {
|
|
22620
|
+
if (word.length > 1 && UNSPACED_RE.test(word)) {
|
|
22621
|
+
if (segmenter2) {
|
|
22622
|
+
for (const { segment } of segmenter2.segment(word)) {
|
|
22623
|
+
words2.push(segment);
|
|
22624
|
+
}
|
|
22625
|
+
} else {
|
|
22626
|
+
words2.push(...word);
|
|
22627
|
+
}
|
|
22628
|
+
} else {
|
|
22629
|
+
words2.push(word);
|
|
22630
|
+
}
|
|
22631
|
+
}
|
|
22632
|
+
return words2;
|
|
22633
|
+
}
|
|
22634
|
+
var MAX_EDIT_LENGTH = 2e3;
|
|
22635
|
+
function diffWordLists(before, after) {
|
|
22636
|
+
return diffArrays(before, after, { maxEditLength: MAX_EDIT_LENGTH })?.map((change) => ({
|
|
22637
|
+
type: change.added ? "added" : change.removed ? "removed" : "equal",
|
|
22638
|
+
tokens: change.value
|
|
22639
|
+
}));
|
|
22640
|
+
}
|
|
22641
|
+
function groupChanges(changes) {
|
|
22642
|
+
const grouped = [];
|
|
22643
|
+
let removed = [];
|
|
22644
|
+
let added = [];
|
|
22645
|
+
const flush = () => {
|
|
22646
|
+
if (removed.length > 0) {
|
|
22647
|
+
grouped.push({ type: "removed", tokens: removed });
|
|
22648
|
+
}
|
|
22649
|
+
if (added.length > 0) {
|
|
22650
|
+
grouped.push({ type: "added", tokens: added });
|
|
22651
|
+
}
|
|
22652
|
+
removed = [];
|
|
22653
|
+
added = [];
|
|
22654
|
+
};
|
|
22655
|
+
changes.forEach((change, i) => {
|
|
22656
|
+
if (change.type === "removed") {
|
|
22657
|
+
removed.push(...change.tokens);
|
|
22658
|
+
} else if (change.type === "added") {
|
|
22659
|
+
added.push(...change.tokens);
|
|
22660
|
+
} else if ((removed.length > 0 || added.length > 0) && i + 1 < changes.length && change.tokens.join("").trim().length <= 1) {
|
|
22661
|
+
removed.push(...change.tokens);
|
|
22662
|
+
added.push(...change.tokens);
|
|
22663
|
+
} else {
|
|
22664
|
+
flush();
|
|
22665
|
+
grouped.push(change);
|
|
22666
|
+
}
|
|
22667
|
+
});
|
|
22668
|
+
flush();
|
|
22669
|
+
return grouped;
|
|
22670
|
+
}
|
|
22671
|
+
function similarity(before, after, segmenter2) {
|
|
22672
|
+
if (before === after) {
|
|
22673
|
+
return 1;
|
|
22674
|
+
}
|
|
22675
|
+
const total = before.length + after.length;
|
|
22676
|
+
if (total === 0) {
|
|
22677
|
+
return 1;
|
|
22678
|
+
}
|
|
22679
|
+
let common = 0;
|
|
22680
|
+
for (const change of diffWordLists(splitWords(before, segmenter2), splitWords(after, segmenter2)) ?? []) {
|
|
22681
|
+
if (change.type === "equal") {
|
|
22682
|
+
common += change.tokens.join("").length;
|
|
22683
|
+
}
|
|
22684
|
+
}
|
|
22685
|
+
return 2 * common / total;
|
|
22686
|
+
}
|
|
22687
|
+
|
|
22688
|
+
// src/diff/diffRender.ts
|
|
22689
|
+
var SIMILAR = 0.4;
|
|
22690
|
+
var CONTAINERS = /* @__PURE__ */ new Set(["bullet_list_open", "ordered_list_open", "table_open"]);
|
|
22691
|
+
var WRAPPED = /* @__PURE__ */ new Set(["fence", "html_block", "front_matter"]);
|
|
22692
|
+
var isWrapped = (token) => WRAPPED.has(token.type) && !isMermaidFence(token);
|
|
22693
|
+
function isCommentsOnly(html2) {
|
|
22694
|
+
let s = html2.trim();
|
|
22695
|
+
if (!s.startsWith("<!--")) {
|
|
22696
|
+
return false;
|
|
22697
|
+
}
|
|
22698
|
+
while (s.startsWith("<!--")) {
|
|
22699
|
+
const end = s.indexOf("-->", 4);
|
|
22700
|
+
if (end < 0) {
|
|
22701
|
+
return false;
|
|
22702
|
+
}
|
|
22703
|
+
s = s.slice(end + 3).trimStart();
|
|
22704
|
+
}
|
|
22705
|
+
return s === "";
|
|
22706
|
+
}
|
|
22707
|
+
var LIST_MARKER_RE = /^[ \t]*(?:[-*+]|\d{1,9}[.)])[ \t]?/;
|
|
22708
|
+
var SPACED = /* @__PURE__ */ new Set(["fence", "mermaid", "code_block", "html_block"]);
|
|
22709
|
+
var MAX_COMPARED_PAIRS = 2500;
|
|
22710
|
+
function kindOf(token) {
|
|
22711
|
+
if (token.type === "heading_open") {
|
|
22712
|
+
return token.tag;
|
|
22713
|
+
}
|
|
22714
|
+
if (token.type === "fence") {
|
|
22715
|
+
return isMermaidFence(token) ? "mermaid" : "fence";
|
|
22716
|
+
}
|
|
22717
|
+
return token.type;
|
|
22718
|
+
}
|
|
22719
|
+
function unitsOf(tokens, lines, start, end, level, env) {
|
|
22720
|
+
const units = [];
|
|
22721
|
+
for (let i = start; i < end; ) {
|
|
22722
|
+
const token = tokens[i];
|
|
22723
|
+
if (token.level !== level || token.nesting === -1 || !token.block) {
|
|
22724
|
+
i++;
|
|
22725
|
+
continue;
|
|
22726
|
+
}
|
|
22727
|
+
let close = i;
|
|
22728
|
+
if (token.nesting === 1) {
|
|
22729
|
+
while (close < end && !(tokens[close].level === level && tokens[close].nesting === -1)) {
|
|
22730
|
+
close++;
|
|
22731
|
+
}
|
|
22732
|
+
}
|
|
22733
|
+
if (token.map) {
|
|
22734
|
+
const kind = kindOf(token);
|
|
22735
|
+
let key = lines.slice(token.map[0], token.map[1]).join("\n");
|
|
22736
|
+
if (token.type === "list_item_open") {
|
|
22737
|
+
key = key.replace(LIST_MARKER_RE, "");
|
|
22738
|
+
}
|
|
22739
|
+
key = SPACED.has(kind) ? key.trimEnd() : key.replace(/\s+/g, " ").trim();
|
|
22740
|
+
const hidden = token.type === "html_block" && isCommentsOnly(token.content) || token.type === "front_matter" && env.frontMatter === false;
|
|
22741
|
+
units.push({ start: i, end: close + 1, key, kind, hidden });
|
|
22742
|
+
}
|
|
22743
|
+
i = close + 1;
|
|
22744
|
+
}
|
|
22745
|
+
return units;
|
|
22282
22746
|
}
|
|
22283
|
-
function
|
|
22284
|
-
const
|
|
22285
|
-
|
|
22286
|
-
|
|
22287
|
-
|
|
22288
|
-
|
|
22289
|
-
|
|
22747
|
+
function align(before, after, alike) {
|
|
22748
|
+
const ops = [];
|
|
22749
|
+
let removed = [];
|
|
22750
|
+
let added = [];
|
|
22751
|
+
const flush = () => {
|
|
22752
|
+
const pairs = [];
|
|
22753
|
+
const compareText = removed.length * added.length <= MAX_COMPARED_PAIRS;
|
|
22754
|
+
let next = 0;
|
|
22755
|
+
added.forEach((b, j3) => {
|
|
22756
|
+
const i3 = removed.findIndex((a, k) => k >= next && alike(a, b, compareText));
|
|
22757
|
+
if (i3 >= 0) {
|
|
22758
|
+
pairs.push([i3, j3]);
|
|
22759
|
+
next = i3 + 1;
|
|
22760
|
+
}
|
|
22761
|
+
});
|
|
22762
|
+
let i2 = 0;
|
|
22763
|
+
let j2 = 0;
|
|
22764
|
+
for (const [pi, pj] of [...pairs, [removed.length, added.length]]) {
|
|
22765
|
+
while (i2 < pi) {
|
|
22766
|
+
ops.push({ type: "deleted", before: removed[i2++] });
|
|
22767
|
+
}
|
|
22768
|
+
while (j2 < pj) {
|
|
22769
|
+
ops.push({ type: "added", after: added[j2++] });
|
|
22770
|
+
}
|
|
22771
|
+
if (pi < removed.length) {
|
|
22772
|
+
ops.push({ type: "changed", before: removed[pi], after: added[pj] });
|
|
22773
|
+
i2 = pi + 1;
|
|
22774
|
+
j2 = pj + 1;
|
|
22775
|
+
}
|
|
22290
22776
|
}
|
|
22291
|
-
|
|
22777
|
+
removed = [];
|
|
22778
|
+
added = [];
|
|
22292
22779
|
};
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
|
|
22299
|
-
|
|
22300
|
-
|
|
22780
|
+
let i = 0;
|
|
22781
|
+
let j = 0;
|
|
22782
|
+
for (const change of diffArrays(
|
|
22783
|
+
before.map((u) => u.key),
|
|
22784
|
+
after.map((u) => u.key)
|
|
22785
|
+
)) {
|
|
22786
|
+
if (change.removed) {
|
|
22787
|
+
removed.push(...before.slice(i, i += change.count));
|
|
22788
|
+
} else if (change.added) {
|
|
22789
|
+
added.push(...after.slice(j, j += change.count));
|
|
22790
|
+
} else {
|
|
22791
|
+
flush();
|
|
22792
|
+
for (let k = 0; k < change.count; k++) {
|
|
22793
|
+
ops.push({ type: "equal", before: before[i++], after: after[j++] });
|
|
22301
22794
|
}
|
|
22302
|
-
|
|
22303
|
-
};
|
|
22795
|
+
}
|
|
22304
22796
|
}
|
|
22305
|
-
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
|
|
22316
|
-
|
|
22317
|
-
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
|
|
22324
|
-
|
|
22325
|
-
|
|
22797
|
+
flush();
|
|
22798
|
+
return ops;
|
|
22799
|
+
}
|
|
22800
|
+
function renderDiff(md2, beforeSource, afterSource, env = {}) {
|
|
22801
|
+
const segmenter2 = wordSegmenter();
|
|
22802
|
+
const beforeEnv = {
|
|
22803
|
+
resolveResource: env.resolveResource,
|
|
22804
|
+
t: env.t,
|
|
22805
|
+
frontMatter: env.frontMatter,
|
|
22806
|
+
headingNumbers: env.headingNumbers,
|
|
22807
|
+
messageWrapWidth: env.messageWrapWidth,
|
|
22808
|
+
wireframes: env.wireframes,
|
|
22809
|
+
forExport: true,
|
|
22810
|
+
docId: "seqnotes-old"
|
|
22811
|
+
};
|
|
22812
|
+
const beforeTokens = md2.parse(beforeSource, beforeEnv);
|
|
22813
|
+
const afterTokens = md2.parse(afterSource, env);
|
|
22814
|
+
for (const token of beforeTokens) {
|
|
22815
|
+
if (token.type === "heading_open" && token.attrs) {
|
|
22816
|
+
token.attrs = token.attrs.filter(([name]) => name !== "id");
|
|
22817
|
+
}
|
|
22818
|
+
}
|
|
22819
|
+
const beforeLines = beforeSource.split(/\r\n?|\n/);
|
|
22820
|
+
const afterLines = afterSource.split(/\r\n?|\n/);
|
|
22821
|
+
const old = [];
|
|
22822
|
+
const stats = { added: 0, changed: 0, deleted: 0 };
|
|
22823
|
+
const inserted = /* @__PURE__ */ new Map();
|
|
22824
|
+
const insert = (index, token) => {
|
|
22825
|
+
inserted.set(index, [...inserted.get(index) ?? [], token]);
|
|
22826
|
+
};
|
|
22827
|
+
const htmlToken = (content, level) => {
|
|
22828
|
+
const token = new MarkdownItCallable.Token("html_block", "", 0);
|
|
22829
|
+
token.content = content;
|
|
22830
|
+
token.block = true;
|
|
22831
|
+
token.level = level;
|
|
22832
|
+
token.meta = { [RENDERED_HTML]: true };
|
|
22833
|
+
return token;
|
|
22834
|
+
};
|
|
22835
|
+
const wrapped = (mark2, html2) => `<div class="seqnotes-diff-block" data-seqnotes-diff="${mark2}">
|
|
22836
|
+
${html2}</div>
|
|
22837
|
+
`;
|
|
22838
|
+
const renderBefore = (unit) => md2.renderer.render(beforeTokens.slice(unit.start, unit.end), md2.options, beforeEnv);
|
|
22839
|
+
const mark = (unit, value, oldIndex) => {
|
|
22840
|
+
const token = afterTokens[unit.start];
|
|
22841
|
+
if (isWrapped(token)) {
|
|
22842
|
+
const attrs = oldIndex === void 0 ? "" : ` data-seqnotes-diff-old="${oldIndex}"`;
|
|
22843
|
+
insert(unit.start, htmlToken(`<div class="seqnotes-diff-block" data-seqnotes-diff="${value}"${attrs}>
|
|
22844
|
+
`, token.level));
|
|
22845
|
+
insert(unit.end, htmlToken("</div>\n", token.level));
|
|
22846
|
+
return;
|
|
22326
22847
|
}
|
|
22327
|
-
|
|
22328
|
-
|
|
22329
|
-
|
|
22330
|
-
tokens[row.index].attrJoin("class", "seqnotes-row");
|
|
22331
|
-
} else if (row.unlinked && !env.forExport) {
|
|
22332
|
-
const rows = rowWording(t);
|
|
22333
|
-
tokens[row.index].attrJoin("class", "seqnotes-unlinked");
|
|
22334
|
-
tokens[row.cell].attrSet("title", rows.title);
|
|
22335
|
-
tokens[row.cell].attrSet("data-seqnotes-mark", rows.mark);
|
|
22336
|
-
}
|
|
22848
|
+
token.attrSet("data-seqnotes-diff", value);
|
|
22849
|
+
if (oldIndex !== void 0) {
|
|
22850
|
+
token.attrSet("data-seqnotes-diff-old", String(oldIndex));
|
|
22337
22851
|
}
|
|
22338
|
-
}
|
|
22339
|
-
const
|
|
22340
|
-
|
|
22341
|
-
|
|
22342
|
-
|
|
22343
|
-
|
|
22344
|
-
|
|
22345
|
-
|
|
22852
|
+
};
|
|
22853
|
+
const alike = (a, b, compareText) => a.kind === b.kind && (CONTAINERS.has(a.kind) || a.kind === "mermaid" || compareText && similarity(a.key, b.key, segmenter2) >= SIMILAR);
|
|
22854
|
+
const numberItems = (tokens2, list2, items) => {
|
|
22855
|
+
const start = Number(tokens2[list2.start].attrGet("start") ?? 1);
|
|
22856
|
+
items.forEach((item, i) => tokens2[item.start].attrSet("value", String(start + i)));
|
|
22857
|
+
};
|
|
22858
|
+
const compare = (before, after, level) => {
|
|
22859
|
+
const ops = align(before, after, alike);
|
|
22860
|
+
let deleted = [];
|
|
22861
|
+
const flushDeleted = (index) => {
|
|
22862
|
+
for (const unit of deleted) {
|
|
22863
|
+
const token = beforeTokens[unit.start];
|
|
22864
|
+
let html2;
|
|
22865
|
+
if (isWrapped(token)) {
|
|
22866
|
+
html2 = wrapped("deleted", renderBefore(unit));
|
|
22867
|
+
} else {
|
|
22868
|
+
token.attrSet("data-seqnotes-diff", "deleted");
|
|
22869
|
+
html2 = renderBefore(unit);
|
|
22870
|
+
}
|
|
22871
|
+
insert(index, htmlToken(html2, level));
|
|
22872
|
+
stats.deleted++;
|
|
22873
|
+
}
|
|
22874
|
+
deleted = [];
|
|
22875
|
+
};
|
|
22876
|
+
for (const op of ops) {
|
|
22877
|
+
if (op.type === "deleted") {
|
|
22878
|
+
if (!op.before.hidden) {
|
|
22879
|
+
deleted.push(op.before);
|
|
22880
|
+
}
|
|
22881
|
+
continue;
|
|
22882
|
+
}
|
|
22883
|
+
flushDeleted(op.after.start);
|
|
22884
|
+
if (op.after.hidden) {
|
|
22885
|
+
continue;
|
|
22886
|
+
}
|
|
22887
|
+
if (op.type === "added") {
|
|
22888
|
+
mark(op.after, "added");
|
|
22889
|
+
stats.added++;
|
|
22890
|
+
} else if (op.type === "changed") {
|
|
22891
|
+
const kind = op.after.kind;
|
|
22892
|
+
if (CONTAINERS.has(kind)) {
|
|
22893
|
+
const depth = kind === "table_open" ? 2 : 1;
|
|
22894
|
+
const beforeItems = unitsOf(beforeTokens, beforeLines, op.before.start + 1, op.before.end - 1, level + depth, beforeEnv);
|
|
22895
|
+
const afterItems = unitsOf(afterTokens, afterLines, op.after.start + 1, op.after.end - 1, level + depth, env);
|
|
22896
|
+
if (kind === "ordered_list_open") {
|
|
22897
|
+
numberItems(beforeTokens, op.before, beforeItems);
|
|
22898
|
+
numberItems(afterTokens, op.after, afterItems);
|
|
22899
|
+
}
|
|
22900
|
+
compare(beforeItems, afterItems, level + depth);
|
|
22901
|
+
} else {
|
|
22902
|
+
old.push(renderBefore(op.before));
|
|
22903
|
+
mark(op.after, "changed", old.length - 1);
|
|
22904
|
+
stats.changed++;
|
|
22905
|
+
}
|
|
22906
|
+
}
|
|
22346
22907
|
}
|
|
22347
|
-
|
|
22348
|
-
}
|
|
22349
|
-
|
|
22350
|
-
|
|
22351
|
-
|
|
22352
|
-
|
|
22908
|
+
flushDeleted(after.length > 0 ? after[after.length - 1].end : 0);
|
|
22909
|
+
};
|
|
22910
|
+
compare(unitsOf(beforeTokens, beforeLines, 0, beforeTokens.length, 0, beforeEnv), unitsOf(afterTokens, afterLines, 0, afterTokens.length, 0, env), 0);
|
|
22911
|
+
const tokens = [];
|
|
22912
|
+
for (let i = 0; i <= afterTokens.length; i++) {
|
|
22913
|
+
tokens.push(...inserted.get(i) ?? []);
|
|
22914
|
+
if (i < afterTokens.length) {
|
|
22915
|
+
tokens.push(afterTokens[i]);
|
|
22353
22916
|
}
|
|
22354
|
-
html2 += render(tokens.slice(pos, diagram.fenceIndex));
|
|
22355
|
-
html2 += `<div class="seqnotes-pair${diagram.stacked ? " seqnotes-pair-stacked" : ""}" data-diagram="${diagram.id}">`;
|
|
22356
|
-
html2 += `<div class="seqnotes-seq-col">${render(tokens.slice(diagram.fenceIndex, diagram.fenceIndex + 1))}</div>`;
|
|
22357
|
-
html2 += `<div class="seqnotes-overview-col">${render(tokens.slice(diagram.fenceIndex + 1, diagram.rangeEnd))}</div>`;
|
|
22358
|
-
html2 += "</div>\n";
|
|
22359
|
-
pos = diagram.rangeEnd;
|
|
22360
22917
|
}
|
|
22361
|
-
|
|
22362
|
-
|
|
22918
|
+
return { html: renderTokens(md2, tokens, env), old, stats };
|
|
22919
|
+
}
|
|
22920
|
+
|
|
22921
|
+
// src/export/exportPage.ts
|
|
22922
|
+
var SCHEME_RE2 = /^[a-z][a-z0-9+.-]*:/i;
|
|
22923
|
+
var isExternalUrl = (src) => SCHEME_RE2.test(src) || src.startsWith("//") || src.startsWith("#");
|
|
22924
|
+
function frontMatterEntries(tokens) {
|
|
22925
|
+
return tokens[0]?.type === "front_matter" ? parseFrontMatter(tokens[0].content) : [];
|
|
22926
|
+
}
|
|
22927
|
+
function titleOf(tokens, fallback) {
|
|
22928
|
+
const title = frontMatterValue(frontMatterEntries(tokens), "title")?.trim();
|
|
22929
|
+
if (title) {
|
|
22930
|
+
return title;
|
|
22931
|
+
}
|
|
22932
|
+
const h1 = tokens.findIndex((t) => t.type === "heading_open" && t.tag === "h1");
|
|
22933
|
+
return h1 >= 0 && headingText(tokens[h1 + 1]).trim() || fallback;
|
|
22934
|
+
}
|
|
22935
|
+
function documentTitle(md2, source, fallback) {
|
|
22936
|
+
return titleOf(md2.parse(source, {}), fallback);
|
|
22937
|
+
}
|
|
22938
|
+
var RESOURCE_PLACEHOLDER = "seqnotes-export-resource:";
|
|
22939
|
+
var PLACEHOLDER_RE = new RegExp(`${RESOURCE_PLACEHOLDER}(\\d+)`, "g");
|
|
22940
|
+
async function withImages(render, resolveImage) {
|
|
22941
|
+
const images = [];
|
|
22942
|
+
const result = render((src) => {
|
|
22943
|
+
if (isExternalUrl(src)) {
|
|
22944
|
+
return src;
|
|
22945
|
+
}
|
|
22946
|
+
images.push(src);
|
|
22947
|
+
return `${RESOURCE_PLACEHOLDER}${images.length - 1}`;
|
|
22948
|
+
});
|
|
22949
|
+
const resolved = await Promise.all(
|
|
22950
|
+
images.map(async (src) => {
|
|
22951
|
+
const url = await resolveImage(src);
|
|
22952
|
+
const suffix = /[?#].*$/s.exec(src)?.[0] ?? "";
|
|
22953
|
+
return url.startsWith("data:") ? url : url + suffix;
|
|
22954
|
+
})
|
|
22955
|
+
);
|
|
22956
|
+
return { result, resolve: (html2) => html2.replace(PLACEHOLDER_RE, (_, i) => escapeHtml2(resolved[Number(i)])) };
|
|
22957
|
+
}
|
|
22958
|
+
async function renderForExport(md2, source, env, resolveImage) {
|
|
22959
|
+
const { result, resolve } = await withImages((resolveResource) => renderDocument(md2, source, { ...env, forExport: true, resolveResource }), resolveImage);
|
|
22960
|
+
return resolve(result);
|
|
22961
|
+
}
|
|
22962
|
+
async function renderDiffForExport(md2, beforeSource, afterSource, env, resolveImage) {
|
|
22963
|
+
const { result, resolve } = await withImages(
|
|
22964
|
+
(resolveResource) => renderDiff(md2, beforeSource, afterSource, { ...env, forExport: true, resolveResource }),
|
|
22965
|
+
resolveImage
|
|
22966
|
+
);
|
|
22967
|
+
return { html: resolve(result.html), old: result.old.map(resolve), stats: result.stats };
|
|
22968
|
+
}
|
|
22969
|
+
var DIFF_TITLES = ["diff-added", "diff-changed", "diff-deleted", "diff-no-changes", "diff-previous-title", "diff-next-title", "diff-hide-title", "diff-show-title"];
|
|
22970
|
+
function exportDiff({ label, stats }, t) {
|
|
22971
|
+
return { label, stats, titles: Object.fromEntries(DIFF_TITLES.map((name) => [`data-seqnotes-${name}`, t(WEBVIEW_TITLES[name])])) };
|
|
22972
|
+
}
|
|
22973
|
+
function exportPage({ lang, title, body, styles, script, settings, tocTitle, splitterTitle, diff }) {
|
|
22974
|
+
const classes = [
|
|
22975
|
+
"seqnotes-viewer",
|
|
22976
|
+
"seqnotes-export",
|
|
22977
|
+
...settings.limitContentWidth ? ["seqnotes-limit-width"] : [],
|
|
22978
|
+
...settings.stickyTableHeader ? ["seqnotes-sticky-table-header"] : [],
|
|
22979
|
+
...settings.tableTreeHighlight ? ["seqnotes-table-tree-highlight"] : []
|
|
22980
|
+
];
|
|
22981
|
+
const splitMinWidth = Number.isFinite(Number(settings.splitMinWidth)) ? Number(settings.splitMinWidth) : 1e3;
|
|
22982
|
+
const tocAttrs = settings.toc ? ` data-seqnotes-toc data-seqnotes-toc-title="${escapeHtml2(tocTitle ?? "")}"` : "";
|
|
22983
|
+
const splitterAttrs = splitterTitle ? ` data-seqnotes-splitter-title="${escapeHtml2(splitterTitle)}"` : "";
|
|
22984
|
+
const diffAttrs = diff ? Object.entries({
|
|
22985
|
+
"data-seqnotes-diff-label": diff.label,
|
|
22986
|
+
"data-seqnotes-diff-stats": `${diff.stats.added},${diff.stats.changed},${diff.stats.deleted}`,
|
|
22987
|
+
...diff.titles
|
|
22988
|
+
}).map(([name, value]) => ` ${name}="${escapeHtml2(value)}"`).join("") : "";
|
|
22989
|
+
return `<!DOCTYPE html>
|
|
22990
|
+
<html lang="${escapeHtml2(lang)}">
|
|
22991
|
+
<head>
|
|
22992
|
+
<meta charset="UTF-8">
|
|
22993
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
22994
|
+
<title>${escapeHtml2(title)}</title>
|
|
22995
|
+
<style>
|
|
22996
|
+
${styles.join("\n").replace(/<\/style/gi, "<\\/style")}
|
|
22997
|
+
</style>
|
|
22998
|
+
</head>
|
|
22999
|
+
<body data-seqnotes-theme="light" class="${classes.join(" ")}" data-seqnotes-split-min-width="${splitMinWidth}"${splitterAttrs}${tocAttrs}${diffAttrs}>
|
|
23000
|
+
<div id="seqnotes-root" class="seqnotes-viewer-root">${body}</div>
|
|
23001
|
+
<script>
|
|
23002
|
+
${script.replace(/<\/script/gi, "<\\/script")}
|
|
23003
|
+
<\/script>
|
|
23004
|
+
</body>
|
|
23005
|
+
</html>
|
|
23006
|
+
`;
|
|
22363
23007
|
}
|
|
22364
23008
|
|
|
22365
23009
|
// node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
|
|
@@ -24001,710 +24645,426 @@ function createDOMPurify() {
|
|
|
24001
24645
|
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
24002
24646
|
if (typeof realTagName !== "string") return false;
|
|
24003
24647
|
if (transformCaseFunc(realTagName) !== "form") return false;
|
|
24004
|
-
return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
|
|
24005
|
-
};
|
|
24006
|
-
const _isDocumentFragment = function _isDocumentFragment2(value) {
|
|
24007
|
-
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
24008
|
-
try {
|
|
24009
|
-
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
24010
|
-
} catch (_) {
|
|
24011
|
-
return false;
|
|
24012
|
-
}
|
|
24013
|
-
};
|
|
24014
|
-
const _isNode = function _isNode2(value) {
|
|
24015
|
-
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
24016
|
-
try {
|
|
24017
|
-
return typeof getNodeType(value) === "number";
|
|
24018
|
-
} catch (_) {
|
|
24019
|
-
return false;
|
|
24020
|
-
}
|
|
24021
|
-
};
|
|
24022
|
-
function _executeHooks(hooks2, currentNode, data) {
|
|
24023
|
-
if (hooks2.length === 0) return;
|
|
24024
|
-
arrayForEach(hooks2, (hook) => {
|
|
24025
|
-
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
24026
|
-
});
|
|
24027
|
-
}
|
|
24028
|
-
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
24029
|
-
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
|
|
24030
|
-
if (SAFE_FOR_XML && LITERAL_TEXT_ELEMENTS[tagName] && _readNodeType(currentNode) === NODE_TYPE.element && _readNamespaceURI(currentNode) === HTML_NAMESPACE && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent))) return true;
|
|
24031
|
-
if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
|
|
24032
|
-
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
|
|
24033
|
-
return false;
|
|
24034
|
-
};
|
|
24035
|
-
const _matchesNameCheck = function _matchesNameCheck2(check, name) {
|
|
24036
|
-
if (check instanceof RegExp) return regExpTest(check, name);
|
|
24037
|
-
if (check instanceof Function) {
|
|
24038
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
|
|
24039
|
-
return Boolean(check(name, ...args));
|
|
24040
|
-
}
|
|
24041
|
-
return false;
|
|
24042
|
-
};
|
|
24043
|
-
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
|
|
24044
|
-
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
24045
|
-
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
|
|
24046
|
-
const parentNode = getParentNode(currentNode);
|
|
24047
|
-
const childNodes = getChildNodes(currentNode);
|
|
24048
|
-
if (childNodes && parentNode) {
|
|
24049
|
-
const childCount = childNodes.length;
|
|
24050
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
24051
|
-
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
24052
|
-
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
24053
|
-
}
|
|
24054
|
-
}
|
|
24055
|
-
}
|
|
24056
|
-
_forceRemove(currentNode);
|
|
24057
|
-
return true;
|
|
24058
|
-
};
|
|
24059
|
-
const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
|
|
24060
|
-
if (hookList.length === 0) return set;
|
|
24061
|
-
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
24062
|
-
};
|
|
24063
|
-
const _handleHookDetachedNode = function _handleHookDetachedNode2(currentNode, root) {
|
|
24064
|
-
if (currentNode === root || getParentNode(currentNode) !== null) return false;
|
|
24065
|
-
if (IN_PLACE) _neutralizeSubtree(currentNode);
|
|
24066
|
-
return true;
|
|
24067
|
-
};
|
|
24068
|
-
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
24069
|
-
_markVisited(currentNode);
|
|
24070
|
-
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
24071
|
-
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
24072
|
-
if (_isClobbered(currentNode)) {
|
|
24073
|
-
_forceRemove(currentNode);
|
|
24074
|
-
return true;
|
|
24075
|
-
}
|
|
24076
|
-
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
24077
|
-
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
24078
|
-
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
24079
|
-
tagName,
|
|
24080
|
-
allowedTags: ALLOWED_TAGS
|
|
24081
|
-
});
|
|
24082
|
-
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
24083
|
-
if (_isUnsafeNode(currentNode, tagName)) {
|
|
24084
|
-
_forceRemove(currentNode);
|
|
24085
|
-
return true;
|
|
24086
|
-
}
|
|
24087
|
-
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
24088
|
-
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
24089
|
-
if (removed === false) {
|
|
24090
|
-
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
24091
|
-
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
24092
|
-
}
|
|
24093
|
-
return removed;
|
|
24094
|
-
}
|
|
24095
|
-
if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
24096
|
-
_forceRemove(currentNode);
|
|
24097
|
-
return true;
|
|
24098
|
-
}
|
|
24099
|
-
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
24100
|
-
_forceRemove(currentNode);
|
|
24101
|
-
return true;
|
|
24102
|
-
}
|
|
24103
|
-
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
24104
|
-
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
24105
|
-
if (currentNode.textContent !== content) {
|
|
24106
|
-
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
24107
|
-
currentNode.textContent = content;
|
|
24108
|
-
}
|
|
24109
|
-
}
|
|
24110
|
-
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
24111
|
-
return _handleHookDetachedNode(currentNode, root);
|
|
24112
|
-
};
|
|
24113
|
-
const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
|
24114
|
-
if (FORBID_ATTR[lcName]) return false;
|
|
24115
|
-
if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
|
|
24116
|
-
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) return false;
|
|
24117
|
-
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
24118
|
-
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
|
|
24119
|
-
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
|
|
24120
|
-
if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
|
|
24121
|
-
if (URI_SAFE_ATTRIBUTES[lcName]) return true;
|
|
24122
|
-
if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
24123
|
-
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
|
|
24124
|
-
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
24125
|
-
return !value;
|
|
24126
|
-
};
|
|
24127
|
-
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
|
|
24128
|
-
"annotation-xml",
|
|
24129
|
-
"color-profile",
|
|
24130
|
-
"font-face",
|
|
24131
|
-
"font-face-format",
|
|
24132
|
-
"font-face-name",
|
|
24133
|
-
"font-face-src",
|
|
24134
|
-
"font-face-uri",
|
|
24135
|
-
"missing-glyph"
|
|
24136
|
-
]);
|
|
24137
|
-
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
24138
|
-
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
24648
|
+
return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
|
|
24139
24649
|
};
|
|
24140
|
-
const
|
|
24141
|
-
if (
|
|
24142
|
-
|
|
24143
|
-
|
|
24144
|
-
|
|
24145
|
-
|
|
24650
|
+
const _isDocumentFragment = function _isDocumentFragment2(value) {
|
|
24651
|
+
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
24652
|
+
try {
|
|
24653
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
24654
|
+
} catch (_) {
|
|
24655
|
+
return false;
|
|
24146
24656
|
}
|
|
24147
|
-
return value;
|
|
24148
24657
|
};
|
|
24149
|
-
const
|
|
24658
|
+
const _isNode = function _isNode2(value) {
|
|
24659
|
+
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
24150
24660
|
try {
|
|
24151
|
-
|
|
24152
|
-
else currentNode.setAttribute(name, value);
|
|
24153
|
-
if (_isClobbered(currentNode)) {
|
|
24154
|
-
_forceRemove(currentNode);
|
|
24155
|
-
return false;
|
|
24156
|
-
}
|
|
24157
|
-
return true;
|
|
24661
|
+
return typeof getNodeType(value) === "number";
|
|
24158
24662
|
} catch (_) {
|
|
24159
|
-
_removeAttribute(name, currentNode);
|
|
24160
24663
|
return false;
|
|
24161
24664
|
}
|
|
24162
24665
|
};
|
|
24163
|
-
|
|
24164
|
-
if (
|
|
24165
|
-
|
|
24666
|
+
function _executeHooks(hooks2, currentNode, data) {
|
|
24667
|
+
if (hooks2.length === 0) return;
|
|
24668
|
+
arrayForEach(hooks2, (hook) => {
|
|
24669
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
24670
|
+
});
|
|
24671
|
+
}
|
|
24672
|
+
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
24673
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
|
|
24674
|
+
if (SAFE_FOR_XML && LITERAL_TEXT_ELEMENTS[tagName] && _readNodeType(currentNode) === NODE_TYPE.element && _readNamespaceURI(currentNode) === HTML_NAMESPACE && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent))) return true;
|
|
24675
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
|
|
24676
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
|
|
24677
|
+
return false;
|
|
24166
24678
|
};
|
|
24167
|
-
const
|
|
24168
|
-
|
|
24169
|
-
if (
|
|
24170
|
-
|
|
24171
|
-
|
|
24172
|
-
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
24173
|
-
const hookEvent = {
|
|
24174
|
-
attrName: "",
|
|
24175
|
-
attrValue: "",
|
|
24176
|
-
keepAttr: true,
|
|
24177
|
-
allowedAttributes: ALLOWED_ATTR,
|
|
24178
|
-
forceKeepAttr: void 0
|
|
24179
|
-
};
|
|
24180
|
-
let l = attributes.length;
|
|
24181
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
24182
|
-
while (l--) {
|
|
24183
|
-
const attr = attributes[l];
|
|
24184
|
-
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
24185
|
-
const lcName = transformCaseFunc(name);
|
|
24186
|
-
const initValue = attrValue;
|
|
24187
|
-
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
24188
|
-
let recreatedNamedProp = false;
|
|
24189
|
-
hookEvent.attrName = lcName;
|
|
24190
|
-
hookEvent.attrValue = value;
|
|
24191
|
-
hookEvent.keepAttr = true;
|
|
24192
|
-
hookEvent.forceKeepAttr = void 0;
|
|
24193
|
-
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
24194
|
-
value = hookEvent.attrValue;
|
|
24195
|
-
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
24196
|
-
_removeAttribute(name, currentNode, attr);
|
|
24197
|
-
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
24198
|
-
recreatedNamedProp = true;
|
|
24199
|
-
}
|
|
24200
|
-
if (_isUnsafeAttributeValue(name, value)) {
|
|
24201
|
-
_removeAttribute(name, currentNode, attr);
|
|
24202
|
-
continue;
|
|
24203
|
-
}
|
|
24204
|
-
if (hookEvent.forceKeepAttr) continue;
|
|
24205
|
-
if (!hookEvent.keepAttr) {
|
|
24206
|
-
_removeAttribute(name, currentNode, attr);
|
|
24207
|
-
continue;
|
|
24208
|
-
}
|
|
24209
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
24210
|
-
_removeAttribute(name, currentNode, attr);
|
|
24211
|
-
continue;
|
|
24212
|
-
}
|
|
24213
|
-
if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
|
|
24214
|
-
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
24215
|
-
_removeAttribute(name, currentNode, attr);
|
|
24216
|
-
continue;
|
|
24217
|
-
}
|
|
24218
|
-
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
24219
|
-
if (value !== initValue) {
|
|
24220
|
-
if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
|
|
24221
|
-
}
|
|
24679
|
+
const _matchesNameCheck = function _matchesNameCheck2(check, name) {
|
|
24680
|
+
if (check instanceof RegExp) return regExpTest(check, name);
|
|
24681
|
+
if (check instanceof Function) {
|
|
24682
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
|
|
24683
|
+
return Boolean(check(name, ...args));
|
|
24222
24684
|
}
|
|
24223
|
-
|
|
24224
|
-
_handleHookDetachedNode(currentNode, root);
|
|
24685
|
+
return false;
|
|
24225
24686
|
};
|
|
24226
|
-
const
|
|
24227
|
-
|
|
24228
|
-
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24232
|
-
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24236
|
-
const innerSr = getShadowRoot(shadowNode);
|
|
24237
|
-
if (_isDocumentFragment(innerSr)) {
|
|
24238
|
-
_sanitizeAttachedShadowRoots(innerSr);
|
|
24239
|
-
_sanitizeShadowDOM2(innerSr);
|
|
24687
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
|
|
24688
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
24689
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
|
|
24690
|
+
const parentNode = getParentNode(currentNode);
|
|
24691
|
+
const childNodes = getChildNodes(currentNode);
|
|
24692
|
+
if (childNodes && parentNode) {
|
|
24693
|
+
const childCount = childNodes.length;
|
|
24694
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
24695
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
24696
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
24240
24697
|
}
|
|
24241
24698
|
}
|
|
24242
24699
|
}
|
|
24243
|
-
|
|
24244
|
-
|
|
24700
|
+
_forceRemove(currentNode);
|
|
24701
|
+
return true;
|
|
24245
24702
|
};
|
|
24246
|
-
const
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
shadow: null
|
|
24250
|
-
}];
|
|
24251
|
-
while (stack.length > 0) {
|
|
24252
|
-
const item = stack.pop();
|
|
24253
|
-
if (item.shadow) {
|
|
24254
|
-
_sanitizeShadowDOM2(item.shadow);
|
|
24255
|
-
continue;
|
|
24256
|
-
}
|
|
24257
|
-
const node = item.node;
|
|
24258
|
-
const isElement = _readNodeType(node) === NODE_TYPE.element;
|
|
24259
|
-
const childNodes = getChildNodes(node);
|
|
24260
|
-
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
|
|
24261
|
-
node: childNodes[i],
|
|
24262
|
-
shadow: null
|
|
24263
|
-
});
|
|
24264
|
-
if (isElement) {
|
|
24265
|
-
const rootName = getNodeName ? getNodeName(node) : null;
|
|
24266
|
-
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
24267
|
-
const content = node.content;
|
|
24268
|
-
if (_isDocumentFragment(content)) stack.push({
|
|
24269
|
-
node: content,
|
|
24270
|
-
shadow: null
|
|
24271
|
-
});
|
|
24272
|
-
}
|
|
24273
|
-
}
|
|
24274
|
-
if (isElement) {
|
|
24275
|
-
const sr = getShadowRoot(node);
|
|
24276
|
-
if (_isDocumentFragment(sr)) stack.push({
|
|
24277
|
-
node: null,
|
|
24278
|
-
shadow: sr
|
|
24279
|
-
}, {
|
|
24280
|
-
node: sr,
|
|
24281
|
-
shadow: null
|
|
24282
|
-
});
|
|
24283
|
-
}
|
|
24284
|
-
}
|
|
24703
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
|
|
24704
|
+
if (hookList.length === 0) return set;
|
|
24705
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
24285
24706
|
};
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
|
|
24290
|
-
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
|
|
24294
|
-
if (
|
|
24295
|
-
|
|
24296
|
-
|
|
24297
|
-
|
|
24298
|
-
if (!DOMPurify.isSupported) return dirty;
|
|
24299
|
-
if (SET_CONFIG) {
|
|
24300
|
-
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
24301
|
-
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
24302
|
-
} else _parseConfig(cfg);
|
|
24303
|
-
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
24304
|
-
if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
24305
|
-
DOMPurify.removed = [];
|
|
24306
|
-
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
24307
|
-
let inPlaceNodes = [];
|
|
24308
|
-
const outerVisited = IN_PLACE_VISITED;
|
|
24309
|
-
if (inPlace) {
|
|
24310
|
-
_neutralizePatchLinkage(dirty);
|
|
24311
|
-
const nn = _readNodeName(dirty);
|
|
24312
|
-
if (typeof nn === "string") {
|
|
24313
|
-
const tagName = transformCaseFunc(nn);
|
|
24314
|
-
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
24315
|
-
_neutralizeRoot(dirty);
|
|
24316
|
-
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
24317
|
-
}
|
|
24318
|
-
}
|
|
24319
|
-
if (_isClobbered(dirty)) {
|
|
24320
|
-
_neutralizeRoot(dirty);
|
|
24321
|
-
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
24322
|
-
}
|
|
24323
|
-
inPlaceNodes = _collectLiveNodes(dirty);
|
|
24324
|
-
IN_PLACE_VISITED = setCreate();
|
|
24325
|
-
} else if (_isNode(dirty)) {
|
|
24326
|
-
body = _initDocument("<!---->");
|
|
24327
|
-
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
24328
|
-
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
|
|
24329
|
-
else if (importedNode.nodeName === "HTML") body = importedNode;
|
|
24330
|
-
else body.appendChild(importedNode);
|
|
24331
|
-
_sanitizeAttachedShadowRoots(body);
|
|
24332
|
-
} else {
|
|
24333
|
-
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
24334
|
-
body = _initDocument(dirty);
|
|
24335
|
-
if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
24707
|
+
const _handleHookDetachedNode = function _handleHookDetachedNode2(currentNode, root) {
|
|
24708
|
+
if (currentNode === root || getParentNode(currentNode) !== null) return false;
|
|
24709
|
+
if (IN_PLACE) _neutralizeSubtree(currentNode);
|
|
24710
|
+
return true;
|
|
24711
|
+
};
|
|
24712
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
24713
|
+
_markVisited(currentNode);
|
|
24714
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
24715
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
24716
|
+
if (_isClobbered(currentNode)) {
|
|
24717
|
+
_forceRemove(currentNode);
|
|
24718
|
+
return true;
|
|
24336
24719
|
}
|
|
24337
|
-
|
|
24338
|
-
|
|
24339
|
-
|
|
24340
|
-
|
|
24341
|
-
|
|
24342
|
-
|
|
24343
|
-
|
|
24344
|
-
|
|
24345
|
-
|
|
24346
|
-
|
|
24347
|
-
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
|
-
|
|
24351
|
-
|
|
24720
|
+
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
24721
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
24722
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
24723
|
+
tagName,
|
|
24724
|
+
allowedTags: ALLOWED_TAGS
|
|
24725
|
+
});
|
|
24726
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
24727
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
24728
|
+
_forceRemove(currentNode);
|
|
24729
|
+
return true;
|
|
24730
|
+
}
|
|
24731
|
+
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
24732
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
24733
|
+
if (removed === false) {
|
|
24734
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
24735
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
24352
24736
|
}
|
|
24353
|
-
|
|
24354
|
-
} finally {
|
|
24355
|
-
IN_PLACE_VISITED = outerVisited;
|
|
24737
|
+
return removed;
|
|
24356
24738
|
}
|
|
24357
|
-
if (
|
|
24358
|
-
|
|
24359
|
-
|
|
24360
|
-
return dirty;
|
|
24739
|
+
if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
24740
|
+
_forceRemove(currentNode);
|
|
24741
|
+
return true;
|
|
24361
24742
|
}
|
|
24362
|
-
if (
|
|
24363
|
-
|
|
24364
|
-
|
|
24365
|
-
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
24366
|
-
while (body.firstChild) returnNode.appendChild(body.firstChild);
|
|
24367
|
-
} else returnNode = body;
|
|
24368
|
-
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
|
|
24369
|
-
return returnNode;
|
|
24743
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
24744
|
+
_forceRemove(currentNode);
|
|
24745
|
+
return true;
|
|
24370
24746
|
}
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
24381
|
-
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
24382
|
-
};
|
|
24383
|
-
DOMPurify.clearConfig = function() {
|
|
24384
|
-
CONFIG = null;
|
|
24385
|
-
SET_CONFIG = false;
|
|
24386
|
-
SET_CONFIG_ALLOWED_TAGS = null;
|
|
24387
|
-
SET_CONFIG_ALLOWED_ATTR = null;
|
|
24388
|
-
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
24389
|
-
emptyHTML = "";
|
|
24747
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
24748
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
24749
|
+
if (currentNode.textContent !== content) {
|
|
24750
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
24751
|
+
currentNode.textContent = content;
|
|
24752
|
+
}
|
|
24753
|
+
}
|
|
24754
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
24755
|
+
return _handleHookDetachedNode(currentNode, root);
|
|
24390
24756
|
};
|
|
24391
|
-
|
|
24392
|
-
if (
|
|
24393
|
-
|
|
24394
|
-
|
|
24395
|
-
|
|
24396
|
-
|
|
24757
|
+
const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
|
24758
|
+
if (FORBID_ATTR[lcName]) return false;
|
|
24759
|
+
if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
|
|
24760
|
+
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) return false;
|
|
24761
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
24762
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
|
|
24763
|
+
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
|
|
24764
|
+
if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
|
|
24765
|
+
if (URI_SAFE_ATTRIBUTES[lcName]) return true;
|
|
24766
|
+
if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
24767
|
+
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
|
|
24768
|
+
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
24769
|
+
return !value;
|
|
24397
24770
|
};
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
|
|
24401
|
-
|
|
24771
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
|
|
24772
|
+
"annotation-xml",
|
|
24773
|
+
"color-profile",
|
|
24774
|
+
"font-face",
|
|
24775
|
+
"font-face-format",
|
|
24776
|
+
"font-face-name",
|
|
24777
|
+
"font-face-src",
|
|
24778
|
+
"font-face-uri",
|
|
24779
|
+
"missing-glyph"
|
|
24780
|
+
]);
|
|
24781
|
+
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
24782
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
24402
24783
|
};
|
|
24403
|
-
|
|
24404
|
-
if (!
|
|
24405
|
-
|
|
24406
|
-
|
|
24407
|
-
|
|
24784
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
|
|
24785
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
24786
|
+
case "TrustedHTML":
|
|
24787
|
+
return _createTrustedHTML(value);
|
|
24788
|
+
case "TrustedScriptURL":
|
|
24789
|
+
return _createTrustedScriptURL(value);
|
|
24408
24790
|
}
|
|
24409
|
-
return
|
|
24791
|
+
return value;
|
|
24410
24792
|
};
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24793
|
+
const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
|
|
24794
|
+
try {
|
|
24795
|
+
if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
|
|
24796
|
+
else currentNode.setAttribute(name, value);
|
|
24797
|
+
if (_isClobbered(currentNode)) {
|
|
24798
|
+
_forceRemove(currentNode);
|
|
24799
|
+
return false;
|
|
24800
|
+
}
|
|
24801
|
+
return true;
|
|
24802
|
+
} catch (_) {
|
|
24803
|
+
_removeAttribute(name, currentNode);
|
|
24804
|
+
return false;
|
|
24805
|
+
}
|
|
24414
24806
|
};
|
|
24415
|
-
|
|
24416
|
-
|
|
24807
|
+
const _isUnsafeAttributeValue = function _isUnsafeAttributeValue2(name, value) {
|
|
24808
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
|
|
24809
|
+
return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
|
|
24417
24810
|
};
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
callback = options;
|
|
24431
|
-
options = {};
|
|
24432
|
-
} else if ("callback" in options) {
|
|
24433
|
-
callback = options.callback;
|
|
24434
|
-
}
|
|
24435
|
-
const oldString = this.castInput(oldStr, options);
|
|
24436
|
-
const newString = this.castInput(newStr, options);
|
|
24437
|
-
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
24438
|
-
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
24439
|
-
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
24440
|
-
}
|
|
24441
|
-
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
24442
|
-
var _a;
|
|
24443
|
-
const done = (value) => {
|
|
24444
|
-
value = this.postProcess(value, options);
|
|
24445
|
-
if (callback) {
|
|
24446
|
-
setTimeout(function() {
|
|
24447
|
-
callback(value);
|
|
24448
|
-
}, 0);
|
|
24449
|
-
return void 0;
|
|
24450
|
-
} else {
|
|
24451
|
-
return value;
|
|
24452
|
-
}
|
|
24811
|
+
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode, root) {
|
|
24812
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
24813
|
+
if (_handleHookDetachedNode(currentNode, root)) return;
|
|
24814
|
+
const attributes = currentNode.attributes;
|
|
24815
|
+
if (!attributes || _isClobbered(currentNode)) return;
|
|
24816
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
24817
|
+
const hookEvent = {
|
|
24818
|
+
attrName: "",
|
|
24819
|
+
attrValue: "",
|
|
24820
|
+
keepAttr: true,
|
|
24821
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
24822
|
+
forceKeepAttr: void 0
|
|
24453
24823
|
};
|
|
24454
|
-
|
|
24455
|
-
|
|
24456
|
-
|
|
24457
|
-
|
|
24458
|
-
|
|
24459
|
-
|
|
24460
|
-
|
|
24461
|
-
|
|
24462
|
-
|
|
24463
|
-
|
|
24464
|
-
|
|
24465
|
-
|
|
24466
|
-
|
|
24467
|
-
|
|
24468
|
-
|
|
24469
|
-
|
|
24470
|
-
|
|
24471
|
-
|
|
24472
|
-
|
|
24473
|
-
|
|
24474
|
-
|
|
24475
|
-
|
|
24476
|
-
|
|
24477
|
-
|
|
24478
|
-
|
|
24479
|
-
|
|
24480
|
-
|
|
24481
|
-
|
|
24482
|
-
|
|
24483
|
-
|
|
24484
|
-
|
|
24485
|
-
|
|
24486
|
-
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
24487
|
-
} else {
|
|
24488
|
-
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
24489
|
-
}
|
|
24490
|
-
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
24491
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
24492
|
-
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
24493
|
-
} else {
|
|
24494
|
-
bestPath[diagonalPath] = basePath;
|
|
24495
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
24496
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
24497
|
-
}
|
|
24498
|
-
if (newPos + 1 >= newLen) {
|
|
24499
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
24500
|
-
}
|
|
24501
|
-
}
|
|
24824
|
+
let l = attributes.length;
|
|
24825
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
24826
|
+
while (l--) {
|
|
24827
|
+
const attr = attributes[l];
|
|
24828
|
+
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
24829
|
+
const lcName = transformCaseFunc(name);
|
|
24830
|
+
const initValue = attrValue;
|
|
24831
|
+
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
24832
|
+
let recreatedNamedProp = false;
|
|
24833
|
+
hookEvent.attrName = lcName;
|
|
24834
|
+
hookEvent.attrValue = value;
|
|
24835
|
+
hookEvent.keepAttr = true;
|
|
24836
|
+
hookEvent.forceKeepAttr = void 0;
|
|
24837
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
24838
|
+
value = hookEvent.attrValue;
|
|
24839
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
24840
|
+
_removeAttribute(name, currentNode, attr);
|
|
24841
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
24842
|
+
recreatedNamedProp = true;
|
|
24843
|
+
}
|
|
24844
|
+
if (_isUnsafeAttributeValue(name, value)) {
|
|
24845
|
+
_removeAttribute(name, currentNode, attr);
|
|
24846
|
+
continue;
|
|
24847
|
+
}
|
|
24848
|
+
if (hookEvent.forceKeepAttr) continue;
|
|
24849
|
+
if (!hookEvent.keepAttr) {
|
|
24850
|
+
_removeAttribute(name, currentNode, attr);
|
|
24851
|
+
continue;
|
|
24852
|
+
}
|
|
24853
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
24854
|
+
_removeAttribute(name, currentNode, attr);
|
|
24855
|
+
continue;
|
|
24502
24856
|
}
|
|
24503
|
-
|
|
24504
|
-
|
|
24505
|
-
|
|
24506
|
-
|
|
24507
|
-
setTimeout(function() {
|
|
24508
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
24509
|
-
return callback(void 0);
|
|
24510
|
-
}
|
|
24511
|
-
if (!execEditLength()) {
|
|
24512
|
-
exec();
|
|
24513
|
-
}
|
|
24514
|
-
}, 0);
|
|
24515
|
-
})();
|
|
24516
|
-
} else {
|
|
24517
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
24518
|
-
const ret = execEditLength();
|
|
24519
|
-
if (ret) {
|
|
24520
|
-
return ret;
|
|
24521
|
-
}
|
|
24857
|
+
if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
|
|
24858
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
24859
|
+
_removeAttribute(name, currentNode, attr);
|
|
24860
|
+
continue;
|
|
24522
24861
|
}
|
|
24523
|
-
|
|
24524
|
-
|
|
24525
|
-
|
|
24526
|
-
const last = path.lastComponent;
|
|
24527
|
-
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
24528
|
-
return {
|
|
24529
|
-
oldPos: path.oldPos + oldPosInc,
|
|
24530
|
-
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
24531
|
-
};
|
|
24532
|
-
} else {
|
|
24533
|
-
return {
|
|
24534
|
-
oldPos: path.oldPos + oldPosInc,
|
|
24535
|
-
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
24536
|
-
};
|
|
24537
|
-
}
|
|
24538
|
-
}
|
|
24539
|
-
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
24540
|
-
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
24541
|
-
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
24542
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
24543
|
-
newPos++;
|
|
24544
|
-
oldPos++;
|
|
24545
|
-
commonCount++;
|
|
24546
|
-
if (options.oneChangePerToken) {
|
|
24547
|
-
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
24862
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
24863
|
+
if (value !== initValue) {
|
|
24864
|
+
if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
|
|
24548
24865
|
}
|
|
24549
24866
|
}
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24559
|
-
|
|
24560
|
-
|
|
24561
|
-
|
|
24562
|
-
|
|
24563
|
-
|
|
24564
|
-
|
|
24565
|
-
|
|
24566
|
-
|
|
24567
|
-
|
|
24867
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
24868
|
+
_handleHookDetachedNode(currentNode, root);
|
|
24869
|
+
};
|
|
24870
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
24871
|
+
let shadowNode = null;
|
|
24872
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
24873
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
24874
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
24875
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
24876
|
+
_sanitizeElements(shadowNode, fragment);
|
|
24877
|
+
_sanitizeAttributes(shadowNode, fragment);
|
|
24878
|
+
if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
|
|
24879
|
+
if (_readNodeType(shadowNode) === NODE_TYPE.element) {
|
|
24880
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
24881
|
+
if (_isDocumentFragment(innerSr)) {
|
|
24882
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
24883
|
+
_sanitizeShadowDOM2(innerSr);
|
|
24884
|
+
}
|
|
24568
24885
|
}
|
|
24569
24886
|
}
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24574
|
-
|
|
24575
|
-
|
|
24576
|
-
|
|
24577
|
-
|
|
24578
|
-
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
components.reverse();
|
|
24599
|
-
const componentLen = components.length;
|
|
24600
|
-
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
24601
|
-
for (; componentPos < componentLen; componentPos++) {
|
|
24602
|
-
const component = components[componentPos];
|
|
24603
|
-
if (!component.removed) {
|
|
24604
|
-
if (!component.added && this.useLongestToken) {
|
|
24605
|
-
let value = newTokens.slice(newPos, newPos + component.count);
|
|
24606
|
-
value = value.map(function(value2, i) {
|
|
24607
|
-
const oldValue = oldTokens[oldPos + i];
|
|
24608
|
-
return oldValue.length > value2.length ? oldValue : value2;
|
|
24887
|
+
if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
|
|
24888
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
24889
|
+
};
|
|
24890
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots2(root) {
|
|
24891
|
+
const stack = [{
|
|
24892
|
+
node: root,
|
|
24893
|
+
shadow: null
|
|
24894
|
+
}];
|
|
24895
|
+
while (stack.length > 0) {
|
|
24896
|
+
const item = stack.pop();
|
|
24897
|
+
if (item.shadow) {
|
|
24898
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
24899
|
+
continue;
|
|
24900
|
+
}
|
|
24901
|
+
const node = item.node;
|
|
24902
|
+
const isElement = _readNodeType(node) === NODE_TYPE.element;
|
|
24903
|
+
const childNodes = getChildNodes(node);
|
|
24904
|
+
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
|
|
24905
|
+
node: childNodes[i],
|
|
24906
|
+
shadow: null
|
|
24907
|
+
});
|
|
24908
|
+
if (isElement) {
|
|
24909
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
24910
|
+
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
24911
|
+
const content = node.content;
|
|
24912
|
+
if (_isDocumentFragment(content)) stack.push({
|
|
24913
|
+
node: content,
|
|
24914
|
+
shadow: null
|
|
24609
24915
|
});
|
|
24610
|
-
component.value = this.join(value);
|
|
24611
|
-
} else {
|
|
24612
|
-
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
24613
|
-
}
|
|
24614
|
-
newPos += component.count;
|
|
24615
|
-
if (!component.added) {
|
|
24616
|
-
oldPos += component.count;
|
|
24617
24916
|
}
|
|
24618
|
-
}
|
|
24619
|
-
|
|
24620
|
-
|
|
24917
|
+
}
|
|
24918
|
+
if (isElement) {
|
|
24919
|
+
const sr = getShadowRoot(node);
|
|
24920
|
+
if (_isDocumentFragment(sr)) stack.push({
|
|
24921
|
+
node: null,
|
|
24922
|
+
shadow: sr
|
|
24923
|
+
}, {
|
|
24924
|
+
node: sr,
|
|
24925
|
+
shadow: null
|
|
24926
|
+
});
|
|
24621
24927
|
}
|
|
24622
24928
|
}
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
};
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
return
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
|
|
24641
|
-
|
|
24642
|
-
|
|
24643
|
-
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24647
|
-
|
|
24648
|
-
|
|
24649
|
-
|
|
24650
|
-
|
|
24651
|
-
|
|
24652
|
-
|
|
24653
|
-
|
|
24654
|
-
|
|
24655
|
-
const words2 = [];
|
|
24656
|
-
for (const [word] of text3.matchAll(WORD_RE)) {
|
|
24657
|
-
if (word.length > 1 && UNSPACED_RE.test(word)) {
|
|
24658
|
-
if (segmenter2) {
|
|
24659
|
-
for (const { segment } of segmenter2.segment(word)) {
|
|
24660
|
-
words2.push(segment);
|
|
24929
|
+
};
|
|
24930
|
+
DOMPurify.sanitize = function(dirty) {
|
|
24931
|
+
let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
24932
|
+
let body = null;
|
|
24933
|
+
let importedNode = null;
|
|
24934
|
+
let currentNode = null;
|
|
24935
|
+
let returnNode = null;
|
|
24936
|
+
IS_EMPTY_INPUT = !dirty;
|
|
24937
|
+
if (IS_EMPTY_INPUT) dirty = "<!-->";
|
|
24938
|
+
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
24939
|
+
dirty = stringifyValue(dirty);
|
|
24940
|
+
if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
|
|
24941
|
+
}
|
|
24942
|
+
if (!DOMPurify.isSupported) return dirty;
|
|
24943
|
+
if (SET_CONFIG) {
|
|
24944
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
24945
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
24946
|
+
} else _parseConfig(cfg);
|
|
24947
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
24948
|
+
if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
24949
|
+
DOMPurify.removed = [];
|
|
24950
|
+
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
24951
|
+
let inPlaceNodes = [];
|
|
24952
|
+
const outerVisited = IN_PLACE_VISITED;
|
|
24953
|
+
if (inPlace) {
|
|
24954
|
+
_neutralizePatchLinkage(dirty);
|
|
24955
|
+
const nn = _readNodeName(dirty);
|
|
24956
|
+
if (typeof nn === "string") {
|
|
24957
|
+
const tagName = transformCaseFunc(nn);
|
|
24958
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
24959
|
+
_neutralizeRoot(dirty);
|
|
24960
|
+
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
24661
24961
|
}
|
|
24662
|
-
} else {
|
|
24663
|
-
words2.push(...word);
|
|
24664
24962
|
}
|
|
24963
|
+
if (_isClobbered(dirty)) {
|
|
24964
|
+
_neutralizeRoot(dirty);
|
|
24965
|
+
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
24966
|
+
}
|
|
24967
|
+
inPlaceNodes = _collectLiveNodes(dirty);
|
|
24968
|
+
IN_PLACE_VISITED = setCreate();
|
|
24969
|
+
} else if (_isNode(dirty)) {
|
|
24970
|
+
body = _initDocument("<!---->");
|
|
24971
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
24972
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
|
|
24973
|
+
else if (importedNode.nodeName === "HTML") body = importedNode;
|
|
24974
|
+
else body.appendChild(importedNode);
|
|
24975
|
+
_sanitizeAttachedShadowRoots(body);
|
|
24665
24976
|
} else {
|
|
24666
|
-
|
|
24977
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
24978
|
+
body = _initDocument(dirty);
|
|
24979
|
+
if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
24667
24980
|
}
|
|
24668
|
-
|
|
24669
|
-
|
|
24670
|
-
|
|
24671
|
-
|
|
24672
|
-
|
|
24673
|
-
|
|
24674
|
-
|
|
24675
|
-
|
|
24676
|
-
|
|
24677
|
-
}
|
|
24678
|
-
|
|
24679
|
-
|
|
24680
|
-
|
|
24681
|
-
|
|
24682
|
-
|
|
24683
|
-
|
|
24684
|
-
|
|
24981
|
+
if (body && FORCE_BODY) _forceRemove(body.firstChild);
|
|
24982
|
+
const walkRoot = inPlace ? dirty : body;
|
|
24983
|
+
try {
|
|
24984
|
+
if (inPlace) _sanitizeAttachedShadowRoots(dirty);
|
|
24985
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
24986
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
24987
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
24988
|
+
_sanitizeAttributes(currentNode, walkRoot);
|
|
24989
|
+
if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
|
|
24990
|
+
}
|
|
24991
|
+
if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
|
|
24992
|
+
} catch (error2) {
|
|
24993
|
+
if (inPlace) {
|
|
24994
|
+
_neutralizeRoot(dirty);
|
|
24995
|
+
_neutralizeDiscarded(dirty, inPlaceNodes);
|
|
24996
|
+
}
|
|
24997
|
+
throw error2;
|
|
24998
|
+
} finally {
|
|
24999
|
+
IN_PLACE_VISITED = outerVisited;
|
|
24685
25000
|
}
|
|
24686
|
-
if (
|
|
24687
|
-
|
|
25001
|
+
if (inPlace) {
|
|
25002
|
+
if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
|
|
25003
|
+
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
|
|
25004
|
+
return dirty;
|
|
24688
25005
|
}
|
|
24689
|
-
|
|
24690
|
-
|
|
25006
|
+
if (RETURN_DOM) {
|
|
25007
|
+
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
|
|
25008
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
25009
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
25010
|
+
while (body.firstChild) returnNode.appendChild(body.firstChild);
|
|
25011
|
+
} else returnNode = body;
|
|
25012
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
|
|
25013
|
+
return returnNode;
|
|
25014
|
+
}
|
|
25015
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
25016
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
25017
|
+
if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
25018
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
24691
25019
|
};
|
|
24692
|
-
|
|
24693
|
-
|
|
24694
|
-
|
|
24695
|
-
|
|
24696
|
-
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
|
|
24700
|
-
|
|
24701
|
-
|
|
24702
|
-
|
|
25020
|
+
DOMPurify.setConfig = function() {
|
|
25021
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
25022
|
+
_parseConfig(cfg);
|
|
25023
|
+
SET_CONFIG = true;
|
|
25024
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
25025
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
25026
|
+
};
|
|
25027
|
+
DOMPurify.clearConfig = function() {
|
|
25028
|
+
CONFIG = null;
|
|
25029
|
+
SET_CONFIG = false;
|
|
25030
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
25031
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
25032
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
25033
|
+
emptyHTML = "";
|
|
25034
|
+
};
|
|
25035
|
+
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
25036
|
+
if (!CONFIG) _parseConfig({});
|
|
25037
|
+
const lcTag = transformCaseFunc(tag);
|
|
25038
|
+
const lcName = transformCaseFunc(attr);
|
|
25039
|
+
if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
|
|
25040
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
25041
|
+
};
|
|
25042
|
+
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
25043
|
+
if (typeof hookFunction !== "function") return;
|
|
25044
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
25045
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
25046
|
+
};
|
|
25047
|
+
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
25048
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
25049
|
+
if (hookFunction !== void 0) {
|
|
25050
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
25051
|
+
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
24703
25052
|
}
|
|
24704
|
-
|
|
24705
|
-
|
|
24706
|
-
|
|
25053
|
+
return arrayPop(hooks[entryPoint]);
|
|
25054
|
+
};
|
|
25055
|
+
DOMPurify.removeHooks = function(entryPoint) {
|
|
25056
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
25057
|
+
hooks[entryPoint] = [];
|
|
25058
|
+
};
|
|
25059
|
+
DOMPurify.removeAllHooks = function() {
|
|
25060
|
+
hooks = _createHooksMap();
|
|
25061
|
+
};
|
|
25062
|
+
return DOMPurify;
|
|
24707
25063
|
}
|
|
25064
|
+
var purify_default = createDOMPurify();
|
|
25065
|
+
|
|
25066
|
+
// webview/preview.ts
|
|
25067
|
+
import mermaid from "mermaid";
|
|
24708
25068
|
|
|
24709
25069
|
// webview/diff.ts
|
|
24710
25070
|
var segmenter;
|
|
@@ -24927,7 +25287,12 @@ function setupDiffBar(root, action, { container, titles, scroll }) {
|
|
|
24927
25287
|
clearTimeout(focusTimer);
|
|
24928
25288
|
focusTimer = setTimeout(() => target.classList.remove("seqnotes-diff-focus"), FOCUS_MS);
|
|
24929
25289
|
}
|
|
25290
|
+
function setLabel(text3) {
|
|
25291
|
+
label.textContent = text3;
|
|
25292
|
+
label.title = text3;
|
|
25293
|
+
}
|
|
24930
25294
|
return {
|
|
25295
|
+
setLabel,
|
|
24931
25296
|
show(diff) {
|
|
24932
25297
|
bar.hidden = !diff;
|
|
24933
25298
|
current = void 0;
|
|
@@ -24935,8 +25300,7 @@ function setupDiffBar(root, action, { container, titles, scroll }) {
|
|
|
24935
25300
|
if (!diff) {
|
|
24936
25301
|
return;
|
|
24937
25302
|
}
|
|
24938
|
-
|
|
24939
|
-
label.title = diff.label;
|
|
25303
|
+
setLabel(diff.label);
|
|
24940
25304
|
const { added, changed, deleted } = diff.stats;
|
|
24941
25305
|
const items = [
|
|
24942
25306
|
["added", added, titles.seqnotesDiffAdded],
|
|
@@ -26673,7 +27037,7 @@ ${source}`;
|
|
|
26673
27037
|
}
|
|
26674
27038
|
});
|
|
26675
27039
|
setUpWarnings();
|
|
26676
|
-
diffBar.show(
|
|
27040
|
+
diffBar.show(lastDiff);
|
|
26677
27041
|
layoutWireframes(root);
|
|
26678
27042
|
addZoomButtons();
|
|
26679
27043
|
markZoomableImages();
|
|
@@ -27313,32 +27677,15 @@ ${source}`;
|
|
|
27313
27677
|
el.classList.remove("seqnotes-wide", "seqnotes-limit-width", "seqnotes-sticky-table-header", "seqnotes-table-tree-highlight");
|
|
27314
27678
|
el.style.removeProperty("--seqnotes-split");
|
|
27315
27679
|
}
|
|
27316
|
-
|
|
27680
|
+
function relabelDiff(label) {
|
|
27681
|
+
if (lastDiff) {
|
|
27682
|
+
lastDiff = { ...lastDiff, label };
|
|
27683
|
+
diffBar.setLabel(label);
|
|
27684
|
+
}
|
|
27685
|
+
}
|
|
27686
|
+
return { handle, destroy, relabelDiff };
|
|
27317
27687
|
}
|
|
27318
27688
|
|
|
27319
|
-
// src/shared/protocol.ts
|
|
27320
|
-
var WEBVIEW_TITLES = {
|
|
27321
|
-
"splitter-title": "Drag to resize, double-click to reset",
|
|
27322
|
-
"hide-warnings-title": "Hide warnings",
|
|
27323
|
-
"toc-title": "Contents",
|
|
27324
|
-
"zoom-title": "Zoom diagram",
|
|
27325
|
-
"zoom-image-title": "Zoom image",
|
|
27326
|
-
"zoom-in-title": "Zoom in",
|
|
27327
|
-
"zoom-out-title": "Zoom out",
|
|
27328
|
-
"zoom-fit-title": "Fit to window",
|
|
27329
|
-
"zoom-close-title": "Close",
|
|
27330
|
-
"diff-added": "{0} added",
|
|
27331
|
-
"diff-changed": "{0} changed",
|
|
27332
|
-
"diff-deleted": "{0} deleted",
|
|
27333
|
-
"diff-no-changes": "No changes",
|
|
27334
|
-
"diff-previous-title": "Previous change",
|
|
27335
|
-
"diff-next-title": "Next change",
|
|
27336
|
-
"diff-close-title": "Stop comparing",
|
|
27337
|
-
"diff-hide-title": "Hide changes",
|
|
27338
|
-
"diff-show-title": "Show changes",
|
|
27339
|
-
"diff-old-diagram": "Diagram before the change"
|
|
27340
|
-
};
|
|
27341
|
-
|
|
27342
27689
|
// webview/viewerContext.ts
|
|
27343
27690
|
function elementScrollHost(scroller) {
|
|
27344
27691
|
const host = {
|
|
@@ -27395,6 +27742,110 @@ function writeTitles(el, t) {
|
|
|
27395
27742
|
}
|
|
27396
27743
|
}
|
|
27397
27744
|
|
|
27745
|
+
// src/export/exportIndex.ts
|
|
27746
|
+
function documentInfo(md2, source, fallback, frontMatter2 = true) {
|
|
27747
|
+
const tokens = md2.parse(source, {});
|
|
27748
|
+
const entries2 = frontMatterEntries(tokens);
|
|
27749
|
+
const meta = {};
|
|
27750
|
+
for (const { key } of frontMatter2 ? DESIGN_DOC_META : []) {
|
|
27751
|
+
const value = frontMatterValue(entries2, key)?.trim();
|
|
27752
|
+
if (value !== void 0) {
|
|
27753
|
+
meta[key] = value;
|
|
27754
|
+
}
|
|
27755
|
+
}
|
|
27756
|
+
return { title: titleOf(tokens, fallback), meta, designDoc: isDesignDoc(entries2) };
|
|
27757
|
+
}
|
|
27758
|
+
function compareFolders(a, b) {
|
|
27759
|
+
const as = a === "" ? [] : a.split("/");
|
|
27760
|
+
const bs = b === "" ? [] : b.split("/");
|
|
27761
|
+
for (let i = 0; i < Math.min(as.length, bs.length); i++) {
|
|
27762
|
+
const order = as[i].localeCompare(bs[i]);
|
|
27763
|
+
if (order !== 0) {
|
|
27764
|
+
return order;
|
|
27765
|
+
}
|
|
27766
|
+
}
|
|
27767
|
+
return as.length - bs.length;
|
|
27768
|
+
}
|
|
27769
|
+
var NO_DESIGN_DOCS = "There are no design docs (Markdown files with type: design_doc in their front matter).";
|
|
27770
|
+
function changesCell(changes, t) {
|
|
27771
|
+
const { added, changed, deleted } = changes.stats;
|
|
27772
|
+
const total = added + changed + deleted;
|
|
27773
|
+
let content;
|
|
27774
|
+
if (changes.isNew) {
|
|
27775
|
+
content = `<span class="seqnotes-index-new">${escapeHtml2(t("New"))}</span>`;
|
|
27776
|
+
} else if (total === 0) {
|
|
27777
|
+
content = `<span class="seqnotes-index-unchanged">${escapeHtml2(t("No changes"))}</span>`;
|
|
27778
|
+
} else {
|
|
27779
|
+
const counts = [
|
|
27780
|
+
["added", added, "{0} added"],
|
|
27781
|
+
["changed", changed, "{0} changed"],
|
|
27782
|
+
["deleted", deleted, "{0} deleted"]
|
|
27783
|
+
];
|
|
27784
|
+
content = '<span class="seqnotes-diff-counts">' + counts.filter(([, count]) => count > 0).map(([kind, count, text3]) => `<span class="seqnotes-diff-count" data-kind="${kind}">${escapeHtml2(t(text3, count))}</span>`).join("") + "</span>";
|
|
27785
|
+
}
|
|
27786
|
+
return `<td class="seqnotes-index-changes" data-seqnotes-sort="${changes.isNew ? Number.MAX_SAFE_INTEGER : total}">${content}</td>`;
|
|
27787
|
+
}
|
|
27788
|
+
function groupByFolder(entries2, keepOrder = false) {
|
|
27789
|
+
const unique = [...new Set(entries2.map((entry) => entry.folder))];
|
|
27790
|
+
const folders = keepOrder ? unique : unique.sort(compareFolders);
|
|
27791
|
+
return folders.map((folder) => {
|
|
27792
|
+
const rows = entries2.filter((entry) => entry.folder === folder);
|
|
27793
|
+
return { folder, entries: keepOrder ? rows : rows.sort((a, b) => a.file.localeCompare(b.file)) };
|
|
27794
|
+
});
|
|
27795
|
+
}
|
|
27796
|
+
function indexBody(title, entries2, t, { empty = "", fileLabel, filterPlaceholder, keepOrder = false } = {}) {
|
|
27797
|
+
const columns = DESIGN_DOC_META.filter(({ key }) => entries2.some((entry) => key in entry.meta));
|
|
27798
|
+
const changes = entries2.some((entry) => entry.changes !== void 0);
|
|
27799
|
+
const headers = [
|
|
27800
|
+
{ key: "title", label: t("Title") },
|
|
27801
|
+
{ key: "file", label: fileLabel ?? t("File") },
|
|
27802
|
+
...columns.map(({ key, label }) => ({ key, label: t(label) })),
|
|
27803
|
+
...changes ? [{ key: "changes", label: t("Changes") }] : []
|
|
27804
|
+
];
|
|
27805
|
+
const head = "<thead><tr>" + headers.map(({ key, label }) => `<th data-seqnotes-column="${key}">${escapeHtml2(label)}</th>`).join("") + "</tr></thead>\n";
|
|
27806
|
+
const row = (entry) => `<tr><td class="seqnotes-index-title"><a href="${escapeHtml2(entry.href)}">${escapeHtml2(entry.title)}</a></td><td class="seqnotes-index-file">${escapeHtml2(entry.file)}</td>` + columns.map(({ key }) => {
|
|
27807
|
+
const value = entry.meta[key];
|
|
27808
|
+
return `<td class="seqnotes-index-${key}">${value === void 0 ? "" : `<span>${escapeHtml2(value)}</span>`}</td>`;
|
|
27809
|
+
}).join("") + (!changes ? "" : entry.changes ? changesCell(entry.changes, t) : '<td class="seqnotes-index-changes"></td>') + "</tr>\n";
|
|
27810
|
+
const tables = groupByFolder(entries2, keepOrder).map(
|
|
27811
|
+
({ folder, entries: rows }) => (folder === "" ? "" : `<h2>${escapeHtml2(folder)}/</h2>
|
|
27812
|
+
`) + `<table>
|
|
27813
|
+
${head}<tbody>
|
|
27814
|
+
${rows.map(row).join("")}</tbody>
|
|
27815
|
+
</table>
|
|
27816
|
+
`
|
|
27817
|
+
);
|
|
27818
|
+
const texts = {
|
|
27819
|
+
"filter-label": t("Filter"),
|
|
27820
|
+
"filter-placeholder": filterPlaceholder ?? t("Filter by title, file name or metadata"),
|
|
27821
|
+
// `{0}` documents shown of `{1}`, filled in by the script.
|
|
27822
|
+
count: t("{0} of {1} documents"),
|
|
27823
|
+
"no-match": t("No documents match the filter."),
|
|
27824
|
+
"sort-title": t("Sort by this column")
|
|
27825
|
+
};
|
|
27826
|
+
const attrs = Object.entries(texts).map(([key, text3]) => ` data-seqnotes-${key}="${escapeHtml2(text3)}"`).join("");
|
|
27827
|
+
const body = entries2.length === 0 ? `<p class="seqnotes-index-empty">${escapeHtml2(empty)}</p>
|
|
27828
|
+
` : tables.join("");
|
|
27829
|
+
return `<div class="seqnotes-index"${attrs}>
|
|
27830
|
+
<h1>${escapeHtml2(title)}</h1>
|
|
27831
|
+
${body}</div>`;
|
|
27832
|
+
}
|
|
27833
|
+
|
|
27834
|
+
// embed/designDocList.ts
|
|
27835
|
+
function designDocListHtml(md2, content, t) {
|
|
27836
|
+
const entries2 = content.documents.map((doc) => {
|
|
27837
|
+
const file = doc.file ?? "";
|
|
27838
|
+
const info = documentInfo(md2, doc.markdown, file || doc.href);
|
|
27839
|
+
return { title: doc.title ?? info.title, meta: info.meta, href: doc.href, folder: doc.folder ?? "", file };
|
|
27840
|
+
});
|
|
27841
|
+
return indexBody(content.title ?? t("Design Docs"), entries2, t, {
|
|
27842
|
+
empty: content.empty ?? t(NO_DESIGN_DOCS),
|
|
27843
|
+
fileLabel: content.fileLabel,
|
|
27844
|
+
filterPlaceholder: content.filterPlaceholder,
|
|
27845
|
+
keepOrder: content.keepOrder
|
|
27846
|
+
});
|
|
27847
|
+
}
|
|
27848
|
+
|
|
27398
27849
|
// embed/viewer.ts
|
|
27399
27850
|
function openLinkInNewTab(href) {
|
|
27400
27851
|
if (/^(?:https?|mailto):/i.test(href)) {
|
|
@@ -27403,6 +27854,12 @@ function openLinkInNewTab(href) {
|
|
|
27403
27854
|
}
|
|
27404
27855
|
var md = createMarkdown();
|
|
27405
27856
|
var viewers = 0;
|
|
27857
|
+
function langOf(lang) {
|
|
27858
|
+
return lang ?? (navigator.language.toLowerCase().startsWith("ja") ? "ja" : "en");
|
|
27859
|
+
}
|
|
27860
|
+
function translator(lang) {
|
|
27861
|
+
return lang === "ja" ? translatorFor(bundle_l10n_ja_default) : formatMessage;
|
|
27862
|
+
}
|
|
27406
27863
|
function resolveUrl(path, baseUrl) {
|
|
27407
27864
|
try {
|
|
27408
27865
|
return new URL(path, baseUrl).href;
|
|
@@ -27424,14 +27881,28 @@ function fetchFrom(baseUrl) {
|
|
|
27424
27881
|
}
|
|
27425
27882
|
};
|
|
27426
27883
|
}
|
|
27427
|
-
|
|
27884
|
+
async function readWireframes(markdown, { readFile, baseUrl }) {
|
|
27885
|
+
const read = readFile ?? (baseUrl === void 0 ? void 0 : fetchFrom(baseUrl));
|
|
27886
|
+
if (!read) {
|
|
27887
|
+
return void 0;
|
|
27888
|
+
}
|
|
27889
|
+
return loadWireframes(md, wireframeSources(md.parse(markdown, {})), (path) => Promise.resolve().then(() => read(path)).catch(() => void 0));
|
|
27890
|
+
}
|
|
27891
|
+
function viewerContent(markdown, env, compareWith, compareLabel) {
|
|
27892
|
+
if (compareWith === void 0) {
|
|
27893
|
+
return { html: renderDocument(md, markdown, env) };
|
|
27894
|
+
}
|
|
27895
|
+
const result = renderDiff(md, compareWith, markdown, env);
|
|
27896
|
+
return { html: result.html, diff: diffView(result, compareLabel) };
|
|
27897
|
+
}
|
|
27898
|
+
function diffView({ old, stats }, compareLabel) {
|
|
27899
|
+
return { label: compareLabel ?? "", old, stats };
|
|
27900
|
+
}
|
|
27901
|
+
var CONTENT_OPTIONS = ["markdown", "baseUrl", "readFile", "resolveResource", "frontMatter", "headingNumbers", "messageWrapWidth", "compareWith"];
|
|
27428
27902
|
var VIEW_OPTIONS = ["documentId", "splitMinWidth", "toc", "diagramLook", "limitContentWidth", "stickyTableHeader", "tableTreeHighlight"];
|
|
27429
|
-
function
|
|
27430
|
-
let current = { ...options };
|
|
27431
|
-
const lang = options.lang ?? (navigator.language.toLowerCase().startsWith("ja") ? "ja" : "en");
|
|
27432
|
-
const t = lang === "ja" ? translatorFor(bundle_l10n_ja_default) : formatMessage;
|
|
27903
|
+
function mountViewer(container, lang, t, options, className = "") {
|
|
27433
27904
|
const el = document.createElement("div");
|
|
27434
|
-
el.className =
|
|
27905
|
+
el.className = `seqnotes-viewer seqnotes-embedded ${className}`.trim();
|
|
27435
27906
|
el.lang = lang;
|
|
27436
27907
|
el.dataset.seqnotesTheme = "auto";
|
|
27437
27908
|
writeTitles(el, t);
|
|
@@ -27450,9 +27921,11 @@ function createViewer(container, options) {
|
|
|
27450
27921
|
let state;
|
|
27451
27922
|
const post = (message) => {
|
|
27452
27923
|
if (message.type === "openLink") {
|
|
27453
|
-
(
|
|
27924
|
+
(options().onOpenLink ?? openLinkInNewTab)(message.href);
|
|
27454
27925
|
} else if (message.type === "revealLine") {
|
|
27455
|
-
|
|
27926
|
+
options().onRevealLine?.(message.line);
|
|
27927
|
+
} else if (message.type === "closeDiff") {
|
|
27928
|
+
options().onCloseDiff?.();
|
|
27456
27929
|
}
|
|
27457
27930
|
};
|
|
27458
27931
|
const preview = createPreview({
|
|
@@ -27466,21 +27939,51 @@ function createViewer(container, options) {
|
|
|
27466
27939
|
});
|
|
27467
27940
|
const systemDark = window.matchMedia("(prefers-color-scheme: dark)");
|
|
27468
27941
|
const applyTheme = () => {
|
|
27469
|
-
const
|
|
27942
|
+
const { theme } = options();
|
|
27943
|
+
const dark = theme === "dark" || theme !== "light" && systemDark.matches;
|
|
27470
27944
|
el.classList.toggle("vscode-dark", dark);
|
|
27471
27945
|
el.classList.toggle("vscode-light", !dark);
|
|
27472
27946
|
};
|
|
27473
27947
|
systemDark.addEventListener("change", applyTheme);
|
|
27474
27948
|
applyTheme();
|
|
27949
|
+
return {
|
|
27950
|
+
preview,
|
|
27951
|
+
applyTheme,
|
|
27952
|
+
destroy() {
|
|
27953
|
+
preview.destroy();
|
|
27954
|
+
systemDark.removeEventListener("change", applyTheme);
|
|
27955
|
+
stopSizing();
|
|
27956
|
+
el.remove();
|
|
27957
|
+
}
|
|
27958
|
+
};
|
|
27959
|
+
}
|
|
27960
|
+
function createViewer(container, options) {
|
|
27961
|
+
let current = { ...options };
|
|
27962
|
+
const lang = langOf(options.lang);
|
|
27963
|
+
const t = translator(lang);
|
|
27475
27964
|
let destroyed = false;
|
|
27476
27965
|
let resolveReady;
|
|
27477
27966
|
const ready = new Promise((resolve) => resolveReady = resolve);
|
|
27478
27967
|
let html2;
|
|
27968
|
+
let diff;
|
|
27969
|
+
let wireframesRead;
|
|
27479
27970
|
let rendering = Promise.resolve();
|
|
27480
27971
|
let pending = false;
|
|
27481
27972
|
let renders = 0;
|
|
27482
27973
|
let shown = 0;
|
|
27483
|
-
|
|
27974
|
+
let dismissed;
|
|
27975
|
+
const closeDiff = () => {
|
|
27976
|
+
if (current.onCloseDiff) {
|
|
27977
|
+
current.onCloseDiff();
|
|
27978
|
+
} else if (!destroyed && current.compareWith !== void 0 && current.compareWith !== dismissed) {
|
|
27979
|
+
dismissed = current.compareWith;
|
|
27980
|
+
if (!pending) {
|
|
27981
|
+
rendering = render(true);
|
|
27982
|
+
}
|
|
27983
|
+
}
|
|
27984
|
+
};
|
|
27985
|
+
const { preview, applyTheme, destroy: unmount } = mountViewer(container, lang, t, () => ({ ...current, onCloseDiff: closeDiff }));
|
|
27986
|
+
async function show(rendered, differences) {
|
|
27484
27987
|
const seq = ++shown;
|
|
27485
27988
|
await preview.handle({
|
|
27486
27989
|
type: "update",
|
|
@@ -27494,26 +27997,32 @@ function createViewer(container, options) {
|
|
|
27494
27997
|
theme: "auto",
|
|
27495
27998
|
limitContentWidth: current.limitContentWidth ?? true,
|
|
27496
27999
|
stickyTableHeader: current.stickyTableHeader ?? true,
|
|
27497
|
-
tableTreeHighlight: current.tableTreeHighlight ?? true
|
|
28000
|
+
tableTreeHighlight: current.tableTreeHighlight ?? true,
|
|
28001
|
+
...differences ? { diff: differences } : {}
|
|
27498
28002
|
});
|
|
27499
28003
|
if (seq === shown) {
|
|
27500
28004
|
resolveReady();
|
|
27501
28005
|
}
|
|
27502
28006
|
}
|
|
27503
|
-
async function render() {
|
|
28007
|
+
async function render(sameWireframes = false) {
|
|
27504
28008
|
const seq = ++renders;
|
|
27505
28009
|
pending = true;
|
|
27506
28010
|
const { markdown, baseUrl } = current;
|
|
27507
|
-
const read = current.readFile ?? (baseUrl === void 0 ? void 0 : fetchFrom(baseUrl));
|
|
27508
28011
|
const resolveResource = current.resolveResource ?? (baseUrl === void 0 ? void 0 : (src) => resolveUrl(src, baseUrl) ?? src);
|
|
27509
|
-
const
|
|
27510
|
-
const wireframes2 = readFile ? await loadWireframes(md, wireframeSources(md.parse(markdown, {})), readFile) : void 0;
|
|
28012
|
+
const wireframes2 = sameWireframes && wireframesRead ? wireframesRead.files : await readWireframes(markdown, current);
|
|
27511
28013
|
if (destroyed || seq !== renders) {
|
|
27512
28014
|
return;
|
|
27513
28015
|
}
|
|
27514
28016
|
pending = false;
|
|
27515
|
-
|
|
27516
|
-
|
|
28017
|
+
wireframesRead = { files: wireframes2 };
|
|
28018
|
+
const compareWith = current.compareWith === dismissed ? void 0 : current.compareWith;
|
|
28019
|
+
({ html: html2, diff } = viewerContent(
|
|
28020
|
+
markdown,
|
|
28021
|
+
{ t, frontMatter: current.frontMatter, headingNumbers: current.headingNumbers, messageWrapWidth: current.messageWrapWidth, wireframes: wireframes2, resolveResource },
|
|
28022
|
+
compareWith,
|
|
28023
|
+
current.compareLabel
|
|
28024
|
+
));
|
|
28025
|
+
await show(html2, diff);
|
|
27517
28026
|
}
|
|
27518
28027
|
rendering = render();
|
|
27519
28028
|
return {
|
|
@@ -27525,6 +28034,9 @@ function createViewer(container, options) {
|
|
|
27525
28034
|
const previous = current;
|
|
27526
28035
|
current = { ...current, ...changes, lang: current.lang };
|
|
27527
28036
|
applyTheme();
|
|
28037
|
+
if (current.compareWith !== previous.compareWith) {
|
|
28038
|
+
dismissed = void 0;
|
|
28039
|
+
}
|
|
27528
28040
|
if (html2 === void 0 || CONTENT_OPTIONS.some((name) => current[name] !== previous[name])) {
|
|
27529
28041
|
rendering = render();
|
|
27530
28042
|
return rendering;
|
|
@@ -27532,9 +28044,13 @@ function createViewer(container, options) {
|
|
|
27532
28044
|
if (pending) {
|
|
27533
28045
|
return rendering;
|
|
27534
28046
|
}
|
|
28047
|
+
if (diff !== void 0 && current.compareLabel !== previous.compareLabel) {
|
|
28048
|
+
diff = diffView(diff, current.compareLabel);
|
|
28049
|
+
preview.relabelDiff(diff.label);
|
|
28050
|
+
}
|
|
27535
28051
|
const revealing = (options2) => options2.onRevealLine !== void 0;
|
|
27536
28052
|
if (VIEW_OPTIONS.some((name) => current[name] !== previous[name]) || revealing(current) !== revealing(previous)) {
|
|
27537
|
-
return show(html2);
|
|
28053
|
+
return show(html2, diff);
|
|
27538
28054
|
}
|
|
27539
28055
|
return Promise.resolve();
|
|
27540
28056
|
},
|
|
@@ -27549,17 +28065,174 @@ function createViewer(container, options) {
|
|
|
27549
28065
|
return;
|
|
27550
28066
|
}
|
|
27551
28067
|
destroyed = true;
|
|
27552
|
-
|
|
27553
|
-
|
|
27554
|
-
|
|
27555
|
-
|
|
28068
|
+
unmount();
|
|
28069
|
+
resolveReady();
|
|
28070
|
+
}
|
|
28071
|
+
};
|
|
28072
|
+
}
|
|
28073
|
+
var LIST_URI = "seqnotes-design-doc-list";
|
|
28074
|
+
var LIST_CONTENT_OPTIONS = ["documents", "title", "fileLabel", "filterPlaceholder", "empty", "keepOrder"];
|
|
28075
|
+
var SCRIPT_SCHEMES = /* @__PURE__ */ new Set(["javascript:", "data:", "vbscript:"]);
|
|
28076
|
+
function openLinkInPage(href) {
|
|
28077
|
+
let url;
|
|
28078
|
+
try {
|
|
28079
|
+
url = new URL(href, document.baseURI);
|
|
28080
|
+
} catch {
|
|
28081
|
+
return;
|
|
28082
|
+
}
|
|
28083
|
+
if (!SCRIPT_SCHEMES.has(url.protocol)) {
|
|
28084
|
+
window.location.assign(url.href);
|
|
28085
|
+
}
|
|
28086
|
+
}
|
|
28087
|
+
function createDesignDocList(container, options) {
|
|
28088
|
+
let current = { ...options };
|
|
28089
|
+
const lang = langOf(options.lang);
|
|
28090
|
+
const t = translator(lang);
|
|
28091
|
+
const { preview, applyTheme, destroy: unmount } = mountViewer(
|
|
28092
|
+
container,
|
|
28093
|
+
lang,
|
|
28094
|
+
t,
|
|
28095
|
+
() => ({ ...current, onOpenLink: current.onOpenLink ?? openLinkInPage }),
|
|
28096
|
+
"seqnotes-embedded-list"
|
|
28097
|
+
);
|
|
28098
|
+
let destroyed = false;
|
|
28099
|
+
let resolveReady;
|
|
28100
|
+
const ready = new Promise((resolve) => resolveReady = resolve);
|
|
28101
|
+
let html2 = designDocListHtml(md, current, t);
|
|
28102
|
+
let shown = 0;
|
|
28103
|
+
async function show() {
|
|
28104
|
+
if (destroyed) {
|
|
28105
|
+
return;
|
|
28106
|
+
}
|
|
28107
|
+
const seq = ++shown;
|
|
28108
|
+
await preview.handle({
|
|
28109
|
+
type: "update",
|
|
28110
|
+
uri: LIST_URI,
|
|
28111
|
+
html: html2,
|
|
28112
|
+
splitMinWidth: 1e3,
|
|
28113
|
+
syncEditor: false,
|
|
28114
|
+
toc: false,
|
|
28115
|
+
diagramLook: "neo",
|
|
28116
|
+
theme: "auto",
|
|
28117
|
+
limitContentWidth: current.limitContentWidth ?? true,
|
|
28118
|
+
stickyTableHeader: false,
|
|
28119
|
+
tableTreeHighlight: false
|
|
28120
|
+
});
|
|
28121
|
+
if (seq === shown) {
|
|
28122
|
+
resolveReady();
|
|
28123
|
+
}
|
|
28124
|
+
}
|
|
28125
|
+
void show();
|
|
28126
|
+
return {
|
|
28127
|
+
ready,
|
|
28128
|
+
update(changes) {
|
|
28129
|
+
if (destroyed) {
|
|
28130
|
+
return Promise.resolve();
|
|
28131
|
+
}
|
|
28132
|
+
const previous = current;
|
|
28133
|
+
current = { ...current, ...changes, lang: current.lang };
|
|
28134
|
+
applyTheme();
|
|
28135
|
+
if (LIST_CONTENT_OPTIONS.some((name) => current[name] !== previous[name])) {
|
|
28136
|
+
html2 = designDocListHtml(md, current, t);
|
|
28137
|
+
}
|
|
28138
|
+
return show();
|
|
28139
|
+
},
|
|
28140
|
+
destroy() {
|
|
28141
|
+
if (destroyed) {
|
|
28142
|
+
return;
|
|
28143
|
+
}
|
|
28144
|
+
destroyed = true;
|
|
28145
|
+
unmount();
|
|
27556
28146
|
resolveReady();
|
|
27557
28147
|
}
|
|
27558
28148
|
};
|
|
27559
28149
|
}
|
|
28150
|
+
var exportCount = 0;
|
|
28151
|
+
async function renderExportBody(html2, t, diagramLook, diff) {
|
|
28152
|
+
const el = document.createElement("div");
|
|
28153
|
+
el.className = "seqnotes-viewer seqnotes-embedded vscode-light";
|
|
28154
|
+
el.dataset.seqnotesTheme = "light";
|
|
28155
|
+
el.setAttribute("aria-hidden", "true");
|
|
28156
|
+
el.style.cssText = "position: fixed; top: 0; left: 0; width: 0; height: 0; overflow: hidden; visibility: hidden; pointer-events: none;";
|
|
28157
|
+
writeTitles(el, t);
|
|
28158
|
+
const root = document.createElement("div");
|
|
28159
|
+
root.className = "seqnotes-viewer-root";
|
|
28160
|
+
el.append(root);
|
|
28161
|
+
document.body.append(el);
|
|
28162
|
+
let state;
|
|
28163
|
+
let preview;
|
|
28164
|
+
try {
|
|
28165
|
+
const exported = new Promise((resolve) => {
|
|
28166
|
+
preview = createPreview({
|
|
28167
|
+
el,
|
|
28168
|
+
root,
|
|
28169
|
+
scroll: elementScrollHost(root),
|
|
28170
|
+
idPrefix: `seqnotes-export-${++exportCount}`,
|
|
28171
|
+
post: (message) => message.type === "exported" && resolve(message),
|
|
28172
|
+
getState: () => state,
|
|
28173
|
+
setState: (next) => state = next
|
|
28174
|
+
});
|
|
28175
|
+
});
|
|
28176
|
+
await preview.handle({ type: "export", id: 1, html: html2, diagramLook, ...diff ? { diff } : {} });
|
|
28177
|
+
const { body, error: error2 } = await exported;
|
|
28178
|
+
if (body === void 0) {
|
|
28179
|
+
throw new Error(error2 ?? "The diagrams could not be rendered.");
|
|
28180
|
+
}
|
|
28181
|
+
return body;
|
|
28182
|
+
} finally {
|
|
28183
|
+
preview?.destroy();
|
|
28184
|
+
el.remove();
|
|
28185
|
+
}
|
|
28186
|
+
}
|
|
28187
|
+
async function exportDocument(options, assets) {
|
|
28188
|
+
const lang = langOf(options.lang);
|
|
28189
|
+
const t = translator(lang);
|
|
28190
|
+
const { markdown, baseUrl } = options;
|
|
28191
|
+
const wireframes2 = await readWireframes(markdown, options);
|
|
28192
|
+
const resolveImage = options.resolveImage ?? ((path) => baseUrl === void 0 ? path : resolveUrl(path, baseUrl) ?? path);
|
|
28193
|
+
const image2 = (src) => {
|
|
28194
|
+
const [path] = src.split(/[?#]/, 1);
|
|
28195
|
+
return Promise.resolve().then(() => resolveImage(path)).then(
|
|
28196
|
+
(url) => typeof url === "string" ? url : path,
|
|
28197
|
+
() => path
|
|
28198
|
+
);
|
|
28199
|
+
};
|
|
28200
|
+
const env = { t, frontMatter: options.frontMatter, headingNumbers: options.headingNumbers, messageWrapWidth: options.messageWrapWidth, wireframes: wireframes2 };
|
|
28201
|
+
let html2;
|
|
28202
|
+
let diff;
|
|
28203
|
+
if (options.compareWith !== void 0) {
|
|
28204
|
+
const result = await renderDiffForExport(md, options.compareWith, markdown, env, image2);
|
|
28205
|
+
html2 = result.html;
|
|
28206
|
+
diff = diffView(result, options.compareLabel);
|
|
28207
|
+
} else {
|
|
28208
|
+
html2 = await renderForExport(md, markdown, env, image2);
|
|
28209
|
+
}
|
|
28210
|
+
const body = await renderExportBody(html2, t, options.diagramLook ?? "neo", diff);
|
|
28211
|
+
return exportPage({
|
|
28212
|
+
lang,
|
|
28213
|
+
title: documentTitle(md, markdown, options.title ?? ""),
|
|
28214
|
+
body,
|
|
28215
|
+
styles: assets.styles,
|
|
28216
|
+
script: assets.script,
|
|
28217
|
+
settings: {
|
|
28218
|
+
limitContentWidth: options.limitContentWidth ?? true,
|
|
28219
|
+
stickyTableHeader: options.stickyTableHeader ?? true,
|
|
28220
|
+
tableTreeHighlight: options.tableTreeHighlight ?? true,
|
|
28221
|
+
splitMinWidth: options.splitMinWidth ?? 1e3,
|
|
28222
|
+
toc: options.toc ?? true
|
|
28223
|
+
},
|
|
28224
|
+
tocTitle: t(WEBVIEW_TITLES["toc-title"]),
|
|
28225
|
+
splitterTitle: t(WEBVIEW_TITLES["splitter-title"]),
|
|
28226
|
+
...diff ? { diff: exportDiff(diff, t) } : {}
|
|
28227
|
+
});
|
|
28228
|
+
}
|
|
27560
28229
|
export {
|
|
28230
|
+
createDesignDocList,
|
|
27561
28231
|
createViewer,
|
|
27562
|
-
|
|
28232
|
+
exportDocument,
|
|
28233
|
+
openLinkInNewTab,
|
|
28234
|
+
openLinkInPage,
|
|
28235
|
+
viewerContent
|
|
27563
28236
|
};
|
|
27564
28237
|
/*! Bundled license information:
|
|
27565
28238
|
|