@wix/cli 1.1.58 → 1.1.59

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-D6QHU2YA.js +7561 -0
  2. package/build/DevCommand-D6QHU2YA.js.map +1 -0
  3. package/build/{DevCommand-32POU3TX.js → DevCommand-PLIPWJKO.js} +14 -15
  4. package/build/{DevCommand-32POU3TX.js.map → DevCommand-PLIPWJKO.js.map} +1 -1
  5. package/build/{LoginCommand-WRCKEWCE.js → LoginCommand-NRZ4VWWM.js} +12 -12
  6. package/build/{LogoutCommand-BYWH527O.js → LogoutCommand-INOYIE67.js} +8 -8
  7. package/build/{WhoamiCommand-WKXZCRSJ.js → WhoamiCommand-4V4GTNFW.js} +4 -4
  8. package/build/{chunk-JMUOY2KY.js → chunk-3RBFRZE2.js} +8 -8
  9. package/build/{chunk-JMUOY2KY.js.map → chunk-3RBFRZE2.js.map} +1 -1
  10. package/build/{chunk-X7GWN4JO.js → chunk-4HVBZRJL.js} +2 -2
  11. package/build/{chunk-CQHI53JJ.js → chunk-4OBSJ6OG.js} +5043 -659
  12. package/build/chunk-4OBSJ6OG.js.map +1 -0
  13. package/build/{chunk-LOJ4G3VD.js → chunk-5XUFGBCU.js} +2 -2
  14. package/build/{chunk-WYEQRRT2.js → chunk-5ZVEBKUO.js} +2829 -66
  15. package/build/chunk-5ZVEBKUO.js.map +1 -0
  16. package/build/{chunk-UQXJQCG3.js → chunk-AXVTET6V.js} +2 -2
  17. package/build/{chunk-53UCEZFU.js → chunk-BNWDAMAL.js} +175 -45
  18. package/build/chunk-BNWDAMAL.js.map +1 -0
  19. package/build/{chunk-MPSJ2YGQ.js → chunk-BV3B44QL.js} +3 -3
  20. package/build/{chunk-IRR7PD4K.js → chunk-CMXHWKEP.js} +3 -3
  21. package/build/{chunk-RJBLVNKS.js → chunk-CS26555F.js} +7 -7
  22. package/build/{chunk-BQ6AW6QJ.js → chunk-F3E4MMLD.js} +6 -6
  23. package/build/{chunk-3R4OZ46Z.js → chunk-G6TDIUNY.js} +2 -2
  24. package/build/{chunk-4S2ZMDZM.js → chunk-GLXEVSFE.js} +7 -7
  25. package/build/{chunk-OIH7DI4E.js → chunk-HYAIYTKF.js} +62 -6
  26. package/build/{chunk-OIH7DI4E.js.map → chunk-HYAIYTKF.js.map} +1 -1
  27. package/build/{chunk-24HYCAK2.js → chunk-JG7FKL4X.js} +3 -3
  28. package/build/{chunk-F63O2UMD.js → chunk-KCTZ5EX4.js} +401 -116
  29. package/build/chunk-KCTZ5EX4.js.map +1 -0
  30. package/build/{chunk-Q5WMVJRK.js → chunk-N5IXBRXL.js} +2 -2
  31. package/build/{chunk-KLWKSELB.js → chunk-OOGMXJJV.js} +6 -6
  32. package/build/{chunk-3KIPOGXI.js → chunk-PNUERA4W.js} +5 -5
  33. package/build/{chunk-WRMFR7CU.js → chunk-QGSHUCNV.js} +8 -8
  34. package/build/{chunk-KOCJZPLK.js → chunk-SELJR2HV.js} +2 -2
  35. package/build/{chunk-XU2RG4HE.js → chunk-T4OH34QF.js} +8 -2
  36. package/build/{chunk-XU2RG4HE.js.map → chunk-T4OH34QF.js.map} +1 -1
  37. package/build/{chunk-WZEZZAE4.js → chunk-U32RURCT.js} +126 -70
  38. package/build/chunk-U32RURCT.js.map +1 -0
  39. package/build/{chunk-5EXKEGN6.js → chunk-V4DAKO7L.js} +297 -440
  40. package/build/chunk-V4DAKO7L.js.map +1 -0
  41. package/build/{chunk-NK4U57KS.js → chunk-VEVISRHN.js} +5 -5
  42. package/build/{chunk-W32TRG4E.js → chunk-WN3D6AOY.js} +39 -25
  43. package/build/chunk-WN3D6AOY.js.map +1 -0
  44. package/build/{chunk-ZOWPPCOU.js → chunk-X7XOMWAQ.js} +5 -5
  45. package/build/{chunk-LC2NSYSB.js → chunk-YUFAOC35.js} +6 -6
  46. package/build/{chunk-KT54TL6D.js → chunk-Z7P6TDPB.js} +6 -6
  47. package/build/{dev-M7P6GT7S.js → dev-TEWYYBKR.js} +23 -24
  48. package/build/{dev-M7P6GT7S.js.map → dev-TEWYYBKR.js.map} +1 -1
  49. package/build/index.js +26 -26
  50. package/build/{install-SX7OQQGW.js → install-MTS6LPPU.js} +17 -17
  51. package/build/{preview-7WGCS2DK.js → preview-TDMPHSVV.js} +18 -18
  52. package/build/{publish-U7Y5KNMR.js → publish-5VLMBE6J.js} +18 -18
  53. package/build/{render-command-TJTVTOHT.js → render-command-7OMEGPW4.js} +11 -11
  54. package/build/{render-command-P4B7B4WB.js → render-command-FELGYBEY.js} +12 -12
  55. package/build/{render-command-6GZ7MNO5.js → render-command-UQPFUBIL.js} +12 -12
  56. package/build/{run-command-ZLQ3PKCS.js → run-command-3YTQS4ZX.js} +10 -10
  57. package/build/{src-WBDWTVY2.js → src-4W2WPIAM.js} +8 -8
  58. package/build/{src-JGFI4IQH.js → src-7NEL65ZK.js} +18 -18
  59. package/build/{src-Q3X5WF65.js → src-IBLQL7AB.js} +6 -6
  60. package/build/{src-WKNIYADZ.js → src-LA3GYOE6.js} +7 -7
  61. package/build/{src-5XWKD5UB.js → src-UWOBS6D7.js} +2 -2
  62. package/build/{src-I6QIZSAX.js → src-Y334LPF5.js} +7 -7
  63. package/build/sync-types-W3PVOJTK.js +30 -0
  64. package/build/{uninstall-L6JBTJHG.js → uninstall-M4DEVSQC.js} +16 -16
  65. package/package.json +5 -5
  66. package/build/DevCommand-WT3DJON6.js +0 -1040
  67. package/build/DevCommand-WT3DJON6.js.map +0 -1
  68. package/build/chunk-53UCEZFU.js.map +0 -1
  69. package/build/chunk-5EXKEGN6.js.map +0 -1
  70. package/build/chunk-CQHI53JJ.js.map +0 -1
  71. package/build/chunk-F63O2UMD.js.map +0 -1
  72. package/build/chunk-OUBPZBBH.js +0 -558
  73. package/build/chunk-OUBPZBBH.js.map +0 -1
  74. package/build/chunk-W32TRG4E.js.map +0 -1
  75. package/build/chunk-WYEQRRT2.js.map +0 -1
  76. package/build/chunk-WZEZZAE4.js.map +0 -1
  77. package/build/sync-types-6XPVFG3C.js +0 -31
  78. /package/build/{LoginCommand-WRCKEWCE.js.map → LoginCommand-NRZ4VWWM.js.map} +0 -0
  79. /package/build/{LogoutCommand-BYWH527O.js.map → LogoutCommand-INOYIE67.js.map} +0 -0
  80. /package/build/{WhoamiCommand-WKXZCRSJ.js.map → WhoamiCommand-4V4GTNFW.js.map} +0 -0
  81. /package/build/{chunk-X7GWN4JO.js.map → chunk-4HVBZRJL.js.map} +0 -0
  82. /package/build/{chunk-LOJ4G3VD.js.map → chunk-5XUFGBCU.js.map} +0 -0
  83. /package/build/{chunk-UQXJQCG3.js.map → chunk-AXVTET6V.js.map} +0 -0
  84. /package/build/{chunk-MPSJ2YGQ.js.map → chunk-BV3B44QL.js.map} +0 -0
  85. /package/build/{chunk-IRR7PD4K.js.map → chunk-CMXHWKEP.js.map} +0 -0
  86. /package/build/{chunk-RJBLVNKS.js.map → chunk-CS26555F.js.map} +0 -0
  87. /package/build/{chunk-BQ6AW6QJ.js.map → chunk-F3E4MMLD.js.map} +0 -0
  88. /package/build/{chunk-3R4OZ46Z.js.map → chunk-G6TDIUNY.js.map} +0 -0
  89. /package/build/{chunk-4S2ZMDZM.js.map → chunk-GLXEVSFE.js.map} +0 -0
  90. /package/build/{chunk-24HYCAK2.js.map → chunk-JG7FKL4X.js.map} +0 -0
  91. /package/build/{chunk-Q5WMVJRK.js.map → chunk-N5IXBRXL.js.map} +0 -0
  92. /package/build/{chunk-KLWKSELB.js.map → chunk-OOGMXJJV.js.map} +0 -0
  93. /package/build/{chunk-3KIPOGXI.js.map → chunk-PNUERA4W.js.map} +0 -0
  94. /package/build/{chunk-WRMFR7CU.js.map → chunk-QGSHUCNV.js.map} +0 -0
  95. /package/build/{chunk-KOCJZPLK.js.map → chunk-SELJR2HV.js.map} +0 -0
  96. /package/build/{chunk-NK4U57KS.js.map → chunk-VEVISRHN.js.map} +0 -0
  97. /package/build/{chunk-ZOWPPCOU.js.map → chunk-X7XOMWAQ.js.map} +0 -0
  98. /package/build/{chunk-LC2NSYSB.js.map → chunk-YUFAOC35.js.map} +0 -0
  99. /package/build/{chunk-KT54TL6D.js.map → chunk-Z7P6TDPB.js.map} +0 -0
  100. /package/build/{install-SX7OQQGW.js.map → install-MTS6LPPU.js.map} +0 -0
  101. /package/build/{preview-7WGCS2DK.js.map → preview-TDMPHSVV.js.map} +0 -0
  102. /package/build/{publish-U7Y5KNMR.js.map → publish-5VLMBE6J.js.map} +0 -0
  103. /package/build/{render-command-TJTVTOHT.js.map → render-command-7OMEGPW4.js.map} +0 -0
  104. /package/build/{render-command-P4B7B4WB.js.map → render-command-FELGYBEY.js.map} +0 -0
  105. /package/build/{render-command-6GZ7MNO5.js.map → render-command-UQPFUBIL.js.map} +0 -0
  106. /package/build/{run-command-ZLQ3PKCS.js.map → run-command-3YTQS4ZX.js.map} +0 -0
  107. /package/build/{src-5XWKD5UB.js.map → src-4W2WPIAM.js.map} +0 -0
  108. /package/build/{src-JGFI4IQH.js.map → src-7NEL65ZK.js.map} +0 -0
  109. /package/build/{src-Q3X5WF65.js.map → src-IBLQL7AB.js.map} +0 -0
  110. /package/build/{src-WKNIYADZ.js.map → src-LA3GYOE6.js.map} +0 -0
  111. /package/build/{src-WBDWTVY2.js.map → src-UWOBS6D7.js.map} +0 -0
  112. /package/build/{src-I6QIZSAX.js.map → src-Y334LPF5.js.map} +0 -0
  113. /package/build/{sync-types-6XPVFG3C.js.map → sync-types-W3PVOJTK.js.map} +0 -0
  114. /package/build/{uninstall-L6JBTJHG.js.map → uninstall-M4DEVSQC.js.map} +0 -0
