create-qwik 0.0.107 → 0.0.108

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/create-qwik CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * @license
4
- * create-qwik 0.0.107-dev20220829203253
4
+ * create-qwik 0.0.108-dev20220906124741
5
5
  * Copyright Builder.io, Inc. All Rights Reserved.
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * create-qwik 0.0.107-dev20220829203253
3
+ * create-qwik 0.0.108-dev20220906124741
4
4
  * Copyright Builder.io, Inc. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-qwik",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "description": "Interactive CLI and API for generating Qwik projects.",
5
5
  "bin": "create-qwik",
6
6
  "main": "index.js",
@@ -15,12 +15,12 @@
15
15
  "typecheck": "tsc --incremental --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@builder.io/qwik": "0.0.107",
18
+ "@builder.io/qwik": "0.0.108",
19
19
  "@types/eslint": "8.4.6",
20
20
  "@types/node": "latest",
21
21
  "@typescript-eslint/eslint-plugin": "5.34.0",
22
22
  "@typescript-eslint/parser": "5.34.0",
23
- "eslint-plugin-qwik": "0.0.107",
23
+ "eslint-plugin-qwik": "0.0.108",
24
24
  "eslint": "8.22.0",
25
25
  "node-fetch": "3.2.10",
26
26
  "typescript": "4.7.4",
