xbintsc 0.6.10 → 0.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ast/expressions.d.ts +6 -0
- package/dist/src/checker/globals.js +2 -1
- package/dist/src/checker/globals.js.map +1 -1
- package/dist/src/checker/type-infer.js +1 -1
- package/dist/src/checker/type-infer.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/codegen/generator/calls/literals.js +4 -1
- package/dist/src/codegen/generator/calls/literals.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +3 -1
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/operators.js +2 -6
- package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.d.ts +9 -0
- package/dist/src/codegen/generator/expressions/primary.js +44 -7
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/state.js +3 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +3 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/bundler/commonjs.js +1 -1
- package/dist/src/driver/bundler/commonjs.js.map +1 -1
- package/dist/src/driver/bundler/symbols.js +6 -0
- package/dist/src/driver/bundler/symbols.js.map +1 -1
- package/dist/src/driver/compiler.js +1 -1
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +2 -0
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/node/crypto/index.js +12 -1
- package/dist/src/extensions/node/crypto/index.js.map +1 -1
- package/dist/src/extensions/node/index.js +2 -0
- package/dist/src/extensions/node/index.js.map +1 -1
- package/dist/src/extensions/node/readline/index.d.ts +12 -0
- package/dist/src/extensions/node/readline/index.js +27 -0
- package/dist/src/extensions/node/readline/index.js.map +1 -0
- package/dist/src/parser/declarations/functions.js +6 -0
- package/dist/src/parser/declarations/functions.js.map +1 -1
- package/dist/src/parser/literals.js +1 -1
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +26 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-modules.test.js +22 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-node.test.js +37 -1
- package/dist/tests/e2e/compile-node.test.js.map +1 -1
- package/dist/tests/e2e/crypto-random.test.d.ts +9 -0
- package/dist/tests/e2e/crypto-random.test.js +63 -0
- package/dist/tests/e2e/crypto-random.test.js.map +1 -0
- package/dist/tests/e2e/date-parse.test.js +44 -1
- package/dist/tests/e2e/date-parse.test.js.map +1 -1
- package/dist/tests/e2e/gui-browser.test.js +61 -0
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-css-coverage.test.js +40 -1
- package/dist/tests/e2e/gui-css-coverage.test.js.map +1 -1
- package/dist/tests/e2e/gui-css-features.test.js +100 -0
- package/dist/tests/e2e/gui-css-features.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +63 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-errors.test.d.ts +11 -0
- package/dist/tests/e2e/gui-errors.test.js +68 -0
- package/dist/tests/e2e/gui-errors.test.js.map +1 -0
- package/dist/tests/e2e/gui-form.test.d.ts +9 -0
- package/dist/tests/e2e/gui-form.test.js +359 -0
- package/dist/tests/e2e/gui-form.test.js.map +1 -0
- package/dist/tests/e2e/gui-script-import-order.test.js +6 -1
- package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
- package/dist/tests/e2e/gui-style.test.js +82 -0
- package/dist/tests/e2e/gui-style.test.js.map +1 -1
- package/dist/tests/e2e/gui-unsupported.test.js +4 -3
- package/dist/tests/e2e/gui-unsupported.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-shadow-sampler.test.js +7 -1
- package/dist/tests/e2e/gui-webgl2-shadow-sampler.test.js.map +1 -1
- package/dist/tests/e2e/harness.d.ts +4 -0
- package/dist/tests/e2e/harness.js +2 -0
- package/dist/tests/e2e/harness.js.map +1 -1
- package/dist/tests/e2e/json-parse-errors.test.d.ts +9 -0
- package/dist/tests/e2e/json-parse-errors.test.js +48 -0
- package/dist/tests/e2e/json-parse-errors.test.js.map +1 -0
- package/dist/tests/e2e/readline.test.d.ts +7 -0
- package/dist/tests/e2e/readline.test.js +73 -0
- package/dist/tests/e2e/readline.test.js.map +1 -0
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/gui/api.md +24 -3
- package/doc/gui/dom.md +28 -14
- package/doc/gui/input.md +74 -3
- package/doc/gui/known-issues.md +2 -1
- package/doc/gui/layout.md +5 -1
- package/doc/implemented/node/crypto.md +8 -0
- package/doc/implemented/node/fs.md +1 -1
- package/doc/implemented/node/readline.md +34 -0
- package/doc/implemented/node.md +1 -0
- package/doc/implemented/stdlib.md +10 -2
- package/doc/unimplemented/node/modules.md +2 -3
- package/doc/unimplemented/node.md +2 -2
- package/doc/zh-CN/gui/api.md +20 -3
- package/doc/zh-CN/gui/dom.md +23 -13
- package/doc/zh-CN/gui/input.md +65 -4
- package/doc/zh-CN/gui/known-issues.md +2 -1
- package/doc/zh-CN/gui/layout.md +4 -1
- package/doc/zh-CN/implemented/node/crypto.md +6 -0
- package/doc/zh-CN/implemented/node/fs.md +1 -1
- package/doc/zh-CN/implemented/node/readline.md +33 -0
- package/doc/zh-CN/implemented/node.md +1 -0
- package/doc/zh-CN/implemented/stdlib.md +10 -2
- package/doc/zh-CN/unimplemented/node/modules.md +1 -2
- package/doc/zh-CN/unimplemented/node.md +2 -2
- package/package.json +7 -7
- package/runtime/ext_gui/browser_abort.cpp +2 -2
- package/runtime/ext_gui/browser_loop.cpp +1 -0
- package/runtime/ext_gui/browser_media.cpp +1 -1
- package/runtime/ext_gui/css_match.cpp +21 -1
- package/runtime/ext_gui/css_selector.cpp +2 -2
- package/runtime/ext_gui/document.cpp +12 -0
- package/runtime/ext_gui/dom.h +41 -2
- package/runtime/ext_gui/dom_api_canvas_image.cpp +2 -1
- package/runtime/ext_gui/dom_api_document.cpp +28 -0
- package/runtime/ext_gui/dom_api_events.cpp +18 -15
- package/runtime/ext_gui/dom_api_form.cpp +567 -0
- package/runtime/ext_gui/dom_api_internal.h +48 -214
- package/runtime/ext_gui/dom_api_mutation.cpp +1 -1
- package/runtime/ext_gui/dom_api_node.cpp +28 -15
- package/runtime/ext_gui/dom_api_node_read.cpp +28 -1
- package/runtime/ext_gui/dom_api_proto.cpp +47 -0
- package/runtime/ext_gui/dom_api_webgl_methods.h +217 -0
- package/runtime/ext_gui/dom_parse.cpp +114 -1
- package/runtime/ext_gui/error_report.cpp +166 -0
- package/runtime/ext_gui/form_focus.cpp +293 -0
- package/runtime/ext_gui/form_input.cpp +448 -0
- package/runtime/ext_gui/form_internal.h +30 -0
- package/runtime/ext_gui/form_shared.cpp +126 -0
- package/runtime/ext_gui/form_state.cpp +536 -0
- package/runtime/ext_gui/form_state.h +97 -0
- package/runtime/ext_gui/gui.cpp +16 -0
- package/runtime/ext_gui/gui_engine.h +53 -4
- package/runtime/ext_gui/gui_events.cpp +67 -49
- package/runtime/ext_gui/layout.cpp +6 -0
- package/runtime/ext_gui/layout.h +4 -0
- package/runtime/ext_gui/layout_flow.cpp +23 -1
- package/runtime/ext_gui/layout_inline.cpp +46 -14
- package/runtime/ext_gui/paint.cpp +26 -1
- package/runtime/ext_gui/paint_form.cpp +389 -0
- package/runtime/ext_gui/paint_internal.h +6 -0
- package/runtime/ext_gui/script.cpp +1 -1
- package/runtime/ext_gui/style.cpp +1 -0
- package/runtime/ext_gui/style.h +13 -0
- package/runtime/ext_gui/style_print.cpp +129 -0
- package/runtime/ext_gui/style_text.cpp +79 -0
- package/runtime/ext_gui/style_ua.cpp +42 -0
- package/runtime/ext_gui/warnings.cpp +5 -7
- package/runtime/ext_gui/webgl_texture.cpp +0 -8
- package/runtime/ext_gui/window.cpp +52 -62
- package/runtime/ext_gui/window_diagnostics.cpp +58 -0
- package/runtime/ext_gui/window_emit.cpp +51 -0
- package/runtime/ext_node/crypto/crypto.c +3 -2
- package/runtime/ext_node/crypto/crypto_hash.h +13 -0
- package/runtime/ext_node/crypto/crypto_random.c +339 -0
- package/runtime/ext_node/fs/async_worker.c +1 -1
- package/runtime/ext_node/fs/fs_ops.c +1 -1
- package/runtime/ext_node/fs/parts/platform.inc +67 -0
- package/runtime/ext_node/readline/readline.c +572 -0
- package/runtime/rt.h +42 -0
- package/runtime/rt_internal.h +3 -2
- package/runtime/xt_crypto.c +132 -0
- package/runtime/xt_io/exception.inc +29 -6
- package/runtime/xt_loop.c +36 -1
- package/runtime/xt_promise.c +26 -2
- package/runtime/xt_random.c +143 -0
- package/runtime/xt_regex/matcher.inc +9 -28
- package/runtime/xt_regex/parser.inc +65 -2
- package/runtime/xt_regex/types.inc +11 -1
- package/runtime/xt_regex.h +6 -2
- package/runtime/xt_stdlib/dispatch.inc +2 -0
- package/runtime/xt_stdlib/math.inc +1 -1
- package/runtime/xt_stdlib2/date.inc +206 -6
- package/runtime/xt_stdlib2/json.inc +4 -546
- package/runtime/xt_stdlib2/json_parse.inc +347 -0
- package/runtime/xt_stdlib2/json_stringify.inc +368 -0
- package/runtime/xt_stdlib2/regexp-match.inc +6 -11
- package/runtime/xt_stdlib2.c +0 -4
- package/runtime/xt_typed_array/elements.inc +2 -6
- package/runtime/xt_url.c +0 -6
- package/runtime/xt_url_object.c +1 -1
- package/src/ast/expressions.ts +6 -0
- package/src/checker/globals.ts +2 -0
- package/src/checker/type-infer.ts +1 -1
- package/src/codegen/generator/calls/literals.ts +4 -1
- package/src/codegen/generator/expressions/assignment.ts +3 -1
- package/src/codegen/generator/expressions/operators.ts +2 -6
- package/src/codegen/generator/expressions/primary.ts +58 -6
- package/src/codegen/generator/state.ts +3 -0
- package/src/codegen/generator/tables.ts +3 -0
- package/src/driver/bundler/commonjs.ts +1 -1
- package/src/driver/bundler/symbols.ts +6 -0
- package/src/driver/compiler.ts +1 -1
- package/src/driver/runtime-objects.ts +2 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/node/crypto/index.ts +12 -1
- package/src/extensions/node/index.ts +2 -0
- package/src/extensions/node/readline/index.ts +31 -0
- package/src/parser/declarations/functions.ts +6 -0
- package/src/parser/literals.ts +1 -1
package/doc/gui/input.md
CHANGED
|
@@ -12,7 +12,8 @@ scaled or translated element is hit exactly where it is drawn — and `:hover`
|
|
|
12
12
|
follows the artwork, not the box flow left behind.
|
|
13
13
|
|
|
14
14
|
- SDL pointer/wheel/key events are routed to the owning window, hit tested, and
|
|
15
|
-
delivered to the handlers registered with `on`. `mousedown` also moves focus
|
|
15
|
+
delivered to the handlers registered with `on`. `mousedown` also moves focus
|
|
16
|
+
and places the caret in a text field.
|
|
16
17
|
- Keyboard events also follow the DOM path: the target is the focused element (or
|
|
17
18
|
`<body>` when nothing is focused), the event bubbles through its ancestors to
|
|
18
19
|
`document`, and finally reaches `window` listeners. This is what lets a page
|
|
@@ -21,12 +22,82 @@ delivered to the handlers registered with `on`. `mousedown` also moves focus.
|
|
|
21
22
|
(`"KeyW"`, `"ArrowUp"`, `"Space"`) and `key` the produced value (`"w"`, `"W"`,
|
|
22
23
|
`" "`) — not SDL's scancode/key names.
|
|
23
24
|
- `:hover` matches the hovered element **and its ancestors** (so hovering a child
|
|
24
|
-
lights up its parents); `:focus` matches the focused element
|
|
25
|
+
lights up its parents); `:focus` matches the focused element and
|
|
26
|
+
`:focus-within` its ancestors too. When either
|
|
25
27
|
changes, `XtDocument::setHover`/`setFocus` recompute styles and layout and mark
|
|
26
28
|
the window's geometry dirty, so the change is painted on the next frame.
|
|
27
29
|
- `win.hitTest(x, y)` and `win.sendEvent(type, options)` expose hit testing and
|
|
28
30
|
synthetic input so the whole path is testable headlessly (the e2e suite drives
|
|
29
31
|
clicks, wheels and keys without a real mouse).
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
## Form controls (M23)
|
|
32
34
|
|
|
35
|
+
`<input>`, `<textarea>` and `<select>` are native leaf boxes: their value,
|
|
36
|
+
selection and checked state live in `Node::form` (`FormState`) and are painted
|
|
37
|
+
by the engine, so no browser/DOM layer is involved.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const user = document.getElementById("user"); // <input id="user" value="abc">
|
|
41
|
+
user.focus();
|
|
42
|
+
user.value; // "abc"
|
|
43
|
+
user.selectionStart; // 3
|
|
44
|
+
user.setSelectionRange(1, 3);
|
|
45
|
+
user.placeholder = "name";
|
|
46
|
+
user.disabled = true;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **`<input>` types**: `text`, `search`, `tel`, `url`, `email`, `password`,
|
|
50
|
+
`number`, `date`, `month`, `week`, `time`, `datetime-local`, `range`, `color`,
|
|
51
|
+
`checkbox`, `radio`, `file`, `submit`, `reset`, `button`, `image` and
|
|
52
|
+
`hidden`. Text-like types are editable; checkbox/radio paint their box and
|
|
53
|
+
toggle on click (radios uncheck the rest of their `name` group); range paints a
|
|
54
|
+
track and thumb and updates from a drag; color paints a swatch; submit/reset/
|
|
55
|
+
button paint their label. `hidden` has no box.
|
|
56
|
+
- **`<textarea>`** is multi-line (`\n` breaks a line), **`<select>`** paints the
|
|
57
|
+
selected `<option>`'s label and cycles the selection on click (there is no
|
|
58
|
+
popup menu). `date`/`time`/`month`/`week` inputs are editable text fields with
|
|
59
|
+
the browser's value shape, and `color`/`file` expose their value/state without
|
|
60
|
+
opening a native picker or file dialog.
|
|
61
|
+
- **`value`** is the live value, separate from the `value` attribute (the
|
|
62
|
+
default). `<textarea>` reads its default from its text content and `<select>`
|
|
63
|
+
from the selected/first `<option>`. Assigning `value` moves the caret to the
|
|
64
|
+
end, as browsers do.
|
|
65
|
+
- **`selectionStart` / `selectionEnd` / `selectionDirection`**,
|
|
66
|
+
`setSelectionRange(start, end, direction)` and `select()` use UTF-16 code-unit
|
|
67
|
+
offsets (the DOM convention), backed by UTF-8 storage.
|
|
68
|
+
- **`checked`**, `type`, `name`, `disabled`, `readOnly`, `required`,
|
|
69
|
+
`placeholder`, `min`, `max`, `step`, `maxLength`, `tabIndex`, `form`,
|
|
70
|
+
`options` and `selectedIndex` are live DOM properties.
|
|
71
|
+
- **`document.activeElement`** is the focused element, or `<body>` when nothing
|
|
72
|
+
is focused. `tabindex` establishes the Tab order (`tabindex="1"` before the
|
|
73
|
+
implicit `0` stops; `-1` is click-focusable but skipped by Tab); Tab and
|
|
74
|
+
Shift+Tab move focus even when no text field is focused. A disabled or hidden
|
|
75
|
+
control cannot be focused, is skipped by Tab and paints dimmed.
|
|
76
|
+
- **Text input** comes from `SDL_EVENT_TEXT_INPUT`, which carries the text the
|
|
77
|
+
keyboard layout or IME actually produced. `keydown` handles the editing
|
|
78
|
+
commands (Backspace/Delete/arrows/Home/End/Ctrl+A/C/X/V, with Shift extending
|
|
79
|
+
the selection) and `keypress` + `input` are dispatched after an edit.
|
|
80
|
+
- **IME** uses `SDL_EVENT_TEXT_EDITING`: the pre-edit text is displayed at the
|
|
81
|
+
caret and `compositionstart` / `compositionupdate` / `compositionend` fire;
|
|
82
|
+
the commit is inserted into the value on `compositionend`.
|
|
83
|
+
- **Clipboard** is the system clipboard through SDL: Ctrl+C/X/V.
|
|
84
|
+
- **Events** fire automatically: `beforeinput` (cancelable) before a text edit,
|
|
85
|
+
`input` after every value change (typing, deletion, checkbox/radio toggle,
|
|
86
|
+
range drag, select), and `change` when the value is committed (a text field
|
|
87
|
+
losing focus after a change, Enter in a single-line field, a checkbox/radio
|
|
88
|
+
click, a range release or a select change). `input`/`change` payloads carry
|
|
89
|
+
`value`; `change` also carries `checked`.
|
|
90
|
+
- **Forms**: a submit button (or Enter in a single-line field) fires a
|
|
91
|
+
cancelable `submit` on the enclosing `<form>` with the `submitter` when one
|
|
92
|
+
was clicked; there is no navigation, so preventing the event or not has the
|
|
93
|
+
same visible result. A reset button or `form.reset()` fires `reset` and
|
|
94
|
+
restores every control's default value/checked state. `form.submit()` and
|
|
95
|
+
`form.requestSubmit(submitter?)` dispatch the same event.
|
|
96
|
+
|
|
97
|
+
`win.sendEvent` also accepts `{ type: "textInput", text }` (as if SDL delivered
|
|
98
|
+
that text), `{ type: "compositionstart" | "compositionupdate" | "compositionend",
|
|
99
|
+
data }` and printable `keydown` events. A real physical `keydown` never inserts
|
|
100
|
+
its US-layout `key`: the matching text-input event does, so an IME or a non-US
|
|
101
|
+
layout cannot double a character.
|
|
102
|
+
|
|
103
|
+
Still to do for full input: drag-selection across several lines and undo/redo.
|
package/doc/gui/known-issues.md
CHANGED
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
shader validation is enabled — running with `MTL_SHADER_VALIDATION=1` makes
|
|
32
32
|
`tests/e2e/gui-webgl2-shadow-sampler.test.ts` pass on such a machine. That
|
|
33
33
|
points at the driver's shader compiler rather than the engine, so the
|
|
34
|
-
workaround is the environment variable
|
|
34
|
+
workaround is the environment variable (the e2e test sets it for macOS runs);
|
|
35
|
+
other Apple GPUs may not show it.
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
package/doc/gui/layout.md
CHANGED
|
@@ -29,7 +29,11 @@ with absolute (viewport-relative) geometry:
|
|
|
29
29
|
`white-space: nowrap` stops a run from wrapping at spaces (a source newline
|
|
30
30
|
collapses to a space); `text-overflow: ellipsis` on a box whose `overflow` is
|
|
31
31
|
not `visible` replaces the part of an overflowing line that does not fit with
|
|
32
|
-
a single U+2026 ellipsis and drops the rest.
|
|
32
|
+
a single U+2026 ellipsis and drops the rest. `overflow-wrap: break-word` /
|
|
33
|
+
`anywhere` (and the `word-wrap` alias) splits a word that does not fit at the
|
|
34
|
+
largest prefix the remaining line can hold. `text-decoration` parses its
|
|
35
|
+
line/style/colour components and paints underline, overline and line-through
|
|
36
|
+
as solid rules (dashed/dotted/wavy are reported computed but painted solid).
|
|
33
37
|
- **Flexbox** — `row`/`column` (and the `-reverse` variants) with `gap`,
|
|
34
38
|
`flex-basis`/`flex-grow`/`flex-shrink`, `justify-content` and `align-items`
|
|
35
39
|
(including `stretch` when the cross size is definite). On both axes the main
|
|
@@ -7,3 +7,11 @@ Location: `src/extensions/node/crypto/index.ts`, `runtime/ext_node/crypto/crypto
|
|
|
7
7
|
- `createHash(algorithm)` returns a hash object with `update(...)` and `digest([encoding])`.
|
|
8
8
|
- The streaming form (`setEncoding` / `write` / `end` / `read`) is supported.
|
|
9
9
|
- SHA-1 and SHA-256 are available.
|
|
10
|
+
- `randomBytes(size[, callback])`, `randomUUID()`, `randomInt([min, ]max[, callback])`,
|
|
11
|
+
`randomFillSync(buffer[, offset[, size]])` and `randomFill(...)` read the OS
|
|
12
|
+
CSPRNG (`BCryptGenRandom` on Windows, `/dev/urandom` elsewhere). `webcrypto`
|
|
13
|
+
exposes the same `getRandomValues` / `randomUUID` object as the global
|
|
14
|
+
`crypto`.
|
|
15
|
+
- `pbkdf2Sync(password, salt, iterations, keylen[, digest])` and
|
|
16
|
+
`pbkdf2(...)` implement PBKDF2-HMAC-SHA1/SHA-256 (the async form invokes the
|
|
17
|
+
callback immediately; the work is synchronous).
|
|
@@ -18,7 +18,7 @@ Location: `src/extensions/node/fs/*.ts`, `runtime/ext_node/fs/*.c`
|
|
|
18
18
|
| `rmSync(path[, options])` | `xt_node_rm` | delete a file/directory; `{ recursive: true }` deletes recursively |
|
|
19
19
|
| `rmdirSync(path[, options])` | `xt_node_rmdir` | delete an empty directory |
|
|
20
20
|
| `unlinkSync(path)` | `xt_node_unlink` | delete a file |
|
|
21
|
-
| `renameSync(oldPath, newPath)` | `xt_node_rename` | rename / move |
|
|
21
|
+
| `renameSync(oldPath, newPath)` | `xt_node_rename` | rename / move; atomically replaces an existing target (`MoveFileExW` + `MOVEFILE_REPLACE_EXISTING` on Windows) |
|
|
22
22
|
| `copyFileSync(src, dest[, flags])` | `xt_node_copy_file` | copy a file; honours `COPYFILE_EXCL` |
|
|
23
23
|
| `cpSync(src, dest[, options])` | `xt_node_cp` | recursive copy; `recursive`, `force`, `errorOnExist`, `dereference`, `preserveTimestamps` |
|
|
24
24
|
| `realpathSync(path)` | `xt_node_realpath` | resolve to an absolute path |
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# `readline`
|
|
2
|
+
|
|
3
|
+
> Part of [Node extension: implemented](../node.md) · [简体中文](../../zh-CN/implemented/node/readline.md)
|
|
4
|
+
|
|
5
|
+
Location: `src/extensions/node/readline/index.ts`, `runtime/ext_node/readline/readline.c`
|
|
6
|
+
|
|
7
|
+
`createInterface(options)` (and `new Interface(options)`) reads standard input
|
|
8
|
+
line by line. The blocking read runs on the async I/O pool, so the event loop
|
|
9
|
+
keeps serving timers while the program waits for a line.
|
|
10
|
+
|
|
11
|
+
| API | Notes |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `createInterface({ input?, output?, prompt?, terminal? })` | `input`/`output` are informational: the implementation always reads stdin and writes stdout. `prompt` sets the initial prompt. |
|
|
14
|
+
| `rl.on(event, fn)` / `rl.once(...)` / `rl.off(...)` / `rl.removeListener(...)` / `rl.removeAllListeners(...)` | `line`, `close`, `pause` and `resume` events |
|
|
15
|
+
| `rl.question(query, callback)` | writes `query`, then calls `callback(answer)` with the next line; questions queue in order and do not emit `line` |
|
|
16
|
+
| `rl.prompt()` / `rl.setPrompt(text)` / `rl.getPrompt()` | write and manage the prompt (default `"> "`); there is no line editing |
|
|
17
|
+
| `rl.pause()` / `rl.resume()` | a line that arrives while paused is buffered and delivered on resume |
|
|
18
|
+
| `rl.close()` | emits `close` and stops reading; end of input closes automatically |
|
|
19
|
+
| `rl.write(text)` / `rl.setRawMode(bool)` | write to stdout; raw mode is accepted as a no-op |
|
|
20
|
+
| `cursorTo(stream, x[, y])`, `moveCursor(stream, dx, dy)`, `clearLine(stream, dir)`, `clearScreenDown(stream)` | write the ANSI escape sequences Node emits; the stream argument is ignored |
|
|
21
|
+
| `emitKeypressEvents(stream[, interface])` | accepted as a no-op |
|
|
22
|
+
|
|
23
|
+
Deviation: there is no terminal line editor, history, completion, `readline/promises`
|
|
24
|
+
or keypress synthesis; `input`/`output` custom streams are not redirected.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createInterface } from "readline";
|
|
28
|
+
|
|
29
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
30
|
+
rl.question("name? ", (name: string) => {
|
|
31
|
+
console.log("hello " + name);
|
|
32
|
+
rl.close();
|
|
33
|
+
});
|
|
34
|
+
```
|
package/doc/implemented/node.md
CHANGED
|
@@ -33,6 +33,7 @@ work on another. Missing or different behaviour is recorded under
|
|
|
33
33
|
| `events` | [events](./node/events.md) | `EventEmitter` (global and named export) |
|
|
34
34
|
| `util` | [util](./node/util.md) | formatting, inspection and predicates |
|
|
35
35
|
| `querystring` | [querystring](./node/querystring.md) | parse / stringify / escape |
|
|
36
|
+
| `readline` | [readline](./node/readline.md) | line/question reader over stdin, cursor helpers |
|
|
36
37
|
| `assert` | [assert](./node/assert.md) | assertion functions |
|
|
37
38
|
| `test` | [test](./node/test.md) | minimal TAP runner |
|
|
38
39
|
| `crypto` | [crypto](./node/crypto.md) | `createHash` (SHA-1 / SHA-256) |
|
|
@@ -37,17 +37,19 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
37
37
|
|
|
38
38
|
## JSON
|
|
39
39
|
|
|
40
|
-
- `JSON.parse` with a `reviver`.
|
|
40
|
+
- `JSON.parse` with a `reviver`; malformed input (bad numbers/strings, trailing text, missing separators) throws a catchable `SyntaxError` instead of returning `undefined`.
|
|
41
41
|
- `JSON.stringify` with a function or array `replacer`, `toJSON`, and `space` (number or string, clamped to 10). `undefined` / function / symbol values follow the standard omission rules.
|
|
42
42
|
- Object keys are emitted in insertion order, with integer keys ordered numerically; circular references throw.
|
|
43
43
|
|
|
44
44
|
## Date
|
|
45
45
|
|
|
46
46
|
- `Date` backed by `gmtime_r`; ISO 8601 parsing through `Date.parse` / `new Date(string)`.
|
|
47
|
+
- `toLocaleDateString` / `toLocaleTimeString` / `toLocaleString` format the local time (`M/D/YYYY`, `h:mm:ss AM`); a small options subset (`weekday`/`year`/`month`/`day`/`hour`/`minute`/`second`/`hour12`) is honoured. `toDateString` / `toTimeString` / `toUTCString` are available too, and an invalid date formats as `Invalid Date`.
|
|
47
48
|
|
|
48
49
|
## RegExp
|
|
49
50
|
|
|
50
|
-
- `RegExp` uses POSIX
|
|
51
|
+
- `RegExp` uses the runtime's self-contained POSIX-ERE-compatible matcher (`regcomp` / `regexec` style) on every host, so results do not depend on the platform's libc. Capture groups are exposed through `exec` / `match` / `replace` / `split` / `search`.
|
|
52
|
+
- Quantifiers include `*`, `+`, `?` and the counted forms `{n}`, `{n,}` and `{n,m}` (with a lazy `?` suffix). Malformed brace groups such as `{x}` and `{,2}` stay literal, as in JavaScript; an inverted range such as `{2,1}` is also treated as literal instead of being rejected.
|
|
51
53
|
- Matching is byte-oriented and `/g` / `/y` `lastIndex` is not honoured — see [Runtime deviations](../unimplemented/deviations.md).
|
|
52
54
|
|
|
53
55
|
## Symbol
|
|
@@ -94,3 +96,9 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
94
96
|
- `btoa` / `atob` base64 encoding and decoding (core globals; not Node-extension-only).
|
|
95
97
|
- `structuredClone`: arrays, objects, `Map`, `Set`, `Date`, `RegExp` and typed arrays, preserving cycles and shared references; functions, symbols, promises and generators are rejected.
|
|
96
98
|
- Timers, `queueMicrotask` and `performance.now` are described in [Async, promises and generators](./async.md); `fetch` in [fetch](./fetch.md).
|
|
99
|
+
|
|
100
|
+
## Global crypto
|
|
101
|
+
|
|
102
|
+
- `crypto.getRandomValues(typedArray)` fills an integer typed array (up to 65 536 bytes) from the OS CSPRNG and returns it; `crypto.randomUUID()` returns a v4 UUID string. `crypto` is also a first-class object and the methods can be detached (`const uuid = crypto.randomUUID`).
|
|
103
|
+
- `Math.random` draws from a xoshiro256** stream seeded from the OS CSPRNG (53 random bits), not from the C `rand()`.
|
|
104
|
+
- Node's `crypto.randomBytes` / `randomInt` / `randomFillSync` / `pbkdf2Sync` surface is documented in [node/crypto](../implemented/node/crypto.md).
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
The following Node built-in modules have no corresponding extension / builtin
|
|
6
6
|
(`fs` / `fs/promises` / `path` / `os` / `process` / `buffer` / `stream` /
|
|
7
|
-
`dgram` / `http` / `events` / `util` / `querystring` / `
|
|
8
|
-
implemented, and `crypto` / `url` / `child_process` / `zlib` /
|
|
7
|
+
`dgram` / `http` / `events` / `util` / `querystring` / `readline` / `assert` /
|
|
8
|
+
`test` are implemented, and `crypto` / `url` / `child_process` / `zlib` /
|
|
9
9
|
`stream/promises` / `worker_threads` are partially implemented; see
|
|
10
10
|
[implemented: Node extension](../../implemented/node.md)):
|
|
11
11
|
|
|
12
12
|
| Module | Notes |
|
|
13
13
|
| --- | --- |
|
|
14
14
|
| `https` | TLS version of HTTP |
|
|
15
|
-
| `readline` | command-line reading |
|
|
16
15
|
| `tls` / `cluster` / `vm` | other core modules not listed |
|
|
17
16
|
|
|
18
17
|
> `crypto` (only `createHash`, now with the streaming API), `url` (only
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Part of [Unimplemented syntax and features](../unimplemented.md) · [简体中文](../zh-CN/unimplemented/node.md)
|
|
4
4
|
|
|
5
|
-
The Node extension implements
|
|
5
|
+
The Node extension implements 22 modules plus the event-loop integration; the
|
|
6
6
|
implemented surface is documented page by page under
|
|
7
7
|
[Node extension: implemented](../implemented/node.md). This section records what
|
|
8
8
|
is missing or differs from Node.
|
|
@@ -11,7 +11,7 @@ is missing or differs from Node.
|
|
|
11
11
|
|
|
12
12
|
- [`fs`](./node/fs.md) — callback-style async operations, real file watching, option callbacks
|
|
13
13
|
- [`fs/promises`](./node/fs-promises.md) — `FileHandle` append/read offsets, immediate `Dir` callbacks, inert `watch`, no cancellation
|
|
14
|
-
- [Fully unimplemented modules](./node/modules.md) — `https`, `
|
|
14
|
+
- [Fully unimplemented modules](./node/modules.md) — `https`, `tls`, `cluster`, `vm`, ...
|
|
15
15
|
- [Global objects and namespaces](./node/globals.md) — `global`, `__dirname`, `require` outside `node_modules`
|
|
16
16
|
- [Async and the event-loop model](./node/async.md) — blocked file watching, blocking `net.connect`, no keep-alive, fixed-size offload pool
|
|
17
17
|
- [The Bun extension](./node/bun.md) — design example only
|
package/doc/zh-CN/gui/api.md
CHANGED
|
@@ -43,8 +43,21 @@ API 编写的文档可以原样运行。
|
|
|
43
43
|
提升操作系统窗口并置位 `document.hasFocus()`,`blur()` 清除它。事件:
|
|
44
44
|
`ready`(首帧呈现后)、`load`、`close`、`resize`、`scroll`、`focus`、`blur`,
|
|
45
45
|
以及输入事件 `mousemove`、`mousedown`、`mouseup`、`click`、`wheel`、
|
|
46
|
-
`keydown`、`keyup
|
|
47
|
-
|
|
46
|
+
`keydown`、`keyup`、`keypress`、`textInput`、
|
|
47
|
+
`compositionstart` / `compositionupdate` / `compositionend`、`beforeinput`、
|
|
48
|
+
`input`、`change`、`submit` 与 `reset`。
|
|
49
|
+
|
|
50
|
+
由引擎调用的代码(元素/窗口监听器、定时器、动画帧、媒体事件)抛出的异常会被
|
|
51
|
+
当作页面错误,而不是终止进程:引擎在回调边界捕获它,并对齐浏览器接口。
|
|
52
|
+
`window.onerror` 收到 `(message, source, line, column, error)`,
|
|
53
|
+
`addEventListener("error", …)` 收到类 `ErrorEvent` 对象(`.message`、`.error`、
|
|
54
|
+
`.filename`、`.lineno`、`.colno`),无人观察的拒绝会变成
|
|
55
|
+
`unhandledrejection` 事件(也可通过 `window.onunhandledrejection` 设置,事件带
|
|
56
|
+
`.reason` / `.promise`)。默认日志写到 stderr;`onerror` 返回 `true` 或调用
|
|
57
|
+
`event.preventDefault()` 可抑制该日志。错误处理器自身抛错也只会被报告,不会关闭窗口。
|
|
58
|
+
|
|
59
|
+
`setSize` 会先结算请求,并在尺寸确实变化时同步触发一次 `resize`,因此不主动泵
|
|
60
|
+
SDL 事件的页面也能收到;后端随后针对同一尺寸的事件会被忽略。
|
|
48
61
|
`createWindow(options)` 除标题与尺寸外还支持:`{ title, width, height,
|
|
49
62
|
highDensity, resizable, borderless, alwaysOnTop, hidden, fullscreen, x, y,
|
|
50
63
|
opacity, maximized, minimized }`,它们会映射到对应的 SDL 窗口标志/调用,而不是
|
|
@@ -171,6 +184,8 @@ win.on("keydown", (e) => console.log(e.key, e.code, e.ctrlKey, e.shiftKey));
|
|
|
171
184
|
| `key`、`code` | keyboard | 浏览器 `KeyboardEvent` 写法:产生的值与物理键 |
|
|
172
185
|
| `repeat`、`ctrl`、`shift`、`alt`、`meta` | keyboard | 修饰键(旧版 DOM 写法) |
|
|
173
186
|
| `ctrlKey`、`shiftKey`、`altKey`、`metaKey` | keyboard | 修饰键(现行 DOM 写法) |
|
|
187
|
+
| `data` | composition | 预编辑文本(`compositionstart`/`update`/`end`) |
|
|
188
|
+
| `text` | `textInput` | IME/键盘布局实际产生的文本 |
|
|
174
189
|
| `target` | pointer、wheel | 该点下最深的元素,表示为类 CSS 描述符(`div#main.card`),可能缺省 |
|
|
175
190
|
|
|
176
191
|
## 诊断
|
|
@@ -189,7 +204,9 @@ win.inlineSvg(selector) // 序列化的内联 <svg>:{ markup, w
|
|
|
189
204
|
win.measureText(text, fontSize?, family?) // 整形后的推进宽度(像素)
|
|
190
205
|
win.fontMetrics(fontSize?, family?) // { ascent, descent, lineHeight, ready }
|
|
191
206
|
win.hitTest(x, y) // 最深的元素描述符,或 ""
|
|
192
|
-
win.sendEvent(type, options?) //
|
|
207
|
+
win.sendEvent(type, options?) // 合成输入(测试用);也支持
|
|
208
|
+
// "textInput" + { text } 与
|
|
209
|
+
// "composition*" 事件 + { data }
|
|
193
210
|
win.advance(ms) // 推进 CSS transition 时钟(测试用)
|
|
194
211
|
win.stats() // 引擎/运行时计数器(内存排查用)
|
|
195
212
|
```
|
package/doc/zh-CN/gui/dom.md
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
**HTML 解析器**(`runtime/ext_gui/dom.{h,cpp}`):标签/属性/文本,注释与
|
|
11
11
|
doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素,原始文本元素
|
|
12
12
|
(`<style>`/`<script>`),以及常见的隐式闭合规则(`li`、`dt`/`dd`、`option`、
|
|
13
|
-
`p
|
|
13
|
+
`p`、标题、表格单元格/行)。解析片段时会补上隐式的 `<html>`/`<head>`/`<body>`
|
|
14
|
+
(顶层 `<style>`/`<title>` 等进入 `<head>`,其余进入 `<body>`),因此即使源文件
|
|
15
|
+
只有一个 `<div>`,`document.body`、`document.head` 与 `body { … }` 也能工作。
|
|
16
|
+
`innerHTML`/`insertAdjacentHTML` 按片段解析,**不会**再合成一层文档包装。
|
|
14
17
|
|
|
15
18
|
**CSS 解析器**(`runtime/ext_gui/css.{h,cpp}`):会剥离注释;`@media` 块递归解析
|
|
16
19
|
(嵌套查询用 `and` 合并,逗号列表会分配到内层查询),其他 at-rule 跳过。规则支持
|
|
@@ -20,7 +23,8 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
|
|
|
20
23
|
(`=`、`~=`、`|=`、`^=`、`$=`、`*=`)、四种组合器(后代、子、相邻兄弟与
|
|
21
24
|
通用兄弟)、伪类 `:first-child`、`:last-child`、`:only-child`、`:empty`、
|
|
22
25
|
`:root`、`:not(...)`、`:nth-child(an+b)`、`:disabled`、`:checked`、有状态的
|
|
23
|
-
`:hover`、`:focus`、`:focus-visible`(目前等同 `:focus
|
|
26
|
+
`:hover`、`:focus`、`:focus-visible`(目前等同 `:focus`)、`:focus-within`
|
|
27
|
+
(聚焦元素及其祖先)与 `:active`
|
|
24
28
|
(见[输入](./input.md)),以及伪元素
|
|
25
29
|
`::before`/`::after`(也接受旧式 `:before`/`:after`)。值:长度
|
|
26
30
|
(`px`、`%`、`em`、`rem`、`vw`、`vh`、`pt`、`pc`、`in`、`cm`、`mm`、`q`)、
|
|
@@ -82,16 +86,15 @@ xt_gui: warning: unsupported CSS unit 'vmin'; the value is ignored
|
|
|
82
86
|
|
|
83
87
|
- **HTML 元素**:引擎缺少其浏览器行为的标签——`applet`、`area`、`basefont`、
|
|
84
88
|
`bgsound`、`blink`、`caption`、`col`、`colgroup`、`datalist`、`details`、
|
|
85
|
-
`dialog`、`embed`、`frame`、`frameset`、`iframe`、`
|
|
86
|
-
`
|
|
87
|
-
`
|
|
88
|
-
`
|
|
89
|
-
`
|
|
90
|
-
|
|
91
|
-
不是被丢弃的特性,因此不会报告。
|
|
89
|
+
`dialog`、`embed`、`frame`、`frameset`、`iframe`、`isindex`、`keygen`、`map`、
|
|
90
|
+
`marquee`、`math`、`meter`、`noembed`、`noframes`、`object`、`output`、`param`、
|
|
91
|
+
`plaintext`、`progress`、`summary`、`table`、`tbody`、`td`、`template`、`tfoot`、
|
|
92
|
+
`th`、`thead`、`tr`、`track` 与 `xmp`。其余标签——包括 `button`、`input`、
|
|
93
|
+
`label`、`select`、`textarea`、自定义元素以及 `<dvi>` 这类拼写错误——都会渲染
|
|
94
|
+
成盒子,这是预期的回退而不是被丢弃的特性,因此不会报告。
|
|
92
95
|
- **HTML 特性(attribute)**:请求了不支持行为的 `href`(链接不会导航)、
|
|
93
96
|
`srcset`、`sizes`、`poster`、`controls`、`contenteditable`、`draggable`、
|
|
94
|
-
`autofocus`、`
|
|
97
|
+
`autofocus`、`hidden`,以及 SVG 的
|
|
95
98
|
`filter`/`mask`/`clip-path`/`marker-*` 特性。
|
|
96
99
|
- **CSS 属性**:子集之外的属性名;以及解析器未实现的长度单位(`ch`、`ex`、
|
|
97
100
|
`vmin`、`dvh` 等)。已支持属性上的非法值不会按“不支持”报告——只检查属性的
|
|
@@ -175,13 +178,20 @@ console.log(box.contains(inner)); // 后代判断
|
|
|
175
178
|
`getComputedStyle(el, pseudoElt)` 从**层叠结果**读取——UA 样式表、作者规则、
|
|
176
179
|
继承和内联声明——而不是回显内联块,因此写在样式表里的规则同样可见。它支持
|
|
177
180
|
`getPropertyValue`、`getPropertyPriority` 与命名属性(`cs.width`、
|
|
178
|
-
`cs.backgroundColor`、`cs["--accent"]
|
|
181
|
+
`cs.backgroundColor`、`cs["--accent"]`)。边框属性也按边序列化:
|
|
182
|
+
`border-top-color` / `border-right-color` / … 会把 `currentColor` 解析为元素
|
|
183
|
+
计算颜色,`border-*-width` 对 `none` 边框报告实际使用的 `0px`,
|
|
184
|
+
`border-*-style` 报告计算后的样式关键字。传入 `"::before"` 或 `"::after"`
|
|
179
185
|
可读取生成内容盒;其他伪元素返回空值。每次读取都会先结算待处理的重新样式,
|
|
180
|
-
|
|
186
|
+
因此早先创建的句柄在后续变更后仍然有效。引擎未建模的标准属性(例如
|
|
187
|
+
`word-break`、`object-fit`、`list-style-type`)会返回其 CSS 初始值而不是 `""`,
|
|
188
|
+
因此「读取当前样式」的常规写法对这些属性同样可用。
|
|
181
189
|
|
|
182
190
|
`getBoundingClientRect()` 在 `x` / `y` / `width` / `height` 之外还带有旧式的
|
|
183
191
|
`top` / `right` / `bottom` / `left` 成员;`document.title = …` 写入文档的
|
|
184
|
-
`<title>`(页面没有该元素时会创建它以及 `<head
|
|
192
|
+
`<title>`(页面没有该元素时会创建它以及 `<head>`)。没有布局盒的节点
|
|
193
|
+
(`display: none`、游离元素或过期句柄)返回全 0 矩形而不是 `undefined`,
|
|
194
|
+
与 DOM 一致。`label.htmlFor` 反映 `for` 属性(可读、可写、可清空)。
|
|
185
195
|
|
|
186
196
|
变更操作会把文档标记为脏;引擎会延迟地(在下一次读取或下一帧之前)重新计算
|
|
187
197
|
样式并重新布局。`inner = …`/`innerHTML = …` **不会**执行脚本。元素事件支持
|
package/doc/zh-CN/gui/input.md
CHANGED
|
@@ -11,18 +11,79 @@
|
|
|
11
11
|
出来**的位置被命中——`:hover` 跟着画面走,而不是跟着流式布局留下的盒子走。
|
|
12
12
|
|
|
13
13
|
- SDL 指针/滚轮/键盘事件会被路由到所属窗口,进行命中测试,并投递给用 `on`
|
|
14
|
-
注册的处理器。`mousedown`
|
|
14
|
+
注册的处理器。`mousedown` 还会移动焦点,并在文本框中放置光标。
|
|
15
15
|
- 键盘事件同时走 DOM 路径:目标为聚焦元素(没有焦点时为 `<body>`),事件沿祖先
|
|
16
16
|
冒泡到 `document`,最后到达 `window` 监听器。因此按浏览器写的
|
|
17
17
|
`document.addEventListener("keydown", …)` 可以直接工作。负载使用浏览器
|
|
18
18
|
`KeyboardEvent` 的写法:`code` 是物理键(`"KeyW"`、`"ArrowUp"`、`"Space"`),
|
|
19
19
|
`key` 是产生的值(`"w"`、`"W"`、`" "`),而不是 SDL 的扫描码/键名。
|
|
20
20
|
- `:hover` 匹配悬停元素**及其祖先**(因此悬停子元素会点亮其父元素);
|
|
21
|
-
`:focus`
|
|
22
|
-
|
|
21
|
+
`:focus` 匹配聚焦元素,`:focus-within` 同时匹配其祖先。当任一改变时,
|
|
22
|
+
`XtDocument::setHover`/`setFocus` 重新计算样式与布局,并把窗口几何标记为
|
|
23
|
+
脏,因此改动会在下一帧绘制。
|
|
23
24
|
- `win.hitTest(x, y)` 与 `win.sendEvent(type, options)` 暴露命中测试与合成
|
|
24
25
|
输入,使整条路径可无头测试(e2e 套件在没有真实鼠标的情况下驱动点击、滚轮
|
|
25
26
|
与按键)。
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
## 表单控件(M23)
|
|
28
29
|
|
|
30
|
+
`<input>`、`<textarea>` 与 `<select>` 是引擎原生的叶子盒:值、选区与勾选状态
|
|
31
|
+
保存在 `Node::form`(`FormState`)中,由引擎绘制,不涉及浏览器/DOM 层。
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const user = document.getElementById("user"); // <input id="user" value="abc">
|
|
35
|
+
user.focus();
|
|
36
|
+
user.value; // "abc"
|
|
37
|
+
user.selectionStart; // 3
|
|
38
|
+
user.setSelectionRange(1, 3);
|
|
39
|
+
user.placeholder = "name";
|
|
40
|
+
user.disabled = true;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- **`<input>` 类型**:`text`、`search`、`tel`、`url`、`email`、`password`、
|
|
44
|
+
`number`、`date`、`month`、`week`、`time`、`datetime-local`、`range`、`color`、
|
|
45
|
+
`checkbox`、`radio`、`file`、`submit`、`reset`、`button`、`image` 与 `hidden`。
|
|
46
|
+
文本类可编辑;checkbox/radio 绘制方框并在点击时切换(radio 会取消同 `name`
|
|
47
|
+
组的其它项);range 绘制轨道与滑块并支持拖动;color 绘制色块;
|
|
48
|
+
submit/reset/button 绘制标签;`hidden` 不产生盒。
|
|
49
|
+
- **`<textarea>`** 支持多行(`\n` 换行),**`<select>`** 绘制当前 `<option>`
|
|
50
|
+
的标签,点击切换选项(没有弹出菜单)。`date`/`time`/`month`/`week` 输入框
|
|
51
|
+
是按浏览器值格式编辑的文本框;`color`/`file` 暴露值/状态,但不会打开原生
|
|
52
|
+
取色器或文件对话框。
|
|
53
|
+
- **`value`** 是活动值,与 `value` 属性(默认值)分离。`<textarea>` 的默认值
|
|
54
|
+
来自其文本内容,`<select>` 来自被选中/第一个 `<option>`。给 `value` 赋值会
|
|
55
|
+
把光标移到末尾,与浏览器一致。
|
|
56
|
+
- **`selectionStart` / `selectionEnd` / `selectionDirection`**、
|
|
57
|
+
`setSelectionRange(start, end, direction)` 与 `select()` 使用 UTF-16 码元
|
|
58
|
+
偏移(DOM 约定),底层存储为 UTF-8。
|
|
59
|
+
- **`checked`**、`type`、`name`、`disabled`、`readOnly`、`required`、
|
|
60
|
+
`placeholder`、`min`、`max`、`step`、`maxLength`、`tabIndex`、`form`、
|
|
61
|
+
`options` 与 `selectedIndex` 均为活动 DOM 属性。
|
|
62
|
+
- **`document.activeElement`** 是聚焦元素;没有焦点时为 `<body>`。`tabindex`
|
|
63
|
+
决定 Tab 顺序(`tabindex="1"` 排在隐式 `0` 之前;`-1` 可点击聚焦但被 Tab
|
|
64
|
+
跳过);即使没有文本框聚焦,Tab 与 Shift+Tab 也能移动焦点。禁用或隐藏的控件
|
|
65
|
+
不能聚焦、会被 Tab 跳过,并以灰色绘制。
|
|
66
|
+
- **文本输入**来自 `SDL_EVENT_TEXT_INPUT`,它携带键盘布局或 IME 实际产生的
|
|
67
|
+
文本。`keydown` 处理编辑命令(Backspace/Delete/方向键/Home/End/Ctrl+A/C/X/V,
|
|
68
|
+
Shift 扩展选区),编辑后派发 `keypress` 与 `input`。
|
|
69
|
+
- **IME** 使用 `SDL_EVENT_TEXT_EDITING`:预编辑文本显示在光标处,并触发
|
|
70
|
+
`compositionstart` / `compositionupdate` / `compositionend`;提交内容在
|
|
71
|
+
`compositionend` 时插入值中。
|
|
72
|
+
- **剪贴板**通过 SDL 使用系统剪贴板:Ctrl+C/X/V。
|
|
73
|
+
- **事件**自动派发:文本编辑前触发可取消的 `beforeinput`,每次值变化后触发
|
|
74
|
+
`input`(输入、删除、checkbox/radio 切换、range 拖动、select 切换),值提交时
|
|
75
|
+
触发 `change`(有改动的文本框失焦、单行输入框回车、checkbox/radio 点击、
|
|
76
|
+
range 释放或 select 切换)。`input`/`change` 负载携带 `value`;`change` 还
|
|
77
|
+
携带 `checked`。
|
|
78
|
+
- **表单**:提交按钮(或单行输入框回车)在所属 `<form>` 上触发可取消的
|
|
79
|
+
`submit`,被点击时携带 `submitter`;引擎不会导航,因此是否阻止事件在视觉上
|
|
80
|
+
没有区别。重置按钮或 `form.reset()` 触发 `reset`,并把每个控件恢复到默认
|
|
81
|
+
值/勾选状态。`form.submit()` 与 `form.requestSubmit(submitter?)` 派发同一个
|
|
82
|
+
事件。
|
|
83
|
+
|
|
84
|
+
`win.sendEvent` 也接受 `{ type: "textInput", text }`(等同于 SDL 投递该文本)、
|
|
85
|
+
`{ type: "compositionstart" | "compositionupdate" | "compositionend", data }` 与
|
|
86
|
+
可打印的 `keydown`。真实的物理 `keydown` 不会插入其 US 布局的 `key`:对应的
|
|
87
|
+
文本输入事件才会插入,因此 IME 或非 US 布局不会重复字符。
|
|
88
|
+
|
|
89
|
+
完整输入仍需完成:跨多行的拖动选择与撤销/重做。
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
打开 Metal GPU 着色器校验后渲染正常——在这类机器上以
|
|
29
29
|
`MTL_SHADER_VALIDATION=1` 运行即可让
|
|
30
30
|
`tests/e2e/gui-webgl2-shadow-sampler.test.ts` 通过。这指向驱动的着色器编译器
|
|
31
|
-
|
|
31
|
+
而非引擎,因此以环境变量作为绕过办法(e2e 测试在 macOS 上会自动设置它);
|
|
32
|
+
其他 Apple GPU 未必存在该问题。
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
- **自动关闭时的偶发崩溃。** 设置 `XT_GUI_AUTOCLOSE_MS` 结束运行时,约五次中有两次会以原生
|
package/doc/zh-CN/gui/layout.md
CHANGED
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
技术栈测量(见[文本技术栈](./rendering.md))。`white-space: nowrap`
|
|
26
26
|
让一段文本不在空格处换行(源码换行会折叠为空格);在 `overflow` 不是
|
|
27
27
|
`visible` 的盒子上,`text-overflow: ellipsis` 会把溢出线放不下的部分替换为
|
|
28
|
-
单个 U+2026
|
|
28
|
+
单个 U+2026 省略号并丢弃其余内容。`overflow-wrap: break-word` / `anywhere`
|
|
29
|
+
(以及 `word-wrap` 别名)会在放不下时按当前行剩余空间的最长前缀拆分单词。
|
|
30
|
+
`text-decoration` 会解析 line/style/color 分量,并把 underline、overline 与
|
|
31
|
+
line-through 绘制为实线(dashed/dotted/wavy 会出现在计算样式中,但按实线绘制)。
|
|
29
32
|
- **Flexbox** —— `row`/`column`(以及 `-reverse` 变体),支持 `gap`、
|
|
30
33
|
`flex-basis`/`flex-grow`/`flex-shrink`、`justify-content` 与 `align-items`
|
|
31
34
|
(当交叉轴尺寸确定时包括 `stretch`)。两个方向的主轴尺寸都先取
|
|
@@ -7,3 +7,9 @@
|
|
|
7
7
|
- `createHash(algorithm)` 返回带 `update(...)` 与 `digest([encoding])` 的哈希对象。
|
|
8
8
|
- 支持流式形式(`setEncoding` / `write` / `end` / `read`)。
|
|
9
9
|
- 提供 SHA-1 与 SHA-256。
|
|
10
|
+
- `randomBytes(size[, callback])`、`randomUUID()`、`randomInt([min, ]max[, callback])`、
|
|
11
|
+
`randomFillSync(buffer[, offset[, size]])` 与 `randomFill(...)` 读取操作系统
|
|
12
|
+
CSPRNG(Windows 上的 `BCryptGenRandom`,其它平台的 `/dev/urandom`)。
|
|
13
|
+
`webcrypto` 暴露与全局 `crypto` 相同的 `getRandomValues` / `randomUUID` 对象。
|
|
14
|
+
- `pbkdf2Sync(password, salt, iterations, keylen[, digest])` 与 `pbkdf2(...)`
|
|
15
|
+
实现 PBKDF2-HMAC-SHA1/SHA-256(异步形式会立即调用回调,计算本身是同步的)。
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
| `rmSync(path[, options])` | `xt_node_rm` | 删除文件/目录,`{ recursive: true }` 递归删除 |
|
|
19
19
|
| `unlinkSync(path)` | `xt_node_unlink` | 删除文件 |
|
|
20
20
|
| `rmdirSync(path)` | `xt_node_rmdir` | 删除空目录 |
|
|
21
|
-
| `renameSync(oldPath, newPath)` | `xt_node_rename` | 重命名 /
|
|
21
|
+
| `renameSync(oldPath, newPath)` | `xt_node_rename` | 重命名 / 移动;原子替换已存在的目标(Windows 使用 `MoveFileExW` + `MOVEFILE_REPLACE_EXISTING`) |
|
|
22
22
|
| `copyFileSync(src, dest[, flags])` | `xt_node_copy_file` | 复制文件;支持 `COPYFILE_EXCL` |
|
|
23
23
|
| `cpSync(src, dest[, options])` | `xt_node_cp` | 递归复制;`recursive` / `force` / `errorOnExist` / `dereference` / `preserveTimestamps` |
|
|
24
24
|
| `realpathSync(path)` | `xt_node_realpath` | 解析为绝对路径 |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `readline`
|
|
2
|
+
|
|
3
|
+
> 属于 [Node 扩展:已实现](../node.md) · [English](../../../implemented/node/readline.md)
|
|
4
|
+
|
|
5
|
+
位置:`src/extensions/node/readline/index.ts`、`runtime/ext_node/readline/readline.c`
|
|
6
|
+
|
|
7
|
+
`createInterface(options)`(以及 `new Interface(options)`)按行读取标准输入。
|
|
8
|
+
阻塞读取运行在异步 I/O 线程池上,因此程序等待输入时事件循环仍会继续处理定时器。
|
|
9
|
+
|
|
10
|
+
| API | 说明 |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `createInterface({ input?, output?, prompt?, terminal? })` | `input`/`output` 仅作声明:实现始终读 stdin、写 stdout。`prompt` 设置初始提示符。 |
|
|
13
|
+
| `rl.on(event, fn)` / `rl.once(...)` / `rl.off(...)` / `rl.removeListener(...)` / `rl.removeAllListeners(...)` | 支持 `line`、`close`、`pause`、`resume` 事件 |
|
|
14
|
+
| `rl.question(query, callback)` | 写出 `query`,用下一行调用 `callback(answer)`;问题按顺序排队,且不触发 `line` |
|
|
15
|
+
| `rl.prompt()` / `rl.setPrompt(text)` / `rl.getPrompt()` | 写出并管理提示符(默认 `"> "`);没有行编辑 |
|
|
16
|
+
| `rl.pause()` / `rl.resume()` | 暂停期间到达的行会缓存,恢复后投递 |
|
|
17
|
+
| `rl.close()` | 触发 `close` 并停止读取;输入结束会自动关闭 |
|
|
18
|
+
| `rl.write(text)` / `rl.setRawMode(bool)` | 写到 stdout;raw mode 作为无操作接受 |
|
|
19
|
+
| `cursorTo(stream, x[, y])`、`moveCursor(stream, dx, dy)`、`clearLine(stream, dir)`、`clearScreenDown(stream)` | 写出 Node 相同的 ANSI 转义序列;stream 参数被忽略 |
|
|
20
|
+
| `emitKeypressEvents(stream[, interface])` | 作为无操作接受 |
|
|
21
|
+
|
|
22
|
+
差异:没有终端行编辑、历史、补全、`readline/promises` 或按键事件合成;
|
|
23
|
+
不会重定向自定义 `input`/`output` 流。
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createInterface } from "readline";
|
|
27
|
+
|
|
28
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
29
|
+
rl.question("name? ", (name: string) => {
|
|
30
|
+
console.log("hello " + name);
|
|
31
|
+
rl.close();
|
|
32
|
+
});
|
|
33
|
+
```
|
|
@@ -31,6 +31,7 @@ TypeScript 导出与 C 实现一一对应。新增模块不需要改动核心编
|
|
|
31
31
|
| `events` | [events](./node/events.md) | `EventEmitter`(全局与具名导出) |
|
|
32
32
|
| `util` | [util](./node/util.md) | 格式化、inspect 与类型谓词 |
|
|
33
33
|
| `querystring` | [querystring](./node/querystring.md) | parse / stringify / escape |
|
|
34
|
+
| `readline` | [readline](./node/readline.md) | 基于 stdin 的逐行/question 读取与光标辅助函数 |
|
|
34
35
|
| `assert` | [assert](./node/assert.md) | 断言函数 |
|
|
35
36
|
| `test` | [test](./node/test.md) | 最小 TAP 运行器 |
|
|
36
37
|
| `crypto` | [crypto](./node/crypto.md) | `createHash`(SHA-1 / SHA-256) |
|
|
@@ -35,17 +35,19 @@
|
|
|
35
35
|
|
|
36
36
|
## JSON
|
|
37
37
|
|
|
38
|
-
- `JSON.parse` 支持 `reviver`。
|
|
38
|
+
- `JSON.parse` 支持 `reviver`;畸形输入(错误数字/字符串、尾随内容、缺少分隔符)会抛出可捕获的 `SyntaxError`,而不是返回 `undefined`。
|
|
39
39
|
- `JSON.stringify` 支持函数或数组 `replacer`、`toJSON`,以及 `space`(数字或字符串,最多 10 个单位)。`undefined` / 函数 / symbol 值遵循标准省略规则。
|
|
40
40
|
- 对象键按插入序输出,整数键按数值排序;循环引用抛错。
|
|
41
41
|
|
|
42
42
|
## Date
|
|
43
43
|
|
|
44
44
|
- `Date` 基于 `gmtime_r`;`Date.parse` / `new Date(string)` 支持 ISO 8601 解析。
|
|
45
|
+
- `toLocaleDateString` / `toLocaleTimeString` / `toLocaleString` 按本地时间格式化(`M/D/YYYY`、`h:mm:ss AM`);支持少量 options(`weekday`/`year`/`month`/`day`/`hour`/`minute`/`second`/`hour12`)。另有 `toDateString` / `toTimeString` / `toUTCString`;无效日期格式化为 `Invalid Date`。
|
|
45
46
|
|
|
46
47
|
## RegExp
|
|
47
48
|
|
|
48
|
-
- `RegExp`
|
|
49
|
+
- `RegExp` 在所有宿主上都使用运行时自带的 POSIX ERE 兼容匹配器(`regcomp` / `regexec` 风格),因此结果不依赖平台 libc。捕获组可经 `exec` / `match` / `replace` / `split` / `search` 使用。
|
|
50
|
+
- 量词支持 `*`、`+`、`?` 以及计数形式 `{n}`、`{n,}`、`{n,m}`(可带惰性 `?` 后缀)。`{x}`、`{,2}` 这类畸形花括号组保持字面量,与 JavaScript 一致;`{2,1}` 这类倒置范围同样按字面量处理,而不是报错。
|
|
49
51
|
- 匹配按字节进行,且 `/g` / `/y` 的 `lastIndex` 不被读取 —— 见[运行时偏差](../unimplemented/deviations.md)。
|
|
50
52
|
|
|
51
53
|
## Symbol
|
|
@@ -90,3 +92,9 @@
|
|
|
90
92
|
- `btoa` / `atob` base64 编解码(核心全局函数,并非 Node 扩展专属)。
|
|
91
93
|
- `structuredClone`:数组、对象、`Map`、`Set`、`Date`、`RegExp` 与类型化数组,保留循环引用与共享引用;函数、symbol、Promise、生成器会被拒绝。
|
|
92
94
|
- 定时器、`queueMicrotask` 与 `performance.now` 见[异步、Promise 与生成器](./async.md);`fetch` 见 [fetch](./fetch.md)。
|
|
95
|
+
|
|
96
|
+
## 全局 crypto
|
|
97
|
+
|
|
98
|
+
- `crypto.getRandomValues(typedArray)` 从操作系统 CSPRNG 填充整数类型化数组(最多 65 536 字节)并返回;`crypto.randomUUID()` 返回 v4 UUID 字符串。`crypto` 也是一等对象,方法可脱离对象使用(`const uuid = crypto.randomUUID`)。
|
|
99
|
+
- `Math.random` 使用由操作系统 CSPRNG 播种的 xoshiro256** 流(53 位随机性),不再使用 C `rand()`。
|
|
100
|
+
- Node 的 `crypto.randomBytes` / `randomInt` / `randomFillSync` / `pbkdf2Sync` 见 [node/crypto](../implemented/node/crypto.md)。
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
> 属于[Node 扩展:未实现](../node.md) · [English](../../../unimplemented/node/modules.md)
|
|
4
4
|
|
|
5
|
-
以下 Node 内置模块没有任何对应扩展 / 内置函数(`fs` / `fs/promises` / `path` / `os` / `process` / `buffer` / `stream` / `dgram` / `http` / `events` / `util` / `querystring` / `assert` / `test` 已实现,`crypto` / `url` / `child_process` / `zlib` / `stream/promises` / `worker_threads` 部分实现,见[已实现:Node 扩展](../../implemented/node.md)):
|
|
5
|
+
以下 Node 内置模块没有任何对应扩展 / 内置函数(`fs` / `fs/promises` / `path` / `os` / `process` / `buffer` / `stream` / `dgram` / `http` / `events` / `util` / `querystring` / `readline` / `assert` / `test` 已实现,`crypto` / `url` / `child_process` / `zlib` / `stream/promises` / `worker_threads` 部分实现,见[已实现:Node 扩展](../../implemented/node.md)):
|
|
6
6
|
|
|
7
7
|
| 模块 | 说明 |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| `https` | TLS 版 HTTP |
|
|
10
|
-
| `readline` | 命令行读取 |
|
|
11
10
|
| `tls` / `cluster` / `vm` | 其余未列出的核心模块 |
|
|
12
11
|
|
|
13
12
|
> `crypto`(仅 `createHash`,现支持流式 API)、`url`(仅 `pathToFileURL` / `fileURLToPath`)、
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
> 属于[未实现语法与功能](../unimplemented.md) · [English](../../unimplemented/node.md)
|
|
4
4
|
|
|
5
|
-
Node 扩展实现了
|
|
5
|
+
Node 扩展实现了 22 个模块以及事件循环集成;已实现表面按模块记录在
|
|
6
6
|
[Node 扩展:已实现](../implemented/node.md)。本节记录缺失或与 Node 不同之处。
|
|
7
7
|
|
|
8
8
|
## 目录
|
|
9
9
|
|
|
10
10
|
- [`fs`](./node/fs.md) —— 回调式异步操作、真正的文件监听、选项回调
|
|
11
11
|
- [`fs/promises`](./node/fs-promises.md) —— `FileHandle` 追加/读取偏移、`Dir` 回调立即完成、`watch` 不触发、无取消
|
|
12
|
-
- [完全未实现的模块](./node/modules.md) —— `https`、`
|
|
12
|
+
- [完全未实现的模块](./node/modules.md) —— `https`、`tls`、`cluster`、`vm` 等
|
|
13
13
|
- [全局对象与命名空间](./node/globals.md) —— `global`、`__dirname`、`node_modules` 之外的 `require`
|
|
14
14
|
- [异步与事件循环模型](./node/async.md) —— 文件监听缺失、阻塞式 `net.connect`、无 keep-alive、固定大小线程池
|
|
15
15
|
- [Bun 扩展](./node/bun.md) —— 仅为设计示例
|