@vtex-email/react 0.0.0-stage → 0.0.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.
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare function Email({ children, className }: {
3
+ children: ReactNode;
4
+ className?: string;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=email.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/adapter/email.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMtC,wBAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAUzF"}
@@ -0,0 +1,3 @@
1
+ import { type Diagnostic } from '@vtex-email/core';
2
+ export declare function diagnoseStyles(html: string): Diagnostic[];
3
+ //# sourceMappingURL=style-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-diagnostics.d.ts","sourceRoot":"","sources":["../../src/adapter/style-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAWtF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAqBzD"}
@@ -0,0 +1,14 @@
1
+ import { type TailwindConfig } from '@react-email/components';
2
+ import { type CompileEmailResult, type EmailDocument, type EmissionProfile } from '@vtex-email/core';
3
+ import { type ReactNode } from 'react';
4
+ export type { BuildManifest, CompiledArtifact, CompileEmailResult } from '@vtex-email/core';
5
+ export interface CompileEmailInput {
6
+ email: EmailDocument<() => ReactNode>;
7
+ locale: string;
8
+ catalog: Readonly<Record<string, string>>;
9
+ profile: EmissionProfile;
10
+ tailwind: TailwindConfig;
11
+ file?: string;
12
+ }
13
+ export declare function compileEmail(input: CompileEmailInput): Promise<CompileEmailResult>;
14
+ //# sourceMappingURL=compile-email.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-email.d.ts","sourceRoot":"","sources":["../../src/compile/compile-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAKL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE3F,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC,MAAM,SAAS,CAAC,CAAA;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,cAAc,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0CxF"}
@@ -0,0 +1,29 @@
1
+ import type { TailwindConfig } from '@react-email/components';
2
+ import { type Diagnostic, type EmissionProfile, type Marker, type SiteRecord } from '@vtex-email/core';
3
+ export declare class CompileAborted extends Error {
4
+ readonly diagnostics: Diagnostic[];
5
+ constructor(diagnostics: Diagnostic[]);
6
+ }
7
+ export interface Session {
8
+ locale: string;
9
+ catalog: Readonly<Record<string, string>>;
10
+ profile: EmissionProfile;
11
+ tailwind: TailwindConfig;
12
+ markers: Map<string, Marker>;
13
+ sites: Map<string, SiteRecord>;
14
+ diagnostics: Diagnostic[];
15
+ nextIndex: number;
16
+ templateId: string;
17
+ file?: string;
18
+ }
19
+ export declare function createSession(input: Omit<Session, 'markers' | 'sites' | 'diagnostics' | 'nextIndex'>): Session;
20
+ export declare function getSession(): Session;
21
+ export declare function runSession<T>(session: Session, run: () => T): T;
22
+ export declare function abort(session: Session, diagnostic: Diagnostic): never;
23
+ export declare function addMarker(session: Session, identity: {
24
+ kind: string;
25
+ path: string;
26
+ detail: string;
27
+ }, marker: Marker): string;
28
+ export declare function addSite(session: Session, id: string, site: SiteRecord): void;
29
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/compile/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAA;AAGzB,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAA;gBAEtB,WAAW,EAAE,UAAU,EAAE;CAKtC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,cAAc,CAAA;IACxB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAUD,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,WAAW,CAAC,GAAG,OAAO,CAE9G;AAED,wBAAgB,UAAU,IAAI,OAAO,CAMpC;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAE/D;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,KAAK,CAGrE;AAED,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACxD,MAAM,EAAE,MAAM,GACb,MAAM,CAmBR;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAE5E"}
@@ -0,0 +1,26 @@
1
+ import type { DynamicAttribute } from '@vtex-email/core';
2
+ import type { ReactNode } from 'react';
3
+ import { type Session } from '../compile/session';
4
+ import { type Expression } from './expr';
5
+ export declare function attributeToken(name: DynamicAttribute, value: string | Expression): string;
6
+ export declare function rejectClassExpression(className: string | Expression | undefined, session: Session): string | undefined;
7
+ export declare function DynamicLink({ href, title, children, className, }: {
8
+ href: string | Expression;
9
+ title?: string | Expression;
10
+ children?: ReactNode;
11
+ className?: string | Expression;
12
+ }): import("react/jsx-runtime").JSX.Element;
13
+ export declare function DynamicImg({ src, alt, title, width, height, }: {
14
+ src: string | Expression;
15
+ alt: string | Expression;
16
+ title?: string | Expression;
17
+ width: number;
18
+ height: number;
19
+ }): import("react/jsx-runtime").JSX.Element;
20
+ export declare function DynamicButton({ href, title, children, className, }: {
21
+ href: string | Expression;
22
+ title?: string | Expression;
23
+ children?: ReactNode;
24
+ className?: string | Expression;
25
+ }): import("react/jsx-runtime").JSX.Element;
26
+ //# sourceMappingURL=attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/dsl/attributes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAetD,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAmCzF;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,EAC1C,OAAO,EAAE,OAAO,GACf,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;CAChC,2CAWA;AAED,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,GAAG,EACH,KAAK,EACL,KAAK,EACL,MAAM,GACP,EAAE;IACD,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;IACxB,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,2CAUA;AAED,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;CAChC,2CAWA"}
@@ -0,0 +1,24 @@
1
+ import type { BlockName } from '@vtex-email/core';
2
+ import { type ReactElement, type ReactNode } from 'react';
3
+ export declare function stamp(children: ReactNode, token: string): ReactElement;
4
+ export declare function openRegion(path: string, block: BlockName, hasElse: boolean): {
5
+ openId: string;
6
+ elseId: string | null;
7
+ };
8
+ export declare function blockRegion(path: string, block: BlockName, children: ReactNode, fallback: ReactNode | undefined): ReactNode;
9
+ export declare function Each({ path, children, fallback }: {
10
+ path: string;
11
+ children: ReactNode;
12
+ fallback?: ReactNode;
13
+ }): ReactNode;
14
+ export declare function If({ path, children, fallback }: {
15
+ path: string;
16
+ children: ReactNode;
17
+ fallback?: ReactNode;
18
+ }): ReactNode;
19
+ export declare function Unless({ path, children, fallback }: {
20
+ path: string;
21
+ children: ReactNode;
22
+ fallback?: ReactNode;
23
+ }): ReactNode;
24
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/dsl/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,kBAAkB,CAAA;AAE7D,OAAO,EAAoD,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK3G,wBAAgB,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAYtE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,OAAO,GACf;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAsB3C;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,SAAS,GAAG,SAAS,GAC9B,SAAS,CAUX;AAED,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,aAE7G;AAED,wBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,aAE3G;AAED,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,aAE/G"}
@@ -0,0 +1,17 @@
1
+ declare const brand: unique symbol;
2
+ export type Expression = {
3
+ readonly kind: 'path';
4
+ readonly value: string;
5
+ readonly [brand]: true;
6
+ } | {
7
+ readonly kind: 'literal';
8
+ readonly value: string | number | boolean | null;
9
+ readonly [brand]: true;
10
+ };
11
+ export declare function isExpression(value: unknown): value is Expression;
12
+ export declare const expr: {
13
+ path(value: string): Expression;
14
+ literal(value: string | number | boolean | null): Expression;
15
+ };
16
+ export {};
17
+ //# sourceMappingURL=expr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expr.d.ts","sourceRoot":"","sources":["../../src/dsl/expr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,EAAE,OAAO,MAAwC,CAAA;AAE5D,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAA;CAAE,GACzE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAE1G,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,eAAO,MAAM,IAAI;gBACH,MAAM,GAAG,UAAU;mBAGhB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU;CAG7D,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { Diagnostic, ResolvedPath, SiteArgument } from '@vtex-email/core';
2
+ import type { Session } from '../compile/session';
3
+ export declare function dslFailure(session: Session, code: string, message: string, extra?: Omit<Diagnostic, 'code' | 'severity' | 'message' | 'templateId' | 'source'>): never;
4
+ export declare function resolvePath(path: string, session: Session): ResolvedPath;
5
+ export declare function readArgument(arg: unknown, session: Session): SiteArgument;
6
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/dsl/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAI9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAKjD,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,CAAM,GACtF,KAAK,CASP;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,CAIxE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,CAUzE"}
@@ -0,0 +1,6 @@
1
+ import { type Expression } from './expr';
2
+ export declare function Trans({ id, values }: {
3
+ id: string;
4
+ values?: Readonly<Record<string, Expression>>;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=trans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trans.d.ts","sourceRoot":"","sources":["../../src/dsl/trans.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAIxC,wBAAgB,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;CAAE,2CA4BlG"}
@@ -0,0 +1,11 @@
1
+ import type { ReactElement } from 'react';
2
+ export declare function Value({ path }: {
3
+ path: string;
4
+ }): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
5
+ export declare function textValue(path: string): ReactElement;
6
+ export declare function textLiteral(value: string | number | boolean | null): ReactElement;
7
+ export declare function Helper({ name, args }: {
8
+ name: string;
9
+ args: readonly unknown[];
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/dsl/values.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAOzC,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,8EAE/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAapD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,YAAY,CAajF;AAED,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,2CAahF"}
@@ -0,0 +1,17 @@
1
+ import { DynamicButton, DynamicImg, DynamicLink } from './attributes';
2
+ import { Each, If, Unless } from './blocks';
3
+ import { expr } from './expr';
4
+ import { Trans } from './trans';
5
+ import { Helper, Value } from './values';
6
+ export declare const Vtex: {
7
+ Each: typeof Each;
8
+ If: typeof If;
9
+ Unless: typeof Unless;
10
+ Value: typeof Value;
11
+ Helper: typeof Helper;
12
+ Link: typeof DynamicLink;
13
+ Img: typeof DynamicImg;
14
+ Button: typeof DynamicButton;
15
+ };
16
+ export { Each, expr, Helper, If, Trans, Unless, Value };
17
+ //# sourceMappingURL=vtex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vtex.d.ts","sourceRoot":"","sources":["../../src/dsl/vtex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAExC,eAAO,MAAM,IAAI;;;;;;;;;CAShB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { Email } from './adapter/email';
2
+ export { diagnoseStyles } from './adapter/style-diagnostics';
3
+ export { compileEmail, type BuildManifest, type CompiledArtifact, type CompileEmailInput, type CompileEmailResult, } from './compile/compile-email';
4
+ export { isExpression, type Expression } from './dsl/expr';
5
+ export { Each, expr, Helper, If, Trans, Unless, Value, Vtex } from './dsl/vtex';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,509 @@
1
+ // src/adapter/email.tsx
2
+ import { Body, Head, Html, Tailwind } from "@react-email/components";
3
+
4
+ // src/compile/session.ts
5
+ import {
6
+ errorDiagnostic,
7
+ mintToken
8
+ } from "@vtex-email/core";
9
+ import { AsyncLocalStorage } from "node:async_hooks";
10
+ var CompileAborted = class extends Error {
11
+ diagnostics;
12
+ constructor(diagnostics) {
13
+ super(diagnostics.map((item) => `${item.code} ${item.message}`).join("\n"));
14
+ this.name = "CompileAborted";
15
+ this.diagnostics = diagnostics;
16
+ }
17
+ };
18
+ var sessionKey = /* @__PURE__ */ Symbol.for("vtex-email.compile-session");
19
+ function sharedStorage() {
20
+ const host = globalThis;
21
+ host[sessionKey] ??= new AsyncLocalStorage();
22
+ return host[sessionKey];
23
+ }
24
+ function createSession(input) {
25
+ return { ...input, markers: /* @__PURE__ */ new Map(), sites: /* @__PURE__ */ new Map(), diagnostics: [], nextIndex: 0 };
26
+ }
27
+ function getSession() {
28
+ const session = sharedStorage().getStore();
29
+ if (!session) {
30
+ throw new CompileAborted([errorDiagnostic("DSL002", "DSL component called outside a compilation.")]);
31
+ }
32
+ return session;
33
+ }
34
+ function runSession(session, run) {
35
+ return sharedStorage().run(session, run);
36
+ }
37
+ function abort(session, diagnostic) {
38
+ session.diagnostics.push(diagnostic);
39
+ throw new CompileAborted(session.diagnostics);
40
+ }
41
+ function addMarker(session, identity, marker) {
42
+ const id = mintToken({
43
+ kind: identity.kind,
44
+ index: session.nextIndex,
45
+ path: identity.path,
46
+ detail: identity.detail
47
+ });
48
+ session.nextIndex += 1;
49
+ if (session.markers.has(id)) {
50
+ abort(
51
+ session,
52
+ errorDiagnostic("TOK001", `Marker collision at ${identity.path}.`, {
53
+ templateId: session.templateId,
54
+ path: identity.path
55
+ })
56
+ );
57
+ }
58
+ session.markers.set(id, marker);
59
+ return id;
60
+ }
61
+ function addSite(session, id, site) {
62
+ session.sites.set(id, site);
63
+ }
64
+
65
+ // src/adapter/email.tsx
66
+ import { jsx, jsxs } from "react/jsx-runtime";
67
+ function Email({ children, className }) {
68
+ const session = getSession();
69
+ return /* @__PURE__ */ jsx(Html, { lang: session.locale, children: /* @__PURE__ */ jsxs(Tailwind, { config: session.tailwind, children: [
70
+ /* @__PURE__ */ jsx(Head, {}),
71
+ /* @__PURE__ */ jsx(Body, { className, children })
72
+ ] }) });
73
+ }
74
+
75
+ // src/adapter/style-diagnostics.ts
76
+ import { errorDiagnostic as errorDiagnostic2, warningDiagnostic } from "@vtex-email/core";
77
+ var LIMIT = "This check does not establish compatibility with email clients.";
78
+ var LIMITED = [
79
+ { pattern: /display\s*:\s*flex\b/i, name: "display:flex" },
80
+ { pattern: /display\s*:\s*grid\b/i, name: "display:grid" },
81
+ { pattern: /position\s*:\s*(?:absolute|fixed)\b/i, name: "position" },
82
+ { pattern: /(?<![-\w])transform\s*:/i, name: "transform" }
83
+ ];
84
+ function diagnoseStyles(html) {
85
+ const diagnostics = [];
86
+ for (const rule of LIMITED) {
87
+ if (rule.pattern.test(html)) {
88
+ diagnostics.push(
89
+ warningDiagnostic("CSS001", `Property "${rule.name}" has limited support in email clients. ${LIMIT}`)
90
+ );
91
+ }
92
+ }
93
+ const preserved = preservedClasses(html);
94
+ const reported = /* @__PURE__ */ new Set();
95
+ for (const match of html.matchAll(/class="([^"]*)"/g)) {
96
+ for (const token of (match[1] ?? "").split(/\s+/)) {
97
+ if (token.length === 0 || preserved.has(token) || reported.has(token)) continue;
98
+ reported.add(token);
99
+ if (unprocessed(token)) {
100
+ diagnostics.push(errorDiagnostic2("CSS002", `Class "${token}" was not processed by the adapter. ${LIMIT}`));
101
+ }
102
+ }
103
+ }
104
+ return diagnostics;
105
+ }
106
+ function preservedClasses(html) {
107
+ const names = /* @__PURE__ */ new Set();
108
+ for (const block of html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/gi)) {
109
+ for (const selector of (block[1] ?? "").matchAll(/\.(-?[_a-zA-Z0-9-]+)/g)) {
110
+ const name = selector[1];
111
+ if (name) names.add(name);
112
+ }
113
+ }
114
+ return names;
115
+ }
116
+ function unprocessed(token) {
117
+ if (token.includes(":")) return true;
118
+ if (["flex", "grid", "absolute", "fixed", "relative", "block", "hidden"].includes(token)) return true;
119
+ return /^(?:m|p|w|h|text|bg|font|border|rounded|inline|items|justify|gap|max|min|sm|md|lg|hover|flex|grid)-/.test(
120
+ token
121
+ );
122
+ }
123
+
124
+ // src/compile/compile-email.ts
125
+ import { render } from "@react-email/components";
126
+ import {
127
+ assembleDocument,
128
+ checkCatalogs,
129
+ errorDiagnostic as errorDiagnostic3,
130
+ isSafeEmailId
131
+ } from "@vtex-email/core";
132
+ import { createElement } from "react";
133
+ async function compileEmail(input) {
134
+ const email = input.email;
135
+ if (!isSafeEmailId(email.id) || email.event.length === 0 || input.locale.length === 0) {
136
+ return fail([errorDiagnostic3("CFG001", "The email id, event, or locale is invalid.", { templateId: email.id })]);
137
+ }
138
+ const catalogIssues = checkCatalogs([input.locale], { [input.locale]: input.catalog }).map((issue) => ({
139
+ ...issue,
140
+ templateId: email.id
141
+ }));
142
+ if (catalogIssues.length > 0) return fail(catalogIssues);
143
+ const session = createSession({
144
+ locale: input.locale,
145
+ catalog: input.catalog,
146
+ profile: input.profile,
147
+ tailwind: input.tailwind,
148
+ templateId: email.id,
149
+ ...input.file ? { file: input.file } : {}
150
+ });
151
+ let html;
152
+ try {
153
+ html = await runSession(session, () => render(createElement(email.template), { pretty: false }));
154
+ } catch (error) {
155
+ const aborted = readAborted(error);
156
+ if (aborted) return fail(aborted);
157
+ const className = classNameExpression(error, email.id, input.file);
158
+ if (className) return fail(className);
159
+ throw error;
160
+ }
161
+ if (session.diagnostics.length > 0) return fail(session.diagnostics);
162
+ return assembleDocument({
163
+ html,
164
+ markers: session.markers,
165
+ sites: session.sites,
166
+ profile: input.profile,
167
+ templateId: email.id,
168
+ event: email.event,
169
+ locale: input.locale
170
+ });
171
+ }
172
+ function fail(diagnostics) {
173
+ return { ok: false, diagnostics };
174
+ }
175
+ function classNameExpression(error, templateId, file) {
176
+ if (!(error instanceof TypeError) || !error.message.includes("className") || !error.message.includes("split"))
177
+ return null;
178
+ return [
179
+ errorDiagnostic3("DSL002", "Expressions are not supported in className.", {
180
+ templateId,
181
+ ...file ? { source: { file } } : {}
182
+ })
183
+ ];
184
+ }
185
+ function readAborted(error) {
186
+ if (error instanceof CompileAborted) return error.diagnostics;
187
+ if (typeof error === "object" && error !== null && "cause" in error) return readAborted(error.cause);
188
+ return null;
189
+ }
190
+
191
+ // src/dsl/expr.ts
192
+ var brand = /* @__PURE__ */ Symbol("vtex-email.expression");
193
+ function isExpression(value) {
194
+ return typeof value === "object" && value !== null && brand in value;
195
+ }
196
+ var expr = {
197
+ path(value) {
198
+ return { kind: "path", value, [brand]: true };
199
+ },
200
+ literal(value) {
201
+ return { kind: "literal", value, [brand]: true };
202
+ }
203
+ };
204
+
205
+ // src/dsl/attributes.tsx
206
+ import { Button as EmailButton, Img as EmailImg, Link as EmailLink } from "@react-email/components";
207
+ import { emitLiteral as emitLiteral2 } from "@vtex-email/core";
208
+
209
+ // src/dsl/resolve.ts
210
+ import { emitLiteral, errorDiagnostic as errorDiagnostic4, parentHops, parsePath } from "@vtex-email/core";
211
+ function dslFailure(session, code, message, extra = {}) {
212
+ abort(
213
+ session,
214
+ errorDiagnostic4(code, message, {
215
+ ...extra,
216
+ templateId: session.templateId,
217
+ ...session.file ? { source: { file: session.file } } : {}
218
+ })
219
+ );
220
+ }
221
+ function resolvePath(path, session) {
222
+ const parsed = parsePath(path, session.profile.allowParentSegments);
223
+ if (!parsed.ok) dslFailure(session, "HBS001", parsed.message, { path });
224
+ return { emitted: parsed.emitted, parentHops: parentHops(parsed.segments) };
225
+ }
226
+ function readArgument(arg, session) {
227
+ if (typeof arg === "object" && arg !== null && "kind" in arg && arg.kind === "helper") {
228
+ dslFailure(session, "HBS002", "Nested helper subexpressions are not supported.");
229
+ }
230
+ if (!isExpression(arg)) {
231
+ dslFailure(session, "HBS002", "Helper argument has no expression kind.");
232
+ }
233
+ if (arg.kind === "literal") return { kind: "literal", emitted: emitLiteral(arg.value) };
234
+ const path = resolvePath(arg.value, session);
235
+ return { kind: "path", emitted: path.emitted, path };
236
+ }
237
+
238
+ // src/dsl/attributes.tsx
239
+ import { jsx as jsx2 } from "react/jsx-runtime";
240
+ function assertStaticUrl(value, session) {
241
+ let url;
242
+ try {
243
+ url = new URL(value);
244
+ } catch {
245
+ dslFailure(session, "HBS001", `Invalid static URL: ${value}`);
246
+ }
247
+ if (url.protocol !== "https:" && url.protocol !== "mailto:" && url.protocol !== "tel:") {
248
+ dslFailure(session, "HBS001", `URL scheme is not allowed: ${url.protocol}`);
249
+ }
250
+ }
251
+ function attributeToken(name, value) {
252
+ const session = getSession();
253
+ if (typeof value === "string") {
254
+ if (name === "href" || name === "src") assertStaticUrl(value, session);
255
+ return value;
256
+ }
257
+ if (!isExpression(value)) {
258
+ dslFailure(session, "DSL002", "A dynamic attribute requires expr.path or expr.literal.");
259
+ }
260
+ if (value.kind === "literal") {
261
+ const emitted = emitLiteral2(value.value);
262
+ const token2 = addMarker(
263
+ session,
264
+ { kind: "attr", path: name, detail: name },
265
+ {
266
+ kind: "attr",
267
+ attribute: name,
268
+ replacement: ""
269
+ }
270
+ );
271
+ addSite(session, token2, { kind: "attr", attribute: name, args: [{ kind: "literal", emitted }] });
272
+ return token2;
273
+ }
274
+ const resolved = resolvePath(value.value, session);
275
+ const token = addMarker(
276
+ session,
277
+ { kind: "attr", path: resolved.emitted, detail: name },
278
+ {
279
+ kind: "attr",
280
+ attribute: name,
281
+ replacement: ""
282
+ }
283
+ );
284
+ addSite(session, token, { kind: "attr", attribute: name, path: resolved });
285
+ return token;
286
+ }
287
+ function rejectClassExpression(className, session) {
288
+ if (className === void 0) return void 0;
289
+ if (isExpression(className)) {
290
+ dslFailure(session, "DSL002", "Expressions are not supported in className.");
291
+ }
292
+ return className;
293
+ }
294
+ function DynamicLink({
295
+ href,
296
+ title,
297
+ children,
298
+ className
299
+ }) {
300
+ const session = getSession();
301
+ return /* @__PURE__ */ jsx2(
302
+ EmailLink,
303
+ {
304
+ className: rejectClassExpression(className, session),
305
+ href: attributeToken("href", href),
306
+ title: title === void 0 ? void 0 : attributeToken("title", title),
307
+ children
308
+ }
309
+ );
310
+ }
311
+ function DynamicImg({
312
+ src,
313
+ alt,
314
+ title,
315
+ width,
316
+ height
317
+ }) {
318
+ return /* @__PURE__ */ jsx2(
319
+ EmailImg,
320
+ {
321
+ alt: attributeToken("alt", alt),
322
+ height,
323
+ src: attributeToken("src", src),
324
+ title: title === void 0 ? void 0 : attributeToken("title", title),
325
+ width
326
+ }
327
+ );
328
+ }
329
+ function DynamicButton({
330
+ href,
331
+ title,
332
+ children,
333
+ className
334
+ }) {
335
+ const session = getSession();
336
+ return /* @__PURE__ */ jsx2(
337
+ EmailButton,
338
+ {
339
+ className: rejectClassExpression(className, session),
340
+ href: attributeToken("href", href),
341
+ title: title === void 0 ? void 0 : attributeToken("title", title),
342
+ children
343
+ }
344
+ );
345
+ }
346
+
347
+ // src/dsl/blocks.tsx
348
+ import { Children, cloneElement, Fragment, isValidElement } from "react";
349
+ import { Fragment as Fragment2, jsxs as jsxs2 } from "react/jsx-runtime";
350
+ function stamp(children, token) {
351
+ const session = getSession();
352
+ let only;
353
+ try {
354
+ const child = Children.only(children);
355
+ if (!isValidElement(child) || child.type === Fragment) throw new Error("not an element");
356
+ only = child;
357
+ } catch (error) {
358
+ if (error instanceof Error && error.name === "CompileAborted") throw error;
359
+ dslFailure(session, "DSL002", "Each DSL block requires a single root element.");
360
+ }
361
+ return cloneElement(only, { "data-anchor": token });
362
+ }
363
+ function openRegion(path, block, hasElse) {
364
+ const session = getSession();
365
+ const resolved = resolvePath(path, session);
366
+ const marker = {
367
+ kind: "open",
368
+ open: "",
369
+ close: "",
370
+ elseId: null
371
+ };
372
+ const openId = addMarker(session, { kind: "open", path: resolved.emitted, detail: block }, marker);
373
+ addSite(session, openId, { kind: "block", block, path: resolved });
374
+ if (!hasElse) return { openId, elseId: null };
375
+ const elseId = addMarker(
376
+ session,
377
+ { kind: "else", path: resolved.emitted, detail: `${block}:else` },
378
+ {
379
+ kind: "else",
380
+ openId
381
+ }
382
+ );
383
+ marker.elseId = elseId;
384
+ return { openId, elseId };
385
+ }
386
+ function blockRegion(path, block, children, fallback) {
387
+ const region = openRegion(path, block, fallback !== void 0);
388
+ const thenNode = stamp(children, region.openId);
389
+ if (!region.elseId || fallback === void 0) return thenNode;
390
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
391
+ thenNode,
392
+ stamp(fallback, region.elseId)
393
+ ] });
394
+ }
395
+ function Each({ path, children, fallback }) {
396
+ return blockRegion(path, "each", children, fallback);
397
+ }
398
+ function If({ path, children, fallback }) {
399
+ return blockRegion(path, "if", children, fallback);
400
+ }
401
+ function Unless({ path, children, fallback }) {
402
+ return blockRegion(path, "unless", children, fallback);
403
+ }
404
+
405
+ // src/dsl/trans.tsx
406
+ import { parseMessage } from "@vtex-email/core";
407
+
408
+ // src/dsl/values.tsx
409
+ import { emitLiteral as emitLiteral3 } from "@vtex-email/core";
410
+ import { jsx as jsx3 } from "react/jsx-runtime";
411
+ function Value({ path }) {
412
+ return textValue(path);
413
+ }
414
+ function textValue(path) {
415
+ const session = getSession();
416
+ const resolved = resolvePath(path, session);
417
+ const token = addMarker(
418
+ session,
419
+ { kind: "text", path: resolved.emitted, detail: "value" },
420
+ {
421
+ kind: "text",
422
+ replacement: ""
423
+ }
424
+ );
425
+ addSite(session, token, { kind: "value", path: resolved });
426
+ return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
427
+ }
428
+ function textLiteral(value) {
429
+ const session = getSession();
430
+ const emitted = emitLiteral3(value);
431
+ const token = addMarker(
432
+ session,
433
+ { kind: "text", path: "literal", detail: emitted },
434
+ {
435
+ kind: "text",
436
+ replacement: ""
437
+ }
438
+ );
439
+ addSite(session, token, { kind: "literal", args: [{ kind: "literal", emitted }] });
440
+ return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
441
+ }
442
+ function Helper({ name, args }) {
443
+ const session = getSession();
444
+ const rendered = args.map((arg) => readArgument(arg, session));
445
+ const token = addMarker(
446
+ session,
447
+ { kind: "text", path: name, detail: rendered.map((arg) => arg.emitted).join(" ") },
448
+ {
449
+ kind: "text",
450
+ replacement: ""
451
+ }
452
+ );
453
+ addSite(session, token, { kind: "helper", helper: name, args: rendered });
454
+ return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
455
+ }
456
+
457
+ // src/dsl/trans.tsx
458
+ import { Fragment as Fragment3, jsx as jsx4 } from "react/jsx-runtime";
459
+ function Trans({ id, values }) {
460
+ const session = getSession();
461
+ const text = session.catalog[id];
462
+ if (text === void 0) {
463
+ dslFailure(session, "I18N001", `Missing key: ${id}`, { locale: session.locale });
464
+ }
465
+ const parsed = parseMessage(text);
466
+ if (!parsed.ok) {
467
+ dslFailure(session, "I18N001", parsed.message, { locale: session.locale });
468
+ }
469
+ const provided = Object.keys(values ?? {}).sort();
470
+ const expected = parsed.placeholders.slice().sort();
471
+ if (provided.join("\0") !== expected.join("\0")) {
472
+ dslFailure(session, "I18N001", `Placeholders for ${id} do not match the catalog.`, { locale: session.locale });
473
+ }
474
+ return /* @__PURE__ */ jsx4(Fragment3, { children: parsed.parts.map((part) => {
475
+ if (part.type === "text") return part.value;
476
+ const value = values?.[part.name];
477
+ if (!value) {
478
+ dslFailure(session, "I18N001", `Missing placeholder value: ${part.name}`, { locale: session.locale });
479
+ }
480
+ if (value.kind === "literal") return textLiteral(value.value);
481
+ return textValue(value.value);
482
+ }) });
483
+ }
484
+
485
+ // src/dsl/vtex.ts
486
+ var Vtex = {
487
+ Each,
488
+ If,
489
+ Unless,
490
+ Value,
491
+ Helper,
492
+ Link: DynamicLink,
493
+ Img: DynamicImg,
494
+ Button: DynamicButton
495
+ };
496
+ export {
497
+ Each,
498
+ Email,
499
+ Helper,
500
+ If,
501
+ Trans,
502
+ Unless,
503
+ Value,
504
+ Vtex,
505
+ compileEmail,
506
+ diagnoseStyles,
507
+ expr,
508
+ isExpression
509
+ };
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@vtex-email/react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "dependencies": {
17
+ "@react-email/components": "1.0.12",
18
+ "@vtex-email/core": "0.0.0",
19
+ "react": "19.3.0",
20
+ "react-dom": "19.3.0"
21
+ },
22
+ "devDependencies": {
23
+ "@vtex-email/vtex": "0.0.0",
24
+ "zod": "4.6.5"
25
+ }
6
26
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.