whet 0.0.8 → 0.0.9

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.
@@ -1,6 +1,5 @@
1
1
  import {CacheManager} from "./cache/CacheManager.js"
2
2
  import {Whet_Fields_} from "./Whet.js"
3
- import {SourceId_Fields_} from "./SourceId.js"
4
3
  import {Log} from "./Log.js"
5
4
  import * as Path from "path"
6
5
  import {Register} from "../genes/Register.js"
@@ -39,18 +38,30 @@ class Project extends Register.inherits() {
39
38
  file = decodeURI(file);
40
39
  file = StringTools.replace(file, "file:///", "");
41
40
  var s = Path.relative(process.cwd(), file);
42
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
43
- s = StringTools.replace(s, "\\", "/");
44
- var this1 = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
41
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
42
+ if (str.length > 0) {
43
+ str = Path.posix.normalize(str);
44
+ str = StringTools.replace(str, "\\", "/");
45
+ };
46
+ s = str;
47
+ var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
45
48
  var s = this1.substring(0, this1.lastIndexOf("/") + 1);
46
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
47
- s = StringTools.replace(s, "\\", "/");
48
- this.rootDir = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
49
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
50
+ if (str.length > 0) {
51
+ str = Path.posix.normalize(str);
52
+ str = StringTools.replace(str, "\\", "/");
53
+ };
54
+ s = str;
55
+ this.rootDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
49
56
  } else {
50
57
  var s = config.rootDir;
51
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
52
- s = StringTools.replace(s, "\\", "/");
53
- this.rootDir = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
58
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
59
+ if (str.length > 0) {
60
+ str = Path.posix.normalize(str);
61
+ str = StringTools.replace(str, "\\", "/");
62
+ };
63
+ s = str;
64
+ this.rootDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
54
65
  };
55
66
  this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
56
67
  Project.projects.push(this);
