mark-deco 0.27.0 → 0.28.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.
Files changed (37) hide show
  1. package/dist/browser.cjs +2 -2
  2. package/dist/browser.d.ts +2 -2
  3. package/dist/browser.mjs +2 -2
  4. package/dist/card-oembed-fallback.cjs +40 -0
  5. package/dist/card-oembed-fallback.cjs.map +1 -0
  6. package/dist/card-oembed-fallback.d.ts +123 -0
  7. package/dist/card-oembed-fallback.mjs +40 -0
  8. package/dist/card-oembed-fallback.mjs.map +1 -0
  9. package/dist/html-generator-BKd2MyoO.cjs +643 -0
  10. package/dist/html-generator-BKd2MyoO.cjs.map +1 -0
  11. package/dist/{html-generator-DpamUjzj.cjs → html-generator-BlVRLqE6.cjs} +7 -634
  12. package/dist/html-generator-BlVRLqE6.cjs.map +1 -0
  13. package/dist/html-generator-CClcgkAK.js +644 -0
  14. package/dist/html-generator-CClcgkAK.js.map +1 -0
  15. package/dist/{html-generator-Dd_srEJw.js → html-generator-DOlAM9Ff.js} +13 -640
  16. package/dist/html-generator-DOlAM9Ff.js.map +1 -0
  17. package/dist/index.cjs +69 -15
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +20 -2
  20. package/dist/index.mjs +58 -4
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/internal.cjs +18 -17
  23. package/dist/internal.cjs.map +1 -1
  24. package/dist/internal.d.ts +12 -2
  25. package/dist/internal.mjs +19 -18
  26. package/dist/internal.mjs.map +1 -1
  27. package/dist/misc.cjs +2 -2
  28. package/dist/misc.d.ts +2 -2
  29. package/dist/misc.mjs +2 -2
  30. package/dist/node.cjs +2 -2
  31. package/dist/node.d.ts +2 -2
  32. package/dist/node.mjs +2 -2
  33. package/dist/utils-B06SsBEd.js +2 -2
  34. package/dist/utils-CoXrMKLM.cjs +2 -2
  35. package/package.json +12 -7
  36. package/dist/html-generator-Dd_srEJw.js.map +0 -1
  37. package/dist/html-generator-DpamUjzj.cjs.map +0 -1
package/dist/browser.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: mark-deco
3
- * version: 0.27.0
3
+ * version: 0.28.0
4
4
  * description: Flexible Markdown to HTML conversion library
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/mark-deco
8
- * git.commit.hash: 9eedf400a4634e8dc23d3f7e05356df3f0a7a77f
8
+ * git.commit.hash: 124aac654302073ffbbd202ac2794d6c9cdc56ea
9
9
  */
10
10
 
11
11
  "use strict";
package/dist/browser.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: mark-deco
3
- * version: 0.27.0
3
+ * version: 0.28.0
4
4
  * description: Flexible Markdown to HTML conversion library
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/mark-deco
8
- * git.commit.hash: 9eedf400a4634e8dc23d3f7e05356df3f0a7a77f
8
+ * git.commit.hash: 124aac654302073ffbbd202ac2794d6c9cdc56ea
9
9
  */
10
10
 
11
11
  /**
package/dist/browser.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: mark-deco
3
- * version: 0.27.0
3
+ * version: 0.28.0
4
4
  * description: Flexible Markdown to HTML conversion library
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/mark-deco
8
- * git.commit.hash: 9eedf400a4634e8dc23d3f7e05356df3f0a7a77f
8
+ * git.commit.hash: 124aac654302073ffbbd202ac2794d6c9cdc56ea
9
9
  */
10
10
 
