@amalgm/live 0.2.54 → 0.2.56
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/PURPOSE.md +6 -0
- package/dist/contracts/binding.d.ts +3 -2
- package/dist/contracts/binding.d.ts.map +1 -1
- package/dist/contracts/deployments.d.ts +39 -0
- package/dist/contracts/deployments.d.ts.map +1 -0
- package/dist/contracts/deployments.js +75 -0
- package/dist/contracts/deployments.js.map +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/detection/adapter-contract.d.ts +0 -33
- package/dist/detection/adapter-contract.d.ts.map +1 -1
- package/dist/detection/adapter-contract.js +0 -32
- package/dist/detection/adapter-contract.js.map +1 -1
- package/dist/detection/diff.d.ts +5 -87
- package/dist/detection/diff.d.ts.map +1 -1
- package/dist/detection/diff.js +5 -111
- package/dist/detection/diff.js.map +1 -1
- package/dist/detection/enrollment.d.ts +8 -17
- package/dist/detection/enrollment.d.ts.map +1 -1
- package/dist/detection/enrollment.js +8 -73
- package/dist/detection/enrollment.js.map +1 -1
- package/dist/detection/index.d.ts +5 -8
- package/dist/detection/index.d.ts.map +1 -1
- package/dist/detection/index.js +5 -8
- package/dist/detection/index.js.map +1 -1
- package/dist/detection/territory.d.ts +1 -27
- package/dist/detection/territory.d.ts.map +1 -1
- package/dist/detection/territory.js +1 -77
- package/dist/detection/territory.js.map +1 -1
- package/dist/transfer/cargo.d.ts +46 -12
- package/dist/transfer/cargo.d.ts.map +1 -1
- package/dist/transfer/cargo.js +52 -18
- package/dist/transfer/cargo.js.map +1 -1
- package/dist/transfer/download.d.ts +8 -6
- package/dist/transfer/download.d.ts.map +1 -1
- package/dist/transfer/download.js +8 -6
- package/dist/transfer/download.js.map +1 -1
- package/dist/transfer/index.d.ts +2 -1
- package/dist/transfer/index.d.ts.map +1 -1
- package/dist/transfer/index.js +2 -1
- package/dist/transfer/index.js.map +1 -1
- package/dist/transfer/ranges.d.ts +43 -0
- package/dist/transfer/ranges.d.ts.map +1 -0
- package/dist/transfer/ranges.js +109 -0
- package/dist/transfer/ranges.js.map +1 -0
- package/dist/transfer/refs.d.ts +35 -0
- package/dist/transfer/refs.d.ts.map +1 -0
- package/dist/transfer/refs.js +45 -0
- package/dist/transfer/refs.js.map +1 -0
- package/dist-cjs/contracts/deployments.js +81 -0
- package/dist-cjs/contracts/deployments.js.map +1 -0
- package/dist-cjs/contracts/index.js +1 -0
- package/dist-cjs/contracts/index.js.map +1 -1
- package/dist-cjs/detection/adapter-contract.js +1 -34
- package/dist-cjs/detection/adapter-contract.js.map +1 -1
- package/dist-cjs/detection/diff.js +5 -113
- package/dist-cjs/detection/diff.js.map +1 -1
- package/dist-cjs/detection/enrollment.js +9 -75
- package/dist-cjs/detection/enrollment.js.map +1 -1
- package/dist-cjs/detection/index.js +5 -8
- package/dist-cjs/detection/index.js.map +1 -1
- package/dist-cjs/detection/territory.js +1 -79
- package/dist-cjs/detection/territory.js.map +1 -1
- package/dist-cjs/transfer/cargo.js +55 -20
- package/dist-cjs/transfer/cargo.js.map +1 -1
- package/dist-cjs/transfer/download.js +8 -6
- package/dist-cjs/transfer/download.js.map +1 -1
- package/dist-cjs/transfer/index.js +2 -1
- package/dist-cjs/transfer/index.js.map +1 -1
- package/dist-cjs/transfer/ranges.js +114 -0
- package/dist-cjs/transfer/ranges.js.map +1 -0
- package/dist-cjs/transfer/refs.js +49 -0
- package/dist-cjs/transfer/refs.js.map +1 -0
- package/package.json +2 -2
- package/dist/detection/continuity.d.ts +0 -54
- package/dist/detection/continuity.d.ts.map +0 -1
- package/dist/detection/continuity.js +0 -85
- package/dist/detection/continuity.js.map +0 -1
- package/dist/transfer/presign.d.ts +0 -26
- package/dist/transfer/presign.d.ts.map +0 -1
- package/dist/transfer/presign.js +0 -44
- package/dist/transfer/presign.js.map +0 -1
- package/dist-cjs/detection/continuity.js +0 -88
- package/dist-cjs/detection/continuity.js.map +0 -1
- package/dist-cjs/transfer/presign.js +0 -48
- package/dist-cjs/transfer/presign.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Detection enrollment
|
|
3
|
+
* Detection enrollment policy.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* User ground enrolls everything except structural local state and paths
|
|
6
|
+
* excluded by its tracked `.amalgmignore`; `.gitignore` never decides Amalgm
|
|
7
|
+
* enrollment, and there are no implicit dependency, dotfile, cache, or secret
|
|
8
|
+
* exclusions. Portable paths already use `/`; a host converts its native
|
|
9
|
+
* separator at the boundary. A literal `\\` is therefore preserved as part of
|
|
10
|
+
* a POSIX filename. The policy is pure strings-in/verdict-out and never
|
|
11
|
+
* inspects disk itself.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.DEFAULT_AMALGM_IGNORE = exports.AMALGM_IGNORE_FILE = exports.AMALGM_CONTROL_DIRECTORY = void 0;
|
|
15
15
|
exports.normalizedRelativePath = normalizedRelativePath;
|
|
16
16
|
exports.isAmalgmControlPath = isAmalgmControlPath;
|
|
17
17
|
exports.isSqliteCoordinationPath = isSqliteCoordinationPath;
|
|
@@ -22,72 +22,6 @@ exports.createUserGroundEnrollmentPolicy = createUserGroundEnrollmentPolicy;
|
|
|
22
22
|
exports.AMALGM_CONTROL_DIRECTORY = '.amalgm';
|
|
23
23
|
exports.AMALGM_IGNORE_FILE = '.amalgmignore';
|
|
24
24
|
exports.DEFAULT_AMALGM_IGNORE = `/${exports.AMALGM_CONTROL_DIRECTORY}/\n`;
|
|
25
|
-
const EXCLUDED_DIRECTORIES = new Set([
|
|
26
|
-
'.amalgm',
|
|
27
|
-
'.aws',
|
|
28
|
-
'.cache',
|
|
29
|
-
'.docker',
|
|
30
|
-
'.git',
|
|
31
|
-
'.gnupg',
|
|
32
|
-
'.gradle',
|
|
33
|
-
'.hg',
|
|
34
|
-
'.kube',
|
|
35
|
-
'.mypy_cache',
|
|
36
|
-
'.next',
|
|
37
|
-
'.nyc_output',
|
|
38
|
-
'.parcel-cache',
|
|
39
|
-
'.pytest_cache',
|
|
40
|
-
'.ruff_cache',
|
|
41
|
-
'.ssh',
|
|
42
|
-
'.svn',
|
|
43
|
-
'.svelte-kit',
|
|
44
|
-
'.turbo',
|
|
45
|
-
'.venv',
|
|
46
|
-
'.vite',
|
|
47
|
-
'__pycache__',
|
|
48
|
-
'coverage',
|
|
49
|
-
'node_modules',
|
|
50
|
-
]);
|
|
51
|
-
const EXCLUDED_FILES = new Set([
|
|
52
|
-
'.DS_Store',
|
|
53
|
-
'Thumbs.db',
|
|
54
|
-
'desktop.ini',
|
|
55
|
-
'npm-debug.log',
|
|
56
|
-
'pnpm-debug.log',
|
|
57
|
-
'yarn-debug.log',
|
|
58
|
-
'yarn-error.log',
|
|
59
|
-
]);
|
|
60
|
-
function isPrivateFile(name) {
|
|
61
|
-
if (/^\.env(?:\..+)?$/i.test(name) && !/\.example$/i.test(name))
|
|
62
|
-
return true;
|
|
63
|
-
if (/^(?:credentials?|secrets?)\.(?:json|ya?ml|toml|ini|conf)$/i.test(name))
|
|
64
|
-
return true;
|
|
65
|
-
if (/^id_(?:dsa|ecdsa|ed25519|rsa)$/i.test(name))
|
|
66
|
-
return true;
|
|
67
|
-
if (/^(?:\.git-credentials|\.netrc|\.npmrc|\.pypirc|auth\.json|kubeconfig)$/i.test(name))
|
|
68
|
-
return true;
|
|
69
|
-
if (/^(?:service[-_]?account|firebase[-_]?adminsdk).*\.json$/i.test(name))
|
|
70
|
-
return true;
|
|
71
|
-
return /\.(?:key|keystore|kdbx|p12|pfx|pem|ppk|tfstate(?:\.backup)?)$/i.test(name);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Legacy explicit-registration policy retained for additive API compatibility.
|
|
75
|
-
* Current user-ground Detect must use {@link createUserGroundEnrollmentPolicy};
|
|
76
|
-
* there are no implicit dependency, dotfile, cache, or secret exclusions.
|
|
77
|
-
* Both separators are path separators; '' never enrolls.
|
|
78
|
-
*
|
|
79
|
-
* @deprecated Use `createUserGroundEnrollmentPolicy` for current user ground.
|
|
80
|
-
*/
|
|
81
|
-
const defaultShouldEnroll = (relPath) => {
|
|
82
|
-
const parts = normalizedRelativePath(String(relPath || '').replace(/\\/g, '/')).split('/').filter(Boolean);
|
|
83
|
-
const name = parts.at(-1);
|
|
84
|
-
if (name === undefined || parts.some((part) => EXCLUDED_DIRECTORIES.has(part)))
|
|
85
|
-
return false;
|
|
86
|
-
if (EXCLUDED_FILES.has(name) || isPrivateFile(name))
|
|
87
|
-
return false;
|
|
88
|
-
return !name.startsWith('.#') && !name.endsWith('~') && !/\.(?:swp|swo)$/i.test(name);
|
|
89
|
-
};
|
|
90
|
-
exports.defaultShouldEnroll = defaultShouldEnroll;
|
|
91
25
|
/**
|
|
92
26
|
* One normalized spelling for portable enrollment and ignore matching.
|
|
93
27
|
* Portable relative paths use `/`. Do not reinterpret `\\`: it is a valid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrollment.js","sourceRoot":"","sources":["../../src/detection/enrollment.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;
|
|
1
|
+
{"version":3,"file":"enrollment.js","sourceRoot":"","sources":["../../src/detection/enrollment.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAiBH,wDAKC;AAGD,kDAEC;AAID,4DAGC;AA4DD,4EAaC;AAtGD;;qEAEqE;AACxD,QAAA,wBAAwB,GAAG,SAAS,CAAC;AACrC,QAAA,kBAAkB,GAAG,eAAe,CAAC;AACrC,QAAA,qBAAqB,GAAG,IAAI,gCAAwB,KAAK,CAAC;AAEvE;;;;GAIG;AACH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|
|
5
|
+
* entity-model.md (identity axioms, the two identity witnesses) and
|
|
6
6
|
* entity-implementation.md (the ratified seams).
|
|
7
7
|
*
|
|
8
8
|
* Everything here is rows and entries in, verdicts out. Walking disk,
|
|
@@ -11,15 +11,13 @@
|
|
|
11
11
|
* policy) and this layer owns only the laws:
|
|
12
12
|
*
|
|
13
13
|
* - `adapter-contract` the seven rails, the ratified detect socket,
|
|
14
|
-
* descriptor conviction
|
|
15
|
-
* judgment, the reference adapter
|
|
14
|
+
* and descriptor conviction
|
|
16
15
|
* - `classify` text/binary from detect's own read evidence
|
|
17
16
|
* - `refusal` declined-vs-broken, named where it is raised
|
|
18
|
-
* - `enrollment` tracked user-ground policy
|
|
19
|
-
* - `diff`
|
|
20
|
-
* - `continuity` root rescue and the undecided address
|
|
17
|
+
* - `enrollment` the tracked user-ground policy
|
|
18
|
+
* - `diff` directory channel identity from inode and address
|
|
21
19
|
* - `watch-boundary` generation-safe Watch input and coverage output
|
|
22
|
-
* - `territory` nearest-repository
|
|
20
|
+
* - `territory` nearest-repository ownership, indexed per graph
|
|
23
21
|
* - `record-proposal` the exact Detect-to-Record contract
|
|
24
22
|
* - `batch` net-difference planning and Watch settlement
|
|
25
23
|
* - `content` text/binary/link replay from one captured read
|
|
@@ -44,7 +42,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
44
42
|
__exportStar(require("./adapter-contract.js"), exports);
|
|
45
43
|
__exportStar(require("./batch.js"), exports);
|
|
46
44
|
__exportStar(require("./classify.js"), exports);
|
|
47
|
-
__exportStar(require("./continuity.js"), exports);
|
|
48
45
|
__exportStar(require("./content.js"), exports);
|
|
49
46
|
__exportStar(require("./diff.js"), exports);
|
|
50
47
|
__exportStar(require("./echo.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detection/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/detection/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;;AAEH,wDAAsC;AACtC,6CAA2B;AAC3B,gDAA8B;AAC9B,+CAA6B;AAC7B,4CAA0B;AAC1B,4CAA0B;AAC1B,kDAAgC;AAChC,uDAAqC;AACrC,kDAAgC;AAChC,+CAA6B;AAC7B,iDAA+B;AAC/B,sDAAoC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/** Nearest-repository ownership for
|
|
2
|
+
/** Nearest-repository ownership, indexed once for a whole graph. */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.indexRepositoryTerritory = indexRepositoryTerritory;
|
|
5
|
-
exports.nearestRepository = nearestRepository;
|
|
6
|
-
exports.recorderTargets = recorderTargets;
|
|
7
5
|
/**
|
|
8
6
|
* Index nearest-repository territory once for a complete or boundary-trimmed
|
|
9
7
|
* graph. Hosts use this when one scan needs ownership for every row: repeated
|
|
@@ -54,80 +52,4 @@ function indexRepositoryTerritory(nodes) {
|
|
|
54
52
|
ownedBy: (repositoryId) => Object.freeze([...(owned.get(repositoryId) ?? [])]),
|
|
55
53
|
});
|
|
56
54
|
}
|
|
57
|
-
/** The nearest repo at or above `uuid`; nested repositories win. */
|
|
58
|
-
function nearestRepository(uuid, byUuid) {
|
|
59
|
-
const seen = new Set();
|
|
60
|
-
let cursor = uuid;
|
|
61
|
-
while (cursor !== null) {
|
|
62
|
-
if (seen.has(cursor))
|
|
63
|
-
throw new Error(`registry corrupt: parent cycle at ${cursor}`);
|
|
64
|
-
seen.add(cursor);
|
|
65
|
-
const row = byUuid(cursor);
|
|
66
|
-
if (!row)
|
|
67
|
-
throw new Error(`no entity ${cursor}`);
|
|
68
|
-
if (row.type === 'repo.git')
|
|
69
|
-
return row;
|
|
70
|
-
cursor = row.parentUuid;
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Name every recorder whose state a transition can change.
|
|
76
|
-
*
|
|
77
|
-
* Ordinary changes outside repository territory publish on the entity UUID.
|
|
78
|
-
* A change wholly inside one repository publishes only the repository parcel.
|
|
79
|
-
* Crossing a repository boundary also publishes the entity graph transition,
|
|
80
|
-
* plus the source and/or destination repositories whose identity maps and
|
|
81
|
-
* Checkpoints changed.
|
|
82
|
-
*/
|
|
83
|
-
function recorderTargets(transition, byUuid) {
|
|
84
|
-
const { base, result } = transition;
|
|
85
|
-
if (base !== null && base.uuid !== result.uuid) {
|
|
86
|
-
throw new Error('a recorder transition cannot change entity UUID');
|
|
87
|
-
}
|
|
88
|
-
const before = nearestRepository(base?.parentUUID ?? null, byUuid);
|
|
89
|
-
const after = nearestRepository(result.parentUUID, byUuid);
|
|
90
|
-
const add = (targets, target) => {
|
|
91
|
-
if (!targets.some((candidate) => candidate.resourceId === target.resourceId))
|
|
92
|
-
targets.push(target);
|
|
93
|
-
};
|
|
94
|
-
// Every `.git` boundary starts its own repository rail, even when nested.
|
|
95
|
-
// Its enclosing repository changes only when the boundary's graph entry
|
|
96
|
-
// changes; ordinary Card/Checkpoint advancement remains on the inner rail.
|
|
97
|
-
if (base?.type === 'repo.git' || result.type === 'repo.git') {
|
|
98
|
-
const targets = [];
|
|
99
|
-
add(targets, {
|
|
100
|
-
kind: result.type === 'repo.git' ? 'repository' : 'entity',
|
|
101
|
-
resourceId: result.uuid,
|
|
102
|
-
});
|
|
103
|
-
const boundaryChanged = base === null
|
|
104
|
-
|| base.type !== result.type
|
|
105
|
-
|| base.parentUUID !== result.parentUUID
|
|
106
|
-
|| base.name !== result.name
|
|
107
|
-
|| base.status !== result.status;
|
|
108
|
-
if (boundaryChanged) {
|
|
109
|
-
if (before)
|
|
110
|
-
add(targets, { kind: 'repository', resourceId: before.uuid });
|
|
111
|
-
if (after)
|
|
112
|
-
add(targets, { kind: 'repository', resourceId: after.uuid });
|
|
113
|
-
}
|
|
114
|
-
return Object.freeze(targets);
|
|
115
|
-
}
|
|
116
|
-
if (base === null) {
|
|
117
|
-
return Object.freeze(after
|
|
118
|
-
? [{ kind: 'repository', resourceId: after.uuid }]
|
|
119
|
-
: [{ kind: 'entity', resourceId: result.uuid }]);
|
|
120
|
-
}
|
|
121
|
-
if (before?.uuid === after?.uuid) {
|
|
122
|
-
return Object.freeze(before
|
|
123
|
-
? [{ kind: 'repository', resourceId: before.uuid }]
|
|
124
|
-
: [{ kind: 'entity', resourceId: result.uuid }]);
|
|
125
|
-
}
|
|
126
|
-
const targets = [{ kind: 'entity', resourceId: result.uuid }];
|
|
127
|
-
for (const repository of [before, after]) {
|
|
128
|
-
if (repository)
|
|
129
|
-
add(targets, { kind: 'repository', resourceId: repository.uuid });
|
|
130
|
-
}
|
|
131
|
-
return Object.freeze(targets);
|
|
132
|
-
}
|
|
133
55
|
//# sourceMappingURL=territory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"territory.js","sourceRoot":"","sources":["../../src/detection/territory.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"territory.js","sourceRoot":"","sources":["../../src/detection/territory.ts"],"names":[],"mappings":";AAAA,oEAAoE;;AAwBpE,4DAyCC;AAhDD;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,KAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgB,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9F,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,GAAG,EAA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,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,CAAC,IAAU,EAAE,EAAE;YACtB,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACvC,CAAC;QACD,OAAO,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;KACvF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,39 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Cargo
|
|
3
|
+
* Cargo stream — cold transport of many complete small artifacts.
|
|
4
4
|
*
|
|
5
5
|
* A register journey moves file counts, not just bytes: tens of thousands
|
|
6
6
|
* of small artifacts whose per-artifact negotiation frames would dwarf the
|
|
7
|
-
* payload.
|
|
8
|
-
*
|
|
9
|
-
* count
|
|
10
|
-
*
|
|
7
|
+
* payload. The set streams as self-contained segments. Each segment carries
|
|
8
|
+
* whole artifacts — every chunk and the manifest identity — so the frame
|
|
9
|
+
* count scales with bytes moved, never with file count. Segments flow
|
|
10
|
+
* through one bounded window and never wait on one another's durability
|
|
11
|
+
* acknowledgements; the authority verifies and seals each segment
|
|
12
|
+
* independently, so an interruption loses only unacknowledged segments and
|
|
13
|
+
* a rerun resumes from the sealed inventory. Only artifacts at or below the
|
|
14
|
+
* segment byte bound ride the stream; larger artifacts keep per-artifact
|
|
15
|
+
* transfer where chunk reuse pays.
|
|
11
16
|
*/
|
|
12
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
18
|
+
exports.CARGO_STREAM_IN_FLIGHT_BYTES = exports.CARGO_SEGMENT_ARTIFACTS = exports.CARGO_SEGMENT_BYTES = void 0;
|
|
19
|
+
exports.planCargoSegments = planCargoSegments;
|
|
20
|
+
exports.streamCargo = streamCargo;
|
|
15
21
|
const batches_js_1 = require("./batches.js");
|
|
16
|
-
|
|
22
|
+
const parallel_js_1 = require("./parallel.js");
|
|
23
|
+
exports.CARGO_SEGMENT_BYTES = batches_js_1.FILE_TRANSFER_BATCH_BYTES;
|
|
17
24
|
/** Bounded by the 64KiB binary-frame header law: every artifact declaration
|
|
18
25
|
* (content hash, bytes, chunk list) rides the JSON header, and 256 worst-case
|
|
19
26
|
* declarations stay under the bound with margin. The byte bound, not this
|
|
20
|
-
* count, decides the
|
|
21
|
-
exports.
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
* count, decides the segment tally on real grounds. */
|
|
28
|
+
exports.CARGO_SEGMENT_ARTIFACTS = 256;
|
|
29
|
+
/** Four full segments may be in flight at once. The window keeps the wire
|
|
30
|
+
* busy while earlier segments await the authority's per-segment durability
|
|
31
|
+
* fan-out, and worst-case payload residency (plaintext plus one encoded
|
|
32
|
+
* copy per in-flight segment) stays comfortably inside a 1-GiB runtime. */
|
|
33
|
+
exports.CARGO_STREAM_IN_FLIGHT_BYTES = 4 * exports.CARGO_SEGMENT_BYTES;
|
|
34
|
+
/** Pack items in order into segments within the byte and artifact bounds. */
|
|
35
|
+
function planCargoSegments(items) {
|
|
36
|
+
const segments = [];
|
|
25
37
|
let current = [];
|
|
26
38
|
let bytes = 0;
|
|
27
39
|
for (const item of items) {
|
|
40
|
+
if (typeof item.contentHash !== 'string' || item.contentHash.length === 0) {
|
|
41
|
+
throw new Error('cargo item is missing its content identity');
|
|
42
|
+
}
|
|
28
43
|
if (!Number.isSafeInteger(item.bytes) || item.bytes < 0) {
|
|
29
|
-
throw new Error('cargo
|
|
44
|
+
throw new Error('cargo item byte count is invalid');
|
|
30
45
|
}
|
|
31
|
-
if (item.bytes > exports.
|
|
32
|
-
throw new Error('cargo
|
|
46
|
+
if (item.bytes > exports.CARGO_SEGMENT_BYTES) {
|
|
47
|
+
throw new Error('cargo item exceeds the segment byte bound');
|
|
33
48
|
}
|
|
34
49
|
if (current.length > 0
|
|
35
|
-
&& (bytes + item.bytes > exports.
|
|
36
|
-
|
|
50
|
+
&& (bytes + item.bytes > exports.CARGO_SEGMENT_BYTES || current.length >= exports.CARGO_SEGMENT_ARTIFACTS)) {
|
|
51
|
+
segments.push({ items: current, bytes });
|
|
37
52
|
current = [];
|
|
38
53
|
bytes = 0;
|
|
39
54
|
}
|
|
@@ -41,7 +56,27 @@ function planCargoWaves(items) {
|
|
|
41
56
|
bytes += item.bytes;
|
|
42
57
|
}
|
|
43
58
|
if (current.length > 0)
|
|
44
|
-
|
|
45
|
-
return
|
|
59
|
+
segments.push({ items: current, bytes });
|
|
60
|
+
return segments;
|
|
61
|
+
}
|
|
62
|
+
/** Stream one cold set of small artifacts as bounded pipelined segments.
|
|
63
|
+
* Every item must come back sealed or the stream fails; a failure stops new
|
|
64
|
+
* admission, lets in-flight segments settle, and leaves their sealed work
|
|
65
|
+
* durable for the resuming rerun. */
|
|
66
|
+
async function streamCargo(items, ports, options = {}) {
|
|
67
|
+
const segments = planCargoSegments(items);
|
|
68
|
+
let artifacts = 0;
|
|
69
|
+
let bytes = 0;
|
|
70
|
+
await (0, parallel_js_1.weightedParallelForEach)(segments, options.lanes ?? parallel_js_1.DEFAULT_TRANSFER_CONCURRENCY, options.maxInFlightBytes ?? exports.CARGO_STREAM_IN_FLIGHT_BYTES, (segment) => Math.max(segment.bytes, 1), async (segment) => {
|
|
71
|
+
const sealed = new Set(await ports.send(segment));
|
|
72
|
+
for (const item of segment.items) {
|
|
73
|
+
if (!sealed.has(item.contentHash)) {
|
|
74
|
+
throw new Error(`cargo authority did not seal ${item.contentHash}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
artifacts += segment.items.length;
|
|
78
|
+
bytes += segment.bytes;
|
|
79
|
+
});
|
|
80
|
+
return { segments: segments.length, artifacts, bytes };
|
|
46
81
|
}
|
|
47
82
|
//# sourceMappingURL=cargo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo.js","sourceRoot":"","sources":["../../src/transfer/cargo.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"cargo.js","sourceRoot":"","sources":["../../src/transfer/cargo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAiDH,8CA2BC;AAMD,kCAyBC;AAzGD,6CAAyD;AACzD,+CAAsF;AAEzE,QAAA,mBAAmB,GAAG,sCAAyB,CAAC;AAC7D;;;uDAGuD;AAC1C,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAC3C;;;2EAG2E;AAC9D,QAAA,4BAA4B,GAAG,CAAC,GAAG,2BAAmB,CAAC;AAiCpE,6EAA6E;AAC7E,SAAgB,iBAAiB,CAC/B,KAAmB;IAEnB,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,IAAI,OAAO,GAAQ,EAAE,CAAC;IACtB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YAC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B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QACD,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;QAClC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC,CACF,CAAC;IACF,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACzD,CAAC"}
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Download a set of immutable artifacts into a machine cache.
|
|
4
4
|
*
|
|
5
|
-
* The set is the primitive: one plan
|
|
6
|
-
* cache which chunks are gaps, one
|
|
7
|
-
* whole set under a single bound, and one seal
|
|
5
|
+
* The set is the primitive: one plan phase proves every manifest and asks the
|
|
6
|
+
* cache which chunks are gaps, one fetch phase obtains every gap across the
|
|
7
|
+
* whole set under a single bound, and one seal phase verifies each complete
|
|
8
8
|
* artifact. A lone artifact is a set of one — there is no second path. This
|
|
9
9
|
* shape removes per-artifact serialization: no artifact waits behind
|
|
10
10
|
* another's plan or seal, only behind the shared fetch bound. Each chunk is
|
|
11
11
|
* still its own storage request — the set changes scheduling, not the
|
|
12
12
|
* request count.
|
|
13
13
|
*
|
|
14
|
-
* Every chunk
|
|
15
|
-
*
|
|
16
|
-
* host's
|
|
14
|
+
* Every chunk keeps one content-addressed identity, whether its sealed
|
|
15
|
+
* envelope lives alone or as a byte range inside an immutable pack. The
|
|
16
|
+
* host's ports resolve and fetch those identities; parallelism, storage
|
|
17
|
+
* layout, transport, and decryption are the host's concern, while the
|
|
18
|
+
* verification laws here remain singular.
|
|
17
19
|
*/
|
|
18
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
21
|
exports.downloadAll = downloadAll;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/transfer/download.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/transfer/download.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAoEH,kCAmEC;AAGD,4BAQC;AAhJD,wDAAkG;AAElG,iDAA+E;AAC/E,+CAIuB;AAwDvB;;uCAEuC;AAChC,KAAK,UAAU,WAAW,CAC/B,SAAsC,EACtC,KAAmC,EACnC,UAA2B,EAAE;IAE7B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,0CAA4B,CAAC;IACxE,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB;WAC5C,0CAA4B,GAAG,wBAAW,CAAC;IAChD,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,IAAA,qCAAsB,EAAC,QAAQ,CAAC,CAAC;IAEnE,MAAM,KAAK,GAAiC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxE,MAAM,IAAA,6BAAe,EAAC,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACvE,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO;QACnC,MAAM,OAAO,GAAG,IAAA,iCAAoB,EAClC,MAAM,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,EACjC,QAAQ,CAAC,WAAW,CACrB,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAA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KAAK;YACnB,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;YACrC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;SAChE,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,IAAI,OAAO,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACpF,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AAC/C,KAAK,UAAU,QAAQ,CAC5B,QAA0B,EAC1B,KAAmC,EACnC,UAA2B,EAAE;IAE7B,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAChE,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACpF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -19,5 +19,6 @@ __exportStar(require("./artifacts.js"), exports);
|
|
|
19
19
|
__exportStar(require("./cargo.js"), exports);
|
|
20
20
|
__exportStar(require("./upload.js"), exports);
|
|
21
21
|
__exportStar(require("./download.js"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./refs.js"), exports);
|
|
23
|
+
__exportStar(require("./ranges.js"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transfer/index.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;;;;;;;;;;;;;;AAExD,iDAA+B;AAC/B,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transfer/index.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;;;;;;;;;;;;;;AAExD,iDAA+B;AAC/B,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ranged pack reading.
|
|
4
|
+
*
|
|
5
|
+
* Sealed envelopes of many small objects live inside one immutable pack.
|
|
6
|
+
* Requests for ranges of the same pack URL made in the same event-loop turn
|
|
7
|
+
* merge into minimal byte spans — one ranged GET per span — and every
|
|
8
|
+
* requester receives exactly its envelope slice. A small hole between wanted
|
|
9
|
+
* ranges is cheaper to read through than to split a request over, so spans
|
|
10
|
+
* merge across gaps up to RANGE_MERGE_GAP_BYTES. Wrong or shifted bytes can
|
|
11
|
+
* never leak: every dispensed slice is still an authenticated envelope the
|
|
12
|
+
* caller opens and hash-verifies.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RANGE_MERGE_GAP_BYTES = void 0;
|
|
16
|
+
exports.planSpans = planSpans;
|
|
17
|
+
exports.createSpanFetcher = createSpanFetcher;
|
|
18
|
+
/** Read through holes up to this size rather than splitting a range request. */
|
|
19
|
+
exports.RANGE_MERGE_GAP_BYTES = 64 * 1024;
|
|
20
|
+
function invalidSpan(span) {
|
|
21
|
+
return !Number.isSafeInteger(span.offset) || span.offset < 0
|
|
22
|
+
|| !Number.isSafeInteger(span.length) || span.length < 1
|
|
23
|
+
|| !Number.isSafeInteger(span.offset + span.length);
|
|
24
|
+
}
|
|
25
|
+
/** Merge wanted ranges into minimal fetch spans. Pure planning — no IO. */
|
|
26
|
+
function planSpans(requests, mergeGap) {
|
|
27
|
+
if (requests.length === 0)
|
|
28
|
+
return { spans: [], slices: [] };
|
|
29
|
+
if (!Number.isSafeInteger(mergeGap) || mergeGap < 0) {
|
|
30
|
+
throw new Error('range plan received an invalid merge gap');
|
|
31
|
+
}
|
|
32
|
+
if (requests.some(invalidSpan))
|
|
33
|
+
throw new Error('range plan received an invalid byte span');
|
|
34
|
+
const order = requests.map((request, index) => ({ request, index }))
|
|
35
|
+
.sort((a, b) => a.request.offset - b.request.offset || a.request.length - b.request.length);
|
|
36
|
+
const spans = [];
|
|
37
|
+
const slices = new Array(requests.length);
|
|
38
|
+
for (const { request, index } of order) {
|
|
39
|
+
const end = request.offset + request.length;
|
|
40
|
+
const current = spans[spans.length - 1];
|
|
41
|
+
if (current && request.offset <= current.end + mergeGap) {
|
|
42
|
+
current.end = Math.max(current.end, end);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
spans.push({ offset: request.offset, end });
|
|
46
|
+
}
|
|
47
|
+
slices[index] = { span: spans.length - 1, start: request.offset - spans[spans.length - 1].offset };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
spans: spans.map((span) => ({ offset: span.offset, length: span.end - span.offset })),
|
|
51
|
+
slices,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function createSpanFetcher(ports) {
|
|
55
|
+
const pending = new Map();
|
|
56
|
+
let scheduled = false;
|
|
57
|
+
const flushUrl = async (url, waiters) => {
|
|
58
|
+
let plan;
|
|
59
|
+
try {
|
|
60
|
+
plan = planSpans(waiters.map((waiter) => waiter.range), exports.RANGE_MERGE_GAP_BYTES);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
waiters.forEach((waiter) => waiter.reject(error));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await Promise.all(plan.spans.map(async (span, spanIndex) => {
|
|
67
|
+
const served = [];
|
|
68
|
+
plan.slices.forEach((slice, index) => {
|
|
69
|
+
if (slice.span === spanIndex)
|
|
70
|
+
served.push({ waiter: waiters[index], start: slice.start });
|
|
71
|
+
});
|
|
72
|
+
try {
|
|
73
|
+
const bytes = await ports.fetchSpan(url, span);
|
|
74
|
+
if (bytes.length !== span.length) {
|
|
75
|
+
throw new Error(`pack range answered ${bytes.length} bytes where ${span.length} were requested`);
|
|
76
|
+
}
|
|
77
|
+
served.forEach(({ waiter, start }) => waiter.resolve(bytes.subarray(start, start + waiter.range.length)));
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
served.forEach(({ waiter }) => waiter.reject(error));
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
const flush = () => {
|
|
85
|
+
scheduled = false;
|
|
86
|
+
const batches = [...pending.entries()];
|
|
87
|
+
pending.clear();
|
|
88
|
+
for (const [url, waiters] of batches)
|
|
89
|
+
void flushUrl(url, waiters);
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
fetch(ref) {
|
|
93
|
+
if (ref.offset == null && ref.length == null) {
|
|
94
|
+
return ports.fetchSpan(ref.url, null);
|
|
95
|
+
}
|
|
96
|
+
const range = { offset: ref.offset ?? -1, length: ref.length ?? -1 };
|
|
97
|
+
if (invalidSpan(range)) {
|
|
98
|
+
return Promise.reject(new Error('content ref carries an invalid pack range'));
|
|
99
|
+
}
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const waiters = pending.get(ref.url);
|
|
102
|
+
if (waiters)
|
|
103
|
+
waiters.push({ range, resolve, reject });
|
|
104
|
+
else
|
|
105
|
+
pending.set(ref.url, [{ range, resolve, reject }]);
|
|
106
|
+
if (!scheduled) {
|
|
107
|
+
scheduled = true;
|
|
108
|
+
setTimeout(flush, 0);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=ranges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ranges.js","sourceRoot":"","sources":["../../src/transfer/ranges.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA2BH,8BAwBC;AAoBD,8CAyDC;AA5HD,gFAAgF;AACnE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BAAE,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;;oBACjD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;gBACxD,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,SAAS,GAAG,IAAI,CAAC;oBACjB,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content-ref brokering for direct content-storage fetches.
|
|
4
|
+
*
|
|
5
|
+
* Downloads fetch every storage object straight from content storage. Callers
|
|
6
|
+
* ask where one object lives at a time; the broker coalesces every request
|
|
7
|
+
* made in the same event-loop turn into one batched refs call. The authority
|
|
8
|
+
* answers each object with a short-lived URL and, when the object's sealed
|
|
9
|
+
* envelope rides inside an immutable pack, the exact byte range holding it.
|
|
10
|
+
* URLs are used immediately and never cached — their expiry is the gateway's
|
|
11
|
+
* revocation lever.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CONTENT_REFS_BATCH_OBJECTS = void 0;
|
|
15
|
+
exports.createRefsBroker = createRefsBroker;
|
|
16
|
+
/** One law shared with the gateway: the most objects one refs call may name. */
|
|
17
|
+
exports.CONTENT_REFS_BATCH_OBJECTS = 2048;
|
|
18
|
+
function createRefsBroker(ports) {
|
|
19
|
+
let pending = [];
|
|
20
|
+
let scheduled = false;
|
|
21
|
+
const flush = async () => {
|
|
22
|
+
scheduled = false;
|
|
23
|
+
while (pending.length > 0) {
|
|
24
|
+
const batch = pending.splice(0, exports.CONTENT_REFS_BATCH_OBJECTS);
|
|
25
|
+
try {
|
|
26
|
+
const refs = await ports.requestRefs(batch.map((waiter) => waiter.object));
|
|
27
|
+
if (refs.length !== batch.length) {
|
|
28
|
+
throw new Error('content refs answered the wrong number of objects');
|
|
29
|
+
}
|
|
30
|
+
batch.forEach((waiter, index) => waiter.resolve(refs[index]));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
batch.forEach((waiter) => waiter.reject(error));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
ref(object) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
pending.push({ object, resolve, reject });
|
|
41
|
+
if (!scheduled) {
|
|
42
|
+
scheduled = true;
|
|
43
|
+
setTimeout(() => { void flush(); }, 0);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/transfer/refs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAmCH,4CA+BC;AAhED,gFAAgF;AACnE,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAgC/C,SAAgB,gBAAgB,CAAC,KAAsB;IACrD,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,MAAM,KAAK,GAAG,KAAK,IAAmB,EAAE;QACtC,SAAS,GAAG,KAAK,CAAC;QAClB,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,kCAA0B,CAAC,CAAC;YAC5D,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,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