build: migrate widget doc generation script, ungit widget reference

This commit is contained in:
jean-emmanuel 2025-09-12 16:31:44 +02:00
parent 6b68237f41
commit 4c98442fed
7 changed files with 1615 additions and 1479 deletions

87
src/docs/client-shim.mjs Normal file
View file

@ -0,0 +1,87 @@
// Dirty browser window shim
import * as DOM from '../client/dom'
document = {
createElement: x=>({
ownerDocument: document,
addEventListener: ()=>{},
style: {},
contentWindow: {},
nodeName: '',
childNodes: [],
setAttribute: ()=>{},
appendChild: ()=>{},
lastChild: {},
toString: ()=>' ',
removeChild: ()=>{},
contentWindow: {
document: {
open: ()=>{},
close: ()=>{},
write: ()=>{},
}
}
}),
getElementById: ()=>document.createElement(),
createTextNode: x=>({
nodeValue: '',
nodeName: '',
childNodes: [],
setAttribute: ()=>{},
appendChild: ()=>{},
lastChild: {},
toString: ()=>' '
}),
createElementNS: x=>[],
addEventListener: ()=>{},
createRange: ()=>{
return {
createContextualFragment:()=>{return {
firstChild: {
querySelectorAll: x=>[]
}
}},
selectNode: ()=>{}
}
},
body: {
appendChild: ()=>{},
addEventListener: ()=>{}
},
location: {},
documentElement: {
appendChild: ()=>{},
removeChild: ()=>{}
}
}
window = {
screen: {width: 800, height: 600},
addEventListener: ()=>{},
location: {},
Image: Function,
document: document,
navigator: {
platform:'',
userAgent: ''
},
NodeList: Array,
WebSocket: Object,
localStorage: {
getItem(){return null}
},
sessionStorage: {
getItem(){return null},
setItem(){},
},
MutationObserver: class MutationObserver{},
ELECTRON_NOGPU: false,
CANVAS_FRAMERATE: 1,
LANG: 'en',
ENV: {id: ''},
IP: '',
DOM
}
Object.assign(global, window)