Skip to content

Commit c90dbd1

Browse files
committed
Merge branch 'release/0.9.1'
2 parents 5ee4d35 + 0a18246 commit c90dbd1

File tree

141 files changed

+6576
-475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+6576
-475
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ matrix:
3636
- env: JDK='OpenJDK 12'
3737

3838
script:
39-
- mvn clean package
39+
- mvn clean verify
4040

4141
after_success:
4242
- '[[ "${JDK}" = "OpenJDK 11" ]] && bash <(curl -s https://codecov.io/bash) || true'

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [0.9.1] - 2019-09-12
9+
- Fix issue with `pm` launcher that doesn't add itself to the classpath
10+
- Fix issue with `pm` lancher that picks the wrong java if `GRAALVM_HOME`
11+
was defined
12+
- Moved `esm`, `polyglot`, etc... run flags to jvm flags in order to be
13+
usable from any command
14+
- Updated codegen to support more temporal types as they are supported
15+
by graal itself
16+
- Added a few more tests to ES4X
17+
- Instrumented `JsonObject` to be a Graal `ProxyObject` (this allows
18+
using it as a native object)
19+
- Instrumented `JsonArray` to be a Graal `ProxyArray` (this is a
20+
preparation for hanlding it as a native array)
21+
822
## [0.9.0] - 2019-08-23
923
- Upgrade to Graal 19.2.0
1024
- Upgrade to Vert.x 3.8.1

codegen/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<parent>
77
<groupId>io.reactiverse</groupId>
88
<artifactId>es4x-parent</artifactId>
9-
<version>0.9.0</version>
9+
<version>0.9.1</version>
1010
<relativePath>..</relativePath>
1111
</parent>
1212

1313
<modelVersion>4.0.0</modelVersion>
1414

1515
<artifactId>es4x-codegen</artifactId>
16-
<version>0.9.0</version>
16+
<version>0.9.1</version>
1717

1818
<properties>
1919
</properties>

codegen/src/main/java/io/reactiverse/es4x/codegen/generator/EnumDTS.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.util.HashSet;
2525
import java.util.Map;
2626

