@forgeax/app-shell 0.1.1 → 0.2.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/index.d.ts +10 -1
- package/dist/index.js +19 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,14 @@ declare class AppShellRegistry {
|
|
|
15
15
|
declare function createShellContribution(input: Omit<ShellContribution, 'contribution'> & {
|
|
16
16
|
contribution: ContributionDeclaration;
|
|
17
17
|
}): ShellContribution;
|
|
18
|
+
type ShellSnapshotPatch<T extends Record<string, unknown>> = {
|
|
19
|
+
readonly [K in keyof T]?: T[K] extends readonly unknown[] ? T[K] : T[K] extends Record<string, unknown> ? Partial<T[K]> : T[K];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Folds ordered shell contributions into an immutable derived snapshot.
|
|
23
|
+
* Object-valued fields merge one level; arrays and scalar values replace the
|
|
24
|
+
* previous value. Undefined fields do not contribute.
|
|
25
|
+
*/
|
|
26
|
+
declare function deriveShellSnapshot<T extends Record<string, unknown>>(base: T, patches: ReadonlyArray<ShellSnapshotPatch<T>>): T;
|
|
18
27
|
|
|
19
|
-
export { AppShellRegistry, type ShellContribution, type ShellSlot, createShellContribution };
|
|
28
|
+
export { AppShellRegistry, type ShellContribution, type ShellSlot, type ShellSnapshotPatch, createShellContribution, deriveShellSnapshot };
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,25 @@ var AppShellRegistry = class {
|
|
|
15
15
|
function createShellContribution(input) {
|
|
16
16
|
return { ...input };
|
|
17
17
|
}
|
|
18
|
+
function deriveShellSnapshot(base, patches) {
|
|
19
|
+
const output = { ...base };
|
|
20
|
+
for (const patch of patches) {
|
|
21
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
22
|
+
if (value === void 0) continue;
|
|
23
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
24
|
+
output[key] = {
|
|
25
|
+
...output[key],
|
|
26
|
+
...value
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
output[key] = value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
18
35
|
export {
|
|
19
36
|
AppShellRegistry,
|
|
20
|
-
createShellContribution
|
|
37
|
+
createShellContribution,
|
|
38
|
+
deriveShellSnapshot
|
|
21
39
|
};
|