@zvenigora/ng-eval-core 0.13.3 → 0.14.1
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/CHANGELOG.md +116 -2
- package/README.md +17 -4
- package/fesm2022/zvenigora-ng-eval-core.mjs +282 -70
- package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
- package/package.json +1 -1
- package/types/zvenigora-ng-eval-core.d.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,120 @@ Versions 0.1.104–0.1.107 are on npm without entries here.
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
+
## [Unreleased]
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## [0.14.1] - 2026-10-30
|
|
18
|
+
|
|
19
|
+
**A patch that fixes [A47](../../docs/backlog-retired.md#a47)**, an arrow's parameter scope under
|
|
20
|
+
`caseInsensitive`, with three changes that are documentation only; the `.d.ts` differs from
|
|
21
|
+
0.14.0's only in the JSDoc of `ParserService.parserOptions`
|
|
22
|
+
([A30](../../docs/backlog-retired.md#a30)).
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- The internal `contextPush`'s JSDoc says what every scope push site does since
|
|
26
|
+
[A42](../../docs/backlog-retired.md#a42): it calls `contextPush(st.context, …)`, its pop runs in
|
|
27
|
+
a `finally`, and both no-op on an absent context. It said each site wrote `st.context?.push(...)`
|
|
28
|
+
([F27](../../docs/backlog-retired.md#f27)). Documentation only: the comment reaches the bundle,
|
|
29
|
+
not the `.d.ts`.
|
|
30
|
+
- The disabled visitor result cache is deleted ([A32](../../docs/backlog-retired.md#a32)). Nothing
|
|
31
|
+
called it or exported it. Documentation only: the bundle loses the commented-out import and call
|
|
32
|
+
sites in the binary and member visitors, and no code; the `.d.ts` is unchanged.
|
|
33
|
+
- `ParserService.parserOptions`' JSDoc says what the setter configures
|
|
34
|
+
([A30](../../docs/backlog-retired.md#a30)): direct `ParserService.parse` calls, whose own options'
|
|
35
|
+
keys win, but for `cacheSize`. `EvalService`, `CompilerService` and `DiscoveryService` pass their
|
|
36
|
+
own options on every parse, which carry every key of `defaultParserOptions`, so only `cacheSize`
|
|
37
|
+
and a key it does not carry, such as `colonIdentifiers`, reach them through the setter.
|
|
38
|
+
`cacheSize` is read from the setter's value alone: it sizes the parse cache once, at
|
|
39
|
+
construction, and a later falsy one stops every parse using the cache, the services' included,
|
|
40
|
+
while a call's or a service's own `cacheSize` changes nothing. No behaviour changes.
|
|
41
|
+
Documentation only: the JSDoc reaches the `.d.ts` and the bundle.
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
- **Under `caseInsensitive`, an arrow's parameters are matched case-insensitively**, as a `let`
|
|
45
|
+
or `const` already was: `(x => X)(1)` gives `1` and `(({ a }) => A)({ a: 4 })` gives `4`, where
|
|
46
|
+
each gave `undefined`, or the context's own value when the context held the name in any
|
|
47
|
+
spelling: over `{ x: 10 }`, `(x => X)(1)` gave `10`. Such a read is now a scope read, so a
|
|
48
|
+
dependency tracker no longer records it as a dependency, where it recorded `X`. A case-variant
|
|
49
|
+
write reaches the parameter, not the caller's context:
|
|
50
|
+
`(x => (X = 5, x))(1)` over `{}` gives `5` and leaves the context empty, where it gave `1` and
|
|
51
|
+
wrote a key `X` there. A case-variant write to a parameter named like a literal,
|
|
52
|
+
`(TRUE => (True = 2))(1)`, writes the parameter, where since 0.13.2 it threw
|
|
53
|
+
`Assignment to read-only name` ([A47](../../docs/backlog-retired.md#a47)).
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## [0.14.0] - 2026-10-26
|
|
58
|
+
|
|
59
|
+
**An assignment evaluates its target as JavaScript does.** A minor carrying breaking changes
|
|
60
|
+
([A45](../../docs/backlog-retired.md#a45) part 2, [A44](../../docs/backlog-retired.md#a44),
|
|
61
|
+
[A52](../../docs/backlog-retired.md#a52); the [A45 plan](../../docs/a45/plan.md)). No exported
|
|
62
|
+
symbol changes shape: the `.d.ts` is byte-identical to 0.13.3's. What changes is behaviour —
|
|
63
|
+
which reads an assignment makes and reports, which key a `caseInsensitive` write reaches, and what
|
|
64
|
+
an identifier holding `null` reads as under `caseInsensitive`. `eval-signals` 0.7.0 and `eval-forms` 0.7.0 raise
|
|
65
|
+
their floors to it.
|
|
66
|
+
|
|
67
|
+
### Breaking
|
|
68
|
+
- **A compound or logical assignment reads its target once, and does not walk it.** A
|
|
69
|
+
member target's object and key are evaluated once, before the right side, and the write reuses
|
|
70
|
+
them: `getObj()[k()] += f()` runs `getObj`, `k`, the read, `f`, then the write, where up to 0.13.3
|
|
71
|
+
it evaluated the object, the key and the read a second time after `f`. A getter on the target is
|
|
72
|
+
called once where it was called twice. Two are read twice where they were read four times: a
|
|
73
|
+
prototype accessor under `caseInsensitive` ([A48](../../docs/backlog.md#a48)), and an accessor
|
|
74
|
+
on the context reached through `this` ([A49](../../docs/backlog.md#a49)). The read events are those of that one read, `a`, then `a.b`, where each was reported
|
|
75
|
+
twice; node hooks and the trace see the target's object and a computed key, and no longer the
|
|
76
|
+
target node, and an identifier target not at all. The value read still passes the checks every
|
|
77
|
+
read value passes, so a listed function as the target, `fetch += 1` or `obj.fetch ||= 1`, is
|
|
78
|
+
still refused ([A45](../../docs/backlog-retired.md#a45), part 2).
|
|
79
|
+
- **`=` does not read its target, and walks it no further than its object and a computed
|
|
80
|
+
key.** As in JavaScript, `getObj()[k()] = f()` runs `getObj`, `k`, `f`, then the write, where up
|
|
81
|
+
to 0.13.3 it read the target, and after `f` evaluated the object and the key and read the target a
|
|
82
|
+
second time. A getter on the target is not called, except an accessor on the context reached
|
|
83
|
+
through `this`, which is called once where it was called four times
|
|
84
|
+
([A49](../../docs/backlog.md#a49)); under `caseInsensitive` a lookup answering an identifier
|
|
85
|
+
target's name is called once, where it was called twice (A49). A listed function as the target is overwritten
|
|
86
|
+
as `obj.fetch++` overwrites one, so `fetch = 1` and `obj.fetch = 1` write `1` where they were
|
|
87
|
+
refused; `fetch += 1` and `fetch ||= 1` read it, and are still refused. The read events are the
|
|
88
|
+
object's own reads: `a.b = 1` reports `a`, where it reported `a` and `a.b` twice each, and
|
|
89
|
+
`x = 1` and `this.x = 1` report nothing. Node hooks and the trace see the object and a computed
|
|
90
|
+
key, and no longer the target node, and an identifier target not at all. The blocklist checks a
|
|
91
|
+
target was given by being read stay, before the right side: `constructor = 1` and
|
|
92
|
+
`o.__proto__ = f()` are refused with `f` not called. Case-sensitive, a `null` or `undefined`
|
|
93
|
+
object with a blocklisted key, `n.constructor = 1`, is now refused as a dangerous property, as it
|
|
94
|
+
already was under `caseInsensitive`, where it was refused as `Cannot set property on non-object`
|
|
95
|
+
([A45](../../docs/backlog-retired.md#a45), part 2).
|
|
96
|
+
- **An identifier update reports the read of its operand**: `x++` and `++x` report one
|
|
97
|
+
read of `x`, as `a.b++` reports one of `a.b`, where they reported none. So a dependency tracker
|
|
98
|
+
records `x`, and a `for` loop's `i++` adds its reads, each flagged `scoped`.
|
|
99
|
+
|
|
100
|
+
### Changed
|
|
101
|
+
- **The README states what an assignment target reads and reports**, in the `AssignmentExpression`
|
|
102
|
+
row and beside `onRead`, with the reads that remain beyond JavaScript's, and that under
|
|
103
|
+
`caseInsensitive` a member write or update reaches the key the read would match. No code change.
|
|
104
|
+
|
|
105
|
+
### Fixed
|
|
106
|
+
- **Under `caseInsensitive`, a member write reaches the key the read would match**: `OBJ.X = 2`,
|
|
107
|
+
`obj["X"] = 2`, `OBJ.X += 1` and `OBJ.X++` on `{ obj: { x: 1 } }` write `x`, where they created a new key `X`
|
|
108
|
+
beside it, and `c.G = 1` calls the setter `g` an instance inherits. A key the lookup matches on
|
|
109
|
+
nothing is written as spelled ([A44](../../docs/backlog-retired.md#a44)).
|
|
110
|
+
- **Under `caseInsensitive`, an identifier holding `null` reads as `null`**, where it read as
|
|
111
|
+
`undefined`: `x === null` is `true`, and `x += 1` gives `1`, where it gave `NaN`. The literals
|
|
112
|
+
registry now answers only a name the context finds nothing for
|
|
113
|
+
([A52](../../docs/backlog-retired.md#a52)).
|
|
114
|
+
|
|
115
|
+
### Security
|
|
116
|
+
- **An identifier update of a blocklisted name is refused**, as its assignment is: `constructor++`,
|
|
117
|
+
`toString++` and `__proto__++` throw `Access to dangerous property … is blocked for security
|
|
118
|
+
reasons`, where up to 0.13.3 the first two wrote an own key onto the caller's context, and under
|
|
119
|
+
`caseInsensitive` all three wrote into its copy.
|
|
120
|
+
- **An identifier update of `this` written as a name is refused**, as every other use of it outside
|
|
121
|
+
a member's object is: `This++` under `caseInsensitive`, and a host-built `this++`, throw `Access
|
|
122
|
+
to "this" outside a member access is blocked for security reasons`, where up to 0.13.3 they wrote
|
|
123
|
+
`NaN` under that key.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
13
127
|
## [0.13.3] - 2026-10-23
|
|
14
128
|
|
|
15
129
|
### Fixed
|
|
@@ -19,7 +133,7 @@ Versions 0.1.104–0.1.107 are on npm without entries here.
|
|
|
19
133
|
longer fires when the assignment short-circuits and writes nothing, as in JavaScript. Logical
|
|
20
134
|
assignment is ES2021, and the default parser options, at `ecmaVersion: 2020`, refuse it at the
|
|
21
135
|
parse, so this reaches only a caller whose own parser options set `ecmaVersion` to 2021 or later
|
|
22
|
-
([A45](../../docs/backlog.md#a45), part 1).
|
|
136
|
+
([A45](../../docs/backlog-retired.md#a45), part 1).
|
|
23
137
|
|
|
24
138
|
---
|
|
25
139
|
|
|
@@ -29,7 +143,7 @@ Versions 0.1.104–0.1.107 are on npm without entries here.
|
|
|
29
143
|
- **The README states a limit of `caseInsensitive` on a context built with `new EvalContext`**: a
|
|
30
144
|
plain object handed to the constructor matches no case variant, even with the option passed to
|
|
31
145
|
the walk too, and `EvalContext.fromContext` is the way to build one that does. No code change
|
|
32
|
-
([A44](../../docs/backlog.md#a44), where it was measured).
|
|
146
|
+
([A44](../../docs/backlog-retired.md#a44), where it was measured).
|
|
33
147
|
|
|
34
148
|
### Fixed
|
|
35
149
|
- **An update converts its operand to a number once, as JavaScript does**, and uses that one
|
package/README.md
CHANGED
|
@@ -274,12 +274,23 @@ The project has been tested with the following node types:
|
|
|
274
274
|
- `TemplateLiteral`
|
|
275
275
|
- `TaggedTemplateExpression`
|
|
276
276
|
- `ObjectExpression`
|
|
277
|
-
- `AssignmentExpression` — to an identifier or a member, parenthesised or not.
|
|
278
|
-
|
|
277
|
+
- `AssignmentExpression` — to an identifier or a member, parenthesised or not. Since 0.14.0 the
|
|
278
|
+
target is evaluated as JavaScript evaluates it: a member target's object and key once, then
|
|
279
|
+
the target's value only for a compound or logical operator, then the right side, then the
|
|
280
|
+
write. So `=` does not read its target, and `+=` or `||=` reads it once; up to 0.13.3 the
|
|
281
|
+
target was read as an operand, and a member target was evaluated again after the right side.
|
|
282
|
+
Three kinds of read remain beyond JavaScript's. Case-sensitive, a getter `g` on the context,
|
|
283
|
+
reached through `this`: `this.g = 1` calls it once and `this.g += 1` twice. Under
|
|
284
|
+
`caseInsensitive`, a lookup that answers an identifier target: `x = 1` calls it once and
|
|
285
|
+
`x += 1` twice. And under `caseInsensitive`, a getter an instance inherits: `c.g += 1` calls it
|
|
286
|
+
twice, as `c.g` does. Destructuring assignment, `[a, b] = arr` or `({ m } = o)`, throws
|
|
287
|
+
`Unsupported assignment target`;
|
|
279
288
|
before `@zvenigora/ng-eval-core` 0.7.0 it silently did nothing. An identifier write that
|
|
280
289
|
would shadow `undefined`, or under `caseInsensitive` a literal, throws
|
|
281
290
|
`Assignment to read-only name`, since 0.13.2
|
|
282
|
-
- `UpdateExpression` — to an identifier or a member, parenthesised or not
|
|
291
|
+
- `UpdateExpression` — to an identifier or a member, parenthesised or not. Under
|
|
292
|
+
`caseInsensitive` a member update writes the key its read matched, since 0.14.0: `OBJ.X++`
|
|
293
|
+
on `{ obj: { x: 1 } }` writes `x`
|
|
283
294
|
- `ArrowFunctionExpression` *potentially unsafe* (AssignmentPattern is not implemented, so a
|
|
284
295
|
destructuring default — `({ a = 1 }) => a` — is rejected rather than defaulted)
|
|
285
296
|
- `SequenceExpression` — each expression in order, the value the last one's
|
|
@@ -351,7 +362,7 @@ To change the evaluator's default behaviour, pass `options`: the last argument o
|
|
|
351
362
|
|
|
352
363
|
### Case-insensitive evaluation
|
|
353
364
|
|
|
354
|
-
While JavaScript is a case-sensitive language, some may find it hard to use. To provide case-insensitive evaluation, set `caseInsensitive` to `true`. It applies to identifiers and to member names alike.
|
|
365
|
+
While JavaScript is a case-sensitive language, some may find it hard to use. To provide case-insensitive evaluation, set `caseInsensitive` to `true`. It applies to identifiers and to member names alike. Since 0.14.0 a member write reaches the key the read would match: `OBJ.X = 2` on `{ obj: { x: 1 } }` writes `x`, where up to 0.13.3 it created a key `X` beside it. A key that matches nothing is written as spelled.
|
|
355
366
|
|
|
356
367
|
```javascript
|
|
357
368
|
import { EvalService } from '@zvenigora/ng-eval-core';
|
|
@@ -521,6 +532,8 @@ state.hooks.onRead((event) => {
|
|
|
521
532
|
});
|
|
522
533
|
```
|
|
523
534
|
|
|
535
|
+
Since 0.14.0 an assignment or an update reports the reads JavaScript makes: `a.b = 1` reports `a` and not `a.b`, `x = 1` reports nothing, a compound or logical assignment one read of its target — `a.b += 1` reports `a`, then `a.b` — and `x++` one read of `x`.
|
|
536
|
+
|
|
524
537
|
If you want a dependency set rather than raw events, `createDependencyTracker()` builds one and applies the `scoped` filtering for you.
|
|
525
538
|
|
|
526
539
|
#### Statements and the empty-completion sentinel
|