nano-git 0.3.1 → 0.3.3

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/dist/core/types.d.mts +1 -1
  3. package/dist/objects/tree.d.mts +4 -0
  4. package/dist/objects/tree.mjs +53 -2
  5. package/dist/repository/tree/tree-patch.mjs +4 -4
  6. package/dist/repository/tree/tree-walk.mjs +1 -1
  7. package/dist/repository/tree/tree-writer.mjs +1 -1
  8. package/dist/workdir/change-index-plan.mjs +2 -2
  9. package/dist/workdir/change-index.mjs +6 -6
  10. package/dist/workdir/core.d.mts +13 -44
  11. package/dist/workdir/directory-view.mjs +2 -2
  12. package/dist/workdir/dirty-dir-plan.mjs +3 -3
  13. package/dist/workdir/file-backend.d.mts +34 -12
  14. package/dist/workdir/file-backend.mjs +67 -86
  15. package/dist/workdir/file.d.mts +2 -2
  16. package/dist/workdir/file.mjs +2 -2
  17. package/dist/workdir/ids.d.mts +1 -1
  18. package/dist/workdir/ids.mjs +3 -3
  19. package/dist/workdir/memory-backend.mjs +4 -39
  20. package/dist/workdir/memory.d.mts +2 -3
  21. package/dist/workdir/memory.mjs +2 -3
  22. package/dist/workdir/nodes.d.mts +7 -7
  23. package/dist/workdir/nodes.mjs +3 -3
  24. package/dist/workdir/origin.mjs +2 -2
  25. package/dist/workdir/overlay.d.mts +3 -3
  26. package/dist/workdir/sqlite-backend.d.mts +31 -14
  27. package/dist/workdir/sqlite-backend.mjs +113 -118
  28. package/dist/workdir/sqlite.d.mts +2 -2
  29. package/dist/workdir/sqlite.mjs +2 -2
  30. package/dist/workdir/state-store.d.mts +4 -4
  31. package/dist/workdir/{session-internal.mjs → workdir-path.mjs} +10 -10
  32. package/dist/workdir/{session-transaction.mjs → workdir-transaction.mjs} +10 -10
  33. package/dist/workdir/workdir.d.mts +30 -0
  34. package/dist/workdir/{session.mjs → workdir.mjs} +17 -17
  35. package/dist/workdir/write-tree.mjs +5 -5
  36. package/package.json +1 -1
  37. package/dist/workdir/memory-backend.d.mts +0 -17
  38. package/dist/workdir/session-id.mjs +0 -18
  39. package/dist/workdir/session.d.mts +0 -30
@@ -1,47 +1,47 @@
1
1
  import { VirtualNotDirectoryError, VirtualNotFileError, VirtualNotSymlinkError, VirtualPathAlreadyExistsError, VirtualPathNotFoundError, VirtualRevertNotSupportedError } from "../core/errors.mjs";
2
2
  import { createNodeId } from "./ids.mjs";
3
- import { overlayBindEntry, overlayRenameEntry, overlayTombstoneEntry } from "./overlay.mjs";
4
- import { revertNodeState } from "./nodes.mjs";
5
3
  import { modeToVirtualEntryKind, readRepoBlobContent } from "./origin.mjs";
4
+ import { overlayBindEntry, overlayRenameEntry, overlayTombstoneEntry } from "./overlay.mjs";
6
5
  import { assertValidVirtualPath, normalizeDirectoryPath } from "./path.mjs";
7
- import { getDirectoryChildrenView, getRootNode, requireExistingWriteTarget, requireMissingWriteTarget, resolveLeafWriteTarget, resolvePath, resolveWriteTransfer } from "./session-internal.mjs";
6
+ import { getDirectoryChildrenView, getRootNode, requireExistingWriteTarget, requireMissingWriteTarget, resolveLeafWriteTarget, resolvePath, resolveWriteTransfer } from "./workdir-path.mjs";
8
7
  import { createChangeIndexPlanner } from "./change-index-plan.mjs";
9
8
  import { computeVirtualDiff, rebuildNormalizedChangeIndex, refreshChangeRecordForPath, replaceChangeRecords, rewriteChangeRecordForRename, writeChangeRecordForCopy } from "./change-index.mjs";
