@doenet/v06-to-v07 0.7.26-dev.571 → 0.7.26-dev.573

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.
Files changed (51) hide show
  1. package/apply-assign-name-renames.d.ts +14 -0
  2. package/apply-assign-name-renames.d.ts.map +1 -0
  3. package/assign-names/apply-renames.d.ts +21 -0
  4. package/assign-names/apply-renames.d.ts.map +1 -0
  5. package/assign-names/break-into-pieces.d.ts +34 -0
  6. package/assign-names/break-into-pieces.d.ts.map +1 -0
  7. package/assign-names/composite-info.d.ts +61 -0
  8. package/assign-names/composite-info.d.ts.map +1 -0
  9. package/assign-names/context.d.ts +103 -0
  10. package/assign-names/context.d.ts.map +1 -0
  11. package/assign-names/prop-access-parts.d.ts +14 -0
  12. package/assign-names/prop-access-parts.d.ts.map +1 -0
  13. package/assign-names/register-assign-names.d.ts +38 -0
  14. package/assign-names/register-assign-names.d.ts.map +1 -0
  15. package/assign-names/register-composite.d.ts +26 -0
  16. package/assign-names/register-composite.d.ts.map +1 -0
  17. package/assign-names/rename-registry.d.ts +90 -0
  18. package/assign-names/rename-registry.d.ts.map +1 -0
  19. package/assign-names/visit-all.d.ts +35 -0
  20. package/assign-names/visit-all.d.ts.map +1 -0
  21. package/core-info/core.d.ts +1 -0
  22. package/core-info/core.d.ts.map +1 -1
  23. package/core-info/determine-prop-type.d.ts +9 -0
  24. package/core-info/determine-prop-type.d.ts.map +1 -1
  25. package/{index-Cxf3BQNw.js → index-4M4L_2sg.js} +2286 -318
  26. package/{index-Cxf3BQNw.js.map → index-4M4L_2sg.js.map} +1 -1
  27. package/index.d.ts.map +1 -1
  28. package/index.js +1 -1
  29. package/normalize-capitalization.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/{sha256-8sXzDnE0-hQwEEL17-DD-3Noo4.js → sha256-8sXzDnE0-BtProggv-BVCPcIg2.js} +2 -2
  32. package/{sha256-8sXzDnE0-hQwEEL17-DD-3Noo4.js.map → sha256-8sXzDnE0-BtProggv-BVCPcIg2.js.map} +1 -1
  33. package/slash-to-dot.d.ts.map +1 -1
  34. package/upgrade-assign-names.d.ts +32 -0
  35. package/upgrade-assign-names.d.ts.map +1 -0
  36. package/upgrade-attribute-syntax.d.ts +4 -1
  37. package/upgrade-attribute-syntax.d.ts.map +1 -1
  38. package/upgrade-collect-element.d.ts +4 -1
  39. package/upgrade-collect-element.d.ts.map +1 -1
  40. package/upgrade-copy-elements.d.ts +45 -0
  41. package/upgrade-copy-elements.d.ts.map +1 -0
  42. package/upgrade-copy-syntax.d.ts.map +1 -1
  43. package/upgrade-deprecated-attributes.d.ts +12 -0
  44. package/upgrade-deprecated-attributes.d.ts.map +1 -0
  45. package/upgrade-list-props.d.ts +4 -0
  46. package/upgrade-list-props.d.ts.map +1 -0
  47. package/upgrade-map-element.d.ts +4 -1
  48. package/upgrade-map-element.d.ts.map +1 -1
  49. package/upgrade-module-element.d.ts.map +1 -1
  50. package/utils.d.ts +34 -2
  51. package/utils.d.ts.map +1 -1
@@ -0,0 +1,14 @@
1
+ import { Plugin } from 'unified';
2
+ import { DastRoot } from '../packages/parser/dist';
3
+ import { AssignNamesContext } from './assign-names/context';
4
+ /**
5
+ * Rewrite every reference to a v0.6 `assignNames` name, using the renames collected by
6
+ * `upgradeCollectElement`, `upgradeMapElement` and `upgradeAssignNames`.
7
+ *
8
+ * This runs once, after all of them, so that a reference is rewritten exactly once no
9
+ * matter which plugin claimed the name.
10
+ */
11
+ export declare const applyAssignNameRenames: Plugin<[
12
+ AssignNamesContext
13
+ ], DastRoot, DastRoot>;
14
+ //# sourceMappingURL=apply-assign-name-renames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-assign-name-renames.d.ts","sourceRoot":"","sources":["../src/apply-assign-name-renames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CACvC;IAAC,kBAAkB;CAAC,EACpB,QAAQ,EACR,QAAQ,CAKX,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { DastMacroPathPart, DastRoot } from '../../packages/parser/dist';
2
+ import { VFile } from 'vfile';
3
+ import { RenameRegistry } from './rename-registry';
4
+ import { AssignNamesContext } from './context';
5
+ /**
6
+ * Rewrite every reference to a v0.6 `assignNames` token into the v0.7 indexed path
7
+ * registered for it.
8
+ *
9
+ * Unlike the per-plugin passes this replaces, it descends into attribute values, macro
10
+ * path indices and function-macro arguments, and it preserves indices the author already
11
+ * wrote (`$a[2]` becomes `$s[1][2]`, not `$s[1]`).
12
+ */
13
+ export declare function applyRefRenames(tree: DastRoot, registry: RenameRegistry, file: VFile, context: AssignNamesContext): void;
14
+ /**
15
+ * Parse the value of a dollar-less reference attribute into a path.
16
+ *
17
+ * A hyphenated name can only be written inside `$(...)`: `$foo-bar` is a subtraction. The
18
+ * bare form is tried first so that everything else parses exactly as it always has.
19
+ */
20
+ export declare function parseReferencePath(value: string): DastMacroPathPart[];
21
+ //# sourceMappingURL=apply-renames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-renames.d.ts","sourceRoot":"","sources":["../../src/assign-names/apply-renames.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,iBAAiB,EACjB,QAAQ,EAGX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,WAAW,CAAC;AAmBjE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,kBAAkB,QAwC9B;AAwID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAarE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A parsed `assignNames` value. A string is a name assigned to a replacement; a nested
3
+ * array means "descend into that replacement and assign these names to *its* replacements".
4
+ */
5
+ export type NamePieces = (string | NamePieces)[];
6
+ export type BreakResult = {
7
+ success: true;
8
+ pieces: NamePieces;
9
+ } | {
10
+ success: false;
11
+ };
12
+ /**
13
+ * Port of v0.6's `breakStringInPiecesBySpacesOrParens`
14
+ * (`utils/serializedStateProcessing.js`). Splits an `assignNames` value on whitespace,
15
+ * with parentheses creating nested groups.
16
+ *
17
+ * ```
18
+ * "a b" -> ["a", "b"]
19
+ * "(a b) (c d)" -> [["a", "b"], ["c", "d"]]
20
+ * "((x)) ((y))" -> [[["x"]], [["y"]]]
21
+ * "(a" -> { success: false }
22
+ * ```
23
+ *
24
+ * The quirks are deliberate and match v0.6 exactly, since the documents being converted
25
+ * were authored against them: unbalanced parentheses fail outright rather than falling
26
+ * back to whitespace splitting, and empty groups are dropped.
27
+ */
28
+ export declare function breakStringInPiecesBySpacesOrParens(string: string): BreakResult;
29
+ /**
30
+ * The first plain name in `pieces`, in document order, descending into nested groups.
31
+ * Returns `undefined` if there are no names at all.
32
+ */
33
+ export declare function firstLeafName(pieces: NamePieces): string | undefined;
34
+ //# sourceMappingURL=break-into-pieces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"break-into-pieces.d.ts","sourceRoot":"","sources":["../../src/assign-names/break-into-pieces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mCAAmC,CAC/C,MAAM,EAAE,MAAM,GACf,WAAW,CAkEb;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAWpE"}
@@ -0,0 +1,61 @@
1
+ import { DastElement } from '../../packages/parser/dist';
2
+ import { VFile } from 'vfile';
3
+ import { PositionMap } from './register-assign-names';
4
+ export type CompositeSpec = {
5
+ /** Canonical v0.7 spelling, used for generated names and messages. */
6
+ name: string;
7
+ /**
8
+ * How to tell whether the composite produces exactly one replacement, which is what
9
+ * makes the `assignNames="a"` -> `name="a"` shortcut safe.
10
+ */
11
+ count: {
12
+ kind: "always-one";
13
+ } | {
14
+ kind: "attr";
15
+ attr: string;
16
+ } | {
17
+ kind: "unknown";
18
+ };
19
+ /**
20
+ * The child element that is a transparent wrapper around a group of replacements.
21
+ * v0.7 flattens these, so names inside them sit one index deeper.
22
+ */
23
+ grouping?: {
24
+ childName: string;
25
+ alsoMatch?: string[];
26
+ };
27
+ /** The element itself has no v0.7 equivalent; warn while still fixing references. */
28
+ noV07Equivalent?: boolean;
29
+ };
30
+ /**
31
+ * The v0.6 composites that accept `assignNames` and are not already owned by another
32
+ * plugin. `copy`, `collect`, `map` and `customAttribute` are deliberately absent: they are
33
+ * handled by `copySourceToExtendOrCopy`/`upgradeCopySyntax`, `upgradeCollectElement`,
34
+ * `upgradeMapElement` and `upgradeModuleElement` respectively.
35
+ */
36
+ export declare const COMPOSITES: Record<string, CompositeSpec>;
37
+ export declare function lookupComposite(node: DastElement): CompositeSpec | undefined;
38
+ /**
39
+ * Whether the composite provably produces a single replacement. When it does, a bare
40
+ * `$name` reference auto-flattens to that replacement, so `assignNames="a"` can simply
41
+ * become `name="a"` with no reference rewriting at all.
42
+ */
43
+ export declare function producesSingleReplacement(node: DastElement, spec: CompositeSpec): boolean;
44
+ export declare function findAttribute(node: DastElement, attrName: string): import('../../packages/parser/dist').DastAttribute | undefined;
45
+ /**
46
+ * Build a {@link PositionMap} accounting for the fact that v0.6 skipped bare text when
47
+ * handing out `assignNames`, while v0.7's `[i]` counts every replacement.
48
+ *
49
+ * Only the level *inside* a transparent `<case>`/`<option>` wrapper can be affected, since
50
+ * that is the only level whose members are authored children rather than generated
51
+ * replacements. Returns `undefined` (meaning "identity") when no branch mixes bare text
52
+ * with components, which is the overwhelmingly common case.
53
+ */
54
+ export declare function makePositionMap(node: DastElement, spec: CompositeSpec, file: VFile): PositionMap | undefined;
55
+ /**
56
+ * The `<map>` counterpart of {@link makePositionMap}: its `<template>` is the single
57
+ * branch, and its children sit at the same depth as an `<option>`/`<case>`'s do — one
58
+ * index for the iteration, then one for the position within it.
59
+ */
60
+ export declare function makeTemplatePositionMap(template: DastElement, node: DastElement, file: VFile): PositionMap | undefined;
61
+ //# sourceMappingURL=composite-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composite-info.d.ts","sourceRoot":"","sources":["../../src/assign-names/composite-info.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,MAAM,aAAa,GAAG;IACxB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,EACC;QAAE,IAAI,EAAE,YAAY,CAAA;KAAE,GACtB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC9B;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACvD,qFAAqF;IACrF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CA4CpD,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACrC,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,aAAa,GACpB,OAAO,CAeT;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sDAIhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,KAAK,GACZ,WAAW,GAAG,SAAS,CAqBzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,KAAK,GACZ,WAAW,GAAG,SAAS,CAEzB"}
@@ -0,0 +1,103 @@
1
+ import { DastElement, DastRoot, DastRootV6 } from '../../packages/parser/dist';
2
+ import { NamePieces } from './break-into-pieces';
3
+ import { RenameRegistry } from './rename-registry';
4
+ import { UniqueNameFactory } from '../utils';
5
+ import { VFile } from 'vfile';
6
+ /**
7
+ * Per-document state shared by every plugin that consumes `assignNames`, so that all of
8
+ * them contribute to one registry and hand out names from one pool.
9
+ */
10
+ export type AssignNamesContext = {
11
+ registry: RenameRegistry;
12
+ uniqueName: UniqueNameFactory;
13
+ /** Names carried by a `name=` attribute, used to detect shadowing. */
14
+ existingNames: Set<string>;
15
+ /**
16
+ * Assigned names that have already been promoted to some composite's `name`. Two
17
+ * composites can carry the same `assignNames` token, and only one of them can end up
18
+ * with the bare name.
19
+ *
20
+ * This pool is deliberately document-wide, which is stricter than v0.7 requires:
21
+ * v0.7 resolves a name by searching outwards from the reference, so two components
22
+ * with the same name are fine as long as they sit under different parents, and a
23
+ * reference that could see both is the only thing that fails (`NonUniqueReferent` in
24
+ * `ref_resolve`). Being strict costs a generated name in the handful of places where
25
+ * an assigned name is already used elsewhere, and buys output that cannot be
26
+ * ambiguous however the references are written. Relaxing it to "taken only by a
27
+ * sibling" is a deliberate design change, not an oversight.
28
+ */
29
+ claimedNames: Set<string>;
30
+ /**
31
+ * The elements that carried `newNamespace`, recorded before that attribute is
32
+ * removed. Only these were namespaces in v0.6, so only these are boundaries when
33
+ * working out which of two same-named assignments a reference meant.
34
+ *
35
+ * The value is how the namespace appears in a reference path: its `name`, or — for a
36
+ * namespace without one, such as the `<template newNamespace>` of a `<map>` — a
37
+ * stand-in that no written path can match. An unnamed namespace cannot be reached
38
+ * from outside, but it still keeps its contents apart from a sibling's.
39
+ */
40
+ namespaceElements: WeakMap<DastElement, string>;
41
+ /**
42
+ * For each name carried by a `name=` attribute, the v0.6 namespaces it sat in,
43
+ * outermost first — the same shape `namespaceChainOf` produces.
44
+ *
45
+ * {@link existingNames} answers "can anything still be called this?", which after
46
+ * flattening is a question about the whole document. This answers the different
47
+ * question of whether a reference written somewhere was already about a real
48
+ * component, which v0.6 resolved per namespace.
49
+ */
50
+ existingNameScopes: Map<string, string[][]>;
51
+ };
52
+ export declare function createAssignNamesContext(tree: DastRoot | DastRootV6): AssignNamesContext;
53
+ /**
54
+ * Whether a real component called `name` sits in the very namespace `ancestorNames`
55
+ * names — the only place a bare reference written there would have found one instead of
56
+ * an assigned name, since v0.6 let a nearer assignment shadow an outer component.
57
+ */
58
+ export declare function nameTakenInScope(context: AssignNamesContext, name: string, ancestorNames: string[] | undefined): boolean;
59
+ /**
60
+ * Decide what the v0.7 `name` of a composite carrying `assignNames` should be.
61
+ *
62
+ * Preference order:
63
+ * 1. the `name` it already has;
64
+ * 2. the first assigned name, so the author's own vocabulary survives
65
+ * (`assignNames="a b"` becomes `name="a"`, with `$a` -> `$a[1]`, `$b` -> `$a[2]`);
66
+ * 3. a generated unique name, when the first assigned name is not a legal v0.7 name,
67
+ * already belongs to some other component, or has already been claimed this way.
68
+ */
69
+ export declare function chooseCompositeName(node: DastElement, pieces: NamePieces, fallbackBase: string, context: AssignNamesContext, file?: VFile): string;
70
+ /**
71
+ * Give `node` the name `name` and drop its `assignNames`.
72
+ *
73
+ * When there is no existing `name` attribute, the `assignNames` attribute is renamed in
74
+ * place so that attribute order (and therefore the shape of the converted source) is
75
+ * preserved.
76
+ */
77
+ export declare function setCompositeName(node: DastElement, name: string): void;
78
+ /**
79
+ * The value of an element's `assignNames` attribute, or `undefined` if it has none.
80
+ */
81
+ export declare function readAssignNames(node: DastElement): string | undefined;
82
+ /**
83
+ * Drop an `assignNames` attribute. v0.7 ignores it, but leaving it in the output trips
84
+ * schema validation and makes "did this document convert?" impossible to grep for.
85
+ */
86
+ export declare function deleteAssignNames(node: DastElement): void;
87
+ /**
88
+ * The `name`s of the elements enclosing a composite, outermost first.
89
+ *
90
+ * `visit` and `visitAll` both report parents nearest-first, which is the opposite of how
91
+ * a reference path reads, so the chain is reversed here. Elements without a name are
92
+ * skipped: they were never addressable, so a reference could not have mentioned them.
93
+ */
94
+ export declare function namespaceChainOf(parents: DastElement[], context: AssignNamesContext): string[];
95
+ /**
96
+ * Record that `to` now stands where `from` stood, so it keeps its namespace.
97
+ *
98
+ * `<map>` over a `<sequence>` becomes a `<repeatForSequence>` built from the sequence
99
+ * element, which throws away the `<template>` — and the template is what carried
100
+ * `newNamespace`. Without this the names assigned inside it would look top-level.
101
+ */
102
+ export declare function inheritNamespace(from: DastElement, to: DastElement, context: AssignNamesContext): void;
103
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/assign-names/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,QAAQ,EACR,UAAU,EAIb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAiB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,cAAc,EAA4B,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACH,iBAAiB,EAGpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAG9B;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,sEAAsE;IACtE,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B;;;;;;;;;;;;;OAaG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B;;;;;;;;;OASG;IACH,iBAAiB,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAChD;;;;;;;;OAQG;IACH,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;CAC/C,CAAC;AAEF,wBAAgB,wBAAwB,CACpC,IAAI,EAAE,QAAQ,GAAG,UAAU,GAC5B,kBAAkB,CA6DpB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EAAE,GAAG,SAAS,GACpC,OAAO,CAWT;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,CAAC,EAAE,KAAK,GACb,MAAM,CAgCR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,QA6B/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAMrE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,QAKlD;AAQD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,WAAW,EAAE,EACtB,OAAO,EAAE,kBAAkB,GAC5B,MAAM,EAAE,CAYV;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,WAAW,EACjB,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,kBAAkB,QAM9B"}
@@ -0,0 +1,14 @@
1
+ import { DastElement, DastMacroPathPart } from '../../packages/parser/dist';
2
+ /** Record that `part` was written after a `.`, so it names a prop and not a component. */
3
+ export declare function markAsPropAccess(part: DastMacroPathPart): void;
4
+ /** Whether `part` was written after a `.`. See {@link markAsPropAccess}. */
5
+ export declare function isPropAccess(part: DastMacroPathPart): boolean;
6
+ /**
7
+ * Record that the parts at `positions` in this attribute's path were written after a `.`.
8
+ */
9
+ export declare function markRawPropPositions(node: DastElement, attrName: string, positions: number[]): void;
10
+ /**
11
+ * Put the marks recorded by {@link markRawPropPositions} back on a freshly parsed path.
12
+ */
13
+ export declare function restoreRawPropPositions(node: DastElement, attrName: string, path: DastMacroPathPart[]): void;
14
+ //# sourceMappingURL=prop-access-parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prop-access-parts.d.ts","sourceRoot":"","sources":["../../src/assign-names/prop-access-parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAoBhE,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,QAEvD;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAE7D;AAeD;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EAAE,QAQtB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,iBAAiB,EAAE,QAY5B"}
@@ -0,0 +1,38 @@
1
+ import { VFile } from 'vfile';
2
+ import { RenameOrigin, RenameRegistry } from './rename-registry';
3
+ /**
4
+ * Translates a v0.6 nesting position into the v0.7 positional index.
5
+ *
6
+ * v0.6 skipped primitive (bare string) replacements when handing out `assignNames`,
7
+ * whereas v0.7's `[i]` counts every replacement including text. When they differ, the
8
+ * caller supplies a map. `depth` is 1-based (1 is the composite's own replacements).
9
+ */
10
+ /**
11
+ * Maps an ordinal to the v0.7 index at that depth, or `undefined` when v0.6's ordinal
12
+ * named nothing there — see `makePositionMap`.
13
+ */
14
+ export type PositionMap = (depth: number, ordinal: number) => number | undefined;
15
+ export type RegisterAssignNamesArgs = {
16
+ /** The raw `assignNames` attribute value. */
17
+ assignNamesValue: string;
18
+ /** The v0.7 `name` the composite will carry. */
19
+ compositeName: string;
20
+ registry: RenameRegistry;
21
+ origin: RenameOrigin;
22
+ file: VFile;
23
+ positionMap?: PositionMap;
24
+ };
25
+ /**
26
+ * Register every name in a v0.6 `assignNames` value against the v0.7 indexed path that
27
+ * replaces it.
28
+ *
29
+ * A leaf name at nested position `(p1 … pk)` becomes `$<compositeName>[p1]…[pk]`, which is
30
+ * how v0.7 addresses the replacement that v0.6 would have given that name. See the
31
+ * conversion notes in `upgrade-assign-names.ts` for why this single rule covers every
32
+ * composite.
33
+ *
34
+ * Returns `false` (having registered nothing and emitted a message) if the value has
35
+ * unbalanced parentheses.
36
+ */
37
+ export declare function registerAssignNames({ assignNamesValue, compositeName, registry, origin, file, positionMap, }: RegisterAssignNamesArgs): boolean;
38
+ //# sourceMappingURL=register-assign-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-assign-names.d.ts","sourceRoot":"","sources":["../../src/assign-names/register-assign-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAK9B,OAAO,EACH,YAAY,EACZ,cAAc,EAGjB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,KACd,MAAM,GAAG,SAAS,CAAC;AAIxB,MAAM,MAAM,uBAAuB,GAAG;IAClC,6CAA6C;IAC7C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,EAChC,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,WAAiC,GACpC,EAAE,uBAAuB,GAAG,OAAO,CAoEnC"}
@@ -0,0 +1,26 @@
1
+ import { DastElement } from '../../packages/parser/dist';
2
+ import { VFile } from 'vfile';
3
+ import { AssignNamesContext } from './context';
4
+ import { PositionMap } from './register-assign-names';
5
+ /**
6
+ * Parse an element's `assignNames`, pick the v0.7 name the composite will carry, and
7
+ * register the indexed path that replaces each assigned name.
8
+ *
9
+ * Returns the chosen name, or `undefined` when the value names nothing — either because
10
+ * it could not be parsed (in which case a message has been recorded) or because it parsed
11
+ * to no names at all, as `assignNames="()"` does. Nothing is registered in either case.
12
+ * The caller is responsible for putting the name on the element — `<map>` puts it on the
13
+ * `<repeat>` it produces rather than on the element that carried `assignNames`.
14
+ */
15
+ export declare function registerCompositeAssignNames({ node, assignNamesValue, fallbackBase, ancestorNames, context, file, positionMap, }: {
16
+ node: DastElement;
17
+ assignNamesValue: string;
18
+ /** Base name to generate from when the assigned names cannot be reused. */
19
+ fallbackBase: string;
20
+ /** See `RenameOrigin.ancestorNames`. */
21
+ ancestorNames?: string[];
22
+ context: AssignNamesContext;
23
+ file: VFile;
24
+ positionMap?: PositionMap;
25
+ }): string | undefined;
26
+ //# sourceMappingURL=register-composite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-composite.d.ts","sourceRoot":"","sources":["../../src/assign-names/register-composite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAK9B,OAAO,EAAE,kBAAkB,EAAuB,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,WAAW,EAAuB,MAAM,yBAAyB,CAAC;AAE3E;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,EACzC,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,IAAI,EACJ,WAAW,GACd,EAAE;IACC,IAAI,EAAE,WAAW,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B,GAAG,MAAM,GAAG,SAAS,CA2CrB"}
@@ -0,0 +1,90 @@
1
+ import { DastElement, DastMacroPathPart } from '../../packages/parser/dist';
2
+ import { VFile } from 'vfile';
3
+ /**
4
+ * A name is a legal v0.7 component name *and* can be referenced.
5
+ *
6
+ * A hyphen is allowed. `$a-b` would parse as a subtraction, but the parenthesized form
7
+ * `$(a-b)` does not, and that is the only form v0.6 could reference such a name with
8
+ * either. `toXml` re-adds the parentheses around any path part containing a hyphen, so
9
+ * `$(a-b[1])` round-trips.
10
+ */
11
+ export declare const VALID_REFERENCEABLE_NAME: RegExp;
12
+ export declare function isValidReferenceableName(name: string): boolean;
13
+ export type RenameOrigin = {
14
+ /** The element that carried the `assignNames` attribute; used in messages. */
15
+ elementName: string;
16
+ /**
17
+ * The element that ends up carrying the new name. A reference written *on* that
18
+ * element cannot mean the name it is about to take — `<copy source="../x0"
19
+ * assignNames="x0">` reaches out of its namespace for the thing it copies — so
20
+ * renames from this origin are not applied there.
21
+ */
22
+ element?: DastElement;
23
+ position?: DastElement["position"];
24
+ /**
25
+ * The `name`s of the elements enclosing the composite, outermost first.
26
+ *
27
+ * v0.6 namespaces meant the same assigned name could appear more than once in a
28
+ * document, and a reference said which it meant by writing the namespace in front of
29
+ * it (`$(g2/a)`). Flattening the namespaces away loses that, so it is recorded here
30
+ * and matched against the front of the reference path.
31
+ */
32
+ ancestorNames?: string[];
33
+ };
34
+ export type RenameTarget = {
35
+ /**
36
+ * The path parts that replace a matched path part. Always length 1 in practice, but
37
+ * kept as an array so the splice site reads the same as the existing plugins.
38
+ *
39
+ * `undefined` means the name was claimed as a composite's v0.7 `name`, so references
40
+ * to it already resolve and must be left exactly as the author wrote them. Such an
41
+ * entry exists only so that a second composite assigning the same name is detected.
42
+ */
43
+ replacement?: DastMacroPathPart[];
44
+ origin: RenameOrigin;
45
+ };
46
+ /**
47
+ * Build the DAST for a path part with a chain of literal indices.
48
+ *
49
+ * `makeIndexedPathPart("s", [1, 2])` is the DAST for `s[1][2]`.
50
+ */
51
+ export declare function makeIndexedPathPart(name: string, indices: number[]): DastMacroPathPart;
52
+ /**
53
+ * Collects every `assignNames` token in a document and the v0.7 indexed path that
54
+ * replaces it. A single registry is shared by all the plugins that consume `assignNames`
55
+ * so that a reference is rewritten exactly once, no matter which plugin claimed the name.
56
+ */
57
+ export declare class RenameRegistry {
58
+ _renames: Map<string, RenameTarget[]>;
59
+ _matched: Set<string>;
60
+ /** Names carried by a `name=` attribute somewhere in the document. */
61
+ _existingNames: ReadonlySet<string>;
62
+ constructor(existingNames?: ReadonlySet<string>);
63
+ /**
64
+ * Register that `oldName` should be replaced by `replacement` wherever it appears in
65
+ * a macro path. The first registration of a name wins; a later one warns.
66
+ *
67
+ * Pass `undefined` for `replacement` to claim the name without rewriting anything,
68
+ * which is what a composite that simply took the assigned name as its own `name`
69
+ * needs: references already resolve, but a later composite assigning the same name
70
+ * must not silently redirect them.
71
+ */
72
+ register(oldName: string, replacement: DastMacroPathPart[] | undefined, origin: RenameOrigin, file: VFile): void;
73
+ /**
74
+ * The rename for `name`, chosen by which of them the reference is reaching into.
75
+ *
76
+ * `precedingNames` are the path parts written before it, so `$g2.a` looks up `a` with
77
+ * `["g2"]`. The registration whose enclosing names are the longest match at the end of
78
+ * that wins; one recorded with no enclosing names matches anything, which is what
79
+ * keeps an unscoped document behaving exactly as before.
80
+ */
81
+ get(name: string, precedingNames?: string[],
82
+ /** Skip renames that would point a reference at the element carrying it. */
83
+ writtenOn?: DastElement): RenameTarget | undefined;
84
+ /** Whether `name` is registered *and* some registration rewrites references to it. */
85
+ hasReplacement(name: string): boolean;
86
+ get size(): number;
87
+ /** Registered names that were never referenced anywhere in the document. */
88
+ unused(): string[];
89
+ }
90
+ //# sourceMappingURL=rename-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename-registry.d.ts","sourceRoot":"","sources":["../../src/assign-names/rename-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,QAA6B,CAAC;AAEnE,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,MAAM,MAAM,YAAY,GAAG;IACvB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,MAAM,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,GAClB,iBAAiB,CASnB;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACvB,QAAQ,8BAAqC;IAC7C,QAAQ,cAAqB;IAC7B,sEAAsE;IACtE,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;gBAExB,aAAa,GAAE,WAAW,CAAC,MAAM,CAAa;IAI1D;;;;;;;;OAQG;IACH,QAAQ,CACJ,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,iBAAiB,EAAE,GAAG,SAAS,EAC5C,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,KAAK;IAmCf;;;;;;;OAOG;IACH,GAAG,CACC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,MAAM,EAAO;IAC7B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,WAAW,GACxB,YAAY,GAAG,SAAS;IA+B3B,sFAAsF;IACtF,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMrC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,4EAA4E;IAC5E,MAAM,IAAI,MAAM,EAAE;CAGrB"}
@@ -0,0 +1,35 @@
1
+ import { DastElement, DastFunctionMacro, DastMacro, DastNodes } from '../../packages/parser/dist';
2
+ /**
3
+ * `parents` is the chain of enclosing elements, nearest first, as `visit` from
4
+ * `@doenet/parser` reports it.
5
+ *
6
+ * `attributeOwner` is the element in whose *attribute* the node sits, when it does. A
7
+ * node among an element's children has none, and descending into an element's children
8
+ * clears it, so it always names the nearest element the node is written *on* rather than
9
+ * merely inside.
10
+ */
11
+ type Visitor = (node: DastNodes, parents: DastElement[], attributeOwner?: DastElement) => void;
12
+ /**
13
+ * Like `visit` from `@doenet/parser`, but it *also* descends into places that `visit`
14
+ * ignores:
15
+ * - `element.attributes[name].children`
16
+ * - `macro.attributes[name].children`
17
+ * - `macro.path[i].index[j].value` (including macros nested in indices)
18
+ * - `functionMacro.input[i][j]`
19
+ *
20
+ * Macro and function-macro nodes are visited **after** their own nested content, so a
21
+ * visitor that rewrites `macro.path` cannot invalidate an in-progress walk of the macros
22
+ * that live inside that path's indices.
23
+ *
24
+ * Note that, unlike `visit`, there is no way to skip or stop the traversal. This function
25
+ * is meant for whole-tree rewrites.
26
+ */
27
+ export declare function visitAll(tree: DastNodes, visitor: Visitor): void;
28
+ /**
29
+ * Call `visitor` on every macro and function macro anywhere in `tree`, including macros
30
+ * that appear inside attribute values, inside path indices, and inside function-macro
31
+ * arguments. Macros are visited innermost-first.
32
+ */
33
+ export declare function visitAllMacros(tree: DastNodes, visitor: (node: DastMacro | DastFunctionMacro, parents: DastElement[], attributeOwner?: DastElement) => void): void;
34
+ export {};
35
+ //# sourceMappingURL=visit-all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visit-all.d.ts","sourceRoot":"","sources":["../../src/assign-names/visit-all.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,SAAS,EAEZ,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;GAQG;AACH,KAAK,OAAO,GAAG,CACX,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,WAAW,EAAE,EACtB,cAAc,CAAC,EAAE,WAAW,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,QAmGzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,CACL,IAAI,EAAE,SAAS,GAAG,iBAAiB,EACnC,OAAO,EAAE,WAAW,EAAE,EACtB,cAAc,CAAC,EAAE,WAAW,KAC3B,IAAI,QAeZ"}
@@ -8,5 +8,6 @@ export declare function createCoreForLookup({ dast }: {
8
8
  core: PublicDoenetMLCore;
9
9
  rustCore: PublicDoenetMLCoreRust;
10
10
  resolvePathToNodeIdx: (name: string, origin?: number) => Promise<number>;
11
+ dispose: () => Promise<void>;
11
12
  }>;
12
13
  //# sourceMappingURL=core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core-info/core.ts"],"names":[],"mappings":"AAAA,OAAa,EACT,kBAAkB,IAAI,sBAAsB,EAO/C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAyB,QAAQ,EAAS,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAoCxE,MAAM,MAAM,oBAAoB,GAAG,OAAO,CACtC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CACzC,CAAC,sBAAsB,CAAC,CAAC;AAE1B,wBAAsB,mBAAmB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE;;;iCA4E9B,MAAM;GAS7C"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core-info/core.ts"],"names":[],"mappings":"AAAA,OAAa,EACT,kBAAkB,IAAI,sBAAsB,EAO/C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAyB,QAAQ,EAAS,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAoCxE,MAAM,MAAM,oBAAoB,GAAG,OAAO,CACtC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CACzC,CAAC,sBAAsB,CAAC,CAAC;AAE1B,wBAAsB,mBAAmB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE;;;iCAwH9B,MAAM;;GAyB7C"}
@@ -12,4 +12,13 @@ export declare function determinePropType(componentType: string, propName: strin
12
12
  * The number of indices accessed in the prop. For example `$foo.bar[1][1]` has 2 indices.
13
13
  */
14
14
  nIndices?: number): string | undefined;
15
+ /**
16
+ * Whether `componentType` is a `<module>` or something derived from one.
17
+ *
18
+ * v0.6 used this to decide the default of `<copy>`'s `link`: with no `link` attribute it
19
+ * linked everything *except* a copy by cid/uri and a copy of a module (see the `link`
20
+ * state variable in v0.6's `Copy.js`). v0.7 says linked/unlinked by choosing between the
21
+ * `extend` and `copy` attributes, so the same question has to be asked here.
22
+ */
23
+ export declare function isModuleComponentType(componentType: string): boolean;
15
24
  //# sourceMappingURL=determine-prop-type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"determine-prop-type.d.ts","sourceRoot":"","sources":["../../src/core-info/determine-prop-type.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM;AAChB;;GAEG;AACH,QAAQ,SAAI,sBA8Ff"}
1
+ {"version":3,"file":"determine-prop-type.d.ts","sourceRoot":"","sources":["../../src/core-info/determine-prop-type.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM;AAChB;;GAEG;AACH,QAAQ,SAAI,sBA8Ff;AA0CD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAKpE"}