Skip to content

Commit 9fbd2e3

Browse files
committed
rewrite
1 parent 83b5066 commit 9fbd2e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+7512
-852
lines changed

client.d.ts

+26-42
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,40 @@
1+
import type { Ref } from 'vue'
2+
import type {
3+
UseQueryArgs,
4+
UseQueryResponse,
5+
UseMutationResponse,
6+
UseSubscriptionResponse,
7+
UseSubscriptionArgs,
8+
} from '@urql/vue'
9+
10+
declare type MaybeRef<T> = T | Ref<T>
11+
112
declare module 'virtual:gql-generation' {
213
export const generated: string[]
314
}
415

516
declare module 'vql' {
6-
import type {
7-
UseQueryArgs,
8-
UseQueryResponse,
9-
UseMutationResponse,
10-
UseSubscriptionResponse,
11-
UseSubscriptionArgs,
12-
UseQueryResponse,
13-
} from '@urql/vue'
14-
15-
declare type UseQueryOptions = Omit<UseQueryArgs, 'variables'>
16-
17-
// Query
18-
export function useQuery<T = any, V = any>(
19-
variables?: UseQueryArgs.variables<T, V> | null,
20-
options?: Partial<UseQueryOptions<T, V>>): UseQueryResponse<T, V>
21-
22-
export function useQuery<T = any, V = any>(
23-
queryName?: string,
24-
variables: UseQueryArgs.variables<T, V>,
25-
options?: Partial<UseQueryOptions<T, V>>): UseQueryResponse<T, V>
26-
27-
// Mutation
28-
export function useMutation<T = any, V = any>(query?: string): UseMutationResponse<T, V>
29-
30-
// Subscriptions
31-
export function useSubscription<T = any, R = T, V = object>(
32-
variables: UseSubscriptionArgs.variables<T, V>,
33-
_args?: Partial<UseSubscriptionArgs<T, V>>,
34-
handler?: MaybeRef<SubscriptionHandler<T, R>>): UseSubscriptionResponse<T, R, V>
35-
36-
export function useSubscription<T = any, R = T, V = object>(
37-
queryName: string,
38-
variables: UseSubscriptionArgs.variables<T, V>,
39-
_args?: Partial<UseSubscriptionArgs<T, V>>,
40-
handler?: MaybeRef<SubscriptionHandler<T, R>>): UseSubscriptionResponse<T, R, V>
17+
18+
export declare function useQuery<T = any, V = object>(_args: Omit<UseQueryArgs<T, V>, 'query'>): UseQueryResponse<T, V>
19+
export declare function useQuery<T = any, V = object>(name: string, _args: Omit<UseQueryArgs<T, V>, 'query'>): UseQueryResponse<T, V>
20+
21+
export declare function useMutation<T = any, V = any>(): UseMutationResponse<T, V>
22+
export declare function useMutation<T = any, V = any>(name: string): UseMutationResponse<T, V>
23+
24+
export declare function useSubscription<T = any, R = T, V = object>(_args: Omit<UseSubscriptionArgs<T, V>, 'query'>, handler?: MaybeRef<SubscriptionHandler<T, R>>): UseSubscriptionResponse<T, R, V>
25+
export declare function useSubscription<T = any, R = T, V = object>(name: string, _args: Omit<UseSubscriptionArgs<T, V>, 'query'>, handler?: MaybeRef<SubscriptionHandler<T, R>>): UseSubscriptionResponse<T, R, V>
4126
}
4227

4328
declare module 'vql-gen' {
4429

45-
interface Variable {
46-
[name: string]: any
47-
}
48-
49-
interface Variables {
30+
export interface UseQueryDynamicVariable {
5031
for: string
51-
variables: Variable
32+
variables: MaybeRef<V>
5233
}
5334

54-
export function useQuery<T = any, V = any>(variables?: Variables[], options?: Partial<UseQueryOptions<T, V>>): UseQueryResponse<T, V>
35+
export interface UseDyanmicQueryArgs<T, V> extends Omit<UseQueryArgs<T, V>, ['query', 'variables']> {
36+
variables: UseQueryDynamicVariable<V>
37+
}
5538

39+
export declare function useQuery<T = any, V = object>(_args: UseDyanmicQueryArgs<T, V>): UseQueryResponse<T, V>
5640
}

docs/.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
node_modules
3+
public

docs/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@antfu"
3+
}

docs/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
.vite-ssg-dist
3+
.vite-ssg-temp
4+
*.local
5+
dist
6+
dist-ssr
7+
node_modules
8+
# intellij stuff
9+
.idea/

docs/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

docs/index.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
7+
<link rel="apple-touch-icon" href="/pwa-192x192.png">
8+
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00aba9">
9+
<meta name="msapplication-TileColor" content="#00aba9">
10+
<meta name="theme-color" content="#ffffff">
11+
</head>
12+
<body>
13+
<div id="app"></div>
14+
<script>
15+
(function() {
16+
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
17+
const setting = localStorage.getItem('color-schema') || 'auto'
18+
if (setting === 'dark' || (prefersDark && setting !== 'light'))
19+
document.documentElement.classList.toggle('dark', true)
20+
})()
21+
</script>
22+
<script type="module" src="/src/main.ts"></script>
23+
</body>
24+
</html>

docs/netlify.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[build.environment]
2+
NPM_FLAGS = "--prefix=/dev/null"
3+
NODE_VERSION = "14"
4+
5+
[build]
6+
publish = "dist"
7+
command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"
8+
9+
[[redirects]]
10+
from = "/*"
11+
to = "/index.html"
12+
status = 200
13+
14+
[[headers]]
15+
for = "/manifest.webmanifest"
16+
[headers.values]
17+
Content-Type = "application/manifest+json"

docs/package.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "vite --port 3333 --open",
5+
"build": "cross-env NODE_ENV=production vite-ssg build",
6+
"preview": "vite preview",
7+
"preview-https": "serve dist"
8+
},
9+
"dependencies": {
10+
"@urql/vue": "^0.3.0",
11+
"@vueuse/core": "^4.8.1",
12+
"@vueuse/head": "^0.5.1",
13+
"markdown-it": "^12.0.6",
14+
"nprogress": "^0.2.0",
15+
"prism-theme-vars": "^0.2.2",
16+
"vue": "^3.0.11",
17+
"vue-i18n": "^9.1.3",
18+
"vue-router": "^4.0.6"
19+
},
20+
"devDependencies": {
21+
"@antfu/eslint-config": "^0.6.2",
22+
"@iconify/json": "^1.1.328",
23+
"@intlify/vite-plugin-vue-i18n": "^2.1.2",
24+
"@types/markdown-it": "^12.0.1",
25+
"@types/nprogress": "^0.2.0",
26+
"@typescript-eslint/eslint-plugin": "^4.21.0",
27+
"@vitejs/plugin-vue": "^1.2.1",
28+
"@vue/compiler-sfc": "^3.0.11",
29+
"@vue/server-renderer": "^3.0.11",
30+
"cross-env": "^7.0.3",
31+
"eslint": "^7.24.0",
32+
"https-localhost": "^4.6.4",
33+
"markdown-it-prism": "^2.1.6",
34+
"pnpm": "^6.0.1",
35+
"typescript": "^4.2.4",
36+
"vite": "^2.1.5",
37+
"vite-plugin-components": "^0.8.3",
38+
"vite-plugin-icons": "^0.5.0",
39+
"vite-plugin-md": "^0.6.3",
40+
"vite-plugin-pages": "^0.9.3",
41+
"vite-plugin-pwa": "^0.7.0",
42+
"vite-plugin-vue-gql": "workspace:*",
43+
"vite-plugin-vue-layouts": "^0.2.2",
44+
"vite-plugin-windicss": "^0.14.0",
45+
"vite-ssg": "^0.9.2"
46+
}
47+
}

docs/public/_headers

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/assets/*
2+
cache-control: max-age=31536000
3+
cache-control: immutable

docs/public/favicon.svg

+9
Loading

docs/public/pwa-192x192.png

3.82 KB
Loading

docs/public/pwa-512x512.png

10 KB
Loading

docs/public/robots.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Allow: /

docs/public/safari-pinned-tab.svg

+41
Loading

docs/src/App.vue

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup lang="ts">
2+
import { useHead } from '@vueuse/head'
3+
4+
// https://github.com/vueuse/head
5+
// you can use this to manipulate the document head in any components,
6+
// they will be rendered correctly in the html results with vite-ssg
7+
useHead({
8+
title: 'Vitesse',
9+
meta: [
10+
{ name: 'description', content: 'Opinionated Vite Starter Template' },
11+
],
12+
})
13+
</script>
14+
15+
<template>
16+
<Titlebar class="dark:text-gray-300 text-gray-700" />
17+
<main class="dark:text-gray-300 pt-22 max-w-screen-lg mx-auto h-screen text-gray-700">
18+
<router-view />
19+
</main>
20+
</template>

docs/src/components/BlockDemo.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```html
2+
<script setup lang="ts">
3+
import { useQuery } from 'vql'
4+
</script>
5+
6+
<template>
7+
<div class="bg-red-500">
8+
This is a demo!!!
9+
</div>
10+
</template>
11+
```

docs/src/components/Button.vue

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<script setup lang="ts">
2+
import { defineProps, computed } from 'vue'
3+
4+
const props = defineProps({
5+
href: {
6+
type: String,
7+
required: false,
8+
},
9+
to: {
10+
type: [String, Object],
11+
required: false,
12+
},
13+
primary: {
14+
type: Boolean,
15+
default: false,
16+
},
17+
icon: {
18+
type: Boolean,
19+
default: false,
20+
},
21+
})
22+
23+
const is = computed(() => {
24+
if (props.href)
25+
return 'a'
26+
27+
if (props.to)
28+
return 'router-link'
29+
30+
return 'button'
31+
})
32+
33+
const bindings = computed(() => {
34+
if (is.value === 'a')
35+
return { href: props.href, target: '_blank' }
36+
37+
if (is.value === 'router-link')
38+
return { to: props.to }
39+
40+
return {}
41+
})
42+
</script>
43+
44+
<template>
45+
<component
46+
:is="is"
47+
v-bind="bindings"
48+
:class="{ 'bg-cyan-500 border-b-2 active:(border-b-0 border-r-0) border-cyan-700 text-cyan-900 hover:bg-cyan-500': primary, 'w-10': icon }"
49+
class="inline-flex flex-row items-center h-10 px-4 ease-in-out transform active:scale-95 rounded-lg focus:outline-none"
50+
>
51+
<div class="grid w-full h-full grid-flow-col gap-2 font-semibold uppercase place-items-center place-content-center">
52+
<slot />
53+
</div>
54+
</component>
55+
</template>

docs/src/components/DataLoader.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import { defineProps } from 'vue'
3+
4+
defineProps<{ fetching: boolean; error: any }>()
5+
</script>
6+
7+
<template>
8+
<div v-if="fetching" class="pt-8">
9+
<Spinner class="mx-auto" />
10+
</div>
11+
<div v-else-if="error?.message">
12+
Oops and error ocurred
13+
</div>
14+
<template v-else>
15+
<slot />
16+
</template>
17+
</template>

docs/src/components/DemoContainer.vue

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script setup lang="ts">
2+
import { ref, onErrorCaptured } from 'vue'
3+
4+
const error: any = ref(null)
5+
onErrorCaptured((err) => {
6+
error.value = err
7+
})
8+
</script>
9+
10+
<template>
11+
<div v-if="error">
12+
{{ error }}
13+
</div>
14+
<div v-else class="mt-8">
15+
<Tabs>
16+
<Tab name="Demo" active>
17+
<div class="p-8">
18+
<slot />
19+
</div>
20+
</Tab>
21+
<Tab name="Source">
22+
<div class="overflow-hidden">
23+
<slot name="source" />
24+
</div>
25+
</Tab>
26+
</Tabs>
27+
</div>
28+
</template>

0 commit comments

Comments
 (0)