framer-code-link 0.14.0 → 0.15.0
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/index.mjs +48 -46
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import fs from "fs/promises";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { WebSocketServer } from "ws";
|
|
7
7
|
import { createHash } from "crypto";
|
|
8
|
-
import { setupTypeAcquisition } from "@typescript/ata";
|
|
9
|
-
import ts from "typescript";
|
|
10
8
|
import { execSync } from "child_process";
|
|
11
9
|
import fs$1 from "fs";
|
|
10
|
+
import { setupTypeAcquisition } from "@typescript/ata";
|
|
11
|
+
import ts from "typescript";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import chokidar from "chokidar";
|
|
14
14
|
|
|
@@ -1002,49 +1002,6 @@ function isSupportedExtension(fileName) {
|
|
|
1002
1002
|
return SUPPORTED_EXTENSIONS.some((ext) => lower.endsWith(ext));
|
|
1003
1003
|
}
|
|
1004
1004
|
|
|
1005
|
-
//#endregion
|
|
1006
|
-
//#region src/utils/imports.ts
|
|
1007
|
-
/**
|
|
1008
|
-
* Extract npm and URL-based imports from source code.
|
|
1009
|
-
*/
|
|
1010
|
-
function extractImports(code) {
|
|
1011
|
-
const imports = [];
|
|
1012
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1013
|
-
const npmRegex = /import\s+(?:(?:\*\s+as\s+\w+)|(?:\w+)|(?:\{[^}]*\}))\s+from\s+['"]([^./][^'"]+)['"]/g;
|
|
1014
|
-
const urlRegex = /import\s+(?:(?:\*\s+as\s+\w+)|(?:\w+)|(?:\{[^}]*\}))\s+from\s+['"]https?:\/\/[^'"]+['"]/g;
|
|
1015
|
-
let match;
|
|
1016
|
-
while ((match = npmRegex.exec(code)) !== null) {
|
|
1017
|
-
const pkgName = match[1];
|
|
1018
|
-
const normalized = pkgName.startsWith("@") ? pkgName.split("/").slice(0, 2).join("/") : pkgName.split("/")[0];
|
|
1019
|
-
if (!seen.has(normalized)) {
|
|
1020
|
-
seen.add(normalized);
|
|
1021
|
-
imports.push({
|
|
1022
|
-
type: "npm",
|
|
1023
|
-
name: normalized,
|
|
1024
|
-
raw: match[0]
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
while ((match = urlRegex.exec(code)) !== null) {
|
|
1029
|
-
const pkgName = extractPackageFromUrl(match[0]);
|
|
1030
|
-
if (pkgName && !seen.has(pkgName)) {
|
|
1031
|
-
seen.add(pkgName);
|
|
1032
|
-
imports.push({
|
|
1033
|
-
type: "url",
|
|
1034
|
-
name: pkgName,
|
|
1035
|
-
raw: match[0]
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
return imports;
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Attempt to derive an npm-style package specifier from a URL import.
|
|
1043
|
-
*/
|
|
1044
|
-
function extractPackageFromUrl(url) {
|
|
1045
|
-
return /\/(@?[^@/]+(?:\/[^@/]+)?)/.exec(url)?.[1] ?? null;
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
1005
|
//#endregion
|
|
1049
1006
|
//#region src/helpers/git.ts
|
|
1050
1007
|
/**
|
|
@@ -1124,6 +1081,49 @@ function tryGitInit(projectDir) {
|
|
|
1124
1081
|
}
|
|
1125
1082
|
}
|
|
1126
1083
|
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/utils/imports.ts
|
|
1086
|
+
/**
|
|
1087
|
+
* Extract npm and URL-based imports from source code.
|
|
1088
|
+
*/
|
|
1089
|
+
function extractImports(code) {
|
|
1090
|
+
const imports = [];
|
|
1091
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1092
|
+
const npmRegex = /import\s+(?:(?:\*\s+as\s+\w+)|(?:\w+)|(?:\{[^}]*\}))\s+from\s+['"]([^./][^'"]+)['"]/g;
|
|
1093
|
+
const urlRegex = /import\s+(?:(?:\*\s+as\s+\w+)|(?:\w+)|(?:\{[^}]*\}))\s+from\s+['"]https?:\/\/[^'"]+['"]/g;
|
|
1094
|
+
let match;
|
|
1095
|
+
while ((match = npmRegex.exec(code)) !== null) {
|
|
1096
|
+
const pkgName = match[1];
|
|
1097
|
+
const normalized = pkgName.startsWith("@") ? pkgName.split("/").slice(0, 2).join("/") : pkgName.split("/")[0];
|
|
1098
|
+
if (!seen.has(normalized)) {
|
|
1099
|
+
seen.add(normalized);
|
|
1100
|
+
imports.push({
|
|
1101
|
+
type: "npm",
|
|
1102
|
+
name: normalized,
|
|
1103
|
+
raw: match[0]
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
while ((match = urlRegex.exec(code)) !== null) {
|
|
1108
|
+
const pkgName = extractPackageFromUrl(match[0]);
|
|
1109
|
+
if (pkgName && !seen.has(pkgName)) {
|
|
1110
|
+
seen.add(pkgName);
|
|
1111
|
+
imports.push({
|
|
1112
|
+
type: "url",
|
|
1113
|
+
name: pkgName,
|
|
1114
|
+
raw: match[0]
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
return imports;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Attempt to derive an npm-style package specifier from a URL import.
|
|
1122
|
+
*/
|
|
1123
|
+
function extractPackageFromUrl(url) {
|
|
1124
|
+
return /\/(@?[^@/]+(?:\/[^@/]+)?)/.exec(url)?.[1] ?? null;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
1127
|
//#endregion
|
|
1128
1128
|
//#region src/helpers/skills.ts
|
|
1129
1129
|
/**
|
|
@@ -1346,7 +1346,6 @@ var Installer = class {
|
|
|
1346
1346
|
this.ensureSkills(),
|
|
1347
1347
|
this.ensureGitignore()
|
|
1348
1348
|
]);
|
|
1349
|
-
tryGitInit(this.projectDir);
|
|
1350
1349
|
Promise.resolve().then(async () => {
|
|
1351
1350
|
await this.ensureReact18Types();
|
|
1352
1351
|
const coreImports = CORE_LIBRARIES.map((lib) => `import "${lib}";`).join("\n");
|
|
@@ -1508,6 +1507,8 @@ declare module "*.json"
|
|
|
1508
1507
|
} catch {}
|
|
1509
1508
|
const content = [
|
|
1510
1509
|
"node_modules/",
|
|
1510
|
+
".DS_Store",
|
|
1511
|
+
"*.local",
|
|
1511
1512
|
"",
|
|
1512
1513
|
"# Framer Code Link",
|
|
1513
1514
|
".framer-sync-state.json",
|
|
@@ -2616,6 +2617,7 @@ async function executeEffect(effect, context) {
|
|
|
2616
2617
|
else if (relativeDirectory && config.projectDirCreated) success(`Synced into ${relativeDirectory} (${effect.updatedCount} files added)`);
|
|
2617
2618
|
else if (relativeDirectory) success(`Synced into ${relativeDirectory} (${effect.updatedCount} files updated, ${effect.unchangedCount} unchanged)`);
|
|
2618
2619
|
else success(`Synced ${effect.totalCount} files (${effect.updatedCount} updated, ${effect.unchangedCount} unchanged)`);
|
|
2620
|
+
if (config.projectDirCreated && config.projectDir) tryGitInit(config.projectDir);
|
|
2619
2621
|
status("Watching for changes...");
|
|
2620
2622
|
return [];
|
|
2621
2623
|
}
|