oc-template-vue-compiler 0.5.5 → 0.6.0
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/lib/hmr.d.ts +7 -0
- package/dist/lib/hmr.js +32 -0
- package/package.json +1 -1
- package/scaffold/src/package.json +2 -2
- package/scaffold/src/src/server.ts +25 -23
package/dist/lib/hmr.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.plugin = exports.appBlock = void 0;
|
|
7
|
+
const plugin_vue_1 = __importDefault(require("@vitejs/plugin-vue"));
|
|
8
|
+
exports.plugin = plugin_vue_1.default;
|
|
9
|
+
const appBlock = ({ name, version, entry }) => `
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module">
|
|
12
|
+
const data = __INITIAL_DATA__;
|
|
13
|
+
window.__$$oc_initialData__ = Object.freeze(data);
|
|
14
|
+
const settings = Object.freeze({ baseUrl: '/', id: 'root', name: '${name}', staticPath: '/', version: '${version}' });
|
|
15
|
+
window.__$$oc_Settings__ = settings;
|
|
16
|
+
|
|
17
|
+
window.oc = window.oc || {};
|
|
18
|
+
window.oc.cmd = window.oc.cmd || [];
|
|
19
|
+
|
|
20
|
+
import App from "${entry}";
|
|
21
|
+
import { createApp } from 'vue';
|
|
22
|
+
|
|
23
|
+
const container = document.getElementById('root');
|
|
24
|
+
const app = createApp(App, data);
|
|
25
|
+
|
|
26
|
+
window.oc.cmd.push(() => {
|
|
27
|
+
app.mount(container);
|
|
28
|
+
window.oc.events.fire('oc:rendered', { ...settings, element: container, });
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
`;
|
|
32
|
+
exports.appBlock = appBlock;
|
package/package.json
CHANGED
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
34
34
|
"@vitejs/plugin-vue": "^5.0.0",
|
|
35
35
|
"jsdom": "^21.1.1",
|
|
36
|
-
"oc-server": "^1.1.
|
|
37
|
-
"oc-template-vue-compiler": "^0.5.
|
|
36
|
+
"oc-server": "^1.1.4",
|
|
37
|
+
"oc-template-vue-compiler": "^0.5.6",
|
|
38
38
|
"typescript": "5.0.2",
|
|
39
39
|
"vitest": "^0.29.7",
|
|
40
40
|
"vue": "^3.3.11",
|
|
@@ -19,29 +19,31 @@ async function getFunFact(year: number) {
|
|
|
19
19
|
return yearsFunFactDatabase[year];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const server = new Server(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
export const server = new Server()
|
|
23
|
+
.handler(async (params: { userId: number }) => {
|
|
24
|
+
const { userId } = params;
|
|
25
|
+
const user = await getUser(userId);
|
|
26
|
+
const [firstName, lastName] = user.name.split(/\s+/);
|
|
27
|
+
|
|
28
|
+
if (firstName === 'Invalid') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
firstName,
|
|
34
|
+
lastName,
|
|
35
|
+
born: user.born,
|
|
36
|
+
hobbies: user.hobbies,
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
.action('funFact', async (params: { year: number }) => {
|
|
40
|
+
const { year } = params;
|
|
41
|
+
const funFact = await getFunFact(year);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
funFact,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
45
47
|
|
|
46
48
|
declare module 'oc-server' {
|
|
47
49
|
interface Register {
|