Skip to content

Commit f45e1a4

Browse files
committed
v0.9.7: the real 0.9.6
1 parent d43bfec commit f45e1a4

File tree

15 files changed

+84
-68
lines changed

15 files changed

+84
-68
lines changed

.github/workflows/server.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ jobs:
4848
path: ${{ matrix.platforms.dir }}
4949
- name: Run tests
5050
run: cargo test --target ${{ matrix.platforms.target }}
51+
if: ${{ matrix.platforms.target != 'aarch64-apple-darwin' }}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to the "vscode-mc-shader" extension will be documented in th
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66

7+
## [0.9.7]
8+
9+
### Fixed
10+
11+
- Fixed bad release tag format
12+
- Fixed extension silently failing on activation
13+
714
## [0.9.6]
815

916
### Added

client/src/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function virtualMergedDocument(e: Extension): Command {
5656
+ vscode.window.activeTextEditor.document.uri.path
5757
.slice(vscode.window.activeTextEditor.document.uri.path.lastIndexOf('.') + 1)
5858
const path = vscode.Uri.parse(`mcglsl:${uri}`)
59-
59+
6060
const doc = await vscode.workspace.openTextDocument(path)
6161
docProvider.onDidChangeEmitter.fire(path)
6262
await vscode.window.showTextDocument(doc, {
@@ -83,7 +83,7 @@ export function parseTree(e: Extension): Command {
8383
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>()
8484
onDidChange = this.onDidChangeEmitter.event
8585

86-
provideTextDocumentContent(uri: vscode.Uri, __: vscode.CancellationToken): vscode.ProviderResult<string> {
86+
provideTextDocumentContent(uri: vscode.Uri, _: vscode.CancellationToken): vscode.ProviderResult<string> {
8787
if (uri.path.includes('.flattened.')) return ''
8888
return getVirtualDocument(uri.path.substring(0, uri.path.lastIndexOf('.')))
8989
}
@@ -96,7 +96,7 @@ export function parseTree(e: Extension): Command {
9696

9797
const uri = vscode.window.activeTextEditor.document.uri
9898
const path = vscode.Uri.parse(`mcglsl:${uri.path}.ast`)
99-
99+
100100
const doc = await vscode.workspace.openTextDocument(path)
101101
docProvider.onDidChangeEmitter.fire(path)
102102
await vscode.window.showTextDocument(doc, {

client/src/extension.ts

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { log } from './log'
66
import { LanguageClient } from './lspClient'
77
import { download, getReleaseInfo } from './net'
88
import { PersistentState } from './persistent_state'
9-
import * as path from 'path'
9+
import * as path from 'path'
1010

1111
const platforms: { [key: string]: string } = {
1212
'x64 win32': 'x86_64-windows-msvc',
@@ -26,21 +26,21 @@ export class Extension {
2626
readonly package: {
2727
version: string
2828
} = vscode.extensions.getExtension(this.extensionID)!.packageJSON;
29-
29+
3030
public get context(): vscode.ExtensionContext {
3131
return this.extensionContext
3232
}
3333

3434
public get lspClient(): lsp.LanguageClient {
3535
return this.client
3636
}
37-
37+
3838
public activate = async (context: vscode.ExtensionContext) => {
3939
this.extensionContext = context
4040
this.state = new PersistentState(context.globalState)
4141

42-
if(!process.env['MCSHADER_DEBUG'] && !(vscode.workspace.getConfiguration('mcglsl').get('skipBootstrap') as boolean)) {
43-
await this.bootstrap()
42+
if (!process.env['MCSHADER_DEBUG'] && !(vscode.workspace.getConfiguration('mcglsl').get('skipBootstrap') as boolean)) {
43+
await this.bootstrap()
4444
} else {
4545
log.info('skipping language server bootstrap')
4646
}
@@ -52,31 +52,31 @@ export class Extension {
5252

5353
log.info('starting language server...')
5454

55-
const lspBinary = process.env['MCSHADER_DEBUG'] ?
56-
this.context.asAbsolutePath(path.join('server', 'target', 'debug', 'mcshader-lsp')) +
57-
(process.platform === 'win32' ? '.exe' : '') :
58-
path.join(this.context.globalStorageUri.fsPath, 'mcshader-lsp')
55+
const lspBinary = process.env['MCSHADER_DEBUG'] ?
56+
this.context.asAbsolutePath(path.join('server', 'target', 'debug', 'mcshader-lsp')) +
57+
(process.platform === 'win32' ? '.exe' : '') :
58+
path.join(this.context.globalStorageUri.fsPath, 'mcshader-lsp')
5959

6060
const filewatcherGlob = this.fileAssociationsToGlob(this.getGLSLFileAssociations())
61-
61+
6262
this.client = await new LanguageClient(this, lspBinary, filewatcherGlob).startServer()
63-
63+
6464
log.info('language server started!')
6565
}
6666

6767
fileAssociationsToGlob = (associations: string[]): string => {
6868
return '**/*.{'.concat(
6969
associations.map(s => s.substring(s.indexOf('.'))).join(',')
70-
) + '}'
70+
) + '}'
7171
}
7272

7373
getGLSLFileAssociations = (): string[] => {
7474
const exts = ['.fsh', '.vsh', '.gsh', '.glsl']
75-
const associations = vscode.workspace.getConfiguration('files').get('associations') as {[key: string]: string}
76-
75+
const associations = vscode.workspace.getConfiguration('files').get('associations') as { [key: string]: string }
76+
7777
Object.keys(associations).forEach((key) => {
78-
if(associations[key] === 'glsl') {
79-
exts.push(key.substring(key.indexOf('*')+1))
78+
if (associations[key] === 'glsl') {
79+
exts.push(key.substring(key.indexOf('*') + 1))
8080
}
8181
})
8282

@@ -85,31 +85,31 @@ export class Extension {
8585

8686
registerCommand = (name: string, f: (e: Extension) => commands.Command) => {
8787
const cmd = f(this)
88-
this.context.subscriptions.push(vscode.commands.registerCommand('mcglsl.'+name, cmd))
88+
this.context.subscriptions.push(vscode.commands.registerCommand('mcglsl.' + name, cmd))
8989
}
9090

91-
deactivate = async () => {
91+
deactivate = async () => {
9292
await this.lspClient.stop()
93-
while(this.context.subscriptions.length > 0) {
93+
while (this.context.subscriptions.length > 0) {
9494
this.context.subscriptions.pop()?.dispose()
9595
}
9696
}
97-
97+
9898
public updateStatus = (icon: string, text: string) => {
9999
this.statusBarItem?.dispose()
100100
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left)
101101
this.statusBarItem.text = icon + ' [mc-shader] ' + text
102102
this.statusBarItem.show()
103103
this.context.subscriptions.push(this.statusBarItem)
104104
}
105-
105+
106106
public clearStatus = () => {
107107
this.statusBarItem?.dispose()
108108
}
109109

110110
private bootstrap = async () => {
111111
mkdirSync(this.extensionContext.globalStoragePath, { recursive: true })
112-
112+
113113
const dest = path.join(this.extensionContext.globalStoragePath, 'mcshader-lsp' + (process.platform === 'win32' ? '.exe' : ''))
114114
const exists = await fs.stat(dest).then(() => true, () => false)
115115
if (!exists) await this.state.updateServerVersion(undefined)
@@ -123,7 +123,7 @@ export class Extension {
123123
log.warn(`incompatible architecture/platform:\n\t${process.arch} ${process.platform}`)
124124
return
125125
}
126-
126+
127127
if (release.tag_name === this.state.serverVersion) {
128128
log.info('server version is same as extension:\n\t', this.state.serverVersion)
129129
return
@@ -135,8 +135,8 @@ export class Extension {
135135

136136
const userResponse = await vscode.window.showInformationMessage(
137137
this.state.serverVersion == undefined ?
138-
`Language server version ${this.package.version} is not installed.` :
139-
`An update is available. Upgrade from ${this.state.serverVersion} to ${release.tag_name}?`,
138+
`Language server version ${this.package.version} is not installed.` :
139+
`An update is available. Upgrade from ${this.state.serverVersion} to ${release.tag_name}?`,
140140
'Download now'
141141
)
142142
if (userResponse !== 'Download now') {
@@ -145,9 +145,16 @@ export class Extension {
145145
}
146146

147147
await download(artifact.browser_download_url, dest)
148-
148+
149149
this.state.updateServerVersion(release.tag_name)
150150
}
151151
}
152152

153-
export const activate = new Extension().activate
153+
export const activate = async (context: vscode.ExtensionContext) => {
154+
try {
155+
new Extension().activate(context)
156+
} catch (e) {
157+
log.error(`failed to activate extension: ${e}`)
158+
throw(e)
159+
}
160+
}

client/src/log.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@ export const log = new class {
99

1010
// Hint: the type [T, ...T[]] means a non-empty array
1111
debug(...msg: [unknown, ...unknown[]]): void {
12-
log.write('DEBUG', ...msg)
12+
log.write('DEBUG', ...msg)
1313
}
1414

1515
info(...msg: [unknown, ...unknown[]]): void {
16-
log.write('INFO ', ...msg)
16+
log.write('INFO ', ...msg)
1717
}
1818

1919
warn(...msg: [unknown, ...unknown[]]): void {
20-
log.write('WARN ', ...msg)
20+
log.write('WARN ', ...msg)
2121
}
2222

2323
error(...msg: [unknown, ...unknown[]]): void {
24-
log.write('ERROR', ...msg)
24+
log.write('ERROR', ...msg)
2525
}
2626

2727
write(label: string, ...messageParts: unknown[]): void {
28-
const message = messageParts.map(log.stringify).join(' ')
29-
const dateTime = new Date().toLocaleString()
30-
log.output.appendLine(`${label} [${dateTime}]: ${message}`)
28+
const message = messageParts.map(log.stringify).join(' ')
29+
const dateTime = new Date().toLocaleString()
30+
log.output.appendLine(`${label} [${dateTime}]: ${message}`)
3131
}
3232

3333
private stringify(val: unknown): string {
34-
if (typeof val === 'string') return val
34+
if (typeof val === 'string') return val
3535
return inspect(val, {
36-
colors: false,
37-
depth: 6, // heuristic
38-
})
36+
colors: false,
37+
depth: 6, // heuristic
38+
})
3939
}
4040
}
4141

client/src/lspClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class LanguageClient extends lsp.LanguageClient {
1111
super('vscode-mc-shader', 'VSCode MC Shader', {
1212
command: lspBinary
1313
}, {
14-
documentSelector: [{scheme: 'file', language: 'glsl'}],
14+
documentSelector: [{ scheme: 'file', language: 'glsl' }],
1515
outputChannel: lspOutputChannel,
1616
synchronize: {
1717
configurationSection: 'mcglsl',
@@ -28,10 +28,10 @@ export class LanguageClient extends lsp.LanguageClient {
2828
this.extension.context.subscriptions.push(this.start())
2929

3030
await this.onReady()
31-
31+
3232
this.onNotification(updateConfigMethod, this.onUpdateConfig)
3333
this.onNotification(statusMethod, this.onStatusChange)
34-
34+
3535
return this
3636
}
3737

client/src/lspExt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export const status = new lsp.NotificationType<StatusParams>(statusMethod)
1212
export const updateConfigMethod = 'mc-glsl/updateConfig'
1313

1414
export type ConfigUpdateParams = {
15-
kv: {key: string, value: string}[]
15+
kv: { key: string, value: string }[]
1616
}

client/src/net.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ interface GithubRelease {
1616
}
1717

1818
export async function getReleaseInfo(releaseTag: string): Promise<GithubRelease> {
19+
log.info('fetching release info for tag', releaseTag)
1920
const response = await fetch(`https://api.github.com/repos/strum355/mcshader-lsp/releases/tags/${releaseTag}`, {
20-
headers: {Accept: 'application/vnd.github.v3+json'}
21+
headers: { Accept: 'application/vnd.github.v3+json' }
2122
})
2223

2324
const isRelease = (obj: unknown): obj is GithubRelease => {
24-
return obj != null && typeof obj === 'object'
25+
return obj != null && typeof obj === 'object'
2526
&& typeof (obj as GithubRelease).tag_name === 'string'
2627
&& Array.isArray((obj as GithubRelease).assets)
2728
&& (obj as GithubRelease).assets.every((a) => typeof a.name === 'string' && typeof a.browser_download_url === 'string')
2829
}
2930

3031
const json = await response.json()
31-
if(!isRelease(json)) {
32-
throw new TypeError('Received malformed request from Github Release API ' + JSON.stringify(json))
32+
if (!isRelease(json)) {
33+
throw new TypeError(`Received malformed request from Github Release API ${JSON.stringify(json)}`)
3334
}
3435
return json
3536
}
@@ -50,14 +51,14 @@ export async function download(url: string, downloadDest: string) {
5051
message: `${newPercentage.toFixed(0)}%`,
5152
increment: newPercentage - lastPercentage
5253
})
53-
54+
5455
lastPercentage = newPercentage
5556
}
5657
})
5758
}
5859
)
5960
}
60-
61+
6162
async function downloadFile(
6263
url: string,
6364
destFilePath: fs.PathLike,
@@ -69,29 +70,29 @@ async function downloadFile(
6970
log.error({ body: await res.text(), headers: res.headers })
7071
throw new Error(`Got response ${res.status} when trying to download ${url}.`)
7172
}
72-
73+
7374
const totalBytes = Number(res.headers.get('content-length'))
74-
75+
7576
log.debug('downloading file with', totalBytes, 'bytes size from', url, 'to', destFilePath)
76-
77+
7778
let readBytes = 0
7879
res.body.on('data', (chunk: Buffer) => {
7980
readBytes += chunk.length
8081
onProgress(readBytes, totalBytes)
8182
})
82-
83+
8384
const destFileStream = fs.createWriteStream(destFilePath, { mode: 0o755 })
84-
85+
8586
await pipeline(res.body, destFileStream)
86-
87+
8788
// Don't apply the workaround in fixed versions of nodejs, since the process
8889
// freezes on them, the process waits for no-longer emitted `close` event.
8990
// The fix was applied in commit 7eed9d6bcc in v13.11.0
9091
// See the nodejs changelog:
9192
// https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V13.md
9293
const [, major, minor] = /v(\d+)\.(\d+)\.(\d+)/.exec(process.version)!
9394
if (+major > 13 || (+major === 13 && +minor >= 11)) return
94-
95+
9596
await new Promise<void>(resolve => {
9697
destFileStream.on('close', resolve)
9798
destFileStream.destroy()

client/src/persistent_state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export class PersistentState {
1212
}
1313

1414
async updateServerVersion(value: string | undefined) {
15-
await this.state.update('serverVersion', value)
15+
await this.state.update('serverVersion', value)
1616
}
1717
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)