@goodandready/dsh-context-lens 0.1.4 → 0.1.5

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 (2) hide show
  1. package/lib/client.js +33 -8
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -208,14 +208,39 @@ window.__ModuleLoader__.load({
208
208
 
209
209
  module.exports.inject = ['slots', 'locale'];
210
210
  module.exports.apply = function apply(ctx) {
211
- try { ctx.locale.register(NS, { en, ru }); } catch (e) {}
212
- if (ctx.slots) {
213
- ctx.slots.register({
214
- name: 'settings.plugin.item',
215
- key: NS,
216
- locale: NS,
217
- inject: () => ({ ctx })
218
- }, PluginCard);
211
+ try { ctx.locale.register(NS, { en, ru }); } catch (e) { console.warn('[dsh-context-lens] locale register failed', e && e.message || e); }
212
+ if (!ctx.slots) return;
213
+ let registered = false;
214
+ const doRegister = () => {
215
+ if (registered) return;
216
+ try {
217
+ const dispose = ctx.slots.register({
218
+ name: 'settings.plugin.item',
219
+ key: NS,
220
+ locale: NS,
221
+ inject: () => ({ ctx })
222
+ }, PluginCard);
223
+ registered = true;
224
+ return dispose;
225
+ } catch (e) {
226
+ // Do not swallow real registration errors — surface diagnostics
227
+ console.error('[dsh-context-lens] settings.plugin.item register failed', e && e.stack || e);
228
+ throw e;
229
+ }
230
+ };
231
+ // Declaration-aware: wait for host to declare the slot (alpha2 SlotCore throws if not declared)
232
+ if (typeof ctx.slots.inject === 'function') {
233
+ try {
234
+ const ok = ctx.slots.inject('settings.plugin.item', doRegister);
235
+ if (!ok) console.warn('[dsh-context-lens] settings.plugin.item inject returned false — slot not declared yet');
236
+ } catch (e) {
237
+ console.error('[dsh-context-lens] settings.plugin.item inject failed', e && e.stack || e);
238
+ // Fallback for older DSH without inject or if inject itself fails — surface error
239
+ try { doRegister(); } catch (e2) { console.error('[dsh-context-lens] fallback register failed', e2 && e2.stack || e2); throw e2; }
240
+ throw e;
241
+ }
242
+ } else {
243
+ try { doRegister(); } catch (e) { console.error('[dsh-context-lens] direct register failed (no inject)', e && e.stack || e); throw e; }
219
244
  }
220
245
  };
221
246
  return module.exports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-context-lens",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "DSH plugin for AST context compression, test log filtering, and token budget guard",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",