piral-lazy 0.15.0-alpha.4036 → 0.15.0-alpha.4122
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/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +19 -6
- package/src/create.test.ts +26 -9
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./create"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,kDAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-lazy",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.4122",
|
|
4
4
|
"description": "Plugin for lazy loading third-party framework components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -19,6 +19,19 @@
|
|
|
19
19
|
"module": "esm/index.js",
|
|
20
20
|
"main": "lib/index.js",
|
|
21
21
|
"typings": "lib/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./esm/index.js",
|
|
25
|
+
"require": "./lib/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./esm/": {
|
|
28
|
+
"import": "./esm/"
|
|
29
|
+
},
|
|
30
|
+
"./lib/": {
|
|
31
|
+
"require": "./lib/"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
22
35
|
"sideEffects": false,
|
|
23
36
|
"files": [
|
|
24
37
|
"esm",
|
|
@@ -43,13 +56,13 @@
|
|
|
43
56
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
44
57
|
},
|
|
45
58
|
"devDependencies": {
|
|
46
|
-
"@types/react": "^
|
|
47
|
-
"piral-core": "0.15.0-alpha.
|
|
48
|
-
"react": "^
|
|
59
|
+
"@types/react": "^18.0.0",
|
|
60
|
+
"piral-core": "0.15.0-alpha.4122",
|
|
61
|
+
"react": "^18.0.0"
|
|
49
62
|
},
|
|
50
63
|
"peerDependencies": {
|
|
51
|
-
"piral-core": "0.14.x",
|
|
64
|
+
"piral-core": "0.14.x || 0.15.x",
|
|
52
65
|
"react": ">=16.8.0"
|
|
53
66
|
},
|
|
54
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "fa0957fe7dedebbbd97a530e518c1a2b7754d475"
|
|
55
68
|
}
|
package/src/create.test.ts
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
import { Atom, swap } from '@dbeining/react-atom';
|
|
2
|
-
import {
|
|
1
|
+
import { Atom, swap, deref } from '@dbeining/react-atom';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { createElement, Suspense } from 'react';
|
|
4
|
+
import { StateContext } from 'piral-core';
|
|
4
5
|
import { createLazyApi } from './create';
|
|
5
6
|
import { act } from 'react-dom/test-utils';
|
|
6
7
|
|
|
7
8
|
function createMockContainer() {
|
|
8
|
-
const state = Atom.of({
|
|
9
|
+
const state = Atom.of({
|
|
10
|
+
components: {},
|
|
11
|
+
errorComponents: {},
|
|
12
|
+
registry: {
|
|
13
|
+
wrappers: {},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
9
16
|
return {
|
|
10
17
|
context: {
|
|
11
|
-
converters: {},
|
|
12
18
|
on: jest.fn(),
|
|
13
19
|
off: jest.fn(),
|
|
14
20
|
emit: jest.fn(),
|
|
15
21
|
defineActions() {},
|
|
16
22
|
state,
|
|
23
|
+
converters: {
|
|
24
|
+
html: ({ component }) => component,
|
|
25
|
+
},
|
|
17
26
|
readState(read) {
|
|
18
|
-
return read(state);
|
|
27
|
+
return read(deref(state));
|
|
19
28
|
},
|
|
20
29
|
dispatch(update) {
|
|
21
30
|
swap(state, update);
|
|
22
31
|
},
|
|
23
32
|
} as any,
|
|
24
|
-
api: {
|
|
33
|
+
api: {
|
|
34
|
+
meta: {
|
|
35
|
+
name: 'sample-pilet',
|
|
36
|
+
},
|
|
37
|
+
} as any,
|
|
25
38
|
};
|
|
26
39
|
}
|
|
27
40
|
|
|
@@ -35,9 +48,13 @@ describe('Piral-Lazy create module', () => {
|
|
|
35
48
|
const { fromLazy, defineDependency } = apiCreator(api);
|
|
36
49
|
defineDependency('testName', () => {});
|
|
37
50
|
const LazyComponent = fromLazy(load, ['testName']);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
const root = createRoot(document.body.appendChild(document.createElement('div')));
|
|
52
|
+
root.render(
|
|
53
|
+
createElement(
|
|
54
|
+
StateContext.Provider,
|
|
55
|
+
{ value: context },
|
|
56
|
+
createElement(Suspense, { fallback: 'anything' }, createElement(LazyComponent)),
|
|
57
|
+
),
|
|
41
58
|
);
|
|
42
59
|
await act(() => Promise.resolve());
|
|
43
60
|
expect(LazyComponent).not.toBeUndefined();
|