@decohere/core 0.0.1-dev.116

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 (262) hide show
  1. package/commonjs/src/caching/cache-manager.js +98 -0
  2. package/commonjs/src/caching/cache.decorator.js +69 -0
  3. package/commonjs/src/caching/cache.js +6 -0
  4. package/commonjs/src/caching/index.js +23 -0
  5. package/commonjs/src/caching/invalidate-cache.decorator.js +92 -0
  6. package/commonjs/src/caching/memoize.decorator.js +36 -0
  7. package/commonjs/src/caching/node-cache-memoize.adapter.js +49 -0
  8. package/commonjs/src/cli/action.js +65 -0
  9. package/commonjs/src/cli/command.js +127 -0
  10. package/commonjs/src/cli/index.js +61 -0
  11. package/commonjs/src/cli/module.type.js +18 -0
  12. package/commonjs/src/cli/options.js +115 -0
  13. package/commonjs/src/collections/collections.js +21 -0
  14. package/commonjs/src/collections/find-duplicates.js +35 -0
  15. package/commonjs/src/collections/index.js +52 -0
  16. package/commonjs/src/collections/merge-arrays.js +34 -0
  17. package/commonjs/src/collections/sum.js +63 -0
  18. package/commonjs/src/collections/unique-objects.js +39 -0
  19. package/commonjs/src/composition/index.js +4 -0
  20. package/commonjs/src/configuration/configuration.types.js +11 -0
  21. package/commonjs/src/configuration/index.js +18 -0
  22. package/commonjs/src/diagnostics/index.js +22 -0
  23. package/commonjs/src/diagnostics/trace.js +86 -0
  24. package/commonjs/src/extensibility/decorator-factory-base.js +22 -0
  25. package/commonjs/src/extensibility/decorator-factory.js +31 -0
  26. package/commonjs/src/extensibility/extension.js +37 -0
  27. package/commonjs/src/extensibility/index.js +23 -0
  28. package/commonjs/src/extensibility/mixwith.js +36 -0
  29. package/commonjs/src/extensibility/pipeline.js +56 -0
  30. package/commonjs/src/extensibility/step.js +18 -0
  31. package/commonjs/src/interop/docker/docker.js +54 -0
  32. package/commonjs/src/interop/errors/interop.error.js +12 -0
  33. package/commonjs/src/interop/git/git.js +134 -0
  34. package/commonjs/src/interop/git/git.types.js +4 -0
  35. package/commonjs/src/interop/index.js +97 -0
  36. package/commonjs/src/interop/node/index.js +18 -0
  37. package/commonjs/src/interop/node/node.js +45 -0
  38. package/commonjs/src/interop/npm/npm.js +231 -0
  39. package/commonjs/src/interop/npm/npm.types.js +16 -0
  40. package/commonjs/src/interop/pnpm/pnpm.js +34 -0
  41. package/commonjs/src/interop/pnpm/pnpm.types.js +4 -0
  42. package/commonjs/src/interop/shell/shell.argv.js +45 -0
  43. package/commonjs/src/interop/shell/shell.js +105 -0
  44. package/commonjs/src/interop/shell/shell.types.js +4 -0
  45. package/commonjs/src/interop/types/detect-package-manager.js +71 -0
  46. package/commonjs/src/interop/types/package-manager.js +4 -0
  47. package/commonjs/src/interop/yarn/yarn.js +34 -0
  48. package/commonjs/src/interop/yarn/yarn.types.js +4 -0
  49. package/commonjs/src/io/copy-file.js +25 -0
  50. package/commonjs/src/io/delete-file.js +21 -0
  51. package/commonjs/src/io/directory-exists.js +24 -0
  52. package/commonjs/src/io/file-exists.js +19 -0
  53. package/commonjs/src/io/find-directories.js +21 -0
  54. package/commonjs/src/io/find-file.js +45 -0
  55. package/commonjs/src/io/index.js +66 -0
  56. package/commonjs/src/io/io.js +28 -0
  57. package/commonjs/src/io/read-file.js +39 -0
  58. package/commonjs/src/io/remove-dir.js +22 -0
  59. package/commonjs/src/io/types/directory.type.js +4 -0
  60. package/commonjs/src/io/types/file.js +28 -0
  61. package/commonjs/src/io/types/index.js +19 -0
  62. package/commonjs/src/io/url-to-path.js +33 -0
  63. package/commonjs/src/io/watch.js +261 -0
  64. package/commonjs/src/io/write-file.js +30 -0
  65. package/commonjs/src/objects/deep-merge.js +67 -0
  66. package/commonjs/src/objects/index.js +11 -0
  67. package/commonjs/src/reflection/index.js +20 -0
  68. package/commonjs/src/reflection/types/index.js +18 -0
  69. package/commonjs/src/reflection/types/reflection.types.js +26 -0
  70. package/commonjs/src/reflection/utilities.js +118 -0
  71. package/commonjs/src/semver/index.js +18 -0
  72. package/commonjs/src/semver/semver.js +92 -0
  73. package/commonjs/src/system/camel-case.js +13 -0
  74. package/commonjs/src/system/debounce.js +19 -0
  75. package/commonjs/src/system/decorator.js +46 -0
  76. package/commonjs/src/system/environment.js +23 -0
  77. package/commonjs/src/system/function.types.js +18 -0
  78. package/commonjs/src/system/index.js +24 -0
  79. package/commonjs/src/system/retry.decorator.js +40 -0
  80. package/commonjs/src/system/sleep.js +13 -0
  81. package/commonjs/src/system/type.utils.js +4 -0
  82. package/commonjs/src/testing/flush-promises.js +16 -0
  83. package/commonjs/src/testing/glob-with-memfs.js +22 -0
  84. package/commonjs/src/testing/index.js +22 -0
  85. package/commonjs/src/testing/memfs.js +52 -0
  86. package/commonjs/src/testing/mock-logger.js +36 -0
  87. package/commonjs/src/testing/spy-on-constructor.js +27 -0
  88. package/es6/src/caching/cache-manager.js +82 -0
  89. package/es6/src/caching/cache.decorator.js +51 -0
  90. package/es6/src/caching/cache.js +3 -0
  91. package/es6/src/caching/index.js +6 -0
  92. package/es6/src/caching/invalidate-cache.decorator.js +71 -0
  93. package/es6/src/caching/memoize.decorator.js +27 -0
  94. package/es6/src/caching/node-cache-memoize.adapter.js +37 -0
  95. package/es6/src/cli/action.js +47 -0
  96. package/es6/src/cli/command.js +106 -0
  97. package/es6/src/cli/index.js +4 -0
  98. package/es6/src/cli/module.type.js +11 -0
  99. package/es6/src/cli/options.js +76 -0
  100. package/es6/src/collections/collections.js +4 -0
  101. package/es6/src/collections/find-duplicates.js +17 -0
  102. package/es6/src/collections/index.js +1 -0
  103. package/es6/src/collections/merge-arrays.js +16 -0
  104. package/es6/src/collections/sum.js +45 -0
  105. package/es6/src/collections/unique-objects.js +21 -0
  106. package/es6/src/composition/index.js +1 -0
  107. package/es6/src/configuration/configuration.types.js +1 -0
  108. package/es6/src/configuration/index.js +1 -0
  109. package/es6/src/diagnostics/index.js +1 -0
  110. package/es6/src/diagnostics/trace.js +68 -0
  111. package/es6/src/extensibility/decorator-factory-base.js +39 -0
  112. package/es6/src/extensibility/decorator-factory.js +21 -0
  113. package/es6/src/extensibility/extension.js +27 -0
  114. package/es6/src/extensibility/index.js +6 -0
  115. package/es6/src/extensibility/mixwith.js +26 -0
  116. package/es6/src/extensibility/pipeline.js +46 -0
  117. package/es6/src/extensibility/step.js +16 -0
  118. package/es6/src/interop/docker/docker.js +44 -0
  119. package/es6/src/interop/errors/interop.error.js +2 -0
  120. package/es6/src/interop/git/git.js +124 -0
  121. package/es6/src/interop/git/git.types.js +1 -0
  122. package/es6/src/interop/index.js +21 -0
  123. package/es6/src/interop/node/index.js +1 -0
  124. package/es6/src/interop/node/node.js +35 -0
  125. package/es6/src/interop/npm/npm.js +180 -0
  126. package/es6/src/interop/npm/npm.types.js +6 -0
  127. package/es6/src/interop/pnpm/pnpm.js +24 -0
  128. package/es6/src/interop/pnpm/pnpm.types.js +1 -0
  129. package/es6/src/interop/shell/shell.argv.js +35 -0
  130. package/es6/src/interop/shell/shell.js +95 -0
  131. package/es6/src/interop/shell/shell.types.js +1 -0
  132. package/es6/src/interop/types/detect-package-manager.js +50 -0
  133. package/es6/src/interop/types/package-manager.js +1 -0
  134. package/es6/src/interop/yarn/yarn.js +24 -0
  135. package/es6/src/interop/yarn/yarn.types.js +1 -0
  136. package/es6/src/io/copy-file.js +10 -0
  137. package/es6/src/io/delete-file.js +6 -0
  138. package/es6/src/io/directory-exists.js +9 -0
  139. package/es6/src/io/file-exists.js +9 -0
  140. package/es6/src/io/find-directories.js +11 -0
  141. package/es6/src/io/find-file.js +27 -0
  142. package/es6/src/io/index.js +2 -0
  143. package/es6/src/io/io.js +11 -0
  144. package/es6/src/io/read-file.js +13 -0
  145. package/es6/src/io/remove-dir.js +7 -0
  146. package/es6/src/io/types/directory.type.js +1 -0
  147. package/es6/src/io/types/file.js +18 -0
  148. package/es6/src/io/types/index.js +2 -0
  149. package/es6/src/io/url-to-path.js +15 -0
  150. package/es6/src/io/watch.js +238 -0
  151. package/es6/src/io/write-file.js +15 -0
  152. package/es6/src/objects/deep-merge.js +57 -0
  153. package/es6/src/objects/index.js +1 -0
  154. package/es6/src/reflection/index.js +3 -0
  155. package/es6/src/reflection/types/index.js +1 -0
  156. package/es6/src/reflection/types/reflection.types.js +8 -0
  157. package/es6/src/reflection/utilities.js +74 -0
  158. package/es6/src/semver/index.js +1 -0
  159. package/es6/src/semver/semver.js +71 -0
  160. package/es6/src/system/camel-case.js +3 -0
  161. package/es6/src/system/debounce.js +9 -0
  162. package/es6/src/system/decorator.js +30 -0
  163. package/es6/src/system/environment.js +5 -0
  164. package/es6/src/system/function.types.js +26 -0
  165. package/es6/src/system/index.js +7 -0
  166. package/es6/src/system/retry.decorator.js +30 -0
  167. package/es6/src/system/sleep.js +3 -0
  168. package/es6/src/system/type.utils.js +1 -0
  169. package/es6/src/testing/flush-promises.js +6 -0
  170. package/es6/src/testing/glob-with-memfs.js +20 -0
  171. package/es6/src/testing/index.js +5 -0
  172. package/es6/src/testing/memfs.js +25 -0
  173. package/es6/src/testing/mock-logger.js +26 -0
  174. package/es6/src/testing/spy-on-constructor.js +31 -0
  175. package/package.json +106 -0
  176. package/types/src/caching/cache-manager.d.ts +59 -0
  177. package/types/src/caching/cache.d.ts +11 -0
  178. package/types/src/caching/cache.decorator.d.ts +18 -0
  179. package/types/src/caching/index.d.ts +6 -0
  180. package/types/src/caching/invalidate-cache.decorator.d.ts +17 -0
  181. package/types/src/caching/memoize.decorator.d.ts +16 -0
  182. package/types/src/caching/node-cache-memoize.adapter.d.ts +22 -0
  183. package/types/src/cli/action.d.ts +36 -0
  184. package/types/src/cli/command.d.ts +34 -0
  185. package/types/src/cli/index.d.ts +7 -0
  186. package/types/src/cli/module.type.d.ts +36 -0
  187. package/types/src/cli/options.d.ts +28 -0
  188. package/types/src/collections/collections.d.ts +4 -0
  189. package/types/src/collections/find-duplicates.d.ts +2 -0
  190. package/types/src/collections/index.d.ts +1 -0
  191. package/types/src/collections/merge-arrays.d.ts +2 -0
  192. package/types/src/collections/sum.d.ts +4 -0
  193. package/types/src/collections/unique-objects.d.ts +2 -0
  194. package/types/src/composition/index.d.ts +37 -0
  195. package/types/src/configuration/configuration.types.d.ts +10 -0
  196. package/types/src/configuration/index.d.ts +1 -0
  197. package/types/src/diagnostics/index.d.ts +1 -0
  198. package/types/src/diagnostics/trace.d.ts +10 -0
  199. package/types/src/extensibility/decorator-factory-base.d.ts +39 -0
  200. package/types/src/extensibility/decorator-factory.d.ts +19 -0
  201. package/types/src/extensibility/extension.d.ts +9 -0
  202. package/types/src/extensibility/index.d.ts +6 -0
  203. package/types/src/extensibility/mixwith.d.ts +6 -0
  204. package/types/src/extensibility/pipeline.d.ts +12 -0
  205. package/types/src/extensibility/step.d.ts +16 -0
  206. package/types/src/interop/docker/docker.d.ts +19 -0
  207. package/types/src/interop/errors/interop.error.d.ts +2 -0
  208. package/types/src/interop/git/git.d.ts +16 -0
  209. package/types/src/interop/git/git.types.d.ts +14 -0
  210. package/types/src/interop/index.d.ts +14 -0
  211. package/types/src/interop/node/index.d.ts +1 -0
  212. package/types/src/interop/node/node.d.ts +5 -0
  213. package/types/src/interop/npm/npm.d.ts +29 -0
  214. package/types/src/interop/npm/npm.types.d.ts +24 -0
  215. package/types/src/interop/pnpm/pnpm.d.ts +9 -0
  216. package/types/src/interop/pnpm/pnpm.types.d.ts +3 -0
  217. package/types/src/interop/shell/shell.argv.d.ts +5 -0
  218. package/types/src/interop/shell/shell.d.ts +6 -0
  219. package/types/src/interop/shell/shell.types.d.ts +9 -0
  220. package/types/src/interop/types/detect-package-manager.d.ts +4 -0
  221. package/types/src/interop/types/package-manager.d.ts +10 -0
  222. package/types/src/interop/yarn/yarn.d.ts +9 -0
  223. package/types/src/interop/yarn/yarn.types.d.ts +3 -0
  224. package/types/src/io/copy-file.d.ts +4 -0
  225. package/types/src/io/delete-file.d.ts +1 -0
  226. package/types/src/io/directory-exists.d.ts +1 -0
  227. package/types/src/io/file-exists.d.ts +1 -0
  228. package/types/src/io/find-directories.d.ts +2 -0
  229. package/types/src/io/find-file.d.ts +9 -0
  230. package/types/src/io/index.d.ts +2 -0
  231. package/types/src/io/io.d.ts +11 -0
  232. package/types/src/io/read-file.d.ts +4 -0
  233. package/types/src/io/remove-dir.d.ts +5 -0
  234. package/types/src/io/types/directory.type.d.ts +4 -0
  235. package/types/src/io/types/file.d.ts +20 -0
  236. package/types/src/io/types/index.d.ts +2 -0
  237. package/types/src/io/url-to-path.d.ts +2 -0
  238. package/types/src/io/watch.d.ts +16 -0
  239. package/types/src/io/write-file.d.ts +5 -0
  240. package/types/src/objects/deep-merge.d.ts +41 -0
  241. package/types/src/objects/index.d.ts +1 -0
  242. package/types/src/reflection/index.d.ts +3 -0
  243. package/types/src/reflection/types/index.d.ts +1 -0
  244. package/types/src/reflection/types/reflection.types.d.ts +21 -0
  245. package/types/src/reflection/utilities.d.ts +27 -0
  246. package/types/src/semver/index.d.ts +1 -0
  247. package/types/src/semver/semver.d.ts +18 -0
  248. package/types/src/system/camel-case.d.ts +1 -0
  249. package/types/src/system/debounce.d.ts +1 -0
  250. package/types/src/system/decorator.d.ts +15 -0
  251. package/types/src/system/environment.d.ts +6 -0
  252. package/types/src/system/function.types.d.ts +55 -0
  253. package/types/src/system/index.d.ts +7 -0
  254. package/types/src/system/retry.decorator.d.ts +6 -0
  255. package/types/src/system/sleep.d.ts +1 -0
  256. package/types/src/system/type.utils.d.ts +1 -0
  257. package/types/src/testing/flush-promises.d.ts +1 -0
  258. package/types/src/testing/glob-with-memfs.d.ts +3 -0
  259. package/types/src/testing/index.d.ts +5 -0
  260. package/types/src/testing/memfs.d.ts +5 -0
  261. package/types/src/testing/mock-logger.d.ts +13 -0
  262. package/types/src/testing/spy-on-constructor.d.ts +21 -0
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./directory.type.js"), exports);
6
+ _export_star(require("./file.js"), exports);
7
+ function _export_star(from, to) {
8
+ Object.keys(from).forEach(function(k) {
9
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
10
+ Object.defineProperty(to, k, {
11
+ enumerable: true,
12
+ get: function() {
13
+ return from[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ return from;
19
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get fileUrlToPath () {
13
+ return fileUrlToPath;
14
+ },
15
+ get pathToFileUrl () {
16
+ return pathToFileUrl;
17
+ }
18
+ });
19
+ const _nodeurl = require("node:url");
20
+ const fileUrlToPath = (url)=>{
21
+ try {
22
+ return (0, _nodeurl.fileURLToPath)(url);
23
+ } catch {
24
+ return url;
25
+ }
26
+ };
27
+ const pathToFileUrl = (path)=>{
28
+ try {
29
+ return (0, _nodeurl.pathToFileURL)(path).toString();
30
+ } catch {
31
+ return path;
32
+ }
33
+ };
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get WatchEvents () {
13
+ return WatchEvents;
14
+ },
15
+ get watch () {
16
+ return watch;
17
+ }
18
+ });
19
+ const _nodefs = require("node:fs");
20
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
21
+ const _picomatch = /*#__PURE__*/ _interop_require_default(require("picomatch"));
22
+ const _file = require("./types/file.js");
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
28
+ const WatchEvents = {
29
+ add: "add",
30
+ change: "change",
31
+ addDir: "addDir",
32
+ unlink: "unlink",
33
+ unlinkDir: "unlinkDir"
34
+ };
35
+ function watch(directory, options = {
36
+ cwd: "."
37
+ }) {
38
+ const { include, ignore, ignoreInitial = false } = options;
39
+ const changeCoalesceMs = 25;
40
+ const handlers = {
41
+ ready: new Set(),
42
+ add: new Set(),
43
+ change: new Set(),
44
+ addDir: new Set(),
45
+ unlink: new Set(),
46
+ unlinkDir: new Set()
47
+ };
48
+ let resolveReady;
49
+ const ready = new Promise((resolve)=>{
50
+ resolveReady = resolve;
51
+ });
52
+ const snapshot = buildSnapshot(directory);
53
+ const isFiltered = (relativePath)=>{
54
+ const posixRelativePath = toPosixPath(relativePath);
55
+ const posixFullPath = toPosixPath(_nodepath.default.resolve(directory, relativePath));
56
+ const matchesEitherPath = (patterns)=>_picomatch.default.isMatch(posixRelativePath, patterns) || _picomatch.default.isMatch(posixFullPath, patterns);
57
+ if (include && include.length > 0) {
58
+ return !matchesEitherPath(include);
59
+ }
60
+ if (ignore && ignore.length > 0) {
61
+ return matchesEitherPath(ignore);
62
+ }
63
+ return false;
64
+ };
65
+ const emit = (event, relativePath)=>{
66
+ if (isFiltered(relativePath)) {
67
+ return;
68
+ }
69
+ const fullPath = _nodepath.default.resolve(directory, relativePath);
70
+ for (const handler of handlers[event]){
71
+ handler(new _file.FileEx({
72
+ fullPath,
73
+ relativePath
74
+ }));
75
+ }
76
+ };
77
+ const pendingChangeTimers = new Map();
78
+ const emitChange = (relativePath)=>{
79
+ const existing = pendingChangeTimers.get(relativePath);
80
+ if (existing != null) {
81
+ clearTimeout(existing);
82
+ }
83
+ const timer = setTimeout(()=>{
84
+ pendingChangeTimers.delete(relativePath);
85
+ emit("change", relativePath);
86
+ }, changeCoalesceMs);
87
+ pendingChangeTimers.set(relativePath, timer);
88
+ };
89
+ const emitReady = ()=>{
90
+ for (const handler of handlers.ready){
91
+ handler();
92
+ }
93
+ };
94
+ queueMicrotask(()=>{
95
+ if (!ignoreInitial) {
96
+ for (const [relativePath, entry] of snapshot){
97
+ emit(entry.isDirectory ? "addDir" : "add", relativePath);
98
+ }
99
+ }
100
+ emitReady();
101
+ resolveReady?.();
102
+ resolveReady = undefined;
103
+ });
104
+ // One non-recursive watcher per directory. Node's recursive mode on Linux tracks files
105
+ // individually and goes silent for a file once an editor replaces it with an atomic save
106
+ // (write temp file, rename over the original); directory watchers keep seeing it (#505).
107
+ const directoryWatchers = new Map();
108
+ const watchDirectory = (relativeDir)=>{
109
+ if (directoryWatchers.has(relativeDir)) {
110
+ return;
111
+ }
112
+ try {
113
+ const watcher = (0, _nodefs.watch)(_nodepath.default.resolve(directory, relativeDir), (_eventType, fileName)=>{
114
+ if (fileName != null) {
115
+ onFsEvent(_nodepath.default.posix.join(relativeDir, toPosixPath(fileName.toString())));
116
+ }
117
+ });
118
+ watcher.on("error", ()=>unwatchDirectory(relativeDir));
119
+ directoryWatchers.set(relativeDir, watcher);
120
+ } catch {
121
+ // The directory vanished before we could watch it; its unlink event covers it.
122
+ }
123
+ };
124
+ const unwatchDirectory = (relativeDir)=>{
125
+ for (const [watchedDir, watcher] of directoryWatchers){
126
+ if (watchedDir === relativeDir || watchedDir.startsWith(`${relativeDir}/`)) {
127
+ watcher.close();
128
+ directoryWatchers.delete(watchedDir);
129
+ }
130
+ }
131
+ };
132
+ /** A directory appeared: watch it, and report what was created in it before we were watching. */ const addDirectory = (relativeDir)=>{
133
+ watchDirectory(relativeDir);
134
+ const found = new Map();
135
+ try {
136
+ collectSnapshotEntries(directory, _nodepath.default.resolve(directory, relativeDir), found);
137
+ } catch {
138
+ return;
139
+ }
140
+ for (const [relativePath, entry] of found){
141
+ if (snapshot.has(relativePath)) continue;
142
+ snapshot.set(relativePath, entry);
143
+ if (entry.isDirectory) watchDirectory(relativePath);
144
+ emit(entry.isDirectory ? "addDir" : "add", relativePath);
145
+ }
146
+ };
147
+ /** A directory went away: stop watching it and forget everything that was under it. */ const removeDirectoryContents = (relativeDir)=>{
148
+ unwatchDirectory(relativeDir);
149
+ // oxlint-disable-next-line unicorn/no-useless-spread -- iterate a copy: the loop deletes from the snapshot
150
+ for (const [relativePath, entry] of [
151
+ ...snapshot
152
+ ]){
153
+ if (relativePath.startsWith(`${relativeDir}/`)) {
154
+ snapshot.delete(relativePath);
155
+ emit(entry.isDirectory ? "unlinkDir" : "unlink", relativePath);
156
+ }
157
+ }
158
+ };
159
+ const onFsEvent = (eventPath)=>{
160
+ const relativePath = eventPath === "." ? "" : eventPath;
161
+ if (relativePath.length === 0) {
162
+ return;
163
+ }
164
+ const fullPath = _nodepath.default.resolve(directory, relativePath);
165
+ const previous = snapshot.get(relativePath);
166
+ try {
167
+ const stat = (0, _nodefs.statSync)(fullPath);
168
+ const current = toSnapshotEntry(stat);
169
+ snapshot.set(relativePath, current);
170
+ if (previous == null) {
171
+ emit(current.isDirectory ? "addDir" : "add", relativePath);
172
+ if (current.isDirectory) addDirectory(relativePath);
173
+ return;
174
+ }
175
+ if (previous.isDirectory !== current.isDirectory) {
176
+ if (previous.isDirectory) removeDirectoryContents(relativePath);
177
+ emit(previous.isDirectory ? "unlinkDir" : "unlink", relativePath);
178
+ emit(current.isDirectory ? "addDir" : "add", relativePath);
179
+ return;
180
+ }
181
+ if (!current.isDirectory && previous.fingerprint !== current.fingerprint) {
182
+ emitChange(relativePath);
183
+ }
184
+ } catch {
185
+ if (previous == null) {
186
+ return;
187
+ }
188
+ snapshot.delete(relativePath);
189
+ const pending = pendingChangeTimers.get(relativePath);
190
+ if (pending != null) {
191
+ clearTimeout(pending);
192
+ pendingChangeTimers.delete(relativePath);
193
+ }
194
+ emit(previous.isDirectory ? "unlinkDir" : "unlink", relativePath);
195
+ }
196
+ };
197
+ watchDirectory("");
198
+ for (const [relativePath, entry] of snapshot){
199
+ if (entry.isDirectory) watchDirectory(relativePath);
200
+ }
201
+ const watchApi = {
202
+ ready,
203
+ on (event, handler) {
204
+ if (event === "ready") {
205
+ handlers.ready.add(handler);
206
+ return watchApi;
207
+ }
208
+ handlers[event].add(handler);
209
+ return watchApi;
210
+ },
211
+ close: ()=>{
212
+ for (const pending of pendingChangeTimers.values()){
213
+ clearTimeout(pending);
214
+ }
215
+ pendingChangeTimers.clear();
216
+ for (const watcher of directoryWatchers.values()){
217
+ watcher.close();
218
+ }
219
+ directoryWatchers.clear();
220
+ }
221
+ };
222
+ return watchApi;
223
+ }
224
+ function buildSnapshot(directoryPath) {
225
+ const snapshot = new Map();
226
+ collectSnapshotEntries(directoryPath, directoryPath, snapshot);
227
+ return snapshot;
228
+ }
229
+ /** Never source, and huge: watching every folder inside them could exhaust OS watch limits. */ const UNWATCHED_DIRECTORIES = new Set([
230
+ "node_modules",
231
+ ".git"
232
+ ]);
233
+ function collectSnapshotEntries(rootDirectoryPath, currentDirectoryPath, snapshot) {
234
+ for (const entry of (0, _nodefs.readdirSync)(currentDirectoryPath, {
235
+ encoding: "utf8"
236
+ })){
237
+ const name = typeof entry === "string" ? entry : String(entry);
238
+ const fullPath = _nodepath.default.join(currentDirectoryPath, name);
239
+ if (UNWATCHED_DIRECTORIES.has(name)) {
240
+ continue;
241
+ }
242
+ const relativePath = toPosixPath(_nodepath.default.relative(rootDirectoryPath, fullPath));
243
+ const stat = (0, _nodefs.statSync)(fullPath);
244
+ const snapshotEntry = toSnapshotEntry(stat);
245
+ snapshot.set(relativePath, snapshotEntry);
246
+ if (!snapshotEntry.isDirectory) {
247
+ continue;
248
+ }
249
+ collectSnapshotEntries(rootDirectoryPath, fullPath, snapshot);
250
+ }
251
+ }
252
+ function toSnapshotEntry(stat) {
253
+ const isDirectory = stat.isDirectory();
254
+ return {
255
+ isDirectory,
256
+ fingerprint: isDirectory ? `dir:${stat.mtimeMs}` : `file:${stat.mtimeMs}:${stat.size}`
257
+ };
258
+ }
259
+ function toPosixPath(filePath) {
260
+ return filePath.split(_nodepath.default.sep).join(_nodepath.default.posix.sep);
261
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "writeFile", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return writeFile;
9
+ }
10
+ });
11
+ const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
12
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ async function writeFile(filePath, content, options = {
19
+ encoding: "utf8",
20
+ mkdir: false
21
+ }) {
22
+ const { encoding, mkdir } = options;
23
+ if (mkdir) {
24
+ const directory = _nodepath.default.dirname(filePath);
25
+ await _promises.default.mkdir(directory, {
26
+ recursive: true
27
+ });
28
+ }
29
+ await _promises.default.writeFile(filePath, content, encoding);
30
+ }
@@ -0,0 +1,67 @@
1
+ // Source https://github.com/voodoocreation/ts-deepmerge/blob/master/package.json
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "merge", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return merge;
10
+ }
11
+ });
12
+ // istanbul ignore next
13
+ const isObject = (obj)=>{
14
+ if (typeof obj === "object" && obj !== null) {
15
+ if (typeof Object.getPrototypeOf === "function") {
16
+ const prototype = Object.getPrototypeOf(obj);
17
+ return prototype === Object.prototype || prototype === null;
18
+ }
19
+ return Object.prototype.toString.call(obj) === "[object Object]";
20
+ }
21
+ return false;
22
+ };
23
+ const merge = (...objects)=>objects.reduce((result, current)=>{
24
+ if (current === undefined) {
25
+ return result;
26
+ }
27
+ if (Array.isArray(current)) {
28
+ throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
29
+ }
30
+ Object.keys(current).forEach((key)=>{
31
+ if ([
32
+ "__proto__",
33
+ "constructor",
34
+ "prototype"
35
+ ].includes(key)) {
36
+ return;
37
+ }
38
+ if (Array.isArray(result[key]) && Array.isArray(current[key])) {
39
+ result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [
40
+ ...result[key],
41
+ ...current[key]
42
+ ] : current[key];
43
+ } else if (isObject(result[key]) && isObject(current[key])) {
44
+ result[key] = merge(result[key], current[key]);
45
+ } else if (!isObject(result[key]) && isObject(current[key])) {
46
+ result[key] = merge(current[key], undefined);
47
+ } else {
48
+ result[key] = current[key] === undefined ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
49
+ }
50
+ });
51
+ return result;
52
+ }, {});
53
+ const defaultOptions = {
54
+ allowUndefinedOverrides: true,
55
+ mergeArrays: true,
56
+ uniqueArrayItems: true
57
+ };
58
+ merge.options = defaultOptions;
59
+ merge.withOptions = (options, ...objects)=>{
60
+ merge.options = {
61
+ ...defaultOptions,
62
+ ...options
63
+ };
64
+ const result = merge(...objects);
65
+ merge.options = defaultOptions;
66
+ return result;
67
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "merge", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _deepmerge.merge;
9
+ }
10
+ });
11
+ const _deepmerge = require("./deep-merge.js");
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ require("reflect-metadata");
6
+ _export_star(require("./types/index.js"), exports);
7
+ _export_star(require("./utilities.js"), exports);
8
+ function _export_star(from, to) {
9
+ Object.keys(from).forEach(function(k) {
10
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
11
+ Object.defineProperty(to, k, {
12
+ enumerable: true,
13
+ get: function() {
14
+ return from[k];
15
+ }
16
+ });
17
+ }
18
+ });
19
+ return from;
20
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./reflection.types.js"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get MetaDataOwners () {
13
+ return MetaDataOwners;
14
+ },
15
+ get ReflectionMeta () {
16
+ return ReflectionMeta;
17
+ }
18
+ });
19
+ const MetaDataOwners = {
20
+ Hearth: "hearth",
21
+ Reflect: "design"
22
+ };
23
+ const ReflectionMeta = {
24
+ paramtypes: `${MetaDataOwners.Reflect}:paramtypes`,
25
+ type: `${MetaDataOwners.Reflect}:type`
26
+ };
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get defineArgumentMeta () {
13
+ return defineArgumentMeta;
14
+ },
15
+ get defineMeta () {
16
+ return defineMeta;
17
+ },
18
+ get getArgumentMeta () {
19
+ return getArgumentMeta;
20
+ },
21
+ get getFieldType () {
22
+ return getFieldType;
23
+ },
24
+ get getFields () {
25
+ return getFields;
26
+ },
27
+ get getFunction () {
28
+ return getFunction;
29
+ },
30
+ get getFunctionArgs () {
31
+ return getFunctionArgs;
32
+ },
33
+ get getFunctionMetadata () {
34
+ return getFunctionMetadata;
35
+ },
36
+ get getFunctions () {
37
+ return getFunctions;
38
+ },
39
+ get getMeta () {
40
+ return getMeta;
41
+ },
42
+ get isArrayType () {
43
+ return isArrayType;
44
+ },
45
+ get isConstructable () {
46
+ return isConstructable;
47
+ },
48
+ get isDateType () {
49
+ return isDateType;
50
+ },
51
+ get isPrimitiveOrDateType () {
52
+ return isPrimitiveOrDateType;
53
+ }
54
+ });
55
+ const _reflectiontypes = require("./types/reflection.types.js");
56
+ const Primitives = [
57
+ "string",
58
+ "number",
59
+ "bigint",
60
+ "boolean",
61
+ "undefined",
62
+ "symbol",
63
+ "null"
64
+ ];
65
+ const isPrimitiveOrDateType = (type)=>{
66
+ return Primitives.includes(type.name.toLocaleLowerCase()) || isDateType(type);
67
+ };
68
+ const isDateType = (type)=>{
69
+ return type?.prototype === Date.prototype;
70
+ };
71
+ function isConstructable(type) {
72
+ const proto = type?.prototype;
73
+ const isConstructable = typeof type === "function" && typeof proto === "object";
74
+ return isConstructable;
75
+ }
76
+ const isArrayType = (type)=>{
77
+ return type?.prototype === Array.prototype;
78
+ };
79
+ function getMeta(key, target, propertyKey) {
80
+ const meta = Reflect.getMetadata(key, target, propertyKey);
81
+ return meta;
82
+ }
83
+ function getFunctions(object) {
84
+ const functions = Object.entries(Object.getOwnPropertyDescriptors(object.prototype)).filter(([key])=>key !== "constructor").map(([, value])=>value);
85
+ return functions;
86
+ }
87
+ function getFunction(object, functionName) {
88
+ const [, value] = Object.entries(Object.getOwnPropertyDescriptors(object.prototype)).find(([k])=>k !== "constructor" && k === functionName);
89
+ return value;
90
+ }
91
+ function getFunctionMetadata(key, target, func) {
92
+ const meta = Reflect.getMetadata(key, target, func.name);
93
+ return meta;
94
+ }
95
+ function getFunctionArgs(target, func) {
96
+ const meta = getFunctionMetadata(_reflectiontypes.ReflectionMeta.paramtypes, target, func);
97
+ return meta;
98
+ }
99
+ function getFields(object) {
100
+ const fields = Object.entries(Object.getOwnPropertyDescriptors(object)).filter(([, val])=>typeof val.value !== "function").map(([key, propertyDescriptor])=>({
101
+ key,
102
+ propertyDescriptor
103
+ }));
104
+ return fields;
105
+ }
106
+ function getFieldType(target, fieldName) {
107
+ return Reflect.getMetadata(_reflectiontypes.ReflectionMeta.type, target, fieldName);
108
+ }
109
+ function getArgumentMeta(key, target, argIndex) {
110
+ const meta = Reflect.getMetadata(key, target, argIndex.toString());
111
+ return meta;
112
+ }
113
+ function defineMeta(key, value, target) {
114
+ Reflect.defineMetadata(key, value, target);
115
+ }
116
+ function defineArgumentMeta(key, value, func, argIndex) {
117
+ Reflect.defineMetadata(key, value, func, argIndex.toString());
118
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./semver.js"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }