chrome-devtools-frontend 1.0.1636056 → 1.0.1640418
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/front_end/core/common/Color.ts +0 -4
- package/front_end/core/host/AidaClientTypes.ts +8 -6
- package/front_end/core/root/Runtime.ts +2 -2
- package/front_end/core/sdk/DOMStorageModel.ts +1 -1
- package/front_end/core/sdk/SourceMap.ts +8 -3
- package/front_end/core/sdk/TargetManager.ts +14 -1
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +147 -0
- package/front_end/generated/ARIAProperties.js +17 -4
- package/front_end/generated/InspectorBackendCommands.ts +13 -7
- package/front_end/generated/SupportedCSSProperties.js +1 -0
- package/front_end/generated/protocol-mapping.d.ts +7 -0
- package/front_end/generated/protocol-proxy-api.d.ts +14 -0
- package/front_end/generated/protocol.ts +120 -2
- package/front_end/global_typings/global_defs.d.ts +13 -0
- package/front_end/models/ai_assistance/AiAgent2.ts +116 -0
- package/front_end/models/ai_assistance/AiConversation.ts +22 -36
- package/front_end/models/ai_assistance/AiHistoryStorage.ts +0 -1
- package/front_end/models/ai_assistance/AiOrigins.ts +46 -0
- package/front_end/models/ai_assistance/AiUtils.ts +9 -0
- package/front_end/models/ai_assistance/README.md +16 -0
- package/front_end/models/ai_assistance/StorageItem.ts +30 -26
- package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +12 -5
- package/front_end/models/ai_assistance/agents/AiAgent.ts +86 -32
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +31 -10
- package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +1 -1
- package/front_end/models/ai_assistance/agents/FileAgent.ts +2 -2
- package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +1 -3
- package/front_end/models/ai_assistance/agents/NetworkAgent.snapshot.txt +19 -0
- package/front_end/models/ai_assistance/agents/NetworkAgent.ts +9 -4
- package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +41 -12
- package/front_end/models/ai_assistance/agents/StorageAgent.ts +442 -122
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
- package/front_end/models/ai_assistance/ai_assistance.ts +4 -2
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/performance/AIContext.ts +7 -8
- package/front_end/models/ai_assistance/skills/README.md +40 -0
- package/front_end/models/ai_assistance/skills/Skill.ts +13 -0
- package/front_end/models/ai_assistance/skills/SkillRegistry.ts +10 -0
- package/front_end/models/ai_assistance/skills/styling.md +6 -0
- package/front_end/models/bindings/CompilerScriptMapping.ts +12 -4
- package/front_end/models/breakpoints/BreakpointManager.ts +54 -2
- package/front_end/models/greendev/Prototypes.ts +0 -7
- package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +20 -0
- package/front_end/models/heap_snapshot/HeapSnapshotProxy.ts +5 -0
- package/front_end/models/issues_manager/EmailVerificationRequestIssue.ts +293 -0
- package/front_end/models/issues_manager/IssuesManager.ts +5 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestInvalidEmail.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +1748 -1739
- package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +1 -1
- package/front_end/models/stack_trace/DetailedErrorStackParser.ts +9 -1
- package/front_end/models/stack_trace/StackTraceImpl.ts +29 -9
- package/front_end/models/stack_trace/StackTraceModel.ts +23 -11
- package/front_end/models/stack_trace/Trie.ts +11 -1
- package/front_end/models/trace/extras/TraceTree.ts +20 -1
- package/front_end/models/trace/insights/Common.ts +9 -0
- package/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +21 -25
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +19 -75
- package/front_end/panels/ai_assistance/components/AccessibilityAgentMarkdownRenderer.ts +10 -3
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +148 -2
- package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -3
- package/front_end/panels/ai_assistance/components/chatMessage.css +27 -0
- package/front_end/panels/application/CookieItemsView.ts +24 -0
- package/front_end/panels/application/DOMStorageItemsView.ts +9 -4
- package/front_end/panels/application/preloading/components/PreloadingString.ts +6 -0
- package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +4 -4
- package/front_end/panels/console/ConsoleViewMessage.ts +13 -102
- package/front_end/panels/elements/StandaloneStylesContainer.ts +10 -0
- package/front_end/panels/elements/StylePropertiesSection.ts +6 -2
- package/front_end/panels/elements/StylePropertyTreeElement.ts +30 -1
- package/front_end/panels/elements/StylesContainer.ts +3 -0
- package/front_end/panels/elements/StylesSidebarPane.ts +54 -4
- package/front_end/panels/elements/elements-meta.ts +14 -0
- package/front_end/panels/layer_viewer/layerDetailsView.css +1 -1
- package/front_end/panels/lighthouse/LighthouseController.ts +1 -1
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +4 -4
- package/front_end/panels/network/NetworkDataGridNode.ts +14 -0
- package/front_end/panels/network/NetworkLogViewColumns.ts +2 -2
- package/front_end/panels/network/RequestHeadersView.ts +55 -19
- package/front_end/panels/network/networkTimingTable.css +2 -4
- package/front_end/panels/recorder/components/ReplaySection.ts +28 -16
- package/front_end/panels/recorder/converters/LighthouseConverter.snapshot.txt +47 -0
- package/front_end/panels/recorder/converters/PuppeteerConverter.snapshot.txt +49 -0
- package/front_end/panels/recorder/converters/PuppeteerReplayConverter.snapshot.txt +33 -0
- package/front_end/panels/settings/SettingsScreen.ts +1 -2
- package/front_end/panels/sources/BreakpointsView.ts +23 -42
- package/front_end/panels/sources/DebuggerPlugin.ts +12 -5
- package/front_end/panels/sources/ScopeChainSidebarPane.ts +169 -106
- package/front_end/panels/timeline/components/IgnoreListSetting.ts +1 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +2 -2
- package/front_end/third_party/marked/README.chromium +3 -6
- package/front_end/third_party/marked/package/README.md +5 -5
- package/front_end/third_party/marked/package/bin/main.js +27 -22
- package/front_end/third_party/marked/package/bin/marked.js +2 -1
- package/front_end/third_party/marked/package/lib/marked.esm.d.ts +346 -256
- package/front_end/third_party/marked/package/lib/marked.esm.js +67 -2698
- package/front_end/third_party/marked/package/lib/marked.esm.js.map +7 -1
- package/front_end/third_party/marked/package/lib/marked.umd.js +69 -2722
- package/front_end/third_party/marked/package/lib/marked.umd.js.map +7 -1
- package/front_end/third_party/marked/package/man/marked.1 +4 -2
- package/front_end/third_party/marked/package/man/marked.1.md +2 -1
- package/front_end/third_party/marked/package/package.json +49 -57
- package/front_end/third_party/puppeteer-replay/README.chromium +2 -2
- package/front_end/third_party/puppeteer-replay/package/lib/cli.js +84 -80
- package/front_end/third_party/puppeteer-replay/package/lib/cli.js.map +1 -1
- package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js +79 -83
- package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js.map +1 -1
- package/front_end/third_party/puppeteer-replay/package/lib/main.d.ts +43 -171
- package/front_end/third_party/puppeteer-replay/package/lib/main.js +51 -206
- package/front_end/third_party/puppeteer-replay/package/lib/main.js.map +1 -1
- package/front_end/third_party/puppeteer-replay/package/package.json +37 -67
- package/front_end/tsconfig.json +1 -1
- package/front_end/ui/components/markdown_view/CodeBlock.ts +17 -6
- package/front_end/ui/components/markdown_view/MarkdownView.ts +39 -3
- package/front_end/ui/components/markdown_view/codeBlock.css +11 -0
- package/front_end/ui/components/markdown_view/markdownView.css +17 -0
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +0 -79
- package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +16 -4
- package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
- package/inspector_overlay/testing/InspectorOverlayHelpers.ts +2 -0
- package/mcp/mcp.ts +1 -6
- package/package.json +14 -16
- package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgent.ts +0 -1015
- package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgentOverlay.ts +0 -87
- package/front_end/third_party/marked/package/bin/marked +0 -215
- package/front_end/third_party/marked/package/lib/marked.cjs +0 -2726
- package/front_end/third_party/marked/package/lib/marked.cjs.map +0 -1
- package/front_end/third_party/marked/package/lib/marked.d.cts +0 -670
- package/front_end/third_party/marked/package/lib/marked.js +0 -2780
- package/front_end/third_party/marked/package/man/marked.1.txt +0 -86
- package/front_end/third_party/marked/package/marked.min.js +0 -6
- package/front_end/third_party/marked/package/src/Lexer.js +0 -492
- package/front_end/third_party/marked/package/src/Parser.js +0 -286
- package/front_end/third_party/marked/package/src/Renderer.js +0 -166
- package/front_end/third_party/marked/package/src/Slugger.js +0 -49
- package/front_end/third_party/marked/package/src/TextRenderer.js +0 -42
- package/front_end/third_party/marked/package/src/Tokenizer.js +0 -755
- package/front_end/third_party/marked/package/src/defaults.js +0 -29
- package/front_end/third_party/marked/package/src/helpers.js +0 -249
- package/front_end/third_party/marked/package/src/marked.js +0 -350
- package/front_end/third_party/marked/package/src/rules.js +0 -285
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs +0 -2099
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs.map +0 -1
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.cts +0 -686
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.ts +0 -35
- package/mcp/HostBindings.ts +0 -319
- /package/front_end/third_party/marked/package/{LICENSE.md → LICENSE} +0 -0
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export function getDefaults() {
|
|
2
|
-
return {
|
|
3
|
-
baseUrl: null,
|
|
4
|
-
breaks: false,
|
|
5
|
-
extensions: null,
|
|
6
|
-
gfm: true,
|
|
7
|
-
headerIds: true,
|
|
8
|
-
headerPrefix: '',
|
|
9
|
-
highlight: null,
|
|
10
|
-
langPrefix: 'language-',
|
|
11
|
-
mangle: true,
|
|
12
|
-
pedantic: false,
|
|
13
|
-
renderer: null,
|
|
14
|
-
sanitize: false,
|
|
15
|
-
sanitizer: null,
|
|
16
|
-
silent: false,
|
|
17
|
-
smartLists: false,
|
|
18
|
-
smartypants: false,
|
|
19
|
-
tokenizer: null,
|
|
20
|
-
walkTokens: null,
|
|
21
|
-
xhtml: false
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export let defaults = getDefaults();
|
|
26
|
-
|
|
27
|
-
export function changeDefaults(newDefaults) {
|
|
28
|
-
defaults = newDefaults;
|
|
29
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helpers
|
|
3
|
-
*/
|
|
4
|
-
const escapeTest = /[&<>"']/;
|
|
5
|
-
const escapeReplace = /[&<>"']/g;
|
|
6
|
-
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
7
|
-
const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
8
|
-
const escapeReplacements = {
|
|
9
|
-
'&': '&',
|
|
10
|
-
'<': '<',
|
|
11
|
-
'>': '>',
|
|
12
|
-
'"': '"',
|
|
13
|
-
"'": '''
|
|
14
|
-
};
|
|
15
|
-
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
16
|
-
export function escape(html, encode) {
|
|
17
|
-
if (encode) {
|
|
18
|
-
if (escapeTest.test(html)) {
|
|
19
|
-
return html.replace(escapeReplace, getEscapeReplacement);
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
if (escapeTestNoEncode.test(html)) {
|
|
23
|
-
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return html;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
31
|
-
|
|
32
|
-
export function unescape(html) {
|
|
33
|
-
// explicitly match decimal, hex, and named HTML entities
|
|
34
|
-
return html.replace(unescapeTest, (_, n) => {
|
|
35
|
-
n = n.toLowerCase();
|
|
36
|
-
if (n === 'colon') return ':';
|
|
37
|
-
if (n.charAt(0) === '#') {
|
|
38
|
-
return n.charAt(1) === 'x'
|
|
39
|
-
? String.fromCharCode(parseInt(n.substring(2), 16))
|
|
40
|
-
: String.fromCharCode(+n.substring(1));
|
|
41
|
-
}
|
|
42
|
-
return '';
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const caret = /(^|[^\[])\^/g;
|
|
47
|
-
export function edit(regex, opt) {
|
|
48
|
-
regex = regex.source || regex;
|
|
49
|
-
opt = opt || '';
|
|
50
|
-
const obj = {
|
|
51
|
-
replace: (name, val) => {
|
|
52
|
-
val = val.source || val;
|
|
53
|
-
val = val.replace(caret, '$1');
|
|
54
|
-
regex = regex.replace(name, val);
|
|
55
|
-
return obj;
|
|
56
|
-
},
|
|
57
|
-
getRegex: () => {
|
|
58
|
-
return new RegExp(regex, opt);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
return obj;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const nonWordAndColonTest = /[^\w:]/g;
|
|
65
|
-
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
66
|
-
export function cleanUrl(sanitize, base, href) {
|
|
67
|
-
if (sanitize) {
|
|
68
|
-
let prot;
|
|
69
|
-
try {
|
|
70
|
-
prot = decodeURIComponent(unescape(href))
|
|
71
|
-
.replace(nonWordAndColonTest, '')
|
|
72
|
-
.toLowerCase();
|
|
73
|
-
} catch (e) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (base && !originIndependentUrl.test(href)) {
|
|
81
|
-
href = resolveUrl(base, href);
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
href = encodeURI(href).replace(/%25/g, '%');
|
|
85
|
-
} catch (e) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
return href;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const baseUrls = {};
|
|
92
|
-
const justDomain = /^[^:]+:\/*[^/]*$/;
|
|
93
|
-
const protocol = /^([^:]+:)[\s\S]*$/;
|
|
94
|
-
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
95
|
-
|
|
96
|
-
export function resolveUrl(base, href) {
|
|
97
|
-
if (!baseUrls[' ' + base]) {
|
|
98
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
99
|
-
// but we might need to add _that_
|
|
100
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
101
|
-
if (justDomain.test(base)) {
|
|
102
|
-
baseUrls[' ' + base] = base + '/';
|
|
103
|
-
} else {
|
|
104
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
base = baseUrls[' ' + base];
|
|
108
|
-
const relativeBase = base.indexOf(':') === -1;
|
|
109
|
-
|
|
110
|
-
if (href.substring(0, 2) === '//') {
|
|
111
|
-
if (relativeBase) {
|
|
112
|
-
return href;
|
|
113
|
-
}
|
|
114
|
-
return base.replace(protocol, '$1') + href;
|
|
115
|
-
} else if (href.charAt(0) === '/') {
|
|
116
|
-
if (relativeBase) {
|
|
117
|
-
return href;
|
|
118
|
-
}
|
|
119
|
-
return base.replace(domain, '$1') + href;
|
|
120
|
-
} else {
|
|
121
|
-
return base + href;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const noopTest = { exec: function noopTest() {} };
|
|
126
|
-
|
|
127
|
-
export function merge(obj) {
|
|
128
|
-
let i = 1,
|
|
129
|
-
target,
|
|
130
|
-
key;
|
|
131
|
-
|
|
132
|
-
for (; i < arguments.length; i++) {
|
|
133
|
-
target = arguments[i];
|
|
134
|
-
for (key in target) {
|
|
135
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
136
|
-
obj[key] = target[key];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return obj;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function splitCells(tableRow, count) {
|
|
145
|
-
// ensure that every cell-delimiting pipe has a space
|
|
146
|
-
// before it to distinguish it from an escaped pipe
|
|
147
|
-
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
148
|
-
let escaped = false,
|
|
149
|
-
curr = offset;
|
|
150
|
-
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
|
151
|
-
if (escaped) {
|
|
152
|
-
// odd number of slashes means | is escaped
|
|
153
|
-
// so we leave it alone
|
|
154
|
-
return '|';
|
|
155
|
-
} else {
|
|
156
|
-
// add space before unescaped |
|
|
157
|
-
return ' |';
|
|
158
|
-
}
|
|
159
|
-
}),
|
|
160
|
-
cells = row.split(/ \|/);
|
|
161
|
-
let i = 0;
|
|
162
|
-
|
|
163
|
-
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
164
|
-
if (!cells[0].trim()) { cells.shift(); }
|
|
165
|
-
if (!cells[cells.length - 1].trim()) { cells.pop(); }
|
|
166
|
-
|
|
167
|
-
if (cells.length > count) {
|
|
168
|
-
cells.splice(count);
|
|
169
|
-
} else {
|
|
170
|
-
while (cells.length < count) cells.push('');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
for (; i < cells.length; i++) {
|
|
174
|
-
// leading or trailing whitespace is ignored per the gfm spec
|
|
175
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
176
|
-
}
|
|
177
|
-
return cells;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
181
|
-
// /c*$/ is vulnerable to REDOS.
|
|
182
|
-
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
183
|
-
export function rtrim(str, c, invert) {
|
|
184
|
-
const l = str.length;
|
|
185
|
-
if (l === 0) {
|
|
186
|
-
return '';
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Length of suffix matching the invert condition.
|
|
190
|
-
let suffLen = 0;
|
|
191
|
-
|
|
192
|
-
// Step left until we fail to match the invert condition.
|
|
193
|
-
while (suffLen < l) {
|
|
194
|
-
const currChar = str.charAt(l - suffLen - 1);
|
|
195
|
-
if (currChar === c && !invert) {
|
|
196
|
-
suffLen++;
|
|
197
|
-
} else if (currChar !== c && invert) {
|
|
198
|
-
suffLen++;
|
|
199
|
-
} else {
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return str.substr(0, l - suffLen);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export function findClosingBracket(str, b) {
|
|
208
|
-
if (str.indexOf(b[1]) === -1) {
|
|
209
|
-
return -1;
|
|
210
|
-
}
|
|
211
|
-
const l = str.length;
|
|
212
|
-
let level = 0,
|
|
213
|
-
i = 0;
|
|
214
|
-
for (; i < l; i++) {
|
|
215
|
-
if (str[i] === '\\') {
|
|
216
|
-
i++;
|
|
217
|
-
} else if (str[i] === b[0]) {
|
|
218
|
-
level++;
|
|
219
|
-
} else if (str[i] === b[1]) {
|
|
220
|
-
level--;
|
|
221
|
-
if (level < 0) {
|
|
222
|
-
return i;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return -1;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export function checkSanitizeDeprecation(opt) {
|
|
230
|
-
if (opt && opt.sanitize && !opt.silent) {
|
|
231
|
-
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// copied from https://stackoverflow.com/a/5450113/806777
|
|
236
|
-
export function repeatString(pattern, count) {
|
|
237
|
-
if (count < 1) {
|
|
238
|
-
return '';
|
|
239
|
-
}
|
|
240
|
-
let result = '';
|
|
241
|
-
while (count > 1) {
|
|
242
|
-
if (count & 1) {
|
|
243
|
-
result += pattern;
|
|
244
|
-
}
|
|
245
|
-
count >>= 1;
|
|
246
|
-
pattern += pattern;
|
|
247
|
-
}
|
|
248
|
-
return result + pattern;
|
|
249
|
-
}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
changeDefaults,
|
|
3
|
-
defaults
|
|
4
|
-
,
|
|
5
|
-
getDefaults} from './defaults.js';
|
|
6
|
-
import {
|
|
7
|
-
checkSanitizeDeprecation,
|
|
8
|
-
escape
|
|
9
|
-
,
|
|
10
|
-
merge} from './helpers.js';
|
|
11
|
-
import { Lexer } from './Lexer.js';
|
|
12
|
-
import { Parser } from './Parser.js';
|
|
13
|
-
import { Renderer } from './Renderer.js';
|
|
14
|
-
import { Slugger } from './Slugger.js';
|
|
15
|
-
import { TextRenderer } from './TextRenderer.js';
|
|
16
|
-
import { Tokenizer } from './Tokenizer.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Marked
|
|
20
|
-
*/
|
|
21
|
-
export function marked(src, opt, callback) {
|
|
22
|
-
// throw error in case of non string input
|
|
23
|
-
if (typeof src === 'undefined' || src === null) {
|
|
24
|
-
throw new Error('marked(): input parameter is undefined or null');
|
|
25
|
-
}
|
|
26
|
-
if (typeof src !== 'string') {
|
|
27
|
-
throw new Error('marked(): input parameter is of type '
|
|
28
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeof opt === 'function') {
|
|
32
|
-
callback = opt;
|
|
33
|
-
opt = null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
37
|
-
checkSanitizeDeprecation(opt);
|
|
38
|
-
|
|
39
|
-
if (callback) {
|
|
40
|
-
const highlight = opt.highlight;
|
|
41
|
-
let tokens;
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
tokens = Lexer.lex(src, opt);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return callback(e);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const done = function(err) {
|
|
50
|
-
let out;
|
|
51
|
-
|
|
52
|
-
if (!err) {
|
|
53
|
-
try {
|
|
54
|
-
if (opt.walkTokens) {
|
|
55
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
56
|
-
}
|
|
57
|
-
out = Parser.parse(tokens, opt);
|
|
58
|
-
} catch (e) {
|
|
59
|
-
err = e;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
opt.highlight = highlight;
|
|
64
|
-
|
|
65
|
-
return err
|
|
66
|
-
? callback(err)
|
|
67
|
-
: callback(null, out);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if (!highlight || highlight.length < 3) {
|
|
71
|
-
return done();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
delete opt.highlight;
|
|
75
|
-
|
|
76
|
-
if (!tokens.length) return done();
|
|
77
|
-
|
|
78
|
-
let pending = 0;
|
|
79
|
-
marked.walkTokens(tokens, function(token) {
|
|
80
|
-
if (token.type === 'code') {
|
|
81
|
-
pending++;
|
|
82
|
-
setTimeout(() => {
|
|
83
|
-
highlight(token.text, token.lang, function(err, code) {
|
|
84
|
-
if (err) {
|
|
85
|
-
return done(err);
|
|
86
|
-
}
|
|
87
|
-
if (code != null && code !== token.text) {
|
|
88
|
-
token.text = code;
|
|
89
|
-
token.escaped = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
pending--;
|
|
93
|
-
if (pending === 0) {
|
|
94
|
-
done();
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}, 0);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
if (pending === 0) {
|
|
102
|
-
done();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
const tokens = Lexer.lex(src, opt);
|
|
110
|
-
if (opt.walkTokens) {
|
|
111
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
112
|
-
}
|
|
113
|
-
return Parser.parse(tokens, opt);
|
|
114
|
-
} catch (e) {
|
|
115
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
116
|
-
if (opt.silent) {
|
|
117
|
-
return '<p>An error occurred:</p><pre>'
|
|
118
|
-
+ escape(e.message + '', true)
|
|
119
|
-
+ '</pre>';
|
|
120
|
-
}
|
|
121
|
-
throw e;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Options
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
marked.options =
|
|
130
|
-
marked.setOptions = function(opt) {
|
|
131
|
-
merge(marked.defaults, opt);
|
|
132
|
-
changeDefaults(marked.defaults);
|
|
133
|
-
return marked;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
marked.getDefaults = getDefaults;
|
|
137
|
-
|
|
138
|
-
marked.defaults = defaults;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Use Extension
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
marked.use = function(...args) {
|
|
145
|
-
const opts = merge({}, ...args);
|
|
146
|
-
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
147
|
-
let hasExtensions;
|
|
148
|
-
|
|
149
|
-
args.forEach((pack) => {
|
|
150
|
-
// ==-- Parse "addon" extensions --== //
|
|
151
|
-
if (pack.extensions) {
|
|
152
|
-
hasExtensions = true;
|
|
153
|
-
pack.extensions.forEach((ext) => {
|
|
154
|
-
if (!ext.name) {
|
|
155
|
-
throw new Error('extension name required');
|
|
156
|
-
}
|
|
157
|
-
if (ext.renderer) { // Renderer extensions
|
|
158
|
-
const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
|
159
|
-
if (prevRenderer) {
|
|
160
|
-
// Replace extension with func to run new extension but fall back if false
|
|
161
|
-
extensions.renderers[ext.name] = function(...args) {
|
|
162
|
-
let ret = ext.renderer.apply(this, args);
|
|
163
|
-
if (ret === false) {
|
|
164
|
-
ret = prevRenderer.apply(this, args);
|
|
165
|
-
}
|
|
166
|
-
return ret;
|
|
167
|
-
};
|
|
168
|
-
} else {
|
|
169
|
-
extensions.renderers[ext.name] = ext.renderer;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (ext.tokenizer) { // Tokenizer Extensions
|
|
173
|
-
if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
|
|
174
|
-
throw new Error("extension level must be 'block' or 'inline'");
|
|
175
|
-
}
|
|
176
|
-
if (extensions[ext.level]) {
|
|
177
|
-
extensions[ext.level].unshift(ext.tokenizer);
|
|
178
|
-
} else {
|
|
179
|
-
extensions[ext.level] = [ext.tokenizer];
|
|
180
|
-
}
|
|
181
|
-
if (ext.start) { // Function to check for start of token
|
|
182
|
-
if (ext.level === 'block') {
|
|
183
|
-
if (extensions.startBlock) {
|
|
184
|
-
extensions.startBlock.push(ext.start);
|
|
185
|
-
} else {
|
|
186
|
-
extensions.startBlock = [ext.start];
|
|
187
|
-
}
|
|
188
|
-
} else if (ext.level === 'inline') {
|
|
189
|
-
if (extensions.startInline) {
|
|
190
|
-
extensions.startInline.push(ext.start);
|
|
191
|
-
} else {
|
|
192
|
-
extensions.startInline = [ext.start];
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (ext.childTokens) { // Child tokens to be visited by walkTokens
|
|
198
|
-
extensions.childTokens[ext.name] = ext.childTokens;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ==-- Parse "overwrite" extensions --== //
|
|
204
|
-
if (pack.renderer) {
|
|
205
|
-
const renderer = marked.defaults.renderer || new Renderer();
|
|
206
|
-
for (const prop in pack.renderer) {
|
|
207
|
-
const prevRenderer = renderer[prop];
|
|
208
|
-
// Replace renderer with func to run extension, but fall back if false
|
|
209
|
-
renderer[prop] = (...args) => {
|
|
210
|
-
let ret = pack.renderer[prop].apply(renderer, args);
|
|
211
|
-
if (ret === false) {
|
|
212
|
-
ret = prevRenderer.apply(renderer, args);
|
|
213
|
-
}
|
|
214
|
-
return ret;
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
opts.renderer = renderer;
|
|
218
|
-
}
|
|
219
|
-
if (pack.tokenizer) {
|
|
220
|
-
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
221
|
-
for (const prop in pack.tokenizer) {
|
|
222
|
-
const prevTokenizer = tokenizer[prop];
|
|
223
|
-
// Replace tokenizer with func to run extension, but fall back if false
|
|
224
|
-
tokenizer[prop] = (...args) => {
|
|
225
|
-
let ret = pack.tokenizer[prop].apply(tokenizer, args);
|
|
226
|
-
if (ret === false) {
|
|
227
|
-
ret = prevTokenizer.apply(tokenizer, args);
|
|
228
|
-
}
|
|
229
|
-
return ret;
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
opts.tokenizer = tokenizer;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// ==-- Parse WalkTokens extensions --== //
|
|
236
|
-
if (pack.walkTokens) {
|
|
237
|
-
const walkTokens = marked.defaults.walkTokens;
|
|
238
|
-
opts.walkTokens = function(token) {
|
|
239
|
-
pack.walkTokens.call(this, token);
|
|
240
|
-
if (walkTokens) {
|
|
241
|
-
walkTokens.call(this, token);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (hasExtensions) {
|
|
247
|
-
opts.extensions = extensions;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
marked.setOptions(opts);
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Run callback for every token
|
|
256
|
-
*/
|
|
257
|
-
|
|
258
|
-
marked.walkTokens = function(tokens, callback) {
|
|
259
|
-
for (const token of tokens) {
|
|
260
|
-
callback.call(marked, token);
|
|
261
|
-
switch (token.type) {
|
|
262
|
-
case 'table': {
|
|
263
|
-
for (const cell of token.header) {
|
|
264
|
-
marked.walkTokens(cell.tokens, callback);
|
|
265
|
-
}
|
|
266
|
-
for (const row of token.rows) {
|
|
267
|
-
for (const cell of row) {
|
|
268
|
-
marked.walkTokens(cell.tokens, callback);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
case 'list': {
|
|
274
|
-
marked.walkTokens(token.items, callback);
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
default: {
|
|
278
|
-
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
|
|
279
|
-
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
|
280
|
-
marked.walkTokens(token[childTokens], callback);
|
|
281
|
-
});
|
|
282
|
-
} else if (token.tokens) {
|
|
283
|
-
marked.walkTokens(token.tokens, callback);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Parse Inline
|
|
292
|
-
*/
|
|
293
|
-
marked.parseInline = function(src, opt) {
|
|
294
|
-
// throw error in case of non string input
|
|
295
|
-
if (typeof src === 'undefined' || src === null) {
|
|
296
|
-
throw new Error('marked.parseInline(): input parameter is undefined or null');
|
|
297
|
-
}
|
|
298
|
-
if (typeof src !== 'string') {
|
|
299
|
-
throw new Error('marked.parseInline(): input parameter is of type '
|
|
300
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
304
|
-
checkSanitizeDeprecation(opt);
|
|
305
|
-
|
|
306
|
-
try {
|
|
307
|
-
const tokens = Lexer.lexInline(src, opt);
|
|
308
|
-
if (opt.walkTokens) {
|
|
309
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
310
|
-
}
|
|
311
|
-
return Parser.parseInline(tokens, opt);
|
|
312
|
-
} catch (e) {
|
|
313
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
314
|
-
if (opt.silent) {
|
|
315
|
-
return '<p>An error occurred:</p><pre>'
|
|
316
|
-
+ escape(e.message + '', true)
|
|
317
|
-
+ '</pre>';
|
|
318
|
-
}
|
|
319
|
-
throw e;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Expose
|
|
325
|
-
*/
|
|
326
|
-
marked.Parser = Parser;
|
|
327
|
-
marked.parser = Parser.parse;
|
|
328
|
-
marked.Renderer = Renderer;
|
|
329
|
-
marked.TextRenderer = TextRenderer;
|
|
330
|
-
marked.Lexer = Lexer;
|
|
331
|
-
marked.lexer = Lexer.lex;
|
|
332
|
-
marked.Tokenizer = Tokenizer;
|
|
333
|
-
marked.Slugger = Slugger;
|
|
334
|
-
marked.parse = marked;
|
|
335
|
-
|
|
336
|
-
export const options = marked.options;
|
|
337
|
-
export const setOptions = marked.setOptions;
|
|
338
|
-
export const use = marked.use;
|
|
339
|
-
export const walkTokens = marked.walkTokens;
|
|
340
|
-
export const parseInline = marked.parseInline;
|
|
341
|
-
export const parse = marked;
|
|
342
|
-
export const parser = Parser.parse;
|
|
343
|
-
export const lexer = Lexer.lex;
|
|
344
|
-
export { defaults, getDefaults } from './defaults.js';
|
|
345
|
-
export { Lexer } from './Lexer.js';
|
|
346
|
-
export { Parser } from './Parser.js';
|
|
347
|
-
export { Tokenizer } from './Tokenizer.js';
|
|
348
|
-
export { Renderer } from './Renderer.js';
|
|
349
|
-
export { TextRenderer } from './TextRenderer.js';
|
|
350
|
-
export { Slugger } from './Slugger.js';
|