create-qwik 1.1.5 → 1.2.1
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/index.cjs +63 -62
- package/package.json +1 -1
- package/starters/apps/base/.eslintrc.cjs +23 -22
- package/starters/apps/base/.vscode/launch.json +2 -2
- package/starters/apps/base/.vscode/qwik-city.code-snippets +5 -13
- package/starters/apps/base/.vscode/qwik.code-snippets +77 -95
- package/starters/apps/base/.vscode/settings.json +3 -0
- package/starters/apps/base/README.md +5 -5
- package/starters/apps/base/gitignore +3 -1
- package/starters/apps/base/package.json +9 -9
- package/starters/apps/base/src/entry.dev.tsx +2 -2
- package/starters/apps/base/src/entry.preview.tsx +3 -3
- package/starters/apps/base/src/entry.ssr.tsx +7 -4
- package/starters/apps/base/src/global.css +3 -3
- package/starters/apps/base/src/routes/service-worker.ts +3 -4
- package/starters/apps/base/tsconfig.json +1 -1
- package/starters/apps/base/vite.config.ts +5 -5
- package/starters/apps/basic/src/components/router-head/router-head.tsx +2 -2
- package/starters/apps/basic/src/components/starter/counter/counter.tsx +12 -6
- package/starters/apps/basic/src/components/starter/footer/footer.tsx +3 -3
- package/starters/apps/basic/src/components/starter/gauge/index.tsx +9 -3
- package/starters/apps/basic/src/components/starter/header/header.tsx +16 -7
- package/starters/apps/basic/src/components/starter/hero/hero.module.css +10 -0
- package/starters/apps/basic/src/components/starter/hero/hero.tsx +16 -9
- package/starters/apps/basic/src/components/starter/icons/qwik.tsx +7 -1
- package/starters/apps/basic/src/components/starter/infobox/infobox.tsx +2 -2
- package/starters/apps/basic/src/components/starter/next-steps/next-steps.tsx +25 -15
- package/starters/apps/basic/src/global.css +3 -3
- package/starters/apps/basic/src/media/thunder.png +0 -0
- package/starters/apps/basic/src/root.tsx +10 -6
- package/starters/apps/basic/src/routes/demo/flower/flower.css +3 -1
- package/starters/apps/basic/src/routes/demo/flower/index.tsx +12 -7
- package/starters/apps/basic/src/routes/demo/todolist/index.tsx +12 -8
- package/starters/apps/basic/src/routes/index.tsx +10 -10
- package/starters/apps/basic/src/routes/layout.tsx +6 -6
- package/starters/apps/basic/src/routes/service-worker.ts +3 -3
- package/starters/apps/basic/src/routes/styles.css +4 -4
- package/starters/apps/empty/src/components/router-head/router-head.tsx +2 -2
- package/starters/apps/empty/src/root.tsx +9 -5
- package/starters/apps/empty/src/routes/index.tsx +5 -5
- package/starters/apps/empty/src/routes/layout.tsx +2 -2
- package/starters/apps/empty/src/routes/service-worker.ts +3 -3
- package/starters/apps/library/.eslintrc.cjs +21 -21
- package/starters/apps/library/package.json +7 -7
- package/starters/apps/library/src/components/counter/counter.tsx +1 -1
- package/starters/apps/library/src/components/logo/logo.tsx +1 -1
- package/starters/apps/library/src/entry.dev.tsx +2 -2
- package/starters/apps/library/src/entry.ssr.tsx +6 -3
- package/starters/apps/library/src/index.ts +2 -2
- package/starters/apps/library/src/root.tsx +2 -2
- package/starters/apps/library/vite.config.ts +6 -6
- package/starters/apps/site-with-visual-cms/README.md +15 -0
- package/starters/apps/site-with-visual-cms/package.json +2 -2
- package/starters/apps/site-with-visual-cms/src/components/builder-registry.ts +15 -5
- package/starters/apps/site-with-visual-cms/src/components/counter/counter.module.css +0 -1
- package/starters/apps/site-with-visual-cms/src/components/counter/counter.tsx +7 -7
- package/starters/apps/site-with-visual-cms/src/components/footer/footer.tsx +2 -2
- package/starters/apps/site-with-visual-cms/src/components/gauge/index.tsx +9 -3
- package/starters/apps/site-with-visual-cms/src/components/header/header.tsx +15 -6
- package/starters/apps/site-with-visual-cms/src/components/icons/qwik.tsx +7 -1
- package/starters/apps/site-with-visual-cms/src/components/router-head/router-head.tsx +2 -2
- package/starters/apps/site-with-visual-cms/src/entry.dev.tsx +2 -2
- package/starters/apps/site-with-visual-cms/src/entry.preview.tsx +3 -3
- package/starters/apps/site-with-visual-cms/src/entry.ssr.tsx +7 -4
- package/starters/apps/site-with-visual-cms/src/global.css +3 -3
- package/starters/apps/site-with-visual-cms/src/root.tsx +10 -6
- package/starters/apps/site-with-visual-cms/src/routes/[...index]/index.tsx +11 -7
- package/starters/apps/site-with-visual-cms/src/routes/layout.tsx +3 -3
- package/starters/apps/site-with-visual-cms/src/routes/service-worker.ts +3 -3
- package/starters/apps/site-with-visual-cms/vite.config.ts +4 -4
- package/starters/apps/site-with-visual-cms/builder-integration.ts +0 -853
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import type { RegisteredComponent } from
|
|
2
|
-
import Counter from
|
|
1
|
+
import type { RegisteredComponent } from "@builder.io/sdk-qwik";
|
|
2
|
+
import Counter from "./counter/counter";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* This array is used to integrate custom components within Builder.
|
|
6
|
+
* https://www.builder.io/c/docs/custom-components-intro
|
|
7
|
+
*
|
|
8
|
+
* These components will be found the "Custom Components"
|
|
9
|
+
* section of Builder's visual editor.
|
|
10
|
+
* You can also turn on "components only mode" to limit
|
|
11
|
+
* editing to only these components.
|
|
12
|
+
* https://www.builder.io/c/docs/guides/components-only-mode
|
|
13
|
+
*/
|
|
4
14
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
5
15
|
{
|
|
6
16
|
component: Counter,
|
|
7
|
-
name:
|
|
17
|
+
name: "Counter",
|
|
8
18
|
inputs: [
|
|
9
19
|
{
|
|
10
|
-
name:
|
|
11
|
-
type:
|
|
20
|
+
name: "initialValue",
|
|
21
|
+
type: "number",
|
|
12
22
|
},
|
|
13
23
|
],
|
|
14
24
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { component$, useSignal, $ } from
|
|
2
|
-
import styles from
|
|
3
|
-
import Gauge from
|
|
1
|
+
import { component$, useSignal, $ } from "@builder.io/qwik";
|
|
2
|
+
import styles from "./counter.module.css";
|
|
3
|
+
import Gauge from "../gauge";
|
|
4
4
|
|
|
5
5
|
export default component$((props: { initialValue: number }) => {
|
|
6
|
-
const count = useSignal(props.initialValue);
|
|
6
|
+
const count = useSignal(props.initialValue || 99);
|
|
7
7
|
|
|
8
8
|
const setCount = $((newValue: number) => {
|
|
9
9
|
if (newValue >= 0 && newValue <= 100) {
|
|
@@ -35,7 +35,7 @@ export const celebrate = $(async () => {
|
|
|
35
35
|
gravity: 0,
|
|
36
36
|
decay: 0.95,
|
|
37
37
|
startVelocity: 30,
|
|
38
|
-
colors: [
|
|
38
|
+
colors: ["006ce9", "ac7ff4", "18b6f6", "713fc2", "ffffff"],
|
|
39
39
|
origin: {
|
|
40
40
|
x: 0.5,
|
|
41
41
|
y: 0.35,
|
|
@@ -47,9 +47,9 @@ export const celebrate = $(async () => {
|
|
|
47
47
|
if ((globalThis as any).confetti) {
|
|
48
48
|
return resolve((globalThis as any).confetti as any);
|
|
49
49
|
}
|
|
50
|
-
const script = document.createElement(
|
|
50
|
+
const script = document.createElement("script");
|
|
51
51
|
script.src =
|
|
52
|
-
|
|
52
|
+
"https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js";
|
|
53
53
|
script.onload = () => resolve((globalThis as any).confetti as any);
|
|
54
54
|
script.onerror = reject;
|
|
55
55
|
document.head.appendChild(script);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { component$ } from
|
|
2
|
-
import styles from
|
|
1
|
+
import { component$ } from "@builder.io/qwik";
|
|
2
|
+
import styles from "./gauge.module.css";
|
|
3
3
|
|
|
4
4
|
export default component$(({ value = 50 }: { value?: number }) => {
|
|
5
5
|
const safeValue = value < 0 || value > 100 ? 50 : value;
|
|
@@ -13,7 +13,13 @@ export default component$(({ value = 50 }: { value?: number }) => {
|
|
|
13
13
|
<stop offset="1000%" stop-color="#AC7FF4" />
|
|
14
14
|
</linearGradient>
|
|
15
15
|
</defs>
|
|
16
|
-
<circle
|
|
16
|
+
<circle
|
|
17
|
+
r="56"
|
|
18
|
+
cx="60"
|
|
19
|
+
cy="60"
|
|
20
|
+
stroke-width="8"
|
|
21
|
+
style="fill: #000; stroke: #0000"
|
|
22
|
+
/>
|
|
17
23
|
<circle
|
|
18
24
|
r="56"
|
|
19
25
|
cx="60"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { component$ } from
|
|
2
|
-
import { QwikLogo } from
|
|
3
|
-
import styles from
|
|
1
|
+
import { component$ } from "@builder.io/qwik";
|
|
2
|
+
import { QwikLogo } from "../icons/qwik";
|
|
3
|
+
import styles from "./header.module.css";
|
|
4
4
|
|
|
5
5
|
export default component$(() => {
|
|
6
6
|
return (
|
|
@@ -13,17 +13,26 @@ export default component$(() => {
|
|
|
13
13
|
</div>
|
|
14
14
|
<ul>
|
|
15
15
|
<li>
|
|
16
|
-
<a
|
|
16
|
+
<a
|
|
17
|
+
href="https://qwik.builder.io/docs/components/overview/"
|
|
18
|
+
target="_blank"
|
|
19
|
+
>
|
|
17
20
|
Docs
|
|
18
21
|
</a>
|
|
19
22
|
</li>
|
|
20
23
|
<li>
|
|
21
|
-
<a
|
|
24
|
+
<a
|
|
25
|
+
href="https://qwik.builder.io/examples/introduction/hello-world/"
|
|
26
|
+
target="_blank"
|
|
27
|
+
>
|
|
22
28
|
Examples
|
|
23
29
|
</a>
|
|
24
30
|
</li>
|
|
25
31
|
<li>
|
|
26
|
-
<a
|
|
32
|
+
<a
|
|
33
|
+
href="https://qwik.builder.io/tutorial/welcome/overview/"
|
|
34
|
+
target="_blank"
|
|
35
|
+
>
|
|
27
36
|
Tutorials
|
|
28
37
|
</a>
|
|
29
38
|
</li>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { component$ } from
|
|
2
|
-
import { useDocumentHead, useLocation } from
|
|
1
|
+
import { component$ } from "@builder.io/qwik";
|
|
2
|
+
import { useDocumentHead, useLocation } from "@builder.io/qwik-city";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The RouterHead component is placed inside of the document `<head>` element.
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* - More code is transferred to the browser than in SSR mode.
|
|
10
10
|
* - Optimizer/Serialization/Deserialization code is not exercised!
|
|
11
11
|
*/
|
|
12
|
-
import { render, type RenderOptions } from
|
|
13
|
-
import Root from
|
|
12
|
+
import { render, type RenderOptions } from "@builder.io/qwik";
|
|
13
|
+
import Root from "./root";
|
|
14
14
|
|
|
15
15
|
export default function (opts: RenderOptions) {
|
|
16
16
|
return render(document, <Root />, opts);
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* - https://vitejs.dev/config/preview-options.html#preview-options
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
import { createQwikCity } from
|
|
14
|
-
import qwikCityPlan from
|
|
15
|
-
import render from
|
|
13
|
+
import { createQwikCity } from "@builder.io/qwik-city/middleware/node";
|
|
14
|
+
import qwikCityPlan from "@qwik-city-plan";
|
|
15
|
+
import render from "./entry.ssr";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The default export is the QwikCity adapter used by Vite preview.
|
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
* - npm run build
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
renderToStream,
|
|
15
|
+
type RenderToStreamOptions,
|
|
16
|
+
} from "@builder.io/qwik/server";
|
|
17
|
+
import { manifest } from "@qwik-client-manifest";
|
|
18
|
+
import Root from "./root";
|
|
16
19
|
|
|
17
20
|
export default function (opts: RenderToStreamOptions) {
|
|
18
21
|
return renderToStream(<Root />, {
|
|
@@ -20,7 +23,7 @@ export default function (opts: RenderToStreamOptions) {
|
|
|
20
23
|
...opts,
|
|
21
24
|
// Use container attributes to set attributes on the html tag.
|
|
22
25
|
containerAttributes: {
|
|
23
|
-
lang:
|
|
26
|
+
lang: "en-us",
|
|
24
27
|
...opts.containerAttributes,
|
|
25
28
|
},
|
|
26
29
|
});
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
|
|
22
22
|
/* SHELL ---------------------------------------- */
|
|
23
23
|
html {
|
|
24
|
-
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
25
|
+
"Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
|
|
26
|
+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
27
27
|
background: var(--footer-background);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { component$ } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { component$ } from "@builder.io/qwik";
|
|
2
|
+
import {
|
|
3
|
+
QwikCityProvider,
|
|
4
|
+
RouterOutlet,
|
|
5
|
+
ServiceWorkerRegister,
|
|
6
|
+
} from "@builder.io/qwik-city";
|
|
7
|
+
import { RouterHead } from "./components/router-head/router-head";
|
|
4
8
|
|
|
5
|
-
import
|
|
9
|
+
import "./global.css";
|
|
6
10
|
|
|
7
11
|
export default component$(() => {
|
|
8
12
|
/**
|
|
9
13
|
* The root of a QwikCity site always start with the <QwikCityProvider> component,
|
|
10
14
|
* immediately followed by the document's <head> and <body>.
|
|
11
15
|
*
|
|
12
|
-
*
|
|
16
|
+
* Don't remove the `<head>` and `<body>` elements.
|
|
13
17
|
*/
|
|
14
18
|
|
|
15
19
|
return (
|
|
@@ -18,10 +22,10 @@ export default component$(() => {
|
|
|
18
22
|
<meta charSet="utf-8" />
|
|
19
23
|
<link rel="manifest" href="/manifest.json" />
|
|
20
24
|
<RouterHead />
|
|
25
|
+
<ServiceWorkerRegister />
|
|
21
26
|
</head>
|
|
22
27
|
<body lang="en">
|
|
23
28
|
<RouterOutlet />
|
|
24
|
-
<ServiceWorkerRegister />
|
|
25
29
|
</body>
|
|
26
30
|
</QwikCityProvider>
|
|
27
31
|
);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { component$ } from
|
|
2
|
-
import { DocumentHead, routeLoader$ } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { component$ } from "@builder.io/qwik";
|
|
2
|
+
import { DocumentHead, routeLoader$ } from "@builder.io/qwik-city";
|
|
3
|
+
import {
|
|
4
|
+
getContent,
|
|
5
|
+
RenderContent,
|
|
6
|
+
getBuilderSearchParams,
|
|
7
|
+
} from "@builder.io/sdk-qwik";
|
|
8
|
+
import { CUSTOM_COMPONENTS } from "../../components/builder-registry";
|
|
5
9
|
|
|
6
10
|
// This page is a catch-all for all routes that don't have a pre-defined route.
|
|
7
11
|
// Using a catch-all route allows you to dynamically create enw pages in Builder.
|
|
@@ -10,13 +14,13 @@ import { CUSTOM_COMPONENTS } from '../../components/builder-registry';
|
|
|
10
14
|
// `routeLoader$()` takes an async function to fetch content
|
|
11
15
|
// from Builder with using `getContent()`.
|
|
12
16
|
export const useBuilderContent = routeLoader$(async ({ url, error }) => {
|
|
13
|
-
const isPreviewing = url.searchParams.has(
|
|
17
|
+
const isPreviewing = url.searchParams.has("builder.preview");
|
|
14
18
|
|
|
15
19
|
// Fetch Builder.io Visual CMS content using the Qwik SDK.
|
|
16
20
|
// The public API key is set in the .env file at the root
|
|
17
21
|
// https://www.builder.io/c/docs/using-your-api-key
|
|
18
22
|
const builderContent = await getContent({
|
|
19
|
-
model:
|
|
23
|
+
model: "page",
|
|
20
24
|
apiKey: import.meta.env.PUBLIC_BUILDER_API_KEY,
|
|
21
25
|
options: getBuilderSearchParams(url.searchParams),
|
|
22
26
|
userAttributes: {
|
|
@@ -27,7 +31,7 @@ export const useBuilderContent = routeLoader$(async ({ url, error }) => {
|
|
|
27
31
|
// If there's no content, throw a 404.
|
|
28
32
|
// You can use your own 404 component here
|
|
29
33
|
if (!builderContent && !isPreviewing) {
|
|
30
|
-
throw error(404,
|
|
34
|
+
throw error(404, "Page not found");
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
// return content fetched from Builder, which is JSON
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { component$, Slot } from
|
|
2
|
-
import Header from
|
|
3
|
-
import Footer from
|
|
1
|
+
import { component$, Slot } from "@builder.io/qwik";
|
|
2
|
+
import Header from "../components/header/header";
|
|
3
|
+
import Footer from "../components/footer/footer";
|
|
4
4
|
|
|
5
5
|
export default component$(() => {
|
|
6
6
|
return (
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* Qwik uses a service worker to speed up your site and reduce latency, ie, not used in the traditional way of offline.
|
|
8
8
|
* You can also use this file to add more functionality that runs in the service worker.
|
|
9
9
|
*/
|
|
10
|
-
import { setupServiceWorker } from
|
|
10
|
+
import { setupServiceWorker } from "@builder.io/qwik-city/service-worker";
|
|
11
11
|
|
|
12
12
|
setupServiceWorker();
|
|
13
13
|
|
|
14
|
-
addEventListener(
|
|
14
|
+
addEventListener("install", () => self.skipWaiting());
|
|
15
15
|
|
|
16
|
-
addEventListener(
|
|
16
|
+
addEventListener("activate", () => self.clients.claim());
|
|
17
17
|
|
|
18
18
|
declare const self: ServiceWorkerGlobalScope;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
2
|
-
import { qwikVite } from
|
|
3
|
-
import { qwikCity } from
|
|
4
|
-
import { builderDevTools } from
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { qwikVite } from "@builder.io/qwik/optimizer";
|
|
3
|
+
import { qwikCity } from "@builder.io/qwik-city/vite";
|
|
4
|
+
import { builderDevTools } from "@builder.io/dev-tools/vite";
|
|
5
5
|
|
|
6
6
|
export default defineConfig(() => {
|
|
7
7
|
return {
|