create-widget 24.1.1-beta.8 → 26.7.21

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 (83) hide show
  1. package/LICENSE +27 -27
  2. package/bin/index.js +277 -0
  3. package/eslint/eslint.config.js +12 -0
  4. package/package.json +24 -15
  5. package/readme.md +82 -0
  6. package/template/react/README.md +41 -0
  7. package/template/react/components.json +25 -0
  8. package/template/react/env.d.ts +1 -0
  9. package/template/react/index.html +13 -0
  10. package/template/react/package.json +42 -0
  11. package/template/react/public/apple-touch-icon.png +0 -0
  12. package/template/react/public/favicon-96x96.png +0 -0
  13. package/template/react/public/favicon.ico +0 -0
  14. package/template/react/public/favicon.svg +3 -0
  15. package/template/react/public/logo.png +0 -0
  16. package/template/react/public/site.webmanifest +21 -0
  17. package/template/react/public/web-app-manifest-192x192.png +0 -0
  18. package/template/react/public/web-app-manifest-512x512.png +0 -0
  19. package/template/{public → react/public}/widget.json +55 -50
  20. package/template/react/src/App.tsx +17 -0
  21. package/template/react/src/assets/main.css +221 -0
  22. package/template/react/src/components/ui/button.tsx +67 -0
  23. package/template/react/src/components/ui/card.tsx +103 -0
  24. package/template/react/src/components/ui/color-picker.tsx +171 -0
  25. package/template/react/src/components/ui/field.tsx +238 -0
  26. package/template/react/src/components/ui/input.tsx +19 -0
  27. package/template/react/src/components/ui/label.tsx +22 -0
  28. package/template/react/src/components/ui/separator.tsx +28 -0
  29. package/template/react/src/components/ui/slider.tsx +57 -0
  30. package/template/react/src/components/ui/switch.tsx +31 -0
  31. package/template/react/src/components/ui/tabs.tsx +88 -0
  32. package/template/react/src/lib/utils.ts +7 -0
  33. package/template/react/src/main.tsx +20 -0
  34. package/template/react/src/pages/home-page.tsx +66 -0
  35. package/template/react/src/widgets/clock/Clock.widget.ts +21 -0
  36. package/template/react/src/widgets/clock/ClockConfigView.tsx +112 -0
  37. package/template/react/src/widgets/clock/ClockWidgetRoutes.ts +25 -0
  38. package/template/react/src/widgets/clock/ClockWidgetView.tsx +104 -0
  39. package/template/react/src/widgets/widget-router.ts +11 -0
  40. package/template/react/tsconfig.app.json +26 -0
  41. package/template/react/tsconfig.json +17 -0
  42. package/template/react/tsconfig.node.json +23 -0
  43. package/template/react/vite.config.ts +27 -0
  44. package/template/{widget.package.ts → react/widget.package.ts} +5 -1
  45. package/template/{.vscode → vue/.vscode}/extensions.json +3 -3
  46. package/template/vue/README.md +34 -0
  47. package/template/{env.d.ts → vue/env.d.ts} +1 -1
  48. package/template/{index.html → vue/index.html} +13 -13
  49. package/template/vue/package.json +34 -0
  50. package/template/vue/public/apple-touch-icon.png +0 -0
  51. package/template/vue/public/favicon-96x96.png +0 -0
  52. package/template/vue/public/favicon.ico +0 -0
  53. package/template/vue/public/favicon.svg +3 -0
  54. package/template/vue/public/logo.png +0 -0
  55. package/template/vue/public/preview_clock.png +0 -0
  56. package/template/vue/public/site.webmanifest +21 -0
  57. package/template/vue/public/web-app-manifest-192x192.png +0 -0
  58. package/template/vue/public/web-app-manifest-512x512.png +0 -0
  59. package/template/{src → vue/src}/App.vue +9 -9
  60. package/template/vue/src/Home.vue +10 -0
  61. package/template/{src → vue/src}/main.ts +13 -12
  62. package/template/{src → vue/src}/router/index.ts +4 -0
  63. package/template/{src → vue/src}/widgets/clock/Clock.widget.ts +21 -21
  64. package/template/{src → vue/src}/widgets/clock/ClockConfigView.vue +37 -38
  65. package/template/{src → vue/src}/widgets/clock/ClockWidgetRoutes.ts +28 -28
  66. package/template/{src → vue/src}/widgets/clock/ClockWidgetView.vue +38 -35
  67. package/template/{src → vue/src}/widgets/widget-router.ts +3 -3
  68. package/template/{tsconfig.app.json → vue/tsconfig.app.json} +13 -13
  69. package/template/{tsconfig.json → vue/tsconfig.json} +11 -11
  70. package/template/{tsconfig.node.json → vue/tsconfig.node.json} +17 -17
  71. package/template/vue/vite.config.ts +29 -0
  72. package/template/vue/widget.package.ts +24 -0
  73. package/unocss/src/main.ts +13 -0
  74. package/unocss/uno.config.ts +5 -0
  75. package/unocss/vite.config.ts +31 -0
  76. package/index.cjs +0 -7913
  77. package/template/README.md +0 -40
  78. package/template/package.json +0 -29
  79. package/template/public/favicon.ico +0 -0
  80. package/template/src/widgets/clock/model/ClockModel.ts +0 -5
  81. package/template/vite.config.ts +0 -15
  82. /package/template/{public → react/public}/preview_clock.png +0 -0
  83. /package/template/{src → vue/src}/assets/main.css +0 -0
