-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
582 lines (563 loc) · 20.5 KB
/
app.js
File metadata and controls
582 lines (563 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
const officialResources = [
{
name: "Pretext repository",
description: "The upstream project: API, caveats, benchmarks, and the core layout model.",
url: "https://github.com/chenglou/pretext",
label: "official repo",
},
{
name: "Live demos by Cheng Lou",
description: "The fastest way to understand what Pretext unlocks in a browser.",
url: "https://chenglou.me/pretext/",
label: "official demos",
},
{
name: "Community demo collection",
description: "A second set of demos and experiments surfaced by the community.",
url: "https://somnai-dreams.github.io/pretext-demos/",
label: "demo archive",
},
{
name: "Development notes",
description: "The upstream development guide and setup details for working on Pretext itself.",
url: "https://github.com/chenglou/pretext/blob/main/DEVELOPMENT.md",
label: "developer notes",
},
];
const featuredPackages = [
"pretext-react",
"pretext-chat",
"pretext-terminal",
"pretext-editor",
"pretext-pdf",
"pretext-canvas",
];
const packages = [
{
name: "pretext-react",
category: "Foundations",
summary: "React hooks and UI primitives for stable text measurement, shrinkwrap, and streaming layout.",
repo: "https://github.com/ShipItAndPray/pretext-react",
demo: "https://shipitandpray.github.io/pretext-react/",
tags: ["react", "hooks", "ui", "streaming"],
},
{
name: "pretext-chat",
category: "Chat & Logs",
summary: "Chat UI components with message premeasurement, virtualization, and streaming-friendly bubbles.",
repo: "https://github.com/ShipItAndPray/pretext-chat",
demo: "https://shipitandpray.github.io/pretext-chat/",
tags: ["chat", "react", "virtualization", "ai-ui"],
},
{
name: "pretext-terminal",
category: "Chat & Logs",
summary: "Canvas-first terminal and log surface for ANSI-rich output and large scrollback.",
repo: "https://github.com/ShipItAndPray/pretext-terminal",
demo: "https://shipitandpray.github.io/pretext-terminal/",
tags: ["terminal", "ansi", "canvas", "logviewer"],
},
{
name: "pretext-editor",
category: "Editors & Docs",
summary: "Canvas text editor driven by Pretext line layout instead of DOM text nodes.",
repo: "https://github.com/ShipItAndPray/pretext-editor",
demo: "https://shipitandpray.github.io/pretext-editor/",
tags: ["editor", "canvas", "text", "monaco-alternative"],
},
{
name: "pretext-pdf",
category: "Editors & Docs",
summary: "PDF generation with correct wrapping, pagination, and layout using Pretext plus pdf-lib.",
repo: "https://github.com/ShipItAndPray/pretext-pdf",
demo: "https://shipitandpray.github.io/pretext-pdf/",
tags: ["pdf", "docgen", "pagination", "layout"],
},
{
name: "pretext-canvas",
category: "Graphics & Media",
summary: "Canvas and WebGL text rendering helpers for wrapped labels, atlases, and text boxes.",
repo: "https://github.com/ShipItAndPray/pretext-canvas",
demo: "https://shipitandpray.github.io/pretext-canvas/",
tags: ["canvas", "webgl", "labels", "rendering"],
},
{
name: "pretext-accordion",
category: "Foundations",
summary: "Zero-CLS accordion component with predictive height measurement.",
repo: "https://github.com/ShipItAndPray/pretext-accordion",
demo: "https://shipitandpray.github.io/pretext-accordion/",
tags: ["accordion", "cls", "ui"],
},
{
name: "pretext-blocks",
category: "Editors & Docs",
summary: "Notion-style block editor virtualization with predicted block heights.",
repo: "https://github.com/ShipItAndPray/pretext-blocks",
demo: "https://shipitandpray.github.io/pretext-blocks/",
tags: ["blocks", "editor", "virtualization"],
},
{
name: "pretext-captions",
category: "Editors & Docs",
summary: "Subtitle editor and renderer with SRT/VTT/ASS support and WCAG-aware layout.",
repo: "https://github.com/ShipItAndPray/pretext-captions",
demo: "https://shipitandpray.github.io/pretext-captions/",
tags: ["subtitles", "captions", "accessibility"],
},
{
name: "pretext-comic",
category: "Graphics & Media",
summary: "Speech bubbles and shape-aware text fitting for comics and dialogue-driven scenes.",
repo: "https://github.com/ShipItAndPray/pretext-comic",
demo: "https://shipitandpray.github.io/pretext-comic/",
tags: ["comic", "speech-bubble", "canvas"],
},
{
name: "pretext-diff",
category: "Editors & Docs",
summary: "Virtualized side-by-side diff viewer for very large text comparisons.",
repo: "https://github.com/ShipItAndPray/pretext-diff",
demo: "https://shipitandpray.github.io/pretext-diff/",
tags: ["diff", "editor", "virtualization"],
},
{
name: "pretext-docgen",
category: "Editors & Docs",
summary: "Document generation without a headless browser, built around deterministic text layout.",
repo: "https://github.com/ShipItAndPray/pretext-docgen",
demo: "https://shipitandpray.github.io/pretext-docgen/",
tags: ["docgen", "pdf", "serverless"],
},
{
name: "pretext-epub",
category: "Editors & Docs",
summary: "EPUB pagination engine with direct page access driven by exact text measurements.",
repo: "https://github.com/ShipItAndPray/pretext-epub",
demo: "https://shipitandpray.github.io/pretext-epub/",
tags: ["epub", "pagination", "reading"],
},
{
name: "pretext-forms",
category: "Foundations",
summary: "Auto-sizing textarea, input, and select components without a measure-after-paint loop.",
repo: "https://github.com/ShipItAndPray/pretext-forms",
demo: "https://shipitandpray.github.io/pretext-forms/",
tags: ["forms", "textarea", "inputs"],
},
{
name: "pretext-logviewer",
category: "Chat & Logs",
summary: "Large log viewer with ANSI colors, search, and virtualized scroll for huge outputs.",
repo: "https://github.com/ShipItAndPray/pretext-logviewer",
demo: "https://shipitandpray.github.io/pretext-logviewer/",
tags: ["logs", "ansi", "search", "virtualization"],
},
{
name: "pretext-markdown",
category: "Editors & Docs",
summary: "Streaming markdown renderer with stable block sizing and lower layout jitter.",
repo: "https://github.com/ShipItAndPray/pretext-markdown",
demo: "https://shipitandpray.github.io/pretext-markdown/",
tags: ["markdown", "streaming", "renderer"],
},
{
name: "pretext-masonry",
category: "Foundations",
summary: "Pinterest-style masonry layout using predicted card heights instead of post-render reads.",
repo: "https://github.com/ShipItAndPray/pretext-masonry",
demo: "https://shipitandpray.github.io/pretext-masonry/",
tags: ["masonry", "grid", "virtualization"],
},
{
name: "pretext-og",
category: "Graphics & Media",
summary: "Open Graph image generation with better text wrapping and layout than typical Satori flows.",
repo: "https://github.com/ShipItAndPray/pretext-og",
demo: "https://shipitandpray.github.io/pretext-og/",
tags: ["og-image", "images", "text-layout"],
},
{
name: "pretext-rn",
category: "Platform Targets",
summary: "React Native bridge for text measurement and FlatList-style layout prediction.",
repo: "https://github.com/ShipItAndPray/pretext-rn",
demo: "https://shipitandpray.github.io/pretext-rn/",
tags: ["react-native", "mobile", "bridge"],
},
{
name: "pretext-slides",
category: "Editors & Docs",
summary: "Markdown-to-canvas presentation tool with Pretext-powered slide layout.",
repo: "https://github.com/ShipItAndPray/pretext-slides",
demo: "https://shipitandpray.github.io/pretext-slides/",
tags: ["slides", "presentations", "canvas"],
},
{
name: "pretext-ssr",
category: "Foundations",
summary: "Font fallback prediction and zero-CLS SSR layout workflows.",
repo: "https://github.com/ShipItAndPray/pretext-ssr",
demo: "https://shipitandpray.github.io/pretext-ssr/",
tags: ["ssr", "fonts", "cls"],
},
{
name: "pretext-table",
category: "Platform Targets",
summary: "Virtualized table with Pretext-powered column sizing and lower measurement cost.",
repo: "https://github.com/ShipItAndPray/pretext-table",
demo: "https://shipitandpray.github.io/pretext-table/",
tags: ["table", "data-grid", "virtualization"],
},
{
name: "pretext-tooltip",
category: "Foundations",
summary: "Tooltips that know their dimensions before render, avoiding repositioning flash.",
repo: "https://github.com/ShipItAndPray/pretext-tooltip",
demo: "https://shipitandpray.github.io/pretext-tooltip/",
tags: ["tooltip", "overlay", "ui"],
},
{
name: "pretext-truncate",
category: "Foundations",
summary: "Multiline truncation without content flash or measure-after-paint hacks.",
repo: "https://github.com/ShipItAndPray/pretext-truncate",
demo: "https://shipitandpray.github.io/pretext-truncate/",
tags: ["truncate", "multiline", "ui"],
},
{
name: "pretext-tts-highlight",
category: "Graphics & Media",
summary: "Word-by-word highlight rendering synced to TTS or other audio timelines.",
repo: "https://github.com/ShipItAndPray/pretext-tts-highlight",
demo: "https://shipitandpray.github.io/pretext-tts-highlight/",
tags: ["tts", "audio", "karaoke"],
},
{
name: "pretext-typewriter",
category: "Foundations",
summary: "Streaming typewriter effects that pre-measure the final box and reduce shift.",
repo: "https://github.com/ShipItAndPray/pretext-typewriter",
demo: "https://shipitandpray.github.io/pretext-typewriter/",
tags: ["typewriter", "animation", "streaming"],
},
{
name: "pretext-webxr",
category: "Graphics & Media",
summary: "XR-oriented text layout helpers for canvas, 3D, and spatial text surfaces.",
repo: "https://github.com/ShipItAndPray/pretext-webxr",
demo: "https://shipitandpray.github.io/pretext-webxr/",
tags: ["webxr", "3d", "spatial-ui"],
},
{
name: "pretext-a11y",
category: "Testing & CI",
summary: "WCAG text overflow audit in CI. No browser needed.",
repo: "https://github.com/ShipItAndPray/pretext-a11y",
demo: "https://shipitandpray.github.io/pretext-a11y/",
tags: ["a11y", "wcag", "ci", "overflow"],
},
{
name: "pretext-animate",
category: "Foundations",
summary: "Physics-based text animations with zero layout reflows. 120fps on mid-range devices.",
repo: "https://github.com/ShipItAndPray/pretext-animate",
demo: "https://shipitandpray.github.io/pretext-animate/",
tags: ["animation", "physics", "canvas"],
},
{
name: "pretext-code-minimap",
category: "Graphics & Media",
summary: "VS Code-style code minimap for the browser. Pixel-accurate, Canvas-rendered.",
repo: "https://github.com/ShipItAndPray/pretext-code-minimap",
demo: "https://shipitandpray.github.io/pretext-code-minimap/",
tags: ["minimap", "editor", "canvas"],
},
{
name: "pretext-devtools",
category: "Testing & CI",
summary: "Overlay Pretext text measurements on any webpage. See predicted vs actual dimensions.",
repo: "https://github.com/ShipItAndPray/pretext-devtools",
demo: "https://shipitandpray.github.io/pretext-devtools/",
tags: ["devtools", "debugging", "overlay"],
},
{
name: "pretext-diff-navigator",
category: "Editors & Docs",
summary: "Side-by-side diff viewer with drift-free synchronized scrolling.",
repo: "https://github.com/ShipItAndPray/pretext-diff-navigator",
demo: "https://shipitandpray.github.io/pretext-diff-navigator/",
tags: ["diff", "scroll-sync", "editor"],
},
{
name: "pretext-gantt",
category: "Graphics & Media",
summary: "Zero-flicker Gantt chart with labels measured and placed correctly on frame 1.",
repo: "https://github.com/ShipItAndPray/pretext-gantt",
demo: "https://shipitandpray.github.io/pretext-gantt/",
tags: ["gantt", "chart", "canvas"],
},
{
name: "pretext-i18n",
category: "Testing & CI",
summary: "Catch i18n text overflow at build time. No browser needed.",
repo: "https://github.com/ShipItAndPray/pretext-i18n",
demo: "https://shipitandpray.github.io/pretext-i18n/",
tags: ["i18n", "overflow", "ci"],
},
{
name: "pretext-infinite-canvas",
category: "Graphics & Media",
summary: "Figma/Miro-style infinite canvas with correct text wrapping at any zoom level.",
repo: "https://github.com/ShipItAndPray/pretext-infinite-canvas",
demo: "https://shipitandpray.github.io/pretext-infinite-canvas/",
tags: ["canvas", "infinite", "zoom", "figma"],
},
{
name: "pretext-map-labels",
category: "Graphics & Media",
summary: "Collision-free label placement for 2D maps and diagrams.",
repo: "https://github.com/ShipItAndPray/pretext-map-labels",
demo: "https://shipitandpray.github.io/pretext-map-labels/",
tags: ["maps", "labels", "collision"],
},
{
name: "pretext-overflow-menu",
category: "Foundations",
summary: "Nav bar that collapses items into '+N more' dropdown correctly on frame 1.",
repo: "https://github.com/ShipItAndPray/pretext-overflow-menu",
demo: "https://shipitandpray.github.io/pretext-overflow-menu/",
tags: ["overflow", "menu", "nav", "ui"],
},
{
name: "pretext-overflow-monitor",
category: "Testing & CI",
summary: "Detect text overflow in CI before any browser render. Zero DOM, pure arithmetic.",
repo: "https://github.com/ShipItAndPray/pretext-overflow-monitor",
demo: "https://shipitandpray.github.io/pretext-overflow-monitor/",
tags: ["overflow", "ci", "monitoring"],
},
{
name: "pretext-repl",
category: "Chat & Logs",
summary: "REPL/notebook UI where output cells expand without shifting other cells.",
repo: "https://github.com/ShipItAndPray/pretext-repl",
demo: "https://shipitandpray.github.io/pretext-repl/",
tags: ["repl", "notebook", "virtualization"],
},
{
name: "pretext-sparkline",
category: "Graphics & Media",
summary: "Inline sparklines with collision-free value labels computed before render.",
repo: "https://github.com/ShipItAndPray/pretext-sparkline",
demo: "https://shipitandpray.github.io/pretext-sparkline/",
tags: ["sparkline", "chart", "inline"],
},
{
name: "pretext-storybook",
category: "Testing & CI",
summary: "Stress-test UI components with dynamic text. Flags overflow before it ships.",
repo: "https://github.com/ShipItAndPray/pretext-storybook",
demo: "https://shipitandpray.github.io/pretext-storybook/",
tags: ["storybook", "testing", "overflow"],
},
{
name: "pretext-word-cloud",
category: "Graphics & Media",
summary: "Deterministic word cloud layout. 500x faster than d3-cloud.",
repo: "https://github.com/ShipItAndPray/pretext-word-cloud",
demo: "https://shipitandpray.github.io/pretext-word-cloud/",
tags: ["word-cloud", "canvas", "layout"],
},
];
const communityProjects = [
{
name: "pinch-type",
label: "community app",
description: "Pinch-to-zoom typography experiment built on Pretext.",
url: "https://github.com/lucascrespo23/pinch-type",
},
{
name: "pretext-playground",
label: "creative coding",
description: "A strong interactive playground showing how far text-driven scenes can go.",
url: "https://github.com/0xNyk/pretext-playground",
},
{
name: "react-pretext",
label: "react wrapper",
description: "Another React-facing package that demonstrates external ecosystem demand.",
url: "https://github.com/jihchi/react-pretext",
},
{
name: "pretext-rich",
label: "rich text",
description: "Inline rich text layout engine layered on top of Pretext.",
url: "https://github.com/joeflateau-octavius/pretext-rich",
},
{
name: "textmash",
label: "layout experiment",
description: "A compact demo showing text wrapping around other text chunks.",
url: "https://github.com/cocktailpeanut/textmash",
},
{
name: "pretext-php",
label: "language port",
description: "A PHP port that proves the ideas can travel outside TypeScript.",
url: "https://github.com/mateffy/pretext-php",
},
];
const stats = [
{ label: "upstream stars", value: "18,006" },
{ label: "ecosystem packages", value: String(packages.length) },
{ label: "live demos verified", value: String(packages.length) },
{ label: "community examples", value: String(communityProjects.length) },
];
const filters = ["All", ...Array.from(new Set(packages.map((item) => item.category)))];
const statGrid = document.getElementById("stat-grid");
const officialGrid = document.getElementById("official-grid");
const featuredBand = document.getElementById("featured-band");
const packageGrid = document.getElementById("package-grid");
const communityGrid = document.getElementById("community-grid");
const filterRow = document.getElementById("filter-row");
const searchInput = document.getElementById("search-input");
let activeFilter = "All";
let searchTerm = "";
function cardLinks(items) {
return `
<div class="card-links">
${items
.map(
(item) =>
`<a class="button secondary" href="${item.href}" target="_blank" rel="noreferrer">${item.label}</a>`
)
.join("")}
</div>
`;
}
function renderStats() {
statGrid.innerHTML = stats
.map(
(stat) => `
<article class="stat">
<span class="mini-label">${stat.label}</span>
<strong>${stat.value}</strong>
</article>
`
)
.join("");
}
function renderOfficial() {
officialGrid.innerHTML = officialResources
.map(
(item) => `
<article class="card">
<div class="meta">${item.label}</div>
<h3>${item.name}</h3>
<p>${item.description}</p>
${cardLinks([{ href: item.url, label: "open" }])}
</article>
`
)
.join("");
}
function renderFeatured() {
const featured = packages.filter((item) => featuredPackages.includes(item.name));
featuredBand.innerHTML = featured
.map(
(item) => `
<article class="featured-card">
<div class="meta">${item.category}</div>
<h3>${item.name}</h3>
<p>${item.summary}</p>
<div class="tag-row">${item.tags
.slice(0, 3)
.map((tag) => `<span class="tag secondary">${tag}</span>`)
.join("")}</div>
${cardLinks([
{ href: item.repo, label: "repo" },
{ href: item.demo, label: "demo" },
])}
</article>
`
)
.join("");
}
function renderFilters() {
filterRow.innerHTML = filters
.map(
(filter) => `
<button class="chip ${filter === activeFilter ? "active" : ""}" data-filter="${filter}">
${filter}
</button>
`
)
.join("");
filterRow.querySelectorAll("[data-filter]").forEach((button) => {
button.addEventListener("click", () => {
activeFilter = button.dataset.filter;
renderFilters();
renderPackages();
});
});
}
function renderPackages() {
const term = searchTerm.trim().toLowerCase();
const visible = packages.filter((item) => {
const matchesFilter = activeFilter === "All" || item.category === activeFilter;
const haystack = [item.name, item.summary, item.category, ...item.tags].join(" ").toLowerCase();
const matchesSearch = !term || haystack.includes(term);
return matchesFilter && matchesSearch;
});
if (visible.length === 0) {
packageGrid.innerHTML = `
<div class="empty-state">
No packages matched this search. Try a broader term or switch back to the full catalog.
</div>
`;
return;
}
packageGrid.innerHTML = visible
.map(
(item) => `
<article class="card">
<div class="meta">${item.category}</div>
<h3>${item.name}</h3>
<p>${item.summary}</p>
<div class="tag-row">
${item.tags.map((tag) => `<span class="tag">${tag}</span>`).join("")}
</div>
${cardLinks([
{ href: item.repo, label: "repo" },
{ href: item.demo, label: "demo" },
])}
</article>
`
)
.join("");
}
function renderCommunity() {
communityGrid.innerHTML = communityProjects
.map(
(item) => `
<article class="card">
<div class="meta">${item.label}</div>
<h3>${item.name}</h3>
<p>${item.description}</p>
${cardLinks([{ href: item.url, label: "repo" }])}
</article>
`
)
.join("");
}
searchInput.addEventListener("input", (event) => {
searchTerm = event.target.value;
renderPackages();
});
renderStats();
renderOfficial();
renderFeatured();
renderFilters();
renderPackages();
renderCommunity();