@guanghechen/path 1.0.0-alpha.5 → 1.0.0-alpha.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.6](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.5...@guanghechen/path@1.0.0-alpha.6) (2023-10-16)
7
+
8
+
9
+ ### Performance Improvements
10
+
11
+ * :art: refactor @guanghechen/path ([8952da3](https://github.com/guanghechen/sora/commit/8952da3154a042a10e76b356da7461a1f8ad8582))
12
+
13
+
14
+
15
+
16
+
6
17
  # [1.0.0-alpha.5](https://github.com/guanghechen/sora/compare/@guanghechen/path@1.0.0-alpha.4...@guanghechen/path@1.0.0-alpha.5) (2023-10-16)
7
18
 
8
19
 
package/lib/cjs/index.cjs CHANGED
@@ -9,8 +9,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
10
10
  var path__default = /*#__PURE__*/_interopDefault(path);
11
11
 
12
- const clazz$1 = 'PhysicalPathResolver';
13
- class PhysicalPathResolver {
12
+ const clazz$1 = 'PathResolver';
13
+ class PathResolver {
14
14
  basename(filepath) {
15
15
  this.ensureAbsolute(filepath);
16
16
  const p = this.normalize(filepath);
@@ -92,8 +92,8 @@ class PhysicalPathResolver {
92
92
  }
93
93
  }
94
94
 
95
- const clazz = 'VirtualPathResolver';
96
- class VirtualPathResolver {
95
+ const clazz = 'UrlPathResolver';
96
+ class UrlPathResolver {
97
97
  basename(filepath) {
98
98
  this.ensureAbsolute(filepath);
99
99
  const p = this.normalize(filepath);
@@ -250,32 +250,16 @@ class WorkspacePathResolver {
250
250
  }
251
251
  }
252
252
 
253
- class PhysicalWorkspacePathResolver extends WorkspacePathResolver {
254
- constructor(root) {
255
- const pathResolver = new PhysicalPathResolver();
256
- super(root, pathResolver);
257
- }
258
- }
259
-
260
- class VirtualWorkspacePathResolver extends WorkspacePathResolver {
261
- constructor(root) {
262
- const pathResolver = new VirtualPathResolver();
263
- super(root, pathResolver);
264
- }
265
- }
266
-
267
- const physicalPathResolver = new PhysicalPathResolver();
268
- const virtualPathResolver = new VirtualPathResolver();
253
+ const pathResolver = new PathResolver();
254
+ const urlPathResolver = new UrlPathResolver();
269
255
 
270
- exports.PhysicalPathResolver = PhysicalPathResolver;
271
- exports.PhysicalWorkspacePathResolver = PhysicalWorkspacePathResolver;
272
- exports.VirtualPathResolver = VirtualPathResolver;
273
- exports.VirtualWorkspacePathResolver = VirtualWorkspacePathResolver;
256
+ exports.PathResolver = PathResolver;
257
+ exports.UrlPathResolver = UrlPathResolver;
274
258
  exports.WorkspacePathResolver = WorkspacePathResolver;
275
259
  exports.findNearestFilepath = findNearestFilepath;
276
260
  exports.locateNearestFilepath = locateNearestFilepath;
277
- exports.physicalPathResolver = physicalPathResolver;
278
- exports.virtualPathResolver = virtualPathResolver;
261
+ exports.pathResolver = pathResolver;
262
+ exports.urlPathResolver = urlPathResolver;
279
263
  Object.keys(path_types).forEach(function (k) {
280
264
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
281
265
  enumerable: true,
package/lib/esm/index.mjs CHANGED
@@ -3,8 +3,8 @@ import { existsSync, readdirSync } from 'node:fs';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  export * from '@guanghechen/path.types';
5
5
 
6
- const clazz$1 = 'PhysicalPathResolver';
7
- class PhysicalPathResolver {
6
+ const clazz$1 = 'PathResolver';
7
+ class PathResolver {
8
8
  basename(filepath) {
9
9
  this.ensureAbsolute(filepath);
10
10
  const p = this.normalize(filepath);
@@ -86,8 +86,8 @@ class PhysicalPathResolver {
86
86
  }
87
87
  }
88
88
 
89
- const clazz = 'VirtualPathResolver';
90
- class VirtualPathResolver {
89
+ const clazz = 'UrlPathResolver';
90
+ class UrlPathResolver {
91
91
  basename(filepath) {
92
92
  this.ensureAbsolute(filepath);
93
93
  const p = this.normalize(filepath);
@@ -244,21 +244,7 @@ class WorkspacePathResolver {
244
244
  }
245
245
  }
246
246
 
247
- class PhysicalWorkspacePathResolver extends WorkspacePathResolver {
248
- constructor(root) {
249
- const pathResolver = new PhysicalPathResolver();
250
- super(root, pathResolver);
251
- }
252
- }
253
-
254
- class VirtualWorkspacePathResolver extends WorkspacePathResolver {
255
- constructor(root) {
256
- const pathResolver = new VirtualPathResolver();
257
- super(root, pathResolver);
258
- }
259
- }
260
-
261
- const physicalPathResolver = new PhysicalPathResolver();
262
- const virtualPathResolver = new VirtualPathResolver();
247
+ const pathResolver = new PathResolver();
248
+ const urlPathResolver = new UrlPathResolver();
263
249
 
264
- export { PhysicalPathResolver, PhysicalWorkspacePathResolver, VirtualPathResolver, VirtualWorkspacePathResolver, WorkspacePathResolver, findNearestFilepath, locateNearestFilepath, physicalPathResolver, virtualPathResolver };
250
+ export { PathResolver, UrlPathResolver, WorkspacePathResolver, findNearestFilepath, locateNearestFilepath, pathResolver, urlPathResolver };
@@ -18,7 +18,7 @@ declare function locateNearestFilepath(currentDir: string, filenames: string | R
18
18
  */
19
19
  declare function findNearestFilepath(currentDir: string, predicate: (filepath: string) => boolean): string | null;
20
20
 
21
- declare class PhysicalPathResolver implements IPathResolver {
21
+ declare class PathResolver implements IPathResolver {
22
22
  basename(filepath: string): string;
23
23
  ensureAbsolute(filepath: string, message?: string | undefined): void | never;
24
24
  ensureSafeRelative(root: string, filepath: string, message?: string | undefined): void | never;
@@ -36,21 +36,7 @@ declare class PhysicalPathResolver implements IPathResolver {
36
36
  protected _internalSafeResolve(root: string, filepath_: string): string;
37
37
  }
38
38
 
39
- declare class WorkspacePathResolver implements IWorkspacePathResolver {
40
- readonly root: string;
41
- readonly pathResolver: IPathResolver;
42
- constructor(root: string, pathResolver: IPathResolver);
43
- ensureSafePath(filepath: string, message?: string | undefined): void | never;
44
- isSafePath(filepath: string): boolean;
45
- relative(filepath: string): string | never;
46
- resolve(filepath: string): string | never;
47
- }
48
-
49
- declare class PhysicalWorkspacePathResolver extends WorkspacePathResolver implements IWorkspacePathResolver {
50
- constructor(root: string);
51
- }
52
-
53
- declare class VirtualPathResolver implements IPathResolver {
39
+ declare class UrlPathResolver implements IPathResolver {
54
40
  basename(filepath: string): string;
55
41
  ensureAbsolute(filepath: string, message?: string | undefined): void | never;
56
42
  ensureSafeRelative(root: string, filepath: string, message?: string | undefined): void;
@@ -69,11 +55,17 @@ declare class VirtualPathResolver implements IPathResolver {
69
55
  protected _internalSafeResolve(root: string, filepath_: string): string;
70
56
  }
71
57
 
72
- declare class VirtualWorkspacePathResolver extends WorkspacePathResolver implements IWorkspacePathResolver {
73
- constructor(root: string);
58
+ declare class WorkspacePathResolver implements IWorkspacePathResolver {
59
+ readonly root: string;
60
+ readonly pathResolver: IPathResolver;
61
+ constructor(root: string, pathResolver: IPathResolver);
62
+ ensureSafePath(filepath: string, message?: string | undefined): void | never;
63
+ isSafePath(filepath: string): boolean;
64
+ relative(filepath: string): string | never;
65
+ resolve(filepath: string): string | never;
74
66
  }
75
67
 
76
- declare const physicalPathResolver: IPathResolver;
77
- declare const virtualPathResolver: IPathResolver;
68
+ declare const pathResolver: IPathResolver;
69
+ declare const urlPathResolver: IPathResolver;
78
70
 
79
- export { PhysicalPathResolver, PhysicalWorkspacePathResolver, VirtualPathResolver, VirtualWorkspacePathResolver, WorkspacePathResolver, findNearestFilepath, locateNearestFilepath, physicalPathResolver, virtualPathResolver };
71
+ export { PathResolver, UrlPathResolver, WorkspacePathResolver, findNearestFilepath, locateNearestFilepath, pathResolver, urlPathResolver };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanghechen/path",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "Path utils.",
5
5
  "author": {
6
6
  "name": "guanghechen",
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0-alpha.4",
11
+ "url": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0-alpha.5",
12
12
  "directory": "packages/path"
13
13
  },
14
- "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0-alpha.4/packages/path#readme",
14
+ "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/path@1.0.0-alpha.5/packages/path#readme",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -45,5 +45,5 @@
45
45
  "dependencies": {
46
46
  "@guanghechen/path.types": "^1.0.0-alpha.4"
47
47
  },
48
- "gitHead": "5970cec8f9021212fd2009f40f65f0abf5ba77ec"
48
+ "gitHead": "e42cabded60b75856018c6f216d08b3d830a29b2"
49
49
  }