-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 切换为单项目-polyfill 动态加载模块(zhi-publisher-shk),拆分zhi-publisher-shk
- Loading branch information
Showing
21 changed files
with
20,103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# publisher-sdk | ||
|
||
a common sdk for publishing post to every platform | ||
|
||
## Usage | ||
|
||
```js | ||
// usage | ||
``` | ||
|
||
## Deps | ||
|
||
``` | ||
## Congregations! publisher-sdk need no deps, it is just pure js code 🎉 | ||
``` | ||
|
||
## Dev | ||
|
||
```bash | ||
pnpm dev -F publisher-sdk | ||
``` | ||
|
||
## Build | ||
|
||
```bash | ||
pnpm build -F publisher-sdk | ||
``` | ||
|
||
## Test | ||
|
||
Execute the unit tests via [vitest](https://vitest.dev) | ||
|
||
```bash | ||
pnpm test -F publisher-sdk | ||
``` | ||
|
||
## Publish | ||
|
||
```bash | ||
pnpm publish -F publisher-sdk --tag latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import PublishSdk from "./publish-sdk"; | ||
export { PublishSdk }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var r = Object.defineProperty; | ||
var g = (i, t, s) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[t] = s; | ||
var n = (i, t, s) => (g(i, typeof t != "symbol" ? t + "" : t, s), s); | ||
(function(i, t) { | ||
!i || i.getElementById("livereloadscript") || (t = i.createElement("script"), t.async = 1, t.src = "//" + (self.location.host || "localhost").split(":")[0] + ":35730/livereload.js?snipver=1", t.id = "livereloadscript", i.getElementsByTagName("head")[0].appendChild(t)); | ||
})(self.document); | ||
class a { | ||
static init(t) { | ||
this.Env = t.Env, this.BlogConstants = t.BlogConstants, this.BlogTypeEnum = t.BlogTypeEnum, this.SiyuanConstants = t.SiyuanConstants, this.SiyuanConfig = t.SiyuanConfig, this.SiYuanApiAdaptor = t.SiYuanApiAdaptor, this.BlogApi = t.BlogApi; | ||
} | ||
/** | ||
* 获取 siyuan-kernel-api 实例 | ||
* | ||
* @param type - Env | BlogTypeEnum | ||
* @param cfg - BlogConfig | ||
* @return BlogApi | ||
*/ | ||
static blogApi(t, s) { | ||
if (!this.bApi) { | ||
let e, o; | ||
switch (t instanceof this.Env && (o = t.getEnv(this.BlogConstants.DEFAULT_BLOG_TYPE_KEY)), o) { | ||
case this.BlogTypeEnum.BlogTypeEnum_Wordpress: | ||
break; | ||
default: { | ||
if (t instanceof this.Env) { | ||
const p = t.getEnvOrDefault(this.SiyuanConstants.VITE_SIYUAN_API_URL_KEY, "http://127.0.0.1:6806"), c = t.getStringEnv(this.SiyuanConstants.VITE_SIYUAN_AUTH_TOKEN_KEY), l = new this.SiyuanConfig(p, c); | ||
l.fixTitle = !0, e = new this.SiYuanApiAdaptor(l); | ||
} else | ||
e = new this.SiYuanApiAdaptor(s); | ||
break; | ||
} | ||
} | ||
if (!e) | ||
throw new Error("ApiAdaptor cannot be null"); | ||
this.bApi = new this.BlogApi(e); | ||
} | ||
return this.bApi; | ||
} | ||
} | ||
/** | ||
* BlogApi | ||
* @private | ||
*/ | ||
n(a, "bApi"), n(a, "Env"), n(a, "BlogConstants"), n(a, "BlogTypeEnum"), n(a, "SiyuanConstants"), n(a, "SiyuanConfig"), n(a, "SiYuanApiAdaptor"), n(a, "BlogApi"); | ||
export { | ||
a as PublishSdk | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "zhi-publisher-sdk", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"description": "a common sdk for publishing post to every platform", | ||
"main": "./dist/index.js", | ||
"typings": "./dist/index.d.ts", | ||
"repository": "terwer/zhi", | ||
"homepage": "https://github.com/terwer/zhi/tree/main/libs/zhi-publisher-sdk", | ||
"author": "terwer", | ||
"license": "GPL", | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"keywords": [ | ||
"zhi", | ||
"lib" | ||
], | ||
"scripts": { | ||
"serve": "vite", | ||
"dev": "vite build --watch", | ||
"build": "vite build", | ||
"start": "vite preview", | ||
"test": "vitest --watch" | ||
}, | ||
"devDependencies": { | ||
"@terwer/eslint-config-custom": "workspace:*", | ||
"@terwer/vite-config-custom": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 发布 SDK | ||
* | ||
* @author terwer | ||
* @version 1.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
declare class PublishSdk { | ||
/** | ||
* BlogApi | ||
* @private | ||
*/ | ||
private static bApi; | ||
private static Env; | ||
private static BlogConstants; | ||
private static BlogTypeEnum; | ||
private static SiyuanConstants; | ||
private static SiyuanConfig; | ||
private static SiYuanApiAdaptor; | ||
private static BlogApi; | ||
static init(options: { | ||
Env: any; | ||
BlogConstants: any; | ||
BlogTypeEnum: any; | ||
SiyuanConstants: any; | ||
SiyuanConfig: any; | ||
SiYuanApiAdaptor: any; | ||
BlogApi: any; | ||
}): void; | ||
/** | ||
* 获取 siyuan-kernel-api 实例 | ||
* | ||
* @param type - Env | BlogTypeEnum | ||
* @param cfg - BlogConfig | ||
* @return BlogApi | ||
*/ | ||
static blogApi(type: any, cfg: any): any; | ||
} | ||
export default PublishSdk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# zhi-siyuan-api | ||
|
||
a siyuan-note api including both kernel and client | ||
|
||
## Usage | ||
|
||
```js | ||
import { SiyuanKernelApi } from "zhi-siyuan-api" | ||
|
||
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "") | ||
const kernelApi = new SiyuanKernelApi(siyuanConfig) | ||
const result = await kernelApi.lsNotebooks() | ||
console.log("result=>", result) | ||
``` | ||
|
||
## Deps | ||
|
||
``` | ||
├── zhi-env | ||
├── zhi-log | ||
├── zhi-common | ||
├── zhi-blog-api | ||
``` | ||
|
||
## Dev | ||
|
||
```bash | ||
pnpm dev -F zhi-siyuan-api | ||
``` | ||
|
||
## Build | ||
|
||
```bash | ||
pnpm build -F zhi-siyuan-api | ||
``` | ||
|
||
## Test | ||
|
||
Execute the unit tests via [vitest](https://vitest.dev) | ||
|
||
```bash | ||
pnpm test -F zhi-siyuan-api | ||
``` | ||
|
||
## Publish | ||
|
||
```bash | ||
pnpm publish -F zhi-siyuan-api --tag latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import SiyuanApi from "./lib/zhi-siyuan-api"; | ||
import SiyuanKernelApi from "./lib/siyuanKernelApi"; | ||
import type { SiyuanData } from "./lib/ISiyuanKernelApi"; | ||
import SiyuanConfig from "./lib/siyuanConfig"; | ||
import SiYuanApiAdaptor from "./lib/siYuanApiAdaptor"; | ||
import SiyuanConstants from "./lib/siyuanConstants"; | ||
export { SiyuanApi }; | ||
export { SiyuanData, SiyuanKernelApi }; | ||
export { SiyuanConstants, SiyuanConfig, SiYuanApiAdaptor }; |
Oops, something went wrong.