chrome-devtools-frontend 1.0.947377 → 1.0.948916
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/config/gni/all_devtools_files.gni +1 -6
- package/config/gni/devtools_grd_files.gni +5 -12
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/.eslintrc.js +1 -0
- package/front_end/Images/src/circled_backslash_icon.svg +3 -0
- package/front_end/core/host/UserMetrics.ts +1 -1
- package/front_end/core/i18n/locales/en-US.json +32 -44
- package/front_end/core/i18n/locales/en-XL.json +32 -44
- package/front_end/core/platform/platform.ts +0 -2
- package/front_end/core/platform/string-utilities.ts +14 -1
- package/front_end/core/platform/utilities.ts +0 -29
- package/front_end/core/root/Runtime.ts +4 -207
- package/front_end/core/sdk/Cookie.ts +0 -21
- package/front_end/core/sdk/RemoteObject.ts +15 -1
- package/front_end/core/sdk/sdk-legacy.ts +0 -3
- package/front_end/entrypoints/devtools_app/{devtools_app-meta-files.ts → devtools_app.ts} +9 -3
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +2 -1
- package/front_end/entrypoints/js_app/{JsMain.ts → js_app.ts} +5 -1
- package/front_end/entrypoints/main/MainImpl.ts +0 -1
- package/front_end/entrypoints/ndb_app/{ndb_app.js → ndb_app.ts} +0 -2
- package/front_end/entrypoints/node_app/node_app.ts +1 -3
- package/front_end/entrypoints/shell/{shell.js → shell.ts} +0 -2
- package/front_end/entrypoints/visibility.gni +3 -1
- package/front_end/entrypoints/worker_app/worker_app.ts +1 -4
- package/front_end/generated/InspectorBackendCommands.js +8 -1
- package/front_end/generated/protocol-mapping.d.ts +4 -0
- package/front_end/generated/protocol-proxy-api.d.ts +6 -0
- package/front_end/generated/protocol.d.ts +9 -0
- package/front_end/legacy/legacy-defs.d.ts +0 -4
- package/front_end/legacy_test_runner/test_runner/TestRunner.js +35 -59
- package/front_end/models/issues_manager/AttributionReportingIssue.ts +27 -2
- package/front_end/models/issues_manager/CorsIssue.ts +15 -15
- package/front_end/models/issues_manager/descriptions/{corsInsecurePrivateNetworkPreflight.md → corsPreflightAllowPrivateNetworkError.md} +1 -1
- package/front_end/panels/accessibility/AccessibilitySidebarView.ts +3 -1
- package/front_end/panels/application/BackForwardCacheStrings.ts +1 -5
- package/front_end/panels/application/BackForwardCacheView.ts +150 -58
- package/front_end/panels/application/ResourcesPanel.ts +0 -42
- package/front_end/panels/application/application-legacy.ts +0 -3
- package/front_end/panels/application/application-meta.ts +0 -13
- package/front_end/panels/application/backForwardCacheView.css +44 -6
- package/front_end/panels/application/components/FrameDetailsView.ts +3 -3
- package/front_end/panels/application/components/OriginTrialTreeView.ts +3 -3
- package/front_end/panels/application/components/StackTrace.ts +1 -1
- package/front_end/panels/console/ConsolePrompt.ts +0 -4
- package/front_end/panels/coverage/CoverageView.ts +1 -1
- package/front_end/panels/css_overview/components/cssOverviewStartView.css +1 -0
- package/front_end/panels/css_overview/cssOverviewCompletedView.css +1 -1
- package/front_end/panels/developer_resources/DeveloperResourcesView.ts +2 -1
- package/front_end/panels/elements/AccessibilityTreeUtils.ts +1 -7
- package/front_end/panels/elements/ElementsPanel.ts +9 -1
- package/front_end/panels/elements/ElementsTreeElement.ts +1 -1
- package/front_end/panels/elements/PropertiesWidget.ts +109 -4
- package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +1 -1
- package/front_end/panels/elements/propertiesWidget.css +34 -0
- package/front_end/panels/emulation/DeviceModeToolbar.ts +5 -1
- package/front_end/panels/issues/CorsIssueDetailsView.ts +20 -8
- package/front_end/panels/network/NetworkWaterfallColumn.ts +2 -0
- package/front_end/panels/profiler/CPUProfileFlameChart.ts +3 -1
- package/front_end/panels/profiler/ProfileDataGrid.ts +2 -1
- package/front_end/panels/settings/components/SyncSection.ts +2 -2
- package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +46 -46
- package/front_end/panels/timeline/TimelineTreeView.ts +2 -1
- package/front_end/ui/components/diff_view/DiffView.ts +4 -4
- package/front_end/ui/components/helpers/component-server-setup.ts +1 -12
- package/front_end/ui/components/helpers/helpers.ts +0 -2
- package/front_end/ui/components/icon_button/IconButton.ts +1 -1
- package/front_end/ui/components/issue_counter/IssueCounter.ts +2 -2
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +3 -3
- package/front_end/ui/components/markdown_view/MarkdownView.ts +4 -4
- package/front_end/ui/components/panel_feedback/PreviewToggle.ts +98 -0
- package/front_end/ui/components/panel_feedback/panel_feedback.ts +1 -0
- package/front_end/ui/components/panel_feedback/previewToggle.css +24 -0
- package/front_end/ui/components/report_view/ReportView.ts +22 -0
- package/front_end/ui/components/report_view/reportSection.css +20 -0
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +1 -1
- package/front_end/ui/components/settings/SettingCheckbox.ts +2 -2
- package/front_end/ui/components/text_editor/config.ts +4 -3
- package/front_end/ui/components/text_editor/javascript.ts +8 -4
- package/front_end/ui/components/text_prompt/TextPrompt.ts +2 -2
- package/front_end/ui/legacy/GlassPane.ts +1 -1
- package/front_end/ui/legacy/SearchableView.ts +2 -1
- package/front_end/ui/legacy/Treeoutline.ts +1 -1
- package/front_end/ui/legacy/Widget.ts +1 -1
- package/front_end/ui/legacy/XWidget.ts +0 -5
- package/front_end/ui/legacy/components/inline_editor/CSSVarSwatch.ts +2 -2
- package/front_end/ui/legacy/components/inline_editor/ColorSwatch.ts +1 -1
- package/front_end/ui/legacy/utils/append-style.ts +2 -13
- package/front_end/ui/legacy/utils/create-shadow-root-with-core-styles.ts +7 -5
- package/package.json +2 -4
- package/scripts/build/build_inspector_overlay.py +15 -1
- package/scripts/build/rjsmin.py +84 -115
- package/scripts/eslint_rules/lib/ban_a_tags_in_lit_html.js +2 -11
- package/scripts/eslint_rules/lib/ban_literal_devtools_component_tag_names.js +2 -11
- package/scripts/eslint_rules/lib/ban_self_closing_custom_element_tagnames.js +2 -11
- package/scripts/eslint_rules/lib/ban_style_tags_in_lit_html.js +2 -11
- package/scripts/eslint_rules/lib/lit_html_data_as_type.js +2 -11
- package/scripts/eslint_rules/lib/lit_html_no_attribute_quotes.js +89 -0
- package/scripts/eslint_rules/lib/lit_no_style_interpolation.js +2 -11
- package/scripts/eslint_rules/lib/no_only_eslint_tests.js +53 -0
- package/scripts/eslint_rules/lib/static_tag_must_be_static_property.js +2 -11
- package/scripts/eslint_rules/lib/utils.js +29 -0
- package/scripts/eslint_rules/tests/.eslintrc.js +18 -0
- package/scripts/eslint_rules/tests/lit_html_no_attribute_quotes_test.js +45 -0
- package/scripts/eslint_rules/tests/no_only_eslint_tests_test.js +94 -0
- package/scripts/eslint_rules/tests/utils_test.js +40 -0
- package/front_end/entrypoints/devtools_app/devtools_app.js +0 -11
- package/front_end/entrypoints/devtools_app/devtools_app.json +0 -4
- package/front_end/entrypoints/js_app/js_app.js +0 -12
- package/front_end/entrypoints/js_app/js_app.json +0 -3
- package/front_end/entrypoints/ndb_app/ndb_app.json +0 -4
- package/front_end/entrypoints/startup/RuntimeInstantiator.ts +0 -95
- package/front_end/entrypoints/startup/startup.ts +0 -9
- package/front_end/panels/help/HelpImpl.ts +0 -141
- package/front_end/panels/help/ReleaseNoteText.ts +0 -1496
- package/front_end/panels/help/ReleaseNoteView.ts +0 -107
- package/front_end/panels/help/help-meta.ts +0 -145
- package/front_end/panels/help/help.ts +0 -13
- package/front_end/panels/help/releaseNote.css +0 -115
- package/front_end/ui/components/helpers/get-stylesheet.ts +0 -45
- package/scripts/build/build_release_applications.py +0 -216
- package/scripts/build/modular_build.py +0 -184
- package/scripts/check_gn.js +0 -119
- package/scripts/json_validator/module.schema.json +0 -19
- package/scripts/json_validator/validate_module_json.js +0 -44
|
@@ -159,6 +159,7 @@ export async function javascriptCompletionSource(cx: CodeMirror.CompletionContex
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
let result: CompletionSet;
|
|
162
|
+
let quote: string|undefined = undefined;
|
|
162
163
|
if (query.type === QueryType.Expression) {
|
|
163
164
|
const [scope, global] = await Promise.all([
|
|
164
165
|
completeExpressionInScope(),
|
|
@@ -174,7 +175,6 @@ export async function javascriptCompletionSource(cx: CodeMirror.CompletionContex
|
|
|
174
175
|
}
|
|
175
176
|
} else if (query.type === QueryType.PropertyName || query.type === QueryType.PropertyExpression) {
|
|
176
177
|
const objectExpr = (query.relatedNode as CodeMirror.SyntaxNode).getChild('Expression');
|
|
177
|
-
let quote = undefined;
|
|
178
178
|
if (query.type === QueryType.PropertyExpression) {
|
|
179
179
|
quote = query.from === undefined ? '\'' : cx.state.sliceDoc(query.from, query.from + 1);
|
|
180
180
|
}
|
|
@@ -189,10 +189,13 @@ export async function javascriptCompletionSource(cx: CodeMirror.CompletionContex
|
|
|
189
189
|
return {
|
|
190
190
|
from: query.from ?? cx.pos,
|
|
191
191
|
options: result.completions,
|
|
192
|
-
span:
|
|
192
|
+
span: !quote ? SPAN_IDENT : quote === '\'' ? SPAN_SINGLE_QUOTE : SPAN_DOUBLE_QUOTE,
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
const SPAN_IDENT = /^#?[\w\P{ASCII}]*$/u, SPAN_SINGLE_QUOTE = /^\'(\\.|[^\\'\n])*'?$/,
|
|
197
|
+
SPAN_DOUBLE_QUOTE = /^"(\\.|[^\\"\n])*"?$/;
|
|
198
|
+
|
|
196
199
|
function getExecutionContext(): SDK.RuntimeModel.ExecutionContext|null {
|
|
197
200
|
return UI.Context.Context.instance().flavor(SDK.RuntimeModel.ExecutionContext);
|
|
198
201
|
}
|
|
@@ -330,8 +333,9 @@ async function completePropertiesInner(
|
|
|
330
333
|
const isFunction = object.type === 'function';
|
|
331
334
|
for (const prop of properties.properties || []) {
|
|
332
335
|
if (!prop.symbol && !(isFunction && (prop.name === 'arguments' || prop.name === 'caller')) &&
|
|
333
|
-
(!prop.private || expression === 'this')) {
|
|
334
|
-
const label =
|
|
336
|
+
(!prop.private || expression === 'this') && (quoted || SPAN_IDENT.test(prop.name))) {
|
|
337
|
+
const label =
|
|
338
|
+
quoted ? quoted + prop.name.replaceAll('\\', '\\\\').replaceAll(quoted, '\\' + quoted) + quoted : prop.name;
|
|
335
339
|
const completion: CodeMirror.Completion = {
|
|
336
340
|
label,
|
|
337
341
|
type: prop.value?.type === 'function' ? functionType : otherType,
|
|
@@ -127,8 +127,8 @@ export class TextPrompt extends HTMLElement {
|
|
|
127
127
|
const output = LitHtml.html`
|
|
128
128
|
<span class="prefix">${this.#prefixText} </span>
|
|
129
129
|
<span class="text-prompt-input"><input aria-label=${this.#ariaLabelText} spellcheck="false" @input=${
|
|
130
|
-
this.onInput} @keydown=${this.onKeyDown}/><span class='suggestion' suggestion
|
|
131
|
-
this.#suggestionText}
|
|
130
|
+
this.onInput} @keydown=${this.onKeyDown}/><span class='suggestion' suggestion=${
|
|
131
|
+
this.#suggestionText}></span></span>`;
|
|
132
132
|
LitHtml.render(output, this.#shadow, {host: this});
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -55,7 +55,7 @@ export class GlassPane {
|
|
|
55
55
|
return this.widgetInternal.isShowing();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
registerRequiredCSS(cssFile:
|
|
58
|
+
registerRequiredCSS(cssFile: {cssContent: string}): void {
|
|
59
59
|
// eslint-disable-next-line no-restricted-syntax -- Should import styles https://crbug.com/1106746
|
|
60
60
|
this.widgetInternal.registerRequiredCSS(cssFile);
|
|
61
61
|
}
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
import * as Common from '../../core/common/common.js';
|
|
37
37
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
38
|
+
import * as Platform from '../../core/platform/platform.js';
|
|
38
39
|
|
|
39
40
|
import * as ARIAUtils from './ARIAUtils.js';
|
|
40
41
|
import {HistoryInput} from './HistoryInput.js';
|
|
@@ -629,7 +630,7 @@ export class SearchConfig {
|
|
|
629
630
|
|
|
630
631
|
// Otherwise just do a plain text search.
|
|
631
632
|
if (!regex) {
|
|
632
|
-
regex = createPlainTextSearchRegex(query, modifiers);
|
|
633
|
+
regex = Platform.StringUtilities.createPlainTextSearchRegex(query, modifiers);
|
|
633
634
|
}
|
|
634
635
|
|
|
635
636
|
return regex;
|
|
@@ -399,7 +399,7 @@ export class TreeOutlineInShadow extends TreeOutline {
|
|
|
399
399
|
this.renderSelection = true;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
registerRequiredCSS(cssFile:
|
|
402
|
+
registerRequiredCSS(cssFile: {cssContent: string}): void {
|
|
403
403
|
Utils.appendStyle(this.shadowRoot, cssFile);
|
|
404
404
|
}
|
|
405
405
|
|
|
@@ -458,7 +458,7 @@ export class Widget {
|
|
|
458
458
|
this.doResize();
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
registerRequiredCSS(cssFile:
|
|
461
|
+
registerRequiredCSS(cssFile: {cssContent: string}): void {
|
|
462
462
|
if (this.isWebComponent) {
|
|
463
463
|
Utils.appendStyle((this.shadowRoot as DocumentFragment), cssFile);
|
|
464
464
|
} else {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
5
|
import * as ComponentHelpers from '../components/helpers/helpers.js';
|
|
6
|
-
import * as Utils from './utils/utils.js';
|
|
7
6
|
|
|
8
7
|
import {XElement} from './XElement.js';
|
|
9
8
|
|
|
@@ -55,10 +54,6 @@ export class XWidget extends XElement {
|
|
|
55
54
|
return this.visible;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
registerRequiredCSS(cssFile: string): void {
|
|
59
|
-
Utils.appendStyle(this.shadowRootInternal || this, cssFile);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
57
|
setOnShown(callback: (() => void)|null): void {
|
|
63
58
|
this.onShownCallback = callback;
|
|
64
59
|
}
|
|
@@ -113,7 +113,7 @@ export class CSSVarSwatch extends HTMLElement {
|
|
|
113
113
|
// The this.variableName's space must be removed, otherwise it cannot be triggered when clicked.
|
|
114
114
|
const onActivate = isDefined ? this.onLinkActivate.bind(this, this.variableName.trim()) : null;
|
|
115
115
|
|
|
116
|
-
return html`<span class
|
|
116
|
+
return html`<span class=${classes} title=${title} @mousedown=${onActivate} @keydown=${
|
|
117
117
|
onActivate} role="link" tabindex="-1">${variableName}</span>`;
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -129,7 +129,7 @@ export class CSSVarSwatch extends HTMLElement {
|
|
|
129
129
|
// Disabled until https://crbug.com/1079231 is fixed.
|
|
130
130
|
// clang-format off
|
|
131
131
|
render(
|
|
132
|
-
html`<span title
|
|
132
|
+
html`<span title=${this.computedValue || ''}>${functionParts.pre}${link}${functionParts.post}</span>`,
|
|
133
133
|
this.shadow, { host: this });
|
|
134
134
|
// clang-format on
|
|
135
135
|
}
|
|
@@ -118,7 +118,7 @@ export class ColorSwatch extends HTMLElement {
|
|
|
118
118
|
// Note also that whitespace between nodes is removed on purpose to avoid pushing these elements apart. Do not
|
|
119
119
|
// re-format the HTML code.
|
|
120
120
|
LitHtml.render(
|
|
121
|
-
LitHtml.html`<span class="color-swatch" title
|
|
121
|
+
LitHtml.html`<span class="color-swatch" title=${this.tooltip}><span class="color-swatch-inner"
|
|
122
122
|
style="background-color: ${this.text};"
|
|
123
123
|
@click=${this.onClick}
|
|
124
124
|
@mousedown=${this.consume}
|
|
@@ -2,19 +2,8 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function appendStyle(node: Node, cssReference: string|{cssContent: string}): void {
|
|
8
|
-
let content: string;
|
|
9
|
-
if (typeof cssReference === 'string') {
|
|
10
|
-
content = Root.Runtime.cachedResources.get(cssReference) || '';
|
|
11
|
-
if (!content) {
|
|
12
|
-
console.error(cssReference + ' not preloaded. Check module.json');
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
content = cssReference.cssContent;
|
|
16
|
-
}
|
|
5
|
+
export function appendStyle(node: Node, {cssContent}: {cssContent: string}): void {
|
|
17
6
|
const styleElement = document.createElement('style');
|
|
18
|
-
styleElement.textContent =
|
|
7
|
+
styleElement.textContent = cssContent;
|
|
19
8
|
node.appendChild(styleElement);
|
|
20
9
|
}
|
|
@@ -7,7 +7,7 @@ import {focusChanged} from './focus-changed.js';
|
|
|
7
7
|
import {injectCoreStyles} from './inject-core-styles.js';
|
|
8
8
|
|
|
9
9
|
interface Options {
|
|
10
|
-
cssFile?:
|
|
10
|
+
cssFile?: CSSStyleSheet[]|{cssContent: string};
|
|
11
11
|
delegatesFocus?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -22,10 +22,12 @@ export function createShadowRootWithCoreStyles(element: Element, options: Option
|
|
|
22
22
|
|
|
23
23
|
const shadowRoot = element.attachShadow({mode: 'open', delegatesFocus});
|
|
24
24
|
injectCoreStyles(shadowRoot);
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (cssFile) {
|
|
26
|
+
if ('cssContent' in cssFile) {
|
|
27
|
+
appendStyle(shadowRoot, cssFile);
|
|
28
|
+
} else {
|
|
29
|
+
shadowRoot.adoptedStyleSheets = cssFile;
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
shadowRoot.addEventListener('focus', focusChanged, true);
|
|
31
33
|
return shadowRoot;
|
package/package.json
CHANGED
|
@@ -27,10 +27,8 @@
|
|
|
27
27
|
"auto-unittest": "scripts/test/run_auto_unittests.py --no-text-coverage",
|
|
28
28
|
"build": "autoninja -C out/Default",
|
|
29
29
|
"build-release": "autoninja -C out/Release",
|
|
30
|
-
"check": "npm run check-
|
|
30
|
+
"check": "npm run check-lint && npm run check-loc",
|
|
31
31
|
"check-external-links": "third_party/node/node.py --output scripts/check_external_links.js",
|
|
32
|
-
"check-gn": "third_party/node/node.py --output scripts/check_gn.js",
|
|
33
|
-
"check-json": "third_party/node/node.py --output scripts/json_validator/validate_module_json.js",
|
|
34
32
|
"check-lint": "third_party/node/node.py --output scripts/test/run_lint_check_js.mjs && third_party/node/node.py --output scripts/test/run_lint_check_css.js",
|
|
35
33
|
"check-lint-css": "third_party/node/node.py --output scripts/test/run_lint_check_css.js",
|
|
36
34
|
"collect-strings": "third_party/node/node.py --output third_party/i18n/collect-strings.js front_end",
|
|
@@ -55,5 +53,5 @@
|
|
|
55
53
|
"unittest": "scripts/test/run_unittests.py --no-text-coverage",
|
|
56
54
|
"watch": "third_party/node/node.py --output scripts/watch_build.js"
|
|
57
55
|
},
|
|
58
|
-
"version": "1.0.
|
|
56
|
+
"version": "1.0.948916"
|
|
59
57
|
}
|
|
@@ -12,7 +12,6 @@ Builds inspector overlay:
|
|
|
12
12
|
|
|
13
13
|
from os import path
|
|
14
14
|
from os.path import join
|
|
15
|
-
from modular_build import read_file, write_file
|
|
16
15
|
from itertools import tee
|
|
17
16
|
|
|
18
17
|
import os
|
|
@@ -29,6 +28,21 @@ finally:
|
|
|
29
28
|
sys.path = original_sys_path
|
|
30
29
|
|
|
31
30
|
|
|
31
|
+
def read_file(filename):
|
|
32
|
+
with open(path.normpath(filename), 'rt', encoding='utf-8') as input:
|
|
33
|
+
return input.read()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def write_file(filename, content):
|
|
37
|
+
if path.exists(filename):
|
|
38
|
+
os.remove(filename)
|
|
39
|
+
directory = path.dirname(filename)
|
|
40
|
+
if not path.exists(directory):
|
|
41
|
+
os.makedirs(directory)
|
|
42
|
+
with open(filename, 'wt', encoding='utf-8') as output:
|
|
43
|
+
output.write(content)
|
|
44
|
+
|
|
45
|
+
|
|
32
46
|
def check_size(filename, data, max_size):
|
|
33
47
|
assert len(
|
|
34
48
|
data
|
package/scripts/build/rjsmin.py
CHANGED
|
@@ -119,8 +119,7 @@ def _make_jsmin(python_only=False):
|
|
|
119
119
|
charclass = r'(?:\[[^\\\]\r\n]*(?:\\[^\r\n][^\\\]\r\n]*)*\])'
|
|
120
120
|
nospecial = r'[^/\\\[\r\n]'
|
|
121
121
|
regex = r'(?:/(?![\r\n/*])%s*(?:(?:\\[^\r\n]|%s)%s*)*/)' % (
|
|
122
|
-
nospecial, charclass, nospecial
|
|
123
|
-
)
|
|
122
|
+
nospecial, charclass, nospecial)
|
|
124
123
|
space = r'(?:%s|%s)' % (space_chars, space_comment)
|
|
125
124
|
newline = r'(?:%s?[\r\n])' % line_comment
|
|
126
125
|
|
|
@@ -147,36 +146,28 @@ def _make_jsmin(python_only=False):
|
|
|
147
146
|
first = last = char
|
|
148
147
|
if last is not None:
|
|
149
148
|
result.append((first, last))
|
|
150
|
-
return ''.join([
|
|
151
|
-
chr(first),
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
return ''.join([
|
|
150
|
+
'%s%s%s' % (chr(first), last > first + 1 and '-'
|
|
151
|
+
or '', last != first and chr(last) or '')
|
|
152
|
+
for first, last in result
|
|
153
|
+
]) # noqa
|
|
155
154
|
|
|
156
155
|
return _re.sub(
|
|
157
156
|
r'([\000-\040\047])', # \047 for better portability
|
|
158
|
-
lambda m: '\\%03o' % ord(m.group(1)),
|
|
159
|
-
|
|
160
|
-
.replace('
|
|
161
|
-
.replace('[', '\\[')
|
|
162
|
-
.replace(']', '\\]')
|
|
163
|
-
)
|
|
164
|
-
)
|
|
157
|
+
lambda m: '\\%03o' % ord(m.group(1)),
|
|
158
|
+
(sequentize(result).replace('\\', '\\\\').replace(
|
|
159
|
+
'[', '\\[').replace(']', '\\]')))
|
|
165
160
|
|
|
166
161
|
def id_literal_(what):
|
|
167
162
|
""" Make id_literal like char class """
|
|
168
163
|
match = _re.compile(what).match
|
|
169
|
-
result = ''.join([
|
|
170
|
-
chr(c) for c in xrange(127) if not match(chr(c))
|
|
171
|
-
])
|
|
164
|
+
result = ''.join([chr(c) for c in xrange(127) if not match(chr(c))])
|
|
172
165
|
return '[^%s]' % fix_charclass(result)
|
|
173
166
|
|
|
174
167
|
def not_id_literal_(keep):
|
|
175
168
|
""" Make negated id_literal like char class """
|
|
176
169
|
match = _re.compile(id_literal_(keep)).match
|
|
177
|
-
result = ''.join([
|
|
178
|
-
chr(c) for c in xrange(127) if not match(chr(c))
|
|
179
|
-
])
|
|
170
|
+
result = ''.join([chr(c) for c in xrange(127) if not match(chr(c))])
|
|
180
171
|
return r'[%s]' % fix_charclass(result)
|
|
181
172
|
|
|
182
173
|
not_id_literal = not_id_literal_(r'[a-zA-Z0-9_$]')
|
|
@@ -192,28 +183,26 @@ def _make_jsmin(python_only=False):
|
|
|
192
183
|
|
|
193
184
|
space_sub_simple = _re.compile((
|
|
194
185
|
# noqa pylint: disable = bad-continuation
|
|
195
|
-
|
|
196
|
-
r'(%(dull)s
|
|
197
|
-
r'|(%(strings)s%(dull)s*)' # 1
|
|
186
|
+
r'(%(dull)s+)' # 0
|
|
187
|
+
r'|(%(strings)s%(dull)s*)' # 1
|
|
198
188
|
r'|(?<=%(preregex1)s)'
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
189
|
+
r'%(space)s*(?:%(newline)s%(space)s*)*'
|
|
190
|
+
r'(%(regex)s)' # 2
|
|
191
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 3
|
|
192
|
+
r'(?=%(post_regex_off)s))?'
|
|
203
193
|
r'|(?<=%(preregex2)s)'
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
r'%(space)s*(?:(%(newline)s)%(space)s*)*' # 4
|
|
195
|
+
r'(%(regex)s)' # 5
|
|
196
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 6
|
|
197
|
+
r'(?=%(post_regex_off)s))?'
|
|
208
198
|
r'|(?<=%(id_literal_close)s)'
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
r'%(space)s*(?:(%(newline)s)%(space)s*)+' # 7
|
|
200
|
+
r'(?=%(id_literal_open)s)'
|
|
211
201
|
r'|(?<=%(id_literal)s)(%(space)s)+(?=%(id_literal)s)' # 8
|
|
212
|
-
r'|(?<=\+)(%(space)s)+(?=\+)'
|
|
213
|
-
r'|(?<=-)(%(space)s)+(?=-)'
|
|
202
|
+
r'|(?<=\+)(%(space)s)+(?=\+)' # 9
|
|
203
|
+
r'|(?<=-)(%(space)s)+(?=-)' # 10
|
|
214
204
|
r'|%(space)s+'
|
|
215
|
-
r'|(?:%(newline)s%(space)s*)+'
|
|
216
|
-
) % locals()).sub
|
|
205
|
+
r'|(?:%(newline)s%(space)s*)+') % locals()).sub
|
|
217
206
|
|
|
218
207
|
# print space_sub_simple.__self__.pattern
|
|
219
208
|
|
|
@@ -245,35 +234,33 @@ def _make_jsmin(python_only=False):
|
|
|
245
234
|
|
|
246
235
|
space_sub_banged = _re.compile((
|
|
247
236
|
# noqa pylint: disable = bad-continuation
|
|
248
|
-
|
|
249
|
-
r'(%(dull)s
|
|
250
|
-
r'|(%(strings)s%(dull)s*)' # 1
|
|
237
|
+
r'(%(dull)s+)' # 0
|
|
238
|
+
r'|(%(strings)s%(dull)s*)' # 1
|
|
251
239
|
r'|(?<=%(preregex1)s)'
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
240
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)*)' # 2
|
|
241
|
+
r'(%(regex)s)' # 3
|
|
242
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 4
|
|
243
|
+
r'(?=%(post_regex_off)s))?'
|
|
256
244
|
r'|(?<=%(preregex2)s)'
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
245
|
+
r'(%(space)s*(?:(%(newline)s)%(space)s*)*)' # 5, 6
|
|
246
|
+
r'(%(regex)s)' # 7
|
|
247
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 8
|
|
248
|
+
r'(?=%(post_regex_off)s))?'
|
|
261
249
|
r'|(?<=%(id_literal_close)s)'
|
|
262
|
-
|
|
263
|
-
|
|
250
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+)' # 9
|
|
251
|
+
r'(?=%(id_literal_open)s)'
|
|
264
252
|
r'|(?<=%(id_literal)s)(%(space)s+)(?=%(id_literal)s)' # 10
|
|
265
|
-
r'|(?<=\+)(%(space)s+)(?=\+)'
|
|
266
|
-
r'|(?<=-)(%(space)s+)(?=-)'
|
|
267
|
-
r'|(%(space)s+)'
|
|
268
|
-
r'|((?:%(newline)s%(space)s*)+)'
|
|
253
|
+
r'|(?<=\+)(%(space)s+)(?=\+)' # 11
|
|
254
|
+
r'|(?<=-)(%(space)s+)(?=-)' # 12
|
|
255
|
+
r'|(%(space)s+)' # 13
|
|
256
|
+
r'|((?:%(newline)s%(space)s*)+)' # 14
|
|
269
257
|
) % locals()).sub
|
|
270
258
|
|
|
271
259
|
# print space_sub_banged.__self__.pattern
|
|
272
260
|
|
|
273
|
-
keep = _re.compile(
|
|
274
|
-
r'%(space_chars)s+|%(space_comment_nobang)s+|%(newline)s+'
|
|
275
|
-
|
|
276
|
-
) % locals()).sub
|
|
261
|
+
keep = _re.compile(
|
|
262
|
+
(r'%(space_chars)s+|%(space_comment_nobang)s+|%(newline)s+'
|
|
263
|
+
r'|(%(bang_comment)s+)') % locals()).sub
|
|
277
264
|
keeper = lambda m: m.groups()[0] or ''
|
|
278
265
|
|
|
279
266
|
# print keep.__self__.pattern
|
|
@@ -333,16 +320,15 @@ def _make_jsmin(python_only=False):
|
|
|
333
320
|
# pylint: disable = redefined-outer-name
|
|
334
321
|
|
|
335
322
|
if keep_bang_comments:
|
|
336
|
-
return space_sub_banged(
|
|
337
|
-
|
|
338
|
-
).strip()
|
|
323
|
+
return space_sub_banged(space_subber_banged,
|
|
324
|
+
'\n%s\n' % script).strip()
|
|
339
325
|
else:
|
|
340
|
-
return space_sub_simple(
|
|
341
|
-
|
|
342
|
-
).strip()
|
|
326
|
+
return space_sub_simple(space_subber_simple,
|
|
327
|
+
'\n%s\n' % script).strip()
|
|
343
328
|
|
|
344
329
|
return jsmin
|
|
345
330
|
|
|
331
|
+
|
|
346
332
|
jsmin = _make_jsmin()
|
|
347
333
|
|
|
348
334
|
|
|
@@ -403,28 +389,19 @@ def jsmin_for_posers(script, keep_bang_comments=False):
|
|
|
403
389
|
r'\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=-)|(?:['
|
|
404
390
|
r'\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)'
|
|
405
391
|
r')+|(?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]'
|
|
406
|
-
r'|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+'
|
|
407
|
-
)
|
|
392
|
+
r'|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+')
|
|
408
393
|
|
|
409
394
|
def subber(match):
|
|
410
395
|
""" Substitution callback """
|
|
411
396
|
groups = match.groups()
|
|
412
|
-
return (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
groups[
|
|
419
|
-
groups[
|
|
420
|
-
groups[6] and '\n' or '',
|
|
421
|
-
)) or
|
|
422
|
-
(groups[7] and '\n') or
|
|
423
|
-
(groups[8] and ' ') or
|
|
424
|
-
(groups[9] and ' ') or
|
|
425
|
-
(groups[10] and ' ') or
|
|
426
|
-
''
|
|
427
|
-
)
|
|
397
|
+
return (groups[0] or groups[1]
|
|
398
|
+
or (groups[3] and (groups[2] + '\n')) or groups[2]
|
|
399
|
+
or (groups[5] and "%s%s%s" % (
|
|
400
|
+
groups[4] and '\n' or '',
|
|
401
|
+
groups[5],
|
|
402
|
+
groups[6] and '\n' or '',
|
|
403
|
+
)) or (groups[7] and '\n') or (groups[8] and ' ')
|
|
404
|
+
or (groups[9] and ' ') or (groups[10] and ' ') or '')
|
|
428
405
|
else:
|
|
429
406
|
rex = (
|
|
430
407
|
r'([^\047"/\000-\040]+)|((?:(?:\047[^\047\\\r\n]*(?:\\(?:[^\r\n]'
|
|
@@ -457,46 +434,39 @@ def jsmin_for_posers(script, keep_bang_comments=False):
|
|
|
457
434
|
r'11\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))+)(?=-'
|
|
458
435
|
r')|((?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*'
|
|
459
436
|
r'\*+)*/))+)|((?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014'
|
|
460
|
-
r'\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+)'
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
r'*]*\*+)*/)+)'
|
|
467
|
-
) % locals()).sub
|
|
437
|
+
r'\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+)')
|
|
438
|
+
|
|
439
|
+
keep = _re.compile(
|
|
440
|
+
(r'[\000-\011\013\014\016-\040]+|(?:/\*(?!!)[^*]*\*+(?:[^/*][^*]*'
|
|
441
|
+
r'\*+)*/)+|(?:(?://[^\r\n]*)?[\r\n])+|((?:/\*![^*]*\*+(?:[^/*][^'
|
|
442
|
+
r'*]*\*+)*/)+)') % locals()).sub
|
|
468
443
|
keeper = lambda m: m.groups()[0] or ''
|
|
469
444
|
|
|
470
445
|
def subber(match):
|
|
471
446
|
""" Substitution callback """
|
|
472
447
|
groups = match.groups()
|
|
473
|
-
return (
|
|
474
|
-
groups[
|
|
475
|
-
groups[
|
|
476
|
-
(groups[
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
(groups[
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
groups[
|
|
486
|
-
keep(keeper, groups[
|
|
487
|
-
groups[
|
|
488
|
-
|
|
489
|
-
(groups[9] and keep(keeper, groups[9] + '\n')) or
|
|
490
|
-
(groups[10] and keep(keeper, groups[10]) or ' ') or
|
|
491
|
-
(groups[11] and keep(keeper, groups[11]) or ' ') or
|
|
492
|
-
(groups[12] and keep(keeper, groups[12]) or ' ') or
|
|
493
|
-
keep(keeper, groups[13] or groups[14])
|
|
494
|
-
)
|
|
448
|
+
return (groups[0] or groups[1] or (groups[3] and "%s%s%s%s" % (
|
|
449
|
+
keep(keeper, groups[2]),
|
|
450
|
+
groups[3],
|
|
451
|
+
keep(keeper, groups[4] or ''),
|
|
452
|
+
groups[4] and '\n' or '',
|
|
453
|
+
)) or (groups[7] and "%s%s%s%s%s" % (
|
|
454
|
+
keep(keeper, groups[5]),
|
|
455
|
+
groups[6] and '\n' or '',
|
|
456
|
+
groups[7],
|
|
457
|
+
keep(keeper, groups[8] or ''),
|
|
458
|
+
groups[8] and '\n' or '',
|
|
459
|
+
)) or (groups[9] and keep(keeper, groups[9] + '\n'))
|
|
460
|
+
or (groups[10] and keep(keeper, groups[10]) or ' ')
|
|
461
|
+
or (groups[11] and keep(keeper, groups[11]) or ' ')
|
|
462
|
+
or (groups[12] and keep(keeper, groups[12]) or ' ')
|
|
463
|
+
or keep(keeper, groups[13] or groups[14]))
|
|
495
464
|
|
|
496
465
|
return _re.sub(rex, subber, '\n%s\n' % script).strip()
|
|
497
466
|
|
|
498
467
|
|
|
499
468
|
if __name__ == '__main__':
|
|
469
|
+
|
|
500
470
|
def main():
|
|
501
471
|
""" Main """
|
|
502
472
|
import sys as _sys
|
|
@@ -508,8 +478,7 @@ if __name__ == '__main__':
|
|
|
508
478
|
else:
|
|
509
479
|
xjsmin = jsmin
|
|
510
480
|
|
|
511
|
-
_sys.stdout.write(
|
|
512
|
-
_sys.stdin.read(), keep_bang_comments=keep_bang_comments
|
|
513
|
-
))
|
|
481
|
+
_sys.stdout.write(
|
|
482
|
+
xjsmin(_sys.stdin.read(), keep_bang_comments=keep_bang_comments))
|
|
514
483
|
|
|
515
484
|
main()
|
|
@@ -3,16 +3,7 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
if (taggedTemplateExpression.name) {
|
|
8
|
-
// Call to html`` and we assume that html = LitHtml's html function.
|
|
9
|
-
return taggedTemplateExpression.name === 'html';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Match calls to LitHtml.html``
|
|
13
|
-
return taggedTemplateExpression.object && taggedTemplateExpression.object.name === 'LitHtml' &&
|
|
14
|
-
taggedTemplateExpression.property.name === 'html';
|
|
15
|
-
}
|
|
6
|
+
const {isLitHtmlTemplateCall} = require('./utils.js');
|
|
16
7
|
|
|
17
8
|
module.exports = {
|
|
18
9
|
meta: {
|
|
@@ -27,7 +18,7 @@ module.exports = {
|
|
|
27
18
|
create: function(context) {
|
|
28
19
|
return {
|
|
29
20
|
TaggedTemplateExpression(node) {
|
|
30
|
-
const isLitHtmlCall = isLitHtmlTemplateCall(node
|
|
21
|
+
const isLitHtmlCall = isLitHtmlTemplateCall(node);
|
|
31
22
|
if (!isLitHtmlCall) {
|
|
32
23
|
return;
|
|
33
24
|
}
|
|
@@ -3,16 +3,7 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
if (taggedTemplateExpression.name) {
|
|
8
|
-
// Call to html`` and we assume that html = LitHtml's html function.
|
|
9
|
-
return taggedTemplateExpression.name === 'html';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Match calls to LitHtml.html``
|
|
13
|
-
return taggedTemplateExpression.object && taggedTemplateExpression.object.name === 'LitHtml' &&
|
|
14
|
-
taggedTemplateExpression.property.name === 'html';
|
|
15
|
-
}
|
|
6
|
+
const {isLitHtmlTemplateCall} = require('./utils.js');
|
|
16
7
|
|
|
17
8
|
module.exports = {
|
|
18
9
|
meta: {
|
|
@@ -28,7 +19,7 @@ module.exports = {
|
|
|
28
19
|
create: function(context) {
|
|
29
20
|
return {
|
|
30
21
|
TaggedTemplateExpression(node) {
|
|
31
|
-
const isLitHtmlCall = isLitHtmlTemplateCall(node
|
|
22
|
+
const isLitHtmlCall = isLitHtmlTemplateCall(node);
|
|
32
23
|
if (!isLitHtmlCall) {
|
|
33
24
|
return;
|
|
34
25
|
}
|
|
@@ -3,16 +3,7 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
if (taggedTemplateExpression.name) {
|
|
8
|
-
// Call to html`` and we assume that html = LitHtml's html function.
|
|
9
|
-
return taggedTemplateExpression.name === 'html';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Match calls to LitHtml.html``
|
|
13
|
-
return taggedTemplateExpression.object && taggedTemplateExpression.object.name === 'LitHtml' &&
|
|
14
|
-
taggedTemplateExpression.property.name === 'html';
|
|
15
|
-
}
|
|
6
|
+
const {isLitHtmlTemplateCall} = require('./utils.js');
|
|
16
7
|
|
|
17
8
|
module.exports = {
|
|
18
9
|
meta: {
|
|
@@ -27,7 +18,7 @@ module.exports = {
|
|
|
27
18
|
create: function(context) {
|
|
28
19
|
return {
|
|
29
20
|
TaggedTemplateExpression(node) {
|
|
30
|
-
const isLitHtmlCall = isLitHtmlTemplateCall(node
|
|
21
|
+
const isLitHtmlCall = isLitHtmlTemplateCall(node);
|
|
31
22
|
if (!isLitHtmlCall) {
|
|
32
23
|
return;
|
|
33
24
|
}
|