@miragon/slidev-speaker-profiles 0.2.1 → 0.2.3
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/bin/slide-ids.mjs +4 -2
- package/package.json +5 -6
- package/stamp.mjs +16 -4
- package/state.ts +9 -0
package/bin/slide-ids.mjs
CHANGED
|
@@ -104,14 +104,16 @@ const where = row => `${rel(row.file)}:${row.start + 1}`
|
|
|
104
104
|
const name = row => row.title || '(untitled)'
|
|
105
105
|
|
|
106
106
|
if (options.mode === 'stamp') {
|
|
107
|
-
const { stamped, unwritable, total, skipped, files } = await stampSlides({ entry, also })
|
|
107
|
+
const { stamped, unwritable, total, skipped, reason, files } = await stampSlides({ entry, also })
|
|
108
108
|
if (unwritable.length) {
|
|
109
109
|
for (const row of unwritable)
|
|
110
110
|
console.error(`FAIL: ${where(row)} has no writable frontmatter block (style: ${row.style})`)
|
|
111
111
|
process.exit(1)
|
|
112
112
|
}
|
|
113
113
|
if (skipped) {
|
|
114
|
-
console.error(
|
|
114
|
+
console.error(reason === 'busy'
|
|
115
|
+
? 'slide ids: another stamping run holds the lock, nothing written'
|
|
116
|
+
: `slide ids: could not take the stamping lock (${reason}), nothing written`)
|
|
115
117
|
process.exit(1)
|
|
116
118
|
}
|
|
117
119
|
if (!stamped.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miragon/slidev-speaker-profiles",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Per-speaker slide selection for a Slidev deck several people present. Each speaker keeps their own profile file, nobody overwrites anybody, and main never changes. Slides are addressed by a stable id the shipped slide-ids CLI stamps into their frontmatter, so a selection survives retitling, reordering and renumbered chapters.",
|
|
6
6
|
"keywords": [
|
|
@@ -26,14 +26,13 @@
|
|
|
26
26
|
"node": ">=20",
|
|
27
27
|
"slidev": ">=0.48.0"
|
|
28
28
|
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@slidev/parser": "52.19.0"
|
|
31
|
-
},
|
|
32
29
|
"devDependencies": {
|
|
33
|
-
"@slidev/
|
|
30
|
+
"@slidev/parser": "52.19.1",
|
|
31
|
+
"@slidev/types": "52.19.1"
|
|
34
32
|
},
|
|
35
33
|
"peerDependencies": {
|
|
36
|
-
"
|
|
34
|
+
"@slidev/parser": "^52.0.0",
|
|
35
|
+
"vue": "3.5.43"
|
|
37
36
|
},
|
|
38
37
|
"files": [
|
|
39
38
|
"bin",
|
package/stamp.mjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* would be forgotten once.
|
|
14
14
|
*/
|
|
15
15
|
import { randomBytes } from 'node:crypto'
|
|
16
|
-
import { closeSync, existsSync, openSync, readFileSync, statSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
16
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, statSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
17
17
|
import path from 'node:path'
|
|
18
18
|
import { injectPreparserExtensionLoader, load } from '@slidev/parser/fs'
|
|
19
19
|
import { walkMarkdownFiles } from './identity.mjs'
|
|
@@ -180,12 +180,24 @@ const LOCK_STALE_MS = 60_000
|
|
|
180
180
|
* matters the other run has written the ids, and stamping is idempotent anyway.
|
|
181
181
|
*/
|
|
182
182
|
function withLock(profilesRoot, fn) {
|
|
183
|
-
const
|
|
183
|
+
const dir = path.join(profilesRoot, PROFILE_DIR)
|
|
184
|
+
const lock = path.join(dir, LOCK_NAME)
|
|
185
|
+
// The very first stamp of a deck runs before anyone has made a profile, so
|
|
186
|
+
// the directory the lock lives in may not exist yet. Creating it is not a
|
|
187
|
+
// side effect: stamping IS the deck opting in, and the profiles land here.
|
|
188
|
+
try {
|
|
189
|
+
mkdirSync(dir, { recursive: true })
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// read-only, or a file in the way. The open below reports it properly.
|
|
193
|
+
}
|
|
184
194
|
let handle
|
|
185
195
|
try {
|
|
186
196
|
handle = openSync(lock, 'wx')
|
|
187
197
|
}
|
|
188
|
-
catch {
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (error?.code !== 'EEXIST')
|
|
200
|
+
return { skipped: true, reason: error?.code ?? 'unknown', stamped: [], total: 0 }
|
|
189
201
|
// A lock left behind by a killed process must not block the deck forever.
|
|
190
202
|
try {
|
|
191
203
|
if (Date.now() - statSync(lock).mtimeMs > LOCK_STALE_MS)
|
|
@@ -193,7 +205,7 @@ function withLock(profilesRoot, fn) {
|
|
|
193
205
|
handle = openSync(lock, 'wx')
|
|
194
206
|
}
|
|
195
207
|
catch {
|
|
196
|
-
return { skipped: true, stamped: [], total: 0 }
|
|
208
|
+
return { skipped: true, reason: 'busy', stamped: [], total: 0 }
|
|
197
209
|
}
|
|
198
210
|
}
|
|
199
211
|
try {
|
package/state.ts
CHANGED
|
@@ -118,6 +118,15 @@ export function drift(currentIds: string[]) {
|
|
|
118
118
|
* So whenever the endpoint answers, its profile wins over the frontmatter.
|
|
119
119
|
*/
|
|
120
120
|
export async function loadServerState() {
|
|
121
|
+
// A built deck has no dev server and therefore no endpoint. Asking anyway
|
|
122
|
+
// costs every viewer a 404 on every load, and any tool that treats a failed
|
|
123
|
+
// request as a defect reports it - the BPM training's hub check flagged all
|
|
124
|
+
// 14 of its decks. The selection is baked into the frontmatter at build time,
|
|
125
|
+
// which is all a built deck needs.
|
|
126
|
+
if (!import.meta.env.DEV) {
|
|
127
|
+
ready.value = true
|
|
128
|
+
return
|
|
129
|
+
}
|
|
121
130
|
try {
|
|
122
131
|
const res = await fetch('/@speaker-profiles/state')
|
|
123
132
|
if (!res.ok)
|