swarm-mail 0.3.4 → 0.4.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/hive/adapter.d.ts.map +1 -1
- package/dist/index.js +24 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/hive/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/hive/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA+B5D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,eAAe,EACnB,UAAU,EAAE,MAAM,GACjB,WAAW,CA6iBb"}
|
package/dist/index.js
CHANGED
|
@@ -19054,6 +19054,10 @@ async function closeAllSwarmMail() {
|
|
|
19054
19054
|
// src/index.ts
|
|
19055
19055
|
init_streams();
|
|
19056
19056
|
|
|
19057
|
+
// src/hive/adapter.ts
|
|
19058
|
+
import { readFileSync, existsSync as existsSync5 } from "node:fs";
|
|
19059
|
+
import { join as join5 } from "node:path";
|
|
19060
|
+
|
|
19057
19061
|
// src/hive/store.ts
|
|
19058
19062
|
init_streams();
|
|
19059
19063
|
|
|
@@ -19911,10 +19915,29 @@ function createHiveAdapter(db, projectKey) {
|
|
|
19911
19915
|
};
|
|
19912
19916
|
}
|
|
19913
19917
|
function generateBeadId(projectKey) {
|
|
19918
|
+
const prefix = getProjectPrefix(projectKey);
|
|
19914
19919
|
const hash2 = projectKey.split("").reduce((acc, char) => (acc << 5) - acc + char.charCodeAt(0) | 0, 0).toString(36).slice(0, 6);
|
|
19915
19920
|
const timestamp = Date.now().toString(36);
|
|
19916
19921
|
const random = Math.random().toString(36).slice(2, 5);
|
|
19917
|
-
return
|
|
19922
|
+
return `${prefix}-${hash2}-${timestamp}${random}`;
|
|
19923
|
+
}
|
|
19924
|
+
function getProjectPrefix(projectKey) {
|
|
19925
|
+
try {
|
|
19926
|
+
const packageJsonPath = join5(projectKey, "package.json");
|
|
19927
|
+
if (!existsSync5(packageJsonPath)) {
|
|
19928
|
+
return "cell";
|
|
19929
|
+
}
|
|
19930
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
19931
|
+
if (!packageJson.name || typeof packageJson.name !== "string") {
|
|
19932
|
+
return "cell";
|
|
19933
|
+
}
|
|
19934
|
+
return slugifyProjectName(packageJson.name);
|
|
19935
|
+
} catch (error45) {
|
|
19936
|
+
return "cell";
|
|
19937
|
+
}
|
|
19938
|
+
}
|
|
19939
|
+
function slugifyProjectName(name) {
|
|
19940
|
+
return name.toLowerCase().replace(/[@/]/g, "-").replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
19918
19941
|
}
|
|
19919
19942
|
|
|
19920
19943
|
// src/hive/index.ts
|