epos-unit 1.10.0 → 1.12.0

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.
@@ -1,6 +1,6 @@
1
1
  import * as mobx from 'mobx';
2
- import { Cls } from 'eposlabs/types';
3
- import { Log } from 'eposlabs/utils';
2
+ import { Cls } from 'dropcap/types';
3
+ import { Log } from 'dropcap/utils';
4
4
 
5
5
  declare const _root_: unique symbol;
6
6
  declare const _parent_: unique symbol;
@@ -18,13 +18,13 @@ declare class Unit<TRoot = unknown> {
18
18
  private [_parent_];
19
19
  private [_disposers_];
20
20
  constructor(parent: Unit<TRoot> | null);
21
- static defineVersioner(versioner: Record<number, (this: any, unit: any) => void>): Record<number, (this: any, unit: any) => void>;
22
21
  get $(): TRoot;
23
22
  closest<T extends Unit>(Ancestor: Cls<T>): T | null;
24
23
  autorun(...args: Parameters<typeof epos.libs.mobx.autorun>): mobx.IReactionDisposer;
25
24
  reaction(...args: Parameters<typeof epos.libs.mobx.reaction>): mobx.IReactionDisposer;
26
25
  setTimeout(...args: Parameters<typeof self.setTimeout>): number;
27
26
  setInterval(...args: Parameters<typeof self.setInterval>): number;
27
+ never(message?: string): void;
28
28
  }
29
29
 
30
30
  export { type Descriptors, Unit, _disposers_, _parent_, _root_ };
package/dist/epos-unit.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/epos-unit.ts
2
2
  import "epos";
3
- import { createLog } from "eposlabs/utils";
3
+ import { createLog } from "dropcap/utils";
4
4
  var _root_ = /* @__PURE__ */ Symbol("root");
5
5
  var _parent_ = /* @__PURE__ */ Symbol("parent");
6
6
  var _disposers_ = /* @__PURE__ */ Symbol("disposers");
@@ -24,6 +24,7 @@ var Unit = class {
24
24
  for (const key of keys) {
25
25
  if (key === "constructor") continue;
26
26
  const descriptor = descriptors[key];
27
+ if (!descriptor) continue;
27
28
  if (descriptor.get || descriptor.set) continue;
28
29
  if (typeof descriptor.value !== "function") continue;
29
30
  _this[key] = descriptor.value.bind(this);
@@ -32,6 +33,7 @@ var Unit = class {
32
33
  if (typeof key === "symbol") continue;
33
34
  if (!key.endsWith("View")) continue;
34
35
  const descriptor = descriptors[key];
36
+ if (!descriptor) continue;
35
37
  if (descriptor.get || descriptor.set) continue;
36
38
  if (typeof _this[key] !== "function") continue;
37
39
  _this[key] = epos.component(_this[key]);
@@ -57,9 +59,6 @@ var Unit = class {
57
59
  if (!("versioner" in this)) return null;
58
60
  return this.versioner;
59
61
  }
60
- static defineVersioner(versioner) {
61
- return versioner;
62
- }
63
62
  // ---------------------------------------------------------------------------
64
63
  // ROOT
65
64
  // ---------------------------------------------------------------------------
@@ -98,6 +97,11 @@ var Unit = class {
98
97
  this[_disposers_].add(() => self.clearInterval(id));
99
98
  return id;
100
99
  }
100
+ never(message = "This should never happen") {
101
+ const error = new Error(`[${this["@"]}] ${message}`);
102
+ Error.captureStackTrace(error, this.never);
103
+ throw error;
104
+ }
101
105
  };
102
106
  function getParent(child) {
103
107
  return child[_parent_] ?? child[epos.symbols.stateParent];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epos-unit",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -13,18 +13,14 @@
13
13
  "release": "sh -c 'npm version ${1:-minor} && npm run build && npm publish' --"
14
14
  },
15
15
  "exports": {
16
- ".": {
17
- "source": "./src/epos-unit.ts",
18
- "import": "./dist/epos-unit.js",
19
- "types": "./dist/epos-unit.d.ts"
20
- }
16
+ ".": "./dist/epos-unit.js"
21
17
  },
22
18
  "files": [
23
- "src",
24
- "dist"
19
+ "dist",
20
+ "src"
25
21
  ],
26
22
  "dependencies": {
27
- "epos": "^1.26.0",
28
- "eposlabs": "^1.15.0"
23
+ "dropcap": "^1.0.0",
24
+ "epos": "^1.30.0"
29
25
  }
30
26
  }
package/src/epos-unit.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'epos'
2
- import type { Cls } from 'eposlabs/types'
3
- import { createLog, Log } from 'eposlabs/utils'
2
+ import type { Cls } from 'dropcap/types'
3
+ import { createLog, Log } from 'dropcap/utils'
4
4
  import type { FC } from 'react'
5
5
 
6
6
  export const _root_ = Symbol('root')
@@ -43,6 +43,7 @@ export class Unit<TRoot = unknown> {
43
43
  for (const key of keys) {
44
44
  if (key === 'constructor') continue
45
45
  const descriptor = descriptors[key]
46
+ if (!descriptor) continue
46
47
  if (descriptor.get || descriptor.set) continue
47
48
  if (typeof descriptor.value !== 'function') continue
48
49
  _this[key] = descriptor.value.bind(this)
@@ -53,6 +54,7 @@ export class Unit<TRoot = unknown> {
53
54
  if (typeof key === 'symbol') continue
54
55
  if (!key.endsWith('View')) continue
55
56
  const descriptor = descriptors[key]
57
+ if (!descriptor) continue
56
58
  if (descriptor.get || descriptor.set) continue
57
59
  if (typeof _this[key] !== 'function') continue
58
60
  _this[key] = epos.component(_this[key] as FC)
@@ -91,10 +93,6 @@ export class Unit<TRoot = unknown> {
91
93
  return this.versioner
92
94
  }
93
95
 
94
- static defineVersioner(versioner: Record<number, (this: any, unit: any) => void>) {
95
- return versioner
96
- }
97
-
98
96
  // ---------------------------------------------------------------------------
99
97
  // ROOT
100
98
  // ---------------------------------------------------------------------------
@@ -140,6 +138,12 @@ export class Unit<TRoot = unknown> {
140
138
  this[_disposers_].add(() => self.clearInterval(id))
141
139
  return id
142
140
  }
141
+
142
+ never(message = 'This should never happen') {
143
+ const error = new Error(`[${this['@']}] ${message}`)
144
+ Error.captureStackTrace(error, this.never)
145
+ throw error
146
+ }
143
147
  }
144
148
 
145
149
  // ---------------------------------------------------------------------------