@hapico/cli 0.0.15 → 0.0.16
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.
- package/bin/index.js +18 -7
- package/dist/index.js +18 -7
- package/index.ts +29 -15
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -263,7 +263,15 @@ class RoomState {
|
|
|
263
263
|
try {
|
|
264
264
|
const jsonStr = typeof data === "string" ? data : data.toString();
|
|
265
265
|
const parsedData = JSON.parse(jsonStr);
|
|
266
|
-
const includes = [
|
|
266
|
+
const includes = [
|
|
267
|
+
"view",
|
|
268
|
+
"coding",
|
|
269
|
+
"refresh_key",
|
|
270
|
+
"useActiveIdFocus",
|
|
271
|
+
"activeId",
|
|
272
|
+
"active_file",
|
|
273
|
+
"figma",
|
|
274
|
+
];
|
|
267
275
|
let newState;
|
|
268
276
|
let changedKeys;
|
|
269
277
|
if (parsedData.type === "state") {
|
|
@@ -325,7 +333,7 @@ class RoomState {
|
|
|
325
333
|
return this.isConnected;
|
|
326
334
|
}
|
|
327
335
|
}
|
|
328
|
-
commander_1.program.version("0.0.
|
|
336
|
+
commander_1.program.version("0.0.16").description("Hapico CLI for project management");
|
|
329
337
|
commander_1.program
|
|
330
338
|
.command("clone <id>")
|
|
331
339
|
.description("Clone a project by ID")
|
|
@@ -437,21 +445,24 @@ commander_1.program
|
|
|
437
445
|
}
|
|
438
446
|
console.log(`Connecting to WebSocket server`);
|
|
439
447
|
const room = new RoomState(`view_${projectId}`, []);
|
|
448
|
+
const fileManager = new FileManager(srcDir);
|
|
449
|
+
const initialFiles = fileManager.listFiles();
|
|
450
|
+
room.files = initialFiles;
|
|
440
451
|
room.connect(async () => {
|
|
441
452
|
devSpinner.succeed("Project started in development mode!");
|
|
442
|
-
const fileManager = new FileManager(srcDir);
|
|
443
|
-
const initialFiles = fileManager.listFiles();
|
|
444
453
|
room.updateState("view", initialFiles);
|
|
445
454
|
fileManager.setOnFileChange((filePath, content) => {
|
|
446
|
-
|
|
455
|
+
var _a;
|
|
456
|
+
const es5 = (_a = (0, exports.compileES5)(content, filePath)) !== null && _a !== void 0 ? _a : "";
|
|
447
457
|
console.log(`File changed: ${filePath === null || filePath === void 0 ? void 0 : filePath.replace(srcDir, ".")}`);
|
|
448
|
-
const
|
|
458
|
+
const updatedFiles = room.files.map((file) => {
|
|
449
459
|
if (path.join(srcDir, file.path) === filePath) {
|
|
450
460
|
return { ...file, content, es5 };
|
|
451
461
|
}
|
|
452
462
|
return file;
|
|
453
463
|
});
|
|
454
|
-
room.
|
|
464
|
+
room.files = updatedFiles;
|
|
465
|
+
room.updateState("view", updatedFiles);
|
|
455
466
|
});
|
|
456
467
|
// Fetch project info
|
|
457
468
|
const projectInfo = getStoredProjectId(pwd);
|
package/dist/index.js
CHANGED
|
@@ -263,7 +263,15 @@ class RoomState {
|
|
|
263
263
|
try {
|
|
264
264
|
const jsonStr = typeof data === "string" ? data : data.toString();
|
|
265
265
|
const parsedData = JSON.parse(jsonStr);
|
|
266
|
-
const includes = [
|
|
266
|
+
const includes = [
|
|
267
|
+
"view",
|
|
268
|
+
"coding",
|
|
269
|
+
"refresh_key",
|
|
270
|
+
"useActiveIdFocus",
|
|
271
|
+
"activeId",
|
|
272
|
+
"active_file",
|
|
273
|
+
"figma",
|
|
274
|
+
];
|
|
267
275
|
let newState;
|
|
268
276
|
let changedKeys;
|
|
269
277
|
if (parsedData.type === "state") {
|
|
@@ -325,7 +333,7 @@ class RoomState {
|
|
|
325
333
|
return this.isConnected;
|
|
326
334
|
}
|
|
327
335
|
}
|
|
328
|
-
commander_1.program.version("0.0.
|
|
336
|
+
commander_1.program.version("0.0.16").description("Hapico CLI for project management");
|
|
329
337
|
commander_1.program
|
|
330
338
|
.command("clone <id>")
|
|
331
339
|
.description("Clone a project by ID")
|
|
@@ -437,21 +445,24 @@ commander_1.program
|
|
|
437
445
|
}
|
|
438
446
|
console.log(`Connecting to WebSocket server`);
|
|
439
447
|
const room = new RoomState(`view_${projectId}`, []);
|
|
448
|
+
const fileManager = new FileManager(srcDir);
|
|
449
|
+
const initialFiles = fileManager.listFiles();
|
|
450
|
+
room.files = initialFiles;
|
|
440
451
|
room.connect(async () => {
|
|
441
452
|
devSpinner.succeed("Project started in development mode!");
|
|
442
|
-
const fileManager = new FileManager(srcDir);
|
|
443
|
-
const initialFiles = fileManager.listFiles();
|
|
444
453
|
room.updateState("view", initialFiles);
|
|
445
454
|
fileManager.setOnFileChange((filePath, content) => {
|
|
446
|
-
|
|
455
|
+
var _a;
|
|
456
|
+
const es5 = (_a = (0, exports.compileES5)(content, filePath)) !== null && _a !== void 0 ? _a : "";
|
|
447
457
|
console.log(`File changed: ${filePath === null || filePath === void 0 ? void 0 : filePath.replace(srcDir, ".")}`);
|
|
448
|
-
const
|
|
458
|
+
const updatedFiles = room.files.map((file) => {
|
|
449
459
|
if (path.join(srcDir, file.path) === filePath) {
|
|
450
460
|
return { ...file, content, es5 };
|
|
451
461
|
}
|
|
452
462
|
return file;
|
|
453
463
|
});
|
|
454
|
-
room.
|
|
464
|
+
room.files = updatedFiles;
|
|
465
|
+
room.updateState("view", updatedFiles);
|
|
455
466
|
});
|
|
456
467
|
// Fetch project info
|
|
457
468
|
const projectInfo = getStoredProjectId(pwd);
|
package/index.ts
CHANGED
|
@@ -261,7 +261,10 @@ class RoomState {
|
|
|
261
261
|
private ws: WebSocket | null;
|
|
262
262
|
private reconnectTimeout: NodeJS.Timeout | null;
|
|
263
263
|
private reconnectAttempts: number;
|
|
264
|
-
private onChangeListeners: Array<{
|
|
264
|
+
private onChangeListeners: Array<{
|
|
265
|
+
key: string;
|
|
266
|
+
callback: (value: any) => void;
|
|
267
|
+
}>;
|
|
265
268
|
|
|
266
269
|
public files: FileContent[] = [];
|
|
267
270
|
|
|
@@ -301,20 +304,28 @@ class RoomState {
|
|
|
301
304
|
this.isConnected = false;
|
|
302
305
|
|
|
303
306
|
this.reconnectAttempts++;
|
|
304
|
-
const delay = Math.min(
|
|
305
|
-
1000 * Math.pow(2, this.reconnectAttempts),
|
|
306
|
-
30000
|
|
307
|
-
);
|
|
307
|
+
const delay = Math.min(1000 * Math.pow(2, this.reconnectAttempts), 30000);
|
|
308
308
|
console.log(`Attempting to reconnect in ${delay / 1000}s...`);
|
|
309
309
|
|
|
310
|
-
this.reconnectTimeout = setTimeout(
|
|
310
|
+
this.reconnectTimeout = setTimeout(
|
|
311
|
+
() => this.connect(onConnected),
|
|
312
|
+
delay
|
|
313
|
+
);
|
|
311
314
|
};
|
|
312
315
|
|
|
313
316
|
this.ws.on("message", (data: Buffer | string) => {
|
|
314
317
|
try {
|
|
315
318
|
const jsonStr = typeof data === "string" ? data : data.toString();
|
|
316
319
|
const parsedData = JSON.parse(jsonStr);
|
|
317
|
-
const includes = [
|
|
320
|
+
const includes = [
|
|
321
|
+
"view",
|
|
322
|
+
"coding",
|
|
323
|
+
"refresh_key",
|
|
324
|
+
"useActiveIdFocus",
|
|
325
|
+
"activeId",
|
|
326
|
+
"active_file",
|
|
327
|
+
"figma",
|
|
328
|
+
];
|
|
318
329
|
|
|
319
330
|
let newState: RoomStateData;
|
|
320
331
|
let changedKeys;
|
|
@@ -336,7 +347,9 @@ class RoomState {
|
|
|
336
347
|
return;
|
|
337
348
|
}
|
|
338
349
|
|
|
339
|
-
const filteredChangedKeys = changedKeys.filter((key) =>
|
|
350
|
+
const filteredChangedKeys = changedKeys.filter((key) =>
|
|
351
|
+
includes.includes(key)
|
|
352
|
+
);
|
|
340
353
|
if (filteredChangedKeys.length > 0) {
|
|
341
354
|
filteredChangedKeys.forEach((key) => {
|
|
342
355
|
const listener = find(this.onChangeListeners, (l) => l.key === key);
|
|
@@ -387,7 +400,7 @@ class RoomState {
|
|
|
387
400
|
}
|
|
388
401
|
}
|
|
389
402
|
|
|
390
|
-
program.version("0.0.
|
|
403
|
+
program.version("0.0.16").description("Hapico CLI for project management");
|
|
391
404
|
|
|
392
405
|
program
|
|
393
406
|
.command("clone <id>")
|
|
@@ -536,25 +549,26 @@ program
|
|
|
536
549
|
|
|
537
550
|
console.log(`Connecting to WebSocket server`);
|
|
538
551
|
const room = new RoomState(`view_${projectId}`, []);
|
|
552
|
+
const fileManager = new FileManager(srcDir);
|
|
553
|
+
const initialFiles = fileManager.listFiles();
|
|
554
|
+
room.files = initialFiles;
|
|
539
555
|
|
|
540
556
|
room.connect(async () => {
|
|
541
557
|
devSpinner.succeed("Project started in development mode!");
|
|
542
558
|
|
|
543
|
-
const fileManager = new FileManager(srcDir);
|
|
544
|
-
|
|
545
|
-
const initialFiles = fileManager.listFiles();
|
|
546
559
|
room.updateState("view", initialFiles);
|
|
547
560
|
|
|
548
561
|
fileManager.setOnFileChange((filePath, content) => {
|
|
549
|
-
const es5 = compileES5(content, filePath);
|
|
562
|
+
const es5 = compileES5(content, filePath) ?? "";
|
|
550
563
|
console.log(`File changed: ${filePath?.replace(srcDir, ".")}`);
|
|
551
|
-
const
|
|
564
|
+
const updatedFiles = room.files.map((file) => {
|
|
552
565
|
if (path.join(srcDir, file.path) === filePath) {
|
|
553
566
|
return { ...file, content, es5 };
|
|
554
567
|
}
|
|
555
568
|
return file;
|
|
556
569
|
});
|
|
557
|
-
room.
|
|
570
|
+
room.files = updatedFiles;
|
|
571
|
+
room.updateState("view", updatedFiles);
|
|
558
572
|
});
|
|
559
573
|
|
|
560
574
|
// Fetch project info
|