27+
import static io.reactiverse.es4x.codegen.generator.Util.isBlacklistedClass;
28+
2729
public class EnumDTS extends Generator<EnumModel> {
2830

2931
public EnumDTS() {
@@ -43,6 +45,10 @@ public String filename(EnumModel model) {
4345
@Override
4446
public String render(EnumModel model, int index, int size, Map<String, Object> session) {
4547

48+
if (isBlacklistedClass(model.getType().getName())) {
49+
return null;
50+
}
51+
4652
StringWriter sw = new StringWriter();
4753
PrintWriter writer = new PrintWriter(sw);
4854

codegen/src/main/java/io/reactiverse/es4x/codegen/generator/IndexDTS.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public String filename(ClassModel model) {
4646
@Override
4747
public String render(ClassModel model, int index, int size, Map<String, Object> session) {
4848

49+
if (isBlacklistedClass(model.getType().getName())) {
50+
return null;
51+
}
52+
4953
StringWriter sw = new StringWriter();
5054
PrintWriter writer = new PrintWriter(sw);
5155

@@ -221,9 +225,9 @@ public String render(ClassModel model, int index, int size, Map<String, Object>
221225
writer.print("\n");
222226
}
223227
writer.println(" /**");
224-
writer.println(" * Attaches callbacks for the resolution and/or rejection of the Promise.");
225-
writer.println(" * @param onfulfilled The callback to execute when the Promise is resolved.");
226-
writer.println(" * @param onrejected The callback to execute when the Promise is rejected.");
228+
writer.println(" * Attaches callbacks for the resolution and/or rejection of the Future.");
229+
writer.println(" * @param onfulfilled The callback to execute when the Future is resolved.");
230+
writer.println(" * @param onrejected The callback to execute when the Future is rejected.");
227231
writer.println(" * @returns A Promise for the completion of which ever callback is executed.");
228232
writer.println(" */");
229233
writer.println(" then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;");

codegen/src/main/java/io/reactiverse/es4x/codegen/generator/OptionsDTS.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ private Collection<ClassTypeInfo> filterImports(Map<String, PropertyInfo> proper
5252
@Override
5353
public String render(DataObjectModel model, int index, int size, Map<String, Object> session) {
5454

55+
if (isBlacklistedClass(model.getType().getName())) {
56+
return null;
57+
}
58+
5559
StringWriter sw = new StringWriter();
5660
PrintWriter writer = new PrintWriter(sw);
5761

@@ -70,12 +74,20 @@ public String render(DataObjectModel model, int index, int size, Map<String, Obj
7074
writer.printf("import { %s } from './enums';\n", referencedType.getSimpleName());
7175
imports = true;
7276
} else {
77+
// ignore missing imports
78+
if (isOptionalModule(getNPMScope(referencedType.getRaw().getModule()))) {
79+
writer.println("// @ts-ignore");
80+
}
7381
writer.printf("import { %s } from '%s/enums';\n", referencedType.getSimpleName(), getNPMScope(referencedType.getRaw().getModule()));
7482
imports = true;
7583
}
7684
}
7785
if (referencedType.getKind() == ClassKind.DATA_OBJECT) {
7886
if (!referencedType.getRaw().getModuleName().equals(model.getType().getRaw().getModuleName())) {
87+
// ignore missing imports
88+
if (isOptionalModule(getNPMScope(referencedType.getRaw().getModule()))) {
89+
writer.println("// @ts-ignore");
90+
}
7991
writer.printf("import { %s } from '%s/options';\n", referencedType.getSimpleName(), getNPMScope(referencedType.getRaw().getModule()));
8092
imports = true;
8193
}
@@ -85,6 +97,10 @@ public String render(DataObjectModel model, int index, int size, Map<String, Obj
8597
writer.printf("import { %s } from './index';\n", referencedType.getSimpleName());
8698
imports = true;
8799
} else {
100+
// ignore missing imports
101+
if (isOptionalModule(getNPMScope(referencedType.getRaw().getModule()))) {
102+
writer.println("// @ts-ignore");
103+
}
88104
writer.printf("import { %s } from '%s';\n", referencedType.getSimpleName(), getNPMScope(referencedType.getRaw().getModule()));
89105
imports = true;
90106
}

codegen/src/main/java/io/reactiverse/es4x/codegen/generator/Util.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ private Util() {
4343

4444
private final static Map<String, JsonObject> OVERRIDES = new HashMap<>();
4545
private final static JsonArray OPTIONAL_DEPENDENCIES;
46+
private final static JsonArray CLASS_BLACKLIST;
4647

4748
static {
4849
/* parse the registry from the system property */
4950
REGISTRY = new JsonArray(System.getProperty("scope-registry", "[]"));
5051
YEAR = Calendar.getInstance().get(Calendar.YEAR);
5152
OPTIONAL_DEPENDENCIES = new JsonArray(System.getProperty("npm-optional-dependencies", "[]"));
53+
CLASS_BLACKLIST = new JsonArray(System.getProperty("npm-class-blacklist", "[]"));
5254

5355
// register known java <-> js types
5456
TYPES.put("io.vertx.core.Closeable", "(completionHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>) => void");
@@ -62,9 +64,14 @@ private Util() {
6264
TYPES.put("java.lang.Long[]", "number[]");
6365
TYPES.put("java.lang.Short[]", "number[]");
6466
TYPES.put("java.lang.String[]", "string[]");
67+
6568
TYPES.put("java.time.Instant", "Date");
66-
// TYPES.put("io.vertx.core.Future", "PromiseLike");
67-
// TYPES.put("io.vertx.core.Promise", "PromiseLike | Promise");
69+
TYPES.put("java.time.LocalDate", "Date");
70+
// TYPES.put("java.time.LocalTime", "Date");
71+
TYPES.put("java.time.LocalDateTime", "Date");
72+
TYPES.put("java.time.ZonedDateTime", "Date");
73+
// TYPES.put("java.time.ZoneId", "Date");
74+
// TYPES.put("java.time.Duration", "Date");
6875

6976
// reserved typescript keywords
7077
RESERVED.addAll(Arrays.asList(
@@ -122,6 +129,10 @@ public static boolean isOptionalModule(String name) {
122129
return OPTIONAL_DEPENDENCIES.contains(name);
123130
}
124131

132+
public static boolean isBlacklistedClass(String name) {
133+
return CLASS_BLACKLIST.contains(name);
134+
}
135+
125136
public static String genType(TypeInfo type) {
126137

127138
switch (type.getKind()) {
@@ -189,7 +200,7 @@ public static String genType(TypeInfo type) {
189200
return type.getRaw().getSimpleName() + "<" + sb.toString() + ">";
190201
}
191202
} else {
192-
// TS is strict with generics, you can't define/use a generic type with out its generic <T>
203+
// TS is strict with generics, you can't define/use a generic type without its generic <T>
193204
if (type.getRaw() != null && type.getRaw().getParams().size() > 0) {
194205
for (TypeParamInfo t : type.getRaw().getParams()) {
195206
if (!first) {
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<template>
2+
<div ref="player"></div>
3+
</template>
4+
<script lang="js">
5+
function fixEscapeCodes(text) {
6+
if (text) {
7+
var f = function(match, p1, offset, string) {
8+
return String.fromCodePoint(parseInt(p1, 16));
9+
};
10+
11+
return text.
12+
replace(/\\u([a-z0-9]{4})/gi, f).
13+
replace(/\\x([a-z0-9]{2})/gi, f).
14+
replace(/\\e/g, "\x1b");
15+
} else {
16+
return text;
17+
}
18+
}
19+
export default {
20+
props: {
21+
src: {
22+
type: String,
23+
required: true
24+
},
25+
cols: {
26+
type: String,
27+
default: "0"
28+
},
29+
rows: {
30+
type: String,
31+
default: "0"
32+
},
33+
autoplay: {
34+
type: String,
35+
default: null
36+
},
37+
preload: {
38+
type: String,
39+
default: null
40+
},
41+
loop: {
42+
type: String,
43+
default: null
44+
},
45+
startAt: {
46+
type: String,
47+
default: null
48+
},
49+
speed: {
50+
type: String,
51+
default: null
52+
},
53+
idleTimeLimit: {
54+
type: String,
55+
default: null
56+
},
57+
poster: {
58+
type: String,
59+
default: null
60+
},
61+
fontSize: {
62+
type: String,
63+
default: null
64+
},
65+
theme: {
66+
type: String,
67+
default: null
68+
},
69+
title: {
70+
type: String,
71+
default: null
72+
},
73+
author: {
74+
type: String,
75+
default: null
76+
},
77+
authorURL: {
78+
type: String,
79+
default: null
80+
},
81+
authorImgURL: {
82+
type: String,
83+
default: null
84+
}
85+
},
86+
mounted() {
87+
let options = this.merge(
88+
this.attribute(this.cols, "width", 0, parseInt),
89+
this.attribute(this.rows, "height", 0, parseInt),
90+
this.attribute(this.autoplay, "autoPlay", true, Boolean),
91+
this.attribute(this.preload, "preload", true, Boolean),
92+
this.attribute(this.loop, "loop", true, Boolean),
93+
this.attribute(this.startAt, "startAt", 0, parseInt),
94+
this.attribute(this.speed, "speed", 1, parseInt),
95+
this.attribute(this.idleTimeLimit, "idleTimeLimit", null, parseFloat),
96+
this.attribute(this.poster, "poster", null, fixEscapeCodes),
97+
this.attribute(this.fontSize, "fontSize"),
98+
this.attribute(this.theme, "theme"),
99+
this.attribute(this.title, "title"),
100+
this.attribute(this.author, "author"),
101+
this.attribute(this.authorURL, "authorURL"),
102+
this.attribute(this.authorImgURL, "authorImgURL"),
103+
{
104+
onCanPlay:() => {
105+
console.log("onCanPlay");
106+
},
107+
onPlay:() => {
108+
console.log("onPlay");
109+
},
110+
onPause:() => {
111+
console.log("onPause");
112+
}
113+
}
114+
);
115+
asciinema.player.js.CreatePlayer(this.$refs["player"], this.src, options);
116+
},
117+
methods: {
118+
attribute(value, optName, defaultValue, coerceFn) {
119+
let obj = {};
120+
if (value !== null) {
121+
if (value === '' && defaultValue !== undefined) {
122+
value = defaultValue;
123+
} else if (coerceFn) {
124+
value = coerceFn(value);
125+
}
126+
obj[optName] = value;
127+
}
128+
return obj;
129+
},
130+
merge() {
131+
let merged = {};
132+
for (let i=0; i<arguments.length; i++) {
133+
let obj = arguments[i];
134+
for (let attrname in obj) {
135+
// noinspection JSUnfilteredForInLoop
136+
merged[attrname] = obj[attrname];
137+
}
138+
}
139+
return merged;
140+
}
141+
}
142+
}
143+
</script>
144+
<style>
145+
.theme-default-content pre {
146+
overflow: hidden;
147+
}
148+
</style>

docs/.vuepress/config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module.exports = {
33
base: '/es4x/',
44

55
head: [
6-
['link', {rel: "shortcut icon", type: "image/png", href: "/favicon.png"}]
6+
['link', {rel: "shortcut icon", type: "image/png", href: "/favicon.png"}],
7+
['link', {rel: "stylesheet", type: "text/css", href:"/player/asciinema-player.css"}],
8+
['script', {src: "/player/asciinema-player.js"}]
79
],
810

911
// look at: https://github.com/vuejs/vuepress/blob/0.x/docs/.vuepress/config.js
@@ -200,15 +202,15 @@ module.exports = {
200202
},
201203
{
202204
text: 'API参考',
203-
link: '/zh/api/'
205+
link: '/api/'
204206
},
205207
{
206208
text: '更新日志',
207209
link: 'https://github.com/reactiverse/es4x/blob/master/CHANGELOG.md'
208210
},
209211
],
210212
sidebar: {
211-
'/get-started/': [
213+
'/zh/get-started/': [
212214
{
213215
title: '由此开始',
214216
collapsable: false,
@@ -226,7 +228,7 @@ module.exports = {
226228
]
227229
}
228230
],
229-
'/advanced/': [
231+
'/zh/advanced/': [
230232
{
231233
title: '进阶内容',
232234
collapsable: false,

0 commit comments

Comments
 (0)