mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
JS: add more API declarations
This commit is contained in:
parent
f734603255
commit
fc9a53bdd3
|
@ -90,4 +90,9 @@ public abstract class XMLHttpRequest implements JSObject {
|
|||
|
||||
@JSBody(script = "return new XMLHttpRequest();")
|
||||
public static native XMLHttpRequest create();
|
||||
|
||||
public abstract void abort();
|
||||
|
||||
@JSProperty
|
||||
public abstract String getResponseURL();
|
||||
}
|
||||
|
|
|
@ -30,4 +30,10 @@ public final class Navigator {
|
|||
|
||||
@JSBody(script = "return (\"geolocation\" in navigator);")
|
||||
public static native boolean isGeolocationAvailable();
|
||||
|
||||
@JSBody(script = "return navigator.language;")
|
||||
public static native String getLanguage();
|
||||
|
||||
@JSBody(script = "return navigator.languages;")
|
||||
public static native String[] getLanguages();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ public abstract class Window implements JSObject, WindowEventTarget, StorageProv
|
|||
|
||||
@JSProperty
|
||||
public abstract int getScreenY();
|
||||
|
||||
@JSProperty
|
||||
public abstract Location getLocation();
|
||||
|
||||
|
@ -184,4 +183,10 @@ public abstract class Window implements JSObject, WindowEventTarget, StorageProv
|
|||
|
||||
@JSProperty
|
||||
public abstract double getDevicePixelRatio();
|
||||
|
||||
@JSBody(params = "s", script = "return window.atob(s);")
|
||||
public static native String atob(String s);
|
||||
|
||||
@JSBody(params = "s", script = "return window.btoa(s);")
|
||||
public static native String btoa(String s);
|
||||
}
|
||||
|
|
27
jso/apis/src/main/java/org/teavm/jso/core/JSMapLike.java
Normal file
27
jso/apis/src/main/java/org/teavm/jso/core/JSMapLike.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2019 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.jso.core;
|
||||
|
||||
import org.teavm.jso.JSIndexer;
|
||||
import org.teavm.jso.JSObject;
|
||||
|
||||
public interface JSMapLike<T extends JSObject> extends JSObject {
|
||||
@JSIndexer
|
||||
T get(String key);
|
||||
|
||||
@JSIndexer
|
||||
void set(String key, T object);
|
||||
}
|
30
jso/apis/src/main/java/org/teavm/jso/core/JSON.java
Normal file
30
jso/apis/src/main/java/org/teavm/jso/core/JSON.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2019 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.jso.core;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.JSObject;
|
||||
|
||||
public final class JSON {
|
||||
private JSON() {
|
||||
}
|
||||
|
||||
@JSBody(params = "s", script = "return JSON.parse(s);")
|
||||
public static native <T extends JSObject> T parse(String s);
|
||||
|
||||
@JSBody(params = "o", script = "JSON.stringify(o);")
|
||||
public static native String stringify(JSObject o);
|
||||
}
|
42
jso/apis/src/main/java/org/teavm/jso/core/JSObjects.java
Normal file
42
jso/apis/src/main/java/org/teavm/jso/core/JSObjects.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2019 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.jso.core;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.JSObject;
|
||||
|
||||
public final class JSObjects {
|
||||
private JSObjects() {
|
||||
}
|
||||
|
||||
@JSBody(params = "object", script = "return Object.getOwnPropertyNames(object);")
|
||||
public static native String[] getOwnPropertyNames(JSObject object);
|
||||
|
||||
@JSBody(script = "return Object.create(null);")
|
||||
public static native <T extends JSObject> T create();
|
||||
|
||||
@JSBody(params = "object", script = "return typeof object === 'undefined';")
|
||||
public static native boolean isUndefined(JSObject object);
|
||||
|
||||
@JSBody(params = "object", script = "return typeof object;")
|
||||
public static native String typeOf(JSObject object);
|
||||
|
||||
@JSBody(params = "object", script = "return object.toString();")
|
||||
public static native String toString(JSObject object);
|
||||
|
||||
@JSBody(params = { "object", "name" }, script = "return name in object;")
|
||||
public static native boolean hasProperty(JSObject object, String name);
|
||||
}
|
|
@ -59,6 +59,12 @@ public interface MouseEvent extends Event {
|
|||
@JSProperty
|
||||
EventTarget getRelatedTarget();
|
||||
|
||||
@JSProperty
|
||||
double getMovementX();
|
||||
|
||||
@JSProperty
|
||||
double getMovementY();
|
||||
|
||||
void initMouseEvent(String type, boolean canBubble, boolean cancelable, JSObject view, int detail, int screenX,
|
||||
int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey,
|
||||
short button, EventTarget relatedTarget);
|
||||
|
|
|
@ -63,4 +63,10 @@ public interface HTMLAnchorElement extends HTMLElement {
|
|||
|
||||
@JSProperty
|
||||
void setText(String value);
|
||||
|
||||
@JSProperty
|
||||
String getDownload();
|
||||
|
||||
@JSProperty
|
||||
void setDownload(String download);
|
||||
}
|
||||
|
|
|
@ -73,4 +73,19 @@ public interface HTMLDocument extends Document, EventTarget {
|
|||
void execCommand(String commandName, boolean showDefaultUI, String valueArgument);
|
||||
|
||||
void execCommand(String commandName);
|
||||
|
||||
@JSProperty
|
||||
String getCookie();
|
||||
|
||||
@JSProperty
|
||||
void setCookie(String cookie);
|
||||
|
||||
@JSProperty
|
||||
String getTitle();
|
||||
|
||||
@JSProperty
|
||||
void setTitle(String title);
|
||||
|
||||
@JSProperty
|
||||
HTMLElement getPointerLockElement();
|
||||
}
|
||||
|
|
|
@ -186,4 +186,8 @@ public interface HTMLElement extends Element, ElementCSSInlineStyle, EventTarget
|
|||
|
||||
@Override
|
||||
NodeList<? extends HTMLElement> querySelectorAll(String selectors);
|
||||
|
||||
void requestPointerLock();
|
||||
|
||||
void exitPointerLock();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2019 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.jso.websocket;
|
||||
|
||||
import org.teavm.jso.JSProperty;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
|
||||
public interface CloseEvent extends Event {
|
||||
@JSProperty
|
||||
int getCode();
|
||||
|
||||
@JSProperty
|
||||
String getReason();
|
||||
|
||||
@JSProperty("wasClean")
|
||||
boolean wasClean();
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright 2019 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.jso.websocket;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
|
||||
public abstract class WebSocket implements JSObject {
|
||||
@JSProperty("onclose")
|
||||
public abstract void onClose(EventListener<CloseEvent> eventListener);
|
||||
|
||||
@JSProperty("onerror")
|
||||
public abstract void onError(EventListener<Event> eventListener);
|
||||
|
||||
@JSProperty("onmessage")
|
||||
public abstract void onMessage(EventListener<MessageEvent> eventListener);
|
||||
|
||||
@JSProperty("onopen")
|
||||
public abstract void onOpen(EventListener<MessageEvent> eventListener);
|
||||
|
||||
@JSBody(params = "url", script = "return new WebSocket(url);")
|
||||
public static native WebSocket create(String url);
|
||||
|
||||
@JSBody(params = { "url", "protocols" }, script = "return new WebSocket(url, protocols);")
|
||||
public static native WebSocket create(String url, String protocols);
|
||||
|
||||
@JSBody(params = { "url", "protocols" }, script = "return new WebSocket(url, protocols);")
|
||||
public static native WebSocket create(String url, String[] protocols);
|
||||
|
||||
public abstract void close();
|
||||
|
||||
public abstract void close(int code);
|
||||
|
||||
public abstract void close(int code, String reason);
|
||||
|
||||
public abstract void send(String data);
|
||||
|
||||
@JSProperty
|
||||
public abstract String getBinaryType();
|
||||
|
||||
@JSProperty
|
||||
public abstract void setBinaryType(String binaryType);
|
||||
|
||||
@JSProperty
|
||||
public abstract int getBufferedAmount();
|
||||
|
||||
@JSProperty
|
||||
public abstract String getExtensions();
|
||||
|
||||
@JSProperty
|
||||
public abstract String getProtocol();
|
||||
|
||||
@JSProperty
|
||||
public abstract int getReadyState();
|
||||
|
||||
@JSProperty
|
||||
public abstract String getUrl();
|
||||
|
||||
@JSBody(script = "return typeof WebSocket !== 'undefined';")
|
||||
protected static native boolean isSupported();
|
||||
}
|
Loading…
Reference in New Issue
Block a user