@pushwoosh/single-spa 0.0.1

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/Parcel.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { type FC } from 'react';
2
+ type ParcelProps = {
3
+ className?: string;
4
+ module: string;
5
+ parcelFunctionName?: string;
6
+ [key: string]: any;
7
+ };
8
+ export declare const Parcel: FC<ParcelProps>;
9
+ export {};
package/Parcel.js ADDED
@@ -0,0 +1,38 @@
1
+ import React, { useMemo } from 'react';
2
+ import singleSpa from 'single-spa';
3
+ import SingleSpaParcel from 'single-spa-react/parcel';
4
+ export const Parcel = ({
5
+ className,
6
+ module,
7
+ parcelFunctionName = 'parcel',
8
+ ...transferProps
9
+ }) => {
10
+ const parcelConfig = useMemo(() => {
11
+ let parcel;
12
+ return {
13
+ bootstrap(props) {
14
+ return System.import(module).then(imported => {
15
+ parcel = imported[parcelFunctionName](props.domElement);
16
+ });
17
+ },
18
+ mount(props) {
19
+ parcel.render(props);
20
+ return Promise.resolve();
21
+ },
22
+ unmount() {
23
+ parcel.unmount();
24
+ return Promise.resolve();
25
+ },
26
+ update(props) {
27
+ parcel.render(props);
28
+ return Promise.resolve();
29
+ }
30
+ };
31
+ }, [module, parcelFunctionName]);
32
+ return React.createElement(SingleSpaParcel, {
33
+ ...transferProps,
34
+ config: parcelConfig,
35
+ wrapClassName: className,
36
+ mountParcel: singleSpa.mountRootParcel
37
+ });
38
+ };
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Parcel';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './Parcel';
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@pushwoosh/single-spa",
3
+ "version": "0.0.1",
4
+ "description": "React component for build Pushwoosh products",
5
+ "main": "index.js",
6
+ "module": "index.js",
7
+ "types": "index.d.ts",
8
+ "sideEffects": false,
9
+ "scripts": {
10
+ "start": "npm run playground",
11
+ "build": "pushwoosh-engine lib:build",
12
+ "playground": "`pushwoosh-engine lib:command:playground`",
13
+ "check": "npm run check:lint && npm run check:types",
14
+ "check:lint": "echo \"Run check:lint\" && eslint .",
15
+ "check:types": "echo \"Run check:types\" && pushwoosh-engine lib:check-types"
16
+ },
17
+ "pre-commit": "check",
18
+ "devDependencies": {
19
+ "@pushwoosh/frontend-builder-engine": "^0.3.1",
20
+ "@pushwoosh/kit-constants": "^1.6.0",
21
+ "@types/react": "^16.14.20",
22
+ "@types/react-dom": "^16.9.14",
23
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
24
+ "@typescript-eslint/parser": "^7.3.1",
25
+ "eslint": "^8.31.0",
26
+ "eslint-config-airbnb": "^19.0.4",
27
+ "eslint-config-airbnb-typescript": "^18.0.0",
28
+ "eslint-import-resolver-alias": "^1.1.2",
29
+ "eslint-plugin-import": "^2.25.2",
30
+ "eslint-plugin-jsx-a11y": "^6.4.1",
31
+ "eslint-plugin-react": "^7.26.1",
32
+ "eslint-plugin-react-hooks": "^4.2.0",
33
+ "pre-commit": "^1.2.2",
34
+ "react": "^16.14.0",
35
+ "react-dom": "^16.14.0"
36
+ },
37
+ "peerDependencies": {
38
+ "react": ">= 16.14.0"
39
+ },
40
+ "engines": {
41
+ "node": ">= 18"
42
+ },
43
+ "dependencies": {
44
+ "single-spa": "^5.9.5",
45
+ "single-spa-react": "^4.6.1"
46
+ }
47
+ }