10
9
  import { createDirtyDirPlanner } from "./dirty-dir-plan.mjs";
11
- import { cloneNodeGraphForCopy, runInWriteTransaction, statDirectoryNode, statNode, updateParentOverlay } from "./session-transaction.mjs";
12
- import { writeTreeFromSession } from "./write-tree.mjs";
10
+ import { revertNodeState } from "./nodes.mjs";
13
11
  import { createVirtualWorkdirMemoryStateStore } from "./memory-backend.mjs";
14
- //#region src/workdir/session.ts
12
+ import { cloneNodeGraphForCopy, runInWriteTransaction, statDirectoryNode, statNode, updateParentOverlay } from "./workdir-transaction.mjs";
13
+ import { writeTreeFromSession } from "./write-tree.mjs";
14
+ //#region src/workdir/workdir.ts
15
15
  /**
16
- * VirtualWorkdirSession 行为编排
16
+ * VirtualWorkdir 行为编排
17
17
  *
18
18
  * Phase 5:完整文件/目录 rename 与 copy 语义。
19
19
  */
20
20
  /**
21
- * 基于 ObjectDatabase 创建 VirtualWorkdirSession
21
+ * 基于 ObjectDatabase 创建 VirtualWorkdir
22
22
  *
23
23
  * @example
24
24
  * ```ts
25
25
  * const repo = createMemoryRepository();
26
26
  * const tree = repo.createTree([]);
27
- * const session = createVirtualWorkdirSession(repo.objects, { baseTree: tree });
28
- * expect(session.readdir()).toEqual([]);
27
+ * const workdir = createVirtualWorkdir(repo.objects, { baseTree: tree });
28
+ * expect(workdir.readdir()).toEqual([]);
29
29
  * ```
30
30
  */
