oc-template-react-compiler 5.2.2 → 6.0.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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +18 -0
  4. package/dist/lib/compile.d.ts +3 -0
  5. package/dist/lib/compile.js +36 -0
  6. package/dist/lib/htmlTemplate.d.ts +10 -0
  7. package/dist/lib/htmlTemplate.js +51 -0
  8. package/dist/lib/reactOCProviderTemplate.d.ts +3 -0
  9. package/dist/lib/reactOCProviderTemplate.js +56 -0
  10. package/dist/utils/index.d.ts +1 -0
  11. package/dist/utils/index.js +17 -0
  12. package/dist/utils/useData.d.ts +7 -0
  13. package/dist/utils/useData.js +31 -0
  14. package/package.json +37 -47
  15. package/scaffold/src/.eslintrc.json +3 -0
  16. package/scaffold/src/package.json +29 -11
  17. package/scaffold/src/public/logo.png +0 -0
  18. package/scaffold/src/src/App.test.tsx +39 -0
  19. package/scaffold/src/src/App.tsx +52 -0
  20. package/scaffold/src/src/oc-app.d.ts +1 -0
  21. package/scaffold/src/src/server.ts +37 -0
  22. package/scaffold/src/src/setupTests.js +1 -0
  23. package/scaffold/src/src/styles.css +30 -0
  24. package/scaffold/src/src/types.ts +15 -0
  25. package/scaffold/src/tsconfig.json +26 -0
  26. package/scaffold/src/vite.config.ts +11 -0
  27. package/index.js +0 -11
  28. package/lib/compile.js +0 -26
  29. package/lib/compileServer.js +0 -100
  30. package/lib/compileView.js +0 -135
  31. package/lib/higherOrderServerTemplate.js +0 -32
  32. package/lib/reactOCProviderTemplate.js +0 -54
  33. package/lib/to-abstract-base-template-utils/font-family-unicode-parser.js +0 -25
  34. package/lib/to-abstract-base-template-utils/oc-webpack/index.js +0 -9
  35. package/lib/to-abstract-base-template-utils/oc-webpack/lib/compiler/index.js +0 -42
  36. package/lib/to-abstract-base-template-utils/oc-webpack/lib/configurator/client/index.js +0 -120
  37. package/lib/to-abstract-base-template-utils/oc-webpack/lib/configurator/createExcludeRegex.js +0 -6
  38. package/lib/to-abstract-base-template-utils/oc-webpack/lib/configurator/index.js +0 -9
  39. package/lib/to-abstract-base-template-utils/oc-webpack/lib/configurator/server/index.js +0 -93
  40. package/lib/viewTemplate.js +0 -35
  41. package/scaffold/src/app.js +0 -11
  42. package/scaffold/src/server.js +0 -4
  43. package/scaffold/src/styles.css +0 -4
  44. package/utils/index.js +0 -4
  45. package/utils/withDataProvider.js +0 -21
  46. package/utils/withSettingProvider.js +0 -21
@@ -1,35 +0,0 @@
1
- const viewTemplate = ({
2
- reactRoot,
3
- css,
4
- externals,
5
- bundleHash,
6
- bundleName
7
- }) => `function(model){
8
- var modelHTML = model.__html ? model.__html : '';
9
- var staticPath = model.reactComponent.props._staticPath;
10
- var props = JSON.stringify(model.reactComponent.props);
11
- var randomId = Math.random() * 10000000;
12
- var reactRootId = "${reactRoot}-" + randomId;
13
- return '${css ? "<style>" + css + "</style>" : ""}' +
14
- '<div id="'+ reactRootId +'" class="${reactRoot}">' + modelHTML + '</div>' +
15
- '<script>' +
16
- 'window.oc = window.oc || {};' +
17
- 'oc.cmd = oc.cmd || [];' +
18
- 'oc.cmd.push(function(oc){' +
19
- '${css ? "oc.events.fire(\\'oc:cssDidMount\\', \\'" + css + "\\');" : ""}' +
20
- 'oc.requireSeries(${JSON.stringify(externals)}, function(){' +
21
- 'oc.require(' +
22
- '["oc", "reactComponents", "${bundleHash}"],' +
23
- '"' + staticPath + '${bundleName}.js",' +
24
- 'function(ReactComponent){' +
25
- 'var targetNode = document.getElementById("'+ reactRootId +'");' +
26
- 'targetNode.setAttribute("id","");' +
27
- 'ReactDOM.hydrate(React.createElement(ReactComponent,' + props + '),targetNode);' +
28
- '}' +
29
- ');' +
30
- '});' +
31
- '});' +
32
- '</script>'
33
- }`;
34
-
35
- module.exports = viewTemplate;
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- import styles from "./styles.css";
3
-
4
- const App = props =>
5
- <div className={styles.special}>
6
- <h1>
7
- Hello {props.name}
8
- </h1>
9
- </div>;
10
-
11
- export default App;
@@ -1,4 +0,0 @@
1
- export const data = (context, callback) => {
2
- const { name } = context.params;
3
- return callback(null, { name });
4
- };
@@ -1,4 +0,0 @@
1
- .special {
2
- background: palevioletred;
3
- color: white;
4
- }
package/utils/index.js DELETED
@@ -1,4 +0,0 @@
1
- import withDataProvider from "./withDataProvider";
2
- import withSettingProvider from "./withSettingProvider";
3
-
4
- export { withDataProvider, withSettingProvider };
@@ -1,21 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
-
4
- const withDataProvider = BaseComponent => {
5
- const Enhanced = (props, context) => {
6
- const propsWithGetData = {
7
- ...props,
8
- getData: context.getData
9
- };
10
-
11
- return <BaseComponent {...propsWithGetData} />;
12
- };
13
-
14
- Enhanced.contextTypes = {
15
- getData: PropTypes.func
16
- };
17
-
18
- return Enhanced;
19
- };
20
-
21
- export default withDataProvider;
@@ -1,21 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
-
4
- const withSettingProvider = BaseComponent => {
5
- const Enhanced = (props, context) => {
6
- const propsWithGetSetting = {
7
- ...props,
8
- getSetting: context.getSetting
9
- };
10
-
11
- return <BaseComponent {...propsWithGetSetting} />;
12
- };
13
-
14
- Enhanced.contextTypes = {
15
- getSetting: PropTypes.func
16
- };
17
-
18
- return Enhanced;
19
- };
20
-
21
- export default withSettingProvider;