@bablr/bablr-vm 0.20.1 → 0.22.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/lib/context.js CHANGED
@@ -2,14 +2,17 @@ import { buildDependentLanguages } from '@bablr/helpers/grammar';
2
2
  import { facades, actuals } from './facades.js';
3
3
  import { getPrototypeOf } from '@bablr/helpers/object';
4
4
  import { states as nodeStates } from './node.js';
5
+ import { PathFacade as Path } from '@bablr/agast-vm';
5
6
 
6
7
  import { sourceTextFor } from '@bablr/agast-helpers/stream';
7
8
  import { streamFromTree } from '@bablr/agast-helpers/tree';
8
- import { allTagsFor, buildFullRange, Path, TagPath } from '@bablr/agast-helpers/path';
9
+ import { allTagsFor } from '@bablr/agast-helpers/path-facade';
10
+ import { buildEmbeddedNode } from '@bablr/agast-vm-helpers/builders';
9
11
 
10
12
  export const ContextFacade = class BABLRContextFacade {
11
13
  constructor(actual) {
12
14
  facades.set(actual, this);
15
+ Object.freeze(this);
13
16
  }
14
17
 
15
18
  get languages() {
@@ -37,18 +40,16 @@ export const ContextFacade = class BABLRContextFacade {
37
40
  fragmentStream = streamFromTree(node);
38
41
  } else if (nodeStates.has(node)) {
39
42
  let state = nodeStates.get(node);
40
- let { childrenIndexRange } = state;
43
+ let { tagsIndexRange } = state;
41
44
  let path = Path.from(state.fragmentNode);
42
45
 
43
- if (!childrenIndexRange) {
44
- childrenIndexRange = buildFullRange(state.node);
46
+ if (!tagsIndexRange) {
47
+ let nodePath = Path.from(state.node);
48
+ tagsIndexRange = [0, nodePath.tagPathAt(-1).tagsIndex];
45
49
  }
46
50
 
47
51
  fragmentStream = allTagsFor(
48
- [
49
- TagPath.from(path, childrenIndexRange[0]),
50
- TagPath.from(path, childrenIndexRange[1] ?? undefined),
51
- ],
52
+ [path.tagPathAt(tagsIndexRange[0], 0), path.tagPathAt(tagsIndexRange[1], -1)],
52
53
  { unshift: true },
53
54
  );
54
55
  } else {