Skip to content

Commit

Permalink
Merge branch 'znck:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 authored Nov 2, 2023
2 parents 6b5d9fe + a81aac2 commit 9475e3e
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 45 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,17 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8.1.1
run_install: |
- recursive: true
args: [--frozen-lockfile]
- name: Build
run: pnpm run build
- name: Upload build artefact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build-artefact
retention-days: 30
Expand All @@ -63,11 +62,10 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8.1.1
run_install: |
- recursive: true
args: [--frozen-lockfile]
Expand Down Expand Up @@ -99,11 +97,10 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8.1.1
run_install: |
- recursive: true
args: [--frozen-lockfile]
Expand Down Expand Up @@ -143,11 +140,10 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8.1.1
run_install: |
- recursive: true
args: [--frozen-lockfile]
Expand Down Expand Up @@ -212,11 +208,10 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8.1.1
run_install: |
- recursive: true
args: [--frozen-lockfile]
Expand Down
2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "znck",
"displayName": "Grammarly",
"description": "A grammar checking for Visual Studio Code using Grammarly.",
"version": "0.22.1",
"version": "0.24.0",
"icon": "assets/logo.png",
"preview": true,
"engines": {
Expand Down
1 change: 1 addition & 0 deletions extension/src/StatusBarController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class StatusBarController {
commands.registerCommand('grammarly.pauseCheck', async (uri?: Uri) => {
const id = uri ?? window.activeTextEditor?.document.uri
if (id == null) return

await this.grammarly.client.protocol.pause(id.toString())
await this.update()
}),
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"packageManager": "pnpm@8.10.2",
"engines": {
"node": "^16.20.0",
"pnpm": "^8.1.1"
"node": "^18.18.2"
},
"scripts": {
"build": "rollup -c && node scripts/build-web-extension.mjs",
Expand Down Expand Up @@ -32,8 +32,8 @@
"rollup": "^2.71.1",
"rollup-plugin-copy": "^3.4.0",
"semver": "^7.3.7",
"tree-sitter-cli": "^0.20.6",
"tree-sitter-html": "^0.19.0",
"tree-sitter-cli": "^0.20.8",
"tree-sitter-html": "^0.20.0",
"tree-sitter-markdown": "^0.7.1",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
Expand Down
1 change: 1 addition & 0 deletions packages/grammarly-languageclient/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function createProtocol(client: BaseLanguageClient): Protocol {
} else {
return async (...args: unknown[]): Promise<unknown> => {
try {
await client.onReady()
const result = await client.sendRequest(`$/${property}`, args)
return result
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/grammarly-languageserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"reflect-metadata": "^0.1.13",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.4",
"web-tree-sitter": "0.20.5"
"web-tree-sitter": "^0.20.8"
},
"devDependencies": {
"domhandler": "^5.0.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/grammarly-richtext-encoder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dist"
],
"dependencies": {
"web-tree-sitter": "0.20.5"
"web-tree-sitter": "^0.20.8"
},
"devDependencies": {
"@grammarly/sdk": "^2.3.17",
Expand Down
40 changes: 31 additions & 9 deletions packages/grammarly-richtext-encoder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,36 @@ export async function createParser(language: string): Promise<Parser> {
return await parser

async function createParserInner() {
await Parser.init()

const parser = new Parser()
parser.setLanguage(await Parser.Language.load(getLanguageFile()))
parsers.set(language, parser)
parsersPending.delete(language)
if (isNodeJS()) {
const fetch = globalThis.fetch
try {
// @ts-ignore
globalThis.fetch = null
await Parser.init()
} catch (e) {
console.log('Error in TreeSitter parser:', e)
throw e
} finally {
globalThis.fetch = fetch
}
} else {
await Parser.init()
}

return parser
try {
const parser = new Parser()
parser.setLanguage(await Parser.Language.load(getLanguageFile()))
parsers.set(language, parser)
parsersPending.delete(language)
return parser
} catch (e) {
console.log(`Error in TreeSitter ${language} parser:`, e)
throw e
}
}

function getLanguageFile(): string | Uint8Array {
// @ts-ignore - Ignore if process does not exist.
if (typeof process !== 'undefined' && process.versions?.node != null) {
if (isNodeJS()) {
// @ts-ignore
if (process.env.NODE_ENV === 'test') {
// @ts-ignore
Expand All @@ -42,4 +59,9 @@ export async function createParser(language: string): Promise<Parser> {
}
}

function isNodeJS(): boolean {
// @ts-ignore - Ignore if process does not exist.
return typeof process !== 'undefined' && process.versions?.node != null
}

export const transformers = { html, markdown } as const
File renamed without changes.
File renamed without changes.
38 changes: 23 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function wasm(file) {
return copy({
targets: [
{
src: Path.resolve(__dirname, 'tree-sitter/tree-sitter-{html,markdown}.wasm'),
src: Path.resolve(__dirname, 'parsers/tree-sitter-{html,markdown}.wasm'),
dest: Path.dirname(file),
},
],
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-wasm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ for (const language in packageNameByLanguage) {
execSync(`$(pnpm bin)/tree-sitter build-wasm ${resolve(rootDir, `node_modules/${packageName}`)}`, {
stdio: 'inherit',
})
execSync(`mv ${packageName}.wasm tree-sitter/tree-sitter-${language}.wasm`, { stdio: 'inherit' })
execSync(`mv ${packageName}.wasm parsers/tree-sitter-${language}.wasm`, { stdio: 'inherit' })
}
2 changes: 1 addition & 1 deletion scripts/publish-extension.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ const VSCODE_MARKETPLACE_TOKEN = process.env.VSCODE_MARKETPLACE_TOKEN
const OVSX_REGISTRY_TOKEN = process.env.OVSX_REGISTRY_TOKEN
const args = RELEASE_CHANNEL === 'pre-release' ? '--pre-release' : ''
execSync(`${bin} publish -p "${VSCODE_MARKETPLACE_TOKEN}" ${args} --packagePath grammarly.vsix`, execArgs)
execSync(`pnpx -y ovsx publish -p "${OVSX_REGISTRY_TOKEN}" --packagePath grammarly.vsix`, execArgs) // Does not support pre-release arg yet.
execSync(`pnpx ovsx publish -p "${OVSX_REGISTRY_TOKEN}" --packagePath grammarly.vsix`, execArgs) // Does not support pre-release arg yet.

0 comments on commit 9475e3e

Please sign in to comment.