@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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/index.js +44 -38
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
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
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
|
-
|
|
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
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
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
|
-
|
|
835
|
-
|
|
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
|
-
|
|
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.
|
|
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": "
|
|
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.
|
|
24
|
-
"@e-mc/types": "0.
|
|
23
|
+
"@e-mc/module": "0.6.1",
|
|
24
|
+
"@e-mc/types": "0.6.1",
|
|
25
25
|
"picomatch": "^2.3.1"
|
|
26
26
|
}
|
|
27
27
|
}
|