@fenglimg/fabric-shared 2.2.0-rc.3 → 2.2.0-rc.8
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/chunk-2GLIAZ5M.js +251 -0
- package/dist/{chunk-355LUDLW.js → chunk-5AKCRBKJ.js} +474 -418
- package/dist/{chunk-QSD4PN4W.js → chunk-B2N3I7UX.js} +410 -532
- package/dist/chunk-BDJQIOQO.js +206 -0
- package/dist/chunk-C7WZPYZE.js +129 -0
- package/dist/{chunk-VW5QGPIN.js → chunk-O6GIHZF3.js} +10 -0
- package/dist/errors/index.d.ts +9 -1
- package/dist/errors/index.js +7 -3
- package/dist/i18n/index.d.ts +29 -23
- package/dist/i18n/index.js +7 -3
- package/dist/{index-Dm4IJWwB.d.ts → index-SrmixArL.d.ts} +87 -28
- package/dist/index.d.ts +571 -551
- package/dist/index.js +1368 -965
- package/dist/node/atomic-write.js +6 -121
- package/dist/node/mcp-payload-guard.js +1 -1
- package/dist/node.d.ts +10 -1
- package/dist/node.js +32 -1
- package/dist/schemas/api-contracts.d.ts +163 -113
- package/dist/schemas/api-contracts.js +3 -3
- package/dist/templates/bootstrap-canonical.d.ts +50 -23
- package/dist/templates/bootstrap-canonical.js +12 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/types-qg4xXVuT.d.ts +8 -0
- package/package.json +3 -2
- package/dist/chunk-AFT7DB4P.js +0 -103
|
@@ -1,124 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return `.${process.pid}.${Date.now()}.${rand}.tmp`;
|
|
8
|
-
}
|
|
9
|
-
async function atomicWriteText(path, content, opts) {
|
|
10
|
-
const tmpPath = path + makeTmpSuffix();
|
|
11
|
-
try {
|
|
12
|
-
if (opts?.fsync) {
|
|
13
|
-
const fd = await open(tmpPath, "w");
|
|
14
|
-
try {
|
|
15
|
-
await fd.writeFile(content, "utf8");
|
|
16
|
-
await fd.datasync();
|
|
17
|
-
} finally {
|
|
18
|
-
await fd.close();
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
await writeFile(tmpPath, content, "utf8");
|
|
22
|
-
}
|
|
23
|
-
await rename(tmpPath, path);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
try {
|
|
26
|
-
await unlink(tmpPath);
|
|
27
|
-
} catch {
|
|
28
|
-
}
|
|
29
|
-
throw err;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async function atomicWriteJson(path, value, opts) {
|
|
33
|
-
const indent = opts?.indent ?? 2;
|
|
34
|
-
const content = JSON.stringify(value, null, indent) + "\n";
|
|
35
|
-
await atomicWriteText(path, content, { fsync: opts?.fsync });
|
|
36
|
-
}
|
|
37
|
-
function isErrnoException(err) {
|
|
38
|
-
return err instanceof Error && typeof err.code === "string";
|
|
39
|
-
}
|
|
40
|
-
function sleep(ms) {
|
|
41
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
42
|
-
}
|
|
43
|
-
async function withFileLock(lockPath, fn, opts = {}) {
|
|
44
|
-
const staleMs = opts.staleMs ?? 1e4;
|
|
45
|
-
const retryDelayMs = opts.retryDelayMs ?? 20;
|
|
46
|
-
const maxWaitMs = opts.maxWaitMs ?? 1e4;
|
|
47
|
-
await mkdir(dirname(lockPath), { recursive: true });
|
|
48
|
-
const token = `${process.pid}.${randomUUID()}`;
|
|
49
|
-
const start = Date.now();
|
|
50
|
-
for (; ; ) {
|
|
51
|
-
let handle;
|
|
52
|
-
try {
|
|
53
|
-
handle = await open(lockPath, "wx");
|
|
54
|
-
} catch (err) {
|
|
55
|
-
if (!isErrnoException(err) || err.code !== "EEXIST") throw err;
|
|
56
|
-
try {
|
|
57
|
-
const st = await stat(lockPath);
|
|
58
|
-
if (Date.now() - st.mtimeMs > staleMs) {
|
|
59
|
-
const staleToken = await readFile(lockPath, "utf8").catch(() => null);
|
|
60
|
-
if (staleToken !== null) {
|
|
61
|
-
await unlinkIfToken(lockPath, staleToken);
|
|
62
|
-
}
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
} catch {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (Date.now() - start > maxWaitMs) {
|
|
69
|
-
throw new Error(`withFileLock: timed out acquiring ${lockPath} after ${maxWaitMs}ms`);
|
|
70
|
-
}
|
|
71
|
-
await sleep(retryDelayMs);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
await handle.writeFile(token, "utf8");
|
|
76
|
-
await handle.close();
|
|
77
|
-
return await fn();
|
|
78
|
-
} finally {
|
|
79
|
-
await unlinkIfToken(lockPath, token);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async function unlinkIfToken(lockPath, expected) {
|
|
84
|
-
try {
|
|
85
|
-
const current = await readFile(lockPath, "utf8");
|
|
86
|
-
if (current === expected) {
|
|
87
|
-
await unlink(lockPath).catch(() => void 0);
|
|
88
|
-
}
|
|
89
|
-
} catch {
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function createLedgerWriteQueue() {
|
|
93
|
-
const chains = /* @__PURE__ */ new Map();
|
|
94
|
-
async function doAppend(path, line) {
|
|
95
|
-
const normalized = line.endsWith("\n") ? line : line + "\n";
|
|
96
|
-
await appendFile(path, normalized, "utf8");
|
|
97
|
-
}
|
|
98
|
-
function enqueue(path, work) {
|
|
99
|
-
const prev = chains.get(path) ?? Promise.resolve();
|
|
100
|
-
const result = prev.catch(() => void 0).then(() => work());
|
|
101
|
-
const chainSlot = result.then(
|
|
102
|
-
() => void 0,
|
|
103
|
-
() => void 0
|
|
104
|
-
);
|
|
105
|
-
chains.set(path, chainSlot);
|
|
106
|
-
chainSlot.finally(() => {
|
|
107
|
-
if (chains.get(path) === chainSlot) {
|
|
108
|
-
chains.delete(path);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
append(path, line) {
|
|
115
|
-
return enqueue(path, () => doAppend(path, line));
|
|
116
|
-
},
|
|
117
|
-
runExclusive(path, fn) {
|
|
118
|
-
return enqueue(path, fn);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
atomicWriteJson,
|
|
3
|
+
atomicWriteText,
|
|
4
|
+
createLedgerWriteQueue,
|
|
5
|
+
withFileLock
|
|
6
|
+
} from "../chunk-C7WZPYZE.js";
|
|
122
7
|
export {
|
|
123
8
|
atomicWriteJson,
|
|
124
9
|
atomicWriteText,
|
package/dist/node.d.ts
CHANGED
|
@@ -11,4 +11,13 @@ type FrameworkInfo = {
|
|
|
11
11
|
type TechProfile = FrameworkInfo;
|
|
12
12
|
declare function detectFramework(root: string): FrameworkInfo;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface ServeLockState {
|
|
15
|
+
pid: number;
|
|
16
|
+
acquiredAt: number;
|
|
17
|
+
host?: string;
|
|
18
|
+
}
|
|
19
|
+
declare function serveLockPath(projectRoot: string): string;
|
|
20
|
+
declare function isAlive(pid: number): boolean;
|
|
21
|
+
declare function readServeLockState(projectRoot: string): ServeLockState | null;
|
|
22
|
+
|
|
23
|
+
export { type FrameworkInfo, type ServeLockState, type TechProfile, detectFramework, isAlive, readServeLockState, serveLockPath };
|
package/dist/node.js
CHANGED
|
@@ -170,6 +170,37 @@ function collectProjectFileEvidence(root, relativePaths) {
|
|
|
170
170
|
function compactStrings(values) {
|
|
171
171
|
return [...new Set(values.filter((value) => value !== null && value !== void 0 && value.length > 0))];
|
|
172
172
|
}
|
|
173
|
+
|
|
174
|
+
// src/node/serve-lock.ts
|
|
175
|
+
import fs from "fs";
|
|
176
|
+
import path from "path";
|
|
177
|
+
var SERVE_LOCK_FILENAME = ".serve.lock";
|
|
178
|
+
function serveLockPath(projectRoot) {
|
|
179
|
+
return path.join(projectRoot, ".fabric", SERVE_LOCK_FILENAME);
|
|
180
|
+
}
|
|
181
|
+
function isAlive(pid) {
|
|
182
|
+
try {
|
|
183
|
+
process.kill(pid, 0);
|
|
184
|
+
return true;
|
|
185
|
+
} catch (e) {
|
|
186
|
+
const err = e;
|
|
187
|
+
if (err.code === "ESRCH") return false;
|
|
188
|
+
if (err.code === "EPERM") return true;
|
|
189
|
+
throw e;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function readServeLockState(projectRoot) {
|
|
193
|
+
const p = serveLockPath(projectRoot);
|
|
194
|
+
if (!fs.existsSync(p)) return null;
|
|
195
|
+
try {
|
|
196
|
+
return JSON.parse(fs.readFileSync(p, "utf8"));
|
|
197
|
+
} catch {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
173
201
|
export {
|
|
174
|
-
detectFramework
|
|
202
|
+
detectFramework,
|
|
203
|
+
isAlive,
|
|
204
|
+
readServeLockState,
|
|
205
|
+
serveLockPath
|
|
175
206
|
};
|