## Description - bump storybook version - move stories to storybook package - add dimensions for testing viewports - improve some stories and types for argTable #### PR fixes following issue(s) Fixes #25534 #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] Jest - [ ] Cypress ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag --------- Co-authored-by: Valera Melnikov <melnikov.vv@greendatasoft.ru>
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
// This file preloads chunks for the edit and view modes ahead of the import()
|
||
// call that will actually require them. This puts these chunks into HTTP cache
|
||
// (so they can be executed immediately) but doesn’t execute them (so that the
|
||
// `retryPromise()` logic around the import() calls can still work).
|
||
//
|
||
// The list of chunks to be preloaded is taken from `index.html`, as it’s only
|
||
// available from webpack stats in the end of the build.
|
||
|
||
declare global {
|
||
interface Window {
|
||
// __APPSMITH_CHUNKS_TO_PRELOAD is added in a script tag in index.html
|
||
__APPSMITH_CHUNKS_TO_PRELOAD?: {
|
||
"edit-mode": string[];
|
||
"view-mode": string[];
|
||
};
|
||
}
|
||
}
|
||
|
||
// Preloading is disabled in LinkRelPreload_spec.js
|
||
const isPreloadingDisabled =
|
||
new URL(window.location.href).searchParams.get("disableChunkPreload") ===
|
||
"true";
|
||
|
||
const currentMode = getModeForPathname(window.location.pathname);
|
||
if (
|
||
!isPreloadingDisabled &&
|
||
window.__APPSMITH_CHUNKS_TO_PRELOAD &&
|
||
currentMode
|
||
) {
|
||
window.__APPSMITH_CHUNKS_TO_PRELOAD[currentMode]
|
||
// @ts-expect-error __webpack_public_path__ might be set on runtime when the CDN is used in EE
|
||
.map((url) => __webpack_public_path__ + url)
|
||
.forEach((url) => {
|
||
const link = document.createElement("link");
|
||
link.rel = "preload";
|
||
link.as = getPreloadValueForFile(url);
|
||
link.href = url;
|
||
document.head.appendChild(link);
|
||
});
|
||
}
|
||
|
||
function getPreloadValueForFile(fileName: string) {
|
||
if (fileName.endsWith(".js")) {
|
||
return "script";
|
||
} else if (fileName.endsWith(".css")) {
|
||
return "style";
|
||
}
|
||
|
||
throw new Error(`Unknown preload type for file: ${fileName}`);
|
||
}
|
||
|
||
function getModeForPathname(
|
||
pathname: string,
|
||
): keyof NonNullable<Window["__APPSMITH_CHUNKS_TO_PRELOAD"]> | null {
|
||
if (/^\/app\/[^\/]+\/[^\/]+\/edit\b/.test(pathname)) {
|
||
return "edit-mode";
|
||
}
|
||
|
||
if (pathname.startsWith("/app/")) {
|
||
return "view-mode";
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
export {};
|