monowind 0.1.0 → 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.
package/dist/element.d.ts CHANGED
@@ -1,14 +1,17 @@
1
- export declare class MonoWindElement extends HTMLElement {
1
+ declare const HTMLElementBase: typeof HTMLElement;
2
+ export declare class MonoWindElement extends HTMLElementBase {
2
3
  #private;
3
4
  constructor();
4
5
  connectedCallback(): void;
5
6
  disconnectedCallback(): void;
6
7
  }
7
- /** Register the <mono-wind> element (idempotent). */
8
+ /** Register the <mono-wind> element (idempotent; no-op without a DOM, so
9
+ * calling it from code that also runs server-side is safe). */
8
10
  export declare function defineMonoWind(): void;
9
11
  declare global {
10
12
  interface HTMLElementTagNameMap {
11
13
  "mono-wind": MonoWindElement;
12
14
  }
13
15
  }
16
+ export {};
14
17
  //# sourceMappingURL=element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAmBA,qBAAa,eAAgB,SAAQ,WAAW;;IAS9C,cAKC;IAED,iBAAiB,IAAI,IAAI,CAqCxB;IAED,oBAAoB,IAAI,IAAI,CAS3B;CA8GF;AAED,qDAAqD;AACrD,wBAAgB,cAAc,IAAI,IAAI,CAGrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,eAAe,CAAC;KAC9B;CACF"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AA2BA,QAAA,MAAM,eAAe,EAEhB,OAAO,WAAW,CAAC;AAExB,qBAAa,eAAgB,SAAQ,eAAe;;IASlD,cAsBC;IAED,iBAAiB,IAAI,IAAI,CAiCxB;IAED,oBAAoB,IAAI,IAAI,CAM3B;CA0IF;AAED;+DAC+D;AAC/D,wBAAgB,cAAc,IAAI,IAAI,CAIrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,eAAe,CAAC;KAC9B;CACF"}
package/dist/flex.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ import type { IntrinsicCache } from "./layout.ts";
2
+ import type { CellStyle, Insets, LayoutNode } from "./types.ts";
3
+ /**
4
+ * Flexbox (specs/flex.md): row and column algorithms, CSS §9.7 flexible
5
+ * length resolution, and the shared distribution/alignment helpers. See
6
+ * layout.ts for the deliberate import cycle between the layout modules.
7
+ */
8
+ export declare function layoutFlexRow(node: LayoutNode, innerWidth: number, innerHeight: number, definiteInnerHeight: number | undefined, border: Insets, padding: Insets, cache: IntrinsicCache): number;
9
+ export declare function layoutFlexColumn(node: LayoutNode, innerWidth: number, innerHeight: number, heightIsDefinite: boolean, border: Insets, padding: Insets, cache: IntrinsicCache): number;
10
+ /**
11
+ * Position each item along the main axis given its size and leftover space.
12
+ * Returns the offset from container inner origin for each item.
13
+ */
14
+ export declare function mainAxisOffsets(justify: CellStyle["justifyContent"], sizes: number[], leftover: number): number[];
15
+ /**
16
+ * Resolve flex main-axis sizes per CSS Flexbox §9.7 ("Resolving Flexible
17
+ * Lengths"), adapted to integers: distribute free space proportionally to
18
+ * grow factors (or shrink weights = base × shrink), clamp each result to the
19
+ * item's own min/max, FREEZE the items whose clamp fired, and redistribute
20
+ * among the rest — repeating until nothing new violates. Without the
21
+ * redistribution rounds, an item clamped up to `min-w-*` would keep space
22
+ * its neighbors were already told they could use, and boxes would overlap.
23
+ *
24
+ * `min`/`max` are outer main sizes in cells, already resolved from percent.
25
+ * When clamps bind, the returned sizes may sum to less or more than
26
+ * `available` — that's CSS (`justify-content` sees the underfill; overflow
27
+ * handles the excess).
28
+ */
29
+ export declare function resolveFlexMainAxis(items: ReadonlyArray<{
30
+ base: number;
31
+ grow: number;
32
+ shrink: number;
33
+ min?: number | undefined;
34
+ max?: number | undefined;
35
+ }>, available: number): number[];
36
+ /**
37
+ * Distribute `total` integer units across N slots proportionally to `weights`,
38
+ * with the remainder (from flooring) given to the slots with the largest
39
+ * fractional part — deterministic, document order for ties.
40
+ */
41
+ export declare function distributeInteger(weights: number[], total: number): number[];
42
+ /** A flex item's cross alignment: its own align-self, else the parent's
43
+ * align-items. */
44
+ export declare function effectiveAlign(child: LayoutNode, parent: LayoutNode): CellStyle["alignItems"];
45
+ export declare function alignCrossOffset(align: CellStyle["alignItems"], container: number, child: number): number;
46
+ export declare function effectiveJustify(style: CellStyle): CellStyle["justifyContent"];
47
+ //# sourceMappingURL=flex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flex.d.ts","sourceRoot":"","sources":["../src/flex.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAEhF;;;;GAIG;AAEH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAAG,SAAS,EACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,cAAc,GACpB,MAAM,CAgNR;AAyBD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,OAAO,EACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,cAAc,GACpB,MAAM,CA4JR;AAgDD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,EACpC,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,MAAM,GACf,MAAM,EAAE,CA0CV;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC,EACF,SAAS,EAAE,MAAM,GAChB,MAAM,EAAE,CA+DV;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAiB5E;AAED;kBACkB;AAClB,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC,YAAY,CAAC,CAI7F;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,EAC9B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,MAAM,CAIR;AA+CD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAS9E"}
package/dist/grid.d.ts ADDED
@@ -0,0 +1,104 @@
1
+ import type { IntrinsicCache } from "./layout.ts";
2
+ import type { GridAutoFlow, GridLine, Insets, LayoutNode, TrackSize } from "./types.ts";
3
+ /**
4
+ * Grid layout (specs/grid.md): template resolution, CSS §8.5 auto-
5
+ * placement, the §11 track sizing algorithm adapted to integer cells, and
6
+ * item placement in areas. Shares the integer distribution and alignment
7
+ * offset machinery with flex. See layout.ts for the deliberate import
8
+ * cycle between the layout modules.
9
+ */
10
+ export declare function layoutGrid(node: LayoutNode, innerWidth: number, innerHeight: number, border: Insets, padding: Insets, cache: IntrinsicCache): number;
11
+ /** The container's intrinsic content widths (specs/grid.md interaction
12
+ * section): run placement and column sizing under a min-content
13
+ * constraint — min-content = the track bases, max-content = the track
14
+ * growth limits (fr tracks report their flex-fraction size), plus gaps.
15
+ * One placement + sizing pass computes both, cached per node. */
16
+ export declare function gridIntrinsicInnerWidths(node: LayoutNode, cache: IntrinsicCache): {
17
+ min: number;
18
+ max: number;
19
+ };
20
+ interface AxisSpec {
21
+ /** Normalized 0-based track index of the start line (explicit tracks
22
+ * occupy [0, explicitCount)); may be negative (implicit tracks before
23
+ * the explicit grid) or null for auto. */
24
+ start: number | null;
25
+ span: number;
26
+ }
27
+ /** The explicit grid of one axis for line resolution: its track count
28
+ * and the names on each of its `explicitCount + 1` lines (template
29
+ * `[name]` groups plus the `<area>-start` / `<area>-end` lines areas
30
+ * imply). Line indices are 0-based; indices outside `0 … explicitCount`
31
+ * are implicit lines. */
32
+ export interface AxisLines {
33
+ explicitCount: number;
34
+ names: string[][];
35
+ }
36
+ /**
37
+ * Resolve one axis of an item's placement from the two line longhands
38
+ * (CSS §8.3). Both lines definite: start = the earlier line, span = the
39
+ * distance (equal lines → the end line is discarded, span 1). One
40
+ * definite line + a span → definite. Only spans (or nothing) →
41
+ * indefinite with the requested span (a named span against `auto` is a
42
+ * plain span — specs/grid.md deviation).
43
+ */
44
+ export declare function resolveAxisPlacement(startLine: GridLine, endLine: GridLine, lines: AxisLines): AxisSpec;
45
+ interface PlacedAxis {
46
+ start: number;
47
+ span: number;
48
+ }
49
+ interface PlacementResult {
50
+ items: {
51
+ col: PlacedAxis;
52
+ row: PlacedAxis;
53
+ }[];
54
+ colOrigin: number;
55
+ colCount: number;
56
+ rowOrigin: number;
57
+ rowCount: number;
58
+ }
59
+ /**
60
+ * CSS §8.5 auto-placement. The flow's major axis grows (rows for `row`
61
+ * flow); the minor axis has a bounded track count. Sparse (default): the
62
+ * cursor only moves forward; `dense` restarts the scan from the grid's
63
+ * start for every item. Items are expected in order-then-document order.
64
+ */
65
+ export declare function placeItems(specs: {
66
+ col: AxisSpec;
67
+ row: AxisSpec;
68
+ }[], explicitCols: number, explicitRows: number, flow: GridAutoFlow): PlacementResult;
69
+ interface SizingItem {
70
+ start: number;
71
+ span: number;
72
+ /** Min-content outer contribution (cells). */
73
+ min: number;
74
+ /** Max-content outer contribution (cells). */
75
+ max: number;
76
+ }
77
+ interface SizingResult {
78
+ sizes: number[];
79
+ /** Gap preceding each track (0 for the first and for collapsed tracks). */
80
+ gapBefore: number[];
81
+ /** Final growth limits (for the container's max-content size). */
82
+ limits: number[];
83
+ }
84
+ /**
85
+ * Size one axis's tracks. `space` is the definite inner size in the axis,
86
+ * or the intrinsic sizing constraint when the axis is indefinite:
87
+ * `"max-content"` for actual layout of an unbounded axis (rows of an
88
+ * auto-height container), `"min-content"` for the container's min-content
89
+ * measure. Steps: initialize from the minmax pairs; grow intrinsic
90
+ * bases/limits from item contributions in ascending span order
91
+ * (equal-weight integer distribution — specs/grid.md deviation); clamp
92
+ * bases to fixed limits (the limit wins, emulating the spec's
93
+ * limited-contribution rule). Definite: maximize bases up to limits
94
+ * (§11.6), distribute the leftover to fr tracks floored at their bases
95
+ * (§11.7), stretch auto-limited tracks over any remainder when the axis's
96
+ * content-distribution is `stretch` (§11.8). Indefinite: fr tracks size
97
+ * to the shared flex fraction (§11.7 with indefinite space), and under
98
+ * the max-content constraint every track maximizes to its growth limit —
99
+ * a fixed minmax max fills even without content, per CSS (§11.6's
100
+ * infinite free space; all three browser engines agree).
101
+ */
102
+ export declare function sizeTracks(trackSizes: TrackSize[], collapsed: boolean[], items: SizingItem[], space: number | "min-content" | "max-content", gap: number, stretchAuto: boolean): SizingResult;
103
+ export {};
104
+ //# sourceMappingURL=grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../src/grid.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EAEV,YAAY,EACZ,QAAQ,EAGR,MAAM,EAEN,UAAU,EAIV,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AAEH,wBAAgB,UAAU,CACxB,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,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