dsh-mnemon 0.5.42 → 0.5.44
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/bin/repair-legacy-session.mjs +18 -2
- package/lib/bundle.js +1 -1
- package/lib/client.js +587 -162
- package/lib/extension-sdk.js +39 -1
- package/lib/index.js +818 -170
- package/lib/{starter-resolution-B5mdKlvf.js → starter-resolution-LTLQsJPW.js} +7 -7
- package/lib/starter.js +1 -1
- package/lib/types/src/client/locales.d.ts +25 -0
- package/lib/types/src/host/protocol.d.ts +11 -0
- package/lib/types/src/sdk/index.d.ts +1 -0
- package/lib/types/src/sdk/projection-reservation.d.ts +3 -0
- package/locale/detail.en.md +7 -0
- package/locale/detail.zh.md +7 -0
- package/locale/en.json +3 -1
- package/locale/zh.json +2 -1
- package/package.json +9 -8
package/lib/extension-sdk.js
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
import { a as memoryConfigurationDigest, c as record, d as truncate, f as canonicalWorkspacePath, i as integer, l as stringArray, m as withMemoryStorageLock, o as migrationLineage, p as workspaceStorageId, s as receipt, t as defineMemoryStrategyConfiguration, u as text } from "./strategy-configuration-CKP2kRss.js";
|
|
2
2
|
import { COMPOSABLE_MEMORY_API_VERSION, MEMORY_VIEW_EXTENSION_SLOTS } from "./contracts.js";
|
|
3
3
|
import { a as defineMemoryStrategy, i as defineMemorySource, o as defineMemoryStrategyExtension, r as defineMemoryPlugin } from "./definitions-DU7MLBhu.js";
|
|
4
|
+
//#region src/sdk/projection-reservation.ts
|
|
5
|
+
/** Reserve complete Source-declared resident data inside the existing View ceiling. */
|
|
6
|
+
function reserveMemoryProjection(spec, sources, budget) {
|
|
7
|
+
const minimums = spec.sources.map((selected) => {
|
|
8
|
+
const source = sources.find((item) => item.sourceInstanceKey === selected.sourceInstanceKey);
|
|
9
|
+
const hints = source?.hints;
|
|
10
|
+
const value = source?.capabilities.includes("project") && hints !== null && typeof hints === "object" && !Array.isArray(hints) ? hints?.minimumProjectionCharacters : void 0;
|
|
11
|
+
if (value === void 0) return 0;
|
|
12
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) throw new Error("Invalid minimum projection hint");
|
|
13
|
+
return value;
|
|
14
|
+
});
|
|
15
|
+
if (minimums.every((value) => value === 0)) return spec;
|
|
16
|
+
const minimum = minimums.reduce((sum, value) => sum + value, 0);
|
|
17
|
+
if (minimum > budget) throw new Error(`Pinned memory requires ${minimum} projection characters but the View budget is ${budget}. Unpin entries or increase the View budget.`);
|
|
18
|
+
const allocation = spec.sources.map((selected, index) => Math.max(minimums[index], selected.projection?.maxCharacters ?? 0));
|
|
19
|
+
let excess = allocation.reduce((sum, value) => sum + value, 0) - budget;
|
|
20
|
+
for (let index = allocation.length - 1; index >= 0 && excess > 0; index--) {
|
|
21
|
+
const reclaimed = Math.min(excess, allocation[index] - minimums[index]);
|
|
22
|
+
allocation[index] -= reclaimed;
|
|
23
|
+
excess -= reclaimed;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...spec,
|
|
27
|
+
sources: spec.sources.map((selected, index) => {
|
|
28
|
+
const { projection, ...rest } = selected;
|
|
29
|
+
const characters = allocation[index];
|
|
30
|
+
return {
|
|
31
|
+
...rest,
|
|
32
|
+
...minimums[index] > 0 ? { required: true } : {},
|
|
33
|
+
...characters === 0 ? {} : { projection: {
|
|
34
|
+
mode: projection?.mode ?? "eager",
|
|
35
|
+
maxCharacters: characters
|
|
36
|
+
} }
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
4
42
|
//#region src/sdk/install.ts
|
|
5
43
|
function locatedEntryId(ctx) {
|
|
6
44
|
const located = ctx.get("loader", false)?.locate(ctx.fiber)?.trim();
|
|
@@ -108,4 +146,4 @@ function defineMemoryViewExtension(definition) {
|
|
|
108
146
|
});
|
|
109
147
|
}
|
|
110
148
|
//#endregion
|
|
111
|
-
export { canonicalWorkspacePath, receipt as createMemoryMutationReceipt, defineMemoryPlugin, defineMemorySource, defineMemoryStrategy, defineMemoryStrategyConfiguration, defineMemoryStrategyExtension, defineMemoryViewExtension, installMemory, memoryConfigurationDigest, integer as memoryInputInteger, migrationLineage as memoryInputMigrationLineage, record as memoryInputRecord, stringArray as memoryInputStringArray, text as memoryInputText, memoryViewExtensionValues, truncate as truncateMemoryText, validateMemoryViewExtension, withMemoryStorageLock, workspaceStorageId };
|
|
149
|
+
export { canonicalWorkspacePath, receipt as createMemoryMutationReceipt, defineMemoryPlugin, defineMemorySource, defineMemoryStrategy, defineMemoryStrategyConfiguration, defineMemoryStrategyExtension, defineMemoryViewExtension, installMemory, memoryConfigurationDigest, integer as memoryInputInteger, migrationLineage as memoryInputMigrationLineage, record as memoryInputRecord, stringArray as memoryInputStringArray, text as memoryInputText, memoryViewExtensionValues, reserveMemoryProjection, truncate as truncateMemoryText, validateMemoryViewExtension, withMemoryStorageLock, workspaceStorageId };
|