@shware/workflow-ui 1.0.1 → 2.0.1

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.
@@ -1,9 +1,7 @@
1
1
  import {
2
2
  ConfigCompileError,
3
- type EmailAddress,
4
3
  type JourneyConfig,
5
4
  compileConfig,
6
- formatEmailAddress,
7
5
  isConfig,
8
6
  isDiscordTemplate,
9
7
  isEmailTemplate,
@@ -18,7 +16,7 @@ import type { ResolvedStudioConfig, StudioError } from '../config';
18
16
  *
19
17
  * workflow.config.ts default-exports `defineConfig({...})` from
20
18
  * `@shware/workflow`, and the studio reads exactly that: its workflows,
21
- * segments, actions, template registries, title and email envelope. It is
19
+ * segments, actions, template registries, title and what the email templates share. It is
22
20
  * compiled with `compileConfig`, the same compile the Worker deploys, so the
23
21
  * studio lists exactly what would ship.
24
22
  *
@@ -139,17 +137,13 @@ function errorOf(error: unknown): StudioError {
139
137
  };
140
138
  }
141
139
 
142
- function formatted(address: EmailAddress | undefined): string | undefined {
143
- return address === undefined ? undefined : formatEmailAddress(address);
144
- }
145
-
146
140
  function failed(error: unknown, title?: string): StudioSnapshot {
147
141
  return {
148
142
  payload: {
149
143
  ...(title !== undefined ? { title } : {}),
150
144
  workflows: {},
151
145
  segments: [],
152
- emailDefaults: {},
146
+ email: {},
153
147
  error: errorOf(error),
154
148
  },
155
149
  registries: { email: undefined, push: undefined, discord: undefined, slack: undefined },
@@ -188,13 +182,13 @@ export async function loadSnapshot(options: {
188
182
  return failed(error);
189
183
  }
190
184
 
191
- const from = formatted(config.emails?.from);
192
- const replyTo = formatted(config.emails?.replyTo);
185
+ const unsubscribeUrl = config.email?.unsubscribeUrl;
186
+ const quickClickMs = config.email?.tracking?.quickClickMs;
193
187
  const shared = {
194
188
  ...(config.title !== undefined ? { title: config.title } : {}),
195
- emailDefaults: {
196
- ...(from !== undefined ? { from } : {}),
197
- ...(replyTo !== undefined ? { replyTo } : {}),
189
+ email: {
190
+ ...(unsubscribeUrl !== undefined ? { unsubscribeUrl } : {}),
191
+ ...(quickClickMs !== undefined ? { tracking: { quickClickMs } } : {}),
198
192
  },
199
193
  };
200
194
 
package/src/server.ts CHANGED
@@ -476,8 +476,10 @@ export async function startStudio(options: StartOptions = {}): Promise<ViteDevSe
476
476
  ],
477
477
  },
478
478
  },
479
- // The app and the user's project each have their own react; one copy only
480
- resolve: { dedupe: ['react', 'react-dom'] },
479
+ // The app and the user's project each have their own react; one copy only. One
480
+ // @shware/workflow too: the preview's <EmailProvider> and the project's layout calling
481
+ // useEmailContext() must share the context object
482
+ resolve: { dedupe: ['react', 'react-dom', '@shware/workflow'] },
481
483
  /*
482
484
  * @react-email/render imports react-dom/server lazily, so the dep scan never
483
485
  * sees it: the first email preview made Vite discover it, re-optimize and