eddev 0.2.65 → 0.2.67-beta1

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 (190) hide show
  1. package/admin/components/ImageWell.d.ts +2 -3
  2. package/admin/components/ImageWell.js +39 -51
  3. package/admin/defineField.d.ts +2 -2
  4. package/admin/defineWidget.d.ts +1 -1
  5. package/admin/defineWidget.js +2 -2
  6. package/admin/index.js +5 -1
  7. package/admin/installFieldTypes.js +26 -26
  8. package/admin/runWidgets.js +17 -28
  9. package/admin/selectMedia.d.ts +2 -2
  10. package/admin/selectMedia.js +1 -1
  11. package/blocks/ContentBlocks.d.ts +6 -6
  12. package/blocks/ContentBlocks.js +58 -66
  13. package/blocks/ErrorBoundaryEditor.d.ts +1 -1
  14. package/blocks/ErrorBoundaryEditor.js +16 -45
  15. package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
  16. package/blocks/ErrorBoundaryFrontend.js +16 -45
  17. package/blocks/InspectorControls.d.ts +1 -1
  18. package/blocks/InspectorControls.js +3 -3
  19. package/blocks/blockAttributes.d.ts +2 -2
  20. package/blocks/blockAttributes.js +24 -44
  21. package/blocks/index.js +5 -1
  22. package/blocks/inlineEditing.d.ts +7 -7
  23. package/blocks/inlineEditing.js +36 -55
  24. package/blocks/installGutenbergHooks.js +48 -68
  25. package/build/babel/plugin-name-defined-components.js +15 -16
  26. package/build/build-favicon.js +11 -62
  27. package/build/clean.js +5 -52
  28. package/build/create-codegen-worker.js +78 -33
  29. package/build/create-serverless-dev-worker.js +61 -39
  30. package/build/create-webpack-worker.js +65 -33
  31. package/build/file-tree.d.ts +2 -2
  32. package/build/file-tree.js +12 -12
  33. package/build/get-webpack-config.js +341 -395
  34. package/build/graphql-codegen/graphql-codegen-files.js +31 -25
  35. package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
  36. package/build/graphql-codegen/graphql-codegen-queries.js +102 -99
  37. package/build/manifests/manifest-blocks.d.ts +1 -1
  38. package/build/manifests/manifest-blocks.js +37 -29
  39. package/build/manifests/manifest-fields.d.ts +1 -1
  40. package/build/manifests/manifest-fields.js +23 -21
  41. package/build/manifests/manifest-views.d.ts +1 -1
  42. package/build/manifests/manifest-views.js +32 -25
  43. package/build/manifests/manifest-widgets.d.ts +1 -1
  44. package/build/manifests/manifest-widgets.js +22 -20
  45. package/build/manifests/manifest.d.ts +2 -2
  46. package/build/manifests/manifest.js +30 -90
  47. package/build/reporter.d.ts +1 -1
  48. package/build/reporter.js +29 -32
  49. package/build/serverless/create-next-app.d.ts +1 -1
  50. package/build/serverless/create-next-app.js +245 -467
  51. package/build/state/codegen-state.d.ts +4 -4
  52. package/build/state/compiler-state.d.ts +5 -5
  53. package/build/state/serverless-state.d.ts +3 -3
  54. package/build/workers/codegen-worker-script.js +392 -507
  55. package/build/workers/serverless-worker-dev-script.js +4 -4
  56. package/build/workers/webpack-worker-script.js +89 -150
  57. package/cli/build.dev.d.ts +1 -1
  58. package/cli/build.dev.js +79 -126
  59. package/cli/build.prod.d.ts +1 -1
  60. package/cli/build.prod.js +42 -98
  61. package/cli/cli.js +16 -55
  62. package/cli/display/components/BundleDisplay.d.ts +1 -2
  63. package/cli/display/components/BundleDisplay.js +13 -24
  64. package/cli/display/components/CodegenDisplay.d.ts +1 -2
  65. package/cli/display/components/CodegenDisplay.js +14 -25
  66. package/cli/display/components/DevCLIDisplay.d.ts +2 -3
  67. package/cli/display/components/DevCLIDisplay.js +14 -25
  68. package/cli/display/components/Fullscreen.js +9 -20
  69. package/cli/display/components/ServerlessDisplay.d.ts +2 -3
  70. package/cli/display/components/ServerlessDisplay.js +15 -26
  71. package/cli/display/components/StatusIcon.d.ts +2 -3
  72. package/cli/display/components/StatusIcon.js +3 -3
  73. package/cli/preinstall.js +4 -5
  74. package/cli/setup.js +25 -73
  75. package/components/AdminBar.d.ts +1 -2
  76. package/components/AdminBar.js +37 -3
  77. package/components/BrowserRouter.d.ts +2 -2
  78. package/components/BrowserRouter.js +41 -54
  79. package/components/InlinePage.d.ts +2 -2
  80. package/components/InlinePage.js +17 -29
  81. package/components/NextRouter.d.ts +2 -2
  82. package/components/NextRouter.js +20 -29
  83. package/components/index.js +5 -1
  84. package/config/config-schema.d.ts +1 -1
  85. package/config/config-schema.js +1 -1
  86. package/config/create-schema-file.js +6 -6
  87. package/config/get-config.js +10 -13
  88. package/config/index.js +5 -1
  89. package/config/parse-config.js +1 -1
  90. package/config/print-zod-errors.js +3 -3
  91. package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -3
  92. package/dev-ui/components/BreakpointColumnHeader.js +7 -18
  93. package/dev-ui/components/BreakpointIndicator.d.ts +1 -2
  94. package/dev-ui/components/BreakpointIndicator.js +25 -32
  95. package/dev-ui/components/DevUI.d.ts +1 -2
  96. package/dev-ui/components/DevUI.js +13 -13
  97. package/dev-ui/components/Launcher.d.ts +2 -2
  98. package/dev-ui/components/Launcher.js +13 -25
  99. package/dev-ui/components/PanelWrapper.d.ts +2 -2
  100. package/dev-ui/components/PanelWrapper.js +8 -8
  101. package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -3
  102. package/dev-ui/components/ResponsiveLerpControl.js +27 -38
  103. package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -5
  104. package/dev-ui/components/ResponsiveScaleEditor.js +64 -78
  105. package/dev-ui/components/atoms/Button.js +1 -1
  106. package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
  107. package/dev-ui/components/atoms/Dropdown.js +8 -9
  108. package/dev-ui/components/atoms/NumberField.d.ts +2 -3
  109. package/dev-ui/components/atoms/NumberField.js +29 -42
  110. package/dev-ui/components/atoms/Spacer.js +1 -1
  111. package/dev-ui/components/atoms/Text.js +1 -1
  112. package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
  113. package/dev-ui/components/atoms/ToggleButton.js +5 -16
  114. package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
  115. package/dev-ui/components/atoms/Tooltip.js +8 -20
  116. package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -2
  117. package/dev-ui/components/panels/AppDataDebugger.js +8 -19
  118. package/dev-ui/components/panels/ColorEditor.d.ts +1 -2
  119. package/dev-ui/components/panels/ColorEditor.js +35 -42
  120. package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -2
  121. package/dev-ui/components/panels/PageDataDebugger.js +8 -20
  122. package/dev-ui/components/panels/QueryDebugger.d.ts +1 -2
  123. package/dev-ui/components/panels/QueryDebugger.js +12 -24
  124. package/dev-ui/components/panels/SpacingEditor.d.ts +1 -2
  125. package/dev-ui/components/panels/SpacingEditor.js +34 -48
  126. package/dev-ui/components/panels/TypographyEditor.d.ts +1 -2
  127. package/dev-ui/components/panels/TypographyEditor.js +38 -46
  128. package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
  129. package/dev-ui/hooks/useBreakpoint.js +13 -13
  130. package/dev-ui/hooks/usePersistState.js +6 -7
  131. package/dev-ui/hooks/useStylesheet.js +6 -6
  132. package/dev-ui/icons.d.ts +15 -16
  133. package/dev-ui/icons.js +16 -27
  134. package/dev-ui/index.js +5 -1
  135. package/dev-ui/loader.d.ts +1 -2
  136. package/dev-ui/loader.js +13 -9
  137. package/dev-ui/panels.d.ts +2 -2
  138. package/dev-ui/panels.js +7 -7
  139. package/dev-ui/theme.d.ts +96 -70
  140. package/dev-ui/theme.js +3 -3
  141. package/dynamic/dynamic-component.d.ts +1 -10
  142. package/dynamic/dynamic-component.js +1 -1
  143. package/dynamic/index.js +5 -1
  144. package/entry/Root.d.ts +2 -3
  145. package/entry/Root.js +16 -26
  146. package/entry/entry.admin.dev.js +4 -4
  147. package/entry/entry.admin.prod.js +4 -4
  148. package/entry/entry.monolith.dev.js +5 -5
  149. package/entry/entry.monolith.prod.js +5 -5
  150. package/gravityforms/gravity-forms.d.ts +2 -2
  151. package/gravityforms/index.js +5 -1
  152. package/gravityforms/useGravityForm.d.ts +2 -2
  153. package/gravityforms/useGravityForm.js +126 -130
  154. package/hooks/index.js +5 -1
  155. package/hooks/queryUtils.d.ts +14 -14
  156. package/hooks/queryUtils.js +101 -192
  157. package/hooks/useAppData.d.ts +2 -2
  158. package/hooks/useAppData.js +9 -9
  159. package/hooks/usePageLoad.js +4 -4
  160. package/hooks/useQueryDebug.d.ts +1 -1
  161. package/hooks/useQueryDebug.js +7 -7
  162. package/hooks/useRPC.d.ts +4 -4
  163. package/hooks/useRPC.js +3 -3
  164. package/package.json +7 -7
  165. package/routing/index.js +5 -1
  166. package/routing/remoteProps.d.ts +1 -1
  167. package/routing/remoteProps.js +31 -72
  168. package/routing/routing.d.ts +15 -15
  169. package/routing/routing.js +108 -170
  170. package/routing/updateEditLink.js +1 -1
  171. package/serverless/define-api.d.ts +1 -1
  172. package/serverless/define-rpc-router.js +8 -4
  173. package/serverless/index.js +6 -2
  174. package/serverless-template/_utils/fetch-wordpress-props.ts +0 -4
  175. package/serverless-template/_utils/fetch-wp.ts +0 -1
  176. package/style/createStitches.d.ts +375 -783
  177. package/style/createStitches.js +164 -142
  178. package/style/index.js +5 -1
  179. package/tsconfig.json +1 -1
  180. package/utils/Observable.d.ts +2 -2
  181. package/utils/Observable.js +12 -15
  182. package/utils/getRepoName.js +3 -3
  183. package/utils/promptIfRepoNameIncorrect.js +18 -64
  184. package/utils/refreshOverlayInterop.js +1 -1
  185. package/utils/reportErrorStack.d.ts +1 -1
  186. package/utils/reportErrorStack.js +1 -1
  187. package/utils/serverlessAppContext.js +1 -1
  188. package/utils/updateEnvFile.js +19 -69
  189. package/utils/useObservable.js +3 -3
  190. package/views/index.js +5 -1
@@ -1,70 +1,115 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createCodegenWorker = void 0;
15
- var worker_threads_1 = require("worker_threads");
16
- var path_1 = require("path");
17
- var Observable_1 = require("../utils/Observable");
4
+ const worker_threads_1 = require("worker_threads");
5
+ const path_1 = require("path");
6
+ const Observable_1 = require("../utils/Observable");
18
7
  function createCodegenWorker(opts) {
19
- var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/codegen-worker-script.js"), {
8
+ const worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/codegen-worker-script.js"), {
20
9
  workerData: opts,
21
10
  stderr: true,
22
11
  stdin: false,
23
12
  stdout: true,
24
- env: __assign(__assign({}, process.env), { FORCE_COLOR: "1" }),
13
+ env: {
14
+ ...process.env,
15
+ FORCE_COLOR: "1",
16
+ },
25
17
  });
26
- worker.stderr.on("data", function (chunk) {
27
- subject.update(function (state) { return (__assign(__assign({}, state), { log: (state.log || "") + chunk })); });
18
+ worker.stderr.on("data", (chunk) => {
19
+ subject.update((state) => ({
20
+ ...state,
21
+ log: (state.log || "") + chunk,
22
+ }));
28
23
  });
29
- worker.stdout.on("data", function (chunk) {
24
+ worker.stdout.on("data", (chunk) => {
30
25
  if (subject.value.status === "generating") {
31
- subject.update(function (state) { return (__assign(__assign({}, state), { log: String(chunk) })); });
26
+ subject.update((state) => ({
27
+ ...state,
28
+ log: String(chunk),
29
+ }));
32
30
  }
33
31
  else {
34
- subject.update(function (state) { return (__assign(__assign({}, state), { log: (state.log || "") + chunk })); });
32
+ subject.update((state) => ({
33
+ ...state,
34
+ log: (state.log || "") + chunk,
35
+ }));
35
36
  }
36
37
  });
37
- var subject = new Observable_1.Observable({
38
+ const subject = new Observable_1.Observable({
38
39
  title: "GraphQL Codegen",
39
40
  status: "ready",
40
41
  log: "",
41
42
  });
42
- worker.on("error", function (err) {
43
+ worker.on("error", (err) => {
43
44
  console.log(err);
44
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error" })); });
45
+ subject.update((state) => ({
46
+ ...state,
47
+ status: "error",
48
+ }));
45
49
  });
46
- worker.on("message", function (data) {
50
+ worker.on("message", (data) => {
47
51
  if (data.code === "ready") {
48
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "ready", log: opts.retainLog ? state.log : "", duration: 0, errors: [] })); });
52
+ subject.update((state) => ({
53
+ ...state,
54
+ status: "ready",
55
+ log: opts.retainLog ? state.log : "",
56
+ duration: 0,
57
+ errors: [],
58
+ }));
49
59
  }
50
60
  else if (data.code === "fetching") {
51
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "fetching", log: opts.retainLog ? state.log : "", duration: 0, errors: [] })); });
61
+ subject.update((state) => ({
62
+ ...state,
63
+ status: "fetching",
64
+ log: opts.retainLog ? state.log : "",
65
+ duration: 0,
66
+ errors: [],
67
+ }));
52
68
  }
53
69
  else if (data.code === "generating") {
54
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "generating", errors: [], duration: 0, log: opts.retainLog ? state.log : "" })); });
70
+ subject.update((state) => ({
71
+ ...state,
72
+ status: "generating",
73
+ errors: [],
74
+ duration: 0,
75
+ log: opts.retainLog ? state.log : "",
76
+ }));
55
77
  }
56
78
  else if (data.code === "error") {
57
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error", statusLabel: "", duration: 0, reason: undefined, errors: data.errors })); });
79
+ subject.update((state) => ({
80
+ ...state,
81
+ status: "error",
82
+ statusLabel: "",
83
+ duration: 0,
84
+ reason: undefined,
85
+ errors: data.errors,
86
+ }));
58
87
  }
59
88
  else if (data.code === "success") {
60
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "success", duration: data.duration, reason: data.reason, errors: [], log: opts.retainLog ? state.log : "" })); });
89
+ subject.update((state) => ({
90
+ ...state,
91
+ status: "success",
92
+ duration: data.duration,
93
+ reason: data.reason,
94
+ errors: [],
95
+ log: opts.retainLog ? state.log : "",
96
+ }));
61
97
  }
62
98
  else if (data.code === "invalidated") {
63
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "invalidated", reason: data.reason, duration: 0 })); });
99
+ subject.update((state) => ({
100
+ ...state,
101
+ status: "invalidated",
102
+ reason: data.reason,
103
+ duration: 0,
104
+ }));
64
105
  }
65
106
  });
66
- worker.on("exit", function () {
67
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "success", log: opts.retainLog ? state.log : "" })); });
107
+ worker.on("exit", () => {
108
+ subject.update((state) => ({
109
+ ...state,
110
+ status: "success",
111
+ log: opts.retainLog ? state.log : "",
112
+ }));
68
113
  });
