@samva/markup 0.9.0 → 0.10.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/AGENTS.md +48 -40
- package/CHANGELOG.md +345 -0
- package/README.md +6 -6
- package/dist/{brand-B-0bN_Ir.d.ts → assets-BIsyMQ92.d.ts} +41 -11
- package/dist/{email/brand.js → brand-C0MKTwmX.js} +64 -4
- package/dist/{theme-css.d.ts → brand.d.ts} +12 -3
- package/dist/brand.js +4 -0
- package/dist/compiler.d.ts +231 -11
- package/dist/compiler.js +1312 -13
- package/dist/components-BZCqegS8.js +1864 -0
- package/dist/diagnostic-model-DJtqbETd.js +38 -0
- package/dist/diagnostic-model-DxthUZBT.d.ts +31 -0
- package/dist/{email/diagnostics.js → diagnostics-CnKFefKz.js} +2 -2
- package/dist/diagnostics.d.ts +406 -27
- package/dist/diagnostics.js +402 -34
- package/dist/edit.d.ts +234 -0
- package/dist/{channel-edit.js → edit.js} +341 -3
- package/dist/email/jsx-dev-runtime.d.ts +1 -1
- package/dist/email/jsx-dev-runtime.js +1 -2
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/jsx-runtime.js +1 -85
- package/dist/{email/components.d.ts → email.d.ts} +2 -2
- package/dist/email.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{cascade-t6kxlgEI.js → ir-CLhlklKV.js} +8 -4
- package/dist/jsx-runtime-CBlexoeR.js +98 -0
- package/dist/{elements-cqldpaJt.d.ts → jsx-runtime-ylIOnaSf.d.ts} +74 -74
- package/dist/{profile-BH-OtdDA.js → profile-pWGtWZXF.js} +153 -20
- package/dist/render-BPonDpCl.d.ts +539 -0
- package/dist/{email/render.js → render-BQmfh94k.js} +102 -8
- package/dist/render.d.ts +35 -0
- package/dist/render.js +49 -0
- package/dist/sms.d.ts +1 -1
- package/dist/sms.js +1 -1
- package/dist/{template-_QE_rQND.d.ts → template-DMPwxMSq.d.ts} +2 -2
- package/dist/{template.js → template-zLUjcwfF.js} +2 -2
- package/dist/{theme-css-hFqcPSar.js → theme-css-JtRCm1fb.js} +2 -2
- package/dist/whatsapp.d.ts +1 -1
- package/dist/whatsapp.js +1 -1
- package/generated/contract.json +16 -10
- package/generated/reference.md +17 -10
- package/package.json +36 -119
- package/samva-brand.d.ts +4 -4
- package/skills/sml/SKILL.md +2 -2
- package/dist/assets-C5duwTya.d.ts +0 -40
- package/dist/channel-edit.d.ts +0 -121
- package/dist/channel-specs-B6M_HlaV.js +0 -29
- package/dist/compatibility-DbISoFIq.js +0 -589
- package/dist/css-BVQKICKC.d.ts +0 -109
- package/dist/diagnostic-codes.d.ts +0 -403
- package/dist/diagnostic-codes.js +0 -399
- package/dist/email/assets.d.ts +0 -2
- package/dist/email/assets.js +0 -63
- package/dist/email/brand-footer.d.ts +0 -34
- package/dist/email/brand-footer.js +0 -63
- package/dist/email/brand.d.ts +0 -2
- package/dist/email/components.js +0 -275
- package/dist/email/diagnostics.d.ts +0 -2
- package/dist/email/elements.d.ts +0 -2
- package/dist/email/elements.js +0 -299
- package/dist/email/html.d.ts +0 -2
- package/dist/email/html.js +0 -321
- package/dist/email/render.d.ts +0 -40
- package/dist/email/text.d.ts +0 -7
- package/dist/email/text.js +0 -100
- package/dist/html-BJepOwZ4.d.ts +0 -56
- package/dist/ir-aaqNE987.d.ts +0 -252
- package/dist/ir.d.ts +0 -2
- package/dist/ir.js +0 -7
- package/dist/preview-Ekdg1dXG.d.ts +0 -100
- package/dist/preview.d.ts +0 -2
- package/dist/preview.js +0 -160
- package/dist/render-ir.d.ts +0 -19
- package/dist/render-ir.js +0 -826
- package/dist/sms-segments.d.ts +0 -13
- package/dist/sms-segments.js +0 -46
- package/dist/source-edit.d.ts +0 -116
- package/dist/source-edit.js +0 -343
- package/dist/source-locations.d.ts +0 -2
- package/dist/source-locations.js +0 -16
- package/dist/static.d.ts +0 -57
- package/dist/static.js +0 -69
- package/dist/tailwind-CMYpZf1v.js +0 -614
- package/dist/template.d.ts +0 -2
- package/dist/theme-css.js +0 -2
- package/dist/theme-imports-lvBw3AD1.js +0 -109
- package/dist/transform-Ct2OMkFN.d.ts +0 -153
package/AGENTS.md
CHANGED
|
@@ -10,63 +10,71 @@ the local editor, project builds, and exports live in `@samva/vite`.
|
|
|
10
10
|
|
|
11
11
|
## Entry points
|
|
12
12
|
|
|
13
|
+
Authoring entries are what a template file imports:
|
|
14
|
+
|
|
13
15
|
- `@samva/markup` — `defineTemplate({ id, schema, fixtures, locale?, email?, sms?, whatsapp? })`,
|
|
14
|
-
`TemplateInput`, and `TEMPLATE_ID_PATTERN` (lowercase kebab-case, the rule the CLI
|
|
15
|
-
share). `email` is `{ subject, preheader?, body }`; each is a function of the
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`checkStaticProfile(source | files, entry?)` is the synchronous structural check: it runs the
|
|
21
|
-
compiler's lowering without Tailwind, a brand or the files an import names, and returns only
|
|
22
|
-
findings the source itself owns. `introducedProfileErrors(before, after)` is what a visual edit
|
|
23
|
-
is refused on.
|
|
24
|
-
- `@samva/markup/source-edit` — the code transforms behind visual edits (`inspectSourceElement`,
|
|
25
|
-
`literalReplacement`, `expressionReplacement`, `classNameEdit`, `structuralReplacements`,
|
|
26
|
-
`applySourceReplacements` with a `ProfileGuard`). Browser-safe: Babel parser only.
|
|
27
|
-
- `@samva/markup/channel-edit` — form reads and exact source edits for the `sms` and `whatsapp`
|
|
28
|
-
channel bodies (`readSmsChannel`, `editSmsChannel`, `readWhatsAppChannel`,
|
|
29
|
-
`editWhatsAppChannel`). Text between a body's expressions is editable; an expression,
|
|
30
|
-
conditional or element is a locked segment that no edit touches. Each edit is a list of
|
|
31
|
-
`SourceReplacement`s for `applySourceReplacements`. Browser-safe: Babel parser only.
|
|
32
|
-
- `@samva/markup/render-ir` — `renderIr(ir, input, { locale, timeZone })`, plus `renderIrSms` and
|
|
33
|
-
`renderIrWhatsApp`. Dependency-free and the send-time security boundary. `@samva/markup/ir` holds
|
|
34
|
-
the IR types and `SML_IR_VERSION`.
|
|
16
|
+
`SmlTemplate`, `TemplateInput`, and `TEMPLATE_ID_PATTERN` (lowercase kebab-case, the rule the CLI
|
|
17
|
+
and API slugs share). `email` is `{ subject, preheader?, body }`; each is a function of the
|
|
18
|
+
validated input.
|
|
19
|
+
- `@samva/markup/email` — email primitives (`Email`, `Section`, `Columns`, `Button`, and the rest of
|
|
20
|
+
its exports). They generate table layout and classic-Outlook fallbacks. Set
|
|
21
|
+
`jsxImportSource: "@samva/markup/email"`; the runtime is `@samva/markup/email/jsx-runtime`.
|
|
35
22
|
- `@samva/markup/fmt` — `fmt.money`, `number`, `date`, `time`, `plural` and `list`: the only
|
|
36
23
|
functions a body may call.
|
|
37
24
|
- `@samva/markup/sms` and `@samva/markup/whatsapp` — the channel components (`Sms`; `WhatsApp` with
|
|
38
25
|
`WhatsApp.Header`, `Body`, `Footer`, `Buttons`, `UrlButton`, `QuickReplyButton`, `PhoneButton`,
|
|
39
26
|
`CopyCodeButton`). `whatsappTemplate` derives Meta's positional `{{n}}` text.
|
|
40
|
-
- `@samva/markup/template` — `defineTemplate`, `SmlTemplate`, `TemplateInput`, and
|
|
41
|
-
`TEMPLATE_NAME_PATTERN`.
|
|
42
|
-
- `@samva/markup/preview` — `renderIrPreview(ir, input)`: the render an editor shows, with an
|
|
43
|
-
instance path (`INSTANCE_PATH_ATTRIBUTE`) stamped on every element and the `selections` that map
|
|
44
|
-
each one to the span of TSX that produced it.
|
|
45
|
-
- `@samva/markup/email` — the JSX runtime. Set `jsxImportSource: "@samva/markup/email"` for email
|
|
46
|
-
entries.
|
|
47
|
-
- `@samva/markup/email/components` — email primitives (`Email`, `Section`, `Columns`, `Button`,
|
|
48
|
-
and the rest of its exports). They generate table layout and classic-Outlook fallbacks.
|
|
49
|
-
- `@samva/markup/email/render` — `compileEmail(tree)` and `renderEmailContent`, which lower a
|
|
50
|
-
derived email tree to HTML and text.
|
|
51
|
-
- `@samva/markup/email/diagnostics` — `EmailDiagnostic` and `EmailCompileError`.
|
|
52
|
-
- `@samva/markup/email/assets` — `isAssetPath` and `ASSET_CONTENT_TYPES`: which imported files
|
|
53
|
-
become content-addressed assets, without loading the compiler.
|
|
54
27
|
- `@samva/markup/input-schema` — `inputSchema`, which turns any Standard JSON Schema into the
|
|
55
28
|
portable JSON Schema and validator a template's input is checked against.
|
|
56
|
-
- `@samva/markup/compiler` — the compiler's building blocks (`transformProject`, Tailwind, the
|
|
57
|
-
cascade, diagnostics). It imports no Vite, esbuild, or Node builtins, so it runs in any
|
|
58
|
-
JavaScript host.
|
|
59
29
|
- `samva:brand` — `BrandLogo` (light logo, swapped for the dark one where the client honors dark
|
|
60
30
|
mode) and `BrandFooter` (company, postal address, social links and the unsubscribe row the send
|
|
61
31
|
path fills). The compiler binds them to the brand the build resolves; add
|
|
62
32
|
`"types": ["@samva/markup/samva-brand"]` to the project's tsconfig for `tsc`. In `theme.css`,
|
|
63
33
|
`@import "samva:brand";` layers the brand theme; `samva:brand/<slug>` names one brand.
|
|
64
34
|
|
|
35
|
+
Tooling entries are what a host (Vite, the CLI, the editor, the API, the template agent) imports:
|
|
36
|
+
|
|
37
|
+
- `@samva/markup/compiler` — `compileTemplate`, which reads a project's files and returns the IR,
|
|
38
|
+
the fixtures, the assets and the diagnostics; `checkTemplateCompatibility` checks each fixture
|
|
39
|
+
against the client matrix and locates findings at source. `checkStaticProfile(source | files,
|
|
40
|
+
entry?)` is the synchronous structural check: it runs the compiler's lowering without Tailwind, a
|
|
41
|
+
brand or the files an import names, and returns only findings the source itself owns.
|
|
42
|
+
`introducedProfileErrors(before, after)` is what a visual edit is refused on. It also holds the
|
|
43
|
+
compiler's building blocks (`transformProject`, Tailwind, the cascade, CSS), the brand footer and
|
|
44
|
+
sample renders (`renderBrandFooter`, `renderBrandSample`), and `TEMPLATE_NAME_PATTERN`. It imports no Vite, esbuild, or Node builtins, so it runs in any
|
|
45
|
+
JavaScript host.
|
|
46
|
+
- `@samva/markup/diagnostics` — source spans and line maps, the `DIAGNOSTIC_CODES` registry with
|
|
47
|
+
each code's fix and upgrade recipe, and `EmailDiagnostic`/`EmailCompileError`. It does not load
|
|
48
|
+
the compiler, so a host that only reports imports it.
|
|
49
|
+
- `@samva/markup/render` — `renderIr(ir, input, { locale, timeZone })`, `renderIrSms` and
|
|
50
|
+
`renderIrWhatsApp`; the IR types and `SML_IR_VERSION`; `renderIrPreview(ir, input)`, the render an
|
|
51
|
+
editor shows, with an instance path (`INSTANCE_PATH_ATTRIBUTE`) on every element and the
|
|
52
|
+
`selections` that map each one to its TSX span; `compileEmail`, the HTML serializer and text
|
|
53
|
+
derivation; the email element table; SMS segment counts. Its import closure excludes the
|
|
54
|
+
compiler's libraries (`tests/entry-closure.test.ts`): it is the send-time security boundary and
|
|
55
|
+
what the API bundles.
|
|
56
|
+
- `@samva/markup/edit` — the code transforms behind visual edits (`inspectSourceElement`,
|
|
57
|
+
`literalReplacement`, `expressionReplacement`, `classNameEdit`, `structuralReplacements`,
|
|
58
|
+
`applySourceReplacements` with a `ProfileGuard`); form reads and exact edits for the `sms` and
|
|
59
|
+
`whatsapp` channel bodies (`readSmsChannel`, `editSmsChannel`, `readWhatsAppChannel`,
|
|
60
|
+
`editWhatsAppChannel`), where text between expressions is editable and every expression,
|
|
61
|
+
conditional or element is a locked segment; and JSX source locations. Browser-safe: Babel parser
|
|
62
|
+
only.
|
|
63
|
+
- `@samva/markup/brand` — brand records and their CSS model (`parseBrandCss`, `printBrandCss`), the
|
|
64
|
+
footer markers a send reads (`renderedFooterMarkers`, `withoutUnsubscribeRow`), and project
|
|
65
|
+
assets (`isAssetPath`, `ASSET_CONTENT_TYPES`, `assetUrl`): which imported files become
|
|
66
|
+
content-addressed assets. The send path imports it, so its closure holds only the css-tree parser
|
|
67
|
+
`theme.css` needs; rendering a footer compiles Tailwind and lives in `./compiler`.
|
|
68
|
+
|
|
69
|
+
`tests/published-dependencies.test.ts` pins this list. The compiler's libraries (Babel, Tailwind,
|
|
70
|
+
css-tree, caniemail) are dependencies, because a template project depends on this package alone and
|
|
71
|
+
`samva templates check` runs its installed compiler.
|
|
72
|
+
|
|
65
73
|
The package ships what an agent needs to author without this repository:
|
|
66
74
|
|
|
67
75
|
- `@samva/markup/contract.json` (`generated/contract.json`) — components with their props, the
|
|
68
76
|
static-profile forms and the forms it refuses, formatters, HTML elements, channel specs and every
|
|
69
|
-
diagnostic code with its fix.
|
|
77
|
+
diagnostic code with its fix. `@samva/markup/reference.md` renders the same contract for reading.
|
|
70
78
|
`bun run codegen:contract` writes both from the modules that own each fact (component and `Fmt`
|
|
71
79
|
interfaces, `PROFILE_FORMS`, `DIAGNOSTIC_CODES`, the element table), and a test fails when they
|
|
72
80
|
drift.
|
|
@@ -98,7 +106,7 @@ Read the contract before authoring. Import only subpaths declared in `package.js
|
|
|
98
106
|
- **Passing a string where you want markup.** Nothing an author passes as a string becomes markup;
|
|
99
107
|
strings render as escaped text. There is no raw-HTML escape hatch: compatibility markup comes only
|
|
100
108
|
from the email primitives.
|
|
101
|
-
- **Using an element or attribute the serializer does not allow.** `@samva/markup/
|
|
109
|
+
- **Using an element or attribute the serializer does not allow.** `@samva/markup/render` is
|
|
102
110
|
the one table behind both the JSX intrinsic prop types and the serializer's allowlist, so an
|
|
103
111
|
unsupported element or attribute fails at typecheck and again at compile with a source location.
|
|
104
112
|
- **Naming a template or fixture like a path.** A template id and a fixture key are both written
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
## @samva/markup@0.10.0
|
|
2
|
+
|
|
3
|
+
### Breaking: `@samva/markup` publishes 17 entries in two tiers
|
|
4
|
+
|
|
5
|
+
Template files import `@samva/markup`, `@samva/markup/email`, `@samva/markup/fmt`,
|
|
6
|
+
`@samva/markup/sms`, `@samva/markup/whatsapp` and `@samva/markup/input-schema`. Email components
|
|
7
|
+
move from `@samva/markup/email/components` to `@samva/markup/email`, the entry `jsxImportSource`
|
|
8
|
+
already names. A template that still imports the old path fails with `moved-import`, which names
|
|
9
|
+
the replacement.
|
|
10
|
+
|
|
11
|
+
Hosts import five tooling entries:
|
|
12
|
+
|
|
13
|
+
| Entry | Replaces |
|
|
14
|
+
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `@samva/markup/compiler` | `./compiler`, `./static`, `./template` (`TEMPLATE_NAME_PATTERN`), `./email/brand-footer` |
|
|
16
|
+
| `@samva/markup/diagnostics` | `./diagnostics`, `./diagnostic-codes`, `./email/diagnostics` |
|
|
17
|
+
| `@samva/markup/render` | `./ir`, `./render-ir`, `./preview`, `./email/render`, `./email/html`, `./email/text`, `./email/elements`, `./sms-segments` |
|
|
18
|
+
| `@samva/markup/edit` | `./source-edit`, `./channel-edit`, `./source-locations` |
|
|
19
|
+
| `@samva/markup/brand` | `./email/brand`, `./email/assets`, `./theme-css` |
|
|
20
|
+
|
|
21
|
+
`@samva/markup/reference.md` replaces `@samva/markup/generated/*`. `tailwindcss`, `css-tree`,
|
|
22
|
+
`caniemail` and `@babel/parser` are dependencies instead of optional peers, so a project that
|
|
23
|
+
depends on `@samva/markup` alone can run `samva templates check`.
|
|
24
|
+
|
|
25
|
+
## @samva/markup@0.9.0
|
|
26
|
+
|
|
27
|
+
### Breaking: remove textual email SML APIs
|
|
28
|
+
|
|
29
|
+
`@samva/markup` removes textual email SML components and grammar types, plus the
|
|
30
|
+
`@samva/markup/candidate`, `/classes`, `/checks`, `/model`, `/ops`, `/registry`, and `/tsx-tracer`
|
|
31
|
+
subpaths. Email templates use TSX `defineEmail` modules and lower directly to subject, HTML, and text
|
|
32
|
+
through the email semantic tree. The structured SML language and compiler remain for SMS and
|
|
33
|
+
WhatsApp.
|
|
34
|
+
|
|
35
|
+
`@samva/vite` removes `darkClassCount` from the public `AuthoringValidationSummary` returned by its
|
|
36
|
+
emit API. Email validation no longer reports a count derived from textual email SML classes.
|
|
37
|
+
|
|
38
|
+
### Breaking: the executing template runtime and the textual SML grammar are removed
|
|
39
|
+
|
|
40
|
+
A template is `defineTemplate` in the static profile, compiled to IR; nothing in `@samva/markup`
|
|
41
|
+
runs a template any more.
|
|
42
|
+
|
|
43
|
+
- **Removed.** `defineEmail`, `isTemplateDefinition`, `TemplateDefinition`, `TemplateRuntime`,
|
|
44
|
+
`renderEmail` and `bindStylesheets`; `compileEmailProject` and the generated entry, reset and
|
|
45
|
+
stylesheet-registry modules (`@samva/markup/email/stylesheets`); the TSX source instrumentation and
|
|
46
|
+
runtime tracing (`@samva/markup/tsx-source-instrumentation`, `@samva/markup/email/selection`); and
|
|
47
|
+
the textual structured SML grammar with its JSX runtime and components
|
|
48
|
+
(`@samva/markup/{ast,components,compile,compile-sms,compile-whatsapp,conditionals,emit,
|
|
49
|
+
interpolate,jsx-runtime,jsx-dev-runtime,lexer,parser,predicate,printer,render-template,variables}`).
|
|
50
|
+
SMS and WhatsApp bodies are the `sms` and `whatsapp` fields of `defineTemplate`, written with
|
|
51
|
+
`Sms` from `@samva/markup/sms` and `WhatsApp` from `@samva/markup/whatsapp`.
|
|
52
|
+
- **`@samva/markup/preview`** adds `renderIrPreview`, which renders a fixture from the IR with an
|
|
53
|
+
instance path on every element and the selection each path resolves to, taken from the source
|
|
54
|
+
spans the compiler recorded. The selection helpers that lived in `email/selection` move here.
|
|
55
|
+
- **`@samva/markup/source-edit`** (moved from `email/source-edit`) is the set of code transforms behind
|
|
56
|
+
visual edits: text, attributes, `className`, and inserting, duplicating, moving and deleting
|
|
57
|
+
elements. `checkStaticProfile` in `@samva/markup/static` refuses an edit that would leave the
|
|
58
|
+
static profile. `@samva/markup/channel-edit` does the same for `sms` and `whatsapp` bodies.
|
|
59
|
+
- **`TemplateInput`** reads the caller input from a template's `schema`.
|
|
60
|
+
|
|
61
|
+
### Breaking: templates are `defineTemplate` in a static profile
|
|
62
|
+
|
|
63
|
+
`@samva/markup` adds `defineTemplate({ id, schema, fixtures, locale?, email, sms?, whatsapp? })` at
|
|
64
|
+
its root. A template is one TSX file in a static profile that the new compiler reads without running:
|
|
65
|
+
text and attribute bindings, template strings, `&&`, `?:`, comparisons, `||`, `.length`, `.map`,
|
|
66
|
+
`fmt.*` calls, arithmetic inside formatter arguments and conditions, partials with props and
|
|
67
|
+
children, conditional class names, `.filter(condition)` before `.map` or `.length`, and
|
|
68
|
+
`<Columns each per>` for grids (a `Column` without a `width` takes an equal share of its row). Everything else is a compile error with a stable code, a
|
|
69
|
+
`file:line:column` location and a fix.
|
|
70
|
+
|
|
71
|
+
- `@samva/markup/static` compiles a project to a versioned JSON IR (`"sml": 1`) and checks every
|
|
72
|
+
binding against the input schema: `unknown-field` with a did-you-mean, `unguarded-optional`, and
|
|
73
|
+
`fixture-invalid` per fixture. Tailwind, project CSS, brand themes, fonts and assets resolve at
|
|
74
|
+
compile time, and `checkTemplateCompatibility` locates client findings at source.
|
|
75
|
+
- `@samva/markup/render-ir` renders the IR against an input as a pure, dependency-free function.
|
|
76
|
+
It escapes for text, attribute and URL contexts and rejects unsafe bound values.
|
|
77
|
+
- `@samva/markup/fmt` adds the deterministic formatters `money`, `number`, `date`, `time`, `plural`
|
|
78
|
+
and `list`, which take their locale and time zone from the render.
|
|
79
|
+
- `@samva/markup/sms` and `@samva/markup/whatsapp` add channel components with distinct names per
|
|
80
|
+
channel; WhatsApp bindings become Meta's positional `{{n}}` placeholders.
|
|
81
|
+
- `id` is lowercase kebab-case, the rule the CLI and API slugs share. `subject` and `preheader`
|
|
82
|
+
belong to the channel; the `Email` component no longer takes a `preheader` prop.
|
|
83
|
+
|
|
84
|
+
`defineEmail` remains for templates that compute over their input, and it stays outside the static
|
|
85
|
+
profile.
|
|
86
|
+
|
|
87
|
+
### Agents get a contract, a skill and a `templates/` root
|
|
88
|
+
|
|
89
|
+
- **`@samva/markup`.** Ships `@samva/markup/contract.json` and `generated/reference.md`, generated
|
|
90
|
+
from the compiler: component props, the static-profile forms and the forms it refuses, formatters,
|
|
91
|
+
HTML elements and every diagnostic code with its fix. The `sml` skill ships in the package under
|
|
92
|
+
`skills/sml`. Every compiler finding now comes from one registry of codes
|
|
93
|
+
(`DIAGNOSTIC_CODES`). The generated `sml-*-contract.json` and `sml-*-reference.md` files are
|
|
94
|
+
replaced by these two.
|
|
95
|
+
- **Entry root.** New hosted projects, the starter and the gallery use `templates/` as the entry
|
|
96
|
+
root. `emails/` is still accepted for entry paths in the API, the SDK types and the CLI
|
|
97
|
+
(`samva templates add`, `move`, `publish`).
|
|
98
|
+
|
|
99
|
+
## @samva/markup@0.8.0
|
|
100
|
+
|
|
101
|
+
### Breaking: `@samva/markup/presets` is `@samva/markup/starters`
|
|
102
|
+
|
|
103
|
+
Every `@samva/markup/presets*` subpath is renamed to `@samva/markup/starters*`, and its exports
|
|
104
|
+
follow: `presetCatalog` is `starterCatalog`, `presetProject` is `starterProject`,
|
|
105
|
+
`presetEmailFixtures` is `starterEmailFixtures`, and every other `preset*` / `Preset*` name reads
|
|
106
|
+
`starter*` / `Starter*`. A public gallery entry's `presetId` is `starterId`, and the corpus
|
|
107
|
+
record types are `OwnedEditableStarter` and `BrandRecreationStarter`. `RECOMMENDED_THEME` and
|
|
108
|
+
`showcaseProjectPaths` are removed.
|
|
109
|
+
|
|
110
|
+
### Starters on theme variables
|
|
111
|
+
|
|
112
|
+
Every starter styles each color and font through a theme variable, and keeps its look in its own
|
|
113
|
+
`starter.css`. `@samva/markup/starters/theme` names the variables every starter defines and a
|
|
114
|
+
brand sets to restyle one (`STARTER_THEME_VARIABLES`: `--color-brand`, `--color-surface`,
|
|
115
|
+
`--font-body` and the rest; `starterThemeVariableNames` adds each color's `-dark` pair) and writes
|
|
116
|
+
the `theme.css` a project starts with (`starterThemeCss({ brand })`), which imports `samva:brand`
|
|
117
|
+
only when `brand` is true:
|
|
118
|
+
|
|
119
|
+
```css
|
|
120
|
+
@import "./starter.css";
|
|
121
|
+
@import "samva:brand";
|
|
122
|
+
@theme {
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`var()` now resolves in a `Button`'s classic Outlook shape and in a `bgcolor`, so
|
|
127
|
+
`<Button backgroundColor="var(--color-brand)">` paints the theme color everywhere. Every `@theme`
|
|
128
|
+
in project and brand CSS compiles as `static`, so a variable a project stylesheet reads reaches
|
|
129
|
+
the inliner even when no utility class reads it.
|
|
130
|
+
|
|
131
|
+
### Theme imports and brand themes
|
|
132
|
+
|
|
133
|
+
A project `theme.css` layers with `@import`: another project stylesheet by relative path, then the
|
|
134
|
+
organization's brand, then the project's own `@theme` overrides.
|
|
135
|
+
|
|
136
|
+
```css
|
|
137
|
+
@import "./starter.css";
|
|
138
|
+
@import "samva:brand";
|
|
139
|
+
|
|
140
|
+
@theme {
|
|
141
|
+
--color-accent: #0f766e;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`samva:brand` names the organization's default brand and `samva:brand/<slug>` names one brand; the
|
|
146
|
+
build supplies it through `compileEmailProject`'s `brand` option. `parseBrandCss` and
|
|
147
|
+
`printBrandCss` (`@samva/markup/theme-css`) read and write the brand theme grammar: `@theme`
|
|
148
|
+
variables in the color, font, text, leading, tracking, radius, spacing, container and shadow
|
|
149
|
+
namespaces, `--color-*` variables in a `@media (prefers-color-scheme: dark)` block, and
|
|
150
|
+
`@font-face` rules with https WOFF2 sources. A dark-mode color compiles to its `--color-*-dark`
|
|
151
|
+
theme variable, read by `dark:` utilities.
|
|
152
|
+
|
|
153
|
+
A project compiles against one brand: importing two fails with `brand-import-conflict`, and a
|
|
154
|
+
`samva:brand` import the build has no brand for, or whose slug names another brand, fails with
|
|
155
|
+
`brand-unavailable`. A brand theme outside the grammar fails with its `brand-css-*` finding.
|
|
156
|
+
`@samva/markup/compiler` exports `parseBrandSpecifier`, `projectBrandSpecifier` and the
|
|
157
|
+
`EmailBrand` types.
|
|
158
|
+
|
|
159
|
+
Breaking: any other `@import` in the theme — including `@import "tailwindcss"` — now refuses the
|
|
160
|
+
compile with `css-import-unresolved` instead of resolving to nothing. An `@import` with layer,
|
|
161
|
+
supports or media conditions, one that imports itself, or a `.css` path outside the project is
|
|
162
|
+
refused the same way. A theme with no utility class in use still compiles its `@font-face` rules.
|
|
163
|
+
|
|
164
|
+
### `BrandLogo` and `BrandFooter`
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { BrandFooter, BrandLogo } from "samva:brand";
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`BrandLogo` renders the brand's logo and swaps to its dark logo where the client honors dark mode.
|
|
171
|
+
It takes `width` (default 120), `alt`, `align` and `className`, and renders nothing when the brand
|
|
172
|
+
has no logo. `BrandFooter` takes `unsubscribeLabel` and `className`.
|
|
173
|
+
`BrandFooter` renders the company name, postal address, social links and an unsubscribe row; the
|
|
174
|
+
send path fills the unsubscribe link per delivery and never click-tracks it, and a template that
|
|
175
|
+
renders `BrandFooter` gets no appended footer. Add `"types": ["@samva/markup/samva-brand"]` to the
|
|
176
|
+
project's tsconfig so `tsc` knows the module.
|
|
177
|
+
|
|
178
|
+
### Breaking: token-table exports removed
|
|
179
|
+
|
|
180
|
+
`@samva/markup/footer`, `@samva/markup/theme`, and `@samva/markup/tokens` are removed; a brand's
|
|
181
|
+
footer renders through `BrandFooter`. `parseThemeCss` and `printThemeCss` are replaced by
|
|
182
|
+
`parseBrandCss` and `printBrandCss` in `@samva/markup/theme-css`.
|
|
183
|
+
|
|
184
|
+
### Local builds resolve `samva:brand`
|
|
185
|
+
|
|
186
|
+
`samvaEditor()`, `buildTemplates()` and `exportEmailProject()` compile a project that imports
|
|
187
|
+
`samva:brand` or `samva:brand/<slug>` against its organization's brand, resolved in this order:
|
|
188
|
+
|
|
189
|
+
1. Live. With `SAMVA_API_KEY` in the environment or the project's `.env` (and `SAMVA_API_URL` for
|
|
190
|
+
another API), the brand is fetched from `/v1/brands`. Without one, the `samva` CLI on `PATH`
|
|
191
|
+
answers `samva brands get --json` with its `samva login` session; `@samva/vite` stores no
|
|
192
|
+
credential.
|
|
193
|
+
2. Snapshot. `.samva/brands/<slug>.json`, written by `samva brands pull [slug]`, with a
|
|
194
|
+
`brand-offline` warning. The default brand reads the most recent snapshot pulled while it was
|
|
195
|
+
the default.
|
|
196
|
+
3. Neither. The build fails with `brand-unavailable`, naming both fixes.
|
|
197
|
+
|
|
198
|
+
When the live brand's digest differs from the snapshot's, the build warns with
|
|
199
|
+
`brand-snapshot-stale`; run `samva brands pull` again. Warnings are build diagnostics and editor log
|
|
200
|
+
lines and never fail a build. The editor and `check --watch` reuse a resolution for up to 30
|
|
201
|
+
seconds. Keep `.samva` in `.gitignore`; a project that imports no brand needs no credentials.
|
|
202
|
+
|
|
203
|
+
`@samva/vite/project` exports `resolveProjectBrand`, `loadBrandEnv`, `BRAND_SNAPSHOT_DIR` and the
|
|
204
|
+
`BrandResolution`, `BrandSnapshot`, `BrandWarning` and `ResolvedBrand` types. The editor recompiles
|
|
205
|
+
the theme when any stylesheet it imports changes.
|
|
206
|
+
|
|
207
|
+
### Breaking: `exportEmailProject` themes the export
|
|
208
|
+
|
|
209
|
+
`exportEmailProject` drops `tailwind` and takes `root` and `theme`. `dir` holds the templates and
|
|
210
|
+
`root` (default `dir`) is the project: its `theme.css` themes the export as in `buildTemplates()`,
|
|
211
|
+
`theme` names another file or `false` disables it, and only `.tsx` files under `dir` are entries.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
const receipt = await exportEmailProject({ dir: "emails", root: ".", out: "dist/email" });
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Project fonts in `@font-face`
|
|
218
|
+
|
|
219
|
+
A template project declares a webfont with ordinary CSS: an `@font-face` in `theme.css` (or any
|
|
220
|
+
imported stylesheet) whose `src` names a `.woff2` file in the project, plus a `--font-*` token in
|
|
221
|
+
`@theme`.
|
|
222
|
+
|
|
223
|
+
```css
|
|
224
|
+
@font-face {
|
|
225
|
+
font-family: "Brand Sans";
|
|
226
|
+
src: url("./fonts/brand-sans.woff2") format("woff2");
|
|
227
|
+
font-weight: 400;
|
|
228
|
+
}
|
|
229
|
+
@theme {
|
|
230
|
+
--font-brand: "Brand Sans", Helvetica, Arial, sans-serif;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The compiler serves the file as a content-addressed asset, so local previews, exports and
|
|
235
|
+
publications all load the same bytes, and it puts the rule in a `<style>` classic Outlook does not
|
|
236
|
+
read, so Outlook uses the rest of the stack instead of Times New Roman.
|
|
237
|
+
|
|
238
|
+
Breaking for projects that already declared fonts: a relative `src` that names no project file, a
|
|
239
|
+
source that is not WOFF2, and an `http:` or `data:` source are compile errors, and a `font-family`
|
|
240
|
+
stack that names a project font without ending in a generic family fails with
|
|
241
|
+
`email-font-fallback`. `Stylesheet` gains `fontFaces`, and `@font-face` no longer appears in
|
|
242
|
+
`headAtRules`.
|
|
243
|
+
|
|
244
|
+
## @samva/markup@0.7.0
|
|
245
|
+
|
|
246
|
+
### Breaking: WhatsApp `category="service"` removed
|
|
247
|
+
|
|
248
|
+
`<WhatsApp category>` accepts `marketing`, `utility`, or `authentication`, the categories Meta
|
|
249
|
+
approves templates under.
|
|
250
|
+
|
|
251
|
+
## @samva/markup@0.6.0
|
|
252
|
+
|
|
253
|
+
### Improve markup compilation safety
|
|
254
|
+
|
|
255
|
+
Invalid or unsafe markup is now rejected earlier, preventing malformed email output. Complex styles
|
|
256
|
+
and conditions also compile more reliably.
|
|
257
|
+
|
|
258
|
+
### Carry the plain-text alternative on a public preview artifact
|
|
259
|
+
|
|
260
|
+
`buildPublicTemplatePreviewArtifact` returns `text` alongside `html`, `subject` and `preheader`, so
|
|
261
|
+
a surface that mounts a preset's published preview has the whole executed fixture rather than its
|
|
262
|
+
HTML half. It is the same value `renderEmail` derived when the artifact was built; nothing is
|
|
263
|
+
recomputed.
|
|
264
|
+
|
|
265
|
+
## @samva/markup@0.5.0
|
|
266
|
+
|
|
267
|
+
### Breaking: a template project no longer installs Effect
|
|
268
|
+
|
|
269
|
+
- **A much smaller install:** `@samva/markup` has no Effect dependency and no `ajv` dependency, so a template project's lockfile and `node_modules` drop both graphs. The JSON Schema 2020-12 dialect the input validator checks against ships inside the package. Writing templates is unchanged: JSX, `defineEmail`, components, fixtures, and the input schema all work exactly as before, and you can still declare template input with an Effect, Zod, or plain JSON schema.
|
|
270
|
+
- **`@samva/vite` drops Effect too:** The Vite plugin carries no Effect dependency either, so `samva email templates build`, the editor dev server, and a template project that installs both packages resolve neither graph.
|
|
271
|
+
- **Breaking: compile and render results:** Everything the compiler returns is now a [better-result](https://better-result.dev) `Result`. Read a success with `Result.isOk(result)` and `result.value`, a failure with `Result.isError(result)` and `result.error`. Errors keep their names and tags — `SmlParseError`, `SmlCompileError`, `SmlOpError`, `EmailCompileError` — so code that matches on `_tag` or catches `EmailCompileError` still works.
|
|
272
|
+
- **Breaking: data unions discriminate on `type`:** `EmailNode` and the editor-op, corpus and gallery unions name their variant with `type` instead of `_tag` — `node.type === "Element"`, `op.type === "setProp"`. Compiler errors are unaffected: `SmlParseError`, `SmlCompileError`, `SmlOpError` and `EmailCompileError` keep `_tag`, which is their error library's own field.
|
|
273
|
+
- **Breaking: schema values are gone:** The package declares its data models as TypeScript types only. Runtime schema values such as `EmailDiagnostic`, `EmailElementSelection`, `SmlOpSchema`, and `SmlDocumentSchema` no longer exist; the types of the same name do, and the shapes are identical. If you decoded one of these at a boundary, declare the schema in your own project against the exported type.
|
|
274
|
+
|
|
275
|
+
## @samva/markup@0.4.0
|
|
276
|
+
|
|
277
|
+
### Faster, reliable saves in large projects
|
|
278
|
+
|
|
279
|
+
- **Saves in large projects are quick again:** Saving a template no longer re-evaluates every template in the project, so previews come back in about the time one template takes to build.
|
|
280
|
+
- **No false "Document changed elsewhere" banner:** Your own edits and fixture switches are recognized as yours, so the editor no longer locks the source panel and undo after a save. Edits made outside the editor are still detected.
|
|
281
|
+
|
|
282
|
+
### Breaking: every email template is a complete, editable project
|
|
283
|
+
|
|
284
|
+
- **28 templates rebuilt:** The 28 remaining single-file presets are rebuilt as showcase projects with their own stylesheet, drawn artwork, and `default` and `long-content` sample data. Marketing, digest, lifecycle, commerce, and notification templates are covered, authored for five fictional senders: Northwick, Kestrel, Northloop, Fernhollow, and Meridian. Template ids and their gallery pages are unchanged.
|
|
285
|
+
- **Breaking: simpler template inputs:** Repeating content such as stories, deals, agenda items, checklist steps, and order lines is a list instead of numbered fields. Images are bundled with the project instead of passed as URLs, and headline and body copy is edited in the template source rather than supplied as input. Optional sections such as sponsors, gift cards, and reminders appear only when you send them. Dates, days remaining, and step numbers come from your input, so scheduled sends never depend on the clock. If you render one of these templates with your own data, move to the new input shape; each template's sample data shows it.
|
|
286
|
+
- **Breaking: four presets retired:** `receipt`, `newsletter`, `promo`, and `order-delivered` are removed from the catalog, the public gallery, and the `PresetId` types. Use `order-receipt`, `product-newsletter`, and `product-launch-promo` instead.
|
|
287
|
+
- **Stock photography removed:** The onboarding tour and setup checklist templates now use drawn artwork, so no template depends on third-party images.
|
|
288
|
+
|
|
289
|
+
## @samva/markup@0.3.0
|
|
290
|
+
|
|
291
|
+
- **Reliable project styling:** Switching between projects or preview fixtures preserves each template's styles and avoids unexpected revision changes.
|
|
292
|
+
- **Better Outlook buttons:** `<Button>` sizes to its label without requiring a fixed width. Explicit widths remain supported.
|
|
293
|
+
- **New editable templates:** Product newsletter, order receipt, product launch promotion, and an attributed Vercel invitation, including styles, images, and sample data.
|
|
294
|
+
- **Richer template inputs:** Use lists and objects for repeating content such as newsletter stories and receipt items.
|
|
295
|
+
- **Cleaner plain-text emails:** Empty table cells no longer leave unnecessary separators.
|
|
296
|
+
- **For custom render integrations:** `bindStylesheets` from `@samva/markup/email/render` binds a renderer to one project's styles.
|
|
297
|
+
|
|
298
|
+
## @samva/markup@0.2.0
|
|
299
|
+
|
|
300
|
+
### Breaking: author email templates with typed input and executable TSX
|
|
301
|
+
|
|
302
|
+
Email entries now default-export `defineEmail({ id, schema, fixtures, render })` from
|
|
303
|
+
`@samva/markup/template`. Replace function-based email entries and `Variables<T>` placeholders
|
|
304
|
+
with a schema and a `render(input)` function. Set `jsxImportSource` to `@samva/markup/email`,
|
|
305
|
+
import email components from `@samva/markup/email/components`, and upgrade `@samva/markup` and
|
|
306
|
+
`@samva/vite` together to 0.2.0. Regenerate the project's dependency lockfile before publishing.
|
|
307
|
+
|
|
308
|
+
The input contract supports Standard JSON Schema, including Effect and Zod schema adapters.
|
|
309
|
+
`TemplateInput<typeof template>` extracts the inferred input type. Named fixtures supply preview
|
|
310
|
+
and validation inputs; rendering evaluates ordinary TSX, imported components, conditionals and
|
|
311
|
+
mapped arrays against actual input. Time and randomness must come from input or fixed `runtime`
|
|
312
|
+
configuration.
|
|
313
|
+
|
|
314
|
+
The shared local and hosted compiler resolves CSS, Tailwind and imported assets, validates fixture
|
|
315
|
+
inputs, and produces HTML, text and email-client diagnostics. Diagnostics identify known support
|
|
316
|
+
constraints; they do not certify rendering in every email client.
|
|
317
|
+
|
|
318
|
+
The Vite editor maps rendered instances to canonical TSX source. Literal edits preserve the
|
|
319
|
+
source expression; computed or structural changes use reviewed source edits. Fixture switching,
|
|
320
|
+
undo/redo, save/reopen and revision-conflict handling keep source edits tied to the preview.
|
|
321
|
+
|
|
322
|
+
Published email templates pin an executable, input contract, dependency graph and runtime
|
|
323
|
+
configuration. Existing email source must adopt the new contract and be republished; previously
|
|
324
|
+
published HTML snapshots are not executable publications.
|
|
325
|
+
|
|
326
|
+
## @samva/markup@0.1.2
|
|
327
|
+
|
|
328
|
+
### Reject oversized SML templates before compilation
|
|
329
|
+
|
|
330
|
+
Templates that exceed supported size, nesting, or node limits now return a validation error before
|
|
331
|
+
compilation.
|
|
332
|
+
|
|
333
|
+
## @samva/markup@0.1.1
|
|
334
|
+
|
|
335
|
+
### Release the 0.1.1 package family
|
|
336
|
+
|
|
337
|
+
`@samva/markup` publishes with the rest of the 0.1.1 family.
|
|
338
|
+
|
|
339
|
+
## @samva/markup@0.1.0
|
|
340
|
+
|
|
341
|
+
### Publish the Samva template authoring toolchain
|
|
342
|
+
|
|
343
|
+
`@samva/markup` and `@samva/vite` are published on npm. They provide typed TSX authoring, local
|
|
344
|
+
visual editing, and deterministic template builds. `samva templates push` uploads the compiled
|
|
345
|
+
templates.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ template is one `.tsx` file that default-exports `defineTemplate`:
|
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
16
|
import { defineTemplate } from "@samva/markup";
|
|
17
|
-
import { Button, Email, Section } from "@samva/markup/email
|
|
17
|
+
import { Button, Email, Section } from "@samva/markup/email";
|
|
18
18
|
import { fmt } from "@samva/markup/fmt";
|
|
19
19
|
import { jsonSchema } from "@samva/markup/input-schema";
|
|
20
20
|
|
|
@@ -94,16 +94,16 @@ export default defineTemplate({
|
|
|
94
94
|
});
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
A template is read, not run. `@samva/markup/
|
|
97
|
+
A template is read, not run. `@samva/markup/compiler` parses the file and the project files it
|
|
98
98
|
imports without evaluating them, checks every binding against the schema, resolves Tailwind and CSS
|
|
99
99
|
against the markup, and produces the template's IR: JSON, versioned (`"sml": 1`), carrying the
|
|
100
|
-
markup, the bindings, the conditions, the loops and the formatters. `@samva/markup/render
|
|
100
|
+
markup, the bindings, the conditions, the loops and the formatters. `@samva/markup/render`
|
|
101
101
|
renders that IR against an input. It is a pure function with no dependencies, so nothing executes
|
|
102
102
|
at send time.
|
|
103
103
|
|
|
104
104
|
```ts
|
|
105
|
-
import { renderIr } from "@samva/markup/render
|
|
106
|
-
import { compileTemplate } from "@samva/markup/
|
|
105
|
+
import { renderIr } from "@samva/markup/render";
|
|
106
|
+
import { compileTemplate } from "@samva/markup/compiler";
|
|
107
107
|
|
|
108
108
|
const compiled = await compileTemplate({
|
|
109
109
|
files, // the project's files by path; binary files become content-addressed assets
|
|
@@ -232,7 +232,7 @@ for diagnostics an agent can apply.
|
|
|
232
232
|
|
|
233
233
|
### Previewing a render
|
|
234
234
|
|
|
235
|
-
`renderIrPreview(ir, input)` from `@samva/markup/
|
|
235
|
+
`renderIrPreview(ir, input)` from `@samva/markup/render` renders a fixture the way `renderIr` does
|
|
236
236
|
and stamps `data-samva-instance` on every element. Its `selections` map each stamped element to the
|
|
237
237
|
line and column of the JSX that produced it, so an editor can select an element on the canvas and
|
|
238
238
|
edit the source at that span. A delivered message never carries the attribute.
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The per-recipient unsubscribe URL is not known at render: the send path
|
|
5
|
-
* substitutes each delivery's link for this placeholder, or removes the
|
|
6
|
-
* unsubscribe row when the send resolved no unsubscribe group.
|
|
7
|
-
*/
|
|
8
|
-
declare const UNSUBSCRIBE_URL_PLACEHOLDER = "%samva:unsubscribe-url%";
|
|
9
|
-
//#endregion
|
|
1
|
+
import { r as EmailDiagnostic } from "./diagnostics-B-Gym34R.js";
|
|
2
|
+
import { r as EmailNode } from "./jsx-runtime-ylIOnaSf.js";
|
|
10
3
|
//#region src/email/brand.d.ts
|
|
11
4
|
interface EmailBrandAddress {
|
|
12
5
|
readonly street1: string;
|
|
@@ -84,5 +77,42 @@ declare const withoutUnsubscribeRow: (rendered: {
|
|
|
84
77
|
readonly text: string | undefined;
|
|
85
78
|
};
|
|
86
79
|
//#endregion
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
//#region src/email/assets.d.ts
|
|
81
|
+
/** Files a template may import, and what they are served as. */
|
|
82
|
+
declare const ASSET_CONTENT_TYPES: Readonly<Record<string, string>>;
|
|
83
|
+
interface AssetEntry {
|
|
84
|
+
/** Project-relative path the template imported. */
|
|
85
|
+
readonly path: string;
|
|
86
|
+
/** SHA-256 of the exact bytes, lowercase hex. */
|
|
87
|
+
readonly digest: string;
|
|
88
|
+
readonly bytes: number;
|
|
89
|
+
readonly contentType: string;
|
|
90
|
+
/** `<digest><ext>` — the name the asset has under any base. */
|
|
91
|
+
readonly fileName: string;
|
|
92
|
+
}
|
|
93
|
+
interface AssetManifest {
|
|
94
|
+
/** Where these assets are served from in this build. */
|
|
95
|
+
readonly base: string;
|
|
96
|
+
readonly assets: readonly AssetEntry[];
|
|
97
|
+
}
|
|
98
|
+
/** True when the compiler turns this import into a content-addressed asset. */
|
|
99
|
+
declare const isAssetPath: (path: string) => boolean;
|
|
100
|
+
/** Address one file by its content. */
|
|
101
|
+
declare const assetEntry: (path: string, bytes: Uint8Array) => Promise<AssetEntry>;
|
|
102
|
+
/**
|
|
103
|
+
* The URL an asset has under a base. The base is a build input: publication
|
|
104
|
+
* passes its hosted origin, and a local export passes whatever it will serve
|
|
105
|
+
* the exported files from.
|
|
106
|
+
*/
|
|
107
|
+
declare const assetUrl: (entry: AssetEntry, base: string) => string;
|
|
108
|
+
/** Record, but never fetch, a URL the template points at. */
|
|
109
|
+
declare const isExternalAsset: (reference: string) => boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Reject an asset base that would produce URLs a client will not load. The
|
|
112
|
+
* relative forms are the ones a page on disk resolves against its own
|
|
113
|
+
* directory, which is what a local export writes.
|
|
114
|
+
*/
|
|
115
|
+
declare const checkAssetBase: (base: string) => readonly EmailDiagnostic[];
|
|
116
|
+
//#endregion
|
|
117
|
+
export { withoutUnsubscribeRow as C, renderedFooterMarkers as S, EmailBrandSocialLink as _, assetUrl as a, UNSUBSCRIBE_ROW_ATTRIBUTE as b, isExternalAsset as c, BrandFooterProps as d, BrandLogoProps as f, EmailBrandFooter as g, EmailBrandAssets as h, assetEntry as i, BRAND_COMPONENT_CLASSES as l, EmailBrandAddress as m, AssetEntry as n, checkAssetBase as o, EmailBrand as p, AssetManifest as r, isAssetPath as s, ASSET_CONTENT_TYPES as t, BrandComponents as u, FOOTER_ATTRIBUTE as v, brandComponents as x, RenderedFooterMarkers as y };
|
|
118
|
+
//# sourceMappingURL=assets-BIsyMQ92.d.ts.map
|
|
@@ -1,5 +1,65 @@
|
|
|
1
|
-
import { i as UNSUBSCRIBE_URL_PLACEHOLDER, r as UNSUBSCRIBE_LINK, t as BRAND_FOOTER_MARKER } from "
|
|
2
|
-
import {
|
|
1
|
+
import { i as UNSUBSCRIBE_URL_PLACEHOLDER, r as UNSUBSCRIBE_LINK, t as BRAND_FOOTER_MARKER } from "./unsubscribe-link-CoesnQDU.js";
|
|
2
|
+
import { a as jsx, n as Fragment } from "./jsx-runtime-CBlexoeR.js";
|
|
3
|
+
//#region src/email/assets.ts
|
|
4
|
+
/** Files a template may import, and what they are served as. */
|
|
5
|
+
const ASSET_CONTENT_TYPES = {
|
|
6
|
+
".png": "image/png",
|
|
7
|
+
".jpg": "image/jpeg",
|
|
8
|
+
".jpeg": "image/jpeg",
|
|
9
|
+
".gif": "image/gif",
|
|
10
|
+
".webp": "image/webp",
|
|
11
|
+
".avif": "image/avif",
|
|
12
|
+
".svg": "image/svg+xml",
|
|
13
|
+
".ico": "image/x-icon",
|
|
14
|
+
".woff": "font/woff",
|
|
15
|
+
".woff2": "font/woff2",
|
|
16
|
+
".ttf": "font/ttf",
|
|
17
|
+
".otf": "font/otf",
|
|
18
|
+
".pdf": "application/pdf",
|
|
19
|
+
".txt": "text/plain"
|
|
20
|
+
};
|
|
21
|
+
const extensionOf = (path) => {
|
|
22
|
+
const dot = path.lastIndexOf(".");
|
|
23
|
+
return dot < 0 ? "" : path.slice(dot).toLowerCase();
|
|
24
|
+
};
|
|
25
|
+
/** True when the compiler turns this import into a content-addressed asset. */
|
|
26
|
+
const isAssetPath = (path) => Object.hasOwn(ASSET_CONTENT_TYPES, extensionOf(path));
|
|
27
|
+
const hex = (buffer) => Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
28
|
+
/** Address one file by its content. */
|
|
29
|
+
const assetEntry = async (path, bytes) => {
|
|
30
|
+
const extension = extensionOf(path);
|
|
31
|
+
const view = new Uint8Array(bytes.byteLength);
|
|
32
|
+
view.set(bytes);
|
|
33
|
+
const digest = hex(await crypto.subtle.digest("SHA-256", view));
|
|
34
|
+
return {
|
|
35
|
+
path,
|
|
36
|
+
digest,
|
|
37
|
+
bytes: bytes.byteLength,
|
|
38
|
+
contentType: ASSET_CONTENT_TYPES[extension] ?? "application/octet-stream",
|
|
39
|
+
fileName: `${digest}${extension}`
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The URL an asset has under a base. The base is a build input: publication
|
|
44
|
+
* passes its hosted origin, and a local export passes whatever it will serve
|
|
45
|
+
* the exported files from.
|
|
46
|
+
*/
|
|
47
|
+
const assetUrl = (entry, base) => `${base.replace(/\/+$/, "")}/${entry.fileName}`;
|
|
48
|
+
const EXTERNAL_IMAGE = /^https:\/\//i;
|
|
49
|
+
/** Record, but never fetch, a URL the template points at. */
|
|
50
|
+
const isExternalAsset = (reference) => EXTERNAL_IMAGE.test(reference);
|
|
51
|
+
/**
|
|
52
|
+
* Reject an asset base that would produce URLs a client will not load. The
|
|
53
|
+
* relative forms are the ones a page on disk resolves against its own
|
|
54
|
+
* directory, which is what a local export writes.
|
|
55
|
+
*/
|
|
56
|
+
const checkAssetBase = (base) => /^(https:\/\/|\.{1,2}\/|\/)/i.test(base) ? [] : [{
|
|
57
|
+
code: "invalid-asset-base",
|
|
58
|
+
severity: "error",
|
|
59
|
+
message: `Asset base ${JSON.stringify(base)} must be an https URL, an absolute path, or a relative path for a local export.`,
|
|
60
|
+
origins: []
|
|
61
|
+
}];
|
|
62
|
+
//#endregion
|
|
3
63
|
//#region src/email/brand.ts
|
|
4
64
|
/** Marks the block the send path recognizes as the template's own footer. */
|
|
5
65
|
const FOOTER_ATTRIBUTE = "data-samva-footer";
|
|
@@ -143,6 +203,6 @@ const withoutUnsubscribeRow = (rendered) => ({
|
|
|
143
203
|
text: rendered.text?.split("\n").filter((line) => !line.includes(UNSUBSCRIBE_URL_PLACEHOLDER)).join("\n")
|
|
144
204
|
});
|
|
145
205
|
//#endregion
|
|
146
|
-
export {
|
|
206
|
+
export { renderedFooterMarkers as a, assetEntry as c, isAssetPath as d, isExternalAsset as f, brandComponents as i, assetUrl as l, FOOTER_ATTRIBUTE as n, withoutUnsubscribeRow as o, UNSUBSCRIBE_ROW_ATTRIBUTE as r, ASSET_CONTENT_TYPES as s, BRAND_COMPONENT_CLASSES as t, checkAssetBase as u };
|
|
147
207
|
|
|
148
|
-
//# sourceMappingURL=brand.js.map
|
|
208
|
+
//# sourceMappingURL=brand-C0MKTwmX.js.map
|