Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add MainFunction #394

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
auto-install-peers=true
# electron_mirror=https://cdn.npmmirror.com/binaries/electron/
# electron_custom_dir=26.3.0
shamefully-hoist=true
18 changes: 18 additions & 0 deletions apps/zhi-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# zhi-cli

## 1.5.15

### Patch Changes

- zhi-log@1.14.15

## 1.5.14

### Patch Changes

- zhi-log@1.14.14

## 1.5.13

### Patch Changes

- zhi-log@1.14.13

## 1.5.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/zhi-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-cli",
"version": "1.5.12",
"version": "1.5.15",
"description": "a tool for generating zhi framework related projects",
"type": "module",
"bin": {
Expand Down
9 changes: 9 additions & 0 deletions libs/zhi-blog-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# zhi-blog-api

## 1.46.1

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0
- zhi-common@1.24.1

## 1.46.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-blog-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-blog-api",
"version": "1.46.0",
"version": "1.46.1",
"type": "module",
"description": "a common blog interface",
"main": "./dist/index.js",
Expand Down
33 changes: 33 additions & 0 deletions libs/zhi-cmd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# zhi-cmd

## 0.3.0

### Minor Changes

- feat: add MainFunction

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0

## 0.2.3

### Patch Changes

- Updated dependencies
- zhi-device@2.6.0

## 0.2.2

### Patch Changes

- Updated dependencies
- zhi-device@2.5.0

## 0.2.1

### Patch Changes

- Updated dependencies
- zhi-device@2.4.0

## 0.2.0

### Minor Changes
Expand Down
5 changes: 2 additions & 3 deletions libs/zhi-cmd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-cmd",
"version": "0.2.0",
"version": "0.3.0",
"type": "module",
"description": "commond utils for siyuan-note",
"main": "./dist/index.cjs",
Expand All @@ -16,8 +16,7 @@
"scripts": {
"dev": "zhi-build --watch",
"build": "zhi-build --production",
"test": "vitest",
"lint": "eslint 'src/**/*.{ts,js}' --fix"
"test": "vitest"
},
"devDependencies": {
"@terwer/esbuild-config-custom": "workspace:*",
Expand Down
11 changes: 8 additions & 3 deletions libs/zhi-cmd/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { CustomCmd } from "./lib/customCmd"
import { SiyuanDevice } from "zhi-device"
import { simpleLogger } from "zhi-lib-base"
import { MainFunction, simpleLogger } from "zhi-lib-base"

const init = () => {
/**
* 命令类库入口
*
* @param args 参数,可选
*/
const main: MainFunction = async (args: any[]) => {
const logger = simpleLogger("zhi-cmd", "zhi", true)
const win = SiyuanDevice.siyuanWindow()
if (!win.zhiCmdInited) {
Expand All @@ -17,4 +22,4 @@ const init = () => {
return win.zhiCmd
}

export default init
export default main
8 changes: 8 additions & 0 deletions libs/zhi-common-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# zhi-common-markdown

## 0.1.7

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0

## 0.1.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-common-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-common-markdown",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",
"description": "a universal Markdown parsing tool",
"main": "./dist/index.js",
Expand Down
8 changes: 8 additions & 0 deletions libs/zhi-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# zhi-common

## 1.24.1

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0

## 1.24.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-common",
"version": "1.24.0",
"version": "1.24.1",
"type": "module",
"description": "a collection of util tools",
"main": "./dist/index.js",
Expand Down
18 changes: 18 additions & 0 deletions libs/zhi-device/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# zhi-device

## 2.6.0

### Minor Changes

- fix: fix this plugin name

## 2.5.0

### Minor Changes

- feat: change device type

## 2.4.0

### Minor Changes

- feat: add path type

## 2.3.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-device/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-device",
"version": "2.3.1",
"version": "2.6.0",
"type": "module",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions libs/zhi-device/src/deviceDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class DeviceDetection {
}

// 思源新窗口
if (SiyuanDevice.isInSiyuanNewWin()) {
return DeviceTypeEnum.DeviceType_Siyuan_NewWin
if (SiyuanDevice.isInSiyuanRendererWin()) {
return DeviceTypeEnum.DeviceType_Siyuan_RendererWin
}

// 思源主窗口
Expand Down
4 changes: 4 additions & 0 deletions libs/zhi-device/src/lib/basePathTypeEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ enum BasePathTypeEnum {
* Zhi 主题目录
*/
BasePathType_ZhiTheme = "ZhiTheme",
/**
* 当前插件目录
*/
BasePathType_ThisPlugin = "ThisPlugin",
/**
* 未设置
*/
Expand Down
4 changes: 2 additions & 2 deletions libs/zhi-device/src/lib/deviceTypeEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ enum DeviceTypeEnum {
DeviceType_Siyuan_Widget = "Siyuan_Widget",

/**
* 思源笔记新窗口
* 思源笔记渲染窗口
*/
DeviceType_Siyuan_NewWin = "Siyuan_NewWindow",
DeviceType_Siyuan_RendererWin = "Siyuan_RendererWindow",

/**
* 思源笔记主窗口
Expand Down
7 changes: 4 additions & 3 deletions libs/zhi-device/src/lib/siyuanDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ class SiyuanDevice {
return false
}
return (
typeof (window as any).siyuan === "undefined" &&
typeof (window as any).parent.process !== "undefined" &&
(window as any).parent.process.versions != null &&
(window as any).parent.process.versions.electron != null
)
}

/**
* 思源笔记新窗口
* 思源笔记渲染窗口
*
* @author terwer
* @version 0.1.0
* @since 0.0.1
*/
public static isInSiyuanNewWin = () => {
public static isInSiyuanRendererWin = () => {
return typeof window !== "undefined" && (window as any).process && (window as any).process.type === "renderer"
}

Expand All @@ -78,7 +79,7 @@ class SiyuanDevice {
if (this.isInSiyuanWidget()) {
win = parent.window
} else {
if (this.isInSiyuanNewWin()) {
if (this.isInSiyuanRendererWin()) {
win = window
} else if (this.isInSiyuanBrowser()) {
win = window
Expand Down
34 changes: 34 additions & 0 deletions libs/zhi-fetch-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# zhi-fetch-middleware

## 0.7.2

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0
- zhi-common@1.24.1

## 0.7.1

### Patch Changes

- Updated dependencies
- zhi-device@2.6.0

## 0.7.0

### Minor Changes

- feat: change device type

### Patch Changes

- Updated dependencies
- zhi-device@2.5.0

## 0.6.6

### Patch Changes

- Updated dependencies
- zhi-device@2.4.0

## 0.6.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-fetch-middleware/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-fetch-middleware",
"version": "0.6.5",
"version": "0.7.2",
"type": "module",
"description": "an intermediate tier prepared for fetch requests",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-fetch-middleware/src/lib/commonFetchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CommonFetchClient {
}
case DeviceTypeEnum.DeviceType_Siyuan_Widget:
case DeviceTypeEnum.DeviceType_Siyuan_MainWin:
case DeviceTypeEnum.DeviceType_Siyuan_NewWin: {
case DeviceTypeEnum.DeviceType_Siyuan_RendererWin: {
this.logger.info("当前处于思源笔记环境,使用electron的fetch获取数据")
result = await fetchNode(this.appInstance, apiUrl, fetchOptions)
break
Expand Down
9 changes: 9 additions & 0 deletions libs/zhi-github-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# zhi-github-middleware

## 0.4.4

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0
- zhi-common@1.24.1

## 0.4.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-github-middleware/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-github-middleware",
"version": "0.4.3",
"version": "0.4.4",
"type": "module",
"description": "a middleware for github api",
"main": "./dist/index.js",
Expand Down
28 changes: 28 additions & 0 deletions libs/zhi-gitlab-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# zhi-gitlab-middleware

## 0.6.9

### Patch Changes

- Updated dependencies
- Updated dependencies
- zhi-lib-base@0.6.0
- zhi-fetch-middleware@0.7.2

## 0.6.8

### Patch Changes

- zhi-fetch-middleware@0.7.1

## 0.6.7

### Patch Changes

- Updated dependencies
- zhi-fetch-middleware@0.7.0

## 0.6.6

### Patch Changes

- zhi-fetch-middleware@0.6.6

## 0.6.5

### Patch Changes
Expand Down
Loading