create-qwik 0.0.8 → 0.0.12

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 (56) hide show
  1. package/README.md +20 -0
  2. package/create-qwik +106 -0
  3. package/index.js +2 -101
  4. package/package.json +5 -4
  5. package/starters/apps/starter/index.html +1 -0
  6. package/starters/apps/starter/package.json +7 -10
  7. package/starters/apps/starter/public/favicon.ico +0 -0
  8. package/starters/apps/starter/src/{index.server.tsx → entry.server.tsx} +4 -5
  9. package/starters/apps/starter/src/root.css +3 -0
  10. package/starters/apps/starter/src/root.tsx +62 -0
  11. package/starters/apps/starter/tsconfig.json +3 -3
  12. package/starters/apps/starter/vite.config.js +34 -0
  13. package/starters/apps/starter-builder/index.html +1 -0
  14. package/starters/apps/starter-builder/package.json +7 -10
  15. package/starters/apps/starter-builder/public/favicon.ico +0 -0
  16. package/starters/apps/starter-builder/src/{index.server.tsx → entry.server.tsx} +4 -8
  17. package/starters/apps/starter-builder/src/root.css +3 -0
  18. package/starters/apps/starter-builder/src/root.tsx +41 -0
  19. package/starters/apps/starter-builder/tsconfig.json +3 -3
  20. package/starters/apps/starter-builder/vite.config.js +34 -0
  21. package/starters/apps/starter-partytown/index.html +1 -0
  22. package/starters/apps/starter-partytown/package.json +8 -11
  23. package/starters/apps/starter-partytown/src/{index.server.tsx → entry.server.tsx} +6 -7
  24. package/starters/apps/starter-partytown/src/root.css +3 -0
  25. package/starters/apps/starter-partytown/src/{my-app.tsx → root.tsx} +12 -18
  26. package/starters/apps/starter-partytown/tsconfig.json +3 -3
  27. package/starters/apps/starter-partytown/vite.config.js +34 -0
  28. package/starters/apps/todo/index.html +1 -0
  29. package/starters/apps/todo/package.json +7 -11
  30. package/starters/apps/todo/public/favicon.ico +0 -0
  31. package/starters/apps/todo/src/{index.server.tsx → entry.server.tsx} +3 -4
  32. package/starters/apps/todo/src/root.css +3 -0
  33. package/starters/apps/todo/src/root.tsx +232 -0
  34. package/starters/apps/todo/src/state.ts +5 -7
  35. package/starters/apps/todo/tsconfig.json +2 -3
  36. package/starters/apps/todo/vite.config.js +34 -0
  37. package/starters/features/prettier/.prettierignore +29 -0
  38. package/starters/features/prettier/package.json +12 -0
  39. package/starters/features/tailwindcss/package.json +10 -0
  40. package/starters/features/tailwindcss/postcss.config.js +6 -0
  41. package/starters/features/tailwindcss/src/root.css +3 -0
  42. package/starters/features/tailwindcss/tailwind.config.js +7 -0
  43. package/starters/servers/cloudflare/package.json +7 -9
  44. package/starters/servers/cloudflare/{workers-site → server}/package.json +1 -1
  45. package/starters/servers/cloudflare/src/{index.cloudflare.tsx → entry.cloudflare.tsx} +11 -4
  46. package/starters/servers/cloudflare/wrangler.toml +2 -2
  47. package/starters/servers/express/package.json +1 -1
  48. package/starters/servers/express/server/index.js +4 -4
  49. package/starters/apps/starter/rollup.config.js +0 -37
  50. package/starters/apps/starter/src/my-app.tsx +0 -63
  51. package/starters/apps/starter-builder/rollup.config.js +0 -37
  52. package/starters/apps/starter-builder/src/my-app.tsx +0 -34
  53. package/starters/apps/starter-partytown/rollup.config.js +0 -37
  54. package/starters/apps/todo/rollup.config.js +0 -39
  55. package/starters/apps/todo/src/components.tsx +0 -225
  56. package/starters/servers/cloudflare/rollup.config.server.js +0 -29
