@e-mc/core 0.11.12 → 0.11.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 +19 -7
  3. package/package.json +3 -3
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.11.12/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.13/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, LogStatus } from "./squared";
@@ -69,7 +69,7 @@ interface HostConstructor extends ModuleConstructor {
69
69
  getThreadCount(full: true): ThreadCountStat;
70
70
  getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
71
71
  getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
72
- getPermissionFromSettings(): IPermission;
72
+ getPermissionFromSettings(freeze?: boolean): IPermission;
73
73
  readonly prototype: IHost;
74
74
  new(config?: HostInitConfig): IHost;
75
75
  }
@@ -232,13 +232,13 @@ NOTE: **@e-mc/core** is mostly a collection of abstract base classes which canno
232
232
 
233
233
  ## References
234
234
 
235
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/squared.d.ts
236
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/core.d.ts
237
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/db.d.ts
238
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/dom.d.ts
239
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/logger.d.ts
240
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/node.d.ts
241
- - https://www.unpkg.com/@e-mc/types@0.11.12/lib/settings.d.ts
235
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/squared.d.ts
236
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/core.d.ts
237
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/db.d.ts
238
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/dom.d.ts
239
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/logger.d.ts
240
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/node.d.ts
241
+ - https://www.unpkg.com/@e-mc/types@0.11.13/lib/settings.d.ts
242
242
 
243
243
  ## LICENSE
244
244
 
package/index.js CHANGED
@@ -236,7 +236,7 @@ function getSettingsValue(options, name, component) {
236
236
  }
237
237
  function isInvalidRange(result, range) {
238
238
  const [lower, upper = 0] = range;
239
- return result.length <= lower || upper > 0 && result.length > upper;
239
+ return Array.isArray(result) && (result.length <= lower || upper > 0 && result.length > upper);
240
240
  }
241
241
  function asPosix(value) {
242
242
  if (module_1.PLATFORM_WIN32) {
@@ -300,6 +300,7 @@ class Host extends module_1 {
300
300
  if (permission.unc_write) {
301
301
  PERMISSION.setUNCWrite(unc_write);
302
302
  }
303
+ Object.freeze(PERMISSION);
303
304
  }
304
305
  if (perm.settings) {
305
306
  const { picomatch: pico, minimatch: mini } = perm.settings;
@@ -476,8 +477,8 @@ class Host extends module_1 {
476
477
  static getLogDelayed() {
477
478
  return HOST.LOG_DELAYED;
478
479
  }
479
- static getPermissionFromSettings() {
480
- return PERMISSION;
480
+ static getPermissionFromSettings(freeze = true) {
481
+ return freeze ? PERMISSION : Permission.clone(PERMISSION);
481
482
  }
482
483
  constructor(config = {}) {
483
484
  super();
@@ -983,6 +984,9 @@ class ClientDb extends Client {
983
984
  }
984
985
  }
985
986
  static storeResult(source, credential, queryString, result, options, sessionKey, sessionExpires) {
987
+ if (!credential || !Array.isArray(result)) {
988
+ return result;
989
+ }
986
990
  let cache, cacheDir;
987
991
  if ((0, types_1.isObject)(sessionKey)) {
988
992
  ({ cacheDir, sessionKey, sessionExpires } = sessionKey);
@@ -1047,8 +1051,14 @@ class ClientDb extends Client {
1047
1051
  }
1048
1052
  else if (typeof sessionKey === 'string' && sessionExpires && sessionExpires > 0) {
1049
1053
  const dbKey = userKey + sessionKey;
1050
- ((CACHE_SESSION[source] ||= {})[dbKey] ||= {})[queryString] = result;
1051
- setTimeout(() => delete CACHE_SESSION[dbKey], sessionExpires * 1000);
1054
+ const sourceData = CACHE_SESSION[source] ||= {};
1055
+ let data = sourceData[dbKey];
1056
+ if (!data) {
1057
+ data = {};
1058
+ sourceData[dbKey] = data;
1059
+ setTimeout(() => delete sourceData[dbKey], sessionExpires * 1000);
1060
+ }
1061
+ data[queryString] = result;
1052
1062
  }
1053
1063
  }
1054
1064
  return result;
@@ -1197,9 +1207,10 @@ class ClientDb extends Client {
1197
1207
  }
1198
1208
  }
1199
1209
  const result = ClientDb.findResult(this.moduleName + '_' + source, uuidKey || credential, queryString, value === 0 ? 0 : ClientDb.getTimeout(value || this.settingsOf(source, 'cache')), sessionKey, renewCache);
1200
- if (!exclusiveOf || !isInvalidRange(result, exclusiveOf)) {
1201
- return result;
1210
+ if (exclusiveOf && !isInvalidRange(result, exclusiveOf)) {
1211
+ return;
1202
1212
  }
1213
+ return result;
1203
1214
  }
1204
1215
  setQueryResult(source, credential, queryString, result, sessionKey) {
1205
1216
  if (!Array.isArray(result)) {
@@ -1484,3 +1495,4 @@ class Permission {
1484
1495
  exports.Permission = Permission;
1485
1496
  _f = kDiskRead, _g = kDiskWrite, _h = kUncRead, _j = kUncWrite;
1486
1497
  PERMISSION = Host.createPermission(true, true);
1498
+ Object.freeze(PERMISSION);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/core",
3
- "version": "0.11.12",
3
+ "version": "0.11.13",
4
4
  "description": "Core modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.11.12",
24
- "@e-mc/types": "0.11.12",
23
+ "@e-mc/module": "0.11.13",
24
+ "@e-mc/types": "0.11.13",
25
25
  "ipaddr.js": "^2.2.0",
26
26
  "picomatch": "^4.0.3"
27
27
  }