Comments (5)
I think this would be best done as a separate tool (maybe written in TS?) so that it could be easily integrated into a webpack/esbuild/etc dev server. Then if there’s a carton dev
command elsewhere, it could pick up the updated Swift bindings using the standard watch mode.
from carton.
Also, from my experience, the TypeScript compiler API provides a ton of functionality in terms of extracting details about types, but it is totally undocumented. Here’s some code I wrote in 2019 that could be a good starting point: https://github.com/denoland/registry/blob/5ec3aa9d853923cf36c19a3d9b58795589cc0ca4/src/analyze_code.js
from carton.
Is there any indication for how stable this API is? One concern could be that it's unstable if it's undocumented, and this quite probably will cause us headaches in the future due to potential breakages.
from carton.
It seems fairly stable, judging based on the log of breaking changes: https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes
from carton.
In terms of DX, my first thought is that you would provide a list of .ts
/.d.ts
files as input, and each would be turned into its own Swift module. That way users could make a file that simply re-exports all of the types they want to use in Swift (although we’d need to pick up dependencies somehow). Some things to think about:
- classes.
WebAPIKit
only works because all of the relevant class constructors are on the global. We’d need to have some sort of glue code to make non-global classes available to Swift - interfaces. TypeScript uses duck typing, which would be slow for Swift to verify. But if our users are willing to trust TypeScript, I guess we could just wrap any
JSObject
without doing type checks. - unions, especially between interfaces. The standard practice in TS is to use a “discriminated union” (i.e. one key like
type
tells you which case of the union a given object is). I don’t know if the TS API gives us enough information to auto-generate discriminators, but either way this will be both non-trivial and super important to get right if we want to let people access arbitrary TS code. - Currently,
WebAPIKit
only supports attaching functions to global classes. How could we most ergonomically support users providing their own imported functions (without them having to deal with manually encodingJSValue
s)?
from carton.
Related Issues (20)
- Publish `carton` as npm package HOT 4
- `carton dev` stops rebuilding/reloading after error
- Pick up `index.html` from resources of the main target in `Package.swift`
- Re-read supplied `index.html` on updates
- Update `carton init` template to allow `carton test` without modification HOT 1
- Add `carton shell` command making SwiftWasm toolchain the default in forked shell
- `carton test` should fail if crashing during `_initialize`
- Fatal Error HOT 9
- `brew install swiftwasm/tap/carton` installs old version HOT 4
- compiler error, [-Wimplicit-function-declaration] HOT 5
- Docker not working HOT 1
- Support Ubuntu 22.04 LTS for toolchain downloader
- Error: Invalid version on Ubuntu 22.04 HOT 4
- ProcessInfo is empty when invoking `carton test` HOT 4
- Mismatched Swift Versions HOT 2
- Customize watcher directory
- Xcode 15 breaks `carton` build process HOT 4
- Missing `swift`- prefix from SDKs HOT 1
- Facing swift compiler version issue on` /root/.carton/sdk/wasm-5.7.1-RELEASE/usr/bin/swift` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carton.