1.1 --- a/ko/kosample/pom.xml Wed Apr 27 07:28:33 2016 +0200
1.2 +++ b/ko/kosample/pom.xml Thu Apr 28 05:59:32 2016 +0200
1.3 @@ -20,7 +20,7 @@
1.4 </modules>
1.5 <properties>
1.6 <bck2brwsr.version>${project.version}</bck2brwsr.version>
1.7 - <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
1.8 + <bck2brwsr.obfuscationlevel>FULL</bck2brwsr.obfuscationlevel>
1.9 <jersey.version>2.13</jersey.version>
1.10 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1.11 </properties>
2.1 --- a/rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js Wed Apr 27 07:28:33 2016 +0200
2.2 +++ b/rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js Thu Apr 28 05:59:32 2016 +0200
2.3 @@ -18,5 +18,3 @@
2.4
2.5 function mul(x, y) { return x * y; }
2.6 function all() { return '*/*'; }
2.7 -window.mul = mul;
2.8 -window.all = all;
3.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Wed Apr 27 07:28:33 2016 +0200
3.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Thu Apr 28 05:59:32 2016 +0200
3.3 @@ -245,7 +245,7 @@
3.4 while (resource.startsWith("/")) {
3.5 resource = resource.substring(1);
3.6 }
3.7 - requireResourceImpl(resource);
3.8 + requireResourceImpl(false, resource);
3.9 asBinary.remove(resource);
3.10 }
3.11 scripts = new StringArray();
3.12 @@ -266,19 +266,25 @@
3.13 }
3.14 }
3.15
3.16 - final void requireResourceImpl(String resource) throws IOException {
3.17 + final void requireResourceImpl(boolean useEval, String resource) throws IOException {
3.18 InputStream emul = resources.get(resource);
3.19 if (emul == null) {
3.20 throw new IOException("Can't find " + resource);
3.21 }
3.22 append("\n// resource from ").append(resource).append("\n");
3.23 - readResource(emul, this);
3.24 + append("\n");
3.25 + if (useEval) {
3.26 + append("(0 || eval)(\"");
3.27 + }
3.28 + readResource(useEval, emul, this);
3.29 + if (useEval) {
3.30 + append("\");");
3.31 + }
3.32 append("\n");
3.33 }
3.34
3.35 - private static void readResource(InputStream emul, Appendable out) throws IOException {
3.36 + private static void readResource(boolean escape, InputStream emul, Appendable out) throws IOException {
3.37 try {
3.38 - int state = 0;
3.39 for (;;) {
3.40 int ch = emul.read();
3.41 if (ch == -1) {
3.42 @@ -287,7 +293,29 @@
3.43 if (ch < 0 || ch > 255) {
3.44 throw new IOException("Invalid char in emulation " + ch);
3.45 }
3.46 - out.append((char)ch);
3.47 + if (escape) {
3.48 + switch (ch) {
3.49 + case '"':
3.50 + out.append("\\\"");
3.51 + break;
3.52 + case '\\':
3.53 + out.append("\\\\");
3.54 + break;
3.55 + case '\n':
3.56 + out.append("\\n\"\n + \"");
3.57 + break;
3.58 + case '\t':
3.59 + out.append("\\t");
3.60 + break;
3.61 + case '\r':
3.62 + out.append("\\r");
3.63 + break;
3.64 + default:
3.65 + out.append((char)ch);
3.66 + }
3.67 + } else {
3.68 + out.append((char)ch);
3.69 + }
3.70 }
3.71 } finally {
3.72 emul.close();
3.73 @@ -741,7 +769,7 @@
3.74
3.75 @Override
3.76 protected void requireResource(String resourcePath) throws IOException {
3.77 - requireResourceImpl(resourcePath);
3.78 + requireResourceImpl(true, resourcePath);
3.79 super.asBinary.remove(resourcePath);
3.80 }
3.81 }
3.82 @@ -860,7 +888,7 @@
3.83
3.84 @Override
3.85 protected void requireResource(String resourcePath) throws IOException {
3.86 - requireResourceImpl(resourcePath);
3.87 + requireResourceImpl(true, resourcePath);
3.88 super.asBinary.remove(resourcePath);
3.89 }
3.90 }