oc-template-preact-compiler 0.3.2 → 0.3.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.
|
@@ -1,47 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const removeExtension = (path) => path.replace(/\.(t|j)sx?$/, '');
|
|
4
|
-
function preactOCProviderTemplate({ viewPath }) {
|
|
4
|
+
function preactOCProviderTemplate({ viewPath, providerFunctions }) {
|
|
5
5
|
return `
|
|
6
6
|
import { render } from 'preact';
|
|
7
7
|
import { useEffect } from 'preact/hooks';
|
|
8
8
|
import View from '${removeExtension(viewPath)}';
|
|
9
9
|
import { DataProvider } from 'oc-template-preact-compiler/dist/utils/useData'
|
|
10
10
|
|
|
11
|
-
function OCProvider(props
|
|
11
|
+
function OCProvider(props) {
|
|
12
12
|
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = props;
|
|
13
13
|
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
|
|
15
|
+
window.oc.events.fire('oc:componentDidMount', rest);
|
|
16
16
|
}, []);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
return (window as any).oc.getData({
|
|
20
|
-
name: providerProps._componentName,
|
|
21
|
-
version: providerProps._componentVersion,
|
|
22
|
-
baseUrl: providerProps._baseUrl,
|
|
23
|
-
parameters
|
|
24
|
-
}, (err: any, data: any) => {
|
|
25
|
-
if (err) {
|
|
26
|
-
return cb(err);
|
|
27
|
-
}
|
|
28
|
-
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = data.component.props;
|
|
29
|
-
cb(null, rest, data.component.props);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getSetting(providerProps: any, setting: string) {
|
|
34
|
-
const settingHash = {
|
|
35
|
-
name: providerProps._componentName,
|
|
36
|
-
version: providerProps._componentVersion,
|
|
37
|
-
baseUrl: providerProps._baseUrl,
|
|
38
|
-
staticPath: providerProps._staticPath
|
|
39
|
-
};
|
|
40
|
-
return (settingHash as any)[setting];
|
|
41
|
-
}
|
|
18
|
+
${providerFunctions}
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
rest.getData = getData;
|
|
21
|
+
rest.getSetting = getSetting;
|
|
45
22
|
|
|
46
23
|
return (
|
|
47
24
|
<DataProvider value={{...rest}}>
|
|
@@ -50,10 +27,12 @@ function preactOCProviderTemplate({ viewPath }) {
|
|
|
50
27
|
);
|
|
51
28
|
}
|
|
52
29
|
|
|
53
|
-
function renderer(props, element) {
|
|
30
|
+
function renderer(props, element, ssr) {
|
|
54
31
|
render(<OCProvider {...props} />, element);
|
|
55
32
|
}
|
|
56
33
|
|
|
34
|
+
renderer.component = OCProvider;
|
|
35
|
+
|
|
57
36
|
export default renderer;
|
|
58
37
|
`;
|
|
59
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-template-preact-compiler",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Compiler for the Preact OC template",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@preact/preset-vite": "^2.5.0",
|
|
33
|
-
"oc-template-preact": "^0.1.
|
|
34
|
-
"oc-vite-compiler": "^3.
|
|
33
|
+
"oc-template-preact": "^0.1.1",
|
|
34
|
+
"oc-vite-compiler": "^3.4.0",
|
|
35
35
|
"preact": "^10"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|