69
114
  return subject;
70
115
  }
@@ -1,44 +1,36 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createServerlessWorker = void 0;
15
- var worker_threads_1 = require("worker_threads");
16
- var path_1 = require("path");
17
- var Observable_1 = require("../utils/Observable");
4
+ const worker_threads_1 = require("worker_threads");
5
+ const path_1 = require("path");
6
+ const Observable_1 = require("../utils/Observable");
18
7
  function createServerlessWorker() {
19
- var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/serverless-worker-dev-script.js"), {
8
+ const worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/serverless-worker-dev-script.js"), {
20
9
  workerData: {},
21
10
  stderr: true,
22
11
  stdin: false,
23
12
  stdout: true,
24
- env: __assign(__assign({}, process.env), { FORCE_COLOR: "1" }),
13
+ env: {
14
+ ...process.env,
15
+ FORCE_COLOR: "1",
16
+ },
25
17
  });
26
- var subject = new Observable_1.Observable({
18
+ const subject = new Observable_1.Observable({
27
19
  title: "Serverless",
28
20
  status: "starting",
29
21
  log: "",
30
22
  });
31
- var parseChunk = function (str) {
32
- var escaped = JSON.stringify(str).replace(/(^"|"$)/g, "");
33
- var status;
34
- var duration = 0;
23
+ const parseChunk = (str) => {
24
+ const escaped = JSON.stringify(str).replace(/(^"|"$)/g, "");
25
+ let status;
26
+ let duration = 0;
35
27
  if (str.includes("\u001b[31merror\u001b[39m")) {
36
28
  status = "error";
37
29
  }
38
30
  else if (str.includes("\u001b[35mevent\u001b[39m") && str.includes("successfully")) {
39
31
  status = "success";
40
- var secondsMatch = str.match(/[0-9.]+s/);
41
- var msMatch = str.match(/[0-9.]+ ms/);
32
+ const secondsMatch = str.match(/[0-9.]+s/);
33
+ const msMatch = str.match(/[0-9.]+ ms/);
42
34
  if (secondsMatch) {
43
35
  duration = parseFloat(secondsMatch[0].replace("s", "")) * 1000;
44
36
  }
@@ -51,41 +43,71 @@ function createServerlessWorker() {
51
43
  }
52
44
  return {
53
45
  text: str,
54
- status: status,
55
- duration: duration,
46
+ status,
47
+ duration,
56
48
  };
57
49
  };
58
- var handleChunk = function (chunk) {
59
- var result = parseChunk(String(chunk));
60
- subject.update(function (state) { return (__assign(__assign({}, state), { log: (state.log || "") + result.text, status: result.status ? result.status : state.status, duration: result.status === "success" ? result.duration : state.duration })); });
50
+ const handleChunk = (chunk) => {
51
+ const result = parseChunk(String(chunk));
52
+ subject.update((state) => ({
53
+ ...state,
54
+ log: (state.log || "") + result.text,
55
+ status: result.status ? result.status : state.status,
56
+ duration: result.status === "success" ? result.duration : state.duration,
57
+ }));
61
58
  };
62
59
  worker.stderr.on("data", handleChunk);
63
60
  worker.stdout.on("data", handleChunk);
64
- worker.on("error", function (err) {
61
+ worker.on("error", (err) => {
65
62
  console.log(err);
66
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error" })); });
63
+ subject.update((state) => ({
64
+ ...state,
65
+ status: "error",
66
+ }));
67
67
  });
68
- worker.on("exit", function (code) {
69
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error" })); });
68
+ worker.on("exit", (code) => {
69
+ subject.update((state) => ({
70
+ ...state,
71
+ status: "error",
72
+ }));
70
73
  });
71
- worker.on("message", function (data) {
74
+ worker.on("message", (data) => {
72
75
  if (data.code === "preparing") {
73
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "preparing" })); });
76
+ subject.update((state) => ({
77
+ ...state,
78
+ status: "preparing",
79
+ }));
74
80
  }
75
81
  else if (data.code === "packaging") {
76
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "packaging" })); });
82
+ subject.update((state) => ({
83
+ ...state,
84
+ status: "packaging",
85
+ }));
77
86
  }
78
87
  else if (data.code === "compiling") {
79
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "compiling" })); });
88
+ subject.update((state) => ({
89
+ ...state,
90
+ status: "compiling",
91
+ }));
80
92
  }
