mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 22:06:17 -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
@@ -3,6 +3,7 @@ import fs from 'node:fs'
|
||||
import process from 'node:process'
|
||||
import { verifyConsoleNoticeSources } from './site-vendor/console/notices.ts'
|
||||
import { verifyMonacoCoreNotices } from './site-vendor/monaco/core-origins.ts'
|
||||
import { verifyMonacoDomNotices } from './site-vendor/monaco/dom-origins.ts'
|
||||
import { verifyMonacoPathNotices } from './site-vendor/monaco/node-path.ts'
|
||||
import { verifyMonacoLanguageNotices } from './site-vendor/monaco/notices.ts'
|
||||
import { writeOrCheckNotices } from './site-vendor/notices.ts'
|
||||
@@ -14,6 +15,7 @@ assert.deepEqual(manifest.groups.map(group => group.name).sort(), ['console', 'm
|
||||
assert.deepEqual(manifest.groups.filter(group => group.name !== 'console').flatMap(group => (group.components || []).map(component => component.name)).sort(), [
|
||||
'@babel/runtime',
|
||||
'@vscode/codicons',
|
||||
'WinJS-derived DOM helpers (Monaco core)',
|
||||
'copy-text-to-clipboard',
|
||||
'core-js',
|
||||
'css-loader',
|
||||
@@ -91,6 +93,7 @@ for (const name of ['LICENSE', 'MIT-LICENSE', 'ATTRIBUTION.md'])
|
||||
assert(vconsoleNotices?.includes(`docs/licenses/vconsole/${name}`), `Missing vConsole notice: ${name}`)
|
||||
verifyConsoleNoticeSources(process.cwd(), manifest)
|
||||
verifyMonacoCoreNotices(process.cwd(), manifest)
|
||||
verifyMonacoDomNotices(process.cwd(), manifest)
|
||||
verifyMonacoPathNotices(process.cwd(), manifest)
|
||||
verifyMonacoLanguageNotices(process.cwd(), manifest)
|
||||
const count = writeOrCheckNotices(process.cwd(), manifest, process.argv.includes('--check'))
|
||||
|
||||
@@ -1025,6 +1025,16 @@
|
||||
"source": "refactor/baselines/site-vendor/monaco-node-path/ATTRIBUTION.md.txt",
|
||||
"target": "docs/licenses/monaco-editor/core-path/ATTRIBUTION.md",
|
||||
"sha256": "40583c701c0bcbd8e10935652a0a8b02e2073b0ef040fb7be7b939c437d8b8dc"
|
||||
},
|
||||
{
|
||||
"source": "refactor/baselines/site-vendor/monaco-dom/winjs-license.txt",
|
||||
"target": "docs/licenses/monaco-editor/core-dom/LICENSE.txt",
|
||||
"sha256": "13217bb585c27ee298f49c7aec2ef74578bc0d644880906a89d2c3ccec5d647e"
|
||||
},
|
||||
{
|
||||
"source": "refactor/baselines/site-vendor/monaco-dom/ATTRIBUTION.md.txt",
|
||||
"target": "docs/licenses/monaco-editor/core-dom/ATTRIBUTION.md",
|
||||
"sha256": "0858d19261742809cecd7174a0a06b2b0013a4b9560b78aede1edd3dd350da21"
|
||||
}
|
||||
],
|
||||
"review": "The complete upstream Monaco LICENSE/ThirdPartyNotices are retained. The unmodified bundled Codicons font exactly matches @vscode/codicons 0.0.26; its historical README, CC BY 4.0 content license, MIT code license and added attribution are distributed below. Other site assets remain subject to their separate provenance reviews.",
|
||||
@@ -1217,6 +1227,18 @@
|
||||
"docs/licenses/monaco-editor/ThirdPartyNotices.txt",
|
||||
"docs/licenses/monaco-editor/core-path/ATTRIBUTION.md"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "WinJS-derived DOM helpers (Monaco core)",
|
||||
"version": "unversioned adaptation; reference WinJS 4.4.5",
|
||||
"tarball": "https://github.com/winjs/winjs/tree/4329b1133b243d9ded3b5a1f98d096ee8e80e889",
|
||||
"assets": [
|
||||
"docs/assets/js/vs/editor/editor.main.js"
|
||||
],
|
||||
"notices": [
|
||||
"docs/licenses/monaco-editor/core-dom/LICENSE.txt",
|
||||
"docs/licenses/monaco-editor/core-dom/ATTRIBUTION.md"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -370,3 +370,39 @@ yarn test:browser test/browser/editor-path.spec.js test/browser/site-vendor.spec
|
||||
Full original core TypeScript compilation, WinJS/Unicode/other embedded origins
|
||||
and the overall SITE-07 acceptance remain separate. A path-module proof is not
|
||||
an exhaustive claim about every Node API or the rest of Monaco.
|
||||
|
||||
## WinJS-derived DOM declarations
|
||||
|
||||
`dom-origins.ts` identifies six complete top-level declaration blocks in fixed
|
||||
VS Code `dom.ts`. `reproduce-dom-origins.ts` verifies those exact blocks in the
|
||||
original editor source map and checks that the shipped editor still equals the
|
||||
fixed npm archive. AST declaration boundaries reject same-named strings, missing
|
||||
blocks and duplicate declarations. This is not compilation of the full DOM module.
|
||||
|
||||
The source explicitly attributes helpers to WinJS but does not identify the copied
|
||||
version. The record keeps `originalWinjsVersion: null`. A fixed WinJS 4.4.5 source
|
||||
and its complete Microsoft MIT terms provide a reproducible comparison, not an
|
||||
assertion that Monaco incorporates that exact unmodified release. The generated
|
||||
core-dom attribution explains CSS/pixel, position and typed-helper adaptations.
|
||||
Do not replace this distinction with a guessed version during later maintenance.
|
||||
|
||||
The ordinary notice build binds the reference license and attribution to the
|
||||
editor asset; it rejects omitted terms or a changed source/asset relationship.
|
||||
The site now carries 88 notice files plus its index. Frozen source and delivered
|
||||
terms preserve original bytes through Git attributes. No dependencies or editor
|
||||
runtime bytes changed; the verifier uses the existing TypeScript parser.
|
||||
|
||||
```sh
|
||||
yarn verify:monaco-dom-origins --fetch
|
||||
yarn verify:monaco-dom-origins
|
||||
yarn build:site-notices
|
||||
yarn check:site-notices
|
||||
yarn test:browser editor-dom.spec.js site-vendor.spec.js --workers=1
|
||||
```
|
||||
|
||||
The browser test calls the actual shipped editor's dimension/position helpers
|
||||
with borders, padding, margins and nested scrolling, comparing page offsets with
|
||||
native geometry. The site test checks all notice HTTP bytes, relative links and
|
||||
real mobile-page playback. Unicode/other embedded sources, unknown original
|
||||
WinJS version, complete original core compilation and SITE-07 acceptance remain
|
||||
open. Source comments and this bounded proof are not full provenance clearance.
|
||||
@@ -0,0 +1,63 @@
|
||||
import type { VendorManifest } from '../notices.ts'
|
||||
import type { Archive, Member, Remote } from './archives.ts'
|
||||
import assert from 'node:assert/strict'
|
||||
import { Buffer } from 'node:buffer'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import ts from 'typescript'
|
||||
import { hash } from './archives.ts'
|
||||
|
||||
export const domOriginNames = ['SizeUtils', 'getTopLeftOffset', 'getTotalWidth', 'getContentWidth', 'getContentHeight', 'getTotalHeight']
|
||||
|
||||
export interface DomOrigins {
|
||||
archives: Archive[]
|
||||
remotes: Remote[]
|
||||
vscodeSource: string
|
||||
winjsSource: string
|
||||
map: Member & { source: string }
|
||||
fragments: { name: string, sha256: string }[]
|
||||
shipped: Member & { target: string }
|
||||
component: { name: string, version: string, tarball: string, assets: string[], notices: string[] }
|
||||
notices: { source: string, target: string, sha256: string }[]
|
||||
originalWinjsVersion: null
|
||||
}
|
||||
|
||||
// Match declaration boundaries, never a same-named string or a substring of a function.
|
||||
export function domOriginFragments(source: string): Map<string, string> {
|
||||
const file = ts.createSourceFile('dom.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)
|
||||
const fragments = new Map<string, string>()
|
||||
for (const node of file.statements) {
|
||||
if ((!ts.isClassDeclaration(node) && !ts.isFunctionDeclaration(node)) || !node.name || !domOriginNames.includes(node.name.text))
|
||||
continue
|
||||
assert(!fragments.has(node.name.text), 'Repeated DOM origin declaration')
|
||||
fragments.set(node.name.text, node.getText(file))
|
||||
}
|
||||
assert.deepEqual([...fragments.keys()], domOriginNames, 'Missing or reordered DOM origin declarations')
|
||||
return fragments
|
||||
}
|
||||
|
||||
export function readDomOrigins(root: string): DomOrigins {
|
||||
return JSON.parse(fs.readFileSync(path.join(root, 'refactor/baselines/monaco-dom-origins-provenance.json'), 'utf8'))
|
||||
}
|
||||
|
||||
export function verifyMonacoDomNotices(root: string, manifest: VendorManifest): void {
|
||||
const record = readDomOrigins(root)
|
||||
assert.equal(record.originalWinjsVersion, null, 'Do not invent the original WinJS adaptation version')
|
||||
assert.equal(record.component.name, 'WinJS-derived DOM helpers (Monaco core)')
|
||||
assert.equal(record.component.version, 'unversioned adaptation; reference WinJS 4.4.5')
|
||||
assert.equal(record.component.tarball, 'https://github.com/winjs/winjs/tree/4329b1133b243d9ded3b5a1f98d096ee8e80e889', 'Wrong fixed WinJS reference')
|
||||
assert.deepEqual(record.component.assets, ['docs/assets/js/vs/editor/editor.main.js'], 'Wrong DOM origin assets')
|
||||
assert.deepEqual(record.notices.map(notice => notice.target), ['docs/licenses/monaco-editor/core-dom/LICENSE.txt', 'docs/licenses/monaco-editor/core-dom/ATTRIBUTION.md'], 'Missing complete DOM notice set')
|
||||
assert.deepEqual(record.component.notices, record.notices.map(notice => notice.target), 'Missing DOM attribution or terms')
|
||||
const group = manifest.groups.find(group => group.name === 'monaco-editor')
|
||||
assert(group, 'Missing Monaco DOM group')
|
||||
assert.deepEqual(group.components?.filter(item => item.name === record.component.name), [record.component], 'Wrong Monaco DOM notice binding')
|
||||
for (const notice of record.notices) {
|
||||
assert.deepEqual(group.notices.filter(item => item.target === notice.target), [notice], 'Missing Monaco DOM notice')
|
||||
assert.equal(hash(fs.readFileSync(path.join(root, notice.source))), notice.sha256, 'Changed Monaco DOM terms')
|
||||
}
|
||||
const source = fs.readFileSync(path.join(root, record.vscodeSource), 'utf8')
|
||||
assert.equal((source.match(/Adapted from WinJS/g) || []).length, 5, 'Changed explicit DOM attribution')
|
||||
const fragments = domOriginFragments(source)
|
||||
assert.deepEqual(record.fragments, [...fragments].map(([name, content]) => ({ name, sha256: hash(Buffer.from(content)) })), 'Changed DOM origin source fragments')
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { ArchiveCache } from './archives.ts'
|
||||
import { domOriginFragments, readDomOrigins, verifyMonacoDomNotices } from './dom-origins.ts'
|
||||
|
||||
const root = fileURLToPath(new URL('../../../', import.meta.url))
|
||||
assert(process.argv.slice(2).every(arg => arg === '--fetch'), 'Use reproduce-dom-origins.ts [--fetch]')
|
||||
assert.equal(process.version, `v${fs.readFileSync(path.join(root, '.node-version'), 'utf8').trim()}`, 'Use canonical Node')
|
||||
const record = readDomOrigins(root)
|
||||
const cache = new ArchiveCache(root, path.join(root, 'refactor/.cache/monaco-review'))
|
||||
await cache.verify(record.archives, record.remotes, process.argv.includes('--fetch'))
|
||||
verifyMonacoDomNotices(root, JSON.parse(fs.readFileSync(path.join(root, 'scripts/site-vendor/manifest.json'), 'utf8')))
|
||||
const map: { sources: string[], sourcesContent: string[] } = JSON.parse(cache.member(record.map).toString('utf8'))
|
||||
assert.equal(map.sources.filter(source => source === record.map.source).length, 1, 'Missing or repeated DOM source map entry')
|
||||
const mapped = domOriginFragments(map.sourcesContent[map.sources.indexOf(record.map.source)]!)
|
||||
const original = domOriginFragments(fs.readFileSync(path.join(root, record.vscodeSource), 'utf8'))
|
||||
assert.deepEqual(mapped, original, 'Prepared DOM adaptations differ from fixed VS Code source')
|
||||
assert.deepEqual(fs.readFileSync(path.join(root, record.shipped.target)), cache.member(record.shipped), 'Shipped DOM asset changed')
|
||||
const winjs = fs.readFileSync(path.join(root, record.winjsSource), 'utf8')
|
||||
for (const name of ['convertToPixels', 'getDimension', 'getTotalWidth', 'getContentWidth', 'getContentHeight', 'getTotalHeight', 'getPosition'])
|
||||
assert(winjs.includes(name), 'Missing referenced WinJS helper')
|
||||
console.log(JSON.stringify({ archives: record.archives.length, gitSources: record.remotes.length, unchangedMappedAdaptations: mapped.size, shippedAssetMatchesArchive: true, originalWinjsVersion: null, referenceVersion: '4.4.5', fullDomCompilation: false }))
|
||||
Reference in new issue
Block a user