Skip to content

Commit

Permalink
feat: add publisher hook and bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed May 14, 2023
1 parent 7337ad1 commit dc34341
Show file tree
Hide file tree
Showing 28 changed files with 446 additions and 2 deletions.
1 change: 1 addition & 0 deletions libs/publisher-bridge/.env.development.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_DEBUG_MODE=true
4 changes: 4 additions & 0 deletions libs/publisher-bridge/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"],
}
2 changes: 2 additions & 0 deletions libs/publisher-bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.DS_Store
11 changes: 11 additions & 0 deletions libs/publisher-bridge/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# platform

# Ignore artifacts:
dist
node_modules

# Ignore all dts files:
*.d.ts

# lib
/pnpm-lock.yaml
30 changes: 30 additions & 0 deletions libs/publisher-bridge/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

module.exports = {
semi: false,
singleQuote: false,
printWidth: 120
}
41 changes: 41 additions & 0 deletions libs/publisher-bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# publisher-bridge

a bridge between publisher plugin and widget

## Usage

```js
// usage
```

## Deps

```
## Congregations! publisher-bridge need no deps, it is just pure js code 🎉
```

## Dev

```bash
pnpm dev -F publisher-bridge
```

## Build

```bash
pnpm build -F publisher-bridge
```

## Test

Execute the unit tests via [vitest](https://vitest.dev)

```bash
pnpm test -F publisher-bridge
```

## Publish

```bash
pnpm publish -F publisher-bridge --tag latest
```
12 changes: 12 additions & 0 deletions libs/publisher-bridge/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
This file is for lib hot-load test only, see <a href="/src/index.ts">/src/index.ts</a>
<script type="module" src="/src/index.ts"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions libs/publisher-bridge/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "publisher-bridge",
"version": "0.0.1",
"type": "module",
"description": "a bridge between publisher plugin and widget",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/libs/publisher-bridge",
"author": "terwer",
"license": "GPL",
"files": [
"dist",
"README.md"
],
"keywords": [
"zhi",
"lib"
],
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "vite preview",
"test": "vitest --watch"
},
"devDependencies": {
"@terwer/eslint-config-custom": "^1.2.0",
"@terwer/vite-config-custom": "^0.2.0"
}
}
7 changes: 7 additions & 0 deletions libs/publisher-bridge/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, it } from "vitest"

describe("index", () => {
it("test index", () => {
console.log("hello")
})
})
5 changes: 5 additions & 0 deletions libs/publisher-bridge/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const init = () => {
return "ok"
}

export default init
42 changes: 42 additions & 0 deletions libs/publisher-bridge/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "Node",
// "allowImportingTsExtensions": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"types": [
"node",
"vite/client"
]
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue"
],
"references": [
{
"path": "./tsconfig.node.json"
}
],
"root": "."
}
10 changes: 10 additions & 0 deletions libs/publisher-bridge/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
27 changes: 27 additions & 0 deletions libs/publisher-bridge/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="vitest" />

import { resolve } from "path"
import { defineConfig } from "vite"

export default defineConfig({
build: {
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/index.ts"),
// the proper extensions will be added
fileName: "index",
formats: ["cjs"],
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [],
},
},

test: {
globals: true,
environment: "jsdom",
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
},
})
1 change: 1 addition & 0 deletions libs/publisher-hook/.env.development.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_DEBUG_MODE=true
4 changes: 4 additions & 0 deletions libs/publisher-hook/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"],
}
2 changes: 2 additions & 0 deletions libs/publisher-hook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.DS_Store
11 changes: 11 additions & 0 deletions libs/publisher-hook/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# platform

# Ignore artifacts:
dist
node_modules

# Ignore all dts files:
*.d.ts

# lib
/pnpm-lock.yaml
30 changes: 30 additions & 0 deletions libs/publisher-hook/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

module.exports = {
semi: false,
singleQuote: false,
printWidth: 120
}
41 changes: 41 additions & 0 deletions libs/publisher-hook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# publisher-hook

siyuanhook for sy-post-publisher widget

## Usage

```js
// usage
```

## Deps

```
## Congregations! publisher-hook need no deps, it is just pure js code 🎉
```

## Dev

```bash
pnpm dev -F publisher-hook
```

## Build

```bash
pnpm build -F publisher-hook
```

## Test

Execute the unit tests via [vitest](https://vitest.dev)

```bash
pnpm test -F publisher-hook
```

## Publish

```bash
pnpm publish -F publisher-hook --tag latest
```
12 changes: 12 additions & 0 deletions libs/publisher-hook/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
This file is for lib hot-load test only, see <a href="/src/index.ts">/src/index.ts</a>
<script type="module" src="/src/index.ts"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions libs/publisher-hook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "publisher-hook",
"version": "0.0.1",
"type": "module",
"description": "siyuanhook for sy-post-publisher widget",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/libs/publisher-hook",
"author": "terwer",
"license": "GPL",
"files": [
"dist",
"README.md"
],
"keywords": [
"zhi",
"lib"
],
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "vite preview",
"test": "vitest --watch"
},
"devDependencies": {
"@terwer/eslint-config-custom": "^1.2.0",
"@terwer/vite-config-custom": "^0.2.0"
}
}
7 changes: 7 additions & 0 deletions libs/publisher-hook/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, it } from "vitest"

describe("index", () => {
it("test index", () => {
console.log("hello")
})
})
5 changes: 5 additions & 0 deletions libs/publisher-hook/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const init = () => {
return "ok"
}

export default init
Loading

0 comments on commit dc34341

Please sign in to comment.