@modern-js/server 2.48.0 → 2.48.2

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 (31) hide show
  1. package/dist/cjs/constants.js +1 -1
  2. package/dist/cjs/dev-tools/dev-middleware/index.js +0 -4
  3. package/dist/cjs/dev-tools/dev-middleware/socketServer.js +2 -7
  4. package/dist/cjs/dev-tools/watcher/dependencyTree.js +0 -3
  5. package/dist/cjs/dev-tools/watcher/index.js +1 -3
  6. package/dist/cjs/dev-tools/watcher/statsCache.js +2 -3
  7. package/dist/cjs/server/devServer.js +6 -40
  8. package/dist/cjs/server/devServerOld.js +3 -9
  9. package/dist/cjs/server/workerSSRRender.js +1 -1
  10. package/dist/esm/constants.js +1 -1
  11. package/dist/esm/dev-tools/dev-middleware/index.js +42 -58
  12. package/dist/esm/dev-tools/dev-middleware/socketServer.js +130 -179
  13. package/dist/esm/dev-tools/watcher/dependencyTree.js +59 -80
  14. package/dist/esm/dev-tools/watcher/index.js +63 -82
  15. package/dist/esm/dev-tools/watcher/statsCache.js +55 -76
  16. package/dist/esm/server/devServer.js +432 -522
  17. package/dist/esm/server/devServerOld.js +455 -515
  18. package/dist/esm/server/workerSSRRender.js +1 -1
  19. package/dist/esm-node/constants.js +1 -1
  20. package/dist/esm-node/dev-tools/dev-middleware/index.js +0 -4
  21. package/dist/esm-node/dev-tools/dev-middleware/socketServer.js +2 -7
  22. package/dist/esm-node/dev-tools/watcher/dependencyTree.js +0 -3
  23. package/dist/esm-node/dev-tools/watcher/index.js +1 -3
  24. package/dist/esm-node/dev-tools/watcher/statsCache.js +2 -3
  25. package/dist/esm-node/server/devServer.js +6 -40
  26. package/dist/esm-node/server/devServerOld.js +3 -9
  27. package/dist/esm-node/server/workerSSRRender.js +1 -1
  28. package/dist/types/server/devServer.d.ts +1 -1
  29. package/dist/types/server/devServerOld.d.ts +1 -1
  30. package/dist/types/types.d.ts +3 -3
  31. package/package.json +10 -10
@@ -1,99 +1,78 @@
1
1
  import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
2
- import { _ as _create_class } from "@swc/helpers/_/_create_class";
3
- import { _ as _define_property } from "@swc/helpers/_/_define_property";
4
2
  import fs from "fs";
5
3
  import crypto from "crypto";
