@e-mc/core 0.5.4 → 0.6.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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/index.js +44 -38
  4. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Mile Square Park
1
+ Copyright 2023 Studio Trigger
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/core
2
2
 
3
- PEP 402 - Forever
3
+ PEP 402 - Forever Ryuko
4
4
 
5
5
  ## LICENSE
6
6
 
package/index.js CHANGED
@@ -272,7 +272,8 @@ class Host extends module_1.default {
272
272
  }
273
273
  if ((0, types_1.isPlainObject)(mini)) {
274
274
  try {
275
- MINIMATCH = require('minimatch');
275
+ const pkg = require('minimatch');
276
+ MINIMATCH = 'minimatch' in pkg ? pkg.minimatch : pkg;
276
277
  MINIMATCH_OPTIONS = { matchBase: true, nocase: PLATFORM_WIN32, ...mini };
277
278
  }
278
279
  catch {
@@ -796,44 +797,46 @@ class ClientDb extends Client {
796
797
  }
797
798
  static findResult(source, credential, queryString, timeout, sessionKey, renewCache) {
798
799
  const userKey = this.extractUUID(credential) || this.asHash(this.asString(credential));
799
- if (userKey) {
800
- queryString = this.asHash(queryString);
801
- if (timeout > 0) {
802
- const userCache = CACHE_USER[source]?.[userKey];
803
- let stored;
804
- if (userCache && (stored = userCache[queryString])) {
805
- const [expires, result] = stored;
806
- if (result) {
807
- const current = Date.now();
808
- let valid;
809
- if (renewCache) {
810
- stored[0] = expireTime(timeout);
811
- valid = true;
812
- }
813
- else if (current < expires) {
814
- valid = true;
815
- }
816
- if (valid) {
817
- stored[2] = current;
818
- incrementSourceCount(source, stored, userCache, queryString);
819
- if (Array.isArray(result)) {
820
- return result;
821
- }
822
- try {
823
- return JSON.parse(fs.readFileSync(result, 'utf-8'));
824
- }
825
- catch {
826
- }
827
- }
828
- clearSourceResult(stored);
800
+ if (!userKey) {
801
+ return;
802
+ }
803
+ queryString = this.asHash(queryString);
804
+ if (timeout > 0) {
805
+ const userCache = CACHE_USER[source]?.[userKey];
806
+ let stored;
807
+ if (!(userCache && (stored = userCache[queryString]))) {
808
+ return;
809
+ }
810
+ const [expires, result] = stored;
811
+ if (result) {
812
+ const current = Date.now();
813
+ let valid;
814
+ if (renewCache) {
815
+ stored[0] = expireTime(timeout);
816
+ valid = true;
817
+ }
818
+ else if (current < expires) {
819
+ valid = true;
820
+ }
821
+ if (valid) {
822
+ stored[2] = current;
823
+ incrementSourceCount(source, stored, userCache, queryString);
824
+ if (Array.isArray(result)) {
825
+ return result;
826
+ }
827
+ try {
828
+ return JSON.parse(fs.readFileSync(result, 'utf-8'));
829
+ }
830
+ catch {
829
831
  }
830
- deleteSourceResult(source, stored);
831
- delete userCache[queryString];
832
832
  }
833
+ clearSourceResult(stored);
833
834
  }
834
- else if (sessionKey) {
835
- return CACHE_SESSION[source]?.[userKey + sessionKey]?.[queryString];
836
- }
835
+ deleteSourceResult(source, stored);
836
+ delete userCache[queryString];
837
+ }
838
+ else if (sessionKey) {
839
+ return CACHE_SESSION[source]?.[userKey + sessionKey]?.[queryString];
837
840
  }
838
841
  }
839
842
  static storeResult(source, credential, queryString, result, options, sessionKey, sessionExpires) {
@@ -884,7 +887,10 @@ class ClientDb extends Client {
884
887
  addSourceResult(source, item);
885
888
  if (cacheDir) {
886
889
  if (partition) {
887
- const subDir = path.join(cacheDir, (STORE_RESULT_COUNT++ % this.STORE_RESULT_PARTITION_SIZE).toString(), queryString.substring(0, this.STORE_RESULT_PARTITION_MULT));
890
+ if (STORE_RESULT_COUNT === this.STORE_RESULT_PARTITION_SIZE) {
891
+ STORE_RESULT_COUNT = 0;
892
+ }
893
+ const subDir = path.join(cacheDir, (STORE_RESULT_COUNT++).toString(), queryString.substring(0, this.STORE_RESULT_PARTITION_MULT));
888
894
  if (this.createDir(subDir)) {
889
895
  cacheDir = subDir;
890
896
  }
@@ -1133,9 +1139,9 @@ class ClientDb extends Client {
1133
1139
  return this.database.filter(item => (item.transactionState & 32) === 32);
1134
1140
  }
1135
1141
  }
1142
+ exports.ClientDb = ClientDb;
1136
1143
  ClientDb.STORE_RESULT_PARTITION_SIZE = 16;
1137
1144
  ClientDb.STORE_RESULT_PARTITION_MULT = 2;
1138
- exports.ClientDb = ClientDb;
1139
1145
  class AbortComponent {
1140
1146
  constructor() {
1141
1147
  this[_d] = new AbortController();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/core",
3
- "version": "0.5.4",
3
+ "version": "0.6.1",
4
4
  "description": "Core modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git+https://github.com/anpham6/e-mc.git",
12
+ "url": "https://github.com/anpham6/e-mc.git",
13
13
  "directory": "src/core"
14
14
  },
15
15
  "keywords": [
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.5.4",
24
- "@e-mc/types": "0.5.4",
23
+ "@e-mc/module": "0.6.1",
24
+ "@e-mc/types": "0.6.1",
25
25
  "picomatch": "^2.3.1"
26
26
  }
27
27
  }