-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 Update doc and fix remote cli install
- Loading branch information
Showing
9 changed files
with
193 additions
and
24 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
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
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,38 @@ | ||
# About plaoc | ||
|
||
[plaoc](https://github.com/BioforestChain/dweb_browser-docs) is a "cross-platform web application" development toolkit based on the dweb-browser platform, aiming to compete with Cordova, Capacitor, and Tauri. | ||
|
||
## cli | ||
|
||
[plaoc cli documentation](./cli/README.md) | ||
|
||
### dev Build | ||
|
||
Navigate to the root directory of dweb_browser. | ||
|
||
```bash | ||
deno task plaoc serve ./plaoc/demo/dist | ||
``` | ||
|
||
> `./plaoc/demo/dist` points to the directory of a built application. | ||
## MutilWebview concept | ||
|
||
1. In Dweb Browser, MutilWebview serves as a frontend container without polluting global variables. All extensions are implemented through network communication (fetch/websocket). | ||
2. In Dweb Browser, JsProcess serves as a backend container, allowing direct IPC communication with various modules without traditional network layers. | ||
3. The "plugins" folder aggregates and organizes these interfaces within the JsProcess environment, allowing developers to access various modules out of the box. It consists of two parts of code: | ||
1. Backend code of JsProcess, which accesses other modules through `jsProcess.nativeFetch/.nativeRequest`, allowing developers to mount it to specific subdomains/ports, enabling frontend developers to access these modules. | ||
2. Frontend code of MutilWebview, which further encapsulates the backend's network requests into declarative WebComponents, making the interfaces more intuitive for frontend developers. | ||
> Additionally, we will further encapsulate these WebComponents to make them compatible with traditional frontend application development frameworks like Capacitor and Cordova. | ||
## publish | ||
|
||
- Tag and push to GitHub. | ||
|
||
```bash | ||
git tag -a 0.0.1 -m "feat: xxx" | ||
``` | ||
|
||
```bash | ||
git push origin <tag-name> | ||
``` |
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 |
---|---|---|
@@ -1,13 +1,55 @@ | ||
### cli | ||
## cli | ||
|
||
1. `deno install -A https://deno.land/x/plaoc/cli/plaoc.ts` | ||
plaoc 前后端打包工具。 | ||
|
||
1. `plaoc bundle ./dir` | ||
会打包成以下的文件夹结构,并输出压缩文件 `.zip` 和一个 `plaoc.metadata.json` | ||
## 安装 | ||
|
||
1. `plaoc preview http://localhost:1231` 或者 `plaoc preview ./dir` | ||
> 会将该 url 放在一个 iframe 中被预览 | ||
> 该命令会输出一行命令: | ||
```bash | ||
dweb-browser-dev install --url http://172.30.90.240:8080/usr/metadata.json | ||
``` | ||
```bash | ||
deno install -A https://deno.land/x/plaoc/cli/plaoc.ts | ||
``` | ||
|
||
## 打包app (bundle/build) | ||
|
||
```bash | ||
plaoc bundle ./dir | ||
``` | ||
会打包成以下的文件夹结构,并输出压缩文件 `.zip` 和一个 `metadata.json`,详情请查看下面文档详情。 | ||
|
||
- bundle | ||
- appId.version.zip | ||
- metadata.json | ||
|
||
### 选项 | ||
|
||
- `--out`: 指定打包完的目录名称,默认为`bundle`。 | ||
- `--version`: 指定app的版本,能覆盖`manifest.json`里面的配置。 | ||
- `--id`: 指定app的id,能覆盖`manifest.json`里面的配置。 | ||
- `--dir`:用来指定开发目录,即指定您创建`manifest.json`的根目录。 | ||
### 示例 | ||
|
||
```bash | ||
plaoc bundle ./plaoc/demo/dist --dir ./plaoc/demo --version 0.0.2 | ||
``` | ||
|
||
## 开发者模式 (serve/preview) | ||
|
||
需要搭配开发者工具使用,这也是一个app的预览模式。 | ||
|
||
```bash | ||
plaoc serve ./dir | ||
``` | ||
|
||
### 选项 | ||
|
||
- `--dir`:用来指定开发目录,即指定您创建`manifest.json`的根目录。 | ||
- `--port`: 用来指定启动的服务端口。 | ||
- `--mode`: 服务的处理模式,可以输入`www`,`live`,`prod`。 | ||
- `--mode www`: 将文件夹作为 usr/www 的只读文件进行启动。 | ||
- `--mode live`: 将本地文件夹使用动态服务器进行启, usr/www 会存在一个 index.html 中来进行跳转。 | ||
- `--mode prod`: 对将打包后的文件直接进行服务启动。 | ||
|
||
### 示例 | ||
|
||
```bash | ||
plaoc preview ./plaoc/demo/dist --dir ./plaoc/demo --mode www | ||
``` |
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,80 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
export function* WalkAny(rootpath: string) { | ||
const dirs = [rootpath]; | ||
for (const dirpath of dirs) { | ||
for (const entryname of fs.readdirSync(dirpath)) { | ||
if (entryname === ".DS_Store") { | ||
continue; | ||
} | ||
const entrypath = path.join(dirpath, entryname); | ||
const stats = fs.statSync(entrypath); | ||
const isDirectory = stats.isDirectory(); | ||
const isFile = stats.isFile(); | ||
const relativepath = path.relative(rootpath, entrypath); | ||
const relativedirpath = path.relative(rootpath, dirpath); | ||
const entryBase = { | ||
entryname, | ||
entrypath, | ||
dirpath, | ||
rootpath, | ||
relativepath, | ||
relativedirpath, | ||
stats, | ||
}; | ||
|
||
if (isFile) { | ||
yield { | ||
...entryBase, | ||
isFile, | ||
isDirectory: false as const, | ||
readText() { | ||
return fs.readFileSync(entrypath, "utf-8"); | ||
}, | ||
readJson<T>() { | ||
return JSON.parse(this.readText()) as T; | ||
}, | ||
read() { | ||
return fs.readFileSync(entrypath); | ||
}, | ||
write(content: string | Uint8Array) { | ||
return fs.writeFileSync(entrypath, content); | ||
}, | ||
writeJson(json: unknown, space?: number) { | ||
return this.write(JSON.stringify(json, null, space)); | ||
}, | ||
updateText(updater: (content: string) => string) { | ||
const oldContent = this.readText(); | ||
const newContent = updater(oldContent); | ||
if (newContent !== oldContent) { | ||
this.write(newContent); | ||
} | ||
}, | ||
}; | ||
} | ||
if (isDirectory) { | ||
yield { | ||
...entryBase, | ||
isDirectory, | ||
isFile: false as const, | ||
}; | ||
dirs.push(entrypath); | ||
} | ||
} | ||
} | ||
} | ||
export function* WalkFiles(rootpath: string) { | ||
for (const entry of WalkAny(rootpath)) { | ||
if (entry.isFile) { | ||
yield entry; | ||
} | ||
} | ||
} | ||
|
||
export function* WalkDirs(rootpath: string) { | ||
for (const entry of WalkAny(rootpath)) { | ||
if (entry.isDirectory) { | ||
yield entry; | ||
} | ||
} | ||
} |
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
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