6
4
  var StatsCache = /* @__PURE__ */ function() {
7
5
  "use strict";
8
6
  function StatsCache2() {
9
7
  _class_call_check(this, StatsCache2);
10
- _define_property(this, "cachedHash", {});
11
- _define_property(this, "cachedSize", {});
8
+ this.cachedHash = {};
9
+ this.cachedSize = {};
12
10
  }
13
- _create_class(StatsCache2, [
14
- {
15
- key: "add",
16
- value: function add(files) {
17
- var _this = this, cachedHash = _this.cachedHash, cachedSize = _this.cachedSize;
18
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
19
- try {
20
- for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
21
- var filename = _step.value;
22
- if (fs.existsSync(filename)) {
23
- var stats = fs.statSync(filename);
24
- if (stats.isFile() && !cachedHash[filename]) {
25
- cachedHash[filename] = this.hash(stats, filename);
26
- cachedSize[filename] = stats.size;
27
- }
28
- }
29
- }
30
- } catch (err) {
31
- _didIteratorError = true;
32
- _iteratorError = err;
33
- } finally {
34
- try {
35
- if (!_iteratorNormalCompletion && _iterator.return != null) {
36
- _iterator.return();
37
- }
38
- } finally {
39
- if (_didIteratorError) {
40
- throw _iteratorError;
41
- }
42
- }
43
- }
44
- }
45
- },
46
- {
47
- key: "refresh",
48
- value: function refresh(filename) {
49
- var _this = this, cachedHash = _this.cachedHash, cachedSize = _this.cachedSize;
11
+ var _proto = StatsCache2.prototype;
12
+ _proto.add = function add(files) {
13
+ var _this = this, cachedHash = _this.cachedHash, cachedSize = _this.cachedSize;
14
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
15
+ try {
16
+ for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
17
+ var filename = _step.value;
50
18
  if (fs.existsSync(filename)) {
51
19
  var stats = fs.statSync(filename);
52
- if (stats.isFile()) {
20
+ if (stats.isFile() && !cachedHash[filename]) {
53
21
  cachedHash[filename] = this.hash(stats, filename);
54
22
  cachedSize[filename] = stats.size;
55
23
  }
56
24
  }
57
25
  }
58
- },
59
- {
60
- key: "del",
61
- value: function del(filename) {
62
- if (this.cachedHash[filename]) {
63
- delete this.cachedHash[filename];
64
- delete this.cachedSize[filename];
65
- }
66
- }
67
- },
68
- {
69
- key: "isDiff",
70
- value: function isDiff(filename) {
71
- var _this = this, cachedHash = _this.cachedHash, cachedSize = _this.cachedSize;
72
- var stats = fs.statSync(filename);
73
- var hash = cachedHash[filename];
74
- var size = cachedSize[filename];
75
- if (stats.size !== size) {
76
- return true;
26
+ } catch (err) {
27
+ _didIteratorError = true;
28
+ _iteratorError = err;
29
+ } finally {
30
+ try {
31
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
32
+ _iterator.return();
77
33
  }
78
- if (this.hash(stats, filename) !== hash) {
79
- return true;
34
+ } finally {
35
+ if (_didIteratorError) {
36
+ throw _iteratorError;
80
37
  }
81
- return false;
82
38
  }
83
- },
84
- {
85
- key: "has",
86
- value: function has(filename) {
87
- return Boolean(this.cachedHash[filename]);
88
- }
89
- },
90
- {
91
- key: "hash",
92
- value: function hash(stats, filename) {
93
- return crypto.createHash("md5").update(fs.readFileSync(filename)).digest("hex");
39
+ }
40
+ };
41
+ _proto.refresh = function refresh(filename) {
42
+ var _this = this, cachedHash = _this.cachedHash, cachedSize = _this.cachedSize;
43
+ if (fs.existsSync(filename)) {
44
+ var stats = fs.statSync(filename);
45
+ if (stats.isFile()) {
46
+ cachedHash[filename] = this.hash(stats, filename);
47
+ cachedSize[filename] = stats.size;
94
48
  }
95
49
  }
96
- ]);
50
+ };
51
+ _proto.del = function del(filename) {
52
+ if (this.cachedHash[filename]) {
53
+ delete this.cachedHash[filename];
54
+ delete this.cachedSize[filename];
55
+ }
56
+ };
57
+ _proto.isDiff = function isDiff(filename) {
58
+ var _this = this, cachedHash = _this.cachedHash, cachedSize = _this.cachedSize;
59
+ var stats = fs.statSync(filename);
60
+ var hash = cachedHash[filename];
61
+ var size = cachedSize[filename];
62
+ if (stats.size !== size) {
63
+ return true;
64
+ }
65
+ if (this.hash(stats, filename) !== hash) {
66
+ return true;
67
+ }
68
+ return false;
69
+ };
70
+ _proto.has = function has(filename) {
71
+ return Boolean(this.cachedHash[filename]);
72
+ };
73
+ _proto.hash = function hash(stats, filename) {
74
+ return crypto.createHash("md5").update(fs.readFileSync(filename)).digest("hex");
75
+ };
97
76
  return StatsCache2;
98
77
  }();
99
78
  export {