Skip to content

Commit f3d9234

Browse files
xeioexy82
authored andcommitted
Documented the "js_engine" directive.
1 parent d1cd405 commit f3d9234

File tree

10 files changed

+276
-6
lines changed

10 files changed

+276
-6
lines changed

xml/en/GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ REFS = \
139139
njs/changes \
140140
njs/cli \
141141
njs/compatibility \
142+
njs/engine \
142143
njs/install \
143144
njs/preload_objects \
144145
njs/reference \

xml/en/docs/http/ngx_http_js_module.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<module name="Module ngx_http_js_module"
1010
link="/en/docs/http/ngx_http_js_module.html"
1111
lang="en"
12-
rev="48">
12+
rev="49">
1313

1414
<section id="summary">
1515

@@ -262,6 +262,24 @@ since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
262262
</directive>
263263

264264

265+
<directive name="js_engine">
266+
<syntax><literal>njs</literal> | <literal>qjs</literal></syntax>
267+
<default>njs</default>
268+
<context>http</context>
269+
<context>server</context>
270+
<context>location</context>
271+
<appeared-in>0.8.6</appeared-in>
272+
273+
<para>
274+
Sets a <link doc="../njs/engine.xml">JavaScript engine</link>
275+
to be used for njs scripts.
276+
The <literal>njs</literal> parameter sets the njs engine, also used by default.
277+
The <literal>qjs</literal> parameter sets the QuickJS engine.
278+
</para>
279+
280+
</directive>
281+
282+
265283
<directive name="js_fetch_buffer_size">
266284
<syntax><value>size</value></syntax>
267285
<default>16k</default>

xml/en/docs/njs/engine.xml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0"?>
2+
3+
<!--
4+
Copyright (C) Nginx, Inc.
5+
-->
6+
7+
<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8+
9+
<article name="JavaScript Engine"
10+
link="/en/docs/njs/engine.html"
11+
lang="en"
12+
rev="1"
13+
toc="no">
14+
15+
<section>
16+
17+
<para>
18+
Starting from version <link doc="changes.xml" id="njs0.8.6">0.8.6</link>,
19+
multiple JavaScript engines are supported.
20+
To specify a particular engine, use the <literal>js_engine</literal> directive
21+
available for both the
22+
<link doc="../http/ngx_http_js_module.xml" id="js_engine">http</link>
23+
and
24+
<link doc="../stream/ngx_stream_js_module.xml" id="js_engine">stream</link>.
25+
By default, the njs engine is used.
26+
</para>
27+
28+
</section>
29+
30+
31+
<section id="njs_engine" name="njs engine">
32+
33+
<para>
34+
njs is an embeddable JavaScript engine
35+
developed as a part of the njs module.
36+
See the <link doc="compatibility.xml">Сompatibility</link> section for details.
37+
</para>
38+
39+
</section>
40+
41+
42+
<section id="quickjs_engine" name="QuickJS engine">
43+
44+
<para>
45+
<link url="https://bellard.org/quickjs/">QuickJS</link> is a lightweight,
46+
embeddable JavaScript engine that supports
47+
the <link url="https://tc39.es/ecma262/2023/">ES2023</link> specification,
48+
including features as modules, asynchronous generators, proxies and BigInt.
49+
</para>
50+
51+
<para>
52+
Since version <link doc="changes.xml" id="njs0.8.6">0.8.6</link>,
53+
a drop-in replacement for
54+
<link doc="reference.xml">njs/nginx objects</link>
55+
has been introduced
56+
to ensure compatibility with the njs engine, with the following exceptions:
57+
58+
<list type="bullet">
59+
60+
<listitem>
61+
nginx modules API:
62+
<link doc="reference.xml" id="ngx_fetch"><literal>ngx.fetch()</literal></link>,
63+
<link doc="reference.xml" id="dict"><literal>ngx.shared.dict</literal></link>.
64+
</listitem>
65+
66+
<listitem>
67+
Built-in modules:
68+
<link doc="reference.xml" id="njs_api_fs"><literal>fs</literal></link>,
69+
<link doc="reference.xml" id="crypto"><literal>crypto</literal></link>,
70+
<link doc="reference.xml" id="builtin_crypto"><literal>WebCrypto</literal></link>,
71+
<link doc="reference.xml" id="xml"><literal>xml</literal></link>.
72+
</listitem>
73+
74+
<listitem>
75+
njs-specific API:
76+
<link doc="reference.xml" id="njs_dump"><literal>njs.dump()</literal></link>,
77+
<link doc="reference.xml" id="njs_on"><literal>njs.on</literal></link>,
78+
<literal>console.dump()</literal>.
79+
</listitem>
80+
81+
<listitem>
82+
<literal>js_preload_object</literal> directive for
83+
<link doc="../http/ngx_http_js_module.xml" id="js_preload_object">http</link>
84+
and
85+
<link doc="../stream/ngx_stream_js_module.xml" id="js_preload_object">stream</link>.
86+
</listitem>
87+
88+
</list>
89+
90+
</para>
91+
92+
</section>
93+
94+
</article>

xml/en/docs/njs/index.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<article name="njs scripting language"
1010
link="/en/docs/njs/index.html"
1111
lang="en"
12-
rev="34"
12+
rev="35"
1313
toc="no">
1414

1515
<section id="summary">
@@ -45,6 +45,10 @@ The compliance is still <link doc="compatibility.xml">evolving</link>.
4545
<link doc="reference.xml"/>
4646
</listitem>
4747

48+
<listitem>
49+
<link doc="engine.xml"/>
50+
</listitem>
51+
4852
<listitem>
4953
<link url="https://github.com/nginx/njs-examples/">Examples</link>
5054
</listitem>

xml/en/docs/stream/ngx_stream_js_module.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<module name="Module ngx_stream_js_module"
1010
link="/en/docs/stream/ngx_stream_js_module.html"
1111
lang="en"
12-
rev="46">
12+
rev="47">
1313

1414
<section id="summary">
1515

@@ -176,6 +176,23 @@ callbacks are dropped.
176176
</directive>
177177

178178

179+
<directive name="js_engine">
180+
<syntax><literal>njs</literal> | <literal>qjs</literal></syntax>
181+
<default>njs</default>
182+
<context>stream</context>
183+
<context>server</context>
184+
<appeared-in>0.8.6</appeared-in>
185+
186+
<para>
187+
Sets a <link doc="../njs/engine.xml">JavaScript engine</link>
188+
to be used for njs scripts.
189+
The <literal>njs</literal> parameter sets the njs engine, also used by default.
190+
The <literal>qjs</literal> parameter sets the QuickJS engine.
191+
</para>
192+
193+
</directive>
194+
195+
179196
<directive name="js_fetch_buffer_size">
180197
<syntax><value>size</value></syntax>
181198
<default>16k</default>

xml/ru/GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ REFS = \
120120
njs/index \
121121
njs/cli \
122122
njs/compatibility \
123+
njs/engine \
123124
njs/install \
124125
njs/node_modules \
125126
njs/preload_objects \

xml/ru/docs/http/ngx_http_js_module.xml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<module name="Модуль ngx_http_js_module"
1010
link="/ru/docs/http/ngx_http_js_module.html"
1111
lang="ru"
12-
rev="48">
12+
rev="49">
1313

1414
<section id="summary">
1515

