whet 0.0.33 → 0.1.0

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.
Files changed (81) hide show
  1. package/bin/Reflect.d.ts +31 -12
  2. package/bin/Reflect.js +46 -19
  3. package/bin/commander/LiteralUnion.d.ts +2 -0
  4. package/bin/commander/OptionValueSource.d.ts +2 -1
  5. package/bin/commander/OutputConfiguration.d.ts +3 -0
  6. package/bin/genes/Register.d.ts +2 -0
  7. package/bin/genes/Register.js +15 -11
  8. package/bin/genes/util/EsMap.js +2 -1
  9. package/bin/haxe/Exception.js +6 -1
  10. package/bin/haxe/ValueException.js +3 -2
  11. package/bin/haxe/ds/List.js +7 -2
  12. package/bin/haxe/ds/ObjectMap.js +2 -2
  13. package/bin/haxe/ds/StringMap.js +2 -2
  14. package/bin/haxe/exceptions/NotImplementedException.js +2 -2
  15. package/bin/haxe/exceptions/PosException.js +3 -2
  16. package/bin/haxe/io/Bytes.js +3 -1
  17. package/bin/haxe/io/BytesBuffer.js +6 -1
  18. package/bin/haxe/io/BytesOutput.js +2 -1
  19. package/bin/haxe/io/Output.js +1 -0
  20. package/bin/haxe/iterators/ArrayIterator.js +3 -1
  21. package/bin/haxe/zip/Writer.js +3 -1
  22. package/bin/js/lib/ConcatArray.d.ts +6 -0
  23. package/bin/js/lib/IRegExp.d.ts +53 -0
  24. package/bin/js/lib/IterableIterator.d.ts +8 -0
  25. package/bin/js/lib/IteratorResult.d.ts +2 -0
  26. package/bin/js/lib/IteratorReturnResult.d.ts +5 -0
  27. package/bin/js/lib/IteratorYieldResult.d.ts +5 -0
  28. package/bin/js/lib/RegExpExecArray.d.ts +137 -0
  29. package/bin/minimatch/MMRegExp.d.ts +55 -0
  30. package/bin/minimatch/MinimatchOptions.d.ts +102 -0
  31. package/bin/minimatch/ParseReturn.d.ts +2 -0
  32. package/bin/minimatch/ParseReturnFiltered.d.ts +2 -0
  33. package/bin/minimatch/Platform.d.ts +2 -0
  34. package/bin/pino_pretty/PrettyOptions.d.ts +2 -2
  35. package/bin/pino_pretty/default_/MessageFormatFunc.d.ts +1 -2
  36. package/bin/pino_pretty/default_/Prettifier.d.ts +2 -0
  37. package/bin/pino_pretty/pinopretty/PrettyOptions.d.ts +118 -0
  38. package/bin/sys/FileStat.d.ts +50 -0
  39. package/bin/whet/ConfigStore.d.ts +32 -0
  40. package/bin/whet/ConfigStore.js +342 -0
  41. package/bin/whet/Project.d.ts +39 -4
  42. package/bin/whet/Project.js +154 -3
  43. package/bin/whet/Source.d.ts +7 -1
  44. package/bin/whet/Source.js +40 -3
  45. package/bin/whet/SourceHash.js +18 -10
  46. package/bin/whet/Stone.d.ts +60 -9
  47. package/bin/whet/Stone.js +180 -18
  48. package/bin/whet/Whet.d.ts +0 -1
  49. package/bin/whet/Whet.js +23 -12
  50. package/bin/whet/cache/BaseCache.d.ts +23 -0
  51. package/bin/whet/cache/BaseCache.js +93 -1
  52. package/bin/whet/cache/CacheManager.d.ts +2 -0
  53. package/bin/whet/cache/CacheManager.js +38 -2
  54. package/bin/whet/cache/FileCache.d.ts +10 -2
  55. package/bin/whet/cache/FileCache.js +144 -42
  56. package/bin/whet/cache/HashCache.js +2 -1
  57. package/bin/whet/cache/MemoryCache.d.ts +3 -0
  58. package/bin/whet/cache/MemoryCache.js +53 -2
  59. package/bin/whet/magic/MinimatchType.d.ts +1 -1
  60. package/bin/whet/magic/MinimatchType.js +3 -3
  61. package/bin/whet/magic/RoutePathType.js +1 -1
  62. package/bin/whet/route/OutputFilterMatcher.js +2 -2
  63. package/bin/whet/route/RouteResult.d.ts +16 -0
  64. package/bin/whet/route/RouteResult.js +37 -4
  65. package/bin/whet/route/Router.d.ts +22 -1
  66. package/bin/whet/route/Router.js +121 -40
  67. package/bin/whet/stones/Files.d.ts +6 -1
  68. package/bin/whet/stones/Files.js +3 -2
  69. package/bin/whet/stones/JsonStone.d.ts +6 -1
  70. package/bin/whet/stones/JsonStone.js +3 -2
  71. package/bin/whet/stones/RemoteFile.d.ts +7 -2
  72. package/bin/whet/stones/RemoteFile.js +7 -4
  73. package/bin/whet/stones/Zip.d.ts +6 -1
  74. package/bin/whet/stones/Zip.js +2 -2
  75. package/bin/whet/stones/haxe/HaxeBuild.d.ts +7 -1
  76. package/bin/whet/stones/haxe/HaxeBuild.js +8 -6
  77. package/bin/whet/stones/haxe/Hxml.d.ts +7 -1
  78. package/bin/whet/stones/haxe/Hxml.js +7 -5
  79. package/bin/whet.d.ts +1 -2
  80. package/bin/whet.js +1 -1
  81. package/package.json +9 -10
