@jxsuite/runtime 4.0.3 → 5.1.0
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/runtime.js +749 -473
- package/dist/runtime.js.map +12 -12
- package/package.json +5 -4
- package/src/cookie.ts +4 -2
- package/src/css.ts +31 -18
- package/src/expression.ts +321 -232
- package/src/pointer.ts +10 -4
- package/src/runtime.ts +1399 -611
- package/src/statements.ts +58 -48
- package/src/types.ts +114 -13
package/src/pointer.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* @docs framework/concepts/references
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import type { JxScope, JxScopeValue } from "./types.ts";
|
|
20
|
+
|
|
19
21
|
/** `~1` is `/` and `~0` is `~`; RFC 6901 §4 fixes this order so `~01` becomes `~1`, not `/`. */
|
|
20
22
|
export function unescapeToken(token: string): string {
|
|
21
23
|
return token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
@@ -45,14 +47,18 @@ export function refSegments(path: string): string[] {
|
|
|
45
47
|
/**
|
|
46
48
|
* Walk a value along a `$ref` path, or `undefined` where the path leaves the object.
|
|
47
49
|
*
|
|
48
|
-
* @param {
|
|
50
|
+
* @param {JxScopeValue} root - A scope, or any member read from one
|
|
49
51
|
* @param {string} path
|
|
50
|
-
* @returns {
|
|
52
|
+
* @returns {JxScopeValue}
|
|
51
53
|
*/
|
|
52
|
-
export function readPath(root:
|
|
54
|
+
export function readPath(root: JxScopeValue, path: string): JxScopeValue {
|
|
53
55
|
let current = root;
|
|
54
56
|
for (const key of refSegments(path)) {
|
|
55
|
-
|
|
57
|
+
/* SAFETY: `?.` stops at null and undefined, and every other JavaScript value, primitives
|
|
58
|
+
included, answers a member read by name (a string's `length`, an array's index). Reading by
|
|
59
|
+
name is how the runtime sees any object, as the `JxScope` record of its members, so the
|
|
60
|
+
member it answers is one more scope member. */
|
|
61
|
+
current = (current as JxScope | null | undefined)?.[key];
|
|
56
62
|
}
|
|
57
63
|
return current;
|
|
58
64
|
}
|