oc-template-vue-compiler 0.0.1 → 0.0.2

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.
@@ -1,3 +1,4 @@
1
- export default function vueOCProviderTemplate({ viewPath }: {
1
+ export default function vueOCProviderTemplate({ viewPath, providerFunctions }: {
2
2
  viewPath: string;
3
+ providerFunctions: string;
3
4
  }): string;
@@ -1,50 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- function vueOCProviderTemplate({ viewPath }) {
3
+ function vueOCProviderTemplate({ viewPath, providerFunctions }) {
4
4
  return `
5
5
  import { createApp } from 'vue'
6
6
  import View from '${viewPath}';
7
7
 
8
- function getDataCb(providerProps, parameters, cb) {
9
- return window.oc.getData({
10
- name: providerProps._componentName,
11
- version: providerProps._componentVersion,
12
- baseUrl: providerProps._baseUrl,
13
- parameters
14
- }, (err, data) => {
15
- if (err) {
16
- return cb(err);
17
- }
18
- const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = data.component.props;
19
- cb(null, rest, data.component.props);
20
- });
21
- }
22
-
23
- function getSetting(providerProps, setting) {
24
- const settingHash = {
25
- name: providerProps._componentName,
26
- version: providerProps._componentVersion,
27
- baseUrl: providerProps._baseUrl,
28
- staticPath: providerProps._staticPath
29
- };
30
- return settingHash[setting];
31
- }
32
-
33
-
34
8
  function renderer(props, element, ssr) {
35
- function getData(params) {
36
- return new Promise((resolve, reject) => {
37
- getDataCb(props, params, (err, data) => {
38
- if (err) {
39
- return reject(err);
40
- }
41
- resolve(data);
42
- });
43
- });
44
- }
45
- props.getData = getData;
46
- props.getSetting = (setting) => getSetting(props, setting);
47
- createApp(View, props).mount(element, ssr);
9
+ const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = props;
10
+ ${providerFunctions}
11
+
12
+ rest.getData = getData;
13
+ rest.getSetting = getSetting;
14
+ createApp(View, rest).mount(element, ssr);
48
15
  }
49
16
 
50
17
  export default renderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-template-vue-compiler",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Compiler for the vueJS OC template",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@vitejs/plugin-vue": "^4.5.2",
33
33
  "oc-template-vue": "^0.0.1",
34
- "oc-vite-compiler": "^3.2.0"
34
+ "oc-vite-compiler": "^3.3.0"
35
35
  },
36
36
  "files": [
37
37
  "dist/**",
@@ -4,7 +4,7 @@
4
4
  "version": "1.0.0",
5
5
  "scripts": {
6
6
  "lint": "eslint --max-warnings 0 --ext .js,.jsx,.ts,.tsx src",
7
- "build": "tsc --noEmit && oc package .",
7
+ "build": "vue-tsc --noEmit && oc package .",
8
8
  "test": "vitest"
9
9
  },
10
10
  "oc": {
@@ -1,38 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref } from 'vue'
3
-
4
- defineProps<{ msg: string }>()
5
-
6
- const count = ref(0)
7
- </script>
8
-
9
- <template>
10
- <h1>{{ msg }}</h1>
11
-
12
- <div class="card">
13
- <button type="button" @click="count++">count is {{ count }}</button>
14
- <p>
15
- Edit
16
- <code>components/HelloWorld.vue</code> to test HMR
17
- </p>
18
- </div>
19
-
20
- <p>
21
- Check out
22
- <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
23
- >create-vue</a
24
- >, the official Vue + Vite starter
25
- </p>
26
- <p>
27
- Install
28
- <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
29
- in your IDE for a better DX
30
- </p>
31
- <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
32
- </template>
33
-
34
- <style scoped>
35
- .read-the-docs {
36
- color: #888;
37
- }
38
- </style>