piral-core 0.15.0-alpha.4332 → 0.15.0-alpha.4396

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.
Files changed (55) hide show
  1. package/esm/actions/state.js +6 -7
  2. package/esm/actions/state.js.map +1 -1
  3. package/esm/debugger.js +1 -2
  4. package/esm/debugger.js.map +1 -1
  5. package/esm/hooks/globalState.js +2 -9
  6. package/esm/hooks/globalState.js.map +1 -1
  7. package/esm/state/createActions.d.ts +2 -2
  8. package/esm/state/createActions.js.map +1 -1
  9. package/esm/state/createGlobalState.d.ts +1 -2
  10. package/esm/state/createGlobalState.js +2 -2
  11. package/esm/state/createGlobalState.js.map +1 -1
  12. package/esm/types/state.d.ts +2 -3
  13. package/lib/actions/state.js +6 -7
  14. package/lib/actions/state.js.map +1 -1
  15. package/lib/debugger.js +1 -2
  16. package/lib/debugger.js.map +1 -1
  17. package/lib/hooks/globalState.js +2 -9
  18. package/lib/hooks/globalState.js.map +1 -1
  19. package/lib/state/createActions.d.ts +2 -2
  20. package/lib/state/createActions.js.map +1 -1
  21. package/lib/state/createGlobalState.d.ts +1 -2
  22. package/lib/state/createGlobalState.js +2 -2
  23. package/lib/state/createGlobalState.js.map +1 -1
  24. package/lib/types/state.d.ts +2 -3
  25. package/package.json +7 -13
  26. package/src/RootListener.test.tsx +5 -7
  27. package/src/actions/app.test.ts +32 -32
  28. package/src/actions/components.test.ts +10 -10
  29. package/src/actions/data.test.ts +49 -49
  30. package/src/actions/define.test.ts +2 -2
  31. package/src/actions/portal.test.ts +17 -17
  32. package/src/actions/state.test.ts +3 -3
  33. package/src/actions/state.ts +7 -8
  34. package/src/components/ForeignComponentContainer.test.tsx +14 -13
  35. package/src/components/Mediator.test.tsx +11 -10
  36. package/src/debugger.ts +1 -2
  37. package/src/helpers.test.tsx +9 -8
  38. package/src/hooks/globalState.ts +2 -11
  39. package/src/hooks/setter.test.ts +3 -4
  40. package/src/modules/element-server.test.ts +4 -4
  41. package/src/modules/element.test.ts +6 -6
  42. package/src/setters/SetComponent.test.tsx +7 -6
  43. package/src/setters/SetError.test.tsx +7 -6
  44. package/src/setters/SetErrors.test.tsx +7 -6
  45. package/src/setters/SetLayout.test.tsx +7 -6
  46. package/src/setters/SetProvider.test.tsx +7 -6
  47. package/src/setters/SetRedirect.test.tsx +7 -6
  48. package/src/setters/SetRoute.test.tsx +7 -6
  49. package/src/state/createActions.ts +3 -3
  50. package/src/state/createGlobalState.test.ts +9 -11
  51. package/src/state/createGlobalState.ts +2 -2
  52. package/src/state/withApi.test.tsx +5 -5
  53. package/src/types/state.ts +2 -3
  54. package/src/hooks/globalState-server.test.ts +0 -41
  55. package/src/hooks/globalState.test.ts +0 -47
@@ -1,7 +1,7 @@
1
+ import create from 'zustand';
1
2
  import { createPiletOptions, PiletOptionsConfig } from './helpers';
2
3
  import { globalDependencies } from './modules';
3
4
  import { PiletMetadata } from 'piral-base';
4
- import { Atom, swap, deref } from '@dbeining/react-atom';
5
5
 
