massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / node_modules / ajv / dist / vocabularies / dynamic / dynamicAnchor.js
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.dynamicAnchor = void 0;
4 const codegen_1 = require("../../compile/codegen");
5 const names_1 = require("../../compile/names");
6 const compile_1 = require("../../compile");
7 const ref_1 = require("../core/ref");
8 const def = {
9     keyword: "$dynamicAnchor",
10     schemaType: "string",
11     code: (cxt) => dynamicAnchor(cxt, cxt.schema),
12 };
13 function dynamicAnchor(cxt, anchor) {
14     const { gen, it } = cxt;
15     it.schemaEnv.root.dynamicAnchors[anchor] = true;
16     const v = (0, codegen_1._) `${names_1.default.dynamicAnchors}${(0, codegen_1.getProperty)(anchor)}`;
17     const validate = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
18     gen.if((0, codegen_1._) `!${v}`, () => gen.assign(v, validate));
19 }
20 exports.dynamicAnchor = dynamicAnchor;
21 function _getValidate(cxt) {
22     const { schemaEnv, schema, self } = cxt.it;
23     const { root, baseId, localRefs, meta } = schemaEnv.root;
24     const { schemaId } = self.opts;
25     const sch = new compile_1.SchemaEnv({ schema, schemaId, root, baseId, localRefs, meta });
26     compile_1.compileSchema.call(self, sch);
27     return (0, ref_1.getValidate)(cxt, sch);
28 }
29 exports.default = def;
30 //# sourceMappingURL=dynamicAnchor.js.map