@speclynx/apidom-core 4.0.2 → 4.0.3

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 (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +6 -7
  3. package/src/fields/fixed-fields.cjs +47 -0
  4. package/src/fields/fixed-fields.mjs +43 -0
  5. package/src/fields/fixed-fields.ts +61 -0
  6. package/src/fields/index.cjs +8 -0
  7. package/src/fields/index.mjs +1 -0
  8. package/src/fields/index.ts +2 -0
  9. package/src/identity/errors/ElementIdentityError.cjs +22 -0
  10. package/src/identity/errors/ElementIdentityError.mjs +19 -0
  11. package/src/identity/errors/ElementIdentityError.ts +26 -0
  12. package/src/identity/index.cjs +64 -0
  13. package/src/identity/index.mjs +58 -0
  14. package/src/identity/index.ts +64 -0
  15. package/src/index.cjs +48 -0
  16. package/src/index.mjs +41 -0
  17. package/src/index.ts +81 -0
  18. package/src/media-types.cjs +21 -0
  19. package/src/media-types.mjs +18 -0
  20. package/src/media-types.ts +24 -0
  21. package/src/merge/deepmerge.cjs +165 -0
  22. package/src/merge/deepmerge.mjs +149 -0
  23. package/src/merge/deepmerge.ts +274 -0
  24. package/src/merge/merge-left.cjs +16 -0
  25. package/src/merge/merge-left.mjs +11 -0
  26. package/src/merge/merge-left.ts +14 -0
  27. package/src/merge/merge-right.cjs +35 -0
  28. package/src/merge/merge-right.mjs +29 -0
  29. package/src/merge/merge-right.ts +42 -0
  30. package/src/namespace.cjs +10 -0
  31. package/src/namespace.mjs +7 -0
  32. package/src/namespace.ts +8 -0
  33. package/src/refractor/plugins/dispatcher/index.cjs +64 -0
  34. package/src/refractor/plugins/dispatcher/index.mjs +54 -0
  35. package/src/refractor/plugins/dispatcher/index.ts +102 -0
  36. package/src/refractor/plugins/element-identity.cjs +31 -0
  37. package/src/refractor/plugins/element-identity.mjs +26 -0
  38. package/src/refractor/plugins/element-identity.ts +31 -0
  39. package/src/refractor/plugins/semantic-element-identity.cjs +33 -0
  40. package/src/refractor/plugins/semantic-element-identity.mjs +29 -0
  41. package/src/refractor/plugins/semantic-element-identity.ts +32 -0
  42. package/src/refractor/toolbox.cjs +47 -0
  43. package/src/refractor/toolbox.mjs +41 -0
  44. package/src/refractor/toolbox.ts +88 -0
  45. package/src/specification.cjs +63 -0
  46. package/src/specification.mjs +59 -0
  47. package/src/specification.ts +68 -0
  48. package/src/transcluder/Transcluder.cjs +111 -0
  49. package/src/transcluder/Transcluder.mjs +107 -0
  50. package/src/transcluder/Transcluder.ts +147 -0
  51. package/src/transcluder/index.cjs +19 -0
  52. package/src/transcluder/index.mjs +13 -0
  53. package/src/transcluder/index.ts +15 -0
  54. package/src/transformers/dehydrate.cjs +15 -0
  55. package/src/transformers/dehydrate.mjs +10 -0
  56. package/src/transformers/dehydrate.ts +14 -0
  57. package/src/transformers/from.cjs +34 -0
  58. package/src/transformers/from.mjs +29 -0
  59. package/src/transformers/from.ts +34 -0
  60. package/src/transformers/serializers/json.cjs +75 -0
  61. package/src/transformers/serializers/json.mjs +70 -0
  62. package/src/transformers/serializers/json.ts +107 -0
  63. package/src/transformers/serializers/value.cjs +50 -0
  64. package/src/transformers/serializers/value.mjs +47 -0
  65. package/src/transformers/serializers/value.ts +70 -0
  66. package/src/transformers/serializers/yaml-1-2.cjs +142 -0
  67. package/src/transformers/serializers/yaml-1-2.mjs +137 -0
  68. package/src/transformers/serializers/yaml-1-2.ts +205 -0
  69. package/src/transformers/sexprs.cjs +31 -0
  70. package/src/transformers/sexprs.mjs +28 -0
  71. package/src/transformers/sexprs.ts +30 -0
  72. package/src/transformers/to-string.cjs +16 -0
  73. package/src/transformers/to-string.mjs +11 -0
  74. package/src/transformers/to-string.ts +15 -0
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
7
+ var _deepmerge = _interopRequireWildcard(require("./deepmerge.cjs"));
8
+ /**
9
+ * @public
10
+ */
11
+
12
+ /**
13
+ * @public
14
+ */
15
+ const mergeRight = (targetElement, sourceElement, options) => {
16
+ const mergedOptions = {
17
+ ..._deepmerge.defaultOptions,
18
+ ...options,
19
+ customMerge: () => (target, source) => source,
20
+ clone: false
21
+ };
22
+ return (0, _deepmerge.default)(targetElement, sourceElement, mergedOptions);
23
+ };
24
+ mergeRight.all = (list, options) => {
25
+ if (!Array.isArray(list)) {
26
+ throw new TypeError('First argument of mergeRight should be an array.');
27
+ }
28
+ if (list.length === 0) {
29
+ return new _apidomDatamodel.ObjectElement();
30
+ }
31
+ return list.reduce((target, source) => {
32
+ return mergeRight(target, source, options);
33
+ }, (0, _deepmerge.emptyElement)(list[0]));
34
+ };
35
+ var _default = exports.default = mergeRight;
@@ -0,0 +1,29 @@
1
+ import { ObjectElement } from '@speclynx/apidom-datamodel';
2
+ import deepmerge, { defaultOptions as defaultDeepmergeOptions, emptyElement } from "./deepmerge.mjs";
3
+ /**
4
+ * @public
5
+ */
6
+ /**
7
+ * @public
8
+ */
9
+ const mergeRight = (targetElement, sourceElement, options) => {
10
+ const mergedOptions = {
11
+ ...defaultDeepmergeOptions,
12
+ ...options,
13
+ customMerge: () => (target, source) => source,
14
+ clone: false
15
+ };
16
+ return deepmerge(targetElement, sourceElement, mergedOptions);
17
+ };
18
+ mergeRight.all = (list, options) => {
19
+ if (!Array.isArray(list)) {
20
+ throw new TypeError('First argument of mergeRight should be an array.');
21
+ }
22
+ if (list.length === 0) {
23
+ return new ObjectElement();
24
+ }
25
+ return list.reduce((target, source) => {
26
+ return mergeRight(target, source, options);
27
+ }, emptyElement(list[0]));
28
+ };
29
+ export default mergeRight;
@@ -0,0 +1,42 @@
1
+ import { ObjectElement } from '@speclynx/apidom-datamodel';
2
+
3
+ import deepmerge, { defaultOptions as defaultDeepmergeOptions, emptyElement } from './deepmerge.ts';
4
+ import type { ObjectOrArrayElement, DeepMergeUserOptions, AnyElement } from './deepmerge.ts';
5
+
6
+ /**
7
+ * @public
8
+ */
9
+ export type MergeRightOptions = Omit<DeepMergeUserOptions, 'customMerge' | 'clone'>;
10
+
11
+ /**
12
+ * @public
13
+ */
14
+ const mergeRight = (
15
+ targetElement: ObjectOrArrayElement,
16
+ sourceElement: ObjectOrArrayElement,
17
+ options?: MergeRightOptions,
18
+ ): AnyElement => {
19
+ const mergedOptions = {
20
+ ...defaultDeepmergeOptions,
21
+ ...options,
22
+ customMerge: () => (target: ObjectOrArrayElement, source: ObjectOrArrayElement) => source,
23
+ clone: false,
24
+ };
25
+
26
+ return deepmerge(targetElement, sourceElement, mergedOptions);
27
+ };
28
+
29
+ mergeRight.all = (list: ObjectOrArrayElement[], options?: MergeRightOptions) => {
30
+ if (!Array.isArray(list)) {
31
+ throw new TypeError('First argument of mergeRight should be an array.');
32
+ }
33
+ if (list.length === 0) {
34
+ return new ObjectElement();
35
+ }
36
+
37
+ return list.reduce((target, source) => {
38
+ return mergeRight(target, source, options);
39
+ }, emptyElement(list[0]));
40
+ };
41
+
42
+ export default mergeRight;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
6
+ /**
7
+ * Default namespace instance with all base elements registered.
8
+ */
9
+ const namespace = new _apidomDatamodel.Namespace();
10
+ var _default = exports.default = namespace;
@@ -0,0 +1,7 @@
1
+ import { Namespace } from '@speclynx/apidom-datamodel';
2
+
3
+ /**
4
+ * Default namespace instance with all base elements registered.
5
+ */
6
+ const namespace = new Namespace();
7
+ export default namespace;
@@ -0,0 +1,8 @@
1
+ import { Namespace } from '@speclynx/apidom-datamodel';
2
+
3
+ /**
4
+ * Default namespace instance with all base elements registered.
5
+ */
6
+ const namespace = new Namespace();
7
+
8
+ export default namespace;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.dispatchPluginsSync = exports.dispatchPluginsAsync = void 0;
6
+ var _apidomTraverse = require("@speclynx/apidom-traverse");
7
+ var _ramda = require("ramda");
8
+ var _ramdaAdjunct = require("ramda-adjunct");
9
+ var _toolbox = _interopRequireDefault(require("../../toolbox.cjs"));
10
+ /**
11
+ * @public
12
+ */
13
+
14
+ /**
15
+ * @public
16
+ */
17
+
18
+ /**
19
+ * @public
20
+ */
21
+
22
+ const defaultDispatchPluginsOptions = {
23
+ toolboxCreator: _toolbox.default,
24
+ visitorOptions: {
25
+ exposeEdits: true
26
+ }
27
+ };
28
+
29
+ /**
30
+ * @public
31
+ */
32
+ const dispatchPluginsSync = (element, plugins, options = {}) => {
33
+ if (plugins.length === 0) return element;
34
+ const mergedOptions = (0, _ramda.mergeDeepRight)(defaultDispatchPluginsOptions, options);
35
+ const {
36
+ toolboxCreator,
37
+ visitorOptions
38
+ } = mergedOptions;
39
+ const toolbox = toolboxCreator();
40
+ const pluginsSpecs = plugins.map(plugin => plugin(toolbox));
41
+ const mergedPluginsVisitor = (0, _apidomTraverse.mergeVisitors)(pluginsSpecs.map((0, _ramda.propOr)({}, 'visitor')), visitorOptions);
42
+ pluginsSpecs.forEach((0, _ramdaAdjunct.invokeArgs)(['pre'], []));
43
+ const newElement = (0, _apidomTraverse.traverse)(element, mergedPluginsVisitor);
44
+ pluginsSpecs.forEach((0, _ramdaAdjunct.invokeArgs)(['post'], []));
45
+ return newElement;
46
+ };
47
+ exports.dispatchPluginsSync = dispatchPluginsSync;
48
+ const dispatchPluginsAsync = async (element, plugins, options = {}) => {
49
+ if (plugins.length === 0) return element;
50
+ const mergedOptions = (0, _ramda.mergeDeepRight)(defaultDispatchPluginsOptions, options);
51
+ const {
52
+ toolboxCreator,
53
+ visitorOptions
54
+ } = mergedOptions;
55
+ const toolbox = toolboxCreator();
56
+ const pluginsSpecs = plugins.map(plugin => plugin(toolbox));
57
+ const mergedPluginsVisitor = (0, _apidomTraverse.mergeVisitorsAsync)(pluginsSpecs.map((0, _ramda.propOr)({}, 'visitor')), visitorOptions);
58
+ await Promise.allSettled(pluginsSpecs.map((0, _ramdaAdjunct.invokeArgs)(['pre'], [])));
59
+ const newElement = await (0, _apidomTraverse.traverseAsync)(element, mergedPluginsVisitor);
60
+ await Promise.allSettled(pluginsSpecs.map((0, _ramdaAdjunct.invokeArgs)(['post'], [])));
61
+ return newElement;
62
+ };
63
+ exports.dispatchPluginsAsync = dispatchPluginsAsync;
64
+ dispatchPluginsSync[Symbol.for('nodejs.util.promisify.custom')] = dispatchPluginsAsync;
@@ -0,0 +1,54 @@
1
+ import { traverse, traverseAsync, mergeVisitors, mergeVisitorsAsync } from '@speclynx/apidom-traverse';
2
+ import { mergeDeepRight, propOr } from 'ramda';
3
+ import { invokeArgs } from 'ramda-adjunct';
4
+ import createToolbox from "../../toolbox.mjs";
5
+ /**
6
+ * @public
7
+ */
8
+ /**
9
+ * @public
10
+ */
11
+ /**
12
+ * @public
13
+ */
14
+ const defaultDispatchPluginsOptions = {
15
+ toolboxCreator: createToolbox,
16
+ visitorOptions: {
17
+ exposeEdits: true
18
+ }
19
+ };
20
+
21
+ /**
22
+ * @public
23
+ */
24
+ export const dispatchPluginsSync = (element, plugins, options = {}) => {
25
+ if (plugins.length === 0) return element;
26
+ const mergedOptions = mergeDeepRight(defaultDispatchPluginsOptions, options);
27
+ const {
28
+ toolboxCreator,
29
+ visitorOptions
30
+ } = mergedOptions;
31
+ const toolbox = toolboxCreator();
32
+ const pluginsSpecs = plugins.map(plugin => plugin(toolbox));
33
+ const mergedPluginsVisitor = mergeVisitors(pluginsSpecs.map(propOr({}, 'visitor')), visitorOptions);
34
+ pluginsSpecs.forEach(invokeArgs(['pre'], []));
35
+ const newElement = traverse(element, mergedPluginsVisitor);
36
+ pluginsSpecs.forEach(invokeArgs(['post'], []));
37
+ return newElement;
38
+ };
39
+ export const dispatchPluginsAsync = async (element, plugins, options = {}) => {
40
+ if (plugins.length === 0) return element;
41
+ const mergedOptions = mergeDeepRight(defaultDispatchPluginsOptions, options);
42
+ const {
43
+ toolboxCreator,
44
+ visitorOptions
45
+ } = mergedOptions;
46
+ const toolbox = toolboxCreator();
47
+ const pluginsSpecs = plugins.map(plugin => plugin(toolbox));
48
+ const mergedPluginsVisitor = mergeVisitorsAsync(pluginsSpecs.map(propOr({}, 'visitor')), visitorOptions);
49
+ await Promise.allSettled(pluginsSpecs.map(invokeArgs(['pre'], [])));
50
+ const newElement = await traverseAsync(element, mergedPluginsVisitor);
51
+ await Promise.allSettled(pluginsSpecs.map(invokeArgs(['post'], [])));
52
+ return newElement;
53
+ };
54
+ dispatchPluginsSync[Symbol.for('nodejs.util.promisify.custom')] = dispatchPluginsAsync;
@@ -0,0 +1,102 @@
1
+ import { Element } from '@speclynx/apidom-datamodel';
2
+ import {
3
+ traverse,
4
+ traverseAsync,
5
+ mergeVisitors,
6
+ mergeVisitorsAsync,
7
+ } from '@speclynx/apidom-traverse';
8
+ import { mergeDeepRight, propOr } from 'ramda';
9
+ import { invokeArgs } from 'ramda-adjunct';
10
+
11
+ import createToolbox from '../../toolbox.ts';
12
+
13
+ /**
14
+ * @public
15
+ */
16
+ export interface DispatchPluginsOptions {
17
+ toolboxCreator: typeof createToolbox;
18
+ visitorOptions: {
19
+ exposeEdits: boolean;
20
+ };
21
+ }
22
+
23
+ /**
24
+ * @public
25
+ */
26
+ export interface DispatchPluginsSync {
27
+ <T extends Element, U extends Element = Element>(
28
+ element: T,
29
+ plugins: ((toolbox: any) => object)[],
30
+ options?: Record<string, unknown>,
31
+ ): U;
32
+ [key: symbol]: DispatchPluginsAsync;
33
+ }
34
+
35
+ /**
36
+ * @public
37
+ */
38
+ export interface DispatchPluginsAsync {
39
+ <T extends Element, U extends Element = Element>(
40
+ element: T,
41
+ plugins: ((toolbox: any) => object)[],
42
+ options?: Record<string, unknown>,
43
+ ): Promise<U>;
44
+ }
45
+
46
+ const defaultDispatchPluginsOptions: DispatchPluginsOptions = {
47
+ toolboxCreator: createToolbox,
48
+ visitorOptions: {
49
+ exposeEdits: true,
50
+ },
51
+ };
52
+
53
+ /**
54
+ * @public
55
+ */
56
+ export const dispatchPluginsSync: DispatchPluginsSync = ((element, plugins, options = {}) => {
57
+ if (plugins.length === 0) return element;
58
+
59
+ const mergedOptions = mergeDeepRight(
60
+ defaultDispatchPluginsOptions,
61
+ options,
62
+ ) as DispatchPluginsOptions;
63
+ const { toolboxCreator, visitorOptions } = mergedOptions;
64
+ const toolbox = toolboxCreator();
65
+ const pluginsSpecs = plugins.map((plugin) => plugin(toolbox));
66
+ const mergedPluginsVisitor = mergeVisitors(
67
+ pluginsSpecs.map(propOr({}, 'visitor')) as object[],
68
+ visitorOptions,
69
+ );
70
+
71
+ pluginsSpecs.forEach(invokeArgs(['pre'], []));
72
+ const newElement = traverse(element, mergedPluginsVisitor);
73
+ pluginsSpecs.forEach(invokeArgs(['post'], []));
74
+ return newElement;
75
+ }) as DispatchPluginsSync;
76
+
77
+ export const dispatchPluginsAsync: DispatchPluginsAsync = (async (
78
+ element,
79
+ plugins,
80
+ options = {},
81
+ ) => {
82
+ if (plugins.length === 0) return element;
83
+
84
+ const mergedOptions = mergeDeepRight(
85
+ defaultDispatchPluginsOptions,
86
+ options,
87
+ ) as DispatchPluginsOptions;
88
+ const { toolboxCreator, visitorOptions } = mergedOptions;
89
+ const toolbox = toolboxCreator();
90
+ const pluginsSpecs = plugins.map((plugin) => plugin(toolbox));
91
+ const mergedPluginsVisitor = mergeVisitorsAsync(
92
+ pluginsSpecs.map(propOr({}, 'visitor')) as object[],
93
+ visitorOptions,
94
+ );
95
+
96
+ await Promise.allSettled(pluginsSpecs.map(invokeArgs(['pre'], [])));
97
+ const newElement = await traverseAsync(element, mergedPluginsVisitor);
98
+ await Promise.allSettled(pluginsSpecs.map(invokeArgs(['post'], [])));
99
+ return newElement;
100
+ }) as DispatchPluginsAsync;
101
+
102
+ dispatchPluginsSync[Symbol.for('nodejs.util.promisify.custom')] = dispatchPluginsAsync;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _index = require("../../identity/index.cjs");
6
+ /**
7
+ * Plugin for decorating every element in ApiDOM tree with UUID.
8
+ * @public
9
+ */
10
+
11
+ const plugin = ({
12
+ length = 6
13
+ } = {}) => () => {
14
+ let identityManager;
15
+ return {
16
+ pre() {
17
+ identityManager = new _index.IdentityManager({
18
+ length
19
+ });
20
+ },
21
+ visitor: {
22
+ enter(path) {
23
+ path.node.id = identityManager.identify(path.node);
24
+ }
25
+ },
26
+ post() {
27
+ identityManager = null;
28
+ }
29
+ };
30
+ };
31
+ var _default = exports.default = plugin;
@@ -0,0 +1,26 @@
1
+ import { IdentityManager } from "../../identity/index.mjs";
2
+ /**
3
+ * Plugin for decorating every element in ApiDOM tree with UUID.
4
+ * @public
5
+ */
6
+ const plugin = ({
7
+ length = 6
8
+ } = {}) => () => {
9
+ let identityManager;
10
+ return {
11
+ pre() {
12
+ identityManager = new IdentityManager({
13
+ length
14
+ });
15
+ },
16
+ visitor: {
17
+ enter(path) {
18
+ path.node.id = identityManager.identify(path.node);
19
+ }
20
+ },
21
+ post() {
22
+ identityManager = null;
23
+ }
24
+ };
25
+ };
26
+ export default plugin;
@@ -0,0 +1,31 @@
1
+ import { Element } from '@speclynx/apidom-datamodel';
2
+ import { Path } from '@speclynx/apidom-traverse';
3
+
4
+ import { IdentityManager } from '../../identity/index.ts';
5
+
6
+ /**
7
+ * Plugin for decorating every element in ApiDOM tree with UUID.
8
+ * @public
9
+ */
10
+
11
+ const plugin =
12
+ ({ length = 6 } = {}) =>
13
+ () => {
14
+ let identityManager: IdentityManager | null;
15
+
16
+ return {
17
+ pre() {
18
+ identityManager = new IdentityManager({ length });
19
+ },
20
+ visitor: {
21
+ enter(path: Path<Element>) {
22
+ path.node.id = identityManager!.identify(path.node);
23
+ },
24
+ },
25
+ post() {
26
+ identityManager = null;
27
+ },
28
+ };
29
+ };
30
+
31
+ export default plugin;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
6
+ var _index = require("../../identity/index.cjs");
7
+ /**
8
+ * Plugin for decorating every semantic element in ApiDOM tree with UUID.
9
+ * @public
10
+ */
11
+ const plugin = ({
12
+ length = 6
13
+ } = {}) => () => {
14
+ let identityManager;
15
+ return {
16
+ pre() {
17
+ identityManager = new _index.IdentityManager({
18
+ length
19
+ });
20
+ },
21
+ visitor: {
22
+ enter(path) {
23
+ if (!(0, _apidomDatamodel.isPrimitiveElement)(path.node)) {
24
+ path.node.id = identityManager.identify(path.node);
25
+ }
26
+ }
27
+ },
28
+ post() {
29
+ identityManager = null;
30
+ }
31
+ };
32
+ };
33
+ var _default = exports.default = plugin;
@@ -0,0 +1,29 @@
1
+ import { isPrimitiveElement } from '@speclynx/apidom-datamodel';
2
+ import { IdentityManager } from "../../identity/index.mjs";
3
+ /**
4
+ * Plugin for decorating every semantic element in ApiDOM tree with UUID.
5
+ * @public
6
+ */
7
+ const plugin = ({
8
+ length = 6
9
+ } = {}) => () => {
10
+ let identityManager;
11
+ return {
12
+ pre() {
13
+ identityManager = new IdentityManager({
14
+ length
15
+ });
16
+ },
17
+ visitor: {
18
+ enter(path) {
19
+ if (!isPrimitiveElement(path.node)) {
20
+ path.node.id = identityManager.identify(path.node);
21
+ }
22
+ }
23
+ },
24
+ post() {
25
+ identityManager = null;
26
+ }
27
+ };
28
+ };
29
+ export default plugin;
@@ -0,0 +1,32 @@
1
+ import { Element, isPrimitiveElement } from '@speclynx/apidom-datamodel';
2
+ import { Path } from '@speclynx/apidom-traverse';
3
+
4
+ import { IdentityManager } from '../../identity/index.ts';
5
+
6
+ /**
7
+ * Plugin for decorating every semantic element in ApiDOM tree with UUID.
8
+ * @public
9
+ */
10
+ const plugin =
11
+ ({ length = 6 } = {}) =>
12
+ () => {
13
+ let identityManager: IdentityManager | null;
14
+
15
+ return {
16
+ pre() {
17
+ identityManager = new IdentityManager({ length });
18
+ },
19
+ visitor: {
20
+ enter(path: Path<Element>) {
21
+ if (!isPrimitiveElement(path.node)) {
22
+ path.node.id = identityManager!.identify(path.node);
23
+ }
24
+ },
25
+ },
26
+ post() {
27
+ identityManager = null;
28
+ },
29
+ };
30
+ };
31
+
32
+ export default plugin;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
7
+ var _namespace = _interopRequireDefault(require("../namespace.cjs"));
8
+ /**
9
+ * @public
10
+ */
11
+
12
+ const predicates = {
13
+ isElement: _apidomDatamodel.isElement,
14
+ isStringElement: _apidomDatamodel.isStringElement,
15
+ isNumberElement: _apidomDatamodel.isNumberElement,
16
+ isNullElement: _apidomDatamodel.isNullElement,
17
+ isBooleanElement: _apidomDatamodel.isBooleanElement,
18
+ isArrayElement: _apidomDatamodel.isArrayElement,
19
+ isObjectElement: _apidomDatamodel.isObjectElement,
20
+ isMemberElement: _apidomDatamodel.isMemberElement,
21
+ isPrimitiveElement: _apidomDatamodel.isPrimitiveElement,
22
+ isLinkElement: _apidomDatamodel.isLinkElement,
23
+ isRefElement: _apidomDatamodel.isRefElement,
24
+ isAnnotationElement: _apidomDatamodel.isAnnotationElement,
25
+ isCommentElement: _apidomDatamodel.isCommentElement,
26
+ isParseResultElement: _apidomDatamodel.isParseResultElement,
27
+ isSourceMapElement: _apidomDatamodel.isSourceMapElement,
28
+ hasElementStyle: _apidomDatamodel.hasElementStyle,
29
+ hasElementSourceMap: _apidomDatamodel.hasElementSourceMap,
30
+ includesSymbols: _apidomDatamodel.includesSymbols,
31
+ includesClasses: _apidomDatamodel.includesClasses
32
+ };
33
+
34
+ /**
35
+ * @public
36
+ */
37
+
38
+ /**
39
+ * @public
40
+ */
41
+ const createToolbox = () => {
42
+ return {
43
+ predicates,
44
+ namespace: _namespace.default
45
+ };
46
+ };
47
+ var _default = exports.default = createToolbox;
@@ -0,0 +1,41 @@
1
+ import { isElement, isStringElement, isNumberElement, isNullElement, isBooleanElement, isArrayElement, isObjectElement, isMemberElement, isPrimitiveElement, isLinkElement, isRefElement, isAnnotationElement, isCommentElement, isParseResultElement, isSourceMapElement, hasElementStyle, hasElementSourceMap, includesSymbols, includesClasses } from '@speclynx/apidom-datamodel';
2
+ import defaultNamespace from "../namespace.mjs";
3
+ /**
4
+ * @public
5
+ */
6
+ const predicates = {
7
+ isElement,
8
+ isStringElement,
9
+ isNumberElement,
10
+ isNullElement,
11
+ isBooleanElement,
12
+ isArrayElement,
13
+ isObjectElement,
14
+ isMemberElement,
15
+ isPrimitiveElement,
16
+ isLinkElement,
17
+ isRefElement,
18
+ isAnnotationElement,
19
+ isCommentElement,
20
+ isParseResultElement,
21
+ isSourceMapElement,
22
+ hasElementStyle,
23
+ hasElementSourceMap,
24
+ includesSymbols,
25
+ includesClasses
26
+ };
27
+
28
+ /**
29
+ * @public
30
+ */
31
+
32
+ /**
33
+ * @public
34
+ */
35
+ const createToolbox = () => {
36
+ return {
37
+ predicates,
38
+ namespace: defaultNamespace
39
+ };
40
+ };
41
+ export default createToolbox;