@typecad/ui 1.0.0-alpha.7 → 1.0.0-alpha.9

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 (84) hide show
  1. package/README.md +6 -0
  2. package/dist/engine-index.js +0 -2
  3. package/dist/preview/host-ui-runtime.d.ts +1 -0
  4. package/dist/preview/host-ui-runtime.js +56 -11
  5. package/dist/ui-engine/font-assets.d.ts +8 -0
  6. package/dist/ui-engine/font-assets.js +13 -0
  7. package/dist/ui-engine/layout-engine.js +19 -6
  8. package/dist/ui-engine/model.d.ts +1 -1
  9. package/dist/ui-engine/model.js +10 -4
  10. package/dist/ui-engine/runtime-header/antialiasing.js +52 -32
  11. package/dist/ui-engine/runtime-header/blend-bodies.js +4 -4
  12. package/dist/ui-engine/runtime-header/canvas-helpers.js +32 -65
  13. package/dist/ui-engine/runtime-header/canvas-scrollbar.js +22 -10
  14. package/dist/ui-engine/runtime-header/color-mono-refresh.js +10 -10
  15. package/dist/ui-engine/runtime-header/cuttlefish-gfx.js +59 -29
  16. package/dist/ui-engine/runtime-header/dirty-scroll-mutators.js +26 -10
  17. package/dist/ui-engine/runtime-header/display-shim.js +8 -8
  18. package/dist/ui-engine/runtime-header/forward-decls.js +48 -6
  19. package/dist/ui-engine/runtime-header/image-drawing.js +154 -84
  20. package/dist/ui-engine/runtime-header/init-press-input.js +20 -5
  21. package/dist/ui-engine/runtime-header/keyboard.js +19 -16
  22. package/dist/ui-engine/runtime-header/node-decoration.js +8 -8
  23. package/dist/ui-engine/runtime-header/node-draw-body.d.ts +1 -0
  24. package/dist/ui-engine/runtime-header/node-draw-body.js +1402 -0
  25. package/dist/ui-engine/runtime-header/paint-order-coords.js +48 -18
  26. package/dist/ui-engine/runtime-header/paint-rects-repair.js +38 -17
  27. package/dist/ui-engine/runtime-header/scroll-physics.js +15 -14
  28. package/dist/ui-engine/runtime-header/state-bindings-nav.js +23 -13
  29. package/dist/ui-engine/runtime-header/structs.js +12 -10
  30. package/dist/ui-engine/runtime-header/text-rendering.js +132 -71
  31. package/dist/ui-engine/runtime-header/tick/bindings-phase.js +29 -10
  32. package/dist/ui-engine/runtime-header/tick/dirty-draw-phase.js +299 -747
  33. package/dist/ui-engine/runtime-header/tick/flush-phase.js +7 -3
  34. package/dist/ui-engine/runtime-header/tick/scroll-canvas-phase.js +19 -3
  35. package/dist/ui-engine/runtime-header/tick/transitions-phase.js +31 -24
  36. package/dist/ui-engine/runtime-header/touch-keyboard-fwd.js +42 -40
  37. package/dist/ui-engine/runtime-header/types-defines.js +23 -3
  38. package/dist/ui-engine/runtime-header.js +2 -0
  39. package/dist/ui-engine/transpile-ui.js +2 -2
  40. package/dist/ui-engine/ua-stylesheet.js +46 -3
  41. package/dist/ui-engine/ui-lowering.d.ts +1 -3
  42. package/dist/ui-engine/ui-lowering.js +4 -23
  43. package/dist/ui-engine/ui-registry.js +1 -7
  44. package/package.json +2 -2
  45. package/src/engine-index.ts +0 -2
  46. package/src/preview/host-ui-runtime.ts +56 -12
  47. package/src/ui-engine/font-assets.ts +13 -0
  48. package/src/ui-engine/layout-engine.ts +19 -6
  49. package/src/ui-engine/model.ts +10 -5
  50. package/src/ui-engine/runtime-header/antialiasing.ts +52 -32
  51. package/src/ui-engine/runtime-header/blend-bodies.ts +4 -4
  52. package/src/ui-engine/runtime-header/canvas-helpers.ts +32 -65
  53. package/src/ui-engine/runtime-header/canvas-scrollbar.ts +22 -10
  54. package/src/ui-engine/runtime-header/color-mono-refresh.ts +10 -10
  55. package/src/ui-engine/runtime-header/cuttlefish-gfx.ts +59 -29
  56. package/src/ui-engine/runtime-header/dirty-scroll-mutators.ts +26 -10
  57. package/src/ui-engine/runtime-header/display-shim.ts +8 -8
  58. package/src/ui-engine/runtime-header/forward-decls.ts +48 -6
  59. package/src/ui-engine/runtime-header/image-drawing.ts +154 -84
  60. package/src/ui-engine/runtime-header/init-press-input.ts +20 -5
  61. package/src/ui-engine/runtime-header/keyboard.ts +19 -16
  62. package/src/ui-engine/runtime-header/node-decoration.ts +8 -8
  63. package/src/ui-engine/runtime-header/node-draw-body.ts +1402 -0
  64. package/src/ui-engine/runtime-header/paint-order-coords.ts +48 -18
  65. package/src/ui-engine/runtime-header/paint-rects-repair.ts +38 -17
  66. package/src/ui-engine/runtime-header/scroll-physics.ts +15 -14
  67. package/src/ui-engine/runtime-header/state-bindings-nav.ts +23 -13
  68. package/src/ui-engine/runtime-header/structs.ts +12 -10
  69. package/src/ui-engine/runtime-header/text-rendering.ts +132 -71
  70. package/src/ui-engine/runtime-header/tick/bindings-phase.ts +29 -10
  71. package/src/ui-engine/runtime-header/tick/dirty-draw-phase.ts +299 -747
  72. package/src/ui-engine/runtime-header/tick/flush-phase.ts +7 -3
  73. package/src/ui-engine/runtime-header/tick/scroll-canvas-phase.ts +19 -3
  74. package/src/ui-engine/runtime-header/tick/transitions-phase.ts +31 -24
  75. package/src/ui-engine/runtime-header/touch-keyboard-fwd.ts +42 -40
  76. package/src/ui-engine/runtime-header/types-defines.ts +23 -3
  77. package/src/ui-engine/runtime-header.ts +2 -0
  78. package/src/ui-engine/transpile-ui.ts +2 -2
  79. package/src/ui-engine/ua-stylesheet.ts +46 -3
  80. package/src/ui-engine/ui-lowering.ts +3 -25
  81. package/src/ui-engine/ui-registry.ts +1 -8
  82. package/dist/ui-engine/scroll-memory-diagnostics.d.ts +0 -16
  83. package/dist/ui-engine/scroll-memory-diagnostics.js +0 -58
  84. package/src/ui-engine/scroll-memory-diagnostics.ts +0 -79