@@ -1,225 +0,0 @@
1
- import {
2
- Fragment,
3
- h,
4
- Host,
5
- qComponent,
6
- qHook,
7
- useHostElement,
8
- useEvent,
9
- notifyRender,
10
- } from '@builder.io/qwik';
11
- import {
12
- addItem,
13
- clearCompleted,
14
- FilterStates,
15
- getFilteredCount,
16
- getFilteredItems,
17
- removeItem,
18
- TodoItem,
19
- Todos,
20
- toggleItem,
21
- updateFilter,
22
- } from './state';
23
- /* eslint no-console: ["off"] */
24
-
25
- // TODO(misko): APIs for better debugger experience: qProps
26
- // TODO(misko): APIs for better debugger experience: dehydrate
27
- // TODO(misko): APIs to have a global way of notifying which events are being fired, so we can console out render events in the demo applications
28
- // TODO(misko): Place breakpoint in DOM modification and notice that too many writes are happening.
29
- // TODO(misko): <item> renders twice on toggle. 1) Due to state change, 2) due to <main> somehow triggering render.
30
-
31
- ////////////////////////////////////////////////////////////////////////////////////////
32
- ////////////////////////////////////////////////////////////////////////////////////////
33
- ////////////////////////////////////////////////////////////////////////////////////////
34
- ////////////////////////////////////////////////////////////////////////////////////////
35
-
36
- /**
37
- * Overall application component.
38
- *
39
- * This component is static (meaning it will never change). Because of this
40
- * Qwik knows that it should never need to be rerendered, and its code will never
41
- * download to the client.
42
- */
43
- export const ToDoApp = qComponent<{ todos: Todos }>({
44
- tagName: 'todo', // optional
45
- onRender: qHook(({ todos }) => {
46
- console.log('on:qRender => <ToDoApp/>');
47
- return (
48
- <section class="todoapp">
49
- <Header todos={todos} />
50
- <Main todos={todos} />
51
- <Footer todos={todos} />
52
- </section>
53
- );
54
- }),
55
- });
56
-
57
- /**
58
- * Header component which is responsible for providing UI to ender new todo item.
59
- *
60
- * This component only rerenders if the user interacts with it through the input.
61
- */
62
- export const Header = qComponent<{ todos: Todos }, { text: string }>({
63
- tagName: 'header', // optional
64
- onMount: qHook(() => ({ text: '' })),
65
- onRender: qHook((_, { text }) => {
66
- console.log('on:qRender => <Header/>');
67
- return (
68
- <>
69
- <h1>todos</h1>
70
- <input
71
- class="new-todo"
72
- placeholder="What needs to be done?"
73
- autoFocus
74
- value={text}
75
- on:keyup={qHook<typeof Header>(({ todos }, state) => {
76
- const event = useEvent<KeyboardEvent>();
77
- const inputValue = (event.target as HTMLInputElement).value;
78
- state.text = inputValue;
79
- if (event.key === 'Enter' && inputValue) {
80
- addItem(todos, state.text);
81
- state.text = '';
82
- }
83
- })}
84
- />
85
- </>
86
- );
87
- }),
88
- });
89
-
90
- /**
91
- * Main body of the application which contains the list of todo items.
92
- *
93
- * This component only rerenders/hydrates/downloads if the list of todos changes.
94
- */
95
- export const Main = qComponent<{ todos: Todos }>({
96
- tagName: 'main', // optional
97
- onRender: qHook(({ todos }) => {
98
- console.log('on:qRender => <Main/>');
99
- return (
100
- <Host class="main">
101
- <ul class="todo-list">
102
- {getFilteredItems(todos).map((key) => (
103
- <Item item={key} todos={todos} />
104
- ))}
105
- </ul>
106
- </Host>
107
- );
108
- }),
109
- });
110
-
111
- /**
112
- * Individual items of the component.
113
- *
114
- * It only rerenders if the user infarcts with it or if the item itself changes.
115
- */
116
- export const Item = qComponent<{ item: TodoItem; todos: Todos }, { editing: boolean }>({
117
- tagName: 'li', // optional
118
- onMount: qHook(() => ({ editing: false })),
119
- onRender: qHook(({ item }, { editing }) => {
120
- console.log(
121
- 'on:qRender => <Item item="' +
122
- JSON.stringify(item, (key, value) => (key.startsWith('__') ? undefined : value)) +
123
- '"/>'
124
- );
125
- return (
126
- <Host class={{ completed: item.completed, editing: editing }}>
127
- <div class="view">
128
- <input
129
- class="toggle"
130
- type="checkbox"
131
- checked={item.completed}
132
- on:click={qHook<typeof Item>(({ item, todos }) => toggleItem(todos, item))}
133
- />
134
- <label
135
- on:dblclick={qHook<typeof Item>(async (props, state) => {
136
- state.editing = true;
137
- const hostElement = useHostElement()!;
138
- await notifyRender(hostElement);
139
- const inputEl = hostElement.querySelector('input.edit') as HTMLInputElement;
140
- inputEl.focus();
141
- inputEl.selectionStart = inputEl.selectionEnd = inputEl.value.length;
142
- })}
143
- >
144
- {item.title}
145
- </label>
146
- <button
147
- class="destroy"
148
- on:click={qHook<typeof Item>(({ item, todos }) => removeItem(todos, item))}
149
- ></button>
150
- </div>
151
- {editing ? (
152
- <input
153
- class="edit"
154
- value={item.title}
155
- on:blur={qHook<typeof Item>((_, state) => (state.editing = false))}
156
- on:keyup={qHook<typeof Item>(({ item }, state) => {
157
- const event = useEvent<KeyboardEvent>();
158
- const inputValue = (event.target as HTMLInputElement).value;
159
- item.title = inputValue;
160
- if (event.key === 'Enter') {
161
- state.editing = false;
162
- }
163
- })}
164
- />
165
- ) : null}
166
- </Host>
167
- );
168
- }),
169
- });
170
-
171
- /**
172
- * Footer showing items remaining and filtering options
173
- *
174
- * It only rerenders if the todos count changes or filters are reset.
175
- */
176
- export const Footer = qComponent<{ todos: Todos }>({
177
- tagName: 'footer', // optional
178
- onRender: qHook(({ todos }) => {
179
- console.log('on:qRender => <Footer/>');
180
- /**
181
- * Example of lite-component (it will always be included with the parent component)
182
- */
183
- function Filter({ filter }: { filter: FilterStates }) {
184
- const lMode = filter.toLowerCase();
185
- return (
186
- <li>
187
- <a
188
- class={{ selected: todos.filter == lMode }}
189
- on:click={qHook<typeof Footer, { filter: FilterStates }>((props, _, { filter }) =>
190
- updateFilter(props.todos, filter)
191
- ).with({ filter })}
192
- >
193
- {filter[0].toUpperCase() + filter.substr(1)}
194
- </a>
195
- </li>
196
- );
197
- }
198
- const remaining = getFilteredCount(todos);
199
- return (
200
- <Host class="footer">
201
- {todos.items.length > 0 ? (
202
- <>
203
- <span class="todo-count">
204
- <strong>{remaining}</strong>
205
- {remaining == 1 ? ' item' : ' items'} left
206
- </span>
207
- <ul class="filters">
208
- {FilterStates.map((f) => (
209
- <Filter filter={f} />
210
- ))}
211
- </ul>
212
- {remaining > 0 ? (
213
- <button
214
- class="clear-completed"
215
- on:click={qHook<typeof Footer>(({ todos }) => clearCompleted(todos))}
216
- >
217
- Clear completed
218
- </button>
219
- ) : null}
220
- </>
221
- ) : null}
222
- </Host>
223
- );
224
- }),
225
- });
@@ -1,29 +0,0 @@
1
- import { nodeResolve } from '@rollup/plugin-node-resolve';
2
- import { qwikRollup } from '@builder.io/qwik/optimizer';
3
- import jsonPlugin from '@rollup/plugin-json';
4
- import commonjs from '@rollup/plugin-commonjs';
5
-
6
- export default async function () {
7
- return {
8
- input: {
9
- index: 'src/index.cloudflare.tsx',
10
- },
11
- inlineDynamicImports: true,
12
- plugins: [
13
- nodeResolve(),
14
- jsonPlugin(),
15
- qwikRollup({
16
- entryStrategy: {
17
- type: 'single',
18
- },
19
- }),
20
- commonjs(),
21
- ],
22
- output: [
23
- {
24
- dir: 'workers-site/build',
25
- format: 'commonjs',
26
- },
27
- ],
28
- };
29
- }