Skip to content

Conversation

@xeioex
Copy link
Contributor

@xeioex xeioex commented Dec 17, 2025

No description provided.

This introduces ngx_js_merge_conftime_loc_conf() to handle merging
of configuration-time properties.

Normally ngx_js_merge_conf() does all the default value initialization
for child location configurations.

There is a special case for global "http" or "stream" configuration
where the parent configuration needs to be initialized (so it can be
reused by server configurations if no additional directives were
defined in them). But parent configurations are not initialized by
ngx_js_merge_conf().

Most of the ngx_js_loc_conf_t values are only used at runtime, so
only configuration-time values need to be merged in the parent.
The runtime values will be provided from the appropriate
ngx_js_loc_conf_t during request processing.

Previously, configuration-time merging was done inline. Extracting
it into a dedicated function simplifies adding new configuration-time
properties.
Added "js_load_http_native_module" and "js_load_stream_native_module"
main nginx.conf level directives. The directives load a dynamic
library. For security reason it is only allowed in the main context.
Later, JS code may import modules loaded with these directives
with standard import syntax.

example.conf:
    ...
    js_load_http_native_module /path/to/lib.so;
    js_load_http_native_module /path/to/lib2.so as lib2;

    http {
        js_import main.js;
	...

main.js:
    import * as lib from 'lib.so';
    import * as lib2 from 'lib2';
    ...

See quickjs.h for the complete QuickJS API reference and
nginx/t/js_native_module.t for a working example.

This closes nginx#968 feature request on Github.
Also added
- ArrayBuffer.prototype.resize()
- ArrayBuffer.prototype.resizeable
- ArrayBuffer.prototype.maxByteLength
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant