@e-mc/core 0.7.0 → 0.7.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 +10 -10
- package/index.d.ts +12 -12
- package/index.js +15 -15
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Copyright 2023 An Pham
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
-
|
|
5
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
-
|
|
7
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
1
|
+
Copyright 2023 An Pham
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
11
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { HostConstructor, ModuleConstructor } from '../types/lib';
|
|
2
|
-
import type { AbortComponentConstructor, ClientConstructor, ClientDbConstructor, PermissionConstructor } from '../types/lib/core';
|
|
3
|
-
|
|
4
|
-
declare namespace core {
|
|
5
|
-
const Module: ModuleConstructor;
|
|
6
|
-
const Host: HostConstructor;
|
|
7
|
-
const Client: ClientConstructor;
|
|
8
|
-
const ClientDb: ClientDbConstructor;
|
|
9
|
-
const AbortComponent: AbortComponentConstructor;
|
|
10
|
-
const Permission: PermissionConstructor;
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
import type { HostConstructor, ModuleConstructor } from '../types/lib';
|
|
2
|
+
import type { AbortComponentConstructor, ClientConstructor, ClientDbConstructor, PermissionConstructor } from '../types/lib/core';
|
|
3
|
+
|
|
4
|
+
declare namespace core {
|
|
5
|
+
const Module: ModuleConstructor;
|
|
6
|
+
const Host: HostConstructor;
|
|
7
|
+
const Client: ClientConstructor;
|
|
8
|
+
const ClientDb: ClientDbConstructor;
|
|
9
|
+
const AbortComponent: AbortComponentConstructor;
|
|
10
|
+
const Permission: PermissionConstructor;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
13
|
export = core;
|
package/index.js
CHANGED
|
@@ -50,20 +50,6 @@ let PICOMATCH_OPTIONS = { nocase: PLATFORM_WIN32 };
|
|
|
50
50
|
let MINIMATCH_OPTIONS = { matchBase: true, nocase: PLATFORM_WIN32 };
|
|
51
51
|
let MINIMATCH;
|
|
52
52
|
let PERMISSION;
|
|
53
|
-
function convertPosix(value) {
|
|
54
|
-
if (value) {
|
|
55
|
-
if ((0, types_1.isString)(value)) {
|
|
56
|
-
return asPosix(value);
|
|
57
|
-
}
|
|
58
|
-
if (Array.isArray(value)) {
|
|
59
|
-
const items = value.filter(item => (0, types_1.isString)(item));
|
|
60
|
-
if (items.length) {
|
|
61
|
-
return items.map(item => asPosix(item));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return '';
|
|
66
|
-
}
|
|
67
53
|
function getSettingsValue(options, name, component) {
|
|
68
54
|
const result = options[name];
|
|
69
55
|
return component ? (0, types_1.isObject)(result) ? result[component] : undefined : result;
|
|
@@ -121,7 +107,7 @@ function matchPermission(permission, pathname) {
|
|
|
121
107
|
return enabled === true && (0, types_1.isString)(pathname) && (value === '**/*' || value === '**' || Permission.match(pathname, value));
|
|
122
108
|
}
|
|
123
109
|
function setPermission(name, pathname, enabled) {
|
|
124
|
-
if (typeof enabled === 'boolean' && (!this[kFreeze] || this[name].enabled === null) && (!enabled || (pathname =
|
|
110
|
+
if (typeof enabled === 'boolean' && (!this[kFreeze] || this[name].enabled === null) && (!enabled || (pathname = Permission.toPosix(pathname)))) {
|
|
125
111
|
if (enabled && Array.isArray(pathname)) {
|
|
126
112
|
switch (pathname.length) {
|
|
127
113
|
case 1:
|
|
@@ -1259,6 +1245,20 @@ class Permission {
|
|
|
1259
1245
|
}
|
|
1260
1246
|
return pm.isMatch(pathname, pattern, PICOMATCH_OPTIONS);
|
|
1261
1247
|
}
|
|
1248
|
+
static toPosix(value) {
|
|
1249
|
+
if (value) {
|
|
1250
|
+
if ((0, types_1.isString)(value)) {
|
|
1251
|
+
return asPosix(value);
|
|
1252
|
+
}
|
|
1253
|
+
if (Array.isArray(value)) {
|
|
1254
|
+
const items = value.filter(item => (0, types_1.isString)(item));
|
|
1255
|
+
if (items.length) {
|
|
1256
|
+
return items.map(item => asPosix(item));
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return '';
|
|
1261
|
+
}
|
|
1262
1262
|
constructor(freeze = false) {
|
|
1263
1263
|
this[_f] = { enabled: null, value: '' };
|
|
1264
1264
|
this[_g] = { enabled: null, value: '' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.7.
|
|
24
|
-
"@e-mc/types": "0.7.
|
|
23
|
+
"@e-mc/module": "0.7.1",
|
|
24
|
+
"@e-mc/types": "0.7.1",
|
|
25
25
|
"picomatch": "^3.0.1"
|
|
26
26
|
}
|
|
27
27
|
}
|