Replace CDN React/ReactDOM/Babel with local libs; remove Babel and inline scripts Build Tailwind locally, add safelist; switch to assets/tailwind.css Self-host Font Awesome and Inter (CSS + woff2); remove external font CDNs Implement strict CSP (no unsafe-inline/eval; scripts/styles/fonts from self) Extract inline handlers; move PWA scripts to external files Add local QR code generation (qrcode lib) and remove api.qrserver.com Improve SessionTypeSelector visual selection (highlighted background and ring) Keep PWA working with service worker and offline assets Refs: CSP hardening, offline-first, no external dependencies
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
// let Utils = require('./utils')
|
|
|
|
exports.render = function (qrData, options, cb) {
|
|
const size = qrData.modules.size
|
|
const data = qrData.modules.data
|
|
|
|
// let opts = Utils.getOptions(options)
|
|
|
|
// use same scheme as https://github.com/gtanner/qrcode-terminal because it actually works! =)
|
|
const black = '\x1b[40m \x1b[0m'
|
|
const white = '\x1b[47m \x1b[0m'
|
|
|
|
let output = ''
|
|
const hMargin = Array(size + 3).join(white)
|
|
const vMargin = Array(2).join(white)
|
|
|
|
output += hMargin + '\n'
|
|
for (let i = 0; i < size; ++i) {
|
|
output += white
|
|
for (let j = 0; j < size; j++) {
|
|
// let topModule = data[i * size + j]
|
|
// let bottomModule = data[(i + 1) * size + j]
|
|
|
|
output += data[i * size + j] ? black : white// getBlockChar(topModule, bottomModule)
|
|
}
|
|
// output += white+'\n'
|
|
output += vMargin + '\n'
|
|
}
|
|
|
|
output += hMargin + '\n'
|
|
|
|
if (typeof cb === 'function') {
|
|
cb(null, output)
|
|
}
|
|
|
|
return output
|
|
}
|
|
/*
|
|
exports.renderToFile = function renderToFile (path, qrData, options, cb) {
|
|
if (typeof cb === 'undefined') {
|
|
cb = options
|
|
options = undefined
|
|
}
|
|
|
|
let fs = require('fs')
|
|
let utf8 = exports.render(qrData, options)
|
|
fs.writeFile(path, utf8, cb)
|
|
}
|
|
*/
|