Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
345 changes: 277 additions & 68 deletions dist/j4ts-file.d.ts

Large diffs are not rendered by default.

1,151 changes: 747 additions & 404 deletions dist/j4ts-file.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions jsweetconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"adapters": [
"org.jsweet.transpiler.extension.Java2TypeScriptAdapter"
]
}
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>j4ts-file</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<jsweet.transpiler.version>1.1.1</jsweet.transpiler.version>
<jsweet.transpiler.version>2.0.1</jsweet.transpiler.version>
</properties>
<licenses>
<license>
Expand Down Expand Up @@ -60,7 +60,7 @@
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
<configuration>
<verbose>true</verbose>
<!-- <sourceMap>true</sourceMap> -->
Expand Down Expand Up @@ -149,14 +149,14 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jsweet.candies</groupId>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-core</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jsweet.candies</groupId>
<groupId>org.jsweet</groupId>
<artifactId>j4ts</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.6.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand All @@ -177,4 +177,4 @@
<url>http://www.jsweet.org</url>
</organization>

</project>
</project>
4 changes: 2 additions & 2 deletions src/main/java/java/io/FileInputStream.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package java.io;

import static jsweet.dom.Globals.atob;
import static jsweet.util.Globals.any;
import static def.dom.Globals.atob;
import static jsweet.util.Lang.any;

/**
* JSweet implementation based on a local storage FS.
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/java/io/FileOutputStream.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package java.io;

import static jsweet.dom.Globals.btoa;
import static jsweet.util.Globals.array;
import static def.dom.Globals.btoa;
import static jsweet.util.Lang.array;
import static jsweet.util.Lang.string;

/**
* JSweet partial implementation based on a local storage FS.
Expand Down Expand Up @@ -65,9 +66,9 @@ public void write(byte b[], int off, int len) throws IOException {

@Override
public void flush() throws IOException {
entry.data = btoa(array(array(content).map((b, __, ___) -> {
return jsweet.lang.String.fromCharCode(b);
})).join(""));
entry.data = btoa(string(array(content).map((b, __, ___) -> {
return string(def.js.String.fromCharCode(b));
}).join("")));
LocalStorageFileSystem.fs.putEntry(file.getAbsolutePath(), entry);
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/java/io/FilenameFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package java.io;

@FunctionalInterface
public interface FilenameFilter {
boolean accept(File dir, String name);
}
11 changes: 6 additions & 5 deletions src/main/java/java/io/LocalStorageFileSystem.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package java.io;

import static jsweet.dom.Globals.localStorage;
import static jsweet.util.Globals.array;
import static def.dom.Globals.localStorage;
import static jsweet.util.Lang.array;
import static jsweet.util.Lang.string;

import jsweet.lang.Array;
import def.js.Array;
import jsweet.lang.Interface;
import jsweet.lang.JSON;
import def.js.JSON;

public class LocalStorageFileSystem extends FileSystem {

Expand Down Expand Up @@ -246,7 +247,7 @@ public boolean delete(File f) {
String parentPath = f.getParentFile().getAbsolutePath();
DirectoryEntry directoryEntry = getDirectoryEntry(parentPath);
Array<String> entries = array(directoryEntry.entries);
directoryEntry.entries = entries.splice(entries.indexOf(f.getName()), 1);
directoryEntry.entries = array(entries.splice(entries.indexOf(f.getName()), 1));
putEntry(parentPath, directoryEntry);
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/test/TestFile.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package test;

import static jsweet.dom.Globals.console;
import static jsweet.dom.Globals.document;
import static jsweet.dom.Globals.localStorage;
import static def.dom.Globals.console;
import static def.dom.Globals.document;
import static def.dom.Globals.localStorage;
import static jsweet.util.Lang.$strict;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
Expand All @@ -11,13 +12,12 @@
import java.io.FileWriter;
import java.io.IOException;

import jsweet.dom.HTMLElement;
import jsweet.util.Globals;
import def.dom.HTMLElement;

public class TestFile {

public static void assertEquals(Object o1, Object o2) {
if (!Globals.equalsStrict(o1, o2)) {
if ($strict(o1 != o2)) {
throw new Error("invalid assertion: " + o1 + "!=" + o2);
}
}
Expand Down
Loading