create-wirejs-app 2.0.108 → 2.0.110
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/package.json +1 -1
- package/templates/default/api/package.json +1 -1
- package/templates/default/gitignore +1 -0
- package/templates/default/package.json +8 -6
- package/templates/default/src/layouts/main.ts +1 -1
- package/templates/default/src/package.json +4 -0
- package/templates/default/src/ssg/index.ts +1 -0
- package/templates/default/src/ssg/realtime-test.ts +1 -1
- package/templates/default/src/ssg/todo-app.ts +1 -1
- package/templates/default/src/ssg/web-worker-test.ts +25 -0
- package/templates/default/src/ssr/simple-wiki/%.ts +1 -1
- package/templates/default/web-worker/package.json +13 -0
- package/templates/default/web-worker/src/index.ts +22 -0
package/package.json
CHANGED
|
@@ -5,24 +5,26 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
7
7
|
"src",
|
|
8
|
-
"api"
|
|
8
|
+
"api",
|
|
9
|
+
"web-worker"
|
|
9
10
|
],
|
|
10
11
|
"dependencies": {
|
|
11
12
|
"dompurify": "^3.2.3",
|
|
12
13
|
"marked": "^15.0.6",
|
|
13
14
|
"wirejs-dom": "^1.0.41",
|
|
14
|
-
"wirejs-resources": "^0.1.
|
|
15
|
-
"wirejs-components": "^0.1.
|
|
15
|
+
"wirejs-resources": "^0.1.105",
|
|
16
|
+
"wirejs-components": "^0.1.48",
|
|
17
|
+
"wirejs-web-worker": "^1.0.2"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
|
-
"wirejs-scripts": "^3.0.
|
|
20
|
+
"wirejs-scripts": "^3.0.103",
|
|
19
21
|
"typescript": "^5.7.3"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
24
|
"prebuild": "npm run prebuild --workspaces --if-present",
|
|
23
25
|
"prestart": "npm run prestart --workspaces --if-present",
|
|
24
|
-
"start": "wirejs-scripts start",
|
|
25
|
-
"build": "
|
|
26
|
+
"start": "wirejs-scripts ws-run-parallel start",
|
|
27
|
+
"build": "npm run build --workspaces --if-present"
|
|
26
28
|
},
|
|
27
29
|
"engines": {
|
|
28
30
|
"node": ">=20.0.0"
|
|
@@ -11,6 +11,7 @@ export async function generate() {
|
|
|
11
11
|
<li><a href='/todo-app.html'>Todo App</a></li>
|
|
12
12
|
<li><a href='/simple-wiki/index.html'>Simple Wiki</a></li>
|
|
13
13
|
<li><a href='/realtime-test.html'>Realtime Test</a></li>
|
|
14
|
+
<li><a href='/web-worker-test.html'>Web Worker Test</a></li>
|
|
14
15
|
</ul>
|
|
15
16
|
</div>`
|
|
16
17
|
})
|
|
@@ -3,7 +3,7 @@ import DOMPurify from 'dompurify';
|
|
|
3
3
|
import { html, attribute, hydrate, list, text, id } from 'wirejs-dom/v2';
|
|
4
4
|
import { AuthenticatedContent } from 'wirejs-components';
|
|
5
5
|
import { Main } from '../layouts/main.js';
|
|
6
|
-
import { chat } from '
|
|
6
|
+
import { chat } from 'internal-api';
|
|
7
7
|
|
|
8
8
|
type RoomMessage = {
|
|
9
9
|
username: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { html, list, attribute, hydrate } from 'wirejs-dom/v2';
|
|
2
2
|
import { AuthenticatedContent } from 'wirejs-components';
|
|
3
|
-
import { todos, Todo } from '
|
|
3
|
+
import { todos, Todo } from 'internal-api';
|
|
4
4
|
import { Main } from '../layouts/main.js';
|
|
5
5
|
|
|
6
6
|
function Todos() {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { html, hydrate, text } from 'wirejs-dom/v2';
|
|
2
|
+
import { Main } from '../layouts/main.js';
|
|
3
|
+
import { worker } from 'web-worker';
|
|
4
|
+
|
|
5
|
+
async function App() {
|
|
6
|
+
return html`<div id='app'>
|
|
7
|
+
<h4>Web Worker Demo</h4>
|
|
8
|
+
<div>${text('status', '...')}</div>
|
|
9
|
+
<div>Web Worker output: ${text('output', '...')}</div>
|
|
10
|
+
</div>`.onadd(async self => {
|
|
11
|
+
console.log('starting web worker');
|
|
12
|
+
self.data.output = (await worker.count(256_000_000, {
|
|
13
|
+
tick: pct => self.data.status = `${Math.floor(pct * 100)} % complete.`
|
|
14
|
+
})).toString();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function generate() {
|
|
19
|
+
return Main({
|
|
20
|
+
pageTitle: 'Welcome!',
|
|
21
|
+
content: await App()
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
hydrate('app', App as any);
|
|
@@ -2,7 +2,7 @@ import { marked } from 'marked';
|
|
|
2
2
|
import DOMPurify from 'dompurify';
|
|
3
3
|
import { html, id, hydrate, node, } from 'wirejs-dom/v2';
|
|
4
4
|
import type { AuthenticationMachineState, Context } from 'wirejs-resources';
|
|
5
|
-
import { auth, wiki } from '
|
|
5
|
+
import { auth, wiki } from 'internal-api';
|
|
6
6
|
import { AuthMonitor } from 'wirejs-components/utils';
|
|
7
7
|
import { Main } from '../../layouts/main.js';
|
|
8
8
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "web-worker",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
"types": "./src/index.ts",
|
|
7
|
+
"default": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"prebuild": "wirejs-web-worker-build",
|
|
11
|
+
"start": "wirejs-scripts watch src npm run prebuild"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SingleWorker } from 'wirejs-web-worker';
|
|
2
|
+
|
|
3
|
+
export const worker = SingleWorker({
|
|
4
|
+
async count(
|
|
5
|
+
upTo: number,
|
|
6
|
+
options?: { tick?: (pct: number) => void }
|
|
7
|
+
) {
|
|
8
|
+
let lastUpdate = new Date();
|
|
9
|
+
options?.tick?.(0);
|
|
10
|
+
let c = 0;
|
|
11
|
+
for (let i = 0; i < upTo; i++) {
|
|
12
|
+
let current = new Date();
|
|
13
|
+
if (current.getTime() - lastUpdate.getTime() > 50) {
|
|
14
|
+
options?.tick?.(i / upTo);
|
|
15
|
+
lastUpdate = current;
|
|
16
|
+
}
|
|
17
|
+
c++;
|
|
18
|
+
}
|
|
19
|
+
options?.tick?.(1);
|
|
20
|
+
return c;
|
|
21
|
+
}
|
|
22
|
+
});
|