dsh-draw 0.2.12 → 0.2.15

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 (40) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/{README.es.md → README-es.md} +19 -7
  3. package/{README.hi.md → README-hi.md} +19 -7
  4. package/{README.pt.md → README-pt.md} +19 -7
  5. package/{README.zh.md → README-zh.md} +19 -7
  6. package/README.md +19 -8
  7. package/lib/client.js +69 -65
  8. package/lib/client.js.map +1 -1
  9. package/lib/index.js +49 -7
  10. package/lib/typert.host.js +1 -1
  11. package/lib/types/client/index.d.ts +12 -0
  12. package/lib/types/client/index.d.ts.map +1 -1
  13. package/lib/types/client/index.js +23 -5
  14. package/lib/types/client/remote.d.ts +110 -31
  15. package/lib/types/client/remote.d.ts.map +1 -1
  16. package/lib/types/client/styles.d.ts.map +1 -1
  17. package/lib/types/client/styles.js +24 -7
  18. package/lib/types/event-gate.d.ts +24 -2
  19. package/lib/types/event-gate.d.ts.map +1 -1
  20. package/lib/types/event-gate.js +31 -3
  21. package/lib/types/index.d.ts.map +1 -1
  22. package/lib/types/index.js +19 -2
  23. package/lib/types/session-events.d.ts.map +1 -1
  24. package/lib/types/session-events.js +9 -2
  25. package/lib/types/typert.host.d.ts +110 -31
  26. package/lib/types/typert.host.d.ts.map +1 -1
  27. package/lib/types/version.d.ts +1 -1
  28. package/lib/types/version.js +1 -1
  29. package/lib/types/wire.d.ts +220 -62
  30. package/lib/types/wire.d.ts.map +1 -1
  31. package/lib/types/wire.js +21 -35
  32. package/lib/{wire-DLW8WmDW.js → wire-BvocRNv3.js} +26 -55
  33. package/package.json +38 -36
  34. package/src/client/index.ts +20 -5
  35. package/src/client/styles.ts +24 -6
  36. package/src/event-gate.ts +45 -3
  37. package/src/index.ts +16 -2
  38. package/src/session-events.ts +9 -2
  39. package/src/version.ts +1 -1
  40. package/src/wire.ts +22 -35
package/lib/client.js CHANGED
@@ -5346,6 +5346,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5346
5346
  *
5347
5347
  * @module dsh-draw/wire
5348
5348
  */
5349
+ /**
5350
+ * Strict wire codec carrying BOTH published and checkout faces: the
5351
+ * `schema` field feeds the npm-published 0.1.5-rc.2 line, `create` feeds the
5352
+ * checkout 0.1.6-alpha.1+ line (schemas materialize lazily on first use).
5353
+ * Built through a variable, so neither typecheck ruler flags the other
5354
+ * face's field as excess.
5355
+ */
5356
+ function strictWire(typeSymbol, schema) {
5357
+ return Object.freeze({
5358
+ mode: "strict",
5359
+ typeSymbol,
5360
+ schema,
5361
+ create: () => schema
5362
+ });
5363
+ }
5349
5364
  /** Strict wire schema for {@link DrawStatusSnapshot} (zod v4, both Typert faces). */
5350
5365
  const DRAW_STATUS_SCHEMA = object({
5351
5366
  pluginVersion: string(),
@@ -5450,11 +5465,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5450
5465
  method: "status",
5451
5466
  invocation: Object.freeze({ kind: "direct" }),
5452
5467
  parameters: Object.freeze([]),
5453
- result: Object.freeze({
5454
- mode: "strict",
5455
- typeSymbol: "dsh-draw/types#DrawStatusSnapshot",
5456
- schema: DRAW_STATUS_SCHEMA
5457
- }),
5468
+ result: strictWire("dsh-draw/types#DrawStatusSnapshot", DRAW_STATUS_SCHEMA),
5458
5469
  sourceLocation: Object.freeze({
5459
5470
  file: "src/wire.ts",
5460
5471
  line: 1,
@@ -5474,17 +5485,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5474
5485
  name: "engineId",
5475
5486
  wire: "engineId",
5476
5487
  source: "json",
5477
- codec: Object.freeze({
5478
- mode: "strict",
5479
- typeSymbol: "dsh-draw/types#EngineId",
5480
- schema: ENGINE_ID_CODEC
5481
- })
5488
+ codec: strictWire("dsh-draw/types#EngineId", ENGINE_ID_CODEC)
5482
5489
  })]),
