ntk 7.7.0 → 8.0.0

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/README.md CHANGED
@@ -53,18 +53,17 @@ rasterizer and cached server-side as XRender glyphs, so drawing a line of
53
53
  text costs about a byte per glyph on the wire. Font names resolve through
54
54
  fontconfig (`fc-match`). Very large and continuously animated sizes render
55
55
  as server-side trapezoids instead of cached bitmaps. A `TextLayout` engine
56
- wraps styled text to a target width, a `MarkdownView` widget renders
57
- markdown (with syntax-highlighted code fences and KaTeX math via
58
- `TexView`) on top of it — see [docs/text.md](docs/text.md) and
59
- [docs/tex.md](docs/tex.md).
56
+ wraps styled text to a target width — see [docs/text.md](docs/text.md).
60
57
 
61
58
  PNG/JPEG images decode client-side (`loadImage`) and composite server-side
62
- via `ctx.drawImage` ([docs/images.md](docs/images.md)). An `HtmlView`
63
- widget renders a static HTML + CSS subset — block flow and flexbox laid
64
- out by yoga-layout, no scripts, no network — with app-controlled link
65
- navigation ([docs/html.md](docs/html.md)). An `SvgView` widget renders
66
- static SVG (shapes, gradients, transforms, `use`) through the same 2d
67
- pipeline ([docs/svg.md](docs/svg.md)).
59
+ via `ctx.drawImage` ([docs/images.md](docs/images.md)). An `SvgView` widget
60
+ renders static SVG (shapes, gradients, transforms, `use`) through the same
61
+ 2d pipeline ([docs/svg.md](docs/svg.md)).
62
+
63
+ Rendering documents — markdown, formulas, rich text — is not ntk's job:
64
+ it draws, and a document is a tree of layout decisions on top of that.
65
+ [`@react-x11/components`](https://github.com/sidorares/react-x11-components)
66
+ is where those live, over the react-x11 renderer.
68
67
 
69
68
  ```js
70
69
  import { createClient } from 'ntk';
package/lib/index.js CHANGED
@@ -16,7 +16,6 @@ import {
16
16
  encodeXEmbedInfo,
17
17
  readXEmbedInfo
18
18
  } from './xembed.js';
19
- import { loadLayout } from './yoga.js';
20
19
  import { decodeKey, groupForState } from './keyboard.js';
21
20
  import Pixmap from './pixmap.js';
22
21
  import Picture from './picture.js';
@@ -50,13 +49,8 @@ import {
50
49
  import { DEFAULT_MASK_POLICY } from './maskcluster.js';
51
50
  import { DEFAULT_SHAPE_POLICY } from './shapeglyphs.js';
52
51
  import { TextLayout } from './text/layout.js';
53
- import HtmlView from './widgets/htmlview.js';
54
52
  import SvgView from './widgets/svgview.js';
55
- import MarkdownView from './widgets/markdownview.js';
56
- import TexView, { configureTex, layoutTex, TexBox } from './widgets/tex.js';
57
- import { tokenize as highlightCode } from './widgets/highlight.js';
58
- import { cssColorStraight, premultiply } from './color.js';
59
- import { cssColor, cssLength } from './widgets/css.js';
53
+ import { cssColor, cssColorStraight, premultiply } from './color.js';
60
54
 
61
55
  // rendering context modules register themselves on Drawable. The direct one
62
56
  // comes last on purpose: it wraps the 'opengl' factory the indirect one just
@@ -116,11 +110,7 @@ export function createClient(options, callback) {
116
110
  const x11Options = { ...(options || {}) };
117
111
  if (x11Options.bufferRequests === undefined) x11Options.bufferRequests = DEFAULT_BUFFER_REQUESTS;
118
112
 
119
- // the layout engine's WASM loads alongside the connection, so widgets are
120
- // usable synchronously by the time the App exists (see lib/yoga.js)
121
- const layout = loadLayout();
122
-
123
- const connecting = new Promise((resolve, reject) => {
113
+ const promise = new Promise((resolve, reject) => {
124
114
  // Resolve the font spec here rather than lazily in `app.fonts`, so a
125
115
  // missing directory is a rejected connect instead of a surprise inside
126
116
  // the first paint. Inside the executor so it rejects rather than throws
@@ -206,8 +196,6 @@ export function createClient(options, callback) {
206
196
  });
207
197
  });
208
198
 
209
- const promise = Promise.all([connecting, layout]).then(([app]) => app);
210
-
211
199
  if (callback) {
212
200
  promise.then(
213
201
  (app) => callback(null, app),
@@ -268,18 +256,10 @@ export {
268
256
  DEFAULT_MASK_POLICY,
269
257
  DEFAULT_SHAPE_POLICY,
270
258
  TextLayout,
271
- HtmlView,
272
259
  SvgView,
273
- MarkdownView,
274
- TexView,
275
- TexBox,
276
- layoutTex,
277
- configureTex,
278
- highlightCode,
279
260
  cssColor,
280
261
  cssColorStraight,
281
262
  premultiply,
282
- cssLength,
283
263
  decodeKey,
284
264
  groupForState,
285
265
  // the `code` on a failed GL setup: branch on it rather than on the message
@@ -289,11 +269,4 @@ export {
289
269
  GL_MODES,
290
270
  DEFAULT_GL_POLICY
291
271
  };
292
- // The layout engine ntk lays HtmlView out with — downstream layout consumers
293
- // (e.g. the react-x11 renderer) must import it from here rather than from
294
- // `yoga-layout`, or they get a second WASM instance whose Nodes cannot be
295
- // mixed with ntk's. Its enum constants are readable as soon as ntk is
296
- // imported; `Node`/`Config` need the WASM, which `createClient()` loads —
297
- // `loadLayout()` is there for widgets used without an App.
298
- export { default as Yoga, loadLayout, layoutLoaded } from './yoga.js';
299
272
  export default { createClient };
@@ -51,10 +51,10 @@ export class TextLayout {
51
51
  const maxWidth = options.maxWidth ?? Infinity;
52
52
 
53
53
  // ---- normalize spans, resolve fonts eagerly ----
54
- // unknown span fields ride along untouched (widgets attach markers like
55
- // MarkdownView's _deco/_href and read them back from line runs)
56
- // An empty span list is a legitimate thing to lay out — MarkdownView
57
- // reaches it for a blank paragraph while a document is being typed —
54
+ // unknown span fields ride along untouched, so a caller can attach its
55
+ // own markers to a span and read them back off the line runs
56
+ // An empty span list is a legitimate thing to lay out — a document view
57
+ // reaches it for a blank paragraph while one is being typed —
58
58
  // and every line still needs a style to take its metrics from, so
59
59
  // stand one in rather than crashing on the first empty line.
60
60
  const given = typeof content === 'string' ? [{ text: content }] : content;
@@ -9,7 +9,7 @@
9
9
  // view.setSvg('<svg viewBox="0 0 24 24">…</svg>');
10
10
  // wnd.map();
11
11
  //
12
- // Standalone (windowless) use mirrors HtmlView/MarkdownView:
12
+ // Standalone (windowless) use, which is how a document renderer drives it:
13
13
  // const view = new SvgView(null);
14
14
  // view.setSvg(svgText);
15
15
  // view.draw(ctx, x, y, width, height);
@@ -59,7 +59,7 @@ const STYLE_ATTRS = {
59
59
  const NUMERIC = new Set(['strokeWidth', 'miterLimit', 'fillOpacity', 'strokeOpacity', 'fontSize']);
60
60
 
61
61
  // documents may come from an XML parse (setSvg: exact case) or from an HTML
62
- // parse (HtmlView inline <svg>: tag/attribute names lowercased) — compare
62
+ // parse (inline <svg>: tag/attribute names lowercased) — compare
63
63
  // names lowercased and look attributes up by their lowercase form too
64
64
  const tag = (node) => (node.name || '').toLowerCase();
65
65
 
@@ -342,8 +342,9 @@ export default class SvgView {
342
342
  }
343
343
 
344
344
  /**
345
- * Adopt an already-parsed `<svg>` element (htmlparser2 DOM node) — used
346
- * by HtmlView for inline SVG. HTML-mode parses (lowercased tag/attribute
345
+ * Adopt an already-parsed `<svg>` element (htmlparser2 DOM node) — how a
346
+ * host document hands over its inline SVG, and how react-x11's `<svg>`
347
+ * element passes JSX children. HTML-mode parses (lowercased tag/attribute
347
348
  * names) are handled.
348
349
  */
349
350
  setSvgDom(element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ntk",
3
- "version": "7.7.0",
3
+ "version": "8.0.0",
4
4
  "description": "Desktop UI toolkit for X11 with canvas-like 2d and OpenGL rendering",
5
5
  "author": "Andrey Sidorov <sidorares@yandex.ru>",
6
6
  "license": "MIT",
@@ -36,21 +36,15 @@
36
36
  "dependencies": {
37
37
  "bidi-js": "^1.0.3",
38
38
  "canvas-fontstyle": "^1.0.1",
39
- "css-select": "^7.0.0",
40
39
  "domutils": "^4.0.2",
41
40
  "extrude-polyline": "^1.0.6",
42
41
  "fontkit": "^2.0.4",
43
- "highlight.js": "^11.11.1",
44
42
  "htmlparser2": "^12.0.0",
45
43
  "jpeg-js": "^0.4.4",
46
- "katex": "^0.18.1",
47
44
  "linebreak": "^1.1.0",
48
- "marked": "^18.0.7",
49
45
  "parse-color": "^1.0.0",
50
46
  "pngjs": "^7.0.0",
51
- "postcss": "^8.5.23",
52
- "x11": "^3.9.0",
53
- "yoga-layout": "^3.2.1"
47
+ "x11": "^3.9.0"
54
48
  },
55
49
  "optionalDependencies": {
56
50
  "x11-dri": ">=0.2.0 <1"
@@ -60,6 +54,7 @@
60
54
  "check-release-message": "node scripts/check-release-message.mjs"
61
55
  },
62
56
  "devDependencies": {
63
- "@conventional-commits/parser": "^0.4.1"
57
+ "@conventional-commits/parser": "^0.4.1",
58
+ "katex": "^0.18.1"
64
59
  }
65
60
  }