chalk-talk 0.13.0 → 0.14.0
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/README.md +1 -1
- package/assets/player.html +3 -3
- package/embed-mermaid.js +1 -1
- package/embed.js +5 -5
- package/kit/SKILL.template.md +55 -0
- package/kit/browser.mjs +181 -0
- package/kit/format.check.ts +22 -0
- package/kit/format.ts +37 -0
- package/kit/page.mjs +15 -0
- package/kit/tools/audit.mjs +42 -0
- package/kit/tools/checks.mjs +67 -0
- package/kit/tools/eval-metrics.mjs +70 -0
- package/kit/tools/gallery.mjs +30 -0
- package/kit/tools/linux-check.mjs +31 -0
- package/kit/tools/vendor.mjs +24 -0
- package/kit/tools/zip.mjs +14 -0
- package/markdown.js +1 -1
- package/mount.global.js +374 -374
- package/mount.js +1 -1
- package/package.json +4 -2
- package/player.js +4 -4
- package/scripts/browser.mjs +1 -1
- package/scripts/build.mjs +17 -5
- package/scripts/contract.mjs +1 -1
- package/scripts/mermaid.mjs +1 -1
- package/scripts/page.mjs +15 -0
package/scripts/browser.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// reads back what the page wrote in <pre id="chalk-<mode>">. It talks to the browser over the DevTools protocol on a
|
|
3
3
|
// pipe (--remote-debugging-pipe) and waits for that <pre> itself: --dump-dom hangs on some machines, the pipe does not.
|
|
4
4
|
// The browsers are tried in order; one that does not start or does not answer in time gives way to the next.
|
|
5
|
-
//
|
|
5
|
+
// Part of the skills kit (chalk-talk/kit): copied into each skill by its tools/assets.mjs. Node only, no dependency.
|
|
6
6
|
import { execFileSync, spawn } from 'node:child_process'
|
|
7
7
|
import { existsSync, mkdtempSync, readdirSync, rmSync } from 'node:fs'
|
|
8
8
|
import { createRequire } from 'node:module'
|
package/scripts/build.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { tmpdir } from 'node:os'
|
|
|
21
21
|
import { basename, dirname, join, resolve } from 'node:path'
|
|
22
22
|
import { fileURLToPath } from 'node:url'
|
|
23
23
|
import { runPages } from './browser.mjs'
|
|
24
|
+
import { fill, inline } from './page.mjs'
|
|
24
25
|
import { ChalkTextError, chaptersFor, parseChalk, PROP_ALIASES, PROP_NAMES, validateScene } from './contract.mjs'
|
|
25
26
|
import { syntaxForLine, syntaxForStep } from './syntax.mjs'
|
|
26
27
|
|
|
@@ -98,9 +99,7 @@ const slug = slugOf(scenes[0], sources[0])
|
|
|
98
99
|
const work = asSvg ? mkdtempSync(join(tmpdir(), 'chalk-talk-svg-')) : undefined
|
|
99
100
|
const out = work ? join(work, 'page.html') : resolve(outArg ?? join(dirname(resolve(sources[0])), `${slug}.html`))
|
|
100
101
|
const content = course ? { course: option('--title') ?? scenes[0].title, lessons: scenes } : scenes[0]
|
|
101
|
-
|
|
102
|
-
const recipe = JSON.stringify(content).replace(/</g, '\\u003c')
|
|
103
|
-
const page = readFileSync(join(here, '../assets/player.html'), 'utf8').replace('{{RECIPE}}', () => recipe)
|
|
102
|
+
const page = fill(readFileSync(join(here, '../assets/player.html'), 'utf8'), { RECIPE: inline(content) })
|
|
104
103
|
writeFileSync(out, page)
|
|
105
104
|
|
|
106
105
|
scenes.forEach((scene, k) => {
|
|
@@ -109,12 +108,17 @@ scenes.forEach((scene, k) => {
|
|
|
109
108
|
console.log(`✓ contract${who}${scene.steps.length} steps, ${chaptersFor(scene).length} chapters, ${values} values`)
|
|
110
109
|
})
|
|
111
110
|
|
|
111
|
+
// Onda C: a figure made with `define` is seen by nobody when the build passes at once (the review measures, it does
|
|
112
|
+
// not see): with one, the snapshots are made anyway and the build asks for one look at the contact sheet.
|
|
113
|
+
const defined = [...new Set(scenes.flatMap((s) => Object.keys(s.defs ?? {})))]
|
|
114
|
+
const snapshots = snapAt >= 0 || (defined.length > 0 && !asSvg)
|
|
115
|
+
|
|
112
116
|
// One browser for everything the page has to do: the review, the snapshots and the SVGs, lesson by lesson.
|
|
113
117
|
const query = (k) => (course ? `lesson=${k + 1}` : '')
|
|
114
118
|
const jobs = []
|
|
115
119
|
scenes.forEach((_, k) => {
|
|
116
120
|
if (!noReview) jobs.push({ what: 'review', k, file: out, mode: 'review', query: query(k) })
|
|
117
|
-
if (
|
|
121
|
+
if (snapshots) jobs.push({ what: 'snapshots', k, file: out, mode: 'snapshots', query: query(k) })
|
|
118
122
|
if (asSvg) jobs.push({ what: 'svg', k, file: out, mode: 'svg', query: query(k) })
|
|
119
123
|
})
|
|
120
124
|
const ran = jobs.length ? await runPages(jobs, { timeout }) : { results: [] }
|
|
@@ -137,11 +141,16 @@ else {
|
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
143
|
|
|
140
|
-
if (
|
|
144
|
+
if (snapshots) {
|
|
141
145
|
const folder = resolve(snapFolder ?? join(dirname(out), `${slug}.snapshots`))
|
|
142
146
|
for (let k = 0; k < scenes.length; k++) {
|
|
143
147
|
const r = result('snapshots', k)
|
|
144
148
|
if (!r || r.error) {
|
|
149
|
+
// asked for: an error; made only for a defined figure: said, and the page is still delivered
|
|
150
|
+
if (snapAt < 0) {
|
|
151
|
+
console.log(`• figures ${defined.length} defined (${defined.join(', ')}): no browser to draw them here — look at them in the lesson`)
|
|
152
|
+
break
|
|
153
|
+
}
|
|
145
154
|
console.error(`✗ snapshots ${r ? r.error : 'no Chrome, Chromium or Edge here to draw them (set CHROME_PATH)'}`)
|
|
146
155
|
code = 4
|
|
147
156
|
break
|
|
@@ -154,6 +163,9 @@ if (snapAt >= 0) {
|
|
|
154
163
|
const sheet = join(into, `${lesson}.contact-sheet.png`)
|
|
155
164
|
png(`${lesson}.contact-sheet.png`, r.sheet)
|
|
156
165
|
console.log(`→ ${sheet} (${r.chapters} ${r.chapters === 1 ? 'chapter' : 'chapters'} × ${r.settings} ${r.settings === 1 ? 'setting' : 'settings'})`)
|
|
166
|
+
if (defined.length && k === scenes.length - 1) {
|
|
167
|
+
console.log(`• figures ${defined.length} defined (${defined.join(', ')}): open the contact sheet once and check ${defined.length === 1 ? 'it reads' : 'they read'} right`)
|
|
168
|
+
}
|
|
157
169
|
}
|
|
158
170
|
}
|
|
159
171
|
|
package/scripts/contract.mjs
CHANGED