@tscircuit/cli 0.1.222 → 0.1.223
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/dist/main.js +27 -11
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -63256,7 +63256,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
63256
63256
|
import { execSync as execSync2 } from "node:child_process";
|
|
63257
63257
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
63258
63258
|
// package.json
|
|
63259
|
-
var version = "0.1.
|
|
63259
|
+
var version = "0.1.222";
|
|
63260
63260
|
var package_default = {
|
|
63261
63261
|
name: "@tscircuit/cli",
|
|
63262
63262
|
version,
|
|
@@ -67867,6 +67867,7 @@ async function addPackage(componentPath, projectDir = process.cwd()) {
|
|
|
67867
67867
|
// cli/dev/DevServer.ts
|
|
67868
67868
|
import Debug2 from "debug";
|
|
67869
67869
|
var debug2 = Debug2("tscircuit:devserver");
|
|
67870
|
+
var BINARY_FILE_EXTENSIONS = new Set([".glb", ".png", ".jpeg", ".jpg"]);
|
|
67870
67871
|
|
|
67871
67872
|
class DevServer {
|
|
67872
67873
|
port;
|
|
@@ -67928,7 +67929,12 @@ class DevServer {
|
|
|
67928
67929
|
if (!fs18.existsSync(dirPath)) {
|
|
67929
67930
|
fs18.mkdirSync(dirPath, { recursive: true });
|
|
67930
67931
|
}
|
|
67931
|
-
|
|
67932
|
+
if (file.binary_content_b64) {
|
|
67933
|
+
const decodedContent = Buffer.from(file.binary_content_b64, "base64");
|
|
67934
|
+
fs18.writeFileSync(fullPath, decodedContent);
|
|
67935
|
+
} else {
|
|
67936
|
+
fs18.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
|
|
67937
|
+
}
|
|
67932
67938
|
}
|
|
67933
67939
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
67934
67940
|
const relativeFilePath = path18.relative(this.projectDir, absoluteFilePath);
|
|
@@ -67937,12 +67943,13 @@ class DevServer {
|
|
|
67937
67943
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
67938
67944
|
return;
|
|
67939
67945
|
await this.typesHandler?.handleFileTypeDependencies(absoluteFilePath);
|
|
67946
|
+
const filePayload = this.createFileUploadPayload(absoluteFilePath, relativeFilePath);
|
|
67940
67947
|
console.log(kleur_default.green(`Saving: ${relativeFilePath}`));
|
|
67941
67948
|
await this.fsKy.post("api/files/upsert", {
|
|
67942
67949
|
json: {
|
|
67943
67950
|
file_path: relativeFilePath,
|
|
67944
|
-
|
|
67945
|
-
|
|
67951
|
+
initiator: "filesystem_change",
|
|
67952
|
+
...filePayload
|
|
67946
67953
|
}
|
|
67947
67954
|
}).json();
|
|
67948
67955
|
}
|
|
@@ -67990,12 +67997,12 @@ class DevServer {
|
|
|
67990
67997
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
67991
67998
|
return;
|
|
67992
67999
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
67993
|
-
const
|
|
68000
|
+
const filePayload = this.createFileUploadPayload(newPath, newRelativePath);
|
|
67994
68001
|
await this.fsKy.post("api/files/upsert", {
|
|
67995
68002
|
json: {
|
|
67996
68003
|
file_path: newRelativePath,
|
|
67997
|
-
|
|
67998
|
-
|
|
68004
|
+
initiator: "filesystem_change",
|
|
68005
|
+
...filePayload
|
|
67999
68006
|
}
|
|
68000
68007
|
});
|
|
68001
68008
|
debug2(`File renamed from ${oldRelativePath} to ${newRelativePath}`);
|
|
@@ -68003,12 +68010,13 @@ class DevServer {
|
|
|
68003
68010
|
async upsertInitialFiles() {
|
|
68004
68011
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
68005
68012
|
for (const filePath of filePaths) {
|
|
68006
|
-
const
|
|
68013
|
+
const relativeFilePath = path18.relative(this.projectDir, filePath);
|
|
68014
|
+
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
68007
68015
|
await this.fsKy.post("api/files/upsert", {
|
|
68008
68016
|
json: {
|
|
68009
|
-
file_path:
|
|
68010
|
-
|
|
68011
|
-
|
|
68017
|
+
file_path: relativeFilePath,
|
|
68018
|
+
initiator: "filesystem_change",
|
|
68019
|
+
...filePayload
|
|
68012
68020
|
}
|
|
68013
68021
|
});
|
|
68014
68022
|
}
|
|
@@ -68035,6 +68043,14 @@ class DevServer {
|
|
|
68035
68043
|
this.eventsWatcher?.stop();
|
|
68036
68044
|
await this.filesystemWatcher?.close();
|
|
68037
68045
|
}
|
|
68046
|
+
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
68047
|
+
const ext = path18.extname(relativeFilePath).toLowerCase();
|
|
68048
|
+
if (BINARY_FILE_EXTENSIONS.has(ext)) {
|
|
68049
|
+
const fileBuffer = fs18.readFileSync(absoluteFilePath);
|
|
68050
|
+
return { binary_content_b64: fileBuffer.toString("base64") };
|
|
68051
|
+
}
|
|
68052
|
+
return { text_content: fs18.readFileSync(absoluteFilePath, "utf-8") };
|
|
68053
|
+
}
|
|
68038
68054
|
async handleInstallPackage(full_package_name) {
|
|
68039
68055
|
const postEvent = async (event, message) => {
|
|
68040
68056
|
await this.fsKy.post("api/events/create", {
|