@wix/cli 1.1.67 → 1.1.69

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 (114) hide show
  1. package/build/{DevCommand-AVJ663GA.js → DevCommand-33URDS3V.js} +13 -13
  2. package/build/{DevCommand-IHVIU2N4.js → DevCommand-5YJ7JVFI.js} +11 -11
  3. package/build/{LoginCommand-AETJTCZN.js → LoginCommand-VXFJURKY.js} +9 -9
  4. package/build/{LogoutCommand-YY7MRKCM.js → LogoutCommand-6X3V6YFR.js} +6 -6
  5. package/build/{PreviewCommand-3OABJYJD.js → PreviewCommand-SZN5FNW2.js} +13 -13
  6. package/build/{PublishCommand-ISZPYYXM.js → PublishCommand-WLNU4ZTZ.js} +13 -13
  7. package/build/{WhoamiCommand-GWPNPHRL.js → WhoamiCommand-LMVW2K4G.js} +3 -3
  8. package/build/{chunk-BEXERG7F.js → chunk-2F3GQZWA.js} +3 -3
  9. package/build/{chunk-5O5XFTPW.js → chunk-2G3JMOVC.js} +4 -4
  10. package/build/{chunk-5O5XFTPW.js.map → chunk-2G3JMOVC.js.map} +1 -1
  11. package/build/{chunk-KJXGVQP7.js → chunk-2PPYTGTP.js} +9 -9
  12. package/build/{chunk-JKBX72QC.js → chunk-2VWITZHD.js} +4 -4
  13. package/build/{chunk-QPYNVASM.js → chunk-3GHXATUB.js} +2 -2
  14. package/build/{chunk-QP2SHVU3.js → chunk-5P7JTOX6.js} +2 -2
  15. package/build/{chunk-Z3MJ3WPQ.js → chunk-6IE2UX3U.js} +7 -7
  16. package/build/{chunk-K74KSKUR.js → chunk-6RXRVNVZ.js} +2 -1
  17. package/build/chunk-73EOTPNH.js +48 -0
  18. package/build/chunk-73EOTPNH.js.map +1 -0
  19. package/build/{chunk-5WRZJFXK.js → chunk-7BZASUF6.js} +5 -5
  20. package/build/{chunk-YX66M2XN.js → chunk-7UNZZYHX.js} +2 -2
  21. package/build/{chunk-AOWEDNOF.js → chunk-AG5NQGMT.js} +2 -2
  22. package/build/{chunk-JXGBYZK7.js → chunk-DCQOM2Z7.js} +6 -6
  23. package/build/{chunk-4XPWCRGU.js → chunk-FP6XJXLI.js} +130 -58
  24. package/build/chunk-FP6XJXLI.js.map +1 -0
  25. package/build/{chunk-IPI4IXDD.js → chunk-GV6YQJVG.js} +396 -37
  26. package/build/chunk-GV6YQJVG.js.map +1 -0
  27. package/build/{chunk-JASQWANH.js → chunk-I2MVJLFR.js} +3 -3
  28. package/build/{chunk-UK7CHIDM.js → chunk-ISDQRGI5.js} +2 -2
  29. package/build/{chunk-ZM6OUS2J.js → chunk-OVP6B64S.js} +5 -5
  30. package/build/{chunk-KJCRO3PB.js → chunk-R63OCR7B.js} +6 -5
  31. package/build/chunk-R63OCR7B.js.map +1 -0
  32. package/build/{chunk-YHMLI3NZ.js → chunk-SNATPUJN.js} +2 -2
  33. package/build/{chunk-IC6K6CSD.js → chunk-STMV4YQN.js} +3 -3
  34. package/build/{chunk-N4L3XZI3.js → chunk-UEWDARJV.js} +4 -4
  35. package/build/{chunk-PWEJ3IWM.js → chunk-V7ZC4LPC.js} +4 -1
  36. package/build/{chunk-PWEJ3IWM.js.map → chunk-V7ZC4LPC.js.map} +1 -1
  37. package/build/{chunk-TIHCOJHY.js → chunk-VPOJLQYV.js} +4 -4
  38. package/build/{chunk-UHGVP5PT.js → chunk-XFBRJSRX.js} +3 -3
  39. package/build/{chunk-ZLPYLX6E.js → chunk-XW5SMEWV.js} +263 -241
  40. package/build/chunk-XW5SMEWV.js.map +1 -0
  41. package/build/{chunk-NXGJ6P6H.js → chunk-ZDRNDE67.js} +8 -8
  42. package/build/{chunk-3P5PTIBR.js → chunk-ZSEFFYYF.js} +3 -2
  43. package/build/chunk-ZSEFFYYF.js.map +1 -0
  44. package/build/dev-XHJYXDWW.js +1605 -0
  45. package/build/dev-XHJYXDWW.js.map +1 -0
  46. package/build/index.js +23 -23
  47. package/build/{install-L6C6V6OD.js → install-R344LMIP.js} +13 -13
  48. package/build/{preview-LDXRFIMB.js → preview-J2P3H55N.js} +16 -16
  49. package/build/{publish-FNN2BROO.js → publish-EVX4FLPC.js} +16 -16
  50. package/build/{render-command-RBG7263F.js → render-command-BKK2MPBU.js} +9 -9
  51. package/build/{render-command-WC6M3AGD.js → render-command-FJHJDHES.js} +8 -8
  52. package/build/{render-command-GLPKMOXW.js → render-command-QQZQXMCT.js} +9 -9
  53. package/build/{run-command-DDRX6HA4.js → run-command-3W35JGKO.js} +6 -6
  54. package/build/{src-5FM5LBPG.js → src-7BPNVTO6.js} +10 -10
  55. package/build/{src-YKFH53HG.js → src-A2WEM6GK.js} +43 -19
  56. package/build/src-A2WEM6GK.js.map +1 -0
  57. package/build/{src-RLHCQYHW.js → src-FRXUOTRK.js} +2 -2
  58. package/build/{src-WZQSHEYJ.js → src-PPNZSRDE.js} +6 -6
  59. package/build/{src-NDQ3YSVS.js → src-WLXQYADV.js} +6 -6
  60. package/build/{src-QDEPJEVY.js → src-ZKWO2KZB.js} +4 -4
  61. package/build/{sync-types-5QBTKL42.js → sync-types-FZK6FRJH.js} +11 -11
  62. package/build/{uninstall-X66KBPSO.js → uninstall-BDYHXWAO.js} +13 -13
  63. package/package.json +2 -2
  64. package/build/chunk-3P5PTIBR.js.map +0 -1
  65. package/build/chunk-4XPWCRGU.js.map +0 -1
  66. package/build/chunk-BCT5PAPG.js +0 -407
  67. package/build/chunk-BCT5PAPG.js.map +0 -1
  68. package/build/chunk-IPI4IXDD.js.map +0 -1
  69. package/build/chunk-KJCRO3PB.js.map +0 -1
  70. package/build/chunk-ZLPYLX6E.js.map +0 -1
  71. package/build/dev-62KN3SLL.js +0 -779
  72. package/build/dev-62KN3SLL.js.map +0 -1
  73. package/build/src-YKFH53HG.js.map +0 -1
  74. /package/build/{DevCommand-AVJ663GA.js.map → DevCommand-33URDS3V.js.map} +0 -0
  75. /package/build/{DevCommand-IHVIU2N4.js.map → DevCommand-5YJ7JVFI.js.map} +0 -0
  76. /package/build/{LoginCommand-AETJTCZN.js.map → LoginCommand-VXFJURKY.js.map} +0 -0
  77. /package/build/{LogoutCommand-YY7MRKCM.js.map → LogoutCommand-6X3V6YFR.js.map} +0 -0
  78. /package/build/{PreviewCommand-3OABJYJD.js.map → PreviewCommand-SZN5FNW2.js.map} +0 -0
  79. /package/build/{PublishCommand-ISZPYYXM.js.map → PublishCommand-WLNU4ZTZ.js.map} +0 -0
  80. /package/build/{WhoamiCommand-GWPNPHRL.js.map → WhoamiCommand-LMVW2K4G.js.map} +0 -0
  81. /package/build/{chunk-BEXERG7F.js.map → chunk-2F3GQZWA.js.map} +0 -0
  82. /package/build/{chunk-KJXGVQP7.js.map → chunk-2PPYTGTP.js.map} +0 -0
  83. /package/build/{chunk-JKBX72QC.js.map → chunk-2VWITZHD.js.map} +0 -0
  84. /package/build/{chunk-QPYNVASM.js.map → chunk-3GHXATUB.js.map} +0 -0
  85. /package/build/{chunk-QP2SHVU3.js.map → chunk-5P7JTOX6.js.map} +0 -0
  86. /package/build/{chunk-Z3MJ3WPQ.js.map → chunk-6IE2UX3U.js.map} +0 -0
  87. /package/build/{chunk-K74KSKUR.js.map → chunk-6RXRVNVZ.js.map} +0 -0
  88. /package/build/{chunk-5WRZJFXK.js.map → chunk-7BZASUF6.js.map} +0 -0
  89. /package/build/{chunk-YX66M2XN.js.map → chunk-7UNZZYHX.js.map} +0 -0
  90. /package/build/{chunk-AOWEDNOF.js.map → chunk-AG5NQGMT.js.map} +0 -0
  91. /package/build/{chunk-JXGBYZK7.js.map → chunk-DCQOM2Z7.js.map} +0 -0
  92. /package/build/{chunk-JASQWANH.js.map → chunk-I2MVJLFR.js.map} +0 -0
  93. /package/build/{chunk-UK7CHIDM.js.map → chunk-ISDQRGI5.js.map} +0 -0
  94. /package/build/{chunk-ZM6OUS2J.js.map → chunk-OVP6B64S.js.map} +0 -0
  95. /package/build/{chunk-YHMLI3NZ.js.map → chunk-SNATPUJN.js.map} +0 -0
  96. /package/build/{chunk-IC6K6CSD.js.map → chunk-STMV4YQN.js.map} +0 -0
  97. /package/build/{chunk-N4L3XZI3.js.map → chunk-UEWDARJV.js.map} +0 -0
  98. /package/build/{chunk-TIHCOJHY.js.map → chunk-VPOJLQYV.js.map} +0 -0
  99. /package/build/{chunk-UHGVP5PT.js.map → chunk-XFBRJSRX.js.map} +0 -0
  100. /package/build/{chunk-NXGJ6P6H.js.map → chunk-ZDRNDE67.js.map} +0 -0
  101. /package/build/{install-L6C6V6OD.js.map → install-R344LMIP.js.map} +0 -0
  102. /package/build/{preview-LDXRFIMB.js.map → preview-J2P3H55N.js.map} +0 -0
  103. /package/build/{publish-FNN2BROO.js.map → publish-EVX4FLPC.js.map} +0 -0
  104. /package/build/{render-command-RBG7263F.js.map → render-command-BKK2MPBU.js.map} +0 -0
  105. /package/build/{render-command-WC6M3AGD.js.map → render-command-FJHJDHES.js.map} +0 -0
  106. /package/build/{render-command-GLPKMOXW.js.map → render-command-QQZQXMCT.js.map} +0 -0
  107. /package/build/{run-command-DDRX6HA4.js.map → run-command-3W35JGKO.js.map} +0 -0
  108. /package/build/{src-5FM5LBPG.js.map → src-7BPNVTO6.js.map} +0 -0
  109. /package/build/{src-QDEPJEVY.js.map → src-FRXUOTRK.js.map} +0 -0
  110. /package/build/{src-RLHCQYHW.js.map → src-PPNZSRDE.js.map} +0 -0
  111. /package/build/{src-NDQ3YSVS.js.map → src-WLXQYADV.js.map} +0 -0
  112. /package/build/{src-WZQSHEYJ.js.map → src-ZKWO2KZB.js.map} +0 -0
  113. /package/build/{sync-types-5QBTKL42.js.map → sync-types-FZK6FRJH.js.map} +0 -0
  114. /package/build/{uninstall-X66KBPSO.js.map → uninstall-BDYHXWAO.js.map} +0 -0
