@servicetitan/lazy-module 19.2.0 → 20.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/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -17,14 +16,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
16
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
17
  });
19
18
  };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.DefaultLoadingError = exports.DefaultLoading = exports.lazyModule = void 0;
22
- const jsx_runtime_1 = require("react/jsx-runtime");
19
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
20
  /* eslint-disable react/no-set-state */
24
- const react_1 = require("react");
25
- const react_ioc_1 = require("@servicetitan/react-ioc");
26
- const error_boundary_1 = require("@servicetitan/error-boundary");
27
- const log_service_1 = require("@servicetitan/log-service");
21
+ import { Component, Suspense, lazy, Fragment } from 'react';
22
+ import { injectDependency, optional } from '@servicetitan/react-ioc';
23
+ import { ErrorBoundary } from '@servicetitan/error-boundary';
24
+ import { Log } from '@servicetitan/log-service';
28
25
  // - Module -
29
26
  /**
30
27
  * Creates a lazy module wrapper, which renders
@@ -32,8 +29,8 @@ const log_service_1 = require("@servicetitan/log-service");
32
29
  * `loadingErrorComponent` when a loading error occurs
33
30
  * `errorFallbackComponent` when a component lifecycle error occurs
34
31
  */
35
- function lazyModule({ loader, name, loadingComponent: Loading = exports.DefaultLoading, loadingErrorComponent: LoadingError = exports.DefaultLoadingError, errorFallbackComponent, }) {
36
- class LazyModule extends react_1.Component {
32
+ export function lazyModule({ loader, name, loadingComponent: Loading = DefaultLoading, loadingErrorComponent: LoadingError = DefaultLoadingError, errorFallbackComponent, }) {
33
+ class LazyModule extends Component {
37
34
  constructor() {
38
35
  super(...arguments);
39
36
  Object.defineProperty(this, "state", {
@@ -75,14 +72,14 @@ function lazyModule({ loader, name, loadingComponent: Loading = exports.DefaultL
75
72
  }
76
73
  render() {
77
74
  const { hasError } = this.state;
78
- return ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, Object.assign({ fallback: errorFallbackComponent, moduleName: name }, { children: hasError ? ((0, jsx_runtime_1.jsx)(LoadingError, { onReload: this.onReload }, void 0)) : ((0, jsx_runtime_1.jsx)(react_1.Suspense, Object.assign({ fallback: (0, jsx_runtime_1.jsx)(Loading, {}, void 0) }, { children: (0, jsx_runtime_1.jsx)(this.Lazy, Object.assign({}, this.props), void 0) }), void 0)) }), void 0));
75
+ return (_jsx(ErrorBoundary, Object.assign({ fallback: errorFallbackComponent, moduleName: name }, { children: hasError ? (_jsx(LoadingError, { onReload: this.onReload }, void 0)) : (_jsx(Suspense, Object.assign({ fallback: _jsx(Loading, {}, void 0) }, { children: _jsx(this.Lazy, Object.assign({}, this.props), void 0) }), void 0)) }), void 0));
79
76
  }
80
77
  /**
81
78
  * Creates a onetime Lazy component with an error handler
82
79
  * (it needed to re-create the Lazy component, when a loading error has occurred)
83
80
  */
84
81
  createLazy() {
85
- return (0, react_1.lazy)(() => __awaiter(this, void 0, void 0, function* () {
82
+ return lazy(() => __awaiter(this, void 0, void 0, function* () {
86
83
  try {
87
84
  return { default: yield loader() };
88
85
  }
@@ -101,16 +98,13 @@ function lazyModule({ loader, name, loadingComponent: Loading = exports.DefaultL
101
98
  value: `lazyModule(${name})`
102
99
  });
103
100
  __decorate([
104
- (0, react_ioc_1.optional)(),
105
- (0, react_ioc_1.injectDependency)(log_service_1.Log),
106
- __metadata("design:type", log_service_1.Log)
101
+ optional(),
102
+ injectDependency(Log),
103
+ __metadata("design:type", Log)
107
104
  ], LazyModule.prototype, "logService", void 0);
108
105
  return LazyModule;
109
106
  }
110
- exports.lazyModule = lazyModule;
111
- const DefaultLoading = () => (0, jsx_runtime_1.jsx)("h2", { children: "Loading..." }, void 0);
112
- exports.DefaultLoading = DefaultLoading;
113
- const DefaultLoadingError = ({ onReload }) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h2", { children: "Cannot load module..." }, void 0), (0, jsx_runtime_1.jsx)("button", Object.assign({ onClick: onReload }, { children: "Reload" }), void 0)] }, void 0));
114
- exports.DefaultLoadingError = DefaultLoadingError;
107
+ export const DefaultLoading = () => _jsx("h2", { children: "Loading..." }, void 0);
108
+ export const DefaultLoadingError = ({ onReload }) => (_jsxs(Fragment, { children: [_jsx("h2", { children: "Cannot load module..." }, void 0), _jsx("button", Object.assign({ onClick: onReload }, { children: "Reload" }), void 0)] }, void 0));
115
109
  const Empty = () => null;
116
110
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,iCAA+E;AAC/E,uDAAqE;AAErE,iEAA6D;AAC7D,2DAAgD;AAUhD,aAAa;AACb;;;;;GAKG;AACH,SAAgB,UAAU,CAAsC,EAC5D,MAAM,EACN,IAAI,EACJ,gBAAgB,EAAE,OAAO,GAAG,sBAAc,EAC1C,qBAAqB,EAAE,YAAY,GAAG,2BAAmB,EACzD,sBAAsB,GACJ;IAClB,MAAM,UAAW,SAAQ,iBAAY;QAArC;;YAGI;;;;uBAAQ;oBACJ,QAAQ,EAAE,KAAK;iBAClB;eAAC;YAMF;;;;uBAAe,IAAI,CAAC,UAAU,EAAE;eAAC;YAkBjC;;;;uBAAmB,GAAG,EAAE;oBACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;oBAC9B,IAAI,CAAC,QAAQ,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CACO,GAAG;kDAAC;IAkDrC,OAAO,UAAU,CAAC;AACtB,CAAC;AAMD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,8CAAmB,CAAC;AAMxD,MAAM,CAAC,MAAM,mBAAmB,GAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACxE,MAAC,QAAQ,eACL,yDAA8B,EAC9B,+BAAQ,OAAO,EAAE,QAAQ,oCAAiB,YACnC,CACd,CAAC;AAEF,MAAM,KAAK,GAAY,GAAG,EAAE,CAAC,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/lazy-module",
3
- "version": "19.2.0",
3
+ "version": "20.0.1",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/lazy-module",
6
6
  "repository": {
@@ -10,21 +10,22 @@
10
10
  },
11
11
  "main": "./dist/index.js",
12
12
  "typings": "./dist/index.d.ts",
13
+ "sideEffects": false,
13
14
  "files": [
14
15
  "dist",
15
16
  "src"
16
17
  ],
17
18
  "devDependencies": {
18
- "@servicetitan/error-boundary": "^19.2.0",
19
- "@servicetitan/log-service": "^19.2.0",
20
- "@servicetitan/react-ioc": "^19.2.0",
21
- "@types/react": "~17.0.37",
19
+ "@servicetitan/error-boundary": "^20.0.1",
20
+ "@servicetitan/log-service": "^20.0.1",
21
+ "@servicetitan/react-ioc": "^20.0.1",
22
+ "@types/react": "~17.0.38",
22
23
  "react": "~17.0.2"
23
24
  },
24
25
  "peerDependencies": {
25
- "@servicetitan/error-boundary": "^17.0.0",
26
- "@servicetitan/log-service": "^17.0.0",
27
- "@servicetitan/react-ioc": "^17.0.0",
26
+ "@servicetitan/error-boundary": "^20.0.0",
27
+ "@servicetitan/log-service": "^20.0.0",
28
+ "@servicetitan/react-ioc": "^20.0.0",
28
29
  "react": "~17.0.2"
29
30
  },
30
31
  "publishConfig": {
@@ -33,5 +34,5 @@
33
34
  "cli": {
34
35
  "webpack": false
35
36
  },
36
- "gitHead": "62c48deffc4ed9aba58325fbad1b256ecbfae553"
37
+ "gitHead": "0c0dc470ff92789389bbb96a8e867ecd439a1509"
37
38
  }