81
93
  else if (data.code === "finished") {
82
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "success", duration: data.duration })); });
94
+ subject.update((state) => ({
95
+ ...state,
96
+ status: "success",
97
+ duration: data.duration,
98
+ }));
83
99
  }
84
100
  else if (data.code === "error") {
85
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error" })); });
101
+ subject.update((state) => ({
102
+ ...state,
103
+ status: "error",
104
+ }));
86
105
  }
87
106
  else if (data.code === "url") {
88
- subject.update(function (state) { return (__assign(__assign({}, state), { url: data.url })); });
107
+ subject.update((state) => ({
108
+ ...state,
109
+ url: data.url,
110
+ }));
89
111
  }
90
112
  });
91
113
  // worker.on("exit", () => {
@@ -1,63 +1,95 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createWebpackWorker = void 0;
15
- var worker_threads_1 = require("worker_threads");
16
- var path_1 = require("path");
17
- var Observable_1 = require("../utils/Observable");
4
+ const worker_threads_1 = require("worker_threads");
5
+ const path_1 = require("path");
6
+ const Observable_1 = require("../utils/Observable");
18
7
  function createWebpackWorker(opts) {
19
- var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/webpack-worker-script.js"), {
8
+ const worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/webpack-worker-script.js"), {
20
9
  workerData: opts,
21
10
  stderr: true,
22
11
  stdin: false,
23
12
  stdout: true,
24
- env: __assign(__assign({}, process.env), { FORCE_COLOR: "1" }),
13
+ env: {
14
+ ...process.env,
15
+ FORCE_COLOR: "1",
16
+ },
25
17
  });
