@lvce-editor/server 0.122.10 → 0.122.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +2 -2
- package/package.json +3 -3
- package/src/argvConfig.js +60 -0
- package/src/server.js +1 -1
- package/test/argvConfig.test.js +30 -0
package/ThirdPartyNotices.txt
CHANGED
|
@@ -2,7 +2,7 @@ This project incorporates components from the projects listed below, that may ha
|
|
|
2
2
|
differing from this project:
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
1) License Notice for static/
|
|
5
|
+
1) License Notice for static/05db451/icons (from https://github.com/microsoft/vscode-codicons)
|
|
6
6
|
---------------------------------------
|
|
7
7
|
|
|
8
8
|
Attribution 4.0 International
|
|
@@ -402,7 +402,7 @@ public licenses.
|
|
|
402
402
|
Creative Commons may be contacted at creativecommons.org.
|
|
403
403
|
|
|
404
404
|
|
|
405
|
-
2) License Notice for static/
|
|
405
|
+
2) License Notice for static/05db451/fonts/FiraCode-VariableFont.ttf (from https://github.com/tonsky/FiraCode)
|
|
406
406
|
---------------------------------------
|
|
407
407
|
|
|
408
408
|
Copyright (c) 2014, The Fira Code Project Authors (https://github.com/tonsky/FiraCode)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/server",
|
|
3
|
-
"version": "0.122.
|
|
3
|
+
"version": "0.122.12",
|
|
4
4
|
"description": "Run LVCE Editor as a server.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": "bin/server.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@lvce-editor/jsonc-parser": "^1.5.2",
|
|
24
|
-
"@lvce-editor/shared-process": "0.122.
|
|
25
|
-
"@lvce-editor/static-server": "0.122.
|
|
24
|
+
"@lvce-editor/shared-process": "0.122.12",
|
|
25
|
+
"@lvce-editor/static-server": "0.122.12"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/argvConfig.js
CHANGED
|
@@ -6,6 +6,8 @@ import { join } from 'node:path'
|
|
|
6
6
|
const applicationName = 'lvce-oss'
|
|
7
7
|
const keyPattern = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/
|
|
8
8
|
const optionsWithSeparateValues = new Set(['--connection-token', '--idle-timeout', '--link', '--only-extension', '--port', '--test-path'])
|
|
9
|
+
const reclaimerFeatureName = 'PartitionAllocMemoryReclaimer'
|
|
10
|
+
const reclaimerFeature = `${reclaimerFeatureName}:interval/1800s`
|
|
9
11
|
|
|
10
12
|
const getArgument = (key, value) => {
|
|
11
13
|
return `--${key}=${value}`
|
|
@@ -63,6 +65,64 @@ export const prepend = (argv, argumentsToPrepend) => {
|
|
|
63
65
|
argv.splice(2, 0, ...argumentsToPrepend)
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
const getFeatureName = (feature) => feature.split(/[:<]/, 1)[0].trim()
|
|
69
|
+
|
|
70
|
+
export const addDefaultMemoryReclaimerFeature = (args) => {
|
|
71
|
+
const enabledFeatures = []
|
|
72
|
+
const disabledFeatures = []
|
|
73
|
+
const keptArgs = []
|
|
74
|
+
for (let index = 0; index < args.length; index++) {
|
|
75
|
+
const arg = args[index]
|
|
76
|
+
if (arg === '--enable-features' || arg === '--disable-features') {
|
|
77
|
+
const target = arg === '--enable-features' ? enabledFeatures : disabledFeatures
|
|
78
|
+
target.push(
|
|
79
|
+
...(args[index + 1] || '')
|
|
80
|
+
.split(',')
|
|
81
|
+
.map((feature) => feature.trim())
|
|
82
|
+
.filter(Boolean),
|
|
83
|
+
)
|
|
84
|
+
index++
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
87
|
+
if (arg.startsWith('--enable-features=')) {
|
|
88
|
+
enabledFeatures.push(
|
|
89
|
+
...arg
|
|
90
|
+
.slice('--enable-features='.length)
|
|
91
|
+
.split(',')
|
|
92
|
+
.map((feature) => feature.trim())
|
|
93
|
+
.filter(Boolean),
|
|
94
|
+
)
|
|
95
|
+
continue
|
|
96
|
+
}
|
|
97
|
+
if (arg.startsWith('--disable-features=')) {
|
|
98
|
+
disabledFeatures.push(
|
|
99
|
+
...arg
|
|
100
|
+
.slice('--disable-features='.length)
|
|
101
|
+
.split(',')
|
|
102
|
+
.map((feature) => feature.trim())
|
|
103
|
+
.filter(Boolean),
|
|
104
|
+
)
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
keptArgs.push(arg)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (disabledFeatures.some((feature) => getFeatureName(feature) === reclaimerFeatureName)) {
|
|
111
|
+
return args
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const reclaimerIndices = enabledFeatures.flatMap((feature, index) => (getFeatureName(feature) === reclaimerFeatureName ? [index] : []))
|
|
115
|
+
const explicitReclaimerIndex = reclaimerIndices.findLast((index) => enabledFeatures[index].includes(':'))
|
|
116
|
+
const featureIndex = reclaimerIndices[0] ?? enabledFeatures.length
|
|
117
|
+
const selectedReclaimerFeature = explicitReclaimerIndex === undefined ? reclaimerFeature : enabledFeatures[explicitReclaimerIndex]
|
|
118
|
+
const mergedFeatures = enabledFeatures.filter((feature) => getFeatureName(feature) !== reclaimerFeatureName)
|
|
119
|
+
mergedFeatures.splice(featureIndex, 0, selectedReclaimerFeature)
|
|
120
|
+
|
|
121
|
+
const featureArguments = [`--enable-features=${mergedFeatures.join(',')}`]
|
|
122
|
+
keptArgs.unshift(...featureArguments)
|
|
123
|
+
return keptArgs
|
|
124
|
+
}
|
|
125
|
+
|
|
66
126
|
export const getWorkspaceArgument = (args) => {
|
|
67
127
|
for (let index = 0; index < args.length; index++) {
|
|
68
128
|
const argument = args[index]
|
package/src/server.js
CHANGED
|
@@ -80,7 +80,7 @@ const isStatic = (url) => {
|
|
|
80
80
|
if (url === '/index.html' || url.startsWith('/index.html?')) {
|
|
81
81
|
return !hasLinkedExtensions
|
|
82
82
|
}
|
|
83
|
-
if (url.startsWith('/
|
|
83
|
+
if (url.startsWith('/05db451')) {
|
|
84
84
|
return true
|
|
85
85
|
}
|
|
86
86
|
if (url.startsWith('/favicon.ico')) {
|
package/test/argvConfig.test.js
CHANGED
|
@@ -24,6 +24,36 @@ test('prepends config arguments before explicit command line arguments', () => {
|
|
|
24
24
|
assert.deepEqual(argv, ['/usr/bin/node', '/usr/lib/lvce/server.js', '--link=/test/extension', '--theme=configured', '--theme=explicit'])
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
+
test('adds the default native memory reclaimer feature without losing enabled features', () => {
|
|
28
|
+
assert.deepEqual(ArgvConfig.addDefaultMemoryReclaimerFeature(['--enable-features=ExampleFeature', '/workspace']), [
|
|
29
|
+
'--enable-features=ExampleFeature,PartitionAllocMemoryReclaimer:interval/1800s',
|
|
30
|
+
'/workspace',
|
|
31
|
+
])
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('preserves an explicitly configured native memory reclaimer interval', () => {
|
|
35
|
+
assert.deepEqual(ArgvConfig.addDefaultMemoryReclaimerFeature(['--enable-features=ExampleFeature,PartitionAllocMemoryReclaimer:interval/32s']), [
|
|
36
|
+
'--enable-features=ExampleFeature,PartitionAllocMemoryReclaimer:interval/32s',
|
|
37
|
+
])
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('honors an explicit native memory reclaimer disable', () => {
|
|
41
|
+
const args = ['--disable-features=ExampleFeature,PartitionAllocMemoryReclaimer', '/workspace']
|
|
42
|
+
assert.equal(ArgvConfig.addDefaultMemoryReclaimerFeature(args), args)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('combines repeated feature switches and replaces a bare native reclaimer entry', () => {
|
|
46
|
+
assert.deepEqual(
|
|
47
|
+
ArgvConfig.addDefaultMemoryReclaimerFeature([
|
|
48
|
+
'--enable-features',
|
|
49
|
+
'ExampleFeature,PartitionAllocMemoryReclaimer',
|
|
50
|
+
'--enable-features=OtherFeature,PartitionAllocMemoryReclaimer:interval/45s',
|
|
51
|
+
'/workspace',
|
|
52
|
+
]),
|
|
53
|
+
['--enable-features=ExampleFeature,PartitionAllocMemoryReclaimer:interval/45s,OtherFeature', '/workspace'],
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
|
|
27
57
|
test('finds the workspace while ignoring repeated link arguments', () => {
|
|
28
58
|
assert.equal(ArgvConfig.getWorkspaceArgument(['--link', '/test/one', '/test/workspace', '--link=/test/two']), '/test/workspace')
|
|
29
59
|
})
|