diff --git a/package.json b/package.json index 01c6b1ebc8a2f..8b241945d96f3 100644 --- a/package.json +++ b/package.json @@ -6164,6 +6164,7 @@ "clean-webpack-plugin": "3.0.0", "csp-html-webpack-plugin": "4.0.0", "css-loader": "3.5.3", + "ejs-loader": "0.3.6", "eslint": "7.1.0", "eslint-cli": "1.1.1", "eslint-config-prettier": "6.11.0", @@ -6177,7 +6178,7 @@ "prettier": "2.0.5", "sass-loader": "8.0.2", "terser-webpack-plugin": "3.0.1", - "ts-loader": "7.0.4", + "ts-loader": "7.0.5", "typescript": "3.9.3", "vsce": "1.75.0", "webpack": "4.43.0", diff --git a/src/webviews/apps/settings/index.html b/src/webviews/apps/settings/index.html deleted file mode 100644 index b613d44eeef8f..0000000000000 --- a/src/webviews/apps/settings/index.html +++ /dev/null @@ -1,3275 +0,0 @@ - - - - - - - - - -
-
- - - -

- GitLens supercharges the Git capabilities built into Visual Studio Code. It helps you to - visualize code authorship at a glance via Git blame annotations and code lens, - seamlessly navigate and explore Git repositories, gain valuable insights via powerful - comparison commands, and so much more. -

-
- -
-
-

Settings

- -
- -
-
-

- For advanced customizations, refer to the - GitLens docs - and edit your - User Settings -

-
- -
-
-
-
- - - - - -
- -

- Adds an unobtrusive blame annotation at the end of the current line -

-
- -
-

- Use the - GitLens: Toggle Line Blame Annotations - command to override this setting for the current window -

-
-
-
- -
-
-
-
-
-
- - - -
- -
- -
-
- - -
-

- When enabled the annotation can be scrolled into view when it is outside the - viewport -

-
-
-
- -
- - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.currentLine -

-
-
-
- -
-
-
- - - - - -
- -

- Adds authorship code lens to the top of files and on code blocks -

-
- -
-

- Use the - GitLens: Toggle Git Code Lens - command to override this setting for the current window -

-
-
-
- -
-
-
-
-
-
- - -
-
- -
-
-
- - - -
-
-
- -
-
- - -
-
- -
-
-
- - - -
-
-
- -
-
- -
-
- -
-
-
- - -
-

At the top of the file

-
- -
-
- - -
-

- At the start of modules, classes, interfaces, etc -

-
- -
-
- - -
-

At the start of functions, methods, etc

-
-
-
-
- -
- - - - - - - - - - - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.codeLens -

-
-
-
- -
-
-
- - - - - -
- -

- Adds a Git blame annotation about the current line to the status bar -

-
- -
-
-
-
-
-
- - - - -
-
- -
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-

- Avoids clearing the previous blame information when changing lines to reduce - status bar "flashing" -

-
-
-
- -
- - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.statusBar -

-
-
-
- -
-
-
- - - - - -
- -

Adds detailed blame information accessible via hovers

-
- -
-
-
-
-
-
- - -
-
-
-
-
- -
-
-
- - - - -
- - - - -
-
- - -
-
- -
-
- - -
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-
- - -
-
- -
-
-
-
- - -
-
-
- -
-
- - -
-
- -
-
- - -
-
-
-
-
- -
- - - - - - - - -
-
-
-
- -
-
-

- Views - - - -

-

Adds rich views to visualize, navigate, and explore

-
- -
-
-
-

- GitLens views can be configured to be shown in different side bar layouts to best - match your workflow -

-
-
- GitLens Layout (default) -

Shows all the views together on the GitLens side bar

-
-
- Source Control Layout -

Shows all the views together on the Source Control side bar

-
-
- -

- You can also simply drag & drop individual views - to create custom layouts -

-
-
-
-
- -
-
-
- - - - - -
- -

- Adds a Repositories view to visualize, navigate, and explore Git repositories -

-
- -
-
-
-
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-

