forked from jan/psslides
- thumbnails: compile the project stylesheet once per rebuild and feed it into the layout sandbox, compose each tile like the runtime does (<section data-ps-slide> around the slide), and show example HTML on the global tile instead of another real slide's content. - worker: less compiles off the main thread in less-worker; a side-effect module shims window/document and disables the browser build's page auto-init, and compilation falls back inline if the worker can't start. - code-to-element: wrap styles[] entries in <style> blocks - raw CSS text in the iframe head fell into <body> and rendered as literal garbage.
14 lines
820 B
TypeScript
14 lines
820 B
TypeScript
// less' browser build runs a page auto-init while its module loads: it
|
|
// reaches for `window`, copies any `window.less` config, then — unless told
|
|
// otherwise — hides `<body>` and rescans the document's stylesheets. A worker
|
|
// has none of that, so bind `window` to the worker scope, stub the single
|
|
// `document` probe the init makes (null-safe downstream), and pre-set
|
|
// `onReady: false` so init stops right after building the compiler.
|
|
// The worker imports this for side effects before `less`, so ESM evaluation
|
|
// order guarantees the shim exists by the time the auto-init runs.
|
|
if (typeof window === 'undefined') {
|
|
const worker = globalThis as unknown as Record<string, unknown>
|
|
worker.window = worker
|
|
worker.document = { getElementsByTagName: () => [] }
|
|
worker.less = { onReady: false }
|
|
}
|