@vtj/local 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller.mjs +8 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.mjs +19 -6
- package/dist/service.d.ts +2 -0
- package/dist/service.mjs +21 -2
- package/package.json +5 -5
package/dist/controller.mjs
CHANGED
|
@@ -60,6 +60,14 @@ const controller = {
|
|
|
60
60
|
getRaw: async (req) => {
|
|
61
61
|
const { project, dsl } = req.data || {};
|
|
62
62
|
return service.getRaw(project, dsl);
|
|
63
|
+
},
|
|
64
|
+
createRawPage: async (req) => {
|
|
65
|
+
const file = req.data;
|
|
66
|
+
return service.createRawPage(file);
|
|
67
|
+
},
|
|
68
|
+
removeRawPage: async (req) => {
|
|
69
|
+
const id = req.data;
|
|
70
|
+
return service.removeRawPage(id);
|
|
63
71
|
}
|
|
64
72
|
};
|
|
65
73
|
export const router = async (req) => {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -3,9 +3,16 @@ export interface DevPluginOptions {
|
|
|
3
3
|
baseURL: string;
|
|
4
4
|
copy: boolean;
|
|
5
5
|
server: boolean;
|
|
6
|
+
staticBase: string;
|
|
6
7
|
link: boolean | string;
|
|
8
|
+
linkOptions: LinkOptions | null;
|
|
7
9
|
vtjDir: string;
|
|
8
10
|
packagesDir: string;
|
|
9
11
|
devMode: boolean;
|
|
10
12
|
}
|
|
13
|
+
export interface LinkOptions {
|
|
14
|
+
entry?: string;
|
|
15
|
+
href?: string;
|
|
16
|
+
serveOnly?: boolean;
|
|
17
|
+
}
|
|
11
18
|
export declare function createDevPlugin(options?: Partial<DevPluginOptions>): Plugin<any>[];
|
package/dist/plugin.mjs
CHANGED
|
@@ -36,23 +36,34 @@ const apiServerPlugin = function(options) {
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
const linkPlugin = function(options) {
|
|
39
|
+
const {
|
|
40
|
+
entry = "/index.html",
|
|
41
|
+
href = "",
|
|
42
|
+
serveOnly = true
|
|
43
|
+
} = options.linkOptions || {};
|
|
39
44
|
let config;
|
|
40
45
|
return {
|
|
41
46
|
name: "vtj-link-plugin",
|
|
42
|
-
apply: "serve",
|
|
47
|
+
apply: serveOnly ? "serve" : void 0,
|
|
43
48
|
configResolved(resolvedConfig) {
|
|
44
49
|
config = resolvedConfig;
|
|
45
50
|
},
|
|
46
|
-
transformIndexHtml(html) {
|
|
51
|
+
transformIndexHtml(html, ctx) {
|
|
47
52
|
if (html.includes("VTJ-LINK")) {
|
|
48
53
|
return html;
|
|
49
54
|
}
|
|
50
55
|
if (options.link) {
|
|
56
|
+
if (ctx.path !== entry) {
|
|
57
|
+
return html;
|
|
58
|
+
}
|
|
51
59
|
const link = typeof options.link === "string" ? options.link : "@vtj/pro/link.js";
|
|
52
60
|
const url = `${config.base}${link}`;
|
|
53
61
|
return html.replace(
|
|
54
62
|
/<\/body>/,
|
|
55
|
-
|
|
63
|
+
`
|
|
64
|
+
<script>window.__VTJ_LINK__ = { href: '${href}' }<\/script>
|
|
65
|
+
<script src="${url}"><\/script></body>
|
|
66
|
+
`
|
|
56
67
|
);
|
|
57
68
|
}
|
|
58
69
|
return html;
|
|
@@ -109,7 +120,9 @@ export function createDevPlugin(options = {}) {
|
|
|
109
120
|
baseURL: "/vtj/local/api",
|
|
110
121
|
copy: true,
|
|
111
122
|
server: true,
|
|
123
|
+
staticBase: "/",
|
|
112
124
|
link: true,
|
|
125
|
+
linkOptions: null,
|
|
113
126
|
vtjDir: ".vtj",
|
|
114
127
|
packagesDir: "../../packages",
|
|
115
128
|
devMode: false,
|
|
@@ -147,18 +160,18 @@ export function createDevPlugin(options = {}) {
|
|
|
147
160
|
const staticOptions = [];
|
|
148
161
|
if (pathExistsSync(proPath)) {
|
|
149
162
|
staticOptions.push({
|
|
150
|
-
path:
|
|
163
|
+
path: `${opts.staticBase}@vtj/pro`,
|
|
151
164
|
dir: proPath
|
|
152
165
|
});
|
|
153
166
|
}
|
|
154
167
|
if (pathExistsSync(materialsPath1)) {
|
|
155
168
|
staticOptions.push({
|
|
156
|
-
path:
|
|
169
|
+
path: `${opts.staticBase}@vtj/materials`,
|
|
157
170
|
dir: materialsPath1
|
|
158
171
|
});
|
|
159
172
|
} else if (pathExistsSync(materialsPath2)) {
|
|
160
173
|
staticOptions.push({
|
|
161
|
-
path:
|
|
174
|
+
path: `${opts.staticBase}@vtj/materials`,
|
|
162
175
|
dir: materialsPath2
|
|
163
176
|
});
|
|
164
177
|
} else {
|
package/dist/service.d.ts
CHANGED
|
@@ -17,3 +17,5 @@ export declare function saveMaterials(project: ProjectSchema, materials: Record<
|
|
|
17
17
|
export declare function publishFile(project: ProjectSchema, file: PageFile | BlockFile, componentMap?: Map<string, MaterialDescription>): Promise<import("./shared").ApiResponse>;
|
|
18
18
|
export declare function publish(project: ProjectSchema): Promise<import("./shared").ApiResponse>;
|
|
19
19
|
export declare function getRaw(project: ProjectSchema, dsl: BlockSchema): Promise<import("./shared").ApiResponse>;
|
|
20
|
+
export declare function createRawPage(file: PageFile): Promise<import("./shared").ApiResponse>;
|
|
21
|
+
export declare function removeRawPage(id: string): Promise<import("./shared").ApiResponse>;
|
package/dist/service.mjs
CHANGED
|
@@ -12,10 +12,11 @@ import {
|
|
|
12
12
|
upperFirstCamelCase,
|
|
13
13
|
timestamp
|
|
14
14
|
} from "@vtj/node";
|
|
15
|
-
import { generator } from "@vtj/coder";
|
|
15
|
+
import { generator, createEmptyPage } from "@vtj/coder";
|
|
16
16
|
import { fail, success } from "./shared.mjs";
|
|
17
17
|
const root = resolve("./");
|
|
18
18
|
const vtjDir = resolve(".vtj");
|
|
19
|
+
const viewsDir = resolve("src/views");
|
|
19
20
|
const getProjectFilePath = (_name) => {
|
|
20
21
|
return resolve(vtjDir, "project.json");
|
|
21
22
|
};
|
|
@@ -37,6 +38,9 @@ const getHistoryItemDir = (fId) => {
|
|
|
37
38
|
const getRawFilePath = (id) => {
|
|
38
39
|
return resolve(vtjDir, `raw/${id}.vue`);
|
|
39
40
|
};
|
|
41
|
+
const getRawPagePath = (id) => {
|
|
42
|
+
return resolve(viewsDir, `${id}.vue`);
|
|
43
|
+
};
|
|
40
44
|
const getLogsDir = () => {
|
|
41
45
|
return resolve(vtjDir, `logs`);
|
|
42
46
|
};
|
|
@@ -61,7 +65,7 @@ export async function init() {
|
|
|
61
65
|
name: description || upperFirstCamelCase(name),
|
|
62
66
|
description
|
|
63
67
|
});
|
|
64
|
-
const dsl = project.toDsl();
|
|
68
|
+
const dsl = project.toDsl(schema.__VERSION__);
|
|
65
69
|
ensureFileSync(filePath);
|
|
66
70
|
writeJsonSync(filePath, dsl);
|
|
67
71
|
return success(dsl);
|
|
@@ -196,3 +200,18 @@ export async function getRaw(project, dsl) {
|
|
|
196
200
|
const content = await generator(dsl, componentMap, project.dependencies);
|
|
197
201
|
return success(content);
|
|
198
202
|
}
|
|
203
|
+
export async function createRawPage(file) {
|
|
204
|
+
const filePath = getRawPagePath(file.id);
|
|
205
|
+
const page = await createEmptyPage(file);
|
|
206
|
+
outputFileSync(filePath, page, "utf-8");
|
|
207
|
+
return success(true);
|
|
208
|
+
}
|
|
209
|
+
export async function removeRawPage(id) {
|
|
210
|
+
const filePath = getRawPagePath(id);
|
|
211
|
+
if (pathExistsSync(filePath)) {
|
|
212
|
+
removeSync(filePath);
|
|
213
|
+
return success(true);
|
|
214
|
+
} else {
|
|
215
|
+
return fail("\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
216
|
+
}
|
|
217
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/local",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "unbuild",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"coverage": "vitest run --coverage"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@vtj/coder": "^0.7.
|
|
14
|
-
"@vtj/core": "^0.7.
|
|
13
|
+
"@vtj/coder": "^0.7.4",
|
|
14
|
+
"@vtj/core": "^0.7.4",
|
|
15
15
|
"@vtj/node": "^0.7.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@vtj/cli": "^0.7.
|
|
18
|
+
"@vtj/cli": "^0.7.3",
|
|
19
19
|
"unbuild": "~2.0.0",
|
|
20
20
|
"vite": "~5.0.11",
|
|
21
21
|
"vitest": "~1.2.1"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "7c7bb7bd2696a691987bd58f20e118987e1cf404",
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
}
|