@@ -0,0 +1,1605 @@
1
+ import { createRequire as _createRequire } from 'node:module';
2
+ const require = _createRequire(import.meta.url);
3
+ import {
4
+ syncTypesWithAuth
5
+ } from "./chunk-7BZASUF6.js";
6
+ import {
7
+ loadProjectGridAppContent
8
+ } from "./chunk-OVP6B64S.js";
9
+ import {
10
+ createLogger,
11
+ execa,
12
+ httpRequest
13
+ } from "./chunk-GV6YQJVG.js";
14
+ import "./chunk-CNXKF7E3.js";
15
+ import {
16
+ authenticate
17
+ } from "./chunk-XFBRJSRX.js";
18
+ import {
19
+ createI18nT
20
+ } from "./chunk-ZSEFFYYF.js";
21
+ import {
22
+ createVeloCLIServer,
23
+ debounceQueue,
24
+ require_chokidar
25
+ } from "./chunk-AG5NQGMT.js";
26
+ import {
27
+ require_normalize_path
28
+ } from "./chunk-EDFOB3LN.js";
29
+ import "./chunk-VPOJLQYV.js";
30
+ import "./chunk-OJHDGJWP.js";
31
+ import {
32
+ updateFiles
33
+ } from "./chunk-SNATPUJN.js";
34
+ import {
35
+ GridAppLayout
36
+ } from "./chunk-6LI4WGAW.js";
37
+ import {
38
+ AppType,
39
+ GridAppLayout as GridAppLayout2,
40
+ createApp,
41
+ pagesDiff
42
+ } from "./chunk-5P7JTOX6.js";
43
+ import {
44
+ saveProjectModel
45
+ } from "./chunk-I2MVJLFR.js";
46
+ import "./chunk-Y4ZVXLXY.js";
47
+ import "./chunk-STMV4YQN.js";
48
+ import {
49
+ createHttpClient,
50
+ isHttpError,
51
+ openBrowser,
52
+ pLimit,
53
+ pRetry,
54
+ resolveUrl,
55
+ serializer,
56
+ toURLSearchParams
57
+ } from "./chunk-R63OCR7B.js";
58
+ import {
59
+ ErrorViewer,
60
+ extractHttpError,
61
+ writeCrashReport
62
+ } from "./chunk-XW5SMEWV.js";
63
+ import {
64
+ renderSync,
65
+ require_react
66
+ } from "./chunk-FP6XJXLI.js";
67
+ import "./chunk-2K5KKUL3.js";
68
+ import {
69
+ wixCliCliMessageDisplayed,
70
+ wixCliCodeHasBeenChanged,
71
+ wixCliFileFolderCreatedRenamedDeleted,
72
+ wixCliReadyForReloadAfterCodeChange,
73
+ wixCliUserResponseToCliMessage
74
+ } from "./chunk-WN3D6AOY.js";
75
+ import "./chunk-W423UTD3.js";
76
+ import "./chunk-YU54OBFT.js";
77
+ import "./chunk-XMTHMR2B.js";
78
+ import "./chunk-7UNZZYHX.js";
79
+ import {
80
+ getDebugLogFilePath,
81
+ getPagesFolder,
82
+ getSourceFolder,
83
+ getTypesDir
84
+ } from "./chunk-SEOIN2A6.js";
85
+ import {
86
+ outputFile,
87
+ pathExists
88
+ } from "./chunk-3GHXATUB.js";
89
+ import {
90
+ getTestOverrides,
91
+ z
92
+ } from "./chunk-PX2L3CCA.js";
93
+ import {
94
+ CliError,
95
+ CliErrorCode
96
+ } from "./chunk-V7ZC4LPC.js";
97
+ import {
98
+ __commonJS,
99
+ __dirname,
100
+ __require,
101
+ __toESM,
102
+ init_esm_shims
103
+ } from "./chunk-PYIAC2GK.js";
104
+
105
+ // ../../node_modules/cloudflared/lib/constants.js
106
+ var require_constants = __commonJS({
107
+ "../../node_modules/cloudflared/lib/constants.js"(exports, module) {
108
+ "use strict";
109
+ init_esm_shims();
110
+ var __create = Object.create;
111
+ var __defProp = Object.defineProperty;
112
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
113
+ var __getOwnPropNames = Object.getOwnPropertyNames;
114
+ var __getProtoOf = Object.getPrototypeOf;
115
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
116
+ var __export = (target, all) => {
117
+ for (var name in all)
118
+ __defProp(target, name, { get: all[name], enumerable: true });
119
+ };
120
+ var __copyProps = (to, from, except, desc) => {
121
+ if (from && typeof from === "object" || typeof from === "function") {
122
+ for (let key of __getOwnPropNames(from))
123
+ if (!__hasOwnProp.call(to, key) && key !== except)
124
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
125
+ }
126
+ return to;
127
+ };
128
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
129
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
130
+ var constants_exports = {};
131
+ __export(constants_exports, {
132
+ CLOUDFLARED_VERSION: () => CLOUDFLARED_VERSION,
133
+ DEFAULT_CLOUDFLARED_BIN: () => DEFAULT_CLOUDFLARED_BIN,
134
+ RELEASE_BASE: () => RELEASE_BASE,
135
+ bin: () => bin3,
136
+ use: () => use
137
+ });
138
+ module.exports = __toCommonJS(constants_exports);
139
+ var import_node_path4 = __toESM2(__require("node:path"));
140
+ var DEFAULT_CLOUDFLARED_BIN = import_node_path4.default.join(__dirname, "..", "bin", process.platform === "win32" ? "cloudflared.exe" : "cloudflared");
141
+ var bin3 = process.env.CLOUDFLARED_BIN || DEFAULT_CLOUDFLARED_BIN;
142
+ function use(executable) {
143
+ bin3 = executable;
144
+ }
145
+ var CLOUDFLARED_VERSION = process.env.CLOUDFLARED_VERSION || "latest";
146
+ var RELEASE_BASE = "https://github.com/cloudflare/cloudflared/releases/";
147
+ }
148
+ });
149
+
150
+ // ../../node_modules/cloudflared/lib/error.js
151
+ var require_error = __commonJS({
152
+ "../../node_modules/cloudflared/lib/error.js"(exports, module) {
153
+ "use strict";
154
+ init_esm_shims();
155
+ var __defProp = Object.defineProperty;
156
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
157
+ var __getOwnPropNames = Object.getOwnPropertyNames;
158
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
159
+ var __export = (target, all) => {
160
+ for (var name in all)
161
+ __defProp(target, name, { get: all[name], enumerable: true });
162
+ };
163
+ var __copyProps = (to, from, except, desc) => {
164
+ if (from && typeof from === "object" || typeof from === "function") {
165
+ for (let key of __getOwnPropNames(from))
166
+ if (!__hasOwnProp.call(to, key) && key !== except)
167
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
168
+ }
169
+ return to;
170
+ };
171
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
172
+ var error_exports = {};
173
+ __export(error_exports, {
174
+ UnsupportedError: () => UnsupportedError
175
+ });
176
+ module.exports = __toCommonJS(error_exports);
177
+ var UnsupportedError = class extends Error {
178
+ constructor(message) {
179
+ super(message);
180
+ }
181
+ };
182
+ }
183
+ });
184
+
185
+ // ../../node_modules/cloudflared/lib/install.js
186
+ var require_install = __commonJS({
187
+ "../../node_modules/cloudflared/lib/install.js"(exports, module) {
188
+ "use strict";
189
+ init_esm_shims();
190
+ var __create = Object.create;
191
+ var __defProp = Object.defineProperty;
192
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
193
+ var __getOwnPropNames = Object.getOwnPropertyNames;
194
+ var __getProtoOf = Object.getPrototypeOf;
195
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
196
+ var __export = (target, all) => {
197
+ for (var name in all)
198
+ __defProp(target, name, { get: all[name], enumerable: true });
199
+ };
200
+ var __copyProps = (to, from, except, desc) => {
201
+ if (from && typeof from === "object" || typeof from === "function") {
202
+ for (let key of __getOwnPropNames(from))
203
+ if (!__hasOwnProp.call(to, key) && key !== except)
204
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
205
+ }
206
+ return to;
207
+ };
208
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
209
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
210
+ var install_exports = {};
211
+ __export(install_exports, {
212
+ install: () => install3,
213
+ install_linux: () => install_linux,
214
+ install_macos: () => install_macos,
215
+ install_windows: () => install_windows
216
+ });
217
+ module.exports = __toCommonJS(install_exports);
218
+ var import_node_fs = __toESM2(__require("node:fs"));
219
+ var import_node_path4 = __toESM2(__require("node:path"));
220
+ var import_node_https = __toESM2(__require("node:https"));
221
+ var import_node_child_process = __require("node:child_process");
222
+ var import_constants = require_constants();
223
+ var import_error = require_error();
224
+ var LINUX_URL = {
225
+ arm64: "cloudflared-linux-arm64",
226
+ arm: "cloudflared-linux-arm",
227
+ x64: "cloudflared-linux-amd64",
228
+ ia32: "cloudflared-linux-386"
229
+ };
230
+ var MACOS_URL = {
231
+ arm64: "cloudflared-darwin-amd64.tgz",
232
+ x64: "cloudflared-darwin-amd64.tgz"
233
+ };
234
+ var WINDOWS_URL = {
235
+ x64: "cloudflared-windows-amd64.exe",
236
+ ia32: "cloudflared-windows-386.exe"
237
+ };
238
+ function resolve_base(version) {
239
+ if (version === "latest") {
240
+ return `${import_constants.RELEASE_BASE}latest/download/`;
241
+ }
242
+ return `${import_constants.RELEASE_BASE}download/${version}/`;
243
+ }
244
+ async function install3(to, version = import_constants.CLOUDFLARED_VERSION) {
245
+ if (process.platform === "linux") {
246
+ return install_linux(to, version);
247
+ } else if (process.platform === "darwin") {
248
+ return install_macos(to, version);
249
+ } else if (process.platform === "win32") {
250
+ return install_windows(to, version);
251
+ } else {
252
+ throw new import_error.UnsupportedError("Unsupported platform: " + process.platform);
253
+ }
254
+ }
255
+ async function install_linux(to, version = import_constants.CLOUDFLARED_VERSION) {
256
+ const file = LINUX_URL[process.arch];
257
+ if (file === void 0) {
258
+ throw new import_error.UnsupportedError("Unsupported architecture: " + process.arch);
259
+ }
260
+ await download(resolve_base(version) + file, to);
261
+ import_node_fs.default.chmodSync(to, "755");
262
+ return to;
263
+ }
264
+ async function install_macos(to, version = import_constants.CLOUDFLARED_VERSION) {
265
+ const file = MACOS_URL[process.arch];
266
+ if (file === void 0) {
267
+ throw new import_error.UnsupportedError("Unsupported architecture: " + process.arch);
268
+ }
269
+ await download(resolve_base(version) + file, `${to}.tgz`);
270
+ process.env.VERBOSE && console.log(`Extracting to ${to}`);
271
+ (0, import_node_child_process.execSync)(`tar -xzf ${import_node_path4.default.basename(`${to}.tgz`)}`, { cwd: import_node_path4.default.dirname(to) });
272
+ import_node_fs.default.unlinkSync(`${to}.tgz`);
273
+ import_node_fs.default.renameSync(`${import_node_path4.default.dirname(to)}/cloudflared`, to);
274
+ return to;
275
+ }
276
+ async function install_windows(to, version = import_constants.CLOUDFLARED_VERSION) {
277
+ const file = WINDOWS_URL[process.arch];
278
+ if (file === void 0) {
279
+ throw new import_error.UnsupportedError("Unsupported architecture: " + process.arch);
280
+ }
281
+ await download(resolve_base(version) + file, to);
282
+ return to;
283
+ }
284
+ function download(url, to, redirect = 0) {
285
+ if (redirect === 0) {
286
+ process.env.VERBOSE && console.log(`Downloading ${url} to ${to}`);
287
+ } else {
288
+ process.env.VERBOSE && console.log(`Redirecting to ${url}`);
289
+ }
290
+ if (!import_node_fs.default.existsSync(import_node_path4.default.dirname(to))) {
291
+ import_node_fs.default.mkdirSync(import_node_path4.default.dirname(to), { recursive: true });
292
+ }
293
+ return new Promise((resolve, reject) => {
294
+ const request = import_node_https.default.get(url, (res) => {
295
+ const redirect_code = [301, 302, 303, 307, 308];
296
+ if (redirect_code.includes(res.statusCode) && res.headers.location !== void 0) {
297
+ request.destroy();
298
+ const redirection = res.headers.location;
299
+ resolve(download(redirection, to, redirect + 1));
300
+ return;
301
+ }
302
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
303
+ const file = import_node_fs.default.createWriteStream(to);
304
+ file.on("finish", () => {
305
+ file.close(() => resolve(to));
306
+ });
307
+ file.on("error", (err) => {
308
+ import_node_fs.default.unlink(to, () => reject(err));
309
+ });
310
+ res.pipe(file);
311
+ } else {
312
+ request.destroy();
313
+ reject(new Error(`HTTP response with status code: ${res.statusCode}`));
314
+ }
315
+ });
316
+ request.on("error", (err) => {
317
+ reject(err);
318
+ });
319
+ request.end();
320
+ });
321
+ }
322
+ }
323
+ });
324
+
325
+ // ../../node_modules/cloudflared/lib/regex.js
326
+ var require_regex = __commonJS({
327
+ "../../node_modules/cloudflared/lib/regex.js"(exports, module) {
328
+ "use strict";
329
+ init_esm_shims();
330
+ var __defProp = Object.defineProperty;
331
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
332
+ var __getOwnPropNames = Object.getOwnPropertyNames;
333
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
334
+ var __export = (target, all) => {
335
+ for (var name in all)
336
+ __defProp(target, name, { get: all[name], enumerable: true });
337
+ };
338
+ var __copyProps = (to, from, except, desc) => {
339
+ if (from && typeof from === "object" || typeof from === "function") {
340
+ for (let key of __getOwnPropNames(from))
341
+ if (!__hasOwnProp.call(to, key) && key !== except)
342
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
343
+ }
344
+ return to;
345
+ };
346
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
347
+ var regex_exports = {};
348
+ __export(regex_exports, {
349
+ config_regex: () => config_regex,
350
+ conn_regex: () => conn_regex,
351
+ connectorID_regex: () => connectorID_regex,
352
+ disconnect_regex: () => disconnect_regex,
353
+ index_regex: () => index_regex,
354
+ ip_regex: () => ip_regex,
355
+ location_regex: () => location_regex,
356
+ metrics_regex: () => metrics_regex,
357
+ tunnelID_regex: () => tunnelID_regex
358
+ });
359
+ module.exports = __toCommonJS(regex_exports);
360
+ var conn_regex = /connection[= ]([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12})/i;
361
+ var ip_regex = /ip=([0-9.]+)/;
362
+ var location_regex = /location=([A-Za-z0-9]+)/;
363
+ var index_regex = /connIndex=(\d)/;
364
+ var disconnect_regex = /Unregistered tunnel connection connIndex=(\d)/i;
365
+ var tunnelID_regex = /tunnelID=([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12})/i;
366
+ var connectorID_regex = /Connector ID: ([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12})/i;
367
+ var metrics_regex = /metrics server on ([0-9.:]+\/metrics)/;
368
+ var config_regex = /config="(.+[^\\])"/;
369
+ }
370
+ });
371
+
372
+ // ../../node_modules/cloudflared/lib/tunnel.js
373
+ var require_tunnel = __commonJS({
374
+ "../../node_modules/cloudflared/lib/tunnel.js"(exports, module) {
375
+ "use strict";
376
+ init_esm_shims();
377
+ var __defProp = Object.defineProperty;
378
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
379
+ var __getOwnPropNames = Object.getOwnPropertyNames;
380
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
381
+ var __export = (target, all) => {
382
+ for (var name in all)
383
+ __defProp(target, name, { get: all[name], enumerable: true });
384
+ };
385
+ var __copyProps = (to, from, except, desc) => {
386
+ if (from && typeof from === "object" || typeof from === "function") {
387
+ for (let key of __getOwnPropNames(from))
388
+ if (!__hasOwnProp.call(to, key) && key !== except)
389
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
390
+ }
391
+ return to;
392
+ };
393
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
394
+ var tunnel_exports = {};
395
+ __export(tunnel_exports, {
396
+ tunnel: () => tunnel2
397
+ });
398
+ module.exports = __toCommonJS(tunnel_exports);
399
+ var import_node_child_process = __require("node:child_process");
400
+ var import_constants = require_constants();
401
+ var import_regex = require_regex();
402
+ function tunnel2(options = {}) {
403
+ const args = ["tunnel"];
404
+ for (const [key, value] of Object.entries(options)) {
405
+ if (typeof value === "string") {
406
+ args.push(`${key}`, value);
407
+ } else if (typeof value === "number") {
408
+ args.push(`${key}`, value.toString());
409
+ } else if (value === null) {
410
+ args.push(`${key}`);
411
+ }
412
+ }
413
+ if (args.length === 1) {
414
+ args.push("--url", "localhost:8080");
415
+ }
416
+ const child = (0, import_node_child_process.spawn)(import_constants.bin, args, { stdio: ["ignore", "pipe", "pipe"] });
417
+ if (process.env.VERBOSE) {
418
+ child.stdout.pipe(process.stdout);
419
+ child.stderr.pipe(process.stderr);
420
+ }
421
+ const url_regex = /\|\s+(https?:\/\/[^\s]+)/;
422
+ let url_resolver = () => void 0;
423
+ let url_rejector = () => void 0;
424
+ const url = new Promise((...pair) => [url_resolver, url_rejector] = pair);
425
+ const connection_resolvers = [];
426
+ const connection_rejectors = [];
427
+ const connections = [];
428
+ for (let i = 0; i < 1; i++) {
429
+ connections.push(new Promise((...pair) => [connection_resolvers[i], connection_rejectors[i]] = pair));
430
+ }
431
+ const parser = (data) => {
432
+ var _a;
433
+ const str = data.toString();
434
+ const url_match = str.match(url_regex);
435
+ url_match && url_resolver(url_match[1]);
436
+ const conn_match = str.match(import_regex.conn_regex);
437
+ const ip_match = str.match(import_regex.ip_regex);
438
+ const location_match = str.match(import_regex.location_regex);
439
+ const index_match = str.match(import_regex.index_regex);
440
+ if (conn_match && ip_match && location_match && index_match) {
441
+ const [, id] = conn_match;
442
+ const [, ip] = ip_match;
443
+ const [, location] = location_match;
444
+ const [, idx] = index_match;
445
+ (_a = connection_resolvers[+idx]) == null ? void 0 : _a.call(connection_resolvers, { id, ip, location });
446
+ }
447
+ };
448
+ child.stdout.on("data", parser).on("error", url_rejector);
449
+ child.stderr.on("data", parser).on("error", url_rejector);
450
+ const stop = () => child.kill("SIGINT");
451
+ return { url, connections, child, stop };
452
+ }
453
+ }
454
+ });
455
+
456
+ // ../../node_modules/cloudflared/lib/service.js
457
+ var require_service = __commonJS({
458
+ "../../node_modules/cloudflared/lib/service.js"(exports, module) {
459
+ "use strict";
460
+ init_esm_shims();
461
+ var __create = Object.create;
462
+ var __defProp = Object.defineProperty;
463
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
464
+ var __getOwnPropNames = Object.getOwnPropertyNames;
465
+ var __getProtoOf = Object.getPrototypeOf;
466
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
467
+ var __export = (target, all) => {
468
+ for (var name in all)
469
+ __defProp(target, name, { get: all[name], enumerable: true });
470
+ };
471
+ var __copyProps = (to, from, except, desc) => {
472
+ if (from && typeof from === "object" || typeof from === "function") {
473
+ for (let key of __getOwnPropNames(from))
474
+ if (!__hasOwnProp.call(to, key) && key !== except)
475
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
476
+ }
477
+ return to;
478
+ };
479
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
480
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
481
+ var service_exports = {};
482
+ __export(service_exports, {
483
+ AlreadyInstalledError: () => AlreadyInstalledError2,
484
+ LINUX_SERVICE_PATH: () => LINUX_SERVICE_PATH,
485
+ MACOS_SERVICE_PATH: () => MACOS_SERVICE_PATH2,
486
+ NotInstalledError: () => NotInstalledError2,
487
+ clean: () => clean,
488
+ current: () => current,
489
+ err: () => err,
490
+ exists: () => exists,
491
+ identifier: () => identifier2,
492
+ install: () => install3,
493
+ journal: () => journal,
494
+ log: () => log,
495
+ service: () => service2,
496
+ service_name: () => service_name,
497
+ uninstall: () => uninstall
498
+ });
499
+ module.exports = __toCommonJS(service_exports);
500
+ var import_node_os = __toESM2(__require("node:os"));
501
+ var import_node_fs = __toESM2(__require("node:fs"));
502
+ var import_node_child_process = __require("node:child_process");
503
+ var import_constants = require_constants();
504
+ var import_regex = require_regex();
505
+ var identifier2 = "com.cloudflare.cloudflared";
506
+ var service_name = "cloudflared.service";
507
+ var MACOS_SERVICE_PATH2 = {
508
+ PLIST: is_root() ? `/Library/LaunchDaemons/${identifier2}.plist` : `${import_node_os.default.homedir()}/Library/LaunchAgents/${identifier2}.plist`,
509
+ OUT: is_root() ? `/Library/Logs/${identifier2}.out.log` : `${import_node_os.default.homedir()}/Library/Logs/${identifier2}.out.log`,
510
+ ERR: is_root() ? `/Library/Logs/${identifier2}.err.log` : `${import_node_os.default.homedir()}/Library/Logs/${identifier2}.err.log`
511
+ };
512
+ var LINUX_SERVICE_PATH = {
513
+ SYSTEMD: `/etc/systemd/system/${service_name}`,
514
+ SERVICE: "/etc/init.d/cloudflared",
515
+ SERVICE_OUT: "/var/log/cloudflared.log",
516
+ SERVICE_ERR: "/var/log/cloudflared.err"
517
+ };
518
+ var service2 = { install: install3, uninstall, exists, log, err, current, clean, journal };
519
+ var AlreadyInstalledError2 = class extends Error {
520
+ constructor() {
521
+ super("service is already installed");
522
+ }
523
+ };
524
+ var NotInstalledError2 = class extends Error {
525
+ constructor() {
526
+ super("service is not installed");
527
+ }
528
+ };
529
+ function install3(token) {
530
+ if (!["darwin", "linux"].includes(process.platform)) {
531
+ throw new Error(`Not Implemented on platform ${process.platform}`);
532
+ }
533
+ if (exists()) {
534
+ throw new AlreadyInstalledError2();
535
+ }
536
+ const args = ["service", "install"];
537
+ if (token) {
538
+ args.push(token);
539
+ }
540
+ const result = (0, import_node_child_process.spawnSync)(import_constants.bin, args);
541
+ if (result.status !== 0) {
542
+ throw new Error(`service install failed: ${result.stderr.toString()}`);
543
+ }
544
+ }
545
+ function uninstall() {
546
+ if (!["darwin", "linux"].includes(process.platform)) {
547
+ throw new Error(`Not Implemented on platform ${process.platform}`);
548
+ }
549
+ if (!exists()) {
550
+ throw new NotInstalledError2();
551
+ }
552
+ const result = (0, import_node_child_process.spawnSync)(import_constants.bin, ["service", "uninstall"]);
553
+ if (result.status !== 0) {
554
+ throw new Error(`service uninstall failed: ${result.stderr.toString()}`);
555
+ }
556
+ if (process.platform === "darwin") {
557
+ import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.OUT);
558
+ import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.ERR);
559
+ } else if (process.platform === "linux" && !is_systemd()) {
560
+ import_node_fs.default.rmSync(LINUX_SERVICE_PATH.SERVICE_OUT);
561
+ import_node_fs.default.rmSync(LINUX_SERVICE_PATH.SERVICE_ERR);
562
+ }
563
+ }
564
+ function log() {
565
+ if (!exists()) {
566
+ throw new NotInstalledError2();
567
+ }
568
+ if (process.platform === "darwin") {
569
+ return import_node_fs.default.readFileSync(MACOS_SERVICE_PATH2.OUT, "utf8");
570
+ }
571
+ if (process.platform === "linux" && !is_systemd()) {
572
+ return import_node_fs.default.readFileSync(LINUX_SERVICE_PATH.SERVICE_OUT, "utf8");
573
+ }
574
+ throw new Error(`Not Implemented on platform ${process.platform}`);
575
+ }
576
+ function err() {
577
+ if (!exists()) {
578
+ throw new NotInstalledError2();
579
+ }
580
+ if (process.platform === "darwin") {
581
+ return import_node_fs.default.readFileSync(MACOS_SERVICE_PATH2.ERR, "utf8");
582
+ }
583
+ if (process.platform === "linux" && !is_systemd()) {
584
+ return import_node_fs.default.readFileSync(LINUX_SERVICE_PATH.SERVICE_ERR, "utf8");
585
+ }
586
+ throw new Error(`Not Implemented on platform ${process.platform}`);
587
+ }
588
+ function journal(n = 300) {
589
+ if (process.platform === "linux" && is_systemd()) {
590
+ const args = ["-u", service_name, "-o", "cat", "-n", n.toString()];
591
+ return (0, import_node_child_process.spawnSync)("journalctl", args).stdout.toString();
592
+ }
593
+ throw new Error(`Not Implemented on platform ${process.platform}`);
594
+ }
595
+ function current() {
596
+ var _a, _b, _c, _d;
597
+ if (!["darwin", "linux"].includes(process.platform)) {
598
+ throw new Error(`Not Implemented on platform ${process.platform}`);
599
+ }
600
+ if (!exists()) {
601
+ throw new NotInstalledError2();
602
+ }
603
+ const log2 = is_systemd() ? journal() : err();
604
+ let tunnelID = "";
605
+ let connectorID = "";
606
+ const connections = [];
607
+ let metrics = "";
608
+ let config = {};
609
+ for (const line of log2.split("\n")) {
610
+ try {
611
+ if (line.match(import_regex.tunnelID_regex)) {
612
+ tunnelID = ((_a = line.match(import_regex.tunnelID_regex)) == null ? void 0 : _a[1]) ?? "";
613
+ } else if (line.match(import_regex.connectorID_regex)) {
614
+ connectorID = ((_b = line.match(import_regex.connectorID_regex)) == null ? void 0 : _b[1]) ?? "";
615
+ } else if (line.match(import_regex.conn_regex) && line.match(import_regex.location_regex) && line.match(import_regex.ip_regex) && line.match(import_regex.index_regex)) {
616
+ const [, id] = line.match(import_regex.conn_regex) ?? [];
617
+ const [, location] = line.match(import_regex.location_regex) ?? [];
618
+ const [, ip] = line.match(import_regex.ip_regex) ?? [];
619
+ const [, idx] = line.match(import_regex.index_regex) ?? [];
620
+ connections[parseInt(idx)] = { id, ip, location };
621
+ } else if (line.match(import_regex.disconnect_regex)) {
622
+ const [, idx] = line.match(import_regex.disconnect_regex) ?? [];
623
+ if (parseInt(idx) in connections) {
624
+ connections[parseInt(idx)] = { id: "", ip: "", location: "" };
625
+ }
626
+ } else if (line.match(import_regex.metrics_regex)) {
627
+ metrics = ((_c = line.match(import_regex.metrics_regex)) == null ? void 0 : _c[1]) ?? "";
628
+ } else if (line.match(import_regex.config_regex)) {
629
+ config = JSON.parse(((_d = line.match(import_regex.config_regex)) == null ? void 0 : _d[1].replace(/\\/g, "")) ?? "{}");
630
+ }
631
+ } catch (err2) {
632
+ if (process.env.VERBOSE) {
633
+ console.error("log parsing failed", err2);
634
+ }
635
+ }
636
+ }
637
+ return { tunnelID, connectorID, connections, metrics, config };
638
+ }
639
+ function clean() {
640
+ if (process.platform !== "darwin") {
641
+ throw new Error(`Not Implemented on platform ${process.platform}`);
642
+ }
643
+ if (exists()) {
644
+ throw new AlreadyInstalledError2();
645
+ }
646
+ import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.OUT, { force: true });
647
+ import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.ERR, { force: true });
648
+ }
649
+ function exists() {
650
+ if (process.platform === "darwin") {
651
+ return import_node_fs.default.existsSync(MACOS_SERVICE_PATH2.PLIST);
652
+ } else if (process.platform === "linux") {
653
+ return is_systemd() ? import_node_fs.default.existsSync(LINUX_SERVICE_PATH.SYSTEMD) : import_node_fs.default.existsSync(LINUX_SERVICE_PATH.SERVICE);
654
+ }
655
+ throw new Error(`Not Implemented on platform ${process.platform}`);
656
+ }
657
+ function is_root() {
658
+ var _a;
659
+ return ((_a = process.getuid) == null ? void 0 : _a.call(process)) === 0;
660
+ }
661
+ function is_systemd() {
662
+ return process.platform === "linux" && import_node_fs.default.existsSync("/run/systemd/system");
663
+ }
664
+ }
665
+ });
666
+
667
+ // ../../node_modules/cloudflared/lib/lib.js
668
+ var require_lib = __commonJS({
669
+ "../../node_modules/cloudflared/lib/lib.js"(exports, module) {
670
+ "use strict";
671
+ init_esm_shims();
672
+ var __defProp = Object.defineProperty;
673
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
674
+ var __getOwnPropNames = Object.getOwnPropertyNames;
675
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
676
+ var __export = (target, all) => {
677
+ for (var name in all)
678
+ __defProp(target, name, { get: all[name], enumerable: true });
679
+ };
680
+ var __copyProps = (to, from, except, desc) => {
681
+ if (from && typeof from === "object" || typeof from === "function") {
682
+ for (let key of __getOwnPropNames(from))
683
+ if (!__hasOwnProp.call(to, key) && key !== except)
684
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
685
+ }
686
+ return to;
687
+ };
688
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
689
+ var lib_exports = {};
690
+ __export(lib_exports, {
691
+ AlreadyInstalledError: () => import_service.AlreadyInstalledError,
692
+ MACOS_SERVICE_PATH: () => import_service.MACOS_SERVICE_PATH,
693
+ NotInstalledError: () => import_service.NotInstalledError,
694
+ bin: () => import_constants.bin,
695
+ identifier: () => import_service.identifier,
696
+ install: () => import_install.install,
697
+ service: () => import_service.service,
698
+ tunnel: () => import_tunnel2.tunnel
699
+ });
700
+ module.exports = __toCommonJS(lib_exports);
701
+ var import_constants = require_constants();
702
+ var import_install = require_install();
703
+ var import_tunnel2 = require_tunnel();
704
+ var import_service = require_service();
705
+ }
706
+ });
707
+
708
+ // ../cli-site-old/src/dev/index.ts
709
+ init_esm_shims();
710
+
711
+ // ../cli-site-old/src/dev/dev.ts
712
+ init_esm_shims();
713
+
714
+ // ../../node_modules/exit-hook/index.js
715
+ init_esm_shims();
716
+ import process2 from "node:process";
717
+ var asyncCallbacks = /* @__PURE__ */ new Set();
718
+ var callbacks = /* @__PURE__ */ new Set();
719
+ var isCalled = false;
720
+ var isRegistered = false;
721
+ async function exit(shouldManuallyExit, isSynchronous, signal) {
722
+ if (isCalled) {
723
+ return;
724
+ }
725
+ isCalled = true;
726
+ if (asyncCallbacks.size > 0 && isSynchronous) {
727
+ console.error([
728
+ "SYNCHRONOUS TERMINATION NOTICE:",
729
+ "When explicitly exiting the process via process.exit or via a parent process,",
730
+ "asynchronous tasks in your exitHooks will not run. Either remove these tasks,",
731
+ "use gracefulExit() instead of process.exit(), or ensure your parent process",
732
+ "sends a SIGINT to the process running this code."
733
+ ].join(" "));
734
+ }
735
+ const exitCode = 128 + signal;
736
+ const done = (force = false) => {
737
+ if (force === true || shouldManuallyExit === true) {
738
+ process2.exit(exitCode);
739
+ }
740
+ };
741
+ for (const callback of callbacks) {
742
+ callback(exitCode);
743
+ }
744
+ if (isSynchronous) {
745
+ done();
746
+ return;
747
+ }
748
+ const promises = [];
749
+ let forceAfter = 0;
750
+ for (const [callback, wait] of asyncCallbacks) {
751
+ forceAfter = Math.max(forceAfter, wait);
752
+ promises.push(Promise.resolve(callback(exitCode)));
753
+ }
754
+ const asyncTimer = setTimeout(() => {
755
+ done(true);
756
+ }, forceAfter);
757
+ await Promise.all(promises);
758
+ clearTimeout(asyncTimer);
759
+ done();
760
+ }
761
+ function addHook(options) {
762
+ const { onExit, wait, isSynchronous } = options;
763
+ const asyncCallbackConfig = [onExit, wait];
764
+ if (isSynchronous) {
765
+ callbacks.add(onExit);
766
+ } else {
767
+ asyncCallbacks.add(asyncCallbackConfig);
768
+ }
769
+ if (!isRegistered) {
770
+ isRegistered = true;
771
+ process2.once("beforeExit", exit.bind(void 0, true, false, -128));
772
+ process2.once("SIGINT", exit.bind(void 0, true, false, 2));
773
+ process2.once("SIGTERM", exit.bind(void 0, true, false, 15));
774
+ process2.once("exit", exit.bind(void 0, false, true, 0));
775
+ process2.on("message", (message) => {
776
+ if (message === "shutdown") {
777
+ exit(true, true, -128);
778
+ }
779
+ });
780
+ }
781
+ return () => {
782
+ if (isSynchronous) {
783
+ callbacks.delete(onExit);
784
+ } else {
785
+ asyncCallbacks.delete(asyncCallbackConfig);
786
+ }
787
+ };
788
+ }
789
+ function asyncExitHook(onExit, options = {}) {
790
+ if (typeof onExit !== "function") {
791
+ throw new TypeError("onExit must be a function");
792
+ }
793
+ if (!(typeof options.wait === "number" && options.wait > 0)) {
794
+ throw new TypeError("wait must be set to a positive numeric value");
795
+ }
796
+ return addHook({
797
+ onExit,
798
+ wait: options.wait,
799
+ isSynchronous: false
800
+ });
801
+ }
802
+
803
+ // ../cli-site-old/src/dev/dev.ts
804
+ var import_react = __toESM(require_react(), 1);
805
+
806
+ // ../cli-tunnel/src/index.ts
807
+ init_esm_shims();
808
+
809
+ // ../cli-tunnel/src/tunnel.ts
810
+ init_esm_shims();
811
+ import { dirname } from "node:path";
812
+ var import_cloudflared = __toESM(require_lib(), 1);
813
+ async function launchTunnel(port, tunnelClient) {
814
+ const { localTunnel } = getTestOverrides();
815
+ if (!localTunnel && !await pathExists(import_cloudflared.bin)) {
816
+ try {
817
+ await (0, import_cloudflared.install)(import_cloudflared.bin);
818
+ } catch (e) {
819
+ const err = e;
820
+ if (e instanceof Error && err.code === "EACCES") {
821
+ throw new CliError({
822
+ code: CliErrorCode.FailedInstallCloudflareNoAccess({
823
+ path: dirname(err.path)
824
+ }),
825
+ cause: e
826
+ });
827
+ }
828
+ throw e;
829
+ }
830
+ }
831
+ const tunnel2 = await tunnelClient.createTunnel({ port });
832
+ const domain = `http${localTunnel ? "" : "s"}://${tunnel2.domain}`;
833
+ const createTunnelPromise = new Promise((resolve, reject) => {
834
+ const tunnelProcess = localTunnel ? execa("echo", [tunnel2.domain, tunnel2.token], { detached: true }) : execa(import_cloudflared.bin, ["tunnel", "run", "--token", tunnel2.token]);
835
+ const close = () => {
836
+ tunnelProcess.kill();
837
+ };
838
+ const listener = async (data) => {
839
+ const output = data.toString();
840
+ const match = output.match(tunnel2.domain)?.[0];
841
+ if (match) {
842
+ resolve({
843
+ domain,
844
+ close
845
+ });
846
+ }
847
+ };
848
+ tunnelProcess.stderr?.on("data", listener);
849
+ tunnelProcess.stdout?.on("data", listener);
850
+ tunnelProcess.on("error", (err) => {
851
+ reject(err);
852
+ });
853
+ });
854
+ return {
855
+ domain,
856
+ close: async () => {
857
+ const tunnel3 = await createTunnelPromise;
858
+ return tunnel3.close();
859
+ }
860
+ };
861
+ }
862
+
863
+ // ../cli-tunnel/src/client.ts
864
+ init_esm_shims();
865
+
866
+ // ../../node_modules/@wix/ambassador-apps-hosting-v1-deployment/build/es/http.impl.js
867
+ init_esm_shims();
868
+ var _createTunnelRequest = {};
869
+ var _createTunnelResponse = {};
870
+ var _deleteTunnelRequest = {};
871
+ var _deleteTunnelResponse = {};
872
+ function resolveWixAppsHostingV1BackendServiceUrl(opts) {
873
+ var domainToMappings = {
874
+ "bo._base_domain_": [
875
+ {
876
+ srcPath: "/_serverless/wix-app-backend-manager",
877
+ destPath: ""
878
+ }
879
+ ],
880
+ "wixbo.ai": [
881
+ {
882
+ srcPath: "/_serverless/wix-app-backend-manager",
883
+ destPath: ""
884
+ }
885
+ ],
886
+ "wix-bo.com": [
887
+ {
888
+ srcPath: "/_serverless/wix-app-backend-manager",
889
+ destPath: ""
890
+ }
891
+ ],
892
+ "manage._base_domain_": [
893
+ {
894
+ srcPath: "/_serverless/wix-app-backend-manager",
895
+ destPath: ""
896
+ }
897
+ ]
898
+ };
899
+ return resolveUrl(Object.assign(opts, { domainToMappings }));
900
+ }
901
+ function createTunnel(payload) {
902
+ var _a = serializer(_createTunnelRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
903
+ var fromRes = serializer(_createTunnelResponse, {}).fromJSON;
904
+ function __createTunnel(_a2) {
905
+ var host = _a2.host;
906
+ var serializedData = toReq(payload);
907
+ var metadata = {
908
+ entityFqdn: "wix.apps.hosting.v1.deployment",
909
+ method: "POST",
910
+ methodFqn: "wix.apps.hosting.v1.BackendService.CreateTunnel",
911
+ url: resolveWixAppsHostingV1BackendServiceUrl({
912
+ protoPath: "/v1/tunnel",
913
+ data: serializedData,
914
+ host
915
+ }),
916
+ data: serializedData,
917
+ transformResponse: fromRes
918
+ };
919
+ return metadata;
920
+ }
921
+ __createTunnel.fromReq = fromReq;
922
+ __createTunnel.__isAmbassador = true;
923
+ return __createTunnel;
924
+ }
925
+ function deleteTunnel(payload) {
926
+ var _a = serializer(_deleteTunnelRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
927
+ var fromRes = serializer(_deleteTunnelResponse, {}).fromJSON;
928
+ function __deleteTunnel(_a2) {
929
+ var host = _a2.host;
930
+ var serializedData = toReq(payload);
931
+ var metadata = {
932
+ entityFqdn: "wix.apps.hosting.v1.deployment",
933
+ method: "DELETE",
934
+ methodFqn: "wix.apps.hosting.v1.BackendService.DeleteTunnel",
935
+ url: resolveWixAppsHostingV1BackendServiceUrl({
936
+ protoPath: "/v1/tunnel",
937
+ data: serializedData,
938
+ host
939
+ }),
940
+ params: toURLSearchParams(serializedData),
941
+ transformResponse: fromRes
942
+ };
943
+ return metadata;
944
+ }
945
+ __deleteTunnel.fromReq = fromReq;
946
+ __deleteTunnel.__isAmbassador = true;
947
+ return __deleteTunnel;
948
+ }
949
+
950
+ // ../cli-tunnel/src/schemas.ts
951
+ init_esm_shims();
952
+ var createTunnelSchema = z.object({
953
+ id: z.string(),
954
+ token: z.string(),
955
+ domain: z.string()
956
+ });
957
+
958
+ // ../cli-tunnel/src/client.ts
959
+ var TunnelClient = class {
960
+ constructor(httpClient) {
961
+ this.httpClient = httpClient;
962
+ const { minRetryTimeout } = getTestOverrides();
963
+ this.retryOptions = {
964
+ retries: 3,
965
+ minTimeout: minRetryTimeout,
966
+ maxTimeout: 3 * 1e3
967
+ };
968
+ }
969
+ retryOptions;
970
+ createTunnel = async ({ port }) => {
971
+ try {
972
+ const { data } = await pRetry(
973
+ () => this.httpClient.request(createTunnel({ port })),
974
+ this.retryOptions
975
+ );
976
+ return createTunnelSchema.parse(data);
977
+ } catch (error) {
978
+ throw new CliError({
979
+ code: CliErrorCode.FailedToCreateTunnel(),
980
+ cause: error
981
+ });
982
+ }
983
+ };
984
+ deleteTunnel = async (tunnelId) => {
985
+ try {
986
+ await pRetry(
987
+ () => this.httpClient.request(deleteTunnel({ id: tunnelId })),
988
+ this.retryOptions
989
+ );
990
+ } catch (error) {
991
+ throw new CliError({
992
+ code: CliErrorCode.FailedToDeleteTunnel(),
993
+ cause: error
994
+ });
995
+ }
996
+ };
997
+ };
998
+
999
+ // ../cli-site-old/src/environment.ts
1000
+ init_esm_shims();
1001
+ var DEV_EDITOR_BASE_URL = "https://wix.com/editor/";
1002
+ function getDevEditorBaseUrl() {
1003
+ return getTestOverrides().devEditorBaseUrl ?? DEV_EDITOR_BASE_URL;
1004
+ }
1005
+
1006
+ // ../cli-site-old/src/gridapp/createGridApp.ts
1007
+ init_esm_shims();
1008
+
1009
+ // ../cli-site-old/src/gridapp/error-handlers/maxFileSizeErrorHandler.ts
1010
+ init_esm_shims();
1011
+ function catchFilesMaxSizeError(err, files = []) {
1012
+ if (!files.length) {
1013
+ return;
1014
+ }
1015
+ const httpError = extractHttpError(err);
1016
+ if (!httpError) {
1017
+ return;
1018
+ }
1019
+ const filesMaxSizeRawViolations = httpError.response?.data?.details?.validationError?.fieldViolations?.filter(
1020
+ (v) => v.violatedRule === "MAX_LENGTH"
1021
+ );
1022
+ if (!filesMaxSizeRawViolations?.length) {
1023
+ return;
1024
+ }
1025
+ const maxSizeViolationsData = tryExtractMaxSizeViolationMetadata(
1026
+ filesMaxSizeRawViolations
1027
+ );
1028
+ throw new CliError({
1029
+ code: CliErrorCode.GridAppFilesMaxLengthExceeded({
1030
+ maxSizeViolationsData,
1031
+ filePaths: files.map((f) => f.path ?? "[unknown file path]")
1032
+ }),
1033
+ cause: httpError
1034
+ });
1035
+ }
1036
+ function tryExtractMaxSizeViolationMetadata(filesMaxSizeViolations) {
1037
+ const fileIndexRegex = /\[(?<fileIndex>\d+)\].content/;
1038
+ const expectedAndReceivedSizeRegex = /has size (?<receivedSize>\d+), expected (?<expectedSize>\d+) or less/;
1039
+ const violationsData = {
1040
+ expectedSize: void 0,
1041
+ files: []
1042
+ };
1043
+ for (const filesMaxSizeViolation of filesMaxSizeViolations) {
1044
+ const fileIndexMatchResult = fileIndexRegex.exec(
1045
+ filesMaxSizeViolation.field
1046
+ );
1047
+ const expectedAndReceivedSizeMatchResult = expectedAndReceivedSizeRegex.exec(filesMaxSizeViolation.description);
1048
+ if (!(fileIndexMatchResult?.groups?.fileIndex && expectedAndReceivedSizeMatchResult?.groups?.receivedSize && expectedAndReceivedSizeMatchResult.groups.expectedSize)) {
1049
+ return null;
1050
+ }
1051
+ violationsData.expectedSize ??= Math.trunc(
1052
+ parseInt(expectedAndReceivedSizeMatchResult.groups.expectedSize, 10) / 1e3
1053
+ );
1054
+ violationsData.files.push({
1055
+ receivedSize: Math.trunc(
1056
+ parseInt(expectedAndReceivedSizeMatchResult.groups.receivedSize, 10) / 1e3
1057
+ ),
1058
+ fileIndex: parseInt(fileIndexMatchResult.groups.fileIndex, 10)
1059
+ });
1060
+ }
1061
+ return violationsData;
1062
+ }
1063
+
1064
+ // ../cli-site-old/src/gridapp/createGridApp.ts
1065
+ async function createAppWithParams(params, opts) {
1066
+ let app;
1067
+ try {
1068
+ const response = await httpRequest(
1069
+ { type: "code", authState: opts.authState },
1070
+ createApp(params)
1071
+ );
1072
+ app = response.data.app;
1073
+ } catch (err) {
1074
+ catchFilesMaxSizeError(err, params.content?.files);
1075
+ throw err;
1076
+ }
1077
+ if (!app?.id) {
1078
+ throw new CliError({
1079
+ code: CliErrorCode.InvalidCreateAppResponse(),
1080
+ info: { app },
1081
+ cause: null
1082
+ });
1083
+ }
1084
+ return app.id;
1085
+ }
1086
+ async function createMutableGridApp(projectFolder, opts) {
1087
+ const content = await loadProjectGridAppContent(projectFolder);
1088
+ return createAppWithParams(
1089
+ {
1090
+ app: {
1091
+ mutable: true,
1092
+ appType: AppType.VELO_ISOLATED
1093
+ },
1094
+ content
1095
+ },
1096
+ opts
1097
+ );
1098
+ }
1099
+
1100
+ // ../cli-site-old/src/gridapp/startGridAppUpdater.ts
1101
+ init_esm_shims();
1102
+ import { readFile } from "node:fs/promises";
1103
+ import { join } from "node:path";
1104
+ var import_chokidar = __toESM(require_chokidar(), 1);
1105
+ var import_normalize_path = __toESM(require_normalize_path(), 1);
1106
+ var WATCH_FS_EVENTS_DEBOUNCE_TIME = 1e3;
1107
+ var getSectionName = (path) => {
1108
+ if (path.startsWith("src/pages")) {
1109
+ return "public";
1110
+ }
1111
+ if (path.startsWith("src/backend")) {
1112
+ return "backend";
1113
+ }
1114
+ return "other";
1115
+ };
1116
+ function startGridAppUpdater(model, gridAppId, opts, logger, biEvents) {
1117
+ const { projectFolder } = model;
1118
+ const limit = pLimit(1);
1119
+ const watcher = (0, import_chokidar.watch)(getSourceFolder(projectFolder), {
1120
+ disableGlobbing: true,
1121
+ cwd: projectFolder,
1122
+ ignoreInitial: true
1123
+ }).on(
1124
+ "all",
1125
+ debounceQueue(async (events) => {
1126
+ await limit(async () => {
1127
+ const logSynced = logger.logSyncingLocalCode();
1128
+ const { added, changed, removed } = normalizeChokidarBatchedEvents(events);
1129
+ const addedArray = Array.from(added.values()).map((path) => ({
1130
+ path,
1131
+ type: "create"
1132
+ }));
1133
+ const changedArray = Array.from(changed.values()).map((path) => ({
1134
+ path,
1135
+ type: "update"
1136
+ }));
1137
+ const removedArray = Array.from(removed.values()).map((path) => ({
1138
+ path,
1139
+ type: "delete"
1140
+ }));
1141
+ for (const val of [...addedArray, ...changedArray, ...removedArray]) {
1142
+ biEvents.file({
1143
+ model,
1144
+ action: val.type,
1145
+ path: val.path,
1146
+ oldPath: "",
1147
+ sectionName: getSectionName(val.path)
1148
+ });
1149
+ if (val.type === "update") {
1150
+ biEvents.codeChanged(model, val.path);
1151
+ }
1152
+ }
1153
+ try {
1154
+ await writeFiles({
1155
+ filesToUpdate: await Promise.all(
1156
+ addedArray.concat(changedArray).map(async (val) => ({
1157
+ path: (0, import_normalize_path.default)(val.path),
1158
+ content: await readFile(
1159
+ join(projectFolder, val.path),
1160
+ "utf8"
1161
+ )
1162
+ }))
1163
+ ),
1164
+ removedArray,
1165
+ gridAppId,
1166
+ authState: opts.authState
1167
+ });
1168
+ const message = logSynced.success();
1169
+ biEvents.messageDisplayed({ message, model });
1170
+ biEvents.readyForReloadAfterCodeChanged(model);
1171
+ } catch (e) {
1172
+ logSynced.fail();
1173
+ const error = new CliError({
1174
+ code: CliErrorCode.GridAppFailedToUpdateFiles(),
1175
+ cause: e,
1176
+ info: {
1177
+ added,
1178
+ changed,
1179
+ removed
1180
+ }
1181
+ });
1182
+ opts.onError(error);
1183
+ }
1184
+ });
1185
+ }, WATCH_FS_EVENTS_DEBOUNCE_TIME)
1186
+ ).on("error", (e) => {
1187
+ const error = new CliError({
1188
+ code: CliErrorCode.FailedToWatchFiles(),
1189
+ cause: e
1190
+ });
1191
+ opts.onError(error);
1192
+ });
1193
+ return { close: () => watcher.close() };
1194
+ }
1195
+ function normalizeChokidarBatchedEvents(events) {
1196
+ return events.reduce(
1197
+ (result, [eventType, filePath]) => {
1198
+ switch (eventType) {
1199
+ case "add": {
1200
+ result.added.add(filePath);
1201
+ break;
1202
+ }
1203
+ case "change": {
1204
+ result.changed.add(filePath);
1205
+ break;
1206
+ }
1207
+ case "unlink": {
1208
+ result.added.delete(filePath);
1209
+ result.changed.delete(filePath);
1210
+ result.removed.add(filePath);
1211
+ break;
1212
+ }
1213
+ case "unlinkDir": {
1214
+ const filePathAsDir = filePath.endsWith("/") ? filePath : `${filePath}/`;
1215
+ for (const filePath2 of result.added) {
1216
+ if (filePath2.startsWith(filePathAsDir)) {
1217
+ result.added.delete(filePath2);
1218
+ }
1219
+ }
1220
+ for (const filePath2 of result.changed) {
1221
+ if (filePath2.startsWith(filePathAsDir)) {
1222
+ result.changed.delete(filePath2);
1223
+ }
1224
+ }
1225
+ result.removed.add(filePath);
1226
+ break;
1227
+ }
1228
+ case "addDir": {
1229
+ break;
1230
+ }
1231
+ }
1232
+ return result;
1233
+ },
1234
+ {
1235
+ added: /* @__PURE__ */ new Set(),
1236
+ changed: /* @__PURE__ */ new Set(),
1237
+ removed: /* @__PURE__ */ new Set()
1238
+ }
1239
+ );
1240
+ }
1241
+ async function writeFiles({
1242
+ filesToUpdate,
1243
+ removedArray,
1244
+ gridAppId,
1245
+ authState
1246
+ }) {
1247
+ try {
1248
+ await httpRequest(
1249
+ {
1250
+ type: "code",
1251
+ authState
1252
+ },
1253
+ updateFiles({
1254
+ gridAppId,
1255
+ layout: GridAppLayout.GITHUB,
1256
+ filesToUpdate,
1257
+ ignoreForbiddenPaths: true,
1258
+ pathsToDelete: removedArray.map((val) => val.path)
1259
+ })
1260
+ );
1261
+ } catch (err) {
1262
+ catchFilesMaxSizeError(err, filesToUpdate);
1263
+ throw err;
1264
+ }
1265
+ }
1266
+
1267
+ // ../cli-site-old/src/key-watcher.ts
1268
+ init_esm_shims();
1269
+ import readline from "node:readline";
1270
+ import { stdin } from "node:process";
1271
+ var KeyWatcher = class {
1272
+ actions = /* @__PURE__ */ new Map();
1273
+ watchExitProcess() {
1274
+ return new Promise((resolve) => {
1275
+ this.on("c", (key) => {
1276
+ if (key.ctrl) {
1277
+ resolve();
1278
+ }
1279
+ });
1280
+ });
1281
+ }
1282
+ on(key, callback) {
1283
+ this.actions.set(key, callback);
1284
+ }
1285
+ watch() {
1286
+ const rl = readline.createInterface(stdin);
1287
+ readline.emitKeypressEvents(stdin, rl);
1288
+ if (stdin.isTTY) {
1289
+ stdin.setRawMode(true);
1290
+ stdin.setEncoding("utf8");
1291
+ }
1292
+ stdin.on("keypress", this.handleKeyPress);
1293
+ return {
1294
+ ctrlCPromise: this.watchExitProcess()
1295
+ };
1296
+ }
1297
+ unwatch() {
1298
+ if (stdin.isTTY) {
1299
+ stdin.setRawMode(false);
1300
+ }
1301
+ stdin.off("keypress", this.handleKeyPress);
1302
+ stdin.pause();
1303
+ this.actions.clear();
1304
+ }
1305
+ handleKeyPress = (_, key) => {
1306
+ this.actions.get(key.name)?.(key);
1307
+ };
1308
+ };
1309
+
1310
+ // ../cli-site-old/src/bi.ts
1311
+ init_esm_shims();
1312
+ import { randomUUID } from "node:crypto";
1313
+ var sitesBiEvents = (biLogger) => ({
1314
+ file: ({
1315
+ model,
1316
+ action,
1317
+ path,
1318
+ sectionName,
1319
+ oldPath
1320
+ }) => {
1321
+ void biLogger.report(
1322
+ wixCliFileFolderCreatedRenamedDeleted({
1323
+ action,
1324
+ path,
1325
+ sectionName,
1326
+ oldPath,
1327
+ siteRevision: Number(model.revision)
1328
+ })
1329
+ );
1330
+ },
1331
+ codeChanged: (model, fileName) => {
1332
+ void biLogger.report(
1333
+ wixCliCodeHasBeenChanged({
1334
+ fileName,
1335
+ siteRevision: Number(model.revision)
1336
+ })
1337
+ );
1338
+ },
1339
+ readyForReloadAfterCodeChanged: (model) => {
1340
+ void biLogger.report(
1341
+ wixCliReadyForReloadAfterCodeChange({
1342
+ siteRevision: Number(model.revision)
1343
+ })
1344
+ );
1345
+ },
1346
+ messageDisplayed: ({
1347
+ message,
1348
+ model
1349
+ }) => {
1350
+ void biLogger.report(
1351
+ wixCliCliMessageDisplayed({
1352
+ message,
1353
+ messageId: randomUUID(),
1354
+ siteRevision: Number(model.revision)
1355
+ })
1356
+ );
1357
+ },
1358
+ userResponse: ({
1359
+ model,
1360
+ action,
1361
+ message
1362
+ }) => {
1363
+ void biLogger.report(
1364
+ wixCliUserResponseToCliMessage({
1365
+ action,
1366
+ message,
1367
+ messageId: randomUUID(),
1368
+ siteRevision: Number(model.revision)
1369
+ })
1370
+ );
1371
+ }
1372
+ });
1373
+
1374
+ // ../cli-site-old/src/dev/sync-all-to-revision.ts
1375
+ init_esm_shims();
1376
+ import { rm as rm2 } from "node:fs/promises";
1377
+
1378
+ // ../cli-site-old/src/sources/index.ts
1379
+ init_esm_shims();
1380
+ import { readdir } from "node:fs/promises";
1381
+
1382
+ // ../cli-site-old/src/sources/pages-diff.ts
1383
+ init_esm_shims();
1384
+ import { join as join2 } from "node:path";
1385
+ import { rm, rename } from "node:fs/promises";
1386
+ async function createPages(projectFolder, pages) {
1387
+ await Promise.all(
1388
+ pages.map((page) => {
1389
+ if (!page.pageId?.path || !page.content) {
1390
+ return Promise.resolve();
1391
+ }
1392
+ return outputFile(join2(projectFolder, page.pageId.path), page.content);
1393
+ })
1394
+ );
1395
+ }
1396
+ async function renamePages(projectFolder, pages) {
1397
+ await Promise.all(
1398
+ pages.map(async (page) => {
1399
+ if (!page.sourcePath?.path || !page.targetPath?.path) {
1400
+ return;
1401
+ }
1402
+ const sourcePath = join2(projectFolder, page.sourcePath.path);
1403
+ const targetPath = join2(projectFolder, page.targetPath.path);
1404
+ if (await pathExists(targetPath)) {
1405
+ return rm(sourcePath, { force: true });
1406
+ }
1407
+ return rename(sourcePath, targetPath);
1408
+ })
1409
+ );
1410
+ }
1411
+ async function deletePages(projectFolder, pages) {
1412
+ await Promise.all(
1413
+ pages.map((page) => {
1414
+ if (!page.path) {
1415
+ return Promise.resolve();
1416
+ }
1417
+ return rm(join2(projectFolder, page.path), { force: true });
1418
+ })
1419
+ );
1420
+ }
1421
+
1422
+ // ../cli-site-old/src/sources/index.ts
1423
+ async function syncPages(model, opts) {
1424
+ const pagesFolder = getPagesFolder(model.projectFolder);
1425
+ if (!await pathExists(pagesFolder)) {
1426
+ throw new CliError({
1427
+ code: CliErrorCode.NoPagesDirectoryFound({
1428
+ srcDir: getSourceFolder(model.projectFolder)
1429
+ }),
1430
+ cause: null
1431
+ });
1432
+ }
1433
+ const params = {
1434
+ layout: GridAppLayout2.GITHUB,
1435
+ sourcePagesPaths: await readdir(pagesFolder),
1436
+ targetRevision: model.revision
1437
+ };
1438
+ const { data } = await httpRequest(
1439
+ {
1440
+ authState: opts.authState,
1441
+ type: "code"
1442
+ },
1443
+ pagesDiff(params)
1444
+ ).catch((e) => {
1445
+ throw new CliError({
1446
+ code: CliErrorCode.FailedToGetPagesDiff(),
1447
+ cause: e,
1448
+ info: { ...params }
1449
+ });
1450
+ });
1451
+ await Promise.all([
1452
+ createPages(model.projectFolder, data.pagesDiff?.created ?? []),
1453
+ renamePages(model.projectFolder, data.pagesDiff?.renamed ?? []),
1454
+ deletePages(model.projectFolder, data.pagesDiff?.deleted ?? [])
1455
+ ]);
1456
+ }
1457
+
1458
+ // ../cli-site-old/src/dev/sync-all-to-revision.ts
1459
+ async function syncAllToRevision(model, opts, logger) {
1460
+ const logTypesSynced = logger.logSyncingTypesToRevision(model.revision);
1461
+ try {
1462
+ await syncTypesWithAuth(model, { authState: opts.authState });
1463
+ logTypesSynced.success();
1464
+ } catch (error) {
1465
+ writeCrashReport(getDebugLogFilePath(model.projectFolder), error);
1466
+ logTypesSynced.fail();
1467
+ await rm2(getTypesDir(model.projectFolder), {
1468
+ recursive: true,
1469
+ force: true
1470
+ }).catch((e) => {
1471
+ writeCrashReport(getDebugLogFilePath(model.projectFolder), e);
1472
+ logger.logRecoverableFailureToRemoveTypesDir(e);
1473
+ });
1474
+ }
1475
+ const logPagesSynced = logger.logSyncingPagesToRevision(model.revision);
1476
+ try {
1477
+ await syncPages(model, { authState: opts.authState });
1478
+ logPagesSynced.success();
1479
+ } catch (error) {
1480
+ logPagesSynced.fail();
1481
+ throw error;
1482
+ }
1483
+ }
1484
+
1485
+ // ../cli-site-old/src/dev/dev.ts
1486
+ async function dev(initialModel, { biLogger, errorReporter }, {
1487
+ https = false,
1488
+ tunnel: useTunnel = false
1489
+ }) {
1490
+ let model = initialModel;
1491
+ const authState = await authenticate({
1492
+ metaSiteId: model.metaSiteId,
1493
+ biLogger,
1494
+ errorReporter
1495
+ });
1496
+ const t = createI18nT();
1497
+ const logger = createLogger({ t });
1498
+ const biEvents = sitesBiEvents(biLogger);
1499
+ const server = createVeloCLIServer({ https });
1500
+ let gridAppId;
1501
+ try {
1502
+ gridAppId = await createMutableGridApp(model.projectFolder, {
1503
+ authState
1504
+ });
1505
+ } catch (error) {
1506
+ const message = isHttpError(error) && error.response?.data?.message;
1507
+ throw new CliError({
1508
+ code: CliErrorCode.FailedToCreateGridApp({
1509
+ error: message
1510
+ }),
1511
+ cause: error
1512
+ });
1513
+ }
1514
+ await syncAllToRevision(model, { authState }, logger);
1515
+ const { close } = startGridAppUpdater(
1516
+ model,
1517
+ gridAppId,
1518
+ {
1519
+ authState,
1520
+ onError(error) {
1521
+ logger.logNewLine();
1522
+ errorReporter.reportError(error);
1523
+ writeCrashReport(getDebugLogFilePath(model.projectFolder), error);
1524
+ renderSync((0, import_react.createElement)(ErrorViewer, { error }));
1525
+ }
1526
+ },
1527
+ logger,
1528
+ biEvents
1529
+ );
1530
+ const onServerDisconnected = (devEditorUrl) => {
1531
+ const message = logger.logNoOpenedTab(devEditorUrl);
1532
+ biEvents.messageDisplayed({ model, message });
1533
+ };
1534
+ const onSyncDevEditorChanges = async (revision) => {
1535
+ if (revision !== model.revision) {
1536
+ const newModel = { ...model, revision };
1537
+ await saveProjectModel(newModel);
1538
+ const message = logger.logUpdatedLocalCodeToRevision({
1539
+ revision: newModel.revision
1540
+ });
1541
+ biEvents.messageDisplayed({ message, model });
1542
+ await syncAllToRevision(newModel, { authState }, logger);
1543
+ model = newModel;
1544
+ }
1545
+ };
1546
+ const openLocalEditor = async (serverPort) => {
1547
+ biEvents.userResponse({
1548
+ action: "Browser opened",
1549
+ message: "Opening the Local Editor",
1550
+ model
1551
+ });
1552
+ const devEditorUrl = getDevEditorUrl(serverPort);
1553
+ if (https) {
1554
+ await openBrowser(new URL(`https://localhost:${serverPort}`).href);
1555
+ } else {
1556
+ await openBrowser(devEditorUrl);
1557
+ }
1558
+ };
1559
+ let keyWatcher;
1560
+ let tunnel2;
1561
+ const getDevEditorUrl = (serverPort) => {
1562
+ const url = new URL(model.metaSiteId, getDevEditorBaseUrl());
1563
+ if (tunnel2) {
1564
+ url.searchParams.append("localEditorDestination", tunnel2.domain);
1565
+ } else {
1566
+ url.searchParams.append("localPort", serverPort.toString());
1567
+ }
1568
+ url.searchParams.append("secureSocket", https.toString());
1569
+ return url.toString();
1570
+ };
1571
+ try {
1572
+ const { port: serverPort } = await server.serve(gridAppId, getDevEditorUrl);
1573
+ if (useTunnel) {
1574
+ const httpClient = createHttpClient({
1575
+ type: "backoffice",
1576
+ getAppToken: authState.getAccessToken
1577
+ });
1578
+ const tunnelClient = new TunnelClient(httpClient);
1579
+ tunnel2 = await launchTunnel(serverPort, tunnelClient);
1580
+ }
1581
+ const devEditorUrl = getDevEditorUrl(serverPort);
1582
+ server.on("disconnected", () => onServerDisconnected(devEditorUrl));
1583
+ server.on("syncDevEditorChanges", onSyncDevEditorChanges);
1584
+ keyWatcher = new KeyWatcher();
1585
+ logger.logOpeningBrowser(https);
1586
+ await openLocalEditor(serverPort);
1587
+ const { ctrlCPromise } = keyWatcher.watch();
1588
+ keyWatcher.on("e", () => openLocalEditor(serverPort));
1589
+ asyncExitHook(
1590
+ async () => {
1591
+ await server.close();
1592
+ tunnel2?.close();
1593
+ },
1594
+ { wait: 500 }
1595
+ );
1596
+ await ctrlCPromise;
1597
+ } finally {
1598
+ keyWatcher?.unwatch();
1599
+ await Promise.all([server.close(), close(), tunnel2?.close()]);
1600
+ }
1601
+ }
1602
+ export {
1603
+ dev
1604
+ };
1605
+ //# sourceMappingURL=dev-XHJYXDWW.js.map