11
11
  import { createMutex } from "async-primitives";
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * name: mark-deco
3
+ * version: 0.28.0
4
+ * description: Flexible Markdown to HTML conversion library
5
+ * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
+ * license: MIT
7
+ * repository.url: https://github.com/kekyo/mark-deco
8
+ * git.commit.hash: 124aac654302073ffbbd202ac2794d6c9cdc56ea
9
+ */
10
+
11
+ "use strict";
12
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
13
+ const htmlGenerator = require("./html-generator-BKd2MyoO.cjs");
14
+ const isProviderNotFoundError = (error) => {
15
+ return error instanceof Error && error.message.startsWith("No oEmbed provider found for URL:");
16
+ };
17
+ const createCardOEmbedFallback = (providerList, options = {}) => {
18
+ const { maxRedirects = 5, timeoutEachRedirect = 1e4 } = options;
19
+ return {
20
+ render: async (url, context) => {
21
+ try {
22
+ const oembedData = await htmlGenerator.fetchOEmbedData(
23
+ url,
24
+ maxRedirects,
25
+ timeoutEachRedirect,
26
+ context,
27
+ providerList
28
+ );
29
+ return htmlGenerator.generateHtml(oembedData, url, options);
30
+ } catch (error) {
31
+ if (error instanceof htmlGenerator.CORSError || isProviderNotFoundError(error)) {
32
+ return void 0;
33
+ }
34
+ throw error;
35
+ }
36
+ }
37
+ };
38
+ };
39
+ exports.createCardOEmbedFallback = createCardOEmbedFallback;
40
+ //# sourceMappingURL=card-oembed-fallback.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-oembed-fallback.cjs","sources":["../src/plugins/card/oembed-fallback.ts"],"sourcesContent":["// mark-deco - Flexible Markdown to HTML conversion library\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/mark-deco\n\nimport { CORSError, fetchOEmbedData } from '../oembed/fetcher';\nimport { generateHtml } from '../oembed/html-generator';\nimport type { OEmbedPluginOptions, OEmbedProvider } from '../oembed/types';\nimport type { CardOEmbedFallback } from './types';\n\nconst isProviderNotFoundError = (error: unknown): boolean => {\n return (\n error instanceof Error &&\n error.message.startsWith('No oEmbed provider found for URL:')\n );\n};\n\n/**\n * Create an oEmbed fallback renderer for card blocks\n * @param providerList - List of oEmbed providers to use\n * @param options - Configuration options for oEmbed fetching/rendering\n * @returns Fallback renderer for card plugin\n */\nexport const createCardOEmbedFallback = (\n providerList: OEmbedProvider[],\n options: OEmbedPluginOptions = {}\n): CardOEmbedFallback => {\n const { maxRedirects = 5, timeoutEachRedirect = 10000 } = options;\n\n return {\n render: async (url, context) => {\n try {\n const oembedData = await fetchOEmbedData(\n url,\n maxRedirects,\n timeoutEachRedirect,\n context,\n providerList\n );\n return generateHtml(oembedData, url, options);\n } catch (error) {\n if (error instanceof CORSError || isProviderNotFoundError(error)) {\n return undefined;\n }\n throw error;\n }\n },\n };\n};\n"],"names":["fetchOEmbedData","generateHtml","CORSError"],"mappings":";;;;;;;;;;;;;AAUA,MAAM,0BAA0B,CAAC,UAA4B;AAC3D,SACE,iBAAiB,SACjB,MAAM,QAAQ,WAAW,mCAAmC;AAEhE;AAQO,MAAM,2BAA2B,CACtC,cACA,UAA+B,OACR;AACvB,QAAM,EAAE,eAAe,GAAG,sBAAsB,QAAU;AAE1D,SAAO;AAAA,IACL,QAAQ,OAAO,KAAK,YAAY;AAC9B,UAAI;AACF,cAAM,aAAa,MAAMA,cAAAA;AAAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAEF,eAAOC,2BAAa,YAAY,KAAK,OAAO;AAAA,MAC9C,SAAS,OAAO;AACd,YAAI,iBAAiBC,cAAAA,aAAa,wBAAwB,KAAK,GAAG;AAChE,iBAAO;AAAA,QACT;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -0,0 +1,123 @@
1
+ /*!
2
+ * name: mark-deco
3
+ * version: 0.28.0
4
+ * description: Flexible Markdown to HTML conversion library
5
+ * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
+ * license: MIT
7
+ * repository.url: https://github.com/kekyo/mark-deco
8
+ * git.commit.hash: 124aac654302073ffbbd202ac2794d6c9cdc56ea
9
+ */
10
+
11
+ /**
12
+ * Optional oEmbed fallback renderer for card blocks
13
+ */
14
+ export declare interface CardOEmbedFallback {
15
+ /** Render oEmbed HTML for the URL, or return undefined to continue with card rendering */
16
+ render: (url: string, context: MarkdownProcessorPluginContext) => Promise<string | undefined>;
17
+ }
18
+
19
+ /**
20
+ * Create an oEmbed fallback renderer for card blocks
21
+ * @param providerList - List of oEmbed providers to use
22
+ * @param options - Configuration options for oEmbed fetching/rendering
23
+ * @returns Fallback renderer for card plugin
24
+ */
25
+ export declare const createCardOEmbedFallback: (providerList: OEmbedProvider[], options?: OEmbedPluginOptions) => CardOEmbedFallback;
26
+
27
+ /**
28
+ * Fetcher interface that encapsulates both fetching function and metadata
29
+ */
30
+ declare interface FetcherType {
31
+ /** The actual fetcher function */
32
+ readonly rawFetcher: (url: string, accept: string, signal: AbortSignal | undefined, logger?: Logger) => Promise<Response>;
33
+ /** User-Agent string used for fetcher HTTP requests */
34
+ readonly userAgent: string;
35
+ }
36
+
37
+ /**
38
+ * Frontmatter data extracted from markdown
39
+ */
40
+ declare interface FrontmatterData {
41
+ readonly [key: string]: unknown;
42
+ }
43
+
44
+ /**
45
+ * Logger interface for customizable logging
46
+ */
47
+ declare interface Logger {
48
+ readonly debug: (message: string, ...args: unknown[]) => void;
49
+ readonly info: (message: string, ...args: unknown[]) => void;
50
+ readonly warn: (message: string, ...args: unknown[]) => void;
51
+ readonly error: (message: string, ...args: unknown[]) => void;
52
+ }
53
+
54
+ /**
55
+ * Context provided to plugins during processing
56
+ */
57
+ declare interface MarkdownProcessorPluginContext {
58
+ /** Logger instance for output */
59
+ readonly logger: Logger;
60
+ /** AbortSignal for cancelling the operation */
61
+ readonly signal: AbortSignal | undefined;
62
+ /** Frontmatter data extracted from the markdown */
63
+ readonly frontmatter: FrontmatterData;
64
+ /** Generate unique ID with consistent prefix+counter approach */
65
+ readonly getUniqueId: () => string;
66
+ /** Fetch function for HTTP requests */
67
+ readonly fetcher: FetcherType;
68
+ }
69
+
70
+ /**
71
+ * oEmbed provider endpoint interface
72
+ */
73
+ declare interface OEmbedEndpoint {
74
+ url: string;
75
+ schemes?: string[];
76
+ discovery?: boolean;
77
+ formats?: string[];
78
+ }
79
+
80
+ /**
81
+ * oEmbed plugin display fields interface
82
+ */
83
+ declare interface OEmbedPluginDisplayFields {
84
+ /** Display order for the title (default: undefined - not displayed, number: display order) */
85
+ title?: number;
86
+ /** Display order for the thumbnail image (default: undefined - not displayed, number: display order) */
87
+ thumbnail?: number;
88
+ /** Display order for the author information (default: undefined - not displayed, number: display order) */
89
+ author?: number;
90
+ /** Display order for the provider information (default: undefined - not displayed, number: display order) */
91
+ provider?: number;
92
+ /** Display order for the description (default: undefined - not displayed, number: display order) */
93
+ description?: number;
94
+ /** Display order for the embedded content (video/rich HTML) (default: undefined - not displayed, number: display order) */
95
+ embeddedContent?: number;
96
+ /** Display order for the external link to the source (default: undefined - not displayed, number: display order) */
97
+ externalLink?: number;
98
+ }
99
+
100
+ /**
101
+ * oEmbed plugin options
102
+ */
103
+ export declare interface OEmbedPluginOptions {
104
+ /** Maximum number of redirects to follow */
105
+ maxRedirects?: number;
106
+ /** Timeout for each redirect request in milliseconds */
107
+ timeoutEachRedirect?: number;
108
+ /** Whether to use metadata URL (from oEmbed response) for links instead of provided URL (default: false) */
109
+ useMetadataUrlLink?: boolean;
110
+ /** Control which metadata fields to display in the generated HTML */
111
+ displayFields?: OEmbedPluginDisplayFields;
112
+ }
113
+
114
+ /**
115
+ * oEmbed provider interface from providers.json
116
+ */
117
+ export declare interface OEmbedProvider {
118
+ provider_name: string;
119
+ provider_url: string;
120
+ endpoints: OEmbedEndpoint[];
121
+ }
122
+
123
+ export { }
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * name: mark-deco
3
+ * version: 0.28.0
4
+ * description: Flexible Markdown to HTML conversion library
5
+ * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
+ * license: MIT
7
+ * repository.url: https://github.com/kekyo/mark-deco
8
+ * git.commit.hash: 124aac654302073ffbbd202ac2794d6c9cdc56ea
9
+ */
10
+
11
+ import { f as fetchOEmbedData, b as generateHtml, C as CORSError } from "./html-generator-CClcgkAK.js";
12
+ const isProviderNotFoundError = (error) => {
13
+ return error instanceof Error && error.message.startsWith("No oEmbed provider found for URL:");
14
+ };
15
+ const createCardOEmbedFallback = (providerList, options = {}) => {
16
+ const { maxRedirects = 5, timeoutEachRedirect = 1e4 } = options;
17
+ return {
18
+ render: async (url, context) => {
19
+ try {
20
+ const oembedData = await fetchOEmbedData(
21
+ url,
22
+ maxRedirects,
23
+ timeoutEachRedirect,
24
+ context,
25
+ providerList
26
+ );
27
+ return generateHtml(oembedData, url, options);
28
+ } catch (error) {
29
+ if (error instanceof CORSError || isProviderNotFoundError(error)) {
30
+ return void 0;
31
+ }
32
+ throw error;
33
+ }
34
+ }
35
+ };
36
+ };
37
+ export {
38
+ createCardOEmbedFallback
39
+ };
40
+ //# sourceMappingURL=card-oembed-fallback.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-oembed-fallback.mjs","sources":["../src/plugins/card/oembed-fallback.ts"],"sourcesContent":["// mark-deco - Flexible Markdown to HTML conversion library\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/mark-deco\n\nimport { CORSError, fetchOEmbedData } from '../oembed/fetcher';\nimport { generateHtml } from '../oembed/html-generator';\nimport type { OEmbedPluginOptions, OEmbedProvider } from '../oembed/types';\nimport type { CardOEmbedFallback } from './types';\n\nconst isProviderNotFoundError = (error: unknown): boolean => {\n return (\n error instanceof Error &&\n error.message.startsWith('No oEmbed provider found for URL:')\n );\n};\n\n/**\n * Create an oEmbed fallback renderer for card blocks\n * @param providerList - List of oEmbed providers to use\n * @param options - Configuration options for oEmbed fetching/rendering\n * @returns Fallback renderer for card plugin\n */\nexport const createCardOEmbedFallback = (\n providerList: OEmbedProvider[],\n options: OEmbedPluginOptions = {}\n): CardOEmbedFallback => {\n const { maxRedirects = 5, timeoutEachRedirect = 10000 } = options;\n\n return {\n render: async (url, context) => {\n try {\n const oembedData = await fetchOEmbedData(\n url,\n maxRedirects,\n timeoutEachRedirect,\n context,\n providerList\n );\n return generateHtml(oembedData, url, options);\n } catch (error) {\n if (error instanceof CORSError || isProviderNotFoundError(error)) {\n return undefined;\n }\n throw error;\n }\n },\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAM,0BAA0B,CAAC,UAA4B;AAC3D,SACE,iBAAiB,SACjB,MAAM,QAAQ,WAAW,mCAAmC;AAEhE;AAQO,MAAM,2BAA2B,CACtC,cACA,UAA+B,OACR;AACvB,QAAM,EAAE,eAAe,GAAG,sBAAsB,QAAU;AAE1D,SAAO;AAAA,IACL,QAAQ,OAAO,KAAK,YAAY;AAC9B,UAAI;AACF,cAAM,aAAa,MAAM;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAEF,eAAO,aAAa,YAAY,KAAK,OAAO;AAAA,MAC9C,SAAS,OAAO;AACd,YAAI,iBAAiB,aAAa,wBAAwB,KAAK,GAAG;AAChE,iBAAO;AAAA,QACT;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;"}