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

move dependency definition to zhi.json #163

Closed
terwer opened this issue Apr 17, 2023 · 4 comments · Fixed by #357
Closed

move dependency definition to zhi.json #163

terwer opened this issue Apr 17, 2023 · 4 comments · Fixed by #357

Comments

@terwer
Copy link
Owner

terwer commented Apr 17, 2023

schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://terwer.space/zhi-schema.json",
  "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"
  ]
}
@terwer terwer added this to zhi Apr 15, 2023
@terwer terwer converted this from a draft issue Apr 17, 2023
@terwer terwer changed the title 依赖定义迁移到zhi.json move dependency defination to zhi.json Apr 17, 2023
@terwer
Copy link
Owner Author

terwer commented Apr 17, 2023

zhi.json

{
  "dependencies": {
    "core": [
      {
        "libpath": "core/plugin-system/plugin.js",
        "baseType": "ZhiTheme",
        "format": "cjs",
        "importType": "require",
        "runAs": ["Siyuan_MainWindow", "Siyuan_Browser"],
        "order": 1
      }
    ],
    "server": [],
    "web": [],
    "vendor": [],
    "plugin": []
  }
}

@terwer
Copy link
Owner Author

terwer commented Apr 17, 2023

Use ajv for validation

https://www.npmjs.com/package/ajv

@terwer
Copy link
Owner Author

terwer commented Apr 17, 2023

js也可以,js这么用

private ZHI_JS = "zhi.json"

// const { default: data } = await import("/appearance/themes/zhi/zhi.js");data
const zhiJson = await SiyuanDevice.importZhiThemeJs(this.ZHI_JSON)

@terwer
Copy link
Owner Author

terwer commented Apr 17, 2023

zhi.js

export default {
  dependencies: {
    core: [
      {
        libpath: "core/plugin-system/plugin.js",
        baseType: "ZhiTheme",
        format: "cjs",
        importType: "require",
        runAs: ["Siyuan_MainWindow", "Siyuan_Browser"],
        order: 1,
      },
    ],
    server: [],
    web: [],
    vendor: [],
    plugin: [],
  },
}

@terwer terwer changed the title move dependency defination to zhi.json move dependency definition to zhi.json Apr 17, 2023
terwer added a commit that referenced this issue Apr 17, 2023
allow plugin system and other modules loading

feat: #163
@terwer terwer closed this as completed Apr 17, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in zhi Apr 17, 2023
terwer added a commit that referenced this issue Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant