Browse Source

playground

master
1549469775 3 years ago
parent
commit
1052f4c901
  1. 3
      .vscode/extensions.json
  2. 5
      package.json
  3. 2
      packages/build/util.ts
  4. 9
      packages/components/button/index.ts
  5. 10
      packages/components/fuck/index.ts
  6. 8
      packages/components/send/index.ts
  7. 15
      packages/components/send/index.vue
  8. 24
      packages/playground/.gitignore
  9. 16
      packages/playground/README.md
  10. 14
      packages/playground/components.d.ts
  11. 13
      packages/playground/index.html
  12. 3
      packages/playground/index.ts
  13. 24
      packages/playground/package.json
  14. BIN
      packages/playground/public/favicon.ico
  15. 23
      packages/playground/src/App.vue
  16. BIN
      packages/playground/src/assets/logo.png
  17. 52
      packages/playground/src/components/HelloWorld.vue
  18. 8
      packages/playground/src/env.d.ts
  19. 4
      packages/playground/src/main.ts
  20. 18
      packages/playground/tsconfig.json
  21. 8
      packages/playground/tsconfig.node.json
  22. 24
      packages/playground/vite.config.ts
  23. 2
      packages/theme-chalk/gulpfile.ts/index.ts
  24. 0
      packages/theme-chalk/gulpfile.ts/tsconfig.json
  25. 2
      packages/theme-chalk/package.json
  26. 0
      packages/theme-chalk/src/index.scss
  27. 2622
      pnpm-lock.yaml

3
.vscode/extensions.json

@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}

5
package.json

@ -13,9 +13,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "pnpm run -C packages/components start", "start": "pnpm run -C packages/components start",
"dev": "pnpm run -C packages/components dev", "dev": "pnpm run -C packages/playground dev",
"build": "pnpm run -C packages/build build && pnpm run -C packages/princess-ui build", "build": "pnpm run -C packages/build build && pnpm run -C packages/princess-ui build",
"gulp": "set TS_NODE_PROJECT=gulpfile.ts/tsconfig.json& gulp -f gulpfile.ts", "theme": "pnpm run -C packages/theme-chalk build",
"release": "cd packages/princess-ui & npm publish" "release": "cd packages/princess-ui & npm publish"
}, },
"keywords": [], "keywords": [],
@ -24,6 +24,7 @@
"devDependencies": { "devDependencies": {
"princess-ui": "workspace:*", "princess-ui": "workspace:*",
"@princess-ui/build": "workspace:*", "@princess-ui/build": "workspace:*",
"@princess-ui/playground": "workspace:*",
"@princess-ui/components": "workspace:*", "@princess-ui/components": "workspace:*",
"@princess-ui/share": "workspace:*", "@princess-ui/share": "workspace:*",
"@princess-ui/theme-chalk": "workspace:*", "@princess-ui/theme-chalk": "workspace:*",

2
packages/build/util.ts

@ -30,7 +30,7 @@ export { }`
const n = "Ps" + _.upperFirst(_.kebabCase(name)) const n = "Ps" + _.upperFirst(_.kebabCase(name))
componetnsStr.push(`import ${n} from "./${name}"`) componetnsStr.push(`import ${n} from "./${name}"`)
newComp.push(n) newComp.push(n)
typeArray.push(n + `: typeof import('./lib/${name}')['default']`) typeArray.push(n + `: typeof import('./lib/${name}')['${n}']`)
}) })
componetnsStr.push(`export { \n ${newComp.join(",\n ")} \n}`) componetnsStr.push(`export { \n ${newComp.join(",\n ")} \n}`)
typeStr = typeStr.replace("__placeholder__", typeArray.join(',\n ')) typeStr = typeStr.replace("__placeholder__", typeArray.join(',\n '))

9
packages/components/button/index.ts

@ -1,4 +1,7 @@
import button from "./index.vue" import PsButton from "./index.vue"
button.name="ps-button" PsButton.name="ps-button"
export default button export {
PsButton
}
export default PsButton

10
packages/components/fuck/index.ts

@ -1,3 +1,7 @@
import fuck from "./index.vue" import PsFuck from "./index.vue"
fuck.name = "ps-fuck" PsFuck.name = "ps-fuck"
export default fuck
export {
PsFuck
}
export default PsFuck

8
packages/components/send/index.ts

@ -0,0 +1,8 @@
import PsSend from "./index.vue"
PsSend.name = "ps-send"
export {
PsSend
}
export default PsSend

15
packages/components/send/index.vue

@ -0,0 +1,15 @@
<template>
<div>
send
</div>
</template>
<script setup lang="ts">
</script>
<style>
div{
color: gold
}
</style>

24
packages/playground/.gitignore

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

16
packages/playground/README.md

@ -0,0 +1,16 @@
# Vue 3 + TypeScript + Vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
## Type Support For `.vue` Imports in TS
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).

14
packages/playground/components.d.ts

@ -0,0 +1,14 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/vue-next/pull/3399
import '@vue/runtime-core'
declare module '@vue/runtime-core' {
export interface GlobalComponents {
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
PsButton: typeof import('@princess-ui/components/button')['PsButton']
PsSend: typeof import('@princess-ui/components/send')['PsSend']
}
}
export {}

13
packages/playground/index.html

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

3
packages/playground/index.ts

@ -1,3 +0,0 @@
import ff from "@noderun/components"
console.log(ff);

24
packages/playground/package.json

@ -1,12 +1,22 @@
{ {
"name": "@princess-ui/playground", "name": "@princess-ui/playground",
"version": "1.0.0", "private": true,
"description": "", "version": "0.0.0",
"main": "index.ts",
"scripts": { "scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
}, },
"keywords": [], "dependencies": {
"author": "", "lodash": "^4.17.21",
"license": "ISC" "vue": "^3.2.25"
},
"devDependencies": {
"@types/lodash": "^4.14.182",
"@vitejs/plugin-vue": "^2.3.3",
"typescript": "^4.5.4",
"unplugin-vue-components": "^0.19.5",
"vite": "^2.9.9",
"vue-tsc": "^0.34.7"
}
} }

BIN
packages/playground/public/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

23
packages/playground/src/App.vue

@ -0,0 +1,23 @@
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import HelloWorld from './components/HelloWorld.vue'
</script>
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
<ps-button color="red" aaa="dd">sada</ps-button>
<ps-send color="red" aaa="dd">sada</ps-send>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

BIN
packages/playground/src/assets/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

52
packages/playground/src/components/HelloWorld.vue

@ -0,0 +1,52 @@
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{ msg: string }>()
const count = ref(0)
</script>
<template>
<h1>{{ msg }}</h1>
<p>
Recommended IDE setup:
<a href="https://code.visualstudio.com/" target="_blank">VS Code</a>
+
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
</p>
<p>See <code>README.md</code> for more information.</p>
<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank">
Vite Docs
</a>
|
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p>
<button type="button" @click="count++">count is: {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>
</template>
<style scoped>
a {
color: #42b983;
}
label {
margin: 0 0.5em;
font-weight: bold;
}
code {
background-color: #eee;
padding: 2px 4px;
border-radius: 4px;
color: #304455;
}
</style>

8
packages/playground/src/env.d.ts

@ -0,0 +1,8 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
}

4
packages/playground/src/main.ts

@ -0,0 +1,4 @@
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')

18
packages/playground/tsconfig.json

@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "components.d.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}

8
packages/playground/tsconfig.node.json

@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}

24
packages/playground/vite.config.ts

@ -0,0 +1,24 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import * as _ from "lodash"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), Components({
dts: true,
resolvers: [
{
type: "component",
resolve: (componentName: string) => {
if (componentName.startsWith("Ps")) {
return {
name: componentName,
from: `@princess-ui/components/${_.lowerFirst(componentName.slice(2))}`
}
}
},
}
],
})]
})

2
gulpfile.ts/index.ts → packages/theme-chalk/gulpfile.ts/index.ts

@ -1,7 +1,7 @@
import { src, dest } from "gulp" import { src, dest } from "gulp"
async function defaultTask(cb) { async function defaultTask(cb) {
await src("packages/theme-chalk/**/*.scss").pipe(dest("lib")) // await src("packages/theme-chalk/**/*.scss").pipe(dest("lib"))
cb() cb()
} }

0
gulpfile.ts/tsconfig.json → packages/theme-chalk/gulpfile.ts/tsconfig.json

2
packages/theme-chalk/package.json

@ -5,7 +5,7 @@
"main": "index.ts", "main": "index.ts",
"module": "index.ts", "module": "index.ts",
"scripts": { "scripts": {
"dev": "ts-node ../../scripts/index.ts" "build": "set TS_NODE_PROJECT=gulpfile.ts/tsconfig.json& gulp -f gulpfile.ts"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

0
packages/theme-chalk/index.scss → packages/theme-chalk/src/index.scss

2622
pnpm-lock.yaml

File diff suppressed because it is too large
Loading…
Cancel
Save