olum-compiler 1.9.5 → 1.9.7
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/bin/copySrc.js +1 -1
- package/lib/changes.txt +8 -0
- package/lib/events.js +9 -7
- package/lib/helpers.js +1 -1
- package/package.json +1 -1
- package/tests/compiler.test.js +4 -3
package/bin/copySrc.js
CHANGED
|
@@ -38,7 +38,7 @@ function injectIndexHtml(indexHtmlPath) {
|
|
|
38
38
|
: `<script>globalThis.__OLUM_DEV__ = true;</script>\n`;
|
|
39
39
|
indexHtmlContent = indexHtmlContent.replace(
|
|
40
40
|
/<\/body>/,
|
|
41
|
-
`\n<div id="app"></div>\n${devFlagTag}${importMapTag}<script defer type="module" src="../src/main.js"></script>\n${devtoolScriptContent}</body>`,
|
|
41
|
+
`\n<div id="olum-app"></div>\n${devFlagTag}${importMapTag}<script defer type="module" src="../src/main.js"></script>\n${devtoolScriptContent}</body>`,
|
|
42
42
|
);
|
|
43
43
|
fs.writeFileSync(indexHtmlPath, indexHtmlContent);
|
|
44
44
|
}
|
package/lib/changes.txt
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
change /tmp/olum-dev-test-E0g6QU/src/page.html
|
|
2
|
+
change /tmp/olum-dev-test-E0g6QU/public/main.css
|
|
3
|
+
addDir /tmp/olum-dev-test-E0g6QU/src/blog
|
|
4
|
+
add /tmp/olum-dev-test-E0g6QU/src/blog/page.html
|
|
5
|
+
unlink /tmp/olum-dev-test-E0g6QU/src/blog/page.html
|
|
6
|
+
unlinkDir /tmp/olum-dev-test-E0g6QU/src/blog
|
|
7
|
+
change /tmp/olum-dev-test-E0g6QU/src/util.js
|
|
8
|
+
change /tmp/olum-dev-test-E0g6QU/src/page.html
|
package/lib/events.js
CHANGED
|
@@ -134,19 +134,21 @@ function handleEvents(body, counter, filePath, anonHandlers, propsAliases) {
|
|
|
134
134
|
return str.replace(/\$event/g, "'$event'");
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
const encodeArgs = (args) =>
|
|
138
|
+
"${encodeURIComponent(JSON.stringify([" +
|
|
139
|
+
args +
|
|
140
|
+
"])).replace(/'/g,'%27')}";
|
|
141
|
+
|
|
137
142
|
let chain = e + "|";
|
|
138
143
|
methodsNames.forEach((item, index) => {
|
|
139
144
|
if (index === methodsNames.length - 1)
|
|
140
145
|
return (chain +=
|
|
141
146
|
item +
|
|
142
|
-
"
|
|
143
|
-
handle$event(methodsArgs[index]) +
|
|
144
|
-
"
|
|
147
|
+
"=" +
|
|
148
|
+
encodeArgs(handle$event(methodsArgs[index])) +
|
|
149
|
+
"-]]-");
|
|
145
150
|
chain +=
|
|
146
|
-
item +
|
|
147
|
-
"=${JSON.stringify([" +
|
|
148
|
-
handle$event(methodsArgs[index]) +
|
|
149
|
-
"])}&";
|
|
151
|
+
item + "=" + encodeArgs(handle$event(methodsArgs[index])) + "&";
|
|
150
152
|
});
|
|
151
153
|
|
|
152
154
|
chain = chain.replace(/{/g, "<-olum->");
|
package/lib/helpers.js
CHANGED
|
@@ -775,7 +775,7 @@ const compileRoutes = (entryPoint) => {
|
|
|
775
775
|
if (manifest["not-found"]) has404Page = true;
|
|
776
776
|
const libImports = `import Olum from "olum";\nimport Router from "olum-router";`;
|
|
777
777
|
const imports = generateImports(manifest);
|
|
778
|
-
const config = `const config = { mode: "history", root: "/", ${has404Page ? `err: "/404",` : ""} routes: routes };\nconst router = new Router(config);\nnew Olum().$("#app").use(router);`;
|
|
778
|
+
const config = `const config = { mode: "history", root: "/", ${has404Page ? `err: "/404",` : ""} routes: routes };\nconst router = new Router(config);\nnew Olum().$("#olum-app").use(router);`;
|
|
779
779
|
routes = generateRoutes(manifest);
|
|
780
780
|
|
|
781
781
|
return `${libImports}\n${imports}\n${routes}\n${config}`;
|
package/package.json
CHANGED
package/tests/compiler.test.js
CHANGED
|
@@ -281,8 +281,9 @@ check(
|
|
|
281
281
|
"$event is forwarded to the handler",
|
|
282
282
|
comp(`<input oninput="setVal($event)" />`, `const setVal = (e) => 0;`),
|
|
283
283
|
(out) =>
|
|
284
|
-
/oninput\|setVal=\$\{JSON\.stringify\(\['\$event'\]\)\
|
|
285
|
-
|
|
284
|
+
/oninput\|setVal=\$\{encodeURIComponent\(JSON\.stringify\(\['\$event'\]\)\)/.test(
|
|
285
|
+
tmpl(out),
|
|
286
|
+
) && parses(out),
|
|
286
287
|
);
|
|
287
288
|
check(
|
|
288
289
|
"inline arrow handler becomes a named __olumAnon_ method",
|
|
@@ -890,7 +891,7 @@ checkFn(
|
|
|
890
891
|
/err: "\/404",/.test(out) &&
|
|
891
892
|
!/Widget|_drafts|Drafts/.test(out) &&
|
|
892
893
|
/new Router\(config\)/.test(out) &&
|
|
893
|
-
/new Olum\(\)\.\$\("
|
|
894
|
+
/new Olum\(\)\.\$\("olum-app"\)\.use\(router\)/.test(out)
|
|
894
895
|
);
|
|
895
896
|
},
|
|
896
897
|
);
|