@@ -1,1040 +0,0 @@
1
- import { createRequire as _createRequire } from 'node:module';
2
- const require = _createRequire(import.meta.url);
3
- import {
4
- createVeloCLIServer,
5
- debounceQueue,
6
- require_chokidar
7
- } from "./chunk-WYEQRRT2.js";
8
- import "./chunk-EDFOB3LN.js";
9
- import {
10
- useVeloClient
11
- } from "./chunk-WRMFR7CU.js";
12
- import "./chunk-Q5WMVJRK.js";
13
- import "./chunk-X7GWN4JO.js";
14
- import {
15
- useProjectModel
16
- } from "./chunk-KT54TL6D.js";
17
- import "./chunk-OUBPZBBH.js";
18
- import {
19
- openBrowser,
20
- pLimit
21
- } from "./chunk-WZEZZAE4.js";
22
- import {
23
- useErrorReporter
24
- } from "./chunk-OIH7DI4E.js";
25
- import {
26
- Alert,
27
- Badge,
28
- Box_default,
29
- Key,
30
- Spinner,
31
- Trans,
32
- require_react,
33
- useAsync,
34
- useAsyncCallback,
35
- useExit,
36
- use_input_default
37
- } from "./chunk-5EXKEGN6.js";
38
- import "./chunk-W32TRG4E.js";
39
- import "./chunk-W423UTD3.js";
40
- import "./chunk-6F2RSXHN.js";
41
- import "./chunk-YU54OBFT.js";
42
- import "./chunk-XMTHMR2B.js";
43
- import {
44
- getSourceFolder
45
- } from "./chunk-LOJ4G3VD.js";
46
- import "./chunk-24HYCAK2.js";
47
- import {
48
- getTestOverrides
49
- } from "./chunk-53UCEZFU.js";
50
- import {
51
- CliError,
52
- CliErrorCode,
53
- require_lib
54
- } from "./chunk-XU2RG4HE.js";
55
- import {
56
- __toESM,
57
- init_esm_shims
58
- } from "./chunk-PYIAC2GK.js";
59
-
60
- // ../cli-site/src/components/DevCommand/DevCommand.tsx
61
- init_esm_shims();
62
- var import_react6 = __toESM(require_react(), 1);
63
-
64
- // ../cli-site/src/components/DevCommand/DevCommandScreen.tsx
65
- init_esm_shims();
66
- var import_react5 = __toESM(require_react(), 1);
67
-
68
- // ../cli-site/src/components/DevCommand/DevEnvironment.tsx
69
- init_esm_shims();
70
- var import_react4 = __toESM(require_react(), 1);
71
- var import_variant = __toESM(require_lib(), 1);
72
-
73
- // ../cli-site/src/site-fs-manager.ts
74
- init_esm_shims();
75
-
76
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/index.js
77
- init_esm_shims();
78
-
79
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/wixSiteFSManager.js
80
- init_esm_shims();
81
-
82
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/index.js
83
- init_esm_shims();
84
-
85
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/code.js
86
- init_esm_shims();
87
- import path from "path";
88
-
89
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/utils/veloUtils.js
90
- init_esm_shims();
91
-
92
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/utils/constants.js
93
- init_esm_shims();
94
- var PAGE_CODE_TEMPLATE = `// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
95
- // \u201CHello, World!\u201D Example: https://learn-code.wix.com/en/article/hello-world
96
-
97
- $w.onReady(function () {
98
- // Write your JavaScript here
99
-
100
- // To select an element by ID use: $w('#elementID')
101
-
102
- // Click 'Preview' to run your code
103
- });
104
- `;
105
-
106
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/utils/veloUtils.js
107
- var readVeloFile = async (siteFileSystem, filePath) => {
108
- const content = await siteFileSystem.readFile(filePath);
109
- return { path: filePath, content };
110
- };
111
- var createDefaultPageCodeFile = async (siteFileSystem, filePath) => siteFileSystem.writeFile(filePath, PAGE_CODE_TEMPLATE);
112
- var getPageCodeFilePath = (pageId) => `public/pages/${pageId}.js`;
113
-
114
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/code.js
115
- var readAllFilesInDir = async (fileSystem, dir) => {
116
- const entries = await fileSystem.readFolder(dir);
117
- const filePromises = entries.map((entry) => {
118
- const entryPath = path.join(dir, entry.name);
119
- if (entry.isFile()) {
120
- return readVeloFile(fileSystem, entryPath);
121
- }
122
- return readAllFilesInDir(fileSystem, entryPath);
123
- });
124
- return (await Promise.all(filePromises)).flat();
125
- };
126
- var readBackendFiles = async (state) => readAllFilesInDir(state.fileSystem, state.fileStructure.getBackendFolderPath());
127
- var readPublicFiles = async (state) => readAllFilesInDir(state.fileSystem, state.fileStructure.getPublicFolderPath());
128
- var readPageCodeFiles = async (state) => {
129
- const codeFiles = [];
130
- const pages = state.pages.getAll();
131
- for (const { pageId, pagePath } of pages) {
132
- const page = state.fileStructure.getPageFilesPaths(pagePath);
133
- const content = await state.fileSystem.readFile(page.code);
134
- codeFiles.push({ path: getPageCodeFilePath(pageId), content });
135
- }
136
- return codeFiles;
137
- };
138
- var getSiteCode = async (state) => {
139
- const allFiles = await Promise.all([
140
- readBackendFiles(state),
141
- readPublicFiles(state),
142
- readPageCodeFiles(state)
143
- ]);
144
- return {
145
- files: allFiles.flat(),
146
- layout: "ONLINE",
147
- ignoreForbiddenPaths: true
148
- };
149
- };
150
-
151
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/index.js
152
- init_esm_shims();
153
-
154
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/document.js
155
- init_esm_shims();
156
-
157
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/utils/wmlUtils.js
158
- init_esm_shims();
159
- var pageIdRegex = /<(?:Master)?Page\s[^>]*?(?<=\s)id="(.+?)".*?>/;
160
- var getPageId = async (siteFileSystem, { structure }) => {
161
- const structureXmlContent = await siteFileSystem.readFile(structure);
162
- const [match2, pageId] = structureXmlContent.match(pageIdRegex) ?? [];
163
- if (!match2) {
164
- throw new Error("pageId not found in wml");
165
- }
166
- return pageId;
167
- };
168
- var mapWmlFiles = async (documentStructure, callbackFn) => {
169
- const [structure, data, style] = await Promise.all([
170
- callbackFn(documentStructure.structure, "structure"),
171
- callbackFn(documentStructure.data, "data"),
172
- callbackFn(documentStructure.style, "style")
173
- ]);
174
- return { structure, data, style };
175
- };
176
- var writeWmlFiles = async (siteFileSystem, documentStructure, wml) => {
177
- const filesContent = convertWmlExportToFiles(wml);
178
- await mapWmlFiles(documentStructure, (filePath, fileName) => siteFileSystem.writeFile(filePath, filesContent[fileName]));
179
- };
180
- var removeWmlFiles = async (siteFileSystem, documentStructure) => {
181
- await mapWmlFiles(documentStructure, (filePath) => siteFileSystem.removeFile(filePath));
182
- };
183
- var writeWml = async (siteFileSystem, documentStructure, pageData) => {
184
- if (pageData === null) {
185
- return removeWmlFiles(siteFileSystem, documentStructure);
186
- }
187
- return writeWmlFiles(siteFileSystem, documentStructure, pageData.data);
188
- };
189
- var readWml = async (siteFileSystem, documentStructure) => {
190
- const filesContent = await mapWmlFiles(documentStructure, async (filePath) => await siteFileSystem.readFile(filePath));
191
- return convertFilesToWmlExport(filesContent);
192
- };
193
- var indentedStringify = (data) => JSON.stringify(data, void 0, 2);
194
- var convertWmlExportToFiles = (wmlExport) => {
195
- const dataWithoutVersion = JSON.parse(wmlExport.data.content);
196
- const dataWithVersion = indentedStringify({ ...dataWithoutVersion, version: wmlExport.version });
197
- return {
198
- structure: wmlExport.structure.content,
199
- style: wmlExport.style.content,
200
- data: dataWithVersion
201
- };
202
- };
203
- var convertFilesToWmlExport = (filesContent) => {
204
- const { version, ...dataWithoutVersion } = JSON.parse(filesContent.data);
205
- return {
206
- structure: { type: "xml", content: filesContent.structure },
207
- data: { type: "json", content: indentedStringify(dataWithoutVersion) },
208
- style: { type: "css", content: filesContent.style },
209
- version
210
- };
211
- };
212
-
213
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/document.js
214
- var getDocumentPages = async (state) => {
215
- const documentPages = {};
216
- const pages = state.pages.getAll();
217
- for (const { pageId, pagePath } of pages) {
218
- const page = state.fileStructure.getPageFilesPaths(pagePath);
219
- const wml = await readWml(state.fileSystem, page.document);
220
- documentPages[pageId] = wml;
221
- }
222
- return documentPages;
223
- };
224
- var getSiteDocument = async (state) => {
225
- const documentPages = await getDocumentPages(state);
226
- const { masterPage, ...otherPages } = documentPages;
227
- if (!masterPage) {
228
- throw new Error("Missing master page");
229
- }
230
- return {
231
- pages: {
232
- masterPage,
233
- ...otherPages
234
- }
235
- };
236
- };
237
-
238
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/externalUpdates.js
239
- init_esm_shims();
240
-
241
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/page/utils.js
242
- init_esm_shims();
243
- import path2 from "path";
244
- var generatePageFolderPathByInfo = (state, pageInfo) => {
245
- const pagePath = state.fileStructure.getPagesPathsForType(pageInfo.type);
246
- return path2.join(...pagePath.map((entry) => entry.type === "Folder" ? entry.name : pageInfo[entry.variableName]));
247
- };
248
- var escapeRegexSpecialChars = (str) => str.replace(/[.*+?^=!:${}()|[\]/\\]/g, "\\$&");
249
- var isPathFormatMatching = (fullPath, basePath) => new RegExp(`^${escapeRegexSpecialChars(basePath)}(?: \\((\\d*)\\))?$`).test(fullPath);
250
- var generateNewPagePath = (state, pageInfo, existingPageFolderPath) => {
251
- let pageFolderPath = generatePageFolderPathByInfo(state, pageInfo);
252
- if (existingPageFolderPath && isPathFormatMatching(existingPageFolderPath, pageFolderPath)) {
253
- return existingPageFolderPath;
254
- }
255
- while (state.pages.getPageId(pageFolderPath)) {
256
- pageFolderPath = incrementPathSuffix(pageFolderPath);
257
- }
258
- return pageFolderPath;
259
- };
260
- var createPageFiles = async (state, folderPath, pageData) => {
261
- const pageStructure = state.fileStructure.getPageFilesPaths(folderPath);
262
- await Promise.all([
263
- writeWml(state.fileSystem, pageStructure.document, pageData),
264
- createDefaultPageCodeFile(state.fileSystem, pageStructure.code)
265
- ]);
266
- };
267
- var createPage = async (state, pageId, pageData) => {
268
- const newPageFolder = generateNewPagePath(state, pageData.info);
269
- await state.fileSystem.createFolder(newPageFolder);
270
- await createPageFiles(state, newPageFolder, pageData);
271
- state.pages.addPage(pageId, newPageFolder);
272
- };
273
- var removePage = async (state, pageId) => {
274
- const folderPath = state.pages.getFolderPath(pageId);
275
- if (!folderPath)
276
- return;
277
- await state.fileSystem.removeFolder(folderPath);
278
- state.pages.removePageById(pageId);
279
- };
280
- var updatePage = async (state, pageId, existingPageFolderPath, pageData) => {
281
- const expectedFolderPath = generateNewPagePath(state, pageData.info, existingPageFolderPath);
282
- if (existingPageFolderPath !== expectedFolderPath) {
283
- await removePage(state, pageId);
284
- await createPage(state, pageId, pageData);
285
- return;
286
- }
287
- const pageStructure = state.fileStructure.getPageFilesPaths(existingPageFolderPath);
288
- await writeWml(state.fileSystem, pageStructure.document, pageData);
289
- };
290
- var incrementPathSuffix = (path6) => {
291
- const [, origPath, suffix = 1] = path6.match(/^(.*?)(?: \((\d+)\))?$/) ?? [];
292
- return `${origPath} (${Number(suffix) + 1})`;
293
- };
294
-
295
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/externalUpdates.js
296
- var applyPageUpdate = async (state, pageId, pageData) => {
297
- if (pageData === null) {
298
- return removePage(state, pageId);
299
- }
300
- const existingPageFolder = state.pages.getFolderPath(pageId);
301
- if (existingPageFolder) {
302
- return updatePage(state, pageId, existingPageFolder, pageData);
303
- }
304
- return createPage(state, pageId, pageData);
305
- };
306
- var applyDocumentExternalUpdates = async (state, { pages }) => {
307
- for (const [pageId, pageData] of Object.entries(pages)) {
308
- await applyPageUpdate(state, pageId, pageData);
309
- }
310
- };
311
-
312
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/state.js
313
- init_esm_shims();
314
-
315
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/siteFileStructure.js
316
- init_esm_shims();
317
-
318
- // ../../node_modules/@wix/anyide-template-layout/dist/index.js
319
- init_esm_shims();
320
-
321
- // ../../node_modules/@wix/anyide-template-layout/dist/code.js
322
- init_esm_shims();
323
-
324
- // ../../node_modules/@wix/anyide-template-layout/dist/configs/index.js
325
- init_esm_shims();
326
-
327
- // ../../node_modules/@wix/anyide-template-layout/dist/configs/blocksConfig.js
328
- init_esm_shims();
329
- var blocksConfig = {
330
- backend: "backend",
331
- public: "public",
332
- pages: {
333
- structure: {
334
- code: "index.js",
335
- document: {
336
- structure: "structure.xml",
337
- data: "data.json",
338
- style: "style.css"
339
- }
340
- },
341
- folders: {
342
- Widget: [
343
- { name: "widgets", type: "Folder" },
344
- { variableName: "widgetName", type: "DynamicFolder" }
345
- ],
346
- Panel: [
347
- { name: "widgets", type: "Folder" },
348
- { variableName: "widgetName", type: "DynamicFolder" },
349
- { name: "panels", type: "Folder" },
350
- { variableName: "panelName", type: "DynamicFolder" }
351
- ]
352
- }
353
- }
354
- };
355
-
356
- // ../../node_modules/@wix/anyide-template-layout/dist/configs/editorConfig.js
357
- init_esm_shims();
358
- var editorConfig = {
359
- backend: "backend",
360
- public: "public",
361
- pages: {
362
- structure: {
363
- code: "index.js",
364
- document: {
365
- structure: "structure.xml",
366
- data: "data.json",
367
- style: "style.css"
368
- }
369
- },
370
- folders: {
371
- Page: [
372
- { name: "pages", type: "Folder" },
373
- { variableName: "title", type: "DynamicFolder" }
374
- ]
375
- }
376
- }
377
- };
378
-
379
- // ../../node_modules/@wix/anyide-template-layout/dist/configs/index.js
380
- var configs = {
381
- Editor: editorConfig,
382
- Blocks: blocksConfig
383
- };
384
- var getConfig = (structureType) => {
385
- const config = configs[structureType];
386
- if (!config) {
387
- throw new Error("Unknown file structure type: " + structureType);
388
- }
389
- return config;
390
- };
391
-
392
- // ../../node_modules/@wix/anyide-template-layout/dist/code.js
393
- var getBackendPath = (structureType) => getConfig(structureType).backend;
394
- var getPublicPath = (structureType) => getConfig(structureType).public;
395
-
396
- // ../../node_modules/@wix/anyide-template-layout/dist/page.js
397
- init_esm_shims();
398
- import path3 from "path";
399
- var getPagesPaths = (structureType) => getConfig(structureType).pages.folders;
400
- var getPageFilesPaths = (structureType, folderPath) => {
401
- const { pages } = getConfig(structureType);
402
- const { structure } = pages;
403
- return {
404
- code: path3.join(folderPath, structure.code),
405
- document: {
406
- structure: path3.join(folderPath, structure.document.structure),
407
- style: path3.join(folderPath, structure.document.style),
408
- data: path3.join(folderPath, structure.document.data)
409
- }
410
- };
411
- };
412
- var getPageFilesNames = (structureType, pageStructureType) => {
413
- const { pages } = getConfig(structureType);
414
- const { structure } = pages;
415
- if (pageStructureType === "document") {
416
- return /* @__PURE__ */ new Set([
417
- structure[pageStructureType].structure,
418
- structure[pageStructureType].data,
419
- structure[pageStructureType].style
420
- ]);
421
- }
422
- return /* @__PURE__ */ new Set([structure[pageStructureType]]);
423
- };
424
-
425
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/siteFileStructure.js
426
- var SiteFileStructure = class {
427
- fileStructureType;
428
- constructor(fileStructureType) {
429
- this.fileStructureType = fileStructureType;
430
- }
431
- getBackendFolderPath() {
432
- return getBackendPath(this.fileStructureType);
433
- }
434
- getPublicFolderPath() {
435
- return getPublicPath(this.fileStructureType);
436
- }
437
- getPagesPaths() {
438
- return getPagesPaths(this.fileStructureType);
439
- }
440
- getPagesPathsForType(type) {
441
- const paths = this.getPagesPaths();
442
- const pathForType = paths[type];
443
- if (!pathForType) {
444
- throw new Error(`page type "${type}" is invalid for structureType "${this.fileStructureType}"`);
445
- }
446
- return pathForType;
447
- }
448
- getPageFilesPaths(pageFolderPath) {
449
- return getPageFilesPaths(this.fileStructureType, pageFolderPath);
450
- }
451
- matchPagePath(filePath) {
452
- const pageFilesPath = this.getPagesPaths();
453
- const sortedPageFilesPath = Object.entries(pageFilesPath).sort((a, b) => b[1].length - a[1].length);
454
- for (const [type, pagePath] of sortedPageFilesPath) {
455
- const typeRegex = new RegExp(`^(${pagePath.map((entry) => entry.type === "Folder" ? entry.name : ".+?").join("/")})/(.+)`);
456
- const path6 = typeRegex.exec(filePath);
457
- if (path6) {
458
- return {
459
- type,
460
- pagePath: path6[1],
461
- fileName: path6[2]
462
- };
463
- }
464
- }
465
- return null;
466
- }
467
- getStructureInfoByFilePath(filePath) {
468
- const backendPath = `${this.getBackendFolderPath()}/`;
469
- const publicPath = `${this.getPublicFolderPath()}/`;
470
- if (filePath.startsWith(backendPath) || filePath.startsWith(publicPath)) {
471
- return { type: "code", isPageFile: false };
472
- }
473
- const pageMatch = this.matchPagePath(filePath);
474
- if (pageMatch) {
475
- const { pagePath, fileName } = pageMatch;
476
- const codeFiles = getPageFilesNames(this.fileStructureType, "code");
477
- if (codeFiles.has(fileName)) {
478
- return { type: "code", isPageFile: true, pagePath };
479
- }
480
- const documentFiles = getPageFilesNames(this.fileStructureType, "document");
481
- if (documentFiles.has(fileName)) {
482
- return { type: "document", isPageFile: true, pagePath };
483
- }
484
- }
485
- return null;
486
- }
487
- };
488
-
489
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/siteFileSystem.js
490
- init_esm_shims();
491
- import fs from "fs/promises";
492
- import path4 from "path";
493
- var SiteFileSystem = class {
494
- rootFolderPath;
495
- constructor(rootFolderPath) {
496
- this.rootFolderPath = rootFolderPath;
497
- }
498
- getFullPath(relativePath) {
499
- return path4.join(this.rootFolderPath, relativePath);
500
- }
501
- async readFile(filePath) {
502
- return fs.readFile(this.getFullPath(filePath), "utf-8");
503
- }
504
- async writeFile(filePath, content) {
505
- return fs.writeFile(this.getFullPath(filePath), content);
506
- }
507
- async removeFile(filePath) {
508
- return fs.rm(this.getFullPath(filePath));
509
- }
510
- async readFolder(folderPath) {
511
- return fs.readdir(this.getFullPath(folderPath), { withFileTypes: true });
512
- }
513
- async createFolder(folderPath) {
514
- await fs.mkdir(this.getFullPath(folderPath), { recursive: true });
515
- }
516
- async removeFolder(folderPath) {
517
- return fs.rm(this.getFullPath(folderPath), { recursive: true });
518
- }
519
- };
520
-
521
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/stateBuilder.js
522
- init_esm_shims();
523
-
524
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/sitePagesState.js
525
- init_esm_shims();
526
- var CaseInsensitiveMap = class {
527
- map = /* @__PURE__ */ new Map();
528
- normalizeKey(key) {
529
- return key.toLowerCase();
530
- }
531
- get(key) {
532
- return this.map.get(this.normalizeKey(key));
533
- }
534
- set(key, value) {
535
- this.map.set(this.normalizeKey(key), value);
536
- }
537
- delete(key) {
538
- this.map.delete(this.normalizeKey(key));
539
- }
540
- entries() {
541
- return this.map.entries();
542
- }
543
- };
544
- var SitePagesState = class {
545
- pageIdToFolderPath = /* @__PURE__ */ new Map();
546
- folderPathToPageId = new CaseInsensitiveMap();
547
- getAll() {
548
- const allPages = [];
549
- for (const [pageId, pagePath] of this.pageIdToFolderPath.entries()) {
550
- allPages.push({ pageId, pagePath });
551
- }
552
- return allPages;
553
- }
554
- addPage(pageId, folderPath) {
555
- this.pageIdToFolderPath.set(pageId, folderPath);
556
- this.folderPathToPageId.set(folderPath, pageId);
557
- }
558
- removePageById(pageId) {
559
- const folderPath = this.pageIdToFolderPath.get(pageId);
560
- if (folderPath === void 0) {
561
- return;
562
- }
563
- this.pageIdToFolderPath.delete(pageId);
564
- this.folderPathToPageId.delete(folderPath);
565
- }
566
- removePageByPath(path6) {
567
- const pageId = this.folderPathToPageId.get(path6);
568
- if (pageId === void 0) {
569
- return;
570
- }
571
- this.pageIdToFolderPath.delete(pageId);
572
- this.folderPathToPageId.delete(path6);
573
- }
574
- getFolderPath(pageId) {
575
- return this.pageIdToFolderPath.get(pageId);
576
- }
577
- getPageId(folderPath) {
578
- return this.folderPathToPageId.get(folderPath);
579
- }
580
- };
581
-
582
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/stateBuilder.js
583
- import path5 from "path";
584
- var getFoldersInPath = async (siteFileSystem, dirPath) => {
585
- const entries = await siteFileSystem.readFolder(dirPath);
586
- return entries.filter((entry) => entry.isDirectory()).map(({ name }) => name);
587
- };
588
- var getMatchingPaths = (folderName, paths) => paths.filter(([first]) => first?.type === "DynamicFolder" || first.name === folderName);
589
- var getPages = async (siteFileSystem, paths, rootPath = "") => {
590
- if (paths.length === 0)
591
- return [];
592
- const result = [];
593
- const rootFolders = await getFoldersInPath(siteFileSystem, rootPath);
594
- for (const folderName of rootFolders) {
595
- const matchingPaths = getMatchingPaths(folderName, paths);
596
- if (matchingPaths.length > 0) {
597
- const finalPaths = matchingPaths.filter((p) => p.length === 1).map(() => path5.join(rootPath, folderName));
598
- const nonFinalPaths = matchingPaths.filter((p) => p.length > 1).map(([, ...rest]) => rest);
599
- const nestedPages = await getPages(siteFileSystem, nonFinalPaths, path5.join(rootPath, folderName));
600
- result.push(...finalPaths, ...nestedPages);
601
- }
602
- }
603
- return result;
604
- };
605
- var getAllPageFolders = async (siteFileStructure, siteFileSystem) => {
606
- const paths = siteFileStructure.getPagesPaths();
607
- return await getPages(siteFileSystem, Object.values(paths));
608
- };
609
- var buildPagesState = async (siteFileStructure, siteFileSystem) => {
610
- const state = new SitePagesState();
611
- const pagesFolders = await getAllPageFolders(siteFileStructure, siteFileSystem);
612
- await Promise.all(pagesFolders.map(async (folderPath) => {
613
- const filePaths = siteFileStructure.getPageFilesPaths(folderPath);
614
- const pageId = await getPageId(siteFileSystem, filePaths.document);
615
- state.addPage(pageId, folderPath);
616
- }));
617
- return state;
618
- };
619
-
620
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/state/state.js
621
- var buildState = async (rootFolderPath, fileStructureType) => {
622
- const fileSystem = new SiteFileSystem(rootFolderPath);
623
- const fileStructure = new SiteFileStructure(fileStructureType);
624
- const pages = await buildPagesState(fileStructure, fileSystem);
625
- return {
626
- fileSystem,
627
- fileStructure,
628
- pages
629
- };
630
- };
631
-
632
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/applyFsUpdates.js
633
- init_esm_shims();
634
-
635
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/code/fsUpdates.js
636
- init_esm_shims();
637
- var initVeloCodeUpdate = () => {
638
- return {
639
- layout: "ONLINE",
640
- ignoreForbiddenPaths: true
641
- };
642
- };
643
- var applyDeleteCode = (codeUpdate, path6) => {
644
- if (!codeUpdate) {
645
- codeUpdate = initVeloCodeUpdate();
646
- }
647
- codeUpdate.pathsToDelete ??= [];
648
- codeUpdate.pathsToDelete.push(path6);
649
- return codeUpdate;
650
- };
651
- var applyUpdateCode = (codeUpdate, veloFile) => {
652
- if (!codeUpdate) {
653
- codeUpdate = initVeloCodeUpdate();
654
- }
655
- codeUpdate.filesToUpdate ??= [];
656
- codeUpdate.filesToUpdate.push(veloFile);
657
- return codeUpdate;
658
- };
659
- var accumulateFsUpdateToVeloCodeUpdate = async (state, veloCodeUpdate, { path: path6, action }) => {
660
- let result = veloCodeUpdate;
661
- if (action === "DELETE") {
662
- result = applyDeleteCode(result, path6);
663
- } else if (action === "UPDATE") {
664
- const veloFile = await readVeloFile(state.fileSystem, path6);
665
- result = applyUpdateCode(result, veloFile);
666
- }
667
- return result;
668
- };
669
-
670
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/page/fsUpdates.js
671
- init_esm_shims();
672
-
673
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/document/fsUpdates.js
674
- init_esm_shims();
675
- var applyDocumentUpdate = (documentUpdate, pageId, value) => {
676
- documentUpdate ??= { pages: {} };
677
- documentUpdate.pages[pageId] = value;
678
- return documentUpdate;
679
- };
680
-
681
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/page/fsUpdates.js
682
- var applyDeletePage = (siteFsUpdate, pageId) => {
683
- siteFsUpdate.document = applyDocumentUpdate(siteFsUpdate.document, pageId, null);
684
- const veloPath = getPageCodeFilePath(pageId);
685
- siteFsUpdate.code = applyDeleteCode(siteFsUpdate.code, veloPath);
686
- return siteFsUpdate;
687
- };
688
- var applyCodeUpdateInPage = async (state, siteFsUpdate, pageId, path6) => {
689
- const veloFile = await readVeloFile(state.fileSystem, path6);
690
- siteFsUpdate.code = applyUpdateCode(siteFsUpdate.code, {
691
- path: getPageCodeFilePath(pageId),
692
- content: veloFile.content
693
- });
694
- return siteFsUpdate;
695
- };
696
- var accumulatePageFsUpdateToWixSiteFSUpdate = async (state, siteFsUpdate, structureInfo, { action, path: path6 }) => {
697
- const result = siteFsUpdate;
698
- const pageId = state.pages.getPageId(structureInfo.pagePath);
699
- if (action === "DELETE") {
700
- if (!pageId) {
701
- return result;
702
- }
703
- const { document, code } = applyDeletePage(result, pageId);
704
- result.document = document;
705
- result.code = code;
706
- state.pages.removePageById(pageId);
707
- } else if (action === "UPDATE") {
708
- const page = state.fileStructure.getPageFilesPaths(structureInfo.pagePath);
709
- if (structureInfo.type === "document") {
710
- const wml = await readWml(state.fileSystem, page.document);
711
- const pageIdInDocument = await getPageId(state.fileSystem, page.document);
712
- const folderPathForPageIdInDocument = state.pages.getFolderPath(pageIdInDocument);
713
- if (folderPathForPageIdInDocument && folderPathForPageIdInDocument !== structureInfo.pagePath) {
714
- throw new Error(`Duplicated pageId found in structure.xml files: ${pageIdInDocument}`);
715
- }
716
- if (pageId !== pageIdInDocument) {
717
- if (pageId) {
718
- const { document, code } = applyDeletePage(result, pageId);
719
- result.document = document;
720
- result.code = code;
721
- await applyCodeUpdateInPage(state, result, pageIdInDocument, page.code);
722
- state.pages.removePageById(pageId);
723
- }
724
- state.pages.addPage(pageIdInDocument, structureInfo.pagePath);
725
- }
726
- result.document = applyDocumentUpdate(result.document, pageIdInDocument, wml);
727
- } else if (structureInfo.type === "code") {
728
- if (!pageId) {
729
- return result;
730
- }
731
- await applyCodeUpdateInPage(state, result, pageId, path6);
732
- }
733
- }
734
- return result;
735
- };
736
-
737
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/applyFsUpdates.js
738
- var applyFsUpdates = async (state, updates) => {
739
- const result = {};
740
- for (const { path: path6, action } of updates) {
741
- const structureInfo = state.fileStructure.getStructureInfoByFilePath(path6);
742
- if (structureInfo === null)
743
- continue;
744
- if (structureInfo.isPageFile) {
745
- const { document, code } = await accumulatePageFsUpdateToWixSiteFSUpdate(state, result, structureInfo, {
746
- path: path6,
747
- action
748
- });
749
- result.code = code;
750
- result.document = document;
751
- } else if (structureInfo.type === "code") {
752
- result.code = await accumulateFsUpdateToVeloCodeUpdate(state, result.code, { path: path6, action });
753
- }
754
- }
755
- return result;
756
- };
757
-
758
- // ../../node_modules/@wix/anyide-cli-file-structure/dist/wixSiteFSManager.js
759
- var WixSiteFSManager = class _WixSiteFSManager {
760
- state;
761
- constructor(state) {
762
- this.state = state;
763
- }
764
- static async create(rootFolderPath, fileStructureType) {
765
- const state = await buildState(rootFolderPath, fileStructureType);
766
- return new _WixSiteFSManager(state);
767
- }
768
- async getCode() {
769
- return getSiteCode(this.state);
770
- }
771
- async getDocument() {
772
- return getSiteDocument(this.state);
773
- }
774
- async applyFsUpdates(updates) {
775
- return applyFsUpdates(this.state, updates);
776
- }
777
- async applyExternalUpdates({ code, document }) {
778
- if (code) {
779
- throw new Error("external code updates are not supported");
780
- }
781
- if (document) {
782
- await applyDocumentExternalUpdates(this.state, document);
783
- }
784
- }
785
- };
786
-
787
- // ../cli-site/src/site-fs-manager.ts
788
- async function createSiteFsManager(cwd) {
789
- const fsManager = await WixSiteFSManager.create(cwd, "Editor").catch(
790
- (error) => {
791
- throw new CliError({
792
- code: CliErrorCode.FailedToInitializeSiteFsManager(),
793
- cause: error
794
- });
795
- }
796
- );
797
- return {
798
- async getCode() {
799
- try {
800
- return await fsManager.getCode();
801
- } catch (error) {
802
- throw new CliError({
803
- code: CliErrorCode.FailedToGetSiteFsManagerCode(),
804
- cause: error
805
- });
806
- }
807
- },
808
- async getDocument() {
809
- try {
810
- return await fsManager.getDocument();
811
- } catch (error) {
812
- throw new CliError({
813
- code: CliErrorCode.FailedToGetSiteFsManagerDocument(),
814
- cause: error
815
- });
816
- }
817
- },
818
- async applyFsUpdates(updates) {
819
- try {
820
- return await fsManager.applyFsUpdates(updates);
821
- } catch (error) {
822
- throw new CliError({
823
- code: CliErrorCode.FailedToApplySiteFsManagerFsUpdates(),
824
- cause: error
825
- });
826
- }
827
- },
828
- async applyExternalUpdates(update) {
829
- try {
830
- await fsManager.applyExternalUpdates(update);
831
- } catch (error) {
832
- throw new CliError({
833
- code: CliErrorCode.FailedToApplySiteFsManagerExternalUpdates(),
834
- cause: error
835
- });
836
- }
837
- }
838
- };
839
- }
840
-
841
- // ../cli-site/src/components/DevCommand/useSrcFolder.ts
842
- init_esm_shims();
843
- function useSrcFolder() {
844
- const { model } = useProjectModel();
845
- return getSourceFolder(model.projectFolder);
846
- }
847
-
848
- // ../cli-site/src/components/DevCommand/useFsWatcher.ts
849
- init_esm_shims();
850
- var import_react = __toESM(require_react(), 1);
851
- var import_chokidar = __toESM(require_chokidar(), 1);
852
- function useFsWatcher(cwd) {
853
- const { reportError } = useErrorReporter();
854
- const [{ watcher, ...publicApi }] = (0, import_react.useState)(() => {
855
- const watcher2 = (0, import_chokidar.watch)(".", {
856
- cwd,
857
- ignoreInitial: true,
858
- disableGlobbing: true
859
- });
860
- return {
861
- watcher: watcher2,
862
- onBatchChange: (eventHandler) => {
863
- const debouncedHandler = debounceQueue(
864
- (events) => {
865
- const uniqEvents = new Map(events);
866
- const update = [];
867
- for (const [path6, action] of uniqEvents) {
868
- update.push({ path: path6, action });
869
- }
870
- eventHandler(update);
871
- },
872
- 400
873
- );
874
- watcher2.on("change", (path6) => debouncedHandler(path6, "UPDATE"));
875
- watcher2.on("add", (path6) => debouncedHandler(path6, "UPDATE"));
876
- watcher2.on("unlink", (path6) => debouncedHandler(path6, "DELETE"));
877
- }
878
- };
879
- });
880
- (0, import_react.useEffect)(() => {
881
- return () => {
882
- watcher.close().catch(reportError);
883
- };
884
- }, [watcher, reportError]);
885
- return publicApi;
886
- }
887
-
888
- // ../cli-site/src/components/DevCommand/useDevEditorUrl.ts
889
- init_esm_shims();
890
- var import_react2 = __toESM(require_react(), 1);
891
- function useDevEditorUrl() {
892
- const { model } = useProjectModel();
893
- return (0, import_react2.useCallback)(
894
- (serverPort) => {
895
- const { devEditorBaseUrl } = getTestOverrides();
896
- const url = new URL(
897
- model.metaSiteId,
898
- devEditorBaseUrl ?? "https://wix.com/editor/"
899
- );
900
- url.searchParams.set("localPort", String(serverPort));
901
- url.searchParams.set("github2", "true");
902
- return url.toString();
903
- },
904
- [model.metaSiteId]
905
- );
906
- }
907
-
908
- // ../cli-site/src/components/DevCommand/useWebSocketServer.ts
909
- init_esm_shims();
910
- var import_react3 = __toESM(require_react(), 1);
911
- function useWebSocketServer() {
912
- const { reportError } = useErrorReporter();
913
- const [server] = (0, import_react3.useState)(() => createVeloCLIServer());
914
- (0, import_react3.useEffect)(() => {
915
- return () => {
916
- server.close().catch(reportError);
917
- };
918
- }, [server, reportError]);
919
- return server;
920
- }
921
-
922
- // ../cli-site/src/components/DevCommand/DevEnvironment.tsx
923
- var DevEnvironmentContext = (0, import_react4.createContext)(null);
924
- var DevEnvironmentProvider = ({
925
- children
926
- }) => {
927
- const exit = useExit();
928
- const srcFolder = useSrcFolder();
929
- const { createMutableApp, updateAppFiles } = useVeloClient();
930
- const getDevEditorUrl = useDevEditorUrl();
931
- const wsServer = useWebSocketServer();
932
- const fsWatcher = useFsWatcher(srcFolder);
933
- const [isSyncing, setIsSyncing] = (0, import_react4.useState)(false);
934
- const [isDevEditorConnected, setIsDevEditorConnected] = (0, import_react4.useState)(false);
935
- const { status } = useAsync(async () => {
936
- const limiter = pLimit(1);
937
- const siteFsManager = await createSiteFsManager(srcFolder);
938
- const code = await siteFsManager.getCode();
939
- const { id: appId } = await createMutableApp(code);
940
- wsServer.on("connected", () => {
941
- setIsDevEditorConnected(true);
942
- });
943
- wsServer.on("disconnected", () => {
944
- setIsDevEditorConnected(false);
945
- });
946
- wsServer.on("documentUpdate", async (document) => {
947
- try {
948
- await limiter(async () => {
949
- setIsSyncing(true);
950
- await siteFsManager.applyExternalUpdates({ document });
951
- });
952
- } catch (error) {
953
- exit(error);
954
- } finally {
955
- setIsSyncing(false);
956
- }
957
- });
958
- const { port } = await wsServer.serve(appId, getDevEditorUrl, {
959
- getDocument: siteFsManager.getDocument,
960
- onConnectionError: exit
961
- });
962
- fsWatcher.onBatchChange(async (update) => {
963
- try {
964
- await limiter(async () => {
965
- setIsSyncing(true);
966
- const { document, code: code2 } = await siteFsManager.applyFsUpdates(update);
967
- await Promise.all([
968
- document && wsServer.syncDocumentUpdate(document),
969
- code2 && updateAppFiles(appId, code2)
970
- ]);
971
- });
972
- } catch (error) {
973
- exit(error);
974
- } finally {
975
- setIsSyncing(false);
976
- }
977
- });
978
- const devEditorUrl = getDevEditorUrl(port);
979
- await openBrowser(devEditorUrl);
980
- return { devEditorUrl };
981
- }, []);
982
- return (0, import_variant.match)(status, {
983
- Error: () => null,
984
- Loading: () => /* @__PURE__ */ import_react4.default.createElement(Spinner, { text: /* @__PURE__ */ import_react4.default.createElement(Trans, { i18nKey: "dev_command.dev_environment.loading" }) }),
985
- Success: ({ result: { devEditorUrl } }) => /* @__PURE__ */ import_react4.default.createElement(
986
- DevEnvironmentContext.Provider,
987
- {
988
- value: {
989
- devEditorUrl,
990
- isDevEditorConnected,
991
- isSyncingChanges: isSyncing
992
- }
993
- },
994
- children
995
- )
996
- });
997
- };
998
- function useDevEnvironment() {
999
- const context = (0, import_react4.useContext)(DevEnvironmentContext);
1000
- if (context == null) {
1001
- throw new Error(
1002
- "useDevEnvironment() cannot be used without an <DevEnvironmentProvider>"
1003
- );
1004
- }
1005
- return context;
1006
- }
1007
-
1008
- // ../cli-site/src/components/DevCommand/DevCommandScreen.tsx
1009
- var DevCommandScreen = () => {
1010
- const { devEditorUrl, isDevEditorConnected, isSyncingChanges } = useDevEnvironment();
1011
- const { execute: openDevEditor } = useAsyncCallback(
1012
- () => openBrowser(devEditorUrl)
1013
- );
1014
- use_input_default((input) => {
1015
- if (input === "e" && !isDevEditorConnected) {
1016
- void openDevEditor();
1017
- }
1018
- });
1019
- return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(Alert, { type: "success" }, /* @__PURE__ */ import_react5.default.createElement(Badge, { skin: "success" }, /* @__PURE__ */ import_react5.default.createElement(Trans, { i18nKey: "general.success" })), " ", /* @__PURE__ */ import_react5.default.createElement(Trans, { i18nKey: "dev_command.dev_environment.success" })), /* @__PURE__ */ import_react5.default.createElement(Box_default, { marginTop: 1, marginLeft: 1 }, !isDevEditorConnected && /* @__PURE__ */ import_react5.default.createElement(Alert, { type: "warning" }, /* @__PURE__ */ import_react5.default.createElement(
1020
- Trans,
1021
- {
1022
- i18nKey: "dev_command.no_open_editor",
1023
- components: [/* @__PURE__ */ import_react5.default.createElement(Key, { value: "E" })]
1024
- }
1025
- )), isDevEditorConnected && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, isSyncingChanges ? /* @__PURE__ */ import_react5.default.createElement(
1026
- Spinner,
1027
- {
1028
- text: /* @__PURE__ */ import_react5.default.createElement(Trans, { i18nKey: "dev_command.sync_changes.loading" })
1029
- }
1030
- ) : /* @__PURE__ */ import_react5.default.createElement(Alert, { type: "success" }, /* @__PURE__ */ import_react5.default.createElement(Trans, { i18nKey: "dev_command.sync_changes.success" })))));
1031
- };
1032
-
1033
- // ../cli-site/src/components/DevCommand/DevCommand.tsx
1034
- var DevCommand = () => {
1035
- return /* @__PURE__ */ import_react6.default.createElement(DevEnvironmentProvider, null, /* @__PURE__ */ import_react6.default.createElement(DevCommandScreen, null));
1036
- };
1037
- export {
1038
- DevCommand
1039
- };
1040
- //# sourceMappingURL=DevCommand-WT3DJON6.js.map