@@ -1,35 +1,38 @@
1
- <script lang="ts" setup>
2
- import { useWidget } from '@widget-js/vue3'
3
- import { ref } from 'vue'
4
- import { ClockModel } from '@/widgets/clock/model/ClockModel'
5
-
6
- const { widgetData } = useWidget(ClockModel)
7
-
8
- const time = ref(new Date().toLocaleTimeString())
9
- setInterval(() => {
10
- time.value = new Date().toLocaleTimeString()
11
- }, 1000)
12
- </script>
13
-
14
- <template>
15
- <widget-wrapper>
16
- <div class="clock">
17
- <span>{{ widgetData.title }}</span>
18
- <span>{{ time }}</span>
19
- </div>
20
- </widget-wrapper>
21
- </template>
22
-
23
- <style scoped>
24
- .clock {
25
- font-size: 16px;
26
- font-weight: bold;
27
- display: flex;
28
- flex-direction: column;
29
- align-items: center;
30
- background-color: var(--widget-background-color);
31
- border-radius: var(--widget-border-radius);
32
- color: var(--widget-color);
33
- justify-content: center;
34
- }
35
- </style>
1
+ <script lang="ts" setup>
2
+ import { useStorage } from '@vueuse/core'
3
+ import { useWidget } from '@widget-js/vue3'
4
+ import { ref } from 'vue'
5
+
6
+ useWidget({})
7
+ const title = useStorage('title', 'Clock')
8
+ const time = ref(new Date().toLocaleTimeString())
9
+ setInterval(() => {
10
+ time.value = new Date().toLocaleTimeString()
11
+ }, 1000)
12
+ </script>
13
+
14
+ <template>
15
+ <widget-wrapper>
16
+ <div class="clock">
17
+ <span>{{ title }}</span>
18
+ <span>{{ time }}</span>
19
+ </div>
20
+ </widget-wrapper>
21
+ </template>
22
+
23
+ <style scoped>
24
+ *{
25
+ user-select: none;
26
+ }
27
+ .clock {
28
+ font-size: 16px;
29
+ font-weight: bold;
30
+ display: flex;
31
+ height: 100%;
32
+ gap: 0.5rem;
33
+ flex-direction: column;
34
+ align-items: center;
35
+ color: var(--widget-color);
36
+ justify-content: center;
37
+ }
38
+ </style>
@@ -1,9 +1,9 @@
1
1
  import type { RouteRecordRaw } from 'vue-router'
2
- import ClockWidgetRoutes from './clock/ClockWidgetRoutes'
3
-
2
+ import ClockWidgetRoutes from './clock/ClockWidgetRoutes'
3
+
4
4
  // FBI WANING! IMPORT PLACE, DONT DELETE THIS LINE
5
5
  const WidgetRouter: RouteRecordRaw[] = [
6
- ...ClockWidgetRoutes,
6
+ ...ClockWidgetRoutes,
7
7
  // FBI WANING! ROUTE PLACE, DONT DELETE THIS LINE
8
8
  ]
9
9
  export default WidgetRouter