@@ -1,16 +0,0 @@
1
- import type { Diagnostic } from "@typecad/cuttlefish/api/shared";
2
- import type { UINodeModel } from "./model.js";
3
- import { DEFAULT_SCROLL_CANVAS_BUDGET_BYTES } from "@typecad/cuttlefish/api/shared";
4
- export { DEFAULT_SCROLL_CANVAS_BUDGET_BYTES };
5
- export interface ScrollMemoryIssue {
6
- nodeIndex: number;
7
- id?: string;
8
- width: number;
9
- height: number;
10
- canvasBytes: number;
11
- budgetBytes: number;
12
- }
13
- /** Collect overflow scroll nodes whose viewport canvas exceeds the budget. */
14
- export declare function collectScrollMemoryIssues(nodes: UINodeModel[], budgetBytes?: number): ScrollMemoryIssue[];
15
- /** Emit transpile warnings for scroll viewports that cannot fit a Mode B canvas. */
16
- export declare function analyzeScrollMemory(nodes: UINodeModel[], budgetBytes?: number): Diagnostic[];
@@ -1,58 +0,0 @@
1
- // Compile-time scroll viewport memory analysis. Overflow scroll containers
2
- // need a viewport-sized RGB565 canvas (~w×h×2 bytes) for smooth Mode B
3
- // scrolling; when that exceeds the device budget, runtime falls back to
4
- // Mode C strip scroll or freezes until memory is available.
5
- import { DEFAULT_SCROLL_CANVAS_BUDGET_BYTES } from "@typecad/cuttlefish/api/shared";
6
- export { DEFAULT_SCROLL_CANVAS_BUDGET_BYTES };
7
- /** Collect overflow scroll nodes whose viewport canvas exceeds the budget. */
8
- export function collectScrollMemoryIssues(nodes, budgetBytes = DEFAULT_SCROLL_CANVAS_BUDGET_BYTES) {
9
- const issues = [];
10
- for (const node of nodes) {
11
- if (!node.scrollable)
12
- continue;
13
- if (node.contentHeight <= node.box.h)
14
- continue;
15
- const canvasBytes = node.box.w * node.box.h * 2;
16
- if (canvasBytes <= budgetBytes)
17
- continue;
18
- issues.push({
19
- nodeIndex: node.index,
20
- id: node.id,
21
- width: node.box.w,
22
- height: node.box.h,
23
- canvasBytes,
24
- budgetBytes,
25
- });
26
- }
27
- return issues;
28
- }
29
- function formatKb(bytes) {
30
- return `${Math.round(bytes / 1024)} KB`;
31
- }
32
- function minimizationHint(issue) {
33
- const maxArea = Math.floor(issue.budgetBytes / 2);
34
- const maxHAtWidth = issue.width > 0 ? Math.floor(maxArea / issue.width) : 0;
35
- const maxWAtHeight = issue.height > 0 ? Math.floor(maxArea / issue.height) : 0;
36
- return [
37
- `Reduce the scroll viewport in CSS (e.g. height ≤ ${maxHAtWidth}px at ${issue.width}px width, or width ≤ ${maxWAtHeight}px at ${issue.height}px height).`,
38
- "Trim fonts, images, or inactive screens to free heap for canvas allocation.",
39
- "Use PSRAM or a board with more SRAM if you need a larger scroll viewport.",
40
- "Adjust display.scroll.scrollCanvasBudgetBytes in cuttlefish.config.ts only if your target has more headroom (runtime allocation may still fail).",
41
- ].join("\n");
42
- }
43
- /** Emit transpile warnings for scroll viewports that cannot fit a Mode B canvas. */
44
- export function analyzeScrollMemory(nodes, budgetBytes = DEFAULT_SCROLL_CANVAS_BUDGET_BYTES) {
45
- return collectScrollMemoryIssues(nodes, budgetBytes).map((issue) => {
46
- const label = issue.id ? `#${issue.id}` : `node ${issue.nodeIndex}`;
47
- return {
48
- severity: "warning",
49
- code: "scroll-canvas-memory",
50
- message: `Scroll viewport ${label} (${issue.width}×${issue.height}px) needs ${issue.canvasBytes} bytes ` +
51
- `(${formatKb(issue.canvasBytes)}) for accurate smooth scrolling, exceeding the ` +
52
- `${issue.budgetBytes}-byte budget (~${formatKb(issue.budgetBytes)}). ` +
53
- "Rendering will fall back to Mode C strip scroll or freeze updates until memory is available — " +
54
- "scrolling may tear, stutter, or skip frames.",
55
- hint: minimizationHint(issue),
56
- };
57
- });
58
- }
@@ -1,79 +0,0 @@
1
- // Compile-time scroll viewport memory analysis. Overflow scroll containers
2
- // need a viewport-sized RGB565 canvas (~w×h×2 bytes) for smooth Mode B
3
- // scrolling; when that exceeds the device budget, runtime falls back to
4
- // Mode C strip scroll or freezes until memory is available.
5
-
6
- import type { Diagnostic } from "@typecad/cuttlefish/api/shared";
7
- import type { UINodeModel } from "./model.js";
8
- import { DEFAULT_SCROLL_CANVAS_BUDGET_BYTES } from "@typecad/cuttlefish/api/shared";
9
-
10
- export { DEFAULT_SCROLL_CANVAS_BUDGET_BYTES };
11
-
12
- export interface ScrollMemoryIssue {
13
- nodeIndex: number;
14
- id?: string;
15
- width: number;
16
- height: number;
17
- canvasBytes: number;
18
- budgetBytes: number;
19
- }
20
-
21
- /** Collect overflow scroll nodes whose viewport canvas exceeds the budget. */
22
- export function collectScrollMemoryIssues(
23
- nodes: UINodeModel[],
24
- budgetBytes: number = DEFAULT_SCROLL_CANVAS_BUDGET_BYTES,
25
- ): ScrollMemoryIssue[] {
26
- const issues: ScrollMemoryIssue[] = [];
27
- for (const node of nodes) {
28
- if (!node.scrollable) continue;
29
- if (node.contentHeight <= node.box.h) continue;
30
- const canvasBytes = node.box.w * node.box.h * 2;
31
- if (canvasBytes <= budgetBytes) continue;
32
- issues.push({
33
- nodeIndex: node.index,
34
- id: node.id,
35
- width: node.box.w,
36
- height: node.box.h,
37
- canvasBytes,
38
- budgetBytes,
39
- });
40
- }
41
- return issues;
42
- }
43
-
44
- function formatKb(bytes: number): string {
45
- return `${Math.round(bytes / 1024)} KB`;
46
- }
47
-
48
- function minimizationHint(issue: ScrollMemoryIssue): string {
49
- const maxArea = Math.floor(issue.budgetBytes / 2);
50
- const maxHAtWidth = issue.width > 0 ? Math.floor(maxArea / issue.width) : 0;
51
- const maxWAtHeight = issue.height > 0 ? Math.floor(maxArea / issue.height) : 0;
52
- return [
53
- `Reduce the scroll viewport in CSS (e.g. height ≤ ${maxHAtWidth}px at ${issue.width}px width, or width ≤ ${maxWAtHeight}px at ${issue.height}px height).`,
54
- "Trim fonts, images, or inactive screens to free heap for canvas allocation.",
55
- "Use PSRAM or a board with more SRAM if you need a larger scroll viewport.",
56
- "Adjust display.scroll.scrollCanvasBudgetBytes in cuttlefish.config.ts only if your target has more headroom (runtime allocation may still fail).",
57
- ].join("\n");
58
- }
59
-
60
- /** Emit transpile warnings for scroll viewports that cannot fit a Mode B canvas. */
61
- export function analyzeScrollMemory(
62
- nodes: UINodeModel[],
63
- budgetBytes: number = DEFAULT_SCROLL_CANVAS_BUDGET_BYTES,
64
- ): Diagnostic[] {
65
- return collectScrollMemoryIssues(nodes, budgetBytes).map((issue) => {
66
- const label = issue.id ? `#${issue.id}` : `node ${issue.nodeIndex}`;
67
- return {
68
- severity: "warning" as const,
69
- code: "scroll-canvas-memory",
70
- message:
71
- `Scroll viewport ${label} (${issue.width}×${issue.height}px) needs ${issue.canvasBytes} bytes ` +
72
- `(${formatKb(issue.canvasBytes)}) for accurate smooth scrolling, exceeding the ` +
73
- `${issue.budgetBytes}-byte budget (~${formatKb(issue.budgetBytes)}). ` +
74
- "Rendering will fall back to Mode C strip scroll or freeze updates until memory is available — " +
75
- "scrolling may tear, stutter, or skip frames.",
76
- hint: minimizationHint(issue),
77
- };
78
- });
79
- }