tsquare 0.12.0 → 0.12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.2
4
+
5
+ The language and the renderer haven't changed: every wireframe renders exactly as in 0.12.1, and render URLs give the same images.
6
+
7
+ - **Loads in Docusaurus:** Docusaurus loads its config, and the remark plugins in it, through jiti 1, which turned `import { z } from "zod"` into `undefined`, so importing tsquare there failed with "Cannot read properties of undefined (reading 'enum')". tsquare now imports zod as `import * as z from "zod"` (the form zod recommends), and a test loads the build through jiti 1.
8
+
9
+ ## 0.12.1
10
+
11
+ The language and the renderer haven't changed: every wireframe renders exactly as in 0.12.0, and render URLs give the same images.
12
+
13
+ - **`tsquare/editor` can wrap long lines:** `lineWrapping: true` wraps instead of scrolling sideways, with each wrapped line's continuation rows indented 4 spaces past its own indentation (2 would look like a child element). Off by default, so the playground is unchanged; `@tsquare-js/react` turns it on, because its editors are often narrow.
14
+
3
15
  ## 0.12.0
4
16
 
5
17
  The language and the renderer haven't changed: every wireframe renders exactly as in 0.11.0, and render URLs give the same images.
package/README.md CHANGED
@@ -145,7 +145,7 @@ const editor = createEditor(document.getElementById("code")!, {
145
145
  });