@@ -1,13 +1,13 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.dom.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "baseUrl": ".",
6
- "paths": {
7
- "@/*": ["./src/*"]
8
- },
9
- "noEmit": true
10
- },
11
- "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
12
- "exclude": ["src/**/__tests__/*"]
13
- }
1
+ {
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "baseUrl": ".",
6
+ "paths": {
7
+ "@/*": ["./src/*"]
8
+ },
9
+ "noEmit": true
10
+ },
11
+ "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
12
+ "exclude": ["src/**/__tests__/*"]
13
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "references": [
3
- {
4
- "path": "./tsconfig.node.json"
5
- },
6
- {
7
- "path": "./tsconfig.app.json"
8
- }
9
- ],
10
- "files": []
11
- }
1
+ {
2
+ "references": [
3
+ {
4
+ "path": "./tsconfig.node.json"
5
+ },
6
+ {
7
+ "path": "./tsconfig.app.json"
8
+ }
9
+ ],
10
+ "files": []
11
+ }
@@ -1,17 +1,17 @@
1
- {
2
- "extends": "@tsconfig/node18/tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "types": ["node"],
8
- "noEmit": true
9
- },
10
- "include": [
11
- "vite.config.*",
12
- "vitest.config.*",
13
- "cypress.config.*",
14
- "nightwatch.conf.*",
15
- "playwright.config.*"
16
- ]
17
- }
1
+ {
2
+ "extends": "@tsconfig/node18/tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "types": ["node"],
8
+ "noEmit": true
9
+ },
10
+ "include": [
11
+ "vite.config.*",
12
+ "vitest.config.*",
13
+ "cypress.config.*",
14
+ "nightwatch.conf.*",
15
+ "playwright.config.*"
16
+ ]
17
+ }
@@ -0,0 +1,29 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import widget from '@widget-js/vite-plugin-widget'
4
+ import AutoImport from 'unplugin-auto-import/vite'
5
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
6
+ import Components from 'unplugin-vue-components/vite'
7
+ import { defineConfig } from 'vite'
8
+
9
+ export default defineConfig((config) => {
10
+ const offlineMode = config.mode === 'offline'
11
+ const base = offlineMode ? './' : '/clock'
12
+ return {
13
+ base,
14
+ plugins: [
15
+ vue(),
16
+ widget({
17
+ zipName: 'test-widget',
18
+ generateZip: offlineMode,
19
+ }),
20
+ AutoImport({ resolvers: [ElementPlusResolver()] }),
21
+ Components({ resolvers: [ElementPlusResolver()] }),
22
+ ],
23
+ resolve: {
24
+ alias: {
25
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
26
+ },
27
+ },
28
+ }
29
+ })
@@ -0,0 +1,24 @@
1
+ import { WidgetPackage } from '@widget-js/core'
2
+
3
+ // TODO 完善组件包信息
4
+ export default new WidgetPackage({
5
+ author: '修改成你的信息',
6
+ description: {
7
+ 'zh-CN': '修改成你的组件描述',
8
+ },
9
+ entry: '/',
10
+ hash: true,
11
+ remote: {
12
+ base: '/',
13
+ hostname: '修改成你的域名',
14
+ hash: true,
15
+ },
16
+ homepage: '',
17
+ name: 'cn.example.widget',
18
+ title: {
19
+ 'zh-CN': '修改成你的组件标题',
20
+ },
21
+ devOptions: {
22
+ folder: './src/widgets/',
23
+ },
24
+ })
@@ -0,0 +1,13 @@
1
+ import 'virtual:uno.css'
2
+ import { WidgetJsPlugin } from '@widget-js/vue3'
3
+ import '@widget-js/vue3/dist/style.css'
4
+ import '@/assets/main.css'
5
+ import { createApp } from 'vue'
6
+ import App from './App.vue'
7
+ import router from './router'
8
+
9
+ const app = createApp(App)
10
+
11
+ app.use(router)
12
+ app.use(WidgetJsPlugin)
13
+ app.mount('#app')
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from 'unocss'
2
+
3
+ export default defineConfig({
4
+ // ...UnoCSS options
5
+ })
@@ -0,0 +1,31 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import widget from '@widget-js/vite-plugin-widget'
4
+ import UnoCSS from 'unocss/vite'
5
+ import AutoImport from 'unplugin-auto-import/vite'
6
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
7
+ import Components from 'unplugin-vue-components/vite'
8
+ import { defineConfig } from 'vite'
9
+
10
+ export default defineConfig((config) => {
11
+ const offlineMode = config.mode === 'offline'
12
+ const base = offlineMode ? './' : '/clock'
13
+ return {
14
+ base,
15
+ plugins: [
16
+ vue(),
17
+ UnoCSS(),
18
+ widget({
19
+ zipName: 'test-widget',
20
+ generateZip: offlineMode,
21
+ }),
22
+ AutoImport({ resolvers: [ElementPlusResolver()] }),
23
+ Components({ resolvers: [ElementPlusResolver()] }),
24
+ ],
25
+ resolve: {
26
+ alias: {
27
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
28
+ },
29
+ },
30
+ }
31
+ })