bare-type-stripper 0.1.4 → 0.1.6
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/CMakeLists.txt +1 -0
- package/README.md +5 -26
- package/binding.c +103 -11
- package/index.d.ts +21 -0
- package/index.js +20 -13
- package/lib/strip.h +52 -4
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-type-stripper.bare +0 -0
- package/prebuilds/android-arm/bare-type-stripper.node +0 -0
- package/prebuilds/android-arm64/bare-type-stripper.bare +0 -0
- package/prebuilds/android-arm64/bare-type-stripper.node +0 -0
- package/prebuilds/android-ia32/bare-type-stripper.bare +0 -0
- package/prebuilds/android-ia32/bare-type-stripper.node +0 -0
- package/prebuilds/android-x64/bare-type-stripper.bare +0 -0
- package/prebuilds/android-x64/bare-type-stripper.node +0 -0
- package/prebuilds/darwin-arm64/bare-type-stripper.bare +0 -0
- package/prebuilds/darwin-arm64/bare-type-stripper.node +0 -0
- package/prebuilds/darwin-x64/bare-type-stripper.bare +0 -0
- package/prebuilds/darwin-x64/bare-type-stripper.node +0 -0
- package/prebuilds/ios-arm64/bare-type-stripper.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-type-stripper.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-type-stripper.bare +0 -0
- package/prebuilds/linux-arm64/bare-type-stripper.bare +0 -0
- package/prebuilds/linux-arm64/bare-type-stripper.node +0 -0
- package/prebuilds/linux-x64/bare-type-stripper.bare +0 -0
- package/prebuilds/linux-x64/bare-type-stripper.node +0 -0
- package/prebuilds/win32-arm64/bare-type-stripper.bare +0 -0
- package/prebuilds/win32-arm64/bare-type-stripper.node +0 -0
- package/prebuilds/win32-x64/bare-type-stripper.bare +0 -0
- package/prebuilds/win32-x64/bare-type-stripper.node +0 -0
package/CMakeLists.txt
CHANGED
package/README.md
CHANGED
|
@@ -20,32 +20,7 @@ strip(`
|
|
|
20
20
|
|
|
21
21
|
## API
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Strip TypeScript-only syntax from `source` and return plain JavaScript as a `Buffer`. Stripped regions are replaced with spaces (newlines preserved) so the output has the same byte length as the input, keeping stack traces and source positions aligned.
|
|
26
|
-
|
|
27
|
-
`source` may be a string or a `Buffer`. When a string, `encoding` selects the character encoding (defaults to `'utf8'`).
|
|
28
|
-
|
|
29
|
-
Throws a `SyntaxError` when the source contains non-erasable TypeScript syntax (see below).
|
|
30
|
-
|
|
31
|
-
Options are reserved.
|
|
32
|
-
|
|
33
|
-
#### `const ranges = strip.lex(source[, encoding][, options])`
|
|
34
|
-
|
|
35
|
-
Return the raw `[start, end, flags?]` ranges that `strip()` would erase, without applying them. The optional third element is a bitmap of flags from `strip.constants` that controls how a single byte in the range is rewritten (instead of being blanked to a space).
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
strip.lex('const x: number = 1')
|
|
39
|
-
// [ [ 7, 16 ] ]
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
#### `strip.constants`
|
|
43
|
-
|
|
44
|
-
| Constant | Description |
|
|
45
|
-
| :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
-
| `SEMI` | The first byte of the range becomes `;` instead of a space. Used on whole-statement strips (`type`, `interface`, `declare`, `import type`, `export type/interface`) and on the first stripped modifier of a class member to keep ASI from folding the preceding statement or field into what follows. |
|
|
47
|
-
| `PAREN` | The first byte of the range becomes `)` instead of a space. Used together with a wider strip range to relocate an arrow function's closing `)` down to the line where `=>` lives, when the (now stripped) return-type annotation spanned newlines. |
|
|
48
|
-
| `ERROR` | The range marks non-erasable TypeScript syntax that cannot be stripped to valid JavaScript. `strip()` throws a `SyntaxError` when a lexed range carries this flag; `lex()` returns the range so callers can implement their own handling. |
|
|
23
|
+
See the [`bare-type-stripper` reference](https://docs.pears.com/reference/bare/modules/bare-type-stripper).
|
|
49
24
|
|
|
50
25
|
## What gets stripped
|
|
51
26
|
|
|
@@ -85,6 +60,10 @@ Constructs with runtime semantics that a purely lexical stripper cannot reproduc
|
|
|
85
60
|
|
|
86
61
|
The stripper targets plain `.ts` sources; JSX (`.tsx`) is not supported and is reported as non-erasable syntax.
|
|
87
62
|
|
|
63
|
+
## Threat model
|
|
64
|
+
|
|
65
|
+
`bare-type-stripper` is one of the addons Bare compiles into its binary, so it inherits [Bare's threat model](https://github.com/holepunchto/bare/blob/main/docs/threat-model.md). See [`docs/threat-model.md`](docs/threat-model.md) for where this addon sits in it.
|
|
66
|
+
|
|
88
67
|
## License
|
|
89
68
|
|
|
90
69
|
Apache-2.0
|
package/binding.c
CHANGED
|
@@ -1,31 +1,121 @@
|
|
|
1
1
|
#include <assert.h>
|
|
2
2
|
#include <bare.h>
|
|
3
3
|
#include <js.h>
|
|
4
|
+
#include <stdbool.h>
|
|
5
|
+
#include <stdint.h>
|
|
4
6
|
#include <stdlib.h>
|
|
5
7
|
#include <string.h>
|
|
6
8
|
#include <uv.h>
|
|
7
9
|
|
|
8
10
|
#include "lib/strip.h"
|
|
9
11
|
|
|
12
|
+
static int
|
|
13
|
+
bare_type_stripper__get_int64(js_env_t *env, js_value_t *value, int64_t *result) {
|
|
14
|
+
int err;
|
|
15
|
+
|
|
16
|
+
bool is_number;
|
|
17
|
+
err = js_is_number(env, value, &is_number);
|
|
18
|
+
assert(err == 0);
|
|
19
|
+
|
|
20
|
+
if (!is_number) return -1;
|
|
21
|
+
|
|
22
|
+
err = js_get_value_int64(env, value, result);
|
|
23
|
+
assert(err == 0);
|
|
24
|
+
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
static js_value_t *
|
|
11
29
|
bare_type_stripper_lex(js_env_t *env, js_callback_info_t *info) {
|
|
12
30
|
int err;
|
|
13
31
|
|
|
14
|
-
size_t argc =
|
|
15
|
-
js_value_t *argv[
|
|
32
|
+
size_t argc = 3;
|
|
33
|
+
js_value_t *argv[3];
|
|
16
34
|
|
|
17
35
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
18
36
|
assert(err == 0);
|
|
19
37
|
|
|
20
|
-
|
|
38
|
+
bool is_arraybuffer;
|
|
39
|
+
err = js_is_arraybuffer(env, argv[0], &is_arraybuffer);
|
|
40
|
+
assert(err == 0);
|
|
21
41
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
err = js_get_typedarray_info(env, argv[0], NULL, (void **) &input, (size_t *) &len, NULL, NULL);
|
|
42
|
+
bool is_sharedarraybuffer;
|
|
43
|
+
err = js_is_sharedarraybuffer(env, argv[0], &is_sharedarraybuffer);
|
|
25
44
|
assert(err == 0);
|
|
26
45
|
|
|
46
|
+
if (!is_arraybuffer && !is_sharedarraybuffer) {
|
|
47
|
+
err = js_throw_type_error(env, NULL, "Input must be a buffer");
|
|
48
|
+
assert(err == 0);
|
|
49
|
+
|
|
50
|
+
return NULL;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void *data;
|
|
54
|
+
size_t byte_len;
|
|
55
|
+
|
|
56
|
+
if (is_sharedarraybuffer) {
|
|
57
|
+
err = js_get_sharedarraybuffer_info(env, argv[0], &data, &byte_len);
|
|
58
|
+
} else {
|
|
59
|
+
err = js_get_arraybuffer_info(env, argv[0], &data, &byte_len);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
assert(err == 0);
|
|
63
|
+
|
|
64
|
+
int64_t offset;
|
|
65
|
+
if (bare_type_stripper__get_int64(env, argv[1], &offset) < 0) {
|
|
66
|
+
err = js_throw_type_error(env, NULL, "Offset must be a number");
|
|
67
|
+
assert(err == 0);
|
|
68
|
+
|
|
69
|
+
return NULL;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
int64_t len;
|
|
73
|
+
if (bare_type_stripper__get_int64(env, argv[2], &len) < 0) {
|
|
74
|
+
err = js_throw_type_error(env, NULL, "Length must be a number");
|
|
75
|
+
assert(err == 0);
|
|
76
|
+
|
|
77
|
+
return NULL;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (offset < 0 || len < 0 || (uint64_t) offset + (uint64_t) len > byte_len) {
|
|
81
|
+
err = js_throw_range_error(env, NULL, "Offset and length are out of bounds");
|
|
82
|
+
assert(err == 0);
|
|
83
|
+
|
|
84
|
+
return NULL;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if ((uint64_t) len > UINT32_MAX) {
|
|
88
|
+
err = js_throw_range_error(env, NULL, "Length is out of bounds");
|
|
89
|
+
assert(err == 0);
|
|
90
|
+
|
|
91
|
+
return NULL;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
utf8_t *input = (utf8_t *) data + offset;
|
|
95
|
+
|
|
96
|
+
// Another thread may write shared memory while we read it, and the ranges we
|
|
97
|
+
// record must describe one input. Lex a private copy instead.
|
|
98
|
+
utf8_t *copy = NULL;
|
|
99
|
+
|
|
100
|
+
if (is_sharedarraybuffer && len > 0) {
|
|
101
|
+
copy = malloc((size_t) len);
|
|
102
|
+
|
|
103
|
+
if (copy == NULL) {
|
|
104
|
+
err = js_throw_error(env, NULL, "Out of memory");
|
|
105
|
+
assert(err == 0);
|
|
106
|
+
|
|
107
|
+
return NULL;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
memcpy(copy, input, (size_t) len);
|
|
111
|
+
|
|
112
|
+
input = copy;
|
|
113
|
+
}
|
|
114
|
+
|
|
27
115
|
bare_type_stripper_t ctx;
|
|
28
|
-
err = bare_type_stripper__lex(&ctx, input, len);
|
|
116
|
+
err = bare_type_stripper__lex(&ctx, input, (size_t) len);
|
|
117
|
+
|
|
118
|
+
free(copy);
|
|
29
119
|
|
|
30
120
|
if (err < 0) {
|
|
31
121
|
free(ctx.ranges);
|
|
@@ -38,17 +128,19 @@ bare_type_stripper_lex(js_env_t *env, js_callback_info_t *info) {
|
|
|
38
128
|
|
|
39
129
|
// Hand the ranges to JS as a single Uint32Array of (start, end, flags)
|
|
40
130
|
// triples.
|
|
131
|
+
size_t size = (size_t) ctx.len * 3;
|
|
132
|
+
|
|
41
133
|
js_value_t *arraybuffer;
|
|
42
|
-
uint32_t *
|
|
43
|
-
err = js_create_arraybuffer(env,
|
|
134
|
+
uint32_t *data_out;
|
|
135
|
+
err = js_create_arraybuffer(env, size * sizeof(uint32_t), (void **) &data_out, &arraybuffer);
|
|
44
136
|
assert(err == 0);
|
|
45
137
|
|
|
46
|
-
if (ctx.len) memcpy(
|
|
138
|
+
if (ctx.len) memcpy(data_out, ctx.ranges, size * sizeof(uint32_t));
|
|
47
139
|
|
|
48
140
|
free(ctx.ranges);
|
|
49
141
|
|
|
50
142
|
js_value_t *ranges;
|
|
51
|
-
err = js_create_typedarray(env, js_uint32array,
|
|
143
|
+
err = js_create_typedarray(env, js_uint32array, size, arraybuffer, 0, &ranges);
|
|
52
144
|
assert(err == 0);
|
|
53
145
|
|
|
54
146
|
return ranges;
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import Buffer, { BufferEncoding } from 'bare-buffer'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Strip TypeScript-only syntax from `input` and return plain JavaScript as a `Buffer`. Stripped
|
|
5
|
+
* regions are replaced with spaces (newlines preserved) so the output has the same byte length as
|
|
6
|
+
* the input, keeping stack traces and source positions aligned.
|
|
7
|
+
* @param input - The TypeScript source to strip, as a string or a `Buffer`. The input is copied
|
|
8
|
+
* before it is lexed, so a buffer backed by a `SharedArrayBuffer` cannot change under the strip.
|
|
9
|
+
* @param encoding - Encoding used to decode `input` when it is a string (default `'utf8'`); ignored
|
|
10
|
+
* when `input` is already a `Buffer`.
|
|
11
|
+
* @param opts - An options object; currently unused.
|
|
12
|
+
* @throws {TypeError} `input` is neither a string nor a buffer.
|
|
13
|
+
* @throws {SyntaxError} the source contains non-erasable TypeScript syntax (`enum`/`const enum`,
|
|
14
|
+
* `namespace`/`module` with a body, parameter properties, or angle-bracket type assertions).
|
|
15
|
+
*/
|
|
3
16
|
declare function strip(input: string | Buffer, encoding?: BufferEncoding, opts?: object): Buffer
|
|
4
17
|
|
|
5
18
|
declare namespace strip {
|
|
19
|
+
/**
|
|
20
|
+
* Lex `input` and return the ranges `strip()` would replace, as `[start, end, flags?]` triples.
|
|
21
|
+
* @param input - The TypeScript source to lex, as a string or a `Buffer`. A buffer backed by a
|
|
22
|
+
* `SharedArrayBuffer` is copied before it is lexed; transfer a plain `ArrayBuffer` when that copy
|
|
23
|
+
* matters.
|
|
24
|
+
* @param encoding - Encoding used to decode `input` when it is a string (default `'utf8'`).
|
|
25
|
+
* @param opts - An options object; currently unused.
|
|
26
|
+
*/
|
|
6
27
|
export function lex(
|
|
7
28
|
input: string | Buffer,
|
|
8
29
|
encoding?: BufferEncoding,
|
package/index.js
CHANGED
|
@@ -6,13 +6,12 @@ module.exports = exports = function strip(input, encoding, opts = {}) {
|
|
|
6
6
|
encoding = null
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const buffer = typeof input === 'string' ? Buffer.from(input, encoding) : input
|
|
9
|
+
// Strip a copy of the input: the ranges must be applied to the same bytes
|
|
10
|
+
// they were lexed from, which shared memory would otherwise let another
|
|
11
|
+
// thread change in between.
|
|
12
|
+
const buffer = Buffer.from(toBuffer(input, encoding))
|
|
14
13
|
|
|
15
|
-
const ranges = binding.lex(buffer)
|
|
14
|
+
const ranges = binding.lex(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
|
16
15
|
|
|
17
16
|
check(buffer, ranges)
|
|
18
17
|
|
|
@@ -25,11 +24,9 @@ exports.lex = function lex(input, encoding, opts = {}) {
|
|
|
25
24
|
encoding = null
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
throw new TypeError(`Input must be a string or buffer. Received type ${typeof input}`)
|
|
30
|
-
}
|
|
27
|
+
const buffer = toBuffer(input, encoding)
|
|
31
28
|
|
|
32
|
-
const ranges = binding.lex(
|
|
29
|
+
const ranges = binding.lex(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
|
33
30
|
|
|
34
31
|
// The binding returns the ranges as a flat Uint32Array of (start, end,
|
|
35
32
|
// flags) triples; reshape into the nested form.
|
|
@@ -68,6 +65,18 @@ exports.constants = {
|
|
|
68
65
|
ERROR: binding.ERROR
|
|
69
66
|
}
|
|
70
67
|
|
|
68
|
+
function toBuffer(input, encoding) {
|
|
69
|
+
if (typeof input === 'string') return Buffer.from(input, encoding)
|
|
70
|
+
|
|
71
|
+
if (!ArrayBuffer.isView(input)) {
|
|
72
|
+
throw new TypeError(`Input must be a string or buffer. Received type ${typeof input}`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Views with a wider element type, such as 'Float64Array' or 'DataView',
|
|
76
|
+
// are lexed as the bytes they span rather than as their elements.
|
|
77
|
+
return Buffer.from(input.buffer, input.byteOffset, input.byteLength)
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
function check(buffer, ranges) {
|
|
72
81
|
for (let r = 0; r < ranges.length; r += 3) {
|
|
73
82
|
if ((ranges[r + 2] & binding.ERROR) === 0) continue
|
|
@@ -95,9 +104,7 @@ function check(buffer, ranges) {
|
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
106
|
|
|
98
|
-
function apply(
|
|
99
|
-
const out = Buffer.from(buffer)
|
|
100
|
-
|
|
107
|
+
function apply(out, ranges) {
|
|
101
108
|
// The lexer emits ranges in scan order: A single-byte flag patch that
|
|
102
109
|
// overlaps a wider strip range (PAREN relocates ')' into a stripped span)
|
|
103
110
|
// always follows that range, so applying in array order keeps the patched
|
package/lib/strip.h
CHANGED
|
@@ -20,6 +20,11 @@ enum {
|
|
|
20
20
|
#define BARE_TYPE_STRIPPER__PAREN_CACHE_SIZE 512 // Power of two
|
|
21
21
|
#define BARE_TYPE_STRIPPER__PAREN_STACK_SIZE 512
|
|
22
22
|
|
|
23
|
+
// Arrow-function lookahead budget, as a multiple of the input length. Cached
|
|
24
|
+
// matches keep well-formed input far below this; it only binds on input
|
|
25
|
+
// crafted to defeat the cache.
|
|
26
|
+
#define BARE_TYPE_STRIPPER__SCAN_BUDGET_FACTOR 64
|
|
27
|
+
|
|
23
28
|
// Lexer context. Carries the input, the accumulated strip ranges, and a
|
|
24
29
|
// small cache of paren match positions used by the arrow-function lookahead.
|
|
25
30
|
typedef struct {
|
|
@@ -39,6 +44,13 @@ typedef struct {
|
|
|
39
44
|
// position 2 or later, so 0 can't be a valid close.
|
|
40
45
|
size_t paren_open[BARE_TYPE_STRIPPER__PAREN_CACHE_SIZE];
|
|
41
46
|
size_t paren_close[BARE_TYPE_STRIPPER__PAREN_CACHE_SIZE];
|
|
47
|
+
|
|
48
|
+
// Bytes the arrow-function lookahead may still scan. The match cache keeps
|
|
49
|
+
// well-formed input linear, but a '(' that never closes can't be cached, so
|
|
50
|
+
// without a budget every '(' in an unclosed tail would rescan it. Running
|
|
51
|
+
// the budget down stops the lookahead from recognizing further arrow
|
|
52
|
+
// functions, degrading the same way exceeding MAX_DEPTH does.
|
|
53
|
+
size_t scan_budget;
|
|
42
54
|
} bare_type_stripper_t;
|
|
43
55
|
|
|
44
56
|
// Previous-token classification, used to decide how to interpret the next
|
|
@@ -99,16 +111,18 @@ bare_type_stripper__add_range_flags(bare_type_stripper_t *ctx, size_t start, siz
|
|
|
99
111
|
assert(end > start);
|
|
100
112
|
|
|
101
113
|
if (ctx->len == ctx->cap) {
|
|
114
|
+
if (ctx->cap > UINT32_MAX / 2) return -1;
|
|
115
|
+
|
|
102
116
|
uint32_t cap = ctx->cap == 0 ? 64 : ctx->cap * 2;
|
|
103
117
|
|
|
104
|
-
uint32_t *ranges = realloc(ctx->ranges, cap * 3 * sizeof(uint32_t));
|
|
118
|
+
uint32_t *ranges = realloc(ctx->ranges, (size_t) cap * 3 * sizeof(uint32_t));
|
|
105
119
|
if (ranges == NULL) return -1;
|
|
106
120
|
|
|
107
121
|
ctx->ranges = ranges;
|
|
108
122
|
ctx->cap = cap;
|
|
109
123
|
}
|
|
110
124
|
|
|
111
|
-
uint32_t *entry = &ctx->ranges[ctx->len * 3];
|
|
125
|
+
uint32_t *entry = &ctx->ranges[(size_t) ctx->len * 3];
|
|
112
126
|
|
|
113
127
|
entry[0] = (uint32_t) start;
|
|
114
128
|
entry[1] = (uint32_t) end;
|
|
@@ -479,6 +493,10 @@ bare_type_stripper__scan_group(bare_type_stripper_t *ctx, size_t i) {
|
|
|
479
493
|
size_t slot = i & (BARE_TYPE_STRIPPER__PAREN_CACHE_SIZE - 1);
|
|
480
494
|
if (ctx->paren_close[slot] != 0 && ctx->paren_open[slot] == i) return ctx->paren_close[slot];
|
|
481
495
|
|
|
496
|
+
if (ctx->scan_budget == 0) return n;
|
|
497
|
+
|
|
498
|
+
size_t start = i;
|
|
499
|
+
|
|
482
500
|
// Positions of the unclosed '(' at each depth, so every nested match
|
|
483
501
|
// discovered along the way gets cached as well. Levels deeper than the
|
|
484
502
|
// stack still balance, they just aren't recorded.
|
|
@@ -516,6 +534,25 @@ bare_type_stripper__scan_group(bare_type_stripper_t *ctx, size_t i) {
|
|
|
516
534
|
i++;
|
|
517
535
|
}
|
|
518
536
|
|
|
537
|
+
size_t scanned = i - start;
|
|
538
|
+
|
|
539
|
+
ctx->scan_budget = ctx->scan_budget > scanned ? ctx->scan_budget - scanned : 0;
|
|
540
|
+
|
|
541
|
+
// Groups still open at end of input never match. Record them as closing
|
|
542
|
+
// there so the next '(' in an unclosed tail answers from the cache instead
|
|
543
|
+
// of rescanning that tail.
|
|
544
|
+
if (depth > 0) {
|
|
545
|
+
int open_depth = depth < BARE_TYPE_STRIPPER__PAREN_STACK_SIZE ? depth : BARE_TYPE_STRIPPER__PAREN_STACK_SIZE;
|
|
546
|
+
|
|
547
|
+
for (int d = 0; d < open_depth; d++) {
|
|
548
|
+
size_t open = opens[d];
|
|
549
|
+
size_t unclosed_slot = open & (BARE_TYPE_STRIPPER__PAREN_CACHE_SIZE - 1);
|
|
550
|
+
|
|
551
|
+
ctx->paren_open[unclosed_slot] = open;
|
|
552
|
+
ctx->paren_close[unclosed_slot] = i;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
519
556
|
return i;
|
|
520
557
|
}
|
|
521
558
|
|
|
@@ -1199,9 +1236,11 @@ bare_type_stripper__process_class_body(bare_type_stripper_t *ctx, size_t *result
|
|
|
1199
1236
|
i = bare_type_stripper__skip_method_head_prefix(s, n, i, true);
|
|
1200
1237
|
|
|
1201
1238
|
// Member name.
|
|
1202
|
-
if (u(0) == '#') i++; // Private name
|
|
1239
|
+
if (i < n && u(0) == '#') i++; // Private name
|
|
1240
|
+
|
|
1241
|
+
if (i >= n) break;
|
|
1203
1242
|
|
|
1204
|
-
if (
|
|
1243
|
+
if (ids(u(0))) {
|
|
1205
1244
|
while (i < n && id(u(0))) i++;
|
|
1206
1245
|
} else if (u(0) == '\'' || u(0) == '"') {
|
|
1207
1246
|
i = bare_type_stripper__skip_string(s, n, i);
|
|
@@ -1679,6 +1718,13 @@ bare_type_stripper__process_named_specifiers(bare_type_stripper_t *ctx, size_t *
|
|
|
1679
1718
|
if (i >= n) break;
|
|
1680
1719
|
if (u(0) == '}') break;
|
|
1681
1720
|
|
|
1721
|
+
// Nothing below consumes a byte that can't open a specifier name, so step
|
|
1722
|
+
// over it here to keep the loop advancing.
|
|
1723
|
+
if (!id(u(0)) && u(0) != '\'' && u(0) != '"' && !(allow_star && u(0) == '*')) {
|
|
1724
|
+
i++;
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1682
1728
|
size_t spec_start = i;
|
|
1683
1729
|
bool is_type = false;
|
|
1684
1730
|
|
|
@@ -3060,6 +3106,8 @@ bare_type_stripper__lex(bare_type_stripper_t *ctx, const utf8_t *s, size_t n) {
|
|
|
3060
3106
|
ctx->len = 0;
|
|
3061
3107
|
ctx->cap = 0;
|
|
3062
3108
|
|
|
3109
|
+
ctx->scan_budget = n * BARE_TYPE_STRIPPER__SCAN_BUDGET_FACTOR;
|
|
3110
|
+
|
|
3063
3111
|
memset(ctx->paren_close, 0, sizeof(ctx->paren_close));
|
|
3064
3112
|
|
|
3065
3113
|
return bare_type_stripper__walk(ctx, &i, 0, true, false, 0);
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|