31
- function createVirtualWorkdirSession(source, options) {
32
- return openVirtualWorkdirSession(source, createVirtualWorkdirMemoryStateStore(options.baseTree));
31
+ function createVirtualWorkdir(source, options) {
32
+ return openVirtualWorkdir(source, createVirtualWorkdirMemoryStateStore(options.baseTree));
33
33
  }
34
34
  /**
35
- * 基于已有状态存储打开 session
35
+ * 基于已有状态存储打开 VirtualWorkdir
36
36
  *
37
37
  * @example
38
38
  * ```ts
39
39
  * const store = createVirtualWorkdirMemoryStateStore(tree);
40
- * const session = openVirtualWorkdirSession(repo.objects, store);
41
- * expect(session.baseTree).toBe(tree);
40
+ * const workdir = openVirtualWorkdir(repo.objects, store);
41
+ * expect(workdir.baseTree).toBe(tree);
42
42
  * ```
43
43
  */
44
- function openVirtualWorkdirSession(source, state) {
44
+ function openVirtualWorkdir(source, state) {
45
45
  const currentNodeHashes = /* @__PURE__ */ new Map();
46
46
  const invalidateDiffCaches = () => {
47
47
  currentNodeHashes.clear();
@@ -277,4 +277,4 @@ function openVirtualWorkdirSession(source, state) {
277
277
  };
278
278
  }
279
279
  //#endregion
280
- export { createVirtualWorkdirSession, openVirtualWorkdirSession };
280
+ export { createVirtualWorkdir, openVirtualWorkdir };
@@ -1,25 +1,25 @@
1
1
  import { writeObject } from "../objects/raw.mjs";
2
2
  import { readRepoTree } from "./origin.mjs";
3
- import { listDirectoryChildren } from "./session-internal.mjs";
3
+ import { listDirectoryChildren } from "./workdir-path.mjs";
4
4
  import { createNamedOriginChildLookup, observeListedDirectoryChild, observeNamedDirectoryChild, planAffectedDirectoryChildren } from "./directory-view.mjs";
5
5
  import { materializeDirtyDirSummary } from "./dirty-dir.mjs";
6
6
  //#region src/workdir/write-tree.ts
7
7
  /**
8
8
  * Virtual Workdir overlay -> tree 最小化编译
9
9
  *
10
- * 遍历 session 的目录 overlay,将受影响的目录重写为新 tree,
10
+ * 遍历 workdir 的目录 overlay,将受影响的目录重写为新 tree,
11
11
  * 未修改的 repo-backed 子树/文件尽量复用原对象哈希。
12
12
  *
13
13
  * writeTree() 成功后不清空 overlay,不推进 baseTree。
14
14
  */
15
15
  /**
16
- * 将当前 session 状态编译为新的根 tree
16
+ * 将当前 workdir 状态编译为新的根 tree
17
17
  *
18
18
  * 只重写受 overlay 影响的目录;文件/符号链接仅在 materialized 时写新 blob。
19
19
  * 未修改的 repo-backed 条目直接复用 origin hash。
20
20
  *
21
21
  * @param source - 可写对象数据库(用于写入新 blob/tree)
22
- * @param state - session 内存状态
22
+ * @param state - workdir 内部状态
23
23
  * @returns 新根 tree 的 SHA-1
24
24
  *
25
25
  * @example
@@ -101,7 +101,7 @@ function compileChildEntry(writeSource, readSource, state, child) {
101
101
  const originHash = node.origin.kind === "repo-tree" ? node.origin.hash : null;
102
102
  return {
103
103
  entry: {
104
- mode: "40000",
104
+ mode: "040000",
105
105
  name: child.name,
106
106
  hash: newHash
107
107
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nano-git",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -1,17 +0,0 @@
1
- import { VirtualWorkdirBackend } from "./core.mjs";
2
-
3
- //#region src/workdir/memory-backend.d.ts
4
- /**
5
- * 创建内存版 Virtual Workdir backend
6
- *
7
- * @example
8
- * ```ts
9
- * const backend = createMemoryVirtualWorkdirBackend();
10
- * const sessionId = backend.createSession({ baseTree: tree });
11
- * const session = backend.openSession(repo.objects, sessionId);
12
- * expect(session.baseTree).toBe(tree);
13
- * ```
14
- */
15
- declare function createMemoryVirtualWorkdirBackend(): VirtualWorkdirBackend;
16
- //#endregion
17
- export { createMemoryVirtualWorkdirBackend };
@@ -1,18 +0,0 @@
1
- //#region src/workdir/session-id.ts
2
- let nextSessionCounter = 1;
3
- /**
4
- * 分配新的 session ID
5
- *
6
- * @example
7
- * ```ts
8
- * const sessionId = createVirtualWorkdirSessionId();
9
- * expect(String(sessionId).startsWith("session:")).toBe(true);
10
- * ```
11
- */
12
- function createVirtualWorkdirSessionId() {
13
- const id = `session:${nextSessionCounter}`;
14
- nextSessionCounter += 1;
15
- return id;
16
- }
17
- //#endregion
18
- export { createVirtualWorkdirSessionId };
@@ -1,30 +0,0 @@
1
- import { ObjectDatabase } from "../core/types/odb.mjs";
2
- import { CreateVirtualWorkdirSessionOptions, VirtualWorkdirSession } from "./core.mjs";
3
- import { VirtualWorkdirStateStore } from "./state-store.mjs";
4
-
5
- //#region src/workdir/session.d.ts
6
- /**
7
- * 基于 ObjectDatabase 创建 VirtualWorkdirSession
8
- *
9
- * @example
10
- * ```ts
11
- * const repo = createMemoryRepository();
12
- * const tree = repo.createTree([]);
13
- * const session = createVirtualWorkdirSession(repo.objects, { baseTree: tree });
14
- * expect(session.readdir()).toEqual([]);
15
- * ```
16
- */
17
- declare function createVirtualWorkdirSession(source: ObjectDatabase, options: CreateVirtualWorkdirSessionOptions): VirtualWorkdirSession;
18
- /**
19
- * 基于已有状态存储打开 session
20
- *
21
- * @example
22
- * ```ts
23
- * const store = createVirtualWorkdirMemoryStateStore(tree);
24
- * const session = openVirtualWorkdirSession(repo.objects, store);
25
- * expect(session.baseTree).toBe(tree);
26
- * ```
27
- */
28
- declare function openVirtualWorkdirSession(source: ObjectDatabase, state: VirtualWorkdirStateStore): VirtualWorkdirSession;
29
- //#endregion
30
- export { createVirtualWorkdirSession, openVirtualWorkdirSession };