round-core 0.0.6 → 0.0.8

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 (46) hide show
  1. package/README.md +21 -0
  2. package/dist/index.d.ts +341 -326
  3. package/dist/vite-plugin.js +52 -3
  4. package/package.json +7 -3
  5. package/.github/workflows/benchmarks.yml +0 -44
  6. package/Round.png +0 -0
  7. package/benchmarks/apps/react/index.html +0 -9
  8. package/benchmarks/apps/react/main.jsx +0 -25
  9. package/benchmarks/apps/react/vite.config.js +0 -12
  10. package/benchmarks/apps/round/index.html +0 -11
  11. package/benchmarks/apps/round/main.jsx +0 -22
  12. package/benchmarks/apps/round/vite.config.js +0 -15
  13. package/benchmarks/bun.lock +0 -497
  14. package/benchmarks/dist-bench/react/assets/index-9KGqIPOU.js +0 -8
  15. package/benchmarks/dist-bench/react/index.html +0 -10
  16. package/benchmarks/dist-bench/round/assets/index-CBBIRhox.js +0 -52
  17. package/benchmarks/dist-bench/round/index.html +0 -8
  18. package/benchmarks/package.json +0 -22
  19. package/benchmarks/scripts/measure-build.js +0 -64
  20. package/benchmarks/tests/runtime.bench.js +0 -51
  21. package/benchmarks/vitest.config.js +0 -8
  22. package/bun.lock +0 -425
  23. package/cli.js +0 -2
  24. package/index.js +0 -2
  25. package/logo.svg +0 -10
  26. package/src/cli.js +0 -608
  27. package/src/compiler/index.js +0 -2
  28. package/src/compiler/transformer.js +0 -443
  29. package/src/compiler/vite-plugin.js +0 -472
  30. package/src/index.d.ts +0 -326
  31. package/src/index.js +0 -45
  32. package/src/runtime/context.js +0 -101
  33. package/src/runtime/dom.js +0 -403
  34. package/src/runtime/error-boundary.js +0 -48
  35. package/src/runtime/error-reporter.js +0 -13
  36. package/src/runtime/error-store.js +0 -85
  37. package/src/runtime/errors.js +0 -152
  38. package/src/runtime/lifecycle.js +0 -142
  39. package/src/runtime/markdown.js +0 -72
  40. package/src/runtime/router.js +0 -468
  41. package/src/runtime/signals.js +0 -548
  42. package/src/runtime/store.js +0 -215
  43. package/src/runtime/suspense.js +0 -128
  44. package/vite.config.build.js +0 -48
  45. package/vite.config.js +0 -10
  46. package/vitest.config.js +0 -8
@@ -1,152 +0,0 @@
1
- import { createElement } from './dom.js';
2
- import { clearErrors, useErrors, reportError } from './error-store.js';
3
-
4
- export { reportError } from './error-store.js';
5
-
6
- export function ErrorProvider(props = {}) {
7
- return createElement('span', { style: { display: 'contents' } }, () => {
8
- const list = useErrors()();
9
- if (!Array.isArray(list) || list.length === 0) return props.children ?? null;
10
-
11
- const first = list[0];
12
-
13
- return createElement(
14
- 'div',
15
- {
16
- style: {
17
- position: 'fixed',
18
- inset: '0',
19
- zIndex: 2147483647,
20
- display: 'flex',
21
- alignItems: 'center',
22
- justifyContent: 'center',
23
- padding: '24px',
24
- background: 'rgba(17, 24, 39, 0.72)',
25
- backdropFilter: 'blur(10px)',
26
- WebkitBackdropFilter: 'blur(10px)'
27
- }
28
- },
29
- createElement(
30
- 'div',
31
- {
32
- style: {
33
- width: 'min(900px, 100%)',
34
- borderRadius: '14px',
35
- border: '1px solid rgba(255,255,255,0.12)',
36
- background: 'rgba(0,0,0,0.55)',
37
- boxShadow: '0 30px 80px rgba(0,0,0,0.55)',
38
- color: '#fff',
39
- overflow: 'hidden'
40
- }
41
- },
42
- createElement(
43
- 'div',
44
- {
45
- style: {
46
- padding: '14px 16px',
47
- display: 'flex',
48
- alignItems: 'center',
49
- gap: '10px',
50
- borderBottom: '1px solid rgba(255,255,255,0.10)',
51
- background: 'linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0))'
52
- }
53
- },
54
- createElement('div', {
55
- style: {
56
- width: '10px',
57
- height: '10px',
58
- borderRadius: '999px',
59
- background: '#ef4444',
60
- boxShadow: '0 0 0 4px rgba(239,68,68,0.18)'
61
- }
62
- }),
63
- createElement('strong', { style: { fontFamily: 'ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial' } }, 'Round Error'),
64
- createElement('span', { style: { opacity: 0.75, fontFamily: 'ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial', fontSize: '12px' } }, new Date(first.time).toLocaleString()),
65
- createElement('button', {
66
- style: {
67
- marginLeft: 'auto',
68
- border: '1px solid rgba(255,255,255,0.16)',
69
- background: 'rgba(255,255,255,0.08)',
70
- color: '#fff',
71
- padding: '8px 10px',
72
- borderRadius: '10px',
73
- cursor: 'pointer'
74
- },
75
- onMouseOver: (e) => { try { e.currentTarget.style.background = 'rgba(255,255,255,0.12)'; } catch { } },
76
- onMouseOut: (e) => { try { e.currentTarget.style.background = 'rgba(255,255,255,0.08)'; } catch { } },
77
- onClick: () => clearErrors()
78
- }, 'Dismiss')
79
- ),
80
- createElement(
81
- 'div',
82
- {
83
- style: {
84
- padding: '16px',
85
- fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
86
- }
87
- },
88
- createElement('div', { style: { fontSize: '14px', fontWeight: '700' } }, String(first.message ?? 'Error')),
89
- createElement(
90
- 'div',
91
- { style: { marginTop: '10px', opacity: 0.85, fontSize: '12px', lineHeight: '18px' } },
92
- first.component ? createElement('div', null, createElement('span', { style: { opacity: 0.75 } }, 'Component: '), String(first.component)) : null,
93
- first.phase ? createElement('div', null, createElement('span', { style: { opacity: 0.75 } }, 'Phase: '), String(first.phase)) : null
94
- ),
95
- first.stack
96
- ? createElement('pre', {
97
- style: {
98
- marginTop: '12px',
99
- padding: '12px',
100
- borderRadius: '12px',
101
- background: 'rgba(0,0,0,0.55)',
102
- border: '1px solid rgba(255,255,255,0.10)',
103
- whiteSpace: 'pre-wrap',
104
- fontSize: '12px',
105
- lineHeight: '18px',
106
- overflow: 'auto',
107
- maxHeight: '55vh'
108
- }
109
- }, String(first.stack))
110
- : null
111
- )
112
- )
113
- );
114
- });
115
- }
116
-
117
- export function initErrorHandling(container) {
118
- if (typeof document === 'undefined') return;
119
- if (!container || !(container instanceof Element)) return;
120
-
121
- if (!document.querySelector('[data-round-error-style="1"]')) {
122
- const style = document.createElement('style');
123
- style.setAttribute('data-round-error-style', '1');
124
- style.textContent = `
125
- [data-round-error-root="1"] pre{scrollbar-width:thin;scrollbar-color:rgba(255,255,255,0.28) rgba(255,255,255,0.06);}
126
- [data-round-error-root="1"] pre::-webkit-scrollbar{width:10px;height:10px;}
127
- [data-round-error-root="1"] pre::-webkit-scrollbar-track{background:rgba(255,255,255,0.06);border-radius:999px;}
128
- [data-round-error-root="1"] pre::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.22);border-radius:999px;border:2px solid rgba(0,0,0,0.35);}
129
- [data-round-error-root="1"] pre::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,0.32);}
130
- `.trim();
131
- document.head.appendChild(style);
132
- }
133
-
134
- if (!document.querySelector('[data-round-error-root="1"]')) {
135
- const root = document.createElement('div');
136
- root.setAttribute('data-round-error-root', '1');
137
- container.appendChild(root);
138
- root.appendChild(createElement(ErrorProvider, null));
139
- }
140
-
141
- if (!window.__round_error_handlers_installed) {
142
- window.__round_error_handlers_installed = true;
143
-
144
- window.addEventListener('error', (e) => {
145
- reportError(e?.error ?? e?.message ?? e, { phase: 'window.error' });
146
- });
147
-
148
- window.addEventListener('unhandledrejection', (e) => {
149
- reportError(e?.reason ?? e, { phase: 'window.unhandledrejection' });
150
- });
151
- }
152
- }
@@ -1,142 +0,0 @@
1
- import { reportErrorSafe } from './error-reporter.js';
2
-
3
- const componentStack = [];
4
-
5
- export function getCurrentComponent() {
6
- return componentStack[componentStack.length - 1];
7
- }
8
-
9
- export function runInLifecycle(componentInstance, fn) {
10
- componentStack.push(componentInstance);
11
- try {
12
- return fn();
13
- } finally {
14
- componentStack.pop();
15
- }
16
- }
17
-
18
- export function createComponentInstance() {
19
- return {
20
- mountHooks: [],
21
- unmountHooks: [],
22
- updateHooks: [],
23
- nodes: [],
24
- isMounted: false,
25
- mountTimerId: null
26
- };
27
- }
28
-
29
- export function onMount(fn) {
30
- const component = getCurrentComponent();
31
- if (component) {
32
- component.mountHooks.push(fn);
33
- } else {
34
- setTimeout(() => {
35
- try {
36
- fn();
37
- } catch (e) {
38
- reportErrorSafe(e, { phase: 'onMount' });
39
- }
40
- }, 0);
41
- }
42
- }
43
-
44
- export function onUnmount(fn) {
45
- const component = getCurrentComponent();
46
- if (component) {
47
- component.unmountHooks.push(fn);
48
- }
49
- }
50
-
51
- export const onCleanup = onUnmount;
52
-
53
- export function onUpdate(fn) {
54
- const component = getCurrentComponent();
55
- if (component) {
56
- component.updateHooks.push(fn);
57
- }
58
- }
59
-
60
- export function mountComponent(component) {
61
- if (component.isMounted) return;
62
-
63
- try {
64
- const root = component?.nodes?.[0];
65
- if (root && root instanceof Node && root.isConnected === false) {
66
- return;
67
- }
68
- } catch {
69
- }
70
-
71
- component.isMounted = true;
72
- component.mountHooks.forEach(hook => {
73
- try {
74
- const cleanup = hook();
75
- if (typeof cleanup === 'function') {
76
- component.unmountHooks.push(cleanup);
77
- }
78
- } catch (e) {
79
- reportErrorSafe(e, { phase: 'mount', component: component.name ?? null });
80
- }
81
- });
82
- }
83
-
84
- export function unmountComponent(component) {
85
- if (!component.isMounted) return;
86
-
87
- if (component.mountTimerId != null) {
88
- try {
89
- clearTimeout(component.mountTimerId);
90
- } catch {
91
- }
92
- component.mountTimerId = null;
93
- }
94
-
95
- component.isMounted = false;
96
- component.unmountHooks.forEach(hook => {
97
- try {
98
- hook();
99
- } catch (e) {
100
- reportErrorSafe(e, { phase: 'unmount', component: component.name ?? null });
101
- }
102
- });
103
- }
104
-
105
- export function triggerUpdate(component) {
106
- if (!component.isMounted) return;
107
- component.updateHooks.forEach(hook => {
108
- try {
109
- hook();
110
- } catch (e) {
111
- reportErrorSafe(e, { phase: 'update', component: component.name ?? null });
112
- }
113
- });
114
- }
115
-
116
- const observer = (typeof MutationObserver !== 'undefined')
117
- ? new MutationObserver((mutations) => {
118
- mutations.forEach(mutation => {
119
- if (mutation.removedNodes.length > 0) {
120
- mutation.removedNodes.forEach(node => {
121
- if (node._componentInstance) {
122
- unmountComponent(node._componentInstance);
123
- }
124
- cleanupNodeRecursively(node);
125
- });
126
- }
127
- });
128
- })
129
- : null;
130
-
131
- function cleanupNodeRecursively(node) {
132
- if (node._componentInstance) {
133
- unmountComponent(node._componentInstance);
134
- }
135
- node.childNodes.forEach(cleanupNodeRecursively);
136
- }
137
-
138
- export function initLifecycleRoot(rootNode) {
139
- if (!rootNode) return;
140
- if (!observer) return;
141
- observer.observe(rootNode, { childList: true, subtree: true });
142
- }
@@ -1,72 +0,0 @@
1
- import { signal } from './signals.js';
2
- import { onMount } from './lifecycle.js';
3
- import { createElement } from './dom.js';
4
- import { marked } from 'marked';
5
- import { reportErrorSafe } from './error-reporter.js';
6
-
7
- const mdLoaders = (typeof import.meta !== 'undefined' && typeof import.meta.glob === 'function')
8
- ? import.meta.glob('/src/**/*.md', { query: '?raw', import: 'default' })
9
- : {};
10
-
11
- export function Markdown(props = {}) {
12
- const html = signal('');
13
-
14
- const parse = (md) => {
15
- try {
16
- return marked.parse(md ?? '');
17
- } catch {
18
- return '';
19
- }
20
- };
21
-
22
- if (typeof props.content === 'string') {
23
- html(parse(props.content));
24
- }
25
-
26
- onMount(async () => {
27
- if (typeof props.src !== 'string') return;
28
-
29
- const base = typeof props.base === 'string' ? props.base : '/src';
30
- const resolved = props.src.startsWith('./') ? (base + props.src.slice(1)) : props.src;
31
-
32
- const loader = mdLoaders[resolved];
33
- if (typeof loader === 'function') {
34
- try {
35
- const text = await loader();
36
- html(parse(text ?? ''));
37
- return;
38
- } catch (e) {
39
- reportErrorSafe(e instanceof Error ? e : new Error(`Failed to load markdown: ${resolved}`), { phase: 'markdown.load', component: 'Markdown' });
40
- html('');
41
- return;
42
- }
43
- }
44
-
45
- try {
46
- const r = await fetch(resolved);
47
- if (!r.ok) {
48
- reportErrorSafe(new Error(`Markdown not found: ${resolved} (HTTP ${r.status})`), { phase: 'markdown.fetch', component: 'Markdown' });
49
- html('');
50
- return;
51
- }
52
- const text = await r.text();
53
-
54
- const looksLikeHtml = /^\s*<!doctype\s+html\b|^\s*<html\b/i.test(text);
55
- if (looksLikeHtml) {
56
- reportErrorSafe(new Error(`Markdown not found (served HTML fallback): ${resolved}`), { phase: 'markdown.fetch', component: 'Markdown' });
57
- html('');
58
- return;
59
- }
60
- html(parse(text));
61
- } catch (e) {
62
- reportErrorSafe(e instanceof Error ? e : new Error(`Failed to fetch markdown: ${resolved}`), { phase: 'markdown.fetch', component: 'Markdown' });
63
- html('');
64
- }
65
- });
66
-
67
- const className = props.className ?? props.theme ?? '';
68
- return createElement('div', {
69
- className,
70
- dangerouslySetInnerHTML: () => ({ __html: html() })
71
- });
72
- }