26
- worker.stderr.on("data", function (chunk) {
27
- subject.update(function (state) { return (__assign(__assign({}, state), { log: (state.log || "") + chunk })); });
18
+ worker.stderr.on("data", (chunk) => {
19
+ subject.update((state) => ({
20
+ ...state,
21
+ log: (state.log || "") + chunk,
22
+ }));
28
23
  });
29
- worker.stdout.on("data", function (chunk) {
30
- var str = chunk.toString();
24
+ worker.stdout.on("data", (chunk) => {
25
+ const str = chunk.toString();
31
26
  if (str.includes("Project is running at") || str.includes("webpack output is served from")) {
32
27
  return;
33
28
  }
34
- subject.update(function (state) { return (__assign(__assign({}, state), { log: (state.log || "") + str })); });
29
+ subject.update((state) => ({
30
+ ...state,
31
+ log: (state.log || "") + str,
32
+ }));
35
33
  });
36
- var subject = new Observable_1.Observable({
34
+ const subject = new Observable_1.Observable({
37
35
  title: opts.title,
38
36
  status: "starting",
39
37
  });
40
- worker.on("error", function (err) {
41
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error", error: err })); });
38
+ worker.on("error", (err) => {
39
+ subject.update((state) => ({
40
+ ...state,
41
+ status: "error",
42
+ error: err,
43
+ }));
42
44
  });
43
- worker.on("message", function (data) {
45
+ worker.on("message", (data) => {
44
46
  if (data.code === "compiling") {
45
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "compiling", statusLabel: state.status === "compiling" ? state.statusLabel : "", log: opts.retainLog ? state.log : "", duration: 0, errors: [] })); });
47
+ subject.update((state) => ({
48
+ ...state,
49
+ status: "compiling",
50
+ statusLabel: state.status === "compiling" ? state.statusLabel : "",
51
+ log: opts.retainLog ? state.log : "",
52
+ duration: 0,
53
+ errors: [],
54
+ }));
46
55
  }
47
56
  else if (data.code === "error") {
48
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "error", statusLabel: "", duration: 0, errors: data.errors })); });
57
+ subject.update((state) => ({
58
+ ...state,
59
+ status: "error",
60
+ statusLabel: "",
61
+ duration: 0,
62
+ errors: data.errors,
63
+ }));
49
64
  }
50
65
  else if (data.code === "finished") {
51
- subject.update(function (state) { return (__assign(__assign({}, state), { status: data.watching ? "waiting" : "success", statusLabel: "", duration: data.duration, log: opts.retainLog ? state.log : "", errors: data.errors })); });
66
+ subject.update((state) => ({
67
+ ...state,
68
+ status: data.watching ? "waiting" : "success",
69
+ statusLabel: "",
70
+ duration: data.duration,
71
+ log: opts.retainLog ? state.log : "",
72
+ errors: data.errors,
73
+ }));
52
74
  }
53
75
  else if (data.code === "invalidated") {
54
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "compiling", statusLabel: data.changedFile
55
- ? "Rebuilding (".concat(data.changedFile.replace(opts.baseDirectory, ""), ")")
56
- : "Rebuilding (changes detected)", log: opts.retainLog ? state.log : "", duration: 0, errors: [] })); });
76
+ subject.update((state) => ({
77
+ ...state,
78
+ status: "compiling",
79
+ statusLabel: data.changedFile
80
+ ? `Rebuilding (${data.changedFile.replace(opts.baseDirectory, "")})`
81
+ : "Rebuilding (changes detected)",
82
+ log: opts.retainLog ? state.log : "",
83
+ duration: 0,
84
+ errors: [],
85
+ }));
57
86
  }