- Chooses the best layout based on the number of files at each nesting level -

-
- -
-
- - -
-

- Compacts (flattens) unnecessary nesting when using a tree layouts -

-
- -
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
-
-
- -
- - - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.views.repositories or - gitlens.views -

-
-
-
- -
-
-
- - - - - -
- -

- Adds a File History view to visualize, navigate, and explore the revision history of the - current file -

-
- -
-
-
-
-
-
- - -
-
- -
-
- - -
-
-
-
- -
- - -
-
-
-
- -
-
-
- - - - - -
- -

- Adds a Line History view to visualize, navigate, and explore the revision history of the - selected lines of current file -

-
- -
-
-
-
-
-
- - -
-
- -
-
- - -
-
-
-
- -
- - -
-
-
-
- -
-
-
- - - - - -
- -

- Adds a Search Commits view to search and explore commit histories by message, author, files, - id, etc -

-
- -
-
-
-
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-

- Compacts (flattens) unnecessary nesting when using a tree layouts -

-
- -
-
- - -
-
-
-
- -
- - - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.views.search or gitlens.views -

-
-
-
- -
-
-
- - - - - -
- -

- Adds a Compare view to visualize comparisons between branches, tags, commits, and more -

-
- -
-
-
-
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-

- Compacts (flattens) unnecessary nesting when using a tree layouts -

-
- -
-
- - -
-
-
-
- -
- - - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.views.compare or gitlens.views -

-
-
-
- -
-
-

- Gutter Blame - - - -

- -

- Adds on-demand gutter blame annotations for the whole file -

-
- -
-

- Use the - - - command to turn the annotations on or off -

-

Press Esc to turn off the annotations

-
-
-
- -
-
-
-
-
- - -
-
- -
-
- - - - -
-
- -
-
- - -
-

- Indicator color reflects the age of the most recent change (hot or cold), while - indicator brightness ranges from bright (newer) to dim (older) based on the - relative age -

-
- -
-
-
- - -
-
-
- -
-
- - -
-
- -
-
- - -
-

- Compacts (deduplicates) matching adjacent blame annotations -

-
- -
-
- - -
-
- -
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
-
-
- -
- - - - - - - - - -
-
- -
-

- For more options, open - User Settings - and search for gitlens.blame -

-
-
-
- -
-
-

- Gutter Heatmap - - - -

- -

- Adds on-demand heatmap (age) indicator to the edge of the gutter to show how recently lines - were changed -

-
- -
-

- Use the - - - command to turn the annotations on or off -

-

Press Esc to turn off the annotations

-
-
-
- -
-
-
-

- Indicator color reflects the age of the most recent - change (hot or cold), while indicator brightness ranges from bright (newer) to dim - (older) based on the relative age -

- -
-
- - -
-
-
- -
- -
-
-
-
- -
-
-

- Recent Changes - - - -

- -

- Adds on-demand recent changes annotations to highlight lines changed by the most recent - commit -

-
- -
-

- Use the - - - command to turn the annotations on or off -

-

Press Esc to turn off the annotations

-
-
-
- -
-
-
-
-
- - -
-
- -
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
-
-
- -
- - - - -
-
-
-
- -
-
-

Dates & Times

-
- -
-
-
-
-
- - -
- - -
- -
-
-
- - - - - -
- Example date: - - -
- -
-
- - - - - -
- Example short date: - - -
-
-
-
-
-
- - - -
-
-

Keyboard Shortcuts

-
- -
-
-
-
-
- - - -
- - - -
-
-
- -
-

- Search for gitlens in the - Keyboard Shortcuts - editor to see the shortcuts and to customize them further -

-
-
-
- -
-
-

- Modes - - - -

- -

- Supports user-defined modes for quickly toggling between sets of settings -

-
- -
-

- Use the - GitLens: Switch Mode - command to quickly switch the active mode -

-

- Use the - GitLens: Toggle Review Mode - command to toggle Review mode -

-

- Use the - GitLens: Toggle Zen Mode - command to toggle Zen mode -

-
-
-
- -
-
-
-
-
- - -
-
- -
-
-
- - -
-
-
-
- -
- - - -
-
- -
-

- For more options or to add your own custom modes, open - User Settings - and search for gitlens.modes -

-
-
-
-
- - -
- - #{endOfBody} - - diff --git a/src/webviews/apps/settings/partials/blame.ejs b/src/webviews/apps/settings/partials/blame.ejs new file mode 100644 index 0000000000000..be3c0bda80f69 --- /dev/null +++ b/src/webviews/apps/settings/partials/blame.ejs @@ -0,0 +1,234 @@ +
+
+

+ Gutter Blame + + + +

+ +

+ Adds on-demand gutter blame annotations for the whole file +

+
+ +
+

+ Use the + + + command to turn the annotations on or off +

+

Press Esc to turn off the annotations

+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ + + + +
+
+ +
+
+ + +
+

+ Indicator color reflects the age of the most recent change (hot or cold), while indicator + brightness ranges from bright (newer) to dim (older) based on the relative age +

+
+ +
+
+
+ + +
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+

+ Compacts (deduplicates) matching adjacent blame annotations +

+
+ +
+
+ + +
+
+ +
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+ + + + + + + + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.blame +

+
+
+
diff --git a/src/webviews/apps/settings/partials/code-lens.ejs b/src/webviews/apps/settings/partials/code-lens.ejs new file mode 100644 index 0000000000000..64e154c99c2ea --- /dev/null +++ b/src/webviews/apps/settings/partials/code-lens.ejs @@ -0,0 +1,272 @@ +
+
+
+ + + + + +
+ +

+ Adds authorship code lens to the top of files and on code blocks +

+
+ +
+

+ Use the + GitLens: Toggle Git Code Lens + command to override this setting for the current window +

+
+
+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+
+ + + +
+
+
+ +
+
+ + +
+
+ +
+
+
+ + + +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+

At the top of the file

+
+ +
+
+ + +
+

+ At the start of modules, classes, interfaces, etc +

+
+ +
+
+ + +
+

At the start of functions, methods, etc

+
+
+
+
+ +
+ + + + + + + + + + + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.codeLens +

+
+
+
diff --git a/src/webviews/apps/settings/partials/current-line.ejs b/src/webviews/apps/settings/partials/current-line.ejs new file mode 100644 index 0000000000000..bcac8a26361e2 --- /dev/null +++ b/src/webviews/apps/settings/partials/current-line.ejs @@ -0,0 +1,107 @@ +
+
+
+ + + + + +
+ +

+ Adds an unobtrusive blame annotation at the end of the current line +

+
+ +
+

+ Use the + GitLens: Toggle Line Blame Annotations + command to override this setting for the current window +

+
+
+
+ +
+
+
+
+
+
+ + + +
+ +
+ +
+
+ + +
+

+ When enabled the annotation can be scrolled into view when it is outside the viewport +

+
+
+
+ +
+ + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.currentLine +

+
+
+
diff --git a/src/webviews/apps/settings/partials/dates.ejs b/src/webviews/apps/settings/partials/dates.ejs new file mode 100644 index 0000000000000..de9bf4d1cb59c --- /dev/null +++ b/src/webviews/apps/settings/partials/dates.ejs @@ -0,0 +1,96 @@ +
+
+

Dates & Times

+
+ +
+
+
+
+
+ + +
+ + +
+ +
+
+
+ + + + + +
+ Example date: + + +
+ +
+
+ + + + + +
+ Example short date: + + +
+
+
+
+
+
diff --git a/src/webviews/apps/settings/partials/heatmap.ejs b/src/webviews/apps/settings/partials/heatmap.ejs new file mode 100644 index 0000000000000..3036e4507cb6c --- /dev/null +++ b/src/webviews/apps/settings/partials/heatmap.ejs @@ -0,0 +1,65 @@ +
+
+

+ Gutter Heatmap + + + +

+ +

