mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 15:26:16 -08:00
build(site): [SITE-07] verify Monaco TypeScript worker and original notices
This commit is contained in:
1 parent
fb1faffbe9
commit
11296975f1
31 files changed
+6580
-8
No files matched your search
@@ -36,6 +36,7 @@ test('mobile vConsole shows logs and upstream site notice texts are served uncha
|
||||
const index = await request.get('/THIRD_PARTY_NOTICES.md')
|
||||
expect(index.status()).toBe(200)
|
||||
expect(await index.text()).toContain('Included component: @vscode/codicons 0.0.26')
|
||||
expect(await index.text()).toContain('Included component: typescript (Monaco worker) 4.4.4')
|
||||
expect(await index.text()).toContain('Included component: console-feed 3.2.2')
|
||||
expect(await index.text()).toContain('Included component: react-pure-render (shallowequal origin) source commit 729cdbd')
|
||||
expect(await index.text()).toContain('Included component: chromium-string-utils')
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import assert from 'node:assert/strict'
|
||||
// eslint-disable-next-line test/no-import-node-test -- Verify fixed source transforms without executing archived runtime.
|
||||
import test from 'node:test'
|
||||
import { browserTypeScript, verifyTypeScriptSource } from '../scripts/site-vendor/monaco/typescript.ts'
|
||||
|
||||
const source = `"use strict";
|
||||
ts.sys = (function () {
|
||||
return 1;
|
||||
})();
|
||||
etwModule = require("etw");
|
||||
var result = ts.sys.require("other");
|
||||
fs = require("fs");
|
||||
debugger;
|
||||
var hooks = require("perf_hooks");
|
||||
//# sourceMappingURL=typescriptServices.js.map
|
||||
`
|
||||
|
||||
test('Monaco TypeScript adaptations reject missing or duplicate historical boundaries', () => {
|
||||
const output = browserTypeScript(source)
|
||||
assert.match(output, /ts.sys = undefined/)
|
||||
assert(!output.includes('require('))
|
||||
assert(!output.includes('sourceMappingURL'))
|
||||
assert(!output.includes('"use strict"'))
|
||||
const emittedDirective = `const emitted = '\"use strict\";';\n`
|
||||
assert(browserTypeScript(source + emittedDirective).includes(emittedDirective))
|
||||
assert.throws(() => browserTypeScript(source.replace(' fs = require("fs");', ' fs = {}')), /adaptation boundary/)
|
||||
assert.throws(() => browserTypeScript(`${source}\n fs = require("fs");`), /adaptation boundary/)
|
||||
assert.throws(() => browserTypeScript(source.replace('//# sourceMappingURL=', '// removed=')), /source map boundary/)
|
||||
assert.throws(() => browserTypeScript(`${source}\n"use strict";`), /strict directive/)
|
||||
})
|
||||
|
||||
test('Monaco TypeScript proof rejects modified or repeated worker content', () => {
|
||||
const output = browserTypeScript(source)
|
||||
const worker = `${' '.repeat(98)}${output}\nnextModule()`
|
||||
assert.equal(verifyTypeScriptSource(source, worker), output.length)
|
||||
assert.throws(() => verifyTypeScriptSource(source, worker.replace('etwModule = undefined', 'etwModule = {}')), /differs/)
|
||||
assert.throws(() => verifyTypeScriptSource(source, worker + output), /Duplicate/)
|
||||
assert.throws(() => verifyTypeScriptSource(source, worker.slice(1)), /differs/)
|
||||
})
|
||||
@@ -144,3 +144,20 @@ test('Console notice CLI rejects omitted package or embedded attribution before
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('Monaco TypeScript supplement requires all three upstream notices and its version explanation', (t) => {
|
||||
const { root } = fixture(t)
|
||||
const manifestPath = path.join(root, 'scripts/site-vendor/manifest.json')
|
||||
fs.mkdirSync(path.dirname(manifestPath), { recursive: true })
|
||||
const original = JSON.parse(fs.readFileSync('scripts/site-vendor/manifest.json', 'utf8'))
|
||||
for (const name of ['LICENSE.txt', 'CopyrightNotice.txt', 'ThirdPartyNoticeText.txt', 'ATTRIBUTION.md']) {
|
||||
const manifest = structuredClone(original)
|
||||
const component = manifest.groups.find(group => group.name === 'monaco-editor').components.find(component => component.name === 'typescript (Monaco worker)')
|
||||
component.notices = component.notices.filter(target => !target.endsWith(`/${name}`))
|
||||
fs.writeFileSync(manifestPath, JSON.stringify(manifest))
|
||||
const result = spawnSync(process.execPath, [path.resolve('scripts/build-site-notices.mjs')], { cwd: root, encoding: 'utf8' })
|
||||
assert.equal(result.status, 1)
|
||||
assert.match(result.stderr, /Missing TypeScript component notice/)
|
||||
assert(!fs.existsSync(path.join(root, 'docs')))
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user