@@ -0,0 +1,22 @@
1
+ {
2
+ "description": "Blank Qwik starter app.",
3
+ "scripts": {
4
+ "build.ssr": "vite build --ssr src/entry.express.tsx",
5
+ "serve": "node server/entry.express"
6
+ },
7
+ "devDependencies": {
8
+ "@types/express": "4.17.13",
9
+ "express": "4.17.3"
10
+ },
11
+ "type": "module",
12
+ "__qwik__": {
13
+ "priority": 0,
14
+ "featureOptions": [
15
+ "prettier",
16
+ "tailwindcss"
17
+ ],
18
+ "featureEnabled": [
19
+ "prettier"
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,189 @@
1
+ import { component$, useStore } from '@builder.io/qwik';
2
+
3
+ let idCounter = 1;
4
+ const adjectives = [
5
+ 'pretty',
6
+ 'large',
7
+ 'big',
8
+ 'small',
9
+ 'tall',
10
+ 'short',
11
+ 'long',
12
+ 'handsome',
13
+ 'plain',
14
+ 'quaint',
15
+ 'clean',
16
+ 'elegant',
17
+ 'easy',
18
+ 'angry',
19
+ 'crazy',
20
+ 'helpful',
21
+ 'mushy',
22
+ 'odd',
23
+ 'unsightly',
24
+ 'adorable',
25
+ 'important',
26
+ 'inexpensive',
27
+ 'cheap',
28
+ 'expensive',
29
+ 'fancy',
30
+ ],
31
+ colours = [
32
+ 'red',
33
+ 'yellow',
34
+ 'blue',
35
+ 'green',
36
+ 'pink',
37
+ 'brown',
38
+ 'purple',
39
+ 'brown',
40
+ 'white',
41
+ 'black',
42
+ 'orange',
43
+ ],
44
+ nouns = [
45
+ 'table',
46
+ 'chair',
47
+ 'house',
48
+ 'bbq',
49
+ 'desk',
50
+ 'car',
51
+ 'pony',
52
+ 'cookie',
53
+ 'sandwich',
54
+ 'burger',
55
+ 'pizza',
56
+ 'mouse',
57
+ 'keyboard',
58
+ ];
59
+
60
+ function _random(max: number) {
61
+ return Math.round(Math.random() * 1000) % max;
62
+ }
63
+
64
+ export function buildData(count: number) {
65
+ const data = new Array(count);
66
+ for (let i = 0; i < count; i++) {
67
+ data[i] = {
68
+ id: idCounter++,
69
+ label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${
70
+ nouns[_random(nouns.length)]
71
+ }`,
72
+ };
73
+ }
74
+ return data;
75
+ }
76
+
77
+ type BenchState = {
78
+ data: Array<{ id: number; label: string }>;
79
+ selected: number | null;
80
+ };
81
+ export const App = component$(() => {
82
+ const state = useStore<BenchState>({ data: [], selected: null });
83
+ return (
84
+ <div class="container">
85
+ <div class="jumbotron">
86
+ <div class="row">
87
+ <div class="col-md-6">
88
+ <h1>Qwik Keyed</h1>
89
+ </div>
90
+ <div class="col-md-6">
91
+ <div class="row">
92
+ <div class="col-sm-6 smallpad">
93
+ <button
94
+ id="run"
95
+ class="btn btn-primary btn-block"
96
+ type="button"
97
+ onClick$={() => (state.data = buildData(1000))}
98
+ >
99
+ Create 1,000 rows
100
+ </button>
101
+ <button
102
+ id="runlots"
103
+ class="btn btn-primary btn-block"
104
+ type="button"
105
+ onClick$={() => (state.data = buildData(10000))}
106
+ >
107
+ Create 10,000 rows
108
+ </button>
109
+ <button
110
+ id="add"
111
+ class="btn btn-primary btn-block"
112
+ type="button"
113
+ onClick$={() => (state.data = state.data.concat(buildData(1000)))}
114
+ >
115
+ Append 1,000 rows
116
+ </button>
117
+ <button
118
+ id="update"
119
+ class="btn btn-primary btn-block"
120
+ type="button"
121
+ onClick$={() => {
122
+ for (let i = 0, d = state.data, len = d.length; i < len; i += 10) {
123
+ d[i].label += ' !!!';
124
+ }
125
+ }}
126
+ >
127
+ Update every 10th row
128
+ </button>
129
+ <button
130
+ id="clear"
131
+ class="btn btn-primary btn-block"
132
+ type="button"
133
+ onClick$={() => (state.data = [])}
134
+ >
135
+ Clear
136
+ </button>
137
+ <button
138
+ id="swaprows"
139
+ class="btn btn-primary btn-block"
140
+ type="button"
141
+ onClick$={() => {
142
+ const d = state.data.slice();
143
+ if (d.length > 998) {
144
+ const tmp = d[1];
145
+ d[1] = d[998];
146
+ d[998] = tmp;
147
+ state.data = d;
148
+ }
149
+ }}
150
+ >
151
+ Swap Rows
152
+ </button>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ <table class="table table-hover table-striped test-data">
159
+ <tbody>
160
+ {state.data.map(({ id, label }) => {
161
+ return (
162
+ <tr key={id} class={id === state.selected ? 'danger' : ''}>
163
+ <td class="col-md-1">{id}</td>
164
+ <td class="col-md-4">
165
+ <a onClick$={() => alert(label)}>{label}</a>
166
+ </td>
167
+ <td class="col-md-1">
168
+ <a
169
+ // onClick$={() => {
170
+ // const d = state.data;
171
+ // d.splice(
172
+ // d.findIndex((d) => d.id === id),
173
+ // 1
174
+ // );
175
+ // }}
176
+ >
177
+ <span class="glyphicon glyphicon-remove" ariaHidden="true" />
178
+ </a>
179
+ </td>
180
+ <td class="col-md-6" />
181
+ </tr>
182
+ );
183
+ })}
184
+ </tbody>
185
+ </table>
186
+ <span class="preloadicon glyphicon glyphicon-remove" ariaHidden="true" />
187
+ </div>
188
+ );
189
+ });
@@ -0,0 +1,59 @@
1
+ import express from 'express';
2
+ import { join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import render from './entry.ssr';
5
+
6
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
7
+
8
+ /**
9
+ * Create an express server
10
+ * https://expressjs.com/
11
+ */
12
+ const app = express();
13
+
14
+ /**
15
+ * Serve static client build files,
16
+ * hashed filenames, immutable cache-control
17
+ */
18
+ app.use(
19
+ '/build',
20
+ express.static(join(__dirname, '..', 'dist', 'build'), {
21
+ immutable: true,
22
+ maxAge: '1y',
23
+ })
24
+ );
25
+
26
+ /**
27
+ * Serve static public files at the root
28
+ */
29
+ app.use(express.static(join(__dirname, '..', 'dist'), { index: false }));
30
+
31
+ /**
32
+ * Server-Side Render Qwik application
33
+ */
34
+ app.get('/*', async (req, res, next) => {
35
+ try {
36
+ // Render the Root component to a string
37
+ const result = await render({
38
+ stream: res,
39
+ });
40
+
41
+ // respond with SSR'd HTML
42
+ if ('html' in result) {
43
+ res.send((result as any).html);
44
+ } else {
45
+ res.end();
46
+ }
47
+ } catch (e) {
48
+ // Error while server-side rendering
49
+ next(e);
50
+ }
51
+ });
52
+
53
+ /**
54
+ * Start the express server
55
+ */
56
+ app.listen(8080, () => {
57
+ /* eslint-disable */
58
+ console.log(`http://localhost:8080/`);
59
+ });
@@ -0,0 +1,15 @@
1
+ import { renderToStream, RenderToStreamOptions } from '@builder.io/qwik/server';
2
+ import { manifest } from '@qwik-client-manifest';
3
+ import Root from './root';
4
+
5
+ /**
6
+ * Server-Side Render method to be called by a server.
7
+ */
8
+ export default function (opts: RenderToStreamOptions) {
9
+ // Render the Root component to a string
10
+ // Pass in the manifest that was generated from the client build
11
+ return renderToStream(<Root />, {
12
+ manifest,
13
+ ...opts,
14
+ });
15
+ }
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Write here your global css styles
3
+ */
@@ -0,0 +1,18 @@
1
+ import { App } from './components/app/app';
2
+
3
+ import './global.css';
4
+
5
+ export default () => {
6
+ return (
7
+ <html>
8
+ <head>
9
+ <meta charSet="utf-8" />
10
+ <title>Qwik Blank App</title>
11
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
12
+ </head>
13
+ <body>
14
+ <App />
15
+ </body>
16
+ </html>
17
+ );
18
+ };
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "type": "module",
15
15
  "devDependencies": {
16
- "@builder.io/qwik-city": "0.0.106",
16
+ "@builder.io/qwik-city": "0.0.108",
17
17
  "vite-tsconfig-paths": "3.5.0"
18
18
  }
19
19
  }