JS: drop support of old library format
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
if (typeof kotlin === 'undefined') {
|
||||
throw new Error("Error loading module 'LibraryExample'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'LibraryExample'.");
|
||||
}
|
||||
var LibraryExample = function (_, Kotlin) {
|
||||
'use strict';
|
||||
function pairAdd(p) {
|
||||
return p.first + p.second | 0;
|
||||
}
|
||||
function pairMul(p) {
|
||||
return Kotlin.imul(p.first, p.second);
|
||||
}
|
||||
function IntHolder(value) {
|
||||
this.value = value;
|
||||
}
|
||||
IntHolder.$metadata$ = {
|
||||
kind: Kotlin.Kind.CLASS,
|
||||
simpleName: 'IntHolder',
|
||||
interfaces: []
|
||||
};
|
||||
IntHolder.prototype.component1 = function () {
|
||||
return this.value;
|
||||
};
|
||||
IntHolder.prototype.copy_za3lpa$ = function (value) {
|
||||
return new IntHolder(value === void 0 ? this.value : value);
|
||||
};
|
||||
IntHolder.prototype.toString = function () {
|
||||
return 'IntHolder(value=' + Kotlin.toString(this.value) + ')';
|
||||
};
|
||||
IntHolder.prototype.hashCode = function () {
|
||||
var result = 0;
|
||||
result = result * 31 + Kotlin.hashCode(this.value) | 0;
|
||||
return result;
|
||||
};
|
||||
IntHolder.prototype.equals = function (other) {
|
||||
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value))));
|
||||
};
|
||||
var package$library = _.library || (_.library = {});
|
||||
var package$sample = package$library.sample || (package$library.sample = {});
|
||||
package$sample.pairAdd_1fzo63$ = pairAdd;
|
||||
package$sample.pairMul_1fzo63$ = pairMul;
|
||||
package$sample.IntHolder = IntHolder;
|
||||
Kotlin.defineModule('LibraryExample', _);
|
||||
return _;
|
||||
}(typeof LibraryExample === 'undefined' ? {} : LibraryExample, kotlin);
|
||||
@@ -0,0 +1 @@
|
||||
// Kotlin.kotlin_module_metadata(1, "LibraryExample", "H4sIAAAAAAAAAJV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79MdnbFzMkMbEJ8LnyIQeCzJK6g1U/wOSAB0W3QkAAA==");
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
# jslib
|
||||
|
||||
Path to sources: `compiler/testData/cli/js/jslib`
|
||||
|
||||
`folderAsLib/LibraryExample.js`, `folderAsLib/LibraryExample.meta.js` and `LibraryExample.jar` should be updated after changing some files in source folder.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
$TESTDATA_DIR$/withLib.kt
|
||||
-libraries
|
||||
compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib
|
||||
compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
warning: 'compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib' is not a valid Kotlin Javascript library
|
||||
warning: 'compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib' is not a valid Kotlin Javascript library
|
||||
compiler/testData/cli/js/withLib.kt:2:8: error: unresolved reference: library
|
||||
import library.sample.*
|
||||
^
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
$TESTDATA_DIR$/withLib.kt
|
||||
-libraries
|
||||
compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example
|
||||
$TESTDATA_DIR$/folderAsLib
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
$TESTDATA_DIR$/withLib.kt
|
||||
-libraries
|
||||
compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar
|
||||
$TESTDATA_DIR$/lib/LibraryExample.jar
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
|
||||
[unzip] Expanding: [TestData]/jslib-example.jar into [Temp]
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -1,17 +0,0 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
<property name="library.path" value="${test.data}/jslib-example.jar"/>
|
||||
<target name="build">
|
||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call">
|
||||
<libraries>
|
||||
<pathelement path="${library.path}"/>
|
||||
</libraries>
|
||||
</kotlin2js>
|
||||
<unzip src="${library.path}" dest="${temp}">
|
||||
<patternset>
|
||||
<include name="*.js"/>
|
||||
<exclude name="META-INF/**"/>
|
||||
</patternset>
|
||||
</unzip>
|
||||
</target>
|
||||
</project>
|
||||
BIN
Binary file not shown.
-14
@@ -1,14 +0,0 @@
|
||||
package foo
|
||||
|
||||
import library.sample.*
|
||||
|
||||
var ok = "FAIL"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val p = Pair(10, 20)
|
||||
val x = pairAdd(p)
|
||||
ok = "OK"
|
||||
println("x=$x")
|
||||
}
|
||||
|
||||
fun box(): String = ok
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
|
||||
[copy] Copying 1 file to [Temp]
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
<property name="library.path" value="${test.data}/jslib-example"/>
|
||||
<target name="build">
|
||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call">
|
||||
<libraries>
|
||||
<pathelement path="${library.path}"/>
|
||||
</libraries>
|
||||
</kotlin2js>
|
||||
<copy todir="${temp}">
|
||||
<fileset dir="${library.path}">
|
||||
<include name="**/*.js"/>
|
||||
<exclude name="META-INF/**"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</project>
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Ant-Version: Apache Ant 1.9.1
|
||||
Created-By: 1.7.0_72-b14 (Oracle Corporation)
|
||||
Built-By: JetBrains
|
||||
Implementation-Vendor: JetBrains
|
||||
Implementation-Version: snapshot
|
||||
Specification-Title: Kotlin JavaScript Lib
|
||||
Kotlin-JS-Module-Name: jslib-example
|
||||
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
# jslib-example
|
||||
|
||||
Path to sources: compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example
|
||||
|
||||
The archive compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar should be updated after
|
||||
changing some files in source folder.
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
this['jslib-example'] = function (Kotlin) {
|
||||
'use strict';
|
||||
var _ = Kotlin.defineRootPackage(null, /** @lends _ */ {
|
||||
library: Kotlin.definePackage(null, /** @lends _.library */ {
|
||||
sample: Kotlin.definePackage(null, /** @lends _.library.sample */ {
|
||||
pairAdd_bunuun$: function (p) {
|
||||
return p.first + p.second;
|
||||
},
|
||||
pairMul_bunuun$: function (p) {
|
||||
return p.first * p.second;
|
||||
},
|
||||
IntHolder: Kotlin.createClass(null, function (value) {
|
||||
this.value = value;
|
||||
}, /** @lends _.library.sample.IntHolder.prototype */ {
|
||||
component1: function () {
|
||||
return this.value;
|
||||
},
|
||||
copy_za3lpa$: function (value) {
|
||||
return new _.library.sample.IntHolder(value === void 0 ? this.value : value);
|
||||
},
|
||||
toString: function () {
|
||||
return 'IntHolder(value=' + Kotlin.toString(this.value) + ')';
|
||||
},
|
||||
hashCode: function () {
|
||||
var result = 0;
|
||||
result = result * 31 + Kotlin.hashCode(this.value) | 0;
|
||||
return result;
|
||||
},
|
||||
equals_za3rmp$: function (other) {
|
||||
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value))));
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
Kotlin.defineModule('jslib-example', _);
|
||||
return _;
|
||||
}(kotlin);
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package foo
|
||||
|
||||
import library.sample.*
|
||||
|
||||
var ok = "FAIL"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val p = Pair(10, 20)
|
||||
val x = pairAdd(p)
|
||||
ok = "OK"
|
||||
println("x=$x")
|
||||
}
|
||||
|
||||
fun box(): String = ok
|
||||
@@ -27,17 +27,13 @@ import java.util.jar.Manifest
|
||||
object LibraryUtils {
|
||||
private val LOG = Logger.getInstance(LibraryUtils::class.java)
|
||||
|
||||
val KOTLIN_JS_MODULE_NAME: String = "Kotlin-JS-Module-Name"
|
||||
private var TITLE_KOTLIN_JAVASCRIPT_STDLIB: String
|
||||
private var TITLE_KOTLIN_JAVASCRIPT_LIB: String
|
||||
|
||||
val META_INF = "META-INF/"
|
||||
private val MANIFEST_PATH = "${META_INF}MANIFEST.MF"
|
||||
private val KOTLIN_JS_MODULE_ATTRIBUTE_NAME = Attributes.Name(KOTLIN_JS_MODULE_NAME)
|
||||
|
||||
init {
|
||||
var jsStdLib = ""
|
||||
var jsLib = ""
|
||||
|
||||
val manifestProperties = LibraryUtils::class.java.getResourceAsStream("/kotlinManifest.properties")
|
||||
if (manifestProperties != null) {
|
||||
@@ -45,7 +41,6 @@ object LibraryUtils {
|
||||
val properties = Properties()
|
||||
properties.load(manifestProperties)
|
||||
jsStdLib = properties.getPropertyOrFail("manifest.impl.title.kotlin.javascript.stdlib")
|
||||
jsLib = properties.getPropertyOrFail("manifest.spec.title.kotlin.javascript.lib")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
LOG.error(e)
|
||||
@@ -57,27 +52,14 @@ object LibraryUtils {
|
||||
}
|
||||
|
||||
TITLE_KOTLIN_JAVASCRIPT_STDLIB = jsStdLib
|
||||
TITLE_KOTLIN_JAVASCRIPT_LIB = jsLib
|
||||
}
|
||||
|
||||
@JvmStatic fun getJarFile(classesRoots: List<VirtualFile>, jarName: String): VirtualFile? {
|
||||
return classesRoots.firstOrNull { it.name == jarName }
|
||||
}
|
||||
|
||||
@JvmStatic fun getKotlinJsModuleName(library: File): String? {
|
||||
return getManifestMainAttributesFromJarOrDirectory(library)?.getValue(KOTLIN_JS_MODULE_ATTRIBUTE_NAME)
|
||||
}
|
||||
|
||||
@JvmStatic fun isOldKotlinJavascriptLibrary(library: File): Boolean =
|
||||
checkAttributeValue(library, TITLE_KOTLIN_JAVASCRIPT_LIB, Attributes.Name.SPECIFICATION_TITLE) &&
|
||||
getKotlinJsModuleName(library) != null
|
||||
|
||||
@JvmStatic fun isKotlinJavascriptLibraryWithMetadata(library: File): Boolean =
|
||||
KotlinJavascriptMetadataUtils.loadMetadata(library).isNotEmpty()
|
||||
|
||||
@Suppress("unused") // used in K2JSCompilerMojo
|
||||
@JvmStatic fun isKotlinJavascriptLibrary(library: File): Boolean =
|
||||
isOldKotlinJavascriptLibrary(library) || isKotlinJavascriptLibraryWithMetadata(library)
|
||||
@JvmStatic fun isKotlinJavascriptLibrary(library: File): Boolean = KotlinJavascriptMetadataUtils.loadMetadata(library).isNotEmpty()
|
||||
|
||||
@JvmStatic fun isKotlinJavascriptStdLibrary(library: File): Boolean {
|
||||
return checkAttributeValue(library, TITLE_KOTLIN_JAVASCRIPT_STDLIB, Attributes.Name.IMPLEMENTATION_TITLE)
|
||||
|
||||
Reference in New Issue
Block a user