oc-template-elm-compiler 0.1.0-beta.1 → 0.1.0-beta.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.
package/dist/lib/compile.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.compile = (0, oc_generic_template_compiler_1.createCompile)({
|
|
|
16
16
|
...options,
|
|
17
17
|
plugins: [(0, vite_plugin_elm_1.default)()],
|
|
18
18
|
viewWrapper: ({ viewPath }) => (0, elmOCProviderTemplate_1.default)({ viewPath, jsPath: undefined }),
|
|
19
|
-
htmlTemplate:
|
|
19
|
+
htmlTemplate: htmlTemplate_1.default,
|
|
20
20
|
externals: (0, oc_template_elm_1.getInfo)().externals
|
|
21
21
|
}, cb),
|
|
22
22
|
compileServer: oc_vite_compiler_1.viteServer,
|
|
@@ -17,14 +17,13 @@ function elmOCProviderTemplate({ jsPath, viewPath }) {
|
|
|
17
17
|
if (err) {
|
|
18
18
|
return cb(err);
|
|
19
19
|
}
|
|
20
|
-
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = data.
|
|
20
|
+
const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = data.component.props;
|
|
21
21
|
cb(null, rest);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function renderer(model, node) {
|
|
26
26
|
const { _baseUrl, _componentName, _componentVersion, _staticPath, ...props } = model;
|
|
27
|
-
const app = Component.Elm["${extractName(viewPath)}"].init({ node, flags });
|
|
28
27
|
const app = Elm["${extractName(viewPath)}"].init({
|
|
29
28
|
node,
|
|
30
29
|
flags: props
|
|
@@ -48,7 +47,7 @@ function elmOCProviderTemplate({ jsPath, viewPath }) {
|
|
|
48
47
|
return app;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
export default
|
|
50
|
+
export default renderer;
|
|
52
51
|
`;
|
|
53
52
|
}
|
|
54
53
|
exports.default = elmOCProviderTemplate;
|
package/dist/lib/htmlTemplate.js
CHANGED
|
@@ -4,11 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const cssesc_1 = __importDefault(require("cssesc"));
|
|
7
|
-
function viewTemplate({ templateId, css, hash,
|
|
8
|
-
return `function
|
|
7
|
+
function viewTemplate({ templateId, css, hash, bundle }) {
|
|
8
|
+
return `function(model){
|
|
9
|
+
oc.elmComponents = oc.elmComponents || {};
|
|
10
|
+
oc.elmComponents['${hash}'] = oc.elmComponents['${hash}'] || (${bundle});
|
|
11
|
+
if (!model) return;
|
|
9
12
|
var modelHTML = model.__html ? model.__html : '';
|
|
10
|
-
var staticPath = model.component.
|
|
11
|
-
var
|
|
13
|
+
var staticPath = model.component.props._staticPath;
|
|
14
|
+
var props = JSON.stringify(model.component.props);
|
|
12
15
|
window.oc = window.oc || {};
|
|
13
16
|
window.oc.__elmTemplate = window.oc.__elmTemplate || { count: 0 };
|
|
14
17
|
var count = window.oc.__elmTemplate.count;
|
|
@@ -19,17 +22,12 @@ function viewTemplate({ templateId, css, hash, bundleName }) {
|
|
|
19
22
|
'<script>' +
|
|
20
23
|
'window.oc = window.oc || {};' +
|
|
21
24
|
'oc.cmd = oc.cmd || [];' +
|
|
25
|
+
|
|
22
26
|
'oc.cmd.push(function(oc){' +
|
|
23
27
|
'${css ? "oc.events.fire(\\'oc:cssDidMount\\', \\'" + css + "\\');" : ''}' +
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'function(ElmComponent) {' +
|
|
28
|
-
'var targetNode = document.getElementById("' + templateId + '");' +
|
|
29
|
-
'targetNode.setAttribute("id","");' +
|
|
30
|
-
'ElmComponent({ node: targetNode, flags:' + flags + '});' +
|
|
31
|
-
'}' +
|
|
32
|
-
');' +
|
|
28
|
+
'var targetNode = document.getElementById("' + templateId + '");' +
|
|
29
|
+
'targetNode.setAttribute("id","");' +
|
|
30
|
+
'oc.elmComponents["${hash}"](' + props + ', targetNode);' +
|
|
33
31
|
'});' +
|
|
34
32
|
'</script>'
|
|
35
33
|
}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-template-elm-compiler",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"oc-statics-compiler": "2.0.10",
|
|
37
37
|
"oc-template-elm": "0.1.0",
|
|
38
38
|
"oc-view-wrapper": "1.0.3",
|
|
39
|
+
"oc-vite-compiler": "^3.0.0",
|
|
39
40
|
"resolve": "1.18.1",
|
|
40
41
|
"vite-plugin-elm": "^2.8.0"
|
|
41
42
|
},
|