vite-plugin-storybook-nextjs 3.1.3--canary.78.ed88a44.0 → 3.1.3
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/dist/index.cjs +7 -15
- package/dist/index.js +7 -15
- package/dist/plugins/next-mocks/alias/cache/index.cjs +13 -1
- package/dist/plugins/next-mocks/alias/cache/index.d.cts +9 -1
- package/dist/plugins/next-mocks/alias/cache/index.d.ts +9 -1
- package/dist/plugins/next-mocks/alias/cache/index.js +10 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var options_js = require('next/dist/build/swc/options.js');
|
|
|
22
22
|
var nextServerConfig = require('next/dist/server/config.js');
|
|
23
23
|
var constants_js = require('next/dist/shared/lib/constants.js');
|
|
24
24
|
var MagicString = require('magic-string');
|
|
25
|
+
var querystring = require('querystring');
|
|
25
26
|
var path = require('path');
|
|
26
27
|
var imageSize = require('image-size');
|
|
27
28
|
|
|
@@ -4727,19 +4728,9 @@ var warnOnce = (message) => {
|
|
|
4727
4728
|
};
|
|
4728
4729
|
var includePattern2 = /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/;
|
|
4729
4730
|
var excludeImporterPattern = /\.(css|scss|sass)$/;
|
|
4730
|
-
var
|
|
4731
|
+
var virtualImage = "virtual:next-image";
|
|
4731
4732
|
var virtualNextImage = "virtual:next/image";
|
|
4732
4733
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
4733
|
-
function encodeBase64Url(str) {
|
|
4734
|
-
const base64 = Buffer.from(str).toString("base64");
|
|
4735
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
4736
|
-
}
|
|
4737
|
-
function decodeBase64Url(str) {
|
|
4738
|
-
const padding = (4 - str.length % 4) % 4;
|
|
4739
|
-
const withPadding = str + "=".repeat(padding);
|
|
4740
|
-
const base64 = withPadding.replace(/-/g, "+").replace(/_/g, "/");
|
|
4741
|
-
return Buffer.from(base64, "base64").toString();
|
|
4742
|
-
}
|
|
4743
4734
|
var require5 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
4744
4735
|
function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
4745
4736
|
let isBrowser = !isVitestEnv;
|
|
@@ -4787,14 +4778,14 @@ function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
|
4787
4778
|
For more info and recommended configuration, see: https://github.com/storybookjs/vite-plugin-storybook-nextjs/blob/main/README.md#faq-includingexcluding-images`
|
|
4788
4779
|
);
|
|
4789
4780
|
}
|
|
4790
|
-
if (includePattern2.test(source) && !excludeImporterPattern.test(importer ?? "") && !importer?.startsWith(
|
|
4781
|
+
if (includePattern2.test(source) && !excludeImporterPattern.test(importer ?? "") && !importer?.startsWith(virtualImage)) {
|
|
4791
4782
|
const isAbsolute3 = posix.isAbsolute(id);
|
|
4792
4783
|
const imagePath = importer ? isAbsolute3 ? source : posix.join(posix.dirname(importer), source) : source;
|
|
4793
4784
|
const pathForFilter = imagePath.replace(postfixRE, "");
|
|
4794
4785
|
if (!filter(pathForFilter)) {
|
|
4795
4786
|
return null;
|
|
4796
4787
|
}
|
|
4797
|
-
return `${
|
|
4788
|
+
return `${virtualImage}?${querystring.encode({ imagePath })}`;
|
|
4798
4789
|
}
|
|
4799
4790
|
if (id === "next/image" && importer !== virtualNextImage) {
|
|
4800
4791
|
return virtualNextImage;
|
|
@@ -4818,8 +4809,9 @@ function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
|
4818
4809
|
)
|
|
4819
4810
|
)).toString("utf-8");
|
|
4820
4811
|
}
|
|
4821
|
-
|
|
4822
|
-
|
|
4812
|
+
const [source, query] = id.split("?");
|
|
4813
|
+
if (virtualImage === source) {
|
|
4814
|
+
const imagePath = querystring.decode(query).imagePath;
|
|
4823
4815
|
const nextConfig = await nextConfigResolver.promise;
|
|
4824
4816
|
try {
|
|
4825
4817
|
if (nextConfig.images?.disableStaticImages) {
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { getParserOptions } from 'next/dist/build/swc/options.js';
|
|
|
20
20
|
import nextServerConfig from 'next/dist/server/config.js';
|
|
21
21
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_TEST, PHASE_PRODUCTION_BUILD } from 'next/dist/shared/lib/constants.js';
|
|
22
22
|
import MagicString from 'magic-string';
|
|
23
|
+
import { decode, encode } from 'querystring';
|
|
23
24
|
import { win32 as win32$1, posix as posix$1, isAbsolute as isAbsolute$1, resolve as resolve$1 } from 'path';
|
|
24
25
|
import { imageSize } from 'image-size';
|
|
25
26
|
|
|
@@ -4694,19 +4695,9 @@ var warnOnce = (message) => {
|
|
|
4694
4695
|
};
|
|
4695
4696
|
var includePattern2 = /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/;
|
|
4696
4697
|
var excludeImporterPattern = /\.(css|scss|sass)$/;
|
|
4697
|
-
var
|
|
4698
|
+
var virtualImage = "virtual:next-image";
|
|
4698
4699
|
var virtualNextImage = "virtual:next/image";
|
|
4699
4700
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
4700
|
-
function encodeBase64Url(str) {
|
|
4701
|
-
const base64 = Buffer.from(str).toString("base64");
|
|
4702
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
4703
|
-
}
|
|
4704
|
-
function decodeBase64Url(str) {
|
|
4705
|
-
const padding = (4 - str.length % 4) % 4;
|
|
4706
|
-
const withPadding = str + "=".repeat(padding);
|
|
4707
|
-
const base64 = withPadding.replace(/-/g, "+").replace(/_/g, "/");
|
|
4708
|
-
return Buffer.from(base64, "base64").toString();
|
|
4709
|
-
}
|
|
4710
4701
|
var require5 = createRequire(import.meta.url);
|
|
4711
4702
|
function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
4712
4703
|
let isBrowser = !isVitestEnv;
|
|
@@ -4754,14 +4745,14 @@ function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
|
4754
4745
|
For more info and recommended configuration, see: https://github.com/storybookjs/vite-plugin-storybook-nextjs/blob/main/README.md#faq-includingexcluding-images`
|
|
4755
4746
|
);
|
|
4756
4747
|
}
|
|
4757
|
-
if (includePattern2.test(source) && !excludeImporterPattern.test(importer ?? "") && !importer?.startsWith(
|
|
4748
|
+
if (includePattern2.test(source) && !excludeImporterPattern.test(importer ?? "") && !importer?.startsWith(virtualImage)) {
|
|
4758
4749
|
const isAbsolute3 = posix.isAbsolute(id);
|
|
4759
4750
|
const imagePath = importer ? isAbsolute3 ? source : posix.join(posix.dirname(importer), source) : source;
|
|
4760
4751
|
const pathForFilter = imagePath.replace(postfixRE, "");
|
|
4761
4752
|
if (!filter(pathForFilter)) {
|
|
4762
4753
|
return null;
|
|
4763
4754
|
}
|
|
4764
|
-
return `${
|
|
4755
|
+
return `${virtualImage}?${encode({ imagePath })}`;
|
|
4765
4756
|
}
|
|
4766
4757
|
if (id === "next/image" && importer !== virtualNextImage) {
|
|
4767
4758
|
return virtualNextImage;
|
|
@@ -4785,8 +4776,9 @@ function vitePluginNextImage(nextConfigResolver, options = {}) {
|
|
|
4785
4776
|
)
|
|
4786
4777
|
)).toString("utf-8");
|
|
4787
4778
|
}
|
|
4788
|
-
|
|
4789
|
-
|
|
4779
|
+
const [source, query] = id.split("?");
|
|
4780
|
+
if (virtualImage === source) {
|
|
4781
|
+
const imagePath = decode(query).imagePath;
|
|
4790
4782
|
const nextConfig = await nextConfigResolver.promise;
|
|
4791
4783
|
try {
|
|
4792
4784
|
if (nextConfig.images?.disableStaticImages) {
|
|
@@ -17,20 +17,32 @@ var unstable_noStore = test.fn().mockName(
|
|
|
17
17
|
"next/cache::unstable_noStore"
|
|
18
18
|
);
|
|
19
19
|
var refresh = test.fn().mockName("next/cache::refresh");
|
|
20
|
+
var cacheLife = test.fn().mockName("next/cache::cacheLife");
|
|
21
|
+
var cacheTag = test.fn().mockName("next/cache::cacheTag");
|
|
22
|
+
var unstable_cacheLife = test.fn().mockName("next/cache::unstable_cacheLife").mockImplementation((...args) => cacheLife(...args));
|
|
23
|
+
var unstable_cacheTag = test.fn().mockName("next/cache::unstable_cacheTag").mockImplementation((...args) => cacheTag(...args));
|
|
20
24
|
var cacheExports = {
|
|
21
25
|
unstable_cache,
|
|
22
26
|
revalidateTag,
|
|
23
27
|
revalidatePath,
|
|
24
28
|
updateTag,
|
|
25
29
|
refresh,
|
|
26
|
-
unstable_noStore
|
|
30
|
+
unstable_noStore,
|
|
31
|
+
cacheLife,
|
|
32
|
+
cacheTag,
|
|
33
|
+
unstable_cacheLife,
|
|
34
|
+
unstable_cacheTag
|
|
27
35
|
};
|
|
28
36
|
var cache_default = cacheExports;
|
|
29
37
|
|
|
38
|
+
exports.cacheLife = cacheLife;
|
|
39
|
+
exports.cacheTag = cacheTag;
|
|
30
40
|
exports.default = cache_default;
|
|
31
41
|
exports.refresh = refresh;
|
|
32
42
|
exports.revalidatePath = revalidatePath;
|
|
33
43
|
exports.revalidateTag = revalidateTag;
|
|
34
44
|
exports.unstable_cache = unstable_cache;
|
|
45
|
+
exports.unstable_cacheLife = unstable_cacheLife;
|
|
46
|
+
exports.unstable_cacheTag = unstable_cacheTag;
|
|
35
47
|
exports.unstable_noStore = unstable_noStore;
|
|
36
48
|
exports.updateTag = updateTag;
|
|
@@ -7,6 +7,10 @@ declare const updateTag: Mock<Procedure>;
|
|
|
7
7
|
declare const unstable_cache: Mock<Procedure>;
|
|
8
8
|
declare const unstable_noStore: Mock<Procedure>;
|
|
9
9
|
declare const refresh: Mock<Procedure>;
|
|
10
|
+
declare const cacheLife: Mock<Procedure>;
|
|
11
|
+
declare const cacheTag: Mock<Procedure>;
|
|
12
|
+
declare const unstable_cacheLife: Mock<Procedure>;
|
|
13
|
+
declare const unstable_cacheTag: Mock<Procedure>;
|
|
10
14
|
declare const cacheExports: {
|
|
11
15
|
unstable_cache: Mock<Procedure>;
|
|
12
16
|
revalidateTag: Mock<Procedure>;
|
|
@@ -14,6 +18,10 @@ declare const cacheExports: {
|
|
|
14
18
|
updateTag: Mock<Procedure>;
|
|
15
19
|
refresh: Mock<Procedure>;
|
|
16
20
|
unstable_noStore: Mock<Procedure>;
|
|
21
|
+
cacheLife: Mock<Procedure>;
|
|
22
|
+
cacheTag: Mock<Procedure>;
|
|
23
|
+
unstable_cacheLife: Mock<Procedure>;
|
|
24
|
+
unstable_cacheTag: Mock<Procedure>;
|
|
17
25
|
};
|
|
18
26
|
|
|
19
|
-
export { cacheExports as default, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_noStore, updateTag };
|
|
27
|
+
export { cacheLife, cacheTag, cacheExports as default, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_noStore, updateTag };
|
|
@@ -7,6 +7,10 @@ declare const updateTag: Mock<Procedure>;
|
|
|
7
7
|
declare const unstable_cache: Mock<Procedure>;
|
|
8
8
|
declare const unstable_noStore: Mock<Procedure>;
|
|
9
9
|
declare const refresh: Mock<Procedure>;
|
|
10
|
+
declare const cacheLife: Mock<Procedure>;
|
|
11
|
+
declare const cacheTag: Mock<Procedure>;
|
|
12
|
+
declare const unstable_cacheLife: Mock<Procedure>;
|
|
13
|
+
declare const unstable_cacheTag: Mock<Procedure>;
|
|
10
14
|
declare const cacheExports: {
|
|
11
15
|
unstable_cache: Mock<Procedure>;
|
|
12
16
|
revalidateTag: Mock<Procedure>;
|
|
@@ -14,6 +18,10 @@ declare const cacheExports: {
|
|
|
14
18
|
updateTag: Mock<Procedure>;
|
|
15
19
|
refresh: Mock<Procedure>;
|
|
16
20
|
unstable_noStore: Mock<Procedure>;
|
|
21
|
+
cacheLife: Mock<Procedure>;
|
|
22
|
+
cacheTag: Mock<Procedure>;
|
|
23
|
+
unstable_cacheLife: Mock<Procedure>;
|
|
24
|
+
unstable_cacheTag: Mock<Procedure>;
|
|
17
25
|
};
|
|
18
26
|
|
|
19
|
-
export { cacheExports as default, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_noStore, updateTag };
|
|
27
|
+
export { cacheLife, cacheTag, cacheExports as default, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_noStore, updateTag };
|
|
@@ -13,14 +13,22 @@ var unstable_noStore = fn().mockName(
|
|
|
13
13
|
"next/cache::unstable_noStore"
|
|
14
14
|
);
|
|
15
15
|
var refresh = fn().mockName("next/cache::refresh");
|
|
16
|
+
var cacheLife = fn().mockName("next/cache::cacheLife");
|
|
17
|
+
var cacheTag = fn().mockName("next/cache::cacheTag");
|
|
18
|
+
var unstable_cacheLife = fn().mockName("next/cache::unstable_cacheLife").mockImplementation((...args) => cacheLife(...args));
|
|
19
|
+
var unstable_cacheTag = fn().mockName("next/cache::unstable_cacheTag").mockImplementation((...args) => cacheTag(...args));
|
|
16
20
|
var cacheExports = {
|
|
17
21
|
unstable_cache,
|
|
18
22
|
revalidateTag,
|
|
19
23
|
revalidatePath,
|
|
20
24
|
updateTag,
|
|
21
25
|
refresh,
|
|
22
|
-
unstable_noStore
|
|
26
|
+
unstable_noStore,
|
|
27
|
+
cacheLife,
|
|
28
|
+
cacheTag,
|
|
29
|
+
unstable_cacheLife,
|
|
30
|
+
unstable_cacheTag
|
|
23
31
|
};
|
|
24
32
|
var cache_default = cacheExports;
|
|
25
33
|
|
|
26
|
-
export { cache_default as default, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_noStore, updateTag };
|
|
34
|
+
export { cacheLife, cacheTag, cache_default as default, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_noStore, updateTag };
|