Skip to content

Commit

Permalink
feat(zhi-core): add basic loading
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed May 3, 2023
1 parent 721b09b commit 1b3d2c0
Show file tree
Hide file tree
Showing 27 changed files with 698 additions and 222 deletions.
5 changes: 2 additions & 3 deletions packages/zhi-core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
"assets": [
"packages/zhi-core/*.md",
"packages/zhi-core/src/core/**",
"packages/zhi-core/src/config/**",
"packages/zhi-core/src/theme.js",
"packages/zhi-core/src/theme.json",
"packages/zhi-core/src/theme.css",
"packages/zhi-core/src/style/common/fonts/webfont.css",
"packages/zhi-core/src/hello.js",
"packages/zhi-core/src/index.html"
"packages/zhi-core/src/style/common/fonts/webfont.css"
]
}
},
Expand Down
3 changes: 3 additions & 0 deletions packages/zhi-core/src/config/deps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
vue: "^3.2.47",
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
export default {
imports: {
"@siyuan-community/zhi-device":
// "/appearance/themes/zhi/core/npm/node_modules/@siyuan-community/zhi-device/src/index.js",
"/Users/terwer/Documents/mydocs/zhi/dist/packages/zhi-lib-device/src/index.js",
"/appearance/themes/zhi/core/npm/node_modules/@siyuan-community/zhi-device/src/index.js",
},
}
154 changes: 154 additions & 0 deletions packages/zhi-core/src/config/zhi-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* 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.
*/

const schema = {
type: "object",
properties: {
dependencies: {
type: "object",
properties: {
core: {
type: "array",
items: {
type: "object",
properties: {
libpath: {
type: "string",
},
baseType: {
type: "string",
},
format: {
type: "string",
},
importType: {
type: "string",
},
runAs: {
type: "array",
items: {
type: "string",
},
},
},
required: ["libpath", "baseType", "format", "importType", "runAs"],
},
},
server: {
type: "array",
items: {
type: "object",
properties: {
libpath: {
type: "string",
},
baseType: {
type: "string",
},
format: {
type: "string",
},
importType: {
type: "string",
},
runAs: {
type: "array",
items: {
type: "string",
},
},
},
required: ["libpath", "baseType", "format", "importType", "runAs"],
},
},
web: {
type: "array",
items: {
type: "object",
properties: {
libpath: {
type: "string",
},
baseType: {
type: "string",
},
format: {
type: "string",
},
importType: {
type: "string",
},
runAs: {
type: "array",
items: {
type: "string",
},
},
},
required: ["libpath", "baseType", "format", "importType", "runAs"],
},
},
vendor: {
type: "array",
items: {
type: "object",
properties: {
name: {
type: "string",
},
enabled: {
type: "boolean",
},
},
required: ["name", "enabled"],
},
},
plugin: {
type: "array",
items: {
type: "object",
properties: {
name: {
type: "string",
},
enabled: {
type: "boolean",
},
},
required: ["name", "enabled"],
},
},
},
required: ["core", "server", "web", "vendor", "plugin"],
},
},
required: ["dependencies"],
}

export default {
$schema: "http://json-schema.org/draft-07/schema#",
$id: "https://terwer.space/zhi-schema.json",
...schema,
}
64 changes: 64 additions & 0 deletions packages/zhi-core/src/config/zhi.example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
export default {
dependencies: {
core: [
{
libpath: "core/plugin-system/plugin.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow", "Siyuan_Browser"],
order: 1,
},
{
libpath: "core/plugin-system/zhi-plugin-loader.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow", "Siyuan_Browser"],
order: 2,
},
],
server: [
{
libpath: "server/electron/index.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow"],
order: 3,
},
{
libpath: "server/cmd/index.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow"],
order: 4,
},
{
libpath: "server/infra/index.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow"],
order: 5,
},
{
libpath: "server/custom/start.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow"],
order: 6,
},
],
web: [],
vendor: [],
plugin: [],
},
blog: {
server: {
post: "3333",
},
},
}
48 changes: 48 additions & 0 deletions packages/zhi-core/src/config/zhi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export default {
dependencies: {
core: [
{
libpath: "server/infra/index.cjs",
baseType: "ZhiTheme",
format: "cjs",
importType: "require",
runAs: ["Siyuan_MainWindow"],
order: 0,
},
{
libpath: "core/plugin-system/plugin.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow", "Siyuan_Browser"],
order: 1,
},
{
libpath: "core/plugin-system/zhi-plugin-loader.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow", "Siyuan_Browser"],
order: 2,
},
],
server: [
{
libpath: "server/electron/index.js",
baseType: "ZhiTheme",
format: "esm",
importType: "import",
runAs: ["Siyuan_MainWindow"],
order: 3,
},
],
web: [],
vendor: [],
plugin: [],
},
blog: {
server: {
post: "3333",
},
},
}
3 changes: 0 additions & 3 deletions packages/zhi-core/src/core/npm/deps.json

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b3d2c0

Please sign in to comment.