whet 0.0.18 → 0.0.20

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,11 +1,9 @@
1
1
  import {Cache} from "./Cache.js"
2
- import {SourceId} from "../SourceId.js"
3
2
  import {SourceHash} from "../SourceHash.js"
4
3
  import {Log} from "../Log.js"
5
4
  import * as Path from "path"
6
5
  import {Boot} from "../../js/Boot.js"
7
6
  import {Register} from "../../genes/Register.js"
8
- import {StringTools} from "../../StringTools.js"
9
7
  import {Std} from "../../Std.js"
10
8
  import {Lambda} from "../../Lambda.js"
11
9
  import {HxOverrides} from "../../HxOverrides.js"
@@ -15,7 +13,7 @@ const $global = Register.$global
15
13
  export const BaseCache = Register.global("$hxClasses")["whet.cache.BaseCache"] =
16
14
  class BaseCache extends Register.inherits() {
17
15
  new(rootDir, cache) {
18
- if (HxOverrides.cca(rootDir, rootDir.length - 1) != 47) {
16
+ if (!(rootDir.length == 0 || rootDir.charCodeAt(rootDir.length - 1) == 47)) {
19
17
  throw new Error("Root dir is a not a dir.");
20
18
  };
21
19
  this.rootDir = rootDir;
@@ -23,74 +21,76 @@ class BaseCache extends Register.inherits() {
23
21
  }
24
22
  get(stone, durability, check) {
25
23
  var _gthis = this;
26
- return stone.finalMaybeHash().then(function (hash) {
27
- if (hash == null) {
28
- Log.log(20, ...["Generating source, because it does not supply a hash.", {"stone": stone, "cache": _gthis}]);
29
- };
30
- if (hash == null) {
31
- return stone.generateSource(null).then(function (generatedSource) {
32
- return {"generatedSource": generatedSource, "hash": generatedSource.hash};
33
- });
34
- } else {
35
- Log.log(20, ...["Stone provided hash.", {"stone": stone, "hash": SourceHash.toHex(hash)}]);
36
- return Promise.resolve({"generatedSource": null, "hash": hash});
37
- };
38
- }).then(function (data) {
39
- var generatedSource = data.generatedSource;
40
- var hash = data.hash;
41
- var values = _gthis.cache.get(_gthis.key(stone));
42
- var ageCount = function (val) {
43
- return Lambda.count(values, function (v) {
44
- if (v != val) {
45
- return v.ctime > val.ctime;
46
- } else {
47
- return false;
48
- };
49
- });
50
- };
51
- var value = null;
52
- if (values != null && values.length > 0) {
53
- value = Lambda.find(values, function (v) {
54
- return SourceHash.equals(v.hash, hash);
55
- });
56
- if (value != null && check._hx_index == 2 && !_gthis.shouldKeep(stone, value, durability, function (v) {
57
- return 0;
58
- }, ageCount)) {
59
- _gthis.remove(stone, value);
60
- value = null;
24
+ return stone.acquire(function () {
25
+ return stone.finalMaybeHash().then(function (hash) {
26
+ if (hash == null) {
27
+ Log.log(20, ...["Generating source, because it does not supply a hash.", {"stone": stone, "cache": _gthis}]);
61
28
  };
62
- if (value != null) {
63
- _gthis.setRecentUseOrder(values, value);
29
+ if (hash == null) {
30
+ return stone.generateSource(null).then(function (generatedSource) {
31
+ return {"generatedSource": generatedSource, "hash": generatedSource.hash};
32
+ });
33
+ } else {
34
+ Log.log(20, ...["Stone provided hash.", {"stone": stone, "hash": SourceHash.toHex(hash)}]);
35
+ return Promise.resolve({"generatedSource": null, "hash": hash});
64
36
  };
65
- };
66
- return ((value != null) ? _gthis.source(stone, value) : Promise.resolve(null)).then(function (src) {
67
- if (src == null) {
68
- Log.log(10, ...["Not cached.", {"stone": stone, "cache": _gthis}]);
69
- return ((value != null) ? _gthis.remove(stone, value) : Promise.resolve(null)).then(function (_) {
70
- if (check._hx_index == 1) {
71
- _gthis.checkDurability(stone, values, durability, function (v) {
72
- return values.indexOf(v) + 1;
73
- }, function (v) {
74
- return ageCount(v) + 1;
75
- });
37
+ }).then(function (data) {
38
+ var generatedSource = data.generatedSource;
39
+ var hash = data.hash;
40
+ var values = _gthis.cache.get(_gthis.key(stone));
41
+ var ageCount = function (val) {
42
+ return Lambda.count(values, function (v) {
43
+ if (v != val) {
44
+ return v.ctime > val.ctime;
45
+ } else {
46
+ return false;
76
47
  };
77
- return ((generatedSource != null) ? Promise.resolve(generatedSource) : stone.generateSource(hash)).then(function (src) {
78
- return _gthis.set(src);
79
- }).then(function (val) {
80
- return _gthis.source(stone, val);
81
- });
82
48
  });
83
- } else {
84
- Log.log(10, ...["Found in cache", {"stone": stone, "cache": _gthis}]);
85
- return Promise.resolve(src);
86
49
  };
87
- }).then(function (src) {
88
- if ((check == null) ? true : check._hx_index == 0) {
89
- _gthis.checkDurability(stone, values, durability, function (v) {
90
- return values.indexOf(v);
91
- }, ageCount);
50
+ var value = null;
51
+ if (values != null && values.length > 0) {
52
+ value = Lambda.find(values, function (v) {
53
+ return SourceHash.equals(v.hash, hash);
54
+ });
55
+ if (value != null && check._hx_index == 2 && !_gthis.shouldKeep(stone, value, durability, function (v) {
56
+ return 0;
57
+ }, ageCount)) {
58
+ _gthis.remove(stone, value);
59
+ value = null;
60
+ };
61
+ if (value != null) {
62
+ _gthis.setRecentUseOrder(values, value);
63
+ };
92
64
  };
93
- return src;
65
+ return ((value != null) ? _gthis.source(stone, value) : Promise.resolve(null)).then(function (src) {
66
+ if (src == null) {
67
+ Log.log(10, ...["Not cached.", {"stone": stone, "cache": _gthis}]);
68
+ return ((value != null) ? _gthis.remove(stone, value) : Promise.resolve(null)).then(function (_) {
69
+ if (check._hx_index == 1) {
70
+ _gthis.checkDurability(stone, values, durability, function (v) {
71
+ return values.indexOf(v) + 1;
72
+ }, function (v) {
73
+ return ageCount(v) + 1;
74
+ });
75
+ };
76
+ return ((generatedSource != null) ? Promise.resolve(generatedSource) : stone.generateSource(hash)).then(function (src) {
77
+ return _gthis.set(src);
78
+ }).then(function (val) {
79
+ return _gthis.source(stone, val);
80
+ });
81
+ });
82
+ } else {
83
+ Log.log(10, ...["Found in cache", {"stone": stone, "cache": _gthis}]);
84
+ return Promise.resolve(src);
85
+ };
86
+ }).then(function (src) {
87
+ if ((check == null) ? true : check._hx_index == 0) {
88
+ _gthis.checkDurability(stone, values, durability, function (v) {
89
+ return values.indexOf(v);
90
+ }, ageCount);
91
+ };
92
+ return src;
93
+ });
94
94
  });
95
95
  });
96
96
  }
@@ -124,31 +124,16 @@ class BaseCache extends Register.inherits() {
124
124
  };
125
125
  var filenames = this.getExistingDirs(stone);
126
126
  var maxNum = (filenames != null) ? Lambda.fold(filenames, function (fn, num) {
127
- var s = fn.substring(0, fn.lastIndexOf("/") + 1);
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;
135
- var root = _gthis.rootDir;
136
- if (this1.charAt(0) != "/") {
137
- throw new Error("Badly formed SourceId.");
138
- };
139
- var parts = Path.posix.join(".", root, ".", this1).split("/");
127
+ var dir = fn.substring(0, fn.lastIndexOf("/") + 1);
128
+ var parts = Path.posix.join(".", _gthis.rootDir, ".", (dir.length == 0) ? "./" : dir).split("/");
140
129
  var name = (parts.length > 1) ? parts[parts.length - 2] : "";
141
130
  return Math.max(num, (name.charAt(0) == "v") ? Std.parseInt(HxOverrides.substr(name, 1, null)) : 0);
142
131
  }, 0) : 0;
143
132
  ++maxNum;
144
- var s = "v" + maxNum + "/";
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, "\\", "/");
133
+ if (!(baseDir.length == 0 || baseDir.charCodeAt(baseDir.length - 1) == 47)) {
134
+ throw new Error("\"" + baseDir + "\" is not a directory.");
149
135
  };
150
- s = str;
151
- return SourceId.getPutInDir((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, baseDir);
136
+ return Path.posix.join(baseDir, "v" + maxNum + "/");
152
137
  }
153
138
  checkDurability(stone, values, durability, useIndex, ageIndex) {
154
139
  Log.log(20, ...["Checking durability.", {"stone": stone, "durability": Std.string(durability)}]);
@@ -1,12 +1,10 @@
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} from "../SourceId.js"
4
+ import {RootDir} 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"
8
- import {StringTools} from "../../StringTools.js"
9
- import {HxOverrides} from "../../HxOverrides.js"
10
8
 
11
9
  const $global = Register.$global
12
10
 
@@ -27,8 +25,10 @@ class CacheManager extends Register.inherits() {
27
25
  var _g = stone.cacheStrategy;
28
26
  switch (_g._hx_index) {
29
27
  case 0:
30
- return stone.finalMaybeHash().then(function (hash) {
31
- return stone.generateSource(hash);
28
+ return stone.acquire(function () {
29
+ return stone.finalMaybeHash().then(function (hash) {
30
+ return stone.generateSource(hash);
31
+ });
32
32
  });
33
33
  break
34
34
  case 1:
@@ -54,8 +54,10 @@ class CacheManager extends Register.inherits() {
54
54
  Log.log(10, ...["Re-generating cached stone.", {"stone": stone}]);
55
55
  switch (stone.cacheStrategy._hx_index) {
56
56
  case 0:
57
- return stone.finalMaybeHash().then(function (hash) {
58
- return stone.generateSource(hash);
57
+ return stone.acquire(function () {
58
+ return stone.finalMaybeHash().then(function (hash) {
59
+ return stone.generateSource(hash);
60
+ });
59
61
  });
60
62
  break
61
63
  case 1:
@@ -77,14 +79,7 @@ class CacheManager extends Register.inherits() {
77
79
  * The path is not reserved. Caching depends on stone's `cacheStrategy` and success of source generation.
78
80
  */
79
81
  getDir(stone, hash) {
80
- var s = stone.id + "/";
81
- var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
82
- if (str.length > 0) {
83
- str = Path.posix.normalize(str);
84
- str = StringTools.replace(str, "\\", "/");
85
- };
86
- s = str;
87
- var baseDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
82
+ var baseDir = stone.id + "/";
88
83
  var tmp;
89
84
  switch (stone.cacheStrategy._hx_index) {
90
85
  case 0:
@@ -98,23 +93,15 @@ class CacheManager extends Register.inherits() {
98
93
 
99
94
  };
100
95
  if (tmp) {
101
- var s = ".temp/";
102
- var str = (".temp/".length > 1 && HxOverrides.cca(".temp/", 0) == 47) ? ".temp/".substring(1) : ".temp/";
103
- if (str.length > 0) {
104
- str = Path.posix.normalize(str);
105
- str = StringTools.replace(str, "\\", "/");
96
+ if (!(".temp/".length == 0 || ".temp/".charCodeAt(".temp/".length - 1) == 47)) {
97
+ throw new Error("\"" + ".temp/" + "\" is not a directory.");
106
98
  };
107
- s = str;
108
- baseDir = SourceId.getPutInDir(baseDir, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
99
+ baseDir = Path.posix.join(".temp/", baseDir);
109
100
  };
110
- var s = ".whet/";
111
- var str = (".whet/".length > 1 && HxOverrides.cca(".whet/", 0) == 47) ? ".whet/".substring(1) : ".whet/";
112
- if (str.length > 0) {
113
- str = Path.posix.normalize(str);
114
- str = StringTools.replace(str, "\\", "/");
101
+ if (!(".whet/".length == 0 || ".whet/".charCodeAt(".whet/".length - 1) == 47)) {
102
+ throw new Error("\"" + ".whet/" + "\" is not a directory.");
115
103
  };
116
- s = str;
117
- baseDir = SourceId.getPutInDir(baseDir, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
104
+ baseDir = Path.posix.join(".whet/", baseDir);
118
105
  var id;
119
106
  var _g = stone.cacheStrategy;
120
107
  switch (_g._hx_index) {
@@ -129,14 +116,8 @@ class CacheManager extends Register.inherits() {
129
116
  break
130
117
  case 3:
131
118
  var _g1 = _g.path;
132
- var s = _g1.substring(0, _g1.lastIndexOf("/") + 1);
133
- var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
134
- if (str.length > 0) {
135
- str = Path.posix.normalize(str);
136
- str = StringTools.replace(str, "\\", "/");
137
- };
138
- s = str;
139
- id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
119
+ var dir = _g1.substring(0, _g1.lastIndexOf("/") + 1);
120
+ id = (dir.length == 0) ? "./" : dir;
140
121
  break
141
122
 
142
123
  };
@@ -7,7 +7,6 @@ import * as Path from "path"
7
7
  import {StringMap} from "../../haxe/ds/StringMap.js"
8
8
  import {Register} from "../../genes/Register.js"
9
9
  import * as Fs from "fs"
10
- import {StringTools} from "../../StringTools.js"
11
10
  import {Reflect as Reflect__1} from "../../Reflect.js"
12
11
  import {Lambda} from "../../Lambda.js"
13
12
  import {HxOverrides} from "../../HxOverrides.js"
@@ -19,18 +18,7 @@ class FileCache extends Register.inherits(BaseCache) {
19
18
  new(rootDir) {
20
19
  this.flushQueued = false;
21
20
  super.new(rootDir, new StringMap());
22
- var s = ".whet/cache.json";
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;
30
- if (this1.charAt(0) != "/") {
31
- throw new Error("Badly formed SourceId.");
32
- };
33
- this.dbFile = Path.posix.join(".", rootDir, ".", this1);
21
+ this.dbFile = Path.posix.join(".", rootDir, ".", ".whet/cache.json");
34
22
  try {
35
23
  var db = JSON.parse(Fs.readFileSync(this.dbFile, {"encoding": "utf-8"}));
36
24
  var _g_keys = Reflect__1.fields(db);
@@ -46,39 +34,16 @@ class FileCache extends Register.inherits(BaseCache) {
46
34
  ++_g1;
47
35
  var tmp = SourceHash.fromHex(val.hash);
48
36
  var val1 = val.ctime;
49
- var s = val.baseDir;
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;
37
+ var val2 = val.baseDir;
57
38
  var _g2 = [];
58
39
  var _g3 = 0;
59
40
  var _g4 = val.files;
60
41
  while (_g3 < _g4.length) {
61
42
  var file = _g4[_g3];
62
43
  ++_g3;
63
- var tmp2 = SourceHash.fromHex(file.fileHash);
64
- var s1 = file.filePath;
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;
72
- var s2 = file.id;
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});
44
+ _g2.push({"fileHash": SourceHash.fromHex(file.fileHash), "filePath": file.filePath, "id": file.id});
80
45
  };
81
- _g.push({"hash": tmp, "ctime": val1, "baseDir": tmp1, "files": _g2});
46
+ _g.push({"hash": tmp, "ctime": val1, "baseDir": val2, "files": _g2});
82
47
  };
83
48
  this1.inst.set(key, _g);
84
49
  };
@@ -93,18 +58,7 @@ class FileCache extends Register.inherits(BaseCache) {
93
58
  var _g = source.origin.cacheStrategy;
94
59
  if (_g._hx_index == 3) {
95
60
  var _g1 = _g.path;
96
- if (source.data.length == 1) {
97
- var s = _g1.substring(_g1.lastIndexOf("/"));
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;
105
- } else {
106
- idOverride = null;
107
- };
61
+ idOverride = (source.data.length == 1) ? _g1.substring(_g1.lastIndexOf("/") + 1) : null;
108
62
  } else {
109
63
  idOverride = null;
110
64
  };
@@ -130,18 +84,11 @@ class FileCache extends Register.inherits(BaseCache) {
130
84
  if (_g._hx_index == 3) {
131
85
  var _g1 = _g.path;
132
86
  var invalidPath;
133
- if (value.files.length == 1 && HxOverrides.cca(_g1, _g1.length - 1) != 47) {
87
+ if (value.files.length == 1 && !(_g1.length == 0 || _g1.charCodeAt(_g1.length - 1) == 47)) {
134
88
  invalidPath = value.files[0].filePath != _g1;
135
89
  } else {
136
- var value1 = value.baseDir;
137
- var s = _g1.substring(0, _g1.lastIndexOf("/") + 1);
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);
90
+ var dir = _g1.substring(0, _g1.lastIndexOf("/") + 1);
91
+ invalidPath = value.baseDir != ((dir.length == 0) ? "./" : dir);
145
92
  };
146
93
  if (invalidPath) {
147
94
  return Promise.resolve(null);
@@ -152,27 +99,30 @@ class FileCache extends Register.inherits(BaseCache) {
152
99
  var _g2 = value.files;
153
100
  while (_g1 < _g2.length) _g.push(new Promise((function (file) {
154
101
  return function (res, rej) {
155
- var this1 = file[0].filePath;
156
- var root = _gthis.rootDir;
157
- if (this1.charAt(0) != "/") {
158
- throw new Error("Badly formed SourceId.");
159
- };
160
- var path = Path.posix.join(".", root, ".", this1);
102
+ var path = Path.posix.join(".", _gthis.rootDir, ".", file[0].filePath);
161
103
  SourceData.fromFile(file[0].id, path, file[0].filePath).then((function (file) {
162
104
  return function (sourceData) {
163
105
  if (sourceData == null || !stone.ignoreFileHash && !SourceHash.equals(sourceData.hash, file[0].fileHash)) {
164
- rej("Wrong hash.");
106
+ rej("Invalid.");
165
107
  } else {
166
108
  res(sourceData);
167
109
  };
168
110
  };
169
- })(file));
111
+ })(file), (function () {
112
+ return function (err) {
113
+ if (((err) instanceof Error) && err.code == "ENOENT") {
114
+ rej("Invalid.");
115
+ } else {
116
+ rej(err);
117
+ };
118
+ };
119
+ })());
170
120
  };
171
121
  })([_g2[_g1++]])));
172
122
  return Promise.all(_g).then(function (data) {
173
123
  return new Source(data, value.hash, stone, value.ctime);
174
124
  }, function (rejected) {
175
- if (rejected == "Wrong hash.") {
125
+ if (rejected == "Invalid.") {
176
126
  return null;
177
127
  } else {
178
128
  throw rejected;
@@ -218,18 +168,8 @@ class FileCache extends Register.inherits(BaseCache) {
218
168
  var _g2 = value.files;
219
169
  while (_g1 < _g2.length) _g.push(new Promise((function (file) {
220
170
  return function (res, rej) {
221
- var this1 = file[0].filePath;
222
- var root = _gthis.rootDir;
223
- if (this1.charAt(0) != "/") {
224
- throw new Error("Badly formed SourceId.");
225
- };
226
- Log.log(20, ...["Deleting file.", {"path": Path.posix.join(".", root, ".", this1)}]);
227
- var this1 = file[0].filePath;
228
- var root = _gthis.rootDir;
229
- if (this1.charAt(0) != "/") {
230
- throw new Error("Badly formed SourceId.");
231
- };
232
- Fs.unlink(Path.posix.join(".", root, ".", this1), (function (file) {
171
+ Log.log(20, ...["Deleting file.", {"path": Path.posix.join(".", _gthis.rootDir, ".", file[0].filePath)}]);
172
+ Fs.unlink(Path.posix.join(".", _gthis.rootDir, ".", file[0].filePath), (function (file) {
233
173
  return function (err) {
234
174
  if (err != null) {
235
175
  Log.log(50, ...["Error deleting file.", {"file": file[0], "error": err}]);
@@ -243,34 +183,14 @@ class FileCache extends Register.inherits(BaseCache) {
243
183
  };
244
184
  }).then(function (_) {
245
185
  return new Promise(function (res, rej) {
246
- var this1 = value.baseDir;
247
- var root = _gthis.rootDir;
248
- if (this1.charAt(0) != "/") {
249
- throw new Error("Badly formed SourceId.");
250
- };
251
- Fs.readdir(Path.posix.join(".", root, ".", this1), function (err, files) {
186
+ Fs.readdir(Path.posix.join(".", _gthis.rootDir, ".", value.baseDir), function (err, files) {
252
187
  if (err != null) {
253
- var this1 = value.baseDir;
254
- var root = _gthis.rootDir;
255
- if (this1.charAt(0) != "/") {
256
- throw new Error("Badly formed SourceId.");
257
- };
258
- Log.log(50, ...["Error reading directory", {"dir": Path.posix.join(".", root, ".", this1), "error": err}]);
188
+ Log.log(50, ...["Error reading directory", {"dir": Path.posix.join(".", _gthis.rootDir, ".", value.baseDir), "error": err}]);
259
189
  res(null);
260
190
  } else if (files.length == 0) {
261
- var this1 = value.baseDir;
262
- var root = _gthis.rootDir;
263
- if (this1.charAt(0) != "/") {
264
- throw new Error("Badly formed SourceId.");
265
- };
266
- Fs.rmdir(Path.posix.join(".", root, ".", this1), function (err) {
191
+ Fs.rmdir(Path.posix.join(".", _gthis.rootDir, ".", value.baseDir), function (err) {
267
192
  if (err != null) {
268
- var this1 = value.baseDir;
269
- var root = _gthis.rootDir;
270
- if (this1.charAt(0) != "/") {
271
- throw new Error("Badly formed SourceId.");
272
- };
273
- Log.log(50, ...["Error removing directory.", {"dir": Path.posix.join(".", root, ".", this1), "error": err}]);
193
+ Log.log(50, ...["Error removing directory.", {"dir": Path.posix.join(".", _gthis.rootDir, ".", value.baseDir), "error": err}]);
274
194
  };
275
195
  res(null);
276
196
  });
@@ -313,52 +233,14 @@ class FileCache extends Register.inherits(BaseCache) {
313
233
  var tmp = SourceHash.toHex(val.hash);
314
234
  var val1 = val.ctime;
315
235
  var tmp1 = HxOverrides.dateStr(new Date(val.ctime * 1000));
316
- var this2 = val.baseDir;
317
- var 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;
325
- if (this2.charAt(0) != "/") {
326
- throw new Error("Badly formed SourceId.");
327
- };
328
- var tmp2 = Path.posix.join(".", root, ".", this2);
236
+ var tmp2 = Path.posix.join(".", "./", ".", val.baseDir);
329
237
  var _g2 = [];
330
238
  var _g3 = 0;
331
239
  var _g4 = val.files;
332
240
  while (_g3 < _g4.length) {
333
241
  var file = _g4[_g3];
334
242
  ++_g3;
335
- var tmp3 = SourceHash.toHex(file.fileHash);
336
- var this3 = file.filePath;
337
- var 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;
345
- if (this3.charAt(0) != "/") {
346
- throw new Error("Badly formed SourceId.");
347
- };
348
- var tmp4 = Path.posix.join(".", root1, ".", this3);
349
- var this4 = file.id;
350
- var 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;
358
- if (this4.charAt(0) != "/") {
359
- throw new Error("Badly formed SourceId.");
360
- };
361
- _g2.push({"fileHash": tmp3, "filePath": tmp4, "id": Path.posix.join(".", root2, ".", this4)});
243
+ _g2.push({"fileHash": SourceHash.toHex(file.fileHash), "filePath": Path.posix.join(".", "./", ".", file.filePath), "id": Path.posix.join(".", "./", ".", file.id)});
362
244
  };
363
245
  _g.push({"hash": tmp, "ctime": val1, "ctimePretty": tmp1, "baseDir": tmp2, "files": _g2});
364
246
  };
@@ -2,11 +2,8 @@ import {Files} from "../stones/Files.js"
2
2
  import {Router} from "../route/Router.js"
3
3
  import {MinimatchType_Fields_} from "./MinimatchType.js"
4
4
  import {Stone} from "../Stone.js"
5
- import * as Path from "path"
6
5
  import Minimatch from "minimatch"
7
6
  import {Register} from "../../genes/Register.js"
8
- import {StringTools} from "../../StringTools.js"
9
- import {HxOverrides} from "../../HxOverrides.js"
10
7
 
11
8
  const $global = Register.$global
12
9
 
@@ -14,14 +11,7 @@ export const RoutePathType_Fields_ = Register.global("$hxClasses")["whet.magic._
14
11
  class RoutePathType_Fields_ {
15
12
  static makeRoutePath(routerPathType) {
16
13
  if (((routerPathType) instanceof Router) || ((routerPathType) instanceof Stone) || typeof(routerPathType) == "string") {
17
- var s = "/";
18
- var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
19
- if (str.length > 0) {
20
- str = Path.posix.normalize(str);
21
- str = StringTools.replace(str, "\\", "/");
22
- };
23
- s = str;
24
- return [{"routeUnder": (HxOverrides.cca(s, 0) == 47) ? s : "/" + s, "source": (typeof(routerPathType) == "string") ? new Files({"paths": [routerPathType]}) : routerPathType, "filter": null, "extractDirs": null}];
14
+ return [{"routeUnder": "", "source": (typeof(routerPathType) == "string") ? new Files({"paths": [routerPathType]}) : routerPathType, "filter": null, "extractDirs": null}];
25
15
  };
26
16
  if (!((routerPathType) instanceof Array)) {
27
17
  throw new Error("RoutePath should be a Stone, Router, or an array.");
@@ -33,14 +23,7 @@ class RoutePathType_Fields_ {
33
23
  var item = _g2[_g1];
34
24
  ++_g1;
35
25
  if (((item) instanceof Router) || ((item) instanceof Stone) || typeof(item) == "string") {
36
- var s = "/";
37
- var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
38
- if (str.length > 0) {
39
- str = Path.posix.normalize(str);
40
- str = StringTools.replace(str, "\\", "/");
41
- };
42
- s = str;
43
- _g.push({"routeUnder": (HxOverrides.cca(s, 0) == 47) ? s : "/" + s, "source": (typeof(item) == "string") ? new Files({"paths": [item]}) : item, "filter": null, "extractDirs": null});
26
+ _g.push({"routeUnder": "", "source": (typeof(item) == "string") ? new Files({"paths": [item]}) : item, "filter": null, "extractDirs": null});
44
27
  } else if (((item) instanceof Array)) {
45
28
  var inner = item;
46
29
  if (typeof(inner[0]) != "string") {
@@ -52,41 +35,20 @@ class RoutePathType_Fields_ {
52
35
  var tmp;
53
36
  switch (inner.length) {
54
37
  case 2:
55
- var s1 = inner[0];
56
- var str1 = (s1.length > 1 && HxOverrides.cca(s1, 0) == 47) ? s1.substring(1) : s1;
57
- if (str1.length > 0) {
58
- str1 = Path.posix.normalize(str1);
59
- str1 = StringTools.replace(str1, "\\", "/");
60
- };
61
- s1 = str1;
62
38
  var src = inner[1];
63
- tmp = {"routeUnder": (HxOverrides.cca(s1, 0) == 47) ? s1 : "/" + s1, "source": (typeof(src) == "string") ? new Files({"paths": [src]}) : src, "filter": null, "extractDirs": null};
39
+ var tmp1 = (typeof(src) == "string") ? new Files({"paths": [src]}) : src;
40
+ tmp = {"routeUnder": inner[0], "source": tmp1, "filter": null, "extractDirs": null};
64
41
  break
65
42
  case 3:
66
- var s2 = inner[0];
67
- var str2 = (s2.length > 1 && HxOverrides.cca(s2, 0) == 47) ? s2.substring(1) : s2;
68
- if (str2.length > 0) {
69
- str2 = Path.posix.normalize(str2);
70
- str2 = StringTools.replace(str2, "\\", "/");
71
- };
72
- s2 = str2;
73
- var tmp1 = (HxOverrides.cca(s2, 0) == 47) ? s2 : "/" + s2;
74
43
  var src1 = inner[1];
75
44
  var tmp2 = (typeof(src1) == "string") ? new Files({"paths": [src1]}) : src1;
76
45
  if (!(typeof(inner[2]) == "string" || inner[2] instanceof Minimatch)) {
77
46
  throw new Error("Third" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
78
47
  };
79
- tmp = {"routeUnder": tmp1, "source": tmp2, "filter": MinimatchType_Fields_.makeMinimatch(inner[2]), "extractDirs": null};
48
+ var tmp3 = MinimatchType_Fields_.makeMinimatch(inner[2]);
49
+ tmp = {"routeUnder": inner[0], "source": tmp2, "filter": tmp3, "extractDirs": null};
80
50
  break
81
51
  case 4:
82
- var s3 = inner[0];
83
- var str3 = (s3.length > 1 && HxOverrides.cca(s3, 0) == 47) ? s3.substring(1) : s3;
84
- if (str3.length > 0) {
85
- str3 = Path.posix.normalize(str3);
86
- str3 = StringTools.replace(str3, "\\", "/");
87
- };
88
- s3 = str3;
89
- var tmp3 = (HxOverrides.cca(s3, 0) == 47) ? s3 : "/" + s3;
90
52
  var src2 = inner[1];
91
53
  var tmp4 = (typeof(src2) == "string") ? new Files({"paths": [src2]}) : src2;
92
54
  if (!(typeof(inner[2]) == "string" || inner[2] instanceof Minimatch)) {
@@ -96,7 +58,8 @@ class RoutePathType_Fields_ {
96
58
  if (!(typeof(inner[3]) == "string" || inner[3] instanceof Minimatch)) {
97
59
  throw new Error("Fourth" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
98
60
  };
99
- tmp = {"routeUnder": tmp3, "source": tmp4, "filter": tmp5, "extractDirs": MinimatchType_Fields_.makeMinimatch(inner[3])};
61
+ var tmp6 = MinimatchType_Fields_.makeMinimatch(inner[3]);
62
+ tmp = {"routeUnder": inner[0], "source": tmp4, "filter": tmp5, "extractDirs": tmp6};
100
63
  break
101
64
  default:
102
65
  throw new Error("Invalid array for a RoutePath element.");