@lincyaw/workspace 1.0.0-rc.7 → 1.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/node/build.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/workspace",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.8",
|
|
4
4
|
"description": "Presmium's workspace service (presmium serve): documents, their history, reviews and the workspace site",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"image-size": "2.0.4",
|
|
34
34
|
"mime-types": "3.0.2",
|
|
35
35
|
"yaml": "^2.9.1",
|
|
36
|
-
"@lincyaw/
|
|
37
|
-
"@lincyaw/
|
|
38
|
-
"@lincyaw/
|
|
36
|
+
"@lincyaw/compiler": "1.0.0-rc.8",
|
|
37
|
+
"@lincyaw/kernel": "1.0.0-rc.8",
|
|
38
|
+
"@lincyaw/server": "1.0.0-rc.8"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/mime-types": "^3.0.1",
|
|
42
|
-
"@lincyaw/mcp": "1.0.0-rc.
|
|
42
|
+
"@lincyaw/mcp": "1.0.0-rc.8"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/node/build.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cpSync, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
-
import { join, resolve } from 'node:path'
|
|
2
|
+
import { isAbsolute, join, resolve } from 'node:path'
|
|
3
3
|
import { build, Compiler } from '@lincyaw/compiler'
|
|
4
4
|
import type { Compilation, RunStats } from '@lincyaw/compiler'
|
|
5
5
|
import { errorMessage, isRecord } from '@lincyaw/kernel'
|
|
@@ -23,7 +23,7 @@ export async function buildWorkspace(root: string, options: { outDir?: string, b
|
|
|
23
23
|
const forms: { dir: string, compilation: Compilation, to: string[] }[] = []
|
|
24
24
|
for (const document of found) {
|
|
25
25
|
const compilation = await new Compiler(join(config.root, document.entry), { bundled: options.bundled, settings: config.settings }).compile({ pruneCache: true })
|
|
26
|
-
const to = presentations(compilation, `${base}${urlPath(document.dir)}
|
|
26
|
+
const to = presentations(compilation, `${base}${urlPath(document.dir)}/`, siteLook(config.site, config.root))
|
|
27
27
|
if (to.length > 0) forms.push({ dir: document.dir, compilation, to })
|
|
28
28
|
const translated = await siteTranslations(compilation)
|
|
29
29
|
findings.push(...compilation.doc.diagnostics, ...translated.findings)
|
|
@@ -57,6 +57,12 @@ export async function buildWorkspace(root: string, options: { outDir?: string, b
|
|
|
57
57
|
|
|
58
58
|
const PRESENTATIONS = ['slides', 'lecture']
|
|
59
59
|
|
|
60
|
+
/** The site's theme and its parameters, for its presentations to look like its pages; a theme directory made absolute. */
|
|
61
|
+
function siteLook(site: Record<string, unknown>, root: string): Record<string, unknown> {
|
|
62
|
+
const theme = typeof site.theme === 'string' && (site.theme.startsWith('.') || isAbsolute(site.theme)) ? resolve(root, site.theme) : site.theme
|
|
63
|
+
return { ...theme !== undefined ? { theme } : {}, ...isRecord(site.params) ? { params: site.params } : {} }
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
const urlPath = (dir: string) => dir.split('/').map(encodeURIComponent).join('/')
|
|
61
67
|
|
|
62
68
|
/**
|
|
@@ -76,11 +82,11 @@ function shareSlidesApp(slides: string, slidesBase: string, outDir: string, base
|
|
|
76
82
|
* The presentation forms a document asks for (`metadata.renderers.slides` or `lecture`), set to be served below its
|
|
77
83
|
* pages at `prefix`: the slides at `slides/`, and the web pages and the slides linked to each other.
|
|
78
84
|
*/
|
|
79
|
-
function presentations(compilation: Compilation, prefix: string): string[] {
|
|
85
|
+
function presentations(compilation: Compilation, prefix: string, look: Record<string, unknown>): string[] {
|
|
80
86
|
const { renderers } = compilation.doc.config
|
|
81
87
|
const to = PRESENTATIONS.filter(form => renderers[form] !== undefined)
|
|
82
88
|
if (to.length === 0) return to
|
|
83
|
-
if (to.includes('slides')) renderers.slides = { ...isRecord(renderers.slides) ? renderers.slides : {}, base: `${prefix}slides/` }
|
|
89
|
+
if (to.includes('slides')) renderers.slides = { ...look, ...isRecord(renderers.slides) ? renderers.slides : {}, base: `${prefix}slides/` }
|
|
84
90
|
const settings = compilation.doc.config.presmium ??= {}
|
|
85
91
|
const web = isRecord(settings['presmium.web']) ? settings['presmium.web'] : {}
|
|
86
92
|
settings['presmium.web'] = { ...web, webUrl: prefix, ...to.includes('slides') ? { slidesUrl: `${prefix}slides/` } : {} }
|