@sxl-studio/storybook-addon 1.0.18 → 1.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 1.1.1
4
+
5
+ - **Registry matching:** removed the behavior where a **single** registry entry was applied to **every** story. Matching now always uses the same story-context heuristic (or explicit `sxl.component` / `sxl.figmaNodeId`). Unrelated stories show the “no Figma integration” state.
6
+
7
+ ## 1.1.0
8
+
9
+ - **Preset (zero-config):** merges Content-Security-Policy so the Figma embed iframe can load (`frame-src` includes `https://www.figma.com`).
10
+ - **Local composition JSON:** if a `tokens/tokens` directory is found next to the Storybook project (or above `.storybook`), files are served in dev at `/sxl-tokens/…` and copied for `storybook build` via `staticDirs`, so `compositionFilePath` from the registry resolves without hand-written Vite config.
11
+ - **Registry filename:** if `diff-code-connect.SXL-Components.json` is absent but another `diff-code-connect.*.json` exists in that folder, Vite `resolve.alias` maps the legacy path to the first matching file (deterministic sort). Import path in `preview.ts` stays stable while the plugin emits `diff-code-connect.<figmaFileKey>.json`.
12
+ - **Logging:** removed informational `console` output from the manager and panel; one `console.warn` remains when Design Embed is on but no Figma URL can be resolved (misconfiguration).
13
+
14
+ ## Earlier
15
+
16
+ See git history for releases before this file was added.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Storybook addon for [SXL Studio](https://sxl-studio.com) — displays Figma Embed, component info, and design token status for components linked via the SXL Studio Figma plugin.
4
4
 
5
+ ## Changelog
6
+
7
+ See [CHANGELOG.md](./CHANGELOG.md) (e.g. **1.1.1** registry matching fix; **1.1.0** preset CSP, `/sxl-tokens`, legacy filename alias, quieter logs).
8
+
5
9
  ## Features
6
10
 
7
11
  - **Figma Embed** — live Figma design iframe centered in the addon panel
@@ -17,9 +21,11 @@ npm install @sxl-studio/storybook-addon --save-dev
17
21
 
18
22
  ## Setup
19
23
 
20
- ### 1. Register the addon
24
+ ### 1. Register the addon (`main`)
25
+
26
+ List **`@sxl-studio/storybook-addon`** in **`addons`**. The preset ships with the package and is applied when Storybook loads the addon (no separate preset import in `main` unless your setup requires the explicit `@sxl-studio/storybook-addon/preset` entry — see troubleshooting in docs).
21
27
 
22
- `.storybook/main.ts`:
28
+ **Minimal `main.ts`:**
23
29
 
24
30
  ```ts
25
31
  export default {
@@ -30,21 +36,35 @@ export default {
30
36
  };
31
37
  ```
32
38
 
33
- ### 2. Import the registry
39
+ **With a shared Storybook config** (internal design-system package, monorepo): **append** to the shared addons array — do not drop existing entries.
34
40
 
35
- The SXL Studio Figma plugin generates a `sxl-codeconnect.json` (or `diff-code-connect.<fileKey>.json`) file that maps Figma components to your codebase. Import it in your Storybook preview config.
41
+ ```ts
42
+ import sharedMain from '@your-org/storybook-vue/main';
36
43
 
37
- **Preset (automatic):** when the addon preset is loaded (default if the package is listed under `addons`), it:
44
+ const config = {
45
+ ...sharedMain,
46
+ addons: [...(sharedMain.addons ?? []), '@sxl-studio/storybook-addon'],
47
+ };
38
48
 
39
- - Serves the sibling folder `tokens/tokens` (if present next to the Storybook app or two levels above `.storybook`) at **`/sxl-tokens/…`**, so composition JSON paths from the registry resolve in dev and via `staticDirs` in `storybook build`.
40
- - If `diff-code-connect.SXL-Components.json` is **missing** but another `diff-code-connect.*.json` exists in that folder, Vite gets a **`resolve.alias`** from the legacy path to the first matching file (sorted by name). You can keep a stable import path in preview while the plugin emits `diff-code-connect.<figmaFileKey>.json`.
49
+ export default config;
50
+ ```
41
51
 
42
- **Option A** using `sxl-codeconnect.json` (exported from plugin):
52
+ ### 2. Import the registry (`preview`)
43
53
 
44
- `.storybook/preview.ts`:
54
+ The SXL Studio Figma plugin generates **`diff-code-connect.<figmaFileKey>.json`** (or an exported `sxl-codeconnect.json`). Put it in **`parameters.sxl.registry`**. The **relative import path is up to your repo** (e.g. `../../tokens/tokens/diff-code-connect.xxx.json`).
55
+
56
+ - **`fromDiffCodeConnect(raw)`** — explicit normalization; use if you prefer one code path.
57
+ - **Raw `import registry from '...json'`** — often enough for current plugin output.
58
+
59
+ **Preset (automatic):** when the addon preset runs, it:
60
+
61
+ - Serves a nearby **`tokens/tokens`** folder at **`/sxl-tokens/…`** (dev + `storybook build` via `staticDirs`) so `compositionFilePath` in the registry resolves without extra Vite config.
62
+ - Can **`resolve.alias`** a stable filename like `diff-code-connect.SXL-Components.json` to the real `diff-code-connect.*.json` when only one candidate exists in that folder (see CHANGELOG).
63
+
64
+ **Minimal `preview.ts`:**
45
65
 
46
66
  ```ts
47
- import registry from '../sxl-codeconnect.json';
67
+ import registry from '../path/to/diff-code-connect.<fileKey>.json';
48
68
 
49
69
  export default {
50
70
  parameters: {
@@ -53,10 +73,25 @@ export default {
53
73
  };
54
74
  ```
55
75
 
56
- **Option B**using the existing `diff-code-connect` file:
76
+ **With a shared `preview`** merge **`parameters`** so shared decorators/globals stay intact:
57
77
 
58
78
  ```ts
59
- import raw from '../diff-code-connect.abc123.json';
79
+ import sharedPreview from '@your-org/storybook-vue/preview';
80
+ import registry from '../../tokens/tokens/diff-code-connect.<fileKey>.json';
81
+
82
+ export default {
83
+ ...sharedPreview,
84
+ parameters: {
85
+ ...sharedPreview.parameters,
86
+ sxl: { registry },
87
+ },
88
+ };
89
+ ```
90
+
91
+ **Alternative — converter:**
92
+
93
+ ```ts
94
+ import raw from '../diff-code-connect.<fileKey>.json';
60
95
  import { fromDiffCodeConnect } from '@sxl-studio/storybook-addon';
61
96
 
62
97
  export default {
@@ -68,6 +103,8 @@ export default {
68
103
 
69
104
  ### 3. Match stories to Figma components
70
105
 
106
+ Stories are matched to registry entries by explicit `sxl.component` / `sxl.figmaNodeId`, or by a **heuristic** on story title and file path. **A registry with a single component is not shown on every story** — unrelated stories show a “no integration” state until the story context matches or you set parameters manually.
107
+
71
108
  Per-story matching:
72
109
 
73
110
  ```ts
package/dist/manager.js CHANGED
@@ -3706,10 +3706,7 @@ function resolveEntry(params, ctx) {
3706
3706
  found = registry.entries.find((e) => e.displayName.toLowerCase() === name);
3707
3707
  }
3708
3708
  }
