create-widget 0.0.2 → 0.0.4
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/lib/index.js +53 -35
- package/package.json +7 -4
- package/.editorconfig +0 -13
- package/.idea/create-widget.iml +0 -9
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jpa-buddy.xml +0 -6
- package/.idea/misc.xml +0 -8
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/src/index.ts +0 -144
- package/src/utils/FileUtils.ts +0 -33
- package/src/utils/deepMerge.ts +0 -26
- package/src/utils/directoryTraverse.ts +0 -35
- package/src/utils/getCommand.ts +0 -13
- package/src/utils/renderTemplate.ts +0 -88
- package/src/utils/sortDependencies.ts +0 -22
- package/test/index.test.ts +0 -24
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -6
- package/widget-test/.vscode/extensions.json +0 -3
- package/widget-test/README.md +0 -40
- package/widget-test/env.d.ts +0 -1
- package/widget-test/index.html +0 -13
- package/widget-test/package.json +0 -30
- package/widget-test/public/favicon.ico +0 -0
- package/widget-test/public/preview_clock.png +0 -0
- package/widget-test/public/widget.json +0 -50
- package/widget-test/src/App.vue +0 -9
- package/widget-test/src/assets/main.css +0 -3
- package/widget-test/src/main.ts +0 -12
- package/widget-test/src/router/index.ts +0 -11
- package/widget-test/src/widgets/clock/Clock.widget.ts +0 -32
- package/widget-test/src/widgets/clock/ClockConfigView.vue +0 -38
- package/widget-test/src/widgets/clock/ClockWidgetRoutes.ts +0 -28
- package/widget-test/src/widgets/clock/ClockWidgetView.vue +0 -34
- package/widget-test/src/widgets/clock/model/ClockModel.ts +0 -5
- package/widget-test/src/widgets/widget-router.ts +0 -8
- package/widget-test/tsconfig.app.json +0 -13
- package/widget-test/tsconfig.json +0 -11
- package/widget-test/tsconfig.node.json +0 -17
- package/widget-test/vite.config.ts +0 -14
- package/widget-test/widget.package.ts +0 -20
- package/widget-test/yarn.lock +0 -1399
package/test/index.test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {expect, test} from "vitest";
|
|
2
|
-
import {minimatch} from "minimatch";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import gradient from "gradient-string"
|
|
5
|
-
|
|
6
|
-
test('minimatch',()=>{
|
|
7
|
-
let fileName = path.basename('C:\\Users\\rtuge\\Desktop\\github\\widgetjs\\packages\\@widget-js\\cli\\template\\Widget.ejs');
|
|
8
|
-
expect(minimatch(fileName,'*.ejs')).toBeTruthy()
|
|
9
|
-
expect(minimatch(fileName,'*.ts')).toBeFalsy()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
test('gradient brand',()=>{
|
|
14
|
-
console.log(gradient([
|
|
15
|
-
{ color: '#42d392', pos: 0 },
|
|
16
|
-
{ color: '#42d392', pos: 0.1 },
|
|
17
|
-
{ color: '#647eff', pos: 1 }
|
|
18
|
-
])('Widget.js - The Desktop Widget Framework'))
|
|
19
|
-
console.log(gradient([
|
|
20
|
-
{color: '#42d392', pos: 0},
|
|
21
|
-
{color: '#42d392', pos: 0.1},
|
|
22
|
-
{color: '#647eff', pos: 1}
|
|
23
|
-
])('Widget.js - The Desktop Widget Framework'));
|
|
24
|
-
})
|
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
package/widget-test/README.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# hello widget
|
|
2
|
-
|
|
3
|
-
This template should help get you started developing with Vue 3 in Vite.
|
|
4
|
-
|
|
5
|
-
## Recommended IDE Setup
|
|
6
|
-
|
|
7
|
-
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
|
8
|
-
|
|
9
|
-
## Type Support for `.vue` Imports in TS
|
|
10
|
-
|
|
11
|
-
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
|
12
|
-
|
|
13
|
-
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
|
14
|
-
|
|
15
|
-
1. Disable the built-in TypeScript Extension
|
|
16
|
-
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
|
17
|
-
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
|
18
|
-
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
|
19
|
-
|
|
20
|
-
## Customize configuration
|
|
21
|
-
|
|
22
|
-
See [Vite Configuration Reference](https://vitejs.dev/config/).
|
|
23
|
-
|
|
24
|
-
## Project Setup
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
npm install
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Compile and Hot-Reload for Development
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
npm run dev
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Type-Check, Compile and Minify for Production
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
npm run build
|
|
40
|
-
```
|
package/widget-test/env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/widget-test/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<link rel="icon" href="/favicon.ico">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/src/main.ts"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/widget-test/package.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hello-widget",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "run-p type-check \"build-only {@}\" --",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"build-only": "vite build",
|
|
11
|
-
"type-check": "vue-tsc --build --force"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"vue": "^3.3.11",
|
|
15
|
-
"vue-router": "^4.2.5",
|
|
16
|
-
"@widget-js/core": "0.11.20",
|
|
17
|
-
"@widget-js/vue3": "0.11.21-rc.2"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@tsconfig/node18": "^18.2.2",
|
|
21
|
-
"@types/node": "^18.19.3",
|
|
22
|
-
"@vitejs/plugin-vue": "^4.5.2",
|
|
23
|
-
"@vue/tsconfig": "^0.5.0",
|
|
24
|
-
"npm-run-all2": "^6.1.1",
|
|
25
|
-
"typescript": "~5.3.0",
|
|
26
|
-
"vite": "^5.0.10",
|
|
27
|
-
"vue-tsc": "^1.8.25",
|
|
28
|
-
"@widget-js/vite-plugin-widget": "^1.2.8"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cn.example.widget",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"author": "修改成你的信息",
|
|
5
|
-
"homepage": "",
|
|
6
|
-
"title": {
|
|
7
|
-
"zh-CN": "修改成你的组件标题"
|
|
8
|
-
},
|
|
9
|
-
"description": {
|
|
10
|
-
"zh-CN": "修改成你的组件描述"
|
|
11
|
-
},
|
|
12
|
-
"entry": "/",
|
|
13
|
-
"hash": true,
|
|
14
|
-
"url": "",
|
|
15
|
-
"widgets": [
|
|
16
|
-
{
|
|
17
|
-
"name": "cn.test.widget.clock",
|
|
18
|
-
"title": {
|
|
19
|
-
"zh-CN": "时钟"
|
|
20
|
-
},
|
|
21
|
-
"description": {
|
|
22
|
-
"zh-CN": "Hello world!"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"recommend"
|
|
26
|
-
],
|
|
27
|
-
"security": false,
|
|
28
|
-
"permissions": [],
|
|
29
|
-
"lang": "zh-CN",
|
|
30
|
-
"width": 2,
|
|
31
|
-
"height": 2,
|
|
32
|
-
"maxWidth": 6,
|
|
33
|
-
"webviewTag": false,
|
|
34
|
-
"maxHeight": 6,
|
|
35
|
-
"minWidth": 2,
|
|
36
|
-
"minHeight": 2,
|
|
37
|
-
"movable": true,
|
|
38
|
-
"singleton": false,
|
|
39
|
-
"resizable": true,
|
|
40
|
-
"path": "/widget/clock",
|
|
41
|
-
"meta": {},
|
|
42
|
-
"backgroundThrottling": true,
|
|
43
|
-
"previewImage": "/preview_clock.png",
|
|
44
|
-
"supportDeployMode": 17,
|
|
45
|
-
"configPagePath": "/widget/config/clock",
|
|
46
|
-
"routes": []
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
"pages": []
|
|
50
|
-
}
|
package/widget-test/src/App.vue
DELETED
package/widget-test/src/main.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { WidgetJsPlugin } from '@widget-js/vue3'
|
|
2
|
-
import '@widget-js/vue3/dist/style.css'
|
|
3
|
-
import '@/assets/main.css'
|
|
4
|
-
import { createApp } from 'vue'
|
|
5
|
-
import App from './App.vue'
|
|
6
|
-
import router from './router'
|
|
7
|
-
|
|
8
|
-
const app = createApp(App)
|
|
9
|
-
|
|
10
|
-
app.use(router)
|
|
11
|
-
app.use(WidgetJsPlugin)
|
|
12
|
-
app.mount('#app')
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import WidgetRouter from '../widgets/widget-router';
|
|
2
|
-
import {createRouter, createWebHashHistory} from 'vue-router';
|
|
3
|
-
|
|
4
|
-
const router = createRouter({
|
|
5
|
-
history: createWebHashHistory(import.meta.env.BASE_URL),
|
|
6
|
-
routes: [
|
|
7
|
-
...WidgetRouter,
|
|
8
|
-
],
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export default router;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Widget, WidgetKeyword } from '@widget-js/core';
|
|
2
|
-
//TODO 修改组件信息,标题,描述,关键词
|
|
3
|
-
const name = 'cn.test.widget.clock';
|
|
4
|
-
//组件标题
|
|
5
|
-
const title = { 'zh-CN': '时钟' };
|
|
6
|
-
//组件描述
|
|
7
|
-
const description = { 'zh-CN': 'Hello world!' };
|
|
8
|
-
//组件关键词
|
|
9
|
-
const keywords = [WidgetKeyword.RECOMMEND];
|
|
10
|
-
//组件路由地址
|
|
11
|
-
const path = '/widget/clock';
|
|
12
|
-
//配置页路由地址
|
|
13
|
-
const configPagePath = '/widget/config/clock';
|
|
14
|
-
//组件关键词
|
|
15
|
-
const ClockWidget = new Widget({
|
|
16
|
-
name: name,
|
|
17
|
-
title: title,
|
|
18
|
-
description: description,
|
|
19
|
-
keywords: keywords,
|
|
20
|
-
lang: 'zh-CN',
|
|
21
|
-
width: 2,
|
|
22
|
-
height: 2,
|
|
23
|
-
minWidth: 2,
|
|
24
|
-
maxWidth: 6,
|
|
25
|
-
minHeight: 2,
|
|
26
|
-
maxHeight: 6,
|
|
27
|
-
previewImage: '/preview_clock.png',
|
|
28
|
-
path,
|
|
29
|
-
configPagePath,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export default ClockWidget;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<widget-edit-dialog
|
|
3
|
-
:widget-params="widgetParams"
|
|
4
|
-
:option="widgetConfigOption"
|
|
5
|
-
v-model="widgetData"
|
|
6
|
-
@apply="save()"
|
|
7
|
-
@confirm="save({ closeWindow: true })"
|
|
8
|
-
>
|
|
9
|
-
<template #custom>
|
|
10
|
-
标题 <input v-model="widgetData.title"/>
|
|
11
|
-
</template>
|
|
12
|
-
</widget-edit-dialog>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script lang="ts" setup>
|
|
16
|
-
import {
|
|
17
|
-
useWidget,
|
|
18
|
-
WidgetConfigOption,
|
|
19
|
-
WidgetEditDialog,
|
|
20
|
-
} from '@widget-js/vue3';
|
|
21
|
-
import {BrowserWindowApi} from '@widget-js/core';
|
|
22
|
-
import {ClockModel} from "@/widgets/clock/model/ClockModel";
|
|
23
|
-
|
|
24
|
-
const {widgetData, widgetParams, save} = useWidget(ClockModel);
|
|
25
|
-
BrowserWindowApi.setup({width: 600, height: 400});
|
|
26
|
-
//修改成需要设置组件参数配置
|
|
27
|
-
const widgetConfigOption = new WidgetConfigOption({
|
|
28
|
-
title:'时钟设置',
|
|
29
|
-
theme: {
|
|
30
|
-
backgroundColor: true,
|
|
31
|
-
borderRadius: true,
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<style scoped>
|
|
37
|
-
|
|
38
|
-
</style>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { RouteRecordRaw } from 'vue-router';
|
|
2
|
-
import ClockWidget from './Clock.widget';
|
|
3
|
-
|
|
4
|
-
const path = ClockWidget.path;
|
|
5
|
-
const name = ClockWidget.name;
|
|
6
|
-
|
|
7
|
-
const configPagePath = ClockWidget.configPagePath!;
|
|
8
|
-
|
|
9
|
-
const ClockWidgetRoutes: RouteRecordRaw[] = [
|
|
10
|
-
{
|
|
11
|
-
path: path,
|
|
12
|
-
name: `${name}`,
|
|
13
|
-
component: () =>
|
|
14
|
-
import(
|
|
15
|
-
/* webpackChunkName: "cn.test.widget.clock" */ './ClockWidgetView.vue'
|
|
16
|
-
),
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
path: configPagePath,
|
|
20
|
-
name: `${name}.config`,
|
|
21
|
-
component: () =>
|
|
22
|
-
import(
|
|
23
|
-
/* webpackChunkName: "cn.test.widget.clock.config" */ './ClockConfigView.vue'
|
|
24
|
-
),
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
export default ClockWidgetRoutes;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<widget-wrapper>
|
|
3
|
-
<div class="clock">
|
|
4
|
-
<span>{{ widgetData.title }}</span>
|
|
5
|
-
<span>{{ time }}</span>
|
|
6
|
-
</div>
|
|
7
|
-
</widget-wrapper>
|
|
8
|
-
</template>
|
|
9
|
-
<script lang="ts" setup>
|
|
10
|
-
import {useWidget} from '@widget-js/vue3';
|
|
11
|
-
import {ref} from "vue";
|
|
12
|
-
import {ClockModel} from "@/widgets/clock/model/ClockModel";
|
|
13
|
-
|
|
14
|
-
const {widgetData} = useWidget(ClockModel);
|
|
15
|
-
|
|
16
|
-
const time = ref(new Date().toLocaleTimeString())
|
|
17
|
-
setInterval(() => {
|
|
18
|
-
time.value = new Date().toLocaleTimeString()
|
|
19
|
-
}, 1000)
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<style scoped>
|
|
23
|
-
.clock {
|
|
24
|
-
font-size: 16px;
|
|
25
|
-
font-weight: bold;
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
align-items: center;
|
|
29
|
-
background-color: var(--widget-background-color);
|
|
30
|
-
border-radius: var(--widget-border-radius);
|
|
31
|
-
color: var(--widget-color);
|
|
32
|
-
justify-content: center;
|
|
33
|
-
}
|
|
34
|
-
</style>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RouteRecordRaw } from 'vue-router'
|
|
2
|
-
import ClockWidgetRoutes from "./clock/ClockWidgetRoutes";
|
|
3
|
-
//FBI WANING! IMPORT PLACE, DONT DELETE THIS LINE
|
|
4
|
-
const WidgetRouter: RouteRecordRaw[] = [
|
|
5
|
-
...ClockWidgetRoutes,
|
|
6
|
-
//FBI WANING! ROUTE PLACE, DONT DELETE THIS LINE
|
|
7
|
-
];
|
|
8
|
-
export default WidgetRouter
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
|
3
|
-
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
|
4
|
-
"exclude": ["src/**/__tests__/*"],
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"composite": true,
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
"baseUrl": ".",
|
|
9
|
-
"paths": {
|
|
10
|
-
"@/*": ["./src/*"]
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsconfig/node18/tsconfig.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"vite.config.*",
|
|
5
|
-
"vitest.config.*",
|
|
6
|
-
"cypress.config.*",
|
|
7
|
-
"nightwatch.conf.*",
|
|
8
|
-
"playwright.config.*"
|
|
9
|
-
],
|
|
10
|
-
"compilerOptions": {
|
|
11
|
-
"composite": true,
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
"module": "ESNext",
|
|
14
|
-
"moduleResolution": "Bundler",
|
|
15
|
-
"types": ["node"]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import widget from '@widget-js/vite-plugin-widget';
|
|
2
|
-
import { fileURLToPath, URL } from 'node:url';
|
|
3
|
-
|
|
4
|
-
import { defineConfig } from 'vite';
|
|
5
|
-
import vue from '@vitejs/plugin-vue';
|
|
6
|
-
// https://vitejs.dev/config/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [vue(), widget()],
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
homepage: '',
|
|
12
|
-
name: 'cn.example.widget',
|
|
13
|
-
title: {
|
|
14
|
-
'zh-CN': '修改成你的组件标题',
|
|
15
|
-
},
|
|
16
|
-
version: '1.0.0',
|
|
17
|
-
devOptions: {
|
|
18
|
-
folder: './src/widgets/',
|
|
19
|
-
},
|
|
20
|
-
});
|