@shware/workflow-ui 2.1.5 → 2.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/workflow-ui",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ShwareHQ/shware-sdk.git"
@@ -40,7 +40,7 @@
40
40
  "@floating-ui/react": "^0.27.20",
41
41
  "@fontsource-variable/inter": "^5.3.0",
42
42
  "@react-email/render": "^2.1.1",
43
- "@shware/workflow": "6.0.0",
43
+ "@shware/workflow": "6.1.1",
44
44
  "@tailwindcss/vite": "^4.3.3",
45
45
  "@tanstack/react-query": "^5.104.5",
46
46
  "@tanstack/react-router": "^1.170.46",
@@ -1,5 +1,10 @@
1
1
  import { render } from '@react-email/render';
2
- import { type EmailConfig, type EmailTemplate, resolveEmail } from '@shware/workflow';
2
+ import {
3
+ type EmailConfig,
4
+ type EmailTemplate,
5
+ PREVIEW_MESSAGE_ID,
6
+ resolveEmail,
7
+ } from '@shware/workflow';
3
8
  import { EmailProvider } from '@shware/workflow/email-context';
4
9
  import { useQuery } from '@tanstack/react-query';
5
10
  import { createElement } from 'react';
@@ -29,8 +34,9 @@ export type EmailPreviewResult =
29
34
  *
30
35
  * The component renders inside the `EmailProvider` the Worker's renderer gives it, with the
31
36
  * template resolved against the config's `email` the same way (`resolveEmail`): a layout's
32
- * unsubscribe link is the one the email would be sent with. The resolved URL is in the key, so a
33
- * changed config default renders again.
37
+ * unsubscribe link is the one the email would be sent with, and its preferences link renders
38
+ * with the placeholder message id a sent copy's would replace. The resolved URLs are in the key,
39
+ * so a changed config default renders again.
34
40
  */
35
41
  export function useEmailPreview(
36
42
  mod: EmailTemplate | undefined,
@@ -38,13 +44,15 @@ export function useEmailPreview(
38
44
  config: EmailConfig,
39
45
  props?: Props
40
46
  ) {
41
- const email = mod === undefined ? undefined : resolveEmail(mod, config);
47
+ const email =
48
+ mod === undefined ? undefined : resolveEmail(mod, config, { messageId: PREVIEW_MESSAGE_ID });
42
49
  return useQuery({
43
50
  queryKey: [
44
51
  'email-preview',
45
52
  key,
46
53
  entryIdentity(mod),
47
54
  email?.unsubscribeUrl ?? null,
55
+ email?.preferencesUrl ?? null,
48
56
  props ?? null,
49
57
  ],
50
58
  queryFn: async (): Promise<EmailPreviewResult> => {
package/src/server.ts CHANGED
@@ -437,6 +437,23 @@ function sourcePosition(cwd: string, rawFile: string, line: number): Located {
437
437
  /** Vite's own `server.fs.deny` default; setting the option replaces it, so it is spelled out. */
438
438
  const VITE_DEFAULT_DENY = ['.env', '.env.*', '*.{crt,pem}', '**/.git/**'];
439
439
 
440
+ /**
441
+ * What `server.fs.deny` refuses whatever the project: Vite's default, plus the credentials a
442
+ * journey project keeps beside its code. `fs.allow` spans the workspace, so without these
443
+ * `/@fs/<path>/.dev.vars` (wrangler's secrets), an APNs `.p8` or a Firebase service account would
444
+ * be one request away for any page that can reach the port.
445
+ */
446
+ export const STUDIO_FS_DENY: readonly string[] = [
447
+ ...VITE_DEFAULT_DENY,
448
+ '**/.dev.vars*',
449
+ '**/*.p8',
450
+ '**/*.plist',
451
+ '**/google-services.json',
452
+ '**/*.pfx',
453
+ '**/*.pem',
454
+ '**/*.key',
455
+ ];
456
+
440
457
  /**
441
458
  * `server.fs.deny` patterns for files the page must never be served.
442
459
  *
@@ -509,8 +526,10 @@ export async function startStudio(options: StartOptions = {}): Promise<ViteDevSe
509
526
  searchForWorkspaceRoot(packageRoot),
510
527
  appRoot,
511
528
  ],
512
- deny: [...VITE_DEFAULT_DENY, ...projectFileDeny([configPath, statsPath])],
529
+ deny: [...STUDIO_FS_DENY, ...projectFileDeny([configPath, statsPath])],
513
530
  },
531
+ // The studio is its own origin and calls no one else's; no page elsewhere may read it
532
+ cors: false,
514
533
  },
515
534
  // The app and the user's project each have their own react; one copy only. One
516
535
  // @shware/workflow too: the preview's <EmailProvider> and the project's layout calling