Skip to content

Commit 5752a00

Browse files
committed
upstream sync, simplify math support, removed unused svelte lib packages
1 parent 6100686 commit 5752a00

161 files changed

Lines changed: 464 additions & 11373 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.compatibility/report.json

Lines changed: 144 additions & 144 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
A modern, ESM-first implementation of the PIE (Platform Independent Elements) specification. This is a **new project** (not a refactor) that provides a clean foundation for future PIE development while maintaining backwards compatibility through the legacy pie-elements project.
44

5+
**Current Status**: Early development (v0.1.0) - 28 React-based elements synced from upstream, core infrastructure in place.
6+
57
## Why a New Project?
68

79
The PIE team's work on upstream library modernization (React 18, MUI 7, Tiptap editor) now enables full ESM adoption and modern tooling. This new project takes advantage of those improvements while keeping the legacy pie-elements available for existing consumers.
810

911
## Key Improvements Over Legacy pie-elements
1012

11-
1. **Framework-agnostic architecture** - Supports multiple frameworks (React, Svelte, future Vue/Angular) via web components, not just React
13+
1. **Framework-agnostic architecture** - Architecture designed to support multiple frameworks (React, Svelte, future Vue/Angular) via web components. Currently: React implementations synced from upstream.
1214
2. **ESM-first build system** - Browser-managed dependencies, better caching, smaller bundles (vs CommonJS + webpack IIFE bundles)
1315
3. **Unified player approach** - Element-level players for development (interactive + print), item-level players in pie-players for production
1416
4. **Symmetric package organization** - Peer folders (delivery/author/controller/print) vs asymmetric legacy structure

apps/element-demo/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
},
2222
"devDependencies": {
2323
"@pie-element/multiple-choice": "workspace:*",
24-
"@pie-element/shared-math-rendering-core": "workspace:*",
2524
"@pie-element/shared-math-rendering-mathjax": "workspace:*",
2625
"@sveltejs/adapter-auto": "^3.3.1",
2726
"@sveltejs/kit": "^2.50.1",

apps/element-demo/test/e2e/test-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function waitForMathRendering(page: Page, timeout = 5000) {
1616
if (!mathJax) return true; // No MathJax, consider done
1717

1818
// MathJax 3.x check
19-
if (mathJax.startup && mathJax.startup.promise) {
19+
if (mathJax.startup?.promise) {
2020
return mathJax.startup.promise.then(() => true).catch(() => true);
2121
}
2222

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

bun.lock

Lines changed: 181 additions & 448 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/ARCHITECTURE.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
## Overview
44

5-
This is a modern implementation of the PIE (Platform Independent Elements) specification, built with TypeScript, ESM, and contemporary tooling. The project currently syncs React-based elements from the upstream [pie-elements](https://github.com/PieLabs/pie-elements) repository while providing modern ESM packaging, Vite builds, and improved developer experience. Future plans include native Svelte 5 implementations for smaller bundle sizes and better performance.
5+
This is a modern implementation of the PIE (Platform Independent Elements) specification, built with TypeScript, ESM, and contemporary tooling. The project currently syncs React-based elements from the upstream [pie-elements](https://github.com/PieLabs/pie-elements) repository while providing modern ESM packaging, Vite builds, and improved developer experience.
6+
7+
**Current Status**: Early development (v0.1.0)
8+
- 28 React elements synced from upstream
9+
- Core infrastructure and build tooling established
10+
- Elements are private packages (not yet published to npm)
11+
- Future plans include native Svelte 5 implementations and public npm releases
612

713
## Core Philosophy
814

@@ -43,9 +49,9 @@ This project differs fundamentally from the legacy pie-elements in eight key way
4349
- **Controllers** are pure TypeScript business logic (completely framework-independent)
4450
- **UI implementations** can use any framework (React, Svelte, Vue, Angular) as long as they produce web components
4551
- **Element Player** loads elements via custom element registry, regardless of underlying framework
46-
- **Coexistence**: React and Svelte elements work side-by-side in the same application
52+
- **Current State**: All 28 elements use React; architecture supports future multi-framework implementations
4753

48-
This flexibility allows choosing the right framework for each use case (e.g., Svelte for smaller bundles, React for ecosystem compatibility).
54+
This architectural flexibility will allow choosing the right framework for each use case (e.g., Svelte for smaller bundles, React for ecosystem compatibility).
4955

5056
### 2. ESM-First Build System
5157

@@ -428,16 +434,20 @@ $ git push
428434

429435
**Publishing strategy:**
430436

431-
Not all packages in the monorepo are published to npm:
437+
**Current Status**: All packages are currently marked as `"private": true` and are not published to npm. This is an early development phase decision.
438+
439+
**Future Publishing Plan**:
432440

433-
- **Element packages** (`@pie-element/*`) - Published for external consumption
434-
- **Library packages** (`@pie-lib/*`) - **NOT published independently**
441+
Once the project reaches a stable release (v1.0.0+):
442+
443+
- **Element packages** (`@pie-element/*`) - Will be published for external consumption
444+
- **Library packages** (`@pie-lib/*`) - Will **NOT** be published independently
435445
- These are internal implementation details of the elements
436446
- Bundled into element packages during build
437-
- External consumers never import `@pie-lib` packages directly
447+
- External consumers will never import `@pie-lib` packages directly
438448
- Simplifies the public API surface
439449

440-
This differs from the legacy approach where `@pie-lib` packages were independently published and consumed. In pie-elements-ng, `@pie-lib` packages exist purely for internal code organization within the monorepo.
450+
This will differ from the legacy approach where `@pie-lib` packages were independently published and consumed. In pie-elements-ng, `@pie-lib` packages exist purely for internal code organization within the monorepo.
441451

442452
**Trade-offs:**
443453

@@ -489,7 +499,7 @@ This project maintains compatibility with the existing PIE ecosystem by syncing
489499
### Source Repositories
490500

491501
- **[pie-elements](https://github.com/PieLabs/pie-elements)**`packages/elements-react/`
492-
- 50+ production-tested React element implementations
502+
- 28 React element implementations synced from upstream
493503
- Controllers (business logic)
494504
- UI components (delivery, authoring, print modes)
495505

@@ -499,7 +509,7 @@ This project maintains compatibility with the existing PIE ecosystem by syncing
499509

500510
### Why Sync?
501511

502-
1. **Leverage existing work** - Reuse 50+ production-tested elements
512+
1. **Leverage existing work** - Reuse production-tested elements from upstream
503513
2. **Maintain compatibility** - Ensure consistency with existing PIE consumers
504514
3. **Modernize existing code** - Transform to ESM, TypeScript, and modern tooling
505515
4. **Stable baseline** - Synced React elements provide production-ready implementations
@@ -1160,19 +1170,25 @@ Note: `'unsafe-inline'` for styles is required for Svelte scoped styles.
11601170

11611171
### NPM Publishing
11621172

1163-
Packages are published to npm via GitHub Actions:
1173+
**Current Status**: Packages are not yet published to npm (all marked as `"private": true`).
1174+
1175+
**Future Publishing Strategy**: Once ready for public release, packages will be published via GitHub Actions:
11641176

11651177
1. Developer creates changeset: `bun run changeset`
11661178
2. PR merged to main
11671179
3. GitHub Action creates "Version Packages" PR
11681180
4. Maintainer merges Version PR
11691181
5. Packages automatically published to npm
11701182

1171-
See [PUBLISHING.md](./PUBLISHING.md) for details.
1183+
See [PUBLISHING.md](./PUBLISHING.md) for details (when available).
11721184

11731185
### Versioning
11741186

1175-
This project uses **workspace-wide versioning** where all packages share the same version number. This is a deliberate architectural decision that differs from the upstream pie-elements/pie-lib projects. See [section 8 above](#8-workspace-wide-versioning) for a detailed explanation of why this approach was chosen and the problems it solves.
1187+
This project is designed to use **workspace-wide versioning** where all packages share the same version number. This is a deliberate architectural decision that differs from the upstream pie-elements/pie-lib projects.
1188+
1189+
**Current Status**: All packages are at version `0.1.0` and marked as `"private": true` (not published). Workspace-wide versioning will be enforced when packages are published publicly.
1190+
1191+
See [section 8 above](#8-workspace-wide-versioning) for a detailed explanation of why this approach was chosen and the problems it solves.
11761192

11771193
**Semantic Versioning (SemVer)**:
11781194

@@ -1190,7 +1206,7 @@ All packages follow semantic versioning as a coordinated unit:
11901206
4. All element packages are released together with the same new version
11911207
5. Internal dependencies automatically updated to the new version
11921208

1193-
**Example release:**
1209+
**Example release (future, when published):**
11941210

11951211
```bash
11961212
# Before: All element packages at 1.4.0
@@ -1199,14 +1215,16 @@ $ bun run changeset
11991215
# PR merged
12001216

12011217
# After: All element packages bumped to 1.5.0
1202-
@pie-element/multiple-choice: 1.5.0 # Published to npm
1203-
@pie-element/drag-in-the-blank: 1.5.0 # Published to npm (even though unchanged)
1218+
@pie-element/multiple-choice: 1.5.0 # Will be published to npm
1219+
@pie-element/drag-in-the-blank: 1.5.0 # Will be published to npm (even though unchanged)
12041220

12051221
# Internal packages are versioned but NOT published:
12061222
@pie-lib/render-ui: 1.5.0 # Internal only (bundled into elements)
12071223
@pie-lib/math-rendering: 1.5.0 # Internal only (bundled into elements)
12081224
```
12091225

1226+
**Current Reality**: All packages are at `0.1.0` and private (not published).
1227+
12101228
This ensures all packages are always compatible and tested together. External consumers only interact with `@pie-element/*` packages, which bundle all necessary dependencies.
12111229

12121230
### CDN Distribution

docs/MATH-RENDERING.md

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Math Rendering in pie-elements-ng
22

3-
**Last Updated:** 2026-02-01
3+
**Last Updated:** 2026-02-09
44
**Status:** ✅ Production Ready (MathJax v4)
55

66
## Overview
77

8-
pie-elements-ng uses **MathJax v4** as the default math renderer, providing:
8+
pie-elements-ng uses **MathJax v4** as the math renderer, providing:
99
- ✅ Full accessibility (Speech Rule Engine, WCAG AAA)
1010
- ✅ Native MathML rendering (100% fidelity)
1111
- ✅ ESM-compatible (unlike MathJax v3)
@@ -14,37 +14,28 @@ pie-elements-ng uses **MathJax v4** as the default math renderer, providing:
1414

1515
## Architecture
1616

17-
### Wrapper Pattern
17+
### Direct Implementation
1818

1919
```
2020
@pie-lib/math-rendering (wrapper)
2121
└─> @pie-element/shared-math-rendering-mathjax (~2.7MB via CDN)
2222
└─> MathJax v4 library
2323
```
2424

25-
The wrapper maintains API compatibility with upstream `@pie-lib/math-rendering` while allowing internal implementation changes.
25+
The wrapper maintains API compatibility with upstream `@pie-lib/math-rendering`.
2626

2727
### Key Packages
2828

29-
1. **`@pie-lib/math-rendering`** - Wrapper package (re-exports from adapter)
29+
1. **`@pie-lib/math-rendering`** - Wrapper package (re-exports from MathJax)
3030
- Location: `packages/lib-react/math-rendering/`
3131
- Auto-generated by sync system
3232
- Maintains upstream API compatibility
3333

34-
2. **`@pie-element/shared-math-rendering-mathjax`** - MathJax v4 adapter
34+
2. **`@pie-element/shared-math-rendering-mathjax`** - MathJax v4 implementation
3535
- Location: `packages/shared/math-rendering-mathjax/`
3636
- Loads MathJax v4 from CDN
3737
- Full accessibility support
38-
39-
3. **`@pie-element/shared-math-rendering-katex`** - KaTeX adapter (legacy)
40-
- Location: `packages/shared/math-rendering-katex/`
41-
- Lightweight alternative (~100KB)
42-
- Available for special use cases
43-
44-
4. **`@pie-element/shared-math-rendering-core`** - Core types
45-
- Location: `packages/shared/math-rendering-core/`
46-
- `MathRenderer` interface
47-
- Shared utilities
38+
- Direct implementation (no abstraction layer)
4839

4940
## Usage
5041

@@ -63,13 +54,12 @@ queueMicrotask(() => {
6354

6455
### For Player Developers
6556

66-
Use the factory function for dependency injection:
57+
Use the factory function for custom configuration:
6758

6859
```typescript
6960
import { createMathjaxRenderer } from '@pie-element/shared-math-rendering-mathjax';
70-
import type { MathRenderer } from '@pie-element/shared-math-rendering-core';
7161

72-
const mathRenderer: MathRenderer = createMathjaxRenderer({
62+
const mathRenderer = createMathjaxRenderer({
7363
accessibility: true, // Enable Speech Rule Engine
7464
useSingleDollar: false, // Disable $...$ delimiters
7565
loadFonts: true, // Load MathJax fonts
@@ -146,22 +136,13 @@ MathJax v4 provides WCAG AAA compliance:
146136

147137
## Why MathJax v4?
148138

149-
### Previous Approach (2026-01-30)
150-
151-
Initially used KaTeX wrapper due to MathJax v3 CommonJS incompatibility:
152-
- ✅ Light bundle (~100KB)
153-
- ✅ Fast rendering
154-
- ⚠️ Limited accessibility
155-
- ⚠️ MathML via conversion (fidelity loss)
139+
MathJax v4 is the only viable option for production because:
156140

157-
### Current Approach (2026-02-01)
158-
159-
Switched to MathJax v4 because:
160-
1. **ESM-compatible** - MathJax v4 is pure ESM (unlike v3)
161-
2. **Full accessibility** - Required for WCAG AAA compliance
141+
1. **ESM-compatible** - Pure ESM (unlike MathJax v3)
142+
2. **Full accessibility** - Required for WCAG AAA compliance (Speech Rule Engine)
162143
3. **Native MathML** - 100% rendering fidelity
163144
4. **Same API** - Backward compatible with upstream
164-
5. **CDN loading** - Zero bundle impact in production
145+
5. **CDN loading** - Zero bundle impact (~2.7MB loaded once, cached)
165146

166147
## Migration from Upstream
167148

@@ -233,27 +214,29 @@ MathJax v4 renders MathML natively - no conversion needed. If MathML doesn't ren
233214
2. **Test with screen reader**: Right-click math → should see context menu
234215
3. **Check ARIA labels**: Inspect rendered math for `aria-label` attributes
235216

236-
## Alternative: KaTeX Adapter
217+
## Authoring Tools
237218

238-
For lightweight contexts where full accessibility isn't required:
219+
### React Elements (Current)
239220

240-
```typescript
241-
import { createKatexRenderer } from '@pie-element/shared-math-rendering-katex';
221+
React elements use the upstream **`@pie-lib/editable-html-tip-tap`** package for authoring interfaces. This package includes:
242222

243-
const renderer = createKatexRenderer();
244-
await renderer(element);
245-
```
223+
- **Custom TipTap math extension** with MathQuill integration
224+
- **Interactive math editing** (not just static rendering)
225+
- **MathQuill** for authoring/editing (visual WYSIWYG math editor)
226+
- **MathJax** for final output rendering
227+
228+
This is already synced from upstream and works correctly with React elements.
229+
230+
### Svelte Elements (Future)
231+
232+
When Svelte-based PIE elements are created, the math editing approach will be determined at that time. Options include:
233+
- Porting the custom TipTap math extension to Svelte
234+
- Using the React component via interop
235+
- Creating a Svelte-native math editing solution
246236

247-
**Use when:**
248-
- Preview/authoring interfaces (internal tools)
249-
- Bundle size is critical
250-
- Content is LaTeX-only (no MathML)
251-
- Basic accessibility is sufficient
237+
### Demo Applications
252238

253-
**Limitations:**
254-
- MathML via conversion (may lose fidelity)
255-
- No Speech Rule Engine
256-
- Limited screen reader support
239+
The demo app's RichTextEditor is primarily for displaying/editing JSON source code and doesn't require math support. Math rendering in the demo happens via the element player using MathJax.
257240

258241
## Development
259242

@@ -310,6 +293,7 @@ bun cli upstream:sync
310293

311294
- **2026-01-30**: Initial KaTeX wrapper (ESM compatibility)
312295
- **2026-02-01**: Switched to MathJax v4 (full accessibility)
296+
- **2026-02-09**: Simplified to MathJax-only (removed abstraction layer)
313297

314298
---
315299

docs/PRINT_SUPPORT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ Where `itemConfig` includes:
7474

7575
## Print Element Architecture
7676

77-
Each element package includes a print export:
77+
**Current Coverage**: Print support is available for 10 out of 28 elements. Print components are being added incrementally as elements are developed.
78+
79+
Each element package can include a print export:
7880

7981
```
8082
packages/elements-react/multiple-choice/

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"packages/shared/*",
88
"packages/elements-react/*",
99
"packages/elements-react/*/demo",
10-
"packages/lib-svelte/*",
1110
"packages/lib-react/*",
1211
"packages/element-player",
1312
"packages/core",
@@ -66,7 +65,6 @@
6665
"@types/dompurify": "^3.2.0",
6766
"@types/glob": "^9.0.0",
6867
"@types/js-yaml": "^4.0.9",
69-
"@types/katex": "^0.16.7",
7068
"@types/lodash": "^4.17.21",
7169
"@types/node": "^25.0.3",
7270
"@types/prop-types": "^15.7.15",

0 commit comments

Comments
 (0)