3709
- if (!found && registry.entries.length === 1) {
3710
- found = registry.entries[0];
3711
- }
3712
- if (!found && registry.entries.length > 1) {
3709
+ if (!found) {
3713
3710
  found = matchByStoryContext(registry.entries, ctx);
3714
3711
  }
3715
3712
  if (!found) {
@@ -3955,17 +3952,8 @@ var SxlPanel = () => {
3955
3952
  "[SXL Studio addon] Embed requested but no Figma URL could be resolved. Set top-level `$figmaFileKey` / registry `figmaFileKey`, or `storybook.figmaUrl` on the entry, then re-export.",
3956
3953
  { nodeId: entryForRender.nodeId, displayName: entryForRender.displayName }
3957
3954
  );
3958
- return;
3959
3955
  }
3960
- if (!showEmbed || !entryForRender.figmaUrl) return;
3961
- const embedUrl = buildEmbedUrl(entryForRender.figmaUrl);
3962
- console.info("[SXL Studio addon] Figma embed", {
3963
- designEmbed: entryForRender.designEmbed,
3964
- figmaUrl: entryForRender.figmaUrl,
3965
- embedUrl,
3966
- hint: "If iframe is blank, verify Storybook CSP frame-src includes https://www.figma.com"
3967
- });
3968
- }, [showEmbed, entryForRender?.figmaUrl, entryForRender?.designEmbed, entryForRender?.nodeId, entryForRender?.displayName]);
3956
+ }, [entryForRender?.designEmbed, entryForRender?.figmaUrl, entryForRender?.nodeId, entryForRender?.displayName]);
3969
3957
  if (result.status === "no-registry") {
3970
3958
  return React2.createElement(NoRegistryState, null);
3971
3959
  }
