@webiny/app 6.3.0-beta.4 → 6.4.0-beta.0
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/App.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +13 -13
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/react-butterfiles/Files.js +148 -217
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/index.js +2 -1
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +2 -3
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +9 -13
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
...rest
|
|
10
|
-
};
|
|
11
|
-
const srcSet = finalProps.srcSet;
|
|
12
|
-
if (srcSet && typeof srcSet === "object") {
|
|
13
|
-
finalProps.srcSet = Object.keys(srcSet).map(key => `${srcSet[key]} ${key}`).join(", ");
|
|
14
|
-
}
|
|
15
|
-
return /*#__PURE__*/React.createElement("img", finalProps);
|
|
1
|
+
import react from "react";
|
|
2
|
+
const Image = ({ ...rest })=>{
|
|
3
|
+
const finalProps = {
|
|
4
|
+
...rest
|
|
5
|
+
};
|
|
6
|
+
const srcSet = finalProps.srcSet;
|
|
7
|
+
if (srcSet && "object" == typeof srcSet) finalProps.srcSet = Object.keys(srcSet).map((key)=>`${srcSet[key]} ${key}`).join(", ");
|
|
8
|
+
return /*#__PURE__*/ react.createElement("img", finalProps);
|
|
16
9
|
};
|
|
17
10
|
export { Image };
|
|
18
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/components/Image.js","sources":["../../../src/plugins/components/Image.tsx"],"sourcesContent":["import React from \"react\";\n\n// Accepts all props that a normal <img> element would accept.\ninterface ImageProps extends React.DetailedHTMLProps<\n React.ImgHTMLAttributes<HTMLImageElement>,\n HTMLImageElement\n> {\n [key: string]: any;\n}\n\nconst Image = ({ ...rest }: ImageProps) => {\n const finalProps = { ...rest };\n const srcSet = finalProps.srcSet;\n if (srcSet && typeof srcSet === \"object\") {\n finalProps.srcSet = Object.keys(srcSet)\n .map(key => `${srcSet[key]} ${key}`)\n .join(\", \");\n }\n\n return <img {...finalProps} />;\n};\n\nexport { Image, type ImageProps };\n"],"names":["Image","rest","finalProps","srcSet","Object","key"],"mappings":";AAUA,MAAMA,QAAQ,CAAC,EAAE,GAAGC,MAAkB;IAClC,MAAMC,aAAa;QAAE,GAAGD,IAAI;IAAC;IAC7B,MAAME,SAASD,WAAW,MAAM;IAChC,IAAIC,UAAU,AAAkB,YAAlB,OAAOA,QACjBD,WAAW,MAAM,GAAGE,OAAO,IAAI,CAACD,QAC3B,GAAG,CAACE,CAAAA,MAAO,GAAGF,MAAM,CAACE,IAAI,CAAC,CAAC,EAAEA,KAAK,EAClC,IAAI,CAAC;IAGd,OAAO,WAAP,GAAO,oBAAC,OAAQH;AACpB"}
|
package/plugins/image.js
CHANGED
|
@@ -1,145 +1,106 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { Image } from "./components/Image.js";
|
|
3
|
-
const SUPPORTED_IMAGE_RESIZE_WIDTHS = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
const SUPPORTED_IMAGE_RESIZE_WIDTHS = [
|
|
4
|
+
128,
|
|
5
|
+
384,
|
|
6
|
+
640,
|
|
7
|
+
750,
|
|
8
|
+
828,
|
|
9
|
+
1080,
|
|
10
|
+
1200,
|
|
11
|
+
1920,
|
|
12
|
+
2048,
|
|
13
|
+
3840
|
|
14
|
+
];
|
|
15
|
+
const getSupportedImageResizeWidth = (width)=>{
|
|
16
|
+
let output = SUPPORTED_IMAGE_RESIZE_WIDTHS[0];
|
|
17
|
+
let i = SUPPORTED_IMAGE_RESIZE_WIDTHS.length;
|
|
18
|
+
while(i >= 0){
|
|
19
|
+
if (width === SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {
|
|
20
|
+
output = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
if (width > SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {
|
|
24
|
+
output = SUPPORTED_IMAGE_RESIZE_WIDTHS[i + 1];
|
|
25
|
+
if (!output) output = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
i--;
|
|
24
29
|
}
|
|
25
|
-
i--;
|
|
26
|
-
}
|
|
27
|
-
return output;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Currently we only allow "width" as a transform option.
|
|
31
|
-
* @param args
|
|
32
|
-
*/
|
|
33
|
-
const sanitizeTransformArgs = args => {
|
|
34
|
-
const output = {};
|
|
35
|
-
if (!args || args.width === undefined || args.width === null) {
|
|
36
30
|
return output;
|
|
37
|
-
}
|
|
38
|
-
const width = parseInt(args.width);
|
|
39
|
-
if (width > 0) {
|
|
40
|
-
output.width = getSupportedImageResizeWidth(width);
|
|
41
|
-
}
|
|
42
|
-
return output;
|
|
43
31
|
};
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return `${parseInt(width)}vw`;
|
|
51
|
-
}
|
|
52
|
-
// Check if width was set as viewport width, with "vw" in the value.
|
|
53
|
-
if (width.endsWith("vw")) {
|
|
54
|
-
return `${parseInt(width)}vw`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Check if width was set as relative, with "em" in the value.
|
|
58
|
-
if (width.endsWith("em")) {
|
|
59
|
-
return `${parseInt(width)}em`;
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
32
|
+
const sanitizeTransformArgs = (args)=>{
|
|
33
|
+
const output = {};
|
|
34
|
+
if (!args || void 0 === args.width || null === args.width) return output;
|
|
35
|
+
const width = parseInt(args.width);
|
|
36
|
+
if (width > 0) output.width = getSupportedImageResizeWidth(width);
|
|
37
|
+
return output;
|
|
62
38
|
};
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
39
|
+
const getSizes = (width)=>{
|
|
40
|
+
if ("string" != typeof width) return;
|
|
41
|
+
if (width.endsWith("%")) return `${parseInt(width)}vw`;
|
|
42
|
+
if (width.endsWith("vw")) return `${parseInt(width)}vw`;
|
|
43
|
+
if (width.endsWith("em")) return `${parseInt(width)}em`;
|
|
71
44
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return supportedWidth <= maxWidth;
|
|
77
|
-
});
|
|
45
|
+
const isFixedImageWidth = (width)=>{
|
|
46
|
+
if (Number.isFinite(width)) return true;
|
|
47
|
+
if ("string" == typeof width && width.endsWith("px")) return true;
|
|
48
|
+
return false;
|
|
78
49
|
};
|
|
79
|
-
const
|
|
80
|
-
|
|
50
|
+
const getSrcSetAutoSizes = (max)=>{
|
|
51
|
+
max = isFixedImageWidth(max) ? parseInt("" + max) : 2500;
|
|
52
|
+
const maxWidth = getSupportedImageResizeWidth(max);
|
|
53
|
+
return SUPPORTED_IMAGE_RESIZE_WIDTHS.filter((supportedWidth)=>supportedWidth <= maxWidth);
|
|
81
54
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
getImageSrc: props => {
|
|
92
|
-
if (!props) {
|
|
93
|
-
return "";
|
|
94
|
-
}
|
|
95
|
-
const {
|
|
96
|
-
src,
|
|
97
|
-
transform
|
|
98
|
-
} = props;
|
|
99
|
-
if (!transform) {
|
|
100
|
-
return src;
|
|
101
|
-
}
|
|
102
|
-
if (!src || src.startsWith("data:") || src.endsWith("svg")) {
|
|
103
|
-
return src;
|
|
104
|
-
}
|
|
105
|
-
const sanitizedParams = sanitizeTransformArgs(transform);
|
|
106
|
-
const params = convertTransformToQueryParams(sanitizedParams);
|
|
107
|
-
return src + "?" + params;
|
|
108
|
-
},
|
|
109
|
-
render(props) {
|
|
110
|
-
const {
|
|
111
|
-
transform,
|
|
112
|
-
srcSet: srcSetInitial,
|
|
113
|
-
...imageProps
|
|
114
|
-
} = props;
|
|
115
|
-
let srcSet = srcSetInitial;
|
|
116
|
-
let sizes;
|
|
117
|
-
const src = imageProps.src;
|
|
118
|
-
if (srcSet && srcSet === "auto") {
|
|
119
|
-
srcSet = {};
|
|
120
|
-
|
|
121
|
-
// Check if image width was forced, and additionally if width was set as pixels, with "px" in the value.
|
|
122
|
-
const forcedWidth = props.width || props.style && props.style.width;
|
|
123
|
-
const srcSetAutoWidths = getSrcSetAutoSizes(forcedWidth);
|
|
124
|
-
srcSetAutoWidths.forEach(width => {
|
|
125
|
-
srcSet[width + "w"] = imagePlugin.getImageSrc({
|
|
126
|
-
src,
|
|
127
|
-
transform: {
|
|
128
|
-
...transform,
|
|
129
|
-
width
|
|
55
|
+
const convertTransformToQueryParams = (transform)=>Object.keys(transform).map((key)=>`${key}=${transform[key]}`).join("&");
|
|
56
|
+
const plugins_image = ()=>{
|
|
57
|
+
const imagePlugin = {
|
|
58
|
+
name: "image-component",
|
|
59
|
+
type: "image-component",
|
|
60
|
+
presets: {
|
|
61
|
+
avatar: {
|
|
62
|
+
width: 300
|
|
130
63
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
64
|
+
},
|
|
65
|
+
getImageSrc: (props)=>{
|
|
66
|
+
if (!props) return "";
|
|
67
|
+
const { src, transform } = props;
|
|
68
|
+
if (!transform) return src;
|
|
69
|
+
if (!src || src.startsWith("data:") || src.endsWith("svg")) return src;
|
|
70
|
+
const sanitizedParams = sanitizeTransformArgs(transform);
|
|
71
|
+
const params = convertTransformToQueryParams(sanitizedParams);
|
|
72
|
+
return src + "?" + params;
|
|
73
|
+
},
|
|
74
|
+
render (props) {
|
|
75
|
+
const { transform, srcSet: srcSetInitial, ...imageProps } = props;
|
|
76
|
+
let srcSet = srcSetInitial;
|
|
77
|
+
let sizes;
|
|
78
|
+
const src = imageProps.src;
|
|
79
|
+
if (srcSet && "auto" === srcSet) {
|
|
80
|
+
srcSet = {};
|
|
81
|
+
const forcedWidth = props.width || props.style && props.style.width;
|
|
82
|
+
const srcSetAutoWidths = getSrcSetAutoSizes(forcedWidth);
|
|
83
|
+
srcSetAutoWidths.forEach((width)=>{
|
|
84
|
+
srcSet[width + "w"] = imagePlugin.getImageSrc({
|
|
85
|
+
src,
|
|
86
|
+
transform: {
|
|
87
|
+
...transform,
|
|
88
|
+
width
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
sizes = getSizes(forcedWidth);
|
|
93
|
+
}
|
|
94
|
+
return /*#__PURE__*/ react.createElement(Image, {
|
|
95
|
+
...imageProps,
|
|
96
|
+
srcSet: srcSet,
|
|
97
|
+
src: src,
|
|
98
|
+
sizes: sizes
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return imagePlugin;
|
|
143
103
|
};
|
|
104
|
+
export default plugins_image;
|
|
144
105
|
|
|
145
106
|
//# sourceMappingURL=image.js.map
|
package/plugins/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/image.js","sources":["../../src/plugins/image.tsx"],"sourcesContent":["import React from \"react\";\nimport { Image } from \"./components/Image.js\";\nimport type { ImageComponentPlugin } from \"~/types.js\";\n\nconst SUPPORTED_IMAGE_RESIZE_WIDTHS = [128, 384, 640, 750, 828, 1080, 1200, 1920, 2048, 3840];\n\n/**\n * Width of the image should not be just any random number. For optimization reasons,\n * we only allow the ones listed in SUPPORTED_IMAGE_RESIZE_WIDTHS list (Webiny Cloud supports only these).\n */\nconst getSupportedImageResizeWidth = (width: number) => {\n let output = SUPPORTED_IMAGE_RESIZE_WIDTHS[0];\n let i = SUPPORTED_IMAGE_RESIZE_WIDTHS.length;\n while (i >= 0) {\n if (width === SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {\n output = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];\n break;\n }\n\n if (width > SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {\n // Use next larger width. If there isn't any, use current.\n output = SUPPORTED_IMAGE_RESIZE_WIDTHS[i + 1];\n if (!output) {\n output = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];\n }\n break;\n }\n\n i--;\n }\n\n return output;\n};\n\ninterface SanitizeTransformArgsParams {\n width?: string;\n}\ninterface SanitizeTransformArgsResult {\n width?: number;\n}\n/**\n * Currently we only allow \"width\" as a transform option.\n * @param args\n */\nconst sanitizeTransformArgs = (args?: SanitizeTransformArgsParams): SanitizeTransformArgsResult => {\n const output: SanitizeTransformArgsResult = {};\n if (!args || args.width === undefined || args.width === null) {\n return output;\n }\n const width = parseInt(args.width);\n if (width > 0) {\n output.width = getSupportedImageResizeWidth(width);\n }\n\n return output;\n};\n\nconst getSizes = (width?: string | number): string | undefined => {\n if (typeof width !== \"string\") {\n return undefined;\n }\n // Check if width was set as percentage, with \"%\" in the value.\n if (width.endsWith(\"%\")) {\n return `${parseInt(width)}vw`;\n }\n // Check if width was set as viewport width, with \"vw\" in the value.\n if (width.endsWith(\"vw\")) {\n return `${parseInt(width)}vw`;\n }\n\n // Check if width was set as relative, with \"em\" in the value.\n if (width.endsWith(\"em\")) {\n return `${parseInt(width)}em`;\n }\n\n return undefined;\n};\n\nconst isFixedImageWidth = (width?: number | string) => {\n if (Number.isFinite(width)) {\n return true;\n }\n\n if (typeof width === \"string\" && width.endsWith(\"px\")) {\n return true;\n }\n return false;\n};\n\nconst getSrcSetAutoSizes = (max?: string | number) => {\n max = isFixedImageWidth(max) ? parseInt(\"\" + max) : 2500;\n const maxWidth = getSupportedImageResizeWidth(max);\n return SUPPORTED_IMAGE_RESIZE_WIDTHS.filter((supportedWidth: number) => {\n return supportedWidth <= maxWidth;\n });\n};\n\nconst convertTransformToQueryParams = (transform: Record<string, any>): string => {\n return Object.keys(transform)\n .map(key => `${key}=${transform[key]}`)\n .join(\"&\");\n};\n\nexport default () => {\n const imagePlugin: ImageComponentPlugin = {\n name: \"image-component\",\n type: \"image-component\",\n presets: {\n avatar: { width: 300 }\n },\n getImageSrc: (props?: Record<string, any>) => {\n if (!props) {\n return \"\";\n }\n\n const { src, transform } = props;\n if (!transform) {\n return src;\n }\n\n if (!src || src.startsWith(\"data:\") || src.endsWith(\"svg\")) {\n return src;\n }\n\n const sanitizedParams = sanitizeTransformArgs(transform);\n const params = convertTransformToQueryParams(sanitizedParams);\n return src + \"?\" + params;\n },\n render(props) {\n const { transform, srcSet: srcSetInitial, ...imageProps } = props;\n let srcSet: any = srcSetInitial;\n let sizes: string | undefined;\n const src = imageProps.src;\n if (srcSet && srcSet === \"auto\") {\n srcSet = {};\n\n // Check if image width was forced, and additionally if width was set as pixels, with \"px\" in the value.\n const forcedWidth = props.width || (props.style && props.style.width);\n const srcSetAutoWidths = getSrcSetAutoSizes(forcedWidth);\n srcSetAutoWidths.forEach(width => {\n srcSet[width + \"w\"] = imagePlugin.getImageSrc({\n src,\n transform: { ...transform, width }\n });\n });\n sizes = getSizes(forcedWidth);\n }\n\n return <Image {...imageProps} srcSet={srcSet} src={src} sizes={sizes} />;\n }\n };\n\n return imagePlugin;\n};\n"],"names":["SUPPORTED_IMAGE_RESIZE_WIDTHS","getSupportedImageResizeWidth","width","output","i","sanitizeTransformArgs","args","undefined","parseInt","getSizes","isFixedImageWidth","Number","getSrcSetAutoSizes","max","maxWidth","supportedWidth","convertTransformToQueryParams","transform","Object","key","imagePlugin","props","src","sanitizedParams","params","srcSetInitial","imageProps","srcSet","sizes","forcedWidth","srcSetAutoWidths","Image"],"mappings":"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"}
|
package/plugins/index.js
CHANGED
|
@@ -1,66 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import warning from "warning";
|
|
3
3
|
import { plugins } from "@webiny/plugins";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
import image_0 from "./image.js";
|
|
5
|
+
const PluginComponent = (props)=>props.children;
|
|
6
|
+
const PluginsComponent = (props)=>props.children;
|
|
7
|
+
const renderPlugin = (name, params = {}, options = {})=>{
|
|
8
|
+
const { wrapper = true, fn = "render" } = options;
|
|
9
|
+
const plugin = plugins.byName(name);
|
|
10
|
+
warning(plugin, `No such plugin "${name}"`);
|
|
11
|
+
if (!plugin) return null;
|
|
12
|
+
const content = plugin[fn](params);
|
|
13
|
+
if (content) return wrapper ? /*#__PURE__*/ react.createElement(PluginComponent, {
|
|
14
|
+
key: plugin.name,
|
|
15
|
+
name: name,
|
|
16
|
+
params: params,
|
|
17
|
+
fn: fn
|
|
18
|
+
}, content) : /*#__PURE__*/ react.cloneElement(content, {
|
|
19
|
+
key: plugin.name
|
|
20
|
+
});
|
|
20
21
|
return null;
|
|
21
|
-
}
|
|
22
|
-
const content = plugin[fn](params);
|
|
23
|
-
if (content) {
|
|
24
|
-
return wrapper ? /*#__PURE__*/React.createElement(PluginComponent, {
|
|
25
|
-
key: plugin.name,
|
|
26
|
-
name: name,
|
|
27
|
-
params: params,
|
|
28
|
-
fn: fn
|
|
29
|
-
}, content) : (/*#__PURE__*/React.cloneElement(content, {
|
|
30
|
-
key: plugin.name
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
22
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return filter(pl);
|
|
48
|
-
})
|
|
49
|
-
/**
|
|
50
|
-
* We cast as string because renderPlugin checks for the plugin.name
|
|
51
|
-
*/.map(plugin => renderPlugin(plugin.name, params, {
|
|
52
|
-
wrapper,
|
|
53
|
-
fn
|
|
54
|
-
})).filter(Boolean);
|
|
55
|
-
if (reverse) {
|
|
56
|
-
content.reverse();
|
|
57
|
-
}
|
|
58
|
-
return wrapper ? /*#__PURE__*/React.createElement(PluginsComponent, {
|
|
59
|
-
type: type,
|
|
60
|
-
params: params,
|
|
61
|
-
fn: fn
|
|
62
|
-
}, content) : content;
|
|
23
|
+
const renderPlugins = (type, params = {}, options = {})=>{
|
|
24
|
+
const { wrapper = true, fn = "render", filter = (v)=>v, reverse } = options;
|
|
25
|
+
const content = plugins.byType(type).filter((pl)=>filter(pl)).map((plugin)=>renderPlugin(plugin.name, params, {
|
|
26
|
+
wrapper,
|
|
27
|
+
fn
|
|
28
|
+
})).filter(Boolean);
|
|
29
|
+
if (reverse) content.reverse();
|
|
30
|
+
return wrapper ? /*#__PURE__*/ react.createElement(PluginsComponent, {
|
|
31
|
+
type: type,
|
|
32
|
+
params: params,
|
|
33
|
+
fn: fn
|
|
34
|
+
}, content) : content;
|
|
63
35
|
};
|
|
64
|
-
|
|
36
|
+
const src_plugins = [
|
|
37
|
+
image_0
|
|
38
|
+
];
|
|
39
|
+
export default src_plugins;
|
|
40
|
+
export { image_0 as imagePlugin, renderPlugin, renderPlugins };
|
|
65
41
|
|
|
66
42
|
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/index.js","sources":["../../src/plugins/index.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\nimport warning from \"warning\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { Plugin } from \"@webiny/plugins/types.js\";\nimport imagePlugin from \"./image.js\";\n\nexport { imagePlugin };\n\ntype RenderPluginOptions<T> = {\n wrapper?: boolean;\n fn?: string;\n filter?: (value: T, index: number, array: T[]) => boolean;\n reverse?: boolean;\n};\n\ninterface RenderPlugin {\n <T extends Plugin = Plugin>(\n name: string,\n params?: any,\n options?: RenderPluginOptions<T>\n ): ReactNode | ReactNode[];\n}\n\ninterface RenderPlugins {\n <T extends Plugin = Plugin>(\n type: string,\n params?: any,\n options?: RenderPluginOptions<T>\n ): ReactNode | ReactNode[];\n}\n\ninterface PluginComponentProps {\n name: string;\n params: Record<string, any>;\n fn: string;\n children: React.ReactNode;\n}\nconst PluginComponent = (props: PluginComponentProps) => {\n return props.children as React.ReactElement;\n};\ninterface PluginsComponentProps {\n type: string;\n params: Record<string, any>;\n fn: string;\n children: React.ReactNode;\n}\nconst PluginsComponent = (props: PluginsComponentProps) => {\n return props.children as React.ReactElement;\n};\n\nexport const renderPlugin: RenderPlugin = (name, params = {}, options = {}) => {\n const { wrapper = true, fn = \"render\" } = options;\n\n const plugin = plugins.byName(name);\n warning(plugin, `No such plugin \"${name}\"`);\n\n if (!plugin) {\n return null;\n }\n\n const content = plugin[fn](params);\n if (content) {\n return wrapper ? (\n <PluginComponent key={plugin.name} name={name} params={params} fn={fn}>\n {content}\n </PluginComponent>\n ) : (\n React.cloneElement(content, { key: plugin.name })\n );\n }\n return null;\n};\n\nexport const renderPlugins: RenderPlugins = (type, params = {}, options = {}) => {\n const { wrapper = true, fn = \"render\", filter = v => v, reverse } = options;\n\n const content = plugins\n .byType(type)\n .filter(pl => {\n /**\n * TODO @ts-refactor Problem with possibility of a different subtype.\n */\n // @ts-expect-error\n return filter(pl);\n })\n /**\n * We cast as string because renderPlugin checks for the plugin.name\n */\n .map(plugin => renderPlugin(plugin.name as string, params, { wrapper, fn }))\n .filter(Boolean);\n\n if (reverse) {\n content.reverse();\n }\n\n return wrapper ? (\n <PluginsComponent type={type} params={params} fn={fn}>\n {content}\n </PluginsComponent>\n ) : (\n content\n );\n};\n\nexport default [imagePlugin];\n"],"names":["PluginComponent","props","PluginsComponent","renderPlugin","name","params","options","wrapper","fn","plugin","plugins","warning","content","React","renderPlugins","type","filter","v","reverse","pl","Boolean","imagePlugin"],"mappings":";;;;AAsCA,MAAMA,kBAAkB,CAACC,QACdA,MAAM,QAAQ;AAQzB,MAAMC,mBAAmB,CAACD,QACfA,MAAM,QAAQ;AAGlB,MAAME,eAA6B,CAACC,MAAMC,SAAS,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC;IACtE,MAAM,EAAEC,UAAU,IAAI,EAAEC,KAAK,QAAQ,EAAE,GAAGF;IAE1C,MAAMG,SAASC,QAAQ,MAAM,CAACN;IAC9BO,QAAQF,QAAQ,CAAC,gBAAgB,EAAEL,KAAK,CAAC,CAAC;IAE1C,IAAI,CAACK,QACD,OAAO;IAGX,MAAMG,UAAUH,MAAM,CAACD,GAAG,CAACH;IAC3B,IAAIO,SACA,OAAOL,UAAU,WAAVA,GACH,oBAACP,iBAAeA;QAAC,KAAKS,OAAO,IAAI;QAAE,MAAML;QAAM,QAAQC;QAAQ,IAAIG;OAC9DI,WAAAA,WAAAA,GAGLC,MAAAA,YAAkB,CAACD,SAAS;QAAE,KAAKH,OAAO,IAAI;IAAC;IAGvD,OAAO;AACX;AAEO,MAAMK,gBAA+B,CAACC,MAAMV,SAAS,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC;IACxE,MAAM,EAAEC,UAAU,IAAI,EAAEC,KAAK,QAAQ,EAAEQ,SAASC,CAAAA,IAAKA,CAAC,EAAEC,OAAO,EAAE,GAAGZ;IAEpE,MAAMM,UAAUF,QAAAA,MACL,CAACK,MACP,MAAM,CAACI,CAAAA,KAKGH,OAAOG,KAKjB,GAAG,CAACV,CAAAA,SAAUN,aAAaM,OAAO,IAAI,EAAYJ,QAAQ;YAAEE;YAASC;QAAG,IACxE,MAAM,CAACY;IAEZ,IAAIF,SACAN,QAAQ,OAAO;IAGnB,OAAOL,UAAU,WAAVA,GACH,oBAACL,kBAAgBA;QAAC,MAAMa;QAAM,QAAQV;QAAQ,IAAIG;OAC7CI,WAGLA;AAER;AAEA,oBAAe;IAACS;CAAY"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { useFeature } from "../../shared/di/useFeature.js";
|
|
2
2
|
import { EnvConfigFeature } from "../../features/envConfig/feature.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* Useful when you want to access EnvConfig inside components and hooks.
|
|
7
|
-
*/
|
|
8
|
-
export function useEnvConfig() {
|
|
9
|
-
const envConfig = useFeature(EnvConfigFeature);
|
|
10
|
-
return envConfig.getAll();
|
|
3
|
+
function useEnvConfig() {
|
|
4
|
+
const envConfig = useFeature(EnvConfigFeature);
|
|
5
|
+
return envConfig.getAll();
|
|
11
6
|
}
|
|
7
|
+
export { useEnvConfig };
|
|
12
8
|
|
|
13
9
|
//# sourceMappingURL=useEnvConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/envConfig/useEnvConfig.js","sources":["../../../src/presentation/envConfig/useEnvConfig.ts"],"sourcesContent":["import { useFeature } from \"~/shared/di/useFeature.js\";\nimport { EnvConfig } from \"~/features/envConfig/index.js\";\nimport { EnvConfigFeature } from \"~/features/envConfig/feature.js\";\n\n/**\n * Returns the EnvConfig instance from DI.\n * Useful when you want to access EnvConfig inside components and hooks.\n */\nexport function useEnvConfig(): EnvConfig.Config {\n const envConfig = useFeature(EnvConfigFeature);\n\n return envConfig.getAll();\n}\n"],"names":["useEnvConfig","envConfig","useFeature","EnvConfigFeature"],"mappings":";;AAQO,SAASA;IACZ,MAAMC,YAAYC,WAAWC;IAE7B,OAAOF,UAAU,MAAM;AAC3B"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { LocalStorageFeature } from "../../features/localStorage/feature.js";
|
|
2
2
|
import { useFeature } from "../../shared/di/useFeature.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
get: localStorageService.get.bind(localStorageService),
|
|
14
|
-
set: localStorageService.set.bind(localStorageService),
|
|
15
|
-
remove: localStorageService.remove.bind(localStorageService),
|
|
16
|
-
clear: localStorageService.clear.bind(localStorageService),
|
|
17
|
-
keys: localStorageService.keys.bind(localStorageService)
|
|
18
|
-
};
|
|
3
|
+
function useLocalStorage() {
|
|
4
|
+
const { localStorageService } = useFeature(LocalStorageFeature);
|
|
5
|
+
return {
|
|
6
|
+
get: localStorageService.get.bind(localStorageService),
|
|
7
|
+
set: localStorageService.set.bind(localStorageService),
|
|
8
|
+
remove: localStorageService.remove.bind(localStorageService),
|
|
9
|
+
clear: localStorageService.clear.bind(localStorageService),
|
|
10
|
+
keys: localStorageService.keys.bind(localStorageService)
|
|
11
|
+
};
|
|
19
12
|
}
|
|
13
|
+
export { useLocalStorage };
|
|
20
14
|
|
|
21
15
|
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/localStorage/useLocalStorage.js","sources":["../../../src/presentation/localStorage/useLocalStorage.ts"],"sourcesContent":["import { LocalStorageFeature } from \"~/features/localStorage/feature.js\";\nimport { LocalStorage } from \"~/features/localStorage/index.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\n/**\n * Returns the LocalStorage instance from DI.\n * Useful when you want to call service methods imperatively inside components.\n */\nexport function useLocalStorage(): LocalStorage.Interface {\n const { localStorageService } = useFeature(LocalStorageFeature);\n\n return {\n get: localStorageService.get.bind(localStorageService),\n set: localStorageService.set.bind(localStorageService),\n remove: localStorageService.remove.bind(localStorageService),\n clear: localStorageService.clear.bind(localStorageService),\n keys: localStorageService.keys.bind(localStorageService)\n };\n}\n"],"names":["useLocalStorage","localStorageService","useFeature","LocalStorageFeature"],"mappings":";;AAQO,SAASA;IACZ,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,WAAWC;IAE3C,OAAO;QACH,KAAKF,oBAAoB,GAAG,CAAC,IAAI,CAACA;QAClC,KAAKA,oBAAoB,GAAG,CAAC,IAAI,CAACA;QAClC,QAAQA,oBAAoB,MAAM,CAAC,IAAI,CAACA;QACxC,OAAOA,oBAAoB,KAAK,CAAC,IAAI,CAACA;QACtC,MAAMA,oBAAoB,IAAI,CAAC,IAAI,CAACA;IACxC;AACJ"}
|
|
@@ -2,19 +2,21 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { autorun } from "mobx";
|
|
3
3
|
import { LocalStorageFeature } from "../../features/localStorage/feature.js";
|
|
4
4
|
import { useFeature } from "../../shared/di/useFeature.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
localStorageService
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
function useLocalStorageValue(key) {
|
|
6
|
+
const { localStorageService } = useFeature(LocalStorageFeature);
|
|
7
|
+
const [value, setValue] = useState(()=>localStorageService.get(key));
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
const dispose = autorun(()=>{
|
|
10
|
+
const value = localStorageService.get(key);
|
|
11
|
+
setValue(value);
|
|
12
|
+
});
|
|
13
|
+
return ()=>dispose();
|
|
14
|
+
}, [
|
|
15
|
+
localStorageService,
|
|
16
|
+
key
|
|
17
|
+
]);
|
|
18
|
+
return value;
|
|
18
19
|
}
|
|
20
|
+
export { useLocalStorageValue };
|
|
19
21
|
|
|
20
22
|
//# sourceMappingURL=useLocalStorageValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/localStorage/useLocalStorageValue.js","sources":["../../../src/presentation/localStorage/useLocalStorageValue.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport { LocalStorageFeature } from \"~/features/localStorage/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\nexport function useLocalStorageValue<T = string>(key: string): T | undefined {\n const { localStorageService } = useFeature(LocalStorageFeature);\n\n const [value, setValue] = useState<T | undefined>(() => localStorageService.get<T>(key));\n\n useEffect(() => {\n const dispose = autorun(() => {\n const value = localStorageService.get<T>(key);\n setValue(value);\n });\n return () => dispose();\n }, [localStorageService, key]);\n\n return value;\n}\n"],"names":["useLocalStorageValue","key","localStorageService","useFeature","LocalStorageFeature","value","setValue","useState","useEffect","dispose","autorun"],"mappings":";;;;AAKO,SAASA,qBAAiCC,GAAW;IACxD,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,WAAWC;IAE3C,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAAwB,IAAML,oBAAoB,GAAG,CAAID;IAEnFO,UAAU;QACN,MAAMC,UAAUC,QAAQ;YACpB,MAAML,QAAQH,oBAAoB,GAAG,CAAID;YACzCK,SAASD;QACb;QACA,OAAO,IAAMI;IACjB,GAAG;QAACP;QAAqBD;KAAI;IAE7B,OAAOI;AACX"}
|