@5cover/lectern 0.1.0 → 0.2.1

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/index.js +7 -1
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/client/entry.js +119 -0
  5. package/dist/client/entry.js.map +1 -0
  6. package/dist/client/graph-CUYNIBIQ.js +407 -0
  7. package/dist/client/graph-CUYNIBIQ.js.map +1 -0
  8. package/dist/index.js +3 -4
  9. package/dist/index.js.map +1 -1
  10. package/package.json +4 -5
  11. package/src/cli/build.ts +0 -79
  12. package/src/cli/dev.ts +0 -58
  13. package/src/cli/index.ts +0 -126
  14. package/src/cli/paths.ts +0 -81
  15. package/src/cli/pdf.ts +0 -70
  16. package/src/cli/render.ts +0 -40
  17. package/src/cli/rules.ts +0 -31
  18. package/src/cli/serve.ts +0 -112
  19. package/src/client/entry.ts +0 -170
  20. package/src/client/graph.tsx +0 -207
  21. package/src/components/Deck.tsx +0 -19
  22. package/src/components/InfographDiscovery.tsx +0 -51
  23. package/src/components/layout.tsx +0 -145
  24. package/src/components/mechanics.tsx +0 -74
  25. package/src/components/util.ts +0 -12
  26. package/src/index.ts +0 -37
  27. package/src/infographDiscovery.ts +0 -188
  28. package/src/infographDiscoveryView.tsx +0 -202
  29. package/src/jsx-runtime.ts +0 -4
  30. package/src/profiles/engie/assets/engie-logo-dark.svg +0 -1
  31. package/src/profiles/engie/assets/engie-logo-white.svg +0 -6
  32. package/src/profiles/engie/assets.d.ts +0 -4
  33. package/src/profiles/engie/atoms.tsx +0 -203
  34. package/src/profiles/engie/index.ts +0 -44
  35. package/src/profiles/engie/profile.ts +0 -132
  36. package/src/profiles/engie/slides.tsx +0 -230
  37. package/src/profiles/index.ts +0 -30
  38. package/src/profiles/types.ts +0 -49
  39. package/src/render/renderDeck.tsx +0 -74
  40. package/src/render/template.ts +0 -68
  41. package/src/types.ts +0 -53
  42. /package/{src → dist}/profiles/engie/engie.css +0 -0
