mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-17 01:56:16 -08:00
build(site): [SITE-07] bind Monaco DOM adaptations and WinJS reference notices
This commit is contained in:
1 parent
3eb5500525
commit
1fed96a909
25 files changed
+6931
-7
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { expect, test } from './fixtures.js'
|
||||
|
||||
test('docs Monaco DOM helpers preserve dimensions and offsets through nested scrolling', async ({ page }, testInfo) => {
|
||||
await page.goto('/test/player.html?core=candidate&chapter=published')
|
||||
await page.addScriptTag({ url: '/assets/js/vs/loader.js' })
|
||||
const observations = await page.evaluate(async () => {
|
||||
window.require.config({ paths: { vs: '/assets/js/vs' } })
|
||||
const load = ids => new Promise((resolve, reject) => window.require(ids, (...modules) => resolve(modules), reject))
|
||||
await load(['vs/editor/editor.main'])
|
||||
const [dom] = await load(['vs/base/browser/dom'])
|
||||
const host = document.createElement('div')
|
||||
host.style.cssText = 'position:relative;width:300px;height:160px;border:5px solid;overflow:scroll;'
|
||||
const spacer = document.createElement('div')
|
||||
spacer.style.cssText = 'width:600px;height:500px;'
|
||||
const child = document.createElement('div')
|
||||
child.style.cssText = 'box-sizing:content-box;position:absolute;left:70px;top:90px;width:120px;height:50px;padding:3px;border:2px solid;margin:7px;'
|
||||
host.append(spacer, child)
|
||||
document.body.append(host)
|
||||
try {
|
||||
return [[0, 0], [25, 35], [0, 0]].map(([left, top]) => {
|
||||
host.scrollLeft = left
|
||||
host.scrollTop = top
|
||||
const rect = child.getBoundingClientRect()
|
||||
return {
|
||||
scroll: [host.scrollLeft, host.scrollTop],
|
||||
content: [dom.getContentWidth(child), dom.getContentHeight(child)],
|
||||
total: [dom.getTotalWidth(child), dom.getTotalHeight(child)],
|
||||
offset: dom.getTopLeftOffset(child),
|
||||
native: { left: rect.left + window.scrollX, top: rect.top + window.scrollY },
|
||||
}
|
||||
})
|
||||
}
|
||||
finally {
|
||||
host.remove()
|
||||
}
|
||||
})
|
||||
for (const value of observations) {
|
||||
expect(value.content).toEqual([120, 50])
|
||||
expect(value.total).toEqual([144, 74])
|
||||
expect(value.offset.left).toBeCloseTo(value.native.left, 1)
|
||||
expect(value.offset.top).toBeCloseTo(value.native.top, 1)
|
||||
}
|
||||
expect(observations.map(value => value.scroll)).toEqual([[0, 0], [25, 35], [0, 0]])
|
||||
await testInfo.attach('monaco-dom-origins', { contentType: 'application/json', body: JSON.stringify(observations) })
|
||||
})
|
||||
@@ -26,6 +26,7 @@ test('mobile vConsole shows logs and upstream site notice texts are served uncha
|
||||
{ path: '/licenses/monaco-editor/language-services/ATTRIBUTION.md', count: 12 },
|
||||
{ path: '/licenses/monaco-editor/core-origins/ATTRIBUTION.md', count: 3 },
|
||||
{ path: '/licenses/monaco-editor/core-path/ATTRIBUTION.md', count: 1 },
|
||||
{ path: '/licenses/monaco-editor/core-dom/ATTRIBUTION.md', count: 1 },
|
||||
]) {
|
||||
const attribution = await request.get(path)
|
||||
expect(attribution.status()).toBe(200)
|
||||
|
||||
@@ -9,12 +9,34 @@ import process from 'node:process'
|
||||
import test from 'node:test'
|
||||
import { verifyConsoleNoticeSources } from '../scripts/site-vendor/console/notices.ts'
|
||||
import { verifyMonacoCoreNotices } from '../scripts/site-vendor/monaco/core-origins.ts'
|
||||
import { domOriginFragments, verifyMonacoDomNotices } from '../scripts/site-vendor/monaco/dom-origins.ts'
|
||||
import { verifyMonacoPathNotices } from '../scripts/site-vendor/monaco/node-path.ts'
|
||||
import { verifyMonacoLanguageNoticeArchives, verifyMonacoLanguageNotices } from '../scripts/site-vendor/monaco/notices.ts'
|
||||
import { generateNotices, writeOrCheckNotices } from '../scripts/site-vendor/notices.ts'
|
||||
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex')
|
||||
|
||||
test('WinJS-derived DOM helpers keep reference terms without claiming an exact original version', () => {
|
||||
const original = JSON.parse(fs.readFileSync('scripts/site-vendor/manifest.json', 'utf8'))
|
||||
assert.doesNotThrow(() => verifyMonacoDomNotices(process.cwd(), original))
|
||||
const missingAsset = structuredClone(original)
|
||||
missingAsset.groups.find(group => group.name === 'monaco-editor').components.find(item => item.name.startsWith('WinJS-derived')).assets = []
|
||||
assert.throws(() => verifyMonacoDomNotices(process.cwd(), missingAsset), /DOM notice binding/)
|
||||
const missingTerms = structuredClone(original)
|
||||
const group = missingTerms.groups.find(group => group.name === 'monaco-editor')
|
||||
group.notices = group.notices.filter(item => !item.target.endsWith('core-dom/LICENSE.txt'))
|
||||
assert.throws(() => verifyMonacoDomNotices(process.cwd(), missingTerms), /DOM notice/)
|
||||
})
|
||||
|
||||
test('DOM origin declarations reject duplicate or missing blocks and ignore same-named strings', () => {
|
||||
const source = fs.readFileSync('refactor/baselines/site-vendor/monaco-dom/vscode-dom.txt', 'utf8')
|
||||
const fragments = domOriginFragments(source)
|
||||
assert.equal(fragments.size, 6)
|
||||
assert.deepEqual(domOriginFragments(`${source}\nconst label = 'getTotalWidth';`), fragments)
|
||||
assert.throws(() => domOriginFragments(`${source}\n${fragments.get('getTotalWidth')}`), /Repeated DOM/)
|
||||
assert.throws(() => domOriginFragments(source.replace(fragments.get('SizeUtils'), 'const SizeUtils = "same name";')), /Missing or reordered/)
|
||||
})
|
||||
|
||||
test('Node path attribution covers both editor and worker and keeps the original terms', () => {
|
||||
const original = JSON.parse(fs.readFileSync('scripts/site-vendor/manifest.json', 'utf8'))
|
||||
assert.doesNotThrow(() => verifyMonacoPathNotices(process.cwd(), original))
|
||||
|
||||
Reference in new issue
Block a user