whet 0.0.30 → 0.0.31

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.
@@ -15,6 +15,20 @@ export declare class SourceHash {
15
15
  static fromFiles(paths: MaybeArray<string>, filter?: null | ((arg0: string) => boolean), recursive?: boolean): Promise<SourceHash>
16
16
  static fromBytes(data: Buffer): SourceHash
17
17
  static fromString(data: string): SourceHash
18
+
19
+ /**
20
+ * Converts `obj` to string via JSON.stringify, defaults to 'null' if undefined to prevent
21
+ * errors. The string is then converted to hash. See also `fromConfig`.
22
+ */
23
+ static fromStringify(obj: any): SourceHash
24
+
25
+ /**
26
+ * Convert a Stone config into hash by ignoring the base `StoneConfig` fields
27
+ * and anything inside `ignoreList`, getting hash of `Stone` and `Router` instances,
28
+ * and applying `fromStringify` on the rest.
29
+ * Only checks keys at root level, no deep inspection is done.
30
+ */
31
+ static fromConfig(obj: {[key: string]: any}, ignoreList?: null | string[]): Promise<SourceHash>
18
32
  static equals(a: SourceHash, b: SourceHash): boolean
19
33
  static toHex(hash: SourceHash): string
20
34
  static fromHex(hex: string): SourceHash
@@ -1,9 +1,12 @@
1
+ import {Router} from "./route/Router.js"
1
2
  import {MaybeArray_Fields_} from "./magic/MaybeArray.js"
2
3
  import {Utils} from "./Utils.js"
4
+ import {Stone} from "./Stone.js"
3
5
  import {Register} from "../genes/Register.js"
4
6
  import * as Fs from "fs"
5
7
  import * as Crypto from "crypto"
6
8
  import {Buffer} from "buffer"
9
+ import {Reflect as Reflect__1} from "../Reflect.js"
7
10
 
8
11
  const $global = Register.$global
9
12
 
@@ -115,6 +118,50 @@ class SourceHash extends Register.inherits() {
115
118
  static fromString(data) {
116
119
  return SourceHash.fromBytes(Buffer.from(data));
117
120
  }
121
+
122
+ /**
123
+ * Converts `obj` to string via JSON.stringify, defaults to 'null' if undefined to prevent
124
+ * errors. The string is then converted to hash. See also `fromConfig`.
125
+ */
126
+ static fromStringify(obj) {
127
+ let tmp = JSON.stringify(obj);
128
+ return SourceHash.fromBytes(Buffer.from((tmp != null) ? tmp : "null"));
129
+ }
130
+
131
+ /**
132
+ * Convert a Stone config into hash by ignoring the base `StoneConfig` fields
133
+ * and anything inside `ignoreList`, getting hash of `Stone` and `Router` instances,
134
+ * and applying `fromStringify` on the rest.
135
+ * Only checks keys at root level, no deep inspection is done.
136
+ */
137
+ static fromConfig(obj, ignoreList) {
138
+ let keys = [];
139
+ let _g = [];
140
+ let _g_keys = Reflect__1.fields(obj);
141
+ let _g_index = 0;
142
+ while (_g_index < _g_keys.length) {
143
+ let key = _g_keys[_g_index++];
144
+ let _g_value = obj[key];
145
+ let tmp;
146
+ switch (key) {
147
+ case "cacheStrategy":case "dependencies":case "id":case "project":
148
+ continue;
149
+ break
150
+ default:
151
+ if (ignoreList != null && ignoreList.includes(key)) {
152
+ continue;
153
+ } else {
154
+ keys.push(key);
155
+ tmp = (((_g_value) instanceof Stone)) ? _g_value.getHash() : (((_g_value) instanceof Router)) ? _g_value.getHash() : SourceHash.fromStringify(_g_value);
156
+ };
157
+
158
+ };
159
+ _g.push(tmp);
160
+ };
161
+ return Promise.all(_g).then(function (hashes) {
162
+ return SourceHash.merge(...hashes);
163
+ });
164
+ }
118
165
  static equals(a, b) {
119
166
  if (a != null && b != null) {
120
167
  return a.bytes.compare(b.bytes) == 0;
@@ -156,8 +203,8 @@ class SourceHash extends Register.inherits() {
156
203
  }
157
204
 
158
205
 
159
- SourceHash.EMPTY = (function($this) {var $r0
206
+ Register.createStatic(SourceHash, "EMPTY", function () { return (function($this) {var $r0
160
207
  let bytes = Buffer.alloc(32);
161
208
 
162
209
  $r0 = new SourceHash(bytes)
163
- return $r0})(this)
210
+ return $r0})(this) })
package/bin/whet/Whet.js CHANGED
@@ -12,7 +12,7 @@ const $global = Register.$global
12
12
  export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
13
13
  class Whet_Fields_ {
14
14
  static main() {
15
- Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.29", "-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").option("--no-pretty", "disable pretty logging").exitOverride();
15
+ Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.31", "-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").option("--no-pretty", "disable pretty logging").exitOverride();
16
16
  try {
17
17
  Whet_Fields_.program.parse();
18
18
  }catch (_g) {
@@ -14,7 +14,7 @@ import {HxOverrides} from "../../HxOverrides.js"
14
14
  const $global = Register.$global
15
15
 
16
16
  export const FileCache = Register.global("$hxClasses")["whet.cache.FileCache"] =
17
- class FileCache extends Register.inherits(BaseCache) {
17
+ class FileCache extends Register.inherits(() => BaseCache, true) {
18
18
  new(rootDir) {
19
19
  this.flushQueued = false;
20
20
  super.new(rootDir, new StringMap());
@@ -5,7 +5,7 @@ import {Register} from "../../genes/Register.js"
5
5
  const $global = Register.$global
6
6
 
7
7
  export const MemoryCache = Register.global("$hxClasses")["whet.cache.MemoryCache"] =
8
- class MemoryCache extends Register.inherits(BaseCache) {
8
+ class MemoryCache extends Register.inherits(() => BaseCache, true) {
9
9
  new(rootDir) {
10
10
  super.new(rootDir, new ObjectMap());
11
11
  }
@@ -8,7 +8,7 @@ import {Register} from "../../genes/Register.js"
8
8
  const $global = Register.$global
9
9
 
10
10
  export const Files = Register.global("$hxClasses")["whet.stones.Files"] =
11
- class Files extends Register.inherits(Stone) {
11
+ class Files extends Register.inherits(() => Stone, true) {
12
12
  new(config) {
13
13
  super.new(config);
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whet",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "NodeJS based assets management and project tooling library.",
5
5
  "scripts": {
6
6
  "devinit": "npx dts2hx commander pino-pretty --modular --noLibWrap",
package/bin/List.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import {List as List__1} from "./haxe/ds/List"
2
-
3
- export type List<T> = List__1<T>