@@ -0,0 +1,342 @@
1
+ import {Router} from "./route/Router.js"
2
+ import {Utils} from "./Utils.js"
3
+ import {Stone} from "./Stone.js"
4
+ import * as Path from "path"
5
+ import {Register} from "../genes/Register.js"
6
+ import * as Fs from "fs"
7
+ import {Reflect as Reflect__1} from "../Reflect.js"
8
+
9
+ const $global = Register.$global
10
+
11
+ export const ConfigStore = Register.global("$hxClasses")["whet.ConfigStore"] =
12
+ class ConfigStore extends Register.inherits() {
13
+ [Register.new](path) {
14
+ this.appliedPatches = new WeakMap();
15
+ this.baselines = new WeakMap();
16
+ this.loadPromise = null;
17
+ this.size = null;
18
+ this.mtimeMs = null;
19
+ this.persistedData = null;
20
+ this.data = null;
21
+ this.path = path;
22
+ }
23
+ ensureApplied(stone) {
24
+ let _gthis = this;
25
+ return this.reload().then(function (_) {
26
+ if (!_gthis.baselines.has(stone)) {
27
+ _gthis.captureBaseline(stone);
28
+ };
29
+ let entry = _gthis.getEntry(stone);
30
+ let lastApplied = _gthis.appliedPatches.get(stone);
31
+ if (entry == lastApplied) {
32
+ return null;
33
+ };
34
+ if (entry != null && lastApplied != null && JSON.stringify(entry) == JSON.stringify(lastApplied)) {
35
+ return null;
36
+ };
37
+ _gthis.applyPatch(stone);
38
+ return null;
39
+ });
40
+ }
41
+ setPatch(stone, patch) {
42
+ let _gthis = this;
43
+ return this.reload().then(function (_) {
44
+ if (_gthis.data == null) {
45
+ _gthis.data = {};
46
+ };
47
+ _gthis.data[stone.id] = patch;
48
+ return _gthis.writeFile();
49
+ }).then(function (_) {
50
+ _gthis.applyPatch(stone);
51
+ return null;
52
+ });
53
+ }
54
+ getEntryById(stoneId) {
55
+ if (this.data == null) {
56
+ return null;
57
+ };
58
+ return this.data[stoneId];
59
+ }
60
+ setEntry(stoneId, patch) {
61
+ if (this.data == null) {
62
+ this.data = {};
63
+ };
64
+ this.data[stoneId] = patch;
65
+ }
66
+ clearEntry(stoneId) {
67
+ if (this.data == null) {
68
+ return;
69
+ };
70
+ if (this.persistedData != null && Object.prototype.hasOwnProperty.call(this.persistedData, stoneId)) {
71
+ this.data[stoneId] = ConfigStore.deepClone(this.persistedData[stoneId]);
72
+ } else {
73
+ Reflect__1.deleteField(this.data, stoneId);
74
+ };
75
+ }
76
+ flush() {
77
+ return this.writeFile();
78
+ }
79
+ isDirty(stoneId) {
80
+ if (stoneId != null) {
81
+ let current = (this.data != null) ? this.data[stoneId] : null;
82
+ let persisted = (this.persistedData != null) ? this.persistedData[stoneId] : null;
83
+ if (current == persisted) {
84
+ return false;
85
+ };
86
+ if (current == null || persisted == null) {
87
+ return true;
88
+ };
89
+ return JSON.stringify(current) != JSON.stringify(persisted);
90
+ };
91
+ return ((this.data != null) ? JSON.stringify(this.data) : "{}") != ((this.persistedData != null) ? JSON.stringify(this.persistedData) : "{}");
92
+ }
93
+ reload() {
94
+ if (this.loadPromise != null) {
95
+ return this.loadPromise;
96
+ };
97
+ let _gthis = this;
98
+ this.loadPromise = this.doReload().then(function (result) {
99
+ _gthis.loadPromise = null;
100
+ return result;
101
+ })["catch"](function (e) {
102
+ _gthis.loadPromise = null;
103
+ return Promise.reject(e);
104
+ });
105
+ return this.loadPromise;
106
+ }
107
+ doReload() {
108
+ let _gthis = this;
109
+ return this.statFile().then(function (stats) {
110
+ if (stats == null) {
111
+ if (_gthis.data == null) {
112
+ _gthis.data = {};
113
+ _gthis.persistedData = {};
114
+ };
115
+ return Promise.resolve(null);
116
+ };
117
+ let newMtime = stats.mtimeMs;
118
+ let newSize = stats.size;
119
+ if (newMtime == _gthis.mtimeMs && newSize == _gthis.size) {
120
+ return Promise.resolve(null);
121
+ };
122
+ return _gthis.readAndParse().then(function (_) {
123
+ _gthis.mtimeMs = newMtime;
124
+ _gthis.size = newSize;
125
+ return null;
126
+ });
127
+ });
128
+ }
129
+ statFile() {
130
+ let _gthis = this;
131
+ return new Promise(function (res, rej) {
132
+ Fs.stat(_gthis.path, function (err, stats) {
133
+ if (err != null) {
134
+ let code = err.code;
135
+ if (code == "ENOENT") {
136
+ res(null);
137
+ } else {
138
+ rej(err);
139
+ };
140
+ } else {
141
+ res(stats);
142
+ };
143
+ });
144
+ });
145
+ }
146
+ readAndParse() {
147
+ let _gthis = this;
148
+ return new Promise(function (res, rej) {
149
+ Fs.readFile(_gthis.path, {"encoding": "utf-8"}, function (err, content) {
150
+ if (err != null) {
151
+ rej(err);
152
+ } else {
153
+ _gthis.data = JSON.parse(content);
154
+ _gthis.persistedData = ConfigStore.deepClone(_gthis.data);
155
+ res(null);
156
+ };
157
+ });
158
+ });
159
+ }
160
+ writeFile() {
161
+ let _gthis = this;
162
+ return Utils.ensureDirExist(Path.dirname(this.path)).then(function (_) {
163
+ let content = JSON.stringify(_gthis.data, null, " ");
164
+ return new Promise(function (res, rej) {
165
+ Fs.writeFile(_gthis.path, content, function (err) {
166
+ if (err != null) {
167
+ rej(err);
168
+ } else {
169
+ Fs.stat(_gthis.path, function (err, stats) {
170
+ if (err != null) {
171
+ rej(err);
172
+ } else {
173
+ _gthis.mtimeMs = stats.mtimeMs;
174
+ _gthis.size = stats.size;
175
+ _gthis.persistedData = ConfigStore.deepClone(_gthis.data);
176
+ res(null);
177
+ };
178
+ });
179
+ };
180
+ });
181
+ });
182
+ });
183
+ }
184
+ getEntry(stone) {
185
+ if (this.data == null) {
186
+ return null;
187
+ };
188
+ return this.data[stone.id];
189
+ }
190
+ captureBaseline(stone) {
191
+ let baseline = {};
192
+ let configObj = stone.config;
193
+ let _g_keys = Reflect__1.fields(configObj);
194
+ let _g_index = 0;
195
+ while (_g_index < _g_keys.length) {
196
+ let key = _g_keys[_g_index++];
197
+ let _g_value = configObj[key];
198
+ if (ConfigStore.BASE_CONFIG_KEYS.includes(key)) {
199
+ continue;
200
+ };
201
+ if (ConfigStore.isJsonSerializable(_g_value)) {
202
+ baseline[key] = ConfigStore.deepClone(_g_value);
203
+ };
204
+ };
205
+ this.baselines.set(stone, baseline);
206
+ }
207
+ applyPatch(stone) {
208
+ let baseline = this.baselines.get(stone);
209
+ if (baseline == null) {
210
+ return;
211
+ };
212
+ let entry = this.getEntry(stone);
213
+ let configObj = stone.config;
214
+ let _g_keys = Reflect__1.fields(baseline);
215
+ let _g_index = 0;
216
+ while (_g_index < _g_keys.length) {
217
+ let key = _g_keys[_g_index++];
218
+ let _g_value = baseline[key];
219
+ if (entry != null && Object.prototype.hasOwnProperty.call(entry, key)) {
220
+ configObj[key] = ConfigStore.deepMerge(ConfigStore.deepClone(_g_value), entry[key]);
221
+ } else {
222
+ configObj[key] = ConfigStore.deepClone(_g_value);
223
+ };
224
+ };
225
+ if (entry != null) {
226
+ let _g_keys = Reflect__1.fields(entry);
227
+ let _g_index = 0;
228
+ while (_g_index < _g_keys.length) {
229
+ let key = _g_keys[_g_index++];
230
+ let _g_value = entry[key];
231
+ if (!Object.prototype.hasOwnProperty.call(baseline, key)) {
232
+ configObj[key] = ConfigStore.deepClone(_g_value);
233
+ };
234
+ };
235
+ };
236
+ let prevApplied = this.appliedPatches.get(stone);
237
+ if (prevApplied != null) {
238
+ let _g_keys = Reflect__1.fields(prevApplied);
239
+ let _g_index = 0;
240
+ while (_g_index < _g_keys.length) {
241
+ let key = _g_keys[_g_index++];
242
+ if (!Object.prototype.hasOwnProperty.call(baseline, key) && (entry == null || !Object.prototype.hasOwnProperty.call(entry, key))) {
243
+ Reflect__1.deleteField(configObj, key);
244
+ };
245
+ };
246
+ };
247
+ this.appliedPatches.set(stone, (entry != null) ? ConfigStore.deepClone(entry) : null);
248
+ }
249
+ static isJsonSerializable(val) {
250
+ if (val == null) {
251
+ return true;
252
+ };
253
+ if (((val) instanceof Stone)) {
254
+ return false;
255
+ };
256
+ if (((val) instanceof Router)) {
257
+ return false;
258
+ };
259
+ if (typeof val === "function") {
260
+ return false;
261
+ };
262
+ return true;
263
+ }
264
+ static deepClone(val) {
265
+ if (val == null) {
266
+ return null;
267
+ };
268
+ if (!ConfigStore.isJsonSerializable(val)) {
269
+ return null;
270
+ };
271
+ if (((val) instanceof Array)) {
272
+ let arr = val;
273
+ let result = new Array(arr.length);
274
+ let _g = 0;
275
+ let _g1 = arr.length;
276
+ while (_g < _g1) {
277
+ let i = _g++;
278
+ result[i] = ConfigStore.deepClone(arr[i]);
279
+ };
280
+ return result;
281
+ };
282
+ if (typeof val === "object") {
283
+ let obj = val;
284
+ let result = {};
285
+ let _g_keys = Reflect__1.fields(obj);
286
+ let _g_index = 0;
287
+ while (_g_index < _g_keys.length) {
288
+ let key = _g_keys[_g_index++];
289
+ result[key] = ConfigStore.deepClone(obj[key]);
290
+ };
291
+ return result;
292
+ };
293
+ return val;
294
+ }
295
+ static deepMerge(base, patch) {
296
+ if (patch == null) {
297
+ return null;
298
+ };
299
+ if (base == null) {
300
+ return ConfigStore.deepClone(patch);
301
+ };
302
+ if (((patch) instanceof Array)) {
303
+ return ConfigStore.deepClone(patch);
304
+ };
305
+ if (typeof patch === "object" && typeof base === "object" && !((base) instanceof Array)) {
306
+ let baseObj = base;
307
+ let patchObj = patch;
308
+ let result = {};
309
+ let _g_keys = Reflect__1.fields(baseObj);
310
+ let _g_index = 0;
311
+ while (_g_index < _g_keys.length) {
312
+ let key = _g_keys[_g_index++];
313
+ result[key] = baseObj[key];
314
+ };
315
+ let _g_keys1 = Reflect__1.fields(patchObj);
316
+ let _g_index1 = 0;
317
+ while (_g_index1 < _g_keys1.length) {
318
+ let key = _g_keys1[_g_index1++];
319
+ result[key] = ConfigStore.deepMerge(result[key], patchObj[key]);
320
+ };
321
+ return result;
322
+ };
323
+ return ConfigStore.deepClone(patch);
324
+ }
325
+ static get __name__() {
326
+ return "whet.ConfigStore"
327
+ }
328
+ get __class__() {
329
+ return ConfigStore
330
+ }
331
+ }
332
+ ConfigStore.prototype.path = null;
333
+ ConfigStore.prototype.data = null;
334
+ ConfigStore.prototype.persistedData = null;
335
+ ConfigStore.prototype.mtimeMs = null;
336
+ ConfigStore.prototype.size = null;
337
+ ConfigStore.prototype.loadPromise = null;
338
+ ConfigStore.prototype.baselines = null;
339
+ ConfigStore.prototype.appliedPatches = null;
340
+
341
+
342
+ ConfigStore.BASE_CONFIG_KEYS = ["cacheStrategy", "id", "project", "dependencies", "configStore"]
@@ -1,5 +1,8 @@
1
1
  import {CacheManager} from "./cache/CacheManager"
