@emulsify/core 4.0.3 → 4.0.4

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.
@@ -115,7 +115,9 @@ export const decorators = [
115
115
  * @param {object} context Story context including args.
116
116
  * @returns {*} Rendered story.
117
117
  */
118
- (Story, { args }) => {
118
+ (Story, context) => {
119
+ const { args } = context;
120
+
119
121
  useEffect(() => {
120
122
  void attachStorybookBehaviors({
121
123
  adapter: platformAdapter,
@@ -123,7 +125,7 @@ export const decorators = [
123
125
  });
124
126
  }, [args]);
125
127
 
126
- return renderHtmlStoryResult(Story({ args }), {
128
+ return renderHtmlStoryResult(Story(context), {
127
129
  platformAdapter,
128
130
  });
129
131
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emulsify/core",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Bundled tooling for Storybook development + Vite Build",
5
5
  "keywords": [
6
6
  "component library",
@@ -157,7 +157,7 @@
157
157
  "twatch": "npm run check-node-version && jest --no-coverage --watch --verbose"
158
158
  },
159
159
  "dependencies": {
160
- "@babel/core": "^7.28.4",
160
+ "@babel/core": "^7.29.7",
161
161
  "@babel/eslint-parser": "^7.28.6",
162
162
  "@babel/preset-env": "^7.28.3",
163
163
  "@emulsify/cli": "^1.11.4",
@@ -171,7 +171,7 @@
171
171
  "autoprefixer": "^10.4.21",
172
172
  "axe-core": "^4.11.4",
173
173
  "babel-preset-minify": "^0.5.2",
174
- "concurrently": "^9.2.1",
174
+ "concurrently": "^9.2.3",
175
175
  "eslint": "^9.39.4",
176
176
  "eslint-config-prettier": "^10.1.8",
177
177
  "eslint-plugin-import": "^2.32.0",
@@ -200,7 +200,7 @@
200
200
  "stylelint-selector-bem-pattern": "^5.0.0",
201
201
  "twig": "^3.0.0",
202
202
  "twig-drupal-filters": "^3.2.0",
203
- "vite": "^7.3.3",
203
+ "vite": "^7.3.5",
204
204
  "vite-plugin-sass-glob-import": "^6.0.0",
205
205
  "vite-plugin-static-copy": "^4.1.0",
206
206
  "vite-plugin-svg-sprite": "^0.7.0",
package/scripts/audit.js CHANGED
@@ -5,7 +5,14 @@
5
5
  */
6
6
 
7
7
  import { lstatSync, readdirSync, statSync } from 'node:fs';
8
- import { basename, dirname, relative, resolve, sep } from 'node:path';
8
+ import {
9
+ basename,
10
+ dirname,
11
+ isAbsolute,
12
+ relative,
13
+ resolve,
14
+ sep,
15
+ } from 'node:path';
9
16
  import { globSync } from 'glob';
10
17
  import { resolveProjectConfig } from '../config/vite/project-config.js';
11
18
  import {
@@ -68,6 +75,7 @@ const RECOMMENDED_PACKAGE_OVERRIDES = [
68
75
  ];
69
76
  const GENERATED_PACKAGE_SCRIPT_DOCS =
70
77
  'https://github.com/emulsify-ds/emulsify-core/blob/4.x/docs/migration-4x.md#manual-packagejson-updates';
78
+ const GENERATED_ASSET_ALIASES = new Set(['icons.svg']);
71
79
 
72
80
  /**
73
81
  * Cache source file reads for one top-level audit run.
@@ -726,6 +734,74 @@ function candidateKeysToFiles(keys, env) {
726
734
  );
727
735
  }
728
736
 
737
+ /**
738
+ * Resolve an audit asset root using Storybook's root-relative convention.
739
+ *
740
+ * @param {string} projectDir - Absolute project root.
741
+ * @param {string} assetRoot - Configured, absolute, or project-relative root.
742
+ * @returns {string} Absolute filesystem path, or an empty string.
743
+ */
744
+ function resolveAuditAssetRoot(projectDir, assetRoot) {
745
+ if (typeof assetRoot !== 'string' || !assetRoot.trim()) return '';
746
+
747
+ const normalizedProjectDir = resolve(projectDir || process.cwd());
748
+ const normalizedRoot = assetRoot.trim();
749
+
750
+ if (isAbsolute(normalizedRoot)) {
751
+ const absoluteRoot = resolve(normalizedRoot);
752
+
753
+ return safeExists(absoluteRoot)
754
+ ? absoluteRoot
755
+ : resolve(normalizedProjectDir, `.${normalizedRoot}`);
756
+ }
757
+
758
+ return resolve(normalizedProjectDir, normalizedRoot);
759
+ }
760
+
761
+ /**
762
+ * Return filesystem roots that Storybook can use for @assets source() calls.
763
+ *
764
+ * @param {object} env - Normalized environment.
765
+ * @param {object} [options={}] - Asset root options.
766
+ * @param {boolean} [options.includeGenerated=false] - Include generated roots.
767
+ * @returns {string[]} Absolute asset roots.
768
+ */
769
+ function auditAssetRoots(env = {}, { includeGenerated = false } = {}) {
770
+ const projectDir = env.projectDir || process.cwd();
771
+ const configuredRoots = Array.isArray(env?.projectStructure?.assetRoots)
772
+ ? env.projectStructure.assetRoots
773
+ : [];
774
+ const fallbackRoots = ['assets', 'src/assets'];
775
+ const generatedRoots = includeGenerated ? ['dist/assets'] : [];
776
+
777
+ return Array.from(
778
+ new Set(
779
+ [...fallbackRoots, ...configuredRoots, ...generatedRoots]
780
+ .map((root) => resolveAuditAssetRoot(projectDir, root))
781
+ .filter(Boolean),
782
+ ),
783
+ );
784
+ }
785
+
786
+ /**
787
+ * Determine whether an @assets reference resolves through Storybook asset roots.
788
+ *
789
+ * @param {string} reference - Twig @assets reference.
790
+ * @param {object} env - Normalized environment.
791
+ * @returns {boolean} TRUE when a candidate exists.
792
+ */
793
+ function resolvesAssetReference(reference, env) {
794
+ const relAsset = reference.replace(/^@assets\//, '');
795
+ if (!relAsset) return false;
796
+ const includeGenerated = GENERATED_ASSET_ALIASES.has(relAsset);
797
+
798
+ return auditAssetRoots(env, { includeGenerated }).some((root) => {
799
+ const candidate = resolve(root, relAsset);
800
+
801
+ return isSameOrInside(candidate, root) && safeExists(candidate);
802
+ });
803
+ }
804
+
729
805
  /**
730
806
  * Determine whether a Twig include/source reference resolves.
731
807
  *
@@ -738,8 +814,7 @@ export function resolvesTwigReference(reference, filePath, env) {
738
814
  if (!reference || /^https?:\/\//i.test(reference)) return true;
739
815
 
740
816
  if (reference.startsWith('@assets/')) {
741
- const relAsset = reference.replace(/^@assets\//, '');
742
- return safeExists(resolve(env.projectDir, 'assets', relAsset));
817
+ return resolvesAssetReference(reference, env);
743
818
  }
744
819
 
745
820
  const candidates =