146
146
  ```
147
147
 
148
- Give the element a height; the editor fills it. Options: `doc`, `data`, `onChange`, `lineNumbers` (default `true`) and `ariaLabel` (default "Wireframe text"). The editor has `getText()`, `setText(text)` (one undoable step), `setIssues(issues)`, `goToLine(n)`, `focus()`, `dom` and `destroy()`.
148
+ Give the element a height; the editor fills it. Options: `doc`, `data`, `onChange`, `lineNumbers` (default `true`), `lineWrapping` (default `false`: wrap long lines instead of scrolling sideways, continuation rows indented 4 spaces past their line's indentation, so they don't look like a child element) and `ariaLabel` (default "Wireframe text"). The editor has `getText()`, `setText(text)` (one undoable step), `setIssues(issues)`, `goToLine(n)`, `focus()`, `dom` and `destroy()`.
149
149
 
150
150
  Its colors are CSS variables, light or dark by the page's `color-scheme`, defaulting to the playground's:
151
151
 
@@ -308,16 +308,16 @@ var require_swap = __commonJS({
308
308
  b[n] = b[m2];
309
309
  b[m2] = i2;
310
310
  };
311
- var swap32 = (array) => {
312
- const len = array.length;
311
+ var swap32 = (array3) => {
312
+ const len = array3.length;
313
313
  for (let i2 = 0; i2 < len; i2 += 4) {
314
- swap(array, i2, i2 + 3);
315
- swap(array, i2 + 1, i2 + 2);
314
+ swap(array3, i2, i2 + 3);
315
+ swap(array3, i2 + 1, i2 + 2);
316
316
  }
317
317
  };
318
- var swap32LE = (array) => {
318
+ var swap32LE = (array3) => {
319
319
  if (isBigEndian) {
320
- swap32(array);
320
+ swap32(array3);
321
321
  }
322
322
  };
323
323
  module.exports = {
@@ -2112,8 +2112,8 @@ var require_escape_html = __commonJS({
2112
2112
  "use strict";
2113
2113
  var matchHtmlRegExp = /["'&<>]/;
2114
2114
  module.exports = escapeHtml;
2115
- function escapeHtml(string) {
2116
- var str = "" + string;
2115
+ function escapeHtml(string3) {
2116
+ var str = "" + string3;
2117
2117
  var match = matchHtmlRegExp.exec(str);
2118
2118
  if (!match) {
2119
2119
  return str;
@@ -3481,8 +3481,8 @@ var $557adaaeb0c7885f$var$LineBreaker = class {
3481
3481
  }
3482
3482
  return null;
3483
3483
  }
3484
- constructor(string) {
3485
- this.string = string;
3484
+ constructor(string3) {
3485
+ this.string = string3;
3486
3486
  this.pos = 0;
3487
3487
  this.lastPos = 0;
3488
3488
  this.curClass = null;
@@ -6053,12 +6053,12 @@ Parser.prototype.parseFixed = function() {
6053
6053
  Parser.prototype.parseString = function(length) {
6054
6054
  var dataView = this.data;
6055
6055
  var offset = this.offset + this.relativeOffset;
6056
- var string = "";
6056
+ var string3 = "";
6057
6057
  this.relativeOffset += length;
6058
6058
  for (var i2 = 0; i2 < length; i2++) {
6059
- string += String.fromCharCode(dataView.getUint8(offset + i2));
6059
+ string3 += String.fromCharCode(dataView.getUint8(offset + i2));
6060
6060
  }
6061
- return string;
6061
+ return string3;
6062
6062
  };
6063
6063
  Parser.prototype.parseTag = function() {
6064
6064
  return this.parseString(4);
@@ -19953,7 +19953,7 @@ async function renderToSvg(spec, options = {}) {
19953
19953
 
19954
19954
  // src/catalog.ts
19955
19955
  import { defineCatalog } from "@json-render/core";
19956
- import { z } from "zod";
19956
+ import * as z from "zod";
19957
19957
 
19958
19958
  // src/layout.ts
19959
19959
  var theme = {
@@ -23264,7 +23264,7 @@ function decodeWireframe(data) {
23264
23264
  }
23265
23265
 
23266
23266
  // src/mcp.ts
23267
- import { z as z2 } from "zod";
23267
+ import * as z2 from "zod";
23268
23268
 
23269
23269
  // src/escape.ts
23270
23270
  var escapeAttr = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/[\r\n]+/g, " ");
package/dist/catalog.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  /**
3
3
  * Props every element except Board and Screen accepts, on top of its own. Kept out of each
4
4
  * component's schema so the prompt describes them once.
@@ -6,7 +6,7 @@ import {
6
6
  componentDefinitions,
7
7
  iconNames,
8
8
  takesUniversalProps
9
- } from "./chunk-EY7YIRMK.js";
9
+ } from "./chunk-WRN5ADPR.js";
10
10
 
11
11
  // src/playground/language-data.ts
12
12
  function unwrap(t) {
@@ -51,7 +51,7 @@ function estimateNoteHeight(text, width) {
51
51
 
52
52
  // src/catalog.ts
53
53
  import { defineCatalog } from "@json-render/core";
54
- import { z } from "zod";
54
+ import * as z from "zod";
55
55
 
56
56
  // src/suggest.ts
57
57
  function editDistance(a, b) {
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  printWireframeText,
7
7
  renderWireframe,
8
8
  wireframePrompt
9
- } from "./chunks/chunk-EY7YIRMK.js";
9
+ } from "./chunks/chunk-WRN5ADPR.js";
10
10
 
11
11
  // src/cli.ts
12
12
  import { readFile, writeFile } from "node:fs/promises";
package/dist/editor.js CHANGED
@@ -9434,9 +9434,9 @@ var LineGap = class {
9434
9434
  }
9435
9435
  return true;
9436
9436
  }
9437
- draw(viewState, wrapping) {
9437
+ draw(viewState, wrapping2) {
9438
9438
  return Decoration.replace({
9439
- widget: new LineGapWidget(this.displaySize * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)
9439
+ widget: new LineGapWidget(this.displaySize * (wrapping2 ? viewState.scaleY : viewState.scaleX), wrapping2)
9440
9440
  }).range(this.from, this.to);
9441
9441
  }
9442
9442
  };
@@ -9732,9 +9732,9 @@ var ViewState = class {
9732
9732
  // predictable. Relies on generous margins (see LG.Margin) to hide
9733
9733
  // the artifacts this might produce from the user.
9734
9734
  ensureLineGaps(current, mayMeasure) {
9735
- let wrapping = this.heightOracle.lineWrapping;
9736
- let margin = wrapping ? 1e4 : 2e3, halfMargin = margin >> 1, doubleMargin = margin << 1;
9737
- if (this.defaultTextDirection != Direction.LTR && !wrapping)
9735
+ let wrapping2 = this.heightOracle.lineWrapping;
9736
+ let margin = wrapping2 ? 1e4 : 2e3, halfMargin = margin >> 1, doubleMargin = margin << 1;
9737
+ if (this.defaultTextDirection != Direction.LTR && !wrapping2)
9738
9738
  return [];
9739
9739
  let gaps = [];
9740
9740
  let addGap = (from, to, line, structure) => {
@@ -9752,13 +9752,13 @@ var ViewState = class {
9752
9752
  }
9753
9753
  let gap = find(current, (gap2) => gap2.from >= line.from && gap2.to <= line.to && Math.abs(gap2.from - from) < halfMargin && Math.abs(gap2.to - to) < halfMargin && !avoid.some((pos) => gap2.from < pos && gap2.to > pos));
9754
9754
  if (!gap) {
9755
- if (to < line.to && mayMeasure && wrapping && mayMeasure.visibleRanges.some((r) => r.from <= to && r.to >= to)) {
9755
+ if (to < line.to && mayMeasure && wrapping2 && mayMeasure.visibleRanges.some((r) => r.from <= to && r.to >= to)) {
9756
9756
  let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;
9757
9757
  if (lineStart > from)
9758
9758
  to = lineStart;
9759
9759
  }
9760
9760
  let size = this.gapSize(line, from, to, structure);
9761
- let displaySize = wrapping || size < 2e6 ? size : 2e6;
9761
+ let displaySize = wrapping2 || size < 2e6 ? size : 2e6;
9762
9762
  gap = new LineGap(from, to, size, displaySize);
9763
9763
  }
9764
9764
  gaps.push(gap);
@@ -9771,7 +9771,7 @@ var ViewState = class {
9771
9771
  return;
9772
9772
  let target = this.scrollTarget ? this.scrollTarget.range.head : null;
9773
9773
  let viewFrom, viewTo;
9774
- if (wrapping) {
9774
+ if (wrapping2) {
9775
9775
  let marginHeight = margin / this.heightOracle.lineLength * this.heightOracle.lineHeight;
9776
9776
  let top2, bot;
9777
9777
  if (target != null) {
@@ -22575,6 +22575,32 @@ var pasteFencedBlock = EditorView.domEventHandlers({
22575
22575
  return true;
22576
22576
  }
22577
22577
  });
22578
+ var CONTINUATION = 4;
22579
+ var hangingIndent = ViewPlugin.fromClass(
22580
+ class {
22581
+ decorations;
22582
+ constructor(view) {
22583
+ this.decorations = this.build(view);
22584
+ }
22585
+ update(u) {
22586
+ if (u.docChanged || u.viewportChanged) this.decorations = this.build(u.view);
22587
+ }
22588
+ build(view) {
22589
+ const builder = new RangeSetBuilder();
22590
+ for (const { from, to } of view.visibleRanges) {
22591
+ for (let pos = from; pos <= to; ) {
22592
+ const line = view.state.doc.lineAt(pos);
22593
+ const indent = line.text.match(/^ */)[0].length;
22594
+ builder.add(line.from, line.from, Decoration.line({ attributes: { style: `padding-left: calc(6px + ${indent + CONTINUATION}ch); text-indent: -${indent + CONTINUATION}ch` } }));
22595
+ pos = line.to + 1;
22596
+ }
22597
+ }
22598
+ return builder.finish();
22599
+ }
22600
+ },
22601
+ { decorations: (p) => p.decorations }
22602
+ );
22603
+ var wrapping = [EditorView.lineWrapping, hangingIndent];
22578
22604
  function createEditor(parent, opts = {}) {
22579
22605
  const extensions = [
22580
22606
  opts.lineNumbers === false ? [] : [lineNumbers(), highlightActiveLineGutter()],
@@ -22592,6 +22618,7 @@ function createEditor(parent, opts = {}) {
22592
22618
  keymap.of([{ key: "Enter", run: newlineKeepIndent }, ...closeBracketsKeymap, ...completionKeymap, ...searchKeymap, ...historyKeymap, indentWithTab, ...defaultKeymap]),
22593
22619
  theme2,
22594
22620
  pasteFencedBlock,
22621
+ opts.lineWrapping ? wrapping : [],
22595
22622
  EditorView.contentAttributes.of({ "aria-label": opts.ariaLabel ?? "Wireframe text", spellcheck: "false", autocapitalize: "off" }),
22596
22623
  EditorView.updateListener.of((u) => {
22597
22624
  if (u.docChanged) opts.onChange?.(u.state.doc.toString());
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  languageData
3
- } from "./chunks/chunk-QWQT7224.js";
3
+ } from "./chunks/chunk-NYVFYSZ6.js";
4
4
  import {
5
5
  DEVICES,
6
6
  RENAMED_PROPS,
@@ -24,7 +24,7 @@ import {
24
24
  upgradeSpec,
25
25
  upgradeWireframe,
26
26
  wireframePrompt
27
- } from "./chunks/chunk-EY7YIRMK.js";
27
+ } from "./chunks/chunk-WRN5ADPR.js";
28
28
 
29
29
  // src/deflate.ts
30
30
  import { deflateRawSync, inflateRawSync } from "node:zlib";
@@ -49,7 +49,7 @@ function decodeWireframe(data) {
49
49
  }
50
50
 
51
51
  // src/mcp.ts
52
- import { z } from "zod";
52
+ import * as z from "zod";
53
53
 
54
54
  // src/escape.ts
55
55
  var escapeAttr = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/[\r\n]+/g, " ");
package/dist/mcp.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * Problems come back as a result with isError, not a thrown error, so the model reads them and fixes
7
7
  * its text: the messages are the same line-numbered ones `tsquare check` prints.
8
8
  */
9
- import { z } from "zod";
9
+ import * as z from "zod";
10
10
  export type ToolContent = {
11
11
  type: "text";
12
12
  text: string;
@@ -8,6 +8,8 @@ export interface EditorOptions {
8
8
  onChange?: (text: string) => void;
9
9
  /** Line numbers in a gutter. Default true. */
10
10
  lineNumbers?: boolean;
11
+ /** Wrap long lines instead of scrolling sideways; continuation rows are indented under their line. Default false. */
12
+ lineWrapping?: boolean;
11
13
  /** The editable area's accessible name. Default "Wireframe text". */
12
14
  ariaLabel?: string;
13
15
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  languageData
3
- } from "../chunks/chunk-QWQT7224.js";
3
+ } from "../chunks/chunk-NYVFYSZ6.js";
4
4
  import {
5
5
  boardLayout,
6
6
  compileWireframe,
@@ -9,7 +9,7 @@ import {
9
9
  renderWireframePng,
10
10
  renderWireframeSvg,
11
11
  wireframePrompt
12
- } from "../chunks/chunk-EY7YIRMK.js";
12
+ } from "../chunks/chunk-WRN5ADPR.js";
13
13
 
14
14
  // src/playground/index.ts
15
15
  import { createServer } from "node:http";