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.
- package/README.md +21 -0
- package/dist/index.d.ts +341 -326
- package/dist/vite-plugin.js +52 -3
- package/package.json +7 -3
- package/.github/workflows/benchmarks.yml +0 -44
- package/Round.png +0 -0
- package/benchmarks/apps/react/index.html +0 -9
- package/benchmarks/apps/react/main.jsx +0 -25
- package/benchmarks/apps/react/vite.config.js +0 -12
- package/benchmarks/apps/round/index.html +0 -11
- package/benchmarks/apps/round/main.jsx +0 -22
- package/benchmarks/apps/round/vite.config.js +0 -15
- package/benchmarks/bun.lock +0 -497
- package/benchmarks/dist-bench/react/assets/index-9KGqIPOU.js +0 -8
- package/benchmarks/dist-bench/react/index.html +0 -10
- package/benchmarks/dist-bench/round/assets/index-CBBIRhox.js +0 -52
- package/benchmarks/dist-bench/round/index.html +0 -8
- package/benchmarks/package.json +0 -22
- package/benchmarks/scripts/measure-build.js +0 -64
- package/benchmarks/tests/runtime.bench.js +0 -51
- package/benchmarks/vitest.config.js +0 -8
- package/bun.lock +0 -425
- package/cli.js +0 -2
- package/index.js +0 -2
- package/logo.svg +0 -10
- package/src/cli.js +0 -608
- package/src/compiler/index.js +0 -2
- package/src/compiler/transformer.js +0 -443
- package/src/compiler/vite-plugin.js +0 -472
- package/src/index.d.ts +0 -326
- package/src/index.js +0 -45
- package/src/runtime/context.js +0 -101
- package/src/runtime/dom.js +0 -403
- package/src/runtime/error-boundary.js +0 -48
- package/src/runtime/error-reporter.js +0 -13
- package/src/runtime/error-store.js +0 -85
- package/src/runtime/errors.js +0 -152
- package/src/runtime/lifecycle.js +0 -142
- package/src/runtime/markdown.js +0 -72
- package/src/runtime/router.js +0 -468
- package/src/runtime/signals.js +0 -548
- package/src/runtime/store.js +0 -215
- package/src/runtime/suspense.js +0 -128
- package/vite.config.build.js +0 -48
- package/vite.config.js +0 -10
- package/vitest.config.js +0 -8
package/dist/vite-plugin.js
CHANGED
|
@@ -202,7 +202,7 @@ function transform(code) {
|
|
|
202
202
|
const block = parseBlock(result, blockStart);
|
|
203
203
|
if (!block) break;
|
|
204
204
|
const content = result.substring(block.start + 1, block.end);
|
|
205
|
-
const replacement = `{${list}.map(${item} => (<Fragment>${content}</Fragment>))}`;
|
|
205
|
+
const replacement = `{(() => ${list}.map(${item} => (<Fragment>${content}</Fragment>)))}`;
|
|
206
206
|
const before = result.substring(0, exprStart);
|
|
207
207
|
const after = result.substring(outer.end + 1);
|
|
208
208
|
result = before + replacement + after;
|
|
@@ -220,11 +220,60 @@ function transform(code) {
|
|
|
220
220
|
const block = parseBlock(result, blockStart);
|
|
221
221
|
if (!block) break;
|
|
222
222
|
const content = result.substring(block.start + 1, block.end);
|
|
223
|
-
const replacement = `{${list}.map(${item} => (<Fragment>${content}</Fragment>))}`;
|
|
223
|
+
const replacement = `{(() => ${list}.map(${item} => (<Fragment>${content}</Fragment>)))}`;
|
|
224
224
|
const before = result.substring(0, exprStart);
|
|
225
225
|
const after = result.substring(block.end + 1);
|
|
226
226
|
result = before + replacement + after;
|
|
227
227
|
}
|
|
228
|
+
while (true) {
|
|
229
|
+
const match = result.match(/\{\s*switch\s*\(/);
|
|
230
|
+
if (!match) break;
|
|
231
|
+
const exprStart = match.index;
|
|
232
|
+
const outer = parseBlock(result, exprStart);
|
|
233
|
+
if (!outer) break;
|
|
234
|
+
let i = consumeWhitespace(result, exprStart + 1);
|
|
235
|
+
const head = result.slice(i);
|
|
236
|
+
const mm = head.match(/^switch\s*\((.*?)\)\s*\{/);
|
|
237
|
+
if (!mm) break;
|
|
238
|
+
const cond = mm[1];
|
|
239
|
+
const blockStart = i + mm[0].length - 1;
|
|
240
|
+
const block = parseBlock(result, blockStart);
|
|
241
|
+
if (!block) break;
|
|
242
|
+
const content = result.substring(block.start + 1, block.end);
|
|
243
|
+
const transformedContent = content.replace(/(case\s+.*?:|default:)([\s\S]*?)(?=case\s+.*?:|default:|$)/g, (m, label, body) => {
|
|
244
|
+
const trimmedBody = body.trim();
|
|
245
|
+
if (!trimmedBody) return m;
|
|
246
|
+
if (trimmedBody.startsWith("return ")) return m;
|
|
247
|
+
return `${label} return (<Fragment>${body}</Fragment>);`;
|
|
248
|
+
});
|
|
249
|
+
const replacement = `{(() => { __ROUND_SWITCH__(${cond}) { ${transformedContent} } })}`;
|
|
250
|
+
const before = result.substring(0, exprStart);
|
|
251
|
+
const after = result.substring(outer.end + 1);
|
|
252
|
+
result = before + replacement + after;
|
|
253
|
+
}
|
|
254
|
+
while (true) {
|
|
255
|
+
const match = result.match(/(^|[\n\r])\s*switch\s*\(/m);
|
|
256
|
+
if (!match) break;
|
|
257
|
+
const switchStart = match.index + match[0].lastIndexOf("switch");
|
|
258
|
+
const head = result.slice(switchStart);
|
|
259
|
+
const mm = head.match(/^switch\s*\((.*?)\)\s*\{/);
|
|
260
|
+
if (!mm) break;
|
|
261
|
+
const cond = mm[1];
|
|
262
|
+
const blockStart = switchStart + mm[0].length - 1;
|
|
263
|
+
const block = parseBlock(result, blockStart);
|
|
264
|
+
if (!block) break;
|
|
265
|
+
const content = result.substring(block.start + 1, block.end);
|
|
266
|
+
const transformedContent = content.replace(/(case\s+.*?:|default:)([\s\S]*?)(?=case\s+.*?:|default:|$)/g, (m, label, body) => {
|
|
267
|
+
const trimmedBody = body.trim();
|
|
268
|
+
if (!trimmedBody) return m;
|
|
269
|
+
if (trimmedBody.startsWith("return ")) return m;
|
|
270
|
+
return `${label} return (<Fragment>${body}</Fragment>);`;
|
|
271
|
+
});
|
|
272
|
+
const replacement = `{(() => { __ROUND_SWITCH__(${cond}) { ${transformedContent} } })}`;
|
|
273
|
+
const before = result.substring(0, switchStart);
|
|
274
|
+
const after = result.substring(block.end + 1);
|
|
275
|
+
result = before + replacement + after;
|
|
276
|
+
}
|
|
228
277
|
}
|
|
229
278
|
function findJsxTagEnd(str, startIndex) {
|
|
230
279
|
let inSingle = false;
|
|
@@ -352,7 +401,7 @@ function transform(code) {
|
|
|
352
401
|
result = transformSuspenseBlocks(result);
|
|
353
402
|
result = transformProviderBlocks(result);
|
|
354
403
|
result = result.replace(/\{\s*([A-Za-z_$][\w$]*)\s*\(\s*\)\s*\}/g, "{() => $1()}").replace(/=\{\s*([A-Za-z_$][\w$]*)\s*\(\s*\)\s*\}/g, "={() => $1()}");
|
|
355
|
-
return result;
|
|
404
|
+
return result.replace(/__ROUND_SWITCH__/g, "switch");
|
|
356
405
|
}
|
|
357
406
|
function normalizePath(p) {
|
|
358
407
|
return p.replaceAll("\\", "/");
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "round-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A lightweight frontend framework for SPA with signals and fine grained reactivity",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"readme": "README.md",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": "./dist/index.js",
|
|
9
10
|
"./vite-plugin": "./dist/vite-plugin.js"
|
|
10
11
|
},
|
|
11
12
|
"type": "module",
|
|
12
|
-
"icon": "
|
|
13
|
+
"icon": "Round.png",
|
|
13
14
|
"repository": {
|
|
14
15
|
"url": "https://github.com/ZtaMDev/RoundJS.git"
|
|
15
16
|
},
|
|
@@ -33,13 +34,16 @@
|
|
|
33
34
|
],
|
|
34
35
|
"author": "Round Framework Team",
|
|
35
36
|
"license": "MIT",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
36
40
|
"dependencies": {
|
|
37
41
|
"marked": "^12.0.2",
|
|
38
42
|
"vite": "^5.0.0"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
|
-
"bun-types": "latest",
|
|
42
45
|
"@types/node": "latest",
|
|
46
|
+
"bun-types": "latest",
|
|
43
47
|
"vitest": "^1.6.0"
|
|
44
48
|
},
|
|
45
49
|
"peerDependencies": {
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
name: Framework Benchmarks
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ main ]
|
|
8
|
-
workflow_dispatch:
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
benchmark:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
|
|
17
|
-
- name: Setup Bun
|
|
18
|
-
uses: oven-sh/setup-bun@v1
|
|
19
|
-
with:
|
|
20
|
-
bun-version: latest
|
|
21
|
-
|
|
22
|
-
- name: Install Root Dependencies
|
|
23
|
-
run: bun install
|
|
24
|
-
|
|
25
|
-
- name: Build Round Core
|
|
26
|
-
run: bun run build:core
|
|
27
|
-
|
|
28
|
-
- name: Install Benchmark Dependencies
|
|
29
|
-
working-directory: ./benchmarks
|
|
30
|
-
run: bun install
|
|
31
|
-
|
|
32
|
-
- name: Run Build Benchmarks
|
|
33
|
-
working-directory: ./benchmarks
|
|
34
|
-
run: bun run bench:build
|
|
35
|
-
|
|
36
|
-
- name: Run Runtime Benchmarks
|
|
37
|
-
working-directory: ./benchmarks
|
|
38
|
-
run: bun run bench:runtime
|
|
39
|
-
|
|
40
|
-
- name: Upload Report
|
|
41
|
-
uses: actions/upload-artifact@v4
|
|
42
|
-
with:
|
|
43
|
-
name: benchmark-report
|
|
44
|
-
path: benchmarks/reports/build-bench.json
|
package/Round.png
DELETED
|
Binary file
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
function App() {
|
|
5
|
-
const [count, setCount] = useState(0);
|
|
6
|
-
const [items] = useState(Array.from({ length: 1000 }, (_, i) => i));
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
console.log('React App Mounted');
|
|
10
|
-
}, []);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div>
|
|
14
|
-
<h1>React Benchmark</h1>
|
|
15
|
-
<button onClick={() => setCount(c => c + 1)}>Count: {count}</button>
|
|
16
|
-
<ul>
|
|
17
|
-
{items.map(i => (
|
|
18
|
-
<li key={i}>Item {i}</li>
|
|
19
|
-
))}
|
|
20
|
-
</ul>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
ReactDOM.createRoot(document.getElementById('root')).render(<App />);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createElement, signal, onMount } from 'round-core';
|
|
2
|
-
|
|
3
|
-
export default function App() {
|
|
4
|
-
const count = signal(0);
|
|
5
|
-
const items = signal(Array.from({ length: 1000 }, (_, i) => i));
|
|
6
|
-
|
|
7
|
-
onMount(() => {
|
|
8
|
-
console.log('Round App Mounted');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<div>
|
|
13
|
-
<h1>Round Benchmark</h1>
|
|
14
|
-
<button onClick={() => count(count() + 1)}>Count: {count}</button>
|
|
15
|
-
<ul>
|
|
16
|
-
{() => items().map(i => (
|
|
17
|
-
<li key={i}>Item {i}</li>
|
|
18
|
-
))}
|
|
19
|
-
</ul>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import RoundPlugin from 'round-core/vite-plugin'; // Use package export
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
root: __dirname,
|
|
7
|
-
plugins: [
|
|
8
|
-
RoundPlugin()
|
|
9
|
-
],
|
|
10
|
-
build: {
|
|
11
|
-
outDir: '../../dist-bench/round',
|
|
12
|
-
emptyOutDir: true,
|
|
13
|
-
minify: true
|
|
14
|
-
}
|
|
15
|
-
});
|