piral-core 0.13.9 → 0.14.0-beta.3157
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/debug-pilet.d.ts +3 -0
- package/debug-pilet.js +12 -0
- package/debug-piral.d.ts +4 -0
- package/debug-piral.js +59 -0
- package/dependencies.codegen +1 -1
- package/esm/Piral.js +6 -8
- package/esm/Piral.js.map +1 -1
- package/esm/actions/app.js +9 -10
- package/esm/actions/app.js.map +1 -1
- package/esm/actions/components.js +4 -5
- package/esm/actions/components.js.map +1 -1
- package/esm/actions/data.js +16 -17
- package/esm/actions/data.js.map +1 -1
- package/esm/actions/define.js +2 -3
- package/esm/actions/define.js.map +1 -1
- package/esm/actions/portal.d.ts +2 -0
- package/esm/actions/portal.js +9 -4
- package/esm/actions/portal.js.map +1 -1
- package/esm/actions/state.js +1 -1
- package/esm/actions/state.js.map +1 -1
- package/esm/components/DefaultErrorInfo.js +1 -2
- package/esm/components/DefaultErrorInfo.js.map +1 -1
- package/esm/components/DefaultLayout.js +1 -4
- package/esm/components/DefaultLayout.js.map +1 -1
- package/esm/components/DefaultLoader.js +1 -1
- package/esm/components/DefaultLoader.js.map +1 -1
- package/esm/components/ErrorBoundary.js +13 -18
- package/esm/components/ErrorBoundary.js.map +1 -1
- package/esm/components/ExtensionSlot.js +5 -9
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/components/Mediator.js +8 -8
- package/esm/components/Mediator.js.map +1 -1
- package/esm/components/PiralRoutes.js +8 -8
- package/esm/components/PiralRoutes.js.map +1 -1
- package/esm/components/PiralView.js +11 -16
- package/esm/components/PiralView.js.map +1 -1
- package/esm/components/PortalRenderer.d.ts +5 -0
- package/esm/components/PortalRenderer.js +7 -0
- package/esm/components/PortalRenderer.js.map +1 -0
- package/esm/components/ResponsiveLayout.js +5 -6
- package/esm/components/ResponsiveLayout.js.map +1 -1
- package/esm/components/SetComponent.js +3 -4
- package/esm/components/SetComponent.js.map +1 -1
- package/esm/components/SetError.js +3 -4
- package/esm/components/SetError.js.map +1 -1
- package/esm/components/SetErrors.js +2 -3
- package/esm/components/SetErrors.js.map +1 -1
- package/esm/components/SetLayout.js +2 -3
- package/esm/components/SetLayout.js.map +1 -1
- package/esm/components/SetProvider.js +3 -4
- package/esm/components/SetProvider.js.map +1 -1
- package/esm/components/SetRedirect.js +3 -4
- package/esm/components/SetRedirect.js.map +1 -1
- package/esm/components/SetRoute.js +3 -4
- package/esm/components/SetRoute.js.map +1 -1
- package/esm/components/SwitchErrorInfo.js +12 -10
- package/esm/components/SwitchErrorInfo.js.map +1 -1
- package/esm/components/components.js +8 -9
- package/esm/components/components.js.map +1 -1
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +1 -0
- package/esm/components/index.js.map +1 -1
- package/esm/createInstance.js +24 -25
- package/esm/createInstance.js.map +1 -1
- package/esm/helpers.d.ts +11 -26
- package/esm/helpers.js +18 -56
- package/esm/helpers.js.map +1 -1
- package/esm/hooks/action.js +1 -1
- package/esm/hooks/action.js.map +1 -1
- package/esm/hooks/actions.js +1 -1
- package/esm/hooks/actions.js.map +1 -1
- package/esm/hooks/globalState.js +5 -5
- package/esm/hooks/globalState.js.map +1 -1
- package/esm/hooks/index.d.ts +0 -5
- package/esm/hooks/index.js +0 -5
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/media.js +8 -7
- package/esm/hooks/media.js.map +1 -1
- package/esm/hooks/setter.js +3 -2
- package/esm/hooks/setter.js.map +1 -1
- package/esm/hooks/sharedData.js +2 -2
- package/esm/hooks/sharedData.js.map +1 -1
- package/esm/modules/api.js +79 -28
- package/esm/modules/api.js.map +1 -1
- package/esm/modules/dependencies.d.ts +3 -4
- package/esm/modules/dependencies.js +11 -14
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/state/createActions.js +7 -12
- package/esm/state/createActions.js.map +1 -1
- package/esm/state/createGlobalState.js +6 -8
- package/esm/state/createGlobalState.js.map +1 -1
- package/esm/state/stateContext.js +1 -1
- package/esm/state/stateContext.js.map +1 -1
- package/esm/state/withApi.js +59 -62
- package/esm/state/withApi.js.map +1 -1
- package/esm/types/config.d.ts +23 -16
- package/esm/types/state.d.ts +13 -0
- package/esm/utils/compare.js +4 -4
- package/esm/utils/compare.js.map +1 -1
- package/esm/utils/data.js +6 -7
- package/esm/utils/data.js.map +1 -1
- package/esm/utils/foreign.d.ts +4 -2
- package/esm/utils/foreign.js +16 -8
- package/esm/utils/foreign.js.map +1 -1
- package/esm/utils/guid.js +3 -3
- package/esm/utils/guid.js.map +1 -1
- package/esm/utils/helpers.d.ts +11 -8
- package/esm/utils/helpers.js +28 -17
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/media.js +8 -7
- package/esm/utils/media.js.map +1 -1
- package/esm/utils/storage.js +13 -14
- package/esm/utils/storage.js.map +1 -1
- package/lib/Piral.js +9 -11
- package/lib/Piral.js.map +1 -1
- package/lib/actions/app.js +11 -12
- package/lib/actions/app.js.map +1 -1
- package/lib/actions/components.js +5 -6
- package/lib/actions/components.js.map +1 -1
- package/lib/actions/data.js +17 -18
- package/lib/actions/data.js.map +1 -1
- package/lib/actions/define.js +2 -3
- package/lib/actions/define.js.map +1 -1
- package/lib/actions/index.js +7 -7
- package/lib/actions/index.js.map +1 -1
- package/lib/actions/portal.d.ts +2 -0
- package/lib/actions/portal.js +12 -5
- package/lib/actions/portal.js.map +1 -1
- package/lib/actions/state.js +3 -3
- package/lib/actions/state.js.map +1 -1
- package/lib/components/DefaultErrorInfo.js +4 -5
- package/lib/components/DefaultErrorInfo.js.map +1 -1
- package/lib/components/DefaultLayout.js +2 -5
- package/lib/components/DefaultLayout.js.map +1 -1
- package/lib/components/DefaultLoader.js +2 -2
- package/lib/components/DefaultLoader.js.map +1 -1
- package/lib/components/ErrorBoundary.js +18 -22
- package/lib/components/ErrorBoundary.js.map +1 -1
- package/lib/components/ExtensionSlot.js +10 -14
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/components/Mediator.js +11 -11
- package/lib/components/Mediator.js.map +1 -1
- package/lib/components/PiralRoutes.js +11 -11
- package/lib/components/PiralRoutes.js.map +1 -1
- package/lib/components/PiralView.js +16 -21
- package/lib/components/PiralView.js.map +1 -1
- package/lib/components/PortalRenderer.d.ts +5 -0
- package/lib/components/PortalRenderer.js +11 -0
- package/lib/components/PortalRenderer.js.map +1 -0
- package/lib/components/ResponsiveLayout.js +9 -10
- package/lib/components/ResponsiveLayout.js.map +1 -1
- package/lib/components/SetComponent.js +4 -5
- package/lib/components/SetComponent.js.map +1 -1
- package/lib/components/SetError.js +4 -5
- package/lib/components/SetError.js.map +1 -1
- package/lib/components/SetErrors.js +4 -5
- package/lib/components/SetErrors.js.map +1 -1
- package/lib/components/SetLayout.js +4 -5
- package/lib/components/SetLayout.js.map +1 -1
- package/lib/components/SetProvider.js +4 -5
- package/lib/components/SetProvider.js.map +1 -1
- package/lib/components/SetRedirect.js +6 -7
- package/lib/components/SetRedirect.js.map +1 -1
- package/lib/components/SetRoute.js +4 -5
- package/lib/components/SetRoute.js.map +1 -1
- package/lib/components/SwitchErrorInfo.js +14 -12
- package/lib/components/SwitchErrorInfo.js.map +1 -1
- package/lib/components/components.js +5 -6
- package/lib/components/components.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +20 -19
- package/lib/components/index.js.map +1 -1
- package/lib/createInstance.js +31 -32
- package/lib/createInstance.js.map +1 -1
- package/lib/helpers.d.ts +11 -26
- package/lib/helpers.js +19 -59
- package/lib/helpers.js.map +1 -1
- package/lib/hooks/action.js +3 -3
- package/lib/hooks/action.js.map +1 -1
- package/lib/hooks/actions.js +4 -4
- package/lib/hooks/actions.js.map +1 -1
- package/lib/hooks/globalState.js +8 -8
- package/lib/hooks/globalState.js.map +1 -1
- package/lib/hooks/index.d.ts +0 -5
- package/lib/hooks/index.js +7 -12
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/media.js +10 -9
- package/lib/hooks/media.js.map +1 -1
- package/lib/hooks/setter.js +4 -3
- package/lib/hooks/setter.js.map +1 -1
- package/lib/hooks/sharedData.js +3 -3
- package/lib/hooks/sharedData.js.map +1 -1
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/modules/api.js +86 -35
- package/lib/modules/api.js.map +1 -1
- package/lib/modules/dependencies.d.ts +3 -4
- package/lib/modules/dependencies.js +13 -16
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/modules/index.js +3 -3
- package/lib/modules/index.js.map +1 -1
- package/lib/state/createActions.js +8 -13
- package/lib/state/createActions.js.map +1 -1
- package/lib/state/createGlobalState.js +9 -11
- package/lib/state/createGlobalState.js.map +1 -1
- package/lib/state/index.js +5 -5
- package/lib/state/index.js.map +1 -1
- package/lib/state/stateContext.js +1 -1
- package/lib/state/stateContext.js.map +1 -1
- package/lib/state/withApi.js +67 -70
- package/lib/state/withApi.js.map +1 -1
- package/lib/types/config.d.ts +23 -16
- package/lib/types/index.js +13 -13
- package/lib/types/index.js.map +1 -1
- package/lib/types/state.d.ts +13 -0
- package/lib/utils/compare.js +4 -4
- package/lib/utils/compare.js.map +1 -1
- package/lib/utils/data.js +6 -7
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/foreign.d.ts +4 -2
- package/lib/utils/foreign.js +21 -11
- package/lib/utils/foreign.js.map +1 -1
- package/lib/utils/guid.js +3 -3
- package/lib/utils/guid.js.map +1 -1
- package/lib/utils/helpers.d.ts +11 -8
- package/lib/utils/helpers.js +30 -17
- package/lib/utils/helpers.js.map +1 -1
- package/lib/utils/index.js +9 -9
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/media.js +7 -6
- package/lib/utils/media.js.map +1 -1
- package/lib/utils/react.js +1 -1
- package/lib/utils/react.js.map +1 -1
- package/lib/utils/storage.js +11 -12
- package/lib/utils/storage.js.map +1 -1
- package/package.json +21 -5
- package/src/Piral.tsx +2 -1
- package/src/actions/portal.ts +19 -1
- package/src/components/ExtensionSlot.tsx +2 -2
- package/src/components/Mediator.tsx +2 -1
- package/src/components/PortalRenderer.tsx +12 -0
- package/src/components/SwitchErrorInfo.tsx +5 -1
- package/src/components/index.ts +1 -0
- package/src/createInstance.tsx +6 -7
- package/src/helpers.test.tsx +7 -39
- package/src/helpers.tsx +32 -85
- package/src/hooks/index.ts +0 -5
- package/src/hooks/media.ts +2 -1
- package/src/hooks/setter.ts +2 -1
- package/src/modules/api.ts +72 -4
- package/src/modules/dependencies.test.ts +18 -5
- package/src/modules/dependencies.ts +12 -18
- package/src/state/withApi.tsx +12 -14
- package/src/types/config.ts +23 -17
- package/src/types/state.ts +13 -0
- package/src/utils/foreign.test.ts +4 -4
- package/src/utils/foreign.ts +28 -5
- package/src/utils/helpers.ts +21 -7
- package/src/utils/media.ts +2 -1
- package/esm/hooks/debounce.d.ts +0 -8
- package/esm/hooks/debounce.js +0 -18
- package/esm/hooks/debounce.js.map +0 -1
- package/esm/hooks/lockBodyScroll.d.ts +0 -6
- package/esm/hooks/lockBodyScroll.js +0 -15
- package/esm/hooks/lockBodyScroll.js.map +0 -1
- package/esm/hooks/onClickOutside.d.ts +0 -8
- package/esm/hooks/onClickOutside.js +0 -23
- package/esm/hooks/onClickOutside.js.map +0 -1
- package/esm/hooks/onScreenVisible.d.ts +0 -11
- package/esm/hooks/onScreenVisible.js +0 -28
- package/esm/hooks/onScreenVisible.js.map +0 -1
- package/esm/hooks/promise.d.ts +0 -13
- package/esm/hooks/promise.js +0 -21
- package/esm/hooks/promise.js.map +0 -1
- package/lib/hooks/debounce.d.ts +0 -8
- package/lib/hooks/debounce.js +0 -22
- package/lib/hooks/debounce.js.map +0 -1
- package/lib/hooks/lockBodyScroll.d.ts +0 -6
- package/lib/hooks/lockBodyScroll.js +0 -19
- package/lib/hooks/lockBodyScroll.js.map +0 -1
- package/lib/hooks/onClickOutside.d.ts +0 -8
- package/lib/hooks/onClickOutside.js +0 -27
- package/lib/hooks/onClickOutside.js.map +0 -1
- package/lib/hooks/onScreenVisible.d.ts +0 -11
- package/lib/hooks/onScreenVisible.js +0 -32
- package/lib/hooks/onScreenVisible.js.map +0 -1
- package/lib/hooks/promise.d.ts +0 -13
- package/lib/hooks/promise.js +0 -25
- package/lib/hooks/promise.js.map +0 -1
- package/src/hooks/debounce.test.ts +0 -67
- package/src/hooks/debounce.ts +0 -19
- package/src/hooks/lockBodyScroll.test.ts +0 -24
- package/src/hooks/lockBodyScroll.ts +0 -15
- package/src/hooks/onClickOutside.test.ts +0 -113
- package/src/hooks/onClickOutside.ts +0 -25
- package/src/hooks/onScreenVisible.test.ts +0 -68
- package/src/hooks/onScreenVisible.ts +0 -28
- package/src/hooks/promise.test.ts +0 -76
- package/src/hooks/promise.ts +0 -35
package/esm/hooks/action.js
CHANGED
|
@@ -5,7 +5,7 @@ import { StateContext } from '../state/stateContext';
|
|
|
5
5
|
* @param action The name of the action to retrieve.
|
|
6
6
|
*/
|
|
7
7
|
export function useAction(action) {
|
|
8
|
-
|
|
8
|
+
const ctx = useContext(StateContext);
|
|
9
9
|
return ctx[action];
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=action.js.map
|
package/esm/hooks/action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAA+B,MAAS;IAC/D,
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAA+B,MAAS;IAC/D,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;AACrB,CAAC"}
|
package/esm/hooks/actions.js
CHANGED
|
@@ -5,7 +5,7 @@ import { StateContext } from '../state/stateContext';
|
|
|
5
5
|
* Hook that gets the actions for manipulating the global state.
|
|
6
6
|
*/
|
|
7
7
|
export function useActions() {
|
|
8
|
-
|
|
8
|
+
const _a = useContext(StateContext), { state } = _a, actions = __rest(_a, ["state"]);
|
|
9
9
|
return actions;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=actions.js.map
|
package/esm/hooks/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/hooks/actions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/hooks/actions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,KAAwB,UAAU,CAAqB,YAAY,CAAC,EAApE,EAAE,KAAK,OAA6D,EAAxD,OAAO,cAAnB,SAAqB,CAA+C,CAAC;IAC3E,OAAO,OAAuB,CAAC;AACjC,CAAC"}
|
package/esm/hooks/globalState.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { useAtom, deref } from '@dbeining/react-atom';
|
|
3
3
|
import { StateContext } from '../state/stateContext';
|
|
4
|
-
|
|
4
|
+
const useGlobalAtom = typeof window !== 'undefined' ? useAtom : useDirectAtom;
|
|
5
5
|
function useDirectAtom(atom, opts) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const state = deref(atom);
|
|
7
|
+
const select = opts && opts.select;
|
|
8
8
|
return typeof select === 'function' ? select(state) : state;
|
|
9
9
|
}
|
|
10
10
|
export function useGlobalState(select) {
|
|
11
|
-
|
|
12
|
-
return useGlobalAtom(state, select && { select
|
|
11
|
+
const { state } = useContext(StateContext);
|
|
12
|
+
return useGlobalAtom(state, select && { select });
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=globalState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalState.js","sourceRoot":"","sources":["../../src/hooks/globalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,
|
|
1
|
+
{"version":3,"file":"globalState.js","sourceRoot":"","sources":["../../src/hooks/globalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,MAAM,aAAa,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;AAE9E,SAAS,aAAa,CAAC,IAAS,EAAE,IAAS;IACzC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,MAAM,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC;IACnC,OAAO,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC;AAeD,MAAM,UAAU,cAAc,CAAI,MAAkC;IAClE,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAC3C,OAAO,aAAa,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
export * from './action';
|
|
2
2
|
export * from './actions';
|
|
3
|
-
export * from './debounce';
|
|
4
3
|
export * from './globalState';
|
|
5
|
-
export * from './lockBodyScroll';
|
|
6
4
|
export * from './media';
|
|
7
|
-
export * from './onClickOutside';
|
|
8
|
-
export * from './onScreenVisible';
|
|
9
|
-
export * from './promise';
|
|
10
5
|
export * from './setter';
|
|
11
6
|
export * from './sharedData';
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
export * from './action';
|
|
2
2
|
export * from './actions';
|
|
3
|
-
export * from './debounce';
|
|
4
3
|
export * from './globalState';
|
|
5
|
-
export * from './lockBodyScroll';
|
|
6
4
|
export * from './media';
|
|
7
|
-
export * from './onClickOutside';
|
|
8
|
-
export * from './onScreenVisible';
|
|
9
|
-
export * from './promise';
|
|
10
5
|
export * from './setter';
|
|
11
6
|
export * from './sharedData';
|
|
12
7
|
//# sourceMappingURL=index.js.map
|
package/esm/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
package/esm/hooks/media.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
+
import { none } from '../utils/helpers';
|
|
2
3
|
import { getCurrentLayout } from '../utils/media';
|
|
3
4
|
/**
|
|
4
5
|
* Hook to detect layout changes (e.g., which UI breakpoint was hit).
|
|
@@ -7,15 +8,15 @@ import { getCurrentLayout } from '../utils/media';
|
|
|
7
8
|
* @param defaultValue The default value.
|
|
8
9
|
*/
|
|
9
10
|
export function useMedia(queries, values, defaultValue) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
useEffect(
|
|
11
|
+
const match = () => getCurrentLayout(queries, values, defaultValue);
|
|
12
|
+
const [value, update] = useState(match);
|
|
13
|
+
useEffect(() => {
|
|
13
14
|
if (typeof document !== 'undefined') {
|
|
14
|
-
|
|
15
|
-
window.addEventListener('resize',
|
|
16
|
-
return
|
|
15
|
+
const handler = () => update(match);
|
|
16
|
+
window.addEventListener('resize', handler);
|
|
17
|
+
return () => window.removeEventListener('resize', handler);
|
|
17
18
|
}
|
|
18
|
-
},
|
|
19
|
+
}, none);
|
|
19
20
|
return value;
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=media.js.map
|
package/esm/hooks/media.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/hooks/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,OAAsB,EAAE,MAAgB,EAAE,YAAe;IACnF,
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/hooks/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,OAAsB,EAAE,MAAgB,EAAE,YAAe;IACnF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACpE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACnC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC3C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;SAC5D;IACH,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/esm/hooks/setter.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useEffect as useSideEffect } from 'react';
|
|
2
|
+
import { none } from '../utils/helpers';
|
|
2
3
|
function useMainEffect(cb) {
|
|
3
4
|
cb();
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
const useEffect = typeof window !== 'undefined' ? useSideEffect : useMainEffect;
|
|
6
7
|
/**
|
|
7
8
|
* Hook for running the callback once on mount.
|
|
8
9
|
* @param cb The callback to be invoked on mounting.
|
|
9
10
|
*/
|
|
10
11
|
export function useSetter(cb) {
|
|
11
|
-
useEffect(cb,
|
|
12
|
+
useEffect(cb, none);
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=setter.js.map
|
package/esm/hooks/setter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setter.js","sourceRoot":"","sources":["../../src/hooks/setter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"setter.js","sourceRoot":"","sources":["../../src/hooks/setter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,SAAS,aAAa,CAAC,EAAc;IACnC,EAAE,EAAE,CAAC;AACP,CAAC;AAED,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAEhF;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAc;IACtC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
package/esm/hooks/sharedData.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useGlobalState } from './globalState';
|
|
2
2
|
export function useSharedData(s) {
|
|
3
|
-
|
|
4
|
-
return useGlobalState(
|
|
3
|
+
const select = s || ((m) => m);
|
|
4
|
+
return useGlobalState((s) => select(s.data));
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=sharedData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedData.js","sourceRoot":"","sources":["../../src/hooks/sharedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgB/C,MAAM,UAAU,aAAa,CAAI,CAAiD;IAChF,
|
|
1
|
+
{"version":3,"file":"sharedData.js","sourceRoot":"","sources":["../../src/hooks/sharedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgB/C,MAAM,UAAU,aAAa,CAAI,CAAiD;IAChF,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
package/esm/modules/api.js
CHANGED
|
@@ -1,67 +1,118 @@
|
|
|
1
|
-
import { __assign as __assign_1, __spreadArray } from "tslib";
|
|
2
1
|
import { isfunc, initializeApi, mergeApis } from 'piral-base';
|
|
3
2
|
import { withApi } from '../state';
|
|
4
3
|
import { ExtensionSlot } from '../components';
|
|
5
|
-
import { createDataOptions, getDataExpiration, renderInDom } from '../utils';
|
|
4
|
+
import { createDataOptions, getDataExpiration, renderInDom, tryParseJson, changeDomPortal, noop } from '../utils';
|
|
5
|
+
if ('customElements' in window) {
|
|
6
|
+
class PiralExtension extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.dispose = noop;
|
|
10
|
+
this.update = noop;
|
|
11
|
+
}
|
|
12
|
+
getProps() {
|
|
13
|
+
const name = this.getAttribute('name');
|
|
14
|
+
const params = tryParseJson(this.getAttribute('params'));
|
|
15
|
+
return { name, params };
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
if (this.isConnected) {
|
|
19
|
+
this.dispatchEvent(new CustomEvent('render-html', {
|
|
20
|
+
bubbles: true,
|
|
21
|
+
detail: {
|
|
22
|
+
target: this,
|
|
23
|
+
props: this.getProps(),
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
this.dispose();
|
|
30
|
+
this.dispose = noop;
|
|
31
|
+
this.update = noop;
|
|
32
|
+
}
|
|
33
|
+
attributeChangedCallback() {
|
|
34
|
+
this.update(this.getProps());
|
|
35
|
+
}
|
|
36
|
+
static get observedAttributes() {
|
|
37
|
+
return ['name', 'params'];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
customElements.define('piral-extension', PiralExtension);
|
|
41
|
+
}
|
|
42
|
+
function render(context, element, props) {
|
|
43
|
+
let [id, portal] = renderInDom(context, element, ExtensionSlot, props);
|
|
44
|
+
const dispose = () => context.hidePortal(id, portal);
|
|
45
|
+
const update = (newProps) => {
|
|
46
|
+
[id, portal] = changeDomPortal(id, portal, context, element, ExtensionSlot, newProps);
|
|
47
|
+
};
|
|
48
|
+
return [dispose, update];
|
|
49
|
+
}
|
|
6
50
|
export function createCoreApi(context) {
|
|
7
|
-
|
|
8
|
-
|
|
51
|
+
document.body.addEventListener('render-html', (ev) => {
|
|
52
|
+
ev.stopPropagation();
|
|
53
|
+
const container = ev.detail.target;
|
|
54
|
+
const [dispose, update] = render(context, container, ev.detail.props);
|
|
55
|
+
container.dispose = dispose;
|
|
56
|
+
container.update = update;
|
|
57
|
+
}, false);
|
|
58
|
+
return (api, target) => {
|
|
59
|
+
const pilet = target.name;
|
|
9
60
|
return {
|
|
10
|
-
getData
|
|
61
|
+
getData(name) {
|
|
11
62
|
return context.readDataValue(name);
|
|
12
63
|
},
|
|
13
|
-
setData
|
|
14
|
-
|
|
15
|
-
|
|
64
|
+
setData(name, value, options) {
|
|
65
|
+
const { target = 'memory', expires } = createDataOptions(options);
|
|
66
|
+
const expiration = getDataExpiration(expires);
|
|
16
67
|
return context.tryWriteDataItem(name, value, pilet, target, expiration);
|
|
17
68
|
},
|
|
18
|
-
registerPage
|
|
69
|
+
registerPage(route, arg, meta) {
|
|
19
70
|
context.registerPage(route, {
|
|
20
|
-
pilet
|
|
21
|
-
meta
|
|
71
|
+
pilet,
|
|
72
|
+
meta,
|
|
22
73
|
component: withApi(context, arg, api, 'page'),
|
|
23
74
|
});
|
|
24
|
-
return
|
|
75
|
+
return () => api.unregisterPage(route);
|
|
25
76
|
},
|
|
26
|
-
unregisterPage
|
|
77
|
+
unregisterPage(route) {
|
|
27
78
|
context.unregisterPage(route);
|
|
28
79
|
},
|
|
29
|
-
registerExtension
|
|
80
|
+
registerExtension(name, arg, defaults) {
|
|
30
81
|
context.registerExtension(name, {
|
|
31
|
-
pilet
|
|
82
|
+
pilet,
|
|
32
83
|
component: withApi(context, arg, api, 'extension'),
|
|
33
84
|
reference: arg,
|
|
34
|
-
defaults
|
|
85
|
+
defaults,
|
|
35
86
|
});
|
|
36
|
-
return
|
|
87
|
+
return () => api.unregisterExtension(name, arg);
|
|
37
88
|
},
|
|
38
|
-
unregisterExtension
|
|
89
|
+
unregisterExtension(name, arg) {
|
|
39
90
|
context.unregisterExtension(name, arg);
|
|
40
91
|
},
|
|
41
|
-
renderHtmlExtension
|
|
42
|
-
|
|
43
|
-
return
|
|
92
|
+
renderHtmlExtension(element, props) {
|
|
93
|
+
const [dispose] = render(context, element, props);
|
|
94
|
+
return dispose;
|
|
44
95
|
},
|
|
45
96
|
Extension: ExtensionSlot,
|
|
46
97
|
};
|
|
47
98
|
};
|
|
48
99
|
}
|
|
49
100
|
export function createExtenders(context, apis) {
|
|
50
|
-
|
|
51
|
-
return creators.map(
|
|
52
|
-
|
|
101
|
+
const creators = [createCoreApi, ...apis.filter(isfunc)];
|
|
102
|
+
return creators.map((c) => {
|
|
103
|
+
const ctx = c(context);
|
|
53
104
|
if (isfunc(ctx)) {
|
|
54
105
|
return ctx;
|
|
55
106
|
}
|
|
56
107
|
else {
|
|
57
|
-
return
|
|
108
|
+
return () => (Object.assign({}, ctx));
|
|
58
109
|
}
|
|
59
110
|
});
|
|
60
111
|
}
|
|
61
112
|
export function defaultApiFactory(context, apis) {
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
|
|
113
|
+
const extenders = createExtenders(context, apis);
|
|
114
|
+
return (target) => {
|
|
115
|
+
const api = initializeApi(target, context);
|
|
65
116
|
context.apis[target.name] = api;
|
|
66
117
|
return mergeApis(api, extenders, target);
|
|
67
118
|
};
|
package/esm/modules/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqC,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjG,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAOlH,IAAI,gBAAgB,IAAI,MAAM,EAAE;IAC9B,MAAM,cAAe,SAAQ,WAAW;QAAxC;;YACE,YAAO,GAAe,IAAI,CAAC;YAC3B,WAAM,GAAc,IAAI,CAAC;QAmC3B,CAAC;QAjCC,QAAQ;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;QAED,iBAAiB;YACf,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,aAAa,EAAE;oBAC7B,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE;wBACN,MAAM,EAAE,IAAI;wBACZ,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE;qBACvB;iBACF,CAAC,CACH,CAAC;aACH;QACH,CAAC;QAED,oBAAoB;YAClB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,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|
|
|
1
1
|
import { PiletMetadata, AvailableDependencies } from 'piral-base';
|
|
2
2
|
/**
|
|
3
3
|
* The global dependencies, which represent the dependencies
|
|
4
|
-
*
|
|
4
|
+
* shared from the app shell itself.
|
|
5
5
|
*/
|
|
6
6
|
export declare const globalDependencies: AvailableDependencies;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* are the global dependencies and the implicitly shared
|
|
8
|
+
* The default dependency selector, which just returns the provided
|
|
10
9
|
* dependencies.
|
|
11
10
|
*/
|
|
12
|
-
export declare function
|
|
11
|
+
export declare function defaultDependencySelector(dependencies: AvailableDependencies): AvailableDependencies;
|
|
13
12
|
/**
|
|
14
13
|
* The default pilet requester, which just returns an empty array.
|
|
15
14
|
* Use your own code to connect to the feed service.
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { isfunc } from 'piral-base';
|
|
3
|
-
var sharedDependencies = {};
|
|
4
|
-
if (process.env.SHARED_DEPENDENCIES) {
|
|
5
|
-
var fillDependencies = require('../../dependencies.codegen');
|
|
6
|
-
if (isfunc(fillDependencies)) {
|
|
7
|
-
fillDependencies(sharedDependencies);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
2
|
/**
|
|
11
3
|
* The global dependencies, which represent the dependencies
|
|
12
|
-
*
|
|
4
|
+
* shared from the app shell itself.
|
|
13
5
|
*/
|
|
14
|
-
export
|
|
6
|
+
export const globalDependencies = {
|
|
15
7
|
react: require('react'),
|
|
16
8
|
'react-dom': require('react-dom'),
|
|
17
9
|
'react-router': require('react-router'),
|
|
@@ -22,13 +14,18 @@ export var globalDependencies = {
|
|
|
22
14
|
'@libre/atom': require('@libre/atom'),
|
|
23
15
|
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
24
16
|
};
|
|
17
|
+
if (process.env.SHARED_DEPENDENCIES) {
|
|
18
|
+
const fillDependencies = require('../../dependencies.codegen');
|
|
19
|
+
if (isfunc(fillDependencies)) {
|
|
20
|
+
fillDependencies(globalDependencies);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
25
23
|
/**
|
|
26
|
-
*
|
|
27
|
-
* are the global dependencies and the implicitly shared
|
|
24
|
+
* The default dependency selector, which just returns the provided
|
|
28
25
|
* dependencies.
|
|
29
26
|
*/
|
|
30
|
-
export function
|
|
31
|
-
return
|
|
27
|
+
export function defaultDependencySelector(dependencies) {
|
|
28
|
+
return dependencies;
|
|
32
29
|
}
|
|
33
30
|
/**
|
|
34
31
|
* The default pilet requester, which just returns an empty array.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,MAAM,EAAE,MAAM,YAAY,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B;IACvD,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;CACxD,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;KACtC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import * as actions from '../actions';
|
|
3
2
|
function createContext(state, events) {
|
|
4
|
-
|
|
5
|
-
html:
|
|
6
|
-
|
|
7
|
-
return component;
|
|
8
|
-
},
|
|
9
|
-
}, state: state });
|
|
3
|
+
const ctx = Object.assign(Object.assign({}, events), { apis: {}, converters: {
|
|
4
|
+
html: ({ component }) => component,
|
|
5
|
+
}, state });
|
|
10
6
|
return ctx;
|
|
11
7
|
}
|
|
12
8
|
export function includeActions(ctx, actions) {
|
|
13
|
-
|
|
14
|
-
for (
|
|
15
|
-
|
|
16
|
-
var action = actions[actionName];
|
|
9
|
+
const actionNames = Object.keys(actions);
|
|
10
|
+
for (const actionName of actionNames) {
|
|
11
|
+
const action = actions[actionName];
|
|
17
12
|
ctx[actionName] = action.bind(ctx, ctx);
|
|
18
13
|
}
|
|
19
14
|
}
|
|
20
15
|
export function createActions(state, events) {
|
|
21
|
-
|
|
16
|
+
const context = createContext(state, events);
|
|
22
17
|
includeActions(context, actions);
|
|
23
18
|
return context;
|
|
24
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAItC,SAAS,aAAa,CAAC,KAAwB,EAAE,MAAoB;IACnE,MAAM,GAAG,GAAG,gCACP,MAAM,KACT,IAAI,EAAE,EAAE,EACR,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS;SACnC,EACD,KAAK,GACgB,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAuB,EAAE,OAA2B;IACjF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAwB,EAAE,MAAoB;IAC1E,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -2,21 +2,19 @@ import { Atom } from '@dbeining/react-atom';
|
|
|
2
2
|
import { BrowserRouter } from 'react-router-dom';
|
|
3
3
|
import { DefaultErrorInfo, DefaultLoadingIndicator, DefaultLayout } from '../components';
|
|
4
4
|
function extend(defaultState, customState) {
|
|
5
|
-
for (
|
|
6
|
-
var key = _a[_i];
|
|
5
|
+
for (const key of Object.keys(customState)) {
|
|
7
6
|
if (key === '__proto__' || key === 'constructor') {
|
|
8
7
|
continue;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const value = customState[key];
|
|
10
|
+
const original = defaultState[key];
|
|
11
|
+
const nested = typeof original === 'object' && typeof value === 'object';
|
|
13
12
|
defaultState[key] = nested ? extend(original, value) : value;
|
|
14
13
|
}
|
|
15
14
|
return defaultState;
|
|
16
15
|
}
|
|
17
|
-
export function createGlobalState(customState) {
|
|
18
|
-
|
|
19
|
-
var defaultState = {
|
|
16
|
+
export function createGlobalState(customState = {}) {
|
|
17
|
+
const defaultState = {
|
|
20
18
|
app: {
|
|
21
19
|
error: undefined,
|
|
22
20
|
loading: typeof window !== 'undefined',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGzF,SAAS,MAAM,CAAI,YAAe,EAAE,WAA6B;IAC/D,
|
|
1
|
+
{"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGzF,SAAS,MAAM,CAAI,YAAe,EAAE,WAA6B;IAC/D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC1C,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,EAAE;YAChD,SAAS;SACV;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;QACzE,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC9D;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,cAA0C,EAAE;IAC5E,MAAM,YAAY,GAAgB;QAChC,GAAG,EAAE;YACH,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,OAAO,MAAM,KAAK,WAAW;YACtC,MAAM,EAAE,SAAS;SAClB;QACD,UAAU,EAAE;YACV,SAAS,EAAE,gBAAgB;YAC3B,gBAAgB,EAAE,uBAAuB;YACzC,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,aAAa;SACtB;QACD,eAAe,EAAE,EAAE;QACnB,QAAQ,EAAE;YACR,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;SACb;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateContext.js","sourceRoot":"","sources":["../../src/state/stateContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"stateContext.js","sourceRoot":"","sources":["../../src/state/stateContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAqB,SAAS,CAAC,CAAC;AAE/E,eAAe,YAAY,CAAC"}
|