Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
3c90b1e3
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
3c90b1e3
编写于
8月 17, 2020
作者:
A
Asher
提交者:
GitHub
8月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1969 from cdr/qol
qol changes
上级
0dcf4697
d8568eba
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
89 addition
and
125 deletion
+89
-125
.eslintrc.yaml
.eslintrc.yaml
+3
-0
ci/build/build-code-server.sh
ci/build/build-code-server.sh
+5
-2
ci/dev/watch.ts
ci/dev/watch.ts
+6
-1
src/browser/pages/login.html
src/browser/pages/login.html
+1
-6
src/browser/pages/login.ts
src/browser/pages/login.ts
+7
-0
src/browser/pages/vscode.html
src/browser/pages/vscode.html
+1
-48
src/browser/pages/vscode.ts
src/browser/pages/vscode.ts
+53
-0
src/node/cli.ts
src/node/cli.ts
+2
-2
src/node/http.ts
src/node/http.ts
+2
-0
src/node/settings.ts
src/node/settings.ts
+5
-5
src/node/util.ts
src/node/util.ts
+1
-20
test/socket.test.ts
test/socket.test.ts
+1
-1
test/util.test.ts
test/util.test.ts
+0
-36
tsconfig.json
tsconfig.json
+2
-4
未找到文件。
.eslintrc.yaml
浏览文件 @
3c90b1e3
...
...
@@ -23,6 +23,9 @@ rules:
no-dupe-class-members
:
off
"
@typescript-eslint/no-use-before-define"
:
off
"
@typescript-eslint/no-non-null-assertion"
:
off
eqeqeq
:
error
import/order
:
[
error
,
{
alphabetize
:
{
order
:
"
asc"
},
groups
:
[[
"
builtin"
,
"
external"
,
"
internal"
],
"
parent"
,
"
sibling"
]
}]
settings
:
# Does not work with CommonJS unfortunately.
...
...
ci/build/build-code-server.sh
浏览文件 @
3c90b1e3
...
...
@@ -9,7 +9,8 @@ MINIFY=${MINIFY-true}
main
()
{
cd
"
$(
dirname
"
${
0
}
"
)
/../.."
tsc
--outDir
out
--tsBuildInfoFile
.cache/out.tsbuildinfo
tsc
# If out/node/entry.js does not already have the shebang,
# we make sure to add it and make it executable.
if
!
grep
-q
-m1
"^#!/usr/bin/env node"
out/node/entry.js
;
then
...
...
@@ -22,7 +23,9 @@ main() {
--out-dir
dist
\
$(
[[
$MINIFY
]]
||
echo
--no-minify
)
\
src/browser/register.ts
\
src/browser/serviceWorker.ts
src/browser/serviceWorker.ts
\
src/browser/pages/login.ts
\
src/browser/pages/vscode.ts
}
main
"
$@
"
ci/dev/watch.ts
浏览文件 @
3c90b1e3
...
...
@@ -164,7 +164,12 @@ class Watcher {
private
createBundler
(
out
=
"
dist
"
):
Bundler
{
return
new
Bundler
(
[
path
.
join
(
this
.
rootPath
,
"
src/browser/register.ts
"
),
path
.
join
(
this
.
rootPath
,
"
src/browser/serviceWorker.ts
"
)],
[
path
.
join
(
this
.
rootPath
,
"
src/browser/register.ts
"
),
path
.
join
(
this
.
rootPath
,
"
src/browser/serviceWorker.ts
"
),
path
.
join
(
this
.
rootPath
,
"
src/browser/pages/login.ts
"
),
path
.
join
(
this
.
rootPath
,
"
src/browser/pages/vscode.ts
"
),
],
{
outDir
:
path
.
join
(
this
.
rootPath
,
out
),
cacheDir
:
path
.
join
(
this
.
rootPath
,
"
.cache
"
),
...
...
src/browser/pages/login.html
浏览文件 @
3c90b1e3
...
...
@@ -47,10 +47,5 @@
</div>
</body>
<script
data-cfasync=
"false"
src=
"{{CS_STATIC_BASE}}/dist/register.js"
></script>
<script>
const
parts
=
window
.
location
.
pathname
.
replace
(
/^
\/
/g
,
""
).
split
(
"
/
"
)
parts
[
parts
.
length
-
1
]
=
"
{{BASE}}
"
const
url
=
new
URL
(
window
.
location
.
origin
+
"
/
"
+
parts
.
join
(
"
/
"
))
document
.
getElementById
(
"
base
"
).
value
=
url
.
pathname
</script>
<script
data-cfasync=
"false"
src=
"{{CS_STATIC_BASE}}/dist/login.js"
></script>
</html>
src/browser/pages/login.ts
0 → 100644
浏览文件 @
3c90b1e3
import
{
getOptions
}
from
"
../../common/util
"
const
options
=
getOptions
()
const
el
=
document
.
getElementById
(
"
base
"
)
as
HTMLInputElement
if
(
el
)
{
el
.
value
=
options
.
base
}
src/browser/pages/vscode.html
浏览文件 @
3c90b1e3
...
...
@@ -43,47 +43,7 @@
<body
aria-label=
""
></body>
<!-- Startup (do not modify order of script tags!) -->
<script>
let
nlsConfig
try
{
nlsConfig
=
JSON
.
parse
(
document
.
getElementById
(
"
vscode-remote-nls-configuration
"
).
getAttribute
(
"
data-settings
"
))
if
(
nlsConfig
.
_resolvedLanguagePackCoreLocation
)
{
const
bundles
=
Object
.
create
(
null
)
nlsConfig
.
loadBundle
=
(
bundle
,
language
,
cb
)
=>
{
let
result
=
bundles
[
bundle
]
if
(
result
)
{
return
cb
(
undefined
,
result
)
}
// FIXME: Only works if path separators are /.
const
path
=
nlsConfig
.
_resolvedLanguagePackCoreLocation
+
"
/
"
+
bundle
.
replace
(
/
\/
/g
,
"
!
"
)
+
"
.nls.json
"
fetch
(
`{{BASE}}/resource/?path=
${
encodeURIComponent
(
path
)}
`
)
.
then
((
response
)
=>
response
.
json
())
.
then
((
json
)
=>
{
bundles
[
bundle
]
=
json
cb
(
undefined
,
json
)
})
.
catch
(
cb
)
}
}
}
catch
(
error
)
{
/* Probably fine. */
}
self
.
require
=
{
baseUrl
:
"
{{CS_STATIC_BASE}}/lib/vscode/out
"
,
paths
:
{
"
vscode-textmate
"
:
`../node_modules/vscode-textmate/release/main`
,
"
vscode-oniguruma
"
:
`../node_modules/vscode-oniguruma/release/main`
,
xterm
:
`../node_modules/xterm/lib/xterm.js`
,
"
xterm-addon-search
"
:
`../node_modules/xterm-addon-search/lib/xterm-addon-search.js`
,
"
xterm-addon-unicode11
"
:
`../node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`
,
"
xterm-addon-webgl
"
:
`../node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`
,
"
semver-umd
"
:
`../node_modules/semver-umd/lib/semver-umd.js`
,
"
iconv-lite-umd
"
:
`../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`
,
jschardet
:
`../node_modules/jschardet/dist/jschardet.min.js`
,
},
"
vs/nls
"
:
nlsConfig
,
}
</script>
<script
data-cfasync=
"false"
src=
"{{CS_STATIC_BASE}}/dist/pages/vscode.js"
></script>
<script
data-cfasync=
"false"
src=
"{{CS_STATIC_BASE}}/dist/register.js"
></script>
<script
data-cfasync=
"false"
src=
"{{CS_STATIC_BASE}}/lib/vscode/out/vs/loader.js"
></script>
<!-- PROD_ONLY
...
...
@@ -93,11 +53,4 @@
<script>
require
([
"
vs/code/browser/workbench/workbench
"
],
function
()
{})
</script>
<script>
try
{
document
.
body
.
style
.
background
=
JSON
.
parse
(
localStorage
.
getItem
(
"
colorThemeData
"
)).
colorMap
[
"
editor.background
"
]
}
catch
(
error
)
{
// Oh well.
}
</script>
</html>
src/browser/pages/vscode.ts
0 → 100644
浏览文件 @
3c90b1e3
import
{
getOptions
}
from
"
../../common/util
"
const
options
=
getOptions
()
// TODO: Add proper types.
/* eslint-disable @typescript-eslint/no-explicit-any */
let
nlsConfig
:
any
try
{
nlsConfig
=
JSON
.
parse
(
document
.
getElementById
(
"
vscode-remote-nls-configuration
"
)
!
.
getAttribute
(
"
data-settings
"
)
!
)
if
(
nlsConfig
.
_resolvedLanguagePackCoreLocation
)
{
const
bundles
=
Object
.
create
(
null
)
nlsConfig
.
loadBundle
=
(
bundle
:
any
,
_language
:
any
,
cb
:
any
):
void
=>
{
const
result
=
bundles
[
bundle
]
if
(
result
)
{
return
cb
(
undefined
,
result
)
}
// FIXME: Only works if path separators are /.
const
path
=
nlsConfig
.
_resolvedLanguagePackCoreLocation
+
"
/
"
+
bundle
.
replace
(
/
\/
/g
,
"
!
"
)
+
"
.nls.json
"
fetch
(
`{{BASE}}/resource/?path=
${
encodeURIComponent
(
path
)}
`
)
.
then
((
response
)
=>
response
.
json
())
.
then
((
json
)
=>
{
bundles
[
bundle
]
=
json
cb
(
undefined
,
json
)
})
.
catch
(
cb
)
}
}
}
catch
(
error
)
{
/* Probably fine. */
}
;(
self
.
require
as
any
)
=
{
baseUrl
:
`
${
options
.
csStaticBase
}
/lib/vscode/out`
,
paths
:
{
"
vscode-textmate
"
:
`../node_modules/vscode-textmate/release/main`
,
"
vscode-oniguruma
"
:
`../node_modules/vscode-oniguruma/release/main`
,
xterm
:
`../node_modules/xterm/lib/xterm.js`
,
"
xterm-addon-search
"
:
`../node_modules/xterm-addon-search/lib/xterm-addon-search.js`
,
"
xterm-addon-unicode11
"
:
`../node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`
,
"
xterm-addon-webgl
"
:
`../node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`
,
"
semver-umd
"
:
`../node_modules/semver-umd/lib/semver-umd.js`
,
"
iconv-lite-umd
"
:
`../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`
,
jschardet
:
`../node_modules/jschardet/dist/jschardet.min.js`
,
},
"
vs/nls
"
:
nlsConfig
,
}
try
{
document
.
body
.
style
.
background
=
JSON
.
parse
(
localStorage
.
getItem
(
"
colorThemeData
"
)
!
).
colorMap
[
"
editor.background
"
]
}
catch
(
error
)
{
// Oh well.
}
src/node/cli.ts
浏览文件 @
3c90b1e3
...
...
@@ -176,7 +176,7 @@ export const parse = (
const
arg
=
argv
[
i
]
// -- signals the end of option parsing.
if
(
!
ended
&&
arg
==
"
--
"
)
{
if
(
!
ended
&&
arg
==
=
"
--
"
)
{
ended
=
true
continue
}
...
...
@@ -224,7 +224,7 @@ export const parse = (
throw
error
(
`--
${
key
}
requires a value`
)
}
if
(
option
.
type
==
OptionalString
&&
value
==
"
false
"
)
{
if
(
option
.
type
==
=
OptionalString
&&
value
=
==
"
false
"
)
{
continue
}
...
...
src/node/http.ts
浏览文件 @
3c90b1e3
...
...
@@ -868,6 +868,7 @@ export class HttpServer {
// isn't setting the host header to match the access domain.
host
===
"
localhost
"
)
{
logger
.
debug
(
"
no valid cookie doman
"
,
field
(
"
host
"
,
host
))
return
undefined
}
...
...
@@ -877,6 +878,7 @@ export class HttpServer {
}
})
logger
.
debug
(
"
got cookie doman
"
,
field
(
"
host
"
,
host
))
return
host
?
`Domain=
${
host
}
`
:
undefined
}
...
...
src/node/settings.ts
浏览文件 @
3c90b1e3
import
{
logger
}
from
"
@coder/logger
"
import
*
as
fs
from
"
fs-extra
"
import
*
as
path
from
"
path
"
import
{
extend
,
paths
}
from
"
./util
"
import
{
logger
}
from
"
@coder/logger
"
import
{
Route
}
from
"
./http
"
import
{
paths
}
from
"
./util
"
export
type
Settings
=
{
[
key
:
string
]:
Settings
|
string
|
boolean
|
number
}
...
...
@@ -30,12 +30,12 @@ export class SettingsProvider<T> {
/**
* Write settings combined with current settings. On failure log a warning.
* Settings
can be shallow or deep merged
.
* Settings
will be merged shallowly
.
*/
public
async
write
(
settings
:
Partial
<
T
>
,
shallow
=
true
):
Promise
<
void
>
{
public
async
write
(
settings
:
Partial
<
T
>
):
Promise
<
void
>
{
try
{
const
oldSettings
=
await
this
.
read
()
const
nextSettings
=
shallow
?
Object
.
assign
({},
oldSettings
,
settings
)
:
extend
(
oldSettings
,
settings
)
const
nextSettings
=
{
...
oldSettings
,
...
settings
}
await
fs
.
writeFile
(
this
.
settingsPath
,
JSON
.
stringify
(
nextSettings
,
null
,
2
))
}
catch
(
error
)
{
logger
.
warn
(
error
.
message
)
...
...
src/node/util.ts
浏览文件 @
3c90b1e3
import
*
as
cp
from
"
child_process
"
import
*
as
crypto
from
"
crypto
"
import
envPaths
from
"
env-paths
"
import
*
as
fs
from
"
fs-extra
"
import
*
as
os
from
"
os
"
import
*
as
path
from
"
path
"
import
*
as
util
from
"
util
"
import
envPaths
from
"
env-paths
"
import
xdgBasedir
from
"
xdg-basedir
"
export
const
tmpdir
=
path
.
join
(
os
.
tmpdir
(),
"
code-server
"
)
...
...
@@ -199,25 +199,6 @@ export const isObject = <T extends object>(obj: T): obj is T => {
return
!
Array
.
isArray
(
obj
)
&&
typeof
obj
===
"
object
"
&&
obj
!==
null
}
/**
* Extend a with b and return a new object. Properties with objects will be
* recursively merged while all other properties are just overwritten.
*/
export
function
extend
<
A
,
B
>
(
a
:
A
,
b
:
B
):
A
&
B
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export
function
extend
(...
args
:
any
[]):
any
{
const
c
=
{}
as
any
// eslint-disable-line @typescript-eslint/no-explicit-any
for
(
const
obj
of
args
)
{
if
(
!
isObject
(
obj
))
{
continue
}
for
(
const
key
in
obj
)
{
c
[
key
]
=
isObject
(
obj
[
key
])
?
extend
(
c
[
key
],
obj
[
key
])
:
obj
[
key
]
}
}
return
c
}
/**
* Taken from vs/base/common/charCode.ts. Copied for now instead of importing so
* we don't have to set up a `vs` alias to be able to import with types (since
...
...
test/socket.test.ts
浏览文件 @
3c90b1e3
...
...
@@ -6,8 +6,8 @@ import * as net from "net"
import
*
as
path
from
"
path
"
import
*
as
tls
from
"
tls
"
import
{
Emitter
}
from
"
../src/common/emitter
"
import
{
generateCertificate
,
tmpdir
}
from
"
../src/node/util
"
import
{
SocketProxyProvider
}
from
"
../src/node/socket
"
import
{
generateCertificate
,
tmpdir
}
from
"
../src/node/util
"
describe
(
"
SocketProxyProvider
"
,
()
=>
{
const
provider
=
new
SocketProxyProvider
()
...
...
test/util.test.ts
浏览文件 @
3c90b1e3
import
*
as
assert
from
"
assert
"
import
{
normalize
}
from
"
../src/common/util
"
import
{
extend
}
from
"
../src/node/util
"
describe
(
"
util
"
,
()
=>
{
describe
(
"
extend
"
,
()
=>
{
it
(
"
should extend
"
,
()
=>
{
const
a
=
{
foo
:
{
bar
:
0
,
baz
:
2
},
garply
:
4
,
waldo
:
6
}
const
b
=
{
foo
:
{
bar
:
1
,
qux
:
3
},
garply
:
"
5
"
,
fred
:
7
}
const
extended
=
extend
(
a
,
b
)
assert
.
deepEqual
(
extended
,
{
foo
:
{
bar
:
1
,
baz
:
2
,
qux
:
3
},
garply
:
"
5
"
,
waldo
:
6
,
fred
:
7
,
})
})
it
(
"
should make deep copies of the original objects
"
,
()
=>
{
const
a
=
{
foo
:
0
,
bar
:
{
frobnozzle
:
2
},
mumble
:
{
qux
:
{
thud
:
4
}
}
}
const
b
=
{
foo
:
1
,
bar
:
{
chad
:
3
}
}
const
extended
=
extend
(
a
,
b
)
assert
.
notEqual
(
a
.
bar
,
extended
.
bar
)
assert
.
notEqual
(
b
.
bar
,
extended
.
bar
)
assert
.
notEqual
(
a
.
mumble
,
extended
.
mumble
)
assert
.
notEqual
(
a
.
mumble
.
qux
,
extended
.
mumble
.
qux
)
})
it
(
"
should handle mismatch in type
"
,
()
=>
{
const
a
=
{
foo
:
{
bar
:
0
,
baz
:
2
,
qux
:
{
mumble
:
11
}
},
garply
:
4
,
waldo
:
{
thud
:
10
}
}
const
b
=
{
foo
:
{
bar
:
[
1
],
baz
:
{
plugh
:
8
},
qux
:
12
},
garply
:
{
nox
:
9
},
waldo
:
7
}
const
extended
=
extend
(
a
,
b
)
assert
.
deepEqual
(
extended
,
{
foo
:
{
bar
:
[
1
],
baz
:
{
plugh
:
8
},
qux
:
12
},
garply
:
{
nox
:
9
},
waldo
:
7
,
})
})
})
describe
(
"
normalize
"
,
()
=>
{
it
(
"
should remove multiple slashes
"
,
()
=>
{
assert
.
equal
(
normalize
(
"
//foo//bar//baz///mumble
"
),
"
/foo/bar/baz/mumble
"
)
...
...
tsconfig.json
浏览文件 @
3c90b1e3
...
...
@@ -8,17 +8,15 @@
"noUnusedLocals"
:
true
,
"forceConsistentCasingInFileNames"
:
true
,
"outDir"
:
"./out"
,
"allowJs"
:
false
,
"jsx"
:
"react"
,
"declaration"
:
true
,
"experimentalDecorators"
:
true
,
"esModuleInterop"
:
true
,
"allowSyntheticDefaultImports"
:
true
,
"sourceMap"
:
true
,
"tsBuildInfoFile"
:
"./.tsbuildinfo"
,
"tsBuildInfoFile"
:
"./.
cache/
tsbuildinfo"
,
"incremental"
:
true
,
"rootDir"
:
"./src"
,
"typeRoots"
:
[
"./node_modules/@types"
,
"./typings"
]
},
"include"
:
[
"./src/**/*.ts"
,
"./src/**/*.tsx"
]
"include"
:
[
"./src/**/*.ts"
]
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录