+ Adds on-demand heatmap (age) indicator to the edge of the gutter to show how recently lines were changed +

+
+ +
+

+ Use the + + + command to turn the annotations on or off +

+

Press Esc to turn off the annotations

+
+
+
+ +
+
+
+

+ Indicator color reflects the age of the most recent change (hot or + cold), while indicator brightness ranges from bright (newer) to dim (older) based on the relative + age +

+ +
+
+ + +
+
+
+ +
+ +
+
+
+
diff --git a/src/webviews/apps/settings/partials/hovers.ejs b/src/webviews/apps/settings/partials/hovers.ejs new file mode 100644 index 0000000000000..f0ab98286efd7 --- /dev/null +++ b/src/webviews/apps/settings/partials/hovers.ejs @@ -0,0 +1,341 @@ +
+
+
+ + + + + +
+ +

Adds detailed blame information accessible via hovers

+
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+
+ + + + +
+ + + + +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+ + +
+
+ +
+
+
+
+ + +
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+ +
+ + + + + + + + +
+
+
+
diff --git a/src/webviews/apps/settings/partials/menus.ejs b/src/webviews/apps/settings/partials/menus.ejs new file mode 100644 index 0000000000000..672d77ad9dde6 --- /dev/null +++ b/src/webviews/apps/settings/partials/menus.ejs @@ -0,0 +1,537 @@ + diff --git a/src/webviews/apps/settings/partials/modes.ejs b/src/webviews/apps/settings/partials/modes.ejs new file mode 100644 index 0000000000000..a3c288e38a1d6 --- /dev/null +++ b/src/webviews/apps/settings/partials/modes.ejs @@ -0,0 +1,91 @@ +
+
+

+ Modes + + + +

+ +

+ Supports user-defined modes for quickly toggling between sets of settings +

+
+ +
+

+ Use the + GitLens: Switch Mode + command to quickly switch the active mode +

+

+ Use the + GitLens: Toggle Review Mode + command to toggle Review mode +

+

+ Use the + GitLens: Toggle Zen Mode + command to toggle Zen mode +

+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+
+ + +
+
+
+
+ +
+ + + +
+
+ +
+

+ For more options or to add your own custom modes, open + User Settings + and search for gitlens.modes +

+
+
+
diff --git a/src/webviews/apps/settings/partials/recent-changes.ejs b/src/webviews/apps/settings/partials/recent-changes.ejs new file mode 100644 index 0000000000000..60c65f34d9707 --- /dev/null +++ b/src/webviews/apps/settings/partials/recent-changes.ejs @@ -0,0 +1,118 @@ +
+
+

+ Recent Changes + + + +

+ +

+ Adds on-demand recent changes annotations to highlight lines changed by the most recent commit +

+
+ +
+

+ Use the + + + command to turn the annotations on or off +

+

Press Esc to turn off the annotations

+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+ + + + +
+
+
+
diff --git a/src/webviews/apps/settings/partials/shortcuts.ejs b/src/webviews/apps/settings/partials/shortcuts.ejs new file mode 100644 index 0000000000000..cd2d2868758a1 --- /dev/null +++ b/src/webviews/apps/settings/partials/shortcuts.ejs @@ -0,0 +1,54 @@ +
+
+

Keyboard Shortcuts

+
+ +
+
+
+
+
+ + + +
+ + + +
+
+
+ +
+

+ Search for gitlens in the + Keyboard Shortcuts + editor to see the shortcuts and to customize them further +

+
+
+
diff --git a/src/webviews/apps/settings/partials/status-bar.ejs b/src/webviews/apps/settings/partials/status-bar.ejs new file mode 100644 index 0000000000000..4194387785529 --- /dev/null +++ b/src/webviews/apps/settings/partials/status-bar.ejs @@ -0,0 +1,126 @@ +
+
+
+ + + + + +
+ +

+ Adds a Git blame annotation about the current line to the status bar +

+
+ +
+
+
+
+
+
+ + + + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+

+ Avoids clearing the previous blame information when changing lines to reduce status bar + "flashing" +

