orz-paged 0.3.0 → 0.4.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/dist/lib.d.ts CHANGED
@@ -34,7 +34,7 @@ export declare function pickDefaultTheme(themes: ThemeAsset[]): string;
34
34
  * @param theme optional theme id; when omitted (or unknown) the default theme
35
35
  * ({@link pickDefaultTheme}) drives the picker's initial selection.
36
36
  */
37
- export declare function composeInlineHtml(source: string, title: string, theme?: string): string;
37
+ export declare function composeInlineHtml(source: string, title: string, theme?: string, delivery?: 'inline' | 'cdn'): string;
38
38
  /**
39
39
  * Generate a self-contained `.paged.html` document, fully inline.
40
40
  *
@@ -56,4 +56,7 @@ export declare function buildPagedHtml(opts: {
56
56
  title?: string;
57
57
  theme?: string;
58
58
  template?: string;
59
+ /** `inline` (default, offline) or `cdn` (small file — engine from jsDelivr;
60
+ * requires orz-paged-browser published at this version). */
61
+ delivery?: 'inline' | 'cdn';
59
62
  }): string;
package/dist/lib.js CHANGED
@@ -81,15 +81,22 @@ export function pickDefaultTheme(themes) {
81
81
  * @param theme optional theme id; when omitted (or unknown) the default theme
82
82
  * ({@link pickDefaultTheme}) drives the picker's initial selection.
83
83
  */
84
- export function composeInlineHtml(source, title, theme) {
84
+ export function composeInlineHtml(source, title, theme, delivery) {
85
85
  const templates = loadTemplates();
86
86
  const { baseCss, themes } = loadThemes();
87
87
  const appJs = readFileSync(findAsset('assets/app.js'), 'utf8');
88
88
  const runtime = getBrowserRuntimeScript(); // copy-as-Markdown (+ qr) from orz-markdown
89
- const renderer = {
90
- mode: 'inline',
91
- js: readFileSync(findAsset('dist/orz-paged.browser.js'), 'utf8'),
92
- };
89
+ // `cdn` references the published engine on jsDelivr (small file); `inline`
90
+ // (default) embeds it. Only the renderer differs from the inline path.
91
+ const renderer = delivery === 'cdn'
92
+ ? {
93
+ mode: 'cdn',
94
+ src: `https://cdn.jsdelivr.net/npm/orz-paged-browser@${selfVersion}/orz-paged.browser.js`,
95
+ }
96
+ : {
97
+ mode: 'inline',
98
+ js: readFileSync(findAsset('dist/orz-paged.browser.js'), 'utf8'),
99
+ };
93
100
  const known = theme && themes.some((t) => t.id === theme);
94
101
  const defaultTheme = known ? theme : pickDefaultTheme(themes);
95
102
  return buildHtml({
@@ -132,5 +139,5 @@ export function buildPagedHtml(opts) {
132
139
  source = t.skeleton;
133
140
  }
134
141
  const title = opts.title || 'Untitled';
135
- return composeInlineHtml(source, title, opts.theme);
142
+ return composeInlineHtml(source, title, opts.theme, opts.delivery);
136
143
  }