2
- import {AnyStone} from "./Stone"
2
+ import {CacheStrategy} from "./cache/Cache"
3
+ import {AnyStone, OutputFilter} from "./Stone"
4
+ import {Source} from "./Source"
5
+ import {ConfigStore} from "./ConfigStore"
3
6
  import {Option, Command} from "commander"
4
7
 
5
8
  export declare class Project {
@@ -9,6 +12,7 @@ export declare class Project {
9
12
  description: string
10
13
  rootDir: string
11
14
  cache: CacheManager
15
+ configStore: ConfigStore
12
16
  stones: AnyStone[]
13
17
  onInit: (config: any) => Promise<any>
14
18
 
@@ -17,13 +21,25 @@ export declare class Project {
17
21
  */
18
22
  config: any
19
23
  protected options: Option[]
24
+ getStone(id: string): null | AnyStone
25
+ describeStones(): StoneDescription[]
26
+ listStoneOutputs(id: string): Promise<null | string[]>
27
+ getStoneSource(id: string, sourceId?: null | string): Promise<null | Source>
28
+ getStoneConfig(id: string): Promise<null | StoneConfigView>
29
+ setStoneConfig(id: string, patch: any, mode: string): Promise<boolean>
30
+ clearStoneConfigPreview(id: string): Promise<boolean>
20
31
  addCommand(name: string, stone?: null | AnyStone): Command
32
+ protected isCommandNameTaken(name: string): boolean
21
33
  toString(): string
22
34
  protected static projects: Project[]
23
35
  }
24
36
 
25
37
  export type ProjectConfig = {
26
38
  cache?: null | CacheManager,
39
+ /**
40
+ Project-level ConfigStore, applies to any stone without an explicit configStore.
41
+ */
42
+ configStore?: null | ConfigStore,
27
43
  description?: null | string,
28
44
  id?: null | string,
29
45
  name: string,
@@ -31,11 +47,30 @@ export type ProjectConfig = {
31
47
  * Called before first command is executed, but after configuration was parsed.
32
48
  */
33
49
  onInit?: null | ((config: any) => Promise<any>),
34
- /**
35
- * Array of Commander.js options this project supports. Use `addOption` to get Option instance.
36
- */
37
50
  options?: null | Option[],
38
51
  rootDir?: null | string
39
52
  }
40
53
 
54
+ export type StoneDescription = {
55
+ cacheStrategy?: null | CacheStrategy,
56
+ className: string,
57
+ id: string,
58
+ outputFilter?: null | OutputFilter
59
+ }
60
+
61
+ export type StoneConfigView = {
62
+ editable: any,
63
+ id: string,
64
+ meta: StoneConfigMeta
65
+ }
66
+
67
+ export type StoneConfigMeta = {
68
+ cacheStrategy: CacheStrategy,
69
+ className: string,
70
+ dependencyIds: string[],
71
+ hasProjectConfigStore: boolean,
72
+ hasStoneConfigStore: boolean,
73
+ uiHints?: null | any
74
+ }
75
+
41
76
  export const addOption: (flags: string, description: null | string) => Option
@@ -1,17 +1,22 @@
1
+ import {StoneId_Fields_} from "./magic/StoneId.js"
2
+ import {MaybeArray_Fields_} from "./magic/MaybeArray.js"
1
3
  import {CacheManager} from "./cache/CacheManager.js"
2
4
  import {Whet_Fields_} from "./Whet.js"
3
5
  import {Log} from "./Log.js"
6
+ import {ConfigStore} from "./ConfigStore.js"
4
7
  import * as Path from "path"
5
8
  import {Register} from "../genes/Register.js"
6
9
  import {Command, Option} from "commander"
7
10
  import {StringTools} from "../StringTools.js"
11
+ import {Reflect as Reflect__1} from "../Reflect.js"
8
12
 
9
13
  const $global = Register.$global
10
14
 
11
15
  export const Project = Register.global("$hxClasses")["whet.Project"] =
12
16
  class Project extends Register.inherits() {
13
- new(config) {
17
+ [Register.new](config) {
14
18
  this.stones = [];
19
+ this.configStore = null;
15
20
  this.cache = null;
16
21
  Log.log(20, ...["Instantiating new Project."]);
17
22
  if (config == null || config.name == null) {
@@ -46,18 +51,154 @@ class Project extends Register.inherits() {
46
51
  } else {
47
52
  this.rootDir = config.rootDir;
48
53
  };
54
+ this.configStore = config.configStore;
49
55
  this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
50
56
  Project.projects.push(this);
51
57
  Log.log(30, ...["New project created.", {"project": this, "projectCount": Project.projects.length}]);
52
58
  }
59
+ getStone(id) {
60
+ let _g = 0;
61
+ let _g1 = this.stones;
62
+ while (_g < _g1.length) {
63
+ let stone = _g1[_g];
64
+ ++_g;
65
+ if (stone.id == id) {
66
+ return stone;
67
+ };
68
+ };
69
+ return null;
70
+ }
71
+ describeStones() {
72
+ let _g = [];
73
+ let _g1 = 0;
74
+ let _g2 = this.stones;
75
+ while (_g1 < _g2.length) {
76
+ let stone = _g2[_g1];
77
+ ++_g1;
78
+ _g.push({"id": stone.id, "className": StoneId_Fields_.getTypeName(stone), "outputFilter": stone.getOutputFilter(), "cacheStrategy": stone.cacheStrategy});
79
+ };
80
+ return _g;
81
+ }
82
+ listStoneOutputs(id) {
83
+ let stone = this.getStone(id);
84
+ if (stone == null) {
85
+ return Promise.resolve(null);
86
+ } else {
87
+ return stone.listIds();
88
+ };
89
+ }
90
+ getStoneSource(id, sourceId) {
91
+ let stone = this.getStone(id);
92
+ if (stone == null) {
93
+ return Promise.resolve(null);
94
+ } else if (sourceId != null) {
95
+ return stone.getPartialSource(sourceId);
96
+ } else {
97
+ return stone.getSource();
98
+ };
99
+ }
100
+ getStoneConfig(id) {
101
+ let stone = this.getStone(id);
102
+ if (stone == null) {
103
+ return Promise.resolve(null);
104
+ };
105
+ let tmp = stone.config.configStore;
106
+ let store = (tmp != null) ? tmp : this.configStore;
107
+ let init = (store != null) ? store.ensureApplied(stone) : Promise.resolve(null);
108
+ let _gthis = this;
109
+ return init.then(function (_) {
110
+ let editable = {};
111
+ let configObj = stone.config;
112
+ let _g_keys = Reflect__1.fields(configObj);
113
+ let _g_index = 0;
114
+ while (_g_index < _g_keys.length) {
115
+ let key = _g_keys[_g_index++];
116
+ let _g_value = configObj[key];
117
+ if (ConfigStore.BASE_CONFIG_KEYS.includes(key)) {
118
+ continue;
119
+ };
120
+ if (ConfigStore.isJsonSerializable(_g_value)) {
121
+ editable[key] = ConfigStore.deepClone(_g_value);
122
+ };
123
+ };
124
+ let depIds = [];
125
+ if (stone.config.dependencies != null) {
126
+ let deps = MaybeArray_Fields_.makeArray(stone.config.dependencies);
127
+ let _g = [];
128
+ let _g1 = 0;
129
+ while (_g1 < deps.length) _g.push(deps[_g1++].id);
130
+ depIds = _g;
131
+ };
132
+ return {"id": stone.id, "editable": editable, "meta": {"className": StoneId_Fields_.getTypeName(stone), "cacheStrategy": stone.cacheStrategy, "dependencyIds": depIds, "hasStoneConfigStore": stone.config.configStore != null, "hasProjectConfigStore": _gthis.configStore != null}};
133
+ });
134
+ }
135
+ setStoneConfig(id, patch, mode) {
136
+ let stone = this.getStone(id);
137
+ if (stone == null) {
138
+ return Promise.resolve(false);
139
+ };
140
+ let tmp = stone.config.configStore;
141
+ let store = (tmp != null) ? tmp : this.configStore;
142
+ if (store == null) {
143
+ return Promise.resolve(false);
144
+ };
145
+ store.setEntry(stone.id, patch);
146
+ if (mode == "persist") {
147
+ return store.flush().then(function (_) {
148
+ return true;
149
+ });
150
+ } else {
151
+ return Promise.resolve(true);
152
+ };
153
+ }
154
+ clearStoneConfigPreview(id) {
155
+ let stone = this.getStone(id);
156
+ if (stone == null) {
157
+ return Promise.resolve(false);
158
+ };
159
+ let tmp = stone.config.configStore;
160
+ let store = (tmp != null) ? tmp : this.configStore;
161
+ if (store == null) {
162
+ return Promise.resolve(false);
163
+ };
164
+ store.clearEntry(stone.id);
165
+ return Promise.resolve(true);
166
+ }
53
167
  addCommand(name, stone) {
54
- let cmd = new Command(name);
168
+ let cmdName = name;
169
+ let cmdAlias = null;
55
170
  if (stone != null) {
56
- cmd.alias(stone.id + "." + cmd.name());
171
+ let alias = stone.id + "." + name;
172
+ if (this.isCommandNameTaken(name)) {
173
+ cmdName = alias;
174
+ } else {
175
+ cmdAlias = alias;
176
+ };
177
+ };
178
+ let cmd = new Command(cmdName);
179
+ if (cmdAlias != null) {
180
+ cmd.alias(cmdAlias);
57
181
  };
58
182
  Whet_Fields_.program.addCommand(cmd);
59
183
  return cmd;
60
184
  }
185
+ isCommandNameTaken(name) {
186
+ let _g = 0;
187
+ let _g1 = Whet_Fields_.program.commands;
188
+ while (_g < _g1.length) {
189
+ let cmd = _g1[_g];
190
+ ++_g;
191
+ if (cmd.name() == name) {
192
+ return true;
193
+ };
194
+ let _g2 = 0;
195
+ let _g3 = cmd.aliases();
196
+ while (_g2 < _g3.length) if (_g3[_g2++] == name) {
197
+ return true;
198
+ };
199
+ };
200
+ return false;
201
+ }
61
202
  toString() {
62
203
  return "" + this.name + "@" + this.rootDir;
63
204
  }
@@ -68,6 +209,16 @@ class Project extends Register.inherits() {
68
209
  return Project
69
210
  }
70
211
  }
212
+ Project.prototype.name = null;
213
+ Project.prototype.id = null;
214
+ Project.prototype.description = null;
215
+ Project.prototype.rootDir = null;
216
+ Project.prototype.cache = null;
217
+ Project.prototype.configStore = null;
218
+ Project.prototype.stones = null;
219
+ Project.prototype.onInit = null;
220
+ Project.prototype.config = null;
221
+ Project.prototype.options = null;
71
222
 
72
223
 
73
224
  Project.projects = []
@@ -4,12 +4,18 @@ import {SourceHash} from "./SourceHash"
4
4
  import {Buffer} from "buffer"
5
5
 
6
6
  export declare class Source {
7
- protected constructor(data: SourceData[], hash: SourceHash, origin: AnyStone, ctime: number)
7
+ protected constructor(data: SourceData[], hash: SourceHash, origin: AnyStone, ctime: number, complete?: boolean)
8
8
  data: SourceData[]
9
9
  hash: SourceHash
10
10
  origin: AnyStone
11
11
  ctime: number
12
+ complete: boolean
12
13
  protected dirPath: string
14
+
15
+ /**
16
+ Filter to a single sourceId. Returns null if sourceId not found.
17
+ */
18
+ filterTo(sourceId: string): null | Source
13
19
  tryDirPath(): null | string
14
20
 
15
21
  /**
@@ -13,15 +13,40 @@ const $global = Register.$global
13
13
 
14
14
  export const Source = Register.global("$hxClasses")["whet.Source"] =
15
15
  class Source extends Register.inherits() {
16
- new(data, hash, origin, ctime) {
16
+ [Register.new](data, hash, origin, ctime, complete) {
17
+ if (complete == null) {
18
+ complete = true;
19
+ };
17
20
  this.dirPath = null;
18
21
  this.data = data;
19
22
  this.hash = hash;
20
23
  this.origin = origin;
21
24
  this.ctime = ctime;
25
+ this.complete = complete;
22
26
  let _g = 0;
23
27
  while (_g < data.length) data[_g++].source = this;
24
28
  }
29
+
30
+ /**
31
+ Filter to a single sourceId. Returns null if sourceId not found.
32
+ */
33
+ filterTo(sourceId) {
34
+ let _this = this.data;
35
+ let _g = [];
36
+ let _g1 = 0;
37
+ while (_g1 < _this.length) {
38
+ let v = _this[_g1];
39
+ ++_g1;
40
+ if (v.id == sourceId) {
41
+ _g.push(v);
42
+ };
43
+ };
44
+ if (_g.length == 0) {
45
+ return null;
46
+ } else {
47
+ return new Source(_g, this.hash, this.origin, this.ctime, this.complete);
48
+ };
49
+ }
25
50
  tryDirPath() {
26
51
  return this.dirPath;
27
52
  }
@@ -57,11 +82,17 @@ class Source extends Register.inherits() {
57
82
  return Source
58
83
  }
59
84
  }
85
+ Source.prototype.data = null;
86
+ Source.prototype.hash = null;
87
+ Source.prototype.origin = null;
88
+ Source.prototype.ctime = null;
89
+ Source.prototype.complete = null;
90
+ Source.prototype.dirPath = null;
60
91
 
61
92
 
62
93
  export const SourceData = Register.global("$hxClasses")["whet.SourceData"] =
63
94
  class SourceData extends Register.inherits() {
64
- new(id, data, knownHash) {
95
+ [Register.new](id, data, knownHash) {
65
96
  this.filePath = null;
66
97
  this.filePathId = null;
67
98
  this.data = data;
@@ -92,7 +123,7 @@ class SourceData extends Register.inherits() {
92
123
  let _gthis = this;
93
124
  if (this.filePath == null) {
94
125
  if (this.source == null) {
95
- new Error("Data without source.");
126
+ return Promise.reject(new Error("Data without source."));
96
127
  };
97
128
  let dir = this.source.getDirPath();
98
129
  let name = (idOverride != null && !(idOverride.length == 0 || idOverride.charCodeAt(idOverride.length - 1) == 47)) ? idOverride : this.id;
@@ -166,4 +197,10 @@ class SourceData extends Register.inherits() {
166
197
  return SourceData
167
198
  }
168
199
  }
200
+ SourceData.prototype.data = null;
201
+ SourceData.prototype.id = null;
202
+ SourceData.prototype.hash = null;
203
+ SourceData.prototype.source = null;
204
+ SourceData.prototype.filePathId = null;
205
+ SourceData.prototype.filePath = null;
169
206