@e-mc/core 0.12.12 → 0.12.13

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.
Files changed (3) hide show
  1. package/README.md +9 -9
  2. package/index.js +17 -8
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.12.12/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.12.13/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, LogStatus, WorkerAction } from "./squared";
@@ -74,7 +74,7 @@ interface HostConstructor extends ModuleConstructor {
74
74
  getThreadCount(full: true): ThreadCountStat;
75
75
  getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
76
76
  getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
77
- getPermissionFromSettings(): IPermission;
77
+ getPermissionFromSettings(freeze?: boolean): IPermission;
78
78
  readonly prototype: IHost;
79
79
  new(config?: HostInitConfig): IHost;
80
80
  }
@@ -319,13 +319,13 @@ NOTE: **@e-mc/core** is mostly a collection of abstract base classes which canno
319
319
 
320
320
  ## References
321
321
 
322
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/squared.d.ts
323
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/core.d.ts
324
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/db.d.ts
325
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/dom.d.ts
326
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/logger.d.ts
327
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/node.d.ts
328
- - https://www.unpkg.com/@e-mc/types@0.12.12/lib/settings.d.ts
322
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/squared.d.ts
323
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/core.d.ts
324
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/db.d.ts
325
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/dom.d.ts
326
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/logger.d.ts
327
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/node.d.ts
328
+ - https://www.unpkg.com/@e-mc/types@0.12.13/lib/settings.d.ts
329
329
 
330
330
  * https://www.npmjs.com/package/@types/node
331
331
 
package/index.js CHANGED
@@ -217,7 +217,7 @@ function getSettingsValue(options, name, component) {
217
217
  }
218
218
  function isInvalidRange(result, range) {
219
219
  const [lower, upper = 0] = range;
220
- return result.length <= lower || upper > 0 && result.length > upper;
220
+ return Array.isArray(result) && (result.length <= lower || upper > 0 && result.length > upper);
221
221
  }
222
222
  function asPosix(value) {
223
223
  if (module_1.PLATFORM_WIN32) {
@@ -281,6 +281,7 @@ class Host extends module_1 {
281
281
  if (permission.unc_write) {
282
282
  PERMISSION.setUNCWrite(unc_write);
283
283
  }
284
+ Object.freeze(PERMISSION);
284
285
  }
285
286
  if (perm.settings) {
286
287
  const { picomatch: pico, minimatch: mini } = perm.settings;
@@ -486,8 +487,8 @@ class Host extends module_1 {
486
487
  static getLogDelayed() {
487
488
  return HOST.LOG_DELAYED;
488
489
  }
489
- static getPermissionFromSettings() {
490
- return PERMISSION;
490
+ static getPermissionFromSettings(freeze = true) {
491
+ return freeze ? PERMISSION : Permission.clone(PERMISSION);
491
492
  }
492
493
  restartable = true;
493
494
  modules = new Set();
@@ -1001,7 +1002,7 @@ class ClientDb extends Client {
1001
1002
  }
1002
1003
  }
1003
1004
  static storeResult(source, credential, queryString, result, options, sessionKey, sessionExpires) {
1004
- if (!credential) {
1005
+ if (!credential || !Array.isArray(result)) {
1005
1006
  return result;
1006
1007
  }
1007
1008
  let cache, cacheDir;
@@ -1068,8 +1069,14 @@ class ClientDb extends Client {
1068
1069
  }
1069
1070
  else if (typeof sessionKey === 'string' && sessionExpires && sessionExpires > 0) {
1070
1071
  const dbKey = userKey + sessionKey;
1071
- ((CACHE_SESSION[source] ||= {})[dbKey] ||= {})[queryString] = result;
1072
- setTimeout(() => delete CACHE_SESSION[dbKey], sessionExpires * 1000);
1072
+ const sourceData = CACHE_SESSION[source] ||= {};
1073
+ let data = sourceData[dbKey];
1074
+ if (!data) {
1075
+ data = {};
1076
+ sourceData[dbKey] = data;
1077
+ setTimeout(() => delete sourceData[dbKey], sessionExpires * 1000);
1078
+ }
1079
+ data[queryString] = result;
1073
1080
  }
1074
1081
  }
1075
1082
  return result;
@@ -1221,9 +1228,10 @@ class ClientDb extends Client {
1221
1228
  }
1222
1229
  }
1223
1230
  const result = ClientDb.findResult(this.moduleName + '_' + source, uuidKey || credential, queryString, value === 0 ? 0 : ClientDb.getTimeout(value || this.settingsOf(source, 'cache')), sessionKey, renewCache);
1224
- if (!exclusiveOf || !isInvalidRange(result, exclusiveOf)) {
1225
- return result;
1231
+ if (exclusiveOf && !isInvalidRange(result, exclusiveOf)) {
1232
+ return;
1226
1233
  }
1234
+ return result;
1227
1235
  }
1228
1236
  setQueryResult(source, credential, queryString, result, sessionKey) {
1229
1237
  if (!Array.isArray(result)) {
@@ -2017,3 +2025,4 @@ class Permission {
2017
2025
  exports.Permission = Permission;
2018
2026
  _a = Permission;
2019
2027
  PERMISSION = Host.createPermission(true, true);
2028
+ Object.freeze(PERMISSION);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/core",
3
- "version": "0.12.12",
3
+ "version": "0.12.13",
4
4
  "description": "Core modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "license": "BSD-3-Clause",
20
20
  "homepage": "https://github.com/anpham6/e-mc#readme",
21
21
  "dependencies": {
22
- "@e-mc/module": "0.12.12",
23
- "@e-mc/types": "0.12.12",
24
- "ipaddr.js": "^2.2.0",
22
+ "@e-mc/module": "0.12.13",
23
+ "@e-mc/types": "0.12.13",
24
+ "ipaddr.js": "^2.3.0",
25
25
  "picomatch": "^4.0.3"
26
26
  }
27
27
  }