Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit830c01a

Browse files
committed
refactor out logs
1 parent58c7745 commit830c01a

File tree

5 files changed

+60
-61
lines changed

5 files changed

+60
-61
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,35 @@ class ReactWebView {
2323

2424
// Listen for when the panel is disposed
2525
// This happens when the user closes the panel or when the panel is closed programatically
26-
this.panel.onDidDispose(()=>this.dispose(),null,this.disposables)
26+
//this.panel.onDidDispose(() => this.dispose(), null, this.disposables)
2727

2828
// Handle messages from the webview
2929
constonReceive=(action:string|CR.Action)=>vscode.commands.executeCommand('coderoad.receive_action',action)
3030
this.panel.webview.onDidReceiveMessage(onReceive,null,this.disposables)
3131

3232
// update panel on changes
3333
constupdateWindows=()=>{
34+
3435
vscode.commands.executeCommand('vscode.setEditorLayout',{orientation:0,groups:[{groups:[{}],size:0.6},{groups:[{}],size:0.4}]})
3536
this.panel.reveal(vscode.ViewColumn.Two)
3637
}
38+
39+
this.panel.onDidDispose(()=>{
40+
updateWindows()
41+
})
42+
43+
// this.panel.onDidChangeViewState(() => {
44+
// console.log('onDidChangeViewState')
45+
// updateWindows()
46+
// })
47+
3748
// prevents new panels from going ontop of coderoad panel
3849
vscode.window.onDidChangeActiveTextEditor((param)=>{
3950
if(!param||param.viewColumn!==vscode.ViewColumn.Two){
4051
updateWindows()
4152
}
4253
})
43-
// prevents moving coderoad panel on top of left panel
54+
////prevents moving coderoad panel on top of left panel
4455
vscode.window.onDidChangeVisibleTextEditors((param)=>{
4556
updateWindows()
4657
})
@@ -52,10 +63,8 @@ class ReactWebView {
5263
// If we already have a panel, show it.
5364
// Otherwise, create a new panel.
5465
if(this.panel&&this.panel.webview){
55-
console.log('reveal')
5666
this.panel.reveal(column)
5767
}else{
58-
console.log('make new panel')
5968
this.panel=this.createWebviewPanel(column)
6069
}
6170
}
@@ -84,15 +93,12 @@ class ReactWebView {
8493
}
8594

8695
publicasyncpostMessage(action:CR.Action):Promise<void>{
87-
console.log('webview postMessage')
88-
console.log(action)
8996
// Send a message to the webview webview.
9097
// You can send any JSON serializable data.
9198
constsuccess=awaitthis.panel.webview.postMessage(action)
9299
if(!success){
93100
thrownewError(`Message post failure:${JSON.stringify(action)}`)
94101
}
95-
console.log('postMessage sent')
96102
}
97103

98104
publicdispose():void{
@@ -125,31 +131,29 @@ class ReactWebView {
125131
conststyleUri=stylePathOnDisk.with({scheme:'vscode-resource'})
126132

127133
// Use a nonce to whitelist which scripts can be run
128-
constnonce=this.getNonce()
129-
constnonce2=this.getNonce()
130-
constnonce3=this.getNonce()
134+
const[n1,n2,n3]=[1,2,3].map(this.getNonce)
131135

132136
return`<!DOCTYPE html>
133137
<html lang="en">
134-
<head>
135-
<meta charset="utf-8">
136-
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
137-
<meta name="theme-color" content="#000000">
138-
<title>React App</title>
139-
<link rel="manifest" href="./manifest.json" />
140-
<link rel="stylesheet" type="text/css" href="${styleUri}">
141-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'nonce-${nonce}' 'nonce-${nonce2}' 'nonce-${nonce3}'; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
142-
<base href="${vscode.Uri.file(path.join(this.extensionPath,'build')).with({scheme:'vscode-resource'})}/">
143-
<style></style>
144-
</head>
145-
146-
<body>
147-
<noscript>You need to enable JavaScript to run this app.</noscript>
148-
<div>Loading...</div>
149-
<script nonce=${nonce} src="./webpackBuild.js"></script>
150-
<script nonce=${nonce2} src="${chunkUri}"></script>
151-
<script nonce="${nonce3}" src="${scriptUri}"></script>
152-
</body>
138+
<head>
139+
<meta charset="utf-8">
140+
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
141+
<meta name="theme-color" content="#000000">
142+
<title>React App</title>
143+
<link rel="manifest" href="./manifest.json" />
144+
<link rel="stylesheet" type="text/css" href="${styleUri}">
145+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'nonce-${n1}' 'nonce-${n2}' 'nonce-${n3}'; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
146+
<base href="${vscode.Uri.file(path.join(this.extensionPath,'build')).with({scheme:'vscode-resource'})}/">
147+
<style></style>
148+
</head>
149+
150+
<body>
151+
<noscript>You need to enable JavaScript to run this app.</noscript>
152+
<div>Loading...</div>
153+
<script nonce=${n1} src="./webpackBuild.js"></script>
154+
<script nonce=${n2} src="${chunkUri}"></script>
155+
<script nonce="${n3}" src="${scriptUri}"></script>
156+
</body>
153157
</html>`
154158
}
155159
}

‎src/editor/workspace.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ export async function isEmptyWorkspace(): Promise<boolean> {
1212
}
1313

1414
// // TODO: workspace change listener
15-
//export async function openReadme(): Promise<void> {
16-
// const { stderr } = await exec('ls')
17-
// if (stderr) {
18-
// throw new Error('Error looking for initial file')
19-
// }
15+
exportasyncfunctionopenReadme():Promise<void>{
16+
const{ stderr}=awaitexec('ls')
17+
if(stderr){
18+
thrownewError('Error looking for initial file')
19+
}
2020

21-
// const file = 'README.md'
22-
// const filePath = path.join(vscode.workspace.rootPath || '', file)
23-
// console.log('filePath', filePath)
24-
// const hasReadme = await exists(file)
21+
constfile='README.md'
22+
constfilePath=path.join(vscode.workspace.rootPath||'',file)
23+
console.log('filePath',filePath)
24+
consthasReadme=awaitexists(file)
2525

26-
// if (!hasReadme) {
27-
// // add readme if none exists
28-
// try {
29-
// const content = '# Welcome to CodeRoad!'
30-
// fs.writeFileSync(filePath, content, 'utf8')
31-
// } catch (error) {
32-
// throw new Error('Error writing READM.md')
33-
// }
34-
// }
26+
if(!hasReadme){
27+
// add readme if none exists
28+
try{
29+
constcontent='# Welcome to CodeRoad!'
30+
fs.writeFileSync(filePath,content,'utf8')
31+
}catch(error){
32+
thrownewError('Error writing READM.md')
33+
}
34+
}
3535

36-
// try {
37-
// const openPath = vscode.Uri.parse(filePath)
38-
// const doc = await vscode.workspace.openTextDocument(openPath)
39-
// await vscode.window.showTextDocument(doc)
40-
// } catch (error) {
41-
// throw new Error('Error opening README doc')
42-
// }
43-
//}
36+
try{
37+
constopenPath=vscode.Uri.parse(filePath)
38+
constdoc=awaitvscode.workspace.openTextDocument(openPath)
39+
awaitvscode.window.showTextDocument(doc)
40+
}catch(error){
41+
thrownewError('Error opening README doc')
42+
}
43+
}

‎src/services/api/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const tutorialsData: { [key: string]: CR.Tutorial } = {
1414

1515
// TODO: replace with fetch resource
1616
exportdefaultasyncfunctionfetch(options:Options):Promise<any>{
17-
console.log('options',options)
1817
switch(options.resource){
1918
case'getTutorialsSummary':
2019
// list of ids with summaries

‎src/services/git/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ const gitOrigin = 'coderoad'
1111
exportasyncfunctiongitLoadCommits(actions:CR.TutorialAction,dispatch:CR.EditorDispatch):Promise<void>{
1212
const{ commits, commands, files}=actions
1313

14-
console.log('commits to load',commits)
15-
1614
for(constcommitofcommits){
1715
const{ stdout, stderr}=awaitexec(`git cherry-pick${commit}`)
1816
if(stderr){
1917
console.error(stderr)
2018
thrownewError('Error loading commit')
2119
}
22-
console.log('add commit',stdout)
2320
}
2421

2522
if(commands){

‎src/state/actions/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ let currentProgress: CR.Progress = {
1616

1717
exportdefault(dispatch:CR.EditorDispatch)=>({
1818
createWebview(){
19-
console.log('execute coderoad.open_webview')
2019
dispatch('coderoad.open_webview')
2120
},
2221
asyncnewOrContinue(){
@@ -152,7 +151,7 @@ export default (dispatch: CR.EditorDispatch) => ({
152151
...context.position,
153152
stepId:nextStepId,
154153
}
155-
console.log('position update',nextPosition)
154+
156155
returnnextPosition
157156
}
158157
}),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp