implemented frontend including separate message system; started to implement backend
This commit is contained in:
3
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=0ecdsa-generate-keypair.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"0ecdsa-generate-keypair.d.ts","sourceRoot":"","sources":["0ecdsa-generate-keypair.js"],"names":[],"mappings":""}
|
||||
15
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.js
generated
vendored
Normal file
15
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
import * as ecdsa from 'lib0/crypto/ecdsa'
|
||||
import * as json from 'lib0/json'
|
||||
import * as env from 'lib0/environment'
|
||||
|
||||
const prefix = env.getConf('name')
|
||||
|
||||
const keypair = await ecdsa.generateKeyPair({ extractable: true })
|
||||
const privateJwk = json.stringify(await ecdsa.exportKeyJwk(keypair.privateKey))
|
||||
const publicJwk = json.stringify(await ecdsa.exportKeyJwk(keypair.publicKey))
|
||||
|
||||
console.log(`
|
||||
${prefix ? prefix.toUpperCase() + '_' : ''}PUBLIC_KEY=${publicJwk}
|
||||
${prefix ? prefix.toUpperCase() + '_' : ''}PRIVATE_KEY=${privateJwk}
|
||||
`)
|
||||
3
yjs-poll/node_modules/lib0/bin/0serve.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/0serve.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=0serve.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/0serve.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/0serve.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"0serve.d.ts","sourceRoot":"","sources":["0serve.js"],"names":[],"mappings":""}
|
||||
97
yjs-poll/node_modules/lib0/bin/0serve.js
generated
vendored
Normal file
97
yjs-poll/node_modules/lib0/bin/0serve.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Simple http server implementation.
|
||||
* Optionally, you may set `DEBUG_BROWSER` environment variable to use a different browser to debug
|
||||
* web apps.
|
||||
*/
|
||||
|
||||
import * as http from 'http'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import * as env from '../environment.js'
|
||||
import * as number from '../number.js'
|
||||
import * as logging from 'lib0/logging'
|
||||
|
||||
const host = env.getParam('--host', 'localhost')
|
||||
const port = number.parseInt(env.getParam('--port', '8000'))
|
||||
const paramOpenFile = env.getParam('-o', '')
|
||||
const debugBrowser = env.getConf('DEBUG_BROWSER')
|
||||
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const types = {
|
||||
html: 'text/html',
|
||||
css: 'text/css',
|
||||
js: 'application/javascript',
|
||||
mjs: 'application/javascript',
|
||||
png: 'image/png',
|
||||
jpg: 'image/jpeg',
|
||||
jpeg: 'image/jpeg',
|
||||
gif: 'image/gif',
|
||||
json: 'application/json',
|
||||
xml: 'application/xml',
|
||||
wasm: 'application/wasm'
|
||||
}
|
||||
|
||||
const root = path.normalize(path.resolve('./'))
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const url = (req.url || '/index.html').split('?')[0]
|
||||
logging.print(logging.ORANGE, logging.BOLD, req.method || '', ' ', logging.GREY, logging.UNBOLD, url)
|
||||
const extension = path.extname(url).slice(1)
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const type = (extension && types[extension]) || types.html
|
||||
const supportedExtension = Boolean(type)
|
||||
if (!supportedExtension) {
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end('404: File not found')
|
||||
return
|
||||
}
|
||||
let fileName = url
|
||||
if (url === '/') fileName = 'index.html'
|
||||
else if (!extension) {
|
||||
try {
|
||||
fs.accessSync(path.join(root, url + '.html'), fs.constants.F_OK)
|
||||
fileName = url + '.html'
|
||||
} catch (e) {
|
||||
fileName = path.join(url, 'index.html')
|
||||
}
|
||||
}
|
||||
|
||||
const filePath = path.join(root, fileName)
|
||||
const isPathUnderRoot = path
|
||||
.normalize(path.resolve(filePath))
|
||||
.startsWith(root)
|
||||
|
||||
if (!isPathUnderRoot) {
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end('404: File not found')
|
||||
logging.print(logging.RED, logging.BOLD, 'Not Found: ', logging.GREY, logging.UNBOLD, url)
|
||||
return
|
||||
}
|
||||
|
||||
fs.readFile(filePath, (err, data) => {
|
||||
if (err) {
|
||||
logging.print(logging.RED, logging.BOLD, 'Cannot read file: ', logging.GREY, logging.UNBOLD, url)
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end('404: File not found')
|
||||
} else {
|
||||
res.writeHead(200, { 'Content-Type': type })
|
||||
res.end(data)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(port, host, () => {
|
||||
logging.print(logging.BOLD, logging.ORANGE, `Server is running on http://${host}:${port}`)
|
||||
if (paramOpenFile) {
|
||||
const start = debugBrowser || (process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open')
|
||||
import('child_process').then(cp => {
|
||||
cp.exec(`${start} http://${host}:${port}/${paramOpenFile}`)
|
||||
})
|
||||
}
|
||||
})
|
||||
3
yjs-poll/node_modules/lib0/bin/gendocs.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/gendocs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=gendocs.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/gendocs.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/gendocs.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gendocs.d.ts","sourceRoot":"","sources":["gendocs.js"],"names":[],"mappings":""}
|
||||
117
yjs-poll/node_modules/lib0/bin/gendocs.js
generated
vendored
Normal file
117
yjs-poll/node_modules/lib0/bin/gendocs.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env node
|
||||
// @ts-ignore
|
||||
import jsdoc from 'jsdoc-api'
|
||||
import * as fs from 'fs'
|
||||
|
||||
const firstTagContentRegex = /<\w>([^<]+)<\/\w>([^]*)/
|
||||
const jsdocReturnRegex = /\* @return {(.*)}/
|
||||
const jsdocTypeRegex = /\* @type {(.*)}/
|
||||
|
||||
const files = fs.readdirSync('./').filter(file => /(?<!(test|config))\.js$/.test(file))
|
||||
|
||||
const _ltregex = /</g
|
||||
const _rtregex = />/g
|
||||
/**
|
||||
* @param {string} s
|
||||
*/
|
||||
const toSafeHtml = s => s.replace(_ltregex, '<').replace(_rtregex, '>')
|
||||
|
||||
const READMEcontent = fs.readFileSync('./README.md', 'utf8')
|
||||
|
||||
jsdoc.explain({
|
||||
files,
|
||||
configure: '.jsdoc.json'
|
||||
}).then(/** @param {Array<any>} json */ json => {
|
||||
const strBuilder = []
|
||||
/**
|
||||
* @type {Object<string, { items: Array<any>, name: string, description: string }>}
|
||||
*/
|
||||
const modules = {}
|
||||
json.forEach(item => {
|
||||
if (item.meta && item.meta.filename) {
|
||||
const mod = modules[item.meta.filename] || (modules[item.meta.filename] = { items: [], name: item.meta.filename.slice(0, -3), description: '' })
|
||||
if (item.kind === 'module') {
|
||||
mod.name = item.name
|
||||
mod.description = item.description || ''
|
||||
} else {
|
||||
mod.items.push(item)
|
||||
}
|
||||
}
|
||||
})
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const classDescriptions = {}
|
||||
for (const fileName in modules) {
|
||||
const mod = modules[fileName]
|
||||
const items = mod.items
|
||||
const desc = firstTagContentRegex.exec(mod.description)
|
||||
const descHead = desc ? desc[1] : ''
|
||||
const descRest = desc ? desc[2] : ''
|
||||
strBuilder.push(`<details><summary><b>[lib0/${mod.name}]</b> ${descHead}</summary>`)
|
||||
strBuilder.push(`<pre>import * as ${mod.name} from 'lib0/${fileName.slice(0, -3)}'</pre>`)
|
||||
if (descRest.length > 0) {
|
||||
strBuilder.push(descRest)
|
||||
}
|
||||
strBuilder.push('<dl>')
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i]
|
||||
if (!item.ignore && item.scope !== 'inner' && item.name[0] !== '_' && item.longname.indexOf('~') < 0) {
|
||||
// strBuilder.push(JSON.stringify(item)) // output json for debugging
|
||||
switch (item.kind) {
|
||||
case 'class': {
|
||||
if (item.params == null) {
|
||||
classDescriptions[item.longname] = item.classdesc
|
||||
break
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
case 'constant': {
|
||||
if (item.params == null && item.returns == null) {
|
||||
const typeEval = jsdocTypeRegex.exec(item.comment)
|
||||
strBuilder.push(`<b><code>${item.longname.slice(7)}${typeEval ? (': ' + toSafeHtml(typeEval[1])) : ''}</code></b><br>`)
|
||||
if (item.description) {
|
||||
strBuilder.push(`<dd>${item.description}</dd>`)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
case 'function': {
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
const getOriginalParamTypeDecl = name => {
|
||||
const regval = new RegExp('@param {(.*)} \\[?' + name + '\\]?[^\\w]*').exec(item.comment)
|
||||
return regval ? regval[1] : null
|
||||
}
|
||||
if (item.params == null && item.returns == null) {
|
||||
break
|
||||
}
|
||||
const paramVal = (item.params || []).map(/** @param {any} ret */ ret => `${ret.name}: ${getOriginalParamTypeDecl(ret.name) || ret.type.names.join('|')}`).join(', ')
|
||||
const evalReturnRegex = jsdocReturnRegex.exec(item.comment)
|
||||
const returnVal = evalReturnRegex ? `: ${evalReturnRegex[1]}` : (item.returns ? item.returns.map(/** @param {any} r */ r => r.type.names.join('|')).join('|') : '')
|
||||
strBuilder.push(`<b><code>${item.kind === 'class' ? 'new ' : ''}${item.longname.slice(7)}(${toSafeHtml(paramVal)})${toSafeHtml(returnVal)}</code></b><br>`)
|
||||
const desc = item.description || item.classdesc || classDescriptions[item.longname] || null
|
||||
if (desc) {
|
||||
strBuilder.push(`<dd>${desc}</dd>`)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'member': {
|
||||
if (item.type) {
|
||||
strBuilder.push(`<b><code>${item.longname.slice(7)}: ${toSafeHtml(/** @type {RegExpExecArray} */ (jsdocTypeRegex.exec(item.comment))[1])}</code></b><br>`)
|
||||
if (item.description) {
|
||||
strBuilder.push(`<dd>${item.description}</dd>`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
strBuilder.push('</dl>')
|
||||
strBuilder.push('</details>')
|
||||
}
|
||||
const replaceReadme = READMEcontent.replace(/<details>[^]*<\/details>/, strBuilder.join('\n'))
|
||||
fs.writeFileSync('./README.md', replaceReadme)
|
||||
})
|
||||
3
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=gentesthtml.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gentesthtml.d.ts","sourceRoot":"","sources":["gentesthtml.js"],"names":[],"mappings":""}
|
||||
89
yjs-poll/node_modules/lib0/bin/gentesthtml.js
generated
vendored
Normal file
89
yjs-poll/node_modules/lib0/bin/gentesthtml.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env node
|
||||
import * as fs from 'fs'
|
||||
import * as object from '../object.js'
|
||||
import * as env from '../environment.js'
|
||||
|
||||
const script = env.getParam('--script', './test.js')
|
||||
const includeDeps = env.getParam('--include-dependencies', '').split(',').filter(d => d.length)
|
||||
const customImportsPath = env.getParam('--custom-imports', '')
|
||||
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const exports = {}
|
||||
/**
|
||||
* @type {Object<string,Object<string,string>>}
|
||||
*/
|
||||
const scopes = {}
|
||||
|
||||
/**
|
||||
* @param {any} v
|
||||
* @param {string} k
|
||||
* @param {string} pkgName
|
||||
* @param {string} pathPrefix
|
||||
* @param {Object<string,string>} importMap
|
||||
*/
|
||||
const extractModMap = (v, k, pkgName, pathPrefix, importMap) => {
|
||||
if (k[0] !== '.') return
|
||||
if (typeof v === 'object') {
|
||||
extractModMap(v.browser || v.import || v.module || v.default, k, pkgName, pathPrefix, importMap)
|
||||
} else if (v && v[0] === '.') {
|
||||
importMap[pkgName + k.slice(1)] = pathPrefix + v.slice(1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
*/
|
||||
const _maybeAddRelPrefix = s => (s[0] !== '.' ? './' : '') + s
|
||||
|
||||
/**
|
||||
* @param {any} pkgJson
|
||||
* @param {string} pathPrefix
|
||||
* @param {Object<string,string>} importMap
|
||||
*/
|
||||
const readPkg = (pkgJson, pathPrefix, importMap) => {
|
||||
if (pkgJson.exports == null && pkgJson.main != null) {
|
||||
importMap[pkgJson.name] = pathPrefix + _maybeAddRelPrefix(pkgJson.main).slice(1)
|
||||
}
|
||||
object.forEach(pkgJson.exports, (v, k) => extractModMap(v, k, pkgJson.name, pathPrefix, importMap))
|
||||
object.forEach(pkgJson.dependencies, (_v, depName) => {
|
||||
const nextImportMap = pathPrefix === '.' ? exports : (scopes[pathPrefix + '/'] || (scopes[pathPrefix + '/'] = {}))
|
||||
const prefix = `./node_modules/${depName}`
|
||||
const depPkgJson = JSON.parse(fs.readFileSync(prefix + '/package.json', { encoding: 'utf8' }))
|
||||
readPkg(depPkgJson, prefix, nextImportMap)
|
||||
})
|
||||
}
|
||||
|
||||
const rootPkgJson = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' }))
|
||||
readPkg(rootPkgJson, '.', exports)
|
||||
includeDeps.forEach(depName => {
|
||||
const prefix = `./node_modules/${depName}`
|
||||
const depPkgJson = JSON.parse(fs.readFileSync(`${prefix}/package.json`, { encoding: 'utf8' }))
|
||||
readPkg(depPkgJson, prefix, exports)
|
||||
})
|
||||
|
||||
const customImports = {}
|
||||
if (customImportsPath !== '') {
|
||||
object.assign(customImports, JSON.parse(fs.readFileSync(customImportsPath, { encoding: 'utf8' })))
|
||||
}
|
||||
|
||||
const testHtml = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Testing ${rootPkgJson.name}</title>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": ${JSON.stringify(object.assign({}, exports, customImports), null, 2)},
|
||||
"scopes": ${JSON.stringify(scopes, null, 2)}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="${script}"></script>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
||||
console.log(testHtml)
|
||||
Reference in New Issue
Block a user