5483
- result: Object.freeze({
5484
- mode: "strict",
5485
- typeSymbol: "dsh-draw/types#DrawProbeResult",
5486
- schema: DRAW_PROBE_SCHEMA
5487
- }),
5490
+ result: strictWire("dsh-draw/types#DrawProbeResult", DRAW_PROBE_SCHEMA),
5488
5491
  sourceLocation: Object.freeze({
5489
5492
  file: "src/wire.ts",
5490
5493
  line: 1,
@@ -5506,26 +5509,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5506
5509
  name: "engineId",
5507
5510
  wire: "engineId",
5508
5511
  source: "json",
5509
- codec: Object.freeze({
5510
- mode: "strict",
5511
- typeSymbol: "dsh-draw/types#EngineId",
5512
- schema: ENGINE_ID_CODEC
5513
- })
5512
+ codec: strictWire("dsh-draw/types#EngineId", ENGINE_ID_CODEC)
5514
5513
  }), Object.freeze({
5515
5514
  name: "value",
5516
5515
  wire: "value",
5517
5516
  source: "json",
5518
- codec: Object.freeze({
5519
- mode: "strict",
5520
- typeSymbol: "dsh-draw/types#CredentialValue",
5521
- schema: CREDENTIAL_VALUE_CODEC
5522
- })
5517
+ codec: strictWire("dsh-draw/types#CredentialValue", CREDENTIAL_VALUE_CODEC)
5523
5518
  })]),
5524
- result: Object.freeze({
5525
- mode: "strict",
5526
- typeSymbol: "dsh-draw/types#CredentialActionResult",
5527
- schema: CREDENTIAL_ACTION_SCHEMA
5528
- }),
5519
+ result: strictWire("dsh-draw/types#CredentialActionResult", CREDENTIAL_ACTION_SCHEMA),
5529
5520
  sourceLocation: Object.freeze({
5530
5521
  file: "src/wire.ts",
5531
5522
  line: 1,
@@ -5545,17 +5536,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5545
5536
  name: "engineId",
5546
5537
  wire: "engineId",
5547
5538
  source: "json",
5548
- codec: Object.freeze({
5549
- mode: "strict",
5550
- typeSymbol: "dsh-draw/types#EngineId",
5551
- schema: ENGINE_ID_CODEC
5552
- })
5539
+ codec: strictWire("dsh-draw/types#EngineId", ENGINE_ID_CODEC)
5553
5540
  })]),
5554
- result: Object.freeze({
5555
- mode: "strict",
5556
- typeSymbol: "dsh-draw/types#CredentialActionResult",
5557
- schema: CREDENTIAL_ACTION_SCHEMA
5558
- }),
5541
+ result: strictWire("dsh-draw/types#CredentialActionResult", CREDENTIAL_ACTION_SCHEMA),
5559
5542
  sourceLocation: Object.freeze({
5560
5543
  file: "src/wire.ts",
5561
5544
  line: 1,
@@ -5578,26 +5561,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5578
5561
  name: "sessionId",
5579
5562
  wire: "sessionId",
5580
5563
  source: "json",
5581
- codec: Object.freeze({
5582
- mode: "strict",
5583
- typeSymbol: "dsh-draw/types#SessionId",
5584
- schema: SESSION_ID_CODEC
5585
- })
5564
+ codec: strictWire("dsh-draw/types#SessionId", SESSION_ID_CODEC)
5586
5565
  }), Object.freeze({
5587
5566
  name: "args",
5588
5567
  wire: "args",
5589
5568
  source: "json",
5590
- codec: Object.freeze({
5591
- mode: "strict",
5592
- typeSymbol: "dsh-draw/types#RegenerateArgs",
5593
- schema: REGENERATE_ARGS_CODEC
5594
- })
5569
+ codec: strictWire("dsh-draw/types#RegenerateArgs", REGENERATE_ARGS_CODEC)
5595
5570
  })]),