58
87
  });
59
- worker.on("exit", function () {
60
- subject.update(function (state) { return (__assign(__assign({}, state), { status: "success" })); });
88
+ worker.on("exit", () => {
89
+ subject.update((state) => ({
90
+ ...state,
91
+ status: "success",
92
+ }));
61
93
  });
62
94
  return subject;
63
95
  }
@@ -1,5 +1,5 @@
1
- declare type FileList = string[];
2
- declare type Disposer = () => void;
1
+ type FileList = string[];
2
+ type Disposer = () => void;
3
3
  export declare function watchFileTree(pattern: string, callback: (files: FileList) => void): Promise<Disposer>;
4
4
  export declare function getFileTree(pattern: string): Promise<FileList>;
5
5
  export {};
@@ -4,35 +4,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getFileTree = exports.watchFileTree = void 0;
7
- var chokidar_1 = __importDefault(require("chokidar"));
8
- var glob_promise_1 = __importDefault(require("glob-promise"));
7
+ const chokidar_1 = __importDefault(require("chokidar"));
8
+ const glob_promise_1 = __importDefault(require("glob-promise"));
9
9
  function watchFileTree(pattern, callback) {
10
- var files = [];
11
- var ready = false;
12
- return new Promise(function (resolve) {
10
+ const files = [];
11
+ let ready = false;
12
+ return new Promise((resolve) => {
13
13
  // Watch, according
14
- var watcher = chokidar_1.default
14
+ const watcher = chokidar_1.default
15
15
  .watch(pattern)
16
- .on("add", function (path) {
16
+ .on("add", (path) => {
17
17
  files.push(path);
18
18
  if (ready)
19
19
  callback(files);
20
20
  })
21
- .on("unlink", function (path) {
22
- var i = files.indexOf(path);
21
+ .on("unlink", (path) => {
22
+ const i = files.indexOf(path);
23
23
  if (i !== -1)
24
24
  files.splice(i, 1);
25
25
  if (ready)
26
26
  callback(files);
27
27
  })
28
- .on("change", function () {
28
+ .on("change", () => {
29
29
  if (ready)
30
30
  callback(files);
31
31
  })
32
- .on("ready", function () {
32
+ .on("ready", () => {
33
33
  ready = true;
34
34
  callback(files);
35
- resolve(function () {
35
+ resolve(() => {
36
36
  watcher.close();
37
37
  });
38
38
  });