@doreamonjs/plugin-shared 1.0.1 → 1.1.22

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.22](https://github.com/doreamonjs/doreamon/compare/v1.1.21...v1.1.22) (2022-09-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * The inferred type of 'default' cannot be named without a reference to '@doreamonjs/application/node_modules/@types/react' ([4b54b09](https://github.com/doreamonjs/doreamon/commit/4b54b09cd8035fcb3185e0c8c378459b511f48ac))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.1.8](https://github.com/doreamonjs/doreamon/compare/v1.1.7...v1.1.8) (2022-09-09)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **plugin-shared:** shared var ambiguity ([a0cd313](https://github.com/doreamonjs/doreamon/commit/a0cd313aa0bc5cb239237993d71f441efe93a0db))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [1.0.1](https://github.com/doreamonjs/doreamon/compare/v0.6.13...v1.0.1) (2022-09-04)
7
29
 
8
30
  **Note:** Version bump only for package @doreamonjs/plugin-shared
@@ -0,0 +1,9 @@
1
+ import { LOGGER, MESSAGE, NOTIFICATION, ROUTER, STORE } from './constants';
2
+ export declare type ContainerServiceKey = typeof LOGGER | typeof ROUTER | typeof STORE | typeof MESSAGE | typeof NOTIFICATION;
3
+ export declare class Container {
4
+ private store;
5
+ register(key: ContainerServiceKey, getter: () => any): void;
6
+ get(key: ContainerServiceKey): any;
7
+ has(key: ContainerServiceKey): boolean;
8
+ }
9
+ export declare const container: Container;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shared = exports.Shared = void 0;
4
- class Shared {
3
+ exports.container = exports.Container = void 0;
4
+ class Container {
5
5
  constructor() {
6
6
  this.store = {};
7
7
  }
@@ -20,5 +20,5 @@ class Shared {
20
20
  return !!this.store[key];
21
21
  }
22
22
  }
23
- exports.Shared = Shared;
24
- exports.shared = new Shared();
23
+ exports.Container = Container;
24
+ exports.container = new Container();
package/lib/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export * from './type';
2
- export * from './shared';
1
+ import { ContainerServiceKey } from './container';
3
2
  export * from './logger';
4
3
  export * from './router';
5
4
  export * from './store';
6
5
  export * from './message';
7
6
  export * from './notification';
7
+ export declare function register(key: ContainerServiceKey, getter: () => any): void;
8
+ export declare function get(key: ContainerServiceKey): any;
9
+ export declare function has(key: ContainerServiceKey): boolean;
package/lib/index.js CHANGED
@@ -10,13 +10,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- const shared_1 = require("./shared");
14
- __exportStar(require("./type"), exports);
15
- __exportStar(require("./shared"), exports);
13
+ exports.has = exports.get = exports.register = void 0;
14
+ const container_1 = require("./container");
15
+ // export * from './type';
16
+ // export * from './container';
16
17
  __exportStar(require("./logger"), exports);
17
18
  __exportStar(require("./router"), exports);
18
19
  __exportStar(require("./store"), exports);
19
20
  __exportStar(require("./message"), exports);
20
21
  __exportStar(require("./notification"), exports);
22
+ function register(key, getter) {
23
+ return container_1.container.register(key, getter);
24
+ }
25
+ exports.register = register;
26
+ function get(key) {
27
+ return container_1.container.get(key);
28
+ }
29
+ exports.get = get;
30
+ function has(key) {
31
+ return container_1.container.has(key);
32
+ }
33
+ exports.has = has;
21
34
  //
22
- globalThis.__doreamonjs = shared_1.shared;
35
+ // globalThis.__doreamonjs = container;
package/lib/logger.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logger = exports.Logger = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const doreamon_1 = require("@zodash/doreamon");
6
- const shared_1 = require("./shared");
6
+ const container_1 = require("./container");
7
7
  const DEFAULT_LOGGER = doreamon_1.default.logger.getLogger('doreamonjs');
8
8
  class Logger {
9
9
  constructor(options) {
@@ -34,12 +34,12 @@ class Logger {
34
34
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.logger) {
35
35
  this._logger = (_b = this.options) === null || _b === void 0 ? void 0 : _b.logger;
36
36
  }
37
- else if (shared_1.shared.has(constants_1.LOGGER)) {
38
- this._logger = shared_1.shared.get(constants_1.LOGGER);
37
+ else if (container_1.container.has(constants_1.LOGGER)) {
38
+ this._logger = container_1.container.get(constants_1.LOGGER);
39
39
  }
40
40
  else {
41
41
  const logger = (this._logger = DEFAULT_LOGGER);
42
- shared_1.shared.register(constants_1.LOGGER, () => {
42
+ container_1.container.register(constants_1.LOGGER, () => {
43
43
  return logger;
44
44
  });
45
45
  }
package/lib/message.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.message = exports.Message = void 0;
4
4
  const constants_1 = require("./constants");
5
- const shared_1 = require("./shared");
5
+ const container_1 = require("./container");
6
6
  class Message {
7
7
  constructor(options) {
8
8
  this.options = options;
@@ -12,7 +12,7 @@ class Message {
12
12
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.message) {
13
13
  return (_b = this.options) === null || _b === void 0 ? void 0 : _b.message;
14
14
  }
15
- return shared_1.shared.get(constants_1.MESSAGE);
15
+ return container_1.container.get(constants_1.MESSAGE);
16
16
  }
17
17
  info(content, duration, onClose) {
18
18
  return this.message.info(content, duration, onClose);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.notification = exports.Notification = void 0;
4
4
  const constants_1 = require("./constants");
5
- const shared_1 = require("./shared");
5
+ const container_1 = require("./container");
6
6
  class Notification {
7
7
  constructor(options) {
8
8
  this.options = options;
@@ -12,7 +12,7 @@ class Notification {
12
12
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.notification) {
13
13
  return (_b = this.options) === null || _b === void 0 ? void 0 : _b.notification;
14
14
  }
15
- return shared_1.shared.get(constants_1.NOTIFICATION);
15
+ return container_1.container.get(constants_1.NOTIFICATION);
16
16
  }
17
17
  success(cfg) {
18
18
  return this.notifier.success(cfg);
package/lib/router.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.router = exports.Router = void 0;
4
4
  const constants_1 = require("./constants");
5
- const shared_1 = require("./shared");
5
+ const container_1 = require("./container");
6
6
  class Router {
7
7
  constructor(options) {
8
8
  this.options = options;
@@ -12,7 +12,7 @@ class Router {
12
12
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.router) {
13
13
  return (_b = this.options) === null || _b === void 0 ? void 0 : _b.router;
14
14
  }
15
- return shared_1.shared.get(constants_1.ROUTER);
15
+ return container_1.container.get(constants_1.ROUTER);
16
16
  }
17
17
  push(path, state) {
18
18
  this.router.push(path, state);
package/lib/store.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.store = exports.Store = void 0;
4
4
  const constants_1 = require("./constants");
5
- const shared_1 = require("./shared");
5
+ const container_1 = require("./container");
6
6
  class Store {
7
7
  constructor(options) {
8
8
  this.options = options;
@@ -12,7 +12,7 @@ class Store {
12
12
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.store) {
13
13
  return (_b = this.options) === null || _b === void 0 ? void 0 : _b.store;
14
14
  }
15
- return shared_1.shared.get(constants_1.STORE);
15
+ return container_1.container.get(constants_1.STORE);
16
16
  }
17
17
  dispatch(action) {
18
18
  this.store.dispatch(action);
package/lib/type.d.ts CHANGED
@@ -1,6 +0,0 @@
1
- import { Shared } from './shared';
2
- declare global {
3
- var __doreamonjs: DoreamonJSShared;
4
- }
5
- export interface DoreamonJSShared extends Shared {
6
- }
package/lib/type.js CHANGED
@@ -1,2 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ // import { container, Container } from './container';
2
+ // declare global {
3
+ // // eslint-disable-next-line no-var
4
+ // var __doreamonjs: DoreamonJSShared;
5
+ // }
6
+ // export interface DoreamonJSShared extends Container { }
7
+ // window.__doreamonjs = container
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doreamonjs/plugin-shared",
3
- "version": "1.0.1",
3
+ "version": "1.1.22",
4
4
  "description": "shared plugin for doreamonjs",
5
5
  "keywords": [
6
6
  "doreamonjs",
@@ -65,11 +65,11 @@
65
65
  "url": "https://github.com/doreamonjs/doreamon/issues"
66
66
  },
67
67
  "devDependencies": {
68
- "@types/react": "^16"
68
+ "@types/react": "16.14.23"
69
69
  },
70
70
  "dependencies": {
71
71
  "@zodash/doreamon": "^1.1.2",
72
72
  "history": "^5.3.0"
73
73
  },
74
- "gitHead": "a1aecaf72f7de2c0408b7a74cb418b9c4a3faac2"
74
+ "gitHead": "92c2265dc0758f67c8815b07909854555e8a9987"
75
75
  }
package/lib/shared.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { LOGGER, MESSAGE, NOTIFICATION, ROUTER, STORE } from './constants';
2
- export declare type SharedServiceKey = typeof LOGGER | typeof ROUTER | typeof STORE | typeof MESSAGE | typeof NOTIFICATION;
3
- export declare class Shared {
4
- private store;
5
- register(key: SharedServiceKey, getter: () => any): void;
6
- get(key: SharedServiceKey): any;
7
- has(key: SharedServiceKey): boolean;
8
- }
9
- export declare const shared: Shared;