orz-slides-browser 1.0.0 → 1.2.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/index.d.ts CHANGED
@@ -10,6 +10,12 @@ export type Kind = 'md' | 'slides' | 'paged';
10
10
  export type EditorMode = 'split' | 'editor' | 'preview';
11
11
  export type HeaderChange = string | null | { multiline: string };
12
12
  export type Ratio = '16:9' | '4:3';
13
+ /**
14
+ * (1.1, orz-markdown 2.5.0) A twin-link naming (FC-18 §8.2): per-kind file-name templates — `{stem}` once, then only
15
+ * `A-Z a-z 0-9 . _ -`, ending in `.html`, same folder — e.g. `{ slides: '{stem}.html', md: '{stem}.html' }`. A kind
16
+ * left out keeps the family name (`x.slides.md` → `x.slides.html`).
17
+ */
18
+ export type TwinNaming = Partial<Record<Kind, string>>;
13
19
 
14
20
  export interface AssembleOptions {
15
21
  /** `inline` (default) inlines the engine; `cdn` loads it from jsDelivr. */
@@ -18,6 +24,8 @@ export interface AssembleOptions {
18
24
  engineSource?: string;
19
25
  /** Resolved includes stored in `#orz-includes` exactly as given. */
20
26
  includes?: Record<string, string>;
27
+ /** (1.1) The host's twin-link naming: links to text twins point at these names, and the file keeps it (`#orz-shell` `"links"`, only when it is not the family naming). An invalid naming rejects. */
28
+ twinLinks?: TwinNaming;
21
29
  }
22
30
 
23
31
  export interface Extracted {
@@ -27,6 +35,13 @@ export interface Extracted {
27
35
  shell: string;
28
36
  delivery: string;
29
37
  includes?: Record<string, string>;
38
+ /** (1.1) The file's twin-link naming (`#orz-shell` `"links"`); absent: the family naming. */
39
+ twinLinks?: TwinNaming;
40
+ /**
41
+ * (1.1) An orz-slides 0.x file: `text` is what the Node `upgrade` writes (the deck block, title, metadata and the
42
+ * theme 0.x showed moved into one header; a fresh uid when it had none), `shell` is ''; what was converted.
43
+ */
44
+ legacy?: { version: string | null; notes: string[] };
30
45
  }
31
46
 
32
47
  export interface Lint { level: 'error' | 'warning' | 'info'; code: string; message: string; line?: number; from?: number; to?: number; next?: string }
@@ -83,6 +98,8 @@ export interface EditorOptions {
83
98
  includes?: Record<string, string>;
84
99
  /** FC-19 §3 `fileName`: the suggested file name of saves without `hooks.save` (picker and download), e.g. `talk.slides.html`; default `document.slides.html`. */
85
100
  fileName?: string;
101
+ /** (1.1) FC-19 §3 `twinLinks`: your twin-link naming — the preview and the live slide name links to text twins so, and a save without `hooks.save` stores it in the file. */
102
+ twinLinks?: TwinNaming;
86
103
  }
87
104
 
88
105
  export type SaveVia = 'hook' | 'host' | 'file' | 'download';
@@ -183,7 +200,8 @@ export interface Editor {
183
200
  export interface RenderPreviewOptions {
184
201
  fetchInclude?(target: string): Promise<string | null>;
185
202
  includes?: Readonly<Record<string, string>>;
186
- twinLinks?: boolean;
203
+ /** `false`: links as written; default `true` (links to text twins point at their `.slides.html` / `.md.html` form); (1.1) a naming: the host's names. */
204
+ twinLinks?: boolean | TwinNaming;
187
205
  /**
188
206
  * A whole HTML document (the header's slide theme and the flattened
189
207
  * preview's styles inline, KaTeX and highlight.js stylesheets linked, the
@@ -209,6 +227,42 @@ export interface SlideTheme {
209
227
  derivedFrom: string | null;
210
228
  sectionNumbers: 'plain' | 'roman' | '01' | 'none';
211
229
  description: string;
230
+ /** (1.1) The slide's page colour (a picker's swatch). */
231
+ paper: string;
232
+ /** (1.1) The theme's signature colour (a picker's swatch). */
233
+ accent: string;
234
+ }
235
+
236
+ /** (1.1) One link of a text (`linkTargets`, orz-markdown 2.5.0). */
237
+ export interface LinkTarget {
238
+ /** The target as the renderer writes it (a Markdown destination percent-encoded; a raw `<a href>` as written). */
239
+ href: string;
240
+ /** 1-based line of the whole text (header lines counted). */
241
+ line: number;
242
+ /** `twin`: a relative link to a text twin; `asset`: another relative path; `other`: an absolute URL, `//host`, a fragment or query. */
243
+ kind: 'twin' | 'asset' | 'other';
244
+ image: boolean;
245
+ raw: boolean;
246
+ }
247
+
248
+ /** (1.1) Options of `printDeck`. */
249
+ export interface PrintDeckOptions {
250
+ /** Each page: the slide over its speaker notes ("Print with notes"). */
251
+ notes?: boolean;
252
+ /** Resolved includes (target as written → text). */
253
+ includes?: Readonly<Record<string, string>>;
254
+ /** An include `includes` lacks (a URL): text or null — your trust policy. */
255
+ fetchInclude?(target: string): Promise<string | null>;
256
+ /** Your twin-link naming. */
257
+ twinLinks?: TwinNaming;
258
+ /** Your CSP nonce: stamped on the stylesheets of the measuring frame and the print document, and on the print frame's script. */
259
+ nonce?: string;
260
+ /** The page (default `document`). */
261
+ document?: Document;
262
+ /** How long the print frame waits for the document's fonts before printing anyway (ms). */
263
+ readyTimeoutMs?: number;
264
+ /** Told what print had to cut (a slide past the fit floor, notes past their page), in the reader's words. */
265
+ onCut?(message: string): void;
212
266
  }
213
267
 
214
268
  /** A deck template (`TEMPLATES`, `newDocument({ template })`). */
@@ -224,6 +278,10 @@ export type LayoutOp =
224
278
  | { type: 'swap'; a: string; b: string }
225
279
  | { type: 'move-content'; from: string; to: string }
226
280
  | { type: 'ensure-region'; name: string }
281
+ /** (1.1) An empty box (a region, `notes` or `footer`) made ready to write in: a place and an empty line under its marker; `select` is that line. */
282
+ | { type: 'open'; name: string }
283
+ /** (1.1) The same for an empty float. */
284
+ | { type: 'open-float'; index: number }
227
285
  | { type: 'float-add'; box?: { left: number; top: number; w: number; h: number }; covers?: boolean }
228
286
  | { type: 'float-geom'; index: number; box: Partial<{ left: number; top: number; w: number; h: number }>; from?: { left: number; top: number; w: number; h: number } }
229
287
  | { type: 'float-delete'; index: number }
@@ -277,6 +335,24 @@ export declare function readDocument(text: string): DocumentInfo;
277
335
  export declare function renderPreview(text: string, options?: RenderPreviewOptions): Promise<string>;
278
336
  export declare function mountEditor(element: HTMLElement, options: EditorOptions): Editor;
279
337
  export declare function editHeader(text: string, changes: Readonly<Record<string, HeaderChange>>): string;
338
+ /** (1.1) The include targets of a text's body, as written, in order, without repeats (orz-markdown 2.5.0, browser-safe). */
339
+ export declare function includeTargets(text: string, directives?: readonly string[]): string[];
340
+ /** (1.1) The links of a text as the parser reads them, with line and kind (orz-markdown 2.5.0): for a site builder's link check. */
341
+ export declare function linkTargets(text: string): LinkTarget[];
342
+ /**
343
+ * (1.1) orz-markdown's `printDocument`: print a whole HTML document in a hidden `srcdoc` frame sandboxed
344
+ * `allow-scripts allow-modals` (never your page); `true` once printed, `false` when the frame said nothing in time.
345
+ */
346
+ export declare function printDocument(html: string, options?: { document?: Document; nonce?: string; readyTimeoutMs?: number; title?: string }): Promise<boolean>;
347
+ /**
348
+ * (1.1) Print a deck from your page as an assembled file's Print does — one slide per page at the slide's size,
349
+ * every fragment shown, each slide fitted, cuts marked; `notes: true` as "Print with notes". The recipe for the
350
+ * editor's `print` event: `editor.on('print', () => printDeck(editor.getText(), { nonce }))`. `false` when a print
351
+ * of this page is still running or the frame said nothing in time.
352
+ */
353
+ export declare function printDeck(text: string, options?: PrintDeckOptions): Promise<boolean>;
354
+ /** (1.1) A CSS `background` for a theme picker's dot: the slide theme's page and signature colours, split diagonally. */
355
+ export declare function themeSwatch(id: string | null | undefined): string;
280
356
  /** The 14 slide themes a header `theme` may name. */
281
357
  export declare const THEMES: readonly SlideTheme[];
282
358
  export declare const DEFAULT_THEME: string;
@@ -348,6 +424,12 @@ export interface OrzCarrierApi {
348
424
  readDocument: typeof readDocument;
349
425
  mountEditor: typeof mountEditor;
350
426
  renderPreview: typeof renderPreview;
427
+ /** (1.1) The kit's browser-safe targets of a text. */
428
+ includeTargets: typeof includeTargets;
429
+ linkTargets: typeof linkTargets;
430
+ /** (1.1) Printing from an app (D-114). */
431
+ printDocument: typeof printDocument;
432
+ printDeck: typeof printDeck;
351
433
  /** orz-slides' extension: the parser and the layout ops. */
352
434
  layout: LayoutApi;
353
435
  /** The booted file's handle in an assembled `.slides.html` (the IIFE only); null elsewhere. Not in the ES module's `OrzCarrier`. */