5596
- result: Object.freeze({
5597
- mode: "strict",
5598
- typeSymbol: "dsh-draw/types#DrawRegenerateResult",
5599
- schema: DRAW_REGENERATE_SCHEMA
5600
- }),
5571
+ result: strictWire("dsh-draw/types#DrawRegenerateResult", DRAW_REGENERATE_SCHEMA),
5601
5572
  sourceLocation: Object.freeze({
5602
5573
  file: "src/wire.ts",
5603
5574
  line: 1,
@@ -5630,12 +5601,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5630
5601
  * @module dsh-draw/client/styles
5631
5602
  */
5632
5603
  const STYLE_ID = "dsh-draw-client-styles";
5604
+ /**
5605
+ * Live installs of this stylesheet. The sheet is shared by every mount of the
5606
+ * browser half, so ownership is counted: the node stays as long as any mount
5607
+ * is alive, and the LAST disposer removes the node this module inserted.
5608
+ * Removing it on the first unmount (or never removing it) is what produced the
5609
+ * styles-lost window and the leaked node respectively.
5610
+ */
5611
+ let liveInstalls = 0;
5633
5612
  /** Install the scoped stylesheet once; returns the removal disposer. */
5634
5613
  function installDrawStyles() {
5635
- if (document.getElementById(STYLE_ID) !== null) return () => void 0;
5636
- const style = document.createElement("style");
5637
- style.id = STYLE_ID;
5638
- style.textContent = `
5614
+ liveInstalls += 1;
5615
+ if (document.getElementById(STYLE_ID) === null) {
5616
+ const style = document.createElement("style");
5617
+ style.id = STYLE_ID;
5618
+ style.textContent = `
5639
5619
  .dshdraw-card { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
5640
5620
  .dshdraw-grid { display: flex; flex-wrap: wrap; gap: 8px; }
5641
5621
  .dshdraw-figure { display: flex; flex-direction: column; gap: 4px; max-width: 320px; }
@@ -5658,9 +5638,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5658
5638
  .dshdraw-badge.warn { color: #9a6700; border-color: #9a6700; }
5659
5639
  .dshdraw-input { flex: 1; min-width: 180px; border: 1px solid var(--dsh-border, #d0d7de); border-radius: 6px; padding: 4px 8px; font-size: 12px; background: transparent; color: inherit; }
5660
5640
  `;
5661
- document.head.append(style);
5641
+ document.head.append(style);
5642
+ }
5643
+ let disposed = false;
5662
5644
  return () => {
5663
- style.remove();
5645
+ if (disposed) return;
5646
+ disposed = true;
5647
+ liveInstalls -= 1;
5648
+ if (liveInstalls <= 0) {
5649
+ liveInstalls = 0;
5650
+ document.getElementById(STYLE_ID)?.remove();
5651
+ }
5664
5652
  };
5665
5653
  }
5666
5654
  //#endregion
@@ -5728,8 +5716,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5728
5716
  });
5729
5717
  }
5730
5718
  /**
5731
- * Read the current session id from the sessions store face (structural:
5732
- * the store shape differs across harness lines, so only the leaf is read).
5719
+ * Read the current session id from the sessions store face (structural: the
5720
+ * store shape differs across harness lines, so only the leaves are read).
5721
+ *
5722
+ * On the 0.1.6 line `SessionListState.current` no longer exists, so the card's
5723
+ * regenerate belongs to the session the main view retains: pick the listed
5724
+ * session whose `retainedBy.mainView` is set — the same rule the upstream
5725
+ * session store applies when it resolves its main binding. Without a retained
5726
+ * session the guard returns undefined and the caller reports it instead of
5727
+ * regenerating against an unknown session.
5733
5728
  */
5734
5729
  function currentSessionId(sessions) {
5735
5730
  try {
@@ -5737,8 +5732,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5737
5732
  if (typeof list !== "object" || list === null) return void 0;
5738
5733
  const getSnapshot = list.getSnapshot;
5739
5734
  if (typeof getSnapshot !== "function") return void 0;
5740
- const current = getSnapshot().current;
5741
- return typeof current === "string" ? current : void 0;
5735
+ const byId = getSnapshot().byId;
5736
+ if (typeof byId !== "object" || byId === null) return void 0;
5737
+ for (const candidate of Object.values(byId)) {
5738
+ if (typeof candidate !== "object" || candidate === null) continue;
5739
+ const retained = candidate.retainedBy;
5740
+ const mainView = typeof retained?.mainView === "number" ? retained.mainView : 0;
5741
+ const id = candidate.id;
5742
+ if (mainView > 0 && typeof id === "string") return id;
5743
+ }
5744
+ return;
5742
5745
  } catch {
5743
5746
  return;
5744
5747
  }
@@ -5746,6 +5749,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5746
5749
  //#endregion
5747
5750
  exports.NS = NS;
5748
5751
  exports.apply = apply;
5752
+ exports.currentSessionId = currentSessionId;
5749
5753
  exports.inject = inject;
5750
5754
  exports.name = name;
5751
5755
  exports.presentDrawPanel = presentDrawPanel;