piral-core 1.3.3-beta.6190 → 1.3.3-beta.6204

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 (122) hide show
  1. package/app.codegen +2 -1
  2. package/esm/utils/routes.js +1 -3
  3. package/esm/utils/routes.js.map +1 -1
  4. package/lib/Piral.js +2 -1
  5. package/lib/Piral.js.map +1 -1
  6. package/lib/PiralContext.js +2 -1
  7. package/lib/PiralContext.js.map +1 -1
  8. package/lib/RootListener.js +2 -1
  9. package/lib/RootListener.js.map +1 -1
  10. package/lib/components/ErrorBoundary.js +1 -1
  11. package/lib/components/ErrorBoundary.js.map +1 -1
  12. package/lib/components/ExtensionSlot.js +2 -1
  13. package/lib/components/ExtensionSlot.js.map +1 -1
  14. package/lib/components/ForeignComponentContainer.js +2 -1
  15. package/lib/components/ForeignComponentContainer.js.map +1 -1
  16. package/lib/components/Mediator.js +2 -1
  17. package/lib/components/Mediator.js.map +1 -1
  18. package/lib/components/PiralGlobals.js +2 -1
  19. package/lib/components/PiralGlobals.js.map +1 -1
  20. package/lib/components/PiralRoutes.js +1 -1
  21. package/lib/components/PiralRoutes.js.map +1 -1
  22. package/lib/components/PiralSuspense.js +2 -1
  23. package/lib/components/PiralSuspense.js.map +1 -1
  24. package/lib/components/PiralView.js +2 -1
  25. package/lib/components/PiralView.js.map +1 -1
  26. package/lib/components/ResponsiveLayout.js +2 -1
  27. package/lib/components/ResponsiveLayout.js.map +1 -1
  28. package/lib/components/SwitchErrorInfo.js +2 -1
  29. package/lib/components/SwitchErrorInfo.js.map +1 -1
  30. package/lib/components/components.js +2 -1
  31. package/lib/components/components.js.map +1 -1
  32. package/lib/components/wrapComponent.js +2 -1
  33. package/lib/components/wrapComponent.js.map +1 -1
  34. package/lib/defaults/DefaultErrorInfo.js +2 -1
  35. package/lib/defaults/DefaultErrorInfo.js.map +1 -1
  36. package/lib/defaults/DefaultLoadingIndicator.js +2 -1
  37. package/lib/defaults/DefaultLoadingIndicator.js.map +1 -1
  38. package/lib/defaults/DefaultRouteSwitch_v5.js +1 -1
  39. package/lib/defaults/DefaultRouteSwitch_v5.js.map +1 -1
  40. package/lib/defaults/DefaultRouteSwitch_v6.js +1 -1
  41. package/lib/defaults/DefaultRouteSwitch_v6.js.map +1 -1
  42. package/lib/defaults/DefaultRouter_v5.js +2 -1
  43. package/lib/defaults/DefaultRouter_v5.js.map +1 -1
  44. package/lib/defaults/DefaultRouter_v6.js +2 -1
  45. package/lib/defaults/DefaultRouter_v6.js.map +1 -1
  46. package/lib/defaults/navigator_v5.js +2 -1
  47. package/lib/defaults/navigator_v5.js.map +1 -1
  48. package/lib/defaults/navigator_v6.js +2 -1
  49. package/lib/defaults/navigator_v6.js.map +1 -1
  50. package/lib/setters/SetErrors.js +2 -1
  51. package/lib/setters/SetErrors.js.map +1 -1
  52. package/lib/setters/SetLayout.js +2 -1
  53. package/lib/setters/SetLayout.js.map +1 -1
  54. package/lib/state/createActions.js +2 -1
  55. package/lib/state/createActions.js.map +1 -1
  56. package/lib/state/createGlobalState.js +2 -1
  57. package/lib/state/createGlobalState.js.map +1 -1
  58. package/lib/state/stateContext.js +2 -1
  59. package/lib/state/stateContext.js.map +1 -1
  60. package/lib/state/withApi.js +2 -1
  61. package/lib/state/withApi.js.map +1 -1
  62. package/lib/utils/extension.js +2 -1
  63. package/lib/utils/extension.js.map +1 -1
  64. package/lib/utils/react.js +2 -1
  65. package/lib/utils/react.js.map +1 -1
  66. package/lib/utils/routes.js +3 -4
  67. package/lib/utils/routes.js.map +1 -1
  68. package/package.json +4 -4
  69. package/src/Piral.test.tsx +48 -0
  70. package/src/RootListener.test.tsx +7 -3
  71. package/src/actions/app.test.ts +12 -0
  72. package/src/actions/components.test.ts +11 -0
  73. package/src/actions/data.test.ts +4 -0
  74. package/src/actions/define.test.ts +4 -3
  75. package/src/actions/portal.test.ts +1 -0
  76. package/src/actions/state.test.ts +4 -3
  77. package/src/components/ExtensionSlot.test.tsx +19 -4
  78. package/src/components/ForeignComponentContainer.test.tsx +12 -8
  79. package/src/components/Mediator.test.tsx +8 -4
  80. package/src/components/PiralRoutes.test.tsx +16 -2
  81. package/src/components/PiralView-server.test.tsx +4 -3
  82. package/src/components/PiralView.test.tsx +11 -3
  83. package/src/components/ResponsiveLayout.test.tsx +9 -5
  84. package/src/components/SwitchErrorInfo.test.tsx +15 -4
  85. package/src/createInstance.test.tsx +14 -0
  86. package/src/defaults/DefaultErrorInfo.test.tsx +5 -1
  87. package/src/defaults/DefaultLayout.test.tsx +4 -0
  88. package/src/defaults/DefaultLoadingIndicator.test.tsx +4 -0
  89. package/src/helpers.test.tsx +47 -27
  90. package/src/hooks/action.test.ts +4 -3
  91. package/src/hooks/actions.test.ts +4 -3
  92. package/src/hooks/media.test.ts +31 -23
  93. package/src/hooks/setter-server.test.ts +3 -2
  94. package/src/hooks/setter.test.ts +5 -1
  95. package/src/hooks/sharedData.test.ts +11 -8
  96. package/src/modules/api.test.ts +19 -18
  97. package/src/modules/core.test.ts +19 -18
  98. package/src/modules/dependencies.test.ts +1 -0
  99. package/src/modules/element-server.test.ts +9 -1
  100. package/src/modules/element.test.ts +11 -0
  101. package/src/setters/SetComponent.test.tsx +7 -3
  102. package/src/setters/SetError.test.tsx +7 -3
  103. package/src/setters/SetErrors.test.tsx +7 -3
  104. package/src/setters/SetLayout.test.tsx +7 -3
  105. package/src/setters/SetProvider.test.tsx +7 -3
  106. package/src/setters/SetRedirect.test.tsx +13 -3
  107. package/src/setters/SetRoute.test.tsx +7 -3
  108. package/src/state/createActions.test.ts +12 -1
  109. package/src/state/createGlobalState.test.ts +35 -59
  110. package/src/state/withApi.test.tsx +12 -8
  111. package/src/utils/compare.test.ts +1 -0
  112. package/src/utils/data.test.ts +5 -0
  113. package/src/utils/extension.test.tsx +5 -1
  114. package/src/utils/foreign.test.ts +9 -8
  115. package/src/utils/guid.test.ts +1 -0
  116. package/src/utils/helpers.test.ts +14 -13
  117. package/src/utils/media-server.test.ts +2 -1
  118. package/src/utils/media.test.ts +19 -11
  119. package/src/utils/routes.test.ts +1 -0
  120. package/src/utils/routes.ts +1 -3
  121. package/src/utils/state.test.ts +7 -6
  122. package/src/utils/storage.test.ts +9 -4
@@ -1,6 +1,4 @@
1
- // Unfortunately `require`d:
2
- // * exports are otherwise potentially converted by, e.g., Parcel (see #385)
3
- const ptr = require('path-to-regexp');
1
+ import ptr from 'path-to-regexp';
4
2
 
5
3
  export function createRouteMatcher(path: string): RegExp {
6
4
  return ptr(path);
@@ -1,28 +1,29 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { withAll, withRootExtension } from './state';
2
3
  import { RootListener } from '../RootListener';
3
4
 
4
5
  describe('State Module', () => {
5
6
  it('withRootExtension should create an extension key', () => {
6
7
  const dispatch = withRootExtension('test', RootListener);
7
- const result = dispatch({ registry: { extensions: {} } });
8
+ const result = dispatch({ registry: { extensions: {} } } as any);
8
9
  expect(result['registry']['extensions']['test']).toBeTruthy();
9
10
  });
10
11
 
11
12
  it('withAll should return identity state with no dispatcher', () => {
12
13
  const dispatchers = withAll();
13
- const result = dispatchers({ state: ['foo', 'boo'] });
14
+ const result = dispatchers({ state: ['foo', 'boo'] } as any);
14
15
  expect(result).toEqual({ state: ['foo', 'boo'] });
15
16
  });
16
17
 
17
18
  it('withAll should return identity state with identity dispatcher', () => {
18
19
  const dispatchers = withAll((s) => s);
19
- const result = dispatchers({ state: ['foo', 'boo'] });
20
+ const result = dispatchers({ state: ['foo', 'boo'] } as any);
20
21
  expect(result).toEqual({ state: ['foo', 'boo'] });
21
22
  });
22
23
 
23
24
  it('withAll should return empty state with blank dispatcher', () => {
24
- const dispatchers = withAll((s) => ({}));
25
- const result = dispatchers({ state: ['foo', 'boo'] });
25
+ const dispatchers = withAll((s) => ({} as any));
26
+ const result = dispatchers({ state: ['foo', 'boo'] } as any);
26
27
  expect(result).toEqual({});
27
28
  });
28
29
 
@@ -31,7 +32,7 @@ describe('State Module', () => {
31
32
  (s) => ({ ...s, foo: 'bar' }),
32
33
  (s) => ({ ...s, bar: 'qxz' }),
33
34
  );
34
- const result = dispatchers({ state: ['foo', 'boo'] });
35
+ const result = dispatchers({ state: ['foo', 'boo'] } as any);
35
36
  expect(result).toEqual({ state: ['foo', 'boo'], foo: 'bar', bar: 'qxz' });
36
37
  });
37
38
  });
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ */
4
+ import { describe, it, expect, vitest } from 'vitest';
1
5
  import { storage, cookie } from './storage';
