offsite 0.0.29 → 0.0.31
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/apps/server/dist/main.mjs +324 -125
- package/apps/server/dist/main.mjs.map +1 -1
- package/apps/server/src/services/open/open.mjs +50 -0
- package/apps/server/src/services/open/open.ts +71 -0
- package/apps/web/dist/assets/{dist-BFSo4bqV.js → dist-BtfuptBR.js} +1 -1
- package/apps/web/dist/assets/index-7KisGKFg.js +782 -0
- package/apps/web/dist/assets/index-BeAmEPQC.css +2 -0
- package/apps/web/dist/assets/video-player-4TBQR7ei.js +1 -0
- package/apps/web/dist/assets/{video-player-DlVZx3V3.js → video-player-DsF9gAr6.js} +1 -1
- package/apps/web/dist/assets/{video-viewer-DJBDb-Jx.js → video-viewer-DAKoRaNT.js} +1 -1
- package/apps/web/dist/index.html +2 -2
- package/apps/web/dist/sw.js +1 -1
- package/package.json +2 -1
- package/apps/web/dist/assets/index-CUhKVIGk.js +0 -782
- package/apps/web/dist/assets/index-Cop1FRe3.css +0 -2
- package/apps/web/dist/assets/video-player-DDu2cDQE.js +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { statSync } from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
const command = process.argv[2]
|
|
7
|
+
const targets = process.argv.slice(3)
|
|
8
|
+
const file = targets.length === 1 ? localFile(targets[0]) : null
|
|
9
|
+
|
|
10
|
+
if (file !== null && statSync(file, { throwIfNoEntry: false })?.isFile()) {
|
|
11
|
+
if (process.env.OFFSITE_OPEN_URL === undefined) {
|
|
12
|
+
console.error(`${command}: OFFSITE_OPEN_URL is not set`)
|
|
13
|
+
process.exit(1)
|
|
14
|
+
}
|
|
15
|
+
const response = await fetch(process.env.OFFSITE_OPEN_URL, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: JSON.stringify({ path: file }),
|
|
18
|
+
})
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
console.error(`${command}: ${await response.text()}`)
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
23
|
+
process.exit(0)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const folder = path.dirname(fileURLToPath(import.meta.url))
|
|
27
|
+
const real = (process.env.PATH ?? '')
|
|
28
|
+
.split(path.delimiter)
|
|
29
|
+
.filter((dir) => dir !== '' && path.resolve(dir) !== folder)
|
|
30
|
+
.map((dir) => path.join(dir, command))
|
|
31
|
+
.find((candidate) => statSync(candidate, { throwIfNoEntry: false })?.isFile())
|
|
32
|
+
if (real === undefined) {
|
|
33
|
+
console.error(`${command}: command not found`)
|
|
34
|
+
process.exit(127)
|
|
35
|
+
}
|
|
36
|
+
const result = spawnSync(real, targets, { stdio: 'inherit' })
|
|
37
|
+
if (result.error !== undefined) {
|
|
38
|
+
throw result.error
|
|
39
|
+
}
|
|
40
|
+
process.exit(result.status ?? 1)
|
|
41
|
+
|
|
42
|
+
function localFile(target) {
|
|
43
|
+
if (target.startsWith('file:')) {
|
|
44
|
+
return fileURLToPath(target)
|
|
45
|
+
}
|
|
46
|
+
if (target.startsWith('-') || /^[a-z][a-z0-9+.-]*:/i.test(target)) {
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
return path.resolve(target)
|
|
50
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto'
|
|
2
|
+
import {
|
|
3
|
+
chmodSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
realpathSync,
|
|
7
|
+
writeFileSync,
|
|
8
|
+
} from 'node:fs'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import { serverDir } from '../../args.ts'
|
|
11
|
+
import { home } from '../../storage/storage.ts'
|
|
12
|
+
|
|
13
|
+
export const openSecret = randomBytes(32).toString('base64url')
|
|
14
|
+
let env: Record<string, string> = {}
|
|
15
|
+
|
|
16
|
+
export function openEnv() {
|
|
17
|
+
return env
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function installOpen(host: string, port: number) {
|
|
21
|
+
if (process.platform === 'win32') {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
mkdirSync(path.join(home, 'bin'), { recursive: true })
|
|
25
|
+
const folder = realpathSync(path.join(home, 'bin'))
|
|
26
|
+
const script = path.join(folder, 'open.mjs')
|
|
27
|
+
writeFileSync(
|
|
28
|
+
script,
|
|
29
|
+
readFileSync(path.join(serverDir, 'src/services/open/open.mjs'))
|
|
30
|
+
)
|
|
31
|
+
for (const name of ['open', 'xdg-open', 'wslview']) {
|
|
32
|
+
const wrapper = path.join(folder, name)
|
|
33
|
+
writeFileSync(
|
|
34
|
+
wrapper,
|
|
35
|
+
`#!/bin/sh\nexec ${quote(process.execPath)} ${quote(script)} ${name} "$@"\n`
|
|
36
|
+
)
|
|
37
|
+
chmodSync(wrapper, 0o755)
|
|
38
|
+
}
|
|
39
|
+
const startup = path.join(folder, 'env.sh')
|
|
40
|
+
writeFileSync(startup, `export PATH=${quote(folder)}:"$PATH"\n`)
|
|
41
|
+
env = {
|
|
42
|
+
PATH:
|
|
43
|
+
process.env.PATH === undefined
|
|
44
|
+
? folder
|
|
45
|
+
: `${folder}${path.delimiter}${process.env.PATH}`,
|
|
46
|
+
BROWSER: path.join(
|
|
47
|
+
folder,
|
|
48
|
+
process.platform === 'darwin' ? 'open' : 'xdg-open'
|
|
49
|
+
),
|
|
50
|
+
OFFSITE_OPEN_URL: `http://${loopback(host)}:${port}/api/open/${openSecret}`,
|
|
51
|
+
CLAUDE_ENV_FILE: startup,
|
|
52
|
+
BASH_ENV: startup,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function loopback(host: string) {
|
|
57
|
+
if (host === '0.0.0.0') {
|
|
58
|
+
return '127.0.0.1'
|
|
59
|
+
}
|
|
60
|
+
if (host === '::') {
|
|
61
|
+
return '[::1]'
|
|
62
|
+
}
|
|
63
|
+
if (host.includes(':')) {
|
|
64
|
+
return `[${host}]`
|
|
65
|
+
}
|
|
66
|
+
return host
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function quote(value: string) {
|
|
70
|
+
return `'${value.replaceAll("'", "'\\''")}'`
|
|
71
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as getSharedHighlighter}from"./dist-BJ6NAVkJ.js";import"./index-
|
|
1
|
+
export{n as getSharedHighlighter}from"./dist-BJ6NAVkJ.js";import"./index-7KisGKFg.js";
|