Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quickjs for quickjs #137

Merged
merged 25 commits into from
Sep 7, 2024
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.31.0

- [#137](https://github.com/justjake/quickjs-emscripten/pull/137)
- Add `quickjs-for-quickjs`, a package that can run inside quickjs, so you can put quickjs inside your quickjs.
- **Possibly breaking**: Fix a build system bug that made commonjs or esm variants include both types, thus being larger than they needed to be. After upgrading a variant to this release, you should verify that it can be imported/required as expected. You may need to add additional variants if you were using an "esm" variant from both cjs and esm.

## v0.30.0

- [#200](https://github.com/justjake/quickjs-emscripten/pull/200) Inspect and iterate handles, equality, changes to result types, changes to debug logging.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ compiled to WebAssembly.
- Create and manipulate values inside the QuickJS runtime ([more][values]).
- Expose host functions to the QuickJS runtime ([more][functions]).
- Execute synchronous code that uses asynchronous functions, with [asyncify][asyncify].
- Supports browsers, NodeJS, Deno, Bun, Cloudflare Workers, QuickJS (via [quickjs-for-quickjs][]).

[Github] | [NPM] | [API Documentation][api] | [Variants][core] | [Examples][tests]

Expand Down Expand Up @@ -43,6 +44,7 @@ main()
[values]: #interfacing-with-the-interpreter
[asyncify]: #asyncify
[functions]: #exposing-apis
[quickjs-for-quickjs]: https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-for-quickjs

- [quickjs-emscripten](#quickjs-emscripten)
- [Usage](#usage)
Expand Down
2 changes: 2 additions & 0 deletions c/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,8 @@ MaybeAsync(JSBorrowedChar *) QTS_Dump(JSContext *ctx, JSValueConst *obj) {
copy_prop_if_needed(ctx, enumerable_props, *obj, "name");
copy_prop_if_needed(ctx, enumerable_props, *obj, "message");
copy_prop_if_needed(ctx, enumerable_props, *obj, "stack");
copy_prop_if_needed(ctx, enumerable_props, *obj, "fileName");
copy_prop_if_needed(ctx, enumerable_props, *obj, "lineNumber");

// Serialize again.
JSValue enumerable_json = JS_JSONStringify(ctx, enumerable_props, JS_UNDEFINED, JS_UNDEFINED);
Expand Down
89 changes: 89 additions & 0 deletions doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[quickjs-emscripten](../../packages.md) • **@jitl/quickjs-asmjs-mjs-release-sync** • [Readme](README.md) \| [Exports](exports.md)

***

# @jitl/quickjs-asmjs-mjs-release-sync

Compiled to pure Javascript, no WebAssembly required.

This generated package is part of [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten).
It contains a variant of the quickjs WASM library, and can be used with quickjs-emscripten-core.

```typescript
import variant from "@jitl/quickjs-asmjs-mjs-release-sync"
import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core"
const QuickJS = await newQuickJSWASMModuleFromVariant(variant)
```

This variant was built with the following settings:

## Contents

- [Library: quickjs](README.md#library-quickjs)
- [Release mode: release](README.md#release-mode-release)
- [Exports: import](README.md#exports-import)
- [Extra async magic? No](README.md#extra-async-magic-no)
- [Single-file, or separate .wasm file? asmjs](README.md#single-file-or-separate-wasm-file-asmjs)
- [More details](README.md#more-details)

## Library: quickjs

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.

## Release mode: release

Optimized for performance; use when building/deploying your application.

## Exports: import

Exports the following in package.json for the package entrypoint:

- Exports a NodeJS-compatible ESModule. Cannot be imported synchronously from a NodeJS CommonJS module.

## Extra async magic? No

The default, normal build. Note that both variants support regular async functions.

## Single-file, or separate .wasm file? asmjs

The C library code is compiled to Javascript, no WebAssembly used. Sometimes called "asmjs". This is the slowest possible option, and is intended for constrained environments that do not support WebAssembly, like quickjs-for-quickjs.

## More details

Full variant JSON description:

```json
{
"library": "quickjs",
"releaseMode": "release",
"syncMode": "sync",
"description": "Compiled to pure Javascript, no WebAssembly required.",
"emscriptenInclusion": "asmjs",
"exports": {
"import": {
"emscriptenEnvironment": ["web", "worker", "node"]
}
}
}
```

Variant-specific Emscripten build flags:

```json
[
"-Oz",
"-flto",
"--closure 1",
"-s FILESYSTEM=0",
"--pre-js $(TEMPLATES)/pre-extension.js",
"--pre-js $(TEMPLATES)/pre-wasmMemory.js",
"-s WASM=0",
"-s SINGLE_FILE=1"
]
```

***

Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/)
40 changes: 40 additions & 0 deletions doc/@jitl/quickjs-asmjs-mjs-release-sync/exports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[quickjs-emscripten](../../packages.md) • **@jitl/quickjs-asmjs-mjs-release-sync** • [Readme](README.md) \| [Exports](exports.md)

***

[quickjs-emscripten](../../packages.md) / @jitl/quickjs-asmjs-mjs-release-sync

# @jitl/quickjs-asmjs-mjs-release-sync

## Contents

- [Variables](exports.md#variables)
- [default](exports.md#default)
- [@jitl/quickjs-asmjs-mjs-release-sync](exports.md#jitlquickjs-asmjs-mjs-release-sync)

## Variables

### default

> **`const`** **default**: [`QuickJSSyncVariant`](../../quickjs-emscripten/interfaces/QuickJSSyncVariant.md)

### @jitl/quickjs-asmjs-mjs-release-sync

[Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) |
Compiled to pure Javascript, no WebAssembly required.

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | asmjs | The C library code is compiled to Javascript, no WebAssembly used. Sometimes called "asmjs". This is the slowest possible option, and is intended for constrained environments that do not support WebAssembly, like quickjs-for-quickjs. |
| exports | import | Has these package.json export conditions |

#### Source

[index.ts:19](https://github.com/justjake/quickjs-emscripten/blob/main/packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts#L19)

***

Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/)
2 changes: 2 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ compiled to WebAssembly.
- Create and manipulate values inside the QuickJS runtime ([more][values]).
- Expose host functions to the QuickJS runtime ([more][functions]).
- Execute synchronous code that uses asynchronous functions, with [asyncify][asyncify].
- Supports browsers, NodeJS, Deno, Bun, Cloudflare Workers, QuickJS (via [quickjs-for-quickjs][]).

[Github] | [NPM] | [API Documentation][api] | [Variants][core] | [Examples][tests]

Expand Down Expand Up @@ -47,6 +48,7 @@ main()
[values]: #interfacing-with-the-interpreter
[asyncify]: #asyncify
[functions]: #exposing-apis
[quickjs-for-quickjs]: https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-for-quickjs

- [quickjs-emscripten](#quickjs-emscripten)
- [Usage](#usage)
Expand Down
1 change: 1 addition & 0 deletions doc/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [@jitl/quickjs-singlefile-browser-debug-asyncify](@jitl/quickjs-singlefile-browser-debug-asyncify/README.md)
- [@jitl/quickjs-singlefile-browser-release-sync](@jitl/quickjs-singlefile-browser-release-sync/README.md)
- [@jitl/quickjs-singlefile-browser-release-asyncify](@jitl/quickjs-singlefile-browser-release-asyncify/README.md)
- [@jitl/quickjs-asmjs-mjs-release-sync](@jitl/quickjs-asmjs-mjs-release-sync/README.md)

***

Expand Down
14 changes: 14 additions & 0 deletions doc/quickjs-emscripten-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const QuickJS = await newQuickJSWASMModuleFromVariant(releaseVariant)
- [@jitl/quickjs-singlefile-browser-debug-asyncify](README.md#jitlquickjs-singlefile-browser-debug-asyncify)
- [@jitl/quickjs-singlefile-browser-release-sync](README.md#jitlquickjs-singlefile-browser-release-sync)
- [@jitl/quickjs-singlefile-browser-release-asyncify](README.md#jitlquickjs-singlefile-browser-release-asyncify)
- [@jitl/quickjs-asmjs-mjs-release-sync](README.md#jitlquickjs-asmjs-mjs-release-sync)

## What's a variant?

Expand Down Expand Up @@ -357,6 +358,19 @@ Variant with the WASM data embedded into a browser ESModule.
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
| exports | browser | Has these package.json export conditions |

### @jitl/quickjs-asmjs-mjs-release-sync

[Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) |
Compiled to pure Javascript, no WebAssembly required.

| Variable | Setting | Description |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | asmjs | The C library code is compiled to Javascript, no WebAssembly used. Sometimes called "asmjs". This is the slowest possible option, and is intended for constrained environments that do not support WebAssembly, like quickjs-for-quickjs. |
| exports | import | Has these package.json export conditions |

***

Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/)
18 changes: 9 additions & 9 deletions doc/quickjs-emscripten-core/classes/DisposableFail.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:426](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L426)
[packages/quickjs-emscripten-core/src/lifetime.ts:451](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L451)

## Properties

Expand All @@ -65,7 +65,7 @@

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427)
[packages/quickjs-emscripten-core/src/lifetime.ts:452](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L452)

## Accessors

Expand All @@ -79,7 +79,7 @@

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:433](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L433)
[packages/quickjs-emscripten-core/src/lifetime.ts:458](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L458)

## Methods

Expand Down Expand Up @@ -117,7 +117,7 @@ Just calls the standard .dispose() method of this class.

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:437](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L437)
[packages/quickjs-emscripten-core/src/lifetime.ts:462](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L462)

***

Expand All @@ -131,7 +131,7 @@ Just calls the standard .dispose() method of this class.

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:443](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L443)
[packages/quickjs-emscripten-core/src/lifetime.ts:468](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L468)

***

Expand All @@ -153,7 +153,7 @@ Just calls the standard .dispose() method of this class.

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:448](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L448)
[packages/quickjs-emscripten-core/src/lifetime.ts:473](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L473)

***

Expand Down Expand Up @@ -183,7 +183,7 @@ Just calls the standard .dispose() method of this class.

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:384](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L384)
[packages/quickjs-emscripten-core/src/lifetime.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L409)

***

Expand Down Expand Up @@ -211,7 +211,7 @@ Just calls the standard .dispose() method of this class.

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:391](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L391)
[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416)

***

Expand Down Expand Up @@ -239,7 +239,7 @@ Just calls the standard .dispose() method of this class.

#### Source

[packages/quickjs-emscripten-core/src/lifetime.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L380)
[packages/quickjs-emscripten-core/src/lifetime.ts:405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L405)

***

Expand Down
Loading
Loading