create-qwik 0.0.16 → 0.0.17-0-dev20220310192647
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/starters/apps/base/index.html +3 -3
- package/starters/apps/base/package.json +5 -4
- package/starters/apps/starter/src/entry.server.tsx +2 -2
- package/starters/apps/starter/src/main.tsx +3 -3
- package/starters/apps/starter-builder/src/entry.server.tsx +2 -2
- package/starters/apps/starter-builder/src/main.tsx +1 -1
- package/starters/apps/starter-partytown/src/entry.server.tsx +2 -2
- package/starters/apps/starter-partytown/src/main.tsx +3 -5
- package/starters/apps/todo/src/components/{main/main.tsx → body/body.tsx} +3 -3
- package/starters/apps/todo/src/components/footer/footer.tsx +11 -10
- package/starters/apps/todo/src/components/header/header.tsx +7 -4
- package/starters/apps/todo/src/components/item/item.tsx +13 -5
- package/starters/apps/todo/src/entry.server.tsx +2 -2
- package/starters/apps/todo/src/main.tsx +12 -13
- package/starters/apps/todo/src/state/state.ts +2 -41
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
<script type="module">
|
|
9
9
|
// Vite Dev Mode Only
|
|
10
10
|
import '@builder.io/qwik/qwikloader.js';
|
|
11
|
-
import { render } from '@builder.io/qwik';
|
|
12
|
-
import {
|
|
13
|
-
render(document.body,
|
|
11
|
+
import { render, jsx } from '@builder.io/qwik';
|
|
12
|
+
import { Main } from '/src/main.tsx';
|
|
13
|
+
render(document.body, jsx(Main, {}));
|
|
14
14
|
</script>
|
|
15
15
|
</body>
|
|
16
16
|
</html>
|
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"typecheck": "
|
|
6
|
+
"typecheck": "tsc --noEmit",
|
|
7
7
|
"build": "npm run typecheck && npm run build.client && npm run build.server",
|
|
8
8
|
"build.client": "vite build",
|
|
9
9
|
"build.server": "vite build --outDir server/build --ssr src/entry.server.tsx",
|
|
10
|
-
"
|
|
11
|
-
"dev": "vite",
|
|
10
|
+
"dev.ssr": "vite",
|
|
12
11
|
"dev.client": "vite --mode clientonly",
|
|
12
|
+
"dev.debug": "node --inspect-brk node_modules/vite/bin/vite.js",
|
|
13
|
+
"dev": "npm run dev.client",
|
|
13
14
|
"start": "npm run dev"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/node": "17.0.17",
|
|
17
|
-
"@builder.io/qwik": "0.0.
|
|
18
|
+
"@builder.io/qwik": "0.0.17-0-dev20220310192647",
|
|
18
19
|
"typescript": "4.5.5",
|
|
19
20
|
"vite": "2.8.0"
|
|
20
21
|
},
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
|
|
10
|
-
import {
|
|
10
|
+
import { Main } from './main';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Entry point for server-side pre-rendering.
|
|
@@ -22,7 +22,7 @@ export function render(opts: RenderToStringOptions) {
|
|
|
22
22
|
<title>Qwik Blank App</title>
|
|
23
23
|
</head>
|
|
24
24
|
<body q:base="/">
|
|
25
|
-
<
|
|
25
|
+
<Main />
|
|
26
26
|
<QwikLoader debug={opts.debug} />
|
|
27
27
|
</body>
|
|
28
28
|
</html>,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useStore, $, component$, useEvent, Host } from '@builder.io/qwik';
|
|
2
2
|
import { Logo } from './components/logo/logo';
|
|
3
3
|
|
|
4
4
|
import './global.css';
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
const state =
|
|
6
|
+
export const Main = component$(() => {
|
|
7
|
+
const state = useStore({ name: 'World' });
|
|
8
8
|
return $(() => (
|
|
9
9
|
<Host class="my-app">
|
|
10
10
|
<Logo />
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
|
|
10
|
-
import {
|
|
10
|
+
import { Main } from './main';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Entry point for server-side pre-rendering.
|
|
@@ -22,7 +22,7 @@ export function render(opts: RenderToStringOptions) {
|
|
|
22
22
|
<title>Qwik Blank App</title>
|
|
23
23
|
</head>
|
|
24
24
|
<body q:base="/">
|
|
25
|
-
<
|
|
25
|
+
<Main />
|
|
26
26
|
<script>({fetchQwikBuilderContent.toString()})();</script>
|
|
27
27
|
<QwikLoader debug={opts.debug} />
|
|
28
28
|
</body>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
|
|
10
10
|
import { partytownSnippet } from '@builder.io/partytown/integration';
|
|
11
|
-
import {
|
|
11
|
+
import { Main } from './main';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Entry point for server-side pre-rendering.
|
|
@@ -24,7 +24,7 @@ export function render(opts: RenderToStringOptions) {
|
|
|
24
24
|
<script children={partytownSnippet({ debug: true })} />
|
|
25
25
|
</head>
|
|
26
26
|
<body q:base="/">
|
|
27
|
-
<
|
|
27
|
+
<Main />
|
|
28
28
|
<script type="text/partytown">
|
|
29
29
|
({partyTownExampleWhichBlocksMainThreadForOneSecond.toString()})()
|
|
30
30
|
</script>
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { component$, $, useEvent,
|
|
1
|
+
import { component$, $, useEvent, useStore } from '@builder.io/qwik';
|
|
2
2
|
import './global.css';
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
const state =
|
|
4
|
+
export const Main = component$(() => {
|
|
5
|
+
const state = useStore({ name: 'World', running: true });
|
|
6
6
|
return $(() => {
|
|
7
|
-
// eslint-disable-next-line no-console
|
|
8
|
-
console.log('Qwik: MyApp component is rendering...');
|
|
9
7
|
return (
|
|
10
8
|
<div id="my-app" on$:expensiveComputationDone={() => (state.running = false)}>
|
|
11
9
|
<p style={{ 'text-align': 'center' }}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { component$, Host, $ } from '@builder.io/qwik';
|
|
2
|
-
import {
|
|
2
|
+
import { FILTERS, Todos } from '../../state/state';
|
|
3
3
|
import { Item } from '../item/item';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -7,12 +7,12 @@ import { Item } from '../item/item';
|
|
|
7
7
|
*
|
|
8
8
|
* This component only rerenders/hydrates/downloads if the list of todos changes.
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
10
|
+
export const Body = component$((props: { todos: Todos }) => {
|
|
11
11
|
return $(() => {
|
|
12
12
|
return (
|
|
13
13
|
<Host class="main">
|
|
14
14
|
<ul class="todo-list">
|
|
15
|
-
{
|
|
15
|
+
{props.todos.items.filter(FILTERS[props.todos.filter]).map((key) => (
|
|
16
16
|
<Item item={key} todos={props.todos} />
|
|
17
17
|
))}
|
|
18
18
|
</ul>
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { component$, Host, $ } from '@builder.io/qwik';
|
|
2
|
-
import {
|
|
3
|
-
clearCompleted,
|
|
4
|
-
FilterStates,
|
|
5
|
-
getFilteredCount,
|
|
6
|
-
Todos,
|
|
7
|
-
updateFilter,
|
|
8
|
-
} from '../../state/state';
|
|
2
|
+
import { FILTERS, FilterStates, Todos } from '../../state/state';
|
|
9
3
|
|
|
10
4
|
/**
|
|
11
5
|
* Footer showing items remaining and filtering options
|
|
@@ -24,14 +18,16 @@ export const Footer = component$(
|
|
|
24
18
|
<li>
|
|
25
19
|
<a
|
|
26
20
|
class={{ selected: props.todos.filter == lMode }}
|
|
27
|
-
on$:click={() =>
|
|
21
|
+
on$:click={() => {
|
|
22
|
+
props.todos.filter = filter;
|
|
23
|
+
}}
|
|
28
24
|
>
|
|
29
25
|
{filter[0].toUpperCase() + filter.substr(1)}
|
|
30
26
|
</a>
|
|
31
27
|
</li>
|
|
32
28
|
);
|
|
33
29
|
}
|
|
34
|
-
const remaining =
|
|
30
|
+
const remaining = props.todos.items.filter(FILTERS.active).length;
|
|
35
31
|
return (
|
|
36
32
|
<Host class="footer">
|
|
37
33
|
{props.todos.items.length > 0 ? (
|
|
@@ -46,7 +42,12 @@ export const Footer = component$(
|
|
|
46
42
|
))}
|
|
47
43
|
</ul>
|
|
48
44
|
{remaining > 0 ? (
|
|
49
|
-
<button
|
|
45
|
+
<button
|
|
46
|
+
class="clear-completed"
|
|
47
|
+
on$:click={() => {
|
|
48
|
+
props.todos.items = props.todos.items.filter(FILTERS.active);
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
50
51
|
Clear completed
|
|
51
52
|
</button>
|
|
52
53
|
) : null}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { component$,
|
|
2
|
-
import {
|
|
1
|
+
import { component$, useStore, $, useEvent } from '@builder.io/qwik';
|
|
2
|
+
import type { Todos } from '../../state/state';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Header component which is responsible for providing UI to ender new todo item.
|
|
@@ -8,7 +8,7 @@ import { addItem, Todos } from '../../state/state';
|
|
|
8
8
|
*/
|
|
9
9
|
export const Header = component$(
|
|
10
10
|
(props: { todos: Todos }) => {
|
|
11
|
-
const state =
|
|
11
|
+
const state = useStore({ text: '' });
|
|
12
12
|
return $(() => {
|
|
13
13
|
return (
|
|
14
14
|
<>
|
|
@@ -23,7 +23,10 @@ export const Header = component$(
|
|
|
23
23
|
const inputValue = (event.target as HTMLInputElement).value;
|
|
24
24
|
state.text = inputValue;
|
|
25
25
|
if (event.key === 'Enter' && inputValue) {
|
|
26
|
-
|
|
26
|
+
props.todos.items.push({
|
|
27
|
+
completed: false,
|
|
28
|
+
title: state.text,
|
|
29
|
+
});
|
|
27
30
|
state.text = '';
|
|
28
31
|
}
|
|
29
32
|
}}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
component$,
|
|
3
|
-
|
|
3
|
+
useStore,
|
|
4
4
|
Host,
|
|
5
5
|
notifyRender,
|
|
6
6
|
$,
|
|
7
7
|
useEvent,
|
|
8
8
|
useHostElement,
|
|
9
9
|
} from '@builder.io/qwik';
|
|
10
|
-
import {
|
|
10
|
+
import type { TodoItem, Todos } from '../../state/state';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Individual items of the component.
|
|
@@ -16,7 +16,7 @@ import { removeItem, TodoItem, Todos, toggleItem } from '../../state/state';
|
|
|
16
16
|
*/
|
|
17
17
|
export const Item = component$(
|
|
18
18
|
(props: { item: TodoItem; todos: Todos }) => {
|
|
19
|
-
const state =
|
|
19
|
+
const state = useStore({ editing: false });
|
|
20
20
|
return $(() => {
|
|
21
21
|
return (
|
|
22
22
|
<Host class={{ completed: props.item.completed, editing: state.editing }}>
|
|
@@ -25,7 +25,9 @@ export const Item = component$(
|
|
|
25
25
|
class="toggle"
|
|
26
26
|
type="checkbox"
|
|
27
27
|
checked={props.item.completed}
|
|
28
|
-
on$:click={() =>
|
|
28
|
+
on$:click={() => {
|
|
29
|
+
props.item.completed = !props.item.completed;
|
|
30
|
+
}}
|
|
29
31
|
/>
|
|
30
32
|
<label
|
|
31
33
|
on$:dblclick={async () => {
|
|
@@ -39,7 +41,13 @@ export const Item = component$(
|
|
|
39
41
|
>
|
|
40
42
|
{props.item.title}
|
|
41
43
|
</label>
|
|
42
|
-
<button
|
|
44
|
+
<button
|
|
45
|
+
class="destroy"
|
|
46
|
+
on$:click={() => {
|
|
47
|
+
const todoItem = props.item;
|
|
48
|
+
props.todos.items = props.todos.items.filter((i) => i != todoItem);
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
43
51
|
</div>
|
|
44
52
|
{state.editing ? (
|
|
45
53
|
<input
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
|
|
7
7
|
*/
|
|
8
8
|
import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
|
|
9
|
-
import {
|
|
9
|
+
import { Main } from './main';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Entry point for server-side pre-rendering.
|
|
@@ -21,7 +21,7 @@ export function render(opts: RenderToStringOptions) {
|
|
|
21
21
|
<title>Qwik Demo: ToDo</title>
|
|
22
22
|
</head>
|
|
23
23
|
<body q:base="/">
|
|
24
|
-
<
|
|
24
|
+
<Main />
|
|
25
25
|
<QwikLoader debug={opts.debug} />
|
|
26
26
|
</body>
|
|
27
27
|
</html>,
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { component$,
|
|
1
|
+
import { component$, $, useStore } from '@builder.io/qwik';
|
|
2
2
|
import { Footer } from './components/footer/footer';
|
|
3
3
|
import { Header } from './components/header/header';
|
|
4
|
-
import {
|
|
4
|
+
import { Body } from './components/body/body';
|
|
5
5
|
import type { Todos } from './state/state';
|
|
6
6
|
|
|
7
7
|
import './base.css';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
|
-
export const todos: Todos = {
|
|
11
|
-
filter: 'all',
|
|
12
|
-
items: [
|
|
13
|
-
{ completed: false, title: 'Read Qwik docs' },
|
|
14
|
-
{ completed: false, title: 'Build HelloWorld' },
|
|
15
|
-
{ completed: false, title: 'Profit' },
|
|
16
|
-
],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
10
|
/**
|
|
20
11
|
* Overall application component.
|
|
21
12
|
*
|
|
@@ -23,12 +14,20 @@ export const todos: Todos = {
|
|
|
23
14
|
* Qwik knows that it should never need to be rerendered, and its code will never
|
|
24
15
|
* download to the client.
|
|
25
16
|
*/
|
|
26
|
-
export const
|
|
17
|
+
export const Main = component$(() => {
|
|
18
|
+
const todos = useStore<Todos>({
|
|
19
|
+
filter: 'all',
|
|
20
|
+
items: [
|
|
21
|
+
{ completed: false, title: 'Read Qwik docs' },
|
|
22
|
+
{ completed: false, title: 'Build HelloWorld' },
|
|
23
|
+
{ completed: false, title: 'Profit' },
|
|
24
|
+
],
|
|
25
|
+
});
|
|
27
26
|
return $(() => {
|
|
28
27
|
return (
|
|
29
28
|
<section class="todoapp">
|
|
30
29
|
<Header todos={todos} />
|
|
31
|
-
<
|
|
30
|
+
<Body todos={todos} />
|
|
32
31
|
<Footer todos={todos} />
|
|
33
32
|
</section>
|
|
34
33
|
);
|
|
@@ -12,51 +12,12 @@ export interface Todos {
|
|
|
12
12
|
items: TodoItem[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
////////////////////////////////////////////////////////////////////////
|
|
16
|
-
// Todo Application State Mutation Functions
|
|
17
|
-
////////////////////////////////////////////////////////////////////////
|
|
18
|
-
|
|
19
|
-
export function addItem(todos: Todos, text: string) {
|
|
20
|
-
todos.items.push({ completed: false, title: text });
|
|
21
|
-
updateFilter(todos);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function removeItem(todos: Todos, todoItem: TodoItem) {
|
|
25
|
-
todos.items = todos.items.filter((i) => i != todoItem);
|
|
26
|
-
updateFilter(todos);
|
|
27
|
-
}
|
|
28
|
-
export function toggleItem(todos: Todos, todoItem: TodoItem) {
|
|
29
|
-
todoItem.completed = !todoItem.completed;
|
|
30
|
-
updateFilter(todos);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function clearCompleted(todos: Todos) {
|
|
34
|
-
todos.items = todos.items.filter(FILTERS.active);
|
|
35
|
-
updateFilter(todos);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
////////////////////////////////////////////////////////////////////////
|
|
39
|
-
// Todo Application State Filter Functions
|
|
40
|
-
////////////////////////////////////////////////////////////////////////
|
|
41
|
-
|
|
42
15
|
export type FilterStates = 'all' | 'active' | 'completed';
|
|
16
|
+
|
|
43
17
|
export const FilterStates: FilterStates[] = ['all', 'active', 'completed'];
|
|
18
|
+
|
|
44
19
|
export const FILTERS = {
|
|
45
20
|
all: () => true,
|
|
46
21
|
active: (i: TodoItem) => i.completed == false,
|
|
47
22
|
completed: (i: TodoItem) => i.completed == true,
|
|
48
23
|
};
|
|
49
|
-
|
|
50
|
-
export function updateFilter(todos: Todos, filter?: FilterStates) {
|
|
51
|
-
if (filter) {
|
|
52
|
-
todos.filter = filter.toLowerCase() as any;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getFilteredItems(todos: Todos): TodoItem[] {
|
|
57
|
-
return todos.items.filter(FILTERS[todos.filter]);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getFilteredCount(todos: Todos) {
|
|
61
|
-
return getFilteredItems(todos).filter(FILTERS.active).length;
|
|
62
|
-
}
|