6
6
  function createMockApi(meta: PiletMetadata) {
7
7
  return {
@@ -13,7 +13,7 @@ function createMockApi(meta: PiletMetadata) {
13
13
  }
14
14
 
15
15
  function createMockContainer() {
16
- const state = Atom.of({
16
+ const state = create(() => ({
17
17
  registry: {
18
18
  pages: {},
19
19
  extensions: {},
@@ -22,7 +22,7 @@ function createMockContainer() {
22
22
  routes: {},
23
23
  components: {},
24
24
  modules: [],
25
- });
25
+ }));
26
26
  return {
27
27
  context: {
28
28
  on: jest.fn(),
@@ -30,19 +30,20 @@ function createMockContainer() {
30
30
  emit: jest.fn(),
31
31
  state,
32
32
  dispatch(cb) {
33
- swap(state, cb);
33
+ state.setState(cb(state.getState()));
34
34
  },
35
35
  readState(cb) {
36
- return cb(deref(state));
36
+ return cb(state.getState());
37
37
  },
38
38
  setComponent(name, comp) {
39
- swap(state, (s) => ({
39
+ const s = state.getState();
40
+ state.setState({
40
41
  ...s,
41
42
  components: {
42
43
  ...s.components,
43
44
  [name]: comp,
44
45
  },
45
- }));
46
+ });
46
47
  },
47
48
  } as any,
48
49
  };
@@ -85,7 +86,7 @@ describe('Piral-Core helpers module', () => {
85
86
  const options = createPiletOptions(optionsConfig);
86
87
 
87
88
  // Assert
88
- expect(options.pilets.length).toEqual(providedPilets.length);
89
+ expect(options.pilets?.length).toEqual(providedPilets.length);
89
90
 
90
91
  if (wasUndefined) {
91
92
  process.env.DEBUG_PIRAL = undefined;
@@ -1,16 +1,7 @@
1
1
  import { useContext } from 'react';
2
- import { useAtom, deref } from '@dbeining/react-atom';
3
2
  import { StateContext } from '../state/stateContext';
4
3
  import { GlobalState } from '../types';
5
4
 
6
- const useGlobalAtom = typeof window !== 'undefined' ? useAtom : useDirectAtom;
7
-
8
- function useDirectAtom(atom: any, opts: any) {
9
- const state = deref(atom);
10
- const select = opts && opts.select;
11
- return typeof select === 'function' ? select(state) : state;
12
- }
13
-
14
5
  /**
15
6
  * Hook to obtain the global state context, which gives you directly
16
7
  * all actions, state, and more of the Piral instance.
@@ -35,6 +26,6 @@ export function useGlobalState(): GlobalState;
35
26
  export function useGlobalState<R>(select: (state: GlobalState) => R): R;
36
27
 
37
28
  export function useGlobalState<R>(select?: (state: GlobalState) => R) {
38
- const { state } = useGlobalStateContext();
39
- return useGlobalAtom(state, select && { select });
29
+ const { state: useState } = useGlobalStateContext();
30
+ return useState(select);
40
31
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { act } from 'react-dom/test-utils';
3
- import { createRoot } from 'react-dom/client';
3
+ import { render } from 'react-dom';
4
4
  import { useSetter } from './setter';
5
5
 
6
6
  describe('UseSetter Hook Module', () => {
@@ -12,9 +12,8 @@ describe('UseSetter Hook Module', () => {
12
12
  return null;
13
13
  };
14
14
 
15
- const root = createRoot(document.body.appendChild(document.createElement('div')));
16
- root.render(React.createElement(MyComponent));
17
- await act(() => new Promise(resolve => setTimeout(resolve, 5)));
15
+ render(React.createElement(MyComponent), document.body.appendChild(document.createElement('div')));
16
+ await act(() => new Promise((resolve) => setTimeout(resolve, 5)));
18
17
  expect(cb).toHaveBeenCalled();
19
18
  });
20
19
  });
@@ -2,17 +2,17 @@
2
2
  * @jest-environment node
3
3
  */
4
4
 
5
- import { Atom, deref } from '@dbeining/react-atom';
5
+ import create from 'zustand';
6
6
  import { createListener } from 'piral-base';
7
7
  import { createActions } from '../state';
8
8
  import { renderElement } from './element';
9
9
 
10
10
  function createMockContext(): [any, any] {
11
- const state = Atom.of({
11
+ const state: any = create(() => ({
12
12
  portals: {
13
13
  root: [],
14
14
  },
15
- });
15
+ }));
16
16
  const context = createActions(state, createListener({}));
17
17
  return [context, state];
18
18
  }
@@ -24,6 +24,6 @@ describe('Elements Module from SSR', () => {
24
24
  addEventListener() {},
25
25
  };
26
26
  renderElement(context, element, {});
27
- expect(deref(state)['portals']['root'].length).toBe(0);
27
+ expect(state.getState().portals.root.length).toBe(0);
28
28
  });
29
29
  });
@@ -1,4 +1,4 @@
1
- import { Atom, deref } from '@dbeining/react-atom';
1
+ import create from 'zustand';
2
2
  import { createListener } from 'piral-base';
3
3
  import { createActions } from '../state';
4
4
  import { renderElement } from './element';
@@ -14,9 +14,9 @@ declare global {
14
14
  }
15
15
 
16
16
  function createMockContext(): [any, any] {
17
- const state = Atom.of({
17
+ const state: any = create(() => ({
18
18
  portals: {},
19
- });
19
+ }));
20
20
  const context = createActions(state, createListener({}));
21
21
  return [context, state];
22
22
  }
@@ -31,7 +31,7 @@ describe('Elements Module', () => {
31
31
  element.dispatchEvent(event);
32
32
  document.body.removeChild(element);
33
33
  (element as any).connectedCallback();
34
- expect(deref(state)['portals']['root'].length).toBe(1);
34
+ expect(state.getState().portals.root.length).toBe(1);
35
35
  });
36
36
 
37
37
  it('disposing piral-extension web component', () => {
@@ -39,9 +39,9 @@ describe('Elements Module', () => {
39
39
  const element = document.createElement('piral-extension');
40
40
  document.body.appendChild(element);
41
41
  const [dispose] = renderElement(context, element, {});
42
- expect(deref(state)['portals']['root'].length).toBe(1);
42
+ expect(state.getState().portals.root.length).toBe(1);
43
43
  dispose();
44
- expect(deref(state)['portals']['root'].length).toBe(0);
44
+ expect(state.getState().portals.root.length).toBe(0);
45
45
  });
46
46
 
47
47
  it('testing setters and getters in piral-extension web component', () => {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetComponent } from './SetComponent';
5
5
  import { StateContext } from '../state';
6
6
 
@@ -8,9 +8,9 @@ const FakeLoading = () => null;
8
8
  FakeLoading.displayName = 'FakeLoading';
9
9
 
10
10
  function createMockContainer() {
11
- const state = Atom.of({
11
+ const state = create(() => ({
12
12
  components: {},
13
- });
13
+ }));
14
14
  return {
15
15
  context: {
16
16
  on: jest.fn(),
@@ -18,13 +18,14 @@ function createMockContainer() {
18
18
  emit: jest.fn(),
19
19
  state,
20
20
  setComponent(name, comp) {
21
- swap(state, (s) => ({
21
+ const s = state.getState();
22
+ state.setState({
22
23
  ...s,
23
24
  components: {
24
25
  ...s.components,
25
26
  [name]: comp,
26
27
  },
27
- }));
28
+ });
28
29
  },
29
30
  } as any,
30
31
  };
@@ -38,7 +39,7 @@ describe('Piral-Core SetComponent component', () => {
38
39
  <SetComponent name="LoadingIndicator" component={FakeLoading} />
39
40
  </StateContext.Provider>,
40
41
  );
41
- expect(deref<any>(context.state).components).toEqual({
42
+ expect(context.state.getState().components).toEqual({
42
43
  LoadingIndicator: FakeLoading,
43
44
  });
44
45
  });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetError } from './SetError';
5
5
  import { StateContext } from '../state';
6
6
 
@@ -8,9 +8,9 @@ const FakeError = () => null;
8
8
  FakeError.displayName = 'FakeError';
9
9
 
10
10
  function createMockContainer() {
11
- const state = Atom.of({
11
+ const state = create(() => ({
12
12
  errorComponents: {},
13
- });
13
+ }));
14
14
  return {
15
15
  context: {
16
16
  on: jest.fn(),
@@ -18,13 +18,14 @@ function createMockContainer() {
18
18
  emit: jest.fn(),
19
19
  state,
20
20
  setErrorComponent(name, comp) {
21
- swap(state, (s) => ({
21
+ const s = state.getState();
22
+ state.setState({
22
23
  ...s,
23
24
  errorComponents: {
24
25
  ...s.errorComponents,
25
26
  [name]: comp,
26
27
  },
27
- }));
28
+ });
28
29
  },
29
30
  } as any,
30
31
  };
@@ -38,7 +39,7 @@ describe('Piral-Core SetError component', () => {
38
39
  <SetError type="loading" component={FakeError} />
39
40
  </StateContext.Provider>,
40
41
  );
41
- expect(deref<any>(context.state).errorComponents).toEqual({
42
+ expect((context.state.getState()).errorComponents).toEqual({
42
43
  loading: FakeError,
43
44
  });
44
45
  });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetErrors } from './SetErrors';
5
5
  import { StateContext } from '../state/stateContext';
6
6
 
@@ -8,9 +8,9 @@ const FakeError = () => null;
8
8
  FakeError.displayName = 'FakeError';
9
9
 
10
10
  function createMockContainer() {
11
- const state = Atom.of({
11
+ const state = create(() => ({
12
12
  errorComponents: {},
13
- });
13
+ }));
14
14
  return {
15
15
  context: {
16
16
  on: jest.fn(),
@@ -18,13 +18,14 @@ function createMockContainer() {
18
18
  emit: jest.fn(),
19
19
  state,
20
20
  setErrorComponent(name, comp) {
21
- swap(state, (s) => ({
21
+ const s = state.getState();
22
+ state.setState({
22
23
  ...s,
23
24
  errorComponents: {
24
25
  ...s.errorComponents,
25
26
  [name]: comp,
26
27
  },
27
- }));
28
+ });
28
29
  },
29
30
  } as any,
30
31
  };
@@ -44,7 +45,7 @@ describe('Piral SetErrors component', () => {
44
45
  />
45
46
  </StateContext.Provider>,
46
47
  );
47
- expect(deref<any>(context.state).errorComponents).toEqual({
48
+ expect(context.state.getState().errorComponents).toEqual({
48
49
  menu: FakeError,
49
50
  });
50
51
  });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetLayout } from './SetLayout';
5
5
  import { StateContext } from '../state/stateContext';
6
6
 
@@ -8,9 +8,9 @@ const FakeContainer = () => null;
8
8
  FakeContainer.displayName = 'FakeContainer';
9
9
 
10
10
  function createMockContainer() {
11
- const state = Atom.of({
11
+ const state = create(() => ({
12
12
  components: {},
13
- });
13
+ }));
14
14
  return {
15
15
  context: {
16
16
  on: jest.fn(),
@@ -18,13 +18,14 @@ function createMockContainer() {
18
18
  emit: jest.fn(),
19
19
  state,
20
20
  setComponent(name, comp) {
21
- swap(state, (s) => ({
21
+ const s = state.getState();
22
+ state.setState({
22
23
  ...s,
23
24
  components: {
24
25
  ...s.components,
25
26
  [name]: comp,
26
27
  },
27
- }));
28
+ });
28
29
  },
29
30
  } as any,
30
31
  };
@@ -44,7 +45,7 @@ describe('Piral SetLayout component', () => {
44
45
  />
45
46
  </StateContext.Provider>,
46
47
  );
47
- expect(deref<any>(context.state).components).toEqual({
48
+ expect(context.state.getState().components).toEqual({
48
49
  DashboardContainer: FakeContainer,
49
50
  });
50
51
  });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetProvider } from './SetProvider';
5
5
  import { StateContext } from '../state';
6
6
 
@@ -8,9 +8,9 @@ const FakeProvider = () => null;
8
8
  FakeProvider.displayName = 'FakeProvider';
9
9
 
10
10
  function createMockContainer() {
11
- const state = Atom.of({
11
+ const state = create(() => ({
12
12
  providers: [],
13
- });
13
+ }));
14
14
  return {
15
15
  context: {
16
16
  on: jest.fn(),
@@ -18,10 +18,11 @@ function createMockContainer() {
18
18
  emit: jest.fn(),
19
19
  state,
20
20
  includeProvider(provider) {
21
- swap(state, (s) => ({
21
+ const update = (s) => ({
22
22
  ...s,
23
23
  providers: [...s.providers, provider],
24
- }));
24
+ });
25
+ state.setState(update(state.getState()));
25
26
  },
26
27
  } as any,
27
28
  };
@@ -36,6 +37,6 @@ describe('Piral-Core SetProvider component', () => {
36
37
  <SetProvider provider={provider} />
37
38
  </StateContext.Provider>,
38
39
  );
39
- expect(deref<any>(context.state).providers).toEqual([provider]);
40
+ expect(context.state.getState().providers).toEqual([provider]);
40
41
  });
41
42
  });
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetRedirect } from './SetRedirect';
5
5
  import { StateContext } from '../state';
6
6
 
7
7
  function createMockContainer() {
8
- const state = Atom.of({
8
+ const state = create(() => ({
9
9
  routes: {},
10
- });
10
+ }));
11
11
  return {
12
12
  context: {
13
13
  on: jest.fn(),
@@ -15,13 +15,14 @@ function createMockContainer() {
15
15
  emit: jest.fn(),
16
16
  state,
17
17
  setRoute(name, comp) {
18
- swap(state, (s) => ({
18
+ const update = (s) => ({
19
19
  ...s,
20
20
  routes: {
21
21
  ...s.routes,
22
22
  [name]: comp,
23
23
  },
24
- }));
24
+ });
25
+ state.setState(update(state.getState()));
25
26
  },
26
27
  } as any,
27
28
  };
@@ -35,7 +36,7 @@ describe('Piral-Core SetRedirect component', () => {
35
36
  <SetRedirect from="/foo" to="/bar" />
36
37
  </StateContext.Provider>,
37
38
  );
38
- expect(deref<any>(context.state).routes).toEqual({
39
+ expect(context.state.getState().routes).toEqual({
39
40
  '/foo': expect.anything(),
40
41
  });
41
42
  });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import create from 'zustand';
2
3
  import { mount } from 'enzyme';
3
- import { Atom, swap, deref } from '@dbeining/react-atom';
4
4
  import { SetRoute } from './SetRoute';
5
5
  import { StateContext } from '../state';
6
6
 
@@ -8,9 +8,9 @@ const FakeRoute = () => null;
8
8
  FakeRoute.displayName = 'FakeRoute';
9
9
 
10
10
  function createMockContainer() {
11
- const state = Atom.of({
11
+ const state = create(() => ({
12
12
  routes: {},
13
- });
13
+ }));
14
14
  return {
15
15
  context: {
16
16
  on: jest.fn(),
@@ -18,13 +18,14 @@ function createMockContainer() {
18
18
  emit: jest.fn(),
19
19
  state,
20
20
  setRoute(name, comp) {
21
- swap(state, (s) => ({
21
+ const update = (s) => ({
22
22
  ...s,
23
23
  routes: {
24
24
  ...s.routes,
25
25
  [name]: comp,
26
26
  },
27
- }));
27
+ });
28
+ state.setState(update(state.getState()));
28
29
  },
29
30
  } as any,
30
31
  };
@@ -38,7 +39,7 @@ describe('Piral-Core SetRoute component', () => {
38
39
  <SetRoute path="/foo" component={FakeRoute} />
39
40
  </StateContext.Provider>,
40
41
  );
41
- expect(deref<any>(context.state).routes).toEqual({
42
+ expect(context.state.getState().routes).toEqual({
42
43
  '/foo': FakeRoute,
43
44
  });
44
45
  });
@@ -1,8 +1,8 @@
1
1
  import * as actions from '../actions';
2
- import { Atom } from '@dbeining/react-atom';
2
+ import { UseBoundStore } from 'zustand';
3
3
  import { EventEmitter, GlobalState, GlobalStateContext, PiralDefineActions } from '../types';
4
4
 
5
- function createContext(state: Atom<GlobalState>, events: EventEmitter) {
5
+ function createContext(state: UseBoundStore<GlobalState>, events: EventEmitter) {
6
6
  const ctx = {
7
7
  ...events,
8
8
  apis: {},
@@ -23,7 +23,7 @@ export function includeActions(ctx: GlobalStateContext, actions: PiralDefineActi
23
23
  }
24
24
  }
25
25
 
26
- export function createActions(state: Atom<GlobalState>, events: EventEmitter): GlobalStateContext {
26
+ export function createActions(state: UseBoundStore<GlobalState>, events: EventEmitter): GlobalStateContext {
27
27
  const context = createContext(state, events);
28
28
  includeActions(context, actions);
29
29
  return context;
@@ -1,4 +1,3 @@
1
- import { deref } from '@dbeining/react-atom';
2
1
  import { createGlobalState } from './createGlobalState';
3
2
 
4
3
  process.env.PIRAL_PUBLIC_PATH = '/';
@@ -8,7 +7,7 @@ describe('Create Global State Module', () => {
8
7
 
9
8
  it('global state works with language as empty string', () => {
10
9
  const globalState = createGlobalState({});
11
- const tmp = deref(globalState);
10
+ const tmp = globalState.getState();
12
11
 
13
12
  console.log(tmp);
14
13
 
@@ -40,7 +39,7 @@ describe('Create Global State Module', () => {
40
39
 
41
40
  it('global state with custom language and translations', () => {
42
41
  const globalState = createGlobalState({});
43
- expect(deref(globalState)).toEqual({
42
+ expect(globalState.getState()).toEqual({
44
43
  app: {
45
44
  loading: true,
46
45
  error: undefined,
@@ -72,7 +71,7 @@ describe('Create Global State Module', () => {
72
71
  '/foo': '...' as any,
73
72
  };
74
73
  const globalState = createGlobalState({ routes });
75
- expect(deref(globalState)).toEqual({
74
+ expect(globalState.getState()).toEqual({
76
75
  app: {
77
76
  error: undefined,
78
77
  loading: true,
@@ -100,7 +99,7 @@ describe('Create Global State Module', () => {
100
99
 
101
100
  it('global state can be created without arguments', () => {
102
101
  const globalState = createGlobalState();
103
- expect(deref(globalState)).toEqual({
102
+ expect(globalState.getState()).toEqual({
104
103
  app: {
105
104
  loading: true,
106
105
  error: undefined,
@@ -130,7 +129,7 @@ describe('Create Global State Module', () => {
130
129
  const globalState = createGlobalState({
131
130
  app: {},
132
131
  });
133
- expect(deref(globalState)).toEqual({
132
+ expect(globalState.getState()).toEqual({
134
133
  app: {
135
134
  loading: true,
136
135
  error: undefined,
@@ -160,7 +159,7 @@ describe('Create Global State Module', () => {
160
159
  const globalState = createGlobalState({
161
160
  app: {},
162
161
  });
163
- expect(deref(globalState)).toEqual({
162
+ expect(globalState.getState()).toEqual({
164
163
  app: {
165
164
  loading: true,
166
165
  error: undefined,
@@ -188,14 +187,13 @@ describe('Create Global State Module', () => {
188
187
 
189
188
  it('global state with non-default breakpoints and more routes', () => {
190
189
  const globalState = createGlobalState({
191
- app: {
192
- },
190
+ app: {},
193
191
  routes: {
194
192
  '/': '...' as any,
195
193
  '/foo': '...' as any,
196
194
  },
197
195
  });
198
- expect(deref(globalState)).toEqual({
196
+ expect(globalState.getState()).toEqual({
199
197
  app: {
200
198
  loading: true,
201
199
  error: undefined,
@@ -230,7 +228,7 @@ describe('Create Global State Module', () => {
230
228
  loading: false,
231
229
  },
232
230
  });
233
- expect(deref(globalState)).toEqual({
231
+ expect(globalState.getState()).toEqual({
234
232
  app: {
235
233
  loading: false,
236
234
  error: undefined,
@@ -1,4 +1,4 @@
1
- import { Atom } from '@dbeining/react-atom';
1
+ import create from 'zustand';
2
2
  import { createDefaultState } from '../../app.codegen';
3
3
  import { GlobalState, NestedPartial } from '../types';
4
4
 
@@ -19,5 +19,5 @@ function extend<T>(defaultState: T, customState: NestedPartial<T>) {
19
19
 
20
20
  export function createGlobalState(customState: NestedPartial<GlobalState> = {}) {
21
21
  const defaultState: GlobalState = createDefaultState();
22
- return Atom.of(extend(defaultState, customState));
22
+ return create(() => extend(defaultState, customState));
23
23
  }
@@ -1,14 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import * as hooks from '../hooks';
3
+ import create from 'zustand';
3
4
  import { mount } from 'enzyme';
4
- import { Atom } from '@dbeining/react-atom';
5
5
  import { withApi } from './withApi';
6
6
  import { StateContext } from '../state';
7
7
 
8
8
  function createMockContainer() {
9
- const state = Atom.of({
9
+ const state = create(() => ({
10
10
  portals: {},
11
- });
11
+ }));
12
12
  return {
13
13
  context: {
14
14
  converters: {},
@@ -29,9 +29,9 @@ function createMockContainer() {
29
29
  }
30
30
 
31
31
  function createMockContainerWithNoWrappers() {
32
- const state = Atom.of({
32
+ const state = create(() => ({
33
33
  portals: {},
34
- });
34
+ }));
35
35
  return {
36
36
  context: {
37
37
  converters: {},
@@ -1,7 +1,7 @@
1
1
  import type { ComponentType, ReactPortal, PropsWithChildren } from 'react';
2
2
  import type { RouteComponentProps } from 'react-router';
3
- import type { Atom } from '@dbeining/react-atom';
4
3
  import type { LoadPiletsOptions } from 'piral-base';
4
+ import type { StoreApi, UseBoundStore } from 'zustand';
5
5
  import type { Dict, Without } from './common';
6
6
  import type { SharedDataItem, DataStoreTarget } from './data';
7
7
  import type {
@@ -36,7 +36,6 @@ export interface StateDispatcher<TState> {
36
36
 
37
37
  declare module './components' {
38
38
  interface ComponentContext {
39
- state: Atom<GlobalState>;
40
39
  readState: PiralActions['readState'];
41
40
  }
42
41
  }
@@ -364,7 +363,7 @@ export interface GlobalStateContext extends PiralActions, EventEmitter {
364
363
  * The global state context atom.
365
364
  * Changes to the state should always be dispatched via the `dispatch` action.
366
365
  */
367
- state: Atom<GlobalState>;
366
+ state: UseBoundStore<GlobalState>;
368
367
  /**
369
368
  * The API objects created for the loaded pilets.
370
369
  */