@better-svelte-email/server 2.0.0-beta.0 → 2.0.0-beta.2
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/README.md +47 -0
- package/dist/index.cjs +3074 -0
- package/dist/index.d.cts +83 -0
- package/dist/index.d.mts +83 -0
- package/dist/index.mjs +3047 -0
- package/package.json +1 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DefaultTreeAdapterTypes } from "parse5";
|
|
2
|
+
import { Config } from "tailwindcss";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/tailwindcss/pixel-based-preset.d.ts
|
|
5
|
+
declare const pixelBasedPreset: TailwindConfig;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/index.d.ts
|
|
8
|
+
type TailwindConfig = Omit<Config, 'content'>;
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating a Renderer instance
|
|
11
|
+
*/
|
|
12
|
+
type RendererOptions = {
|
|
13
|
+
/** Tailwind CSS configuration */tailwindConfig?: TailwindConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Custom CSS to inject into email rendering (e.g., app theme variables).
|
|
16
|
+
*
|
|
17
|
+
* This CSS is injected during Tailwind compilation, making variables and styles
|
|
18
|
+
* available for processing. Useful for maintaining consistent styling between
|
|
19
|
+
* your app and emails (e.g., shadcn-svelte theme variables).
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import appStyles from './app.css?raw';
|
|
25
|
+
* const renderer = new Renderer({ customCSS: appStyles });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
customCSS?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Base font size in pixels for converting relative units (rem, em) to absolute pixels.
|
|
31
|
+
* Used when resolving calc() expressions with mixed units.
|
|
32
|
+
*
|
|
33
|
+
* Note: `em` is treated as `rem` (relative to this base) since parent element
|
|
34
|
+
* context is not available during email rendering.
|
|
35
|
+
*
|
|
36
|
+
* @default 16
|
|
37
|
+
*/
|
|
38
|
+
baseFontSize?: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Options for rendering a Svelte component
|
|
42
|
+
*/
|
|
43
|
+
type RenderOptions = {
|
|
44
|
+
props?: Omit<Record<string, any>, '$$slots' | '$$events'> | undefined;
|
|
45
|
+
context?: Map<any, any>;
|
|
46
|
+
idPrefix?: string;
|
|
47
|
+
};
|
|
48
|
+
declare class Renderer {
|
|
49
|
+
private tailwindConfig;
|
|
50
|
+
private customCSS?;
|
|
51
|
+
private baseFontSize;
|
|
52
|
+
constructor(tailwindConfig?: TailwindConfig);
|
|
53
|
+
constructor(options?: RendererOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Renders a Svelte component to email-safe HTML with inlined Tailwind CSS.
|
|
56
|
+
*
|
|
57
|
+
* Automatically:
|
|
58
|
+
* - Converts Tailwind classes to inline styles
|
|
59
|
+
* - Injects media queries into `<head>` for responsive classes
|
|
60
|
+
* - Replaces DOCTYPE with XHTML 1.0 Transitional
|
|
61
|
+
* - Removes comments and Svelte artifacts
|
|
62
|
+
*
|
|
63
|
+
* @param component - The Svelte component to render
|
|
64
|
+
* @param options - Render options including props, context, and idPrefix
|
|
65
|
+
* @returns Email-safe HTML string
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const html = await renderer.render(EmailComponent, {
|
|
70
|
+
* props: { username: 'john_doe', resetUrl: 'https://...' }
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
render: (component: any, options?: RenderOptions | undefined) => Promise<string>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Render HTML as plain text
|
|
78
|
+
* @param markup - HTML string
|
|
79
|
+
* @returns Plain text string
|
|
80
|
+
*/
|
|
81
|
+
declare const toPlainText: (markup: string) => string;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { type DefaultTreeAdapterTypes as AST, RenderOptions, Renderer, RendererOptions, TailwindConfig, pixelBasedPreset, toPlainText };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DefaultTreeAdapterTypes } from "parse5";
|
|
2
|
+
import { Config } from "tailwindcss";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/tailwindcss/pixel-based-preset.d.ts
|
|
5
|
+
declare const pixelBasedPreset: TailwindConfig;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/index.d.ts
|
|
8
|
+
type TailwindConfig = Omit<Config, 'content'>;
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating a Renderer instance
|
|
11
|
+
*/
|
|
12
|
+
type RendererOptions = {
|
|
13
|
+
/** Tailwind CSS configuration */tailwindConfig?: TailwindConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Custom CSS to inject into email rendering (e.g., app theme variables).
|
|
16
|
+
*
|
|
17
|
+
* This CSS is injected during Tailwind compilation, making variables and styles
|
|
18
|
+
* available for processing. Useful for maintaining consistent styling between
|
|
19
|
+
* your app and emails (e.g., shadcn-svelte theme variables).
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import appStyles from './app.css?raw';
|
|
25
|
+
* const renderer = new Renderer({ customCSS: appStyles });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
customCSS?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Base font size in pixels for converting relative units (rem, em) to absolute pixels.
|
|
31
|
+
* Used when resolving calc() expressions with mixed units.
|
|
32
|
+
*
|
|
33
|
+
* Note: `em` is treated as `rem` (relative to this base) since parent element
|
|
34
|
+
* context is not available during email rendering.
|
|
35
|
+
*
|
|
36
|
+
* @default 16
|
|
37
|
+
*/
|
|
38
|
+
baseFontSize?: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Options for rendering a Svelte component
|
|
42
|
+
*/
|
|
43
|
+
type RenderOptions = {
|
|
44
|
+
props?: Omit<Record<string, any>, '$$slots' | '$$events'> | undefined;
|
|
45
|
+
context?: Map<any, any>;
|
|
46
|
+
idPrefix?: string;
|
|
47
|
+
};
|
|
48
|
+
declare class Renderer {
|
|
49
|
+
private tailwindConfig;
|
|
50
|
+
private customCSS?;
|
|
51
|
+
private baseFontSize;
|
|
52
|
+
constructor(tailwindConfig?: TailwindConfig);
|
|
53
|
+
constructor(options?: RendererOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Renders a Svelte component to email-safe HTML with inlined Tailwind CSS.
|
|
56
|
+
*
|
|
57
|
+
* Automatically:
|
|
58
|
+
* - Converts Tailwind classes to inline styles
|
|
59
|
+
* - Injects media queries into `<head>` for responsive classes
|
|
60
|
+
* - Replaces DOCTYPE with XHTML 1.0 Transitional
|
|
61
|
+
* - Removes comments and Svelte artifacts
|
|
62
|
+
*
|
|
63
|
+
* @param component - The Svelte component to render
|
|
64
|
+
* @param options - Render options including props, context, and idPrefix
|
|
65
|
+
* @returns Email-safe HTML string
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const html = await renderer.render(EmailComponent, {
|
|
70
|
+
* props: { username: 'john_doe', resetUrl: 'https://...' }
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
render: (component: any, options?: RenderOptions | undefined) => Promise<string>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Render HTML as plain text
|
|
78
|
+
* @param markup - HTML string
|
|
79
|
+
* @returns Plain text string
|
|
80
|
+
*/
|
|
81
|
+
declare const toPlainText: (markup: string) => string;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { type DefaultTreeAdapterTypes as AST, RenderOptions, Renderer, RendererOptions, TailwindConfig, pixelBasedPreset, toPlainText };
|