Skip to content

Commit

Permalink
fix(grammar): avoid circular reference for injections
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 20, 2023
1 parent 025eff6 commit f045e8f
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 221 deletions.
126 changes: 63 additions & 63 deletions packages/tm-grammars/README.md

Large diffs are not rendered by default.

250 changes: 118 additions & 132 deletions packages/tm-grammars/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/tm-grammars/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tm-grammars",
"type": "module",
"version": "0.0.3",
"version": "0.0.4",
"packageManager": "[email protected]",
"description": "Collecton of TextMate grammars in JSON",
"author": "Anthony Fu <[email protected]>",
Expand Down
14 changes: 7 additions & 7 deletions packages/tm-themes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ import { themes } from 'tm-themes'
<!--list-start-->
| Name | Source | License | Type |
| ---- | ------ | ------- | ---- |
| `dark-modern` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/dark_modern.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `dark-plus` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/dark_plus.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `dark-modern` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/dark_modern.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `dark-plus` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/dark_plus.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `dracula` | [dracula/visual-studio-code](https://github.com/dracula/visual-studio-code/blob/e475d548db27773fa0004b252c0a4701f187fb7e/src/dracula.yml) | [MIT](https://raw.githubusercontent.com/dracula/visual-studio-code/master/LICENSE) | `dark` |
| `dracula-soft` | [dracula/visual-studio-code](https://github.com/dracula/visual-studio-code/blob/e475d548db27773fa0004b252c0a4701f187fb7e/src/dracula.yml) | [MIT](https://raw.githubusercontent.com/dracula/visual-studio-code/master/LICENSE) | `dark` |
| `github-dark` | [primer/github-vscode-theme](https://github.com/primer/github-vscode-theme/blob/38b50d41bdc6b190b7351e220956af043221d763/src/theme.js) | [MIT](https://raw.githubusercontent.com/primer/github-vscode-theme/main/LICENSE) | `dark` |
| `github-dark-dimmed` | [primer/github-vscode-theme](https://github.com/primer/github-vscode-theme/blob/38b50d41bdc6b190b7351e220956af043221d763/src/theme.js) | [MIT](https://raw.githubusercontent.com/primer/github-vscode-theme/main/LICENSE) | `dark` |
| `github-light` | [primer/github-vscode-theme](https://github.com/primer/github-vscode-theme/blob/38b50d41bdc6b190b7351e220956af043221d763/src/theme.js) | [MIT](https://raw.githubusercontent.com/primer/github-vscode-theme/main/LICENSE) | `light` |
| `light-modern` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/light_modern.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `light` |
| `light-plus` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/light_plus.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `light` |
| `light-modern` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/light_modern.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `light` |
| `light-plus` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/light_plus.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `light` |
| `material-theme` | [material-theme/vsc-material-theme](https://github.com/material-theme/vsc-material-theme/blob/9c1313579cecdd377fc475ccf108da6402216745/src/material.theme.config.ts) | [Apache-2.0](https://raw.githubusercontent.com/material-theme/vsc-material-theme/main/LICENSE) | `dark` |
| `material-theme-darker` | [material-theme/vsc-material-theme](https://github.com/material-theme/vsc-material-theme/blob/9c1313579cecdd377fc475ccf108da6402216745/src/material.theme.config.ts) | [Apache-2.0](https://raw.githubusercontent.com/material-theme/vsc-material-theme/main/LICENSE) | `dark` |
| `material-theme-lighter` | [material-theme/vsc-material-theme](https://github.com/material-theme/vsc-material-theme/blob/9c1313579cecdd377fc475ccf108da6402216745/src/material.theme.config.ts) | [Apache-2.0](https://raw.githubusercontent.com/material-theme/vsc-material-theme/main/LICENSE) | `light` |
| `material-theme-ocean` | [material-theme/vsc-material-theme](https://github.com/material-theme/vsc-material-theme/blob/9c1313579cecdd377fc475ccf108da6402216745/src/material.theme.config.ts) | [Apache-2.0](https://raw.githubusercontent.com/material-theme/vsc-material-theme/main/LICENSE) | `dark` |
| `material-theme-palenight` | [material-theme/vsc-material-theme](https://github.com/material-theme/vsc-material-theme/blob/9c1313579cecdd377fc475ccf108da6402216745/src/material.theme.config.ts) | [Apache-2.0](https://raw.githubusercontent.com/material-theme/vsc-material-theme/main/LICENSE) | `dark` |
| `min-dark` | [misolori/min-theme](https://github.com/misolori/min-theme/blob/dd796c3f294daecfb7f10ed277ffdc30517d59cf/themes/min-dark.json) | [MIT](https://raw.githubusercontent.com/miguelsolorio/min-theme/master/LICENSE) | `dark` |
| `min-light` | [misolori/min-theme](https://github.com/misolori/min-theme/blob/dd796c3f294daecfb7f10ed277ffdc30517d59cf/themes/min-light.json) | [MIT](https://raw.githubusercontent.com/miguelsolorio/min-theme/master/LICENSE) | `light` |
| `monokai` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-monokai/themes/monokai-color-theme.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `monokai` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-monokai/themes/monokai-color-theme.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `nord` | [arcticicestudio/nord-visual-studio-code](https://github.com/arcticicestudio/nord-visual-studio-code/blob/8ead09822c02d0d49d0f764104505e5a34d3689f/themes/nord-color-theme.json) | [MIT](https://raw.githubusercontent.com/nordtheme/visual-studio-code/develop/license) | `dark` |
| `one-dark-pro` | [Binaryify/OneDark-Pro](https://github.com/Binaryify/OneDark-Pro/blob/0f37dcd4d02d71465ed0bc65c3829cbdfaa3fc5f/themes/OneDark-Pro.json) | [MIT](https://raw.githubusercontent.com/Binaryify/OneDark-Pro/master/LICENSE.txt) | `dark` |
| `poimandres` | [drcmda/poimandres-theme](https://github.com/drcmda/poimandres-theme/blob/a7b8ed96b2319d44b53f755bdc8f321deb69c729/themes/poimandres-color-theme.json) | | `dark` |
Expand All @@ -46,8 +46,8 @@ import { themes } from 'tm-themes'
| `rose-pine-moon` | [rose-pine/vscode](https://github.com/rose-pine/vscode/blob/5a6d89246d58316802bf5c54bb83d6654ff6a1c5/themes/rose-pine-moon-color-theme.json) | [MIT](https://raw.githubusercontent.com/rose-pine/vscode/main/license) | `dark` |
| `slack-dark` | [slack-theme/visual-studio-code](https://github.com/slack-theme/visual-studio-code/blob/ae207bda0c2477fb609b21377ab0a7a40b1f4b0b/themes/dark-mode.json) | [MIT](https://raw.githubusercontent.com/slack-theme/visual-studio-code/master/License) | `dark` |
| `slack-ochin` | [slack-theme/visual-studio-code](https://github.com/slack-theme/visual-studio-code/blob/ae207bda0c2477fb609b21377ab0a7a40b1f4b0b/themes/ochin.json) | [MIT](https://raw.githubusercontent.com/slack-theme/visual-studio-code/master/License) | `light` |
| `solarized-dark` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-solarized-dark/themes/solarized-dark-color-theme.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `solarized-light` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-solarized-light/themes/solarized-light-color-theme.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `light` |
| `solarized-dark` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-solarized-dark/themes/solarized-dark-color-theme.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `dark` |
| `solarized-light` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-solarized-light/themes/solarized-light-color-theme.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `light` |
| `vitesse-black` | [antfu/vscode-theme-vitesse](https://github.com/antfu/vscode-theme-vitesse/blob/b2a0afe97416cff8526763e7517d21631c456d19/themes/vitesse-black.json) | [MIT](https://raw.githubusercontent.com/antfu/vscode-theme-vitesse/main/LICENSE) | `dark` |
| `vitesse-dark` | [antfu/vscode-theme-vitesse](https://github.com/antfu/vscode-theme-vitesse/blob/b2a0afe97416cff8526763e7517d21631c456d19/themes/vitesse-dark.json) | [MIT](https://raw.githubusercontent.com/antfu/vscode-theme-vitesse/main/LICENSE) | `dark` |
| `vitesse-light` | [antfu/vscode-theme-vitesse](https://github.com/antfu/vscode-theme-vitesse/blob/b2a0afe97416cff8526763e7517d21631c456d19/themes/vitesse-light.json) | [MIT](https://raw.githubusercontent.com/antfu/vscode-theme-vitesse/main/LICENSE) | `light` |
Expand Down
28 changes: 14 additions & 14 deletions packages/tm-themes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ export const themes = [
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'dark-modern',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/dark_modern.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/dark_modern.json',
type: 'dark',
},
{
displayName: 'Dark Plus',
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'dark-plus',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/dark_plus.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/dark_plus.json',
type: 'dark',
},
{
Expand Down Expand Up @@ -67,17 +67,17 @@ export const themes = [
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'light-modern',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/light_modern.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/light_modern.json',
type: 'light',
},
{
displayName: 'Light Plus',
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'light-plus',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-defaults/themes/light_plus.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-defaults/themes/light_plus.json',
type: 'light',
},
{
Expand Down Expand Up @@ -148,8 +148,8 @@ export const themes = [
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'monokai',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-monokai/themes/monokai-color-theme.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-monokai/themes/monokai-color-theme.json',
type: 'dark',
},
{
Expand Down Expand Up @@ -227,17 +227,17 @@ export const themes = [
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'solarized-dark',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-solarized-dark/themes/solarized-dark-color-theme.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-solarized-dark/themes/solarized-dark-color-theme.json',
type: 'dark',
},
{
displayName: 'Solarized Light',
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'solarized-light',
sha: 'c9631868cd2585d82bc5c1f00c235c09da2e37d8',
source: 'https://github.com/microsoft/vscode/blob/c9631868cd2585d82bc5c1f00c235c09da2e37d8/extensions/theme-solarized-light/themes/solarized-light-color-theme.json',
sha: 'fffda8e1feb468b621bf245a0f47c61976bf1fff',
source: 'https://github.com/microsoft/vscode/blob/fffda8e1feb468b621bf245a0f47c61976bf1fff/extensions/theme-solarized-light/themes/solarized-light-color-theme.json',
type: 'light',
},
{
Expand Down
9 changes: 5 additions & 4 deletions scripts/grammars/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ resolvedInfo.sort((a, b) => a.name.localeCompare(b.name))
resolvedInfo.forEach((info) => {
const grammar = scopeToGrammar.get(info.scopeName)!
const includes = Array.from(JSON.stringify(grammar, null, 2).matchAll(/"include": "(.*?)"/g)).map(i => i[1].replace(/#.*$/g, '')).filter(i => i && !i.startsWith('#'))
const embedded = Array.from(new Set([
const embedded = new Set([
...includes.map(i => scopeToGrammar.get(i)?.name).filter(Boolean).filter(i => i !== info.name),
...resolvedInfo.filter(i => i.embeddedIn?.includes(info.name)).map(i => i.name),
]))
if (embedded.length)
info.embedded = embedded as string[]
])
info.embeddedIn?.forEach(i => embedded.delete(i))
if (embedded.size)
info.embedded = Array.from(embedded) as string[]
})

await fs.writeFile(
Expand Down

0 comments on commit f045e8f

Please sign in to comment.