-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6df39dc
commit d40bd99
Showing
11 changed files
with
411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2024 ihromant. | ||
* | ||
* 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.ajax; | ||
|
||
import org.teavm.jso.JSClass; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.core.JSArray; | ||
import org.teavm.jso.dom.html.HTMLElement; | ||
import org.teavm.jso.dom.html.HTMLFormElement; | ||
import org.teavm.jso.file.Blob; | ||
|
||
@JSClass | ||
public class FormData implements JSObject { | ||
public FormData() { | ||
} | ||
|
||
public FormData(HTMLFormElement form) { | ||
} | ||
|
||
public FormData(HTMLFormElement form, HTMLElement submitter) { | ||
} | ||
|
||
public native void append(String name, String value); | ||
|
||
public native void append(String name, Blob value); | ||
|
||
public native void append(String name, String value, String fileName); | ||
|
||
public native void append(String name, Blob value, String fileName); | ||
|
||
public native void delete(String name); | ||
|
||
/** | ||
* Actual element is either {@link Blob} or {@link org.teavm.jso.core.JSString} | ||
*/ | ||
// TODO: update signature when union types supported in TeaVM | ||
public native JSObject get(String name); | ||
|
||
/** | ||
* Actual elements are {@link Blob} or {@link org.teavm.jso.core.JSString} | ||
*/ | ||
// TODO: update signature when union types supported in TeaVM | ||
public native JSArray<JSObject> getAll(String name); | ||
|
||
public native boolean has(String name); | ||
|
||
public native void set(String name, String value); | ||
|
||
public native void set(String name, Blob value); | ||
|
||
public native void set(String name, String value, String fileName); | ||
|
||
public native void set(String name, Blob value, String fileName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2024 ihromant. | ||
* | ||
* 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.file; | ||
|
||
import org.teavm.jso.JSClass; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSArrayReader; | ||
import org.teavm.jso.core.JSPromise; | ||
import org.teavm.jso.streams.ReadableStream; | ||
import org.teavm.jso.typedarrays.ArrayBuffer; | ||
|
||
@JSClass | ||
public class Blob implements JSObject { | ||
/** | ||
* Actual elements within array are either {@link Blob} or {@link org.teavm.jso.core.JSString} | ||
*/ | ||
// TODO: update signature when | ||
public Blob(JSArrayReader<? extends JSObject> array) { | ||
} | ||
|
||
/** | ||
* Actual elements within array are either {@link Blob} or {@link org.teavm.jso.core.JSString} | ||
*/ | ||
public Blob(JSArrayReader<? extends JSObject> array, BlobPropertyBag options) { | ||
} | ||
|
||
@JSProperty | ||
public native int getSize(); | ||
|
||
@JSProperty | ||
public native String getType(); | ||
|
||
public native JSPromise<ArrayBuffer> arrayBuffer(); | ||
|
||
public native Blob slice(); | ||
|
||
public native Blob slice(int start); | ||
|
||
public native Blob slice(int start, int end); | ||
|
||
public native Blob slice(int start, int end, String contentType); | ||
|
||
public native ReadableStream stream(); | ||
|
||
public native JSPromise<String> text(); | ||
} |
51 changes: 51 additions & 0 deletions
51
jso/apis/src/main/java/org/teavm/jso/file/BlobPropertyBag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2024 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.file; | ||
|
||
import org.teavm.jso.JSClass; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSObjects; | ||
|
||
@JSClass(transparent = true) | ||
public abstract class BlobPropertyBag implements JSObject { | ||
public static final String ENDING_TYPE_TRANSPARENT = "transparent"; | ||
public static final String ENDING_TYPE_NATIVE = "native"; | ||
|
||
BlobPropertyBag() { | ||
} | ||
|
||
public static BlobPropertyBag create() { | ||
return JSObjects.create(); | ||
} | ||
|
||
public BlobPropertyBag type(String type) { | ||
setType(type); | ||
return this; | ||
} | ||
|
||
// TODO: update signature when union of strings (lighweight enums) are supported in TeaVM | ||
public BlobPropertyBag endingType(String endingType) { | ||
setEndingType(endingType); | ||
return this; | ||
} | ||
|
||
@JSProperty | ||
private native void setType(String type); | ||
|
||
@JSProperty | ||
private native void setEndingType(String endingType); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2024 ihromant. | ||
* | ||
* 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.file; | ||
|
||
import org.teavm.jso.JSClass; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSArrayReader; | ||
|
||
@JSClass | ||
public class File extends Blob implements JSObject { | ||
/** | ||
* Actual elements within array are either {@link Blob} or {@link org.teavm.jso.core.JSString} | ||
*/ | ||
public File(JSArrayReader<JSObject> array, String fileName) { | ||
super(null); | ||
} | ||
|
||
/** | ||
* Actual elements within array are either {@link Blob} or {@link org.teavm.jso.core.JSString} | ||
*/ | ||
public File(JSArrayReader<JSObject> array, String fileName, JSObject options) { | ||
super(null, null); | ||
} | ||
|
||
@JSProperty | ||
public native double getLastModified(); | ||
|
||
@JSProperty | ||
public native String getName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2024 ihromant. | ||
* | ||
* 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.file; | ||
|
||
import org.teavm.jso.JSIndexer; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.core.JSArrayReader; | ||
|
||
public interface FileList extends JSObject, JSArrayReader<File> { | ||
@JSIndexer | ||
File item(int index); | ||
} |
48 changes: 48 additions & 0 deletions
48
jso/apis/src/main/java/org/teavm/jso/file/FilePropertyBag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 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.file; | ||
|
||
import org.teavm.jso.JSClass; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSObjects; | ||
|
||
@JSClass(transparent = true) | ||
public class FilePropertyBag extends BlobPropertyBag { | ||
FilePropertyBag() { | ||
} | ||
|
||
public static FilePropertyBag create() { | ||
return JSObjects.create(); | ||
} | ||
|
||
@Override | ||
public FilePropertyBag type(String type) { | ||
return (FilePropertyBag) super.type(type); | ||
} | ||
|
||
@Override | ||
public FilePropertyBag endingType(String endingType) { | ||
return (FilePropertyBag) super.endingType(endingType); | ||
} | ||
|
||
public FilePropertyBag lastModified(long lastModified) { | ||
setLastModified(lastModified); | ||
return this; | ||
} | ||
|
||
@JSProperty | ||
private native void setLastModified(double lastModified); | ||
} |
42 changes: 42 additions & 0 deletions
42
jso/apis/src/main/java/org/teavm/jso/streams/ReadableStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2024 ihromant. | ||
* | ||
* 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.streams; | ||
|
||
import org.teavm.jso.JSClass; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSArrayReader; | ||
import org.teavm.jso.core.JSPromise; | ||
import org.teavm.jso.core.JSUndefined; | ||
|
||
@JSClass | ||
public class ReadableStream implements JSObject { | ||
private ReadableStream() { | ||
} | ||
|
||
@JSProperty | ||
public native boolean isLocked(); | ||
|
||
public native JSPromise<JSUndefined> abort(String reason); | ||
|
||
public native JSPromise<JSUndefined> cancel(); | ||
|
||
public native JSPromise<JSUndefined> cancel(String reason); | ||
|
||
public native JSArrayReader<? extends ReadableStream> tee(); | ||
|
||
public native ReadableStreamDefaultReader getReader(); | ||
} |
Oops, something went wrong.