@@ -3987,10 +3975,7 @@ var SxlPanel = () => {
3987
3975
  style: iframe,
3988
3976
  allowFullScreen: true,
3989
3977
  allow: "clipboard-write; fullscreen",
3990
- referrerPolicy: "no-referrer-when-downgrade",
3991
- onLoad: () => {
3992
- console.info("[SXL Studio addon] Figma iframe load event fired");
3993
- }
3978
+ referrerPolicy: "no-referrer-when-downgrade"
3994
3979
  }
3995
3980
  ), /* @__PURE__ */ React2.createElement("div", { style: embedFooter }, /* @__PURE__ */ React2.createElement(
3996
3981
  "a",
@@ -4066,7 +4051,6 @@ var FigmaIcon = () => /* @__PURE__ */ React2.createElement("svg", { width: "14",
4066
4051
  var REGISTRY_GUARD_KEY = "__sxlStudioAddonRegistered__";
4067
4052
  if (!globalThis[REGISTRY_GUARD_KEY]) {
4068
4053
  globalThis[REGISTRY_GUARD_KEY] = true;
4069
- console.info("[SXL Storybook Addon] register manager addon");
4070
4054
  addons.register(ADDON_ID, () => {
4071
4055
  addons.add(PANEL_ID, {
4072
4056
  type: types.PANEL,
@@ -4077,8 +4061,6 @@ if (!globalThis[REGISTRY_GUARD_KEY]) {
4077
4061
  }
4078
4062
  });
4079
4063
  });
4080
- } else {
4081
- console.warn("[SXL Storybook Addon] skip duplicate manager registration");
4082
4064
  }
4083
4065
  /*! Bundled license information:
4084
4066
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sxl-studio/storybook-addon",
3
- "version": "1.0.18",
3
+ "version": "1.1.1",
4
4
  "description": "Storybook addon for SXL Studio — displays Figma Embed, component info and design token status for linked components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,6 +16,7 @@
16
16
  "files": [
17
17
  "dist",
18
18
  "README.md",
19
+ "CHANGELOG.md",
19
20
  "preset.js"
20
21
  ],
21
22
  "publishConfig": {
@@ -25,7 +26,8 @@
25
26
  "build": "tsup",
26
27
  "dev": "tsup --watch",
27
28
  "lint": "tsc --noEmit",
28
- "prepublishOnly": "npm run build"
29
+ "prepublishOnly": "npm run build",
30
+ "push": "npm run build && npm publish"
29
31
  },
30
32
  "keywords": [
31
33
  "storybook",