@jiezhengj/dsh-dyslexia 0.1.1 → 0.1.2

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/client.js +19 -6
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @jiezhengj/dsh-dyslexia 0.1.0 | MIT | bundles Pele 1.13.0 (MIT, see THIRD-PARTY-NOTICES.md) */
1
+ /*! @jiezhengj/dsh-dyslexia 0.1.2 | MIT | bundles Pele 1.13.0 (MIT, see THIRD-PARTY-NOTICES.md) */
2
2
  ;(function () {
3
3
  function reportLoadFailure(scope, error) {
4
4
  try { console.error('dsh-dyslexia: ' + scope, error) } catch (_error) {}
@@ -407,10 +407,23 @@ function makeFallbackTranslate(doc) {
407
407
  }
408
408
 
409
409
  /**
410
- * A host `t` is used when it answers with a string and its signature still
411
- * matches; anything else — a changed signature, a throw, an empty answer —
412
- * falls back to the strings shipped here, so a picture is never lost over a
413
- * label.
410
+ * A host answer counts only when it is a real translation: a non-empty string
411
+ * that is not the key echoed back and that no longer carries an unfilled
412
+ * placeholder. A host that has not registered this plugin's namespace answers
413
+ * with the key itself, which is how a bare `copySource` once reached a screen.
414
+ */
415
+ function isResolved(value, key) {
416
+ if (typeof value !== 'string' || value.length === 0) return false
417
+ if (value.indexOf(key) !== -1) return false
418
+ return value.indexOf('{{') === -1
419
+ }
420
+
421
+ /**
422
+ * A host `t` is used when it answers with a real translation and its signature
423
+ * still matches; anything else — a changed signature, a throw, an empty answer,
424
+ * the key echoed back, an unfilled placeholder — falls back to the strings
425
+ * shipped here, so a picture is never lost over a label and no internal key is
426
+ * ever shown.
414
427
  */
415
428
  function translateFor(props, doc) {
416
429
  const fallback = makeFallbackTranslate(doc)
@@ -419,7 +432,7 @@ function translateFor(props, doc) {
419
432
  return function translate(key, values) {
420
433
  try {
421
434
  const value = hostTranslate(key, values)
422
- if (typeof value === 'string' && value.length > 0) return value
435
+ if (isResolved(value, key)) return value
423
436
  } catch (error) {
424
437
  void error
425
438
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiezhengj/dsh-dyslexia",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Draws mermaid code blocks in DeepSeek Harness conversations as diagrams, in place in the message.",
5
5
  "keywords": [
6
6
  "dsh",