@@ -1,230 +0,0 @@
1
- import type { ComponentChildren } from 'preact'
2
- import type { StyleEscapeHatch, Transition } from '../../types'
3
- import { cx } from '../../components/util'
4
- import engieLogoWhite from './assets/engie-logo-white.svg'
5
-
6
- /*
7
- * ENGIE slide components — the layout philosophy of the ENGIE PowerPoint
8
- * template: navy cover with a large white title, restrained navy content
9
- * titles, navy section dividers, a numbered summary. Styling lives in engie.css.
10
- */
11
-
12
- interface SlideBaseProps extends StyleEscapeHatch {
13
- background?: string
14
- transition?: Transition
15
- autoAnimate?: boolean
16
- attrs?: Record<string, string | number | boolean>
17
- id?: string
18
- }
19
-
20
- function sectionAttrs(p: SlideBaseProps) {
21
- return {
22
- id: p.id,
23
- 'data-background-color': p.background,
24
- 'data-transition': p.transition,
25
- 'data-auto-animate': p.autoAnimate ? true : undefined,
26
- style: p.style,
27
- ...(p.attrs ?? {}),
28
- }
29
- }
30
-
31
- /**
32
- * ENGIE Fluid brand gradient ray — inlined as an SVG (not a CSS background) so
33
- * Reveal scales the SVG uniformly with the slide. The profile anchors it to the
34
- * canvas edge as a genuine full-bleed visual rather than a painted background.
35
- *
36
- * Each instance gets a UNIQUE gradient id: reveal shows one slide at a time and
37
- * hides the rest with `display:none`. A shared id makes every `url(#id)` resolve
38
- * to the first definition in the document (on the cover), and Chrome fails to
39
- * resolve that paint server across the hidden-cover boundary, so section-slide
40
- * rays paint transparent. Unique ids keep each ray's paint server on its own slide.
41
- */
42
- let rayId = 0
43
-
44
- function BrandLogo({ height }: { height?: number }) {
45
- return <img class="lectern-brand-logo" src={engieLogoWhite} height={height} alt="ENGIE" />
46
- }
47
-
48
- function Ray() {
49
- const gradientId = `present_gradient_ray_${rayId++}`
50
- const width = 720,
51
- height = 26
52
- return (
53
- <svg
54
- class="lectern-ray"
55
- width={width}
56
- height={height}
57
- viewBox={`0 0 ${width} ${height}`}
58
- preserveAspectRatio="none"
59
- fill="none"
60
- aria-hidden="true"
61
- xmlns="http://www.w3.org/2000/svg">
62
- <rect width={width} height={height} fill={`url(#${gradientId})`} />
63
- <defs>
64
- <linearGradient id={gradientId} x1="0" y1="0" x2="1" y2="0">
65
- <stop stop-color="#00BCFD" />
66
- <stop offset="1" stop-color="#23D2B5" />
67
- </linearGradient>
68
- </defs>
69
- </svg>
70
- )
71
- }
72
-
73
- /** Confidentiality level — required by the ENGIE template on every deck. */
74
- export type Confidentiality = 'Non-confidentiel' | 'Confidentiel' | 'Strictement confidentiel'
75
-
76
- /** Content slide: 25pt navy title (top-left, no underline), optional subtitle, body. */
77
- export interface SlideProps extends SlideBaseProps {
78
- /** Slide title (~25pt navy). */
79
- heading?: ComponentChildren
80
- /** Semantic mark rendered in the top-right corner of the slide header. */
81
- logo?: ComponentChildren
82
- /** Second-level title, rendered under the heading (use sparingly). */
83
- subtitle?: ComponentChildren
84
- /** Small uppercase eyebrow above the heading. */
85
- kicker?: ComponentChildren
86
- children?: ComponentChildren
87
- }
88
-
89
- export function Slide({ heading, logo, subtitle, kicker, children, class: cls, ...rest }: SlideProps) {
90
- return (
91
- <section class={cx('lectern-slide', cls)} {...sectionAttrs(rest)}>
92
- <div class="lectern-slide-content">
93
- <header class="lectern-slide-header">
94
- <div class="lectern-slide-header-copy">
95
- {kicker ? <p class="lectern-kicker">{kicker}</p> : null}
96
- {heading ? <h2 class="lectern-heading">{heading}</h2> : null}
97
- {subtitle ? <p class="lectern-subtitle">{subtitle}</p> : null}
98
- </div>
99
- {logo ? <aside class="lectern-slide-logo">{logo}</aside> : null}
100
- </header>
101
- <main class="lectern-slide-main">{children}</main>
102
- </div>
103
- </section>
104
- )
105
- }
106
-
107
- /** Cover: navy full-bleed, large white title, white logo, confidentiality tag. */
108
- export interface TitleSlideProps extends SlideBaseProps {
109
- title: ComponentChildren
110
- subtitle?: ComponentChildren
111
- author?: ComponentChildren
112
- date?: ComponentChildren
113
- /** Small eyebrow above the title (e.g. entity / department). */
114
- eyebrow?: ComponentChildren
115
- /** Confidentiality level shown bottom-right (ENGIE requirement). */
116
- confidentiality?: Confidentiality
117
- /** Full-width panel that occupies the remaining lower part of the cover. */
118
- footer?: ComponentChildren
119
- children?: ComponentChildren
120
- logoHeight?: number
121
- }
122
-
123
- export function TitleSlide({
124
- title,
125
- subtitle,
126
- author,
127
- date,
128
- eyebrow,
129
- confidentiality,
130
- footer,
131
- children,
132
- class: cls,
133
- logoHeight,
134
- ...rest
135
- }: TitleSlideProps) {
136
- return (
137
- <section
138
- class={cx('lectern-title-slide', footer ? 'has-footer' : false, cls)}
139
- {...sectionAttrs({ background: 'var(--lectern-navy)', ...rest })}>
140
- <div class="lectern-title-main">
141
- <div class="lectern-title-content">
142
- <BrandLogo height={logoHeight} />
143
- {eyebrow ? <p class="lectern-eyebrow">{eyebrow}</p> : null}
144
- <h1 class="lectern-title">{title}</h1>
145
- </div>
146
- <Ray />
147
- <div class="lectern-title-meta">
148
- {subtitle ? <p class="lectern-subtitle">{subtitle}</p> : null}
149
- {(author || date) && (
150
- <p class="lectern-byline">
151
- {author ? <span class="lectern-author">{author}</span> : null}
152
- {author && date ? <span class="lectern-sep"> · </span> : null}
153
- {date ? <span class="lectern-date">{date}</span> : null}
154
- </p>
155
- )}
156
- {children}
157
- </div>
158
- </div>
159
- {confidentiality ? <p class="lectern-confidentiality">{confidentiality}</p> : null}
160
- {footer ? <div class="lectern-title-footer">{footer}</div> : null}
161
- </section>
162
- )
163
- }
164
-
165
- /** Full-bleed navy section divider: number + white title + white logo. */
166
- export interface SectionSlideProps extends SlideBaseProps {
167
- title: ComponentChildren
168
- subtitle?: ComponentChildren
169
- /** Section number, e.g. "02". */
170
- number?: ComponentChildren
171
- logoHeight?: number
172
- }
173
-
174
- export function SectionSlide({ title, subtitle, number, class: cls, logoHeight, ...rest }: SectionSlideProps) {
175
- return (
176
- <section
177
- class={cx('lectern-section-slide', cls)}
178
- {...sectionAttrs({ background: 'var(--lectern-section-bg)', ...rest })}>
179
- <div class="lectern-section-main">
180
- <div class="lectern-section-content">
181
- <BrandLogo height={logoHeight} />
182
- {number ? <p class="lectern-section-number">{number}</p> : null}
183
- <h2 class="lectern-section-title">{title}</h2>
184
- </div>
185
- <Ray />
186
- {subtitle ? <p class="lectern-section-subtitle">{subtitle}</p> : null}
187
- </div>
188
- </section>
189
- )
190
- }
191
-
192
- /** A summary / agenda slide: auto-numbered chapters (01, 02, …) in a grid. */
193
- export interface SummaryItem {
194
- title: ComponentChildren
195
- /** Optional complementary line under the chapter title. */
196
- hint?: ComponentChildren
197
- }
198
-
199
- export interface SummaryProps extends SlideBaseProps {
200
- items: SummaryItem[]
201
- /** Slide heading (defaults to "Sommaire"). */
202
- heading?: ComponentChildren
203
- children?: ComponentChildren
204
- }
205
-
206
- export function Summary({ items, heading = 'Sommaire', class: cls, children, ...rest }: SummaryProps) {
207
- return (
208
- <section class={cx('lectern-slide lectern-summary-slide', cls)} {...sectionAttrs(rest)}>
209
- <div class="lectern-slide-content">
210
- <header class="lectern-slide-header">
211
- <div class="lectern-slide-header-copy">
212
- <h2 class="lectern-heading">{heading}</h2>
213
- </div>
214
- </header>
215
- <main class="lectern-slide-main">
216
- <ol class="lectern-summary">
217
- {items.map((it, i) => (
218
- <li class="lectern-summary-item">
219
- <span class="lectern-summary-num">{String(i + 1).padStart(2, '0')}</span>
220
- <span class="lectern-summary-title">{it.title}</span>
221
- {it.hint ? <span class="lectern-summary-hint">{it.hint}</span> : null}
222
- </li>
223
- ))}
224
- </ol>
225
- </main>
226
- </div>
227
- {children}
228
- </section>
229
- )
230
- }
@@ -1,30 +0,0 @@
1
- import type { Profile } from './types'
2
- import { engie } from './engie/profile'
3
-
4
- /** All registered profiles, keyed by name. */
5
- export const profiles: Record<string, Profile> = {
6
- engie,
7
- }
8
-
9
- /** The default profile applied when a deck doesn't name one. */
10
- export const DEFAULT_PROFILE = 'engie'
11
-
12
- /** Look up a profile by name; returns undefined if unknown. */
13
- export function getProfile(name: string | undefined): Profile | undefined {
14
- return profiles[name ?? DEFAULT_PROFILE]
15
- }
16
-
17
- /** Names of all registered profiles. */
18
- export function profileNames(): string[] {
19
- return Object.keys(profiles)
20
- }
21
-
22
- /** Resolve a deck's `profile` (object or built-in name) to a profile; throws on an unknown name. */
23
- export function resolveProfile(profile: string | Profile | undefined): Profile {
24
- if (typeof profile === 'object') return profile
25
- const found = getProfile(profile)
26
- if (!found) throw new Error(`Unknown profile: "${profile}". Available: ${profileNames().join(', ')}`)
27
- return found
28
- }
29
-
30
- export type { Profile, Rule, RuleGroup, RuleSeverity } from './types'
@@ -1,49 +0,0 @@
1
- import { RevealConfig } from 'reveal.js'
2
-
3
- /**
4
- * A profile is more than a theme: it bundles the *presentation* (CSS + reveal
5
- * configuration) AND the *doctrine* (rules describing what a well-formed deck
6
- * looks like) for a given house style — e.g. ENGIE / Fluid.
7
- *
8
- * Today profiles change look and configuration; rules are natural-language
9
- * guidance surfaced by `lectern rules <profile>`. A future `check` hook could
10
- * make a subset of them machine-verifiable (linting) without changing this shape.
11
- */
12
- export interface Profile {
13
- /** Stable identifier used on the CLI and as the `.profile-<name>` root class. */
14
- name: string
15
- /** Human-readable name for display. */
16
- label: string
17
- /** One-line description of the house style. */
18
- description: string
19
- /** reveal.js config defaults merged under any per-deck overrides. */
20
- reveal?: RevealConfig
21
- /**
22
- * The look: a stylesheet bundled into the deck's client after lectern's core
23
- * CSS (reveal.js, code highlighting). Any specifier Vite can import from the
24
- * project: a file URL (`new URL('./brand.css', import.meta.url)`), an
25
- * absolute path, or a package path (`'my-brand/brand.css'`). Scope its rules
26
- * under `.reveal.profile-<name>`.
27
- */
28
- stylesheet?: string | URL
29
- /** The doctrine: what a well-formed deck in this profile looks like. */
30
- rules: RuleGroup[]
31
- }
32
-
33
- /** How strongly a rule is held. Descriptive today; a linter could act on it later. */
34
- export type RuleSeverity = 'must' | 'should' | 'advisory'
35
-
36
- export interface Rule {
37
- /** Stable kebab-case id, e.g. "title-max-lines". */
38
- id: string
39
- /** Natural-language statement of the rule. Valuable on its own. */
40
- statement: string
41
- /** How strongly it is held. */
42
- severity: RuleSeverity
43
- }
44
-
45
- /** Rules grouped by theme (Structure, Colours, Typography, …). */
46
- export interface RuleGroup {
47
- title: string
48
- rules: Rule[]
49
- }
@@ -1,74 +0,0 @@
1
- import { Fragment, h, type VNode } from 'preact'
2
- import { render } from 'preact-render-to-string'
3
- import { isDeck } from '../components/Deck'
4
- import { DEFAULT_PROFILE, resolveProfile } from '../profiles'
5
- import type { Profile } from '../profiles/types'
6
- import type { DeckMeta, ResolvedDeckMeta } from '../types'
7
- import { htmlShell } from './template'
8
-
9
- export interface RenderOptions {
10
- /** Script tag(s) to inject before </body> (e.g. the bundled client entry). */
11
- bodyScripts?: string
12
- /** Extra tags for <head> (e.g. hashed CSS from a bundler). */
13
- headTags?: string
14
- /** Override/merge deck metadata. */
15
- meta?: Partial<Omit<DeckMeta, 'profile'>>
16
- }
17
-
18
- const DEFAULT_META: Required<Pick<DeckMeta, 'title' | 'profile' | 'transition'>> = {
19
- title: 'Untitled deck',
20
- profile: DEFAULT_PROFILE,
21
- transition: 'slide',
22
- }
23
-
24
- /**
25
- * Turn a deck VNode into its metadata, its resolved profile and the inner
26
- * `.slides` HTML. Reads deck-level props from a top-level `<Deck>`; if the
27
- * export is a raw fragment/array of slides, sensible defaults are used.
28
- */
29
- export function renderDeck(deck: VNode | VNode[]): { meta: ResolvedDeckMeta; profile: Profile; slidesHtml: string } {
30
- let meta: DeckMeta = { ...DEFAULT_META }
31
- let slides: unknown = deck
32
-
33
- // Unwrap one functional layer so a profile-bound <Deck> (which returns a
34
- // core <Deck> vnode) is recognised.
35
- let root = deck as VNode
36
- if (!Array.isArray(deck) && !isDeck(deck) && typeof (deck as VNode)?.type === 'function') {
37
- try {
38
- const inner = (deck as VNode).type as (p: unknown) => VNode
39
- const unwrapped = inner((deck as VNode).props)
40
- if (unwrapped && isDeck(unwrapped)) root = unwrapped
41
- } catch {
42
- /* fall back to treating `deck` as slides */
43
- }
44
- }
45
-
46
- if (!Array.isArray(deck) && isDeck(root)) {
47
- const { children, ...rest } = root.props
48
- meta = { ...DEFAULT_META, ...rest }
49
- slides = children
50
- }
51
-
52
- // Merge the profile's reveal defaults under any per-deck overrides.
53
- const profile = resolveProfile(meta.profile)
54
- const resolved: ResolvedDeckMeta = {
55
- ...meta,
56
- profile: profile.name,
57
- reveal: { ...profile.reveal, ...meta.reveal },
58
- }
59
-
60
- // Wrap in a Fragment so arrays / multiple roots render cleanly.
61
- const slidesHtml = render(h(Fragment, null, slides as never))
62
- return { meta: resolved, profile, slidesHtml }
63
- }
64
-
65
- /** Full standalone HTML document for a deck. */
66
- export function renderToHtml(deck: VNode | VNode[], options: RenderOptions = {}): string {
67
- const { meta, slidesHtml } = renderDeck(deck)
68
- return htmlShell({
69
- meta: { ...meta, ...options.meta },
70
- slidesHtml,
71
- bodyScripts: options.bodyScripts ?? '',
72
- headTags: options.headTags ?? '',
73
- })
74
- }
@@ -1,68 +0,0 @@
1
- import type { ResolvedDeckMeta } from '../types'
2
-
3
- export interface ShellInput {
4
- meta: ResolvedDeckMeta
5
- slidesHtml: string
6
- /**
7
- * Injected before `</body>`
8
- *
9
- * Typically the bundled client entry script.
10
- */
11
- bodyScripts: string
12
- /**
13
- * Injected into `<head>`
14
- *
15
- * Extra CSS/link tags.
16
- */
17
- headTags: string
18
- }
19
-
20
- function escapeHtml(s: string): string {
21
- return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
22
- }
23
-
24
- /** Serialize deck config for the client, safe to embed in a `<script>`. */
25
- function configScript(meta: ResolvedDeckMeta): string {
26
- const config = {
27
- profile: meta.profile,
28
- transition: meta.transition ?? 'slide',
29
- reveal: meta.reveal ?? {},
30
- }
31
- // Escape `<` to avoid breaking out of the script element.
32
- const json = JSON.stringify(config).replace(/</g, '\\u003c')
33
- return `<script type="application/json" id="lectern-config">${json}</script>`
34
- }
35
-
36
- function footer(meta: ResolvedDeckMeta): string {
37
- if (!meta.footer && !meta.author) return ''
38
- const parts: string[] = []
39
- if (meta.author) parts.push(`<span class="lectern-footer-brand">${escapeHtml(meta.author)}</span>`)
40
- if (meta.footer) parts.push(`<span>${escapeHtml(meta.footer)}</span>`)
41
- return `<div class="lectern-footer">${parts.join(`<span class="lectern-sep"> · </span>`)}</div>`
42
- }
43
-
44
- /**
45
- * Assemble the complete HTML document. The client entry (bundled by the CLI)
46
- * imports all CSS/JS, so the <head> here stays minimal.
47
- */
48
- export function htmlShell({ meta, slidesHtml, bodyScripts, headTags }: ShellInput): string {
49
- return `<!doctype html>
50
- <html lang="fr">
51
- <head>
52
- <meta charset="utf-8" />
53
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
54
- <title>${escapeHtml(meta.title)}</title>
55
- ${headTags}
56
- </head>
57
- <body>
58
- <div class="reveal profile-${meta.profile}">
59
- <div class="slides">
60
- ${slidesHtml}
61
- </div>
62
- ${footer(meta)}
63
- </div>
64
- ${configScript(meta)}
65
- ${bodyScripts}
66
- </body>
67
- </html>`
68
- }
package/src/types.ts DELETED
@@ -1,53 +0,0 @@
1
- import type { ComponentChildren, VNode } from 'preact'
2
- import { RevealConfig } from 'reveal.js'
3
- import type { Profile } from './profiles/types'
4
-
5
- /** reveal.js slide transition names. */
6
- export type Transition = 'none' | 'fade' | 'slide' | 'convex' | 'concave' | 'zoom'
7
-
8
- /**
9
- * Names of the house-style profiles shipped with `lectern`, usable as a
10
- * shorthand for their `Profile` object. Currently only ENGIE / Fluid.
11
- */
12
- export type ProfileName = 'engie'
13
-
14
- /** Common props accepted by every visual component: a one-off escape hatch. */
15
- export interface StyleEscapeHatch {
16
- /** Extra CSS class(es) appended after the component's own classes. */
17
- class?: string
18
- /** Inline style for a single-slide tweak. Prefer Fluid tokens where possible. */
19
- style?: string | Record<string, string | number>
20
- }
21
-
22
- /** Top-level deck metadata, read by the renderer to build the HTML shell. */
23
- export interface DeckMeta {
24
- /** Deck title used for the document `<title>` and speaker view. */
25
- title: string
26
- /** Author / presenter name. */
27
- author?: string
28
- /** Free-form date label, e.g. "Juin 2026". */
29
- date?: string
30
- /**
31
- * House-style profile to apply (look + reveal config + rules): a `Profile`
32
- * object, yours or a built-in one, or a built-in profile's name. Defaults to "engie".
33
- */
34
- profile?: ProfileName | Profile
35
- /** Default slide transition. Defaults to "slide". */
36
- transition?: Transition
37
- /** Persistent footer text shown on every slide (e.g. confidentiality note). */
38
- footer?: string
39
- /** Extra reveal.js config, merged over the defaults. */
40
- reveal?: Partial<RevealConfig>
41
- }
42
-
43
- /** Deck metadata after rendering: the profile is resolved down to its name. */
44
- export interface ResolvedDeckMeta extends Omit<DeckMeta, 'profile'> {
45
- profile: string
46
- }
47
-
48
- export interface DeckProps extends DeckMeta {
49
- children?: ComponentChildren
50
- }
51
-
52
- /** A VNode is what every `lectern` component returns. */
53
- export type Slide = VNode
File without changes