@@ -262,6 +262,25 @@ function filter(r, data, flags) {
262262
</directive>
263263

264264

265+
<directive name="js_engine">
266+
<syntax><literal>njs</literal> | <literal>qjs</literal></syntax>
267+
<default>njs</default>
268+
<context>http</context>
269+
<context>server</context>
270+
<context>location</context>
271+
<appeared-in>0.8.6</appeared-in>
272+
273+
<para>
274+
Задаёт <link doc="../njs/engine.xml">движок JavaScript</link>
275+
для использования в сценариях njs.
276+
Параметр <literal>njs</literal> задаёт использование движка njs,
277+
также используемого по умолчанию.
278+
Параметр <literal>qjs</literal> задаёт использование движка QuickJS.
279+
</para>
280+
281+
</directive>
282+
283+
265284
<directive name="js_fetch_buffer_size">
266285
<syntax><value>размер</value></syntax>
267286
<default>16k</default>

xml/ru/docs/njs/engine.xml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0"?>
2+
3+
<!--
4+
Copyright (C) Nginx, Inc.
5+
-->
6+
7+
<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8+
9+
<article name="Движок JavaScript"
10+
link="/ru/docs/njs/engine.html"
11+
lang="ru"
12+
rev="1"
13+
toc="no">
14+
15+
<section>
16+
17+
<para>
18+
Начиная с версии <link doc="../njs/changes.xml" id="njs0.8.6">0.8.6</link>
19+
поддерживается несколько JS-движков.
20+
Для выбора движка используется директива <literal>js_engine</literal>
21+
в
22+
<link doc="../http/ngx_http_js_module.xml" id="js_engine">http</link>
23+
и
24+
<link doc="../stream/ngx_stream_js_module.xml" id="js_engine">stream</link>.
25+
По умолчанию используется движок njs.
26+
</para>
27+
28+
</section>
29+
30+
31+
<section id="njs_engine" name="Движок njs">
32+
33+
<para>
34+
njs &mdash; встроенный движок JavaScript,
35+
разработанный как часть модуля njs.
36+
Подробнее см. в разделе <link doc="compatibility.xml">Совместимость</link>.
37+
</para>
38+
39+
</section>
40+
41+
42+
<section id="quickjs_engine" name="Движок QuickJS">
43+
44+
<para>
45+
<link url="https://bellard.org/quickjs/">QuickJS</link> &mdash; компактный
46+
встроенный движок JavaScript, который поддерживает
47+
спецификацию <link url="https://tc39.es/ecma262/2023/">ES2023</link>,
48+
включая модули, асинхронные генераторы, прокси и BigInt.
49+
</para>
50+
51+
<para>
52+
Начиная с <link doc="changes.xml" id="njs0.8.6">0.8.6</link>
53+
доступна
54+
оперативная замена
55+
<link doc="reference.xml">njs/nginx objects</link>
56+
для обеспечения совместимости с движком njs, но с некоторыми исключениями:
57+
58+
<list type="bullet">
59+
60+
<listitem>
61+
API nginx-модулей:
62+
<link doc="reference.xml" id="ngx_fetch"><literal>ngx.fetch()</literal></link>,
63+
<link doc="reference.xml" id="dict"><literal>ngx.shared.dict</literal></link>.
64+
</listitem>
65+
66+
<listitem>
67+
встроенные модули:
68+
<link doc="reference.xml" id="njs_api_fs"><literal>fs</literal></link>,
69+
<link doc="reference.xml" id="crypto"><literal>crypto</literal></link>,
70+
<link doc="reference.xml" id="builtin_crypto"><literal>WebCrypto</literal></link>,
71+
<link doc="reference.xml" id="xml"><literal>xml</literal></link>.
72+
</listitem>
73+
74+
<listitem>
75+
API njs:
76+
<link doc="reference.xml" id="njs_dump"><literal>njs.dump()</literal></link>,
77+
<link doc="reference.xml" id="njs_on"><literal>njs.on</literal></link>,
78+
<literal>console.dump()</literal>.
79+
</listitem>
80+
81+
<listitem>
82+
директива <literal>js_preload_object</literal> для
83+
<link doc="../http/ngx_http_js_module.xml" id="js_preload_object">http</link>
84+
и
85+
<link doc="../stream/ngx_stream_js_module.xml" id="js_preload_object">stream</link>.
86+
</listitem>
87+
88+
</list>
89+
90+
</para>
91+
92+
</section>
93+
94+
</article>

xml/ru/docs/njs/index.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<article name="Сценарный язык njs"
1010
link="/ru/docs/njs/index.html"
1111
lang="ru"
12-
rev="34"
12+
rev="35"
1313
toc="no">
1414

1515
<section id="summary">
@@ -45,6 +45,10 @@ njs совместим с
4545
<link doc="reference.xml"/>
4646
</listitem>
4747

48+
<listitem>
49+
<link doc="engine.xml"/>
50+
</listitem>
51+
4852
<listitem>
4953
<link url="https://github.com/nginx/njs-examples/">Примеры использования</link>
5054
</listitem>

xml/ru/docs/stream/ngx_stream_js_module.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<module name="Модуль ngx_stream_js_module"
1010
link="/ru/docs/stream/ngx_stream_js_module.html"
1111
lang="ru"
12-
rev="46">
12+
rev="47">
1313

1414
<section id="summary">
1515

@@ -175,6 +175,24 @@ export default {bar, preread, req_line, header_inject, access};
175175
</directive>
176176

177177

178+
<directive name="js_engine">
179+
<syntax><literal>njs</literal> | <literal>qjs</literal></syntax>
180+
<default>njs</default>
181+
<context>stream</context>
182+
<context>server</context>
183+
<appeared-in>0.8.6</appeared-in>
184+
185+
<para>
186+
Задаёт <link doc="../njs/engine.xml">движок JavaScript</link>
187+
для использования в сценариях njs.
188+
Параметр <literal>njs</literal> задаёт использование движка njs,
189+
также используемого по умолчанию.
190+
Параметр <literal>qjs</literal> задаёт использование движка QuickJS.
191+
</para>
192+
193+
</directive>
194+
195+
178196
<directive name="js_fetch_buffer_size">
179197
<syntax><value>размер</value></syntax>
180198
<default>16k</default>

0 commit comments

Comments
 (0)