Compare commits
	
		
			No commits in common. "0738ce4cb1390e17935ba1bf97a5423340ecceca" and "4d59b1a9acdb0ec7f173ebf6d29f1532d13f0777" have entirely different histories.
		
	
	
		
			0738ce4cb1
			...
			4d59b1a9ac
		
	
		
					 10 changed files with 7 additions and 38 deletions
				
			
		
							
								
								
									
										9
									
								
								build.js
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								build.js
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -145,11 +145,9 @@ async function addJS(sourcePath, targetPath) {
 | 
			
		|||
	await fs.promises.writeFile(pj(buildDir, targetPath), content)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function addBundle(sourcePath, targetPath, module = false) {
 | 
			
		||||
	let opts = {}
 | 
			
		||||
	if(module) opts.standalone = sourcePath
 | 
			
		||||
async function addBundle(sourcePath, targetPath) {
 | 
			
		||||
	const content = await new Promise(resolve => {
 | 
			
		||||
		browserify([], opts)
 | 
			
		||||
		browserify()
 | 
			
		||||
			.add(pj(".", sourcePath))
 | 
			
		||||
			.transform(file => {
 | 
			
		||||
				let content = ""
 | 
			
		||||
| 
						 | 
				
			
			@ -289,9 +287,6 @@ async function addBabel(sourcePath, targetPath) {
 | 
			
		|||
			await addPug(item.source, item.target)
 | 
			
		||||
		} else if (item.type === "bundle") {
 | 
			
		||||
			await addBundle(item.source, item.target)
 | 
			
		||||
		} else if (item.type === "module") {
 | 
			
		||||
			// Creates a standalone bundle that can be imported on runtime
 | 
			
		||||
			await addBundle(item.source, item.target, true)
 | 
			
		||||
		} else {
 | 
			
		||||
			throw new Error("Unknown item type: "+item.type)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								spec.js
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								spec.js
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -19,11 +19,6 @@ module.exports = [
 | 
			
		|||
		source: "/js/main.js",
 | 
			
		||||
		target: "/static/bundle.js"
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		type: "module",
 | 
			
		||||
		source: "/js/hljs.js",
 | 
			
		||||
		target: "/static/hljs.js"
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		type: "file",
 | 
			
		||||
		source: "/assets/fonts/whitney-500.woff",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,6 @@ html
 | 
			
		|||
      != JSON.stringify([...static.keys()].map(k => [k, getStatic(k)]))
 | 
			
		||||
      | )
 | 
			
		||||
    link(rel="stylesheet" type="text/css" href=getStatic("/sass/main.sass"))
 | 
			
		||||
    link(rel="preload" as="script" href=getStatic("/js/hljs.js"))
 | 
			
		||||
    script(type="module" src=getStatic("/js/main.js"))
 | 
			
		||||
  body
 | 
			
		||||
    main.main
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
const {ElemJS} = require("../basic")
 | 
			
		||||
const {lazyLoad} = require("../lazy-load-module")
 | 
			
		||||
const hljs = require("highlight.js")
 | 
			
		||||
 | 
			
		||||
class HighlightedCode extends ElemJS {
 | 
			
		||||
	constructor(code) {
 | 
			
		||||
		super(code)
 | 
			
		||||
		lazyLoad("/static/hljs.js").then(hljs => hljs.highlightBlock(this.element))
 | 
			
		||||
		hljs.highlightBlock(this.element)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
const {ElemJS, ejs} = require("../basic")
 | 
			
		||||
const {dateFormatter} = require("../date-formatter")
 | 
			
		||||
const {dateFormatter} = require("../dateFormatter")
 | 
			
		||||
 | 
			
		||||
class MatrixEvent extends ElemJS {
 | 
			
		||||
	constructor(data) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
const {ejs, ElemJS} = require("../basic")
 | 
			
		||||
const hljs = require("highlight.js")
 | 
			
		||||
const {HighlightedCode} = require("./components")
 | 
			
		||||
const DOMPurify = require("dompurify")
 | 
			
		||||
const {resolveMxc} = require("../functions")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
const hljs = require("highlight.js")
 | 
			
		||||
module.exports = hljs
 | 
			
		||||
| 
						 | 
				
			
			@ -1,19 +0,0 @@
 | 
			
		|||
// I hate this with passion
 | 
			
		||||
async function lazyLoad(url) {
 | 
			
		||||
	const cache = window.lazy_load_cache || new Map()
 | 
			
		||||
	if (cache.get(url)) return cache.get(url)
 | 
			
		||||
 | 
			
		||||
	const module = loadModuleWithoutCache(url)
 | 
			
		||||
	cache.set(url, module)
 | 
			
		||||
	return module
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Loads the module without caching
 | 
			
		||||
async function loadModuleWithoutCache(url) {
 | 
			
		||||
	const src = await fetch(url).then(r => r.text())
 | 
			
		||||
	let module = {}
 | 
			
		||||
	eval(src)
 | 
			
		||||
	return module.exports
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {lazyLoad}
 | 
			
		||||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ const {Sender} = require("./sender.js")
 | 
			
		|||
const lsm = require("./lsm.js")
 | 
			
		||||
const {resolveMxc} = require("./functions.js")
 | 
			
		||||
const {renderEvent} = require("./events/renderEvent")
 | 
			
		||||
const {dateFormatter} = require("./date-formatter")
 | 
			
		||||
const {dateFormatter} = require("./dateFormatter")
 | 
			
		||||
 | 
			
		||||
let debug = false
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue