oc-template-react-compiler 6.0.2 → 6.0.3
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,56 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const removeExtension = (path) => path.replace(/\.(t|j)sx?$/, '');
|
|
4
|
-
function reactOCProviderTemplate({ viewPath }) {
|
|
4
|
+
function reactOCProviderTemplate({ viewPath, providerFunctions }) {
|
|
5
5
|
return `
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import View from '${removeExtension(viewPath)}';
|
|
8
8
|
import { DataProvider } from 'oc-template-react-compiler/dist/utils/useData'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = (this.props as any);
|
|
13
|
-
(window as any).oc.events.fire('oc:componentDidMount', rest);
|
|
14
|
-
}
|
|
10
|
+
function OCProvider(props) {
|
|
11
|
+
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = props;
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
version: providerProps._componentVersion,
|
|
20
|
-
baseUrl: providerProps._baseUrl,
|
|
21
|
-
parameters
|
|
22
|
-
}, (err: any, data: any) => {
|
|
23
|
-
if (err) {
|
|
24
|
-
return cb(err);
|
|
25
|
-
}
|
|
26
|
-
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = (data.component.props as any);
|
|
27
|
-
cb(null, rest, data.component.props);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
window.oc.events.fire('oc:componentDidMount', rest);
|
|
15
|
+
}, []);
|
|
30
16
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
baseUrl: providerProps._baseUrl,
|
|
36
|
-
staticPath: providerProps._staticPath
|
|
37
|
-
};
|
|
38
|
-
return (settingHash as any)[setting];
|
|
39
|
-
}
|
|
17
|
+
${providerFunctions}
|
|
18
|
+
|
|
19
|
+
rest.getData = getData;
|
|
20
|
+
rest.getSetting = getSetting;
|
|
40
21
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<DataProvider value={{...rest}}>
|
|
47
|
-
<View { ...rest } />
|
|
48
|
-
</DataProvider>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
22
|
+
return (
|
|
23
|
+
<DataProvider value={{...rest}}>
|
|
24
|
+
<View { ...rest } />
|
|
25
|
+
</DataProvider>
|
|
26
|
+
);
|
|
51
27
|
}
|
|
52
28
|
|
|
53
|
-
function renderer(props, element, ssr) {
|
|
29
|
+
export default function renderer(props, element, ssr) {
|
|
54
30
|
if (window.ReactDOM.createRoot) {
|
|
55
31
|
if (ssr) {
|
|
56
32
|
window.ReactDOM.hydrateRoot(element, <OCProvider {...props} />);
|
|
@@ -65,8 +41,6 @@ function reactOCProviderTemplate({ viewPath }) {
|
|
|
65
41
|
}
|
|
66
42
|
}
|
|
67
43
|
}
|
|
68
|
-
|
|
69
|
-
export default renderer;
|
|
70
44
|
`;
|
|
71
45
|
}
|
|
72
46
|
exports.default = reactOCProviderTemplate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-template-react-compiler",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"description": "Compiler for the React 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-react": "^4.0.0",
|
|
33
33
|
"oc-template-react": "^4.0.0",
|
|
34
|
-
"oc-vite-compiler": "^3.
|
|
34
|
+
"oc-vite-compiler": "^3.3.0",
|
|
35
35
|
"react": "18.2.0",
|
|
36
36
|
"react-dom": "18.2.0"
|
|
37
37
|
},
|