@react-x11/components 0.3.0 → 0.5.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 +131 -4
- package/dist/charts/components.d.ts +3 -1
- package/dist/charts/components.d.ts.map +1 -1
- package/dist/charts/components.js +8 -4
- package/dist/charts/components.js.map +1 -1
- package/dist/charts/node.d.ts +13 -6
- package/dist/charts/node.d.ts.map +1 -1
- package/dist/charts/node.js +75 -24
- package/dist/charts/node.js.map +1 -1
- package/dist/charts/render.d.ts +4 -0
- package/dist/charts/render.d.ts.map +1 -1
- package/dist/charts/render.js +11 -6
- package/dist/charts/render.js.map +1 -1
- package/dist/code-editor/node.d.ts +47 -16
- package/dist/code-editor/node.d.ts.map +1 -1
- package/dist/code-editor/node.js +121 -51
- package/dist/code-editor/node.js.map +1 -1
- package/dist/flow/draw.d.ts +19 -1
- package/dist/flow/draw.d.ts.map +1 -1
- package/dist/flow/draw.js +64 -35
- package/dist/flow/draw.js.map +1 -1
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +24 -8
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/model.d.ts +4 -2
- package/dist/flow/model.d.ts.map +1 -1
- package/dist/flow/model.js +4 -2
- package/dist/flow/model.js.map +1 -1
- package/dist/flow/node.d.ts +40 -9
- package/dist/flow/node.d.ts.map +1 -1
- package/dist/flow/node.js +142 -53
- package/dist/flow/node.js.map +1 -1
- package/dist/flow/types.d.ts +46 -21
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/formula/index.d.ts +4 -2
- package/dist/formula/index.d.ts.map +1 -1
- package/dist/formula/index.js.map +1 -1
- package/dist/formula/node.d.ts +5 -1
- package/dist/formula/node.d.ts.map +1 -1
- package/dist/formula/node.js +19 -3
- package/dist/formula/node.js.map +1 -1
- package/dist/html/controls.d.ts +4 -1
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/cascade.d.ts +11 -5
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +18 -8
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/parse.d.ts +15 -10
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +41 -16
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +3 -0
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +3 -1
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/values.d.ts +14 -1
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +11 -8
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +1 -0
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +12 -5
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +7 -4
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +22 -1
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/node.d.ts +22 -8
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +97 -15
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +3 -0
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +2 -2
- package/dist/html/paint.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/maps/clip.d.ts +43 -0
- package/dist/maps/clip.d.ts.map +1 -0
- package/dist/maps/clip.js +171 -0
- package/dist/maps/clip.js.map +1 -0
- package/dist/maps/gzip.d.ts +15 -0
- package/dist/maps/gzip.d.ts.map +1 -0
- package/dist/maps/gzip.js +56 -0
- package/dist/maps/gzip.js.map +1 -0
- package/dist/maps/index.d.ts +55 -0
- package/dist/maps/index.d.ts.map +1 -0
- package/dist/maps/index.js +141 -0
- package/dist/maps/index.js.map +1 -0
- package/dist/maps/labels.d.ts +123 -0
- package/dist/maps/labels.d.ts.map +1 -0
- package/dist/maps/labels.js +323 -0
- package/dist/maps/labels.js.map +1 -0
- package/dist/maps/mvt.d.ts +244 -0
- package/dist/maps/mvt.d.ts.map +1 -0
- package/dist/maps/mvt.js +820 -0
- package/dist/maps/mvt.js.map +1 -0
- package/dist/maps/node.d.ts +278 -0
- package/dist/maps/node.d.ts.map +1 -0
- package/dist/maps/node.js +1459 -0
- package/dist/maps/node.js.map +1 -0
- package/dist/maps/overlay.d.ts +157 -0
- package/dist/maps/overlay.d.ts.map +1 -0
- package/dist/maps/overlay.js +472 -0
- package/dist/maps/overlay.js.map +1 -0
- package/dist/maps/paint.d.ts +226 -0
- package/dist/maps/paint.d.ts.map +1 -0
- package/dist/maps/paint.js +705 -0
- package/dist/maps/paint.js.map +1 -0
- package/dist/maps/proj.d.ts +281 -0
- package/dist/maps/proj.d.ts.map +1 -0
- package/dist/maps/proj.js +451 -0
- package/dist/maps/proj.js.map +1 -0
- package/dist/maps/sources.d.ts +256 -0
- package/dist/maps/sources.d.ts.map +1 -0
- package/dist/maps/sources.js +210 -0
- package/dist/maps/sources.js.map +1 -0
- package/dist/maps/style.d.ts +141 -0
- package/dist/maps/style.d.ts.map +1 -0
- package/dist/maps/style.js +147 -0
- package/dist/maps/style.js.map +1 -0
- package/dist/maps/styles.d.ts +82 -0
- package/dist/maps/styles.d.ts.map +1 -0
- package/dist/maps/styles.js +898 -0
- package/dist/maps/styles.js.map +1 -0
- package/dist/maps/tiles.d.ts +283 -0
- package/dist/maps/tiles.d.ts.map +1 -0
- package/dist/maps/tiles.js +469 -0
- package/dist/maps/tiles.js.map +1 -0
- package/dist/maps/types.d.ts +244 -0
- package/dist/maps/types.d.ts.map +1 -0
- package/dist/maps/types.js +2 -0
- package/dist/maps/types.js.map +1 -0
- package/dist/qml/containers.d.ts +3 -0
- package/dist/qml/containers.d.ts.map +1 -0
- package/dist/qml/containers.js +331 -0
- package/dist/qml/containers.js.map +1 -0
- package/dist/qml/controls.d.ts +12 -0
- package/dist/qml/controls.d.ts.map +1 -0
- package/dist/qml/controls.js +21 -0
- package/dist/qml/controls.js.map +1 -0
- package/dist/qml/globals.d.ts +6 -0
- package/dist/qml/globals.d.ts.map +1 -0
- package/dist/qml/globals.js +25 -0
- package/dist/qml/globals.js.map +1 -0
- package/dist/qml/index.d.ts +15 -0
- package/dist/qml/index.d.ts.map +1 -0
- package/dist/qml/index.js +25 -0
- package/dist/qml/index.js.map +1 -0
- package/dist/qml/interaction.d.ts +12 -0
- package/dist/qml/interaction.d.ts.map +1 -0
- package/dist/qml/interaction.js +246 -0
- package/dist/qml/interaction.js.map +1 -0
- package/dist/qml/ir.d.ts +106 -0
- package/dist/qml/ir.d.ts.map +1 -0
- package/dist/qml/ir.js +7 -0
- package/dist/qml/ir.js.map +1 -0
- package/dist/qml/layouts.d.ts +3 -0
- package/dist/qml/layouts.d.ts.map +1 -0
- package/dist/qml/layouts.js +122 -0
- package/dist/qml/layouts.js.map +1 -0
- package/dist/qml/models.d.ts +14 -0
- package/dist/qml/models.d.ts.map +1 -0
- package/dist/qml/models.js +80 -0
- package/dist/qml/models.js.map +1 -0
- package/dist/qml/objects.d.ts +228 -0
- package/dist/qml/objects.d.ts.map +1 -0
- package/dist/qml/objects.js +1103 -0
- package/dist/qml/objects.js.map +1 -0
- package/dist/qml/parse.d.ts +10 -0
- package/dist/qml/parse.d.ts.map +1 -0
- package/dist/qml/parse.js +607 -0
- package/dist/qml/parse.js.map +1 -0
- package/dist/qml/qtquick.d.ts +7 -0
- package/dist/qml/qtquick.d.ts.map +1 -0
- package/dist/qml/qtquick.js +347 -0
- package/dist/qml/qtquick.js.map +1 -0
- package/dist/qml/react.d.ts +83 -0
- package/dist/qml/react.d.ts.map +1 -0
- package/dist/qml/react.js +323 -0
- package/dist/qml/react.js.map +1 -0
- package/dist/qml/resolver.d.ts +38 -0
- package/dist/qml/resolver.d.ts.map +1 -0
- package/dist/qml/resolver.js +64 -0
- package/dist/qml/resolver.js.map +1 -0
- package/dist/qml/slots.d.ts +65 -0
- package/dist/qml/slots.d.ts.map +1 -0
- package/dist/qml/slots.js +230 -0
- package/dist/qml/slots.js.map +1 -0
- package/dist/qml/states.d.ts +5 -0
- package/dist/qml/states.d.ts.map +1 -0
- package/dist/qml/states.js +276 -0
- package/dist/qml/states.js.map +1 -0
- package/dist/qml/view-utils.d.ts +42 -0
- package/dist/qml/view-utils.d.ts.map +1 -0
- package/dist/qml/view-utils.js +121 -0
- package/dist/qml/view-utils.js.map +1 -0
- package/dist/reorder/hx.d.ts +18 -0
- package/dist/reorder/hx.d.ts.map +1 -0
- package/dist/reorder/hx.js +10 -0
- package/dist/reorder/hx.js.map +1 -0
- package/dist/reorder/index.d.ts +314 -0
- package/dist/reorder/index.d.ts.map +1 -0
- package/dist/reorder/index.js +1539 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/model.d.ts +107 -0
- package/dist/reorder/model.d.ts.map +1 -0
- package/dist/reorder/model.js +162 -0
- package/dist/reorder/model.js.map +1 -0
- package/dist/richtext/node.d.ts +15 -5
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js +40 -11
- package/dist/richtext/node.js.map +1 -1
- package/dist/richtext/runs.d.ts +35 -13
- package/dist/richtext/runs.d.ts.map +1 -1
- package/dist/richtext/runs.js +83 -27
- package/dist/richtext/runs.js.map +1 -1
- package/dist/tabs/hx.d.ts +18 -0
- package/dist/tabs/hx.d.ts.map +1 -0
- package/dist/tabs/hx.js +10 -0
- package/dist/tabs/hx.js.map +1 -0
- package/dist/tabs/index.d.ts +160 -0
- package/dist/tabs/index.d.ts.map +1 -0
- package/dist/tabs/index.js +1265 -0
- package/dist/tabs/index.js.map +1 -0
- package/dist/terminal/vt/fonts.d.ts +45 -15
- package/dist/terminal/vt/fonts.d.ts.map +1 -1
- package/dist/terminal/vt/fonts.js +89 -19
- package/dist/terminal/vt/fonts.js.map +1 -1
- package/dist/terminal/vt/index.d.ts +1 -1
- package/dist/terminal/vt/index.d.ts.map +1 -1
- package/dist/terminal/vt/index.js +3 -3
- package/dist/terminal/vt/index.js.map +1 -1
- package/dist/terminal/vt/node.d.ts +42 -0
- package/dist/terminal/vt/node.d.ts.map +1 -1
- package/dist/terminal/vt/node.js +95 -11
- package/dist/terminal/vt/node.js.map +1 -1
- package/dist/terminal/vt/pty.d.ts +16 -0
- package/dist/terminal/vt/pty.d.ts.map +1 -1
- package/dist/terminal/vt/pty.js +186 -0
- package/dist/terminal/vt/pty.js.map +1 -1
- package/dist/terminal/vt/renderer.d.ts.map +1 -1
- package/dist/terminal/vt/renderer.js +13 -3
- package/dist/terminal/vt/renderer.js.map +1 -1
- package/package.json +23 -3
- package/src/charts/components.ts +14 -7
- package/src/charts/node.ts +81 -26
- package/src/charts/render.ts +16 -6
- package/src/code-editor/node.ts +147 -53
- package/src/flow/draw.ts +104 -35
- package/src/flow/index.ts +33 -13
- package/src/flow/model.ts +4 -2
- package/src/flow/node.ts +158 -59
- package/src/flow/types.ts +46 -21
- package/src/formula/index.ts +4 -2
- package/src/formula/node.ts +24 -5
- package/src/html/controls.ts +4 -1
- package/src/html/css/cascade.ts +18 -7
- package/src/html/css/parse.ts +46 -21
- package/src/html/css/style.ts +6 -1
- package/src/html/css/values.ts +25 -9
- package/src/html/index.ts +1 -0
- package/src/html/layout/boxes.ts +19 -9
- package/src/html/layout/inline.ts +23 -1
- package/src/html/node.ts +110 -17
- package/src/html/paint.ts +17 -2
- package/src/index.ts +142 -0
- package/src/maps/clip.ts +184 -0
- package/src/maps/gzip.ts +66 -0
- package/src/maps/index.ts +316 -0
- package/src/maps/labels.ts +442 -0
- package/src/maps/mvt.ts +857 -0
- package/src/maps/node.ts +1819 -0
- package/src/maps/overlay.ts +639 -0
- package/src/maps/paint.ts +978 -0
- package/src/maps/proj.ts +641 -0
- package/src/maps/sources.ts +425 -0
- package/src/maps/style.ts +309 -0
- package/src/maps/styles.ts +1040 -0
- package/src/maps/tiles.ts +676 -0
- package/src/maps/types.ts +260 -0
- package/src/qml/containers.tsx +380 -0
- package/src/qml/controls.tsx +47 -0
- package/src/qml/globals.ts +33 -0
- package/src/qml/index.ts +67 -0
- package/src/qml/interaction.tsx +317 -0
- package/src/qml/ir.ts +80 -0
- package/src/qml/layouts.tsx +141 -0
- package/src/qml/models.ts +101 -0
- package/src/qml/objects.ts +1431 -0
- package/src/qml/parse.ts +624 -0
- package/src/qml/qtquick.tsx +413 -0
- package/src/qml/react.tsx +454 -0
- package/src/qml/resolver.ts +99 -0
- package/src/qml/slots.ts +249 -0
- package/src/qml/states.ts +318 -0
- package/src/qml/view-utils.ts +140 -0
- package/src/reorder/hx.ts +31 -0
- package/src/reorder/index.ts +2223 -0
- package/src/reorder/model.ts +232 -0
- package/src/richtext/node.ts +49 -14
- package/src/richtext/runs.ts +115 -30
- package/src/tabs/hx.ts +31 -0
- package/src/tabs/index.ts +1686 -0
- package/src/terminal/vt/fonts.ts +128 -36
- package/src/terminal/vt/index.ts +4 -2
- package/src/terminal/vt/node.ts +105 -12
- package/src/terminal/vt/pty.ts +243 -0
- package/src/terminal/vt/renderer.ts +13 -3
package/src/html/paint.ts
CHANGED
|
@@ -54,6 +54,9 @@ export interface PaintOptions {
|
|
|
54
54
|
/** Where the document's origin sits in the window. Scrolling is this. */
|
|
55
55
|
originX: number;
|
|
56
56
|
originY: number;
|
|
57
|
+
/** Device pixels per logical pixel, for the run rules — a link's
|
|
58
|
+
* underline is a logical pixel thick, not a device one. Default 1. */
|
|
59
|
+
scale?: number;
|
|
57
60
|
/** The rectangle being repainted, in window coordinates, or null for all. */
|
|
58
61
|
damage: Rect | null;
|
|
59
62
|
/** The document range the selection covers, in code units, or null. */
|
|
@@ -526,7 +529,13 @@ function paintLines(ctx: PaintContext, box: Box, options: PaintOptions): void {
|
|
|
526
529
|
for (const text of line.texts) {
|
|
527
530
|
const natural = text.layout.lines[text.layoutLine];
|
|
528
531
|
if (natural)
|
|
529
|
-
paintRunBackgrounds(
|
|
532
|
+
paintRunBackgrounds(
|
|
533
|
+
ctx,
|
|
534
|
+
natural,
|
|
535
|
+
text.drawX + dx,
|
|
536
|
+
text.drawY + dy,
|
|
537
|
+
options.scale ?? 1,
|
|
538
|
+
);
|
|
530
539
|
}
|
|
531
540
|
paintSelection(ctx, line, options);
|
|
532
541
|
}
|
|
@@ -556,7 +565,13 @@ function paintLines(ctx: PaintContext, box: Box, options: PaintOptions): void {
|
|
|
556
565
|
for (const text of line.texts) {
|
|
557
566
|
const natural = text.layout.lines[text.layoutLine];
|
|
558
567
|
if (natural)
|
|
559
|
-
paintRunRules(
|
|
568
|
+
paintRunRules(
|
|
569
|
+
ctx,
|
|
570
|
+
natural,
|
|
571
|
+
text.drawX + dx,
|
|
572
|
+
text.drawY + dy,
|
|
573
|
+
options.scale ?? 1,
|
|
574
|
+
);
|
|
560
575
|
}
|
|
561
576
|
for (const placed of line.atomics) paintBox(ctx, placed.box, options);
|
|
562
577
|
}
|
package/src/index.ts
CHANGED
|
@@ -250,6 +250,7 @@ export type {
|
|
|
250
250
|
NodeChange,
|
|
251
251
|
NodeMouseHandler,
|
|
252
252
|
NodePaintContext,
|
|
253
|
+
NodeRenderContext,
|
|
253
254
|
PanePosition,
|
|
254
255
|
Viewport,
|
|
255
256
|
XYPosition,
|
|
@@ -288,6 +289,59 @@ export type {
|
|
|
288
289
|
TableStyles,
|
|
289
290
|
} from './table/index.js';
|
|
290
291
|
|
|
292
|
+
// A 2D map: vector tiles the application supplies, drawn into one element
|
|
293
|
+
// that owns the viewport. `docs/prd-maps.md` is the design record — what
|
|
294
|
+
// the formats are, who serves them, and what each of the three caches
|
|
295
|
+
// underneath this is for. `Map` shadows the built-in of that name inside a
|
|
296
|
+
// module that imports it, so `import { Map as MapView }` is there for a
|
|
297
|
+
// module that needs both.
|
|
298
|
+
export { Map, MapViewNode, MAPVIEW_ELEMENT } from './maps/index.js';
|
|
299
|
+
// The projection and the tile grid, which an application doing its own
|
|
300
|
+
// geography — clustering markers, deciding what to fetch — needs the same
|
|
301
|
+
// arithmetic for. Qualified on the way through the barrel where a bare name
|
|
302
|
+
// would be ambiguous beside a calendar and a terminal.
|
|
303
|
+
export {
|
|
304
|
+
boundsOf as boundsOfPositions,
|
|
305
|
+
cameraForBounds,
|
|
306
|
+
distanceMetres,
|
|
307
|
+
metresPerPixel,
|
|
308
|
+
tileBounds,
|
|
309
|
+
tileCover,
|
|
310
|
+
tileOf,
|
|
311
|
+
wrapLon,
|
|
312
|
+
} from './maps/index.js';
|
|
313
|
+
// The tile sources, the default style, and the two format helpers every
|
|
314
|
+
// map application ends up writing.
|
|
315
|
+
export {
|
|
316
|
+
OSM_ATTRIBUTION,
|
|
317
|
+
decodePolyline,
|
|
318
|
+
geoJsonOverlays,
|
|
319
|
+
googleTileSource,
|
|
320
|
+
osmRasterSource,
|
|
321
|
+
osmVectorSource,
|
|
322
|
+
openMapTilesStyle,
|
|
323
|
+
shortbreadStyle,
|
|
324
|
+
} from './maps/index.js';
|
|
325
|
+
export type {
|
|
326
|
+
FitBoundsOptions as MapFitBoundsOptions,
|
|
327
|
+
LngLat,
|
|
328
|
+
LngLatBounds,
|
|
329
|
+
MapCamera,
|
|
330
|
+
MapFrameStats,
|
|
331
|
+
MapHandle,
|
|
332
|
+
MapMarker,
|
|
333
|
+
MapOverlay,
|
|
334
|
+
MapPointerEvent,
|
|
335
|
+
MapProps,
|
|
336
|
+
MapSource,
|
|
337
|
+
MapStyle,
|
|
338
|
+
MapStyleLayer,
|
|
339
|
+
MapViewProps,
|
|
340
|
+
TileData,
|
|
341
|
+
TileId,
|
|
342
|
+
TileRequest,
|
|
343
|
+
} from './maps/index.js';
|
|
344
|
+
|
|
291
345
|
export { Markdown, parse as parseMarkdown } from './markdown/index.js';
|
|
292
346
|
export type {
|
|
293
347
|
MarkdownProps,
|
|
@@ -482,6 +536,71 @@ export type {
|
|
|
482
536
|
TimelineVariant,
|
|
483
537
|
} from './timeline/index.js';
|
|
484
538
|
|
|
539
|
+
// One visible panel at a time. Chakra UI's Tabs with the parts spelled flat,
|
|
540
|
+
// like `<Timeline>` — `Tabs.Root` is `<Tabs>`, `Tabs.Trigger` is
|
|
541
|
+
// `<TabsTrigger>`. Successor to react-x11's own items-array `<Tabs>`.
|
|
542
|
+
export {
|
|
543
|
+
Tabs,
|
|
544
|
+
TabsContent,
|
|
545
|
+
TabsIndicator,
|
|
546
|
+
TabsList,
|
|
547
|
+
TabsTrigger,
|
|
548
|
+
} from './tabs/index.js';
|
|
549
|
+
export type {
|
|
550
|
+
TabsContentProps,
|
|
551
|
+
TabsIndicatorProps,
|
|
552
|
+
TabsListProps,
|
|
553
|
+
TabsProps,
|
|
554
|
+
TabsSize,
|
|
555
|
+
TabsTriggerProps,
|
|
556
|
+
TabsValueChange,
|
|
557
|
+
TabsVariant,
|
|
558
|
+
} from './tabs/index.js';
|
|
559
|
+
|
|
560
|
+
// A list the user reorders by dragging. The sortable layer over core's own
|
|
561
|
+
// drag and drop — `@dnd-kit/sortable`'s position over `@dnd-kit/core`, with
|
|
562
|
+
// the engine being react-x11's. `docs/prd-reorder.md` is the survey and the
|
|
563
|
+
// design record. The model comes out with it: an app that drives a list
|
|
564
|
+
// from outside does the same slot arithmetic.
|
|
565
|
+
export {
|
|
566
|
+
ReorderList,
|
|
567
|
+
ReorderItem,
|
|
568
|
+
ReorderHandle,
|
|
569
|
+
REORDER_TYPE,
|
|
570
|
+
useReorderItem,
|
|
571
|
+
arrayMove,
|
|
572
|
+
closestSlot,
|
|
573
|
+
insertAtSlot,
|
|
574
|
+
insertManyAtSlot,
|
|
575
|
+
isNoopSlot,
|
|
576
|
+
moveManyToSlot,
|
|
577
|
+
moveToSlot,
|
|
578
|
+
} from './reorder/index.js';
|
|
579
|
+
export type {
|
|
580
|
+
ReorderChange,
|
|
581
|
+
ReorderCombine,
|
|
582
|
+
ReorderDragEnd,
|
|
583
|
+
ReorderDragStart,
|
|
584
|
+
ReorderDragUpdate,
|
|
585
|
+
ReorderDrop,
|
|
586
|
+
ReorderDropQuery,
|
|
587
|
+
ReorderEdge,
|
|
588
|
+
ReorderHandleProps,
|
|
589
|
+
ReorderId,
|
|
590
|
+
ReorderInput,
|
|
591
|
+
ReorderInsert,
|
|
592
|
+
ReorderItemProps,
|
|
593
|
+
ReorderItemState,
|
|
594
|
+
ReorderListProps,
|
|
595
|
+
ReorderOrientation,
|
|
596
|
+
ReorderPoint,
|
|
597
|
+
ReorderPreviewSize,
|
|
598
|
+
ReorderRect,
|
|
599
|
+
ReorderRemove,
|
|
600
|
+
ReorderSlot,
|
|
601
|
+
ReorderStyles,
|
|
602
|
+
} from './reorder/index.js';
|
|
603
|
+
|
|
485
604
|
export {
|
|
486
605
|
TrayHost,
|
|
487
606
|
TrayManager,
|
|
@@ -636,3 +755,26 @@ export type {
|
|
|
636
755
|
ThreeSize,
|
|
637
756
|
ThreeViewport,
|
|
638
757
|
} from './three/index.js';
|
|
758
|
+
export {
|
|
759
|
+
QmlView,
|
|
760
|
+
QmlNode,
|
|
761
|
+
Qt,
|
|
762
|
+
parseQml,
|
|
763
|
+
instantiateDocument,
|
|
764
|
+
registerQmlModule,
|
|
765
|
+
registerReactComponent,
|
|
766
|
+
registerControls,
|
|
767
|
+
createFileResolver,
|
|
768
|
+
geometryStyle,
|
|
769
|
+
captureNode,
|
|
770
|
+
qmlColor,
|
|
771
|
+
} from './qml/index.js';
|
|
772
|
+
export type {
|
|
773
|
+
QmlViewProps,
|
|
774
|
+
QmlViewHandle,
|
|
775
|
+
QmlDocument,
|
|
776
|
+
QmlTypeDef,
|
|
777
|
+
QmlFacade,
|
|
778
|
+
QmlInstance,
|
|
779
|
+
QmlResolver,
|
|
780
|
+
} from './qml/index.js';
|
package/src/maps/clip.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Clipping geometry to the target, and why anything has to.
|
|
2
|
+
//
|
|
3
|
+
// **Coordinates in this renderer are bounded and the world's are not.**
|
|
4
|
+
// ntk hands a stroke's geometry to XRender as 16.16 fixed point, which
|
|
5
|
+
// overflows a signed 32-bit word at 32,768, and a composite's coordinates
|
|
6
|
+
// are int16. Two things routinely exceed that:
|
|
7
|
+
//
|
|
8
|
+
// - an **overlay**, which is geography: a route's far end stays where it
|
|
9
|
+
// is when the camera zooms into one corner of it, and a world is
|
|
10
|
+
// `512 · 2^zoom` pixels — 134 million at zoom 20;
|
|
11
|
+
// - a **tile drawn past its own depth**, where one source tile is
|
|
12
|
+
// rasterized into each cell of a grid over it, so a tile-wide polygon is
|
|
13
|
+
// `span` tiles wide in the surface's pixels.
|
|
14
|
+
//
|
|
15
|
+
// Both want the same two algorithms, so they live here rather than twice.
|
|
16
|
+
// Cohen-Sutherland for a line, because the common case is a segment wholly
|
|
17
|
+
// inside or wholly outside and both are answered by one `&`/`|` of the
|
|
18
|
+
// endpoints' codes with no arithmetic at all; Sutherland-Hodgman for an
|
|
19
|
+
// area, because a fill needs a closed boundary — the part of a polygon that
|
|
20
|
+
// crosses the window has to come back along the window's edge, which
|
|
21
|
+
// segment clipping cannot produce.
|
|
22
|
+
|
|
23
|
+
/** The clip window, in the same target pixels the path is built in. */
|
|
24
|
+
export interface ClipRect {
|
|
25
|
+
minX: number;
|
|
26
|
+
minY: number;
|
|
27
|
+
maxX: number;
|
|
28
|
+
maxY: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* How far outside the pane geometry is still kept.
|
|
33
|
+
*
|
|
34
|
+
* Not zero: a line clipped exactly at the edge would have its join and its
|
|
35
|
+
* cap drawn at the boundary rather than outside it, which shows as a blunt
|
|
36
|
+
* end against the pane's edge. A margin wider than any stroke this draws
|
|
37
|
+
* puts those artefacts off-screen, and is still far inside the range that
|
|
38
|
+
* overflows.
|
|
39
|
+
*/
|
|
40
|
+
export const CLIP_MARGIN = 256;
|
|
41
|
+
|
|
42
|
+
export function clipOf(
|
|
43
|
+
pane: { x: number; y: number; width: number; height: number },
|
|
44
|
+
scale: number,
|
|
45
|
+
): ClipRect {
|
|
46
|
+
return {
|
|
47
|
+
minX: (pane.x - CLIP_MARGIN) * scale,
|
|
48
|
+
minY: (pane.y - CLIP_MARGIN) * scale,
|
|
49
|
+
maxX: (pane.x + pane.width + CLIP_MARGIN) * scale,
|
|
50
|
+
maxY: (pane.y + pane.height + CLIP_MARGIN) * scale,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const INSIDE = 0;
|
|
55
|
+
const LEFT = 1;
|
|
56
|
+
const RIGHT = 2;
|
|
57
|
+
const BOTTOM = 4;
|
|
58
|
+
const TOP = 8;
|
|
59
|
+
|
|
60
|
+
function outcode(x: number, y: number, clip: ClipRect): number {
|
|
61
|
+
let code = INSIDE;
|
|
62
|
+
if (x < clip.minX) code |= LEFT;
|
|
63
|
+
else if (x > clip.maxX) code |= RIGHT;
|
|
64
|
+
if (y < clip.minY) code |= BOTTOM;
|
|
65
|
+
else if (y > clip.maxY) code |= TOP;
|
|
66
|
+
return code;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Cohen-Sutherland: the visible piece of one segment, or null.
|
|
71
|
+
*
|
|
72
|
+
* Chosen over Liang-Barsky because the common case here is a segment wholly
|
|
73
|
+
* inside or wholly outside, and both are answered by one `&`/`|` of the two
|
|
74
|
+
* endpoints' codes with no arithmetic at all.
|
|
75
|
+
*/
|
|
76
|
+
export function clipSegment(
|
|
77
|
+
ax: number,
|
|
78
|
+
ay: number,
|
|
79
|
+
bx: number,
|
|
80
|
+
by: number,
|
|
81
|
+
clip: ClipRect,
|
|
82
|
+
): [number, number, number, number] | null {
|
|
83
|
+
let x0 = ax;
|
|
84
|
+
let y0 = ay;
|
|
85
|
+
let x1 = bx;
|
|
86
|
+
let y1 = by;
|
|
87
|
+
let code0 = outcode(x0, y0, clip);
|
|
88
|
+
let code1 = outcode(x1, y1, clip);
|
|
89
|
+
for (;;) {
|
|
90
|
+
if ((code0 | code1) === 0) return [x0, y0, x1, y1]; // both inside
|
|
91
|
+
if ((code0 & code1) !== 0) return null; // both beyond one edge
|
|
92
|
+
const code = code0 !== 0 ? code0 : code1;
|
|
93
|
+
let x = 0;
|
|
94
|
+
let y = 0;
|
|
95
|
+
if (code & TOP) {
|
|
96
|
+
x = x0 + ((x1 - x0) * (clip.maxY - y0)) / (y1 - y0);
|
|
97
|
+
y = clip.maxY;
|
|
98
|
+
} else if (code & BOTTOM) {
|
|
99
|
+
x = x0 + ((x1 - x0) * (clip.minY - y0)) / (y1 - y0);
|
|
100
|
+
y = clip.minY;
|
|
101
|
+
} else if (code & RIGHT) {
|
|
102
|
+
y = y0 + ((y1 - y0) * (clip.maxX - x0)) / (x1 - x0);
|
|
103
|
+
x = clip.maxX;
|
|
104
|
+
} else {
|
|
105
|
+
y = y0 + ((y1 - y0) * (clip.minX - x0)) / (x1 - x0);
|
|
106
|
+
x = clip.minX;
|
|
107
|
+
}
|
|
108
|
+
if (code === code0) {
|
|
109
|
+
x0 = x;
|
|
110
|
+
y0 = y;
|
|
111
|
+
code0 = outcode(x0, y0, clip);
|
|
112
|
+
} else {
|
|
113
|
+
x1 = x;
|
|
114
|
+
y1 = y;
|
|
115
|
+
code1 = outcode(x1, y1, clip);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sutherland-Hodgman: a ring clipped to the rectangle, in place of the
|
|
122
|
+
* original.
|
|
123
|
+
*
|
|
124
|
+
* Rings rather than segments, because a fill needs a closed boundary: the
|
|
125
|
+
* part of a polygon that crosses the window has to come back along the
|
|
126
|
+
* window's edge, which segment clipping cannot produce. Winding is
|
|
127
|
+
* preserved, so an interior ring stays an interior ring and the non-zero
|
|
128
|
+
* fill still puts a hole where one belongs.
|
|
129
|
+
*/
|
|
130
|
+
export function clipRing(points: readonly number[], clip: ClipRect): number[] {
|
|
131
|
+
let output = [...points];
|
|
132
|
+
const edges: [
|
|
133
|
+
(x: number, y: number) => boolean,
|
|
134
|
+
(ax: number, ay: number, bx: number, by: number) => [number, number],
|
|
135
|
+
][] = [
|
|
136
|
+
[
|
|
137
|
+
(x) => x >= clip.minX,
|
|
138
|
+
(ax, ay, bx, by) => [
|
|
139
|
+
clip.minX,
|
|
140
|
+
ay + ((by - ay) * (clip.minX - ax)) / (bx - ax),
|
|
141
|
+
],
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
(x) => x <= clip.maxX,
|
|
145
|
+
(ax, ay, bx, by) => [
|
|
146
|
+
clip.maxX,
|
|
147
|
+
ay + ((by - ay) * (clip.maxX - ax)) / (bx - ax),
|
|
148
|
+
],
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
(_x, y) => y >= clip.minY,
|
|
152
|
+
(ax, ay, bx, by) => [
|
|
153
|
+
ax + ((bx - ax) * (clip.minY - ay)) / (by - ay),
|
|
154
|
+
clip.minY,
|
|
155
|
+
],
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
(_x, y) => y <= clip.maxY,
|
|
159
|
+
(ax, ay, bx, by) => [
|
|
160
|
+
ax + ((bx - ax) * (clip.maxY - ay)) / (by - ay),
|
|
161
|
+
clip.maxY,
|
|
162
|
+
],
|
|
163
|
+
],
|
|
164
|
+
];
|
|
165
|
+
for (const [inside, intersect] of edges) {
|
|
166
|
+
const input = output;
|
|
167
|
+
output = [];
|
|
168
|
+
if (input.length < 6) return [];
|
|
169
|
+
for (let i = 0; i < input.length; i += 2) {
|
|
170
|
+
const ax = input[i];
|
|
171
|
+
const ay = input[i + 1];
|
|
172
|
+
const bx = input[(i + 2) % input.length];
|
|
173
|
+
const by = input[(i + 3) % input.length];
|
|
174
|
+
const aIn = inside(ax, ay);
|
|
175
|
+
const bIn = inside(bx, by);
|
|
176
|
+
if (aIn) output.push(ax, ay);
|
|
177
|
+
if (aIn !== bIn) {
|
|
178
|
+
const [ix, iy] = intersect(ax, ay, bx, by);
|
|
179
|
+
output.push(ix, iy);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return output;
|
|
184
|
+
}
|
package/src/maps/gzip.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Un-gzip a tile body, when it is one.
|
|
2
|
+
//
|
|
3
|
+
// Tile servers serve `Content-Encoding: gzip` — which a `fetch` undoes —
|
|
4
|
+
// and a good number of them *also* store the tile gzipped inside that, so
|
|
5
|
+
// the body an application hands over may still have the magic on it. That
|
|
6
|
+
// is a transport detail rather than the decoder's business, so it is
|
|
7
|
+
// unwrapped once, here, and `parseTile` only ever sees protobuf.
|
|
8
|
+
//
|
|
9
|
+
// `node:zlib` is reached the way `src/embed/host.ts` reaches `child_process`
|
|
10
|
+
// and for the same reason: `tsconfig.build.json` sets `types: []`, so `src/`
|
|
11
|
+
// may not name a Node module, and a package that did would stop resolving
|
|
12
|
+
// on a runtime that has no such module. So the module is found on
|
|
13
|
+
// `globalThis` if the host put it there and otherwise not at all — and a
|
|
14
|
+
// runtime with no zlib gets a clear error naming the one line of
|
|
15
|
+
// application code that fixes it, rather than a protobuf parse failure
|
|
16
|
+
// twenty frames away.
|
|
17
|
+
|
|
18
|
+
/** The two bytes every gzip member starts with. */
|
|
19
|
+
export function isGzip(bytes: Uint8Array): boolean {
|
|
20
|
+
return bytes.length > 2 && bytes[0] === 0x1f && bytes[1] === 0x8b;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Zlib {
|
|
24
|
+
gunzipSync(data: Uint8Array): Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let zlib: Zlib | null | undefined;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Teach this package how to un-gzip, for a runtime where it cannot find out
|
|
31
|
+
* by itself.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { gunzipSync } from 'node:zlib';
|
|
35
|
+
* setGunzip((data) => gunzipSync(data));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function setGunzip(gunzipSync: (data: Uint8Array) => Uint8Array): void {
|
|
39
|
+
zlib = { gunzipSync };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function findZlib(): Zlib | null {
|
|
43
|
+
if (zlib !== undefined) return zlib;
|
|
44
|
+
// Node and Bun both expose it on `globalThis` under a `require` that a
|
|
45
|
+
// bundler will not follow, which is what keeps this out of a browser
|
|
46
|
+
// bundle. Anything else: no zlib, and `setGunzip` is the way in.
|
|
47
|
+
const g = globalThis as {
|
|
48
|
+
process?: { getBuiltinModule?(name: string): unknown };
|
|
49
|
+
};
|
|
50
|
+
const module = g.process?.getBuiltinModule?.('node:zlib') as Zlib | undefined;
|
|
51
|
+
zlib = module && typeof module.gunzipSync === 'function' ? module : null;
|
|
52
|
+
return zlib;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The bytes, un-gzipped if they were. */
|
|
56
|
+
export function gunzipIfNeeded(bytes: Uint8Array): Uint8Array {
|
|
57
|
+
if (!isGzip(bytes)) return bytes;
|
|
58
|
+
const found = findZlib();
|
|
59
|
+
if (!found) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
'a gzipped tile arrived and this runtime has no zlib — ' +
|
|
62
|
+
'un-gzip it in your source, or call setGunzip() once at startup',
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return found.gunzipSync(bytes);
|
|
66
|
+
}
|