@andersundsehr/storybook-typo3 0.1.18 → 0.1.20
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.
@@ -21,9 +21,8 @@ export async function fetchRenderAction(urlA, id, params, storyContext) {
|
|
21
21
|
if (!storyContext.component) {
|
22
22
|
error('No component found in story context. This function requires a Fluid component to render.', 4123764578913);
|
23
23
|
}
|
24
|
-
const viewHelper = (typeof storyContext.component === 'string') ? storyContext.component : storyContext.component.fullName;
|
25
24
|
const body = {
|
26
|
-
viewHelper:
|
25
|
+
viewHelper: storyContext.component.fullName,
|
27
26
|
arguments: params,
|
28
27
|
site: storyContext.globals?.site || 'default',
|
29
28
|
siteLanguage: storyContext.globals?.language || 'default',
|
@@ -32,5 +31,6 @@ export async function fetchRenderAction(urlA, id, params, storyContext) {
|
|
32
31
|
return await fetchWithUserRetry(url + '/_storybook/render', {
|
33
32
|
method: 'POST',
|
34
33
|
body: JSON.stringify(body),
|
34
|
+
signal: storyContext.abortSignal,
|
35
35
|
}, 'rendering component', 'text');
|
36
36
|
}
|
@@ -19,10 +19,24 @@ In any case we should get the error in json so we can handle it in the frontend
|
|
19
19
|
Sometimes it can still be text/html so we need to handle that as well.
|
20
20
|
*/
|
21
21
|
let updatableApiKey = import.meta.env.STORYBOOK_TYPO3_KEY;
|
22
|
+
function anySignal(...signals) {
|
23
|
+
const controller = new AbortController();
|
24
|
+
for (const s of signals) {
|
25
|
+
if (!s) {
|
26
|
+
continue;
|
27
|
+
}
|
28
|
+
if (s.aborted) {
|
29
|
+
controller.abort(s.reason);
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
s.addEventListener('abort', () => controller.abort(s.reason), { once: true });
|
33
|
+
}
|
34
|
+
return controller.signal;
|
35
|
+
}
|
22
36
|
export async function fetchWithUserRetry(url, options, message, resultType = 'json') {
|
23
37
|
try {
|
24
38
|
options = { ...options }; // Clone options to avoid mutating the original
|
25
|
-
options.signal = options.signal
|
39
|
+
options.signal = anySignal(options.signal, AbortSignal.timeout(5000));
|
26
40
|
options.headers = {
|
27
41
|
...options.headers,
|
28
42
|
'Content-Type': 'application/json',
|
@@ -48,7 +62,7 @@ async function retry(errorOrResponse, url, options, message, resultType) {
|
|
48
62
|
retry = true;
|
49
63
|
confirmationMessage = `🔐 ${errorType.message}\n\n`
|
50
64
|
+ `🔗 url: ${url}\n\n`
|
51
|
-
+ `💬 Please insert the correct API key:\ncan be found in the .env file:\n\n`;
|
65
|
+
+ `💬 Please insert the correct API key:\ncan be found in the .env file of your TYPO3:\n\n`;
|
52
66
|
// if there was no api key, it will be set into the .env from the php code automatically
|
53
67
|
// we wait 1 second to give HMR time to update the .env file and reload the page, otherwise the user has to provide the key
|
54
68
|
if (!updatableApiKey) {
|
package/dist/preset.js
CHANGED
@@ -12,7 +12,13 @@ export const addons = ['@storybook/addon-docs', '@storybook/addon-a11y'];
|
|
12
12
|
*/
|
13
13
|
export { viteFinal };
|
14
14
|
export const core = {
|
15
|
-
builder:
|
15
|
+
builder: {
|
16
|
+
name: '@storybook/builder-vite',
|
17
|
+
options: {
|
18
|
+
// to overwrite the user's vite.config.js
|
19
|
+
viteConfigPath: require.resolve('./empty-vite.config'),
|
20
|
+
},
|
21
|
+
},
|
16
22
|
renderer: getAbsolutePath('@storybook/server'),
|
17
23
|
disableTelemetry: true,
|
18
24
|
};
|
package/package.json
CHANGED