2
6
 
3
7
  function mockLocalStorage<T>(mockObj: T) {
@@ -17,7 +21,7 @@ function mockCookieStorage(initialValue = '') {
17
21
  describe('Storage Module', () => {
18
22
  it('storage gets item from local storage', () => {
19
23
  const localStorage = mockLocalStorage({
20
- getItem: jest.fn(() => 'bar'),
24
+ getItem: vitest.fn(() => 'bar'),
21
25
  });
22
26
  const result = storage.getItem('foo');
23
27
  expect(result).toBe('bar');
@@ -26,7 +30,7 @@ describe('Storage Module', () => {
26
30
 
27
31
  it('storage sets item to local storage', () => {
28
32
  const localStorage = mockLocalStorage({
29
- setItem: jest.fn(),
33
+ setItem: vitest.fn(),
30
34
  });
31
35
  storage.setItem('foo', 'bar');
32
36
  expect(localStorage.setItem).toHaveBeenCalledWith('foo', 'bar');
@@ -34,7 +38,7 @@ describe('Storage Module', () => {
34
38
 
35
39
  it('storage removes item at local storage', () => {
36
40
  const localStorage = mockLocalStorage({
37
- removeItem: jest.fn(),
41
+ removeItem: vitest.fn(),
38
42
  });
39
43
  storage.removeItem('foo');
40
44
  expect(localStorage.removeItem).toHaveBeenCalledWith('foo');
@@ -66,8 +70,9 @@ describe('Storage Module', () => {
66
70
 
67
71
  it('cookie sets item to cookie without domain', () => {
68
72
  const oldLocation = window.location;
73
+ //@ts-ignore
69
74
  delete window.location;
70
-
75
+ //@ts-ignore
71
76
  window.location = {
72
77
  host: '',
73
78
  };