@goodandready/dsh-context-lens 0.1.24 → 0.1.25
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/CHANGELOG.md +5 -0
- package/lib/index.js +56 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to `@goodandready/dsh-context-lens` will be documented in th
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.25] - 2026-09-25
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **SettingsForms modern API adapter (#66)**: removed legacy call to nonexistent `sctx.settings.register` preventing crash on DSH 0.1.7-rc.1 core. Implemented `SettingsForms` adapter with `configure({ auto: false })`, live reading via `describe()` / `get()`, dynamic updates via `settings/document-updated`, and full cleanup on effect disposal.
|
|
12
|
+
|
|
8
13
|
## [0.1.24] - 2026-09-24
|
|
9
14
|
|
|
10
15
|
### Performance
|
package/lib/index.js
CHANGED
|
@@ -29,21 +29,69 @@ const NS = '@goodandready/dsh-context-lens';
|
|
|
29
29
|
export { renderOutput };
|
|
30
30
|
|
|
31
31
|
export function apply(ctx, config) {
|
|
32
|
-
let
|
|
32
|
+
let readConfig = () => config;
|
|
33
|
+
const getConfig = () => readConfig();
|
|
33
34
|
|
|
34
35
|
ctx.inject(['settings'], (sctx) => {
|
|
36
|
+
if (!sctx?.settings) return;
|
|
37
|
+
|
|
38
|
+
let disposeConfigure;
|
|
39
|
+
try {
|
|
40
|
+
if (typeof sctx.settings.configure === 'function') {
|
|
41
|
+
disposeConfigure = sctx.settings.configure({ auto: false }, ctx.fiber);
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
ctx.logger?.warn?.('dsh-context-lens: settings configure failed: ' + (error instanceof Error ? error.message : String(error)));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const readLiveSettings = () => {
|
|
48
|
+
try {
|
|
49
|
+
if (typeof sctx.settings.describe === 'function') {
|
|
50
|
+
const desc = sctx.settings.describe()?.find?.((row) => row.ns === NS);
|
|
51
|
+
if (desc && desc.value && typeof desc.value === 'object') {
|
|
52
|
+
return Config(desc.value);
|
|
53
|
+
}
|
|
54
|
+
} else if (typeof sctx.settings.get === 'function') {
|
|
55
|
+
const val = sctx.settings.get(NS);
|
|
56
|
+
if (val && typeof val === 'object') {
|
|
57
|
+
return Config(val);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
ctx.logger?.warn?.('dsh-context-lens: settings describe failed: ' + (error instanceof Error ? error.message : String(error)));
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
readConfig = () => readLiveSettings() ?? Config(ctx.fiber?.config ?? config) ?? config;
|
|
67
|
+
|
|
35
68
|
if (typeof sctx.effect === 'function') {
|
|
36
69
|
sctx.effect(() => {
|
|
37
|
-
const
|
|
38
|
-
|
|
70
|
+
const disposeDocUpdated = typeof sctx.on === 'function'
|
|
71
|
+
? sctx.on('settings/document-updated', (updatedNs) => {
|
|
72
|
+
if (updatedNs === NS) {
|
|
73
|
+
// Live settings refreshed on next readLiveSettings call
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
: null;
|
|
39
77
|
return () => {
|
|
40
|
-
if (typeof
|
|
41
|
-
|
|
78
|
+
if (typeof disposeConfigure === 'function') {
|
|
79
|
+
try {
|
|
80
|
+
disposeConfigure();
|
|
81
|
+
} catch (err) {
|
|
82
|
+
ctx.logger?.debug?.('dsh-context-lens: disposeConfigure failed', err);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (typeof disposeDocUpdated === 'function') {
|
|
86
|
+
try {
|
|
87
|
+
disposeDocUpdated();
|
|
88
|
+
} catch (err) {
|
|
89
|
+
ctx.logger?.debug?.('dsh-context-lens: disposeDocUpdated failed', err);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
readConfig = () => config;
|
|
42
93
|
};
|
|
43
94
|
}, 'dsh-context-lens: settings');
|
|
44
|
-
} else {
|
|
45
|
-
const scope = sctx.settings.register(NS, Config, { base: config });
|
|
46
|
-
getConfig = () => scope.get() ?? config;
|
|
47
95
|
}
|
|
48
96
|
});
|
|
49
97
|
|
package/package.json
CHANGED