@@ -26,6 +26,10 @@ export declare class Source {
26
26
  export declare class SourceData {
27
27
  protected constructor(id: string, data: Buffer)
28
28
  data: Buffer
29
+
30
+ /**
31
+ Name relative to the stone that generated it.
32
+ */
29
33
  id: string
30
34
  hash: SourceHash
31
35
  source: Source
@@ -43,7 +47,10 @@ export declare class SourceData {
43
47
  protected getFilePath(idOverride?: null | string): Promise<string>
44
48
 
45
49
  /**
46
- * `path` is the actual cwd-relative path. `pathId` is the project-relative source Id.
50
+ * @param id Path id relative to stone that generates it.
51
+ * @param path Actual path relative to CWD.
52
+ * @param pathId Path Id relative to project.
53
+ * @return Promise<SourceData>
47
54
  */
48
55
  static fromFile(id: string, path: string, pathId: string): Promise<SourceData>
49
56
  static fromString(id: string, s: string): SourceData
@@ -1,5 +1,5 @@
1
1
  import {Utils} from "./Utils.js"
2
- import {SourceId_Fields_, SourceId, RootDir} from "./SourceId.js"
2
+ import {SourceId, RootDir} from "./SourceId.js"
3
3
  import {SourceHash} from "./SourceHash.js"
4
4
  import {Log} from "./Log.js"
5
5
  import * as Path from "path"
@@ -46,9 +46,13 @@ class Source extends Register.inherits() {
46
46
  return this.data[0];
47
47
  } else {
48
48
  var s = id;
49
- s = Path.posix.normalize((id.length > 1 && SourceId_Fields_.startsWithSlash(id)) ? HxOverrides.substr(id, 1, null) : id);
50
- s = StringTools.replace(s, "\\", "/");
51
- var sid = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
49
+ var str = (id.length > 1 && HxOverrides.cca(id, 0) == 47) ? id.substring(1) : id;
50
+ if (str.length > 0) {
51
+ str = Path.posix.normalize(str);
52
+ str = StringTools.replace(str, "\\", "/");
53
+ };
54
+ s = str;
55
+ var sid = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
52
56
  return Lambda.find(this.data, function (entry) {
53
57
  return entry.id == sid;
54
58
  });
@@ -113,7 +117,10 @@ class SourceData extends Register.inherits() {
113
117
  }
114
118
 
115
119
  /**
116
- * `path` is the actual cwd-relative path. `pathId` is the project-relative source Id.
120
+ * @param id Path id relative to stone that generates it.
121
+ * @param path Actual path relative to CWD.
122
+ * @param pathId Path Id relative to project.
123
+ * @return Promise<SourceData>
117
124
  */
118
125
  static fromFile(id, path, pathId) {
119
126
  return new Promise(function (res, rej) {
@@ -125,9 +132,13 @@ class SourceData extends Register.inherits() {
125
132
  var source = SourceData.fromBytes(id, buffer);
126
133
  source.filePath = path;
127
134
  var s = pathId;
128
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
129
- s = StringTools.replace(s, "\\", "/");
130
- source.filePathId = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
135
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
136
+ if (str.length > 0) {
137
+ str = Path.posix.normalize(str);
138
+ str = StringTools.replace(str, "\\", "/");
139
+ };
140
+ s = str;
141
+ source.filePathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
131
142
  res(source);
132
143
  };
133
144
  });
@@ -138,9 +149,13 @@ class SourceData extends Register.inherits() {
138
149
  }
139
150
  static fromBytes(id, data) {
140
151
  var s = id;
141
- s = Path.posix.normalize((id.length > 1 && SourceId_Fields_.startsWithSlash(id)) ? HxOverrides.substr(id, 1, null) : id);
142
- s = StringTools.replace(s, "\\", "/");
143
- return new SourceData((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s, data);
152
+ var str = (id.length > 1 && HxOverrides.cca(id, 0) == 47) ? id.substring(1) : id;
153
+ if (str.length > 0) {
154
+ str = Path.posix.normalize(str);
155
+ str = StringTools.replace(str, "\\", "/");
156
+ };
157
+ s = str;
158
+ return new SourceData((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, data);
144
159
  }
145
160
  static get __name__() {
146
161
  return "whet.SourceData"
@@ -9,3 +9,4 @@ export declare class RootDir {
9
9
  static fromProject(p: Project): string
10
10
  }
11
11
 
12
+ export const fromCwdPath: (s: string, root: string) => string
@@ -8,37 +8,53 @@ const $global = Register.$global
8
8
  export const SourceId = Register.global("$hxClasses")["whet._SourceId.SourceId"] =
9
9
  class SourceId {
10
10
  static relativeTo(this1, directory) {
11
- if (!SourceId_Fields_.endsWithSlash(directory)) {
11
+ if (HxOverrides.cca(directory, directory.length - 1) != 47) {
12
12
  throw new Error("\"" + directory + "\" is not a directory.");
13
13
  };
14
14
  var tmp;
15
15
  var s = this1.substring(0, this1.lastIndexOf("/") + 1);
16
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
17
- s = StringTools.replace(s, "\\", "/");
18
- tmp = ((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s).indexOf(directory) == 0;
16
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
17
+ if (str.length > 0) {
18
+ str = Path.posix.normalize(str);
19
+ str = StringTools.replace(str, "\\", "/");
20
+ };
21
+ s = str;
22
+ tmp = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s).indexOf(directory) == 0;
19
23
  if (tmp) {
20
- return HxOverrides.substr(this1, directory.length - 1, null);
24
+ return this1.substring(directory.length - 1);
21
25
  } else {
22
26
  return null;
23
27
  };
24
28
  }
25
29
  static getPutInDir(this1, dir) {
26
- if (!SourceId_Fields_.endsWithSlash(dir)) {
30
+ if (HxOverrides.cca(dir, dir.length - 1) != 47) {
27
31
  throw new Error("\"" + dir + "\" is not a directory.");
28
32
  };
29
33
  var s = "/";
30
- s = Path.posix.normalize(("/".length > 1 && SourceId_Fields_.startsWithSlash("/")) ? HxOverrides.substr("/", 1, null) : "/");
31
- s = StringTools.replace(s, "\\", "/");
32
- if (dir == ((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s)) {
34
+ var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
35
+ if (str.length > 0) {
36
+ str = Path.posix.normalize(str);
37
+ str = StringTools.replace(str, "\\", "/");
38
+ };
39
+ s = str;
40
+ if (dir == ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s)) {
33
41
  var s = this1;
34
- s = Path.posix.normalize((this1.length > 1 && SourceId_Fields_.startsWithSlash(this1)) ? HxOverrides.substr(this1, 1, null) : this1);
35
- s = StringTools.replace(s, "\\", "/");
36
- return (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
42
+ var str = (this1.length > 1 && HxOverrides.cca(this1, 0) == 47) ? this1.substring(1) : this1;
43
+ if (str.length > 0) {
44
+ str = Path.posix.normalize(str);
45
+ str = StringTools.replace(str, "\\", "/");
46
+ };
47
+ s = str;
48
+ return (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
37
49
  } else {
38
50
  var s = dir + this1;
39
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
40
- s = StringTools.replace(s, "\\", "/");
41
- return (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
51
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
52
+ if (str.length > 0) {
53
+ str = Path.posix.normalize(str);
54
+ str = StringTools.replace(str, "\\", "/");
55
+ };
56
+ s = str;
57
+ return (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
42
58
  };
43
59
  }
44
60
  static get __name__() {
@@ -66,11 +82,20 @@ class RootDir {
66
82
 
67
83
  export const SourceId_Fields_ = Register.global("$hxClasses")["whet._SourceId.SourceId_Fields_"] =
68
84
  class SourceId_Fields_ {
69
- static startsWithSlash(str) {
70
- return HxOverrides.cca(str, 0) == 47;
71
- }
72
- static endsWithSlash(str) {
73
- return HxOverrides.cca(str, str.length - 1) == 47;
85
+ static fromCwdPath(s, root) {
86
+ var s1 = Path.posix;
87
+ var str = s;
88
+ if (str.length > 0) {
89
+ str = Path.posix.normalize(str);
90
+ str = StringTools.replace(str, "\\", "/");
91
+ };
92
+ s = s1.resolve(str);
93
+ var rootStr = root;
94
+ if (HxOverrides.cca(rootStr, 0) == 47) {
95
+ rootStr = rootStr.substring(1);
96
+ };
97
+ rootStr = Path.posix.resolve(rootStr);
98
+ return Path.posix.relative(rootStr, s);
74
99
  }
75
100
  static get __name__() {
76
101
  return "whet._SourceId.SourceId_Fields_"
@@ -81,3 +106,4 @@ class SourceId_Fields_ {
81
106
  }
82
107
 
83
108
 
109
+ export const fromCwdPath = SourceId_Fields_.fromCwdPath
package/bin/whet/Stone.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {StoneId_Fields_} from "./magic/StoneId.js"
2
2
  import {CacheStrategy, CacheDurability} from "./cache/Cache.js"
3
3
  import {Utils} from "./Utils.js"
4
- import {SourceId_Fields_, SourceId, RootDir} from "./SourceId.js"
4
+ import {SourceId, RootDir} from "./SourceId.js"
5
5
  import {SourceHash} from "./SourceHash.js"
6
6
  import {Source} from "./Source.js"
7
7
  import {Project} from "./Project.js"
@@ -141,9 +141,13 @@ class Stone extends Register.inherits() {
141
141
  generate = true;
142
142
  };
143
143
  var s = path;
144
- s = Path.posix.normalize((path.length > 1 && SourceId_Fields_.startsWithSlash(path)) ? HxOverrides.substr(path, 1, null) : path);
145
- s = StringTools.replace(s, "\\", "/");
146
- this.cacheStrategy = CacheStrategy.AbsolutePath((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s, CacheDurability.LimitCountByAge(1));
144
+ var str = (path.length > 1 && HxOverrides.cca(path, 0) == 47) ? path.substring(1) : path;
145
+ if (str.length > 0) {
146
+ str = Path.posix.normalize(str);
147
+ str = StringTools.replace(str, "\\", "/");
148
+ };
149
+ s = str;
150
+ this.cacheStrategy = CacheStrategy.AbsolutePath((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, CacheDurability.LimitCountByAge(1));
147
151
  if (generate) {
148
152
  return this.getSource();
149
153
  } else {
@@ -160,10 +164,14 @@ class Stone extends Register.inherits() {
160
164
  var _gthis = this;
161
165
  Log.log(30, ...["Exporting file(s).", {"path": path, "stone": this}]);
162
166
  var s = path;
163
- s = Path.posix.normalize((path.length > 1 && SourceId_Fields_.startsWithSlash(path)) ? HxOverrides.substr(path, 1, null) : path);
164
- s = StringTools.replace(s, "\\", "/");
165
- var pathId = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
166
- var isDir = SourceId_Fields_.endsWithSlash(pathId);
167
+ var str = (path.length > 1 && HxOverrides.cca(path, 0) == 47) ? path.substring(1) : path;
168
+ if (str.length > 0) {
169
+ str = Path.posix.normalize(str);
170
+ str = StringTools.replace(str, "\\", "/");
171
+ };
172
+ s = str;
173
+ var pathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
174
+ var isDir = HxOverrides.cca(pathId, pathId.length - 1) == 47;
167
175
  return this.getSource().then(function (src) {
168
176
  if (src.data.length > 1 && !isDir) {
169
177
  throw new Error("Path is not a directory for multiple source export.");
package/bin/whet/Whet.js CHANGED
@@ -10,7 +10,7 @@ const $global = Register.$global
10
10
  export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
11
11
  class Whet_Fields_ {
12
12
  static main() {
13
- Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.8", "-v, --version").allowUnknownOption(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info");
13
+ Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.9", "-v, --version").allowUnknownOption(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info");
14
14
  Whet_Fields_.program.parse();
15
15
  var options = Whet_Fields_.program.opts();
16
16
  if (options.logLevel != null) {
@@ -1,5 +1,5 @@
1
1
  import {Cache} from "./Cache.js"
2
- import {SourceId_Fields_, SourceId} from "../SourceId.js"
2
+ import {SourceId} from "../SourceId.js"
3
3
  import {SourceHash} from "../SourceHash.js"
4
4
  import {Log} from "../Log.js"
5
5
  import * as Path from "path"
@@ -15,7 +15,7 @@ const $global = Register.$global
15
15
  export const BaseCache = Register.global("$hxClasses")["whet.cache.BaseCache"] =
16
16
  class BaseCache extends Register.inherits() {
17
17
  new(rootDir, cache) {
18
- if (!SourceId_Fields_.endsWithSlash(rootDir)) {
18
+ if (HxOverrides.cca(rootDir, rootDir.length - 1) != 47) {
19
19
  throw new Error("Root dir is a not a dir.");
20
20
  };
21
21
  this.rootDir = rootDir;
@@ -125,9 +125,13 @@ class BaseCache extends Register.inherits() {
125
125
  var filenames = this.getExistingDirs(stone);
126
126
  var maxNum = (filenames != null) ? Lambda.fold(filenames, function (fn, num) {
127
127
  var s = fn.substring(0, fn.lastIndexOf("/") + 1);
128
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
129
- s = StringTools.replace(s, "\\", "/");
130
- var this1 = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
128
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
129
+ if (str.length > 0) {
130
+ str = Path.posix.normalize(str);
131
+ str = StringTools.replace(str, "\\", "/");
132
+ };
133
+ s = str;
134
+ var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
131
135
  var root = _gthis.rootDir;
132
136
  if (this1.charAt(0) != "/") {
133
137
  throw new Error("Badly formed SourceId.");
@@ -138,9 +142,13 @@ class BaseCache extends Register.inherits() {
138
142
  }, 0) : 0;
139
143
  ++maxNum;
140
144
  var s = "v" + maxNum + "/";
141
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
142
- s = StringTools.replace(s, "\\", "/");
143
- return SourceId.getPutInDir((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s, baseDir);
145
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
146
+ if (str.length > 0) {
147
+ str = Path.posix.normalize(str);
148
+ str = StringTools.replace(str, "\\", "/");
149
+ };
150
+ s = str;
151
+ return SourceId.getPutInDir((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, baseDir);
144
152
  }
145
153
  checkDurability(stone, values, durability, useIndex, ageIndex) {
146
154
  Log.log(20, ...["Checking durability.", {"stone": stone, "durability": Std.string(durability)}]);
@@ -1,7 +1,7 @@
1
1
  import {MemoryCache} from "./MemoryCache.js"
2
2
  import {FileCache} from "./FileCache.js"
3
3
  import {CacheStrategy, CacheDurability, DurabilityCheck} from "./Cache.js"
4
- import {RootDir, SourceId_Fields_, SourceId} from "../SourceId.js"
4
+ import {RootDir, SourceId} from "../SourceId.js"
5
5
  import {Log} from "../Log.js"
6
6
  import * as Path from "path"
7
7
  import {Register} from "../../genes/Register.js"
@@ -54,9 +54,13 @@ class CacheManager extends Register.inherits() {
54
54
  */
55
55
  getDir(stone, hash) {
56
56
  var s = stone.id + "/";
57
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
58
- s = StringTools.replace(s, "\\", "/");
59
- var baseDir = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
57
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
58
+ if (str.length > 0) {
59
+ str = Path.posix.normalize(str);
60
+ str = StringTools.replace(str, "\\", "/");
61
+ };
62
+ s = str;
63
+ var baseDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
60
64
  var tmp;
61
65
  switch (stone.cacheStrategy._hx_index) {
62
66
  case 0:
@@ -71,14 +75,22 @@ class CacheManager extends Register.inherits() {
71
75
  };
72
76
  if (tmp) {
73
77
  var s = ".temp/";
74
- s = Path.posix.normalize((".temp/".length > 1 && SourceId_Fields_.startsWithSlash(".temp/")) ? HxOverrides.substr(".temp/", 1, null) : ".temp/");
75
- s = StringTools.replace(s, "\\", "/");
76
- baseDir = SourceId.getPutInDir(baseDir, (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s);
78
+ var str = (".temp/".length > 1 && HxOverrides.cca(".temp/", 0) == 47) ? ".temp/".substring(1) : ".temp/";
79
+ if (str.length > 0) {
80
+ str = Path.posix.normalize(str);
81
+ str = StringTools.replace(str, "\\", "/");
82
+ };
83
+ s = str;
84
+ baseDir = SourceId.getPutInDir(baseDir, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
77
85
  };
78
86
  var s = ".whet/";
79
- s = Path.posix.normalize((".whet/".length > 1 && SourceId_Fields_.startsWithSlash(".whet/")) ? HxOverrides.substr(".whet/", 1, null) : ".whet/");
80
- s = StringTools.replace(s, "\\", "/");
81
- baseDir = SourceId.getPutInDir(baseDir, (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s);
87
+ var str = (".whet/".length > 1 && HxOverrides.cca(".whet/", 0) == 47) ? ".whet/".substring(1) : ".whet/";
88
+ if (str.length > 0) {
89
+ str = Path.posix.normalize(str);
90
+ str = StringTools.replace(str, "\\", "/");
91
+ };
92
+ s = str;
93
+ baseDir = SourceId.getPutInDir(baseDir, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
82
94
  var id;
83
95
  var _g = stone.cacheStrategy;
84
96
  switch (_g._hx_index) {
@@ -94,9 +106,13 @@ class CacheManager extends Register.inherits() {
94
106
  case 3:
95
107
  var _g1 = _g.path;
96
108
  var s = _g1.substring(0, _g1.lastIndexOf("/") + 1);
97
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
98
- s = StringTools.replace(s, "\\", "/");
99
- id = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
109
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
110
+ if (str.length > 0) {
111
+ str = Path.posix.normalize(str);
112
+ str = StringTools.replace(str, "\\", "/");
113
+ };
114
+ s = str;
115
+ id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
100
116
  break
101
117
 
102
118
  };
@@ -1,6 +1,5 @@
1
1
  import {BaseCache} from "./BaseCache.js"
2
2
  import {Utils} from "../Utils.js"
3
- import {SourceId_Fields_} from "../SourceId.js"
4
3
  import {SourceHash} from "../SourceHash.js"
5
4
  import {SourceData, Source} from "../Source.js"
6
5
  import {Log} from "../Log.js"
@@ -21,9 +20,13 @@ class FileCache extends Register.inherits(BaseCache) {
21
20
  this.flushQueued = false;
22
21
  super.new(rootDir, new StringMap());
23
22
  var s = ".whet/cache.json";
24
- s = Path.posix.normalize((".whet/cache.json".length > 1 && SourceId_Fields_.startsWithSlash(".whet/cache.json")) ? HxOverrides.substr(".whet/cache.json", 1, null) : ".whet/cache.json");
25
- s = StringTools.replace(s, "\\", "/");
26
- var this1 = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
23
+ var str = (".whet/cache.json".length > 1 && HxOverrides.cca(".whet/cache.json", 0) == 47) ? ".whet/cache.json".substring(1) : ".whet/cache.json";
24
+ if (str.length > 0) {
25
+ str = Path.posix.normalize(str);
26
+ str = StringTools.replace(str, "\\", "/");
27
+ };
28
+ s = str;
29
+ var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
27
30
  if (this1.charAt(0) != "/") {
28
31
  throw new Error("Badly formed SourceId.");
29
32
  };
@@ -44,9 +47,13 @@ class FileCache extends Register.inherits(BaseCache) {
44
47
  var tmp = SourceHash.fromHex(val.hash);
45
48
  var val1 = val.ctime;
46
49
  var s = val.baseDir;
47
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
48
- s = StringTools.replace(s, "\\", "/");
49
- var tmp1 = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
50
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
51
+ if (str.length > 0) {
52
+ str = Path.posix.normalize(str);
53
+ str = StringTools.replace(str, "\\", "/");
54
+ };
55
+ s = str;
56
+ var tmp1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
50
57
  var _g2 = [];
51
58
  var _g3 = 0;
52
59
  var _g4 = val.files;
@@ -55,13 +62,21 @@ class FileCache extends Register.inherits(BaseCache) {
55
62
  ++_g3;
56
63
  var tmp2 = SourceHash.fromHex(file.fileHash);
57
64
  var s1 = file.filePath;
58
- s1 = Path.posix.normalize((s1.length > 1 && SourceId_Fields_.startsWithSlash(s1)) ? HxOverrides.substr(s1, 1, null) : s1);
59
- s1 = StringTools.replace(s1, "\\", "/");
60
- var tmp3 = (SourceId_Fields_.startsWithSlash(s1)) ? s1 : "/" + s1;
65
+ var str1 = (s1.length > 1 && HxOverrides.cca(s1, 0) == 47) ? s1.substring(1) : s1;
66
+ if (str1.length > 0) {
67
+ str1 = Path.posix.normalize(str1);
68
+ str1 = StringTools.replace(str1, "\\", "/");
69
+ };
70
+ s1 = str1;
71
+ var tmp3 = (HxOverrides.cca(s1, 0) == 47) ? s1 : "/" + s1;
61
72
  var s2 = file.id;
62
- s2 = Path.posix.normalize((s2.length > 1 && SourceId_Fields_.startsWithSlash(s2)) ? HxOverrides.substr(s2, 1, null) : s2);
63
- s2 = StringTools.replace(s2, "\\", "/");
64
- _g2.push({"fileHash": tmp2, "filePath": tmp3, "id": (SourceId_Fields_.startsWithSlash(s2)) ? s2 : "/" + s2});
73
+ var str2 = (s2.length > 1 && HxOverrides.cca(s2, 0) == 47) ? s2.substring(1) : s2;
74
+ if (str2.length > 0) {
75
+ str2 = Path.posix.normalize(str2);
76
+ str2 = StringTools.replace(str2, "\\", "/");
77
+ };
78
+ s2 = str2;
79
+ _g2.push({"fileHash": tmp2, "filePath": tmp3, "id": (HxOverrides.cca(s2, 0) == 47) ? s2 : "/" + s2});
65
80
  };
66
81
  _g.push({"hash": tmp, "ctime": val1, "baseDir": tmp1, "files": _g2});
67
82
  };
@@ -80,9 +95,13 @@ class FileCache extends Register.inherits(BaseCache) {
80
95
  var _g1 = _g.path;
81
96
  if (source.data.length == 1) {
82
97
  var s = _g1.substring(_g1.lastIndexOf("/"));
83
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
84
- s = StringTools.replace(s, "\\", "/");
85
- idOverride = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
98
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
99
+ if (str.length > 0) {
100
+ str = Path.posix.normalize(str);
101
+ str = StringTools.replace(str, "\\", "/");
102
+ };
103
+ s = str;
104
+ idOverride = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
86
105
  } else {
87
106
  idOverride = null;
88
107
  };
@@ -111,14 +130,18 @@ class FileCache extends Register.inherits(BaseCache) {
111
130
  if (_g._hx_index == 3) {
112
131
  var _g1 = _g.path;
113
132
  var invalidPath;
114
- if (value.files.length == 1 && !SourceId_Fields_.endsWithSlash(_g1)) {
133
+ if (value.files.length == 1 && HxOverrides.cca(_g1, _g1.length - 1) != 47) {
115
134
  invalidPath = value.files[0].filePath != _g1;
116
135
  } else {
117
136
  var value1 = value.baseDir;
118
137
  var s = _g1.substring(0, _g1.lastIndexOf("/") + 1);
119
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
120
- s = StringTools.replace(s, "\\", "/");
121
- invalidPath = value1 != ((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s);
138
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
139
+ if (str.length > 0) {
140
+ str = Path.posix.normalize(str);
141
+ str = StringTools.replace(str, "\\", "/");
142
+ };
143
+ s = str;
144
+ invalidPath = value1 != ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
122
145
  };
123
146
  if (invalidPath) {
124
147
  return Promise.resolve(null);
@@ -292,9 +315,13 @@ class FileCache extends Register.inherits(BaseCache) {
292
315
  var tmp1 = HxOverrides.dateStr(new Date(val.ctime * 1000));
293
316
  var this2 = val.baseDir;
294
317
  var s = "/";
295
- s = Path.posix.normalize(("/".length > 1 && SourceId_Fields_.startsWithSlash("/")) ? HxOverrides.substr("/", 1, null) : "/");
296
- s = StringTools.replace(s, "\\", "/");
297
- var root = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
318
+ var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
319
+ if (str.length > 0) {
320
+ str = Path.posix.normalize(str);
321
+ str = StringTools.replace(str, "\\", "/");
322
+ };
323
+ s = str;
324
+ var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
298
325
  if (this2.charAt(0) != "/") {
299
326
  throw new Error("Badly formed SourceId.");
300
327
  };
@@ -308,18 +335,26 @@ class FileCache extends Register.inherits(BaseCache) {
308
335
  var tmp3 = SourceHash.toHex(file.fileHash);
309
336
  var this3 = file.filePath;
310
337
  var s1 = "/";
311
- s1 = Path.posix.normalize(("/".length > 1 && SourceId_Fields_.startsWithSlash("/")) ? HxOverrides.substr("/", 1, null) : "/");
312
- s1 = StringTools.replace(s1, "\\", "/");
313
- var root1 = (SourceId_Fields_.startsWithSlash(s1)) ? s1 : "/" + s1;
338
+ var str1 = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
339
+ if (str1.length > 0) {
340
+ str1 = Path.posix.normalize(str1);
341
+ str1 = StringTools.replace(str1, "\\", "/");
342
+ };
343
+ s1 = str1;
344
+ var root1 = (HxOverrides.cca(s1, 0) == 47) ? s1 : "/" + s1;
314
345
  if (this3.charAt(0) != "/") {
315
346
  throw new Error("Badly formed SourceId.");
316
347
  };
317
348
  var tmp4 = Path.posix.join(".", root1, ".", this3);
318
349
  var this4 = file.id;
319
350
  var s2 = "/";
320
- s2 = Path.posix.normalize(("/".length > 1 && SourceId_Fields_.startsWithSlash("/")) ? HxOverrides.substr("/", 1, null) : "/");
321
- s2 = StringTools.replace(s2, "\\", "/");
322
- var root2 = (SourceId_Fields_.startsWithSlash(s2)) ? s2 : "/" + s2;
351
+ var str2 = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
352
+ if (str2.length > 0) {
353
+ str2 = Path.posix.normalize(str2);
354
+ str2 = StringTools.replace(str2, "\\", "/");
355
+ };
356
+ s2 = str2;
357
+ var root2 = (HxOverrides.cca(s2, 0) == 47) ? s2 : "/" + s2;
323
358
  if (this4.charAt(0) != "/") {
324
359
  throw new Error("Badly formed SourceId.");
325
360
  };
@@ -1,7 +1,6 @@
1
1
  import {Router} from "../route/Router.js"
2
2
  import {Route} from "../route/Route.js"
3
3
  import {RouteType_Fields_} from "./RouteType.js"
4
- import {SourceId_Fields_} from "../SourceId.js"
5
4
  import * as Path from "path"
6
5
  import {Register} from "../../genes/Register.js"
7
6
  import {StringTools} from "../../StringTools.js"
@@ -34,9 +33,13 @@ class RoutePathType_Fields_ {
34
33
  throw new Error("RoutePath element should have at most 3 entries `[serveId, route, filter]`.");
35
34
  };
36
35
  var s = item[0];
37
- s = Path.posix.normalize((s.length > 1 && SourceId_Fields_.startsWithSlash(s)) ? HxOverrides.substr(s, 1, null) : s);
38
- s = StringTools.replace(s, "\\", "/");
39
- var tmp = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
36
+ var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
37
+ if (str.length > 0) {
38
+ str = Path.posix.normalize(str);
39
+ str = StringTools.replace(str, "\\", "/");
40
+ };
41
+ s = str;
42
+ var tmp = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
40
43
  var _g3 = item.slice(1);
41
44
  _g.push({"routeUnder": tmp, "route": (_g3.length == 1) ? (((item[1]) instanceof Route)) ? item[1] : RouteType_Fields_.makeRoute([_g3]) : RouteType_Fields_.makeRoute([_g3])});
42
45
  };