Skip to content

Commit

Permalink
feat: init docs by vitepress
Browse files Browse the repository at this point in the history
  • Loading branch information
1ncounter committed Aug 8, 2024
1 parent a782090 commit 9e08c2a
Show file tree
Hide file tree
Showing 76 changed files with 2,593 additions and 760 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ typings/
codealike.json
.node

.must.config.js
# docs
.vitepress
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 100,
"printWidth": 120,
"tabWidth": 2,
"semi": true,
"jsxSingleQuote": false,
Expand Down
4 changes: 4 additions & 0 deletions TODOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
7. github workflows

lodaes replace

IDE 的引擎设计
工作区的虚拟文件设计
窗口、视图、编辑器、边栏、面板的设计
49 changes: 49 additions & 0 deletions docs/api-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
outline: deep
---

# Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:

```md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```

<script setup>
import { useData } from 'vitepress'

const { site, theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
Empty file added docs/api/index.md
Empty file.
8 changes: 8 additions & 0 deletions docs/examples/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 你好,世界

step1: 启动引擎,新建一个项目,新建一个低代码文件(.lc)
step2: 打开画布
step3: 拖拽组件
step4: 点击保存 (cmd + s)
step5: 点击预览 (cmd + p)
step6: 点击关闭,重新打开这个页面,内容不变
Empty file added docs/guide/introduction.md
Empty file.
Empty file added docs/guide/quick-start.md
Empty file.
22 changes: 22 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
layout: home

hero:
name: 'LowCodeEngine'
text: '基于 LowCodeEngine 快速打造高生产力的低代码研发平台'
actions:
- theme: brand
text: 介绍
link: /guide/introduction
- theme: alt
text: 快速开始
link: /guide/quick-start

features:
- title: 标准化协议
details: 底层协议栈定义的是标准,标准的统一让上层产物的互通成为可能
- title: 最小内核
details: 精心打造低代码领域的编排、入料、出码、渲染模块
- title: 最强生态
details: 配套生态开箱即用,打造企业级低代码技术体系
---
85 changes: 85 additions & 0 deletions docs/markdown-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Markdown Extension Examples

This page demonstrates some of the built-in markdown extensions provided by VitePress.

## Syntax Highlighting

VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:

**Input**

````md
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````

**Output**

```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```

## Custom Containers

**Input**

```md
::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::
```

**Output**

::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::

## More

Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
23 changes: 23 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@alilc/lowcode-engine-docs",
"version": "2.0.0-alpha.0",
"description": "低代码引擎版本化文档",
"keywords": [
"lowcode",
"engine",
"docs"
],
"scripts": {
"docs:dev": "vitepress dev .",
"docs:build": "vitepress build .",
"docs:preview": "vitepress preview ."
},
"repository": {
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main"
},
"license": "MIT",
"devDependencies": {
"vitepress": "^1.3.1"
}
}
1 change: 1 addition & 0 deletions docs/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 16 additions & 19 deletions packages/engine-core/src/command/commandRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
type Event,
type EventDisposable,
type EventListener,
Emitter,
Events,
LinkedList,
TypeConstraint,
validateConstraints,
Iterable,
IDisposable,
Disposable,
toDisposable,
} from '@alilc/lowcode-shared';
import { ICommand, ICommandHandler } from './command';
import { Extensions, Registry } from '../extension/registry';
Expand All @@ -15,27 +15,24 @@ import { ICommandService } from './commandService';
export type ICommandsMap = Map<string, ICommand>;

export interface ICommandRegistry {
onDidRegisterCommand: Event<string>;
onDidRegisterCommand: Events.Event<string>;

registerCommand(id: string, command: ICommandHandler): EventDisposable;
registerCommand(command: ICommand): EventDisposable;
registerCommand(id: string, command: ICommandHandler): IDisposable;
registerCommand(command: ICommand): IDisposable;

registerCommandAlias(oldId: string, newId: string): EventDisposable;
registerCommandAlias(oldId: string, newId: string): IDisposable;

getCommand(id: string): ICommand | undefined;
getCommands(): ICommandsMap;
}

class CommandsRegistryImpl implements ICommandRegistry {
class CommandsRegistryImpl extends Disposable implements ICommandRegistry {
private readonly _commands = new Map<string, LinkedList<ICommand>>();

private readonly _didRegisterCommandEmitter = new Emitter<string>();
private readonly _onDidRegisterCommand = this._addDispose(new Events.Emitter<string>());
onDidRegisterCommand = this._onDidRegisterCommand.event;

onDidRegisterCommand(fn: EventListener<string>) {
return this._didRegisterCommandEmitter.on(fn);
}

registerCommand(idOrCommand: string | ICommand, handler?: ICommandHandler): EventDisposable {
registerCommand(idOrCommand: string | ICommand, handler?: ICommandHandler): IDisposable {
if (!idOrCommand) {
throw new Error(`invalid command`);
}
Expand Down Expand Up @@ -71,21 +68,21 @@ class CommandsRegistryImpl implements ICommandRegistry {

const removeFn = commands.unshift(idOrCommand);

const ret = () => {
const ret = toDisposable(() => {
removeFn();
const command = this._commands.get(id);
if (command?.isEmpty()) {
this._commands.delete(id);
}
};
});

// tell the world about this command
this._didRegisterCommandEmitter.emit(id);
this._onDidRegisterCommand.notify(id);

return ret;
}

registerCommandAlias(oldId: string, newId: string): EventDisposable {
registerCommandAlias(oldId: string, newId: string): IDisposable {
return this.registerCommand(oldId, (accessor, ...args) =>
accessor.get(ICommandService).executeCommand(newId, ...args),
);
Expand Down
Loading

0 comments on commit 9e08c2a

Please sign in to comment.