Bump JavaScriptKit dependency to 0.6.0 (#107)

Handling of the `static.zip` archive has changed slightly, where now the archive no longer has a nested `static` directory in it, which makes packaging slightly more predictable. For some reason passing wildcards to `zip` no longer works for me.
This commit is contained in:
Max Desiatov 2020-09-14 12:36:06 +01:00 committed by GitHub
parent 9c94fd02b1
commit 3478fb082e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 27 deletions

View File

@ -15,11 +15,11 @@
import Foundation
import TSCBasic
extension String {
public extension String {
var isAbsolutePath: Bool { first == "/" }
}
extension FileSystem {
public extension FileSystem {
func traverseRecursively(_ traversalRoot: AbsolutePath) throws -> [AbsolutePath] {
guard exists(traversalRoot, followSymlink: true) else {
return []

View File

@ -17,8 +17,8 @@ import Foundation
import TSCBasic
import TSCUtility
private let compatibleJSKitRevision = "c90e82f"
public let compatibleJSKitVersion = Version(0, 5, 0)
private let compatibleJSKitRevision = "ad1544f"
public let compatibleJSKitVersion = Version(0, 6, 0)
enum ToolchainError: Error, CustomStringConvertible {
case directoryDoesNotExist(AbsolutePath)

View File

@ -52,7 +52,12 @@ struct HashArchive: ParsableCommand {
localFileSystem.readFileContents(AbsolutePath(staticPath, "bundle.js"))
).hexadecimalRepresentation.uppercased()
try ProcessRunner(["zip", "static.zip", "static/*"], terminal).waitUntilFinished()
let archiveSources = try localFileSystem.traverseRecursively(staticPath)
// `traverseRecursively` also returns the `staticPath` directory itself, dropping it here
.dropFirst()
.map(\.pathString)
try ProcessRunner(["zip", "-j", "static.zip"] + archiveSources, terminal).waitUntilFinished()
let archiveHash = try SHA256().hash(
localFileSystem.readFileContents(AbsolutePath(
@ -75,6 +80,7 @@ struct HashArchive: ParsableCommand {
let staticArchiveHash = ByteString([
\(arrayString(from: archiveHash)),
])
"""
try localFileSystem.writeFileContents(

View File

@ -17,8 +17,11 @@ import Foundation
import TSCBasic
import TSCUtility
/** The `static.zip` archive is always uploaded to release assets of a previous release
instead of the forthcoming release, because the corresponding new release tag doesn't exist yet.
*/
private let staticArchiveURL =
"https://github.com/swiftwasm/carton/releases/download/0.5.0/static.zip"
"https://github.com/swiftwasm/carton/releases/download/0.4.1/static.zip"
private let verifyHash = Equality<ByteString, String> {
"""
@ -80,8 +83,10 @@ struct Dependency {
try fileSystem.writeFileContents(archiveFile, bytes: downloadedArchive)
terminal.logLookup("Unpacking the archive: ", archiveFile)
let staticDir = cartonDir.appending(component: "static")
try fileSystem.createDirectory(staticDir)
try await {
ZipArchiver().extract(from: archiveFile, to: cartonDir, completion: $0)
ZipArchiver().extract(from: archiveFile, to: staticDir, completion: $0)
}
}

View File

@ -1,16 +1,16 @@
import TSCBasic
let devDependencySHA256 = ByteString([
0xE5, 0x21, 0x17, 0xB3, 0xA7, 0xDF, 0xFF, 0x9D, 0x48, 0x4F, 0x60, 0x06, 0x74, 0x4F, 0xC1, 0x6D,
0x28, 0x34, 0x23, 0xB4, 0xFD, 0xF0, 0xF8, 0xDC, 0x2C, 0xA2, 0xE4, 0xCF, 0x23, 0x54, 0xB1, 0x81,
0xC8, 0xA8, 0x50, 0x49, 0xFA, 0x10, 0x63, 0x97, 0xAD, 0xC7, 0xB7, 0x5C, 0x48, 0xCA, 0x67, 0xD7,
0xC2, 0x4C, 0x1D, 0x64, 0x41, 0x18, 0x26, 0x46, 0xD3, 0xC3, 0x85, 0xB8, 0x9A, 0x52, 0x3D, 0x47,
])
let bundleDependencySHA256 = ByteString([
0x3C, 0xD9, 0xF6, 0x10, 0x6B, 0x2B, 0xA6, 0x35, 0x87, 0x2D, 0x05, 0x69, 0x21, 0x4D, 0xBB, 0x0F,
0x0E, 0xE6, 0x40, 0x5D, 0x8D, 0xBA, 0x1E, 0x27, 0x53, 0x7B, 0x23, 0x00, 0x3E, 0x65, 0x08, 0x90,
0xF8, 0x52, 0x7A, 0xC1, 0xDA, 0xEE, 0x49, 0x3B, 0x02, 0xF5, 0xA6, 0xE5, 0x8F, 0x38, 0x25, 0xEF,
0x8D, 0xF1, 0xB1, 0x2A, 0xE7, 0x02, 0x9F, 0x8A, 0xED, 0xE5, 0x97, 0xCB, 0xA7, 0xD3, 0x94, 0x39,
])
let staticArchiveHash = ByteString([
0xD5, 0x63, 0xC5, 0x6F, 0x60, 0x60, 0x4C, 0xA5, 0xB3, 0xB1, 0xDC, 0xB5, 0x33, 0x28, 0xFB, 0xB0,
0xA5, 0xF3, 0x1E, 0x91, 0xC9, 0x2D, 0x2E, 0x45, 0x40, 0xFD, 0x33, 0xEA, 0x17, 0xF4, 0x66, 0x06,
0x59, 0x31, 0xC8, 0x55, 0x52, 0x90, 0x17, 0xD3, 0xC6, 0x24, 0xA5, 0xA3, 0x2A, 0x96, 0x26, 0x34,
0xB8, 0x35, 0xB2, 0x1C, 0x12, 0xA6, 0xFE, 0x47, 0x90, 0xA2, 0x8E, 0xF4, 0x94, 0x9D, 0x68, 0x1A,
])

View File

@ -1 +1 @@
wasm-5.3-SNAPSHOT-2020-09-03-a
wasm-5.3-SNAPSHOT-2020-09-08-a

View File

@ -3,11 +3,11 @@
"pins": [
{
"package": "JavaScriptKit",
"repositoryURL": "https://github.com/kateinoigakukun/JavaScriptKit",
"repositoryURL": "https://github.com/swiftwasm/JavaScriptKit",
"state": {
"branch": null,
"revision": "c90e82fe1d576a2ccd1aae798380bf80be7885fb",
"version": "0.5.0"
"revision": "ad1544ff312e31a22d05426320913f24593ce838",
"version": "0.6.0"
}
}
]

View File

@ -9,10 +9,7 @@ let package = Package(
.executable(name: "TestApp", targets: ["TestApp"]),
],
dependencies: [
.package(
url: "https://github.com/kateinoigakukun/JavaScriptKit",
.upToNextMinor(from: "0.5.0")
),
.package(url: "https://github.com/swiftwasm/JavaScriptKit", from: "0.6.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test

View File

@ -17,7 +17,7 @@ import Foundation
import JavaScriptKit
import TestLibrary
let document = JSObjectRef.global.document.object!
let document = JSObject.global.document.object!
let button = document.createElement!("button").object!
button.innerText = .string("Crash!")
@ -33,12 +33,14 @@ func crash() {
}
let buttonNode = document.getElementsByTagName!("button").object![0].object!
buttonNode.onclick = .function { _ in
let handler = JSValue.function { _ in
print(text)
crash()
return .undefined
}
buttonNode.onclick = handler
let div = document.createElement!("div").object!
div.innerHTML = .string(#"""
<a href=\#(Bundle.module.path(forResource: "data", ofType: "json")!)>Link to a static resource</a>

6
package-lock.json generated
View File

@ -2111,9 +2111,9 @@
"dev": true
},
"javascript-kit-swift": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/javascript-kit-swift/-/javascript-kit-swift-0.5.0.tgz",
"integrity": "sha512-1M4dtQVrvPLBZhv/yIpMZHz6wEo9RtijtKHVd+jt7PfmnBK1ZvFRivYXqSA852RWW2YfLw82G1efYHUQZFFLig==",
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/javascript-kit-swift/-/javascript-kit-swift-0.6.0.tgz",
"integrity": "sha512-4AKfGjXa7smMIDlR8JNxPvKdJjd2h1usl/CP4i8UrX5xN6Hy6Fa9Gbu+NP67yXDYAjnvxFaBcieg13T91/k3Og==",
"dev": true
},
"json-parse-better-errors": {

View File

@ -27,7 +27,7 @@
"devDependencies": {
"@wasmer/wasi": "^0.11.2",
"@wasmer/wasmfs": "^0.11.2",
"javascript-kit-swift": "^0.5.0",
"javascript-kit-swift": "^0.6.0",
"reconnecting-websocket": "^4.4.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"