+
+
+
+ +
+ + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.statusBar +

+
+
+
diff --git a/src/webviews/apps/settings/partials/views.compare.ejs b/src/webviews/apps/settings/partials/views.compare.ejs new file mode 100644 index 0000000000000..01fc372330e24 --- /dev/null +++ b/src/webviews/apps/settings/partials/views.compare.ejs @@ -0,0 +1,116 @@ +
+
+
+ + + + + +
+ +

+ Adds a Compare view to visualize comparisons between branches, tags, commits, and more +

+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+

+ Compacts (flattens) unnecessary nesting when using a tree layouts +

+
+ +
+
+ + +
+
+
+
+ +
+ + + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.views.compare or gitlens.views +

+
+
+
diff --git a/src/webviews/apps/settings/partials/views.ejs b/src/webviews/apps/settings/partials/views.ejs new file mode 100644 index 0000000000000..423b9051876e2 --- /dev/null +++ b/src/webviews/apps/settings/partials/views.ejs @@ -0,0 +1,51 @@ +
+
+

+ Views + + + +

+

Adds rich views to visualize, navigate, and explore

+
+ +
+
+
+

+ GitLens views can be configured to be shown in different side bar layouts to best match your + workflow +

+
+
+ GitLens Layout (default) +

Shows all the views together on the GitLens side bar

+
+
+ Source Control Layout +

Shows all the views together on the Source Control side bar

+
+
+ +

+ You can also simply drag & drop individual views to create + custom layouts +

+
+
+
+
diff --git a/src/webviews/apps/settings/partials/views.file-history.ejs b/src/webviews/apps/settings/partials/views.file-history.ejs new file mode 100644 index 0000000000000..bf06cca60c80b --- /dev/null +++ b/src/webviews/apps/settings/partials/views.file-history.ejs @@ -0,0 +1,69 @@ +
+
+
+ + + + + +
+ +

+ Adds a File History view to visualize, navigate, and explore the revision history of the current file +

+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+ + +
+
+
+
diff --git a/src/webviews/apps/settings/partials/views.line-history.ejs b/src/webviews/apps/settings/partials/views.line-history.ejs new file mode 100644 index 0000000000000..6937b9521ebd1 --- /dev/null +++ b/src/webviews/apps/settings/partials/views.line-history.ejs @@ -0,0 +1,70 @@ +
+
+
+ + + + + +
+ +

+ Adds a Line History view to visualize, navigate, and explore the revision history of the selected lines of + current file +

+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+ + +
+
+
+
diff --git a/src/webviews/apps/settings/partials/views.repositories.ejs b/src/webviews/apps/settings/partials/views.repositories.ejs new file mode 100644 index 0000000000000..5d6f92537e9ca --- /dev/null +++ b/src/webviews/apps/settings/partials/views.repositories.ejs @@ -0,0 +1,220 @@ +
+
+
+ + + + + +
+ +

+ Adds a Repositories view to visualize, navigate, and explore Git repositories +

+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+

+ Chooses the best layout based on the number of files at each nesting level +

+
+ +
+
+ + +
+

+ Compacts (flattens) unnecessary nesting when using a tree layouts +

+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+ + + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.views.repositories or + gitlens.views +

+
+
+
diff --git a/src/webviews/apps/settings/partials/views.search.ejs b/src/webviews/apps/settings/partials/views.search.ejs new file mode 100644 index 0000000000000..893302ea40324 --- /dev/null +++ b/src/webviews/apps/settings/partials/views.search.ejs @@ -0,0 +1,116 @@ +
+
+
+ + + + + +
+ +

+ Adds a Search Commits view to search and explore commit histories by message, author, files, id, etc +

+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+

+ Compacts (flattens) unnecessary nesting when using a tree layouts +

+
+ +
+
+ + +
+
+
+
+ +
+ + + + +
+
+ +
+

+ For more options, open + User Settings + and search for gitlens.views.search or gitlens.views +

