dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x
This commit is contained in:
commit
e6dcef9bf5
302 files changed
+75178
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
export const BROWSER_CONNECTION_TARGET = '/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-client-connection/lib/client.js'
|
||||
export const BROWSER_CONNECTION_RELATIVE_TARGET = 'node_modules/@deepseek-ai/dsh-client-connection/lib/client.js'
|
||||
|
||||
const LOOPBACK_CLASSIFICATIONS = Object.freeze([
|
||||
'isLoopback: pageLocation === void 0 || isLoopbackHostname(pageLocation.hostname),',
|
||||
'isLoopback: transport?.ownsHost === true || pageLocation === void 0 || isLoopbackHostname(pageLocation.hostname),',
|
||||
])
|
||||
|
||||
export function patchBrowserLoopback(target = BROWSER_CONNECTION_TARGET) {
|
||||
const after = 'isLoopback: true,'
|
||||
const source = readFileSync(target, 'utf8')
|
||||
const matches = LOOPBACK_CLASSIFICATIONS.flatMap(before => source.split(before).slice(1).map(() => before))
|
||||
|
||||
if (matches.length !== 1) {
|
||||
throw new Error(
|
||||
`Expected exactly one browser loopback classification in ${target}, found ${matches.length}. ` +
|
||||
'The upstream package may have changed; review this patch before building.',
|
||||
)
|
||||
}
|
||||
|
||||
writeFileSync(target, source.replace(matches[0], after))
|
||||
}
|
||||
|
||||
export function applyPatch(dshRoot) {
|
||||
patchBrowserLoopback(resolve(dshRoot, BROWSER_CONNECTION_RELATIVE_TARGET))
|
||||
}
|
||||
|
||||
export function verifyPatch(dshRoot) {
|
||||
const target = resolve(dshRoot, BROWSER_CONNECTION_RELATIVE_TARGET)
|
||||
const source = readFileSync(target, 'utf8')
|
||||
const matches = source.split('isLoopback: true,').length - 1
|
||||
if (matches !== 1 || LOOPBACK_CLASSIFICATIONS.some(classification => source.includes(classification))) {
|
||||
throw new Error(`Browser loopback Patch verification failed for ${target}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (resolve(process.argv[1] ?? '') === fileURLToPath(import.meta.url)) patchBrowserLoopback()
|
||||
Reference in new issue
Block a user