+
+
+
diff --git a/src/webviews/apps/settings/settings.ejs b/src/webviews/apps/settings/settings.ejs new file mode 100644 index 0000000000000..48a6fcbe2a48e --- /dev/null +++ b/src/webviews/apps/settings/settings.ejs @@ -0,0 +1,416 @@ + + + + + + + + + +
+
+ + + +

+ GitLens supercharges the Git capabilities built into Visual Studio Code. It helps you to + visualize code authorship at a glance via Git blame annotations and code lens, + seamlessly navigate and explore Git repositories, gain valuable insights via powerful + comparison commands, and so much more. +

+
+ +
+
+

Settings

+ +
+ +
+
+

+ For advanced customizations, refer to the + GitLens docs + and edit your + User Settings +

+
+ +
+ + <%= require('./partials/current-line.ejs')() %> + + <%= require('./partials/code-lens.ejs')() %> + + <%= require('./partials/status-bar.ejs')() %> + + <%= require('./partials/hovers.ejs')() %> + + <%= require('./partials/views.ejs')() %> + + <%= require('./partials/views.repositories.ejs')() %> + + <%= require('./partials/views.file-history.ejs')() %> + + <%= require('./partials/views.line-history.ejs')() %> + + <%= require('./partials/views.search.ejs')() %> + + <%= require('./partials/views.compare.ejs')() %> + + <%= require('./partials/blame.ejs')() %> + + <%= require('./partials/heatmap.ejs')() %> + + <%= require('./partials/recent-changes.ejs')() %> + + <%= require('./partials/dates.ejs')() %> + + <%= require('./partials/menus.ejs')() %> + + <%= require('./partials/shortcuts.ejs')() %> + + <%= require('./partials/modes.ejs')() %> +
+ + +
+ + #{endOfBody} + + diff --git a/src/webviews/apps/settings/index.ts b/src/webviews/apps/settings/settings.ts similarity index 100% rename from src/webviews/apps/settings/index.ts rename to src/webviews/apps/settings/settings.ts diff --git a/src/webviews/apps/welcome/index.html b/src/webviews/apps/welcome/welcome.ejs similarity index 100% rename from src/webviews/apps/welcome/index.html rename to src/webviews/apps/welcome/welcome.ejs diff --git a/src/webviews/apps/welcome/index.ts b/src/webviews/apps/welcome/welcome.ts similarity index 100% rename from src/webviews/apps/welcome/index.ts rename to src/webviews/apps/welcome/welcome.ts diff --git a/src/webviews/webviewBase.ts b/src/webviews/webviewBase.ts index 16ee9d1378385..5a76e3790d6fe 100644 --- a/src/webviews/webviewBase.ts +++ b/src/webviews/webviewBase.ts @@ -8,6 +8,7 @@ import { Disposable, Uri, ViewColumn, + Webview, WebviewPanel, WebviewPanelOnDidChangeViewStateEvent, window, @@ -101,7 +102,7 @@ export abstract class WebviewBase implements Disposable { const inspect = configuration.inspect(key as any)!; let value = params.changes[key]; - if (value !== undefined) { + if (value != null) { if (params.scope === 'workspace') { if (value === inspect.workspaceValue) continue; } else { @@ -136,25 +137,21 @@ export abstract class WebviewBase implements Disposable { } get visible() { - return this._panel === undefined ? false : this._panel.visible; + return this._panel?.visible ?? false; } hide() { - if (this._panel === undefined) return; - - this._panel.dispose(); + this._panel?.dispose(); } setTitle(title: string) { - if (this._panel === undefined) return; + if (this._panel == null) return; this._panel.title = title; } async show(column: ViewColumn = ViewColumn.Active): Promise { - const html = await this.getHtml(); - - if (this._panel === undefined) { + if (this._panel == null) { this._panel = window.createWebviewPanel( this.id, this.title, @@ -176,17 +173,20 @@ export abstract class WebviewBase implements Disposable { ...this.registerCommands(), ); - this._panel.webview.html = html; + this._panel.webview.html = await this.getHtml(this._panel.webview); } else { + const html = await this.getHtml(this._panel.webview); + // Reset the html to get the webview to reload this._panel.webview.html = ''; this._panel.webview.html = html; + this._panel.reveal(this._panel.viewColumn ?? ViewColumn.Active, false); } } private _html: string | undefined; - private async getHtml(): Promise { + private async getHtml(webview: Webview): Promise { const filename = Container.context.asAbsolutePath(paths.join('dist/webviews/', this.filename)); let content; @@ -202,16 +202,15 @@ export abstract class WebviewBase implements Disposable { }); }); } else { - if (this._html !== undefined) return this._html; + if (this._html != null) return this._html; const doc = await workspace.openTextDocument(filename); content = doc.getText(); } - let html = content.replace( - /#{root}/g, - Uri.file(Container.context.asAbsolutePath('.')).with({ scheme: 'vscode-resource' }).toString(), - ); + let html = content + .replace(/#{cspSource}/g, webview.cspSource) + .replace(/#{root}/g, webview.asWebviewUri(Uri.file(Container.context.asAbsolutePath('.'))).toString()); if (this.renderHead) { html = html.replace(/#{head}/i, await this.renderHead()); @@ -249,7 +248,7 @@ export abstract class WebviewBase implements Disposable { } private postMessage(message: IpcMessage) { - if (this._panel === undefined) return Promise.resolve(false); + if (this._panel == null) return Promise.resolve(false); return this._panel.webview.postMessage(message); } diff --git a/webpack.config.js b/webpack.config.js index aae6b24fd6739..f877d06b7f7c5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -210,12 +210,12 @@ function getWebviewsConfig(mode, env) { const cspPolicy = { 'default-src': "'none'", - 'img-src': ['vscode-resource:', 'https:', 'data:'], - 'script-src': ['vscode-resource:', "'nonce-Z2l0bGVucy1ib290c3RyYXA='"], - 'style-src': ['vscode-resource:'], + 'img-src': ['#{cspSource}', 'https:', 'data:'], + 'script-src': ['#{cspSource}', "'nonce-Z2l0bGVucy1ib290c3RyYXA='"], + 'style-src': ['#{cspSource}'], }; - if (mode === 'production') { + if (mode !== 'production') { cspPolicy['script-src'].push("'unsafe-eval'"); } @@ -237,7 +237,7 @@ function getWebviewsConfig(mode, env) { new HtmlPlugin({ excludeAssets: [/.+-styles\.js/], excludeChunks: ['welcome'], - template: 'settings/index.html', + template: 'settings/settings.ejs', filename: path.resolve(__dirname, 'dist/webviews/settings.html'), inject: true, cspPlugin: { @@ -265,7 +265,7 @@ function getWebviewsConfig(mode, env) { new HtmlPlugin({ excludeAssets: [/.+-styles\.js/], excludeChunks: ['settings'], - template: 'welcome/index.html', + template: 'welcome/welcome.ejs', filename: path.resolve(__dirname, 'dist/webviews/welcome.html'), inject: true, cspPlugin: { @@ -317,10 +317,11 @@ function getWebviewsConfig(mode, env) { context: path.resolve(__dirname, 'src/webviews/apps'), entry: { 'main-styles': ['./scss/main.scss'], - settings: ['./settings/index.ts'], - welcome: ['./welcome/index.ts'], + settings: ['./settings/settings.ts'], + welcome: ['./welcome/welcome.ts'], }, mode: mode, + target: 'web', devtool: mode === 'production' ? undefined : 'eval-source-map', output: { filename: '[name].js', @@ -364,6 +365,10 @@ function getWebviewsConfig(mode, env) { ], exclude: /node_modules/, }, + { + test: /\.ejs$/, + loader: 'ejs-loader', + }, ], }, resolve: { diff --git a/yarn.lock b/yarn.lock index 2469a1417c4ce..2be813866096e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -64,13 +64,13 @@ once "^1.4.0" "@octokit/request@^5.3.0": - version "5.4.3" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.3.tgz#85b78ea4ae6e1c4ac2b02528102d4cd776145935" - integrity sha512-RtqMzF3mhqxmWoqVD84x2gdtbqn2inTBU/HPkWf5u0R5r7fBTaLPAcCBgukeI2gjTwD9ChL9Cu0MlTBs7B/tSw== + version "5.4.4" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.4.tgz#dc57e85e86284fa016d0c1a2701a70a10cec4ff2" + integrity sha512-vqv1lz41c6VTxUvF9nM+a6U+vvP3vGk7drDpr0DVQg4zyqlOiKVrY17DLD6de5okj+YLHKcoqaUZTBtlNZ1BtQ== dependencies: "@octokit/endpoint" "^6.0.1" "@octokit/request-error" "^2.0.0" - "@octokit/types" "^2.11.1" + "@octokit/types" "^4.0.1" deprecation "^2.0.0" is-plain-object "^3.0.0" node-fetch "^2.3.0" @@ -85,9 +85,9 @@ "@types/node" ">= 8" "@octokit/types@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-4.0.1.tgz#dd32ff2407699f3a0c909cdd24de17b45b7d7051" - integrity sha512-Ho6h7w2h9y8RRE8r656hIj1oiSbwbIHJGF5r9G5FOwS2VdDPq8QLGvsG4x6pKHpvyGK7j+43sAc2cJKMiFoIJw== + version "4.0.2" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-4.0.2.tgz#4e5be1ed1d39532f6b1bc5ad7ce52086a83cf379" + integrity sha512-+4X6qfhT/fk/5FD66395NrFLxCzD6FsGlpPwfwvnukdyfYbhiZB/FJltiT1XM5Q63rGGBSf9FPaNV3WpNHm54A== dependencies: "@types/node" ">= 8" @@ -829,6 +829,11 @@ bfj@^6.1.1: hoopy "^0.1.4" tryer "^1.0.1" +big.js@^3.1.3: + version "3.2.0" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" + integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q== + big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" @@ -2181,6 +2186,14 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= +ejs-loader@0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/ejs-loader/-/ejs-loader-0.3.6.tgz#e6ce60ce8234bd1ce8e69ea59fab0d3b350d4935" + integrity sha512-HdnKczoNzvqTlwCbkwEIAKdrC5JWExBbIqh0GLqzmeCX5LYt5wWjq2JXwU9vcAVgn74gGKxcZIleuZF6jnmVdw== + dependencies: + loader-utils "^0.2.7" + lodash "^4.17.15" + ejs@^2.6.1: version "2.7.4" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.7.4.tgz#48661287573dcc53e366c7a1ae52c3a120eec9ba" @@ -4154,6 +4167,11 @@ json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= +json5@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= + json5@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" @@ -4286,6 +4304,16 @@ loader-utils@1.2.3: emojis-list "^2.0.0" json5 "^1.0.1" +loader-utils@^0.2.7: + version "0.2.17" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" + integrity sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g= + dependencies: + big.js "^3.1.3" + emojis-list "^2.0.0" + json5 "^0.5.0" + object-assign "^4.0.1" + loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3: version "1.4.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" @@ -7081,10 +7109,10 @@ tryer@^1.0.1: resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== -ts-loader@7.0.4: - version "7.0.4" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-7.0.4.tgz#5d9b95227de5afb91fdd9668f8920eb193cfe0cc" - integrity sha512-5du6OQHl+4ZjO4crEyoYUyWSrmmo7bAO+inkaILZ68mvahqrfoa4nn0DRmpQ4ruT4l+cuJCgF0xD7SBIyLeeow== +ts-loader@7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-7.0.5.tgz#789338fb01cb5dc0a33c54e50558b34a73c9c4c5" + integrity sha512-zXypEIT6k3oTc+OZNx/cqElrsbBtYqDknf48OZos0NQ3RTt045fBIU8RRSu+suObBzYB355aIPGOe/3kj9h7Ig== dependencies: chalk "^2.3.0" enhanced-resolve "^4.0.0"